OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "webkit/support/test_media_stream_client.h" | 5 #include "webkit/support/test_media_stream_client.h" |
6 | 6 |
7 #include "googleurl/src/gurl.h" | 7 #include "googleurl/src/gurl.h" |
8 #include "media/base/message_loop_factory.h" | 8 #include "media/base/message_loop_factory.h" |
9 #include "media/base/pipeline.h" | 9 #include "media/base/pipeline.h" |
10 #include "media/filters/video_frame_generator.h" | 10 #include "media/filters/video_frame_generator.h" |
11 | |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaStreamRegistr
y.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaStreamRegistr
y.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amComponent.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amComponent.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amDescriptor.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amDescriptor.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
| 15 #include "webkit/media/simple_video_frame_provider.h" |
16 | 16 |
17 using namespace WebKit; | 17 using namespace WebKit; |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 static const int kVideoCaptureWidth = 352; | 21 static const int kVideoCaptureWidth = 352; |
22 static const int kVideoCaptureHeight = 288; | 22 static const int kVideoCaptureHeight = 288; |
23 static const int kVideoCaptureFrameDurationMs = 33; | 23 static const int kVideoCaptureFrameDurationMs = 33; |
24 | 24 |
25 bool IsMockMediaStreamWithVideo(const WebURL& url) { | 25 bool IsMockMediaStreamWithVideo(const WebURL& url) { |
26 WebMediaStreamDescriptor descriptor( | 26 WebMediaStreamDescriptor descriptor( |
27 WebMediaStreamRegistry::lookupMediaStreamDescriptor(url)); | 27 WebMediaStreamRegistry::lookupMediaStreamDescriptor(url)); |
28 if (descriptor.isNull()) | 28 if (descriptor.isNull()) |
29 return false; | 29 return false; |
30 WebVector<WebMediaStreamComponent> videoSources; | 30 WebVector<WebMediaStreamComponent> videoSources; |
31 descriptor.videoSources(videoSources); | 31 descriptor.videoSources(videoSources); |
32 return videoSources.size() > 0; | 32 return videoSources.size() > 0; |
33 } | 33 } |
34 | 34 |
35 } // namespace | 35 } // namespace |
36 | 36 |
37 namespace webkit_support { | 37 namespace webkit_support { |
38 | 38 |
| 39 TestMediaStreamClient::TestMediaStreamClient() {} |
| 40 |
| 41 TestMediaStreamClient::~TestMediaStreamClient() {} |
| 42 |
| 43 bool TestMediaStreamClient::IsMediaStream(const GURL& url) { |
| 44 return IsMockMediaStreamWithVideo(url); |
| 45 } |
| 46 |
| 47 scoped_refptr<webkit_media::VideoFrameProvider> |
| 48 TestMediaStreamClient::GetVideoFrameProvider( |
| 49 const GURL& url, |
| 50 const base::Closure& error_cb, |
| 51 const webkit_media::VideoFrameProvider::RepaintCB& repaint_cb) { |
| 52 if (!IsMockMediaStreamWithVideo(url)) |
| 53 return NULL; |
| 54 |
| 55 return new webkit_media::SimpleVideoFrameProvider( |
| 56 gfx::Size(kVideoCaptureWidth, kVideoCaptureHeight), |
| 57 base::TimeDelta::FromMilliseconds(kVideoCaptureFrameDurationMs), |
| 58 error_cb, |
| 59 repaint_cb); |
| 60 } |
| 61 |
39 scoped_refptr<media::VideoDecoder> TestMediaStreamClient::GetVideoDecoder( | 62 scoped_refptr<media::VideoDecoder> TestMediaStreamClient::GetVideoDecoder( |
40 const GURL& url, media::MessageLoopFactory* message_loop_factory) { | 63 const GURL& url, media::MessageLoopFactory* message_loop_factory) { |
41 // This class is installed in a chain of possible VideoDecoder creators | 64 // This class is installed in a chain of possible VideoDecoder creators |
42 // which are called in order until one returns an object. | 65 // which are called in order until one returns an object. |
43 // Make sure we are dealing with a Mock MediaStream. If not, bail out. | 66 // Make sure we are dealing with a Mock MediaStream. If not, bail out. |
44 if (!IsMockMediaStreamWithVideo(url)) | 67 if (!IsMockMediaStreamWithVideo(url)) |
45 return NULL; | 68 return NULL; |
46 | 69 |
47 return new media::VideoFrameGenerator( | 70 return new media::VideoFrameGenerator( |
48 message_loop_factory->GetMessageLoop(media::MessageLoopFactory::kDecoder), | 71 message_loop_factory->GetMessageLoop(media::MessageLoopFactory::kDecoder), |
49 gfx::Size(kVideoCaptureWidth, kVideoCaptureHeight), | 72 gfx::Size(kVideoCaptureWidth, kVideoCaptureHeight), |
50 base::TimeDelta::FromMilliseconds(kVideoCaptureFrameDurationMs)); | 73 base::TimeDelta::FromMilliseconds(kVideoCaptureFrameDurationMs)); |
51 } | 74 } |
52 | 75 |
53 } // namespace webkit_support | 76 } // namespace webkit_support |
OLD | NEW |