完善rtt相关代码

This commit is contained in:
xiongziliang
2021-07-06 23:09:56 +08:00
parent 4c296488f1
commit 986e9511a2
3 changed files with 17 additions and 1 deletions

View File

@@ -103,7 +103,7 @@ void RtcpContext::onRtcp(RtcpHeader *rtcp) {
//转换为毫秒
auto ms_inc = ntpmsw_inc * 1000 + (ntplsw_inc / ((double) (((uint64_t) 1) << 32) * 1.0e-3));
auto rtt = (int) ((ms_inc - delay_ms) / 2);
auto rtt = (int) (ms_inc - delay_ms);
_rtt[item->ssrc] = rtt;
//InfoL << "ssrc:" << item->ssrc << ",rtt:" << rtt;
}
@@ -113,6 +113,14 @@ void RtcpContext::onRtcp(RtcpHeader *rtcp) {
}
}
uint32_t RtcpContext::getRtt(uint32_t ssrc) const {
auto it = _rtt.find(ssrc);
if (it == _rtt.end()) {
return 0;
}
return it->second;
}
size_t RtcpContext::getExpectedPackets() const {
if (!_is_receiver) {
throw std::runtime_error("rtp发送者无法统计应收包数");