From fe161675077a561ec53ca78806cc9dbc812b1ce9 Mon Sep 17 00:00:00 2001 From: "stefan@webrtc.org" Date: Mon, 8 Sep 2014 08:45:25 +0000 Subject: [PATCH] Fix RTT calculations for send-only channels. As we don't know the SSRC of the other end in a send-only channel since we haven't received packets from that end, we are required to assume that the SSRC of the first report block is the correct SSRC to use for RTT calculations. BUG=3781 R=mflodman@webrtc.org Review URL: https://webrtc-codereview.appspot.com/14349004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7097 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/video_engine/vie_channel.cc | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/webrtc/video_engine/vie_channel.cc b/webrtc/video_engine/vie_channel.cc index b8f900273..bbcb602cc 100644 --- a/webrtc/video_engine/vie_channel.cc +++ b/webrtc/video_engine/vie_channel.cc @@ -1012,15 +1012,33 @@ int32_t ViEChannel::GetSendRtcpStatistics(uint16_t* fraction_lost, // Aggregate the report blocks associated with streams sent on this channel. std::vector report_blocks; rtp_rtcp_->RemoteRTCPStat(&report_blocks); - for (std::list::iterator it = simulcast_rtp_rtcp_.begin(); - it != simulcast_rtp_rtcp_.end(); - ++it) { - (*it)->RemoteRTCPStat(&report_blocks); + { + CriticalSectionScoped lock(rtp_rtcp_cs_.get()); + for (std::list::iterator it = simulcast_rtp_rtcp_.begin(); + it != simulcast_rtp_rtcp_.end(); + ++it) { + (*it)->RemoteRTCPStat(&report_blocks); + } } if (report_blocks.empty()) return -1; + uint32_t remote_ssrc = vie_receiver_.GetRemoteSsrc(); + std::vector::const_iterator it = report_blocks.begin(); + for (; it != report_blocks.end(); ++it) { + if (it->remoteSSRC == remote_ssrc) + break; + } + if (it == report_blocks.end()) { + // We have not received packets with an SSRC matching the report blocks. To + // have a chance of calculating an RTT we will try with the SSRC of the + // first report block received. + // This is very important for send-only channels where we don't know the + // SSRC of the other end. + remote_ssrc = report_blocks[0].remoteSSRC; + } + RTCPReportBlock report; if (report_blocks.size() > 1) report = AggregateReportBlocks(report_blocks, &prev_report_blocks_); @@ -1034,8 +1052,7 @@ int32_t ViEChannel::GetSendRtcpStatistics(uint16_t* fraction_lost, uint16_t dummy; uint16_t rtt = 0; - if (rtp_rtcp_->RTT( - vie_receiver_.GetRemoteSsrc(), &rtt, &dummy, &dummy, &dummy) != 0) { + if (rtp_rtcp_->RTT(remote_ssrc, &rtt, &dummy, &dummy, &dummy) != 0) { return -1; } *rtt_ms = rtt;