1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "webkit/support/test_media_stream_client.h"
7 #include "googleurl/src/gurl.h"
8 #include "media/base/message_loop_factory.h"
9 #include "media/base/pipeline.h"
10 #include "media/filters/video_frame_generator.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaStreamRegistry.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStreamComponent.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStreamDescriptor.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
17 using namespace WebKit
;
21 static const int kVideoCaptureWidth
= 352;
22 static const int kVideoCaptureHeight
= 288;
23 static const int kVideoCaptureFrameDurationMs
= 33;
25 bool IsMockMediaStreamWithVideo(const WebURL
& url
) {
26 WebMediaStreamDescriptor
descriptor(
27 WebMediaStreamRegistry::lookupMediaStreamDescriptor(url
));
28 if (descriptor
.isNull())
30 WebVector
<WebMediaStreamComponent
> videoSources
;
31 descriptor
.videoSources(videoSources
);
32 return videoSources
.size() > 0;
37 namespace webkit_support
{
39 scoped_refptr
<media::VideoDecoder
> TestMediaStreamClient::GetVideoDecoder(
40 const GURL
& url
, media::MessageLoopFactory
* message_loop_factory
) {
41 // This class is installed in a chain of possible VideoDecoder creators
42 // which are called in order until one returns an object.
43 // Make sure we are dealing with a Mock MediaStream. If not, bail out.
44 if (!IsMockMediaStreamWithVideo(url
))
47 return new media::VideoFrameGenerator(
48 message_loop_factory
->GetMessageLoop(media::MessageLoopFactory::kDecoder
),
49 gfx::Size(kVideoCaptureWidth
, kVideoCaptureHeight
),
50 base::TimeDelta::FromMilliseconds(kVideoCaptureFrameDurationMs
));
53 } // namespace webkit_support