ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chromecast / media / cma / pipeline / media_pipeline_impl.h
blobe474535f8fada586abd6c7eed7775449d7516e30
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.
5 #ifndef CHROMECAST_MEDIA_CMA_PIPELINE_MEDIA_PIPELINE_IMPL_H_
6 #define CHROMECAST_MEDIA_CMA_PIPELINE_MEDIA_PIPELINE_IMPL_H_
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"
19 namespace chromecast {
20 namespace media {
21 class AudioPipelineImpl;
22 class BufferingController;
23 class MediaClockDevice;
24 class MediaPipelineDevice;
25 class VideoPipelineImpl;
27 class MediaPipelineImpl : public MediaPipeline {
28 public:
29 MediaPipelineImpl();
30 ~MediaPipelineImpl() override;
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);
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;
55 AudioPipelineImpl* GetAudioPipelineImpl() const;
56 VideoPipelineImpl* GetVideoPipelineImpl() const;
58 void SetCdm(::media::BrowserCdm* cdm);
60 private:
61 void StateTransition(const ::media::PipelineStatusCB& status_cb,
62 ::media::PipelineStatus status);
64 // Invoked to notify about a change of buffering state.
65 void OnBufferingNotification(bool is_buffering);
67 void UpdateMediaTime();
69 void OnError(::media::PipelineStatus error);
71 base::ThreadChecker thread_checker_;
73 MediaPipelineClient client_;
75 scoped_ptr<BufferingController> buffering_controller_;
77 // Interface with the underlying hardware media pipeline.
78 scoped_ptr<MediaPipelineDevice> media_pipeline_device_;
79 MediaClockDevice* clock_device_;
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_;
87 // Playback rate set by the upper layer.
88 float target_playback_rate_;
90 // Indicate a possible re-buffering phase.
91 bool is_buffering_;
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_;
99 // Used to make the statistics update period a multiplier of the time update
100 // period.
101 int statistics_rolling_counter_;
103 base::WeakPtr<MediaPipelineImpl> weak_this_;
104 base::WeakPtrFactory<MediaPipelineImpl> weak_factory_;
106 DISALLOW_COPY_AND_ASSIGN(MediaPipelineImpl);
109 } // namespace media
110 } // namespace chromecast
112 #endif // CHROMECAST_MEDIA_CMA_PIPELINE_MEDIA_PIPELINE_IMPL_H_