1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_BASE_AUDIO_DECODER_H_
#define MEDIA_BASE_AUDIO_DECODER_H_
#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/decoder_buffer.h"
#include "media/base/media_export.h"
#include "media/base/pipeline_status.h"
namespace media {
class AudioBuffer;
class DemuxerStream;
class MEDIA_EXPORT AudioDecoder {
public:
// 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, // We're all good.
kAborted, // We aborted as a result of Stop() or Reset().
kNotEnoughData, // Not enough data to produce a video frame.
kDecodeError, // A decoding error occurred.
kDecryptError // Decrypting error happened.
};
AudioDecoder();
virtual ~AudioDecoder();
// Initializes an AudioDecoder with the given DemuxerStream, executing the
// callback upon completion.
// statistics_cb is used to update global pipeline statistics.
virtual void Initialize(const AudioDecoderConfig& config,
const PipelineStatusCB& status_cb) = 0;
// Requests samples to be decoded and returned via the provided callback.
// Only one decode may be in flight at any given time.
//
// Implementations guarantee that the callback 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
// Decode().
typedef base::Callback<void(Status, const scoped_refptr<AudioBuffer>&)>
DecodeCB;
virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer,
const DecodeCB& decode_cb) = 0;
// Some AudioDecoders will queue up multiple AudioBuffers from a single
// DecoderBuffer, if we have any such queued buffers this will return the next
// one. Otherwise we return a NULL AudioBuffer.
virtual scoped_refptr<AudioBuffer> GetDecodeOutput();
// Resets decoder state, dropping any queued encoded data.
virtual void Reset(const base::Closure& closure) = 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.
// Note that if Initialize() has been called, Stop() must be called and
// complete before deleting the decoder.
virtual void Stop(const base::Closure& closure) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(AudioDecoder);
};
} // namespace media
#endif // MEDIA_BASE_AUDIO_DECODER_H_
|