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/pipeline.h"
9 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStream.h"
10 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamTrack.h"
11 #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaStreamRegistry.h"
13 #include "webkit/media/media_stream_audio_renderer.h"
14 #include "webkit/media/simple_video_frame_provider.h"
16 using namespace WebKit
;
20 static const int kVideoCaptureWidth
= 352;
21 static const int kVideoCaptureHeight
= 288;
22 static const int kVideoCaptureFrameDurationMs
= 33;
24 bool IsMockMediaStreamWithVideo(const WebURL
& url
) {
25 WebMediaStream
descriptor(
26 WebMediaStreamRegistry::lookupMediaStreamDescriptor(url
));
27 if (descriptor
.isNull())
29 WebVector
<WebMediaStreamTrack
> videoSources
;
30 descriptor
.videoSources(videoSources
);
31 return videoSources
.size() > 0;
36 namespace webkit_support
{
38 TestMediaStreamClient::TestMediaStreamClient() {}
40 TestMediaStreamClient::~TestMediaStreamClient() {}
42 bool TestMediaStreamClient::IsMediaStream(const GURL
& url
) {
43 return IsMockMediaStreamWithVideo(url
);
46 scoped_refptr
<webkit_media::VideoFrameProvider
>
47 TestMediaStreamClient::GetVideoFrameProvider(
49 const base::Closure
& error_cb
,
50 const webkit_media::VideoFrameProvider::RepaintCB
& repaint_cb
) {
51 if (!IsMockMediaStreamWithVideo(url
))
54 return new webkit_media::SimpleVideoFrameProvider(
55 gfx::Size(kVideoCaptureWidth
, kVideoCaptureHeight
),
56 base::TimeDelta::FromMilliseconds(kVideoCaptureFrameDurationMs
),
61 scoped_refptr
<webkit_media::MediaStreamAudioRenderer
>
62 TestMediaStreamClient::GetAudioRenderer(const GURL
& url
) {
66 } // namespace webkit_support