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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 class WebContentDecryptionModuleImpl; | 58 class WebContentDecryptionModuleImpl; |
58 class WebMediaPlayerDelegate; | 59 class WebMediaPlayerDelegate; |
59 class WebMediaPlayerParams; | 60 class WebMediaPlayerParams; |
60 class WebTextTrackImpl; | 61 class WebTextTrackImpl; |
61 | 62 |
62 // The canonical implementation of blink::WebMediaPlayer that's backed by | 63 // The canonical implementation of blink::WebMediaPlayer that's backed by |
63 // media::Pipeline. Handles normal resource loading, Media Source, and | 64 // media::Pipeline. Handles normal resource loading, Media Source, and |
64 // Encrypted Media. | 65 // Encrypted Media. |
65 class WebMediaPlayerImpl | 66 class WebMediaPlayerImpl |
66 : public blink::WebMediaPlayer, | 67 : public blink::WebMediaPlayer, |
68 public BufferedDataSourceHost, | |
67 public base::SupportsWeakPtr<WebMediaPlayerImpl> { | 69 public base::SupportsWeakPtr<WebMediaPlayerImpl> { |
68 public: | 70 public: |
69 // Constructs a WebMediaPlayer implementation using Chromium's media stack. | 71 // Constructs a WebMediaPlayer implementation using Chromium's media stack. |
70 // |delegate| may be null. | 72 // |delegate| may be null. |
71 WebMediaPlayerImpl( | 73 WebMediaPlayerImpl( |
72 blink::WebFrame* frame, | 74 blink::WebFrame* 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(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 unsigned init_data_length, | 151 unsigned init_data_length, |
150 const blink::WebString& session_id); | 152 const blink::WebString& session_id); |
151 | 153 |
152 virtual MediaKeyException cancelKeyRequest( | 154 virtual MediaKeyException cancelKeyRequest( |
153 const blink::WebString& key_system, | 155 const blink::WebString& key_system, |
154 const blink::WebString& session_id); | 156 const blink::WebString& session_id); |
155 | 157 |
156 virtual void setContentDecryptionModule( | 158 virtual void setContentDecryptionModule( |
157 blink::WebContentDecryptionModule* cdm); | 159 blink::WebContentDecryptionModule* cdm); |
158 | 160 |
161 // BufferedDataSourceHost implementation. | |
162 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; | |
163 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE; | |
164 | |
159 // Notifies blink that the entire media element region has been invalidated. | 165 // Notifies blink that the entire media element region has been invalidated. |
160 // This path is slower than notifying the compositor directly as it performs | 166 // 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: | 167 // 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 | 168 // 1) Major state changes (e.g., first frame available, run time error |
163 // occured) | 169 // occured) |
164 // 2) Compositing not available | 170 // 2) Compositing not available |
165 void InvalidateOnMainThread(); | 171 void InvalidateOnMainThread(); |
166 | 172 |
167 void OnPipelineSeek(media::PipelineStatus status); | 173 void OnPipelineSeek(media::PipelineStatus status); |
168 void OnPipelineEnded(); | 174 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 | 243 // If |decryptor_ready_cb| is null, the existing callback will be fired with |
238 // NULL immediately and reset. | 244 // NULL immediately and reset. |
239 void SetDecryptorReadyCB(const media::DecryptorReadyCB& decryptor_ready_cb); | 245 void SetDecryptorReadyCB(const media::DecryptorReadyCB& decryptor_ready_cb); |
240 | 246 |
241 blink::WebFrame* frame_; | 247 blink::WebFrame* frame_; |
242 | 248 |
243 // TODO(hclam): get rid of these members and read from the pipeline directly. | 249 // TODO(hclam): get rid of these members and read from the pipeline directly. |
244 blink::WebMediaPlayer::NetworkState network_state_; | 250 blink::WebMediaPlayer::NetworkState network_state_; |
245 blink::WebMediaPlayer::ReadyState ready_state_; | 251 blink::WebMediaPlayer::ReadyState ready_state_; |
246 | 252 |
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 | 253 // 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. | 254 // for DCHECKs so methods calls won't execute in the wrong thread. |
252 const scoped_refptr<base::MessageLoopProxy> main_loop_; | 255 const scoped_refptr<base::MessageLoopProxy> main_loop_; |
253 | 256 |
254 scoped_refptr<base::MessageLoopProxy> media_loop_; | 257 scoped_refptr<base::MessageLoopProxy> media_loop_; |
255 scoped_refptr<media::MediaLog> media_log_; | 258 scoped_refptr<media::MediaLog> media_log_; |
256 media::Pipeline pipeline_; | 259 media::Pipeline pipeline_; |
257 | 260 |
258 // The currently selected key system. Empty string means that no key system | 261 // The currently selected key system. Empty string means that no key system |
259 // has been selected. | 262 // has been selected. |
260 std::string current_key_system_; | 263 std::string current_key_system_; |
261 | 264 |
262 // The LoadType passed in the |load_type| parameter of the load() call. | 265 // The LoadType passed in the |load_type| parameter of the load() call. |
263 LoadType load_type_; | 266 LoadType load_type_; |
264 | 267 |
265 // Cache of metadata for answering hasAudio(), hasVideo(), and naturalSize(). | 268 // Cache of metadata for answering hasAudio(), hasVideo(), and naturalSize(). |
266 media::PipelineMetadata pipeline_metadata_; | 269 media::PipelineMetadata pipeline_metadata_; |
267 | 270 |
271 // TODO(sandersd): comment. | |
272 int64 total_bytes_; | |
scherkus (not reviewing)
2014/04/03 21:59:37
nit: I'd stash all these variables together around
sandersd (OOO until July 31)
2014/04/04 23:48:41
Done.
| |
273 | |
274 // List of buffered byte ranges for estimating buffered time. | |
275 media::Ranges<int64> buffered_byte_ranges_; | |
276 | |
277 // TODO(sandersd): comment. | |
278 blink::WebTimeRanges buffered_; | |
279 | |
280 // True when AddBufferedByteRange() has been called more recently than | |
281 // didLoadingProgress(). | |
282 mutable bool did_loading_progress_; | |
283 | |
268 // Playback state. | 284 // Playback state. |
269 // | 285 // |
270 // TODO(scherkus): we have these because Pipeline favours the simplicity of a | 286 // TODO(scherkus): we have these because Pipeline favours the simplicity of a |
271 // single "playback rate" over worrying about paused/stopped etc... It forces | 287 // single "playback rate" over worrying about paused/stopped etc... It forces |
272 // all clients to manage the pause+playback rate externally, but is that | 288 // all clients to manage the pause+playback rate externally, but is that |
273 // really a bad thing? | 289 // really a bad thing? |
274 // | 290 // |
275 // TODO(scherkus): since SetPlaybackRate(0) is asynchronous and we don't want | 291 // TODO(scherkus): since SetPlaybackRate(0) is asynchronous and we don't want |
276 // to hang the render thread during pause(), we record the time at the same | 292 // to hang the render thread during pause(), we record the time at the same |
277 // time we pause and then return that value in currentTime(). Otherwise our | 293 // time we pause and then return that value in currentTime(). Otherwise our |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 WebContentDecryptionModuleImpl* web_cdm_; | 359 WebContentDecryptionModuleImpl* web_cdm_; |
344 | 360 |
345 media::DecryptorReadyCB decryptor_ready_cb_; | 361 media::DecryptorReadyCB decryptor_ready_cb_; |
346 | 362 |
347 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); | 363 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); |
348 }; | 364 }; |
349 | 365 |
350 } // namespace content | 366 } // namespace content |
351 | 367 |
352 #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ | 368 #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_IMPL_H_ |
OLD | NEW |