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
|
enum RTPExtensionType
|
||||||
{
|
{
|
||||||
NONE,
|
kRtpExtensionNone,
|
||||||
TRANSMISSION_TIME_OFFSET
|
kRtpExtensionTransmissionTimeOffset,
|
||||||
|
kRtpExtensionAudioLevel,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum RTCPAppSubTypes
|
enum RTCPAppSubTypes
|
||||||
|
@ -112,7 +112,7 @@ WebRtc_Word32 RtpHeaderExtensionMap::Size() const {
|
|||||||
RTPExtensionType RtpHeaderExtensionMap::First() const {
|
RTPExtensionType RtpHeaderExtensionMap::First() const {
|
||||||
MapItem* item = extensionMap_.First();
|
MapItem* item = extensionMap_.First();
|
||||||
if (item == NULL) {
|
if (item == NULL) {
|
||||||
return NONE;
|
return kRtpExtensionNone;
|
||||||
}
|
}
|
||||||
HeaderExtension* extension = (HeaderExtension*)item->GetItem();
|
HeaderExtension* extension = (HeaderExtension*)item->GetItem();
|
||||||
return extension->type;
|
return extension->type;
|
||||||
@ -122,15 +122,15 @@ RTPExtensionType RtpHeaderExtensionMap::Next(RTPExtensionType type) const
|
|||||||
{
|
{
|
||||||
WebRtc_UWord8 id;
|
WebRtc_UWord8 id;
|
||||||
if (GetId(type, &id) != 0) {
|
if (GetId(type, &id) != 0) {
|
||||||
return NONE;
|
return kRtpExtensionNone;
|
||||||
}
|
}
|
||||||
MapItem* item = extensionMap_.Find(id);
|
MapItem* item = extensionMap_.Find(id);
|
||||||
if (item == NULL) {
|
if (item == NULL) {
|
||||||
return NONE;
|
return kRtpExtensionNone;
|
||||||
}
|
}
|
||||||
item = extensionMap_.Next(item);
|
item = extensionMap_.Next(item);
|
||||||
if (item == NULL) {
|
if (item == NULL) {
|
||||||
return NONE;
|
return kRtpExtensionNone;
|
||||||
}
|
}
|
||||||
HeaderExtension* extension = (HeaderExtension*)item->GetItem();
|
HeaderExtension* extension = (HeaderExtension*)item->GetItem();
|
||||||
return extension->type;
|
return extension->type;
|
||||||
|
@ -28,7 +28,7 @@ struct HeaderExtension {
|
|||||||
HeaderExtension(RTPExtensionType extension_type)
|
HeaderExtension(RTPExtensionType extension_type)
|
||||||
: type(extension_type),
|
: type(extension_type),
|
||||||
length(0) {
|
length(0) {
|
||||||
if (type == TRANSMISSION_TIME_OFFSET) {
|
if (type == kRtpExtensionTransmissionTimeOffset) {
|
||||||
length = TRANSMISSION_TIME_OFFSET_LENGTH_IN_BYTES;
|
length = TRANSMISSION_TIME_OFFSET_LENGTH_IN_BYTES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,31 +32,31 @@ class RtpHeaderExtensionTest : public ::testing::Test {
|
|||||||
|
|
||||||
TEST_F(RtpHeaderExtensionTest, Register) {
|
TEST_F(RtpHeaderExtensionTest, Register) {
|
||||||
EXPECT_EQ(0, map_.Size());
|
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(1, map_.Size());
|
||||||
EXPECT_EQ(0, map_.Deregister(TRANSMISSION_TIME_OFFSET));
|
EXPECT_EQ(0, map_.Deregister(kRtpExtensionTransmissionTimeOffset));
|
||||||
EXPECT_EQ(0, map_.Size());
|
EXPECT_EQ(0, map_.Size());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(RtpHeaderExtensionTest, RegisterIllegalArg) {
|
TEST_F(RtpHeaderExtensionTest, RegisterIllegalArg) {
|
||||||
// Valid range for id: [1-14].
|
// Valid range for id: [1-14].
|
||||||
EXPECT_EQ(-1, map_.Register(TRANSMISSION_TIME_OFFSET, 0));
|
EXPECT_EQ(-1, map_.Register(kRtpExtensionTransmissionTimeOffset, 0));
|
||||||
EXPECT_EQ(-1, map_.Register(TRANSMISSION_TIME_OFFSET, 15));
|
EXPECT_EQ(-1, map_.Register(kRtpExtensionTransmissionTimeOffset, 15));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(RtpHeaderExtensionTest, DeregisterIllegalArg) {
|
TEST_F(RtpHeaderExtensionTest, DeregisterIllegalArg) {
|
||||||
// Not registered.
|
// Not registered.
|
||||||
EXPECT_EQ(-1, map_.Deregister(TRANSMISSION_TIME_OFFSET));
|
EXPECT_EQ(-1, map_.Deregister(kRtpExtensionTransmissionTimeOffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(RtpHeaderExtensionTest, NonUniqueId) {
|
TEST_F(RtpHeaderExtensionTest, NonUniqueId) {
|
||||||
EXPECT_EQ(0, map_.Register(TRANSMISSION_TIME_OFFSET, kId));
|
EXPECT_EQ(0, map_.Register(kRtpExtensionTransmissionTimeOffset, kId));
|
||||||
EXPECT_EQ(-1, map_.Register(TRANSMISSION_TIME_OFFSET, kId));
|
EXPECT_EQ(-1, map_.Register(kRtpExtensionTransmissionTimeOffset, kId));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(RtpHeaderExtensionTest, GetLength) {
|
TEST_F(RtpHeaderExtensionTest, GetLength) {
|
||||||
EXPECT_EQ(0, map_.GetTotalLengthInBytes());
|
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 +
|
EXPECT_EQ(RTP_ONE_BYTE_HEADER_LENGTH_IN_BYTES +
|
||||||
TRANSMISSION_TIME_OFFSET_LENGTH_IN_BYTES,
|
TRANSMISSION_TIME_OFFSET_LENGTH_IN_BYTES,
|
||||||
map_.GetTotalLengthInBytes());
|
map_.GetTotalLengthInBytes());
|
||||||
@ -66,41 +66,41 @@ TEST_F(RtpHeaderExtensionTest, GetType) {
|
|||||||
RTPExtensionType typeOut;
|
RTPExtensionType typeOut;
|
||||||
EXPECT_EQ(-1, map_.GetType(kId, &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(0, map_.GetType(kId, &typeOut));
|
||||||
EXPECT_EQ(TRANSMISSION_TIME_OFFSET, typeOut);
|
EXPECT_EQ(kRtpExtensionTransmissionTimeOffset, typeOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(RtpHeaderExtensionTest, GetId) {
|
TEST_F(RtpHeaderExtensionTest, GetId) {
|
||||||
WebRtc_UWord8 idOut;
|
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_.Register(kRtpExtensionTransmissionTimeOffset, kId));
|
||||||
EXPECT_EQ(0, map_.GetId(TRANSMISSION_TIME_OFFSET, &idOut));
|
EXPECT_EQ(0, map_.GetId(kRtpExtensionTransmissionTimeOffset, &idOut));
|
||||||
EXPECT_EQ(kId, idOut);
|
EXPECT_EQ(kId, idOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(RtpHeaderExtensionTest, IterateTypes) {
|
TEST_F(RtpHeaderExtensionTest, IterateTypes) {
|
||||||
EXPECT_EQ(NONE, map_.First());
|
EXPECT_EQ(kRtpExtensionNone, map_.First());
|
||||||
EXPECT_EQ(NONE, map_.Next(TRANSMISSION_TIME_OFFSET));
|
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(kRtpExtensionTransmissionTimeOffset, map_.First());
|
||||||
EXPECT_EQ(NONE, map_.Next(TRANSMISSION_TIME_OFFSET));
|
EXPECT_EQ(kRtpExtensionNone, map_.Next(kRtpExtensionTransmissionTimeOffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(RtpHeaderExtensionTest, GetCopy) {
|
TEST_F(RtpHeaderExtensionTest, GetCopy) {
|
||||||
EXPECT_EQ(0, map_.Register(TRANSMISSION_TIME_OFFSET, kId));
|
EXPECT_EQ(0, map_.Register(kRtpExtensionTransmissionTimeOffset, kId));
|
||||||
|
|
||||||
RtpHeaderExtensionMap mapOut;
|
RtpHeaderExtensionMap mapOut;
|
||||||
map_.GetCopy(&mapOut);
|
map_.GetCopy(&mapOut);
|
||||||
EXPECT_EQ(1, mapOut.Size());
|
EXPECT_EQ(1, mapOut.Size());
|
||||||
EXPECT_EQ(TRANSMISSION_TIME_OFFSET, mapOut.First());
|
EXPECT_EQ(kRtpExtensionTransmissionTimeOffset, mapOut.First());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(RtpHeaderExtensionTest, Erase) {
|
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());
|
EXPECT_EQ(1, map_.Size());
|
||||||
map_.Erase();
|
map_.Erase();
|
||||||
EXPECT_EQ(0, map_.Size());
|
EXPECT_EQ(0, map_.Size());
|
||||||
|
@ -2090,13 +2090,19 @@ WebRtc_Word32 ModuleRtpRtcpImpl::SetRTPAudioLevelIndicationStatus(
|
|||||||
const bool enable,
|
const bool enable,
|
||||||
const WebRtc_UWord8 ID) {
|
const WebRtc_UWord8 ID) {
|
||||||
|
|
||||||
WEBRTC_TRACE(kTraceModuleCall,
|
WEBRTC_TRACE(kTraceModuleCall,
|
||||||
kTraceRtpRtcp,
|
kTraceRtpRtcp,
|
||||||
_id,
|
_id,
|
||||||
"SetRTPAudioLevelIndicationStatus(enable=%d, ID=%u)",
|
"SetRTPAudioLevelIndicationStatus(enable=%d, ID=%u)",
|
||||||
enable,
|
enable,
|
||||||
ID);
|
ID);
|
||||||
return _rtpSender.SetAudioLevelIndicationStatus(enable, ID);
|
|
||||||
|
if (enable) {
|
||||||
|
_rtpReceiver.RegisterRtpHeaderExtension(kRtpExtensionAudioLevel, ID);
|
||||||
|
} else {
|
||||||
|
_rtpReceiver.DeregisterRtpHeaderExtension(kRtpExtensionAudioLevel);
|
||||||
|
}
|
||||||
|
return _rtpSender.SetAudioLevelIndicationStatus(enable, ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 ModuleRtpRtcpImpl::GetRTPAudioLevelIndicationStatus(
|
WebRtc_Word32 ModuleRtpRtcpImpl::GetRTPAudioLevelIndicationStatus(
|
||||||
|
@ -1314,10 +1314,10 @@ RTPSender::BuildRTPHeaderExtension(WebRtc_UWord8* dataBuffer) const
|
|||||||
WebRtc_UWord16 total_block_length = 0;
|
WebRtc_UWord16 total_block_length = 0;
|
||||||
|
|
||||||
RTPExtensionType type = _rtpHeaderExtensionMap.First();
|
RTPExtensionType type = _rtpHeaderExtensionMap.First();
|
||||||
while (type != NONE)
|
while (type != kRtpExtensionNone)
|
||||||
{
|
{
|
||||||
WebRtc_UWord8 block_length = 0;
|
WebRtc_UWord8 block_length = 0;
|
||||||
if (type == TRANSMISSION_TIME_OFFSET)
|
if (type == kRtpExtensionTransmissionTimeOffset)
|
||||||
{
|
{
|
||||||
block_length = BuildTransmissionTimeOffsetExtension(
|
block_length = BuildTransmissionTimeOffsetExtension(
|
||||||
dataBuffer + kHeaderLength + total_block_length);
|
dataBuffer + kHeaderLength + total_block_length);
|
||||||
@ -1363,7 +1363,8 @@ RTPSender::BuildTransmissionTimeOffsetExtension(WebRtc_UWord8* dataBuffer) const
|
|||||||
|
|
||||||
// Get id defined by user.
|
// Get id defined by user.
|
||||||
WebRtc_UWord8 id;
|
WebRtc_UWord8 id;
|
||||||
if (_rtpHeaderExtensionMap.GetId(TRANSMISSION_TIME_OFFSET, &id) != 0) {
|
if (_rtpHeaderExtensionMap.GetId(kRtpExtensionTransmissionTimeOffset, &id)
|
||||||
|
!= 0) {
|
||||||
// Not registered.
|
// Not registered.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ class RtpSenderTest : public ::testing::Test {
|
|||||||
RtpSenderTest()
|
RtpSenderTest()
|
||||||
: rtp_sender_(new RTPSender(0, false, ModuleRTPUtility::GetSystemClock())),
|
: rtp_sender_(new RTPSender(0, false, ModuleRTPUtility::GetSystemClock())),
|
||||||
kMarkerBit(true),
|
kMarkerBit(true),
|
||||||
kType(TRANSMISSION_TIME_OFFSET) {
|
kType(kRtpExtensionTransmissionTimeOffset) {
|
||||||
EXPECT_EQ(0, rtp_sender_->SetSequenceNumber(kSeqNum));
|
EXPECT_EQ(0, rtp_sender_->SetSequenceNumber(kSeqNum));
|
||||||
}
|
}
|
||||||
~RtpSenderTest() {
|
~RtpSenderTest() {
|
||||||
|
@ -695,14 +695,14 @@ void ModuleRTPUtility::RTPHeaderParser::ParseOneByteExtensionHeader(
|
|||||||
|
|
||||||
RTPExtensionType type;
|
RTPExtensionType type;
|
||||||
if (ptrExtensionMap->GetType(id, &type) != 0) {
|
if (ptrExtensionMap->GetType(id, &type) != 0) {
|
||||||
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, -1,
|
WEBRTC_TRACE(kTraceStream, kTraceRtpRtcp, -1,
|
||||||
"Failed to find extension id: %d", id);
|
"Failed to find extension id: %d", id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case TRANSMISSION_TIME_OFFSET:
|
case kRtpExtensionTransmissionTimeOffset:
|
||||||
{
|
{
|
||||||
if (len != 2)
|
if (len != 2)
|
||||||
{
|
{
|
||||||
@ -722,8 +722,8 @@ void ModuleRTPUtility::RTPHeaderParser::ParseOneByteExtensionHeader(
|
|||||||
parsedPacket.extension.transmissionTimeOffset = transmissionTimeOffset;
|
parsedPacket.extension.transmissionTimeOffset = transmissionTimeOffset;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//case RTP_AUDIO_LEVEL_ID;
|
case kRtpExtensionAudioLevel:
|
||||||
//{
|
{
|
||||||
// --- Only used for debugging ---
|
// --- Only used for debugging ---
|
||||||
// 0 1 2 3
|
// 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
|
// 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);
|
//const WebRtc_UWord8 level = (*ptr & 0x7f);
|
||||||
//DEBUG_PRINT("RTP_AUDIO_LEVEL_UNIQUE_ID: ID=%u, len=%u, V=%u, level=%u",
|
//DEBUG_PRINT("RTP_AUDIO_LEVEL_UNIQUE_ID: ID=%u, len=%u, V=%u, level=%u",
|
||||||
// ID, len, V, level);
|
// ID, len, V, level);
|
||||||
//}
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, -1,
|
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, -1,
|
||||||
|
Loading…
Reference in New Issue
Block a user