| 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 #ifndef CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ | 6 #define CONTENT_RENDERER_MEDIA_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/common/content_export.h" |
| 17 #include "content/renderer/media/buffered_data_source.h" |
| 18 #include "content/renderer/media/buffered_data_source_host_impl.h" |
| 16 #include "content/renderer/media/crypto/proxy_decryptor.h" | 19 #include "content/renderer/media/crypto/proxy_decryptor.h" |
| 17 #include "content/renderer/media/video_frame_compositor.h" | 20 #include "content/renderer/media/video_frame_compositor.h" |
| 18 #include "media/base/audio_renderer_sink.h" | 21 #include "media/base/audio_renderer_sink.h" |
| 19 #include "media/base/decryptor.h" | 22 #include "media/base/decryptor.h" |
| 20 // TODO(xhwang): Remove when we remove prefixed EME implementation. | 23 // TODO(xhwang): Remove when we remove prefixed EME implementation. |
| 21 #include "media/base/media_keys.h" | 24 #include "media/base/media_keys.h" |
| 22 #include "media/base/pipeline.h" | 25 #include "media/base/pipeline.h" |
| 23 #include "media/base/text_track.h" | 26 #include "media/base/text_track.h" |
| 24 #include "media/filters/skcanvas_video_renderer.h" | 27 #include "media/filters/skcanvas_video_renderer.h" |
| 25 #include "skia/ext/platform_canvas.h" | 28 #include "skia/ext/platform_canvas.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 56 class VideoFrameCompositor; | 59 class VideoFrameCompositor; |
| 57 class WebAudioSourceProviderImpl; | 60 class WebAudioSourceProviderImpl; |
| 58 class WebContentDecryptionModuleImpl; | 61 class WebContentDecryptionModuleImpl; |
| 59 class WebMediaPlayerDelegate; | 62 class WebMediaPlayerDelegate; |
| 60 class WebMediaPlayerParams; | 63 class WebMediaPlayerParams; |
| 61 class WebTextTrackImpl; | 64 class WebTextTrackImpl; |
| 62 | 65 |
| 63 // The canonical implementation of blink::WebMediaPlayer that's backed by | 66 // The canonical implementation of blink::WebMediaPlayer that's backed by |
| 64 // media::Pipeline. Handles normal resource loading, Media Source, and | 67 // media::Pipeline. Handles normal resource loading, Media Source, and |
| 65 // Encrypted Media. | 68 // Encrypted Media. |
| 66 class WebMediaPlayerImpl | 69 class CONTENT_EXPORT WebMediaPlayerImpl |
| 67 : public blink::WebMediaPlayer, | 70 : public blink::WebMediaPlayer, |
| 68 public base::SupportsWeakPtr<WebMediaPlayerImpl> { | 71 public base::SupportsWeakPtr<WebMediaPlayerImpl> { |
| 69 public: | 72 public: |
| 70 // Constructs a WebMediaPlayer implementation using Chromium's media stack. | 73 // Constructs a WebMediaPlayer implementation using Chromium's media stack. |
| 71 // |delegate| may be null. | 74 // |delegate| may be null. |
| 72 WebMediaPlayerImpl(blink::WebLocalFrame* frame, | 75 WebMediaPlayerImpl(blink::WebLocalFrame* frame, |
| 73 blink::WebMediaPlayerClient* client, | 76 blink::WebMediaPlayerClient* client, |
| 74 base::WeakPtr<WebMediaPlayerDelegate> delegate, | 77 base::WeakPtr<WebMediaPlayerDelegate> delegate, |
| 75 const WebMediaPlayerParams& params); | 78 const WebMediaPlayerParams& params); |
| 76 virtual ~WebMediaPlayerImpl(); | 79 virtual ~WebMediaPlayerImpl(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 107 virtual bool seeking() const; | 110 virtual bool seeking() const; |
| 108 virtual double duration() const; | 111 virtual double duration() const; |
| 109 virtual double currentTime() const; | 112 virtual double currentTime() const; |
| 110 | 113 |
| 111 // Internal states of loading and network. | 114 // Internal states of loading and network. |
| 112 // TODO(hclam): Ask the pipeline about the state rather than having reading | 115 // TODO(hclam): Ask the pipeline about the state rather than having reading |
| 113 // them from members which would cause race conditions. | 116 // them from members which would cause race conditions. |
| 114 virtual blink::WebMediaPlayer::NetworkState networkState() const; | 117 virtual blink::WebMediaPlayer::NetworkState networkState() const; |
| 115 virtual blink::WebMediaPlayer::ReadyState readyState() const; | 118 virtual blink::WebMediaPlayer::ReadyState readyState() const; |
| 116 | 119 |
| 120 // TODO(sandersd): Change this to non-const in blink::WebMediaPlayer. |
| 121 // http://crbug.com/360251 |
| 117 virtual bool didLoadingProgress() const; | 122 virtual bool didLoadingProgress() const; |
| 118 | 123 |
| 119 virtual bool hasSingleSecurityOrigin() const; | 124 virtual bool hasSingleSecurityOrigin() const; |
| 120 virtual bool didPassCORSAccessCheck() const; | 125 virtual bool didPassCORSAccessCheck() const; |
| 121 | 126 |
| 122 virtual double mediaTimeForTimeValue(double timeValue) const; | 127 virtual double mediaTimeForTimeValue(double timeValue) const; |
| 123 | 128 |
| 124 virtual unsigned decodedFrameCount() const; | 129 virtual unsigned decodedFrameCount() const; |
| 125 virtual unsigned droppedFrameCount() const; | 130 virtual unsigned droppedFrameCount() const; |
| 126 virtual unsigned audioDecodedByteCount() const; | 131 virtual unsigned audioDecodedByteCount() const; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 // If |decryptor_ready_cb| is null, the existing callback will be fired with | 242 // If |decryptor_ready_cb| is null, the existing callback will be fired with |
| 238 // NULL immediately and reset. | 243 // NULL immediately and reset. |
| 239 void SetDecryptorReadyCB(const media::DecryptorReadyCB& decryptor_ready_cb); | 244 void SetDecryptorReadyCB(const media::DecryptorReadyCB& decryptor_ready_cb); |
| 240 | 245 |
| 241 blink::WebLocalFrame* frame_; | 246 blink::WebLocalFrame* frame_; |
| 242 | 247 |
| 243 // TODO(hclam): get rid of these members and read from the pipeline directly. | 248 // TODO(hclam): get rid of these members and read from the pipeline directly. |
| 244 blink::WebMediaPlayer::NetworkState network_state_; | 249 blink::WebMediaPlayer::NetworkState network_state_; |
| 245 blink::WebMediaPlayer::ReadyState ready_state_; | 250 blink::WebMediaPlayer::ReadyState ready_state_; |
| 246 | 251 |
| 247 // Keep a list of buffered time ranges. | |
| 248 blink::WebTimeRanges buffered_; | |
| 249 | |
| 250 // Message loops for posting tasks on Chrome's main thread. Also used | 252 // Message loops for posting tasks on Chrome's main thread. Also used |
| 251 // for DCHECKs so methods calls won't execute in the wrong thread. | 253 // for DCHECKs so methods calls won't execute in the wrong thread. |
| 252 const scoped_refptr<base::MessageLoopProxy> main_loop_; | 254 const scoped_refptr<base::MessageLoopProxy> main_loop_; |
| 253 | 255 |
| 254 scoped_refptr<base::MessageLoopProxy> media_loop_; | 256 scoped_refptr<base::MessageLoopProxy> media_loop_; |
| 255 scoped_refptr<media::MediaLog> media_log_; | 257 scoped_refptr<media::MediaLog> media_log_; |
| 256 media::Pipeline pipeline_; | 258 media::Pipeline pipeline_; |
| 257 | 259 |
| 258 // The currently selected key system. Empty string means that no key system | 260 // The currently selected key system. Empty string means that no key system |
| 259 // has been selected. | 261 // has been selected. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 // These two are mutually exclusive: | 315 // These two are mutually exclusive: |
| 314 // |data_source_| is used for regular resource loads. | 316 // |data_source_| is used for regular resource loads. |
| 315 // |chunk_demuxer_| is used for Media Source resource loads. | 317 // |chunk_demuxer_| is used for Media Source resource loads. |
| 316 // | 318 // |
| 317 // |demuxer_| will contain the appropriate demuxer based on which resource | 319 // |demuxer_| will contain the appropriate demuxer based on which resource |
| 318 // load strategy we're using. | 320 // load strategy we're using. |
| 319 scoped_ptr<BufferedDataSource> data_source_; | 321 scoped_ptr<BufferedDataSource> data_source_; |
| 320 scoped_ptr<media::Demuxer> demuxer_; | 322 scoped_ptr<media::Demuxer> demuxer_; |
| 321 media::ChunkDemuxer* chunk_demuxer_; | 323 media::ChunkDemuxer* chunk_demuxer_; |
| 322 | 324 |
| 325 BufferedDataSourceHostImpl buffered_data_source_host_; |
| 326 // TODO(sandersd): Remove this cache. http://crbug.com/360254 |
| 327 blink::WebTimeRanges buffered_web_time_ranges_; |
| 328 |
| 323 // Temporary for EME v0.1. In the future the init data type should be passed | 329 // Temporary for EME v0.1. In the future the init data type should be passed |
| 324 // through GenerateKeyRequest() directly from WebKit. | 330 // through GenerateKeyRequest() directly from WebKit. |
| 325 std::string init_data_type_; | 331 std::string init_data_type_; |
| 326 | 332 |
| 327 // Video rendering members. | 333 // Video rendering members. |
| 328 VideoFrameCompositor compositor_; | 334 VideoFrameCompositor compositor_; |
| 329 media::SkCanvasVideoRenderer skcanvas_video_renderer_; | 335 media::SkCanvasVideoRenderer skcanvas_video_renderer_; |
| 330 | 336 |
| 331 // The compositor layer for displaying the video content when using composited | 337 // The compositor layer for displaying the video content when using composited |
| 332 // playback. | 338 // playback. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 343 WebContentDecryptionModuleImpl* web_cdm_; | 349 WebContentDecryptionModuleImpl* web_cdm_; |
| 344 | 350 |
| 345 media::DecryptorReadyCB decryptor_ready_cb_; | 351 media::DecryptorReadyCB decryptor_ready_cb_; |
| 346 | 352 |
| 347 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); | 353 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); |
| 348 }; | 354 }; |
| 349 | 355 |
| 350 } // namespace content | 356 } // namespace content |
| 351 | 357 |
| 352 #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ | 358 #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ |
| OLD | NEW |