Removed list and map wrappers, for RTCP handling.
Review URL: https://webrtc-codereview.appspot.com/349011 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1473 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
9ff87db5c0
commit
26f8d9c7f3
@ -52,66 +52,30 @@ RTCPReceiver::RTCPReceiver(const WebRtc_Word32 id,
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, id, "%s created", __FUNCTION__);
|
||||
}
|
||||
|
||||
RTCPReceiver::~RTCPReceiver()
|
||||
{
|
||||
delete _criticalSectionRTCPReceiver;
|
||||
delete _criticalSectionFeedbacks;
|
||||
RTCPReceiver::~RTCPReceiver() {
|
||||
delete _criticalSectionRTCPReceiver;
|
||||
delete _criticalSectionFeedbacks;
|
||||
|
||||
bool loop = true;
|
||||
do
|
||||
{
|
||||
MapItem* item = _receivedReportBlockMap.First();
|
||||
if(item)
|
||||
{
|
||||
// delete
|
||||
RTCPReportBlockInformation* block= ((RTCPReportBlockInformation*)item->GetItem());
|
||||
delete block;
|
||||
|
||||
// remove from map and delete Item
|
||||
_receivedReportBlockMap.Erase(item);
|
||||
} else
|
||||
{
|
||||
loop = false;
|
||||
}
|
||||
} while (loop);
|
||||
|
||||
loop = true;
|
||||
do
|
||||
{
|
||||
MapItem* item = _receivedInfoMap.First();
|
||||
if(item)
|
||||
{
|
||||
// delete
|
||||
RTCPReceiveInformation* block= ((RTCPReceiveInformation*)item->GetItem());
|
||||
delete block;
|
||||
|
||||
// remove from map and delete Item
|
||||
_receivedInfoMap.Erase(item);
|
||||
} else
|
||||
{
|
||||
loop = false;
|
||||
}
|
||||
} while (loop);
|
||||
|
||||
loop = true;
|
||||
do
|
||||
{
|
||||
MapItem* item = _receivedCnameMap.First();
|
||||
if(item)
|
||||
{
|
||||
// delete
|
||||
RTCPCnameInformation* block= ((RTCPCnameInformation*)item->GetItem());
|
||||
delete block;
|
||||
|
||||
// remove from map and delete Item
|
||||
_receivedCnameMap.Erase(item);
|
||||
} else
|
||||
{
|
||||
loop = false;
|
||||
}
|
||||
} while (loop);
|
||||
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, _id, "%s deleted", __FUNCTION__);
|
||||
while (!_receivedReportBlockMap.empty()) {
|
||||
std::map<WebRtc_UWord32, RTCPReportBlockInformation*>::iterator first =
|
||||
_receivedReportBlockMap.begin();
|
||||
delete first->second;
|
||||
_receivedReportBlockMap.erase(first);
|
||||
}
|
||||
while (!_receivedInfoMap.empty()) {
|
||||
std::map<WebRtc_UWord32, RTCPReceiveInformation*>::iterator first =
|
||||
_receivedInfoMap.begin();
|
||||
delete first->second;
|
||||
_receivedInfoMap.erase(first);
|
||||
}
|
||||
while (!_receivedCnameMap.empty()) {
|
||||
std::map<WebRtc_UWord32, RTCPCnameInformation*>::iterator first =
|
||||
_receivedCnameMap.begin();
|
||||
delete first->second;
|
||||
_receivedCnameMap.erase(first);
|
||||
}
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, _id,
|
||||
"%s deleted", __FUNCTION__);
|
||||
}
|
||||
|
||||
void
|
||||
@ -285,21 +249,15 @@ RTCPReceiver::SenderInfoReceived(RTCPSenderInfo* senderInfo) const
|
||||
// we can get multiple receive reports when we receive the report from a CE
|
||||
WebRtc_Word32 RTCPReceiver::StatisticsReceived(
|
||||
std::vector<RTCPReportBlock>* receiveBlocks) const {
|
||||
if (receiveBlocks == NULL) {
|
||||
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s invalid argument",
|
||||
__FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
assert(receiveBlocks);
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
|
||||
MapItem* ptrReportBlockInfoItem = _receivedReportBlockMap.First();
|
||||
while (ptrReportBlockInfoItem != NULL) {
|
||||
RTCPReportBlockInformation* item =
|
||||
static_cast<RTCPReportBlockInformation*> (
|
||||
ptrReportBlockInfoItem->GetItem());
|
||||
receiveBlocks->push_back(item->remoteReceiveBlock);
|
||||
ptrReportBlockInfoItem =
|
||||
_receivedReportBlockMap.Next(ptrReportBlockInfoItem);
|
||||
std::map<WebRtc_UWord32, RTCPReportBlockInformation*>::const_iterator it =
|
||||
_receivedReportBlockMap.begin();
|
||||
|
||||
while (it != _receivedReportBlockMap.end()) {
|
||||
receiveBlocks->push_back(it->second->remoteReceiveBlock);
|
||||
it++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -566,190 +524,174 @@ RTCPReceiver::HandleReportBlock(const RTCPUtility::RTCPPacket& rtcpPacket,
|
||||
}
|
||||
|
||||
RTCPReportBlockInformation*
|
||||
RTCPReceiver::CreateReportBlockInformation(WebRtc_UWord32 remoteSSRC)
|
||||
{
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
RTCPReceiver::CreateReportBlockInformation(WebRtc_UWord32 remoteSSRC) {
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
|
||||
RTCPReportBlockInformation* ptrReportBlockInfo = NULL;
|
||||
MapItem* ptrReportBlockInfoItem = _receivedReportBlockMap.Find(remoteSSRC);
|
||||
if (ptrReportBlockInfoItem == NULL)
|
||||
{
|
||||
ptrReportBlockInfo = new RTCPReportBlockInformation;
|
||||
_receivedReportBlockMap.Insert(remoteSSRC, ptrReportBlockInfo);
|
||||
} else
|
||||
{
|
||||
ptrReportBlockInfo = static_cast<RTCPReportBlockInformation*>(ptrReportBlockInfoItem->GetItem());
|
||||
}
|
||||
return ptrReportBlockInfo;
|
||||
std::map<WebRtc_UWord32, RTCPReportBlockInformation*>::iterator it =
|
||||
_receivedReportBlockMap.find(remoteSSRC);
|
||||
|
||||
RTCPReportBlockInformation* ptrReportBlockInfo = NULL;
|
||||
if (it != _receivedReportBlockMap.end()) {
|
||||
ptrReportBlockInfo = it->second;
|
||||
} else {
|
||||
ptrReportBlockInfo = new RTCPReportBlockInformation;
|
||||
_receivedReportBlockMap[remoteSSRC] = ptrReportBlockInfo;
|
||||
}
|
||||
return ptrReportBlockInfo;
|
||||
}
|
||||
|
||||
RTCPReportBlockInformation*
|
||||
RTCPReceiver::GetReportBlockInformation(WebRtc_UWord32 remoteSSRC) const
|
||||
{
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
RTCPReceiver::GetReportBlockInformation(WebRtc_UWord32 remoteSSRC) const {
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
|
||||
MapItem* ptrReportBlockInfoItem = _receivedReportBlockMap.Find(remoteSSRC);
|
||||
if (ptrReportBlockInfoItem == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return static_cast<RTCPReportBlockInformation*>(ptrReportBlockInfoItem->GetItem());
|
||||
std::map<WebRtc_UWord32, RTCPReportBlockInformation*>::const_iterator it =
|
||||
_receivedReportBlockMap.find(remoteSSRC);
|
||||
|
||||
if (it == _receivedReportBlockMap.end()) {
|
||||
return NULL;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
RTCPCnameInformation*
|
||||
RTCPReceiver::CreateCnameInformation(WebRtc_UWord32 remoteSSRC)
|
||||
{
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
RTCPReceiver::CreateCnameInformation(WebRtc_UWord32 remoteSSRC) {
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
|
||||
RTCPCnameInformation* ptrCnameInfo = NULL;
|
||||
MapItem* ptrCnameInfoItem = _receivedCnameMap.Find(remoteSSRC);
|
||||
if (ptrCnameInfoItem == NULL)
|
||||
{
|
||||
ptrCnameInfo = new RTCPCnameInformation;
|
||||
_receivedCnameMap.Insert(remoteSSRC, ptrCnameInfo);
|
||||
} else
|
||||
{
|
||||
ptrCnameInfo = static_cast<RTCPCnameInformation*>(ptrCnameInfoItem->GetItem());
|
||||
}
|
||||
return ptrCnameInfo;
|
||||
std::map<WebRtc_UWord32, RTCPCnameInformation*>::iterator it =
|
||||
_receivedCnameMap.find(remoteSSRC);
|
||||
|
||||
if (it != _receivedCnameMap.end()) {
|
||||
return it->second;
|
||||
}
|
||||
RTCPCnameInformation* cnameInfo = new RTCPCnameInformation;
|
||||
_receivedCnameMap[remoteSSRC] = cnameInfo;
|
||||
return cnameInfo;
|
||||
}
|
||||
|
||||
RTCPCnameInformation*
|
||||
RTCPReceiver::GetCnameInformation(WebRtc_UWord32 remoteSSRC) const
|
||||
{
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
RTCPReceiver::GetCnameInformation(WebRtc_UWord32 remoteSSRC) const {
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
|
||||
MapItem* ptrCnameInfoItem = _receivedCnameMap.Find(remoteSSRC);
|
||||
if (ptrCnameInfoItem == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return static_cast<RTCPCnameInformation*>(ptrCnameInfoItem->GetItem());
|
||||
std::map<WebRtc_UWord32, RTCPCnameInformation*>::const_iterator it =
|
||||
_receivedCnameMap.find(remoteSSRC);
|
||||
|
||||
if (it == _receivedCnameMap.end()) {
|
||||
return NULL;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
RTCPReceiveInformation*
|
||||
RTCPReceiver::CreateReceiveInformation(WebRtc_UWord32 remoteSSRC)
|
||||
{
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
RTCPReceiver::CreateReceiveInformation(WebRtc_UWord32 remoteSSRC) {
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
|
||||
RTCPReceiveInformation* ptrReceiveInfo = NULL;
|
||||
MapItem* ptrReceiveInfoItem = _receivedInfoMap.Find(remoteSSRC);
|
||||
if (ptrReceiveInfoItem == NULL)
|
||||
{
|
||||
ptrReceiveInfo = new RTCPReceiveInformation;
|
||||
_receivedInfoMap.Insert(remoteSSRC, ptrReceiveInfo);
|
||||
} else
|
||||
{
|
||||
ptrReceiveInfo = static_cast<RTCPReceiveInformation*>(ptrReceiveInfoItem->GetItem());
|
||||
}
|
||||
return ptrReceiveInfo;
|
||||
std::map<WebRtc_UWord32, RTCPReceiveInformation*>::iterator it =
|
||||
_receivedInfoMap.find(remoteSSRC);
|
||||
|
||||
if (it != _receivedInfoMap.end()) {
|
||||
return it->second;
|
||||
}
|
||||
RTCPReceiveInformation* receiveInfo = new RTCPReceiveInformation;
|
||||
_receivedInfoMap[remoteSSRC] = receiveInfo;
|
||||
return receiveInfo;
|
||||
}
|
||||
|
||||
RTCPReceiveInformation*
|
||||
RTCPReceiver::GetReceiveInformation(WebRtc_UWord32 remoteSSRC)
|
||||
{
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
RTCPReceiver::GetReceiveInformation(WebRtc_UWord32 remoteSSRC) {
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
|
||||
MapItem* ptrReceiveInfoItem = _receivedInfoMap.Find(remoteSSRC);
|
||||
if (ptrReceiveInfoItem == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return static_cast<RTCPReceiveInformation*>(ptrReceiveInfoItem->GetItem());
|
||||
std::map<WebRtc_UWord32, RTCPReceiveInformation*>::iterator it =
|
||||
_receivedInfoMap.find(remoteSSRC);
|
||||
if (it == _receivedInfoMap.end()) {
|
||||
return NULL;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
void
|
||||
RTCPReceiver::UpdateReceiveInformation( RTCPReceiveInformation& receiveInformation)
|
||||
{
|
||||
// Update that this remote is alive
|
||||
receiveInformation.lastTimeReceived = _clock.GetTimeInMS();
|
||||
void RTCPReceiver::UpdateReceiveInformation(
|
||||
RTCPReceiveInformation& receiveInformation) {
|
||||
// Update that this remote is alive
|
||||
receiveInformation.lastTimeReceived = _clock.GetTimeInMS();
|
||||
}
|
||||
|
||||
bool
|
||||
RTCPReceiver::UpdateRTCPReceiveInformationTimers()
|
||||
{
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
bool RTCPReceiver::UpdateRTCPReceiveInformationTimers() {
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
|
||||
bool updateBoundingSet = false;
|
||||
WebRtc_UWord32 timeNow = _clock.GetTimeInMS();
|
||||
MapItem* receiveInfoItem=_receivedInfoMap.First();
|
||||
bool updateBoundingSet = false;
|
||||
WebRtc_UWord32 timeNow = _clock.GetTimeInMS();
|
||||
|
||||
while(receiveInfoItem)
|
||||
{
|
||||
RTCPReceiveInformation* receiveInfo = (RTCPReceiveInformation*)receiveInfoItem->GetItem();
|
||||
if(receiveInfo == NULL)
|
||||
{
|
||||
return updateBoundingSet;
|
||||
}
|
||||
// time since last received rtcp packet
|
||||
// when we dont have a lastTimeReceived and the object is marked readyForDelete
|
||||
// it's removed from the map
|
||||
if( receiveInfo->lastTimeReceived)
|
||||
{
|
||||
if((timeNow - receiveInfo->lastTimeReceived) > 5*RTCP_INTERVAL_AUDIO_MS) // use audio define since we don't know what interval the remote peer is using
|
||||
{
|
||||
// no rtcp packet for the last five regular intervals, reset limitations
|
||||
receiveInfo->TmmbrSet.lengthOfSet = 0;
|
||||
receiveInfo->lastTimeReceived = 0; // prevent that we call this over and over again
|
||||
updateBoundingSet = true; // send new TMMBN to all channels using the default codec
|
||||
}
|
||||
receiveInfoItem = _receivedInfoMap.Next(receiveInfoItem);
|
||||
}else
|
||||
{
|
||||
if(receiveInfo->readyForDelete)
|
||||
{
|
||||
// store our current receiveInfoItem
|
||||
MapItem* receiveInfoItemToBeErased = receiveInfoItem;
|
||||
|
||||
// iterate
|
||||
receiveInfoItem = _receivedInfoMap.Next(receiveInfoItem);
|
||||
|
||||
// delete current
|
||||
delete receiveInfo;
|
||||
_receivedInfoMap.Erase(receiveInfoItemToBeErased);
|
||||
}else
|
||||
{
|
||||
receiveInfoItem = _receivedInfoMap.Next(receiveInfoItem);
|
||||
}
|
||||
}
|
||||
std::map<WebRtc_UWord32, RTCPReceiveInformation*>::iterator receiveInfoIt =
|
||||
_receivedInfoMap.begin();
|
||||
|
||||
while (receiveInfoIt != _receivedInfoMap.end()) {
|
||||
RTCPReceiveInformation* receiveInfo = receiveInfoIt->second;
|
||||
if (receiveInfo == NULL) {
|
||||
return updateBoundingSet;
|
||||
}
|
||||
return updateBoundingSet;
|
||||
// time since last received rtcp packet
|
||||
// when we dont have a lastTimeReceived and the object is marked
|
||||
// readyForDelete it's removed from the map
|
||||
if (receiveInfo->lastTimeReceived) {
|
||||
/// use audio define since we don't know what interval the remote peer is
|
||||
// using
|
||||
if ((timeNow - receiveInfo->lastTimeReceived) >
|
||||
5 * RTCP_INTERVAL_AUDIO_MS) {
|
||||
// no rtcp packet for the last five regular intervals, reset limitations
|
||||
receiveInfo->TmmbrSet.lengthOfSet = 0;
|
||||
// prevent that we call this over and over again
|
||||
receiveInfo->lastTimeReceived = 0;
|
||||
// send new TMMBN to all channels using the default codec
|
||||
updateBoundingSet = true;
|
||||
}
|
||||
receiveInfoIt++;
|
||||
} else if (receiveInfo->readyForDelete) {
|
||||
// store our current receiveInfoItem
|
||||
std::map<WebRtc_UWord32, RTCPReceiveInformation*>::iterator
|
||||
receiveInfoItemToBeErased = receiveInfoIt;
|
||||
receiveInfoIt++;
|
||||
delete receiveInfoItemToBeErased->second;
|
||||
_receivedInfoMap.erase(receiveInfoItemToBeErased);
|
||||
} else {
|
||||
receiveInfoIt++;
|
||||
}
|
||||
}
|
||||
return updateBoundingSet;
|
||||
}
|
||||
|
||||
WebRtc_Word32
|
||||
RTCPReceiver::BoundingSet(bool &tmmbrOwner, TMMBRSet*& boundingSetRec)
|
||||
{
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
WebRtc_Word32 RTCPReceiver::BoundingSet(bool &tmmbrOwner,
|
||||
TMMBRSet*& boundingSetRec) {
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
|
||||
MapItem* receiveInfoItem=_receivedInfoMap.Find(_remoteSSRC);
|
||||
if(receiveInfoItem )
|
||||
{
|
||||
RTCPReceiveInformation* receiveInfo = (RTCPReceiveInformation*)receiveInfoItem->GetItem();
|
||||
if(receiveInfo == NULL)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s failed to get RTCPReceiveInformation", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
if(receiveInfo->TmmbnBoundingSet.lengthOfSet > 0)
|
||||
{
|
||||
boundingSetRec->VerifyAndAllocateSet(receiveInfo->TmmbnBoundingSet.lengthOfSet + 1);
|
||||
for(WebRtc_UWord32 i=0; i< receiveInfo->TmmbnBoundingSet.lengthOfSet; i++)
|
||||
{
|
||||
if(receiveInfo->TmmbnBoundingSet.ptrSsrcSet[i] == _SSRC)
|
||||
{
|
||||
// owner of bounding set
|
||||
tmmbrOwner = true;
|
||||
}
|
||||
boundingSetRec->ptrTmmbrSet[i] = receiveInfo->TmmbnBoundingSet.ptrTmmbrSet[i];
|
||||
boundingSetRec->ptrPacketOHSet[i] = receiveInfo->TmmbnBoundingSet.ptrPacketOHSet[i];
|
||||
boundingSetRec->ptrSsrcSet[i] = receiveInfo->TmmbnBoundingSet.ptrSsrcSet[i];
|
||||
}
|
||||
return receiveInfo->TmmbnBoundingSet.lengthOfSet;
|
||||
}
|
||||
}
|
||||
std::map<WebRtc_UWord32, RTCPReceiveInformation*>::iterator receiveInfoIt =
|
||||
_receivedInfoMap.find(_remoteSSRC);
|
||||
|
||||
if (receiveInfoIt == _receivedInfoMap.end()) {
|
||||
return -1;
|
||||
}
|
||||
RTCPReceiveInformation* receiveInfo = receiveInfoIt->second;
|
||||
if (receiveInfo == NULL) {
|
||||
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
|
||||
"%s failed to get RTCPReceiveInformation",
|
||||
__FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
if (receiveInfo->TmmbnBoundingSet.lengthOfSet > 0) {
|
||||
boundingSetRec->VerifyAndAllocateSet(
|
||||
receiveInfo->TmmbnBoundingSet.lengthOfSet + 1);
|
||||
for(WebRtc_UWord32 i=0; i< receiveInfo->TmmbnBoundingSet.lengthOfSet; i++) {
|
||||
if(receiveInfo->TmmbnBoundingSet.ptrSsrcSet[i] == _SSRC) {
|
||||
// owner of bounding set
|
||||
tmmbrOwner = true;
|
||||
}
|
||||
boundingSetRec->ptrTmmbrSet[i] =
|
||||
receiveInfo->TmmbnBoundingSet.ptrTmmbrSet[i];
|
||||
boundingSetRec->ptrPacketOHSet[i] =
|
||||
receiveInfo->TmmbnBoundingSet.ptrPacketOHSet[i];
|
||||
boundingSetRec->ptrSsrcSet[i] =
|
||||
receiveInfo->TmmbnBoundingSet.ptrSsrcSet[i];
|
||||
}
|
||||
}
|
||||
return receiveInfo->TmmbnBoundingSet.lengthOfSet;
|
||||
}
|
||||
|
||||
// no need for critsect we have _criticalSectionRTCPReceiver
|
||||
@ -833,34 +775,35 @@ RTCPReceiver::HandleNACKItem(const RTCPUtility::RTCPPacket& rtcpPacket,
|
||||
}
|
||||
|
||||
// no need for critsect we have _criticalSectionRTCPReceiver
|
||||
void
|
||||
RTCPReceiver::HandleBYE(RTCPUtility::RTCPParserV2& rtcpParser)
|
||||
{
|
||||
const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
|
||||
void RTCPReceiver::HandleBYE(RTCPUtility::RTCPParserV2& rtcpParser) {
|
||||
const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
|
||||
|
||||
// clear our lists
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
// clear our lists
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
std::map<WebRtc_UWord32, RTCPReportBlockInformation*>::iterator
|
||||
reportBlockInfoIt = _receivedReportBlockMap.find(
|
||||
rtcpPacket.BYE.SenderSSRC);
|
||||
|
||||
MapItem* ptrReportBlockInfoItem = _receivedReportBlockMap.Find(rtcpPacket.BYE.SenderSSRC);
|
||||
if (ptrReportBlockInfoItem != NULL)
|
||||
{
|
||||
delete static_cast<RTCPReportBlockInformation*>(ptrReportBlockInfoItem->GetItem());
|
||||
_receivedReportBlockMap.Erase(ptrReportBlockInfoItem);
|
||||
}
|
||||
// we can't delete it due to TMMBR
|
||||
MapItem* ptrReceiveInfoItem = _receivedInfoMap.Find(rtcpPacket.BYE.SenderSSRC);
|
||||
if (ptrReceiveInfoItem != NULL)
|
||||
{
|
||||
static_cast<RTCPReceiveInformation*>(ptrReceiveInfoItem->GetItem())->readyForDelete = true;
|
||||
}
|
||||
if (reportBlockInfoIt != _receivedReportBlockMap.end()) {
|
||||
delete reportBlockInfoIt->second;
|
||||
_receivedReportBlockMap.erase(reportBlockInfoIt);
|
||||
}
|
||||
// we can't delete it due to TMMBR
|
||||
std::map<WebRtc_UWord32, RTCPReceiveInformation*>::iterator receiveInfoIt =
|
||||
_receivedInfoMap.find(rtcpPacket.BYE.SenderSSRC);
|
||||
|
||||
MapItem* ptrCnameInfoItem = _receivedCnameMap.Find(rtcpPacket.BYE.SenderSSRC);
|
||||
if (ptrCnameInfoItem != NULL)
|
||||
{
|
||||
delete static_cast<RTCPCnameInformation*>(ptrCnameInfoItem->GetItem());
|
||||
_receivedCnameMap.Erase(ptrCnameInfoItem);
|
||||
}
|
||||
rtcpParser.Iterate();
|
||||
if (receiveInfoIt != _receivedInfoMap.end()) {
|
||||
receiveInfoIt->second->readyForDelete = true;
|
||||
}
|
||||
|
||||
std::map<WebRtc_UWord32, RTCPCnameInformation*>::iterator cnameInfoIt =
|
||||
_receivedCnameMap.find(rtcpPacket.BYE.SenderSSRC);
|
||||
|
||||
if (cnameInfoIt != _receivedCnameMap.end()) {
|
||||
delete cnameInfoIt->second;
|
||||
_receivedCnameMap.erase(cnameInfoIt);
|
||||
}
|
||||
rtcpParser.Iterate();
|
||||
}
|
||||
|
||||
// no need for critsect we have _criticalSectionRTCPReceiver
|
||||
@ -1464,54 +1407,46 @@ RTCPReceiver::CNAME(const WebRtc_UWord32 remoteSSRC,
|
||||
}
|
||||
|
||||
// no callbacks allowed inside this function
|
||||
WebRtc_Word32
|
||||
RTCPReceiver::TMMBRReceived(const WebRtc_UWord32 size,
|
||||
const WebRtc_UWord32 accNumCandidates,
|
||||
TMMBRSet* candidateSet) const
|
||||
{
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
WebRtc_Word32 RTCPReceiver::TMMBRReceived(const WebRtc_UWord32 size,
|
||||
const WebRtc_UWord32 accNumCandidates,
|
||||
TMMBRSet* candidateSet) const {
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
|
||||
|
||||
MapItem* receiveInfoItem=_receivedInfoMap.First();
|
||||
if(receiveInfoItem == NULL)
|
||||
{
|
||||
std::map<WebRtc_UWord32, RTCPReceiveInformation*>::const_iterator
|
||||
receiveInfoIt = _receivedInfoMap.begin();
|
||||
if (receiveInfoIt == _receivedInfoMap.end()) {
|
||||
return -1;
|
||||
}
|
||||
WebRtc_UWord32 num = accNumCandidates;
|
||||
if (candidateSet) {
|
||||
while( num < size && receiveInfoIt != _receivedInfoMap.end()) {
|
||||
RTCPReceiveInformation* receiveInfo = receiveInfoIt->second;
|
||||
if (receiveInfo == NULL) {
|
||||
return 0;
|
||||
}
|
||||
for (WebRtc_UWord32 i = 0;
|
||||
(num < size) && (i < receiveInfo->TmmbrSet.lengthOfSet); i++) {
|
||||
if (receiveInfo->GetTMMBRSet(i, num, candidateSet,
|
||||
_clock.GetTimeInMS()) == 0) {
|
||||
num++;
|
||||
}
|
||||
}
|
||||
receiveInfoIt++;
|
||||
}
|
||||
} else {
|
||||
while (receiveInfoIt != _receivedInfoMap.end()) {
|
||||
RTCPReceiveInformation* receiveInfo = receiveInfoIt->second;
|
||||
if(receiveInfo == NULL) {
|
||||
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
|
||||
"%s failed to get RTCPReceiveInformation",
|
||||
__FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
num += receiveInfo->TmmbrSet.lengthOfSet;
|
||||
receiveInfoIt++;
|
||||
}
|
||||
WebRtc_UWord32 num = accNumCandidates;
|
||||
if(candidateSet)
|
||||
{
|
||||
while( num < size && receiveInfoItem)
|
||||
{
|
||||
RTCPReceiveInformation* receiveInfo = (RTCPReceiveInformation*)receiveInfoItem->GetItem();
|
||||
if(receiveInfo == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
for (WebRtc_UWord32 i = 0; (num < size) && (i < receiveInfo->TmmbrSet.lengthOfSet); i++)
|
||||
{
|
||||
if(receiveInfo->GetTMMBRSet(i, num, candidateSet,
|
||||
_clock.GetTimeInMS()) == 0)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
}
|
||||
receiveInfoItem = _receivedInfoMap.Next(receiveInfoItem);
|
||||
}
|
||||
} else
|
||||
{
|
||||
while(receiveInfoItem)
|
||||
{
|
||||
RTCPReceiveInformation* receiveInfo = (RTCPReceiveInformation*)receiveInfoItem->GetItem();
|
||||
if(receiveInfo == NULL)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s failed to get RTCPReceiveInformation", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
num += receiveInfo->TmmbrSet.lengthOfSet;
|
||||
|
||||
receiveInfoItem = _receivedInfoMap.Next(receiveInfoItem);
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
WebRtc_Word32
|
||||
|
@ -11,10 +11,10 @@
|
||||
#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_H_
|
||||
#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_H_
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "typedefs.h"
|
||||
#include "map_wrapper.h"
|
||||
#include "rtp_utility.h"
|
||||
#include "rtcp_utility.h"
|
||||
#include "rtp_rtcp_defines.h"
|
||||
@ -189,33 +189,36 @@ protected:
|
||||
void HandleAPPItem(RTCPUtility::RTCPParserV2& rtcpParser,
|
||||
RTCPHelp::RTCPPacketInformation& rtcpPacketInformation);
|
||||
|
||||
private:
|
||||
WebRtc_Word32 _id;
|
||||
RtpRtcpClock& _clock;
|
||||
RTCPMethod _method;
|
||||
WebRtc_UWord32 _lastReceived;
|
||||
ModuleRtpRtcpImpl& _rtpRtcp;
|
||||
private:
|
||||
WebRtc_Word32 _id;
|
||||
RtpRtcpClock& _clock;
|
||||
RTCPMethod _method;
|
||||
WebRtc_UWord32 _lastReceived;
|
||||
ModuleRtpRtcpImpl& _rtpRtcp;
|
||||
|
||||
CriticalSectionWrapper* _criticalSectionFeedbacks;
|
||||
RtcpFeedback* _cbRtcpFeedback;
|
||||
RtpVideoFeedback* _cbVideoFeedback;
|
||||
CriticalSectionWrapper* _criticalSectionFeedbacks;
|
||||
RtcpFeedback* _cbRtcpFeedback;
|
||||
RtpVideoFeedback* _cbVideoFeedback;
|
||||
|
||||
CriticalSectionWrapper* _criticalSectionRTCPReceiver;
|
||||
WebRtc_UWord32 _SSRC;
|
||||
WebRtc_UWord32 _remoteSSRC;
|
||||
CriticalSectionWrapper* _criticalSectionRTCPReceiver;
|
||||
WebRtc_UWord32 _SSRC;
|
||||
WebRtc_UWord32 _remoteSSRC;
|
||||
|
||||
// Received send report
|
||||
RTCPSenderInfo _remoteSenderInfo;
|
||||
WebRtc_UWord32 _lastReceivedSRNTPsecs; // when did we receive the last send report
|
||||
WebRtc_UWord32 _lastReceivedSRNTPfrac;
|
||||
// Received send report
|
||||
RTCPSenderInfo _remoteSenderInfo;
|
||||
// when did we receive the last send report
|
||||
WebRtc_UWord32 _lastReceivedSRNTPsecs;
|
||||
WebRtc_UWord32 _lastReceivedSRNTPfrac;
|
||||
|
||||
// Received report block
|
||||
MapWrapper _receivedReportBlockMap; // pair SSRC to report block
|
||||
MapWrapper _receivedInfoMap; // pair SSRC of sender to might not be a SSRC that have any data (i.e. a conference)
|
||||
MapWrapper _receivedCnameMap; // pair SSRC to Cname
|
||||
// Received report blocks.
|
||||
std::map<WebRtc_UWord32, RTCPHelp::RTCPReportBlockInformation*>
|
||||
_receivedReportBlockMap;
|
||||
std::map<WebRtc_UWord32, RTCPHelp::RTCPReceiveInformation*>
|
||||
_receivedInfoMap;
|
||||
std::map<WebRtc_UWord32, RTCPUtility::RTCPCnameInformation*>
|
||||
_receivedCnameMap;
|
||||
|
||||
// timeout
|
||||
WebRtc_UWord32 _packetTimeOutMS;
|
||||
WebRtc_UWord32 _packetTimeOutMS;
|
||||
};
|
||||
} // namespace webrtc
|
||||
#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_H_
|
||||
|
@ -9,7 +9,6 @@
|
||||
*/
|
||||
|
||||
#include "rtcp_sender.h"
|
||||
#include "rtcp_utility.h"
|
||||
|
||||
#include <string.h> // memcpy
|
||||
#include <cassert> // assert
|
||||
@ -22,6 +21,9 @@
|
||||
#include "rtp_rtcp_impl.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
using RTCPUtility::RTCPCnameInformation;
|
||||
|
||||
RTCPSender::RTCPSender(const WebRtc_Word32 id,
|
||||
const bool audio,
|
||||
RtpRtcpClock* clock,
|
||||
@ -87,37 +89,26 @@ RTCPSender::RTCPSender(const WebRtc_Word32 id,
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, id, "%s created", __FUNCTION__);
|
||||
}
|
||||
|
||||
RTCPSender::~RTCPSender()
|
||||
{
|
||||
delete [] _rembSSRC;
|
||||
delete [] _appData;
|
||||
RTCPSender::~RTCPSender() {
|
||||
delete [] _rembSSRC;
|
||||
delete [] _appData;
|
||||
|
||||
MapItem* item = _reportBlocks.First();
|
||||
while(item)
|
||||
{
|
||||
RTCPReportBlock* ptr = (RTCPReportBlock*)(item->GetItem());
|
||||
if(ptr)
|
||||
{
|
||||
delete ptr;
|
||||
}
|
||||
_reportBlocks.Erase(item);
|
||||
item = _reportBlocks.First();
|
||||
}
|
||||
item = _csrcCNAMEs.First();
|
||||
while(item)
|
||||
{
|
||||
RTCPUtility::RTCPCnameInformation* ptr = (RTCPUtility::RTCPCnameInformation*)(item->GetItem());
|
||||
if(ptr)
|
||||
{
|
||||
delete ptr;
|
||||
}
|
||||
_csrcCNAMEs.Erase(item);
|
||||
item = _csrcCNAMEs.First();
|
||||
}
|
||||
delete _criticalSectionTransport;
|
||||
delete _criticalSectionRTCPSender;
|
||||
while (!_reportBlocks.empty()) {
|
||||
std::map<WebRtc_UWord32, RTCPReportBlock*>::iterator it =
|
||||
_reportBlocks.begin();
|
||||
delete it->second;
|
||||
_reportBlocks.erase(it);
|
||||
}
|
||||
while (!_csrcCNAMEs.empty()) {
|
||||
std::map<WebRtc_UWord32, RTCPCnameInformation*>::iterator it =
|
||||
_csrcCNAMEs.begin();
|
||||
delete it->second;
|
||||
_csrcCNAMEs.erase(it);
|
||||
}
|
||||
delete _criticalSectionTransport;
|
||||
delete _criticalSectionRTCPSender;
|
||||
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, _id, "%s deleted", __FUNCTION__);
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, _id, "%s deleted", __FUNCTION__);
|
||||
}
|
||||
|
||||
WebRtc_Word32
|
||||
@ -367,71 +358,50 @@ RTCPSender::CNAME(WebRtc_Word8 cName[RTCP_CNAME_SIZE])
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32
|
||||
RTCPSender::SetCNAME(const WebRtc_Word8 cName[RTCP_CNAME_SIZE])
|
||||
{
|
||||
if(cName == NULL)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s invalid argument", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
WebRtc_Word32 length = (WebRtc_Word32)strlen(cName);
|
||||
if(length > RTCP_CNAME_SIZE)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s invalid argument, too long cName", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPSender);
|
||||
|
||||
memcpy(_CNAME, cName, length+1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32
|
||||
RTCPSender::AddMixedCNAME(const WebRtc_UWord32 SSRC,
|
||||
const WebRtc_Word8 cName[RTCP_CNAME_SIZE])
|
||||
{
|
||||
if(cName == NULL)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s invalid argument", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
WebRtc_Word32 length = (WebRtc_Word32)strlen(cName);
|
||||
if(length > RTCP_CNAME_SIZE)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s invalid argument, too long cName", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPSender);
|
||||
if(_csrcCNAMEs.Size() == kRtpCsrcSize)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
RTCPUtility::RTCPCnameInformation* ptr= new RTCPUtility::RTCPCnameInformation();
|
||||
|
||||
memcpy(ptr->name, cName, length+1);
|
||||
ptr->length = (WebRtc_UWord8)length;
|
||||
_csrcCNAMEs.Insert(SSRC, ptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32
|
||||
RTCPSender::RemoveMixedCNAME(const WebRtc_UWord32 SSRC)
|
||||
{
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPSender);
|
||||
MapItem* item= _csrcCNAMEs.Find(SSRC);
|
||||
if(item)
|
||||
{
|
||||
RTCPUtility::RTCPCnameInformation* ptr= (RTCPUtility::RTCPCnameInformation*)(item->GetItem());
|
||||
if(ptr)
|
||||
{
|
||||
delete ptr;
|
||||
}
|
||||
_csrcCNAMEs.Erase(item);
|
||||
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;
|
||||
}
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPSender);
|
||||
memcpy(_CNAME, cName, length + 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;
|
||||
}
|
||||
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);
|
||||
_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);
|
||||
|
||||
if (it == _csrcCNAMEs.end()) {
|
||||
return -1;
|
||||
}
|
||||
delete it->second;
|
||||
_csrcCNAMEs.erase(it);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -553,46 +523,38 @@ RTCPSender::SendTimeOfSendReport(const WebRtc_UWord32 sendReport)
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32
|
||||
RTCPSender::AddReportBlock(const WebRtc_UWord32 SSRC,
|
||||
const RTCPReportBlock* reportBlock)
|
||||
{
|
||||
if(reportBlock == NULL)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s invalid argument", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
WebRtc_Word32 RTCPSender::AddReportBlock(const WebRtc_UWord32 SSRC,
|
||||
const RTCPReportBlock* reportBlock) {
|
||||
if (reportBlock == NULL) {
|
||||
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
|
||||
"%s invalid argument", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPSender);
|
||||
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPSender);
|
||||
|
||||
if(_reportBlocks.Size() >= RTCP_MAX_REPORT_BLOCKS)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s invalid argument", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
RTCPReportBlock* copyReportBlock = new RTCPReportBlock();
|
||||
memcpy(copyReportBlock, reportBlock, sizeof(RTCPReportBlock));
|
||||
_reportBlocks.Insert(SSRC, copyReportBlock);
|
||||
return 0;
|
||||
if (_reportBlocks.size() >= RTCP_MAX_REPORT_BLOCKS) {
|
||||
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
|
||||
"%s invalid argument", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
RTCPReportBlock* copyReportBlock = new RTCPReportBlock();
|
||||
memcpy(copyReportBlock, reportBlock, sizeof(RTCPReportBlock));
|
||||
_reportBlocks[SSRC] = copyReportBlock;
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32
|
||||
RTCPSender::RemoveReportBlock(const WebRtc_UWord32 SSRC)
|
||||
{
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPSender);
|
||||
WebRtc_Word32 RTCPSender::RemoveReportBlock(const WebRtc_UWord32 SSRC) {
|
||||
CriticalSectionScoped lock(_criticalSectionRTCPSender);
|
||||
|
||||
MapItem* item= _reportBlocks.Find(SSRC);
|
||||
if(item)
|
||||
{
|
||||
RTCPReportBlock* ptr= (RTCPReportBlock*)(item->GetItem());
|
||||
if(ptr)
|
||||
{
|
||||
delete ptr;
|
||||
}
|
||||
_reportBlocks.Erase(item);
|
||||
return 0;
|
||||
}
|
||||
std::map<WebRtc_UWord32, RTCPReportBlock*>::iterator it =
|
||||
_reportBlocks.find(SSRC);
|
||||
|
||||
if (it == _reportBlocks.end()) {
|
||||
return -1;
|
||||
}
|
||||
delete it->second;
|
||||
_reportBlocks.erase(it);
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32
|
||||
@ -721,108 +683,95 @@ RTCPSender::BuildSR(WebRtc_UWord8* rtcpbuffer,
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word32
|
||||
RTCPSender::BuildSDEC(WebRtc_UWord8* rtcpbuffer, WebRtc_UWord32& pos)
|
||||
{
|
||||
WebRtc_UWord32 lengthCname =(WebRtc_UWord32)strlen((char*)_CNAME);
|
||||
WebRtc_Word32 RTCPSender::BuildSDEC(WebRtc_UWord8* rtcpbuffer,
|
||||
WebRtc_UWord32& pos) {
|
||||
size_t lengthCname = strlen(_CNAME);
|
||||
assert(lengthCname < RTCP_CNAME_SIZE);
|
||||
|
||||
// sanity max is 255
|
||||
if(lengthCname > RTCP_CNAME_SIZE)
|
||||
{
|
||||
lengthCname = RTCP_CNAME_SIZE;
|
||||
}
|
||||
// sanity
|
||||
if(pos + 12+ lengthCname >= IP_PACKET_SIZE)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s invalid argument", __FUNCTION__);
|
||||
return -2;
|
||||
}
|
||||
// SDEC Source Description
|
||||
// sanity
|
||||
if(pos + 12 + lengthCname >= IP_PACKET_SIZE) {
|
||||
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
|
||||
"%s invalid argument", __FUNCTION__);
|
||||
return -2;
|
||||
}
|
||||
// SDEC Source Description
|
||||
|
||||
// We always need to add SDES CNAME
|
||||
rtcpbuffer[pos++]=(WebRtc_UWord8)0x80 + 1 + _csrcCNAMEs.Size(); // source counts
|
||||
rtcpbuffer[pos++]=(WebRtc_UWord8)202;
|
||||
// We always need to add SDES CNAME
|
||||
rtcpbuffer[pos++] = static_cast<WebRtc_UWord8>(0x80 + 1 + _csrcCNAMEs.size());
|
||||
rtcpbuffer[pos++] = static_cast<WebRtc_UWord8>(202);
|
||||
|
||||
// handle SDES length later on
|
||||
WebRtc_UWord32 SDESLengthPos = pos;
|
||||
pos++;
|
||||
pos++;
|
||||
// handle SDES length later on
|
||||
WebRtc_UWord32 SDESLengthPos = pos;
|
||||
pos++;
|
||||
pos++;
|
||||
|
||||
// Add our own SSRC
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos, _SSRC);
|
||||
// Add our own SSRC
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos, _SSRC);
|
||||
pos += 4;
|
||||
|
||||
// CNAME = 1
|
||||
rtcpbuffer[pos++] = static_cast<WebRtc_UWord8>(1);
|
||||
|
||||
//
|
||||
rtcpbuffer[pos++] = static_cast<WebRtc_UWord8>(lengthCname);
|
||||
|
||||
WebRtc_UWord16 SDESLength = 10;
|
||||
|
||||
memcpy(&rtcpbuffer[pos], _CNAME, lengthCname);
|
||||
pos += lengthCname;
|
||||
SDESLength += (WebRtc_UWord16)lengthCname;
|
||||
|
||||
WebRtc_UWord16 padding = 0;
|
||||
// We must have a zero field even if we have an even multiple of 4 bytes
|
||||
if ((pos % 4) == 0) {
|
||||
padding++;
|
||||
rtcpbuffer[pos++]=0;
|
||||
}
|
||||
while ((pos % 4) != 0) {
|
||||
padding++;
|
||||
rtcpbuffer[pos++]=0;
|
||||
}
|
||||
SDESLength += padding;
|
||||
|
||||
std::map<WebRtc_UWord32, RTCPUtility::RTCPCnameInformation*>::iterator it =
|
||||
_csrcCNAMEs.begin();
|
||||
|
||||
for(; it != _csrcCNAMEs.end(); it++) {
|
||||
RTCPCnameInformation* cname = it->second;
|
||||
WebRtc_UWord32 SSRC = it->first;
|
||||
|
||||
// Add SSRC
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos, SSRC);
|
||||
pos += 4;
|
||||
|
||||
// CNAME = 1
|
||||
rtcpbuffer[pos++]=(WebRtc_UWord8)1;
|
||||
rtcpbuffer[pos++] = static_cast<WebRtc_UWord8>(1);
|
||||
|
||||
//
|
||||
rtcpbuffer[pos++]=(WebRtc_UWord8)lengthCname;
|
||||
rtcpbuffer[pos++]= cname->length;
|
||||
|
||||
WebRtc_UWord16 SDESLength = 10;
|
||||
SDESLength += 6;
|
||||
|
||||
memcpy(&rtcpbuffer[pos],_CNAME,lengthCname);
|
||||
pos += lengthCname;
|
||||
SDESLength += (WebRtc_UWord16)lengthCname;
|
||||
memcpy(&rtcpbuffer[pos], cname->name, cname->length);
|
||||
pos += cname->length;
|
||||
SDESLength += cname->length;
|
||||
|
||||
WebRtc_UWord16 padding =0;
|
||||
WebRtc_UWord16 padding = 0;
|
||||
|
||||
// We must have a zero field even if we have an even multiple of 4 bytes
|
||||
if((pos % 4) ==0)
|
||||
{
|
||||
padding++;
|
||||
rtcpbuffer[pos++]=0;
|
||||
if((pos % 4) == 0){
|
||||
padding++;
|
||||
rtcpbuffer[pos++]=0;
|
||||
}
|
||||
while((pos % 4) !=0)
|
||||
{
|
||||
padding++;
|
||||
rtcpbuffer[pos++]=0;
|
||||
while((pos % 4) != 0){
|
||||
padding++;
|
||||
rtcpbuffer[pos++] = 0;
|
||||
}
|
||||
SDESLength += padding;
|
||||
|
||||
MapItem* item = _csrcCNAMEs.First();
|
||||
|
||||
for(int i = 0; item && i < _csrcCNAMEs.Size(); i++)
|
||||
{
|
||||
RTCPUtility::RTCPCnameInformation* cname = (RTCPUtility::RTCPCnameInformation*)(item->GetItem());
|
||||
WebRtc_UWord32 SSRC = item->GetUnsignedId();
|
||||
|
||||
// Add SSRC
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos, SSRC);
|
||||
pos += 4;
|
||||
|
||||
// CNAME = 1
|
||||
rtcpbuffer[pos++]=(WebRtc_UWord8)1;
|
||||
|
||||
rtcpbuffer[pos++]= cname->length;
|
||||
|
||||
SDESLength += 6;
|
||||
|
||||
memcpy(&rtcpbuffer[pos],cname->name, cname->length);
|
||||
pos += cname->length;
|
||||
SDESLength += cname->length;
|
||||
|
||||
WebRtc_UWord16 padding =0;
|
||||
|
||||
// We must have a zero field even if we have an even multiple of 4 bytes
|
||||
if((pos % 4) ==0)
|
||||
{
|
||||
padding++;
|
||||
rtcpbuffer[pos++]=0;
|
||||
}
|
||||
while((pos % 4) !=0)
|
||||
{
|
||||
padding++;
|
||||
rtcpbuffer[pos++]=0;
|
||||
}
|
||||
SDESLength += padding;
|
||||
|
||||
item = _csrcCNAMEs.Next(item);
|
||||
}
|
||||
WebRtc_UWord16 length = SDESLength;
|
||||
length= (length/4) - 1; // in 32-bit words minus one and we dont count the header
|
||||
|
||||
ModuleRTPUtility::AssignUWord16ToBuffer(rtcpbuffer+SDESLengthPos, length);
|
||||
return 0;
|
||||
}
|
||||
// in 32-bit words minus one and we don't count the header
|
||||
WebRtc_UWord16 length = (SDESLength / 4) - 1;
|
||||
ModuleRTPUtility::AssignUWord16ToBuffer(rtcpbuffer + SDESLengthPos, length);
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word32
|
||||
@ -887,7 +836,7 @@ RTCPSender::BuildExtendedJitterReport(
|
||||
WebRtc_UWord32& pos,
|
||||
const WebRtc_UWord32 jitterTransmissionTimeOffset)
|
||||
{
|
||||
if (_reportBlocks.Size() > 0)
|
||||
if (_reportBlocks.size() > 0)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceWarning, kTraceRtpRtcp, _id, "Not implemented.");
|
||||
return 0;
|
||||
@ -2125,104 +2074,103 @@ RTCPSender::SetRTCPVoIPMetrics(const RTCPVoIPMetric* VoIPMetric)
|
||||
}
|
||||
|
||||
// called under critsect _criticalSectionRTCPSender
|
||||
WebRtc_Word32
|
||||
RTCPSender::AddReportBlocks(WebRtc_UWord8* rtcpbuffer,
|
||||
WebRtc_UWord32& pos,
|
||||
WebRtc_UWord8& numberOfReportBlocks,
|
||||
const RTCPReportBlock* received,
|
||||
const WebRtc_UWord32 NTPsec,
|
||||
const WebRtc_UWord32 NTPfrac)
|
||||
{
|
||||
// sanity one block
|
||||
if(pos + 24 >= IP_PACKET_SIZE)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s invalid argument", __FUNCTION__);
|
||||
return -1;
|
||||
WebRtc_Word32 RTCPSender::AddReportBlocks(WebRtc_UWord8* rtcpbuffer,
|
||||
WebRtc_UWord32& pos,
|
||||
WebRtc_UWord8& numberOfReportBlocks,
|
||||
const RTCPReportBlock* received,
|
||||
const WebRtc_UWord32 NTPsec,
|
||||
const WebRtc_UWord32 NTPfrac) {
|
||||
// sanity one block
|
||||
if(pos + 24 >= IP_PACKET_SIZE) {
|
||||
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
|
||||
"%s invalid argument", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
numberOfReportBlocks = _reportBlocks.size();
|
||||
if (received) {
|
||||
// add our multiple RR to numberOfReportBlocks
|
||||
numberOfReportBlocks++;
|
||||
}
|
||||
if (received) {
|
||||
// answer to the one that sends to me
|
||||
_lastRTCPTime[0] = ModuleRTPUtility::ConvertNTPTimeToMS(NTPsec, NTPfrac);
|
||||
|
||||
// Remote SSRC
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos, _remoteSSRC);
|
||||
pos += 4;
|
||||
|
||||
// fraction lost
|
||||
rtcpbuffer[pos++]=received->fractionLost;
|
||||
|
||||
// cumulative loss
|
||||
ModuleRTPUtility::AssignUWord24ToBuffer(rtcpbuffer+pos,
|
||||
received->cumulativeLost);
|
||||
pos += 3;
|
||||
// extended highest seq_no, contain the highest sequence number received
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos,
|
||||
received->extendedHighSeqNum);
|
||||
pos += 4;
|
||||
|
||||
//Jitter
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos, received->jitter);
|
||||
pos += 4;
|
||||
|
||||
// Last SR timestamp, our NTP time when we received the last report
|
||||
// This is the value that we read from the send report packet not when we
|
||||
// received it...
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos, received->lastSR);
|
||||
pos += 4;
|
||||
|
||||
// Delay since last received report,time since we received the report
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos,
|
||||
received->delaySinceLastSR);
|
||||
pos += 4;
|
||||
}
|
||||
if ((pos + _reportBlocks.size() * 24) >= IP_PACKET_SIZE) {
|
||||
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
|
||||
"%s invalid argument", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
std::map<WebRtc_UWord32, RTCPReportBlock*>::iterator it =
|
||||
_reportBlocks.begin();
|
||||
|
||||
for (; it != _reportBlocks.end(); it++) {
|
||||
// we can have multiple report block in a conference
|
||||
WebRtc_UWord32 remoteSSRC = it->first;
|
||||
RTCPReportBlock* reportBlock = it->second;
|
||||
if (reportBlock) {
|
||||
// Remote SSRC
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos, remoteSSRC);
|
||||
pos += 4;
|
||||
|
||||
// fraction lost
|
||||
rtcpbuffer[pos++] = reportBlock->fractionLost;
|
||||
|
||||
// cumulative loss
|
||||
ModuleRTPUtility::AssignUWord24ToBuffer(rtcpbuffer+pos,
|
||||
reportBlock->cumulativeLost);
|
||||
pos += 3;
|
||||
|
||||
// extended highest seq_no, contain the highest sequence number received
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos,
|
||||
reportBlock->extendedHighSeqNum);
|
||||
pos += 4;
|
||||
|
||||
//Jitter
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos,
|
||||
reportBlock->jitter);
|
||||
pos += 4;
|
||||
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos,
|
||||
reportBlock->lastSR);
|
||||
pos += 4;
|
||||
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos,
|
||||
reportBlock->delaySinceLastSR);
|
||||
pos += 4;
|
||||
}
|
||||
|
||||
numberOfReportBlocks = _reportBlocks.Size();
|
||||
if(received)
|
||||
{
|
||||
// add our multiple RR to numberOfReportBlocks
|
||||
numberOfReportBlocks++;
|
||||
}
|
||||
|
||||
if(received)
|
||||
{
|
||||
// answer to the one that sends to me
|
||||
_lastRTCPTime[0] = ModuleRTPUtility::ConvertNTPTimeToMS(NTPsec, NTPfrac);
|
||||
|
||||
// Remote SSRC
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos, _remoteSSRC);
|
||||
pos += 4;
|
||||
|
||||
// fraction lost
|
||||
rtcpbuffer[pos++]=received->fractionLost;
|
||||
|
||||
// cumulative loss
|
||||
ModuleRTPUtility::AssignUWord24ToBuffer(rtcpbuffer+pos, received->cumulativeLost);
|
||||
pos += 3;
|
||||
|
||||
// extended highest seq_no, contain the highest sequence number received
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos, received->extendedHighSeqNum);
|
||||
pos += 4;
|
||||
|
||||
//Jitter
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos, received->jitter);
|
||||
pos += 4;
|
||||
|
||||
// Last SR timestamp, our NTP time when we received the last report
|
||||
// This is the value that we read from the send report packet not when we received it...
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos, received->lastSR);
|
||||
pos += 4;
|
||||
|
||||
// Delay since last received report,time since we received the report
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos, received->delaySinceLastSR);
|
||||
pos += 4;
|
||||
}
|
||||
|
||||
if(pos + _reportBlocks.Size()*24 >= IP_PACKET_SIZE)
|
||||
{
|
||||
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id, "%s invalid argument", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
MapItem* item = _reportBlocks.First();
|
||||
for(int i = 0; i < _reportBlocks.Size() && item; i++)
|
||||
{
|
||||
// we can have multiple report block in a conference
|
||||
WebRtc_UWord32 remoteSSRC = item->GetId();
|
||||
RTCPReportBlock* reportBlock = (RTCPReportBlock*)item->GetItem();
|
||||
if(reportBlock)
|
||||
{
|
||||
// Remote SSRC
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos, remoteSSRC);
|
||||
pos += 4;
|
||||
|
||||
// fraction lost
|
||||
rtcpbuffer[pos++]=(WebRtc_UWord8)(reportBlock->fractionLost);
|
||||
|
||||
// cumulative loss
|
||||
ModuleRTPUtility::AssignUWord24ToBuffer(rtcpbuffer+pos, reportBlock->cumulativeLost);
|
||||
pos += 3;
|
||||
|
||||
// extended highest seq_no, contain the highest sequence number received
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos, reportBlock->extendedHighSeqNum);
|
||||
pos += 4;
|
||||
|
||||
//Jitter
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos, reportBlock->jitter);
|
||||
pos += 4;
|
||||
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos, reportBlock->lastSR);
|
||||
pos += 4;
|
||||
|
||||
ModuleRTPUtility::AssignUWord32ToBuffer(rtcpbuffer+pos, reportBlock->delaySinceLastSR);
|
||||
pos += 4;
|
||||
}
|
||||
item = _reportBlocks.Next(item);
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
// no callbacks allowed inside this function
|
||||
|
@ -11,9 +11,11 @@
|
||||
#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_SENDER_H_
|
||||
#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_SENDER_H_
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "typedefs.h"
|
||||
#include "rtcp_utility.h"
|
||||
#include "rtp_utility.h"
|
||||
#include "map_wrapper.h"
|
||||
#include "rtp_rtcp_defines.h"
|
||||
#include "remote_rate_control.h"
|
||||
#include "tmmbr_help.h"
|
||||
@ -213,12 +215,12 @@ private:
|
||||
|
||||
WebRtc_UWord32 _nextTimeToSendRTCP;
|
||||
|
||||
WebRtc_UWord32 _SSRC;
|
||||
WebRtc_UWord32 _remoteSSRC; // SSRC that we receive on our RTP channel
|
||||
WebRtc_UWord8 _CNAME[RTCP_CNAME_SIZE];
|
||||
WebRtc_UWord32 _SSRC;
|
||||
WebRtc_UWord32 _remoteSSRC; // SSRC that we receive on our RTP channel
|
||||
char _CNAME[RTCP_CNAME_SIZE];
|
||||
|
||||
MapWrapper _reportBlocks; // map of SSRC to RTCPReportBlock
|
||||
MapWrapper _csrcCNAMEs; // map of SSRC to Cnames
|
||||
std::map<WebRtc_UWord32, RTCPReportBlock*> _reportBlocks;
|
||||
std::map<WebRtc_UWord32, RTCPUtility::RTCPCnameInformation*> _csrcCNAMEs;
|
||||
|
||||
WebRtc_Word32 _cameraDelayMS;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user