From fa64a595adef6beefa07caaf65e2dcde44d0be04 Mon Sep 17 00:00:00 2001 From: "wu@webrtc.org" Date: Mon, 3 Jun 2013 21:27:57 +0000 Subject: [PATCH] Change SetRTPAudioLevelIndicationStatus to ignore the id in the case of disabling. This makes it easier for the users of the interface, i.e. doesn't need to remember the id in order to disable audio level indication later. BUG=1828 TEST=unit tests R=henrika@webrtc.org Review URL: https://webrtc-codereview.appspot.com/1598005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4157 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/modules/rtp_rtcp/source/rtp_sender_audio.cc | 2 +- webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc | 2 ++ webrtc/voice_engine/test/auto_test/voe_extended_test.cc | 6 ++++-- webrtc/voice_engine/voe_rtp_rtcp_impl.cc | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.cc index c3725c3456..b95b40a411 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.cc @@ -487,7 +487,7 @@ int32_t RTPSenderAudio::SetAudioLevelIndicationStatus(const bool enable, const uint8_t ID) { - if(ID < 1 || ID > 14) + if(enable && (ID < 1 || ID > 14)) { return -1; } diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc index 28bfea5f3c..96d518a366 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc @@ -547,6 +547,7 @@ TEST_F(RtpSenderAudioTest, BuildRTPPacketWithAudioLevelExtension) { VerifyRTPHeaderCommon(rtp_header2); EXPECT_EQ(length, rtp_header2.headerLength); // TODO(solenberg): Should verify that we didn't get audio level. + EXPECT_EQ(0, rtp_sender_->SetAudioLevelIndicationStatus(false, 0)); } TEST_F(RtpSenderAudioTest, SendAudio) { @@ -612,6 +613,7 @@ TEST_F(RtpSenderAudioTest, SendAudioWithAudioLevelExtension) { EXPECT_EQ(0, memcmp(extension, payload_data - sizeof(extension), sizeof(extension))); + EXPECT_EQ(0, rtp_sender_->SetAudioLevelIndicationStatus(false, 0)); } } // namespace webrtc diff --git a/webrtc/voice_engine/test/auto_test/voe_extended_test.cc b/webrtc/voice_engine/test/auto_test/voe_extended_test.cc index bb2838ec52..d0f4833112 100644 --- a/webrtc/voice_engine/test/auto_test/voe_extended_test.cc +++ b/webrtc/voice_engine/test/auto_test/voe_extended_test.cc @@ -4525,12 +4525,14 @@ int VoEExtendedTest::TestRTP_RTCP() { TEST_MUSTPASS(-1 != rtp_rtcp->SetRTPAudioLevelIndicationStatus(0, true, 15)); MARK(); TEST_ERROR(VE_INVALID_ARGUMENT); - TEST_MUSTPASS(-1 != rtp_rtcp->SetRTPAudioLevelIndicationStatus(0, false, 15)); - MARK(); TEST_MUSTPASS(-1 != rtp_rtcp->SetRTPAudioLevelIndicationStatus(1, true, 5)); MARK(); TEST_ERROR(VE_CHANNEL_NOT_VALID); + // test any id can be used on disabling. + TEST_MUSTPASS(0 != rtp_rtcp->SetRTPAudioLevelIndicationStatus(0, false, 0)); + MARK(); + // test complete valid input range [1,14] bool audioLevelEnabled(false); unsigned char ID(0); diff --git a/webrtc/voice_engine/voe_rtp_rtcp_impl.cc b/webrtc/voice_engine/voe_rtp_rtcp_impl.cc index 102e09e3cb..b49ea41c82 100644 --- a/webrtc/voice_engine/voe_rtp_rtcp_impl.cc +++ b/webrtc/voice_engine/voe_rtp_rtcp_impl.cc @@ -224,8 +224,8 @@ int VoERTP_RTCPImpl::SetRTPAudioLevelIndicationStatus(int channel, _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } - if (ID < kVoiceEngineMinRtpExtensionId || - ID > kVoiceEngineMaxRtpExtensionId) + if (enable && (ID < kVoiceEngineMinRtpExtensionId || + ID > kVoiceEngineMaxRtpExtensionId)) { // [RFC5285] The 4-bit ID is the local identifier of this element in // the range 1-14 inclusive.