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;