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_BASE_AUDIO_PIPELINE_IMPL_H_ | 5 #ifndef CHROMECAST_MEDIA_CMA_BASE_AUDIO_PIPELINE_IMPL_H_ |
6 #define CHROMECAST_MEDIA_CMA_BASE_AUDIO_PIPELINE_IMPL_H_ | 6 #define CHROMECAST_MEDIA_CMA_BASE_AUDIO_PIPELINE_IMPL_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.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/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
13 #include "chromecast/media/cma/pipeline/audio_pipeline.h" | 13 #include "chromecast/media/cma/pipeline/audio_pipeline.h" |
14 #include "chromecast/media/cma/pipeline/av_pipeline_client.h" | 14 #include "chromecast/media/cma/pipeline/av_pipeline_client.h" |
| 15 #include "chromecast/public/media/media_pipeline_backend.h" |
15 #include "chromecast/public/media/stream_id.h" | 16 #include "chromecast/public/media/stream_id.h" |
16 | 17 |
17 namespace media { | 18 namespace media { |
18 class AudioDecoderConfig; | 19 class AudioDecoderConfig; |
19 class VideoDecoderConfig; | 20 class VideoDecoderConfig; |
20 } | 21 } |
21 | 22 |
22 namespace chromecast { | 23 namespace chromecast { |
23 namespace media { | 24 namespace media { |
24 class AudioPipelineDevice; | |
25 class AvPipelineImpl; | 25 class AvPipelineImpl; |
26 class BrowserCdmCast; | 26 class BrowserCdmCast; |
27 class BufferingState; | 27 class BufferingState; |
28 class CodedFrameProvider; | 28 class CodedFrameProvider; |
29 | 29 |
30 class AudioPipelineImpl : public AudioPipeline { | 30 class AudioPipelineImpl { |
31 public: | 31 public: |
32 // |buffering_controller| can be NULL. | 32 AudioPipelineImpl(MediaPipelineBackend::AudioDecoder* decoder, |
33 explicit AudioPipelineImpl(AudioPipelineDevice* audio_device); | 33 const BrowserAvPipelineClient& client); |
34 ~AudioPipelineImpl() override; | 34 ~AudioPipelineImpl(); |
35 | 35 |
36 // Input port of the pipeline. | 36 // Input port of the pipeline. |
37 void SetCodedFrameProvider(scoped_ptr<CodedFrameProvider> frame_provider); | 37 void SetCodedFrameProvider(scoped_ptr<CodedFrameProvider> frame_provider); |
38 | 38 |
39 // Provide the CDM to use to decrypt samples. | 39 // Provide the CDM to use to decrypt samples. |
40 void SetCdm(BrowserCdmCast* media_keys); | 40 void SetCdm(BrowserCdmCast* media_keys); |
41 | 41 |
42 // Functions to control the state of the audio pipeline. | 42 // Functions to control the state of the audio pipeline. |
43 void Initialize( | 43 void Initialize( |
44 const ::media::AudioDecoderConfig& config, | 44 const ::media::AudioDecoderConfig& config, |
45 scoped_ptr<CodedFrameProvider> frame_provider, | 45 scoped_ptr<CodedFrameProvider> frame_provider, |
46 const ::media::PipelineStatusCB& status_cb); | 46 const ::media::PipelineStatusCB& status_cb); |
47 bool StartPlayingFrom(base::TimeDelta time, | 47 bool StartPlayingFrom(base::TimeDelta time, |
48 const scoped_refptr<BufferingState>& buffering_state); | 48 const scoped_refptr<BufferingState>& buffering_state); |
49 void Flush(const ::media::PipelineStatusCB& status_cb); | 49 void Flush(const ::media::PipelineStatusCB& status_cb); |
50 void Stop(); | 50 void Stop(); |
51 | 51 |
52 // Update the playback statistics for this audio stream. | 52 // Update the playback statistics for this audio stream. |
53 void UpdateStatistics(); | 53 void UpdateStatistics(); |
54 | 54 |
55 // AudioPipeline implementation. | 55 void SetVolume(float volume); |
56 void SetClient(const AvPipelineClient& client) override; | 56 |
57 void SetVolume(float volume) override; | 57 void OnBufferPushed(MediaPipelineBackend::BufferStatus status); |
| 58 void OnEndOfStream(); |
| 59 void OnError(); |
58 | 60 |
59 private: | 61 private: |
60 void OnFlushDone(const ::media::PipelineStatusCB& status_cb); | 62 void OnFlushDone(const ::media::PipelineStatusCB& status_cb); |
61 void OnUpdateConfig(StreamId id, | 63 void OnUpdateConfig(StreamId id, |
62 const ::media::AudioDecoderConfig& audio_config, | 64 const ::media::AudioDecoderConfig& audio_config, |
63 const ::media::VideoDecoderConfig& video_config); | 65 const ::media::VideoDecoderConfig& video_config); |
64 | 66 |
65 AudioPipelineDevice* audio_device_; | 67 MediaPipelineBackend::AudioDecoder* decoder_; |
66 | 68 |
67 scoped_ptr<AvPipelineImpl> av_pipeline_impl_; | 69 scoped_ptr<AvPipelineImpl> av_pipeline_impl_; |
68 AvPipelineClient audio_client_; | 70 BrowserAvPipelineClient audio_client_; |
69 | 71 |
70 ::media::PipelineStatistics previous_stats_; | 72 ::media::PipelineStatistics previous_stats_; |
71 | 73 |
72 base::WeakPtr<AudioPipelineImpl> weak_this_; | 74 base::WeakPtr<AudioPipelineImpl> weak_this_; |
73 base::WeakPtrFactory<AudioPipelineImpl> weak_factory_; | 75 base::WeakPtrFactory<AudioPipelineImpl> weak_factory_; |
74 | 76 |
75 DISALLOW_COPY_AND_ASSIGN(AudioPipelineImpl); | 77 DISALLOW_COPY_AND_ASSIGN(AudioPipelineImpl); |
76 }; | 78 }; |
77 | 79 |
78 } // namespace media | 80 } // namespace media |
79 } // namespace chromecast | 81 } // namespace chromecast |
80 | 82 |
81 #endif // CHROMECAST_MEDIA_CMA_BASE_AUDIO_PIPELINE_IMPL_H_ | 83 #endif // CHROMECAST_MEDIA_CMA_BASE_AUDIO_PIPELINE_IMPL_H_ |
OLD | NEW |