Remove simulcast modules from ViEReceiver.

Instead of maintaining two lists of simulcast modules, deliver RTCP
packets to simulcast modules inside ViEChannel.

BUG=1695
R=stefan@webrtc.org

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

Cr-Commit-Position: refs/heads/master@{#9027}
diff --git a/webrtc/video_engine/vie_channel.cc b/webrtc/video_engine/vie_channel.cc
index 353dc12..5068438 100644
--- a/webrtc/video_engine/vie_channel.cc
+++ b/webrtc/video_engine/vie_channel.cc
@@ -509,9 +509,6 @@
         rtp_rtcp->RegisterSendChannelRtpStatisticsCallback(
             rtp_rtcp_->GetSendChannelRtpStatisticsCallback());
       }
-      // |RegisterSimulcastRtpRtcpModules| resets all old weak pointers and old
-      // modules can be deleted after this step.
-      vie_receiver_.RegisterSimulcastRtpRtcpModules(simulcast_rtp_rtcp_);
     } else {
       while (!simulcast_rtp_rtcp_.empty()) {
         RtpRtcp* rtp_rtcp = simulcast_rtp_rtcp_.back();
@@ -523,8 +520,6 @@
         simulcast_rtp_rtcp_.pop_back();
         removed_rtp_rtcp_.push_front(rtp_rtcp);
       }
-      // Clear any previous modules.
-      vie_receiver_.RegisterSimulcastRtpRtcpModules(simulcast_rtp_rtcp_);
     }
 
     // Don't log this error, no way to check in advance if this pl_type is
@@ -1602,7 +1597,16 @@
       return -1;
     }
   }
-  return vie_receiver_.ReceivedRTCPPacket(rtcp_packet, rtcp_packet_length);
+  int ret = vie_receiver_.ReceivedRTCPPacket(rtcp_packet, rtcp_packet_length);
+  if (ret != 0)
+    return ret;
+
+  CriticalSectionScoped cs(rtp_rtcp_cs_.get());
+  for (RtpRtcp* rtp_rtcp : simulcast_rtp_rtcp_) {
+    rtp_rtcp->IncomingRtcpPacket(static_cast<const uint8_t*>(rtcp_packet),
+                                 rtcp_packet_length);
+  }
+  return 0;
 }
 
 int32_t ViEChannel::SetMTU(uint16_t mtu) {
diff --git a/webrtc/video_engine/vie_receiver.cc b/webrtc/video_engine/vie_receiver.cc
index e61c82b..0265ee6 100644
--- a/webrtc/video_engine/vie_receiver.cc
+++ b/webrtc/video_engine/vie_receiver.cc
@@ -151,18 +151,6 @@
   return rtp_receiver_.get();
 }
 
-void ViEReceiver::RegisterSimulcastRtpRtcpModules(
-    const std::list<RtpRtcp*>& rtp_modules) {
-  CriticalSectionScoped cs(receive_cs_.get());
-  rtp_rtcp_simulcast_.clear();
-
-  if (!rtp_modules.empty()) {
-    rtp_rtcp_simulcast_.insert(rtp_rtcp_simulcast_.begin(),
-                               rtp_modules.begin(),
-                               rtp_modules.end());
-  }
-}
-
 bool ViEReceiver::SetReceiveTimestampOffsetStatus(bool enable, int id) {
   if (enable) {
     return rtp_header_parser_->RegisterRtpHeaderExtension(
@@ -419,12 +407,6 @@
     if (rtp_dump_) {
       rtp_dump_->DumpPacket(rtcp_packet, rtcp_packet_length);
     }
-
-    std::list<RtpRtcp*>::iterator it = rtp_rtcp_simulcast_.begin();
-    while (it != rtp_rtcp_simulcast_.end()) {
-      RtpRtcp* rtp_rtcp = *it++;
-      rtp_rtcp->IncomingRtcpPacket(rtcp_packet, rtcp_packet_length);
-    }
   }
   assert(rtp_rtcp_);  // Should be set by owner at construction time.
   int ret = rtp_rtcp_->IncomingRtcpPacket(rtcp_packet, rtcp_packet_length);
diff --git a/webrtc/video_engine/vie_receiver.h b/webrtc/video_engine/vie_receiver.h
index 5c09a3e..3cb8677 100644
--- a/webrtc/video_engine/vie_receiver.h
+++ b/webrtc/video_engine/vie_receiver.h
@@ -60,8 +60,6 @@
 
   RtpReceiver* GetRtpReceiver() const;
 
-  void RegisterSimulcastRtpRtcpModules(const std::list<RtpRtcp*>& rtp_modules);
-
   bool SetReceiveTimestampOffsetStatus(bool enable, int id);
   bool SetReceiveAbsoluteSendTimeStatus(bool enable, int id);
   bool SetReceiveVideoRotationStatus(bool enable, int id);
@@ -113,7 +111,6 @@
   rtc::scoped_ptr<ReceiveStatistics> rtp_receive_statistics_;
   rtc::scoped_ptr<FecReceiver> fec_receiver_;
   RtpRtcp* rtp_rtcp_;
-  std::list<RtpRtcp*> rtp_rtcp_simulcast_;
   VideoCodingModule* vcm_;
   RemoteBitrateEstimator* remote_bitrate_estimator_;