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