Fix for RTP extension audio level.
Review URL: http://webrtc-codereview.appspot.com/339002 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1334 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
d77a6614fa
commit
6c1d41583a
@ -41,8 +41,9 @@ enum RTPAliveType
|
||||
|
||||
enum RTPExtensionType
|
||||
{
|
||||
NONE,
|
||||
TRANSMISSION_TIME_OFFSET
|
||||
kRtpExtensionNone,
|
||||
kRtpExtensionTransmissionTimeOffset,
|
||||
kRtpExtensionAudioLevel,
|
||||
};
|
||||
|
||||
enum RTCPAppSubTypes
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -2096,6 +2096,12 @@ WebRtc_Word32 ModuleRtpRtcpImpl::SetRTPAudioLevelIndicationStatus(
|
||||
"SetRTPAudioLevelIndicationStatus(enable=%d, ID=%u)",
|
||||
enable,
|
||||
ID);
|
||||
|
||||
if (enable) {
|
||||
_rtpReceiver.RegisterRtpHeaderExtension(kRtpExtensionAudioLevel, ID);
|
||||
} else {
|
||||
_rtpReceiver.DeregisterRtpHeaderExtension(kRtpExtensionAudioLevel);
|
||||
}
|
||||
return _rtpSender.SetAudioLevelIndicationStatus(enable, ID);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user