#ifndef MEDIA_FILTERS_OPUS_AUDIO_DECODER_H_
#define MEDIA_FILTERS_OPUS_AUDIO_DECODER_H_
#include "base/callback.h"
#include "base/time/time.h"
#include "media/base/audio_decoder.h"
#include "media/base/demuxer_stream.h"
#include "media/base/sample_format.h"
struct OpusMSDecoder;
namespace base {
class SingleThreadTaskRunner;
}
namespace media {
class AudioBuffer;
class AudioTimestampHelper;
class DecoderBuffer;
struct QueuedAudioBuffer;
class MEDIA_EXPORT OpusAudioDecoder : public AudioDecoder {
public:
explicit OpusAudioDecoder(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
virtual ~OpusAudioDecoder();
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 void Reset(const base::Closure& closure) OVERRIDE;
virtual void Stop() OVERRIDE;
private:
void ReadFromDemuxerStream();
void DecodeBuffer(const scoped_refptr<DecoderBuffer>& input,
const DecodeCB& decode_cb);
bool ConfigureDecoder();
void CloseDecoder();
void ResetTimestampState();
bool Decode(const scoped_refptr<DecoderBuffer>& input,
scoped_refptr<AudioBuffer>* output_buffer);
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
AudioDecoderConfig config_;
OpusMSDecoder* opus_decoder_;
scoped_ptr<AudioTimestampHelper> output_timestamp_helper_;
base::TimeDelta last_input_timestamp_;
int frames_to_discard_;
int frame_delay_at_start_;
base::TimeDelta start_input_timestamp_;
base::TimeDelta timestamp_offset_;
DISALLOW_IMPLICIT_CONSTRUCTORS(OpusAudioDecoder);
};
}
#endif