Add ability to configure sampling rate for input/output video dumps in PC level framework
Bug: b/179986638 Change-Id: I9ab960840e4b8f912abe4fb79cfd9278f4d4562a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/208760 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Artem Titov <titovartem@webrtc.org> Cr-Commit-Position: refs/heads/master@{#33350}
This commit is contained in:
@ -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<std::string> 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<std::string> 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.
|
||||
|
||||
@ -28,17 +28,23 @@ namespace {
|
||||
|
||||
class VideoWriter final : public rtc::VideoSinkInterface<VideoFrame> {
|
||||
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<VideoWriter>(writer));
|
||||
sinks.push_back(std::make_unique<VideoWriter>(
|
||||
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<VideoWriter>(writer));
|
||||
sinks.push_back(std::make_unique<VideoWriter>(
|
||||
writer, config.output_dump_sampling_modulo));
|
||||
}
|
||||
if (config.show_on_screen) {
|
||||
sinks.push_back(absl::WrapUnique(
|
||||
|
||||
@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user