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}
This commit is contained in:
Artem Titov
2019-09-06 14:31:50 +02:00
committed by Commit Bot
parent 2aaf66e464
commit ddef8d1b6b
5 changed files with 30 additions and 10 deletions

View File

@ -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<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.

View File

@ -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",

View File

@ -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<VideoFrame> {
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<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));
}

View File

@ -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 @@ namespace webrtc_pc_e2e {
// 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 @@ class VideoQualityAnalyzerInjectionHelper : public StatsObserverInterface {
// 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);

View File

@ -590,7 +590,8 @@ void PeerConnectionE2EQualityTest::OnTrackCallback(
// 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 @@ 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<test::FrameGeneratorCapturer>(