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();