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);
|
||||
|
||||
/****************************************************************************
|
||||
* WebRtcOpus_SetMaxBandwidth(...)
|
||||
* WebRtcOpus_SetMaxPlaybackRate(...)
|
||||
*
|
||||
* Configures the maximum bandwidth for encoding. This can be taken as a hint
|
||||
* about the maximum output bandwidth that the receiver is capable to render,
|
||||
* due to hardware limitations. Sending signals with higher audio bandwidth
|
||||
* results in higher than necessary network usage and encoding complexity.
|
||||
* Configures the maximum playback rate for encoding. Due to hardware
|
||||
* limitations, the receiver may render audio up to a playback rate. Opus
|
||||
* encoder can use this information to optimize for network usage and encoding
|
||||
* complexity. This will affect the audio bandwidth in the coded audio. However,
|
||||
* the input/output sample rate is not affected.
|
||||
*
|
||||
* Input:
|
||||
* - inst : Encoder context
|
||||
* - bandwidth : Maximum encoding bandwidth in Hz.
|
||||
* This parameter can take any value, but values
|
||||
* other than Opus typical bandwidths: 4000, 6000,
|
||||
* 8000, 12000, and 20000 will be rounded up (values
|
||||
* greater than 20000 will be rounded down) to
|
||||
* these values.
|
||||
* - frequency_hz : Maximum playback rate in Hz.
|
||||
* This parameter can take any value. The relation
|
||||
* between the value and the Opus internal mode is
|
||||
* as following:
|
||||
* frequency_hz <= 8000 narrow band
|
||||
* 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
|
||||
* -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
|
||||
* 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;
|
||||
|
||||
if (!inst)
|
||||
return -1;
|
||||
|
||||
if (bandwidth <= 4000) {
|
||||
if (frequency_hz <= 8000) {
|
||||
set_bandwidth = OPUS_BANDWIDTH_NARROWBAND;
|
||||
} else if (bandwidth <= 6000) {
|
||||
} else if (frequency_hz <= 12000) {
|
||||
set_bandwidth = OPUS_BANDWIDTH_MEDIUMBAND;
|
||||
} else if (bandwidth <= 8000) {
|
||||
} else if (frequency_hz <= 16000) {
|
||||
set_bandwidth = OPUS_BANDWIDTH_WIDEBAND;
|
||||
} else if (bandwidth <= 12000) {
|
||||
} else if (frequency_hz <= 24000) {
|
||||
set_bandwidth = OPUS_BANDWIDTH_SUPERWIDEBAND;
|
||||
} else {
|
||||
set_bandwidth = OPUS_BANDWIDTH_FULLBAND;
|
||||
|
||||
@@ -30,7 +30,7 @@ class OpusTest : public ::testing::Test {
|
||||
OpusTest();
|
||||
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_stereo_encoder_;
|
||||
@@ -66,15 +66,15 @@ void OpusTest::SetUp() {
|
||||
input_file = NULL;
|
||||
}
|
||||
|
||||
void OpusTest::TestSetMaxBandwidth(opus_int32 expect, int32_t set) {
|
||||
void OpusTest::TestSetMaxPlaybackRate(opus_int32 expect, int32_t set) {
|
||||
opus_int32 bandwidth;
|
||||
// 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_GET_MAX_BANDWIDTH(&bandwidth));
|
||||
EXPECT_EQ(expect, bandwidth);
|
||||
// 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_GET_MAX_BANDWIDTH(&bandwidth));
|
||||
EXPECT_EQ(expect, bandwidth);
|
||||
@@ -355,22 +355,25 @@ TEST_F(OpusTest, OpusSetPacketLossRate) {
|
||||
EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_stereo_encoder_));
|
||||
}
|
||||
|
||||
TEST_F(OpusTest, OpusSetMaxBandwidth) {
|
||||
TEST_F(OpusTest, OpusSetMaxPlaybackRate) {
|
||||
// Test without creating encoder memory.
|
||||
EXPECT_EQ(-1, WebRtcOpus_SetMaxBandwidth(opus_mono_encoder_, 20000));
|
||||
EXPECT_EQ(-1, WebRtcOpus_SetMaxBandwidth(opus_stereo_encoder_, 20000));
|
||||
EXPECT_EQ(-1, WebRtcOpus_SetMaxPlaybackRate(opus_mono_encoder_, 20000));
|
||||
EXPECT_EQ(-1, WebRtcOpus_SetMaxPlaybackRate(opus_stereo_encoder_, 20000));
|
||||
|
||||
// Create encoder memory, try with different bitrates.
|
||||
EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_mono_encoder_, 1));
|
||||
EXPECT_EQ(0, WebRtcOpus_EncoderCreate(&opus_stereo_encoder_, 2));
|
||||
|
||||
TestSetMaxBandwidth(OPUS_BANDWIDTH_FULLBAND, 24000);
|
||||
TestSetMaxBandwidth(OPUS_BANDWIDTH_FULLBAND, 14000);
|
||||
TestSetMaxBandwidth(OPUS_BANDWIDTH_SUPERWIDEBAND, 10000);
|
||||
TestSetMaxBandwidth(OPUS_BANDWIDTH_WIDEBAND, 7000);
|
||||
TestSetMaxBandwidth(OPUS_BANDWIDTH_MEDIUMBAND, 6000);
|
||||
TestSetMaxBandwidth(OPUS_BANDWIDTH_NARROWBAND, 4000);
|
||||
TestSetMaxBandwidth(OPUS_BANDWIDTH_NARROWBAND, 3000);
|
||||
TestSetMaxPlaybackRate(OPUS_BANDWIDTH_FULLBAND, 48000);
|
||||
TestSetMaxPlaybackRate(OPUS_BANDWIDTH_FULLBAND, 24001);
|
||||
TestSetMaxPlaybackRate(OPUS_BANDWIDTH_SUPERWIDEBAND, 24000);
|
||||
TestSetMaxPlaybackRate(OPUS_BANDWIDTH_SUPERWIDEBAND, 16001);
|
||||
TestSetMaxPlaybackRate(OPUS_BANDWIDTH_WIDEBAND, 16000);
|
||||
TestSetMaxPlaybackRate(OPUS_BANDWIDTH_WIDEBAND, 12001);
|
||||
TestSetMaxPlaybackRate(OPUS_BANDWIDTH_MEDIUMBAND, 12000);
|
||||
TestSetMaxPlaybackRate(OPUS_BANDWIDTH_MEDIUMBAND, 8001);
|
||||
TestSetMaxPlaybackRate(OPUS_BANDWIDTH_NARROWBAND, 8000);
|
||||
TestSetMaxPlaybackRate(OPUS_BANDWIDTH_NARROWBAND, 4000);
|
||||
|
||||
// Free memory.
|
||||
EXPECT_EQ(0, WebRtcOpus_EncoderFree(opus_mono_encoder_));
|
||||
|
||||
@@ -1000,9 +1000,9 @@ int16_t ACMGenericCodec::REDPayloadISAC(const int32_t /* isac_rate */,
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ACMGenericCodec::SetOpusMaxBandwidth(int /* max_bandwidth */) {
|
||||
int ACMGenericCodec::SetOpusMaxPlaybackRate(int /* frequency_hz */) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -538,21 +538,20 @@ class ACMGenericCodec {
|
||||
int16_t* payload_len_bytes);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// int SetOpusMaxBandwidth()
|
||||
// Sets maximum required encoding bandwidth for Opus. This is to tell Opus
|
||||
// that it is enough to code the input audio up to a bandwidth. A use case of
|
||||
// this is when the receiver cannot render the full band. Opus can take this
|
||||
// information to optimize the bit rate and increase the computation
|
||||
// efficiency.
|
||||
// int SetOpusMaxPlaybackRate()
|
||||
// Sets maximum playback rate the receiver will render, if the codec is Opus.
|
||||
// This is to tell Opus that it is enough to code the input audio up to a
|
||||
// bandwidth. Opus can take this information to optimize the bit rate and
|
||||
// increase the computation efficiency.
|
||||
//
|
||||
// Input:
|
||||
// -max_bandwidth : maximum required bandwidth.
|
||||
// -frequency_hz : maximum playback rate in Hz.
|
||||
//
|
||||
// Return value:
|
||||
// -1 if failed or on codecs other than Opus
|
||||
// 0 if succeeded.
|
||||
//
|
||||
virtual int SetOpusMaxBandwidth(int /* max_bandwidth */);
|
||||
virtual int SetOpusMaxPlaybackRate(int /* frequency_hz */);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// HasFrameToEncode()
|
||||
|
||||
@@ -263,9 +263,9 @@ int ACMOpus::SetPacketLossRate(int loss_rate) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ACMOpus::SetOpusMaxBandwidth(int max_bandwidth) {
|
||||
// Ask the encoder to change the maximum required bandwidth.
|
||||
return WebRtcOpus_SetMaxBandwidth(encoder_inst_ptr_, max_bandwidth);
|
||||
int ACMOpus::SetOpusMaxPlaybackRate(int frequency_hz) {
|
||||
// Informs Opus encoder of the maximum playback rate the receiver will render.
|
||||
return WebRtcOpus_SetMaxPlaybackRate(encoder_inst_ptr_, frequency_hz);
|
||||
}
|
||||
|
||||
#endif // WEBRTC_CODEC_OPUS
|
||||
|
||||
@@ -38,7 +38,7 @@ class ACMOpus : public ACMGenericCodec {
|
||||
|
||||
virtual int SetPacketLossRate(int loss_rate) OVERRIDE;
|
||||
|
||||
virtual int SetOpusMaxBandwidth(int max_bandwidth) OVERRIDE;
|
||||
virtual int SetOpusMaxPlaybackRate(int frequency_hz) OVERRIDE;
|
||||
|
||||
protected:
|
||||
void DestructEncoderSafe();
|
||||
|
||||
@@ -1911,13 +1911,13 @@ int AudioCodingModuleImpl::ConfigISACBandwidthEstimator(
|
||||
frame_size_ms, rate_bit_per_sec, enforce_frame_size);
|
||||
}
|
||||
|
||||
// Informs Opus encoder about the maximum audio bandwidth needs to be encoded.
|
||||
int AudioCodingModuleImpl::SetOpusMaxBandwidth(int bandwidth_hz) {
|
||||
// Informs Opus encoder of the maximum playback rate the receiver will render.
|
||||
int AudioCodingModuleImpl::SetOpusMaxPlaybackRate(int frequency_hz) {
|
||||
CriticalSectionScoped lock(acm_crit_sect_);
|
||||
if (!HaveValidEncoder("SetOpusMaxBandwidth")) {
|
||||
if (!HaveValidEncoder("SetOpusMaxPlaybackRate")) {
|
||||
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) {
|
||||
|
||||
@@ -232,9 +232,9 @@ class AudioCodingModuleImpl : public AudioCodingModule {
|
||||
int rate_bit_per_sec,
|
||||
bool enforce_frame_size = false);
|
||||
|
||||
// If current send codec is Opus, informs it about the maximum audio
|
||||
// bandwidth needs to be encoded.
|
||||
int SetOpusMaxBandwidth(int bandwidth_hz);
|
||||
// If current send codec is Opus, informs it about the maximum playback rate
|
||||
// the receiver will render.
|
||||
int SetOpusMaxPlaybackRate(int frequency_hz);
|
||||
|
||||
int UnregisterReceiveCodec(uint8_t payload_type);
|
||||
|
||||
|
||||
@@ -916,21 +916,20 @@ class AudioCodingModule: public Module {
|
||||
bool enforce_frame_size = false) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// int SetOpusMaxBandwidth()
|
||||
// If current send codec is Opus, informs it about maximum audio bandwidth
|
||||
// needs to be encoded. A use case of this is when the receiver can only play
|
||||
// audio up to frequency limit. Opus can use this information to optimize
|
||||
// the bit rate and increase the computation efficiency.
|
||||
// int SetOpusMaxPlaybackRate()
|
||||
// If current send codec is Opus, informs it about maximum playback rate the
|
||||
// receiver will render. Opus can use this information to optimize the bit
|
||||
// rate and increase the computation efficiency.
|
||||
//
|
||||
// Input:
|
||||
// -banbwidth_hz : maximum bandwidth in Hz.
|
||||
// -frequency_hz : maximum playback rate in Hz.
|
||||
//
|
||||
// Return value:
|
||||
// -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.
|
||||
//
|
||||
virtual int SetOpusMaxBandwidth(int banbwidth_hz) = 0;
|
||||
virtual int SetOpusMaxPlaybackRate(int frequency_hz) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// statistics
|
||||
|
||||
Reference in New Issue
Block a user