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

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

Issue 297553002: Add callback in VideoDecoder and AudioDecoder to return decoded frames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | media/base/audio_decoder.cc » ('j') | media/base/video_decoder.h » ('J')
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/audio_decoder_config.h"
11 #include "media/base/channel_layout.h" 11 #include "media/base/channel_layout.h"
12 #include "media/base/decoder_buffer.h" 12 #include "media/base/decoder_buffer.h"
13 #include "media/base/media_export.h" 13 #include "media/base/media_export.h"
14 #include "media/base/pipeline_status.h" 14 #include "media/base/pipeline_status.h"
15 15
16 namespace media { 16 namespace media {
17 17
18 class AudioBuffer; 18 class AudioBuffer;
19 class DemuxerStream; 19 class DemuxerStream;
20 20
21 class MEDIA_EXPORT AudioDecoder { 21 class MEDIA_EXPORT AudioDecoder {
22 public: 22 public:
23 // Status codes for decode operations. 23 // Status codes for decode operations.
24 // TODO(rileya): Now that both AudioDecoder and VideoDecoder Status enums 24 // TODO(rileya): Now that both AudioDecoder and VideoDecoder Status enums
25 // match, break them into a decoder_status.h. 25 // match, break them into a decoder_status.h.
26 enum Status { 26 enum Status {
27 kOk, // We're all good. 27 kOk, // We're all good.
28 kAborted, // We aborted as a result of Stop() or Reset(). 28 kAborted, // We aborted as a result of Stop() or Reset().
29 kNotEnoughData, // Not enough data to produce a video frame.
30 kDecodeError, // A decoding error occurred. 29 kDecodeError, // A decoding error occurred.
31 kDecryptError // Decrypting error happened. 30 kDecryptError // Decrypting error happened.
32 }; 31 };
33 32
33 // Callback to return decoded buffers.
34 typedef base::Callback<void(const scoped_refptr<AudioBuffer>&)> OutputCB;
35
36 // Callback for Decode();
37 typedef base::Callback<void(Status)> DecodeCB;
xhwang 2014/05/29 22:15:14 What does this exactly mean? We need a comment her
Sergey Ulanov 2014/06/03 00:08:11 Done.
38
34 AudioDecoder(); 39 AudioDecoder();
35 virtual ~AudioDecoder(); 40 virtual ~AudioDecoder();
36 41
37 // Initializes an AudioDecoder with the given DemuxerStream, executing the 42 // Initializes an AudioDecoder with the given DemuxerStream, executing the
38 // callback upon completion. 43 // callback upon completion.
39 // statistics_cb is used to update global pipeline statistics. 44 // statistics_cb is used to update global pipeline statistics.
xhwang 2014/05/29 22:15:14 Add a comment on |output_cb|.
Sergey Ulanov 2014/06/03 00:08:11 Done.
40 virtual void Initialize(const AudioDecoderConfig& config, 45 virtual void Initialize(const AudioDecoderConfig& config,
41 const PipelineStatusCB& status_cb) = 0; 46 const PipelineStatusCB& status_cb,
47 const OutputCB& output_cb) = 0;
42 48
43 // Requests samples to be decoded and returned via the provided callback. 49 // Requests samples to be decoded and returned via the provided callback.
xhwang 2014/05/29 22:15:14 This needs to be updated.
Sergey Ulanov 2014/06/03 00:08:11 Done.
44 // Only one decode may be in flight at any given time. 50 // Only one decode may be in flight at any given time.
45 // 51 //
46 // Implementations guarantee that the callback will not be called from within 52 // Implementations guarantee that the callback will not be called from within
47 // this method. 53 // this method.
48 // 54 //
49 // Non-NULL sample buffer pointers will contain decoded audio data or may 55 // Non-NULL sample buffer pointers will contain decoded audio data or may
50 // indicate the end of the stream. A NULL buffer pointer indicates an aborted 56 // indicate the end of the stream. A NULL buffer pointer indicates an aborted
51 // Decode(). 57 // Decode().
52 typedef base::Callback<void(Status, const scoped_refptr<AudioBuffer>&)>
53 DecodeCB;
54 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, 58 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer,
55 const DecodeCB& decode_cb) = 0; 59 const DecodeCB& decode_cb) = 0;
56 60
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();
61
62 // Resets decoder state, dropping any queued encoded data. 61 // Resets decoder state, dropping any queued encoded data.
63 virtual void Reset(const base::Closure& closure) = 0; 62 virtual void Reset(const base::Closure& closure) = 0;
xhwang 2014/05/29 22:15:14 In this case, shall all decoded frames be simply d
Sergey Ulanov 2014/06/03 00:08:11 I think the comment is not entirely true. The buff
xhwang 2014/06/05 21:53:48 To clarify, do you mean when Reset() is called, th
Sergey Ulanov 2014/06/06 22:49:39 Yes, that's right.
64 63
65 // Stops decoder, fires any pending callbacks and sets the decoder to an 64 // Stops decoder, fires any pending callbacks and sets the decoder to an
66 // uninitialized state. An AudioDecoder cannot be re-initialized after it has 65 // uninitialized state. An AudioDecoder cannot be re-initialized after it has
67 // been stopped. 66 // been stopped.
68 // Note that if Initialize() is pending or has finished successfully, Stop() 67 // Note that if Initialize() is pending or has finished successfully, Stop()
69 // must be called before destructing the decoder. 68 // must be called before destructing the decoder.
70 virtual void Stop() = 0; 69 virtual void Stop() = 0;
xhwang 2014/05/29 22:15:14 ditto about "shall all decoded frames be simply dr
Sergey Ulanov 2014/06/03 00:08:11 Done. BTW, Do we really need this method? Given t
xhwang 2014/06/05 21:53:48 You are absolutely right! We are planning to drop
71 70
72 private: 71 private:
73 DISALLOW_COPY_AND_ASSIGN(AudioDecoder); 72 DISALLOW_COPY_AND_ASSIGN(AudioDecoder);
74 }; 73 };
75 74
76 } // namespace media 75 } // namespace media
77 76
78 #endif // MEDIA_BASE_AUDIO_DECODER_H_ 77 #endif // MEDIA_BASE_AUDIO_DECODER_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/audio_decoder.cc » ('j') | media/base/video_decoder.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698