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 <memory> |
10 #include <string> | 11 #include <string> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/linked_ptr.h" | 16 #include "base/memory/linked_ptr.h" |
16 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.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/media_tracks.h" | 21 #include "media/base/media_tracks.h" |
22 #include "media/base/pipeline_impl.h" | 22 #include "media/base/pipeline_impl.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/surface_manager.h" |
25 #include "media/base/text_track.h" | 25 #include "media/base/text_track.h" |
26 #include "media/blink/buffered_data_source.h" | 26 #include "media/blink/buffered_data_source.h" |
27 #include "media/blink/buffered_data_source_host_impl.h" | 27 #include "media/blink/buffered_data_source_host_impl.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 public NON_EXPORTED_BASE(WebMediaPlayerDelegate::Observer), | 83 public NON_EXPORTED_BASE(WebMediaPlayerDelegate::Observer), |
84 public base::SupportsWeakPtr<WebMediaPlayerImpl> { | 84 public base::SupportsWeakPtr<WebMediaPlayerImpl> { |
85 public: | 85 public: |
86 // Constructs a WebMediaPlayer implementation using Chromium's media stack. | 86 // Constructs a WebMediaPlayer implementation using Chromium's media stack. |
87 // |delegate| may be null. |renderer_factory| must not be null. | 87 // |delegate| may be null. |renderer_factory| must not be null. |
88 WebMediaPlayerImpl( | 88 WebMediaPlayerImpl( |
89 blink::WebLocalFrame* frame, | 89 blink::WebLocalFrame* frame, |
90 blink::WebMediaPlayerClient* client, | 90 blink::WebMediaPlayerClient* client, |
91 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, | 91 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, |
92 base::WeakPtr<WebMediaPlayerDelegate> delegate, | 92 base::WeakPtr<WebMediaPlayerDelegate> delegate, |
93 scoped_ptr<RendererFactory> renderer_factory, | 93 std::unique_ptr<RendererFactory> renderer_factory, |
94 linked_ptr<UrlIndex> url_index, | 94 linked_ptr<UrlIndex> url_index, |
95 const WebMediaPlayerParams& params); | 95 const WebMediaPlayerParams& params); |
96 ~WebMediaPlayerImpl() override; | 96 ~WebMediaPlayerImpl() override; |
97 | 97 |
98 void load(LoadType load_type, | 98 void load(LoadType load_type, |
99 const blink::WebMediaPlayerSource& source, | 99 const blink::WebMediaPlayerSource& source, |
100 CORSMode cors_mode) override; | 100 CORSMode cors_mode) override; |
101 | 101 |
102 // Playback controls. | 102 // Playback controls. |
103 void play() override; | 103 void play() override; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 | 246 |
247 // Called after asynchronous initialization of a data source completed. | 247 // Called after asynchronous initialization of a data source completed. |
248 void DataSourceInitialized(bool success); | 248 void DataSourceInitialized(bool success); |
249 | 249 |
250 // Called when the data source is downloading or paused. | 250 // Called when the data source is downloading or paused. |
251 void NotifyDownloading(bool is_downloading); | 251 void NotifyDownloading(bool is_downloading); |
252 | 252 |
253 void OnSurfaceRequested(const SurfaceCreatedCB& surface_created_cb); | 253 void OnSurfaceRequested(const SurfaceCreatedCB& surface_created_cb); |
254 | 254 |
255 // Creates a Renderer via the |renderer_factory_|. | 255 // Creates a Renderer via the |renderer_factory_|. |
256 scoped_ptr<Renderer> CreateRenderer(); | 256 std::unique_ptr<Renderer> CreateRenderer(); |
257 | 257 |
258 // Finishes starting the pipeline due to a call to load(). | 258 // Finishes starting the pipeline due to a call to load(). |
259 void StartPipeline(); | 259 void StartPipeline(); |
260 | 260 |
261 // 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 |
262 // they've changed. | 262 // they've changed. |
263 void SetNetworkState(blink::WebMediaPlayer::NetworkState state); | 263 void SetNetworkState(blink::WebMediaPlayer::NetworkState state); |
264 void SetReadyState(blink::WebMediaPlayer::ReadyState state); | 264 void SetReadyState(blink::WebMediaPlayer::ReadyState state); |
265 | 265 |
266 // Gets the duration value reported by the pipeline. | 266 // Gets the duration value reported by the pipeline. |
(...skipping 12 matching lines...) Expand all Loading... |
279 // compositor can return the frame. | 279 // compositor can return the frame. |
280 scoped_refptr<VideoFrame> GetCurrentFrameFromCompositor(); | 280 scoped_refptr<VideoFrame> GetCurrentFrameFromCompositor(); |
281 | 281 |
282 // Called when the demuxer encounters encrypted streams. | 282 // Called when the demuxer encounters encrypted streams. |
283 void OnEncryptedMediaInitData(EmeInitDataType init_data_type, | 283 void OnEncryptedMediaInitData(EmeInitDataType init_data_type, |
284 const std::vector<uint8_t>& init_data); | 284 const std::vector<uint8_t>& init_data); |
285 | 285 |
286 // Called when the FFmpegDemuxer encounters new media tracks. This is only | 286 // Called when the FFmpegDemuxer encounters new media tracks. This is only |
287 // invoked when using FFmpegDemuxer, since MSE/ChunkDemuxer handle media | 287 // invoked when using FFmpegDemuxer, since MSE/ChunkDemuxer handle media |
288 // tracks separately in WebSourceBufferImpl. | 288 // tracks separately in WebSourceBufferImpl. |
289 void OnFFmpegMediaTracksUpdated(scoped_ptr<MediaTracks> tracks); | 289 void OnFFmpegMediaTracksUpdated(std::unique_ptr<MediaTracks> tracks); |
290 | 290 |
291 // Called when a decoder detects that the key needed to decrypt the stream | 291 // Called when a decoder detects that the key needed to decrypt the stream |
292 // is not available. | 292 // is not available. |
293 void OnWaitingForDecryptionKey(); | 293 void OnWaitingForDecryptionKey(); |
294 | 294 |
295 // Sets |cdm_context| on the pipeline and fires |cdm_attached_cb| when done. | 295 // Sets |cdm_context| on the pipeline and fires |cdm_attached_cb| when done. |
296 // Parameter order is reversed for easy binding. | 296 // Parameter order is reversed for easy binding. |
297 void SetCdm(const CdmAttachedCB& cdm_attached_cb, CdmContext* cdm_context); | 297 void SetCdm(const CdmAttachedCB& cdm_attached_cb, CdmContext* cdm_context); |
298 | 298 |
299 // Called when a CDM has been attached to the |pipeline_|. | 299 // Called when a CDM has been attached to the |pipeline_|. |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 scoped_refptr<WebAudioSourceProviderImpl> audio_source_provider_; | 440 scoped_refptr<WebAudioSourceProviderImpl> audio_source_provider_; |
441 | 441 |
442 bool supports_save_; | 442 bool supports_save_; |
443 | 443 |
444 // These two are mutually exclusive: | 444 // These two are mutually exclusive: |
445 // |data_source_| is used for regular resource loads. | 445 // |data_source_| is used for regular resource loads. |
446 // |chunk_demuxer_| is used for Media Source resource loads. | 446 // |chunk_demuxer_| is used for Media Source resource loads. |
447 // | 447 // |
448 // |demuxer_| will contain the appropriate demuxer based on which resource | 448 // |demuxer_| will contain the appropriate demuxer based on which resource |
449 // load strategy we're using. | 449 // load strategy we're using. |
450 scoped_ptr<BufferedDataSourceInterface> data_source_; | 450 std::unique_ptr<BufferedDataSourceInterface> data_source_; |
451 scoped_ptr<Demuxer> demuxer_; | 451 std::unique_ptr<Demuxer> demuxer_; |
452 ChunkDemuxer* chunk_demuxer_; | 452 ChunkDemuxer* chunk_demuxer_; |
453 | 453 |
454 BufferedDataSourceHostImpl buffered_data_source_host_; | 454 BufferedDataSourceHostImpl buffered_data_source_host_; |
455 linked_ptr<UrlIndex> url_index_; | 455 linked_ptr<UrlIndex> url_index_; |
456 | 456 |
457 // Video rendering members. | 457 // Video rendering members. |
458 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; | 458 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; |
459 VideoFrameCompositor* compositor_; // Deleted on |compositor_task_runner_|. | 459 VideoFrameCompositor* compositor_; // Deleted on |compositor_task_runner_|. |
460 SkCanvasVideoRenderer skcanvas_video_renderer_; | 460 SkCanvasVideoRenderer skcanvas_video_renderer_; |
461 | 461 |
462 // The compositor layer for displaying the video content when using composited | 462 // The compositor layer for displaying the video content when using composited |
463 // playback. | 463 // playback. |
464 scoped_ptr<cc_blink::WebLayerImpl> video_weblayer_; | 464 std::unique_ptr<cc_blink::WebLayerImpl> video_weblayer_; |
465 | 465 |
466 scoped_ptr<blink::WebContentDecryptionModuleResult> set_cdm_result_; | 466 std::unique_ptr<blink::WebContentDecryptionModuleResult> set_cdm_result_; |
467 | 467 |
468 // Whether a CDM has been successfully attached. | 468 // Whether a CDM has been successfully attached. |
469 bool is_cdm_attached_; | 469 bool is_cdm_attached_; |
470 | 470 |
471 #if defined(OS_ANDROID) // WMPI_CAST | 471 #if defined(OS_ANDROID) // WMPI_CAST |
472 WebMediaPlayerCast cast_impl_; | 472 WebMediaPlayerCast cast_impl_; |
473 #endif | 473 #endif |
474 | 474 |
475 // The last volume received by setVolume() and the last volume multiplier from | 475 // The last volume received by setVolume() and the last volume multiplier from |
476 // OnVolumeMultiplierUpdate(). The multiplier is typical 1.0, but may be less | 476 // OnVolumeMultiplierUpdate(). The multiplier is typical 1.0, but may be less |
477 // if the WebMediaPlayerDelegate has requested a volume reduction (ducking) | 477 // if the WebMediaPlayerDelegate has requested a volume reduction (ducking) |
478 // for a transient sound. Playout volume is derived by volume * multiplier. | 478 // for a transient sound. Playout volume is derived by volume * multiplier. |
479 double volume_; | 479 double volume_; |
480 double volume_multiplier_; | 480 double volume_multiplier_; |
481 | 481 |
482 scoped_ptr<RendererFactory> renderer_factory_; | 482 std::unique_ptr<RendererFactory> renderer_factory_; |
483 | 483 |
484 // For requesting surfaces on behalf of the Android H/W decoder in fullscreen. | 484 // For requesting surfaces on behalf of the Android H/W decoder in fullscreen. |
485 // This will be null everywhere but Android. | 485 // This will be null everywhere but Android. |
486 SurfaceManager* surface_manager_; | 486 SurfaceManager* surface_manager_; |
487 | 487 |
488 // Suppresses calls to OnPipelineError() after destruction / shutdown has been | 488 // Suppresses calls to OnPipelineError() after destruction / shutdown has been |
489 // started; prevents us from spuriously logging errors that are transient or | 489 // started; prevents us from spuriously logging errors that are transient or |
490 // unimportant. | 490 // unimportant. |
491 bool suppress_destruction_errors_; | 491 bool suppress_destruction_errors_; |
492 | 492 |
493 // State indicating if it's okay to suspend or not. Updated on the first time | 493 // State indicating if it's okay to suspend or not. Updated on the first time |
494 // OnSuspendRequested() is called. If the state is UNKNOWN, the current frame | 494 // OnSuspendRequested() is called. If the state is UNKNOWN, the current frame |
495 // from the compositor will be queried to see if suspend is supported; the | 495 // from the compositor will be queried to see if suspend is supported; the |
496 // state will be set to YES or NO respectively if a frame is available. | 496 // state will be set to YES or NO respectively if a frame is available. |
497 enum class CanSuspendState { UNKNOWN, YES, NO }; | 497 enum class CanSuspendState { UNKNOWN, YES, NO }; |
498 CanSuspendState can_suspend_state_; | 498 CanSuspendState can_suspend_state_; |
499 | 499 |
500 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); | 500 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); |
501 }; | 501 }; |
502 | 502 |
503 } // namespace media | 503 } // namespace media |
504 | 504 |
505 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ | 505 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ |
OLD | NEW |