OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Audio rendering unit utilizing an AudioRendererSink to output data. | 5 // Audio rendering unit utilizing an AudioRendererSink to output data. |
6 // | 6 // |
7 // This class lives inside three threads during it's lifetime, namely: | 7 // This class lives inside three threads during it's lifetime, namely: |
8 // 1. Render thread. | 8 // 1. Render thread. |
9 // This object is created on the render thread. | 9 // This object is created on the render thread. |
10 // 2. Pipeline thread | 10 // 2. Pipeline thread |
(...skipping 11 matching lines...) Expand all Loading... | |
22 | 22 |
23 #include <deque> | 23 #include <deque> |
24 | 24 |
25 #include "base/gtest_prod_util.h" | 25 #include "base/gtest_prod_util.h" |
26 #include "base/synchronization/lock.h" | 26 #include "base/synchronization/lock.h" |
27 #include "base/threading/thread_checker.h" | 27 #include "base/threading/thread_checker.h" |
28 #include "media/base/audio_decoder.h" | 28 #include "media/base/audio_decoder.h" |
29 #include "media/base/audio_renderer.h" | 29 #include "media/base/audio_renderer.h" |
30 #include "media/base/audio_renderer_sink.h" | 30 #include "media/base/audio_renderer_sink.h" |
31 #include "media/base/buffers.h" | 31 #include "media/base/buffers.h" |
32 #include "media/base/decryptor.h" | |
32 #include "media/filters/audio_renderer_algorithm.h" | 33 #include "media/filters/audio_renderer_algorithm.h" |
33 | 34 |
34 namespace media { | 35 namespace media { |
35 | 36 |
37 class AudioDecoderSelector; | |
36 class AudioSplicer; | 38 class AudioSplicer; |
39 class DecryptingDemuxerStream; | |
37 | 40 |
38 class MEDIA_EXPORT AudioRendererImpl | 41 class MEDIA_EXPORT AudioRendererImpl |
39 : public AudioRenderer, | 42 : public AudioRenderer, |
40 NON_EXPORTED_BASE(public media::AudioRendererSink::RenderCallback) { | 43 NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) { |
41 public: | 44 public: |
42 // Methods called on Render thread ------------------------------------------ | 45 // Methods called on Render thread ------------------------------------------ |
43 // An AudioRendererSink is used as the destination for the rendered audio. | 46 // An AudioRendererSink is used as the destination for the rendered audio. |
44 explicit AudioRendererImpl(media::AudioRendererSink* sink); | 47 explicit AudioRendererImpl(AudioRendererSink* sink); |
45 | 48 |
46 // Methods called on pipeline thread ---------------------------------------- | 49 // Methods called on pipeline thread ---------------------------------------- |
47 // AudioRenderer implementation. | 50 // AudioRenderer implementation. |
48 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, | 51 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, |
49 const AudioDecoderList& decoders, | 52 const AudioDecoderList& decoders, |
53 const SetDecryptorReadyCB& set_decryptor_ready_cb, | |
50 const PipelineStatusCB& init_cb, | 54 const PipelineStatusCB& init_cb, |
51 const StatisticsCB& statistics_cb, | 55 const StatisticsCB& statistics_cb, |
52 const base::Closure& underflow_cb, | 56 const base::Closure& underflow_cb, |
53 const TimeCB& time_cb, | 57 const TimeCB& time_cb, |
54 const base::Closure& ended_cb, | 58 const base::Closure& ended_cb, |
55 const base::Closure& disabled_cb, | 59 const base::Closure& disabled_cb, |
56 const PipelineStatusCB& error_cb) OVERRIDE; | 60 const PipelineStatusCB& error_cb) OVERRIDE; |
57 virtual void Play(const base::Closure& callback) OVERRIDE; | 61 virtual void Play(const base::Closure& callback) OVERRIDE; |
58 virtual void Pause(const base::Closure& callback) OVERRIDE; | 62 virtual void Pause(const base::Closure& callback) OVERRIDE; |
59 virtual void Flush(const base::Closure& callback) OVERRIDE; | 63 virtual void Flush(const base::Closure& callback) OVERRIDE; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 // increments |pending_reads_|. | 135 // increments |pending_reads_|. |
132 // | 136 // |
133 // Safe to call from any thread. | 137 // Safe to call from any thread. |
134 void ScheduleRead_Locked(); | 138 void ScheduleRead_Locked(); |
135 | 139 |
136 // Returns true if the data in the buffer is all before | 140 // Returns true if the data in the buffer is all before |
137 // |preroll_timestamp_|. This can only return true while | 141 // |preroll_timestamp_|. This can only return true while |
138 // in the kPrerolling state. | 142 // in the kPrerolling state. |
139 bool IsBeforePrerollTime(const scoped_refptr<Buffer>& buffer); | 143 bool IsBeforePrerollTime(const scoped_refptr<Buffer>& buffer); |
140 | 144 |
141 // Pops the front of |decoders|, assigns it to |decoder_| and then | 145 // Called when |decoder_selector_| selected the |selected_decoder|. |
142 // calls initialize on the new decoder. | 146 // |decrypting_demuxer_stream| is also populated if a DecryptingDemuxerStream |
143 void InitializeNextDecoder(const scoped_refptr<DemuxerStream>& demuxer_stream, | 147 // created to help decrypt the encrypted stream. |
ddorwin
2012/12/13 05:08:25
is/was ...
xhwang
2012/12/13 11:24:36
Done.
| |
144 scoped_ptr<AudioDecoderList> decoders); | 148 // |decoder_selector| is passed here to keep the AudioDecoderSelector alive |
149 // until OnDecoderSelected() finishes. | |
150 void OnDecoderSelected( | |
151 scoped_ptr<AudioDecoderSelector> decoder_selector, | |
152 const scoped_refptr<AudioDecoder>& selected_decoder, | |
153 const scoped_refptr<DecryptingDemuxerStream>& decrypting_demuxer_stream); | |
145 | 154 |
146 // Called when |decoder_| initialization completes. | 155 // Called when |decrypting_demuxer_stream_| finishes Reset(). |
147 // |demuxer_stream| & |decoders| are used if initialization failed and | 156 void OnDecryptingDemuxerStreamReset(const base::Closure& callback); |
148 // InitializeNextDecoder() needs to be called again. | |
149 void OnDecoderInitDone(const scoped_refptr<DemuxerStream>& demuxer_stream, | |
150 scoped_ptr<AudioDecoderList> decoders, | |
151 PipelineStatus status); | |
152 | 157 |
153 // Audio decoder. | 158 // These two will be set by AudioDecoderSelector::SelectAudioDecoder(). |
154 scoped_refptr<AudioDecoder> decoder_; | 159 scoped_refptr<AudioDecoder> decoder_; |
160 scoped_refptr<DecryptingDemuxerStream> decrypting_demuxer_stream_; | |
155 | 161 |
156 scoped_ptr<AudioSplicer> splicer_; | 162 scoped_ptr<AudioSplicer> splicer_; |
157 | 163 |
158 // The sink (destination) for rendered audio. |sink_| must only be accessed | 164 // The sink (destination) for rendered audio. |sink_| must only be accessed |
159 // on the pipeline thread (verify with |pipeline_thread_checker_|). |sink_| | 165 // on the pipeline thread (verify with |pipeline_thread_checker_|). |sink_| |
160 // must never be called under |lock_| or the 3-way thread bridge between the | 166 // must never be called under |lock_| or the 3-way thread bridge between the |
161 // audio, pipeline, and decoder threads may deadlock. | 167 // audio, pipeline, and decoder threads may deadlock. |
162 scoped_refptr<media::AudioRendererSink> sink_; | 168 scoped_refptr<media::AudioRendererSink> sink_; |
163 | 169 |
164 // Ensures certain methods are always called on the pipeline thread. | 170 // Ensures certain methods are always called on the pipeline thread. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 // Variables used only on the audio thread. --------------------------------- | 248 // Variables used only on the audio thread. --------------------------------- |
243 int actual_frames_per_buffer_; | 249 int actual_frames_per_buffer_; |
244 scoped_array<uint8> audio_buffer_; | 250 scoped_array<uint8> audio_buffer_; |
245 | 251 |
246 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); | 252 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); |
247 }; | 253 }; |
248 | 254 |
249 } // namespace media | 255 } // namespace media |
250 | 256 |
251 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ | 257 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ |
OLD | NEW |