diff --git a/webrtc/video_engine/vie_channel.cc b/webrtc/video_engine/vie_channel.cc index 5068438446..353dc12863 100644 --- a/webrtc/video_engine/vie_channel.cc +++ b/webrtc/video_engine/vie_channel.cc @@ -509,6 +509,9 @@ int32_t ViEChannel::SetSendCodec(const VideoCodec& video_codec, 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(); @@ -520,6 +523,8 @@ int32_t ViEChannel::SetSendCodec(const VideoCodec& video_codec, 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 @@ -1597,16 +1602,7 @@ int32_t ViEChannel::ReceivedRTCPPacket( return -1; } } - 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(rtcp_packet), - rtcp_packet_length); - } - return 0; + return vie_receiver_.ReceivedRTCPPacket(rtcp_packet, rtcp_packet_length); } int32_t ViEChannel::SetMTU(uint16_t mtu) { diff --git a/webrtc/video_engine/vie_receiver.cc b/webrtc/video_engine/vie_receiver.cc index 0265ee6cef..e61c82bb9d 100644 --- a/webrtc/video_engine/vie_receiver.cc +++ b/webrtc/video_engine/vie_receiver.cc @@ -151,6 +151,18 @@ RtpReceiver* ViEReceiver::GetRtpReceiver() const { return rtp_receiver_.get(); } +void ViEReceiver::RegisterSimulcastRtpRtcpModules( + const std::list& 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( @@ -407,6 +419,12 @@ int ViEReceiver::InsertRTCPPacket(const uint8_t* rtcp_packet, if (rtp_dump_) { rtp_dump_->DumpPacket(rtcp_packet, rtcp_packet_length); } + + std::list::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 3cb8677446..5c09a3e482 100644 --- a/webrtc/video_engine/vie_receiver.h +++ b/webrtc/video_engine/vie_receiver.h @@ -60,6 +60,8 @@ class ViEReceiver : public RtpData { RtpReceiver* GetRtpReceiver() const; + void RegisterSimulcastRtpRtcpModules(const std::list& rtp_modules); + bool SetReceiveTimestampOffsetStatus(bool enable, int id); bool SetReceiveAbsoluteSendTimeStatus(bool enable, int id); bool SetReceiveVideoRotationStatus(bool enable, int id); @@ -111,6 +113,7 @@ class ViEReceiver : public RtpData { rtc::scoped_ptr rtp_receive_statistics_; rtc::scoped_ptr fec_receiver_; RtpRtcp* rtp_rtcp_; + std::list rtp_rtcp_simulcast_; VideoCodingModule* vcm_; RemoteBitrateEstimator* remote_bitrate_estimator_;