| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Filters are connected in a strongly typed manner, with downstream filters | 5 // Filters are connected in a strongly typed manner, with downstream filters |
| 6 // always reading data from upstream filters. Upstream filters have no clue | 6 // always reading data from upstream filters. Upstream filters have no clue |
| 7 // who is actually reading from them, and return the results via callbacks. | 7 // who is actually reading from them, and return the results via callbacks. |
| 8 // | 8 // |
| 9 // DemuxerStream(Video) <- VideoDecoder <- VideoRenderer | 9 // DemuxerStream(Video) <- VideoDecoder <- VideoRenderer |
| 10 // DataSource <- Demuxer < | 10 // DataSource <- Demuxer < |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 class MEDIA_EXPORT AudioDecoder : public Filter { | 157 class MEDIA_EXPORT AudioDecoder : public Filter { |
| 158 public: | 158 public: |
| 159 // Initialize a AudioDecoder with the given DemuxerStream, executing the | 159 // Initialize a AudioDecoder with the given DemuxerStream, executing the |
| 160 // callback upon completion. | 160 // callback upon completion. |
| 161 // stats_callback is used to update global pipeline statistics. | 161 // stats_callback is used to update global pipeline statistics. |
| 162 // | 162 // |
| 163 // TODO(scherkus): switch to PipelineStatus callback. | 163 // TODO(scherkus): switch to PipelineStatus callback. |
| 164 virtual void Initialize(DemuxerStream* stream, const base::Closure& callback, | 164 virtual void Initialize(DemuxerStream* stream, const base::Closure& callback, |
| 165 const StatisticsCallback& stats_callback) = 0; | 165 const StatisticsCallback& stats_callback) = 0; |
| 166 | 166 |
| 167 // Renderer provides an output buffer for Decoder to write to. These buffers | 167 // Request samples to be decoded and returned via the provided callback. |
| 168 // will be recycled to renderer via the permanent callback. | 168 // Only one read may be in flight at any given time. |
| 169 // | 169 // |
| 170 // We could also pass empty pointer here to let decoder provide buffers pool. | 170 // Implementations guarantee that the callback will not be called from within |
| 171 virtual void ProduceAudioSamples(scoped_refptr<Buffer> buffer) = 0; | 171 // this method. |
| 172 | 172 // |
| 173 // Installs a permanent callback for passing decoded audio output. | 173 // Sample buffers will be non-NULL yet may be end of stream buffers. |
| 174 typedef base::Callback<void(scoped_refptr<Buffer>)> ConsumeAudioSamplesCB; | 174 typedef base::Callback<void(scoped_refptr<Buffer>)> ReadCB; |
| 175 void set_consume_audio_samples_callback( | 175 virtual void Read(const ReadCB& callback) = 0; |
| 176 const ConsumeAudioSamplesCB& callback) { | |
| 177 consume_audio_samples_callback_ = callback; | |
| 178 } | |
| 179 | 176 |
| 180 // Returns various information about the decoded audio format. | 177 // Returns various information about the decoded audio format. |
| 181 virtual int bits_per_channel() = 0; | 178 virtual int bits_per_channel() = 0; |
| 182 virtual ChannelLayout channel_layout() = 0; | 179 virtual ChannelLayout channel_layout() = 0; |
| 183 virtual int samples_per_second() = 0; | 180 virtual int samples_per_second() = 0; |
| 184 | 181 |
| 185 protected: | 182 protected: |
| 186 AudioDecoder(); | 183 AudioDecoder(); |
| 187 virtual ~AudioDecoder(); | 184 virtual ~AudioDecoder(); |
| 188 | |
| 189 // Executes the permanent callback to pass off decoded audio. | |
| 190 void ConsumeAudioSamples(scoped_refptr<Buffer> buffer); | |
| 191 | |
| 192 private: | |
| 193 ConsumeAudioSamplesCB consume_audio_samples_callback_; | |
| 194 }; | 185 }; |
| 195 | 186 |
| 196 | 187 |
| 197 class MEDIA_EXPORT VideoRenderer : public Filter { | 188 class MEDIA_EXPORT VideoRenderer : public Filter { |
| 198 public: | 189 public: |
| 199 // Initialize a VideoRenderer with the given VideoDecoder, executing the | 190 // Initialize a VideoRenderer with the given VideoDecoder, executing the |
| 200 // callback upon completion. | 191 // callback upon completion. |
| 201 virtual void Initialize(VideoDecoder* decoder, const base::Closure& callback, | 192 virtual void Initialize(VideoDecoder* decoder, const base::Closure& callback, |
| 202 const StatisticsCallback& stats_callback) = 0; | 193 const StatisticsCallback& stats_callback) = 0; |
| 203 | 194 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 228 | 219 |
| 229 // Resumes playback after underflow occurs. | 220 // Resumes playback after underflow occurs. |
| 230 // |buffer_more_audio| is set to true if you want to increase the size of the | 221 // |buffer_more_audio| is set to true if you want to increase the size of the |
| 231 // decoded audio buffer. | 222 // decoded audio buffer. |
| 232 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0; | 223 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0; |
| 233 }; | 224 }; |
| 234 | 225 |
| 235 } // namespace media | 226 } // namespace media |
| 236 | 227 |
| 237 #endif // MEDIA_BASE_FILTERS_H_ | 228 #endif // MEDIA_BASE_FILTERS_H_ |
| OLD | NEW |