| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CHROMECAST_MEDIA_CMA_PIPELINE_MEDIA_PIPELINE_IMPL_H_ | 5 #ifndef CHROMECAST_MEDIA_CMA_PIPELINE_MEDIA_PIPELINE_IMPL_H_ |
| 6 #define CHROMECAST_MEDIA_CMA_PIPELINE_MEDIA_PIPELINE_IMPL_H_ | 6 #define CHROMECAST_MEDIA_CMA_PIPELINE_MEDIA_PIPELINE_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
| 14 #include "chromecast/media/cma/pipeline/load_type.h" | 14 #include "chromecast/media/cma/pipeline/load_type.h" |
| 15 #include "chromecast/media/cma/pipeline/media_pipeline.h" | 15 #include "chromecast/media/cma/pipeline/media_pipeline.h" |
| 16 #include "chromecast/media/cma/pipeline/media_pipeline_client.h" | 16 #include "chromecast/media/cma/pipeline/media_pipeline_client.h" |
| 17 #include "chromecast/public/media/media_pipeline_backend.h" |
| 17 #include "media/base/serial_runner.h" | 18 #include "media/base/serial_runner.h" |
| 18 | 19 |
| 19 namespace chromecast { | 20 namespace chromecast { |
| 20 namespace media { | 21 namespace media { |
| 22 |
| 21 class AudioPipelineImpl; | 23 class AudioPipelineImpl; |
| 24 struct BrowserAvPipelineClient; |
| 25 struct BrowserVideoPipelineClient; |
| 22 class BrowserCdmCast; | 26 class BrowserCdmCast; |
| 23 class BufferingController; | 27 class BufferingController; |
| 24 class MediaClockDevice; | |
| 25 class MediaPipelineBackend; | |
| 26 class VideoPipelineImpl; | 28 class VideoPipelineImpl; |
| 27 | 29 |
| 28 class MediaPipelineImpl : public MediaPipeline { | 30 class MediaPipelineImpl : public MediaPipelineBackend::Delegate { |
| 29 public: | 31 public: |
| 30 MediaPipelineImpl(); | 32 MediaPipelineImpl(); |
| 31 ~MediaPipelineImpl() override; | 33 ~MediaPipelineImpl() override; |
| 32 | 34 |
| 33 // Initialize the media pipeline: the pipeline is configured based on | 35 // Initialize the media pipeline: the pipeline is configured based on |
| 34 // |load_type|. | 36 // |load_type|. |
| 35 void Initialize(LoadType load_type, | 37 void Initialize(LoadType load_type, |
| 36 scoped_ptr<MediaPipelineBackend> media_pipeline_backend); | 38 scoped_ptr<MediaPipelineBackend> media_pipeline_backend); |
| 37 | 39 |
| 38 // MediaPipeline implementation. | 40 void SetClient(const BrowserMediaPipelineClient& client); |
| 39 void SetClient(const MediaPipelineClient& client) override; | 41 void SetCdm(int cdm_id); |
| 40 void SetCdm(int cdm_id) override; | |
| 41 AudioPipeline* GetAudioPipeline() const override; | |
| 42 VideoPipeline* GetVideoPipeline() const override; | |
| 43 void InitializeAudio( | |
| 44 const ::media::AudioDecoderConfig& config, | |
| 45 scoped_ptr<CodedFrameProvider> frame_provider, | |
| 46 const ::media::PipelineStatusCB& status_cb) override; | |
| 47 void InitializeVideo( | |
| 48 const std::vector<::media::VideoDecoderConfig>& configs, | |
| 49 scoped_ptr<CodedFrameProvider> frame_provider, | |
| 50 const ::media::PipelineStatusCB& status_cb) override; | |
| 51 void StartPlayingFrom(base::TimeDelta time) override; | |
| 52 void Flush(const ::media::PipelineStatusCB& status_cb) override; | |
| 53 void Stop() override; | |
| 54 void SetPlaybackRate(double playback_rate) override; | |
| 55 | 42 |
| 56 AudioPipelineImpl* GetAudioPipelineImpl() const; | 43 // MediaPipelineBackendDelegate implementation: |
| 57 VideoPipelineImpl* GetVideoPipelineImpl() const; | 44 void OnVideoResolutionChanged(MediaPipelineBackend::Decoder* decoder, |
| 45 const Size& size) override; |
| 46 void OnPushBufferComplete(MediaPipelineBackend::Decoder* decoder, |
| 47 MediaPipelineBackend::BufferStatus status) override; |
| 48 void OnEndOfStream(MediaPipelineBackend::Decoder* decoder) override; |
| 49 void OnDecoderError(MediaPipelineBackend::Decoder* decoder) override; |
| 50 |
| 51 void InitializeAudio(const ::media::AudioDecoderConfig& config, |
| 52 const BrowserAvPipelineClient& client, |
| 53 scoped_ptr<CodedFrameProvider> frame_provider, |
| 54 const ::media::PipelineStatusCB& status_cb); |
| 55 void InitializeVideo(const std::vector< ::media::VideoDecoderConfig>& configs, |
| 56 const BrowserVideoPipelineClient& client, |
| 57 scoped_ptr<CodedFrameProvider> frame_provider, |
| 58 const ::media::PipelineStatusCB& status_cb); |
| 59 void StartPlayingFrom(base::TimeDelta time); |
| 60 void Flush(const ::media::PipelineStatusCB& status_cb); |
| 61 void Stop(); |
| 62 void SetPlaybackRate(double playback_rate); |
| 63 void SetVolume(float volume); |
| 58 | 64 |
| 59 void SetCdm(BrowserCdmCast* cdm); | 65 void SetCdm(BrowserCdmCast* cdm); |
| 60 | 66 |
| 61 private: | 67 private: |
| 62 void StateTransition(const ::media::PipelineStatusCB& status_cb, | 68 void StateTransition(const ::media::PipelineStatusCB& status_cb, |
| 63 ::media::PipelineStatus status); | 69 ::media::PipelineStatus status); |
| 64 | 70 |
| 65 // Invoked to notify about a change of buffering state. | 71 // Invoked to notify about a change of buffering state. |
| 66 void OnBufferingNotification(bool is_buffering); | 72 void OnBufferingNotification(bool is_buffering); |
| 67 | 73 |
| 68 void UpdateMediaTime(); | 74 void UpdateMediaTime(); |
| 69 | 75 |
| 70 void OnError(::media::PipelineStatus error); | 76 void OnError(::media::PipelineStatus error); |
| 71 | 77 |
| 72 base::ThreadChecker thread_checker_; | 78 base::ThreadChecker thread_checker_; |
| 73 | 79 |
| 74 MediaPipelineClient client_; | 80 BrowserMediaPipelineClient client_; |
| 75 | 81 |
| 76 scoped_ptr<BufferingController> buffering_controller_; | 82 scoped_ptr<BufferingController> buffering_controller_; |
| 77 | 83 |
| 78 // Interface with the underlying hardware media pipeline. | 84 // Interface with the underlying hardware media pipeline. |
| 79 scoped_ptr<MediaPipelineBackend> media_pipeline_backend_; | 85 scoped_ptr<MediaPipelineBackend> media_pipeline_backend_; |
| 80 MediaClockDevice* clock_device_; | 86 MediaPipelineBackend::AudioDecoder* audio_decoder_; |
| 87 MediaPipelineBackend::VideoDecoder* video_decoder_; |
| 81 | 88 |
| 89 bool backend_initialized_; |
| 82 bool has_audio_; | 90 bool has_audio_; |
| 83 bool has_video_; | 91 bool has_video_; |
| 84 scoped_ptr<AudioPipelineImpl> audio_pipeline_; | 92 scoped_ptr<AudioPipelineImpl> audio_pipeline_; |
| 85 scoped_ptr<VideoPipelineImpl> video_pipeline_; | 93 scoped_ptr<VideoPipelineImpl> video_pipeline_; |
| 86 scoped_ptr< ::media::SerialRunner> pending_flush_callbacks_; | 94 scoped_ptr< ::media::SerialRunner> pending_flush_callbacks_; |
| 87 | 95 |
| 96 // Whether or not the backend is currently paused. |
| 97 bool paused_; |
| 88 // Playback rate set by the upper layer. | 98 // Playback rate set by the upper layer. |
| 89 float target_playback_rate_; | 99 float target_playback_rate_; |
| 90 | 100 |
| 91 // Indicate a possible re-buffering phase. | |
| 92 bool is_buffering_; | |
| 93 | |
| 94 // The media time is retrieved at regular intervals. | 101 // The media time is retrieved at regular intervals. |
| 95 // Indicate whether time update is enabled. | 102 // Indicate whether time update is enabled. |
| 96 bool enable_time_update_; | 103 bool enable_time_update_; |
| 97 bool pending_time_update_task_; | 104 bool pending_time_update_task_; |
| 98 base::TimeDelta last_media_time_; | 105 base::TimeDelta last_media_time_; |
| 99 | 106 |
| 100 // Used to make the statistics update period a multiplier of the time update | 107 // Used to make the statistics update period a multiplier of the time update |
| 101 // period. | 108 // period. |
| 102 int statistics_rolling_counter_; | 109 int statistics_rolling_counter_; |
| 103 | 110 |
| 104 base::WeakPtr<MediaPipelineImpl> weak_this_; | 111 base::WeakPtr<MediaPipelineImpl> weak_this_; |
| 105 base::WeakPtrFactory<MediaPipelineImpl> weak_factory_; | 112 base::WeakPtrFactory<MediaPipelineImpl> weak_factory_; |
| 106 | 113 |
| 107 DISALLOW_COPY_AND_ASSIGN(MediaPipelineImpl); | 114 DISALLOW_COPY_AND_ASSIGN(MediaPipelineImpl); |
| 108 }; | 115 }; |
| 109 | 116 |
| 110 } // namespace media | 117 } // namespace media |
| 111 } // namespace chromecast | 118 } // namespace chromecast |
| 112 | 119 |
| 113 #endif // CHROMECAST_MEDIA_CMA_PIPELINE_MEDIA_PIPELINE_IMPL_H_ | 120 #endif // CHROMECAST_MEDIA_CMA_PIPELINE_MEDIA_PIPELINE_IMPL_H_ |
| OLD | NEW |