| 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/mocks/test_media_stream_client.h" | 5 #include "webkit/mocks/test_media_stream_client.h" |
| 6 | 6 |
| 7 #include "googleurl/src/gurl.h" | 7 #include "googleurl/src/gurl.h" |
| 8 #include "media/base/media_log.h" | 8 #include "media/base/media_log.h" |
| 9 #include "media/base/pipeline.h" | 9 #include "media/base/pipeline.h" |
| 10 #include "third_party/WebKit/public/platform/WebMediaStream.h" | 10 #include "third_party/WebKit/public/platform/WebMediaStream.h" |
| 11 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 11 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| 12 #include "third_party/WebKit/public/platform/WebVector.h" | 12 #include "third_party/WebKit/public/platform/WebVector.h" |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaStreamRegistr
y.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaStreamRegistr
y.h" |
| 14 #include "webkit/renderer/media/media_stream_audio_renderer.h" | 14 #include "webkit/renderer/media/media_stream_audio_renderer.h" |
| 15 #include "webkit/renderer/media/simple_video_frame_provider.h" | 15 #include "webkit/renderer/media/simple_video_frame_provider.h" |
| 16 #include "webkit/renderer/media/webmediaplayer_impl.h" | |
| 17 #include "webkit/renderer/media/webmediaplayer_ms.h" | |
| 18 #include "webkit/renderer/media/webmediaplayer_params.h" | |
| 19 | 16 |
| 20 using namespace WebKit; | 17 using namespace WebKit; |
| 21 | 18 |
| 22 namespace { | 19 namespace { |
| 23 | 20 |
| 24 static const int kVideoCaptureWidth = 352; | 21 static const int kVideoCaptureWidth = 352; |
| 25 static const int kVideoCaptureHeight = 288; | 22 static const int kVideoCaptureHeight = 288; |
| 26 static const int kVideoCaptureFrameDurationMs = 33; | 23 static const int kVideoCaptureFrameDurationMs = 33; |
| 27 | 24 |
| 28 bool IsMockMediaStreamWithVideo(const WebURL& url) { | 25 bool IsMockMediaStreamWithVideo(const WebURL& url) { |
| 29 #if ENABLE_WEBRTC | 26 #if ENABLE_WEBRTC |
| 30 WebMediaStream descriptor( | 27 WebMediaStream descriptor( |
| 31 WebMediaStreamRegistry::lookupMediaStreamDescriptor(url)); | 28 WebMediaStreamRegistry::lookupMediaStreamDescriptor(url)); |
| 32 if (descriptor.isNull()) | 29 if (descriptor.isNull()) |
| 33 return false; | 30 return false; |
| 34 WebVector<WebMediaStreamTrack> videoSources; | 31 WebVector<WebMediaStreamTrack> videoSources; |
| 35 descriptor.videoSources(videoSources); | 32 descriptor.videoSources(videoSources); |
| 36 return videoSources.size() > 0; | 33 return videoSources.size() > 0; |
| 37 #else | 34 #else |
| 38 return false; | 35 return false; |
| 39 #endif | 36 #endif |
| 40 } | 37 } |
| 41 | 38 |
| 42 } // namespace | 39 } // namespace |
| 43 | 40 |
| 44 namespace webkit_glue { | 41 namespace webkit_glue { |
| 45 | 42 |
| 46 WebKit::WebMediaPlayer* CreateMediaPlayer( | |
| 47 WebFrame* frame, | |
| 48 const WebURL& url, | |
| 49 WebMediaPlayerClient* client, | |
| 50 webkit_media::MediaStreamClient* media_stream_client) { | |
| 51 if (media_stream_client && media_stream_client->IsMediaStream(url)) { | |
| 52 return new webkit_media::WebMediaPlayerMS( | |
| 53 frame, | |
| 54 client, | |
| 55 base::WeakPtr<webkit_media::WebMediaPlayerDelegate>(), | |
| 56 media_stream_client, | |
| 57 new media::MediaLog()); | |
| 58 } | |
| 59 | |
| 60 #if defined(OS_ANDROID) | |
| 61 return NULL; | |
| 62 #else | |
| 63 webkit_media::WebMediaPlayerParams params( | |
| 64 NULL, NULL, new media::MediaLog()); | |
| 65 return new webkit_media::WebMediaPlayerImpl( | |
| 66 frame, | |
| 67 client, | |
| 68 base::WeakPtr<webkit_media::WebMediaPlayerDelegate>(), | |
| 69 params); | |
| 70 #endif | |
| 71 } | |
| 72 | |
| 73 TestMediaStreamClient::TestMediaStreamClient() {} | 43 TestMediaStreamClient::TestMediaStreamClient() {} |
| 74 | 44 |
| 75 TestMediaStreamClient::~TestMediaStreamClient() {} | 45 TestMediaStreamClient::~TestMediaStreamClient() {} |
| 76 | 46 |
| 77 bool TestMediaStreamClient::IsMediaStream(const GURL& url) { | 47 bool TestMediaStreamClient::IsMediaStream(const GURL& url) { |
| 78 return IsMockMediaStreamWithVideo(url); | 48 return IsMockMediaStreamWithVideo(url); |
| 79 } | 49 } |
| 80 | 50 |
| 81 scoped_refptr<webkit_media::VideoFrameProvider> | 51 scoped_refptr<webkit_media::VideoFrameProvider> |
| 82 TestMediaStreamClient::GetVideoFrameProvider( | 52 TestMediaStreamClient::GetVideoFrameProvider( |
| 83 const GURL& url, | 53 const GURL& url, |
| 84 const base::Closure& error_cb, | 54 const base::Closure& error_cb, |
| 85 const webkit_media::VideoFrameProvider::RepaintCB& repaint_cb) { | 55 const webkit_media::VideoFrameProvider::RepaintCB& repaint_cb) { |
| 86 if (!IsMockMediaStreamWithVideo(url)) | 56 if (!IsMockMediaStreamWithVideo(url)) |
| 87 return NULL; | 57 return NULL; |
| 88 | 58 |
| 89 return new webkit_media::SimpleVideoFrameProvider( | 59 return new webkit_media::SimpleVideoFrameProvider( |
| 90 gfx::Size(kVideoCaptureWidth, kVideoCaptureHeight), | 60 gfx::Size(kVideoCaptureWidth, kVideoCaptureHeight), |
| 91 base::TimeDelta::FromMilliseconds(kVideoCaptureFrameDurationMs), | 61 base::TimeDelta::FromMilliseconds(kVideoCaptureFrameDurationMs), |
| 92 error_cb, | 62 error_cb, |
| 93 repaint_cb); | 63 repaint_cb); |
| 94 } | 64 } |
| 95 | 65 |
| 96 scoped_refptr<webkit_media::MediaStreamAudioRenderer> | 66 scoped_refptr<webkit_media::MediaStreamAudioRenderer> |
| 97 TestMediaStreamClient::GetAudioRenderer(const GURL& url) { | 67 TestMediaStreamClient::GetAudioRenderer(const GURL& url) { |
| 98 return NULL; | 68 return NULL; |
| 99 } | 69 } |
| 100 | 70 |
| 101 } // namespace webkit_glue | 71 } // namespace webkit_glue |
| OLD | NEW |