Add support of displaying video during the PC level test
Bug: webrtc:10138
Change-Id: Ic74b58bc4f1be1793e0dd1a0c286f8d4200fe6f2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/151901
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29111}
diff --git a/api/test/peerconnection_quality_test_fixture.h b/api/test/peerconnection_quality_test_fixture.h
index 9c77ef3..91a1a2a 100644
--- a/api/test/peerconnection_quality_test_fixture.h
+++ b/api/test/peerconnection_quality_test_fixture.h
@@ -197,6 +197,8 @@
// 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;
+ // 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 afd343a..a718589 100644
--- a/test/pc/e2e/BUILD.gn
+++ b/test/pc/e2e/BUILD.gn
@@ -193,6 +193,8 @@
":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 c2501c9..bc276ba 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 @@
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 @@
return;
}
analyzer_->OnFrameRendered(frame);
- for (auto& listener : sinks_) {
- listener->OnFrame(frame);
+ for (auto& sink : sinks_) {
+ sink->OnFrame(frame);
}
}
@@ -143,25 +144,36 @@
std::unique_ptr<test::FrameGenerator>
VideoQualityAnalyzerInjectionHelper::WrapFrameGenerator(
- std::string stream_label,
+ const VideoConfig& config,
std::unique_ptr<test::FrameGenerator> delegate,
test::VideoFrameWriter* writer) const {
std::vector<std::unique_ptr<rtc::VideoSinkInterface<VideoFrame>>> sinks;
if (writer) {
sinks.push_back(absl::make_unique<VideoWriter>(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<AnalyzingFrameGenerator>(
- 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<rtc::VideoSinkInterface<VideoFrame>>
VideoQualityAnalyzerInjectionHelper::CreateVideoSink(
+ const VideoConfig& config,
test::VideoFrameWriter* writer) const {
std::vector<std::unique_ptr<rtc::VideoSinkInterface<VideoFrame>>> sinks;
if (writer) {
sinks.push_back(absl::make_unique<VideoWriter>(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<AnalyzingVideoSink>(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 8438edc..eb07a5d 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 <memory>
#include <string>
+#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 @@
// VideoQualityAnalyzerInterface into PeerConnection pipeline.
class VideoQualityAnalyzerInjectionHelper : public StatsObserverInterface {
public:
+ using VideoConfig = PeerConnectionE2EQualityTestFixture::VideoConfig;
+
VideoQualityAnalyzerInjectionHelper(
std::unique_ptr<VideoQualityAnalyzerInterface> analyzer,
EncodedImageDataInjector* injector,
@@ -55,13 +58,14 @@
// captured frames. If |writer| in not nullptr, will dump captured frames
// with provided writer.
std::unique_ptr<test::FrameGenerator> WrapFrameGenerator(
- std::string stream_label,
+ const VideoConfig& config,
std::unique_ptr<test::FrameGenerator> 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<rtc::VideoSinkInterface<VideoFrame>> 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 6f9b82e..47f2b43 100644
--- a/test/pc/e2e/peer_connection_quality_test.cc
+++ b/test/pc/e2e/peer_connection_quality_test.cc
@@ -590,7 +590,8 @@
// track->kind() is kVideoKind.
auto* video_track = static_cast<VideoTrackInterface*>(track.get());
std::unique_ptr<rtc::VideoSinkInterface<VideoFrame>> 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 @@
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<test::FrameGeneratorCapturer>(