From 720bc4df3d090e5c1ea43916f04bc8f78524907d Mon Sep 17 00:00:00 2001 From: philipel Date: Tue, 18 Oct 2022 08:51:17 +0200 Subject: [PATCH] Add --extend_run_time_duration flag to video_replay. Bug: webrtc:14508, webrtc:14103 Change-Id: I728388ff6a70bf42de87e6bbb0969df8ecc5a1b1 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/279641 Commit-Queue: Philip Eliasson Reviewed-by: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#38435} --- rtc_tools/video_replay.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/rtc_tools/video_replay.cc b/rtc_tools/video_replay.cc index 173439af12..b829ab519b 100644 --- a/rtc_tools/video_replay.cc +++ b/rtc_tools/video_replay.cc @@ -159,6 +159,13 @@ ABSL_FLAG(bool, disable_preview, false, "Disable decoded video preview."); ABSL_FLAG(bool, disable_decoding, false, "Disable video decoding."); +ABSL_FLAG(int, + extend_run_time_duration, + 0, + "Extends the run time of the receiving client after the last RTP " + "packet has been delivered. Typically useful to let the last few " + "frames be decoded and rendered. Duration given in seconds."); + namespace { bool ValidatePayloadType(int32_t payload_type) { return payload_type > 0 && payload_type <= 127; @@ -605,9 +612,10 @@ class RtpReplayer final { } } } - // One more call to SleepOrAdvanceTime is required to process the last + // Note that even when `extend_run_time_duration` is zero + // `SleepOrAdvanceTime` should still be called in order to process the last // delivered packet when running in simulated time. - SleepOrAdvanceTime(0); + SleepOrAdvanceTime(absl::GetFlag(FLAGS_extend_run_time_duration) * 1000); fprintf(stderr, "num_packets: %d\n", num_packets); @@ -672,6 +680,7 @@ int main(int argc, char* argv[]) { RTC_CHECK(ValidateRtpHeaderExtensionId( absl::GetFlag(FLAGS_transmission_offset_id))); RTC_CHECK(ValidateInputFilenameNotEmpty(absl::GetFlag(FLAGS_input_file))); + RTC_CHECK_GE(absl::GetFlag(FLAGS_extend_run_time_duration), 0); rtc::ThreadManager::Instance()->WrapCurrentThread(); webrtc::test::RunTest(webrtc::RtpReplay);