1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef REMOTING_CODEC_AUDIO_ENCODER_OPUS_H_
6 #define REMOTING_CODEC_AUDIO_ENCODER_OPUS_H_
8 #include "remoting/codec/audio_encoder.h"
10 #include "remoting/proto/audio.pb.h"
16 class MultiChannelResampler
;
23 class AudioEncoderOpus
: public AudioEncoder
{
26 ~AudioEncoderOpus() override
;
28 // AudioEncoder interface.
29 scoped_ptr
<AudioPacket
> Encode(scoped_ptr
<AudioPacket
> packet
) override
;
33 void DestroyEncoder();
34 bool ResetForPacket(AudioPacket
* packet
);
36 void FetchBytesToResample(int resampler_frame_delay
,
37 media::AudioBus
* audio_bus
);
40 AudioPacket::Channels channels_
;
41 OpusEncoder
* encoder_
;
44 scoped_ptr
<media::MultiChannelResampler
> resampler_
;
45 scoped_ptr
<char[]> resample_buffer_
;
46 scoped_ptr
<media::AudioBus
> resampler_bus_
;
48 // Used to pass packet to the FetchBytesToResampler() callback.
49 const char* resampling_data_
;
50 int resampling_data_size_
;
51 int resampling_data_pos_
;
53 // Left-over unencoded samples from the previous AudioPacket.
54 scoped_ptr
<int16
[]> leftover_buffer_
;
55 int leftover_buffer_size_
;
56 int leftover_samples_
;
58 DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus
);
61 } // namespace remoting
63 #endif // REMOTING_CODEC_AUDIO_ENCODER_OPUS_H_