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 27 matching lines...) Expand all Loading... |
38 | 38 |
39 // AudioDecoder implementation. | 39 // AudioDecoder implementation. |
40 virtual void Initialize(DemuxerStream* stream, | 40 virtual void Initialize(DemuxerStream* stream, |
41 const PipelineStatusCB& status_cb, | 41 const PipelineStatusCB& status_cb, |
42 const StatisticsCB& statistics_cb) OVERRIDE; | 42 const StatisticsCB& statistics_cb) OVERRIDE; |
43 virtual void Read(const ReadCB& read_cb) OVERRIDE; | 43 virtual void Read(const ReadCB& read_cb) OVERRIDE; |
44 virtual int bits_per_channel() OVERRIDE; | 44 virtual int bits_per_channel() OVERRIDE; |
45 virtual ChannelLayout channel_layout() OVERRIDE; | 45 virtual ChannelLayout channel_layout() OVERRIDE; |
46 virtual int samples_per_second() OVERRIDE; | 46 virtual int samples_per_second() OVERRIDE; |
47 virtual void Reset(const base::Closure& closure) OVERRIDE; | 47 virtual void Reset(const base::Closure& closure) OVERRIDE; |
48 virtual void Stop(const base::Closure& closure) OVERRIDE; | |
49 | 48 |
50 // Callback called from within FFmpeg to allocate a buffer based on | 49 // Callback called from within FFmpeg to allocate a buffer based on |
51 // the dimensions of |codec_context|. See AVCodecContext.get_buffer2 | 50 // the dimensions of |codec_context|. See AVCodecContext.get_buffer2 |
52 // documentation inside FFmpeg. | 51 // documentation inside FFmpeg. |
53 int GetAudioBuffer(AVCodecContext* codec, AVFrame* frame, int flags); | 52 int GetAudioBuffer(AVCodecContext* codec, AVFrame* frame, int flags); |
54 | 53 |
55 private: | 54 private: |
56 void DoStop(); | |
57 void DoReset(); | |
58 | |
59 // Reads from the demuxer stream with corresponding callback method. | 55 // Reads from the demuxer stream with corresponding callback method. |
60 void ReadFromDemuxerStream(); | 56 void ReadFromDemuxerStream(); |
61 void BufferReady(DemuxerStream::Status status, | 57 void BufferReady(DemuxerStream::Status status, |
62 const scoped_refptr<DecoderBuffer>& input); | 58 const scoped_refptr<DecoderBuffer>& input); |
63 | 59 |
64 bool ConfigureDecoder(); | 60 bool ConfigureDecoder(); |
65 void ReleaseFFmpegResources(); | 61 void ReleaseFFmpegResources(); |
66 void ResetTimestampState(); | 62 void ResetTimestampState(); |
67 void RunDecodeLoop(const scoped_refptr<DecoderBuffer>& input, | 63 void RunDecodeLoop(const scoped_refptr<DecoderBuffer>& input, |
68 bool skip_eos_append); | 64 bool skip_eos_append); |
(...skipping 20 matching lines...) Expand all Loading... |
89 scoped_ptr<AudioTimestampHelper> output_timestamp_helper_; | 85 scoped_ptr<AudioTimestampHelper> output_timestamp_helper_; |
90 base::TimeDelta last_input_timestamp_; | 86 base::TimeDelta last_input_timestamp_; |
91 | 87 |
92 // Number of frames to drop before generating output buffers. | 88 // Number of frames to drop before generating output buffers. |
93 int output_frames_to_drop_; | 89 int output_frames_to_drop_; |
94 | 90 |
95 // Holds decoded audio. | 91 // Holds decoded audio. |
96 scoped_ptr_malloc<AVFrame, ScopedPtrAVFreeFrame> av_frame_; | 92 scoped_ptr_malloc<AVFrame, ScopedPtrAVFreeFrame> av_frame_; |
97 | 93 |
98 ReadCB read_cb_; | 94 ReadCB read_cb_; |
99 base::Closure stop_cb_; | |
100 base::Closure reset_cb_; | |
101 | 95 |
102 // Since multiple frames may be decoded from the same packet we need to queue | 96 // Since multiple frames may be decoded from the same packet we need to queue |
103 // them up and hand them out as we receive Read() calls. | 97 // them up and hand them out as we receive Read() calls. |
104 std::list<QueuedAudioBuffer> queued_audio_; | 98 std::list<QueuedAudioBuffer> queued_audio_; |
105 | 99 |
106 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder); | 100 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder); |
107 }; | 101 }; |
108 | 102 |
109 } // namespace media | 103 } // namespace media |
110 | 104 |
111 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ | 105 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ |
OLD | NEW |