Remove intermediate RTCP CNAME buffers.
Sets CNAME using a pointer to only perform a copy inside the RTCP
sender.
BUG=
R=tommi@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/50169005
Cr-Commit-Position: refs/heads/master@{#9346}
diff --git a/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h b/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h
index beb03f3..fac4d3a 100644
--- a/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h
+++ b/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h
@@ -338,7 +338,7 @@
*
* return -1 on failure else 0
*/
- virtual int32_t SetCNAME(const char cName[RTCP_CNAME_SIZE]) = 0;
+ virtual int32_t SetCNAME(const char* c_name) = 0;
/*
* Get remote CName
diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc
index d0feed5..a104fec 100644
--- a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc
@@ -315,13 +315,14 @@
remote_ssrc_ = ssrc;
}
-int32_t RTCPSender::SetCNAME(const char cName[RTCP_CNAME_SIZE]) {
- if (!cName)
+int32_t RTCPSender::SetCNAME(const char* c_name) {
+ if (!c_name)
return -1;
+ DCHECK_LT(strlen(c_name), static_cast<size_t>(RTCP_CNAME_SIZE));
CriticalSectionScoped lock(critical_section_rtcp_sender_.get());
cname_[RTCP_CNAME_SIZE - 1] = 0;
- strncpy(cname_, cName, RTCP_CNAME_SIZE - 1);
+ strncpy(cname_, c_name, RTCP_CNAME_SIZE - 1);
return 0;
}
diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_sender.h b/webrtc/modules/rtp_rtcp/source/rtcp_sender.h
index 673aaf0..143fef7 100644
--- a/webrtc/modules/rtp_rtcp/source/rtcp_sender.h
+++ b/webrtc/modules/rtp_rtcp/source/rtcp_sender.h
@@ -95,7 +95,7 @@
void SetRemoteSSRC(uint32_t ssrc);
- int32_t SetCNAME(const char cName[RTCP_CNAME_SIZE]);
+ int32_t SetCNAME(const char* cName);
int32_t AddMixedCNAME(uint32_t SSRC, const char cName[RTCP_CNAME_SIZE]);
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
index 1afbe01..a79774d 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
@@ -493,7 +493,7 @@
rtcp_receiver_.SetRTCPStatus(method);
}
-int32_t ModuleRtpRtcpImpl::SetCNAME(const char c_name[RTCP_CNAME_SIZE]) {
+int32_t ModuleRtpRtcpImpl::SetCNAME(const char* c_name) {
return rtcp_sender_.SetCNAME(c_name);
}
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h
index 191bed7..68b88ff 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h
+++ b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h
@@ -131,7 +131,7 @@
void SetRTCPStatus(RTCPMethod method) override;
// Set RTCP CName.
- int32_t SetCNAME(const char c_name[RTCP_CNAME_SIZE]) override;
+ int32_t SetCNAME(const char* c_name) override;
// Get remote CName.
int32_t RemoteCNAME(uint32_t remote_ssrc,
diff --git a/webrtc/video/video_send_stream.cc b/webrtc/video/video_send_stream.cc
index 3e6a7e5..254b7d6 100644
--- a/webrtc/video/video_send_stream.cc
+++ b/webrtc/video/video_send_stream.cc
@@ -172,12 +172,7 @@
ConfigureSsrcs();
- char rtcp_cname[RTCP_CNAME_SIZE];
- DCHECK_LT(config_.rtp.c_name.length(), sizeof(rtcp_cname));
- strncpy(rtcp_cname, config_.rtp.c_name.c_str(), sizeof(rtcp_cname) - 1);
- rtcp_cname[sizeof(rtcp_cname) - 1] = '\0';
-
- vie_channel_->SetRTCPCName(rtcp_cname);
+ vie_channel_->SetRTCPCName(config_.rtp.c_name.c_str());
vie_capturer_ = new ViECapturer(module_process_thread_, vie_encoder_);
diff --git a/webrtc/video_engine/vie_channel.cc b/webrtc/video_engine/vie_channel.cc
index a44148f..c66f5d6 100644
--- a/webrtc/video_engine/vie_channel.cc
+++ b/webrtc/video_engine/vie_channel.cc
@@ -1075,7 +1075,7 @@
return rtp_state;
}
-int32_t ViEChannel::SetRTCPCName(const char rtcp_cname[]) {
+int32_t ViEChannel::SetRTCPCName(const char* rtcp_cname) {
if (rtp_rtcp_->Sending()) {
return -1;
}
diff --git a/webrtc/video_engine/vie_channel.h b/webrtc/video_engine/vie_channel.h
index 23202a7..4b4a73e 100644
--- a/webrtc/video_engine/vie_channel.h
+++ b/webrtc/video_engine/vie_channel.h
@@ -192,7 +192,7 @@
RtpState GetRtpStateForSsrc(uint32_t ssrc);
// Sets the CName for the outgoing stream on the channel.
- int32_t SetRTCPCName(const char rtcp_cname[]);
+ int32_t SetRTCPCName(const char* rtcp_cname);
// Gets the CName of the incoming stream.
int32_t GetRemoteRTCPCName(char rtcp_cname[]);