mediasoup 3.27.1 → 3.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/node/lib/Consumer.d.ts.map +1 -1
  3. package/node/lib/Consumer.js +4 -51
  4. package/node/lib/Producer.d.ts.map +1 -1
  5. package/node/lib/Producer.js +4 -8
  6. package/node/lib/ProducerTypes.d.ts +4 -2
  7. package/node/lib/ProducerTypes.d.ts.map +1 -1
  8. package/node/lib/Router.d.ts.map +1 -1
  9. package/node/lib/Router.js +4 -0
  10. package/node/lib/Transport.d.ts.map +1 -1
  11. package/node/lib/Transport.js +7 -10
  12. package/node/lib/fbs/rtp-parameters/rtp-header-extension-uri.d.ts +3 -4
  13. package/node/lib/fbs/rtp-parameters/rtp-header-extension-uri.d.ts.map +1 -1
  14. package/node/lib/fbs/rtp-parameters/rtp-header-extension-uri.js +3 -4
  15. package/node/lib/ortc.d.ts +0 -2
  16. package/node/lib/ortc.d.ts.map +1 -1
  17. package/node/lib/ortc.js +11 -21
  18. package/node/lib/rtpMappingFbsUtils.d.ts +6 -0
  19. package/node/lib/rtpMappingFbsUtils.d.ts.map +1 -0
  20. package/node/lib/rtpMappingFbsUtils.js +65 -0
  21. package/node/lib/rtpParametersFbsUtils.d.ts.map +1 -1
  22. package/node/lib/rtpParametersFbsUtils.js +0 -6
  23. package/node/lib/rtpParametersTypes.d.ts +1 -1
  24. package/node/lib/rtpParametersTypes.d.ts.map +1 -1
  25. package/node/lib/rtpStreamFbsUtils.d.ts +4 -0
  26. package/node/lib/rtpStreamFbsUtils.d.ts.map +1 -0
  27. package/node/lib/rtpStreamFbsUtils.js +51 -0
  28. package/node/lib/supportedRtpCapabilities.d.ts.map +1 -1
  29. package/node/lib/supportedRtpCapabilities.js +6 -13
  30. package/node/lib/test/test-Consumer.js +1 -13
  31. package/node/lib/test/test-DataConsumer.js +9 -0
  32. package/node/lib/test/test-DataProducer.js +38 -0
  33. package/node/lib/test/test-PipeTransport.js +27 -29
  34. package/node/lib/test/test-Producer.js +97 -0
  35. package/node/lib/test/test-ortc.js +34 -14
  36. package/package.json +10 -10
  37. package/worker/fbs/rtpParameters.fbs +0 -1
  38. package/worker/fuzzer/src/FuzzerUtils.cpp +5 -3
  39. package/worker/fuzzer/src/RTC/RTP/FuzzerPacket.cpp +16 -2
  40. package/worker/include/DepLibUV.hpp +13 -0
  41. package/worker/include/RTC/BWE/AlrDetector.hpp +97 -0
  42. package/worker/include/RTC/BWE/BitrateProber.hpp +217 -0
  43. package/worker/include/RTC/BWE/{Utils.hpp → BitrateUtils.hpp} +3 -3
  44. package/worker/include/RTC/BWE/BweTypes.hpp +170 -2
  45. package/worker/include/RTC/BWE/FeedbackAdapter.hpp +0 -14
  46. package/worker/include/RTC/BWE/InterArrival.hpp +117 -0
  47. package/worker/include/RTC/BWE/IntervalBudget.hpp +81 -0
  48. package/worker/include/RTC/BWE/LossBasedController.hpp +105 -0
  49. package/worker/include/RTC/BWE/OveruseDetector.hpp +71 -0
  50. package/worker/include/RTC/BWE/OveruseEstimator.hpp +115 -0
  51. package/worker/include/RTC/BWE/ProbeBitrateEstimator.hpp +84 -0
  52. package/worker/include/RTC/BWE/ProbeController.hpp +379 -0
  53. package/worker/include/RTC/BWE/ProbePacketGenerator.hpp +130 -0
  54. package/worker/include/RTC/BWE/ProbingScheduler.hpp +187 -0
  55. package/worker/include/RTC/BWE/RembGenerator.hpp +96 -0
  56. package/worker/include/RTC/BWE/RemoteBitrateEstimatorAbsSendTime.hpp +237 -0
  57. package/worker/include/RTC/BWE/RobustThroughputEstimator.hpp +26 -0
  58. package/worker/include/RTC/BWE/SendPacketHistory.hpp +161 -25
  59. package/worker/include/RTC/BWE/TransportWideCcFeedbackGenerator.hpp +146 -0
  60. package/worker/include/RTC/BWE/TrendlineEstimator.hpp +15 -0
  61. package/worker/include/RTC/Consts.hpp +70 -0
  62. package/worker/include/RTC/DataConsumer.hpp +3 -5
  63. package/worker/include/RTC/DirectTransport.hpp +4 -5
  64. package/worker/include/RTC/PipeTransport.hpp +4 -5
  65. package/worker/include/RTC/PlainTransport.hpp +4 -5
  66. package/worker/include/RTC/RTCP/FeedbackPsRemb.hpp +6 -7
  67. package/worker/include/RTC/RTCP/FeedbackRtpTransport.hpp +3 -1
  68. package/worker/include/RTC/RTP/Codecs/Tools.hpp +1 -1
  69. package/worker/include/RTC/RTP/HeaderExtensionIds.hpp +0 -1
  70. package/worker/include/RTC/RTP/Packet.hpp +16 -4
  71. package/worker/include/RTC/RTP/ProbationGenerator.hpp +0 -8
  72. package/worker/include/RTC/RTP/RtpStream.hpp +12 -9
  73. package/worker/include/RTC/RTP/RtpStreamRecv.hpp +22 -4
  74. package/worker/include/RTC/RTP/RtpStreamSend.hpp +4 -2
  75. package/worker/include/RTC/RTP/RtxStream.hpp +10 -4
  76. package/worker/include/RTC/RateCalculator.hpp +103 -24
  77. package/worker/include/RTC/RemoteCaptureTimeEstimator.hpp +33 -3
  78. package/worker/include/RTC/{RtcLogger.hpp → RtcLogger/RtpPacket.hpp} +5 -3
  79. package/worker/include/RTC/RtcLogger/SendBurst.hpp +88 -0
  80. package/worker/include/RTC/RtpDictionaries.hpp +3 -4
  81. package/worker/include/RTC/SCTP/association/Association.hpp +1 -1
  82. package/worker/include/RTC/SCTP/public/AssociationMetrics.hpp +0 -1
  83. package/worker/include/RTC/SCTP/public/SctpTypes.hpp +4 -4
  84. package/worker/include/RTC/SCTP/rx/DataTracker.hpp +1 -1
  85. package/worker/include/RTC/SCTP/rx/ReassemblyQueue.hpp +1 -1
  86. package/worker/include/RTC/SctpDictionaries.hpp +2 -2
  87. package/worker/include/RTC/TcpConnection.hpp +2 -1
  88. package/worker/include/RTC/Transport.hpp +23 -8
  89. package/worker/include/RTC/TransportTuple.hpp +61 -6
  90. package/worker/include/RTC/WebRtcTransport.hpp +4 -5
  91. package/worker/include/Shared.hpp +5 -0
  92. package/worker/include/SharedInterface.hpp +10 -0
  93. package/worker/include/Utils.hpp +72 -3
  94. package/worker/include/common.hpp +12 -4
  95. package/worker/include/handles/SendCallbacks.hpp +34 -0
  96. package/worker/include/handles/TcpConnectionHandle.hpp +4 -12
  97. package/worker/include/handles/UdpSocketHandle.hpp +4 -8
  98. package/worker/meson.build +41 -3
  99. package/worker/meson_options.txt +1 -0
  100. package/worker/mocks/include/MockShared.hpp +16 -2
  101. package/worker/mocks/include/handles/MockBackoffTimerHandle.hpp +1 -1
  102. package/worker/scripts/package-lock.json +6 -6
  103. package/worker/src/RTC/BWE/AimdRateControl.cpp +4 -5
  104. package/worker/src/RTC/BWE/AlrDetector.cpp +80 -0
  105. package/worker/src/RTC/BWE/BitrateProber.cpp +256 -0
  106. package/worker/src/RTC/BWE/{Utils.cpp → BitrateUtils.cpp} +4 -4
  107. package/worker/src/RTC/BWE/DelayBasedBwe.cpp +2 -2
  108. package/worker/src/RTC/BWE/FeedbackAdapter.cpp +20 -37
  109. package/worker/src/RTC/BWE/InterArrival.cpp +216 -0
  110. package/worker/src/RTC/BWE/IntervalBudget.cpp +93 -0
  111. package/worker/src/RTC/BWE/LossBasedController.cpp +189 -41
  112. package/worker/src/RTC/BWE/OveruseDetector.cpp +128 -0
  113. package/worker/src/RTC/BWE/OveruseEstimator.cpp +166 -0
  114. package/worker/src/RTC/BWE/ProbeBitrateEstimator.cpp +222 -0
  115. package/worker/src/RTC/BWE/ProbeController.cpp +645 -0
  116. package/worker/src/RTC/BWE/ProbePacketGenerator.cpp +140 -0
  117. package/worker/src/RTC/BWE/ProbingScheduler.cpp +196 -0
  118. package/worker/src/RTC/BWE/RembGenerator.cpp +169 -0
  119. package/worker/src/RTC/BWE/RemoteBitrateEstimatorAbsSendTime.cpp +497 -0
  120. package/worker/src/RTC/BWE/RobustThroughputEstimator.cpp +47 -0
  121. package/worker/src/RTC/BWE/SendPacketHistory.cpp +173 -50
  122. package/worker/src/RTC/BWE/TargetRateController.cpp +12 -14
  123. package/worker/src/RTC/BWE/TransportWideCcFeedbackGenerator.cpp +377 -0
  124. package/worker/src/RTC/BWE/TrendlineEstimator.cpp +19 -0
  125. package/worker/src/RTC/Consumer.cpp +7 -5
  126. package/worker/src/RTC/DataConsumer.cpp +8 -10
  127. package/worker/src/RTC/DirectTransport.cpp +14 -8
  128. package/worker/src/RTC/DtlsTransport.cpp +8 -8
  129. package/worker/src/RTC/ICE/IceCandidate.cpp +4 -4
  130. package/worker/src/RTC/ICE/IceServer.cpp +1 -1
  131. package/worker/src/RTC/PipeTransport.cpp +13 -8
  132. package/worker/src/RTC/PlainTransport.cpp +13 -8
  133. package/worker/src/RTC/Producer.cpp +14 -31
  134. package/worker/src/RTC/RTCP/Bye.cpp +1 -1
  135. package/worker/src/RTC/RTCP/FeedbackPsRemb.cpp +18 -0
  136. package/worker/src/RTC/RTCP/FeedbackPsRpsi.cpp +2 -2
  137. package/worker/src/RTC/RTCP/FeedbackPsVbcm.cpp +2 -1
  138. package/worker/src/RTC/RTCP/FeedbackRtpTransport.cpp +2 -2
  139. package/worker/src/RTC/RTCP/Sdes.cpp +1 -1
  140. package/worker/src/RTC/RTP/Codecs/DependencyDescriptor.cpp +2 -1
  141. package/worker/src/RTC/RTP/Packet.cpp +26 -11
  142. package/worker/src/RTC/RTP/ProbationGenerator.cpp +5 -6
  143. package/worker/src/RTC/RTP/RtpStream.cpp +1 -1
  144. package/worker/src/RTC/RTP/RtpStreamRecv.cpp +69 -48
  145. package/worker/src/RTC/RTP/RtpStreamSend.cpp +31 -31
  146. package/worker/src/RTC/RTP/RtxStream.cpp +22 -7
  147. package/worker/src/RTC/RateCalculator.cpp +133 -28
  148. package/worker/src/RTC/RemoteCaptureTimeEstimator.cpp +56 -1
  149. package/worker/src/RTC/{RtcLogger.cpp → RtcLogger/RtpPacket.cpp} +2 -2
  150. package/worker/src/RTC/RtcLogger/SendBurst.cpp +124 -0
  151. package/worker/src/RTC/RtpDictionaries/RtpHeaderExtensionUri.cpp +2 -12
  152. package/worker/src/RTC/RtpDictionaries/RtpParameters.cpp +1 -1
  153. package/worker/src/RTC/SCTP/association/Association.cpp +1 -1
  154. package/worker/src/RTC/SCTP/rx/InterleavedReassemblyStreams.cpp +3 -3
  155. package/worker/src/RTC/SCTP/rx/ReassemblyQueue.cpp +2 -1
  156. package/worker/src/RTC/SCTP/rx/TraditionalReassemblyStreams.cpp +4 -4
  157. package/worker/src/RTC/SCTP/tx/RetransmissionTimeout.cpp +4 -4
  158. package/worker/src/RTC/SctpDictionaries/SctpStreamParameters.cpp +6 -10
  159. package/worker/src/RTC/SimulcastProducerStreamManager.cpp +2 -2
  160. package/worker/src/RTC/SrtpSession.cpp +2 -2
  161. package/worker/src/RTC/SvcProducerStreamManager.cpp +2 -2
  162. package/worker/src/RTC/TcpConnection.cpp +2 -2
  163. package/worker/src/RTC/Transport.cpp +111 -93
  164. package/worker/src/RTC/TransportTuple.cpp +4 -4
  165. package/worker/src/RTC/WebRtcServer.cpp +4 -3
  166. package/worker/src/RTC/WebRtcTransport.cpp +20 -13
  167. package/worker/src/Utils/BitStream.cpp +24 -0
  168. package/worker/src/handles/BackoffTimerHandle.cpp +1 -1
  169. package/worker/src/handles/TcpConnectionHandle.cpp +13 -23
  170. package/worker/src/handles/UdpSocketHandle.cpp +14 -21
  171. package/worker/test/include/RTC/BWE/helpers/LinkSimulator.hpp +68 -14
  172. package/worker/test/include/RTC/BWE/helpers/RemoteBitrateEstimatorAbsSendTimeTestHelper.hpp +125 -0
  173. package/worker/test/src/RTC/BWE/TestAlrDetector.cpp +110 -0
  174. package/worker/test/src/RTC/BWE/TestBitrateProber.cpp +418 -0
  175. package/worker/test/src/RTC/BWE/TestBitrateUtils.cpp +61 -0
  176. package/worker/test/src/RTC/BWE/TestDelayBasedBwe.cpp +4 -4
  177. package/worker/test/src/RTC/BWE/TestFeedbackAdapter.cpp +53 -37
  178. package/worker/test/src/RTC/BWE/TestInterArrival.cpp +643 -0
  179. package/worker/test/src/RTC/BWE/TestIntervalBudget.cpp +130 -0
  180. package/worker/test/src/RTC/BWE/TestOveruseDetector.cpp +519 -0
  181. package/worker/test/src/RTC/BWE/TestProbeBitrateEstimator.cpp +266 -0
  182. package/worker/test/src/RTC/BWE/TestProbeController.cpp +1682 -0
  183. package/worker/test/src/RTC/BWE/TestProbePacketGenerator.cpp +265 -0
  184. package/worker/test/src/RTC/BWE/TestProbingScheduler.cpp +260 -0
  185. package/worker/test/src/RTC/BWE/TestRembGenerator.cpp +285 -0
  186. package/worker/test/src/RTC/BWE/TestRemoteBitrateEstimatorAbsSendTime.cpp +414 -0
  187. package/worker/test/src/RTC/BWE/TestSendPacketHistory.cpp +296 -77
  188. package/worker/test/src/RTC/BWE/TestTransportWideCcFeedbackGenerator.cpp +578 -0
  189. package/worker/test/src/RTC/BWE/helpers/LinkSimulator.cpp +133 -29
  190. package/worker/test/src/RTC/BWE/helpers/RemoteBitrateEstimatorAbsSendTimeTestHelper.cpp +625 -0
  191. package/worker/test/src/RTC/RTCP/TestFeedbackPsRemb.cpp +19 -0
  192. package/worker/test/src/RTC/RTP/TestPacket.cpp +58 -4
  193. package/worker/test/src/RTC/RTP/TestProbationGenerator.cpp +3 -2
  194. package/worker/test/src/RTC/RTP/TestRtpStreamRecv.cpp +50 -0
  195. package/worker/test/src/RTC/RTP/TestRtpStreamSend.cpp +59 -0
  196. package/worker/test/src/RTC/TestRateCalculator.cpp +322 -60
  197. package/worker/test/src/RTC/TestRemoteCaptureTimeEstimator.cpp +95 -7
  198. package/worker/test/src/RTC/TestSimpleProducerStreamManager.cpp +34 -16
  199. package/worker/test/src/RTC/TestSimulcastProducerStreamManager.cpp +31 -13
  200. package/worker/test/src/RTC/TestSvcProducerStreamManager.cpp +37 -19
  201. package/worker/test/src/RTC/TestTransportCongestionControlServer.cpp +10 -10
  202. package/worker/test/src/Utils/TestTime.cpp +120 -21
  203. package/worker/test/src/RTC/BWE/TestUtils.cpp +0 -61
@@ -1475,7 +1475,7 @@ SCENARIO("RTP Packet", "[serializable][rtp][packet]")
1475
1475
  // Requires Two-Bytes type extensions due to length > 16.
1476
1476
  extensions.assign(
1477
1477
  {
1478
- { RTC::RtpHeaderExtensionUri::Type::TIME_OFFSET, 1, 17, rtpCommon::DataBuffer }
1478
+ { RTC::RtpHeaderExtensionUri::Type::ABS_CAPTURE_TIME, 1, 17, rtpCommon::DataBuffer }
1479
1479
  });
1480
1480
  packet->SetExtensions(RTC::RTP::Packet::ExtensionsType::Auto, extensions);
1481
1481
  REQUIRE(packet->HasTwoBytesExtensions());
@@ -1488,15 +1488,19 @@ SCENARIO("RTP Packet", "[serializable][rtp][packet]")
1488
1488
 
1489
1489
  std::vector<RTC::RTP::Packet::Extension> extensions;
1490
1490
 
1491
+ const uint32_t absSendtime{ 12345678 };
1492
+ const uint16_t wideSeqNumber{ 5555 };
1493
+ const uint64_t absCaptureTimestamp{ 0x83AA7E8000000000 };
1494
+
1491
1495
  std::string mid{ "mid-€1" };
1492
1496
  std::string rid{ "r1-ß" };
1493
- uint32_t absSendtime{ 12345678 };
1494
- uint16_t wideSeqNumber{ 5555 };
1495
1497
  uint8_t absSendtimeValue[100]{};
1496
1498
  uint8_t wideSeqNumberValue[100]{};
1499
+ uint8_t absCaptureTimeValue[100]{};
1497
1500
 
1498
1501
  Utils::Byte::Set3Bytes(absSendtimeValue, 0, absSendtime);
1499
1502
  Utils::Byte::Set2Bytes(wideSeqNumberValue, 0, wideSeqNumber);
1503
+ Utils::Byte::Set8Bytes(absCaptureTimeValue, 0, absCaptureTimestamp);
1500
1504
 
1501
1505
  // clang-format off
1502
1506
  extensions.assign(
@@ -1524,6 +1528,12 @@ SCENARIO("RTP Packet", "[serializable][rtp][packet]")
1524
1528
  4,
1525
1529
  2,
1526
1530
  wideSeqNumberValue
1531
+ },
1532
+ {
1533
+ RTC::RtpHeaderExtensionUri::Type::ABS_CAPTURE_TIME,
1534
+ 5,
1535
+ 8,
1536
+ absCaptureTimeValue
1527
1537
  }
1528
1538
  }
1529
1539
  );
@@ -1537,6 +1547,8 @@ SCENARIO("RTP Packet", "[serializable][rtp][packet]")
1537
1547
  std::string readRid;
1538
1548
  uint32_t readAbsSendtime;
1539
1549
  uint16_t readWideSeqNumber;
1550
+ uint64_t readAbsCaptureTimestamp;
1551
+ int64_t readEstimatedCaptureClockOffset;
1540
1552
 
1541
1553
  REQUIRE(packet->ReadMid(readMid));
1542
1554
  REQUIRE(readMid == mid);
@@ -1546,14 +1558,18 @@ SCENARIO("RTP Packet", "[serializable][rtp][packet]")
1546
1558
  REQUIRE(readAbsSendtime == absSendtime);
1547
1559
  REQUIRE(packet->ReadTransportWideCc01(readWideSeqNumber));
1548
1560
  REQUIRE(readWideSeqNumber == wideSeqNumber);
1561
+ REQUIRE(packet->ReadAbsCaptureTime(readAbsCaptureTimestamp, readEstimatedCaptureClockOffset));
1562
+ REQUIRE(readAbsCaptureTimestamp == absCaptureTimestamp);
1549
1563
 
1550
1564
  const std::string newMid{ "mid-®2" };
1551
1565
  const int64_t newAbsSendtimeUs{ 999999250 };
1552
1566
  const uint16_t newWideSeqNumber{ 5556 };
1567
+ const uint64_t newAbsCaptureTimestamp{ 0x83AA7E8100000000 };
1553
1568
 
1554
1569
  REQUIRE(packet->UpdateMid(newMid));
1555
- REQUIRE(packet->UpdateAbsSendTime(newAbsSendtimeUs));
1570
+ REQUIRE(packet->UpdateAbsSendTime(Utils::Time::TimeUsToAbsSendTime(newAbsSendtimeUs)));
1556
1571
  REQUIRE(packet->UpdateTransportWideCc01(newWideSeqNumber));
1572
+ REQUIRE(packet->UpdateAbsCaptureTime(newAbsCaptureTimestamp));
1557
1573
 
1558
1574
  REQUIRE(packet->ReadMid(readMid));
1559
1575
  REQUIRE(readMid == newMid);
@@ -1563,6 +1579,8 @@ SCENARIO("RTP Packet", "[serializable][rtp][packet]")
1563
1579
  REQUIRE(readAbsSendtime == Utils::Time::TimeUsToAbsSendTime(newAbsSendtimeUs));
1564
1580
  REQUIRE(packet->ReadTransportWideCc01(readWideSeqNumber));
1565
1581
  REQUIRE(readWideSeqNumber == newWideSeqNumber);
1582
+ REQUIRE(packet->ReadAbsCaptureTime(readAbsCaptureTimestamp, readEstimatedCaptureClockOffset));
1583
+ REQUIRE(readAbsCaptureTimestamp == newAbsCaptureTimestamp);
1566
1584
 
1567
1585
  std::unique_ptr<RTC::RTP::Packet> packet2{ RTC::RTP::Packet::Parse(
1568
1586
  packet->GetBuffer(), packet->GetLength()) };
@@ -2168,6 +2186,42 @@ SCENARIO("RTP Packet", "[serializable][rtp][packet]")
2168
2186
  REQUIRE(packet->IsPaddedTo4Bytes() == false);
2169
2187
  }
2170
2188
 
2189
+ SECTION("Packet::RtxEncode() does not write beyond the new packet length")
2190
+ {
2191
+ std::unique_ptr<RTC::RTP::Packet> packet{ RTC::RTP::Packet::Factory(
2192
+ rtpCommon::FactoryBuffer, sizeof(rtpCommon::FactoryBuffer)) };
2193
+
2194
+ // clang-format off
2195
+ uint8_t payload[] =
2196
+ {
2197
+ 0x11, 0x22, 0x33, 0x44,
2198
+ 0x55, 0x66, 0x77, 0x88,
2199
+ 0x99, 0xAA
2200
+ };
2201
+ // clang-format on
2202
+
2203
+ packet->SetPayload(payload, 10);
2204
+
2205
+ const auto length = packet->GetLength();
2206
+
2207
+ REQUIRE(length == RTC::RTP::Packet::FixedHeaderMinLength + 10);
2208
+
2209
+ // Bytes that will belong to the packet once RTX encoded, and canary bytes
2210
+ // right after them.
2211
+ rtpCommon::FactoryBuffer[length] = 0x55;
2212
+ rtpCommon::FactoryBuffer[length + 1] = 0x55;
2213
+ rtpCommon::FactoryBuffer[length + 2] = 0xEE;
2214
+ rtpCommon::FactoryBuffer[length + 3] = 0xEE;
2215
+
2216
+ packet->RtxEncode(/*payloadType*/ 111, /*ssrc*/ 999999, /*seq*/ 666);
2217
+
2218
+ REQUIRE(packet->GetLength() == length + 2);
2219
+ REQUIRE(packet->GetPayloadLength() == 12);
2220
+ REQUIRE(rtpCommon::FactoryBuffer[length + 2] == 0xEE);
2221
+ REQUIRE(rtpCommon::FactoryBuffer[length + 3] == 0xEE);
2222
+ REQUIRE(std::memcmp(packet->GetPayload() + 2, payload, 10) == 0);
2223
+ }
2224
+
2171
2225
  SECTION("Packet::SetBufferReleasedListener() when Packet is destroyed succeeds")
2172
2226
  {
2173
2227
  std::unique_ptr<RTC::RTP::Packet> packet{ RTC::RTP::Packet::Factory(
@@ -1,4 +1,5 @@
1
1
  #include "common.hpp"
2
+ #include "RTC/Consts.hpp"
2
3
  #include "RTC/RTP/ProbationGenerator.hpp"
3
4
  #include <catch2/catch_test_macros.hpp>
4
5
 
@@ -11,8 +12,8 @@ SCENARIO("RTP ProbationGenerator", "[rtp][probation-generator]")
11
12
  const auto* packet = probationGenerator.GetNextPacket(1000);
12
13
  const auto seq = packet->GetSequenceNumber();
13
14
 
14
- REQUIRE(packet->GetSsrc() == RTC::RTP::ProbationGenerator::Ssrc);
15
- REQUIRE(packet->GetPayloadType() == RTC::RTP::ProbationGenerator::PayloadType);
15
+ REQUIRE(packet->GetSsrc() == RTC::Consts::BweProbeRtpSsrc);
16
+ REQUIRE(packet->GetPayloadType() == RTC::Consts::BweProbeRtpPayloadType);
16
17
  REQUIRE(packet->GetLength() == 1000);
17
18
  REQUIRE(packet->IsPaddedTo4Bytes());
18
19
 
@@ -1,6 +1,7 @@
1
1
  #include "common.hpp"
2
2
  #include "RTC/RTCP/FeedbackPs.hpp"
3
3
  #include "RTC/RTCP/FeedbackRtpNack.hpp"
4
+ #include "RTC/RTCP/XrDelaySinceLastRr.hpp"
4
5
  #include "RTC/RTP/Packet.hpp"
5
6
  #include "RTC/RTP/RtpStream.hpp"
6
7
  #include "RTC/RTP/RtpStreamRecv.hpp"
@@ -243,6 +244,55 @@ SCENARIO("RtpStreamRecv", "[rtp][rtpstream][rtpstreamrecv]")
243
244
  listener.nackedSeqNumbers.clear();
244
245
  }
245
246
 
247
+ SECTION("RTT is computed from Extended Reports")
248
+ {
249
+ RtpStreamRecvListener listener;
250
+ RTC::RTP::RtpStreamRecv rtpStream(
251
+ std::addressof(listener), std::addressof(shared), params, SendNackDelay, UseRtpInactivityCheck);
252
+
253
+ auto receiveDelaySinceLastRr = [&](int64_t receivedAtUs, uint32_t lastRr, uint32_t dlrr)
254
+ {
255
+ RTC::RTCP::DelaySinceLastRr::SsrcInfo ssrcInfo;
256
+
257
+ ssrcInfo.SetSsrc(params.ssrc);
258
+ ssrcInfo.SetLastReceiverReport(lastRr);
259
+ ssrcInfo.SetDelaySinceLastReceiverReport(dlrr);
260
+
261
+ rtpStream.ReceiveRtcpXrDelaySinceLastRr(std::addressof(ssrcInfo), receivedAtUs);
262
+ };
263
+
264
+ // The compact NTP representation has 16 bits of seconds, so it wraps around
265
+ // every 65536 seconds.
266
+ constexpr int64_t WrapUs{ 65536 * 1000000LL };
267
+
268
+ // The Receiver Reference Time is sent 1 second before the wrap, the remote
269
+ // endpoint holds it for half a second, and its answer arrives right at the wrap.
270
+ receiveDelaySinceLastRr(WrapUs, 0xFFFF0000, 0x8000);
271
+
272
+ REQUIRE(rtpStream.GetRttMs() == 500.0f);
273
+
274
+ // No Receiver Reference Time was received by the remote endpoint yet, so the
275
+ // last RTT is kept.
276
+ receiveDelaySinceLastRr(WrapUs, 0, 0);
277
+
278
+ REQUIRE(rtpStream.GetRttMs() == 500.0f);
279
+
280
+ // The remote endpoint answers the Receiver Reference Time right away.
281
+ receiveDelaySinceLastRr((10 * 1000000) + 500000, 0x000A0000, 0);
282
+
283
+ REQUIRE(rtpStream.GetRttMs() == 500.0f);
284
+
285
+ // A negative RTT yields 1 millisecond.
286
+ receiveDelaySinceLastRr(20 * 1000000, 0x00140000, 0x8000);
287
+
288
+ REQUIRE(rtpStream.GetRttMs() == 1.0f);
289
+
290
+ // So does a RTT too small to be true.
291
+ receiveDelaySinceLastRr(20 * 1000000, 0x0013FFFF, 0);
292
+
293
+ REQUIRE(rtpStream.GetRttMs() == 1.0f);
294
+ }
295
+
246
296
  SECTION("require key frame")
247
297
  {
248
298
  RtpStreamRecvListener listener;
@@ -1,5 +1,6 @@
1
1
  #include "common.hpp"
2
2
  #include "RTC/RTCP/FeedbackRtpNack.hpp"
3
+ #include "RTC/RTCP/ReceiverReport.hpp"
3
4
  #include "RTC/RTCP/SenderReport.hpp"
4
5
  #include "RTC/RTP/Codecs/AV1.hpp"
5
6
  #include "RTC/RTP/Codecs/PayloadDescriptorHandler.hpp"
@@ -1244,6 +1245,64 @@ SCENARIO("RtpStreamSend", "[rtp][rtcp][nack][rtpstream][rtpstreamsend]")
1244
1245
  REQUIRE_FALSE(staleReport);
1245
1246
  }
1246
1247
 
1248
+ SECTION("RTT is computed from Receiver Reports")
1249
+ {
1250
+ TestRtpStreamListener testRtpStreamListener;
1251
+
1252
+ RTC::RTP::RtpStream::Params params;
1253
+
1254
+ params.ssrc = 1111;
1255
+ params.clockRate = 90000;
1256
+ params.mimeType.type = RTC::RtpCodecMimeType::Type::VIDEO;
1257
+
1258
+ std::string mid;
1259
+
1260
+ RTC::RTP::RtpStreamSend stream(
1261
+ std::addressof(testRtpStreamListener), std::addressof(shared), params, mid);
1262
+
1263
+ auto receiveReceiverReport = [&](int64_t receivedAtUs, uint32_t lastSr, uint32_t dlsr)
1264
+ {
1265
+ RTC::RTCP::ReceiverReport report;
1266
+
1267
+ report.SetSsrc(params.ssrc);
1268
+ report.SetLastSenderReport(lastSr);
1269
+ report.SetDelaySinceLastSenderReport(dlsr);
1270
+
1271
+ stream.ReceiveRtcpReceiverReport(std::addressof(report), receivedAtUs);
1272
+ };
1273
+
1274
+ // The compact NTP representation has 16 bits of seconds, so it wraps around
1275
+ // every 65536 seconds.
1276
+ constexpr int64_t WrapUs{ 65536 * 1000000LL };
1277
+
1278
+ // The Sender Report is sent 1 second before the wrap, the remote endpoint holds
1279
+ // it for half a second, and the Receiver Report arrives right at the wrap.
1280
+ receiveReceiverReport(WrapUs, 0xFFFF0000, 0x8000);
1281
+
1282
+ REQUIRE(stream.GetRttMs() == 500.0f);
1283
+
1284
+ // No Sender Report was received by the remote endpoint yet, so the last RTT is
1285
+ // kept.
1286
+ receiveReceiverReport(WrapUs, 0, 0);
1287
+
1288
+ REQUIRE(stream.GetRttMs() == 500.0f);
1289
+
1290
+ // The remote endpoint answers the Sender Report right away.
1291
+ receiveReceiverReport((10 * 1000000) + 500000, 0x000A0000, 0);
1292
+
1293
+ REQUIRE(stream.GetRttMs() == 500.0f);
1294
+
1295
+ // A negative RTT yields 1 millisecond.
1296
+ receiveReceiverReport(20 * 1000000, 0x00140000, 0x8000);
1297
+
1298
+ REQUIRE(stream.GetRttMs() == 1.0f);
1299
+
1300
+ // So does a RTT too small to be true.
1301
+ receiveReceiverReport(20 * 1000000, 0x0013FFFF, 0);
1302
+
1303
+ REQUIRE(stream.GetRttMs() == 1.0f);
1304
+ }
1305
+
1247
1306
  #ifdef PERFORMANCE_TEST
1248
1307
  SECTION("Performance")
1249
1308
  {