From 203ff1932344ca802c9e38ba38443ac9bd03e950 Mon Sep 17 00:00:00 2001 From: penguinol Date: Thu, 20 Feb 2025 19:58:02 +0800 Subject: [PATCH] fix lack of tcc feedback --- worker/include/RTC/RTCP/CompoundPacket.hpp | 12 +----------- worker/include/RTC/RtpPacket.hpp | 8 ++++++++ worker/src/RTC/RTCP/CompoundPacket.cpp | 6 +++--- worker/src/RTC/RtpStreamRecv.cpp | 2 +- worker/src/RTC/RtpStreamSend.cpp | 2 +- worker/src/RTC/Transport.cpp | 4 ++-- .../src/RTC/TransportCongestionControlServer.cpp | 14 ++++++++++---- 7 files changed, 26 insertions(+), 22 deletions(-) diff --git a/worker/include/RTC/RTCP/CompoundPacket.hpp b/worker/include/RTC/RTCP/CompoundPacket.hpp index 228ba06d73..d5420bc9fa 100644 --- a/worker/include/RTC/RTCP/CompoundPacket.hpp +++ b/worker/include/RTC/RTCP/CompoundPacket.hpp @@ -7,7 +7,7 @@ #include "RTC/RTCP/SenderReport.hpp" #include "RTC/RTCP/XrDelaySinceLastRr.hpp" #include "RTC/RTCP/XrReceiverReferenceTime.hpp" -#include "RTC/RtpPacket.hpp" // MtuSize. +#include "RTC/RtpPacket.hpp" // MaxPacketSize. #include namespace RTC @@ -16,16 +16,6 @@ namespace RTC { class CompoundPacket { - public: - // Maximum size for a CompundPacket. - // * IPv4|Ipv6 header size: 20|40 bytes. IPv6 considered. - // * UDP|TCP header size: 8|20 bytes. TCP considered. - // * SRTP Encryption: 148 bytes. - // SRTP_MAX_TRAILER_LEN+4 is the maximum number of octects that will be - // added to an RTCP packet by srtp_protect_rtcp(). - // srtp.h: SRTP_MAX_TRAILER_LEN (SRTP_MAX_TAG_LEN + SRTP_MAX_MKI_LEN) - constexpr static size_t MaxSize{ RTC::MtuSize - 40u - 20u - 148u }; - public: CompoundPacket() = default; diff --git a/worker/include/RTC/RtpPacket.hpp b/worker/include/RTC/RtpPacket.hpp index 2058058365..8c8afaed99 100644 --- a/worker/include/RTC/RtpPacket.hpp +++ b/worker/include/RTC/RtpPacket.hpp @@ -18,6 +18,14 @@ namespace RTC { // Max MTU size. constexpr size_t MtuSize{ 1500u }; + // Maximum size for a CompundPacket. + // * IPv4|Ipv6 header size: 20|40 bytes. IPv6 considered. + // * UDP|TCP header size: 8|20 bytes. TCP considered. + // * SRTP Encryption: 148 bytes. + // SRTP_MAX_TRAILER_LEN+4 is the maximum number of octects that will be + // added to an RTCP packet by srtp_protect_rtcp(). + // srtp.h: SRTP_MAX_TRAILER_LEN (SRTP_MAX_TAG_LEN + SRTP_MAX_MKI_LEN) + constexpr size_t MaxPacketSize{ RTC::MtuSize - 40 - 20 - 148u }; // MID header extension max length (just used when setting/updating MID // extension). constexpr uint8_t MidMaxLength{ 8u }; diff --git a/worker/src/RTC/RTCP/CompoundPacket.cpp b/worker/src/RTC/RTCP/CompoundPacket.cpp index 4429f4d2f6..2227853885 100644 --- a/worker/src/RTC/RTCP/CompoundPacket.cpp +++ b/worker/src/RTC/RTCP/CompoundPacket.cpp @@ -101,7 +101,7 @@ namespace RTC } // New items can hold in the packet, report it. - if (GetSize() <= MaxSize) + if (GetSize() <= RTC::MaxPacketSize) { return true; } @@ -160,7 +160,7 @@ namespace RTC } // New items can hold in the packet, report it. - if (GetSize() <= MaxSize) + if (GetSize() <= RTC::MaxPacketSize) { return true; } @@ -206,7 +206,7 @@ namespace RTC } // New items can hold in the packet, report it. - if (GetSize() <= MaxSize) + if (GetSize() <= RTC::MaxPacketSize) { return true; } diff --git a/worker/src/RTC/RtpStreamRecv.cpp b/worker/src/RTC/RtpStreamRecv.cpp index ba9e50c6d8..bea8be1aa3 100644 --- a/worker/src/RTC/RtpStreamRecv.cpp +++ b/worker/src/RTC/RtpStreamRecv.cpp @@ -191,7 +191,7 @@ namespace RTC RtpStreamRecv::RtpStreamRecv( RTC::RtpStreamRecv::Listener* listener, RTC::RtpStream::Params& params, - unsigned int sendNackDelayMs, + uint32_t sendNackDelayMs, bool useRtpInactivityCheck) : RTC::RtpStream::RtpStream(listener, params, 10), sendNackDelayMs(sendNackDelayMs), useRtpInactivityCheck(useRtpInactivityCheck), diff --git a/worker/src/RTC/RtpStreamSend.cpp b/worker/src/RTC/RtpStreamSend.cpp index 79875ce9c3..5a5c5b11d8 100644 --- a/worker/src/RTC/RtpStreamSend.cpp +++ b/worker/src/RTC/RtpStreamSend.cpp @@ -465,7 +465,7 @@ namespace RTC MS_DEBUG_TAG( rtx, "ignoring retransmission for a packet already resent in the last RTT ms " - "[seq:%" PRIu16 ", rtt:%" PRIu32 "]", + "[seq:%" PRIu16 ", rtt:%" PRIu16 "]", packet->GetSequenceNumber(), rtt); } diff --git a/worker/src/RTC/Transport.cpp b/worker/src/RTC/Transport.cpp index ea5426970f..fe3720c899 100644 --- a/worker/src/RTC/Transport.cpp +++ b/worker/src/RTC/Transport.cpp @@ -758,8 +758,8 @@ namespace RTC if (createTccServer) { - this->tccServer = - std::make_shared(this, bweType, RTC::MtuSize); + this->tccServer = std::make_shared( + this, bweType, RTC::MaxPacketSize); if (this->maxIncomingBitrate != 0u) { diff --git a/worker/src/RTC/TransportCongestionControlServer.cpp b/worker/src/RTC/TransportCongestionControlServer.cpp index c5d21de37a..a487fb8c32 100644 --- a/worker/src/RTC/TransportCongestionControlServer.cpp +++ b/worker/src/RTC/TransportCongestionControlServer.cpp @@ -233,14 +233,20 @@ namespace RTC case RTC::RTCP::FeedbackRtpTransportPacket::AddPacketResult::MAX_SIZE_EXCEEDED: { - // This should not happen. - MS_WARN_TAG(rtcp, "transport-cc feedback packet is exceeded"); + // Send ongoing feedback packet + auto sent = SendTransportCcFeedback(); + + if (sent) + { + ++this->transportCcFeedbackPacketCount; + } // Create a new feedback packet. - // NOTE: Do not increment packet count it since the previous ongoing - // feedback packet was not sent. ResetTransportCcFeedback(this->transportCcFeedbackPacketCount); + // Decrease iterator to add current packet again. + --it; + break; }