From 2580bc4c30fa7a92e24dd3577dc88fc70e46fa47 Mon Sep 17 00:00:00 2001 From: "solenberg@webrtc.org" Date: Fri, 3 May 2013 09:22:14 +0000 Subject: [PATCH] Get rid of some unnecessary copying when sending REMBs. BUG= Review URL: https://webrtc-codereview.appspot.com/1325005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3947 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/video_engine/vie_remb.cc | 16 +++------------- webrtc/video_engine/vie_remb.h | 1 - 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/webrtc/video_engine/vie_remb.cc b/webrtc/video_engine/vie_remb.cc index 8cc473263..eb70fac9d 100644 --- a/webrtc/video_engine/vie_remb.cc +++ b/webrtc/video_engine/vie_remb.cc @@ -122,10 +122,6 @@ void VieRemb::OnReceiveBitrateChanged(std::vector* ssrcs, } } bitrate_ = bitrate; - // TODO(holmer): Remove |ssrcs_| from this class as the REMB is produced - // immediately upon a call to this function. - ssrcs_.resize(ssrcs->size()); - std::copy(ssrcs->begin(), ssrcs->end(), ssrcs_.begin()); // Calculate total receive bitrate estimate. int64_t now = TickTime::MillisecondTimestamp(); @@ -136,7 +132,7 @@ void VieRemb::OnReceiveBitrateChanged(std::vector* ssrcs, } last_remb_time_ = now; - if (ssrcs_.empty() || receive_modules_.empty()) { + if (ssrcs->empty() || receive_modules_.empty()) { list_crit_->Leave(); return; } @@ -154,19 +150,13 @@ void VieRemb::OnReceiveBitrateChanged(std::vector* ssrcs, if (last_send_bitrate_ < kRembMinimumBitrateKbps) { last_send_bitrate_ = kRembMinimumBitrateKbps; } - // Copy SSRCs to avoid race conditions. - int ssrcs_length = ssrcs_.size(); - unsigned int* ssrcs_copy = new unsigned int[ssrcs_length]; - for (int i = 0; i < ssrcs_length; ++i) { - ssrcs_copy[i] = ssrcs_[i]; - } + list_crit_->Leave(); if (sender) { // TODO(holmer): Change RTP module API to take a vector pointer. - sender->SetREMBData(bitrate_, ssrcs_length, ssrcs_copy); + sender->SetREMBData(bitrate_, ssrcs->size(), &(*ssrcs)[0]); } - delete [] ssrcs_copy; } } // namespace webrtc diff --git a/webrtc/video_engine/vie_remb.h b/webrtc/video_engine/vie_remb.h index 5365b7fd0..d4b380373 100644 --- a/webrtc/video_engine/vie_remb.h +++ b/webrtc/video_engine/vie_remb.h @@ -71,7 +71,6 @@ class VieRemb : public RemoteBitrateObserver { // The last bitrate update. unsigned int bitrate_; - std::vector ssrcs_; }; } // namespace webrtc