summaryrefslogtreecommitdiffstats
path: root/chromium/media/base/audio_decoder.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/media/base/audio_decoder.h')
-rw-r--r--chromium/media/base/audio_decoder.h67
1 files changed, 43 insertions, 24 deletions
diff --git a/chromium/media/base/audio_decoder.h b/chromium/media/base/audio_decoder.h
index aa2eeb80ea8..0118b5e4fdd 100644
--- a/chromium/media/base/audio_decoder.h
+++ b/chromium/media/base/audio_decoder.h
@@ -7,9 +7,11 @@
#include "base/callback.h"
#include "base/memory/ref_counted.h"
+#include "media/base/audio_decoder_config.h"
#include "media/base/channel_layout.h"
-#include "media/base/pipeline_status.h"
+#include "media/base/decoder_buffer.h"
#include "media/base/media_export.h"
+#include "media/base/pipeline_status.h"
namespace media {
@@ -18,44 +20,61 @@ class DemuxerStream;
class MEDIA_EXPORT AudioDecoder {
public:
- // Status codes for read operations.
+ // Status codes for decode operations.
+ // TODO(rileya): Now that both AudioDecoder and VideoDecoder Status enums
+ // match, break them into a decoder_status.h.
enum Status {
- kOk,
- kAborted,
- kDecodeError,
+ kOk, // We're all good.
+ kAborted, // We aborted as a result of Stop() or Reset().
+ kDecodeError, // A decoding error occurred.
+ kDecryptError // Decrypting error happened.
};
+ // Callback for AudioDecoder to return a decoded frame whenever it becomes
+ // available. Only non-EOS frames should be returned via this callback.
+ typedef base::Callback<void(const scoped_refptr<AudioBuffer>&)> OutputCB;
+
+ // Callback for Decode(). Called after the decoder has completed decoding
+ // corresponding DecoderBuffer, indicating that it's ready to accept another
+ // buffer to decode.
+ typedef base::Callback<void(Status)> DecodeCB;
+
AudioDecoder();
virtual ~AudioDecoder();
- // Initialize an AudioDecoder with the given DemuxerStream, executing the
+ // Initializes an AudioDecoder with the given DemuxerStream, executing the
// callback upon completion.
- // statistics_cb is used to update global pipeline statistics.
- virtual void Initialize(DemuxerStream* stream,
+ // |statistics_cb| is used to update global pipeline statistics.
+ // |output_cb| is called for decoded audio buffers (see Decode()).
+ virtual void Initialize(const AudioDecoderConfig& config,
const PipelineStatusCB& status_cb,
- const StatisticsCB& statistics_cb) = 0;
+ const OutputCB& output_cb) = 0;
- // Request samples to be decoded and returned via the provided callback.
- // Only one read may be in flight at any given time.
+ // Requests samples to be decoded. Only one decode may be in flight at any
+ // given time. Once the buffer is decoded the decoder calls |decode_cb|.
+ // |output_cb| specified in Initialize() is called for each decoded buffer,
+ // before or after |decode_cb|.
//
- // Implementations guarantee that the callback will not be called from within
+ // Implementations guarantee that the callbacks will not be called from within
// this method.
//
- // Non-NULL sample buffer pointers will contain decoded audio data or may
- // indicate the end of the stream. A NULL buffer pointer indicates an aborted
- // Read(). This can happen if the DemuxerStream gets flushed and doesn't have
- // any more data to return.
- typedef base::Callback<void(Status, const scoped_refptr<AudioBuffer>&)>
- ReadCB;
- virtual void Read(const ReadCB& read_cb) = 0;
+ // If |buffer| is an EOS buffer then the decoder must be flushed, i.e.
+ // |output_cb| must be called for each frame pending in the queue and
+ // |decode_cb| must be called after that.
+ virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer,
+ const DecodeCB& decode_cb) = 0;
- // Reset decoder state, dropping any queued encoded data.
+ // Resets decoder state. All pending Decode() requests will be finished or
+ // aborted before |closure| is called.
virtual void Reset(const base::Closure& closure) = 0;
- // Returns various information about the decoded audio format.
- virtual int bits_per_channel() = 0;
- virtual ChannelLayout channel_layout() = 0;
- virtual int samples_per_second() = 0;
+ // Stops decoder, fires any pending callbacks and sets the decoder to an
+ // uninitialized state. An AudioDecoder cannot be re-initialized after it has
+ // been stopped. DecodeCB and OutputCB may still be called for older buffers
+ // if they were scheduled before this method is called.
+ // Note that if Initialize() is pending or has finished successfully, Stop()
+ // must be called before destructing the decoder.
+ virtual void Stop() = 0;
private:
DISALLOW_COPY_AND_ASSIGN(AudioDecoder);