Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Unified Diff: webrtc/api/peerconnection.cc

Issue 1871993002: Only generate one CNAME per PeerConnection. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Renaming: cname -> rtcp_cname. Modified the peerconnectioninterface unit tests. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/api/peerconnection.h ('k') | webrtc/api/peerconnectioninterface_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/peerconnection.cc
diff --git a/webrtc/api/peerconnection.cc b/webrtc/api/peerconnection.cc
index 7f1f4523781685f062bfa0f7e8b639fd1cc1b8d4..506a21582f7ae0ce6f4dffa34497ac72b4dc14ee 100644
--- a/webrtc/api/peerconnection.cc
+++ b/webrtc/api/peerconnection.cc
@@ -66,6 +66,9 @@ static const char kTransport[] = "transport";
// NOTE: Must be in the same order as the ServiceType enum.
static const char* kValidIceServiceTypes[] = {"stun", "stuns", "turn", "turns"};
+// The length of RTCP CNAMEs.
+static const int kRtcpCnameLength = 16;
+
// NOTE: A loop below assumes that the first value of this enum is 0 and all
// other values are incremental.
enum ServiceType {
@@ -377,6 +380,16 @@ void AddSendStreams(
namespace webrtc {
+// Generate a RTCP CNAME when a PeerConnection is created.
+std::string GenerateRtcpCname() {
+ std::string cname;
+ if (!rtc::CreateRandomString(kRtcpCnameLength, &cname)) {
+ LOG(LS_ERROR) << "Failed to generate CNAME.";
+ RTC_DCHECK(false);
+ }
+ return cname;
+}
+
bool ExtractMediaSessionOptions(
const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options,
bool is_offer,
@@ -508,6 +521,7 @@ PeerConnection::PeerConnection(PeerConnectionFactory* factory)
ice_state_(kIceNew),
ice_connection_state_(kIceConnectionNew),
ice_gathering_state_(kIceGatheringNew),
+ rtcp_cname_(GenerateRtcpCname()),
local_streams_(StreamCollection::Create()),
remote_streams_(StreamCollection::Create()) {}
@@ -1503,6 +1517,8 @@ bool PeerConnection::GetOptionsForOffer(
if (session_->data_channel_type() == cricket::DCT_SCTP && HasDataChannels()) {
session_options->data_channel_type = cricket::DCT_SCTP;
}
+
+ session_options->rtcp_cname = rtcp_cname_;
return true;
}
@@ -1540,6 +1556,8 @@ bool PeerConnection::GetOptionsForAnswer(
if (!ParseConstraintsForAnswer(constraints, session_options)) {
return false;
}
+ session_options->rtcp_cname = rtcp_cname_;
+
FinishOptionsForAnswer(session_options);
return true;
}
@@ -1552,6 +1570,8 @@ bool PeerConnection::GetOptionsForAnswer(
if (!ExtractMediaSessionOptions(options, false, session_options)) {
return false;
}
+ session_options->rtcp_cname = rtcp_cname_;
+
FinishOptionsForAnswer(session_options);
return true;
}
« no previous file with comments | « webrtc/api/peerconnection.h ('k') | webrtc/api/peerconnectioninterface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698