mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-25 20:27:34 +08:00
完善rtt相关代码
This commit is contained in:
parent
4c296488f1
commit
986e9511a2
@ -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发送者无法统计应收包数");
|
||||
|
@ -71,6 +71,13 @@ public:
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* 获取rtt
|
||||
* @param ssrc rtp ssrc
|
||||
* @return rtt,单位毫秒
|
||||
*/
|
||||
uint32_t getRtt(uint32_t ssrc) const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* 上次结果与本次结果间应收包数
|
||||
|
@ -640,6 +640,7 @@ void WebRtcTransportImp::onRtcp(const char *buf, size_t len) {
|
||||
auto it = _ssrc_to_track.find(item->ssrc);
|
||||
if (it != _ssrc_to_track.end()) {
|
||||
auto &track = it->second;
|
||||
track->rtcp_context_send->onRtcp(rtcp);
|
||||
auto sr = track->rtcp_context_send->createRtcpSR(track->answer_ssrc_rtp);
|
||||
sendRtcpPacket(sr->data(), sr->size(), true);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user