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