diff --git a/test/pc/e2e/analyzer/video/analyzing_video_sink.cc b/test/pc/e2e/analyzer/video/analyzing_video_sink.cc index 20e396683d..56a2bd3529 100644 --- a/test/pc/e2e/analyzer/video/analyzing_video_sink.cc +++ b/test/pc/e2e/analyzer/video/analyzing_video_sink.cc @@ -9,6 +9,7 @@ */ #include "test/pc/e2e/analyzer/video/analyzing_video_sink.h" +#include #include #include #include @@ -60,13 +61,14 @@ void AnalyzingVideoSink::UpdateSubscription( for (auto it = stream_sinks_.cbegin(); it != stream_sinks_.cend();) { std::optional new_requested_resolution = subscription_.GetResolutionForPeer(it->second.sender_peer_name); - if (!new_requested_resolution.has_value() || - (*new_requested_resolution != it->second.resolution)) { + if (new_requested_resolution != it->second.resolution) { RTC_LOG(LS_INFO) << peer_name_ << ": Subscribed resolution for stream " << it->first << " from " << it->second.sender_peer_name << " was updated from " << it->second.resolution.ToString() << " to " - << new_requested_resolution->ToString() + << (new_requested_resolution.has_value() + ? new_requested_resolution->ToString() + : "none") << ". Repopulating all video sinks and recreating " << "requested video writers"; writers_to_close.insert(it->second.video_frame_writer); @@ -140,8 +142,10 @@ VideoFrame AnalyzingVideoSink::ScaleVideoFrame( const VideoFrame& frame, const VideoResolution& required_resolution) { Timestamp processing_started = clock_->CurrentTime(); - if (required_resolution.width() == static_cast(frame.width()) && - required_resolution.height() == static_cast(frame.height())) { + if ((required_resolution.width() == static_cast(frame.width()) && + required_resolution.height() == static_cast(frame.height())) || + !required_resolution.IsRegular() || + (required_resolution.width() == 0 || required_resolution.height() == 0)) { if (report_infra_stats_) { stats_.scaling_tims_ms.AddSample( (clock_->CurrentTime() - processing_started).ms()); diff --git a/test/pc/e2e/analyzer/video/analyzing_video_sink_test.cc b/test/pc/e2e/analyzer/video/analyzing_video_sink_test.cc index b2f8ef8c74..23c3bae688 100644 --- a/test/pc/e2e/analyzer/video/analyzing_video_sink_test.cc +++ b/test/pc/e2e/analyzer/video/analyzing_video_sink_test.cc @@ -321,6 +321,74 @@ TEST_F(AnalyzingVideoSinkTest, ExpectOutputFilesCount(2); } +TEST_F(AnalyzingVideoSinkTest, KeepsCountingFrameWhenUnsucsribed) { + VideoSubscription subscription_before; + subscription_before.SubscribeToPeer( + "alice", VideoResolution(/*width=*/1280, /*height=*/720, /*fps=*/30)); + + VideoConfig video_config("alice_video", /*width=*/1280, /*height=*/720, + /*fps=*/30); + + ExampleVideoQualityAnalyzer analyzer; + std::unique_ptr frame_generator = + CreateFrameGenerator(/*width=*/1280, /*height=*/720); + VideoFrame frame_before = CreateFrame(*frame_generator); + frame_before.set_id( + analyzer.OnFrameCaptured("alice", "alice_video", frame_before)); + VideoFrame frame_after = CreateFrame(*frame_generator); + frame_after.set_id( + analyzer.OnFrameCaptured("alice", "alice_video", frame_after)); + + { + AnalyzingVideoSinksHelper helper; + helper.AddConfig("alice", video_config); + AnalyzingVideoSink sink("bob", Clock::GetRealTimeClock(), analyzer, helper, + subscription_before, /*report_infra_stats=*/false); + sink.OnFrame(frame_before); + + sink.UpdateSubscription(VideoSubscription()); + sink.OnFrame(frame_after); + } + + EXPECT_THAT(analyzer.frames_rendered(), Eq(2)); +} + +TEST_F(AnalyzingVideoSinkTest, + KeepsCountingFrameWhenUnsucsribedUsingEmptyResolution) { + VideoSubscription subscription_before; + subscription_before.SubscribeToPeer( + "alice", VideoResolution(/*width=*/1280, /*height=*/720, /*fps=*/30)); + VideoSubscription subscription_after; + subscription_after.SubscribeToPeer( + "alice", VideoResolution(/*width=*/0, /*height=*/0, /*fps=*/0)); + + VideoConfig video_config("alice_video", /*width=*/1280, /*height=*/720, + /*fps=*/30); + + ExampleVideoQualityAnalyzer analyzer; + std::unique_ptr frame_generator = + CreateFrameGenerator(/*width=*/1280, /*height=*/720); + VideoFrame frame_before = CreateFrame(*frame_generator); + frame_before.set_id( + analyzer.OnFrameCaptured("alice", "alice_video", frame_before)); + VideoFrame frame_after = CreateFrame(*frame_generator); + frame_after.set_id( + analyzer.OnFrameCaptured("alice", "alice_video", frame_after)); + + { + AnalyzingVideoSinksHelper helper; + helper.AddConfig("alice", video_config); + AnalyzingVideoSink sink("bob", Clock::GetRealTimeClock(), analyzer, helper, + subscription_before, /*report_infra_stats=*/false); + sink.OnFrame(frame_before); + + sink.UpdateSubscription(subscription_after); + sink.OnFrame(frame_after); + } + + EXPECT_THAT(analyzer.frames_rendered(), Eq(2)); +} + TEST_F(AnalyzingVideoSinkTest, VideoFramesAreDumpedCorrectlyWhenSubscriptionChangedOnTheSameOne) { VideoSubscription subscription_before;