Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(530)

Unified Diff: media/filters/ffmpeg_audio_decoder.h

Issue 6901135: Rewriting FFmpegAudioDecoder and eliminating DecoderBase. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: fixes Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/filters/ffmpeg_audio_decoder.h
diff --git a/media/filters/ffmpeg_audio_decoder.h b/media/filters/ffmpeg_audio_decoder.h
index 1025083598c29fba952380f309024c7c301a50cf..73002f8a94ecce2593d35500d6d4df634a325cbd 100644
--- a/media/filters/ffmpeg_audio_decoder.h
+++ b/media/filters/ffmpeg_audio_decoder.h
@@ -5,54 +5,73 @@
#ifndef MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_
#define MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_
-#include "media/filters/decoder_base.h"
+#include <list>
+
+#include "base/message_loop.h"
+#include "media/base/filters.h"
struct AVCodecContext;
namespace media {
-// Forward declaration for scoped_ptr_malloc.
-class ScopedPtrAVFree;
+class DataBuffer;
-class MEDIA_EXPORT FFmpegAudioDecoder
- : public DecoderBase<AudioDecoder, Buffer> {
+class MEDIA_EXPORT FFmpegAudioDecoder : public AudioDecoder {
public:
explicit FFmpegAudioDecoder(MessageLoop* message_loop);
virtual ~FFmpegAudioDecoder();
- // AudioDecoder implementation.
- virtual AudioDecoderConfig config();
- virtual void ProduceAudioSamples(scoped_refptr<Buffer> output);
-
- protected:
- virtual void DoInitialize(DemuxerStream* demuxer_stream, bool* success,
- Task* done_cb);
-
- virtual void DoSeek(base::TimeDelta time, Task* done_cb);
+ // Filter implementation.
+ virtual void Flush(FilterCallback* callback) OVERRIDE;
- virtual void DoDecode(Buffer* input);
+ // AudioDecoder implementation.
+ virtual void Initialize(DemuxerStream* stream, FilterCallback* callback,
+ StatisticsCallback* stats_callback) OVERRIDE;
+ virtual AudioDecoderConfig config() OVERRIDE;
+ virtual void ProduceAudioSamples(scoped_refptr<Buffer> buffer) OVERRIDE;
private:
- // Calculates the duration of an audio buffer based on the sample rate,
- // channels and bits per sample given the size in bytes.
- base::TimeDelta CalculateDuration(size_t size);
-
- // A FFmpeg defined structure that holds decoder information, this variable
- // is initialized in OnInitialize().
+ // Methods running on decoder thread.
+ void DoInitialize(scoped_refptr<DemuxerStream> stream,
acolwell GONE FROM CHROMIUM 2011/09/16 19:04:37 const&
scherkus (not reviewing) 2011/09/16 20:39:40 Done.
+ FilterCallback* callback,
+ StatisticsCallback* stats_callback);
+ void DoFlush(FilterCallback* callback);
+ void DoProduceAudioSamples(scoped_refptr<Buffer> output);
acolwell GONE FROM CHROMIUM 2011/09/16 19:04:37 const&
scherkus (not reviewing) 2011/09/16 20:39:40 Done.
+ void DoDecodeBuffer(const scoped_refptr<Buffer>& input);
+
+ // Reads from the demuxer stream with corresponding callback method.
+ void ReadFromDemuxerStream();
+ void DecodeBuffer(Buffer* buffer);
+
+ // Updates the output buffer's duration and timestamp based on the input
+ // buffer. Will fall back to an estimated timestamp if the input lacks a
+ // valid timestamp.
+ void UpdateDurationAndTimestamp(const Buffer* input, DataBuffer* output);
+
+ // Calculates duration based on size of decoded audio bytes.
+ base::TimeDelta CalculateDuration(int size);
+
+ MessageLoop* message_loop_;
+
+ scoped_refptr<DemuxerStream> demuxer_stream_;
+ scoped_ptr<StatisticsCallback> stats_callback_;
AVCodecContext* codec_context_;
AudioDecoderConfig config_;
- // Estimated timestamp for next packet. Useful for packets without timestamps.
base::TimeDelta estimated_next_timestamp_;
- // Data buffer to carry decoded raw PCM samples. This buffer is created by
- // av_malloc() and is used throughout the lifetime of this class.
- scoped_ptr_malloc<uint8, ScopedPtrAVFree> output_buffer_;
+ // Holds decoded audio.
+ const int decoded_audio_size_;
+ uint8* decoded_audio_; // Allocated via av_malloc().
acolwell GONE FROM CHROMIUM 2011/09/16 19:04:37 It would be nice if you explained, in a comment, w
scherkus (not reviewing) 2011/09/16 20:39:40 Done.
+
+ // Holds downstream-provided buffers.
+ std::list<scoped_refptr<Buffer> > output_buffers_;
- static const size_t kOutputBufferSize;
+ // Tracks reads issued for compressed data.
+ int pending_reads_;
- DISALLOW_COPY_AND_ASSIGN(FFmpegAudioDecoder);
+ DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder);
};
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698