in RtcpTransceiver support replying to RRTR per local ssrc

to support clients (e.g. RTCPReceiver) that collect and report RTT per sender ssrc.

Bug: webrtc:8239, webrtc:13853
Change-Id: I907fb35277b0f23bbe9f2cd2ef979ce0fb1f9338
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/257440
Reviewed-by: Emil Lundmark <lndmrk@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36439}
This commit is contained in:
Danil Chapovalov
2022-04-04 13:28:08 +02:00
committed by WebRTC LUCI CQ
parent ca32793187
commit ba1b56adf6
4 changed files with 131 additions and 56 deletions

View File

@ -1387,6 +1387,68 @@ TEST(RtcpTransceiverImplTest, RepliesToRrtrWhenEnabled) {
/*delay=*/kComactNtpOneSecond / 2)));
}
TEST(RtcpTransceiverImplTest, CanReplyToRrtrOnceForAllLocalSsrcs) {
static constexpr uint32_t kRemoteSsrc = 4321;
static constexpr uint32_t kLocalSsrcs[] = {1234, 5678};
SimulatedClock clock(0);
RtcpTransceiverConfig config = DefaultTestConfig();
config.clock = &clock;
config.reply_to_non_sender_rtt_measurement = true;
config.reply_to_non_sender_rtt_mesaurments_on_all_ssrcs = false;
RtcpPacketParser rtcp_parser;
RtcpParserTransport transport(&rtcp_parser);
config.outgoing_transport = &transport;
RtcpTransceiverImpl rtcp_transceiver(config);
MockRtpStreamRtcpHandler local_sender0;
MockRtpStreamRtcpHandler local_sender1;
rtcp_transceiver.AddMediaSender(kLocalSsrcs[0], &local_sender0);
rtcp_transceiver.AddMediaSender(kLocalSsrcs[1], &local_sender1);
rtcp::ExtendedReports xr;
rtcp::Rrtr rrtr;
rrtr.SetNtp(NtpTime(uint64_t{0x1111'2222'3333'4444}));
xr.SetRrtr(rrtr);
xr.SetSenderSsrc(kRemoteSsrc);
rtcp_transceiver.ReceivePacket(xr.Build(), clock.CurrentTime());
clock.AdvanceTime(TimeDelta::Millis(1'500));
rtcp_transceiver.SendCompoundPacket();
EXPECT_EQ(rtcp_parser.xr()->num_packets(), 1);
}
TEST(RtcpTransceiverImplTest, CanReplyToRrtrForEachLocalSsrc) {
static constexpr uint32_t kRemoteSsrc = 4321;
static constexpr uint32_t kLocalSsrc[] = {1234, 5678};
SimulatedClock clock(0);
RtcpTransceiverConfig config = DefaultTestConfig();
config.clock = &clock;
config.reply_to_non_sender_rtt_measurement = true;
config.reply_to_non_sender_rtt_mesaurments_on_all_ssrcs = true;
RtcpPacketParser rtcp_parser;
RtcpParserTransport transport(&rtcp_parser);
config.outgoing_transport = &transport;
RtcpTransceiverImpl rtcp_transceiver(config);
MockRtpStreamRtcpHandler local_sender0;
MockRtpStreamRtcpHandler local_sender1;
rtcp_transceiver.AddMediaSender(kLocalSsrc[0], &local_sender0);
rtcp_transceiver.AddMediaSender(kLocalSsrc[1], &local_sender1);
rtcp::ExtendedReports xr;
rtcp::Rrtr rrtr;
rrtr.SetNtp(NtpTime(uint64_t{0x1111'2222'3333'4444}));
xr.SetRrtr(rrtr);
xr.SetSenderSsrc(kRemoteSsrc);
rtcp_transceiver.ReceivePacket(xr.Build(), clock.CurrentTime());
clock.AdvanceTime(TimeDelta::Millis(1'500));
rtcp_transceiver.SendCompoundPacket();
EXPECT_EQ(rtcp_parser.xr()->num_packets(), 2);
}
TEST(RtcpTransceiverImplTest, SendsNoXrRrtrWhenDisabled) {
SimulatedClock clock(0);
RtcpTransceiverConfig config;