Cleaning up all use of RTP_PAYLOAD_NAME_SIZE and RTCP_CNAME_SIZE also fixed the char handing in trace.

Review URL: https://webrtc-codereview.appspot.com/358001

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1535 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pwestin@webrtc.org 2012-01-24 17:16:59 +00:00
parent 218db3de20
commit f6bb77a6f0
27 changed files with 345 additions and 464 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -41,7 +41,7 @@ class RefCountedModule : public Module {
// TODO(perkj): Make this pure virtual when Chromium have implemented
// reference counting ADM and Video capture module.
virtual int32_t AddRef() {
assert(!"Not implemented.");
assert(false && "Not implemented.");
return 1;
}
@ -52,7 +52,7 @@ class RefCountedModule : public Module {
// TODO(perkj): Make this pure virtual when Chromium have implemented
// reference counting ADM and Video capture module.
virtual int32_t Release() {
assert(!"Not implemented.");
assert(false && "Not implemented.");
return 1;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -621,14 +621,14 @@ public:
*
* return -1 on failure else 0
*/
virtual WebRtc_Word32 SetCNAME(const WebRtc_Word8 cName[RTCP_CNAME_SIZE]) = 0;
virtual WebRtc_Word32 SetCNAME(const char cName[RTCP_CNAME_SIZE]) = 0;
/*
* Get RTCP CName (i.e unique identifier)
*
* return -1 on failure else 0
*/
virtual WebRtc_Word32 CNAME(WebRtc_Word8 cName[RTCP_CNAME_SIZE]) = 0;
virtual WebRtc_Word32 CNAME(char cName[RTCP_CNAME_SIZE]) = 0;
/*
* Get remote CName
@ -637,7 +637,7 @@ public:
*/
virtual WebRtc_Word32 RemoteCNAME(
const WebRtc_UWord32 remoteSSRC,
WebRtc_Word8 cName[RTCP_CNAME_SIZE]) const = 0;
char cName[RTCP_CNAME_SIZE]) const = 0;
/*
* Get remote NTP
@ -657,7 +657,7 @@ public:
*/
virtual WebRtc_Word32 AddMixedCNAME(
const WebRtc_UWord32 SSRC,
const WebRtc_Word8 cName[RTCP_CNAME_SIZE]) = 0;
const char cName[RTCP_CNAME_SIZE]) = 0;
/*
* RemoveMixedCNAME

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -189,7 +189,7 @@ public:
virtual WebRtc_Word32 OnInitializeDecoder(
const WebRtc_Word32 id,
const WebRtc_Word8 payloadType,
const WebRtc_Word8 payloadName[RTP_PAYLOAD_NAME_SIZE],
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
const int frequency,
const WebRtc_UWord8 channels,
const WebRtc_UWord32 rate) = 0;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -564,6 +564,7 @@ RTCPReceiver::CreateCnameInformation(WebRtc_UWord32 remoteSSRC) {
return it->second;
}
RTCPCnameInformation* cnameInfo = new RTCPCnameInformation;
memset(cnameInfo->name, 0, RTCP_CNAME_SIZE);
_receivedCnameMap[remoteSSRC] = cnameInfo;
return cnameInfo;
}
@ -707,17 +708,14 @@ RTCPReceiver::HandleSDES(RTCPUtility::RTCPParserV2& rtcpParser)
}
// no need for critsect we have _criticalSectionRTCPReceiver
void
RTCPReceiver::HandleSDESChunk(RTCPUtility::RTCPParserV2& rtcpParser)
{
const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
void RTCPReceiver::HandleSDESChunk(RTCPUtility::RTCPParserV2& rtcpParser) {
const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
RTCPCnameInformation* cnameInfo =
CreateCnameInformation(rtcpPacket.CName.SenderSSRC);
assert(cnameInfo);
RTCPCnameInformation* cnameInfo = CreateCnameInformation(rtcpPacket.CName.SenderSSRC);
if (cnameInfo)
{
memcpy(cnameInfo->name, rtcpPacket.CName.CName, rtcpPacket.CName.CNameLength);
cnameInfo->length = rtcpPacket.CName.CNameLength;
}
cnameInfo->name[RTCP_CNAME_SIZE - 1] = 0;
strncpy(cnameInfo->name, rtcpPacket.CName.CName, RTCP_CNAME_SIZE - 1);
}
// no need for critsect we have _criticalSectionRTCPReceiver
@ -1383,27 +1381,20 @@ RTCPReceiver::UpdateBandwidthEstimate(const WebRtc_UWord16 bwEstimateKbit)
}
WebRtc_Word32
RTCPReceiver::CNAME(const WebRtc_UWord32 remoteSSRC,
WebRtc_Word8 cName[RTCP_CNAME_SIZE]) const
{
if(cName == NULL)
{
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s invalid argument", __FUNCTION__);
return -1;
}
WebRtc_Word32 RTCPReceiver::CNAME(const WebRtc_UWord32 remoteSSRC,
char cName[RTCP_CNAME_SIZE]) const {
if (cName == NULL) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
"%s invalid argument", __FUNCTION__);
return -1;
}
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
RTCPCnameInformation* cnameInfo = GetCnameInformation(remoteSSRC);
assert(cnameInfo);
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
RTCPCnameInformation* cnameInfo = GetCnameInformation(remoteSSRC);
if(cnameInfo == NULL)
{
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "\tfailed to GetCnameInformation(%d)", remoteSSRC);
return -1;
}
memcpy(cName, cnameInfo->name, cnameInfo->length);
cName[cnameInfo->length] = 0;
return 0;
cName[RTCP_CNAME_SIZE - 1] = 0;
strncpy(cName, cnameInfo->name, RTCP_CNAME_SIZE - 1);
return 0;
}
// no callbacks allowed inside this function

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -54,7 +54,7 @@ public:
// get received cname
WebRtc_Word32 CNAME(const WebRtc_UWord32 remoteSSRC,
WebRtc_Word8 cName[RTCP_CNAME_SIZE]) const;
char cName[RTCP_CNAME_SIZE]) const;
// get received NTP
WebRtc_Word32 NTP(WebRtc_UWord32 *ReceivedNTPsecs,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -345,54 +345,38 @@ RTCPSender::SetCameraDelay(const WebRtc_Word32 delayMS)
return 0;
}
WebRtc_Word32
RTCPSender::CNAME(WebRtc_Word8 cName[RTCP_CNAME_SIZE])
{
if(cName == NULL)
{
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s invalid argument", __FUNCTION__);
return -1;
}
CriticalSectionScoped lock(_criticalSectionRTCPSender);
memcpy(cName, _CNAME, RTCP_CNAME_SIZE);
return 0;
}
WebRtc_Word32 RTCPSender::SetCNAME(const WebRtc_Word8 cName[RTCP_CNAME_SIZE]) {
size_t length = strlen(cName);
if (length >= RTCP_CNAME_SIZE) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
"%s invalid argument, too long cName", __FUNCTION__);
return -1;
}
WebRtc_Word32 RTCPSender::CNAME(char cName[RTCP_CNAME_SIZE]) {
assert(cName);
CriticalSectionScoped lock(_criticalSectionRTCPSender);
memcpy(_CNAME, cName, length + 1);
cName[RTCP_CNAME_SIZE - 1] = 0;
strncpy(cName, _CNAME, RTCP_CNAME_SIZE - 1);
return 0;
}
WebRtc_Word32 RTCPSender::AddMixedCNAME(
const WebRtc_UWord32 SSRC,
const WebRtc_Word8 cName[RTCP_CNAME_SIZE]) {
size_t length = strlen(cName);
if (length >= RTCP_CNAME_SIZE) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
"%s invalid argument, too long cName", __FUNCTION__);
return -1;
}
WebRtc_Word32 RTCPSender::SetCNAME(const char cName[RTCP_CNAME_SIZE]) {
assert(cName);
CriticalSectionScoped lock(_criticalSectionRTCPSender);
_CNAME[RTCP_CNAME_SIZE - 1] = 0;
strncpy(_CNAME, cName, RTCP_CNAME_SIZE - 1);
return 0;
}
WebRtc_Word32 RTCPSender::AddMixedCNAME(const WebRtc_UWord32 SSRC,
const char cName[RTCP_CNAME_SIZE]) {
assert(cName);
CriticalSectionScoped lock(_criticalSectionRTCPSender);
if (_csrcCNAMEs.size() >= kRtpCsrcSize) {
return -1;
}
RTCPCnameInformation* ptr = new RTCPCnameInformation();
memcpy(ptr->name, cName, length + 1);
ptr->length = static_cast<WebRtc_UWord8>(length);
ptr->name[RTCP_CNAME_SIZE - 1] = 0;
strncpy(ptr->name, cName, RTCP_CNAME_SIZE - 1);
_csrcCNAMEs[SSRC] = ptr;
return 0;
}
WebRtc_Word32 RTCPSender::RemoveMixedCNAME(const WebRtc_UWord32 SSRC) {
CriticalSectionScoped lock(_criticalSectionRTCPSender);
std::map<WebRtc_UWord32, RTCPCnameInformation*>::iterator it =
_csrcCNAMEs.find(SSRC);
@ -747,14 +731,16 @@ WebRtc_Word32 RTCPSender::BuildSDEC(WebRtc_UWord8* rtcpbuffer,
// CNAME = 1
rtcpbuffer[pos++] = static_cast<WebRtc_UWord8>(1);
rtcpbuffer[pos++]= cname->length;
size_t length = strlen(cname->name);
assert(length < RTCP_CNAME_SIZE);
rtcpbuffer[pos++]= static_cast<WebRtc_UWord8>(length);
SDESLength += 6;
memcpy(&rtcpbuffer[pos], cname->name, cname->length);
pos += cname->length;
SDESLength += cname->length;
memcpy(&rtcpbuffer[pos],cname->name, length);
pos += length;
SDESLength += length;
WebRtc_UWord16 padding = 0;
// We must have a zero field even if we have an even multiple of 4 bytes
@ -769,8 +755,9 @@ WebRtc_Word32 RTCPSender::BuildSDEC(WebRtc_UWord8* rtcpbuffer,
SDESLength += padding;
}
// in 32-bit words minus one and we don't count the header
WebRtc_UWord16 length = (SDESLength / 4) - 1;
ModuleRTPUtility::AssignUWord16ToBuffer(rtcpbuffer + SDESLengthPos, length);
WebRtc_UWord16 buffer_length = (SDESLength / 4) - 1;
ModuleRTPUtility::AssignUWord16ToBuffer(rtcpbuffer + SDESLengthPos,
buffer_length);
return 0;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -51,11 +51,11 @@ public:
WebRtc_Word32 SetCameraDelay(const WebRtc_Word32 delayMS);
WebRtc_Word32 CNAME(WebRtc_Word8 cName[RTCP_CNAME_SIZE]);
WebRtc_Word32 SetCNAME(const WebRtc_Word8 cName[RTCP_CNAME_SIZE]);
WebRtc_Word32 CNAME(char cName[RTCP_CNAME_SIZE]);
WebRtc_Word32 SetCNAME(const char cName[RTCP_CNAME_SIZE]);
WebRtc_Word32 AddMixedCNAME(const WebRtc_UWord32 SSRC,
const WebRtc_Word8 cName[RTCP_CNAME_SIZE]);
const char cName[RTCP_CNAME_SIZE]);
WebRtc_Word32 RemoveMixedCNAME(const WebRtc_UWord32 SSRC);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -16,17 +16,6 @@
namespace webrtc {
RTCPUtility::RTCPCnameInformation::RTCPCnameInformation() :
length(0)
{
memset(name, 0, sizeof(name));
}
RTCPUtility::RTCPCnameInformation::~RTCPCnameInformation()
{
}
///////////
// RTCPParserV2 : currently read only
RTCPUtility::RTCPParserV2::RTCPParserV2(const WebRtc_UWord8* rtcpData,
@ -759,8 +748,8 @@ RTCPUtility::RTCPParserV2::ParseSDESItem()
EndCurrentBlock();
return false;
}
for (unsigned int i = 0; i < len; ++i)
WebRtc_UWord8 i = 0;
for (; i < len; ++i)
{
const WebRtc_UWord8 c = _ptrRTCPData[i];
if ((c < ' ') || (c > '{') || (c == '%') || (c == '\\'))
@ -771,16 +760,14 @@ RTCPUtility::RTCPParserV2::ParseSDESItem()
EndCurrentBlock();
return false;
}
_packet.CName.CName[i] = c;
}
_packetType = kRtcpSdesChunkCode;
_packet.CName.CNameLength = len;
// Make sure we are null terminated.
_packet.CName.CName[i] = 0;
_packetType = kRtcpSdesChunkCode;
foundCName = true;
}
_ptrRTCPData += len;
itemOctetsRead += len;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -20,16 +20,10 @@
namespace webrtc {
namespace RTCPUtility {
// CNAME
class RTCPCnameInformation
struct RTCPCnameInformation
{
public:
RTCPCnameInformation();
~RTCPCnameInformation();
WebRtc_UWord8 name[RTCP_CNAME_SIZE];
WebRtc_UWord8 length;
char name[RTCP_CNAME_SIZE];
};
struct RTCPPacketRR
{
WebRtc_UWord32 SenderSSRC;
@ -58,13 +52,11 @@ namespace RTCPUtility {
WebRtc_UWord32 LastSR;
WebRtc_UWord32 DelayLastSR;
};
struct RTCPPacketSDESCName
{
// RFC3550
WebRtc_UWord32 SenderSSRC;
WebRtc_UWord8 CName[RTCP_CNAME_SIZE];
WebRtc_UWord8 CNameLength;
char CName[RTCP_CNAME_SIZE];
};
struct RTCPPacketExtendedJitterReportItem

View File

@ -348,7 +348,7 @@ RTPReceiver::RegisterIncomingDataCallback(RtpData* incomingDataCallback)
}
WebRtc_Word32 RTPReceiver::RegisterReceivePayload(
const WebRtc_Word8 payloadName[RTP_PAYLOAD_NAME_SIZE],
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 frequency,
const WebRtc_UWord8 channels,
@ -450,7 +450,8 @@ WebRtc_Word32 RTPReceiver::RegisterReceivePayload(
_redPayloadType = payloadType;
payload = new Payload;
payload->audio = false;
memcpy(payload->name, payloadName, RTP_PAYLOAD_NAME_SIZE);
payload->name[RTP_PAYLOAD_NAME_SIZE - 1] = 0;
strncpy(payload->name, payloadName, RTP_PAYLOAD_NAME_SIZE - 1);
} else {
if (_audio) {
payload = RegisterReceiveAudioPayload(payloadName, payloadType,
@ -493,7 +494,7 @@ WebRtc_Word32 RTPReceiver::DeRegisterReceivePayload(
}
WebRtc_Word32 RTPReceiver::ReceivePayloadType(
const WebRtc_Word8 payloadName[RTP_PAYLOAD_NAME_SIZE],
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
const WebRtc_UWord32 frequency,
const WebRtc_UWord8 channels,
const WebRtc_UWord32 rate,
@ -549,7 +550,7 @@ WebRtc_Word32 RTPReceiver::ReceivePayloadType(
WebRtc_Word32 RTPReceiver::ReceivePayload(
const WebRtc_Word8 payloadType,
WebRtc_Word8 payloadName[RTP_PAYLOAD_NAME_SIZE],
char payloadName[RTP_PAYLOAD_NAME_SIZE],
WebRtc_UWord32* frequency,
WebRtc_UWord8* channels,
WebRtc_UWord32* rate) const {
@ -587,18 +588,20 @@ WebRtc_Word32 RTPReceiver::ReceivePayload(
}
}
if (payloadName) {
memcpy(payloadName, payload->name, RTP_PAYLOAD_NAME_SIZE);
payloadName[RTP_PAYLOAD_NAME_SIZE - 1] = 0;
strncpy(payloadName, payload->name, RTP_PAYLOAD_NAME_SIZE - 1);
}
return 0;
}
WebRtc_Word32 RTPReceiver::RemotePayload(
WebRtc_Word8 payloadName[RTP_PAYLOAD_NAME_SIZE],
char payloadName[RTP_PAYLOAD_NAME_SIZE],
WebRtc_Word8* payloadType,
WebRtc_UWord32* frequency,
WebRtc_UWord8* channels) const {
if(_lastReceivedPayloadType == -1) {
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, _id, "%s invalid state", __FUNCTION__);
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, _id,
"%s invalid state", __FUNCTION__);
return -1;
}
std::map<WebRtc_Word8, Payload*>::const_iterator it =
@ -610,7 +613,7 @@ WebRtc_Word32 RTPReceiver::RemotePayload(
Payload* payload = it->second;
assert(payload);
payloadName[RTP_PAYLOAD_NAME_SIZE - 1] = 0;
memcpy(payloadName, payload->name, RTP_PAYLOAD_NAME_SIZE - 1);
strncpy(payloadName, payload->name, RTP_PAYLOAD_NAME_SIZE - 1);
if (payloadType) {
*payloadType = _lastReceivedPayloadType;
@ -1134,11 +1137,10 @@ RTPReceiver::SetSSRCFilter(const bool enable, const WebRtc_UWord32 allowedSSRC)
void RTPReceiver::CheckSSRCChanged(const WebRtcRTPHeader* rtpHeader) {
bool newSSRC = false;
bool reInitializeDecoder = false;
WebRtc_Word8 payloadName[RTP_PAYLOAD_NAME_SIZE];
char payloadName[RTP_PAYLOAD_NAME_SIZE];
WebRtc_UWord32 frequency = 90000; // default video freq
WebRtc_UWord8 channels = 1;
WebRtc_UWord32 rate = 0;
memset(payloadName, 0, sizeof(payloadName));
{
CriticalSectionScoped lock(_criticalSectionRTPReceiver);
@ -1170,7 +1172,7 @@ void RTPReceiver::CheckSSRCChanged(const WebRtcRTPHeader* rtpHeader) {
Payload* payload = it->second;
assert(payload);
payloadName[RTP_PAYLOAD_NAME_SIZE - 1] = 0;
memcpy(payloadName, payload->name, RTP_PAYLOAD_NAME_SIZE - 1);
strncpy(payloadName, payload->name, RTP_PAYLOAD_NAME_SIZE - 1);
if(payload->audio) {
frequency = payload->typeSpecific.Audio.frequency;
channels = payload->typeSpecific.Audio.channels;
@ -1214,7 +1216,7 @@ WebRtc_Word32 RTPReceiver::CheckPayloadChanged(
VideoPayload& videoSpecificPayload) {
bool reInitializeDecoder = false;
WebRtc_Word8 payloadName[RTP_PAYLOAD_NAME_SIZE];
char payloadName[RTP_PAYLOAD_NAME_SIZE];
WebRtc_Word8 payloadType = rtpHeader->header.payloadType;
{
@ -1262,7 +1264,7 @@ WebRtc_Word32 RTPReceiver::CheckPayloadChanged(
Payload* payload = it->second;
assert(payload);
payloadName[RTP_PAYLOAD_NAME_SIZE - 1] = 0;
memcpy(payloadName, payload->name, RTP_PAYLOAD_NAME_SIZE - 1);
strncpy(payloadName, payload->name, RTP_PAYLOAD_NAME_SIZE - 1);
_lastReceivedPayloadType = payloadType;
reInitializeDecoder = true;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -56,31 +56,32 @@ public:
WebRtc_Word32 RegisterIncomingDataCallback(RtpData* incomingDataCallback);
WebRtc_Word32 RegisterIncomingRTPCallback(RtpFeedback* incomingMessagesCallback);
WebRtc_Word32 RegisterReceivePayload( const WebRtc_Word8 payloadName[RTP_PAYLOAD_NAME_SIZE],
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 frequency,
const WebRtc_UWord8 channels,
const WebRtc_UWord32 rate);
WebRtc_Word32 RegisterReceivePayload(
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 frequency,
const WebRtc_UWord8 channels,
const WebRtc_UWord32 rate);
WebRtc_Word32 DeRegisterReceivePayload(const WebRtc_Word8 payloadType);
WebRtc_Word32 ReceivePayloadType(
const WebRtc_Word8 payloadName[RTP_PAYLOAD_NAME_SIZE],
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
const WebRtc_UWord32 frequency,
const WebRtc_UWord8 channels,
const WebRtc_UWord32 rate,
WebRtc_Word8* payloadType) const;
WebRtc_Word32 ReceivePayload(const WebRtc_Word8 payloadType,
WebRtc_Word8 payloadName[RTP_PAYLOAD_NAME_SIZE],
char payloadName[RTP_PAYLOAD_NAME_SIZE],
WebRtc_UWord32* frequency,
WebRtc_UWord8* channels,
WebRtc_UWord32* rate) const;
WebRtc_Word32 RemotePayload(WebRtc_Word8 payloadName[RTP_PAYLOAD_NAME_SIZE],
WebRtc_Word8* payloadType,
WebRtc_UWord32* frequency,
WebRtc_UWord8* channels) const;
WebRtc_Word32 RemotePayload(char payloadName[RTP_PAYLOAD_NAME_SIZE],
WebRtc_Word8* payloadType,
WebRtc_UWord32* frequency,
WebRtc_UWord8* channels) const;
WebRtc_Word32 IncomingRTPPacket(WebRtcRTPHeader* rtpheader,
const WebRtc_UWord8* incomingRtpPacket,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -202,92 +202,64 @@ RTPReceiverAudio::CNGPayloadType(const WebRtc_Word8 payloadType,
G7221 frame N/A
*/
ModuleRTPUtility::Payload*
RTPReceiverAudio::RegisterReceiveAudioPayload(const WebRtc_Word8 payloadName[RTP_PAYLOAD_NAME_SIZE],
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 frequency,
const WebRtc_UWord8 channels,
const WebRtc_UWord32 rate)
{
WebRtc_Word32 length = (WebRtc_Word32)strlen(payloadName);
if(length > RTP_PAYLOAD_NAME_SIZE)
{
assert(false);
return NULL;
ModuleRTPUtility::Payload* RTPReceiverAudio::RegisterReceiveAudioPayload(
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 frequency,
const WebRtc_UWord8 channels,
const WebRtc_UWord32 rate) {
if (ModuleRTPUtility::StringCompare(payloadName, "telephone-event", 15)) {
_telephoneEventPayloadType = payloadType;
}
if (ModuleRTPUtility::StringCompare(payloadName, "cn", 2)) {
// we can have three CNG on 8000Hz, 16000Hz and 32000Hz
if(frequency == 8000){
_cngNBPayloadType = payloadType;
} else if(frequency == 16000) {
_cngWBPayloadType = payloadType;
} else if(frequency == 32000) {
_cngSWBPayloadType = payloadType;
} else {
assert(false);
return NULL;
}
if (ModuleRTPUtility::StringCompare(payloadName,"telephone-event",15))
{
_telephoneEventPayloadType = payloadType;
}
WebRtc_UWord8 bitsPerSample = 0; // zero implies frame based
if (ModuleRTPUtility::StringCompare(payloadName, "DVI4", 4)) {
bitsPerSample = 4;
} else if(ModuleRTPUtility::StringCompare(payloadName, "G722", 4)) {
if(ModuleRTPUtility::StringCompare(payloadName, "G7221", 5)) {
// frame based
} else {
_G722PayloadType = payloadType;
bitsPerSample = 4;
}
if (ModuleRTPUtility::StringCompare(payloadName,"cn",2))
{
// we can have three CNG on 8000Hz, 16000Hz and 32000Hz
if(frequency == 8000)
{
_cngNBPayloadType = payloadType;
} else if(frequency == 16000)
{
_cngWBPayloadType = payloadType;
} else if(frequency == 32000)
{
_cngSWBPayloadType = payloadType;
}else
{
assert(false);
return NULL;
}
}
WebRtc_UWord8 bitsPerSample = 0; // zero implies frame based
if (ModuleRTPUtility::StringCompare(payloadName,"DVI4",4))
{
bitsPerSample = 4;
} else if(ModuleRTPUtility::StringCompare(payloadName,"G722",4))
{
if(ModuleRTPUtility::StringCompare(payloadName,"G7221",5))
{
// frame based
} else
{
_G722PayloadType = payloadType;
bitsPerSample = 4;
}
} else if(ModuleRTPUtility::StringCompare(payloadName,"G726-40",7))
{
bitsPerSample = 5;
} else if(ModuleRTPUtility::StringCompare(payloadName,"G726-32",7))
{
bitsPerSample = 4;
} else if(ModuleRTPUtility::StringCompare(payloadName,"G726-24",7))
{
bitsPerSample = 3;
} else if(ModuleRTPUtility::StringCompare(payloadName,"G726-16",7))
{
bitsPerSample = 2;
} else if(ModuleRTPUtility::StringCompare(payloadName,"L8",2))
{
bitsPerSample = 8;
} else if(ModuleRTPUtility::StringCompare(payloadName,"L16",3))
{
bitsPerSample = 16;
} else if(ModuleRTPUtility::StringCompare(payloadName,"PCMU",4))
{
bitsPerSample = 8;
} else if(ModuleRTPUtility::StringCompare(payloadName,"PCMA",4))
{
bitsPerSample = 8;
}
ModuleRTPUtility::Payload* payload = new ModuleRTPUtility::Payload;
memcpy(payload->name, payloadName, length+1);
payload->typeSpecific.Audio.frequency = frequency;
payload->typeSpecific.Audio.channels = channels;
payload->typeSpecific.Audio.bitsPerSample = bitsPerSample;
payload->typeSpecific.Audio.rate = rate;
payload->audio = true;
return payload;
} else if(ModuleRTPUtility::StringCompare(payloadName,"G726-40",7)) {
bitsPerSample = 5;
} else if(ModuleRTPUtility::StringCompare(payloadName,"G726-32",7)) {
bitsPerSample = 4;
} else if(ModuleRTPUtility::StringCompare(payloadName,"G726-24",7)) {
bitsPerSample = 3;
} else if(ModuleRTPUtility::StringCompare(payloadName,"G726-16",7)) {
bitsPerSample = 2;
} else if(ModuleRTPUtility::StringCompare(payloadName,"L8",2)) {
bitsPerSample = 8;
} else if(ModuleRTPUtility::StringCompare(payloadName,"L16",3)) {
bitsPerSample = 16;
} else if(ModuleRTPUtility::StringCompare(payloadName,"PCMU",4)) {
bitsPerSample = 8;
} else if(ModuleRTPUtility::StringCompare(payloadName,"PCMA",4)) {
bitsPerSample = 8;
}
ModuleRTPUtility::Payload* payload = new ModuleRTPUtility::Payload;
payload->name[RTP_PAYLOAD_NAME_SIZE - 1] = 0;
strncpy(payload->name, payloadName, RTP_PAYLOAD_NAME_SIZE - 1);
payload->typeSpecific.Audio.frequency = frequency;
payload->typeSpecific.Audio.channels = channels;
payload->typeSpecific.Audio.bitsPerSample = bitsPerSample;
payload->typeSpecific.Audio.rate = rate;
payload->audio = true;
return payload;
}
// we are not allowed to have any critsects when calling CallbackOfReceivedPayloadData

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -33,11 +33,12 @@ public:
WebRtc_Word32 RegisterIncomingAudioCallback(RtpAudioFeedback* incomingMessagesCallback);
ModuleRTPUtility::Payload* RegisterReceiveAudioPayload(const WebRtc_Word8 payloadName[RTP_PAYLOAD_NAME_SIZE],
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 frequency,
const WebRtc_UWord8 channels,
const WebRtc_UWord32 rate);
ModuleRTPUtility::Payload* RegisterReceiveAudioPayload(
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 frequency,
const WebRtc_UWord8 channels,
const WebRtc_UWord32 rate);
WebRtc_UWord32 AudioFrequency() const;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -99,38 +99,33 @@ RTPReceiverVideo::UpdateBandwidthManagement(const WebRtc_UWord32 bitrateBps,
}
}
ModuleRTPUtility::Payload*
RTPReceiverVideo::RegisterReceiveVideoPayload(const WebRtc_Word8 payloadName[RTP_PAYLOAD_NAME_SIZE],
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 maxRate)
{
RtpVideoCodecTypes videoType = kRtpNoVideo;
if (ModuleRTPUtility::StringCompare(payloadName, "VP8",3))
{
videoType = kRtpVp8Video;
} else if (ModuleRTPUtility::StringCompare(payloadName, "I420", 4))
{
videoType = kRtpNoVideo;
} else if (ModuleRTPUtility::StringCompare(payloadName, "ULPFEC", 6))
{
// store this
if(_receiveFEC == NULL)
{
_receiveFEC = new ReceiverFEC(_id, this);
}
_receiveFEC->SetPayloadTypeFEC(payloadType);
videoType = kRtpFecVideo;
} else
{
return NULL;
ModuleRTPUtility::Payload* RTPReceiverVideo::RegisterReceiveVideoPayload(
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 maxRate) {
RtpVideoCodecTypes videoType = kRtpNoVideo;
if (ModuleRTPUtility::StringCompare(payloadName, "VP8", 3)) {
videoType = kRtpVp8Video;
} else if (ModuleRTPUtility::StringCompare(payloadName, "I420", 4)) {
videoType = kRtpNoVideo;
} else if (ModuleRTPUtility::StringCompare(payloadName, "ULPFEC", 6)) {
// store this
if (_receiveFEC == NULL) {
_receiveFEC = new ReceiverFEC(_id, this);
}
_receiveFEC->SetPayloadTypeFEC(payloadType);
videoType = kRtpFecVideo;
} else {
return NULL;
}
ModuleRTPUtility::Payload* payload = new ModuleRTPUtility::Payload;
ModuleRTPUtility::Payload* payload = new ModuleRTPUtility::Payload;
strncpy(payload->name, payloadName, RTP_PAYLOAD_NAME_SIZE);
payload->typeSpecific.Video.videoCodecType = videoType;
payload->typeSpecific.Video.maxRate = maxRate;
payload->audio = false;
return payload;
payload->name[RTP_PAYLOAD_NAME_SIZE - 1] = 0;
strncpy(payload->name, payloadName, RTP_PAYLOAD_NAME_SIZE - 1);
payload->typeSpecific.Video.videoCodecType = videoType;
payload->typeSpecific.Video.maxRate = maxRate;
payload->audio = false;
return payload;
}
void RTPReceiverVideo::ResetOverUseDetector()
@ -406,56 +401,43 @@ RTPReceiverVideo::ReceiveRecoveredPacketCallback(WebRtcRTPHeader* rtpHeader,
payload->typeSpecific.Video.videoCodecType);
}
WebRtc_Word32
RTPReceiverVideo::SetCodecType(const RtpVideoCodecTypes videoType,
WebRtcRTPHeader* rtpHeader) const
{
switch (videoType)
{
WebRtc_Word32 RTPReceiverVideo::SetCodecType(const RtpVideoCodecTypes videoType,
WebRtcRTPHeader* rtpHeader) const {
switch (videoType) {
case kRtpNoVideo:
rtpHeader->type.Video.codec = kRTPVideoGeneric;
break;
rtpHeader->type.Video.codec = kRTPVideoGeneric;
break;
case kRtpVp8Video:
rtpHeader->type.Video.codec = kRTPVideoVP8;
break;
rtpHeader->type.Video.codec = kRTPVideoVP8;
break;
case kRtpFecVideo:
rtpHeader->type.Video.codec = kRTPVideoFEC;
break;
default:
assert(((void)"ParseCodecSpecific videoType can not be unknown here!", false));
return -1;
}
return 0;
rtpHeader->type.Video.codec = kRTPVideoFEC;
break;
}
return 0;
}
WebRtc_Word32
RTPReceiverVideo::ParseVideoCodecSpecificSwitch(WebRtcRTPHeader* rtpHeader,
const WebRtc_UWord8* payloadData,
const WebRtc_UWord16 payloadDataLength,
const RtpVideoCodecTypes videoType)
{
WebRtc_Word32 retVal = SetCodecType(videoType, rtpHeader);
if(retVal != 0)
{
return retVal;
}
// all receive functions release _criticalSectionReceiverVideo before returning
switch (videoType)
{
case kRtpNoVideo:
retVal = ReceiveGenericCodec(rtpHeader, payloadData, payloadDataLength);
break;
case kRtpVp8Video:
retVal = ReceiveVp8Codec(rtpHeader, payloadData, payloadDataLength);
break;
default:
_criticalSectionReceiverVideo->Leave();
assert(((void)"ParseCodecSpecific videoType can not be unknown here!", false));
return -1;
}
WebRtc_Word32 RTPReceiverVideo::ParseVideoCodecSpecificSwitch(
WebRtcRTPHeader* rtpHeader,
const WebRtc_UWord8* payloadData,
const WebRtc_UWord16 payloadDataLength,
const RtpVideoCodecTypes videoType) {
WebRtc_Word32 retVal = SetCodecType(videoType, rtpHeader);
if (retVal != 0) {
return retVal;
}
// All receive functions release _criticalSectionReceiverVideo before
// returning.
switch (videoType) {
case kRtpNoVideo:
return ReceiveGenericCodec(rtpHeader, payloadData, payloadDataLength);
case kRtpVp8Video:
return ReceiveVp8Codec(rtpHeader, payloadData, payloadDataLength);
case kRtpFecVideo:
break;
}
_criticalSectionReceiverVideo->Leave();
return -1;
}
WebRtc_Word32

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -44,7 +44,7 @@ public:
const WebRtc_UWord16 roundTripTimeMs);
ModuleRTPUtility::Payload* RegisterReceiveVideoPayload(
const WebRtc_Word8 payloadName[RTP_PAYLOAD_NAME_SIZE],
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 maxRate);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -1523,46 +1523,38 @@ WebRtc_UWord32 ModuleRtpRtcpImpl::LastSendReport(WebRtc_UWord32& lastRTCPTime)
return _rtcpSender.LastSendReport(lastRTCPTime);
}
WebRtc_Word32
ModuleRtpRtcpImpl::SetCNAME(const WebRtc_Word8 cName[RTCP_CNAME_SIZE])
{
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, _id, "SetCNAME(%s)", cName);
return _rtcpSender.SetCNAME(cName);
WebRtc_Word32 ModuleRtpRtcpImpl::SetCNAME(const char cName[RTCP_CNAME_SIZE]) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, _id, "SetCNAME(%s)", cName);
return _rtcpSender.SetCNAME(cName);
}
WebRtc_Word32
ModuleRtpRtcpImpl::CNAME(WebRtc_Word8 cName[RTCP_CNAME_SIZE])
{
WebRtc_Word32 ModuleRtpRtcpImpl::CNAME(char cName[RTCP_CNAME_SIZE]) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, _id, "CNAME()");
return _rtcpSender.CNAME(cName);
}
WebRtc_Word32
ModuleRtpRtcpImpl::AddMixedCNAME(const WebRtc_UWord32 SSRC,
const WebRtc_Word8 cName[RTCP_CNAME_SIZE])
{
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, _id, "AddMixedCNAME(SSRC:%u)", SSRC);
WebRtc_Word32 ModuleRtpRtcpImpl::AddMixedCNAME(
const WebRtc_UWord32 SSRC,
const char cName[RTCP_CNAME_SIZE]) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, _id,
"AddMixedCNAME(SSRC:%u)", SSRC);
return _rtcpSender.AddMixedCNAME(SSRC, cName);
return _rtcpSender.AddMixedCNAME(SSRC, cName);
}
WebRtc_Word32
ModuleRtpRtcpImpl::RemoveMixedCNAME(const WebRtc_UWord32 SSRC)
{
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, _id, "RemoveMixedCNAME(SSRC:%u)", SSRC);
WebRtc_Word32 ModuleRtpRtcpImpl::RemoveMixedCNAME(const WebRtc_UWord32 SSRC) {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, _id,
"RemoveMixedCNAME(SSRC:%u)", SSRC);
return _rtcpSender.RemoveMixedCNAME(SSRC);
}
WebRtc_Word32
ModuleRtpRtcpImpl::RemoteCNAME(const WebRtc_UWord32 remoteSSRC,
WebRtc_Word8 cName[RTCP_CNAME_SIZE]) const
{
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, _id, "RemoteCNAME(SSRC:%u)", remoteSSRC);
WebRtc_Word32 ModuleRtpRtcpImpl::RemoteCNAME(
const WebRtc_UWord32 remoteSSRC,
char cName[RTCP_CNAME_SIZE]) const {
WEBRTC_TRACE(kTraceModuleCall, kTraceRtpRtcp, _id,
"RemoteCNAME(SSRC:%u)", remoteSSRC);
return _rtcpReceiver.CNAME(remoteSSRC, cName);
return _rtcpReceiver.CNAME(remoteSSRC, cName);
}
WebRtc_UWord16 ModuleRtpRtcpImpl::RemoteSequenceNumber() const

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -162,13 +162,6 @@ public:
virtual WebRtc_Word32 RegisterSendPayload(const VideoCodec& videoCodec);
// set codec name and payload type
WebRtc_Word32 RegisterSendPayload(const WebRtc_Word8 payloadName[RTP_PAYLOAD_NAME_SIZE],
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 frequency,
const WebRtc_UWord8 channels,
const WebRtc_UWord32 rate);
virtual WebRtc_Word32 DeRegisterSendPayload(const WebRtc_Word8 payloadType);
virtual WebRtc_Word8 SendPayloadType() const;
@ -255,14 +248,14 @@ public:
virtual WebRtc_Word32 SetRTCPStatus(const RTCPMethod method);
// Set RTCP CName
virtual WebRtc_Word32 SetCNAME(const WebRtc_Word8 cName[RTCP_CNAME_SIZE]);
virtual WebRtc_Word32 SetCNAME(const char cName[RTCP_CNAME_SIZE]);
// Get RTCP CName
virtual WebRtc_Word32 CNAME(WebRtc_Word8 cName[RTCP_CNAME_SIZE]);
virtual WebRtc_Word32 CNAME(char cName[RTCP_CNAME_SIZE]);
// Get remote CName
virtual WebRtc_Word32 RemoteCNAME(const WebRtc_UWord32 remoteSSRC,
WebRtc_Word8 cName[RTCP_CNAME_SIZE]) const;
char cName[RTCP_CNAME_SIZE]) const;
// Get remote NTP
virtual WebRtc_Word32 RemoteNTP(WebRtc_UWord32 *ReceivedNTPsecs,
@ -271,7 +264,7 @@ public:
WebRtc_UWord32 *RTCPArrivalTimeFrac) const ;
virtual WebRtc_Word32 AddMixedCNAME(const WebRtc_UWord32 SSRC,
const WebRtc_Word8 cName[RTCP_CNAME_SIZE]);
const char cName[RTCP_CNAME_SIZE]);
virtual WebRtc_Word32 RemoveMixedCNAME(const WebRtc_UWord32 SSRC);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -272,16 +272,12 @@ RTPSender::RtpHeaderExtensionTotalLength() const
//can be called multiple times
WebRtc_Word32 RTPSender::RegisterPayload(
const WebRtc_Word8 payloadName[RTP_PAYLOAD_NAME_SIZE],
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
const WebRtc_Word8 payloadNumber,
const WebRtc_UWord32 frequency,
const WebRtc_UWord8 channels,
const WebRtc_UWord32 rate) {
if (!payloadName) {
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s invalid argument",
__FUNCTION__);
return -1;
}
assert(payloadName);
CriticalSectionScoped cs(_sendCritsect);
if (payloadNumber == _keepAlivePayloadType) {
@ -298,11 +294,8 @@ WebRtc_Word32 RTPSender::RegisterPayload(
assert(payload);
// check if it's the same as we already have
WebRtc_Word32 payloadNameLength = (WebRtc_Word32)strlen(payloadName);
WebRtc_Word32 nameLength = (WebRtc_Word32)strlen(payload->name);
if (payloadNameLength == nameLength &&
ModuleRTPUtility::StringCompare(payload->name, payloadName,
nameLength)) {
if (ModuleRTPUtility::StringCompare(payload->name, payloadName,
RTP_PAYLOAD_NAME_SIZE - 1)) {
if (_audioConfigured && payload->audio &&
payload->typeSpecific.Audio.frequency == frequency &&
(payload->typeSpecific.Audio.rate == rate ||

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -90,7 +90,7 @@ public:
WebRtc_Word32 RegisterSendTransport(Transport* outgoingTransport);
WebRtc_Word32 RegisterPayload(
const WebRtc_Word8 payloadName[RTP_PAYLOAD_NAME_SIZE],
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 frequency,
const WebRtc_UWord8 channels,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -106,56 +106,44 @@ RTPSenderAudio::SetAudioPacketSize(const WebRtc_UWord16 packetSizeSamples)
return 0;
}
WebRtc_Word32
RTPSenderAudio::RegisterAudioPayload(const WebRtc_Word8 payloadName[RTP_PAYLOAD_NAME_SIZE],
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 frequency,
const WebRtc_UWord8 channels,
const WebRtc_UWord32 rate,
ModuleRTPUtility::Payload*& payload)
{
WebRtc_Word32 length = (WebRtc_Word32)strlen(payloadName);
if(length > RTP_PAYLOAD_NAME_SIZE)
{
return -1;
WebRtc_Word32 RTPSenderAudio::RegisterAudioPayload(
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 frequency,
const WebRtc_UWord8 channels,
const WebRtc_UWord32 rate,
ModuleRTPUtility::Payload*& payload) {
CriticalSectionScoped cs(_sendAudioCritsect);
if (ModuleRTPUtility::StringCompare(payloadName, "cn", 2)) {
// we can have multiple CNG payload types
if (frequency == 8000) {
_cngNBPayloadType = payloadType;
} else if (frequency == 16000) {
_cngWBPayloadType = payloadType;
} else if (frequency == 32000) {
_cngSWBPayloadType = payloadType;
} else {
return -1;
}
CriticalSectionScoped cs(_sendAudioCritsect);
if (ModuleRTPUtility::StringCompare(payloadName,"cn",2))
{
// we can have multiple CNG payload types
if(frequency == 8000)
{
_cngNBPayloadType = payloadType;
} else if(frequency == 16000)
{
_cngWBPayloadType = payloadType;
} else if(frequency == 32000)
{
_cngSWBPayloadType = payloadType;
}else
{
return -1;
}
}
if (ModuleRTPUtility::StringCompare(payloadName,"telephone-event",15))
{
// Don't add it to the list
// we dont want to allow send with a DTMF payloadtype
_dtmfPayloadType = payloadType;
return 0;
// The default timestamp rate is 8000 Hz, but other rates may be defined.
}
payload = new ModuleRTPUtility::Payload;
payload->typeSpecific.Audio.frequency = frequency;
payload->typeSpecific.Audio.channels = channels;
payload->typeSpecific.Audio.rate = rate;
payload->audio = true;
memcpy(payload->name, payloadName, length+1);
}
if (ModuleRTPUtility::StringCompare(payloadName, "telephone-event", 15)) {
// Don't add it to the list
// we dont want to allow send with a DTMF payloadtype
_dtmfPayloadType = payloadType;
return 0;
// The default timestamp rate is 8000 Hz, but other rates may be defined.
}
payload = new ModuleRTPUtility::Payload;
payload->typeSpecific.Audio.frequency = frequency;
payload->typeSpecific.Audio.channels = channels;
payload->typeSpecific.Audio.rate = rate;
payload->audio = true;
payload->name[RTP_PAYLOAD_NAME_SIZE - 1] = 0;
strncpy(payload->name, payloadName, RTP_PAYLOAD_NAME_SIZE - 1);
return 0;
}
bool

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -32,19 +32,20 @@ public:
WebRtc_Word32 Init();
WebRtc_Word32 RegisterAudioPayload(const WebRtc_Word8 payloadName[RTP_PAYLOAD_NAME_SIZE],
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 frequency,
const WebRtc_UWord8 channels,
const WebRtc_UWord32 rate,
ModuleRTPUtility::Payload*& payload);
WebRtc_Word32 RegisterAudioPayload(
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 frequency,
const WebRtc_UWord8 channels,
const WebRtc_UWord32 rate,
ModuleRTPUtility::Payload*& payload);
WebRtc_Word32 SendAudio(const FrameType frameType,
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 captureTimeStamp,
const WebRtc_UWord8* payloadData,
const WebRtc_UWord32 payloadSize,
const RTPFragmentationHeader* fragmentation);
const WebRtc_Word8 payloadType,
const WebRtc_UWord32 captureTimeStamp,
const WebRtc_UWord8* payloadData,
const WebRtc_UWord32 payloadSize,
const RTPFragmentationHeader* fragmentation);
// set audio packet size, used to determine when it's time to send a DTMF packet in silence (CNG)
WebRtc_Word32 SetAudioPacketSize(const WebRtc_UWord16 packetSizeSamples);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -113,12 +113,11 @@ WebRtc_Word32 RTPSenderVideo::RegisterVideoPayload(
} else if (ModuleRTPUtility::StringCompare(payloadName, "I420", 4)) {
videoType = kRtpNoVideo;
} else {
videoType = kRtpNoVideo;
return -1;
}
payload = new ModuleRTPUtility::Payload;
payload->name[RTP_PAYLOAD_NAME_SIZE - 1] = 0;
strncpy(payload->name, payloadName, RTP_PAYLOAD_NAME_SIZE - 1);
payload->name[RTP_PAYLOAD_NAME_SIZE - 1] = 0; // Null terminate string.
payload->typeSpecific.Video.videoCodecType = videoType;
payload->typeSpecific.Video.maxRate = maxBitRate;
payload->audio = false;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -322,15 +322,15 @@ bool OldTimestamp(uint32_t newTimestamp,
*/
#if defined(_WIN32)
bool ModuleRTPUtility::StringCompare(const WebRtc_Word8* str1,
const WebRtc_Word8* str2,
bool ModuleRTPUtility::StringCompare(const char* str1,
const char* str2,
const WebRtc_UWord32 length)
{
return (_strnicmp(str1, str2, length) == 0)?true: false;
}
#elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC)
bool ModuleRTPUtility::StringCompare(const WebRtc_Word8* str1,
const WebRtc_Word8* str2,
bool ModuleRTPUtility::StringCompare(const char* str1,
const char* str2,
const WebRtc_UWord32 length)
{
return (strncasecmp(str1, str2, length) == 0)?true: false;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -55,8 +55,8 @@ namespace ModuleRTPUtility
};
struct Payload
{
WebRtc_Word8 name[RTP_PAYLOAD_NAME_SIZE];
bool audio;
char name[RTP_PAYLOAD_NAME_SIZE];
bool audio;
PayloadUnion typeSpecific;
};
@ -89,8 +89,8 @@ namespace ModuleRTPUtility
uint32_t existingTimestamp,
bool* wrapped);
bool StringCompare(const WebRtc_Word8* str1,
const WebRtc_Word8* str2,
bool StringCompare(const char* str1,
const char* str2,
const WebRtc_UWord32 length);
void AssignUWord32ToBuffer(WebRtc_UWord8* dataBuffer, WebRtc_UWord32 value);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -45,11 +45,11 @@ public:
// Sets the file name. If addFileCounter is false the same file will be
// reused when it fills up. If it's true a new file with incremented name
// will be used.
static WebRtc_Word32 SetTraceFile(const WebRtc_Word8* fileName,
static WebRtc_Word32 SetTraceFile(const char* fileName,
const bool addFileCounter = false);
// Returns the name of the file that the trace is currently writing to.
static WebRtc_Word32 TraceFile(WebRtc_Word8 fileName[1024]);
static WebRtc_Word32 TraceFile(char fileName[1024]);
// Registers callback to receive trace messages. TODO (hellner)
// why not use OutStream instead? Why is TraceCallback not defined in this

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -94,7 +94,7 @@ TraceImpl::TraceImpl()
for(int n = 0; n < WEBRTC_TRACE_MAX_QUEUE; n++)
{
_messageQueue[m][n] = new
WebRtc_Word8[WEBRTC_TRACE_MAX_MESSAGE_SIZE];
char[WEBRTC_TRACE_MAX_MESSAGE_SIZE];
}
}
}
@ -350,7 +350,7 @@ WebRtc_Word32 TraceImpl::AddModuleAndId(char* traceMessage,
return 25;
}
WebRtc_Word32 TraceImpl::SetTraceFileImpl(const WebRtc_Word8* fileNameUTF8,
WebRtc_Word32 TraceImpl::SetTraceFileImpl(const char* fileNameUTF8,
const bool addFileCounter)
{
CriticalSectionScoped lock(_critsectInterface);
@ -364,7 +364,7 @@ WebRtc_Word32 TraceImpl::SetTraceFileImpl(const WebRtc_Word8* fileNameUTF8,
{
_fileCountText = 1;
WebRtc_Word8 fileNameWithCounterUTF8[FileWrapper::kMaxFileNameSize];
char fileNameWithCounterUTF8[FileWrapper::kMaxFileNameSize];
CreateFileName(fileNameUTF8, fileNameWithCounterUTF8,
_fileCountText);
if(_traceFile.OpenFile(fileNameWithCounterUTF8, false, false,
@ -385,7 +385,7 @@ WebRtc_Word32 TraceImpl::SetTraceFileImpl(const WebRtc_Word8* fileNameUTF8,
}
WebRtc_Word32 TraceImpl::TraceFileImpl(
WebRtc_Word8 fileNameUTF8[FileWrapper::kMaxFileNameSize])
char fileNameUTF8[FileWrapper::kMaxFileNameSize])
{
CriticalSectionScoped lock(_critsectInterface);
return _traceFile.FileName(fileNameUTF8, FileWrapper::kMaxFileNameSize);
@ -556,8 +556,8 @@ void TraceImpl::WriteToFile()
_traceFile.Rewind();
} else
{
WebRtc_Word8 oldFileName[FileWrapper::kMaxFileNameSize];
WebRtc_Word8 newFileName[FileWrapper::kMaxFileNameSize];
char oldFileName[FileWrapper::kMaxFileNameSize];
char newFileName[FileWrapper::kMaxFileNameSize];
// get current name
_traceFile.FileName(oldFileName,
@ -577,7 +577,7 @@ void TraceImpl::WriteToFile()
}
if(_rowCountText == 0)
{
WebRtc_Word8 message[WEBRTC_TRACE_MAX_MESSAGE_SIZE + 1];
char message[WEBRTC_TRACE_MAX_MESSAGE_SIZE + 1];
WebRtc_Word32 length = AddDateTimeInfo(message);
if(length != -1)
{
@ -669,8 +669,8 @@ bool TraceImpl::TraceCheck(const TraceLevel level) const
}
bool TraceImpl::UpdateFileName(
const WebRtc_Word8 fileNameUTF8[FileWrapper::kMaxFileNameSize],
WebRtc_Word8 fileNameWithCounterUTF8[FileWrapper::kMaxFileNameSize],
const char fileNameUTF8[FileWrapper::kMaxFileNameSize],
char fileNameWithCounterUTF8[FileWrapper::kMaxFileNameSize],
const WebRtc_UWord32 newCount) const
{
WebRtc_Word32 length = (WebRtc_Word32)strlen(fileNameUTF8);
@ -712,8 +712,8 @@ bool TraceImpl::UpdateFileName(
}
bool TraceImpl::CreateFileName(
const WebRtc_Word8 fileNameUTF8[FileWrapper::kMaxFileNameSize],
WebRtc_Word8 fileNameWithCounterUTF8[FileWrapper::kMaxFileNameSize],
const char fileNameUTF8[FileWrapper::kMaxFileNameSize],
char fileNameWithCounterUTF8[FileWrapper::kMaxFileNameSize],
const WebRtc_UWord32 newCount) const
{
WebRtc_Word32 length = (WebRtc_Word32)strlen(fileNameUTF8);
@ -766,7 +766,7 @@ WebRtc_Word32 Trace::LevelFilter(WebRtc_UWord32& filter)
return 0;
}
WebRtc_Word32 Trace::TraceFile(WebRtc_Word8 fileName[FileWrapper::kMaxFileNameSize])
WebRtc_Word32 Trace::TraceFile(char fileName[FileWrapper::kMaxFileNameSize])
{
TraceImpl* trace = TraceImpl::GetTrace();
if(trace)
@ -778,7 +778,7 @@ WebRtc_Word32 Trace::TraceFile(WebRtc_Word8 fileName[FileWrapper::kMaxFileNameSi
return -1;
}
WebRtc_Word32 Trace::SetTraceFile(const WebRtc_Word8* fileName,
WebRtc_Word32 Trace::SetTraceFile(const char* fileName,
const bool addFileCounter)
{
TraceImpl* trace = TraceImpl::GetTrace();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -49,10 +49,10 @@ public:
static TraceImpl* CreateInstance();
static TraceImpl* GetTrace(const TraceLevel level = kTraceAll);
WebRtc_Word32 SetTraceFileImpl(const WebRtc_Word8* fileName,
WebRtc_Word32 SetTraceFileImpl(const char* fileName,
const bool addFileCounter);
WebRtc_Word32 TraceFileImpl(
WebRtc_Word8 fileName[FileWrapper::kMaxFileNameSize]);
char fileName[FileWrapper::kMaxFileNameSize]);
WebRtc_Word32 SetTraceCallbackImpl(TraceCallback* callback);
@ -99,13 +99,13 @@ private:
const TraceLevel level);
bool UpdateFileName(
const WebRtc_Word8 fileNameUTF8[FileWrapper::kMaxFileNameSize],
WebRtc_Word8 fileNameWithCounterUTF8[FileWrapper::kMaxFileNameSize],
const char fileNameUTF8[FileWrapper::kMaxFileNameSize],
char fileNameWithCounterUTF8[FileWrapper::kMaxFileNameSize],
const WebRtc_UWord32 newCount) const;
bool CreateFileName(
const WebRtc_Word8 fileNameUTF8[FileWrapper::kMaxFileNameSize],
WebRtc_Word8 fileNameWithCounterUTF8[FileWrapper::kMaxFileNameSize],
const char fileNameUTF8[FileWrapper::kMaxFileNameSize],
char fileNameWithCounterUTF8[FileWrapper::kMaxFileNameSize],
const WebRtc_UWord32 newCount) const;
void WriteToFile();
@ -124,7 +124,7 @@ private:
WebRtc_UWord16 _nextFreeIdx[WEBRTC_TRACE_NUM_ARRAY];
TraceLevel _level[WEBRTC_TRACE_NUM_ARRAY][WEBRTC_TRACE_MAX_QUEUE];
WebRtc_UWord16 _length[WEBRTC_TRACE_NUM_ARRAY][WEBRTC_TRACE_MAX_QUEUE];
WebRtc_Word8* _messageQueue[WEBRTC_TRACE_NUM_ARRAY][WEBRTC_TRACE_MAX_QUEUE];
char* _messageQueue[WEBRTC_TRACE_NUM_ARRAY][WEBRTC_TRACE_MAX_QUEUE];
WebRtc_UWord8 _activeQueue;
};
} // namespace webrtc