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

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

Issue 1143223007: media: Reland "Simplify {Audio|Video}Decoder initialization callback." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 | « content/renderer/pepper/video_decoder_shim.cc ('k') | media/base/mock_filters.h » ('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 <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "media/base/audio_decoder_config.h" 12 #include "media/base/audio_decoder_config.h"
13 #include "media/base/channel_layout.h" 13 #include "media/base/channel_layout.h"
14 #include "media/base/decoder_buffer.h" 14 #include "media/base/decoder_buffer.h"
15 #include "media/base/media_export.h" 15 #include "media/base/media_export.h"
16 #include "media/base/pipeline_status.h" 16 #include "media/base/pipeline_status.h"
17 17
18 namespace media { 18 namespace media {
19 19
20 class AudioBuffer; 20 class AudioBuffer;
21 class DemuxerStream; 21 class DemuxerStream;
22 22
23 class MEDIA_EXPORT AudioDecoder { 23 class MEDIA_EXPORT AudioDecoder {
24 public: 24 public:
25 // Status codes for decode operations. 25 // Status codes for decode operations.
26 // TODO(rileya): Now that both AudioDecoder and VideoDecoder Status enums 26 // TODO(rileya): Now that both AudioDecoder and VideoDecoder Status enums
27 // match, break them into a decoder_status.h. 27 // match, break them into a decoder_status.h.
28 enum Status { 28 enum Status {
29 kOk, // We're all good. 29 kOk, // We're all good.
30 kAborted, // We aborted as a result of Reset() or destruction. 30 kAborted, // We aborted as a result of Reset() or destruction.
31 kDecodeError // A decoding error occurred. 31 kDecodeError // A decoding error occurred.
32 }; 32 };
33 33
34 // Callback for VideoDecoder initialization.
35 typedef base::Callback<void(bool success)> InitCB;
36
34 // Callback for AudioDecoder to return a decoded frame whenever it becomes 37 // Callback for AudioDecoder to return a decoded frame whenever it becomes
35 // available. Only non-EOS frames should be returned via this callback. 38 // available. Only non-EOS frames should be returned via this callback.
36 typedef base::Callback<void(const scoped_refptr<AudioBuffer>&)> OutputCB; 39 typedef base::Callback<void(const scoped_refptr<AudioBuffer>&)> OutputCB;
37 40
38 // Callback for Decode(). Called after the decoder has completed decoding 41 // Callback for Decode(). Called after the decoder has completed decoding
39 // corresponding DecoderBuffer, indicating that it's ready to accept another 42 // corresponding DecoderBuffer, indicating that it's ready to accept another
40 // buffer to decode. 43 // buffer to decode.
41 typedef base::Callback<void(Status)> DecodeCB; 44 typedef base::Callback<void(Status)> DecodeCB;
42 45
43 AudioDecoder(); 46 AudioDecoder();
44 47
45 // Fires any pending callbacks, stops and destroys the decoder. 48 // Fires any pending callbacks, stops and destroys the decoder.
46 // Note: Since this is a destructor, |this| will be destroyed after this call. 49 // Note: Since this is a destructor, |this| will be destroyed after this call.
47 // Make sure the callbacks fired from this call doesn't post any task that 50 // Make sure the callbacks fired from this call doesn't post any task that
48 // depends on |this|. 51 // depends on |this|.
49 virtual ~AudioDecoder(); 52 virtual ~AudioDecoder();
50 53
51 // Returns the name of the decoder for logging purpose. 54 // Returns the name of the decoder for logging purpose.
52 virtual std::string GetDisplayName() const = 0; 55 virtual std::string GetDisplayName() const = 0;
53 56
54 // Initializes an AudioDecoder with the given DemuxerStream, executing the 57 // Initializes an AudioDecoder with the given DemuxerStream, executing the
55 // callback upon completion. 58 // callback upon completion.
56 // |statistics_cb| is used to update global pipeline statistics. 59 // |init_cb| is used to return initialization status.
57 // |output_cb| is called for decoded audio buffers (see Decode()). 60 // |output_cb| is called for decoded audio buffers (see Decode()).
58 virtual void Initialize(const AudioDecoderConfig& config, 61 virtual void Initialize(const AudioDecoderConfig& config,
59 const PipelineStatusCB& status_cb, 62 const InitCB& init_cb,
60 const OutputCB& output_cb) = 0; 63 const OutputCB& output_cb) = 0;
61 64
62 // Requests samples to be decoded. Only one decode may be in flight at any 65 // Requests samples to be decoded. Only one decode may be in flight at any
63 // given time. Once the buffer is decoded the decoder calls |decode_cb|. 66 // given time. Once the buffer is decoded the decoder calls |decode_cb|.
64 // |output_cb| specified in Initialize() is called for each decoded buffer, 67 // |output_cb| specified in Initialize() is called for each decoded buffer,
65 // before or after |decode_cb|. 68 // before or after |decode_cb|.
66 // 69 //
67 // Implementations guarantee that the callbacks will not be called from within 70 // Implementations guarantee that the callbacks will not be called from within
68 // this method. 71 // this method.
69 // 72 //
70 // If |buffer| is an EOS buffer then the decoder must be flushed, i.e. 73 // If |buffer| is an EOS buffer then the decoder must be flushed, i.e.
71 // |output_cb| must be called for each frame pending in the queue and 74 // |output_cb| must be called for each frame pending in the queue and
72 // |decode_cb| must be called after that. 75 // |decode_cb| must be called after that.
73 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, 76 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer,
74 const DecodeCB& decode_cb) = 0; 77 const DecodeCB& decode_cb) = 0;
75 78
76 // Resets decoder state. All pending Decode() requests will be finished or 79 // Resets decoder state. All pending Decode() requests will be finished or
77 // aborted before |closure| is called. 80 // aborted before |closure| is called.
78 virtual void Reset(const base::Closure& closure) = 0; 81 virtual void Reset(const base::Closure& closure) = 0;
79 82
80 private: 83 private:
81 DISALLOW_COPY_AND_ASSIGN(AudioDecoder); 84 DISALLOW_COPY_AND_ASSIGN(AudioDecoder);
82 }; 85 };
83 86
84 } // namespace media 87 } // namespace media
85 88
86 #endif // MEDIA_BASE_AUDIO_DECODER_H_ 89 #endif // MEDIA_BASE_AUDIO_DECODER_H_
OLDNEW
« no previous file with comments | « content/renderer/pepper/video_decoder_shim.cc ('k') | media/base/mock_filters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698