Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: webkit/mocks/test_media_stream_client.cc

Issue 15005005: Use a shared thread for media operations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/mocks/test_media_stream_client.h ('k') | webkit/support/webkit_support.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/Source/Platform/chromium/public/WebMediaStream.h" 10 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStream.h"
11 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamTrack .h" 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamTrack .h"
12 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h"
12 #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h" 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaStreamRegistr y.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaStreamRegistr y.h"
14 #include "webkit/media/media_stream_audio_renderer.h" 15 #include "webkit/media/media_stream_audio_renderer.h"
15 #include "webkit/media/simple_video_frame_provider.h" 16 #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"
19 17
20 using namespace WebKit; 18 using namespace WebKit;
21 19
22 namespace { 20 namespace {
23 21
24 static const int kVideoCaptureWidth = 352; 22 static const int kVideoCaptureWidth = 352;
25 static const int kVideoCaptureHeight = 288; 23 static const int kVideoCaptureHeight = 288;
26 static const int kVideoCaptureFrameDurationMs = 33; 24 static const int kVideoCaptureFrameDurationMs = 33;
27 25
28 bool IsMockMediaStreamWithVideo(const WebURL& url) { 26 bool IsMockMediaStreamWithVideo(const WebURL& url) {
29 #if ENABLE_WEBRTC 27 #if ENABLE_WEBRTC
30 WebMediaStream descriptor( 28 WebMediaStream descriptor(
31 WebMediaStreamRegistry::lookupMediaStreamDescriptor(url)); 29 WebMediaStreamRegistry::lookupMediaStreamDescriptor(url));
32 if (descriptor.isNull()) 30 if (descriptor.isNull())
33 return false; 31 return false;
34 WebVector<WebMediaStreamTrack> videoSources; 32 WebVector<WebMediaStreamTrack> videoSources;
35 descriptor.videoSources(videoSources); 33 descriptor.videoSources(videoSources);
36 return videoSources.size() > 0; 34 return videoSources.size() > 0;
37 #else 35 #else
38 return false; 36 return false;
39 #endif 37 #endif
40 } 38 }
41 39
42 } // namespace 40 } // namespace
43 41
44 namespace webkit_glue { 42 namespace webkit_glue {
45 43
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() {} 44 TestMediaStreamClient::TestMediaStreamClient() {}
74 45
75 TestMediaStreamClient::~TestMediaStreamClient() {} 46 TestMediaStreamClient::~TestMediaStreamClient() {}
76 47
77 bool TestMediaStreamClient::IsMediaStream(const GURL& url) { 48 bool TestMediaStreamClient::IsMediaStream(const GURL& url) {
78 return IsMockMediaStreamWithVideo(url); 49 return IsMockMediaStreamWithVideo(url);
79 } 50 }
80 51
81 scoped_refptr<webkit_media::VideoFrameProvider> 52 scoped_refptr<webkit_media::VideoFrameProvider>
82 TestMediaStreamClient::GetVideoFrameProvider( 53 TestMediaStreamClient::GetVideoFrameProvider(
83 const GURL& url, 54 const GURL& url,
84 const base::Closure& error_cb, 55 const base::Closure& error_cb,
85 const webkit_media::VideoFrameProvider::RepaintCB& repaint_cb) { 56 const webkit_media::VideoFrameProvider::RepaintCB& repaint_cb) {
86 if (!IsMockMediaStreamWithVideo(url)) 57 if (!IsMockMediaStreamWithVideo(url))
87 return NULL; 58 return NULL;
88 59
89 return new webkit_media::SimpleVideoFrameProvider( 60 return new webkit_media::SimpleVideoFrameProvider(
90 gfx::Size(kVideoCaptureWidth, kVideoCaptureHeight), 61 gfx::Size(kVideoCaptureWidth, kVideoCaptureHeight),
91 base::TimeDelta::FromMilliseconds(kVideoCaptureFrameDurationMs), 62 base::TimeDelta::FromMilliseconds(kVideoCaptureFrameDurationMs),
92 error_cb, 63 error_cb,
93 repaint_cb); 64 repaint_cb);
94 } 65 }
95 66
96 scoped_refptr<webkit_media::MediaStreamAudioRenderer> 67 scoped_refptr<webkit_media::MediaStreamAudioRenderer>
97 TestMediaStreamClient::GetAudioRenderer(const GURL& url) { 68 TestMediaStreamClient::GetAudioRenderer(const GURL& url) {
98 return NULL; 69 return NULL;
99 } 70 }
100 71
101 } // namespace webkit_glue 72 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/mocks/test_media_stream_client.h ('k') | webkit/support/webkit_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698