diff --git a/api/test/peerconnection_quality_test_fixture.h b/api/test/peerconnection_quality_test_fixture.h index f370478956..8717e8f73d 100644 --- a/api/test/peerconnection_quality_test_fixture.h +++ b/api/test/peerconnection_quality_test_fixture.h @@ -220,11 +220,19 @@ class PeerConnectionE2EQualityTestFixture { // was captured during the test for this video stream on sender side. // It is useful when generator is used as input. absl::optional input_dump_file_name; + // Used only if |input_dump_file_name| is set. Specifies the module for the + // video frames to be dumped. Modulo equals X means every Xth frame will be + // written to the dump file. The value must be greater than 0. + int input_dump_sampling_modulo = 1; // If specified this file will be used as output on the receiver side for // this stream. If multiple streams will be produced by input stream, // 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; + // Used only if |output_dump_file_name| is set. Specifies the module for the + // video frames to be dumped. Modulo equals X means every Xth frame will be + // written to the dump file. The value must be greater than 0. + int output_dump_sampling_modulo = 1; // If true will display input and output video on the user's screen. bool show_on_screen = false; // If specified, determines a sync group to which this video stream belongs. 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 ebfb41697d..6d14558aa0 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 @@ -28,17 +28,23 @@ namespace { class VideoWriter final : public rtc::VideoSinkInterface { public: - VideoWriter(test::VideoFrameWriter* video_writer) - : video_writer_(video_writer) {} + VideoWriter(test::VideoFrameWriter* video_writer, int sampling_modulo) + : video_writer_(video_writer), sampling_modulo_(sampling_modulo) {} ~VideoWriter() override = default; void OnFrame(const VideoFrame& frame) override { + if (frames_counter_++ % sampling_modulo_ != 0) { + return; + } bool result = video_writer_->WriteFrame(frame); RTC_CHECK(result) << "Failed to write frame"; } private: - test::VideoFrameWriter* video_writer_; + test::VideoFrameWriter* const video_writer_; + const int sampling_modulo_; + + int64_t frames_counter_ = 0; }; class AnalyzingFramePreprocessor @@ -122,7 +128,8 @@ VideoQualityAnalyzerInjectionHelper::CreateFramePreprocessor( test::VideoFrameWriter* writer = MaybeCreateVideoWriter(config.input_dump_file_name, config); if (writer) { - sinks.push_back(std::make_unique(writer)); + sinks.push_back(std::make_unique( + writer, config.input_dump_sampling_modulo)); } if (config.show_on_screen) { sinks.push_back(absl::WrapUnique( @@ -225,7 +232,8 @@ VideoQualityAnalyzerInjectionHelper::PopulateSinks( test::VideoFrameWriter* writer = MaybeCreateVideoWriter(config.output_dump_file_name, config); if (writer) { - sinks.push_back(std::make_unique(writer)); + sinks.push_back(std::make_unique( + writer, config.output_dump_sampling_modulo)); } if (config.show_on_screen) { sinks.push_back(absl::WrapUnique( diff --git a/test/pc/e2e/peer_configurer.cc b/test/pc/e2e/peer_configurer.cc index b5616b5d68..18570c2c6b 100644 --- a/test/pc/e2e/peer_configurer.cc +++ b/test/pc/e2e/peer_configurer.cc @@ -134,6 +134,15 @@ void ValidateParams( RTC_CHECK(inserted) << "Duplicate video_config.stream_label=" << video_config.stream_label.value(); + if (video_config.input_dump_file_name.has_value()) { + RTC_CHECK_GT(video_config.input_dump_sampling_modulo, 0) + << "video_config.input_dump_sampling_modulo must be greater than 0"; + } + if (video_config.output_dump_file_name.has_value()) { + RTC_CHECK_GT(video_config.output_dump_sampling_modulo, 0) + << "video_config.input_dump_sampling_modulo must be greater than 0"; + } + // TODO(bugs.webrtc.org/4762): remove this check after synchronization of // more than two streams is supported. if (video_config.sync_group.has_value()) {