RTCPReceiver store cname as std::string.
simplifying cname management.
Remove RTCPUtility::RTCPCnameInformation
since it was last use of the structure.
BUG=webrtc:5565
NOTRY=true
Review-Url: https://codereview.webrtc.org/2354333004
Cr-Commit-Position: refs/heads/master@{#14399}
diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc b/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc
index d81b383..638922c 100644
--- a/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc
@@ -49,9 +49,6 @@
using rtcp::ReportBlock;
using RTCPHelp::RTCPReceiveInformation;
using RTCPHelp::RTCPReportBlockInformation;
-using RTCPUtility::RTCPCnameInformation;
-using RTCPUtility::RTCPPacketReportBlockItem;
-using RTCPUtility::RTCPPacketTypes;
// The number of RTCP time intervals needed to trigger a timeout.
const int kRrTimeoutIntervals = 3;
@@ -122,12 +119,6 @@
delete first->second;
_receivedInfoMap.erase(first);
}
- while (!_receivedCnameMap.empty()) {
- std::map<uint32_t, RTCPCnameInformation*>::iterator first =
- _receivedCnameMap.begin();
- delete first->second;
- _receivedCnameMap.erase(first);
- }
}
bool RTCPReceiver::IncomingPacket(const uint8_t* packet, size_t packet_size) {
@@ -611,35 +602,6 @@
return it_info->second;
}
-RTCPCnameInformation* RTCPReceiver::CreateCnameInformation(
- uint32_t remoteSSRC) {
- rtc::CritScope lock(&_criticalSectionRTCPReceiver);
-
- std::map<uint32_t, RTCPCnameInformation*>::iterator it =
- _receivedCnameMap.find(remoteSSRC);
-
- if (it != _receivedCnameMap.end()) {
- return it->second;
- }
- RTCPCnameInformation* cnameInfo = new RTCPCnameInformation;
- memset(cnameInfo->name, 0, RTCP_CNAME_SIZE);
- _receivedCnameMap[remoteSSRC] = cnameInfo;
- return cnameInfo;
-}
-
-RTCPCnameInformation* RTCPReceiver::GetCnameInformation(
- uint32_t remoteSSRC) const {
- rtc::CritScope lock(&_criticalSectionRTCPReceiver);
-
- std::map<uint32_t, RTCPCnameInformation*>::const_iterator it =
- _receivedCnameMap.find(remoteSSRC);
-
- if (it == _receivedCnameMap.end()) {
- return NULL;
- }
- return it->second;
-}
-
RTCPReceiveInformation* RTCPReceiver::CreateReceiveInformation(
uint32_t remoteSSRC) {
rtc::CritScope lock(&_criticalSectionRTCPReceiver);
@@ -765,11 +727,7 @@
}
for (const rtcp::Sdes::Chunk& chunk : sdes.chunks()) {
- RTCPCnameInformation* cnameInfo = CreateCnameInformation(chunk.ssrc);
- RTC_DCHECK(cnameInfo);
-
- cnameInfo->name[RTCP_CNAME_SIZE - 1] = 0;
- strncpy(cnameInfo->name, chunk.cname.c_str(), RTCP_CNAME_SIZE - 1);
+ received_cnames_[chunk.ssrc] = chunk.cname;
{
rtc::CritScope lock(&_criticalSectionFeedbacks);
if (stats_callback_)
@@ -827,13 +785,7 @@
if (receiveInfoIt != _receivedInfoMap.end())
receiveInfoIt->second->ready_for_delete = true;
- std::map<uint32_t, RTCPCnameInformation*>::iterator cnameInfoIt =
- _receivedCnameMap.find(bye.sender_ssrc());
-
- if (cnameInfoIt != _receivedCnameMap.end()) {
- delete cnameInfoIt->second;
- _receivedCnameMap.erase(cnameInfoIt);
- }
+ received_cnames_.erase(bye.sender_ssrc());
xr_rr_rtt_ms_ = 0;
}
@@ -1186,15 +1138,15 @@
int32_t RTCPReceiver::CNAME(uint32_t remoteSSRC,
char cName[RTCP_CNAME_SIZE]) const {
- assert(cName);
+ RTC_DCHECK(cName);
rtc::CritScope lock(&_criticalSectionRTCPReceiver);
- RTCPCnameInformation* cnameInfo = GetCnameInformation(remoteSSRC);
- if (cnameInfo == NULL) {
+ auto received_cname_it = received_cnames_.find(remoteSSRC);
+ if (received_cname_it == received_cnames_.end())
return -1;
- }
- cName[RTCP_CNAME_SIZE - 1] = 0;
- strncpy(cName, cnameInfo->name, RTCP_CNAME_SIZE - 1);
+
+ size_t length = received_cname_it->second.copy(cName, RTCP_CNAME_SIZE - 1);
+ cName[length] = 0;
return 0;
}
diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_receiver.h b/webrtc/modules/rtp_rtcp/source/rtcp_receiver.h
index 5e3ab07..0fbcdbc 100644
--- a/webrtc/modules/rtp_rtcp/source/rtcp_receiver.h
+++ b/webrtc/modules/rtp_rtcp/source/rtcp_receiver.h
@@ -13,6 +13,7 @@
#include <map>
#include <set>
+#include <string>
#include <vector>
#include "webrtc/base/criticalsection.h"
@@ -127,11 +128,6 @@
void TriggerCallbacksFromRTCPPacket(
const PacketInformation& packet_information);
- RTCPUtility::RTCPCnameInformation* CreateCnameInformation(
- uint32_t remoteSSRC);
- RTCPUtility::RTCPCnameInformation* GetCnameInformation(
- uint32_t remoteSSRC) const;
-
RTCPHelp::RTCPReceiveInformation* CreateReceiveInformation(
uint32_t remoteSSRC);
RTCPHelp::RTCPReceiveInformation* GetReceiveInformation(uint32_t remoteSSRC);
@@ -249,7 +245,8 @@
ReportBlockMap _receivedReportBlockMap
GUARDED_BY(_criticalSectionRTCPReceiver);
ReceivedInfoMap _receivedInfoMap;
- std::map<uint32_t, RTCPUtility::RTCPCnameInformation*> _receivedCnameMap;
+ std::map<uint32_t, std::string> received_cnames_
+ GUARDED_BY(_criticalSectionRTCPReceiver);
// The last time we received an RTCP RR.
int64_t _lastReceivedRrMs;
diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_utility.h b/webrtc/modules/rtp_rtcp/source/rtcp_utility.h
index 629de4e..86fee8e 100644
--- a/webrtc/modules/rtp_rtcp/source/rtcp_utility.h
+++ b/webrtc/modules/rtp_rtcp/source/rtcp_utility.h
@@ -49,10 +49,6 @@
uint32_t MidNtp(uint32_t ntp_sec, uint32_t ntp_frac);
-// CNAME
-struct RTCPCnameInformation {
- char name[RTCP_CNAME_SIZE];
-};
struct RTCPPacketRR {
uint32_t SenderSSRC;
uint8_t NumberOfReportBlocks;