Deliver RTCP packets only once per receive stream.

Receive streams can have multiple entries in the SSRC table when RTX is
configured. This does not mean that they should receive RTCP packets
more than once.

BUG=4546
R=asapersson@webrtc.org, stefan@webrtc.org

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

Cr-Commit-Position: refs/heads/master@{#9019}
diff --git a/webrtc/video/call.cc b/webrtc/video/call.cc
index 9a2af7b..bdd873e 100644
--- a/webrtc/video/call.cc
+++ b/webrtc/video/call.cc
@@ -142,6 +142,7 @@
   rtc::scoped_ptr<RWLockWrapper> receive_crit_;
   std::map<uint32_t, VideoReceiveStream*> receive_ssrcs_
       GUARDED_BY(receive_crit_);
+  std::set<VideoReceiveStream*> receive_streams_ GUARDED_BY(receive_crit_);
 
   rtc::scoped_ptr<RWLockWrapper> send_crit_;
   std::map<uint32_t, VideoSendStream*> send_ssrcs_ GUARDED_BY(send_crit_);
@@ -233,6 +234,7 @@
   CHECK_EQ(0u, send_ssrcs_.size());
   CHECK_EQ(0u, send_streams_.size());
   CHECK_EQ(0u, receive_ssrcs_.size());
+  CHECK_EQ(0u, receive_streams_.size());
   base_->DeleteChannel(base_channel_id_);
 
   render_->DeRegisterVideoRenderModule(*external_render_.get());
@@ -330,6 +332,7 @@
       config.rtp.rtx.begin();
   if (it != config.rtp.rtx.end())
     receive_ssrcs_[it->second.ssrc] = receive_stream;
+  receive_streams_.insert(receive_stream);
 
   if (!network_enabled_)
     receive_stream->SignalNetworkState(kNetworkDown);
@@ -358,6 +361,7 @@
         ++it;
       }
     }
+    receive_streams_.erase(receive_stream_impl);
   }
   CHECK(receive_stream_impl != nullptr);
   delete receive_stream_impl;
@@ -444,14 +448,14 @@
   bool rtcp_delivered = false;
   {
     ReadLockScoped read_lock(*receive_crit_);
-    for (auto& kv : receive_ssrcs_) {
-      if (kv.second->DeliverRtcp(packet, length))
+    for (VideoReceiveStream* stream : receive_streams_) {
+      if (stream->DeliverRtcp(packet, length))
         rtcp_delivered = true;
     }
   }
   {
     ReadLockScoped read_lock(*send_crit_);
-    for (auto& stream : send_streams_) {
+    for (VideoSendStream* stream : send_streams_) {
       if (stream->DeliverRtcp(packet, length))
         rtcp_delivered = true;
     }