From 0cd61b6e287c156d6189490d64842dfdfcaa524a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85sa=20Persson?= Date: Mon, 9 Sep 2019 14:56:38 +0200 Subject: [PATCH] MultiCodecReceiveTest: fix for flaky test. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:10828 Change-Id: I0fb2f4cdf0481e6c0036ae4dba861c5fbd4b98e5 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/152160 Reviewed-by: Rasmus Brandt Commit-Queue: Åsa Persson Cr-Commit-Position: refs/heads/master@{#29124} --- .../multi_codec_receive_tests.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/video/end_to_end_tests/multi_codec_receive_tests.cc b/video/end_to_end_tests/multi_codec_receive_tests.cc index 56da4090e2..bbb22187b0 100644 --- a/video/end_to_end_tests/multi_codec_receive_tests.cc +++ b/video/end_to_end_tests/multi_codec_receive_tests.cc @@ -60,10 +60,11 @@ class FrameObserver : public test::RtpRtcpObserver, public: FrameObserver() : test::RtpRtcpObserver(test::CallTest::kDefaultTimeoutMs) {} - void Reset() { + void Reset(uint8_t expected_payload_type) { rtc::CritScope lock(&crit_); num_sent_frames_ = 0; num_rendered_frames_ = 0; + expected_payload_type_ = expected_payload_type; } private: @@ -78,13 +79,13 @@ class FrameObserver : public test::RtpRtcpObserver, if ((length - header.headerLength) == header.paddingLength) return SEND_PACKET; // Skip padding, may be sent after OnFrame is called. + if (expected_payload_type_ && + header.payloadType != expected_payload_type_.value()) { + return DROP_PACKET; // All frames sent. + } + if (!last_timestamp_ || header.timestamp != *last_timestamp_) { // New frame. - if (last_payload_type_) { - bool new_payload_type = header.payloadType != *last_payload_type_; - EXPECT_EQ(num_sent_frames_ == 0, new_payload_type) - << "Payload type should change after reset."; - } // Sent enough frames? if (num_sent_frames_ >= kFramesToObserve) return DROP_PACKET; @@ -94,7 +95,6 @@ class FrameObserver : public test::RtpRtcpObserver, } last_timestamp_ = header.timestamp; - last_payload_type_ = header.payloadType; return SEND_PACKET; } @@ -115,7 +115,7 @@ class FrameObserver : public test::RtpRtcpObserver, rtc::CriticalSection crit_; absl::optional last_timestamp_; - absl::optional last_payload_type_; + absl::optional expected_payload_type_; int num_sent_frames_ RTC_GUARDED_BY(crit_) = 0; int num_rendered_frames_ RTC_GUARDED_BY(crit_) = 0; std::vector sent_timestamps_ RTC_GUARDED_BY(crit_); @@ -222,7 +222,7 @@ void MultiCodecReceiveTest::RunTestWithCodecs( // Recreate VideoSendStream with new config (codec, temporal layers). task_queue_.SendTask([this, i, &configs]() { DestroyVideoSendStreams(); - observer_.Reset(); + observer_.Reset(PayloadNameToPayloadType(configs[i].payload_name)); ConfigureEncoder(configs[i]); CreateVideoSendStreams();