Chromium Code Reviews| Index: media/filters/ffmpeg_audio_decoder.h |
| diff --git a/media/filters/ffmpeg_audio_decoder.h b/media/filters/ffmpeg_audio_decoder.h |
| index 42bce45109ab5a5b82d2002a0356dac5fdc6660e..621434dede62c6a4bdbfbca4b4edd3c53aaffdf9 100644 |
| --- a/media/filters/ffmpeg_audio_decoder.h |
| +++ b/media/filters/ffmpeg_audio_decoder.h |
| @@ -26,7 +26,6 @@ namespace media { |
| class AudioTimestampHelper; |
| class DecoderBuffer; |
| -struct QueuedAudioBuffer; |
| class ScopedPtrAVFreeContext; |
| class ScopedPtrAVFreeFrame; |
| @@ -37,10 +36,11 @@ class MEDIA_EXPORT FFmpegAudioDecoder : public AudioDecoder { |
| virtual ~FFmpegAudioDecoder(); |
| // AudioDecoder implementation. |
| - virtual void Initialize(DemuxerStream* stream, |
| - const PipelineStatusCB& status_cb, |
| - const StatisticsCB& statistics_cb) OVERRIDE; |
| - virtual void Read(const ReadCB& read_cb) OVERRIDE; |
| + virtual void Initialize(const AudioDecoderConfig& config, |
| + const PipelineStatusCB& status_cb) OVERRIDE; |
| + virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
| + const DecodeCB& decode_cb) OVERRIDE; |
| + virtual scoped_refptr<AudioBuffer> GetDecodeOutput() OVERRIDE; |
| virtual int bits_per_channel() OVERRIDE; |
| virtual ChannelLayout channel_layout() OVERRIDE; |
| virtual int samples_per_second() OVERRIDE; |
| @@ -53,27 +53,41 @@ class MEDIA_EXPORT FFmpegAudioDecoder : public AudioDecoder { |
| int GetAudioBuffer(AVCodecContext* codec, AVFrame* frame, int flags); |
| private: |
| - void DoStop(); |
| + |
|
DaleCurtis
2014/03/04 01:01:33
Remove extra line.
rileya (GONE FROM CHROMIUM)
2014/03/04 02:03:01
Done.
|
| + enum DecoderState { |
| + kUninitialized, |
| + kNormal, |
| + kFlushCodec, |
| + kDecodeFinished, |
| + kError |
| + }; |
| + |
| + // Reset decoder and call |reset_cb_|. |
| void DoReset(); |
| - // Reads from the demuxer stream with corresponding callback method. |
| - void ReadFromDemuxerStream(); |
| - void BufferReady(DemuxerStream::Status status, |
| - const scoped_refptr<DecoderBuffer>& input); |
| + // Handles decoding an unencrypted encoded buffer. |
| + void DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer, |
| + const DecodeCB& decode_cb); |
| + bool FFmpegDecode(const scoped_refptr<DecoderBuffer>& buffer); |
| + // Handles (re-)initializing the decoder with a (new) config. |
| + // Returns true if initialization was successful. |
| bool ConfigureDecoder(); |
| + |
| + // Releases resources associated with |codec_context_| and |av_frame_| |
| + // and resets them to NULL. |
| void ReleaseFFmpegResources(); |
| void ResetTimestampState(); |
| - void RunDecodeLoop(const scoped_refptr<DecoderBuffer>& input, |
| - bool skip_eos_append); |
| scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| base::WeakPtrFactory<FFmpegAudioDecoder> weak_factory_; |
| base::WeakPtr<FFmpegAudioDecoder> weak_this_; |
| - DemuxerStream* demuxer_stream_; |
| - StatisticsCB statistics_cb_; |
| + DecoderState state_; |
| + |
| + // FFmpeg structures owned by this object. |
| scoped_ptr_malloc<AVCodecContext, ScopedPtrAVFreeContext> codec_context_; |
| + scoped_ptr_malloc<AVFrame, ScopedPtrAVFreeFrame> av_frame_; |
| // Decoded audio format. |
| int bytes_per_channel_; |
| @@ -85,6 +99,8 @@ class MEDIA_EXPORT FFmpegAudioDecoder : public AudioDecoder { |
| int av_sample_format_; |
| SampleFormat sample_format_; |
| + AudioDecoderConfig config_; |
| + |
| // Used for computing output timestamps. |
| scoped_ptr<AudioTimestampHelper> output_timestamp_helper_; |
| base::TimeDelta last_input_timestamp_; |
| @@ -92,16 +108,9 @@ class MEDIA_EXPORT FFmpegAudioDecoder : public AudioDecoder { |
| // Number of frames to drop before generating output buffers. |
| int output_frames_to_drop_; |
| - // Holds decoded audio. |
| - scoped_ptr_malloc<AVFrame, ScopedPtrAVFreeFrame> av_frame_; |
| - |
| - ReadCB read_cb_; |
|
rileya (GONE FROM CHROMIUM)
2014/03/04 00:14:27
Conveniently, all of init/decode/reset/stop functi
|
| - base::Closure stop_cb_; |
| - base::Closure reset_cb_; |
| - |
| // Since multiple frames may be decoded from the same packet we need to queue |
| - // them up and hand them out as we receive Read() calls. |
| - std::list<QueuedAudioBuffer> queued_audio_; |
| + // them up. |
| + std::list<scoped_refptr<AudioBuffer> > queued_audio_; |
| DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder); |
| }; |