From da1c9e08acb2ab8c25bbb1bdfd301a7516421936 Mon Sep 17 00:00:00 2001 From: Philipp Hancke Date: Mon, 9 Dec 2024 09:33:27 -0800 Subject: [PATCH] video_replay: fix wait when using start_timestamp which should not wait for the amount of time between the initial packet (which is ignored) and the packet video_replay was told to start at. BUG=webrtc:382396709 Change-Id: Ic9c465cfa3e0ab66d9c2ff2e8e56a5bf419b8687 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/370712 Commit-Queue: Philipp Hancke Reviewed-by: Mirko Bonadei Reviewed-by: Sergey Silkin Reviewed-by: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#43750} --- rtc_tools/video_replay.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rtc_tools/video_replay.cc b/rtc_tools/video_replay.cc index a11f5692e5..b189bef2b8 100644 --- a/rtc_tools/video_replay.cc +++ b/rtc_tools/video_replay.cc @@ -590,10 +590,6 @@ class RtpReplayer final { while (true) { int64_t now_ms = CurrentTimeMs(); - if (replay_start_ms == -1) { - replay_start_ms = now_ms; - } - test::RtpPacket packet; if (!rtp_reader_->NextPacket(&packet)) { break; @@ -619,6 +615,9 @@ class RtpReplayer final { header.Timestamp() > stop_timestamp) { continue; } + if (replay_start_ms == -1) { + replay_start_ms = now_ms - packet.time_ms; + } int64_t deliver_in_ms = replay_start_ms + packet.time_ms - now_ms; SleepOrAdvanceTime(deliver_in_ms);