Add new members to AudioEncoderOpus::Config

Adding fec_enabled and max_playback_rate_hz.

BUG=3926
COAUTHOR:kwiberg@webrtc.org

R=minyue@webrtc.org, tina.legrand@webrtc.org
TBR=kwiberg@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/39659004

Cr-Commit-Position: refs/heads/master@{#8207}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8207 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrik.lundin@webrtc.org 2015-01-29 16:08:40 +00:00
parent 7a37bfc240
commit 13980253f0
2 changed files with 17 additions and 4 deletions

View File

@ -23,7 +23,6 @@ const int kMaxBitrateBps = 512000;
// We always encode at 48 kHz.
const int kSampleRateHz = 48000;
int16_t ClampInt16(size_t x) {
return static_cast<int16_t>(
std::min(x, static_cast<size_t>(std::numeric_limits<int16_t>::max())));
@ -41,13 +40,15 @@ AudioEncoderOpus::Config::Config()
num_channels(1),
payload_type(120),
application(kVoip),
bitrate_bps(64000) {
bitrate_bps(64000),
fec_enabled(false),
max_playback_rate_hz(48000) {
}
bool AudioEncoderOpus::Config::IsOk() const {
if (frame_size_ms <= 0 || frame_size_ms % 10 != 0)
return false;
if (num_channels <= 0)
if (num_channels != 1 && num_channels != 2)
return false;
if (bitrate_bps < kMinBitrateBps || bitrate_bps > kMaxBitrateBps)
return false;
@ -67,6 +68,13 @@ AudioEncoderOpus::AudioEncoderOpus(const Config& config)
input_buffer_.reserve(num_10ms_frames_per_packet_ * samples_per_10ms_frame_);
CHECK_EQ(0, WebRtcOpus_EncoderCreate(&inst_, num_channels_, application_));
SetTargetBitrate(config.bitrate_bps);
if (config.fec_enabled) {
CHECK_EQ(0, WebRtcOpus_EnableFec(inst_));
} else {
CHECK_EQ(0, WebRtcOpus_DisableFec(inst_));
}
CHECK_EQ(0,
WebRtcOpus_SetMaxPlaybackRate(inst_, config.max_playback_rate_hz));
}
AudioEncoderOpus::~AudioEncoderOpus() {

View File

@ -18,7 +18,10 @@
namespace webrtc {
class AudioEncoderOpus : public AudioEncoder {
// NOTE: This class has neither ThreadChecker, nor locks. The owner of an
// AudioEncoderOpus object must ensure that it is not accessed concurrently.
class AudioEncoderOpus final : public AudioEncoder {
public:
enum ApplicationMode {
kVoip = 0,
@ -33,6 +36,8 @@ class AudioEncoderOpus : public AudioEncoder {
int payload_type;
ApplicationMode application;
int bitrate_bps;
bool fec_enabled;
int max_playback_rate_hz;
};
explicit AudioEncoderOpus(const Config& config);