| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "media/filters/decoder_base.h" | 8 #include "media/filters/decoder_base.h" |
| 9 | 9 |
| 10 struct AVCodecContext; | 10 struct AVCodecContext; |
| 11 | 11 |
| 12 namespace media { | 12 namespace media { |
| 13 | 13 |
| 14 // Forward declaration for scoped_ptr_malloc. | 14 // Forward declaration for scoped_ptr_malloc. |
| 15 class ScopedPtrAVFree; | 15 class ScopedPtrAVFree; |
| 16 | 16 |
| 17 class MEDIA_EXPORT FFmpegAudioDecoder | 17 class MEDIA_EXPORT FFmpegAudioDecoder |
| 18 : public DecoderBase<AudioDecoder, Buffer> { | 18 : public DecoderBase<AudioDecoder, Buffer> { |
| 19 public: | 19 public: |
| 20 explicit FFmpegAudioDecoder(MessageLoop* message_loop); | 20 explicit FFmpegAudioDecoder(MessageLoop* message_loop); |
| 21 virtual ~FFmpegAudioDecoder(); | 21 virtual ~FFmpegAudioDecoder(); |
| 22 | 22 |
| 23 // AudioDecoder implementation. | 23 // AudioDecoder implementation. |
| 24 virtual AudioDecoderConfig config(); | |
| 25 virtual void ProduceAudioSamples(scoped_refptr<Buffer> output); | 24 virtual void ProduceAudioSamples(scoped_refptr<Buffer> output); |
| 25 virtual int bits_per_channel(); |
| 26 virtual ChannelLayout channel_layout(); |
| 27 virtual int sample_rate(); |
| 26 | 28 |
| 27 protected: | 29 protected: |
| 28 virtual void DoInitialize(DemuxerStream* demuxer_stream, bool* success, | 30 virtual void DoInitialize(DemuxerStream* demuxer_stream, bool* success, |
| 29 Task* done_cb); | 31 Task* done_cb); |
| 30 | 32 |
| 31 virtual void DoSeek(base::TimeDelta time, Task* done_cb); | 33 virtual void DoSeek(base::TimeDelta time, Task* done_cb); |
| 32 | 34 |
| 33 virtual void DoDecode(Buffer* input); | 35 virtual void DoDecode(Buffer* input); |
| 34 | 36 |
| 35 private: | 37 private: |
| 36 // Calculates the duration of an audio buffer based on the sample rate, | 38 // Calculates the duration of an audio buffer based on the sample rate, |
| 37 // channels and bits per sample given the size in bytes. | 39 // channels and bits per sample given the size in bytes. |
| 38 base::TimeDelta CalculateDuration(size_t size); | 40 base::TimeDelta CalculateDuration(size_t size); |
| 39 | 41 |
| 40 // A FFmpeg defined structure that holds decoder information, this variable | 42 // A FFmpeg defined structure that holds decoder information, this variable |
| 41 // is initialized in OnInitialize(). | 43 // is initialized in OnInitialize(). |
| 42 AVCodecContext* codec_context_; | 44 AVCodecContext* codec_context_; |
| 43 | 45 |
| 44 AudioDecoderConfig config_; | 46 // Decoded audio format. |
| 47 int bits_per_channel_; |
| 48 ChannelLayout channel_layout_; |
| 49 int sample_rate_; |
| 45 | 50 |
| 46 // Estimated timestamp for next packet. Useful for packets without timestamps. | 51 // Estimated timestamp for next packet. Useful for packets without timestamps. |
| 47 base::TimeDelta estimated_next_timestamp_; | 52 base::TimeDelta estimated_next_timestamp_; |
| 48 | 53 |
| 49 // Data buffer to carry decoded raw PCM samples. This buffer is created by | 54 // Data buffer to carry decoded raw PCM samples. This buffer is created by |
| 50 // av_malloc() and is used throughout the lifetime of this class. | 55 // av_malloc() and is used throughout the lifetime of this class. |
| 51 scoped_ptr_malloc<uint8, ScopedPtrAVFree> output_buffer_; | 56 scoped_ptr_malloc<uint8, ScopedPtrAVFree> output_buffer_; |
| 52 | 57 |
| 53 static const size_t kOutputBufferSize; | 58 static const size_t kOutputBufferSize; |
| 54 | 59 |
| 55 DISALLOW_COPY_AND_ASSIGN(FFmpegAudioDecoder); | 60 DISALLOW_COPY_AND_ASSIGN(FFmpegAudioDecoder); |
| 56 }; | 61 }; |
| 57 | 62 |
| 58 } // namespace media | 63 } // namespace media |
| 59 | 64 |
| 60 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ | 65 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ |
| OLD | NEW |