| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // 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/base/factory.h" | 8 #include "media/base/factory.h" |
| 9 #include "media/filters/decoder_base.h" | 9 #include "media/filters/decoder_base.h" |
| 10 | 10 |
| 11 struct AVCodecContext; | 11 struct AVCodecContext; |
| 12 | 12 |
| 13 namespace media { | 13 namespace media { |
| 14 | 14 |
| 15 // Forward declaration for scoped_ptr_malloc. | 15 // Forward declaration for scoped_ptr_malloc. |
| 16 class ScopedPtrAVFree; | 16 class ScopedPtrAVFree; |
| 17 | 17 |
| 18 class FFmpegAudioDecoder : public DecoderBase<AudioDecoder, Buffer> { | 18 class FFmpegAudioDecoder : public DecoderBase<AudioDecoder, Buffer> { |
| 19 public: | 19 public: |
| 20 static FilterFactory* CreateFactory() { | 20 static FilterFactory* CreateFactory() { |
| 21 return new FilterFactoryImpl0<FFmpegAudioDecoder>(); | 21 return new FilterFactoryImpl0<FFmpegAudioDecoder>(); |
| 22 } | 22 } |
| 23 | 23 |
| 24 static bool IsMediaFormatSupported(const MediaFormat& media_format); | 24 static bool IsMediaFormatSupported(const MediaFormat& media_format); |
| 25 | 25 |
| 26 protected: | 26 protected: |
| 27 virtual bool OnInitialize(DemuxerStream* demuxer_stream); | 27 virtual bool OnInitialize(DemuxerStream* demuxer_stream); |
| 28 | 28 |
| 29 virtual void OnSeek(base::TimeDelta time); |
| 30 |
| 29 virtual void OnStop(); | 31 virtual void OnStop(); |
| 30 | 32 |
| 31 virtual void OnDecode(Buffer* input); | 33 virtual void OnDecode(Buffer* input); |
| 32 | 34 |
| 33 private: | 35 private: |
| 34 friend class FilterFactoryImpl0<FFmpegAudioDecoder>; | 36 friend class FilterFactoryImpl0<FFmpegAudioDecoder>; |
| 35 FFmpegAudioDecoder(); | 37 FFmpegAudioDecoder(); |
| 36 virtual ~FFmpegAudioDecoder(); | 38 virtual ~FFmpegAudioDecoder(); |
| 37 | 39 |
| 38 // Calculates the duration of an audio buffer based on the sample rate, | 40 // Calculates the duration of an audio buffer based on the sample rate, |
| 39 // channels and bits per sample given the size in bytes. | 41 // channels and bits per sample given the size in bytes. |
| 40 base::TimeDelta CalculateDuration(size_t size); | 42 base::TimeDelta CalculateDuration(size_t size); |
| 41 | 43 |
| 42 // A FFmpeg defined structure that holds decoder information, this variable | 44 // A FFmpeg defined structure that holds decoder information, this variable |
| 43 // is initialized in OnInitialize(). | 45 // is initialized in OnInitialize(). |
| 44 AVCodecContext* codec_context_; | 46 AVCodecContext* codec_context_; |
| 45 | 47 |
| 48 // Estimated timestamp for next packet. Useful for packets without timestamps. |
| 49 base::TimeDelta estimated_next_timestamp_; |
| 50 |
| 46 // Data buffer to carry decoded raw PCM samples. This buffer is created by | 51 // Data buffer to carry decoded raw PCM samples. This buffer is created by |
| 47 // av_malloc() and is used throughout the lifetime of this class. | 52 // av_malloc() and is used throughout the lifetime of this class. |
| 48 scoped_ptr_malloc<uint8, ScopedPtrAVFree> output_buffer_; | 53 scoped_ptr_malloc<uint8, ScopedPtrAVFree> output_buffer_; |
| 49 | 54 |
| 50 static const size_t kOutputBufferSize; | 55 static const size_t kOutputBufferSize; |
| 51 | 56 |
| 52 DISALLOW_COPY_AND_ASSIGN(FFmpegAudioDecoder); | 57 DISALLOW_COPY_AND_ASSIGN(FFmpegAudioDecoder); |
| 53 }; | 58 }; |
| 54 | 59 |
| 55 } // namespace media | 60 } // namespace media |
| 56 | 61 |
| 57 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ | 62 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ |
| OLD | NEW |