diff --git a/worker/src/RTC/TransportCongestionControlServer.cpp b/worker/src/RTC/TransportCongestionControlServer.cpp index 12325a60bb..cb6af0f9d1 100644 --- a/worker/src/RTC/TransportCongestionControlServer.cpp +++ b/worker/src/RTC/TransportCongestionControlServer.cpp @@ -184,7 +184,7 @@ namespace RTC if (it != this->mapPacketArrivalTimes.end()) { - // set base sequence num and reference time + // Set base sequence num and reference time. this->transportCcFeedbackPacket->SetBase(this->transportCcFeedbackStartSeqNum, it->second); for (; it != this->mapPacketArrivalTimes.end(); ++it) @@ -305,8 +305,9 @@ namespace RTC { MS_TRACE(); - // Ignore nowMs value if it's smaller than 500 in order to avoid negative values - // (Should never happen) and return early if the condition is met. + // Ignore nowMs value if it's smaller than PacketArrivalTimestampWindow in + // order to avoid negative values (should never happen) and return early if + // the condition is met. if (nowMs >= PacketArrivalTimestampWindow) { auto expiryTimestamp = nowMs - PacketArrivalTimestampWindow; diff --git a/worker/test/src/RTC/TestTransportCongestionControlServer.cpp b/worker/test/src/RTC/TestTransportCongestionControlServer.cpp index 720525a28a..e5cbc42513 100644 --- a/worker/test/src/RTC/TestTransportCongestionControlServer.cpp +++ b/worker/test/src/RTC/TestTransportCongestionControlServer.cpp @@ -27,7 +27,8 @@ class TestTransportCongestionControlServerListener : public TransportCongestionC RTC::TransportCongestionControlServer* tccServer, RTC::RTCP::Packet* packet) override { auto* tccPacket = dynamic_cast(packet); - if (tccPacket == nullptr) + + if (!tccPacket) { return; } @@ -43,11 +44,13 @@ class TestTransportCongestionControlServerListener : public TransportCongestionC auto packetResultIt = packetResults.begin(); auto testResultIt = testResults.begin(); + for (; packetResultIt != packetResults.end() && testResultIt != testResults.end(); ++packetResultIt, ++testResultIt) { REQUIRE(packetResultIt->sequenceNumber == testResultIt->wideSeqNumber); REQUIRE(packetResultIt->received == testResultIt->received); + if (packetResultIt->received) { REQUIRE(packetResultIt->receivedAtMs == testResultIt->timestamp); @@ -86,14 +89,16 @@ void validate(std::vector& inputs, Te TestTransportCongestionControlServerListener listener; auto tccServer = TransportCongestionControlServer(&listener, RTC::BweType::TRANSPORT_CC, RTC::MtuSize); + tccServer.SetMaxIncomingBitrate(150000); tccServer.TransportConnected(); RtpPacket* packet = RtpPacket::Parse(buffer, sizeof(buffer)); + packet->SetTransportWideCc01ExtensionId(5); packet->SetSequenceNumber(1); - // save results + // Save results. listener.SetResults(results); uint64_t startTs = inputs[0].nowMs; @@ -101,8 +106,9 @@ void validate(std::vector& inputs, Te for (auto input : inputs) { - // Periodic sending TCC packets + // Periodic sending TCC packets. uint64_t diffTs = input.nowMs - startTs; + if (diffTs >= TransportCcFeedbackSendInterval) { tccServer.FillAndSendTransportCcFeedback(); @@ -114,7 +120,6 @@ void validate(std::vector& inputs, Te } tccServer.FillAndSendTransportCcFeedback(); - listener.Check(); };