Deliver RTCP packets only once per send stream.

For simulcast VideoSendStreams there are more than one entry in the SSRC
table causing RTCP to currently be delivered more than once per stream.
This messes up unique NACK stats as all NACK requests sent to such a
sender will be delivered multiple times and not look unique.

BUG=4544
R=asapersson@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/50709004

Cr-Commit-Position: refs/heads/master@{#8998}
diff --git a/webrtc/video/call.cc b/webrtc/video/call.cc
index 7c8b059..9a2af7b 100644
--- a/webrtc/video/call.cc
+++ b/webrtc/video/call.cc
@@ -145,6 +145,7 @@
 
   rtc::scoped_ptr<RWLockWrapper> send_crit_;
   std::map<uint32_t, VideoSendStream*> send_ssrcs_ GUARDED_BY(send_crit_);
+  std::set<VideoSendStream*> send_streams_ GUARDED_BY(send_crit_);
 
   rtc::scoped_ptr<CpuOveruseObserverProxy> overuse_observer_proxy_;
 
@@ -230,6 +231,7 @@
 
 Call::~Call() {
   CHECK_EQ(0u, send_ssrcs_.size());
+  CHECK_EQ(0u, send_streams_.size());
   CHECK_EQ(0u, receive_ssrcs_.size());
   base_->DeleteChannel(base_channel_id_);
 
@@ -262,6 +264,7 @@
   // while changing network state.
   CriticalSectionScoped lock(network_enabled_crit_.get());
   WriteLockScoped write_lock(*send_crit_);
+  send_streams_.insert(send_stream);
   for (size_t i = 0; i < config.rtp.ssrcs.size(); ++i) {
     DCHECK(send_ssrcs_.find(config.rtp.ssrcs[i]) == send_ssrcs_.end());
     send_ssrcs_[config.rtp.ssrcs[i]] = send_stream;
@@ -289,6 +292,7 @@
         ++it;
       }
     }
+    send_streams_.erase(send_stream_impl);
   }
   CHECK(send_stream_impl != nullptr);
 
@@ -440,22 +444,15 @@
   bool rtcp_delivered = false;
   {
     ReadLockScoped read_lock(*receive_crit_);
-    for (std::map<uint32_t, VideoReceiveStream*>::iterator it =
-             receive_ssrcs_.begin();
-         it != receive_ssrcs_.end();
-         ++it) {
-      if (it->second->DeliverRtcp(packet, length))
+    for (auto& kv : receive_ssrcs_) {
+      if (kv.second->DeliverRtcp(packet, length))
         rtcp_delivered = true;
     }
   }
-
   {
     ReadLockScoped read_lock(*send_crit_);
-    for (std::map<uint32_t, VideoSendStream*>::iterator it =
-             send_ssrcs_.begin();
-         it != send_ssrcs_.end();
-         ++it) {
-      if (it->second->DeliverRtcp(packet, length))
+    for (auto& stream : send_streams_) {
+      if (stream->DeliverRtcp(packet, length))
         rtcp_delivered = true;
     }
   }