| 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 // 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. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 #ifndef WEBKIT_MEDIA_WEBMEDIAPLAYER_IMPL_H_ | 48 #ifndef WEBKIT_MEDIA_WEBMEDIAPLAYER_IMPL_H_ |
| 49 #define WEBKIT_MEDIA_WEBMEDIAPLAYER_IMPL_H_ | 49 #define WEBKIT_MEDIA_WEBMEDIAPLAYER_IMPL_H_ |
| 50 | 50 |
| 51 #include <string> | 51 #include <string> |
| 52 | 52 |
| 53 #include "base/memory/ref_counted.h" | 53 #include "base/memory/ref_counted.h" |
| 54 #include "base/memory/scoped_ptr.h" | 54 #include "base/memory/scoped_ptr.h" |
| 55 #include "base/memory/weak_ptr.h" | 55 #include "base/memory/weak_ptr.h" |
| 56 #include "base/message_loop.h" | 56 #include "base/message_loop.h" |
| 57 #include "base/threading/thread.h" |
| 57 #include "googleurl/src/gurl.h" | 58 #include "googleurl/src/gurl.h" |
| 58 #include "media/base/audio_renderer_sink.h" | 59 #include "media/base/audio_renderer_sink.h" |
| 59 #include "media/base/decryptor.h" | 60 #include "media/base/decryptor.h" |
| 60 #include "media/base/message_loop_factory.h" | |
| 61 #include "media/base/pipeline.h" | 61 #include "media/base/pipeline.h" |
| 62 #include "skia/ext/platform_canvas.h" | 62 #include "skia/ext/platform_canvas.h" |
| 63 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAudioSourceProvide
r.h" | 63 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAudioSourceProvide
r.h" |
| 64 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h" | 64 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h" |
| 65 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerClient.
h" | 65 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerClient.
h" |
| 66 #include "webkit/media/crypto/key_systems.h" | 66 #include "webkit/media/crypto/key_systems.h" |
| 67 #include "webkit/media/crypto/proxy_decryptor.h" | 67 #include "webkit/media/crypto/proxy_decryptor.h" |
| 68 | 68 |
| 69 class RenderAudioSourceProvider; | 69 class RenderAudioSourceProvider; |
| 70 | 70 |
| 71 namespace WebKit { | 71 namespace WebKit { |
| 72 class WebAudioSourceProvider; | |
| 73 class WebFrame; | 72 class WebFrame; |
| 74 } | 73 } |
| 75 | 74 |
| 76 namespace media { | 75 namespace media { |
| 77 class AudioRendererSink; | |
| 78 class ChunkDemuxer; | 76 class ChunkDemuxer; |
| 79 class MediaLog; | 77 class MediaLog; |
| 80 } | 78 } |
| 81 | 79 |
| 82 namespace webkit_media { | 80 namespace webkit_media { |
| 83 | 81 |
| 84 class MediaStreamClient; | 82 class MediaStreamClient; |
| 85 class WebMediaPlayerDelegate; | 83 class WebMediaPlayerDelegate; |
| 84 class WebMediaPlayerParams; |
| 86 class WebMediaPlayerProxy; | 85 class WebMediaPlayerProxy; |
| 87 | 86 |
| 88 class WebMediaPlayerImpl | 87 class WebMediaPlayerImpl |
| 89 : public WebKit::WebMediaPlayer, | 88 : public WebKit::WebMediaPlayer, |
| 90 public MessageLoop::DestructionObserver, | 89 public MessageLoop::DestructionObserver, |
| 91 public base::SupportsWeakPtr<WebMediaPlayerImpl> { | 90 public base::SupportsWeakPtr<WebMediaPlayerImpl> { |
| 92 public: | 91 public: |
| 93 // Construct a WebMediaPlayerImpl with reference to the client, and media | 92 // Constructs a WebMediaPlayer implementation using Chromium's media stack. |
| 94 // filter collection. By providing the filter collection the implementor can | |
| 95 // provide more specific media filters that does resource loading and | |
| 96 // rendering. | |
| 97 // | 93 // |
| 98 // WebMediaPlayerImpl comes packaged with the following media filters: | 94 // |delegate| may be null. |
| 99 // - URL fetching | 95 WebMediaPlayerImpl( |
| 100 // - Demuxing | 96 WebKit::WebFrame* frame, |
| 101 // - Software audio/video decoding | 97 WebKit::WebMediaPlayerClient* client, |
| 102 // - Video rendering | 98 base::WeakPtr<WebMediaPlayerDelegate> delegate, |
| 103 // | 99 const WebMediaPlayerParams& params); |
| 104 // Clients are expected to add their platform-specific audio rendering media | |
| 105 // filter if they wish to hear any sound coming out the speakers, otherwise | |
| 106 // audio data is discarded and media plays back based on wall clock time. | |
| 107 // | |
| 108 // When calling this, the |audio_source_provider| and | |
| 109 // |audio_renderer_sink| arguments should be the same object. | |
| 110 // | |
| 111 // TODO(scherkus): Remove WebAudioSourceProvider parameter once we | |
| 112 // refactor RenderAudioSourceProvider to live under webkit/media/ | |
| 113 // instead of content/renderer/, see http://crbug.com/136442 | |
| 114 | |
| 115 WebMediaPlayerImpl(WebKit::WebFrame* frame, | |
| 116 WebKit::WebMediaPlayerClient* client, | |
| 117 base::WeakPtr<WebMediaPlayerDelegate> delegate, | |
| 118 media::FilterCollection* collection, | |
| 119 WebKit::WebAudioSourceProvider* audio_source_provider, | |
| 120 media::AudioRendererSink* audio_renderer_sink, | |
| 121 media::MessageLoopFactory* message_loop_factory, | |
| 122 MediaStreamClient* media_stream_client, | |
| 123 media::MediaLog* media_log); | |
| 124 virtual ~WebMediaPlayerImpl(); | 100 virtual ~WebMediaPlayerImpl(); |
| 125 | 101 |
| 126 virtual void load(const WebKit::WebURL& url, CORSMode cors_mode); | 102 virtual void load(const WebKit::WebURL& url, CORSMode cors_mode); |
| 127 virtual void cancelLoad(); | 103 virtual void cancelLoad(); |
| 128 | 104 |
| 129 // Playback controls. | 105 // Playback controls. |
| 130 virtual void play(); | 106 virtual void play(); |
| 131 virtual void pause(); | 107 virtual void pause(); |
| 132 virtual bool supportsFullscreen() const; | 108 virtual bool supportsFullscreen() const; |
| 133 virtual bool supportsSave() const; | 109 virtual bool supportsSave() const; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 | 274 |
| 299 // Keep a list of buffered time ranges. | 275 // Keep a list of buffered time ranges. |
| 300 WebKit::WebTimeRanges buffered_; | 276 WebKit::WebTimeRanges buffered_; |
| 301 | 277 |
| 302 // Message loops for posting tasks between Chrome's main thread. Also used | 278 // Message loops for posting tasks between Chrome's main thread. Also used |
| 303 // for DCHECKs so methods calls won't execute in the wrong thread. | 279 // for DCHECKs so methods calls won't execute in the wrong thread. |
| 304 MessageLoop* main_loop_; | 280 MessageLoop* main_loop_; |
| 305 | 281 |
| 306 scoped_ptr<media::FilterCollection> filter_collection_; | 282 scoped_ptr<media::FilterCollection> filter_collection_; |
| 307 scoped_refptr<media::Pipeline> pipeline_; | 283 scoped_refptr<media::Pipeline> pipeline_; |
| 284 base::Thread media_thread_; |
| 308 | 285 |
| 309 // The currently selected key system. Empty string means that no key system | 286 // The currently selected key system. Empty string means that no key system |
| 310 // has been selected. | 287 // has been selected. |
| 311 WebKit::WebString current_key_system_; | 288 WebKit::WebString current_key_system_; |
| 312 | 289 |
| 313 scoped_ptr<media::MessageLoopFactory> message_loop_factory_; | |
| 314 | |
| 315 // Playback state. | 290 // Playback state. |
| 316 // | 291 // |
| 317 // TODO(scherkus): we have these because Pipeline favours the simplicity of a | 292 // TODO(scherkus): we have these because Pipeline favours the simplicity of a |
| 318 // single "playback rate" over worrying about paused/stopped etc... It forces | 293 // single "playback rate" over worrying about paused/stopped etc... It forces |
| 319 // all clients to manage the pause+playback rate externally, but is that | 294 // all clients to manage the pause+playback rate externally, but is that |
| 320 // really a bad thing? | 295 // really a bad thing? |
| 321 // | 296 // |
| 322 // TODO(scherkus): since SetPlaybackRate(0) is asynchronous and we don't want | 297 // TODO(scherkus): since SetPlaybackRate(0) is asynchronous and we don't want |
| 323 // to hang the render thread during pause(), we record the time at the same | 298 // to hang the render thread during pause(), we record the time at the same |
| 324 // time we pause and then return that value in currentTime(). Otherwise our | 299 // time we pause and then return that value in currentTime(). Otherwise our |
| (...skipping 20 matching lines...) Expand all Loading... |
| 345 scoped_refptr<media::MediaLog> media_log_; | 320 scoped_refptr<media::MediaLog> media_log_; |
| 346 | 321 |
| 347 // Since accelerated compositing status is only known after the first layout, | 322 // Since accelerated compositing status is only known after the first layout, |
| 348 // we delay reporting it to UMA until that time. | 323 // we delay reporting it to UMA until that time. |
| 349 bool accelerated_compositing_reported_; | 324 bool accelerated_compositing_reported_; |
| 350 | 325 |
| 351 bool incremented_externally_allocated_memory_; | 326 bool incremented_externally_allocated_memory_; |
| 352 | 327 |
| 353 WebKit::WebAudioSourceProvider* audio_source_provider_; | 328 WebKit::WebAudioSourceProvider* audio_source_provider_; |
| 354 | 329 |
| 355 scoped_refptr<media::AudioRendererSink> audio_renderer_sink_; | |
| 356 | |
| 357 bool is_local_source_; | 330 bool is_local_source_; |
| 358 bool supports_save_; | 331 bool supports_save_; |
| 359 | 332 |
| 360 // The decryptor that manages decryption keys and decrypts encrypted frames. | 333 // The decryptor that manages decryption keys and decrypts encrypted frames. |
| 361 scoped_ptr<ProxyDecryptor> decryptor_; | 334 scoped_ptr<ProxyDecryptor> decryptor_; |
| 362 | 335 |
| 363 bool starting_; | 336 bool starting_; |
| 364 | 337 |
| 365 scoped_refptr<media::ChunkDemuxer> chunk_demuxer_; | 338 scoped_refptr<media::ChunkDemuxer> chunk_demuxer_; |
| 366 | 339 |
| 367 // Temporary for EME v0.1. In the future the init data type should be passed | 340 // Temporary for EME v0.1. In the future the init data type should be passed |
| 368 // through GenerateKeyRequest() directly from WebKit. | 341 // through GenerateKeyRequest() directly from WebKit. |
| 369 std::string init_data_type_; | 342 std::string init_data_type_; |
| 370 | 343 |
| 371 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); | 344 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); |
| 372 }; | 345 }; |
| 373 | 346 |
| 374 } // namespace webkit_media | 347 } // namespace webkit_media |
| 375 | 348 |
| 376 #endif // WEBKIT_MEDIA_WEBMEDIAPLAYER_IMPL_H_ | 349 #endif // WEBKIT_MEDIA_WEBMEDIAPLAYER_IMPL_H_ |
| OLD | NEW |