| 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 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 explicit FFmpegAudioDecoder( | 34 explicit FFmpegAudioDecoder( |
| 35 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | 35 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
| 36 virtual ~FFmpegAudioDecoder(); | 36 virtual ~FFmpegAudioDecoder(); |
| 37 | 37 |
| 38 // AudioDecoder implementation. | 38 // AudioDecoder implementation. |
| 39 virtual void Initialize(const AudioDecoderConfig& config, | 39 virtual void Initialize(const AudioDecoderConfig& config, |
| 40 const PipelineStatusCB& status_cb) OVERRIDE; | 40 const PipelineStatusCB& status_cb) OVERRIDE; |
| 41 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 41 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
| 42 const DecodeCB& decode_cb) OVERRIDE; | 42 const DecodeCB& decode_cb) OVERRIDE; |
| 43 virtual scoped_refptr<AudioBuffer> GetDecodeOutput() OVERRIDE; | 43 virtual scoped_refptr<AudioBuffer> GetDecodeOutput() OVERRIDE; |
| 44 virtual int bits_per_channel() OVERRIDE; | |
| 45 virtual ChannelLayout channel_layout() OVERRIDE; | |
| 46 virtual int samples_per_second() OVERRIDE; | |
| 47 virtual void Reset(const base::Closure& closure) OVERRIDE; | 44 virtual void Reset(const base::Closure& closure) OVERRIDE; |
| 48 virtual void Stop(const base::Closure& closure) OVERRIDE; | 45 virtual void Stop(const base::Closure& closure) OVERRIDE; |
| 49 | 46 |
| 50 private: | 47 private: |
| 51 enum DecoderState { | 48 enum DecoderState { |
| 52 kUninitialized, | 49 kUninitialized, |
| 53 kNormal, | 50 kNormal, |
| 54 kFlushCodec, | 51 kFlushCodec, |
| 55 kDecodeFinished, | 52 kDecodeFinished, |
| 56 kError | 53 kError |
| (...skipping 19 matching lines...) Expand all Loading... |
| 76 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 73 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 77 base::WeakPtrFactory<FFmpegAudioDecoder> weak_factory_; | 74 base::WeakPtrFactory<FFmpegAudioDecoder> weak_factory_; |
| 78 base::WeakPtr<FFmpegAudioDecoder> weak_this_; | 75 base::WeakPtr<FFmpegAudioDecoder> weak_this_; |
| 79 | 76 |
| 80 DecoderState state_; | 77 DecoderState state_; |
| 81 | 78 |
| 82 // FFmpeg structures owned by this object. | 79 // FFmpeg structures owned by this object. |
| 83 scoped_ptr_malloc<AVCodecContext, ScopedPtrAVFreeContext> codec_context_; | 80 scoped_ptr_malloc<AVCodecContext, ScopedPtrAVFreeContext> codec_context_; |
| 84 scoped_ptr_malloc<AVFrame, ScopedPtrAVFreeFrame> av_frame_; | 81 scoped_ptr_malloc<AVFrame, ScopedPtrAVFreeFrame> av_frame_; |
| 85 | 82 |
| 86 // Decoded audio format. | 83 AudioDecoderConfig config_; |
| 87 int bytes_per_channel_; | |
| 88 ChannelLayout channel_layout_; | |
| 89 int channels_; | |
| 90 int samples_per_second_; | |
| 91 | 84 |
| 92 // AVSampleFormat initially requested; not Chrome's SampleFormat. | 85 // AVSampleFormat initially requested; not Chrome's SampleFormat. |
| 93 int av_sample_format_; | 86 int av_sample_format_; |
| 94 SampleFormat sample_format_; | |
| 95 | |
| 96 AudioDecoderConfig config_; | |
| 97 | 87 |
| 98 // Used for computing output timestamps. | 88 // Used for computing output timestamps. |
| 99 scoped_ptr<AudioTimestampHelper> output_timestamp_helper_; | 89 scoped_ptr<AudioTimestampHelper> output_timestamp_helper_; |
| 100 base::TimeDelta last_input_timestamp_; | 90 base::TimeDelta last_input_timestamp_; |
| 101 | 91 |
| 102 // Number of frames to drop before generating output buffers. | 92 // Number of frames to drop before generating output buffers. |
| 103 int output_frames_to_drop_; | 93 int output_frames_to_drop_; |
| 104 | 94 |
| 105 // Since multiple frames may be decoded from the same packet we need to queue | 95 // Since multiple frames may be decoded from the same packet we need to queue |
| 106 // them up. | 96 // them up. |
| 107 std::list<scoped_refptr<AudioBuffer> > queued_audio_; | 97 std::list<scoped_refptr<AudioBuffer> > queued_audio_; |
| 108 | 98 |
| 109 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder); | 99 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder); |
| 110 }; | 100 }; |
| 111 | 101 |
| 112 } // namespace media | 102 } // namespace media |
| 113 | 103 |
| 114 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ | 104 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ |
| OLD | NEW |