Renaming SetOpusMaxBandwidth to SetOpusMaxPlaybackRate
This is to maintain the consistency with the Opus codec option "maxplaybackrate" defined in http://tools.ietf.org/html/draft-spittka-payload-rtp-opus-03 BUG= R=tina.legrand@webrtc.org Review URL: https://webrtc-codereview.appspot.com/14279004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7038 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -73,25 +73,29 @@ int16_t WebRtcOpus_SetBitRate(OpusEncInst* inst, int32_t rate);
|
|||||||
int16_t WebRtcOpus_SetPacketLossRate(OpusEncInst* inst, int32_t loss_rate);
|
int16_t WebRtcOpus_SetPacketLossRate(OpusEncInst* inst, int32_t loss_rate);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* WebRtcOpus_SetMaxBandwidth(...)
|
* WebRtcOpus_SetMaxPlaybackRate(...)
|
||||||
*
|
*
|
||||||
* Configures the maximum bandwidth for encoding. This can be taken as a hint
|
* Configures the maximum playback rate for encoding. Due to hardware
|
||||||
* about the maximum output bandwidth that the receiver is capable to render,
|
* limitations, the receiver may render audio up to a playback rate. Opus
|
||||||
* due to hardware limitations. Sending signals with higher audio bandwidth
|
* encoder can use this information to optimize for network usage and encoding
|
||||||
* results in higher than necessary network usage and encoding complexity.
|
* complexity. This will affect the audio bandwidth in the coded audio. However,
|
||||||
|
* the input/output sample rate is not affected.
|
||||||
*
|
*
|
||||||
* Input:
|
* Input:
|
||||||
* - inst : Encoder context
|
* - inst : Encoder context
|
||||||
* - bandwidth : Maximum encoding bandwidth in Hz.
|
* - frequency_hz : Maximum playback rate in Hz.
|
||||||
* This parameter can take any value, but values
|
* This parameter can take any value. The relation
|
||||||
* other than Opus typical bandwidths: 4000, 6000,
|
* between the value and the Opus internal mode is
|
||||||
* 8000, 12000, and 20000 will be rounded up (values
|
* as following:
|
||||||
* greater than 20000 will be rounded down) to
|
* frequency_hz <= 8000 narrow band
|
||||||
* these values.
|
* 8000 < frequency_hz <= 12000 medium band
|
||||||
|
* 12000 < frequency_hz <= 16000 wide band
|
||||||
|
* 16000 < frequency_hz <= 24000 super wide band
|
||||||
|
* frequency_hz > 24000 full band
|
||||||
* Return value : 0 - Success
|
* Return value : 0 - Success
|
||||||
* -1 - Error
|
* -1 - Error
|
||||||
*/
|
*/
|
||||||
int16_t WebRtcOpus_SetMaxBandwidth(OpusEncInst* inst, int32_t bandwidth);
|
int16_t WebRtcOpus_SetMaxPlaybackRate(OpusEncInst* inst, int32_t frequency_hz);
|
||||||
|
|
||||||
/* TODO(minyue): Check whether an API to check the FEC and the packet loss rate
|
/* TODO(minyue): Check whether an API to check the FEC and the packet loss rate
|
||||||
* is needed. It might not be very useful since there are not many use cases and
|
* is needed. It might not be very useful since there are not many use cases and
|
||||||
|
|||||||
@@ -99,19 +99,19 @@ int16_t WebRtcOpus_SetPacketLossRate(OpusEncInst* inst, int32_t loss_rate) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t WebRtcOpus_SetMaxBandwidth(OpusEncInst* inst, int32_t bandwidth) {
|
int16_t WebRtcOpus_SetMaxPlaybackRate(OpusEncInst* inst, int32_t frequency_hz) {
|
||||||
opus_int32 set_bandwidth;
|
opus_int32 set_bandwidth;
|
||||||
|
|
||||||
if (!inst)
|
if (!inst)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (bandwidth <= 4000) {
|
if (frequency_hz <= 8000) {
|
||||||
set_bandwidth = OPUS_BANDWIDTH_NARROWBAND;
|
set_bandwidth = OPUS_BANDWIDTH_NARROWBAND;
|
||||||
} else if (bandwidth <= 6000) {
|
} else if (frequency_hz <= 12000) {
|
||||||
set_bandwidth = OPUS_BANDWIDTH_MEDIUMBAND;
|
set_bandwidth = OPUS_BANDWIDTH_MEDIUMBAND;
|
||||||
} else if (bandwidth <= 8000) {
|
} else if (frequency_hz <= 16000) {
|
||||||
set_bandwidth = OPUS_BANDWIDTH_WIDEBAND;
|
set_bandwidth = OPUS_BANDWIDTH_WIDEBAND;
|
||||||
} else if (bandwidth <= 12000) {
|
} else if (frequency_hz <= 24000) {
|
||||||
set_bandwidth = OPUS_BANDWIDTH_SUPERWIDEBAND;
|
set_bandwidth = OPUS_BANDWIDTH_SUPERWIDEBAND;
|
||||||
} else {
|
} else {
|
||||||
set_bandwidth = OPUS_BANDWIDTH_FULLBAND;
|
set_bandwidth = OPUS_BANDWIDTH_FULLBAND;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class OpusTest : public ::testing::Test {
|
|||||||
OpusTest();
|
OpusTest();
|
||||||
virtual void SetUp();
|
virtual void SetUp();
|
||||||
|
|
||||||
void TestSetMaxBandwidth(opus_int32 expect, int32_t set);
|
void TestSetMaxPlaybackRate(opus_int32 expect, int32_t set);
|
||||||
|
|
||||||
WebRtcOpusEncInst* opus_mono_encoder_;
|
WebRtcOpusEncInst* opus_mono_encoder_;
|
||||||
WebRtcOpusEncInst* opus_stereo_encoder_;
|
WebRtcOpusEncInst* opus_stereo_encoder_;
|
||||||
@@ -66,15 +66,15 @@ void OpusTest::SetUp() {
|
|||||||
input_file = NULL;
|
input_file = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpusTest::TestSetMaxBandwidth(opus_int32 expect, int32_t set) {
|
void OpusTest::TestSetMaxPlaybackRate(opus_int32 expect, int32_t set) {
|
||||||
opus_int32 bandwidth;
|
opus_int32 bandwidth;
|
||||||
// Test mono encoder.
|
// Test mono encoder.
|
||||||
EXPECT_EQ(0, WebRtcOpus_SetMaxBandwidth(opus_mono_encoder_, set));
|
EXPECT_EQ(0, WebRtcOpus_SetMaxPlaybackRate(opus_mono_encoder_, set));
|
||||||
opus_encoder_ctl(opus_mono_encoder_->encoder,
|
opus_encoder_ctl(opus_mono_encoder_->encoder,
|
||||||
OPUS_GET_MAX_BANDWIDTH(&bandwidth));
|
OPUS_GET_MAX_BANDWIDTH(&bandwidth));
|
||||||
EXPECT_EQ(expect, bandwidth);
|
EXPECT_EQ(expect, bandwidth);
|
||||||
// Test stereo encoder.
|
// Test stereo encoder.
|
||||||
EXPECT_EQ(0, WebRtcOpus_SetMaxBandwidth(opus_stereo_encoder_, set));
|
EXPECT_EQ(0, WebRtcOpus_SetMaxPlaybackRate(opus_stereo_encoder_, set));
|
||||||
opus_encoder_ctl(opus_stereo_encoder_->encoder,
|
opus_encoder_ctl(opus_stereo_encoder_->encoder,
|
||||||
OPUS_GET_MAX_BANDWIDTH(&bandwidth));
|
OPUS_GET_MAX_BANDWIDTH(&bandwidth));
|
||||||
EXPECT_EQ(expect, bandwidth);
|
EXPECT_EQ(expect, bandwidth);
|
||||||
@@ -355,22 +355,25 @@ TEST_F(OpusTest, OpusSetPacketLossRate) {
|
|||||||
EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_stereo_encoder_));
|
EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_stereo_encoder_));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(OpusTest, OpusSetMaxBandwidth) {
|
TEST_F(OpusTest, OpusSetMaxPlaybackRate) {
|
||||||
// Test without creating encoder memory.
|
// Test without creating encoder memory.
|
||||||
EXPECT_EQ(-1, WebRtcOpus_SetMaxBandwidth(opus_mono_encoder_, 20000));
|
EXPECT_EQ(-1, WebRtcOpus_SetMaxPlaybackRate(opus_mono_encoder_, 20000));
|
||||||
EXPECT_EQ(-1, WebRtcOpus_SetMaxBandwidth(opus_stereo_encoder_, 20000));
|
EXPECT_EQ(-1, WebRtcOpus_SetMaxPlaybackRate(opus_stereo_encoder_, 20000));
|
||||||
|
|
||||||
// Create encoder memory, try with different bitrates.
|
// Create encoder memory, try with different bitrates.
|
||||||
EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_mono_encoder_, 1));
|
EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_mono_encoder_, 1));
|
||||||
EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_stereo_encoder_, 2));
|
EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_stereo_encoder_, 2));
|
||||||
|
|
||||||
TestSetMaxBandwidth(OPUS_BANDWIDTH_FULLBAND, 24000);
|
TestSetMaxPlaybackRate(OPUS_BANDWIDTH_FULLBAND, 48000);
|
||||||
TestSetMaxBandwidth(OPUS_BANDWIDTH_FULLBAND, 14000);
|
TestSetMaxPlaybackRate(OPUS_BANDWIDTH_FULLBAND, 24001);
|
||||||
TestSetMaxBandwidth(OPUS_BANDWIDTH_SUPERWIDEBAND, 10000);
|
TestSetMaxPlaybackRate(OPUS_BANDWIDTH_SUPERWIDEBAND, 24000);
|
||||||
TestSetMaxBandwidth(OPUS_BANDWIDTH_WIDEBAND, 7000);
|
TestSetMaxPlaybackRate(OPUS_BANDWIDTH_SUPERWIDEBAND, 16001);
|
||||||
TestSetMaxBandwidth(OPUS_BANDWIDTH_MEDIUMBAND, 6000);
|
TestSetMaxPlaybackRate(OPUS_BANDWIDTH_WIDEBAND, 16000);
|
||||||
TestSetMaxBandwidth(OPUS_BANDWIDTH_NARROWBAND, 4000);
|
TestSetMaxPlaybackRate(OPUS_BANDWIDTH_WIDEBAND, 12001);
|
||||||
TestSetMaxBandwidth(OPUS_BANDWIDTH_NARROWBAND, 3000);
|
TestSetMaxPlaybackRate(OPUS_BANDWIDTH_MEDIUMBAND, 12000);
|
||||||
|
TestSetMaxPlaybackRate(OPUS_BANDWIDTH_MEDIUMBAND, 8001);
|
||||||
|
TestSetMaxPlaybackRate(OPUS_BANDWIDTH_NARROWBAND, 8000);
|
||||||
|
TestSetMaxPlaybackRate(OPUS_BANDWIDTH_NARROWBAND, 4000);
|
||||||
|
|
||||||
// Free memory.
|
// Free memory.
|
||||||
EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_mono_encoder_));
|
EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_mono_encoder_));
|
||||||
|
|||||||
@@ -1000,9 +1000,9 @@ int16_t ACMGenericCodec::REDPayloadISAC(const int32_t /* isac_rate */,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ACMGenericCodec::SetOpusMaxBandwidth(int /* max_bandwidth */) {
|
int ACMGenericCodec::SetOpusMaxPlaybackRate(int /* frequency_hz */) {
|
||||||
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceAudioCoding, unique_id_,
|
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceAudioCoding, unique_id_,
|
||||||
"The send-codec is not Opus, failed to set maximum bandwidth.");
|
"The send-codec is not Opus, failed to set maximum playback rate.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -538,21 +538,20 @@ class ACMGenericCodec {
|
|||||||
int16_t* payload_len_bytes);
|
int16_t* payload_len_bytes);
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// int SetOpusMaxBandwidth()
|
// int SetOpusMaxPlaybackRate()
|
||||||
// Sets maximum required encoding bandwidth for Opus. This is to tell Opus
|
// Sets maximum playback rate the receiver will render, if the codec is Opus.
|
||||||
// that it is enough to code the input audio up to a bandwidth. A use case of
|
// This is to tell Opus that it is enough to code the input audio up to a
|
||||||
// this is when the receiver cannot render the full band. Opus can take this
|
// bandwidth. Opus can take this information to optimize the bit rate and
|
||||||
// information to optimize the bit rate and increase the computation
|
// increase the computation efficiency.
|
||||||
// efficiency.
|
|
||||||
//
|
//
|
||||||
// Input:
|
// Input:
|
||||||
// -max_bandwidth : maximum required bandwidth.
|
// -frequency_hz : maximum playback rate in Hz.
|
||||||
//
|
//
|
||||||
// Return value:
|
// Return value:
|
||||||
// -1 if failed or on codecs other than Opus
|
// -1 if failed or on codecs other than Opus
|
||||||
// 0 if succeeded.
|
// 0 if succeeded.
|
||||||
//
|
//
|
||||||
virtual int SetOpusMaxBandwidth(int /* max_bandwidth */);
|
virtual int SetOpusMaxPlaybackRate(int /* frequency_hz */);
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// HasFrameToEncode()
|
// HasFrameToEncode()
|
||||||
|
|||||||
@@ -263,9 +263,9 @@ int ACMOpus::SetPacketLossRate(int loss_rate) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ACMOpus::SetOpusMaxBandwidth(int max_bandwidth) {
|
int ACMOpus::SetOpusMaxPlaybackRate(int frequency_hz) {
|
||||||
// Ask the encoder to change the maximum required bandwidth.
|
// Informs Opus encoder of the maximum playback rate the receiver will render.
|
||||||
return WebRtcOpus_SetMaxBandwidth(encoder_inst_ptr_, max_bandwidth);
|
return WebRtcOpus_SetMaxPlaybackRate(encoder_inst_ptr_, frequency_hz);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // WEBRTC_CODEC_OPUS
|
#endif // WEBRTC_CODEC_OPUS
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class ACMOpus : public ACMGenericCodec {
|
|||||||
|
|
||||||
virtual int SetPacketLossRate(int loss_rate) OVERRIDE;
|
virtual int SetPacketLossRate(int loss_rate) OVERRIDE;
|
||||||
|
|
||||||
virtual int SetOpusMaxBandwidth(int max_bandwidth) OVERRIDE;
|
virtual int SetOpusMaxPlaybackRate(int frequency_hz) OVERRIDE;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void DestructEncoderSafe();
|
void DestructEncoderSafe();
|
||||||
|
|||||||
@@ -1911,13 +1911,13 @@ int AudioCodingModuleImpl::ConfigISACBandwidthEstimator(
|
|||||||
frame_size_ms, rate_bit_per_sec, enforce_frame_size);
|
frame_size_ms, rate_bit_per_sec, enforce_frame_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Informs Opus encoder about the maximum audio bandwidth needs to be encoded.
|
// Informs Opus encoder of the maximum playback rate the receiver will render.
|
||||||
int AudioCodingModuleImpl::SetOpusMaxBandwidth(int bandwidth_hz) {
|
int AudioCodingModuleImpl::SetOpusMaxPlaybackRate(int frequency_hz) {
|
||||||
CriticalSectionScoped lock(acm_crit_sect_);
|
CriticalSectionScoped lock(acm_crit_sect_);
|
||||||
if (!HaveValidEncoder("SetOpusMaxBandwidth")) {
|
if (!HaveValidEncoder("SetOpusMaxPlaybackRate")) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return codecs_[current_send_codec_idx_]->SetOpusMaxBandwidth(bandwidth_hz);
|
return codecs_[current_send_codec_idx_]->SetOpusMaxPlaybackRate(frequency_hz);
|
||||||
}
|
}
|
||||||
|
|
||||||
int AudioCodingModuleImpl::PlayoutTimestamp(uint32_t* timestamp) {
|
int AudioCodingModuleImpl::PlayoutTimestamp(uint32_t* timestamp) {
|
||||||
|
|||||||
@@ -232,9 +232,9 @@ class AudioCodingModuleImpl : public AudioCodingModule {
|
|||||||
int rate_bit_per_sec,
|
int rate_bit_per_sec,
|
||||||
bool enforce_frame_size = false);
|
bool enforce_frame_size = false);
|
||||||
|
|
||||||
// If current send codec is Opus, informs it about the maximum audio
|
// If current send codec is Opus, informs it about the maximum playback rate
|
||||||
// bandwidth needs to be encoded.
|
// the receiver will render.
|
||||||
int SetOpusMaxBandwidth(int bandwidth_hz);
|
int SetOpusMaxPlaybackRate(int frequency_hz);
|
||||||
|
|
||||||
int UnregisterReceiveCodec(uint8_t payload_type);
|
int UnregisterReceiveCodec(uint8_t payload_type);
|
||||||
|
|
||||||
|
|||||||
@@ -916,21 +916,20 @@ class AudioCodingModule: public Module {
|
|||||||
bool enforce_frame_size = false) = 0;
|
bool enforce_frame_size = false) = 0;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// int SetOpusMaxBandwidth()
|
// int SetOpusMaxPlaybackRate()
|
||||||
// If current send codec is Opus, informs it about maximum audio bandwidth
|
// If current send codec is Opus, informs it about maximum playback rate the
|
||||||
// needs to be encoded. A use case of this is when the receiver can only play
|
// receiver will render. Opus can use this information to optimize the bit
|
||||||
// audio up to frequency limit. Opus can use this information to optimize
|
// rate and increase the computation efficiency.
|
||||||
// the bit rate and increase the computation efficiency.
|
|
||||||
//
|
//
|
||||||
// Input:
|
// Input:
|
||||||
// -banbwidth_hz : maximum bandwidth in Hz.
|
// -frequency_hz : maximum playback rate in Hz.
|
||||||
//
|
//
|
||||||
// Return value:
|
// Return value:
|
||||||
// -1 if current send codec is not Opus or
|
// -1 if current send codec is not Opus or
|
||||||
// error occurred in setting the bandwidth,
|
// error occurred in setting the maximum playback rate,
|
||||||
// 0 maximum bandwidth is set successfully.
|
// 0 maximum bandwidth is set successfully.
|
||||||
//
|
//
|
||||||
virtual int SetOpusMaxBandwidth(int banbwidth_hz) = 0;
|
virtual int SetOpusMaxPlaybackRate(int frequency_hz) = 0;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// statistics
|
// statistics
|
||||||
|
|||||||
@@ -1751,14 +1751,14 @@ Channel::SetSendCNPayloadType(int type, PayloadFrequencies frequency)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Channel::SetOpusMaxBandwidth(int bandwidth_hz) {
|
int Channel::SetOpusMaxPlaybackRate(int frequency_hz) {
|
||||||
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
|
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
|
||||||
"Channel::SetOpusMaxBandwidth()");
|
"Channel::SetOpusMaxPlaybackRate()");
|
||||||
|
|
||||||
if (audio_coding_->SetOpusMaxBandwidth(bandwidth_hz) != 0) {
|
if (audio_coding_->SetOpusMaxPlaybackRate(frequency_hz) != 0) {
|
||||||
_engineStatisticsPtr->SetLastError(
|
_engineStatisticsPtr->SetLastError(
|
||||||
VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
|
VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
|
||||||
"SetOpusMaxBandwidth() failed to set maximum encoding bandwidth");
|
"SetOpusMaxPlaybackRate() failed to set maximum playback rate");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ public:
|
|||||||
int32_t SetRecPayloadType(const CodecInst& codec);
|
int32_t SetRecPayloadType(const CodecInst& codec);
|
||||||
int32_t GetRecPayloadType(CodecInst& codec);
|
int32_t GetRecPayloadType(CodecInst& codec);
|
||||||
int32_t SetSendCNPayloadType(int type, PayloadFrequencies frequency);
|
int32_t SetSendCNPayloadType(int type, PayloadFrequencies frequency);
|
||||||
int SetOpusMaxBandwidth(int bandwidth_hz);
|
int SetOpusMaxPlaybackRate(int frequency_hz);
|
||||||
|
|
||||||
// VoE dual-streaming.
|
// VoE dual-streaming.
|
||||||
int SetSecondarySendCodec(const CodecInst& codec, int red_payload_type);
|
int SetSecondarySendCodec(const CodecInst& codec, int red_payload_type);
|
||||||
|
|||||||
@@ -126,11 +126,11 @@ public:
|
|||||||
virtual int GetVADStatus(int channel, bool& enabled, VadModes& mode,
|
virtual int GetVADStatus(int channel, bool& enabled, VadModes& mode,
|
||||||
bool& disabledDTX) = 0;
|
bool& disabledDTX) = 0;
|
||||||
|
|
||||||
// Sets the maximum audio bandwidth needs to be encoded in Hz,
|
// If send codec is Opus on a specified |channel|, sets the maximum playback
|
||||||
// |bandwidth_hz|, for the Opus encoder on a specific |channel|.
|
// rate the receiver will render: |frequency_hz| (in Hz).
|
||||||
// TODO(minyue): Make SetOpusMaxBandwidth() pure virtual when
|
// TODO(minyue): Make SetOpusMaxPlaybackRate() pure virtual when
|
||||||
// fakewebrtcvoiceengine in talk is ready.
|
// fakewebrtcvoiceengine in talk is ready.
|
||||||
virtual int SetOpusMaxBandwidth(int channel, int bandwidth_hz) {
|
virtual int SetOpusMaxPlaybackRate(int channel, int frequency_hz) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -130,30 +130,30 @@ TEST_F(CodecTest, VoiceActivityDetectionCanBeTurnedOff) {
|
|||||||
EXPECT_EQ(webrtc::kVadConventional, vad_mode);
|
EXPECT_EQ(webrtc::kVadConventional, vad_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(CodecTest, OpusMaxBandwidthCanBeSet) {
|
TEST_F(CodecTest, OpusMaxPlaybackRateCanBeSet) {
|
||||||
for (int i = 0; i < voe_codec_->NumOfCodecs(); ++i) {
|
for (int i = 0; i < voe_codec_->NumOfCodecs(); ++i) {
|
||||||
voe_codec_->GetCodec(i, codec_instance_);
|
voe_codec_->GetCodec(i, codec_instance_);
|
||||||
if (_stricmp("opus", codec_instance_.plname)) {
|
if (_stricmp("opus", codec_instance_.plname)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
voe_codec_->SetSendCodec(channel_, codec_instance_);
|
voe_codec_->SetSendCodec(channel_, codec_instance_);
|
||||||
// SetOpusMaxBandwidth can handle any integer as the bandwidth. Following
|
// SetOpusMaxPlaybackRate can handle any integer as the bandwidth. Following
|
||||||
// tests some most commonly used numbers.
|
// tests some most commonly used numbers.
|
||||||
EXPECT_EQ(0, voe_codec_->SetOpusMaxBandwidth(channel_, 24000));
|
EXPECT_EQ(0, voe_codec_->SetOpusMaxPlaybackRate(channel_, 48000));
|
||||||
EXPECT_EQ(0, voe_codec_->SetOpusMaxBandwidth(channel_, 16000));
|
EXPECT_EQ(0, voe_codec_->SetOpusMaxPlaybackRate(channel_, 32000));
|
||||||
EXPECT_EQ(0, voe_codec_->SetOpusMaxBandwidth(channel_, 8000));
|
EXPECT_EQ(0, voe_codec_->SetOpusMaxPlaybackRate(channel_, 16000));
|
||||||
EXPECT_EQ(0, voe_codec_->SetOpusMaxBandwidth(channel_, 4000));
|
EXPECT_EQ(0, voe_codec_->SetOpusMaxPlaybackRate(channel_, 8000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(CodecTest, OpusMaxBandwidthCannotBeSetForNonOpus) {
|
TEST_F(CodecTest, OpusMaxPlaybackRateCannotBeSetForNonOpus) {
|
||||||
for (int i = 0; i < voe_codec_->NumOfCodecs(); ++i) {
|
for (int i = 0; i < voe_codec_->NumOfCodecs(); ++i) {
|
||||||
voe_codec_->GetCodec(i, codec_instance_);
|
voe_codec_->GetCodec(i, codec_instance_);
|
||||||
if (!_stricmp("opus", codec_instance_.plname)) {
|
if (!_stricmp("opus", codec_instance_.plname)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
voe_codec_->SetSendCodec(channel_, codec_instance_);
|
voe_codec_->SetSendCodec(channel_, codec_instance_);
|
||||||
EXPECT_EQ(-1, voe_codec_->SetOpusMaxBandwidth(channel_, 16000));
|
EXPECT_EQ(-1, voe_codec_->SetOpusMaxPlaybackRate(channel_, 16000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -445,7 +445,7 @@ void RunTest(std::string out_path) {
|
|||||||
printf("%i. Remove a file-playing channel \n", option_index++);
|
printf("%i. Remove a file-playing channel \n", option_index++);
|
||||||
printf("%i. Toggle Opus stereo (Opus must be selected again to apply "
|
printf("%i. Toggle Opus stereo (Opus must be selected again to apply "
|
||||||
"the setting) \n", option_index++);
|
"the setting) \n", option_index++);
|
||||||
printf("%i. Set Opus maximum audio bandwidth \n", option_index++);
|
printf("%i. Set Opus maximum playback rate \n", option_index++);
|
||||||
printf("%i. Set bit rate (only take effect on codecs that allow the "
|
printf("%i. Set bit rate (only take effect on codecs that allow the "
|
||||||
"change) \n", option_index++);
|
"change) \n", option_index++);
|
||||||
|
|
||||||
@@ -761,10 +761,10 @@ void RunTest(std::string out_path) {
|
|||||||
printf("\n Opus mono enabled (select Opus again to apply the "
|
printf("\n Opus mono enabled (select Opus again to apply the "
|
||||||
"setting). \n");
|
"setting). \n");
|
||||||
} else if (option_selection == option_index++) {
|
} else if (option_selection == option_index++) {
|
||||||
printf("\n Input bandwidth in Hz: ");
|
printf("\n Input maxium playback rate in Hz: ");
|
||||||
int max_playback_rate;
|
int max_playback_rate;
|
||||||
ASSERT_EQ(1, scanf("%i", &max_playback_rate));
|
ASSERT_EQ(1, scanf("%i", &max_playback_rate));
|
||||||
res = codec->SetOpusMaxBandwidth(chan, max_playback_rate);
|
res = codec->SetOpusMaxPlaybackRate(chan, max_playback_rate);
|
||||||
VALIDATE;
|
VALIDATE;
|
||||||
} else if (option_selection == option_index++) {
|
} else if (option_selection == option_index++) {
|
||||||
res = codec->GetSendCodec(chan, cinst);
|
res = codec->GetSendCodec(chan, cinst);
|
||||||
|
|||||||
@@ -418,10 +418,10 @@ int VoECodecImpl::GetVADStatus(int channel, bool& enabled, VadModes& mode,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int VoECodecImpl::SetOpusMaxBandwidth(int channel, int bandwidth_hz) {
|
int VoECodecImpl::SetOpusMaxPlaybackRate(int channel, int frequency_hz) {
|
||||||
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
|
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
|
||||||
"SetOpusMaxBandwidth(channel=%d, bandwidth_hz=%d)", channel,
|
"SetOpusMaxPlaybackRate(channel=%d, frequency_hz=%d)", channel,
|
||||||
bandwidth_hz);
|
frequency_hz);
|
||||||
if (!_shared->statistics().Initialized()) {
|
if (!_shared->statistics().Initialized()) {
|
||||||
_shared->SetLastError(VE_NOT_INITED, kTraceError);
|
_shared->SetLastError(VE_NOT_INITED, kTraceError);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -430,10 +430,10 @@ int VoECodecImpl::SetOpusMaxBandwidth(int channel, int bandwidth_hz) {
|
|||||||
voe::Channel* channelPtr = ch.channel();
|
voe::Channel* channelPtr = ch.channel();
|
||||||
if (channelPtr == NULL) {
|
if (channelPtr == NULL) {
|
||||||
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
|
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
|
||||||
"SetOpusMaxBandwidth failed to locate channel");
|
"SetOpusMaxPlaybackRate failed to locate channel");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return channelPtr->SetOpusMaxBandwidth(bandwidth_hz);
|
return channelPtr->SetOpusMaxPlaybackRate(frequency_hz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoECodecImpl::ACMToExternalCodecRepresentation(CodecInst& toInst,
|
void VoECodecImpl::ACMToExternalCodecRepresentation(CodecInst& toInst,
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
VadModes& mode,
|
VadModes& mode,
|
||||||
bool& disabledDTX);
|
bool& disabledDTX);
|
||||||
|
|
||||||
virtual int SetOpusMaxBandwidth(int channel, int bandwidth_hz);
|
virtual int SetOpusMaxPlaybackRate(int channel, int frequency_hz);
|
||||||
|
|
||||||
// Dual-streaming
|
// Dual-streaming
|
||||||
virtual int SetSecondarySendCodec(int channel, const CodecInst& codec,
|
virtual int SetSecondarySendCodec(int channel, const CodecInst& codec,
|
||||||
|
|||||||
Reference in New Issue
Block a user