Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Iñaki Baz Castillo <[email protected]>
  • Loading branch information
penguinol and ibc authored Jan 30, 2024
1 parent 882e6d9 commit b6a9729
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
7 changes: 4 additions & 3 deletions worker/src/RTC/TransportCongestionControlServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
13 changes: 9 additions & 4 deletions worker/test/src/RTC/TestTransportCongestionControlServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class TestTransportCongestionControlServerListener : public TransportCongestionC
RTC::TransportCongestionControlServer* tccServer, RTC::RTCP::Packet* packet) override
{
auto* tccPacket = dynamic_cast<RTCP::FeedbackRtpTransportPacket*>(packet);
if (tccPacket == nullptr)

if (!tccPacket)
{
return;
}
Expand All @@ -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);
Expand Down Expand Up @@ -86,23 +89,26 @@ void validate(std::vector<TestTransportCongestionControlServerInput>& 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;
uint64_t TransportCcFeedbackSendInterval{ 100u }; // In ms.

for (auto input : inputs)
{
// Periodic sending TCC packets
// Periodic sending TCC packets.
uint64_t diffTs = input.nowMs - startTs;

if (diffTs >= TransportCcFeedbackSendInterval)
{
tccServer.FillAndSendTransportCcFeedback();
Expand All @@ -114,7 +120,6 @@ void validate(std::vector<TestTransportCongestionControlServerInput>& inputs, Te
}

tccServer.FillAndSendTransportCcFeedback();

listener.Check();
};

Expand Down

0 comments on commit b6a9729

Please sign in to comment.