Chromium Code Reviews| 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 <list> |
| 9 | |
| 10 #include "base/message_loop.h" | |
| 11 #include "media/base/filters.h" | |
| 12 #include "media/base/data_buffer.h" | |
| 9 | 13 |
| 10 struct AVCodecContext; | 14 struct AVCodecContext; |
| 11 | 15 |
| 12 namespace media { | 16 namespace media { |
| 13 | 17 |
| 14 // Forward declaration for scoped_ptr_malloc. | 18 class FFmpegAudioDecoder : public AudioDecoder { |
| 15 class ScopedPtrAVFree; | |
| 16 | |
| 17 class FFmpegAudioDecoder : public DecoderBase<AudioDecoder, Buffer> { | |
| 18 public: | 19 public: |
| 19 explicit FFmpegAudioDecoder(MessageLoop* message_loop); | 20 explicit FFmpegAudioDecoder(MessageLoop* message_loop); |
| 20 virtual ~FFmpegAudioDecoder(); | 21 virtual ~FFmpegAudioDecoder(); |
| 21 | 22 |
| 23 // Filter implementation. | |
| 24 virtual void Play(FilterCallback* callback); | |
|
acolwell GONE FROM CHROMIUM
2011/05/13 19:35:37
Remove because it isn't used. I envision AudioDeco
scherkus (not reviewing)
2011/09/11 14:49:22
Done.
| |
| 25 virtual void Pause(FilterCallback* callback); | |
|
acolwell GONE FROM CHROMIUM
2011/05/13 19:35:37
ditto
scherkus (not reviewing)
2011/09/11 14:49:22
Done.
| |
| 26 virtual void Flush(FilterCallback* callback); | |
| 27 virtual void Stop(FilterCallback* callback); | |
| 28 virtual void Seek(base::TimeDelta time, FilterCallback* callback); | |
|
acolwell GONE FROM CHROMIUM
2011/05/13 19:35:37
ditto
scherkus (not reviewing)
2011/09/11 14:49:22
Done.
| |
| 29 | |
| 22 // AudioDecoder implementation. | 30 // AudioDecoder implementation. |
| 31 virtual void Initialize(DemuxerStream* stream, FilterCallback* callback, | |
| 32 StatisticsCallback* stats_callback); | |
| 23 virtual AudioDecoderConfig config(); | 33 virtual AudioDecoderConfig config(); |
| 24 virtual void ProduceAudioSamples(scoped_refptr<Buffer> output); | 34 virtual void ProduceAudioSamples(scoped_refptr<Buffer> buffer); |
| 25 | |
| 26 protected: | |
| 27 virtual void DoInitialize(DemuxerStream* demuxer_stream, bool* success, | |
| 28 Task* done_cb); | |
| 29 | |
| 30 virtual void DoSeek(base::TimeDelta time, Task* done_cb); | |
| 31 | |
| 32 virtual void DoDecode(Buffer* input); | |
| 33 | 35 |
| 34 private: | 36 private: |
| 35 // Calculates the duration of an audio buffer based on the sample rate, | 37 void DoInitialize(DemuxerStream* stream, FilterCallback* callback, |
|
acolwell GONE FROM CHROMIUM
2011/05/13 19:35:37
Add comments for methods.
scherkus (not reviewing)
2011/09/11 14:49:22
Done.
| |
| 36 // channels and bits per sample given the size in bytes. | 38 StatisticsCallback* stats_callback); |
| 37 base::TimeDelta CalculateDuration(size_t size); | 39 void DoQueueOutputBuffer(scoped_refptr<Buffer> output); |
| 40 void DoDecodeInputBuffer(scoped_refptr<Buffer> input); | |
| 38 | 41 |
| 39 // A FFmpeg defined structure that holds decoder information, this variable | 42 void DecodeFinished(scoped_refptr<Buffer> output, |
| 40 // is initialized in OnInitialize(). | 43 const PipelineStatistics& statistics); |
| 44 | |
| 45 void ReadFromDemuxerStream(); | |
| 46 void OnReadComplete(Buffer* buffer); | |
| 47 void UpdateDurationAndTimestamp(Buffer* input, DataBuffer* output); | |
| 48 base::TimeDelta CalculateDuration(int size); | |
| 49 | |
| 50 MessageLoop* message_loop_; | |
| 51 | |
| 52 DemuxerStream* demuxer_stream_; | |
|
acolwell GONE FROM CHROMIUM
2011/05/13 19:35:37
scoped_refptr?
scherkus (not reviewing)
2011/09/11 14:49:22
Done.
| |
| 53 scoped_ptr<StatisticsCallback> stats_callback_; | |
| 41 AVCodecContext* codec_context_; | 54 AVCodecContext* codec_context_; |
| 42 | 55 |
| 43 AudioDecoderConfig config_; | 56 AudioDecoderConfig config_; |
| 44 | 57 |
| 45 // Estimated timestamp for next packet. Useful for packets without timestamps. | |
| 46 base::TimeDelta estimated_next_timestamp_; | 58 base::TimeDelta estimated_next_timestamp_; |
| 47 | 59 |
| 48 // Data buffer to carry decoded raw PCM samples. This buffer is created by | 60 // Holds decoded audio. |
| 49 // av_malloc() and is used throughout the lifetime of this class. | 61 scoped_ptr<int16_t> decoded_audio_; |
| 50 scoped_ptr_malloc<uint8, ScopedPtrAVFree> output_buffer_; | |
| 51 | 62 |
| 52 static const size_t kOutputBufferSize; | 63 // Holds downstream-provided buffers. |
| 64 std::list<scoped_refptr<Buffer> > output_buffers_; | |
| 53 | 65 |
| 54 DISALLOW_COPY_AND_ASSIGN(FFmpegAudioDecoder); | 66 // Tracks reads issued for compressed data. |
| 67 int pending_reads_; | |
| 68 | |
| 69 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder); | |
| 55 }; | 70 }; |
| 56 | 71 |
| 57 } // namespace media | 72 } // namespace media |
| 58 | 73 |
| 59 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ | 74 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ |
| OLD | NEW |