#ifndef REMOTING_CODEC_AUDIO_ENCODER_OPUS_H_
#define REMOTING_CODEC_AUDIO_ENCODER_OPUS_H_
#include "remoting/codec/audio_encoder.h"
#include "remoting/proto/audio.pb.h"
struct OpusEncoder;
namespace media {
class AudioBus;
class MultiChannelResampler;
}
namespace remoting {
class AudioPacket;
class AudioEncoderOpus : public AudioEncoder {
public:
AudioEncoderOpus();
virtual ~AudioEncoderOpus();
virtual scoped_ptr<AudioPacket> Encode(
scoped_ptr<AudioPacket> packet) OVERRIDE;
private:
void InitEncoder();
void DestroyEncoder();
bool ResetForPacket(AudioPacket* packet);
void FetchBytesToResample(int resampler_frame_delay,
media::AudioBus* audio_bus);
int sampling_rate_;
AudioPacket::Channels channels_;
OpusEncoder* encoder_;
int frame_size_;
scoped_ptr<media::MultiChannelResampler> resampler_;
scoped_ptr<char[]> resample_buffer_;
scoped_ptr<media::AudioBus> resampler_bus_;
const char* resampling_data_;
int resampling_data_size_;
int resampling_data_pos_;
scoped_ptr<int16[]> leftover_buffer_;
int leftover_buffer_size_;
int leftover_samples_;
DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus);
};
}
#endif