sr发送限频

This commit is contained in:
mtdxc
2025-09-29 16:08:05 +08:00
committed by 夏楚
parent 13f603328f
commit 21d1ea9676
4 changed files with 11 additions and 12 deletions

View File

@@ -107,6 +107,11 @@ uint32_t RtcpContextForSend::getRtt(uint32_t ssrc) const {
}
Buffer::Ptr RtcpContextForSend::createRtcpSR(uint32_t rtcp_ssrc) {
uint64_t now = getCurrentMillisecond();
if (now - _last_sr_tsp < 5000) {
return nullptr;
}
_last_sr_tsp = now;
auto rtcp = RtcpSR::create(0);
rtcp->setNtpStamp(_last_ntp_stamp_ms);
rtcp->rtpts = htonl(_last_rtp_stamp);
@@ -117,7 +122,7 @@ Buffer::Ptr RtcpContextForSend::createRtcpSR(uint32_t rtcp_ssrc) {
// 记录上次发送的sender report信息用于后续统计rtt [AUTO-TRANSLATED:1d22d2c8]
// Record the last sent sender report information for subsequent RTT statistics
auto last_sr_lsr = ((ntohl(rtcp->ntpmsw) & 0xFFFF) << 16) | ((ntohl(rtcp->ntplsw) >> 16) & 0xFFFF);
_sender_report_ntp[last_sr_lsr] = getCurrentMillisecond();
_sender_report_ntp[last_sr_lsr] = now;
if (_sender_report_ntp.size() >= 5) {
// 删除最早的sr rtcp [AUTO-TRANSLATED:2457e08d]
// Delete the earliest sr rtcp