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 MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ | 5 #ifndef MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ |
6 #define MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ | 6 #define MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/linked_ptr.h" | 15 #include "base/memory/linked_ptr.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
21 #include "media/base/cdm_factory.h" | 21 #include "media/base/cdm_factory.h" |
22 #include "media/base/pipeline.h" | 22 #include "media/base/pipeline.h" |
23 #include "media/base/renderer_factory.h" | 23 #include "media/base/renderer_factory.h" |
24 #include "media/base/surface_manager.h" | |
24 #include "media/base/text_track.h" | 25 #include "media/base/text_track.h" |
25 #include "media/blink/buffered_data_source.h" | 26 #include "media/blink/buffered_data_source.h" |
26 #include "media/blink/buffered_data_source_host_impl.h" | 27 #include "media/blink/buffered_data_source_host_impl.h" |
27 #include "media/blink/encrypted_media_player_support.h" | 28 #include "media/blink/encrypted_media_player_support.h" |
28 #include "media/blink/media_blink_export.h" | 29 #include "media/blink/media_blink_export.h" |
29 #include "media/blink/multibuffer_data_source.h" | 30 #include "media/blink/multibuffer_data_source.h" |
30 #include "media/blink/video_frame_compositor.h" | 31 #include "media/blink/video_frame_compositor.h" |
31 #include "media/blink/webmediaplayer_delegate.h" | 32 #include "media/blink/webmediaplayer_delegate.h" |
32 #include "media/blink/webmediaplayer_params.h" | 33 #include "media/blink/webmediaplayer_params.h" |
33 #include "media/blink/webmediaplayer_util.h" | 34 #include "media/blink/webmediaplayer_util.h" |
(...skipping 18 matching lines...) Expand all Loading... | |
52 namespace base { | 53 namespace base { |
53 class SingleThreadTaskRunner; | 54 class SingleThreadTaskRunner; |
54 class TaskRunner; | 55 class TaskRunner; |
55 } | 56 } |
56 | 57 |
57 namespace cc_blink { | 58 namespace cc_blink { |
58 class WebLayerImpl; | 59 class WebLayerImpl; |
59 } | 60 } |
60 | 61 |
61 namespace media { | 62 namespace media { |
62 | |
63 class AudioHardwareConfig; | 63 class AudioHardwareConfig; |
64 class ChunkDemuxer; | 64 class ChunkDemuxer; |
65 class GpuVideoAcceleratorFactories; | 65 class GpuVideoAcceleratorFactories; |
66 class MediaLog; | 66 class MediaLog; |
67 class UrlIndex; | 67 class UrlIndex; |
68 class VideoFrameCompositor; | 68 class VideoFrameCompositor; |
69 class WebAudioSourceProviderImpl; | 69 class WebAudioSourceProviderImpl; |
70 class WebMediaPlayerDelegate; | 70 class WebMediaPlayerDelegate; |
71 class WebTextTrackImpl; | 71 class WebTextTrackImpl; |
72 | 72 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 const blink::WebString& session_id) override; | 174 const blink::WebString& session_id) override; |
175 | 175 |
176 MediaKeyException cancelKeyRequest( | 176 MediaKeyException cancelKeyRequest( |
177 const blink::WebString& key_system, | 177 const blink::WebString& key_system, |
178 const blink::WebString& session_id) override; | 178 const blink::WebString& session_id) override; |
179 | 179 |
180 void setContentDecryptionModule( | 180 void setContentDecryptionModule( |
181 blink::WebContentDecryptionModule* cdm, | 181 blink::WebContentDecryptionModule* cdm, |
182 blink::WebContentDecryptionModuleResult result) override; | 182 blink::WebContentDecryptionModuleResult result) override; |
183 | 183 |
184 void enterFullscreen() override; | |
185 void exitedFullscreen() override; | |
186 | |
184 void OnPipelineSeeked(bool time_changed, PipelineStatus status); | 187 void OnPipelineSeeked(bool time_changed, PipelineStatus status); |
185 void OnPipelineSuspended(PipelineStatus status); | 188 void OnPipelineSuspended(PipelineStatus status); |
186 void OnPipelineEnded(); | 189 void OnPipelineEnded(); |
187 void OnPipelineError(PipelineStatus error); | 190 void OnPipelineError(PipelineStatus error); |
188 void OnPipelineMetadata(PipelineMetadata metadata); | 191 void OnPipelineMetadata(PipelineMetadata metadata); |
189 void OnPipelineBufferingStateChanged(BufferingState buffering_state); | 192 void OnPipelineBufferingStateChanged(BufferingState buffering_state); |
190 void OnDemuxerOpened(); | 193 void OnDemuxerOpened(); |
191 void OnAddTextTrack(const TextTrackConfig& config, | 194 void OnAddTextTrack(const TextTrackConfig& config, |
192 const AddTextTrackDoneCB& done_cb); | 195 const AddTextTrackDoneCB& done_cb); |
193 | 196 |
194 // WebMediaPlayerDelegate::Observer implementation. | 197 // WebMediaPlayerDelegate::Observer implementation. |
195 void OnHidden() override; | 198 void OnHidden() override; |
196 void OnShown() override; | 199 void OnShown() override; |
197 void OnPlay() override; | 200 void OnPlay() override; |
198 void OnPause() override; | 201 void OnPause() override; |
199 void OnVolumeMultiplierUpdate(double multiplier) override; | 202 void OnVolumeMultiplierUpdate(double multiplier) override; |
200 | 203 |
201 #if defined(OS_ANDROID) // WMPI_CAST | 204 #if defined(OS_ANDROID) |
205 void SetSurfaceManager(SurfaceManager* surface_manager); | |
206 | |
207 // WMPI_CAST | |
202 bool isRemote() const override; | 208 bool isRemote() const override; |
203 void requestRemotePlayback() override; | 209 void requestRemotePlayback() override; |
204 void requestRemotePlaybackControl() override; | 210 void requestRemotePlaybackControl() override; |
205 | 211 |
206 void SetMediaPlayerManager( | 212 void SetMediaPlayerManager( |
207 RendererMediaPlayerManagerInterface* media_player_manager); | 213 RendererMediaPlayerManagerInterface* media_player_manager); |
208 void OnRemotePlaybackEnded(); | 214 void OnRemotePlaybackEnded(); |
209 void OnDisconnectedFromRemoteDevice(double t); | 215 void OnDisconnectedFromRemoteDevice(double t); |
210 void SuspendForRemote(); | 216 void SuspendForRemote(); |
211 void DisplayCastFrameAfterSuspend(const scoped_refptr<VideoFrame>& new_frame, | 217 void DisplayCastFrameAfterSuspend(const scoped_refptr<VideoFrame>& new_frame, |
(...skipping 10 matching lines...) Expand all Loading... | |
222 // Initiate suspending the pipeline. | 228 // Initiate suspending the pipeline. |
223 void Suspend(); | 229 void Suspend(); |
224 | 230 |
225 // Ask for the pipeline to be resumed, will call Resume() when ready. | 231 // Ask for the pipeline to be resumed, will call Resume() when ready. |
226 // (Possibly immediately.) | 232 // (Possibly immediately.) |
227 void ScheduleResume(); | 233 void ScheduleResume(); |
228 | 234 |
229 // Initiate resuming the pipeline. | 235 // Initiate resuming the pipeline. |
230 void Resume(); | 236 void Resume(); |
231 | 237 |
238 // Ask for the renderer to be restarted (destructed and recreated). | |
239 void ScheduleRestart(); | |
240 | |
232 // Called after |defer_load_cb_| has decided to allow the load. If | 241 // Called after |defer_load_cb_| has decided to allow the load. If |
233 // |defer_load_cb_| is null this is called immediately. | 242 // |defer_load_cb_| is null this is called immediately. |
234 void DoLoad(LoadType load_type, | 243 void DoLoad(LoadType load_type, |
235 const blink::WebURL& url, | 244 const blink::WebURL& url, |
236 CORSMode cors_mode); | 245 CORSMode cors_mode); |
237 | 246 |
238 // Called after asynchronous initialization of a data source completed. | 247 // Called after asynchronous initialization of a data source completed. |
239 void DataSourceInitialized(bool success); | 248 void DataSourceInitialized(bool success); |
240 | 249 |
241 // Called when the data source is downloading or paused. | 250 // Called when the data source is downloading or paused. |
242 void NotifyDownloading(bool is_downloading); | 251 void NotifyDownloading(bool is_downloading); |
243 | 252 |
253 void OnSurfaceRequested(const SurfaceCreatedCB& surface_created_cb); | |
liberato (no reviews please)
2016/02/05 22:09:46
probably want to #if android this, since the defin
| |
254 | |
244 // Creates a Renderer via the |renderer_factory_|. | 255 // Creates a Renderer via the |renderer_factory_|. |
245 scoped_ptr<Renderer> CreateRenderer(); | 256 scoped_ptr<Renderer> CreateRenderer(); |
246 | 257 |
247 // Finishes starting the pipeline due to a call to load(). | 258 // Finishes starting the pipeline due to a call to load(). |
248 void StartPipeline(); | 259 void StartPipeline(); |
249 | 260 |
250 // Helpers that set the network/ready state and notifies the client if | 261 // Helpers that set the network/ready state and notifies the client if |
251 // they've changed. | 262 // they've changed. |
252 void SetNetworkState(blink::WebMediaPlayer::NetworkState state); | 263 void SetNetworkState(blink::WebMediaPlayer::NetworkState state); |
253 void SetReadyState(blink::WebMediaPlayer::ReadyState state); | 264 void SetReadyState(blink::WebMediaPlayer::ReadyState state); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
362 | 373 |
363 // Set for the entire period between suspend starting and resume completing. | 374 // Set for the entire period between suspend starting and resume completing. |
364 bool suspending_; | 375 bool suspending_; |
365 | 376 |
366 // Set while suspending to detect double-suspend. | 377 // Set while suspending to detect double-suspend. |
367 bool suspended_; | 378 bool suspended_; |
368 | 379 |
369 // Set while resuming to detect double-resume. | 380 // Set while resuming to detect double-resume. |
370 bool resuming_; | 381 bool resuming_; |
371 | 382 |
383 // Set when doing both a suspend and resume in sequence in order to restart | |
384 // the pipeline, and specifically the decoders. | |
385 bool pending_suspend_resume_cycle_; | |
386 | |
372 // TODO(scherkus): Replace with an explicit ended signal to HTMLMediaElement, | 387 // TODO(scherkus): Replace with an explicit ended signal to HTMLMediaElement, |
373 // see http://crbug.com/409280 | 388 // see http://crbug.com/409280 |
374 bool ended_; | 389 bool ended_; |
375 | 390 |
376 // Indicates that a seek is queued after the current seek completes or, if the | 391 // Indicates that a seek is queued after the current seek completes or, if the |
377 // pipeline is suspended, after it resumes. Only the last queued seek will | 392 // pipeline is suspended, after it resumes. Only the last queued seek will |
378 // have any effect. | 393 // have any effect. |
379 bool pending_seek_; | 394 bool pending_seek_; |
380 | 395 |
381 // |pending_seek_time_| is meaningless when |pending_seek_| is false. | 396 // |pending_seek_time_| is meaningless when |pending_seek_| is false. |
382 base::TimeDelta pending_seek_time_; | 397 base::TimeDelta pending_seek_time_; |
383 | 398 |
384 // Tracks whether to issue time changed notifications during buffering state | 399 // Tracks whether to issue time changed notifications during buffering state |
385 // changes. | 400 // changes. |
386 bool should_notify_time_changed_; | 401 bool should_notify_time_changed_; |
387 | 402 |
403 bool fullscreen_; | |
404 | |
405 // Whether the current decoder requires a restart on fullscreen transitions. | |
406 bool decoder_requires_restart_for_fullscreen_; | |
407 | |
388 blink::WebMediaPlayerClient* client_; | 408 blink::WebMediaPlayerClient* client_; |
389 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client_; | 409 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client_; |
390 | 410 |
391 // WebMediaPlayer notifies the |delegate_| of playback state changes using | 411 // WebMediaPlayer notifies the |delegate_| of playback state changes using |
392 // |delegate_id_|; an id provided after registering with the delegate. The | 412 // |delegate_id_|; an id provided after registering with the delegate. The |
393 // WebMediaPlayer may also receive directives (play, pause) from the delegate | 413 // WebMediaPlayer may also receive directives (play, pause) from the delegate |
394 // via the WebMediaPlayerDelegate::Observer interface after registration. | 414 // via the WebMediaPlayerDelegate::Observer interface after registration. |
395 base::WeakPtr<WebMediaPlayerDelegate> delegate_; | 415 base::WeakPtr<WebMediaPlayerDelegate> delegate_; |
396 int delegate_id_; | 416 int delegate_id_; |
397 | 417 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
431 // playback. | 451 // playback. |
432 scoped_ptr<cc_blink::WebLayerImpl> video_weblayer_; | 452 scoped_ptr<cc_blink::WebLayerImpl> video_weblayer_; |
433 | 453 |
434 EncryptedMediaPlayerSupport encrypted_media_support_; | 454 EncryptedMediaPlayerSupport encrypted_media_support_; |
435 | 455 |
436 scoped_ptr<blink::WebContentDecryptionModuleResult> set_cdm_result_; | 456 scoped_ptr<blink::WebContentDecryptionModuleResult> set_cdm_result_; |
437 | 457 |
438 // Whether a CDM has been successfully attached. | 458 // Whether a CDM has been successfully attached. |
439 bool is_cdm_attached_; | 459 bool is_cdm_attached_; |
440 | 460 |
441 #if defined(OS_ANDROID) // WMPI_CAST | 461 #if defined(OS_ANDROID) |
462 // For requesting surfaces on behalf of the Android H/W decoder in fullscreen. | |
DaleCurtis
2016/02/06 00:17:39
Lets avoid the OS_ANDROID #define where possible a
watk
2016/02/11 23:03:25
Done.
| |
463 SurfaceManager* surface_manager_; | |
464 | |
465 // WMPI_CAST | |
442 WebMediaPlayerCast cast_impl_; | 466 WebMediaPlayerCast cast_impl_; |
443 #endif | 467 #endif |
444 | 468 |
445 // The last volume received by setVolume() and the last volume multiplier from | 469 // The last volume received by setVolume() and the last volume multiplier from |
446 // OnVolumeMultiplierUpdate(). The multiplier is typical 1.0, but may be less | 470 // OnVolumeMultiplierUpdate(). The multiplier is typical 1.0, but may be less |
447 // if the WebMediaPlayerDelegate has requested a volume reduction (ducking) | 471 // if the WebMediaPlayerDelegate has requested a volume reduction (ducking) |
448 // for a transient sound. Playout volume is derived by volume * multiplier. | 472 // for a transient sound. Playout volume is derived by volume * multiplier. |
449 double volume_; | 473 double volume_; |
450 double volume_multiplier_; | 474 double volume_multiplier_; |
451 | 475 |
452 scoped_ptr<RendererFactory> renderer_factory_; | 476 scoped_ptr<RendererFactory> renderer_factory_; |
453 | 477 |
454 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); | 478 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); |
455 }; | 479 }; |
456 | 480 |
457 } // namespace media | 481 } // namespace media |
458 | 482 |
459 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ | 483 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ |
OLD | NEW |