| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 class MEDIA_EXPORT AudioDecoder : public Filter { | 197 class MEDIA_EXPORT AudioDecoder : public Filter { |
| 198 public: | 198 public: |
| 199 // Initialize a AudioDecoder with the given DemuxerStream, executing the | 199 // Initialize a AudioDecoder with the given DemuxerStream, executing the |
| 200 // callback upon completion. | 200 // callback upon completion. |
| 201 // stats_callback is used to update global pipeline statistics. | 201 // stats_callback is used to update global pipeline statistics. |
| 202 // | 202 // |
| 203 // TODO(scherkus): switch to PipelineStatus callback. | 203 // TODO(scherkus): switch to PipelineStatus callback. |
| 204 virtual void Initialize(DemuxerStream* stream, const base::Closure& callback, | 204 virtual void Initialize(DemuxerStream* stream, const base::Closure& callback, |
| 205 const StatisticsCallback& stats_callback) = 0; | 205 const StatisticsCallback& stats_callback) = 0; |
| 206 | 206 |
| 207 // Renderer provides an output buffer for Decoder to write to. These buffers | 207 // Request samples to be decoded and returned via the provided callback. |
| 208 // will be recycled to renderer via the permanent callback. | 208 // Only one read may be in flight at any given time. |
| 209 // | 209 // |
| 210 // We could also pass empty pointer here to let decoder provide buffers pool. | 210 // Implementations guarantee that the callback will not be called from within |
| 211 virtual void ProduceAudioSamples(scoped_refptr<Buffer> buffer) = 0; | 211 // this method. |
| 212 | 212 // |
| 213 // Installs a permanent callback for passing decoded audio output. | 213 // Sample buffers will be non-NULL yet may be end of stream buffers. |
| 214 typedef base::Callback<void(scoped_refptr<Buffer>)> ConsumeAudioSamplesCB; | 214 typedef base::Callback<void(scoped_refptr<Buffer>)> ReadCB; |
| 215 void set_consume_audio_samples_callback( | 215 virtual void Read(const ReadCB& callback) = 0; |
| 216 const ConsumeAudioSamplesCB& callback) { | |
| 217 consume_audio_samples_callback_ = callback; | |
| 218 } | |
| 219 | 216 |
| 220 // Returns various information about the decoded audio format. | 217 // Returns various information about the decoded audio format. |
| 221 virtual int bits_per_channel() = 0; | 218 virtual int bits_per_channel() = 0; |
| 222 virtual ChannelLayout channel_layout() = 0; | 219 virtual ChannelLayout channel_layout() = 0; |
| 223 virtual int samples_per_second() = 0; | 220 virtual int samples_per_second() = 0; |
| 224 | 221 |
| 225 protected: | 222 protected: |
| 226 AudioDecoder(); | 223 AudioDecoder(); |
| 227 virtual ~AudioDecoder(); | 224 virtual ~AudioDecoder(); |
| 228 | |
| 229 // Executes the permanent callback to pass off decoded audio. | |
| 230 void ConsumeAudioSamples(scoped_refptr<Buffer> buffer); | |
| 231 | |
| 232 private: | |
| 233 ConsumeAudioSamplesCB consume_audio_samples_callback_; | |
| 234 }; | 225 }; |
| 235 | 226 |
| 236 | 227 |
| 237 class MEDIA_EXPORT VideoRenderer : public Filter { | 228 class MEDIA_EXPORT VideoRenderer : public Filter { |
| 238 public: | 229 public: |
| 239 // Initialize a VideoRenderer with the given VideoDecoder, executing the | 230 // Initialize a VideoRenderer with the given VideoDecoder, executing the |
| 240 // callback upon completion. | 231 // callback upon completion. |
| 241 virtual void Initialize(VideoDecoder* decoder, const base::Closure& callback, | 232 virtual void Initialize(VideoDecoder* decoder, const base::Closure& callback, |
| 242 const StatisticsCallback& stats_callback) = 0; | 233 const StatisticsCallback& stats_callback) = 0; |
| 243 | 234 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 268 | 259 |
| 269 // Resumes playback after underflow occurs. | 260 // Resumes playback after underflow occurs. |
| 270 // |buffer_more_audio| is set to true if you want to increase the size of the | 261 // |buffer_more_audio| is set to true if you want to increase the size of the |
| 271 // decoded audio buffer. | 262 // decoded audio buffer. |
| 272 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0; | 263 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0; |
| 273 }; | 264 }; |
| 274 | 265 |
| 275 } // namespace media | 266 } // namespace media |
| 276 | 267 |
| 277 #endif // MEDIA_BASE_FILTERS_H_ | 268 #endif // MEDIA_BASE_FILTERS_H_ |
| OLD | NEW |