From a596a389ea7cb586cd39f548888d4f8ae50cf03a Mon Sep 17 00:00:00 2001 From: "turaj@webrtc.org" Date: Thu, 17 Apr 2014 23:30:49 +0000 Subject: [PATCH] Fix iSAC/48000 issue with ACM2. Registeration of iSAC into NetEq is through injecting and external AudioDecoder. This is because iSAC encoder and decoder need to share instances for bandwidth estimator to work. When external decoder is registerred, the sampling rate of the decoder had to be specified. iSAC/48000 decoder has a native sampling rate of 32000 Hz, but it has been registered as 48000 Hz decoder. This CL fixing this issue by letting NetEq to obtain sampling rate of an external coder according to its existing database. BUG=3143 TEST=voe_cmd_test,modules_unittest,try-bots R=henrik.lundin@webrtc.org Review URL: https://webrtc-codereview.appspot.com/12139004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5936 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/modules/audio_coding/main/acm2/acm_receiver.cc | 3 +-- webrtc/modules/audio_coding/neteq4/interface/neteq.h | 5 ++--- .../audio_coding/neteq4/neteq_external_decoder_unittest.cc | 1 - webrtc/modules/audio_coding/neteq4/neteq_impl.cc | 2 +- webrtc/modules/audio_coding/neteq4/neteq_impl.h | 5 ++--- webrtc/modules/audio_coding/neteq4/neteq_impl_unittest.cc | 2 +- 6 files changed, 7 insertions(+), 11 deletions(-) diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc index 1205568075..826d4c4f01 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc +++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc @@ -505,8 +505,7 @@ int32_t AcmReceiver::AddCodec(int acm_codec_id, ret_val = neteq_->RegisterPayloadType(neteq_decoder, payload_type); } else { ret_val = neteq_->RegisterExternalDecoder( - audio_decoder, neteq_decoder, - ACMCodecDB::database_[acm_codec_id].plfreq, payload_type); + audio_decoder, neteq_decoder, payload_type); } if (ret_val != NetEq::kOK) { LOG_FERR3(LS_ERROR, "AcmReceiver::AddCodec", acm_codec_id, payload_type, diff --git a/webrtc/modules/audio_coding/neteq4/interface/neteq.h b/webrtc/modules/audio_coding/neteq4/interface/neteq.h index 0f6f4062ae..8defe4f72e 100644 --- a/webrtc/modules/audio_coding/neteq4/interface/neteq.h +++ b/webrtc/modules/audio_coding/neteq4/interface/neteq.h @@ -161,11 +161,10 @@ class NetEq { // Provides an externally created decoder object |decoder| to insert in the // decoder database. The decoder implements a decoder of type |codec| and - // associates it with |rtp_payload_type|. The decoder operates at the - // frequency |sample_rate_hz|. Returns kOK on success, kFail on failure. + // associates it with |rtp_payload_type|. Returns kOK on success, + // kFail on failure. virtual int RegisterExternalDecoder(AudioDecoder* decoder, enum NetEqDecoder codec, - int sample_rate_hz, uint8_t rtp_payload_type) = 0; // Removes |rtp_payload_type| from the codec database. Returns 0 on success, diff --git a/webrtc/modules/audio_coding/neteq4/neteq_external_decoder_unittest.cc b/webrtc/modules/audio_coding/neteq4/neteq_external_decoder_unittest.cc index 0b6706b4d6..8cfe48395e 100644 --- a/webrtc/modules/audio_coding/neteq4/neteq_external_decoder_unittest.cc +++ b/webrtc/modules/audio_coding/neteq4/neteq_external_decoder_unittest.cc @@ -80,7 +80,6 @@ class NetEqExternalDecoderTest : public ::testing::Test { ASSERT_EQ(NetEq::kOK, neteq_external_->RegisterExternalDecoder(external_decoder_, decoder, - sample_rate_hz_, kPayloadType)); ASSERT_EQ(NetEq::kOK, neteq_->RegisterPayloadType(decoder, kPayloadType)); diff --git a/webrtc/modules/audio_coding/neteq4/neteq_impl.cc b/webrtc/modules/audio_coding/neteq4/neteq_impl.cc index e407ee83ec..dcf48ad417 100644 --- a/webrtc/modules/audio_coding/neteq4/neteq_impl.cc +++ b/webrtc/modules/audio_coding/neteq4/neteq_impl.cc @@ -201,7 +201,6 @@ int NetEqImpl::RegisterPayloadType(enum NetEqDecoder codec, int NetEqImpl::RegisterExternalDecoder(AudioDecoder* decoder, enum NetEqDecoder codec, - int sample_rate_hz, uint8_t rtp_payload_type) { CriticalSectionScoped lock(crit_sect_.get()); LOG_API2(static_cast(rtp_payload_type), codec); @@ -210,6 +209,7 @@ int NetEqImpl::RegisterExternalDecoder(AudioDecoder* decoder, assert(false); return kFail; } + const int sample_rate_hz = AudioDecoder::CodecSampleRateHz(codec); int ret = decoder_database_->InsertExternal(rtp_payload_type, codec, sample_rate_hz, decoder); if (ret != DecoderDatabase::kOK) { diff --git a/webrtc/modules/audio_coding/neteq4/neteq_impl.h b/webrtc/modules/audio_coding/neteq4/neteq_impl.h index 3d883a0140..09a0049fbb 100644 --- a/webrtc/modules/audio_coding/neteq4/neteq_impl.h +++ b/webrtc/modules/audio_coding/neteq4/neteq_impl.h @@ -115,11 +115,10 @@ class NetEqImpl : public webrtc::NetEq { // Provides an externally created decoder object |decoder| to insert in the // decoder database. The decoder implements a decoder of type |codec| and - // associates it with |rtp_payload_type|. The decoder operates at the - // frequency |sample_rate_hz|. Returns kOK on success, kFail on failure. + // associates it with |rtp_payload_type|. Returns kOK on success, kFail on + // failure. virtual int RegisterExternalDecoder(AudioDecoder* decoder, enum NetEqDecoder codec, - int sample_rate_hz, uint8_t rtp_payload_type); // Removes |rtp_payload_type| from the codec database. Returns 0 on success, diff --git a/webrtc/modules/audio_coding/neteq4/neteq_impl_unittest.cc b/webrtc/modules/audio_coding/neteq4/neteq_impl_unittest.cc index 27e8b52dbd..15a1c8b8bc 100644 --- a/webrtc/modules/audio_coding/neteq4/neteq_impl_unittest.cc +++ b/webrtc/modules/audio_coding/neteq4/neteq_impl_unittest.cc @@ -452,7 +452,7 @@ TEST_F(NetEqImplTest, VerifyTimestampPropagation) { EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( - &decoder_, kDecoderPCM16B, 8000, kPayloadType)); + &decoder_, kDecoderPCM16B, kPayloadType)); // Insert one packet. EXPECT_EQ(NetEq::kOK,