OLD | NEW |
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_FILTERS_FFMPEG_AUDIO_DECODER_H_ | 5 #ifndef MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ |
6 #define MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ | 6 #define MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "media/base/audio_buffer.h" |
14 #include "media/base/audio_decoder.h" | 15 #include "media/base/audio_decoder.h" |
15 #include "media/base/demuxer_stream.h" | 16 #include "media/base/demuxer_stream.h" |
16 #include "media/base/media_log.h" | 17 #include "media/base/media_log.h" |
17 #include "media/base/sample_format.h" | 18 #include "media/base/sample_format.h" |
18 #include "media/ffmpeg/ffmpeg_deleters.h" | 19 #include "media/ffmpeg/ffmpeg_deleters.h" |
19 | 20 |
20 struct AVCodecContext; | 21 struct AVCodecContext; |
21 struct AVFrame; | 22 struct AVFrame; |
22 | 23 |
23 namespace base { | 24 namespace base { |
(...skipping 15 matching lines...) Expand all Loading... |
39 // AudioDecoder implementation. | 40 // AudioDecoder implementation. |
40 std::string GetDisplayName() const override; | 41 std::string GetDisplayName() const override; |
41 void Initialize(const AudioDecoderConfig& config, | 42 void Initialize(const AudioDecoderConfig& config, |
42 CdmContext* cdm_context, | 43 CdmContext* cdm_context, |
43 const InitCB& init_cb, | 44 const InitCB& init_cb, |
44 const OutputCB& output_cb) override; | 45 const OutputCB& output_cb) override; |
45 void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 46 void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
46 const DecodeCB& decode_cb) override; | 47 const DecodeCB& decode_cb) override; |
47 void Reset(const base::Closure& closure) override; | 48 void Reset(const base::Closure& closure) override; |
48 | 49 |
| 50 // Callback called from within FFmpeg to allocate a buffer based on the |
| 51 // properties of |codec_context| and |frame|. See AVCodecContext.get_buffer2 |
| 52 // documentation inside FFmpeg. |
| 53 int GetAudioBuffer(struct AVCodecContext* s, AVFrame* frame, int flags); |
| 54 |
49 private: | 55 private: |
50 // There are four states the decoder can be in: | 56 // There are four states the decoder can be in: |
51 // | 57 // |
52 // - kUninitialized: The decoder is not initialized. | 58 // - kUninitialized: The decoder is not initialized. |
53 // - kNormal: This is the normal state. The decoder is idle and ready to | 59 // - kNormal: This is the normal state. The decoder is idle and ready to |
54 // decode input buffers, or is decoding an input buffer. | 60 // decode input buffers, or is decoding an input buffer. |
55 // - kDecodeFinished: EOS buffer received, codec flushed and decode finished. | 61 // - kDecodeFinished: EOS buffer received, codec flushed and decode finished. |
56 // No further Decode() call should be made. | 62 // No further Decode() call should be made. |
57 // - kError: Unexpected error happened. | 63 // - kError: Unexpected error happened. |
58 // | 64 // |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 110 |
105 AudioDecoderConfig config_; | 111 AudioDecoderConfig config_; |
106 | 112 |
107 // AVSampleFormat initially requested; not Chrome's SampleFormat. | 113 // AVSampleFormat initially requested; not Chrome's SampleFormat. |
108 int av_sample_format_; | 114 int av_sample_format_; |
109 | 115 |
110 std::unique_ptr<AudioDiscardHelper> discard_helper_; | 116 std::unique_ptr<AudioDiscardHelper> discard_helper_; |
111 | 117 |
112 scoped_refptr<MediaLog> media_log_; | 118 scoped_refptr<MediaLog> media_log_; |
113 | 119 |
| 120 scoped_refptr<AudioBufferMemoryPool> pool_; |
| 121 |
114 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder); | 122 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder); |
115 }; | 123 }; |
116 | 124 |
117 } // namespace media | 125 } // namespace media |
118 | 126 |
119 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ | 127 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ |
OLD | NEW |