[sql] Integrate SQLite recover.c module.
[chromium-blink-merge.git] / content / test / test_media_stream_client.cc
blob1aa438506011747b2ddedb179c30bd401ac41691
1 // Copyright 2013 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 "content/test/test_media_stream_client.h"
7 #include "content/renderer/media/media_stream_audio_renderer.h"
8 #include "content/test/test_video_frame_provider.h"
9 #include "third_party/WebKit/public/platform/WebMediaStream.h"
10 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
11 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h"
12 #include "url/gurl.h"
14 using namespace WebKit;
16 namespace {
18 static const int kVideoCaptureWidth = 352;
19 static const int kVideoCaptureHeight = 288;
20 static const int kVideoCaptureFrameDurationMs = 33;
22 bool IsMockMediaStreamWithVideo(const WebURL& url) {
23 #if ENABLE_WEBRTC
24 WebMediaStream descriptor(
25 WebMediaStreamRegistry::lookupMediaStreamDescriptor(url));
26 if (descriptor.isNull())
27 return false;
28 WebVector<WebMediaStreamTrack> videoSources;
29 descriptor.videoSources(videoSources);
30 return videoSources.size() > 0;
31 #else
32 return false;
33 #endif
36 } // namespace
38 namespace content {
40 TestMediaStreamClient::TestMediaStreamClient(RenderView* render_view)
41 : RenderViewObserver(render_view) {}
43 TestMediaStreamClient::~TestMediaStreamClient() {}
45 bool TestMediaStreamClient::IsMediaStream(const GURL& url) {
46 return IsMockMediaStreamWithVideo(url);
49 scoped_refptr<VideoFrameProvider> TestMediaStreamClient::GetVideoFrameProvider(
50 const GURL& url,
51 const base::Closure& error_cb,
52 const VideoFrameProvider::RepaintCB& repaint_cb) {
53 if (!IsMockMediaStreamWithVideo(url))
54 return NULL;
56 return new TestVideoFrameProvider(
57 gfx::Size(kVideoCaptureWidth, kVideoCaptureHeight),
58 base::TimeDelta::FromMilliseconds(kVideoCaptureFrameDurationMs),
59 error_cb,
60 repaint_cb);
63 scoped_refptr<MediaStreamAudioRenderer> TestMediaStreamClient::GetAudioRenderer(
64 const GURL& url) {
65 return NULL;
68 } // namespace content