summaryrefslogtreecommitdiff
path: root/voice_engine/channel.cc
diff options
context:
space:
mode:
authorminyue@webrtc.org <minyue@webrtc.org>2014-09-11 07:51:53 +0000
committerminyue@webrtc.org <minyue@webrtc.org>2014-09-11 07:51:53 +0000
commit2b742db21b21460df4906976847b9aafa97a060b (patch)
treeeac0144fbdfb296922365f923064b0c70a9f9d35 /voice_engine/channel.cc
parent6b0dab1b84bb8b6cccd9cffa15067099c1fcfa51 (diff)
downloadwebrtc-2b742db21b21460df4906976847b9aafa97a060b.tar.gz
Calculating round-trip-time in send-only channel in VoE.
TESTS=built chromium and tested with 1:1 hangout call BUG= R=stefan@webrtc.org, xians@webrtc.org Review URL: https://webrtc-codereview.appspot.com/23489004 git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@7147 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'voice_engine/channel.cc')
-rw-r--r--voice_engine/channel.cc85
1 files changed, 48 insertions, 37 deletions
diff --git a/voice_engine/channel.cc b/voice_engine/channel.cc
index 41728c74..6d6b099c 100644
--- a/voice_engine/channel.cc
+++ b/voice_engine/channel.cc
@@ -3481,43 +3481,7 @@ Channel::GetRTPStatistics(CallStatistics& stats)
stats.jitterSamples);
// --- RTT
-
- uint16_t RTT(0);
- RTCPMethod method = _rtpRtcpModule->RTCP();
- if (method == kRtcpOff)
- {
- WEBRTC_TRACE(kTraceWarning, kTraceVoice,
- VoEId(_instanceId, _channelId),
- "GetRTPStatistics() RTCP is disabled => valid RTT "
- "measurements cannot be retrieved");
- } else
- {
- // The remote SSRC will be zero if no RTP packet has been received.
- uint32_t remoteSSRC = rtp_receiver_->SSRC();
- if (remoteSSRC > 0)
- {
- uint16_t avgRTT(0);
- uint16_t maxRTT(0);
- uint16_t minRTT(0);
-
- if (_rtpRtcpModule->RTT(remoteSSRC, &RTT, &avgRTT, &minRTT, &maxRTT)
- != 0)
- {
- WEBRTC_TRACE(kTraceWarning, kTraceVoice,
- VoEId(_instanceId, _channelId),
- "GetRTPStatistics() failed to retrieve RTT from "
- "the RTP/RTCP module");
- }
- } else
- {
- WEBRTC_TRACE(kTraceWarning, kTraceVoice,
- VoEId(_instanceId, _channelId),
- "GetRTPStatistics() failed to measure RTT since no "
- "RTP packets have been received yet");
- }
- }
-
- stats.rttMs = static_cast<int> (RTT);
+ stats.rttMs = GetRTT();
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_instanceId, _channelId),
@@ -4566,5 +4530,52 @@ int32_t Channel::GetPlayoutFrequency() {
return playout_frequency;
}
+int Channel::GetRTT() const {
+ RTCPMethod method = _rtpRtcpModule->RTCP();
+ if (method == kRtcpOff) {
+ WEBRTC_TRACE(kTraceWarning, kTraceVoice,
+ VoEId(_instanceId, _channelId),
+ "GetRTPStatistics() RTCP is disabled => valid RTT "
+ "measurements cannot be retrieved");
+ return 0;
+ }
+ std::vector<RTCPReportBlock> report_blocks;
+ _rtpRtcpModule->RemoteRTCPStat(&report_blocks);
+ if (report_blocks.empty()) {
+ WEBRTC_TRACE(kTraceWarning, kTraceVoice,
+ VoEId(_instanceId, _channelId),
+ "GetRTPStatistics() failed to measure RTT since no "
+ "RTCP packets have been received yet");
+ return 0;
+ }
+
+ uint32_t remoteSSRC = rtp_receiver_->SSRC();
+ std::vector<RTCPReportBlock>::const_iterator it = report_blocks.begin();
+ for (; it != report_blocks.end(); ++it) {
+ if (it->remoteSSRC == remoteSSRC)
+ break;
+ }
+ if (it == report_blocks.end()) {
+ // We have not received packets with SSRC matching the report blocks.
+ // To calculate RTT we try with the SSRC of the first report block.
+ // This is very important for send-only channels where we don't know
+ // the SSRC of the other end.
+ remoteSSRC = report_blocks[0].remoteSSRC;
+ }
+ uint16_t rtt = 0;
+ uint16_t avg_rtt = 0;
+ uint16_t max_rtt= 0;
+ uint16_t min_rtt = 0;
+ if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt)
+ != 0) {
+ WEBRTC_TRACE(kTraceWarning, kTraceVoice,
+ VoEId(_instanceId, _channelId),
+ "GetRTPStatistics() failed to retrieve RTT from "
+ "the RTP/RTCP module");
+ return 0;
+ }
+ return static_cast<int>(rtt);
+}
+
} // namespace voe
} // namespace webrtc