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@7147 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
minyue@webrtc.org 2014-09-11 07:51:53 +00:00
parent 1972ff8a6e
commit 2b58a4433f
2 changed files with 49 additions and 37 deletions

View File

@ -3481,43 +3481,7 @@ Channel::GetRTPStatistics(CallStatistics& stats)
stats.jitterSamples); stats.jitterSamples);
// --- RTT // --- RTT
stats.rttMs = GetRTT();
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);
WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, WEBRTC_TRACE(kTraceStateInfo, kTraceVoice,
VoEId(_instanceId, _channelId), VoEId(_instanceId, _channelId),
@ -4566,5 +4530,52 @@ int32_t Channel::GetPlayoutFrequency() {
return playout_frequency; 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 voe
} // namespace webrtc } // namespace webrtc

View File

@ -508,6 +508,7 @@ private:
unsigned char id); unsigned char id);
int32_t GetPlayoutFrequency(); int32_t GetPlayoutFrequency();
int GetRTT() const;
CriticalSectionWrapper& _fileCritSect; CriticalSectionWrapper& _fileCritSect;
CriticalSectionWrapper& _callbackCritSect; CriticalSectionWrapper& _callbackCritSect;