diff --git a/src/modules/rtp_rtcp/interface/rtp_rtcp_defines.h b/src/modules/rtp_rtcp/interface/rtp_rtcp_defines.h index 86e476875..ddd994a37 100644 --- a/src/modules/rtp_rtcp/interface/rtp_rtcp_defines.h +++ b/src/modules/rtp_rtcp/interface/rtp_rtcp_defines.h @@ -41,8 +41,9 @@ enum RTPAliveType enum RTPExtensionType { - NONE, - TRANSMISSION_TIME_OFFSET + kRtpExtensionNone, + kRtpExtensionTransmissionTimeOffset, + kRtpExtensionAudioLevel, }; enum RTCPAppSubTypes diff --git a/src/modules/rtp_rtcp/source/rtp_header_extension.cc b/src/modules/rtp_rtcp/source/rtp_header_extension.cc index c85517f84..d45330c91 100644 --- a/src/modules/rtp_rtcp/source/rtp_header_extension.cc +++ b/src/modules/rtp_rtcp/source/rtp_header_extension.cc @@ -112,7 +112,7 @@ WebRtc_Word32 RtpHeaderExtensionMap::Size() const { RTPExtensionType RtpHeaderExtensionMap::First() const { MapItem* item = extensionMap_.First(); if (item == NULL) { - return NONE; + return kRtpExtensionNone; } HeaderExtension* extension = (HeaderExtension*)item->GetItem(); return extension->type; @@ -122,15 +122,15 @@ RTPExtensionType RtpHeaderExtensionMap::Next(RTPExtensionType type) const { WebRtc_UWord8 id; if (GetId(type, &id) != 0) { - return NONE; + return kRtpExtensionNone; } MapItem* item = extensionMap_.Find(id); if (item == NULL) { - return NONE; + return kRtpExtensionNone; } item = extensionMap_.Next(item); if (item == NULL) { - return NONE; + return kRtpExtensionNone; } HeaderExtension* extension = (HeaderExtension*)item->GetItem(); return extension->type; diff --git a/src/modules/rtp_rtcp/source/rtp_header_extension.h b/src/modules/rtp_rtcp/source/rtp_header_extension.h index 090f4a6dd..26c7de78d 100644 --- a/src/modules/rtp_rtcp/source/rtp_header_extension.h +++ b/src/modules/rtp_rtcp/source/rtp_header_extension.h @@ -28,7 +28,7 @@ struct HeaderExtension { HeaderExtension(RTPExtensionType extension_type) : type(extension_type), length(0) { - if (type == TRANSMISSION_TIME_OFFSET) { + if (type == kRtpExtensionTransmissionTimeOffset) { length = TRANSMISSION_TIME_OFFSET_LENGTH_IN_BYTES; } } diff --git a/src/modules/rtp_rtcp/source/rtp_header_extension_test.cc b/src/modules/rtp_rtcp/source/rtp_header_extension_test.cc index 8bca4fbd5..3da3b9671 100644 --- a/src/modules/rtp_rtcp/source/rtp_header_extension_test.cc +++ b/src/modules/rtp_rtcp/source/rtp_header_extension_test.cc @@ -32,31 +32,31 @@ class RtpHeaderExtensionTest : public ::testing::Test { TEST_F(RtpHeaderExtensionTest, Register) { EXPECT_EQ(0, map_.Size()); - EXPECT_EQ(0, map_.Register(TRANSMISSION_TIME_OFFSET, kId)); + EXPECT_EQ(0, map_.Register(kRtpExtensionTransmissionTimeOffset, kId)); EXPECT_EQ(1, map_.Size()); - EXPECT_EQ(0, map_.Deregister(TRANSMISSION_TIME_OFFSET)); + EXPECT_EQ(0, map_.Deregister(kRtpExtensionTransmissionTimeOffset)); EXPECT_EQ(0, map_.Size()); } TEST_F(RtpHeaderExtensionTest, RegisterIllegalArg) { // Valid range for id: [1-14]. - EXPECT_EQ(-1, map_.Register(TRANSMISSION_TIME_OFFSET, 0)); - EXPECT_EQ(-1, map_.Register(TRANSMISSION_TIME_OFFSET, 15)); + EXPECT_EQ(-1, map_.Register(kRtpExtensionTransmissionTimeOffset, 0)); + EXPECT_EQ(-1, map_.Register(kRtpExtensionTransmissionTimeOffset, 15)); } TEST_F(RtpHeaderExtensionTest, DeregisterIllegalArg) { // Not registered. - EXPECT_EQ(-1, map_.Deregister(TRANSMISSION_TIME_OFFSET)); + EXPECT_EQ(-1, map_.Deregister(kRtpExtensionTransmissionTimeOffset)); } TEST_F(RtpHeaderExtensionTest, NonUniqueId) { - EXPECT_EQ(0, map_.Register(TRANSMISSION_TIME_OFFSET, kId)); - EXPECT_EQ(-1, map_.Register(TRANSMISSION_TIME_OFFSET, kId)); + EXPECT_EQ(0, map_.Register(kRtpExtensionTransmissionTimeOffset, kId)); + EXPECT_EQ(-1, map_.Register(kRtpExtensionTransmissionTimeOffset, kId)); } TEST_F(RtpHeaderExtensionTest, GetLength) { EXPECT_EQ(0, map_.GetTotalLengthInBytes()); - EXPECT_EQ(0, map_.Register(TRANSMISSION_TIME_OFFSET, kId)); + EXPECT_EQ(0, map_.Register(kRtpExtensionTransmissionTimeOffset, kId)); EXPECT_EQ(RTP_ONE_BYTE_HEADER_LENGTH_IN_BYTES + TRANSMISSION_TIME_OFFSET_LENGTH_IN_BYTES, map_.GetTotalLengthInBytes()); @@ -66,41 +66,41 @@ TEST_F(RtpHeaderExtensionTest, GetType) { RTPExtensionType typeOut; EXPECT_EQ(-1, map_.GetType(kId, &typeOut)); - EXPECT_EQ(0, map_.Register(TRANSMISSION_TIME_OFFSET, kId)); + EXPECT_EQ(0, map_.Register(kRtpExtensionTransmissionTimeOffset, kId)); EXPECT_EQ(0, map_.GetType(kId, &typeOut)); - EXPECT_EQ(TRANSMISSION_TIME_OFFSET, typeOut); + EXPECT_EQ(kRtpExtensionTransmissionTimeOffset, typeOut); } TEST_F(RtpHeaderExtensionTest, GetId) { WebRtc_UWord8 idOut; - EXPECT_EQ(-1, map_.GetId(TRANSMISSION_TIME_OFFSET, &idOut)); + EXPECT_EQ(-1, map_.GetId(kRtpExtensionTransmissionTimeOffset, &idOut)); - EXPECT_EQ(0, map_.Register(TRANSMISSION_TIME_OFFSET, kId)); - EXPECT_EQ(0, map_.GetId(TRANSMISSION_TIME_OFFSET, &idOut)); + EXPECT_EQ(0, map_.Register(kRtpExtensionTransmissionTimeOffset, kId)); + EXPECT_EQ(0, map_.GetId(kRtpExtensionTransmissionTimeOffset, &idOut)); EXPECT_EQ(kId, idOut); } TEST_F(RtpHeaderExtensionTest, IterateTypes) { - EXPECT_EQ(NONE, map_.First()); - EXPECT_EQ(NONE, map_.Next(TRANSMISSION_TIME_OFFSET)); + EXPECT_EQ(kRtpExtensionNone, map_.First()); + EXPECT_EQ(kRtpExtensionNone, map_.Next(kRtpExtensionTransmissionTimeOffset)); - EXPECT_EQ(0, map_.Register(TRANSMISSION_TIME_OFFSET, kId)); + EXPECT_EQ(0, map_.Register(kRtpExtensionTransmissionTimeOffset, kId)); - EXPECT_EQ(TRANSMISSION_TIME_OFFSET, map_.First()); - EXPECT_EQ(NONE, map_.Next(TRANSMISSION_TIME_OFFSET)); + EXPECT_EQ(kRtpExtensionTransmissionTimeOffset, map_.First()); + EXPECT_EQ(kRtpExtensionNone, map_.Next(kRtpExtensionTransmissionTimeOffset)); } TEST_F(RtpHeaderExtensionTest, GetCopy) { - EXPECT_EQ(0, map_.Register(TRANSMISSION_TIME_OFFSET, kId)); + EXPECT_EQ(0, map_.Register(kRtpExtensionTransmissionTimeOffset, kId)); RtpHeaderExtensionMap mapOut; map_.GetCopy(&mapOut); EXPECT_EQ(1, mapOut.Size()); - EXPECT_EQ(TRANSMISSION_TIME_OFFSET, mapOut.First()); + EXPECT_EQ(kRtpExtensionTransmissionTimeOffset, mapOut.First()); } TEST_F(RtpHeaderExtensionTest, Erase) { - EXPECT_EQ(0, map_.Register(TRANSMISSION_TIME_OFFSET, kId)); + EXPECT_EQ(0, map_.Register(kRtpExtensionTransmissionTimeOffset, kId)); EXPECT_EQ(1, map_.Size()); map_.Erase(); EXPECT_EQ(0, map_.Size()); diff --git a/src/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/src/modules/rtp_rtcp/source/rtp_rtcp_impl.cc index d2da5b76a..03a66904d 100644 --- a/src/modules/rtp_rtcp/source/rtp_rtcp_impl.cc +++ b/src/modules/rtp_rtcp/source/rtp_rtcp_impl.cc @@ -2090,13 +2090,19 @@ WebRtc_Word32 ModuleRtpRtcpImpl::SetRTPAudioLevelIndicationStatus( const bool enable, const WebRtc_UWord8 ID) { - WEBRTC_TRACE(kTraceModuleCall, - kTraceRtpRtcp, - _id, - "SetRTPAudioLevelIndicationStatus(enable=%d, ID=%u)", - enable, - ID); - return _rtpSender.SetAudioLevelIndicationStatus(enable, ID); + WEBRTC_TRACE(kTraceModuleCall, + kTraceRtpRtcp, + _id, + "SetRTPAudioLevelIndicationStatus(enable=%d, ID=%u)", + enable, + ID); + + if (enable) { + _rtpReceiver.RegisterRtpHeaderExtension(kRtpExtensionAudioLevel, ID); + } else { + _rtpReceiver.DeregisterRtpHeaderExtension(kRtpExtensionAudioLevel); + } + return _rtpSender.SetAudioLevelIndicationStatus(enable, ID); } WebRtc_Word32 ModuleRtpRtcpImpl::GetRTPAudioLevelIndicationStatus( diff --git a/src/modules/rtp_rtcp/source/rtp_sender.cc b/src/modules/rtp_rtcp/source/rtp_sender.cc index 583c48270..2bc2c8707 100644 --- a/src/modules/rtp_rtcp/source/rtp_sender.cc +++ b/src/modules/rtp_rtcp/source/rtp_sender.cc @@ -1314,10 +1314,10 @@ RTPSender::BuildRTPHeaderExtension(WebRtc_UWord8* dataBuffer) const WebRtc_UWord16 total_block_length = 0; RTPExtensionType type = _rtpHeaderExtensionMap.First(); - while (type != NONE) + while (type != kRtpExtensionNone) { WebRtc_UWord8 block_length = 0; - if (type == TRANSMISSION_TIME_OFFSET) + if (type == kRtpExtensionTransmissionTimeOffset) { block_length = BuildTransmissionTimeOffsetExtension( dataBuffer + kHeaderLength + total_block_length); @@ -1363,7 +1363,8 @@ RTPSender::BuildTransmissionTimeOffsetExtension(WebRtc_UWord8* dataBuffer) const // Get id defined by user. WebRtc_UWord8 id; - if (_rtpHeaderExtensionMap.GetId(TRANSMISSION_TIME_OFFSET, &id) != 0) { + if (_rtpHeaderExtensionMap.GetId(kRtpExtensionTransmissionTimeOffset, &id) + != 0) { // Not registered. return 0; } diff --git a/src/modules/rtp_rtcp/source/rtp_sender_test.cc b/src/modules/rtp_rtcp/source/rtp_sender_test.cc index e765ee1ac..cde82fd3e 100644 --- a/src/modules/rtp_rtcp/source/rtp_sender_test.cc +++ b/src/modules/rtp_rtcp/source/rtp_sender_test.cc @@ -37,7 +37,7 @@ class RtpSenderTest : public ::testing::Test { RtpSenderTest() : rtp_sender_(new RTPSender(0, false, ModuleRTPUtility::GetSystemClock())), kMarkerBit(true), - kType(TRANSMISSION_TIME_OFFSET) { + kType(kRtpExtensionTransmissionTimeOffset) { EXPECT_EQ(0, rtp_sender_->SetSequenceNumber(kSeqNum)); } ~RtpSenderTest() { diff --git a/src/modules/rtp_rtcp/source/rtp_utility.cc b/src/modules/rtp_rtcp/source/rtp_utility.cc index de4871ece..f00884915 100644 --- a/src/modules/rtp_rtcp/source/rtp_utility.cc +++ b/src/modules/rtp_rtcp/source/rtp_utility.cc @@ -695,14 +695,14 @@ void ModuleRTPUtility::RTPHeaderParser::ParseOneByteExtensionHeader( RTPExtensionType type; if (ptrExtensionMap->GetType(id, &type) != 0) { - WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, -1, + WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, -1, "Failed to find extension id: %d", id); return; } switch (type) { - case TRANSMISSION_TIME_OFFSET: + case kRtpExtensionTransmissionTimeOffset: { if (len != 2) { @@ -722,8 +722,8 @@ void ModuleRTPUtility::RTPHeaderParser::ParseOneByteExtensionHeader( parsedPacket.extension.transmissionTimeOffset = transmissionTimeOffset; break; } - //case RTP_AUDIO_LEVEL_ID; - //{ + case kRtpExtensionAudioLevel: + { // --- Only used for debugging --- // 0 1 2 3 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 @@ -737,7 +737,8 @@ void ModuleRTPUtility::RTPHeaderParser::ParseOneByteExtensionHeader( //const WebRtc_UWord8 level = (*ptr & 0x7f); //DEBUG_PRINT("RTP_AUDIO_LEVEL_UNIQUE_ID: ID=%u, len=%u, V=%u, level=%u", // ID, len, V, level); - //} + break; + } default: { WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, -1,