From 2f3b75d30d1664cd9b0c2c7285c1c31974147c3d Mon Sep 17 00:00:00 2001 From: philipel Date: Wed, 13 Mar 2024 13:02:15 +0100 Subject: [PATCH] Reset prev_unwrapped_timestamp_ in TimestampExtrapolator::Reset Bug: b/325916306 Change-Id: I7c52ed45d02c8e602670f5e8e345543fed4523f3 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/342860 Reviewed-by: Stefan Holmer Commit-Queue: Philip Eliasson Cr-Commit-Position: refs/heads/main@{#41897} --- .../timing/timestamp_extrapolator.cc | 1 + .../timing/timestamp_extrapolator_unittest.cc | 16 ++++++++++++++++ video/video_receive_stream2_unittest.cc | 3 ++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/modules/video_coding/timing/timestamp_extrapolator.cc b/modules/video_coding/timing/timestamp_extrapolator.cc index a90df8bf7f..cc7eff97ba 100644 --- a/modules/video_coding/timing/timestamp_extrapolator.cc +++ b/modules/video_coding/timing/timestamp_extrapolator.cc @@ -42,6 +42,7 @@ void TimestampExtrapolator::Reset(Timestamp start) { start_ = start; prev_ = start_; first_unwrapped_timestamp_ = absl::nullopt; + prev_unwrapped_timestamp_ = absl::nullopt; w_[0] = 90.0; w_[1] = 0; p_[0][0] = 1; diff --git a/modules/video_coding/timing/timestamp_extrapolator_unittest.cc b/modules/video_coding/timing/timestamp_extrapolator_unittest.cc index d6c8fa9de1..fa1e23a385 100644 --- a/modules/video_coding/timing/timestamp_extrapolator_unittest.cc +++ b/modules/video_coding/timing/timestamp_extrapolator_unittest.cc @@ -231,4 +231,20 @@ TEST(TimestampExtrapolatorTest, TimestampJump) { Optional(clock.CurrentTime())); } +TEST(TimestampExtrapolatorTest, GapInReceivedFrames) { + SimulatedClock clock( + Timestamp::Seconds(std::numeric_limits::max() / 90000 - 31)); + TimestampExtrapolator ts_extrapolator(clock.CurrentTime()); + + uint32_t rtp = std::numeric_limits::max(); + clock.AdvanceTime(k25FpsDelay); + ts_extrapolator.Update(clock.CurrentTime(), rtp); + + rtp += 30 * 90000; + clock.AdvanceTime(TimeDelta::Seconds(30)); + ts_extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_THAT(ts_extrapolator.ExtrapolateLocalTime(rtp), + Optional(clock.CurrentTime())); +} + } // namespace webrtc diff --git a/video/video_receive_stream2_unittest.cc b/video/video_receive_stream2_unittest.cc index 10b9d88324..f4802e45fa 100644 --- a/video/video_receive_stream2_unittest.cc +++ b/video/video_receive_stream2_unittest.cc @@ -1020,7 +1020,8 @@ TEST_P(VideoReceiveStream2Test, RtpTimestampWrapAround) { .Build()); EXPECT_CALL(mock_decoder_, Decode(test::RtpTimestamp(kWrapAroundRtp), _)) .Times(1); - EXPECT_THAT(fake_renderer_.WaitForFrame(TimeDelta::Zero()), RenderedFrame()); + EXPECT_THAT(fake_renderer_.WaitForFrame(TimeDelta::Seconds(1)), + RenderedFrame()); video_receive_stream_->Stop(); }