From 3ffa1f917ec1a8bd7666669ddb3f8ba0fd26cb4e Mon Sep 17 00:00:00 2001 From: "buildbot@webrtc.org" Date: Wed, 2 Jul 2014 19:51:26 +0000 Subject: [PATCH] (Auto)update libjingle 70422491-> 70424781 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6586 4adac7df-926f-26a2-2b94-8c16560cd09d --- talk/media/webrtc/fakewebrtcvoiceengine.h | 5 ++++ talk/media/webrtc/webrtcvoiceengine.cc | 29 ++++++++++--------- .../webrtc/webrtcvoiceengine_unittest.cc | 11 +++++++ 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/talk/media/webrtc/fakewebrtcvoiceengine.h b/talk/media/webrtc/fakewebrtcvoiceengine.h index e3b7537cfc..5ceaf9354a 100644 --- a/talk/media/webrtc/fakewebrtcvoiceengine.h +++ b/talk/media/webrtc/fakewebrtcvoiceengine.h @@ -539,6 +539,11 @@ class FakeWebRtcVoiceEngine #ifdef USE_WEBRTC_DEV_BRANCH WEBRTC_FUNC(SetFECStatus, (int channel, bool enable)) { WEBRTC_CHECK_CHANNEL(channel); + if (strcmp(channels_[channel]->send_codec.plname, "opus")) { + // Return -1 if current send codec is not Opus. + // TODO(minyue): Excludes other codecs if they support inband FEC. + return -1; + } channels_[channel]->codec_fec = enable; return 0; } diff --git a/talk/media/webrtc/webrtcvoiceengine.cc b/talk/media/webrtc/webrtcvoiceengine.cc index 7df4788442..10115d4d56 100644 --- a/talk/media/webrtc/webrtcvoiceengine.cc +++ b/talk/media/webrtc/webrtcvoiceengine.cc @@ -1985,6 +1985,7 @@ bool WebRtcVoiceMediaChannel::SetSendCodecs( memset(&send_codec, 0, sizeof(send_codec)); bool nack_enabled = nack_enabled_; + bool enable_codec_fec = false; // Set send codec (the first non-telephone-event/CN codec) for (std::vector::const_iterator it = codecs.begin(); @@ -2035,19 +2036,6 @@ bool WebRtcVoiceMediaChannel::SetSendCodecs( if (bitrate_from_params != 0) { voe_codec.rate = bitrate_from_params; } - - // For Opus, we also enable inband FEC if it is requested. - if (IsOpusFecEnabled(*it)) { - LOG(LS_INFO) << "Enabling Opus FEC on channel " << channel; -#ifdef USE_WEBRTC_DEV_BRANCH - if (engine()->voe()->codec()->SetFECStatus(channel, true) == -1) { - // Enable in-band FEC of the Opus codec. Treat any failure as a fatal - // internal error. - LOG_RTCERR2(SetFECStatus, channel, true); - return false; - } -#endif // USE_WEBRTC_DEV_BRANCH - } } // We'll use the first codec in the list to actually send audio data. @@ -2078,6 +2066,8 @@ bool WebRtcVoiceMediaChannel::SetSendCodecs( } else { send_codec = voe_codec; nack_enabled = IsNackEnabled(*it); + // For Opus as the send codec, we enable inband FEC if requested. + enable_codec_fec = IsOpus(*it) && IsOpusFecEnabled(*it); } found_send_codec = true; break; @@ -2098,6 +2088,19 @@ bool WebRtcVoiceMediaChannel::SetSendCodecs( if (!SetSendCodec(channel, send_codec)) return false; + // FEC should be enabled after SetSendCodec. + if (enable_codec_fec) { + LOG(LS_INFO) << "Attempt to enable codec internal FEC on channel " + << channel; +#ifdef USE_WEBRTC_DEV_BRANCH + if (engine()->voe()->codec()->SetFECStatus(channel, true) == -1) { + // Enable codec internal FEC. Treat any failure as fatal internal error. + LOG_RTCERR2(SetFECStatus, channel, true); + return false; + } +#endif // USE_WEBRTC_DEV_BRANCH + } + // Always update the |send_codec_| to the currently set send codec. send_codec_.reset(new webrtc::CodecInst(send_codec)); diff --git a/talk/media/webrtc/webrtcvoiceengine_unittest.cc b/talk/media/webrtc/webrtcvoiceengine_unittest.cc index 58893b98ac..5974a04e34 100644 --- a/talk/media/webrtc/webrtcvoiceengine_unittest.cc +++ b/talk/media/webrtc/webrtcvoiceengine_unittest.cc @@ -1217,6 +1217,17 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacNoFec) { EXPECT_TRUE(channel_->SetSendCodecs(codecs)); EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); } + +// Test the with non-Opus, even if useinbandfec=1, FEC is off. +TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacWithParamNoFec) { + EXPECT_TRUE(SetupEngine()); + int channel_num = voe_.GetLastChannel(); + std::vector codecs; + codecs.push_back(kIsacCodec); + codecs[0].params["useinbandfec"] = "1"; + EXPECT_TRUE(channel_->SetSendCodecs(codecs)); + EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); +} #endif // USE_WEBRTC_DEV_BRANCH // Test AudioOptions controls whether opus FEC is supported in codec list.