Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: media/filters/audio_renderer_impl.h

Issue 11492003: Encrypted Media: Support Audio Decrypt-Only. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments resolved Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 AudioRendererImpl(AudioRendererSink* sink,
48 const SetDecryptorReadyCB& set_decryptor_ready_cb);
scherkus (not reviewing) 2012/12/14 06:39:12 it's a bit unfortunate to have to pass this in onl
xhwang 2012/12/14 07:45:06 I actually like this idea ;)
scherkus (not reviewing) 2012/12/14 19:43:45 ...actually I thought about this a bit more. If w
45 49
46 // Methods called on pipeline thread ---------------------------------------- 50 // Methods called on pipeline thread ----------------------------------------
47 // AudioRenderer implementation. 51 // AudioRenderer implementation.
48 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, 52 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream,
49 const AudioDecoderList& decoders, 53 const AudioDecoderList& decoders,
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,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
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| was also populated if a DecryptingDemuxerStream
143 void InitializeNextDecoder(const scoped_refptr<DemuxerStream>& demuxer_stream, 147 // created to help decrypt the encrypted stream.
144 scoped_ptr<AudioDecoderList> decoders); 148 // Note: |decoder_selector| is passed here to keep the AudioDecoderSelector
149 // alive 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 void ResetDecoder(const base::Closure& callback);
147 // |demuxer_stream| & |decoders| are used if initialization failed and
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
153 // Audio decoder.
154 scoped_refptr<AudioDecoder> decoder_;
155 156
156 scoped_ptr<AudioSplicer> splicer_; 157 scoped_ptr<AudioSplicer> splicer_;
157 158
158 // The sink (destination) for rendered audio. |sink_| must only be accessed 159 // The sink (destination) for rendered audio. |sink_| must only be accessed
159 // on the pipeline thread (verify with |pipeline_thread_checker_|). |sink_| 160 // 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 161 // must never be called under |lock_| or the 3-way thread bridge between the
161 // audio, pipeline, and decoder threads may deadlock. 162 // audio, pipeline, and decoder threads may deadlock.
162 scoped_refptr<media::AudioRendererSink> sink_; 163 scoped_refptr<media::AudioRendererSink> sink_;
163 164
165 SetDecryptorReadyCB set_decryptor_ready_cb_;
166
167 // These two will be set by AudioDecoderSelector::SelectAudioDecoder().
168 scoped_refptr<AudioDecoder> decoder_;
169 scoped_refptr<DecryptingDemuxerStream> decrypting_demuxer_stream_;
170
164 // Ensures certain methods are always called on the pipeline thread. 171 // Ensures certain methods are always called on the pipeline thread.
165 base::ThreadChecker pipeline_thread_checker_; 172 base::ThreadChecker pipeline_thread_checker_;
166 173
167 // AudioParameters constructed during Initialize() based on |decoder_|. 174 // AudioParameters constructed during Initialize() based on |decoder_|.
168 AudioParameters audio_parameters_; 175 AudioParameters audio_parameters_;
169 176
170 // Callbacks provided during Initialize(). 177 // Callbacks provided during Initialize().
171 PipelineStatusCB init_cb_; 178 PipelineStatusCB init_cb_;
172 StatisticsCB statistics_cb_; 179 StatisticsCB statistics_cb_;
173 base::Closure underflow_cb_; 180 base::Closure underflow_cb_;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 // Variables used only on the audio thread. --------------------------------- 249 // Variables used only on the audio thread. ---------------------------------
243 int actual_frames_per_buffer_; 250 int actual_frames_per_buffer_;
244 scoped_array<uint8> audio_buffer_; 251 scoped_array<uint8> audio_buffer_;
245 252
246 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); 253 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl);
247 }; 254 };
248 255
249 } // namespace media 256 } // namespace media
250 257
251 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ 258 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698