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