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

Side by Side Diff: media/base/audio_decoder.h

Issue 141243003: Add AudioBufferStream. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@decoderstream_rebased
Patch Set: Rebase! Created 6 years, 9 months 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
« no previous file with comments | « no previous file | media/base/audio_decoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef MEDIA_BASE_AUDIO_DECODER_H_ 5 #ifndef MEDIA_BASE_AUDIO_DECODER_H_
6 #define MEDIA_BASE_AUDIO_DECODER_H_ 6 #define MEDIA_BASE_AUDIO_DECODER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "media/base/audio_decoder_config.h"
10 #include "media/base/channel_layout.h" 11 #include "media/base/channel_layout.h"
12 #include "media/base/decoder_buffer.h"
13 #include "media/base/media_export.h"
11 #include "media/base/pipeline_status.h" 14 #include "media/base/pipeline_status.h"
12 #include "media/base/media_export.h"
13 15
14 namespace media { 16 namespace media {
15 17
16 class AudioBuffer; 18 class AudioBuffer;
17 class DemuxerStream; 19 class DemuxerStream;
18 20
19 class MEDIA_EXPORT AudioDecoder { 21 class MEDIA_EXPORT AudioDecoder {
20 public: 22 public:
21 // Status codes for read operations. 23 // Status codes for decode operations.
24 // TODO(rileya): Now that both AudioDecoder and VideoDecoder Status enums
25 // match, break them into a decoder_status.h.
22 enum Status { 26 enum Status {
23 kOk, 27 kOk, // We're all good.
24 kAborted, 28 kAborted, // We aborted as a result of Stop() or Reset().
25 kDecodeError, 29 kNotEnoughData, // Not enough data to produce a video frame.
30 kDecodeError, // A decoding error occurred.
31 kDecryptError // Decrypting error happened.
26 }; 32 };
27 33
28 AudioDecoder(); 34 AudioDecoder();
29 virtual ~AudioDecoder(); 35 virtual ~AudioDecoder();
30 36
31 // Initializes an AudioDecoder with the given DemuxerStream, executing the 37 // Initializes an AudioDecoder with the given DemuxerStream, executing the
32 // callback upon completion. 38 // callback upon completion.
33 // statistics_cb is used to update global pipeline statistics. 39 // statistics_cb is used to update global pipeline statistics.
34 virtual void Initialize(DemuxerStream* stream, 40 virtual void Initialize(const AudioDecoderConfig& config,
35 const PipelineStatusCB& status_cb, 41 const PipelineStatusCB& status_cb) = 0;
36 const StatisticsCB& statistics_cb) = 0;
37 42
38 // Requests samples to be decoded and returned via the provided callback. 43 // Requests samples to be decoded and returned via the provided callback.
39 // Only one read may be in flight at any given time. 44 // Only one decode may be in flight at any given time.
40 // 45 //
41 // Implementations guarantee that the callback will not be called from within 46 // Implementations guarantee that the callback will not be called from within
42 // this method. 47 // this method.
43 // 48 //
44 // Non-NULL sample buffer pointers will contain decoded audio data or may 49 // Non-NULL sample buffer pointers will contain decoded audio data or may
45 // indicate the end of the stream. A NULL buffer pointer indicates an aborted 50 // indicate the end of the stream. A NULL buffer pointer indicates an aborted
46 // Read(). This can happen if the DemuxerStream gets flushed and doesn't have 51 // Decode().
47 // any more data to return.
48 typedef base::Callback<void(Status, const scoped_refptr<AudioBuffer>&)> 52 typedef base::Callback<void(Status, const scoped_refptr<AudioBuffer>&)>
49 ReadCB; 53 DecodeCB;
50 virtual void Read(const ReadCB& read_cb) = 0; 54 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer,
55 const DecodeCB& decode_cb) = 0;
56
57 // Some AudioDecoders will queue up multiple AudioBuffers from a single
58 // DecoderBuffer, if we have any such queued buffers this will return the next
59 // one. Otherwise we return a NULL AudioBuffer.
60 virtual scoped_refptr<AudioBuffer> GetDecodeOutput();
51 61
52 // Resets decoder state, dropping any queued encoded data. 62 // Resets decoder state, dropping any queued encoded data.
53 virtual void Reset(const base::Closure& closure) = 0; 63 virtual void Reset(const base::Closure& closure) = 0;
54 64
55 // Stops decoder, fires any pending callbacks and sets the decoder to an 65 // Stops decoder, fires any pending callbacks and sets the decoder to an
56 // uninitialized state. An AudioDecoder cannot be re-initialized after it has 66 // uninitialized state. An AudioDecoder cannot be re-initialized after it has
57 // been stopped. 67 // been stopped.
58 // Note that if Initialize() has been called, Stop() must be called and 68 // Note that if Initialize() has been called, Stop() must be called and
59 // complete before deleting the decoder. 69 // complete before deleting the decoder.
60 virtual void Stop(const base::Closure& closure) = 0; 70 virtual void Stop(const base::Closure& closure) = 0;
61 71
62 // Returns various information about the decoded audio format. 72 // Returns various information about the decoded audio format.
63 virtual int bits_per_channel() = 0; 73 virtual int bits_per_channel() = 0;
64 virtual ChannelLayout channel_layout() = 0; 74 virtual ChannelLayout channel_layout() = 0;
65 virtual int samples_per_second() = 0; 75 virtual int samples_per_second() = 0;
66 76
67 private: 77 private:
68 DISALLOW_COPY_AND_ASSIGN(AudioDecoder); 78 DISALLOW_COPY_AND_ASSIGN(AudioDecoder);
69 }; 79 };
70 80
71 } // namespace media 81 } // namespace media
72 82
73 #endif // MEDIA_BASE_AUDIO_DECODER_H_ 83 #endif // MEDIA_BASE_AUDIO_DECODER_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/audio_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698