diff --git a/api/test/peerconnection_quality_test_fixture.h b/api/test/peerconnection_quality_test_fixture.h index 9c77ef35cd..91a1a2a162 100644 --- a/api/test/peerconnection_quality_test_fixture.h +++ b/api/test/peerconnection_quality_test_fixture.h @@ -197,6 +197,8 @@ class PeerConnectionE2EQualityTestFixture { // output files will be appended with indexes. The produced files contains // what was rendered for this video stream on receiver side. absl::optional output_dump_file_name; + // If true will display input and output video on the user's screen. + bool show_on_screen = false; }; // Contains properties for audio in the call. diff --git a/test/pc/e2e/BUILD.gn b/test/pc/e2e/BUILD.gn index afd343a26a..a718589c4d 100644 --- a/test/pc/e2e/BUILD.gn +++ b/test/pc/e2e/BUILD.gn @@ -193,6 +193,8 @@ if (rtc_include_tests) { ":quality_analyzing_video_decoder", ":quality_analyzing_video_encoder", ":simulcast_dummy_buffer_helper", + "../..:test_renderer", + "../../../api:peer_connection_quality_test_fixture_api", "../../../api:stats_observer_interface", "../../../api:video_quality_analyzer_api", "../../../api/video:video_frame", diff --git a/test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.cc b/test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.cc index c2501c9895..bc276bac62 100644 --- a/test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.cc +++ b/test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.cc @@ -16,6 +16,7 @@ #include "test/pc/e2e/analyzer/video/quality_analyzing_video_decoder.h" #include "test/pc/e2e/analyzer/video/quality_analyzing_video_encoder.h" #include "test/pc/e2e/analyzer/video/simulcast_dummy_buffer_helper.h" +#include "test/video_renderer.h" namespace webrtc { namespace webrtc_pc_e2e { @@ -58,8 +59,8 @@ class AnalyzingFrameGenerator final : public test::FrameGenerator { uint16_t frame_id = analyzer_->OnFrameCaptured(stream_label_, *frame); frame->set_id(frame_id); - for (auto& listener : sinks_) { - listener->OnFrame(*frame); + for (auto& sink : sinks_) { + sink->OnFrame(*frame); } return frame; } @@ -94,8 +95,8 @@ class AnalyzingVideoSink final : public rtc::VideoSinkInterface { return; } analyzer_->OnFrameRendered(frame); - for (auto& listener : sinks_) { - listener->OnFrame(frame); + for (auto& sink : sinks_) { + sink->OnFrame(frame); } } @@ -143,25 +144,36 @@ VideoQualityAnalyzerInjectionHelper::WrapVideoDecoderFactory( std::unique_ptr VideoQualityAnalyzerInjectionHelper::WrapFrameGenerator( - std::string stream_label, + const VideoConfig& config, std::unique_ptr delegate, test::VideoFrameWriter* writer) const { std::vector>> sinks; if (writer) { sinks.push_back(absl::make_unique(writer)); } + if (config.show_on_screen) { + sinks.push_back(absl::WrapUnique( + test::VideoRenderer::Create((*config.stream_label + "-capture").c_str(), + config.width, config.height))); + } return absl::make_unique( - std::move(stream_label), std::move(delegate), analyzer_.get(), + std::move(*config.stream_label), std::move(delegate), analyzer_.get(), std::move(sinks)); } std::unique_ptr> VideoQualityAnalyzerInjectionHelper::CreateVideoSink( + const VideoConfig& config, test::VideoFrameWriter* writer) const { std::vector>> sinks; if (writer) { sinks.push_back(absl::make_unique(writer)); } + if (config.show_on_screen) { + sinks.push_back(absl::WrapUnique( + test::VideoRenderer::Create((*config.stream_label + "-render").c_str(), + config.width, config.height))); + } return absl::make_unique(analyzer_.get(), std::move(sinks)); } diff --git a/test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.h b/test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.h index 8438edc735..eb07a5df8d 100644 --- a/test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.h +++ b/test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.h @@ -15,6 +15,7 @@ #include #include +#include "api/test/peerconnection_quality_test_fixture.h" #include "api/test/stats_observer_interface.h" #include "api/test/video_quality_analyzer_interface.h" #include "api/video/video_frame.h" @@ -33,6 +34,8 @@ namespace webrtc_pc_e2e { // VideoQualityAnalyzerInterface into PeerConnection pipeline. class VideoQualityAnalyzerInjectionHelper : public StatsObserverInterface { public: + using VideoConfig = PeerConnectionE2EQualityTestFixture::VideoConfig; + VideoQualityAnalyzerInjectionHelper( std::unique_ptr analyzer, EncodedImageDataInjector* injector, @@ -55,13 +58,14 @@ class VideoQualityAnalyzerInjectionHelper : public StatsObserverInterface { // captured frames. If |writer| in not nullptr, will dump captured frames // with provided writer. std::unique_ptr WrapFrameGenerator( - std::string stream_label, + const VideoConfig& config, std::unique_ptr delegate, test::VideoFrameWriter* writer) const; // Creates sink, that will allow video quality analyzer to get access to the // rendered frames. If |writer| in not nullptr, will dump rendered frames // with provided writer. std::unique_ptr> CreateVideoSink( + const VideoConfig& config, test::VideoFrameWriter* writer) const; void Start(std::string test_case_name, int max_threads_count); diff --git a/test/pc/e2e/peer_connection_quality_test.cc b/test/pc/e2e/peer_connection_quality_test.cc index 6f9b82eb4e..47f2b43425 100644 --- a/test/pc/e2e/peer_connection_quality_test.cc +++ b/test/pc/e2e/peer_connection_quality_test.cc @@ -590,7 +590,8 @@ void PeerConnectionE2EQualityTest::OnTrackCallback( // track->kind() is kVideoKind. auto* video_track = static_cast(track.get()); std::unique_ptr> video_sink = - video_quality_analyzer_injection_helper_->CreateVideoSink(writer); + video_quality_analyzer_injection_helper_->CreateVideoSink(*video_config, + writer); video_track->AddOrUpdateSink(video_sink.get(), rtc::VideoSinkWants()); output_video_sinks_.push_back(std::move(video_sink)); } @@ -680,8 +681,7 @@ PeerConnectionE2EQualityTest::MaybeAddVideo(TestPeer* peer) { MaybeCreateVideoWriter(video_config.input_dump_file_name, video_config); frame_generator = video_quality_analyzer_injection_helper_->WrapFrameGenerator( - video_config.stream_label.value(), std::move(frame_generator), - writer); + video_config, std::move(frame_generator), writer); // Setup FrameGenerator into peer connection. auto capturer = absl::make_unique(