From 4abca6699def3d223bd95fe7e7cf111a9d074878 Mon Sep 17 00:00:00 2001 From: Per K Date: Thu, 19 Jan 2023 15:11:07 +0100 Subject: [PATCH] Ensure FakeNetwork propages arrival_time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:14833 Change-Id: I584524cca81e17ac91d581daab6030705ad68dac Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/291104 Reviewed-by: Erik Språng Commit-Queue: Erik Språng Auto-Submit: Per Kjellander Commit-Queue: Per Kjellander Cr-Commit-Position: refs/heads/main@{#39148} --- call/BUILD.gn | 1 + call/fake_network_pipe.h | 3 +++ call/fake_network_pipe_unittest.cc | 26 ++++++++++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/call/BUILD.gn b/call/BUILD.gn index fd4b1119fd..f4c3295ff5 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -670,6 +670,7 @@ if (rtc_include_tests) { "../api:simulated_network_api", "../api/units:data_rate", "../api/units:time_delta", + "../api/units:timestamp", "../modules/rtp_rtcp:rtp_rtcp_format", "../rtc_base:checks", "../system_wrappers", diff --git a/call/fake_network_pipe.h b/call/fake_network_pipe.h index 198615cb79..2649a00904 100644 --- a/call/fake_network_pipe.h +++ b/call/fake_network_pipe.h @@ -70,6 +70,9 @@ class NetworkPacket { bool is_rtcp() const { return is_rtcp_; } MediaType media_type() const { return media_type_; } absl::optional packet_time_us() const { return packet_time_us_; } + RtpPacketReceived* packet_received() { + return packet_received_ ? &packet_received_.value() : nullptr; + } absl::optional packet_received() const { return packet_received_; } diff --git a/call/fake_network_pipe_unittest.cc b/call/fake_network_pipe_unittest.cc index 9c4e6d926f..d3f7734893 100644 --- a/call/fake_network_pipe_unittest.cc +++ b/call/fake_network_pipe_unittest.cc @@ -13,6 +13,8 @@ #include #include +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "call/simulated_network.h" #include "modules/rtp_rtcp/include/rtp_header_extension_map.h" #include "modules/rtp_rtcp/source/rtp_header_extensions.h" @@ -441,6 +443,30 @@ TEST_F(FakeNetworkPipeTest, SetReceiver) { pipe->Process(); } +TEST_F(FakeNetworkPipeTest, DeliverRtpPacketSetsCorrectArrivalTime) { + BuiltInNetworkBehaviorConfig config; + config.queue_delay_ms = 100; + MockReceiver receiver; + auto simulated_network = std::make_unique(config); + std::unique_ptr pipe(new FakeNetworkPipe( + &fake_clock_, std::move(simulated_network), &receiver)); + + Timestamp send_time = fake_clock_.CurrentTime(); + RtpPacketReceived packet(nullptr, send_time); + packet.SetExtension(123); + pipe->DeliverRtpPacket(MediaType::VIDEO, std::move(packet), + [](const RtpPacketReceived&) { return false; }); + + // Advance the network delay to get the first packet. + fake_clock_.AdvanceTimeMilliseconds(config.queue_delay_ms); + EXPECT_CALL(receiver, DeliverRtpPacket(MediaType::VIDEO, _, _)) + .WillOnce(WithArg<1>([&](RtpPacketReceived packet) { + EXPECT_EQ(packet.arrival_time(), + send_time + TimeDelta::Millis(config.queue_delay_ms)); + })); + pipe->Process(); +} + TEST_F(FakeNetworkPipeTest, DeliverRtpPacketPropagatesExtensions) { BuiltInNetworkBehaviorConfig config; config.queue_delay_ms = 100;