blob: d0ad27f4ea63db78c2b612243f0295bd721fa457 [file] [log] [blame]
// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
// source code is governed by a BSD-style license that can be found in the
// LICENSE file.
#include "media/base/factory.h"
#include "media/filters/decoder_base.h"
struct AVCodecContext;
namespace media {
// Forward declaration for scoped_ptr_malloc.
class ScopedPtrAVFree;
class FFmpegAudioDecoder : public DecoderBase<AudioDecoder, Buffer> {
static FilterFactory* CreateFactory() {
return new FilterFactoryImpl0<FFmpegAudioDecoder>();
static bool IsMediaFormatSupported(const MediaFormat& media_format);
virtual void DoInitialize(DemuxerStream* demuxer_stream, bool* success,
Task* done_cb);
virtual void DoSeek(base::TimeDelta time, Task* done_cb);
virtual void DoDecode(Buffer* input);
friend class FilterFactoryImpl0<FFmpegAudioDecoder>;
virtual ~FFmpegAudioDecoder();
// 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().
AVCodecContext* codec_context_;
// 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_;
static const size_t kOutputBufferSize;
} // namespace media