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

Side by Side Diff: media/blink/webmediaplayer_impl.h

Issue 495353003: Move WebMediaPlayerImpl and its dependencies to media/blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More Android fixes Created 6 years, 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ 5 #ifndef MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_
6 #define CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ 6 #define MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
16 #include "content/renderer/media/buffered_data_source_host_impl.h"
17 #include "content/renderer/media/video_frame_compositor.h"
18 #include "media/base/audio_renderer_sink.h" 16 #include "media/base/audio_renderer_sink.h"
17 #include "media/base/media_export.h"
19 // TODO(xhwang): Remove when we remove prefixed EME implementation. 18 // TODO(xhwang): Remove when we remove prefixed EME implementation.
20 #include "media/base/media_keys.h" 19 #include "media/base/media_keys.h"
21 #include "media/base/pipeline.h" 20 #include "media/base/pipeline.h"
22 #include "media/base/text_track.h" 21 #include "media/base/text_track.h"
22 #include "media/blink/buffered_data_source.h"
23 #include "media/blink/buffered_data_source_host_impl.h"
24 #include "media/blink/video_frame_compositor.h"
23 #include "media/filters/skcanvas_video_renderer.h" 25 #include "media/filters/skcanvas_video_renderer.h"
24 #include "skia/ext/platform_canvas.h"
25 #include "third_party/WebKit/public/platform/WebAudioSourceProvider.h" 26 #include "third_party/WebKit/public/platform/WebAudioSourceProvider.h"
26 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" 27 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
27 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" 28 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
28 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" 29 #include "third_party/WebKit/public/platform/WebMediaPlayer.h"
29 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" 30 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h"
30 #include "url/gurl.h" 31 #include "url/gurl.h"
31 32
32 namespace blink { 33 namespace blink {
33 class WebLocalFrame; 34 class WebLocalFrame;
34 } 35 }
35 36
36 namespace base { 37 namespace base {
37 class SingleThreadTaskRunner; 38 class SingleThreadTaskRunner;
38 } 39 }
39 40
40 namespace cc_blink { 41 namespace cc_blink {
41 class WebLayerImpl; 42 class WebLayerImpl;
42 } 43 }
43 44
44 namespace media { 45 namespace media {
45 class AudioHardwareConfig; 46 class AudioHardwareConfig;
46 class ChunkDemuxer; 47 class ChunkDemuxer;
48 class EncryptedMediaPlayerSupport;
47 class GpuVideoAcceleratorFactories; 49 class GpuVideoAcceleratorFactories;
48 class MediaLog; 50 class MediaLog;
49 }
50
51
52 namespace content {
53 class BufferedDataSource;
54 class EncryptedMediaPlayerSupport;
55 class VideoFrameCompositor; 51 class VideoFrameCompositor;
56 class WebAudioSourceProviderImpl; 52 class WebAudioSourceProviderImpl;
57 class WebMediaPlayerDelegate; 53 class WebMediaPlayerDelegate;
58 class WebMediaPlayerParams; 54 class WebMediaPlayerParams;
59 class WebTextTrackImpl; 55 class WebTextTrackImpl;
60 56
61 // The canonical implementation of blink::WebMediaPlayer that's backed by 57 // The canonical implementation of blink::WebMediaPlayer that's backed by
62 // media::Pipeline. Handles normal resource loading, Media Source, and 58 // Pipeline. Handles normal resource loading, Media Source, and
63 // Encrypted Media. 59 // Encrypted Media.
64 class WebMediaPlayerImpl 60 class MEDIA_EXPORT WebMediaPlayerImpl
65 : public blink::WebMediaPlayer, 61 : public blink::WebMediaPlayer,
66 public base::SupportsWeakPtr<WebMediaPlayerImpl> { 62 public base::SupportsWeakPtr<WebMediaPlayerImpl> {
67 public: 63 public:
68 // Constructs a WebMediaPlayer implementation using Chromium's media stack. 64 // Constructs a WebMediaPlayer implementation using Chromium's media stack.
69 // |delegate| may be null. 65 // |delegate| may be null.
70 WebMediaPlayerImpl(blink::WebLocalFrame* frame, 66 WebMediaPlayerImpl(blink::WebLocalFrame* frame,
71 blink::WebMediaPlayerClient* client, 67 blink::WebMediaPlayerClient* client,
72 base::WeakPtr<WebMediaPlayerDelegate> delegate, 68 base::WeakPtr<WebMediaPlayerDelegate> delegate,
73 const WebMediaPlayerParams& params); 69 const WebMediaPlayerParams& params);
74 virtual ~WebMediaPlayerImpl(); 70 virtual ~WebMediaPlayerImpl();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 // TODO(jrummell): Remove this method once Blink updated to use the other 156 // TODO(jrummell): Remove this method once Blink updated to use the other
161 // two methods. 157 // two methods.
162 virtual void setContentDecryptionModule( 158 virtual void setContentDecryptionModule(
163 blink::WebContentDecryptionModule* cdm); 159 blink::WebContentDecryptionModule* cdm);
164 virtual void setContentDecryptionModule( 160 virtual void setContentDecryptionModule(
165 blink::WebContentDecryptionModule* cdm, 161 blink::WebContentDecryptionModule* cdm,
166 blink::WebContentDecryptionModuleResult result); 162 blink::WebContentDecryptionModuleResult result);
167 virtual void setContentDecryptionModuleSync( 163 virtual void setContentDecryptionModuleSync(
168 blink::WebContentDecryptionModule* cdm); 164 blink::WebContentDecryptionModule* cdm);
169 165
170 void OnPipelineSeeked(bool time_changed, media::PipelineStatus status); 166 void OnPipelineSeeked(bool time_changed, PipelineStatus status);
171 void OnPipelineEnded(); 167 void OnPipelineEnded();
172 void OnPipelineError(media::PipelineStatus error); 168 void OnPipelineError(PipelineStatus error);
173 void OnPipelineMetadata(media::PipelineMetadata metadata); 169 void OnPipelineMetadata(PipelineMetadata metadata);
174 void OnPipelineBufferingStateChanged(media::BufferingState buffering_state); 170 void OnPipelineBufferingStateChanged(BufferingState buffering_state);
175 void OnDemuxerOpened(); 171 void OnDemuxerOpened();
176 void OnAddTextTrack(const media::TextTrackConfig& config, 172 void OnAddTextTrack(const TextTrackConfig& config,
177 const media::AddTextTrackDoneCB& done_cb); 173 const AddTextTrackDoneCB& done_cb);
178 174
179 private: 175 private:
180 // Called after |defer_load_cb_| has decided to allow the load. If 176 // Called after |defer_load_cb_| has decided to allow the load. If
181 // |defer_load_cb_| is null this is called immediately. 177 // |defer_load_cb_| is null this is called immediately.
182 void DoLoad(LoadType load_type, 178 void DoLoad(LoadType load_type,
183 const blink::WebURL& url, 179 const blink::WebURL& url,
184 CORSMode cors_mode); 180 CORSMode cors_mode);
185 181
186 // Called after asynchronous initialization of a data source completed. 182 // Called after asynchronous initialization of a data source completed.
187 void DataSourceInitialized(bool success); 183 void DataSourceInitialized(bool success);
188 184
189 // Called when the data source is downloading or paused. 185 // Called when the data source is downloading or paused.
190 void NotifyDownloading(bool is_downloading); 186 void NotifyDownloading(bool is_downloading);
191 187
192 // Creates a media::Renderer that will be used by the |pipeline_|. 188 // Creates a Renderer that will be used by the |pipeline_|.
193 scoped_ptr<media::Renderer> CreateRenderer(); 189 scoped_ptr<Renderer> CreateRenderer();
194 190
195 // Finishes starting the pipeline due to a call to load(). 191 // Finishes starting the pipeline due to a call to load().
196 void StartPipeline(); 192 void StartPipeline();
197 193
198 // Helpers that set the network/ready state and notifies the client if 194 // Helpers that set the network/ready state and notifies the client if
199 // they've changed. 195 // they've changed.
200 void SetNetworkState(blink::WebMediaPlayer::NetworkState state); 196 void SetNetworkState(blink::WebMediaPlayer::NetworkState state);
201 void SetReadyState(blink::WebMediaPlayer::ReadyState state); 197 void SetReadyState(blink::WebMediaPlayer::ReadyState state);
202 198
203 // Gets the duration value reported by the pipeline. 199 // Gets the duration value reported by the pipeline.
204 double GetPipelineDuration() const; 200 double GetPipelineDuration() const;
205 201
206 // Callbacks from |pipeline_| that are forwarded to |client_|. 202 // Callbacks from |pipeline_| that are forwarded to |client_|.
207 void OnDurationChanged(); 203 void OnDurationChanged();
208 void OnNaturalSizeChanged(gfx::Size size); 204 void OnNaturalSizeChanged(gfx::Size size);
209 void OnOpacityChanged(bool opaque); 205 void OnOpacityChanged(bool opaque);
210 206
211 // Called by VideoRendererImpl on its internal thread with the new frame to be 207 // Called by VideoRendererImpl on its internal thread with the new frame to be
212 // painted. 208 // painted.
213 void FrameReady(const scoped_refptr<media::VideoFrame>& frame); 209 void FrameReady(const scoped_refptr<VideoFrame>& frame);
214 210
215 // Called when the ContentDecryptionModule has been attached to the 211 // Called when the ContentDecryptionModule has been attached to the
216 // pipeline/decoders. 212 // pipeline/decoders.
217 void ContentDecryptionModuleAttached( 213 void ContentDecryptionModuleAttached(
218 blink::WebContentDecryptionModuleResult result, 214 blink::WebContentDecryptionModuleResult result,
219 bool success); 215 bool success);
220 216
221 // Returns the current video frame from |compositor_|. Blocks until the 217 // Returns the current video frame from |compositor_|. Blocks until the
222 // compositor can return the frame. 218 // compositor can return the frame.
223 scoped_refptr<media::VideoFrame> GetCurrentFrameFromCompositor(); 219 scoped_refptr<VideoFrame> GetCurrentFrameFromCompositor();
224 220
225 blink::WebLocalFrame* frame_; 221 blink::WebLocalFrame* frame_;
226 222
227 // TODO(hclam): get rid of these members and read from the pipeline directly. 223 // TODO(hclam): get rid of these members and read from the pipeline directly.
228 blink::WebMediaPlayer::NetworkState network_state_; 224 blink::WebMediaPlayer::NetworkState network_state_;
229 blink::WebMediaPlayer::ReadyState ready_state_; 225 blink::WebMediaPlayer::ReadyState ready_state_;
230 226
231 // Preload state for when |data_source_| is created after setPreload(). 227 // Preload state for when |data_source_| is created after setPreload().
232 BufferedDataSource::Preload preload_; 228 BufferedDataSource::Preload preload_;
233 229
234 // Task runner for posting tasks on Chrome's main thread. Also used 230 // Task runner for posting tasks on Chrome's main thread. Also used
235 // for DCHECKs so methods calls won't execute in the wrong thread. 231 // for DCHECKs so methods calls won't execute in the wrong thread.
236 const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; 232 const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
237 233
238 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; 234 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
239 scoped_refptr<media::MediaLog> media_log_; 235 scoped_refptr<MediaLog> media_log_;
240 media::Pipeline pipeline_; 236 Pipeline pipeline_;
241 237
242 // The LoadType passed in the |load_type| parameter of the load() call. 238 // The LoadType passed in the |load_type| parameter of the load() call.
243 LoadType load_type_; 239 LoadType load_type_;
244 240
245 // Cache of metadata for answering hasAudio(), hasVideo(), and naturalSize(). 241 // Cache of metadata for answering hasAudio(), hasVideo(), and naturalSize().
246 media::PipelineMetadata pipeline_metadata_; 242 PipelineMetadata pipeline_metadata_;
247 243
248 // Whether the video is known to be opaque or not. 244 // Whether the video is known to be opaque or not.
249 bool opaque_; 245 bool opaque_;
250 246
251 // Playback state. 247 // Playback state.
252 // 248 //
253 // TODO(scherkus): we have these because Pipeline favours the simplicity of a 249 // TODO(scherkus): we have these because Pipeline favours the simplicity of a
254 // single "playback rate" over worrying about paused/stopped etc... It forces 250 // single "playback rate" over worrying about paused/stopped etc... It forces
255 // all clients to manage the pause+playback rate externally, but is that 251 // all clients to manage the pause+playback rate externally, but is that
256 // really a bad thing? 252 // really a bad thing?
(...skipping 17 matching lines...) Expand all
274 // changes. 270 // changes.
275 bool should_notify_time_changed_; 271 bool should_notify_time_changed_;
276 272
277 blink::WebMediaPlayerClient* client_; 273 blink::WebMediaPlayerClient* client_;
278 274
279 base::WeakPtr<WebMediaPlayerDelegate> delegate_; 275 base::WeakPtr<WebMediaPlayerDelegate> delegate_;
280 276
281 base::Callback<void(const base::Closure&)> defer_load_cb_; 277 base::Callback<void(const base::Closure&)> defer_load_cb_;
282 278
283 // Factories for supporting video accelerators. May be null. 279 // Factories for supporting video accelerators. May be null.
284 scoped_refptr<media::GpuVideoAcceleratorFactories> gpu_factories_; 280 scoped_refptr<GpuVideoAcceleratorFactories> gpu_factories_;
285 281
286 // Routes audio playback to either AudioRendererSink or WebAudio. 282 // Routes audio playback to either AudioRendererSink or WebAudio.
287 scoped_refptr<WebAudioSourceProviderImpl> audio_source_provider_; 283 scoped_refptr<WebAudioSourceProviderImpl> audio_source_provider_;
288 284
289 bool supports_save_; 285 bool supports_save_;
290 286
291 // These two are mutually exclusive: 287 // These two are mutually exclusive:
292 // |data_source_| is used for regular resource loads. 288 // |data_source_| is used for regular resource loads.
293 // |chunk_demuxer_| is used for Media Source resource loads. 289 // |chunk_demuxer_| is used for Media Source resource loads.
294 // 290 //
295 // |demuxer_| will contain the appropriate demuxer based on which resource 291 // |demuxer_| will contain the appropriate demuxer based on which resource
296 // load strategy we're using. 292 // load strategy we're using.
297 scoped_ptr<BufferedDataSource> data_source_; 293 scoped_ptr<BufferedDataSource> data_source_;
298 scoped_ptr<media::Demuxer> demuxer_; 294 scoped_ptr<Demuxer> demuxer_;
299 media::ChunkDemuxer* chunk_demuxer_; 295 ChunkDemuxer* chunk_demuxer_;
300 296
301 BufferedDataSourceHostImpl buffered_data_source_host_; 297 BufferedDataSourceHostImpl buffered_data_source_host_;
302 298
303 // Video rendering members. 299 // Video rendering members.
304 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; 300 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
305 VideoFrameCompositor* compositor_; // Deleted on |compositor_task_runner_|. 301 VideoFrameCompositor* compositor_; // Deleted on |compositor_task_runner_|.
306 media::SkCanvasVideoRenderer skcanvas_video_renderer_; 302 SkCanvasVideoRenderer skcanvas_video_renderer_;
307 303
308 // The compositor layer for displaying the video content when using composited 304 // The compositor layer for displaying the video content when using composited
309 // playback. 305 // playback.
310 scoped_ptr<cc_blink::WebLayerImpl> video_weblayer_; 306 scoped_ptr<cc_blink::WebLayerImpl> video_weblayer_;
311 307
312 // Text track objects get a unique index value when they're created. 308 // Text track objects get a unique index value when they're created.
313 int text_track_index_; 309 int text_track_index_;
314 310
315 scoped_ptr<EncryptedMediaPlayerSupport> encrypted_media_support_; 311 scoped_ptr<EncryptedMediaPlayerSupport> encrypted_media_support_;
316 312
317 const media::AudioHardwareConfig& audio_hardware_config_; 313 const media::AudioHardwareConfig& audio_hardware_config_;
318 314
319 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); 315 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl);
320 }; 316 };
321 317
322 } // namespace content 318 } // namespace media
323 319
324 #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ 320 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698