Add helper frame generator factories for the pc framework tests.

Bug: webrtc:11534
Change-Id: I569fb9e78aa38f0a17f4e4a261dd93c4b8ba9ca0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174340
Commit-Queue: Andrey Logvin <landrey@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31162}
This commit is contained in:
Andrey Logvin
2020-05-04 17:27:09 +00:00
committed by Commit Bot
parent 3c5450e693
commit dad6a940e1
7 changed files with 186 additions and 74 deletions

View File

@ -472,6 +472,22 @@ rtc_library("create_frame_generator") {
]
}
rtc_library("create_peer_connection_quality_test_frame_generator") {
visibility = [ "*" ]
testonly = true
sources = [
"test/create_peer_connection_quality_test_frame_generator.cc",
"test/create_peer_connection_quality_test_frame_generator.h",
]
deps = [
":create_frame_generator",
":frame_generator_api",
":peer_connection_quality_test_fixture_api",
"../test:fileutils",
"//third_party/abseil-cpp/absl/types:optional",
]
}
rtc_source_set("libjingle_logging_api") {
visibility = [ "*" ]
sources = [ "rtc_event_log_output.h" ]

View File

@ -0,0 +1,107 @@
/*
* Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "api/test/create_peer_connection_quality_test_frame_generator.h"
#include <utility>
#include <vector>
#include "api/test/create_frame_generator.h"
#include "api/test/peerconnection_quality_test_fixture.h"
#include "test/testsupport/file_utils.h"
namespace webrtc {
namespace webrtc_pc_e2e {
using VideoConfig =
::webrtc::webrtc_pc_e2e::PeerConnectionE2EQualityTestFixture::VideoConfig;
using ScreenShareConfig = ::webrtc::webrtc_pc_e2e::
PeerConnectionE2EQualityTestFixture::ScreenShareConfig;
void ValidateScreenShareConfig(const VideoConfig& video_config,
const ScreenShareConfig& screen_share_config) {
if (screen_share_config.slides_yuv_file_names.empty()) {
if (screen_share_config.scrolling_params) {
// If we have scrolling params, then its |source_width| and |source_heigh|
// will be used as width and height of video input, so we have to validate
// it against width and height of default input.
RTC_CHECK_EQ(screen_share_config.scrolling_params->source_width,
kDefaultSlidesWidth);
RTC_CHECK_EQ(screen_share_config.scrolling_params->source_height,
kDefaultSlidesHeight);
} else {
RTC_CHECK_EQ(video_config.width, kDefaultSlidesWidth);
RTC_CHECK_EQ(video_config.height, kDefaultSlidesHeight);
}
}
if (video_config.screen_share_config->scrolling_params) {
RTC_CHECK_LE(screen_share_config.scrolling_params->duration,
screen_share_config.slide_change_interval);
RTC_CHECK_GE(screen_share_config.scrolling_params->source_width,
video_config.width);
RTC_CHECK_GE(screen_share_config.scrolling_params->source_height,
video_config.height);
}
}
std::unique_ptr<test::FrameGeneratorInterface> CreateSquareFrameGenerator(
const VideoConfig& video_config,
absl::optional<test::FrameGeneratorInterface::OutputType> type) {
return test::CreateSquareFrameGenerator(
video_config.width, video_config.height, std::move(type), absl::nullopt);
}
std::unique_ptr<test::FrameGeneratorInterface> CreateFromYuvFileFrameGenerator(
const VideoConfig& video_config,
std::string filename) {
return test::CreateFromYuvFileFrameGenerator(
{std::move(filename)}, video_config.width, video_config.height,
/*frame_repeat_count=*/1);
}
std::unique_ptr<test::FrameGeneratorInterface> CreateScreenShareFrameGenerator(
const VideoConfig& video_config,
const ScreenShareConfig& screen_share_config) {
ValidateScreenShareConfig(video_config, screen_share_config);
if (screen_share_config.generate_slides) {
return test::CreateSlideFrameGenerator(
video_config.width, video_config.height,
screen_share_config.slide_change_interval.seconds() * video_config.fps);
}
std::vector<std::string> slides = screen_share_config.slides_yuv_file_names;
if (slides.empty()) {
// If slides is empty we need to add default slides as source. In such case
// video width and height is validated to be equal to kDefaultSlidesWidth
// and kDefaultSlidesHeight.
slides.push_back(test::ResourcePath("web_screenshot_1850_1110", "yuv"));
slides.push_back(test::ResourcePath("presentation_1850_1110", "yuv"));
slides.push_back(test::ResourcePath("photo_1850_1110", "yuv"));
slides.push_back(test::ResourcePath("difficult_photo_1850_1110", "yuv"));
}
if (!screen_share_config.scrolling_params) {
// Cycle image every slide_change_interval seconds.
return test::CreateFromYuvFileFrameGenerator(
slides, video_config.width, video_config.height,
screen_share_config.slide_change_interval.seconds() * video_config.fps);
}
// |pause_duration| is nonnegative. It is validated in ValidateParams(...).
TimeDelta pause_duration = screen_share_config.slide_change_interval -
screen_share_config.scrolling_params->duration;
return test::CreateScrollingInputFromYuvFilesFrameGenerator(
Clock::GetRealTimeClock(), slides,
screen_share_config.scrolling_params->source_width,
screen_share_config.scrolling_params->source_height, video_config.width,
video_config.height, screen_share_config.scrolling_params->duration.ms(),
pause_duration.ms());
}
} // namespace webrtc_pc_e2e
} // namespace webrtc

View File

@ -0,0 +1,55 @@
/*
* Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef API_TEST_CREATE_PEER_CONNECTION_QUALITY_TEST_FRAME_GENERATOR_H_
#define API_TEST_CREATE_PEER_CONNECTION_QUALITY_TEST_FRAME_GENERATOR_H_
#include <memory>
#include <string>
#include "absl/types/optional.h"
#include "api/test/frame_generator_interface.h"
#include "api/test/peerconnection_quality_test_fixture.h"
namespace webrtc {
namespace webrtc_pc_e2e {
// Validates that ScreeanShare frame generator can be created based on the
// screen_share_config.
// This function is temporarily added to the public interface and will be
// removed from here after refactoring is done.
// TODO(landrey) remove from the header file
void ValidateScreenShareConfig(
const PeerConnectionE2EQualityTestFixture::VideoConfig& video_config,
const PeerConnectionE2EQualityTestFixture::ScreenShareConfig&
screen_share_config);
// Creates a frame generator that produces frames with small squares that move
// randomly towards the lower right corner. |type| has the default value
// FrameGeneratorInterface::OutputType::I420. video_config specifies frame
// weight and height.
std::unique_ptr<test::FrameGeneratorInterface> CreateSquareFrameGenerator(
const PeerConnectionE2EQualityTestFixture::VideoConfig& video_config,
absl::optional<test::FrameGeneratorInterface::OutputType> type);
// Creates a frame generator that plays frames from the yuv file.
std::unique_ptr<test::FrameGeneratorInterface> CreateFromYuvFileFrameGenerator(
const PeerConnectionE2EQualityTestFixture::VideoConfig& video_config,
std::string filename);
// Creates a proper frame generator for testing screen sharing.
std::unique_ptr<test::FrameGeneratorInterface> CreateScreenShareFrameGenerator(
const PeerConnectionE2EQualityTestFixture::VideoConfig& video_config,
const PeerConnectionE2EQualityTestFixture::ScreenShareConfig&
screen_share_config);
} // namespace webrtc_pc_e2e
} // namespace webrtc
#endif // API_TEST_CREATE_PEER_CONNECTION_QUALITY_TEST_FRAME_GENERATOR_H_

View File

@ -274,6 +274,7 @@ if (rtc_include_tests) {
"../..:platform_video_capturer",
"../..:video_test_common",
"../../../api:create_frame_generator",
"../../../api:create_peer_connection_quality_test_frame_generator",
"../../../api:frame_generator_api",
"../../../api:peer_connection_quality_test_fixture_api",
"../../../api/video:video_frame",
@ -292,6 +293,7 @@ if (rtc_include_tests) {
":peer_connection_quality_test_params",
"../..:fileutils",
"../../../api:callfactory_api",
"../../../api:create_peer_connection_quality_test_frame_generator",
"../../../api:fec_controller_api",
"../../../api:packet_socket_factory",
"../../../api:peer_connection_quality_test_fixture_api",

View File

@ -13,6 +13,7 @@
#include <utility>
#include "api/test/create_frame_generator.h"
#include "api/test/create_peer_connection_quality_test_frame_generator.h"
#include "test/frame_generator_capturer.h"
#include "test/platform_video_capturer.h"
#include "test/testsupport/file_utils.h"
@ -135,7 +136,8 @@ std::unique_ptr<test::TestVideoCapturer> MediaHelper::CreateVideoCapturer(
video_config.width, video_config.height, /*frame_repeat_count=*/1);
}
if (video_config.screen_share_config) {
frame_generator = CreateScreenShareFrameGenerator(video_config);
frame_generator = CreateScreenShareFrameGenerator(
video_config, *video_config.screen_share_config);
}
RTC_CHECK(frame_generator) << "Unsupported video_config input source";
@ -147,47 +149,5 @@ std::unique_ptr<test::TestVideoCapturer> MediaHelper::CreateVideoCapturer(
return capturer;
}
std::unique_ptr<test::FrameGeneratorInterface>
MediaHelper::CreateScreenShareFrameGenerator(const VideoConfig& video_config) {
RTC_CHECK(video_config.screen_share_config);
if (video_config.screen_share_config->generate_slides) {
return test::CreateSlideFrameGenerator(
video_config.width, video_config.height,
video_config.screen_share_config->slide_change_interval.seconds() *
video_config.fps);
}
std::vector<std::string> slides =
video_config.screen_share_config->slides_yuv_file_names;
if (slides.empty()) {
// If slides is empty we need to add default slides as source. In such case
// video width and height is validated to be equal to kDefaultSlidesWidth
// and kDefaultSlidesHeight.
slides.push_back(test::ResourcePath("web_screenshot_1850_1110", "yuv"));
slides.push_back(test::ResourcePath("presentation_1850_1110", "yuv"));
slides.push_back(test::ResourcePath("photo_1850_1110", "yuv"));
slides.push_back(test::ResourcePath("difficult_photo_1850_1110", "yuv"));
}
if (!video_config.screen_share_config->scrolling_params) {
// Cycle image every slide_change_interval seconds.
return test::CreateFromYuvFileFrameGenerator(
slides, video_config.width, video_config.height,
video_config.screen_share_config->slide_change_interval.seconds() *
video_config.fps);
}
// |pause_duration| is nonnegative. It is validated in ValidateParams(...).
TimeDelta pause_duration =
video_config.screen_share_config->slide_change_interval -
video_config.screen_share_config->scrolling_params->duration;
return test::CreateScrollingInputFromYuvFilesFrameGenerator(
clock_, slides,
video_config.screen_share_config->scrolling_params->source_width,
video_config.screen_share_config->scrolling_params->source_height,
video_config.width, video_config.height,
video_config.screen_share_config->scrolling_params->duration.ms(),
pause_duration.ms());
}
} // namespace webrtc_pc_e2e
} // namespace webrtc

View File

@ -44,9 +44,6 @@ class MediaHelper {
std::unique_ptr<test::FrameGeneratorInterface> generator,
std::unique_ptr<test::TestVideoCapturer::FramePreprocessor>
frame_preprocessor);
std::unique_ptr<test::FrameGeneratorInterface>
CreateScreenShareFrameGenerator(
const PeerConnectionE2EQualityTestFixture::VideoConfig& video_config);
Clock* const clock_;
TaskQueueFactory* const task_queue_factory_;

View File

@ -12,6 +12,7 @@
#include <set>
#include "api/test/create_peer_connection_quality_test_frame_generator.h"
#include "test/testsupport/file_utils.h"
namespace webrtc {
@ -134,34 +135,8 @@ void ValidateParams(
video_config, (*peers[i]->video_generators())[j] != nullptr);
if (video_config.screen_share_config) {
if (video_config.screen_share_config->slides_yuv_file_names.empty()) {
if (video_config.screen_share_config->scrolling_params) {
// If we have scrolling params, then its |source_width| and
// |source_heigh| will be used as width and height of video input,
// so we have to validate it against width and height of default
// input.
RTC_CHECK_EQ(video_config.screen_share_config->scrolling_params
->source_width,
kDefaultSlidesWidth);
RTC_CHECK_EQ(video_config.screen_share_config->scrolling_params
->source_height,
kDefaultSlidesHeight);
} else {
RTC_CHECK_EQ(video_config.width, kDefaultSlidesWidth);
RTC_CHECK_EQ(video_config.height, kDefaultSlidesHeight);
}
}
if (video_config.screen_share_config->scrolling_params) {
RTC_CHECK_LE(
video_config.screen_share_config->scrolling_params->duration,
video_config.screen_share_config->slide_change_interval);
RTC_CHECK_GE(
video_config.screen_share_config->scrolling_params->source_width,
video_config.width);
RTC_CHECK_GE(
video_config.screen_share_config->scrolling_params->source_height,
video_config.height);
}
ValidateScreenShareConfig(video_config,
*video_config.screen_share_config);
}
if (video_config.simulcast_config) {
has_simulcast = true;