OLD | NEW |
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 // Delegate calls from WebCore::MediaPlayerPrivate to Chrome's video player. | 5 // Delegate calls from WebCore::MediaPlayerPrivate to Chrome's video player. |
6 // It contains Pipeline which is the actual media player pipeline, it glues | 6 // It contains Pipeline which is the actual media player pipeline, it glues |
7 // the media player pipeline, data source, audio renderer and renderer. | 7 // the media player pipeline, data source, audio renderer and renderer. |
8 // Pipeline would creates multiple threads and access some public methods | 8 // Pipeline would creates multiple threads and access some public methods |
9 // of this class, so we need to be extra careful about concurrent access of | 9 // of this class, so we need to be extra careful about concurrent access of |
10 // methods and members. | 10 // methods and members. |
11 // | 11 // |
12 // Other issues: | 12 // Other issues: |
13 // During tear down of the whole browser or a tab, the DOM tree may not be | 13 // During tear down of the whole browser or a tab, the DOM tree may not be |
14 // destructed nicely, and there will be some dangling media threads trying to | 14 // destructed nicely, and there will be some dangling media threads trying to |
15 // the main thread, so we need this class to listen to destruction event of the | 15 // the main thread, so we need this class to listen to destruction event of the |
16 // main thread and cleanup the media threads when the even is received. Also | 16 // main thread and cleanup the media threads when the even is received. Also |
17 // at destruction of this class we will need to unhook it from destruction event | 17 // at destruction of this class we will need to unhook it from destruction event |
18 // list of the main thread. | 18 // list of the main thread. |
19 | 19 |
20 #ifndef WEBKIT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ | 20 #ifndef CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ |
21 #define WEBKIT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ | 21 #define CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ |
22 | 22 |
23 #include <string> | 23 #include <string> |
24 | 24 |
25 #include "base/memory/ref_counted.h" | 25 #include "base/memory/ref_counted.h" |
26 #include "base/memory/scoped_ptr.h" | 26 #include "base/memory/scoped_ptr.h" |
27 #include "base/memory/weak_ptr.h" | 27 #include "base/memory/weak_ptr.h" |
28 #include "base/threading/thread.h" | 28 #include "base/threading/thread.h" |
29 #include "cc/layers/video_frame_provider.h" | 29 #include "cc/layers/video_frame_provider.h" |
| 30 #include "content/common/content_export.h" |
30 #include "googleurl/src/gurl.h" | 31 #include "googleurl/src/gurl.h" |
31 #include "media/base/audio_renderer_sink.h" | 32 #include "media/base/audio_renderer_sink.h" |
32 #include "media/base/decryptor.h" | 33 #include "media/base/decryptor.h" |
33 #include "media/base/media_keys.h" | 34 #include "media/base/media_keys.h" |
34 #include "media/base/pipeline.h" | 35 #include "media/base/pipeline.h" |
35 #include "media/base/text_track.h" | 36 #include "media/base/text_track.h" |
36 #include "media/filters/gpu_video_decoder.h" | 37 #include "media/filters/gpu_video_decoder.h" |
37 #include "media/filters/skcanvas_video_renderer.h" | 38 #include "media/filters/skcanvas_video_renderer.h" |
38 #include "skia/ext/platform_canvas.h" | 39 #include "skia/ext/platform_canvas.h" |
39 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 40 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
(...skipping 15 matching lines...) Expand all Loading... |
55 namespace media { | 56 namespace media { |
56 class ChunkDemuxer; | 57 class ChunkDemuxer; |
57 class FFmpegDemuxer; | 58 class FFmpegDemuxer; |
58 class MediaLog; | 59 class MediaLog; |
59 } | 60 } |
60 | 61 |
61 namespace webkit { | 62 namespace webkit { |
62 class WebLayerImpl; | 63 class WebLayerImpl; |
63 } | 64 } |
64 | 65 |
65 namespace webkit_media { | 66 namespace content { |
66 | |
67 class BufferedDataSource; | 67 class BufferedDataSource; |
| 68 class MediaPlayerLoadDelegate; |
68 class MediaStreamClient; | 69 class MediaStreamClient; |
69 class WebAudioSourceProviderImpl; | 70 class WebAudioSourceProviderImpl; |
| 71 class WebTextTrackImpl; |
| 72 } |
| 73 |
| 74 namespace content { |
70 class WebMediaPlayerDelegate; | 75 class WebMediaPlayerDelegate; |
71 class WebMediaPlayerParams; | 76 class WebMediaPlayerParams; |
72 class WebTextTrackImpl; | |
73 | 77 |
74 class WebMediaPlayerImpl | 78 class CONTENT_EXPORT WebMediaPlayerImpl |
75 : public WebKit::WebMediaPlayer, | 79 : public WebKit::WebMediaPlayer, |
76 public cc::VideoFrameProvider, | 80 public cc::VideoFrameProvider, |
77 public base::MessageLoop::DestructionObserver, | 81 public base::MessageLoop::DestructionObserver, |
78 public base::SupportsWeakPtr<WebMediaPlayerImpl> { | 82 public base::SupportsWeakPtr<WebMediaPlayerImpl> { |
79 public: | 83 public: |
80 // Constructs a WebMediaPlayer implementation using Chromium's media stack. | 84 // Constructs a WebMediaPlayer implementation using Chromium's media stack. |
81 // | 85 // |
82 // |delegate| may be null. | 86 // |delegate| may be null. |
83 WebMediaPlayerImpl( | 87 WebMediaPlayerImpl( |
84 WebKit::WebFrame* frame, | 88 WebKit::WebFrame* frame, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 void OnNeedKey(const std::string& type, | 202 void OnNeedKey(const std::string& type, |
199 const std::string& session_id, | 203 const std::string& session_id, |
200 scoped_ptr<uint8[]> init_data, | 204 scoped_ptr<uint8[]> init_data, |
201 int init_data_size); | 205 int init_data_size); |
202 scoped_ptr<media::TextTrack> OnTextTrack(media::TextKind kind, | 206 scoped_ptr<media::TextTrack> OnTextTrack(media::TextKind kind, |
203 const std::string& label, | 207 const std::string& label, |
204 const std::string& language); | 208 const std::string& language); |
205 void SetOpaque(bool); | 209 void SetOpaque(bool); |
206 | 210 |
207 private: | 211 private: |
208 // Contains common logic used across the different types loading. | 212 // Called after |load_delegate_| has decided to allow the load. If |
209 void LoadSetup(const WebKit::WebURL& url); | 213 // |load_delegate_| is NULL this is called immediately. |
| 214 void ContinueLoad(const WebKit::WebURL& url, |
| 215 WebKit::WebMediaSource* media_source, |
| 216 CORSMode cors_mode); |
210 | 217 |
211 // Called after asynchronous initialization of a data source completed. | 218 // Called after asynchronous initialization of a data source completed. |
212 void DataSourceInitialized(const GURL& gurl, bool success); | 219 void DataSourceInitialized(const GURL& gurl, bool success); |
213 | 220 |
214 // Called when the data source is downloading or paused. | 221 // Called when the data source is downloading or paused. |
215 void NotifyDownloading(bool is_downloading); | 222 void NotifyDownloading(bool is_downloading); |
216 | 223 |
217 // Finishes starting the pipeline due to a call to load(). | 224 // Finishes starting the pipeline due to a call to load(). |
218 // | 225 // |
219 // A non-null |media_source| will construct a Media Source pipeline. | 226 // A non-null |media_source| will construct a Media Source pipeline. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 double playback_rate_; | 303 double playback_rate_; |
297 base::TimeDelta paused_time_; | 304 base::TimeDelta paused_time_; |
298 | 305 |
299 // Seek gets pending if another seek is in progress. Only last pending seek | 306 // Seek gets pending if another seek is in progress. Only last pending seek |
300 // will have effect. | 307 // will have effect. |
301 bool pending_seek_; | 308 bool pending_seek_; |
302 double pending_seek_seconds_; | 309 double pending_seek_seconds_; |
303 | 310 |
304 WebKit::WebMediaPlayerClient* client_; | 311 WebKit::WebMediaPlayerClient* client_; |
305 | 312 |
| 313 MediaPlayerLoadDelegate* load_delegate_; |
| 314 |
306 base::WeakPtr<WebMediaPlayerDelegate> delegate_; | 315 base::WeakPtr<WebMediaPlayerDelegate> delegate_; |
307 | 316 |
308 MediaStreamClient* media_stream_client_; | |
309 | |
310 scoped_refptr<media::MediaLog> media_log_; | 317 scoped_refptr<media::MediaLog> media_log_; |
311 | 318 |
312 // Since accelerated compositing status is only known after the first layout, | 319 // Since accelerated compositing status is only known after the first layout, |
313 // we delay reporting it to UMA until that time. | 320 // we delay reporting it to UMA until that time. |
314 bool accelerated_compositing_reported_; | 321 bool accelerated_compositing_reported_; |
315 | 322 |
316 bool incremented_externally_allocated_memory_; | 323 bool incremented_externally_allocated_memory_; |
317 | 324 |
318 // Factories for supporting GpuVideoDecoder. May be null. | 325 // Factories for supporting GpuVideoDecoder. May be null. |
319 scoped_refptr<media::GpuVideoDecoder::Factories> gpu_factories_; | 326 scoped_refptr<media::GpuVideoDecoder::Factories> gpu_factories_; |
320 | 327 |
321 // Routes audio playback to either AudioRendererSink or WebAudio. | 328 // Routes audio playback to either AudioRendererSink or WebAudio. |
322 scoped_refptr<WebAudioSourceProviderImpl> audio_source_provider_; | 329 scoped_refptr<WebAudioSourceProviderImpl> audio_source_provider_; |
323 | 330 |
324 bool is_local_source_; | 331 bool is_local_source_; |
325 bool supports_save_; | 332 bool supports_save_; |
326 | 333 |
327 // The decryptor that manages decryption keys and decrypts encrypted frames. | 334 // The decryptor that manages decryption keys and decrypts encrypted frames. |
328 scoped_ptr<ProxyDecryptor> decryptor_; | 335 scoped_ptr<webkit_media::ProxyDecryptor> decryptor_; |
329 | 336 |
330 bool starting_; | 337 bool starting_; |
331 | 338 |
332 // These two are mutually exclusive: | 339 // These two are mutually exclusive: |
333 // |data_source_| is used for regular resource loads. | 340 // |data_source_| is used for regular resource loads. |
334 // |chunk_demuxer_| is used for Media Source resource loads. | 341 // |chunk_demuxer_| is used for Media Source resource loads. |
335 // | 342 // |
336 // |demuxer_| will contain the appropriate demuxer based on which resource | 343 // |demuxer_| will contain the appropriate demuxer based on which resource |
337 // load strategy we're using. | 344 // load strategy we're using. |
338 scoped_ptr<BufferedDataSource> data_source_; | 345 scoped_ptr<BufferedDataSource> data_source_; |
(...skipping 22 matching lines...) Expand all Loading... |
361 // A pointer back to the compositor to inform it about state changes. This is | 368 // A pointer back to the compositor to inform it about state changes. This is |
362 // not NULL while the compositor is actively using this webmediaplayer. | 369 // not NULL while the compositor is actively using this webmediaplayer. |
363 cc::VideoFrameProvider::Client* video_frame_provider_client_; | 370 cc::VideoFrameProvider::Client* video_frame_provider_client_; |
364 | 371 |
365 // Text track objects get a unique index value when they're created. | 372 // Text track objects get a unique index value when they're created. |
366 int text_track_index_; | 373 int text_track_index_; |
367 | 374 |
368 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); | 375 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); |
369 }; | 376 }; |
370 | 377 |
371 } // namespace webkit_media | 378 } // namespace content |
372 | 379 |
373 #endif // WEBKIT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ | 380 #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ |
OLD | NEW |