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/renderer/media/buffered_data_source.h" | |
16 #include "content/renderer/media/crypto/proxy_decryptor.h" | 17 #include "content/renderer/media/crypto/proxy_decryptor.h" |
17 #include "content/renderer/media/video_frame_compositor.h" | 18 #include "content/renderer/media/video_frame_compositor.h" |
18 #include "media/base/audio_renderer_sink.h" | 19 #include "media/base/audio_renderer_sink.h" |
19 #include "media/base/decryptor.h" | 20 #include "media/base/decryptor.h" |
20 // TODO(xhwang): Remove when we remove prefixed EME implementation. | 21 // TODO(xhwang): Remove when we remove prefixed EME implementation. |
21 #include "media/base/media_keys.h" | 22 #include "media/base/media_keys.h" |
22 #include "media/base/pipeline.h" | 23 #include "media/base/pipeline.h" |
23 #include "media/base/text_track.h" | 24 #include "media/base/text_track.h" |
24 #include "media/filters/skcanvas_video_renderer.h" | 25 #include "media/filters/skcanvas_video_renderer.h" |
25 #include "skia/ext/platform_canvas.h" | 26 #include "skia/ext/platform_canvas.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 class WebContentDecryptionModuleImpl; | 59 class WebContentDecryptionModuleImpl; |
59 class WebMediaPlayerDelegate; | 60 class WebMediaPlayerDelegate; |
60 class WebMediaPlayerParams; | 61 class WebMediaPlayerParams; |
61 class WebTextTrackImpl; | 62 class WebTextTrackImpl; |
62 | 63 |
63 // The canonical implementation of blink::WebMediaPlayer that's backed by | 64 // The canonical implementation of blink::WebMediaPlayer that's backed by |
64 // media::Pipeline. Handles normal resource loading, Media Source, and | 65 // media::Pipeline. Handles normal resource loading, Media Source, and |
65 // Encrypted Media. | 66 // Encrypted Media. |
66 class WebMediaPlayerImpl | 67 class WebMediaPlayerImpl |
67 : public blink::WebMediaPlayer, | 68 : public blink::WebMediaPlayer, |
69 public BufferedDataSourceHost, | |
68 public base::SupportsWeakPtr<WebMediaPlayerImpl> { | 70 public base::SupportsWeakPtr<WebMediaPlayerImpl> { |
69 public: | 71 public: |
70 // Constructs a WebMediaPlayer implementation using Chromium's media stack. | 72 // Constructs a WebMediaPlayer implementation using Chromium's media stack. |
71 // |delegate| may be null. | 73 // |delegate| may be null. |
72 WebMediaPlayerImpl(blink::WebLocalFrame* frame, | 74 WebMediaPlayerImpl(blink::WebLocalFrame* frame, |
73 blink::WebMediaPlayerClient* client, | 75 blink::WebMediaPlayerClient* client, |
74 base::WeakPtr<WebMediaPlayerDelegate> delegate, | 76 base::WeakPtr<WebMediaPlayerDelegate> delegate, |
75 const WebMediaPlayerParams& params); | 77 const WebMediaPlayerParams& params); |
76 virtual ~WebMediaPlayerImpl(); | 78 virtual ~WebMediaPlayerImpl(); |
77 | 79 |
(...skipping 29 matching lines...) Expand all Loading... | |
107 virtual bool seeking() const; | 109 virtual bool seeking() const; |
108 virtual double duration() const; | 110 virtual double duration() const; |
109 virtual double currentTime() const; | 111 virtual double currentTime() const; |
110 | 112 |
111 // Internal states of loading and network. | 113 // Internal states of loading and network. |
112 // TODO(hclam): Ask the pipeline about the state rather than having reading | 114 // TODO(hclam): Ask the pipeline about the state rather than having reading |
113 // them from members which would cause race conditions. | 115 // them from members which would cause race conditions. |
114 virtual blink::WebMediaPlayer::NetworkState networkState() const; | 116 virtual blink::WebMediaPlayer::NetworkState networkState() const; |
115 virtual blink::WebMediaPlayer::ReadyState readyState() const; | 117 virtual blink::WebMediaPlayer::ReadyState readyState() const; |
116 | 118 |
119 // FIXME: Change this to non-const in blink::WebMediaPlayer. | |
scherkus (not reviewing)
2014/04/05 00:00:02
sillyness: blink uses FIXME (leftover from WebKit
| |
120 // http://crbug.com/360251 | |
117 virtual bool didLoadingProgress() const; | 121 virtual bool didLoadingProgress() const; |
118 | 122 |
119 virtual bool hasSingleSecurityOrigin() const; | 123 virtual bool hasSingleSecurityOrigin() const; |
120 virtual bool didPassCORSAccessCheck() const; | 124 virtual bool didPassCORSAccessCheck() const; |
121 | 125 |
122 virtual double mediaTimeForTimeValue(double timeValue) const; | 126 virtual double mediaTimeForTimeValue(double timeValue) const; |
123 | 127 |
124 virtual unsigned decodedFrameCount() const; | 128 virtual unsigned decodedFrameCount() const; |
125 virtual unsigned droppedFrameCount() const; | 129 virtual unsigned droppedFrameCount() const; |
126 virtual unsigned audioDecodedByteCount() const; | 130 virtual unsigned audioDecodedByteCount() const; |
(...skipping 22 matching lines...) Expand all Loading... | |
149 unsigned init_data_length, | 153 unsigned init_data_length, |
150 const blink::WebString& session_id); | 154 const blink::WebString& session_id); |
151 | 155 |
152 virtual MediaKeyException cancelKeyRequest( | 156 virtual MediaKeyException cancelKeyRequest( |
153 const blink::WebString& key_system, | 157 const blink::WebString& key_system, |
154 const blink::WebString& session_id); | 158 const blink::WebString& session_id); |
155 | 159 |
156 virtual void setContentDecryptionModule( | 160 virtual void setContentDecryptionModule( |
157 blink::WebContentDecryptionModule* cdm); | 161 blink::WebContentDecryptionModule* cdm); |
158 | 162 |
163 // BufferedDataSourceHost implementation. | |
164 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; | |
165 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE; | |
166 | |
159 // Notifies blink that the entire media element region has been invalidated. | 167 // Notifies blink that the entire media element region has been invalidated. |
160 // This path is slower than notifying the compositor directly as it performs | 168 // This path is slower than notifying the compositor directly as it performs |
161 // more work and can trigger layouts. It should only be used in two cases: | 169 // more work and can trigger layouts. It should only be used in two cases: |
162 // 1) Major state changes (e.g., first frame available, run time error | 170 // 1) Major state changes (e.g., first frame available, run time error |
163 // occured) | 171 // occured) |
164 // 2) Compositing not available | 172 // 2) Compositing not available |
165 void InvalidateOnMainThread(); | 173 void InvalidateOnMainThread(); |
166 | 174 |
167 void OnPipelineSeek(media::PipelineStatus status); | 175 void OnPipelineSeek(media::PipelineStatus status); |
168 void OnPipelineEnded(); | 176 void OnPipelineEnded(); |
(...skipping 68 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 | 245 // If |decryptor_ready_cb| is null, the existing callback will be fired with |
238 // NULL immediately and reset. | 246 // NULL immediately and reset. |
239 void SetDecryptorReadyCB(const media::DecryptorReadyCB& decryptor_ready_cb); | 247 void SetDecryptorReadyCB(const media::DecryptorReadyCB& decryptor_ready_cb); |
240 | 248 |
241 blink::WebLocalFrame* frame_; | 249 blink::WebLocalFrame* frame_; |
242 | 250 |
243 // TODO(hclam): get rid of these members and read from the pipeline directly. | 251 // TODO(hclam): get rid of these members and read from the pipeline directly. |
244 blink::WebMediaPlayer::NetworkState network_state_; | 252 blink::WebMediaPlayer::NetworkState network_state_; |
245 blink::WebMediaPlayer::ReadyState ready_state_; | 253 blink::WebMediaPlayer::ReadyState ready_state_; |
246 | 254 |
247 // Keep a list of buffered time ranges. | 255 // FIXME: Remove this cache. http://crbug.com/360254 |
scherkus (not reviewing)
2014/04/05 00:00:02
ditto
| |
248 blink::WebTimeRanges buffered_; | 256 blink::WebTimeRanges buffered_; |
249 | 257 |
250 // Message loops for posting tasks on Chrome's main thread. Also used | 258 // 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. | 259 // for DCHECKs so methods calls won't execute in the wrong thread. |
252 const scoped_refptr<base::MessageLoopProxy> main_loop_; | 260 const scoped_refptr<base::MessageLoopProxy> main_loop_; |
253 | 261 |
254 scoped_refptr<base::MessageLoopProxy> media_loop_; | 262 scoped_refptr<base::MessageLoopProxy> media_loop_; |
255 scoped_refptr<media::MediaLog> media_log_; | 263 scoped_refptr<media::MediaLog> media_log_; |
256 media::Pipeline pipeline_; | 264 media::Pipeline pipeline_; |
257 | 265 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 // These two are mutually exclusive: | 321 // These two are mutually exclusive: |
314 // |data_source_| is used for regular resource loads. | 322 // |data_source_| is used for regular resource loads. |
315 // |chunk_demuxer_| is used for Media Source resource loads. | 323 // |chunk_demuxer_| is used for Media Source resource loads. |
316 // | 324 // |
317 // |demuxer_| will contain the appropriate demuxer based on which resource | 325 // |demuxer_| will contain the appropriate demuxer based on which resource |
318 // load strategy we're using. | 326 // load strategy we're using. |
319 scoped_ptr<BufferedDataSource> data_source_; | 327 scoped_ptr<BufferedDataSource> data_source_; |
320 scoped_ptr<media::Demuxer> demuxer_; | 328 scoped_ptr<media::Demuxer> demuxer_; |
321 media::ChunkDemuxer* chunk_demuxer_; | 329 media::ChunkDemuxer* chunk_demuxer_; |
322 | 330 |
331 // Total size of the data source. | |
332 int64 total_bytes_; | |
333 | |
334 // List of buffered byte ranges for estimating buffered time. | |
335 media::Ranges<int64> buffered_byte_ranges_; | |
336 | |
337 // True when AddBufferedByteRange() has been called more recently than | |
338 // didLoadingProgress(). | |
339 mutable bool did_loading_progress_; | |
340 | |
323 // Temporary for EME v0.1. In the future the init data type should be passed | 341 // Temporary for EME v0.1. In the future the init data type should be passed |
324 // through GenerateKeyRequest() directly from WebKit. | 342 // through GenerateKeyRequest() directly from WebKit. |
325 std::string init_data_type_; | 343 std::string init_data_type_; |
326 | 344 |
327 // Video rendering members. | 345 // Video rendering members. |
328 VideoFrameCompositor compositor_; | 346 VideoFrameCompositor compositor_; |
329 media::SkCanvasVideoRenderer skcanvas_video_renderer_; | 347 media::SkCanvasVideoRenderer skcanvas_video_renderer_; |
330 | 348 |
331 // The compositor layer for displaying the video content when using composited | 349 // The compositor layer for displaying the video content when using composited |
332 // playback. | 350 // playback. |
(...skipping 10 matching lines...) Expand all Loading... | |
343 WebContentDecryptionModuleImpl* web_cdm_; | 361 WebContentDecryptionModuleImpl* web_cdm_; |
344 | 362 |
345 media::DecryptorReadyCB decryptor_ready_cb_; | 363 media::DecryptorReadyCB decryptor_ready_cb_; |
346 | 364 |
347 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); | 365 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); |
348 }; | 366 }; |
349 | 367 |
350 } // namespace content | 368 } // namespace content |
351 | 369 |
352 #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ | 370 #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ |
OLD | NEW |