From 9ba52f89acd1b9bc88115880dfe2716147bf3b5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Bostr=C3=B6m?= Date: Mon, 1 Jun 2015 14:12:28 +0200 Subject: [PATCH] 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} --- webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h | 2 +- webrtc/modules/rtp_rtcp/source/rtcp_sender.cc | 7 ++++--- webrtc/modules/rtp_rtcp/source/rtcp_sender.h | 2 +- webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc | 2 +- webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h | 2 +- webrtc/video/video_send_stream.cc | 7 +------ webrtc/video_engine/vie_channel.cc | 2 +- webrtc/video_engine/vie_channel.h | 2 +- 8 files changed, 11 insertions(+), 15 deletions(-) diff --git a/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h b/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h index beb03f37c3..fac4d3a9d9 100644 --- a/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h +++ b/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h @@ -338,7 +338,7 @@ class RtpRtcp : public Module { * * 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 d0feed5084..a104fec09f 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc +++ b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc @@ -315,13 +315,14 @@ void RTCPSender::SetRemoteSSRC(uint32_t ssrc) { 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(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 673aaf0f2e..143fef7a89 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_sender.h +++ b/webrtc/modules/rtp_rtcp/source/rtcp_sender.h @@ -95,7 +95,7 @@ public: 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 1afbe01681..a79774d160 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 @@ void ModuleRtpRtcpImpl::SetRTCPStatus(const RTCPMethod method) { 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 191bed7cf6..68b88ffef8 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 @@ class ModuleRtpRtcpImpl : public RtpRtcp { 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 3e6a7e51a3..254b7d610a 100644 --- a/webrtc/video/video_send_stream.cc +++ b/webrtc/video/video_send_stream.cc @@ -172,12 +172,7 @@ VideoSendStream::VideoSendStream( 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 a44148f560..c66f5d6ad6 100644 --- a/webrtc/video_engine/vie_channel.cc +++ b/webrtc/video_engine/vie_channel.cc @@ -1075,7 +1075,7 @@ RtpState ViEChannel::GetRtpStateForSsrc(uint32_t ssrc) { 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 23202a7d39..4b4a73e373 100644 --- a/webrtc/video_engine/vie_channel.h +++ b/webrtc/video_engine/vie_channel.h @@ -192,7 +192,7 @@ class ViEChannel : public VCMFrameTypeCallback, 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[]);