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
This commit is contained in:
wu@webrtc.org 2013-06-03 21:27:57 +00:00
parent c1eb560a5c
commit fa64a595ad
4 changed files with 9 additions and 5 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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);

View File

@ -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.