From db0cf7624e8b7782e8b0864f9e01925ecdc3027d Mon Sep 17 00:00:00 2001 From: pbos Date: Thu, 2 Jul 2015 04:14:46 -0700 Subject: [PATCH] Add test for dropping repeated NTP timestamps. Regression test for enforcing that frames with repeated or old NTP timestamps are dropped. BUG=chromium:480953, webrtc:4615 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/1220193002 Cr-Commit-Position: refs/heads/master@{#9533} --- webrtc/video/video_capture_input_unittest.cc | 30 ++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/webrtc/video/video_capture_input_unittest.cc b/webrtc/video/video_capture_input_unittest.cc index cc4b5b08d..2ab7e51dc 100644 --- a/webrtc/video/video_capture_input_unittest.cc +++ b/webrtc/video/video_capture_input_unittest.cc @@ -139,7 +139,7 @@ TEST_F(VideoCaptureInputTest, DoesNotRetainHandleNorCopyBuffer) { } TEST_F(VideoCaptureInputTest, TestNtpTimeStampSetIfRenderTimeSet) { - input_frames_.push_back(CreateVideoFrame(static_cast(0))); + input_frames_.push_back(CreateVideoFrame(0)); input_frames_[0]->set_render_time_ms(5); input_frames_[0]->set_ntp_time_ms(0); @@ -150,7 +150,7 @@ TEST_F(VideoCaptureInputTest, TestNtpTimeStampSetIfRenderTimeSet) { } TEST_F(VideoCaptureInputTest, TestRtpTimeStampSet) { - input_frames_.push_back(CreateVideoFrame(static_cast(0))); + input_frames_.push_back(CreateVideoFrame(0)); input_frames_[0]->set_render_time_ms(0); input_frames_[0]->set_ntp_time_ms(1); input_frames_[0]->set_timestamp(0); @@ -161,6 +161,32 @@ TEST_F(VideoCaptureInputTest, TestRtpTimeStampSet) { input_frames_[0]->ntp_time_ms() * 90); } +TEST_F(VideoCaptureInputTest, DropsFramesWithSameOrOldNtpTimestamp) { + input_frames_.push_back(CreateVideoFrame(0)); + + input_frames_[0]->set_ntp_time_ms(17); + AddInputFrame(input_frames_[0]); + WaitOutputFrame(); + EXPECT_EQ(output_frames_[0]->timestamp(), + input_frames_[0]->ntp_time_ms() * 90); + + // Repeat frame with the same NTP timestamp should drop. + AddInputFrame(input_frames_[0]); + EXPECT_EQ(kEventTimeout, output_frame_event_->Wait(FRAME_TIMEOUT_MS)); + + // As should frames with a decreased NTP timestamp. + input_frames_[0]->set_ntp_time_ms(input_frames_[0]->ntp_time_ms() - 1); + AddInputFrame(input_frames_[0]); + EXPECT_EQ(kEventTimeout, output_frame_event_->Wait(FRAME_TIMEOUT_MS)); + + // But delivering with an increased NTP timestamp should succeed. + input_frames_[0]->set_ntp_time_ms(4711); + AddInputFrame(input_frames_[0]); + WaitOutputFrame(); + EXPECT_EQ(output_frames_[1]->timestamp(), + input_frames_[0]->ntp_time_ms() * 90); +} + TEST_F(VideoCaptureInputTest, TestTextureFrames) { const int kNumFrame = 3; for (int i = 0 ; i < kNumFrame; ++i) {