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:

committed by
Commit Bot

parent
3c5450e693
commit
dad6a940e1
16
api/BUILD.gn
16
api/BUILD.gn
@ -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") {
|
rtc_source_set("libjingle_logging_api") {
|
||||||
visibility = [ "*" ]
|
visibility = [ "*" ]
|
||||||
sources = [ "rtc_event_log_output.h" ]
|
sources = [ "rtc_event_log_output.h" ]
|
||||||
|
107
api/test/create_peer_connection_quality_test_frame_generator.cc
Normal file
107
api/test/create_peer_connection_quality_test_frame_generator.cc
Normal 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
|
@ -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_
|
@ -274,6 +274,7 @@ if (rtc_include_tests) {
|
|||||||
"../..:platform_video_capturer",
|
"../..:platform_video_capturer",
|
||||||
"../..:video_test_common",
|
"../..:video_test_common",
|
||||||
"../../../api:create_frame_generator",
|
"../../../api:create_frame_generator",
|
||||||
|
"../../../api:create_peer_connection_quality_test_frame_generator",
|
||||||
"../../../api:frame_generator_api",
|
"../../../api:frame_generator_api",
|
||||||
"../../../api:peer_connection_quality_test_fixture_api",
|
"../../../api:peer_connection_quality_test_fixture_api",
|
||||||
"../../../api/video:video_frame",
|
"../../../api/video:video_frame",
|
||||||
@ -292,6 +293,7 @@ if (rtc_include_tests) {
|
|||||||
":peer_connection_quality_test_params",
|
":peer_connection_quality_test_params",
|
||||||
"../..:fileutils",
|
"../..:fileutils",
|
||||||
"../../../api:callfactory_api",
|
"../../../api:callfactory_api",
|
||||||
|
"../../../api:create_peer_connection_quality_test_frame_generator",
|
||||||
"../../../api:fec_controller_api",
|
"../../../api:fec_controller_api",
|
||||||
"../../../api:packet_socket_factory",
|
"../../../api:packet_socket_factory",
|
||||||
"../../../api:peer_connection_quality_test_fixture_api",
|
"../../../api:peer_connection_quality_test_fixture_api",
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "api/test/create_frame_generator.h"
|
#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/frame_generator_capturer.h"
|
||||||
#include "test/platform_video_capturer.h"
|
#include "test/platform_video_capturer.h"
|
||||||
#include "test/testsupport/file_utils.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);
|
video_config.width, video_config.height, /*frame_repeat_count=*/1);
|
||||||
}
|
}
|
||||||
if (video_config.screen_share_config) {
|
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";
|
RTC_CHECK(frame_generator) << "Unsupported video_config input source";
|
||||||
|
|
||||||
@ -147,47 +149,5 @@ std::unique_ptr<test::TestVideoCapturer> MediaHelper::CreateVideoCapturer(
|
|||||||
return capturer;
|
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_pc_e2e
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -44,9 +44,6 @@ class MediaHelper {
|
|||||||
std::unique_ptr<test::FrameGeneratorInterface> generator,
|
std::unique_ptr<test::FrameGeneratorInterface> generator,
|
||||||
std::unique_ptr<test::TestVideoCapturer::FramePreprocessor>
|
std::unique_ptr<test::TestVideoCapturer::FramePreprocessor>
|
||||||
frame_preprocessor);
|
frame_preprocessor);
|
||||||
std::unique_ptr<test::FrameGeneratorInterface>
|
|
||||||
CreateScreenShareFrameGenerator(
|
|
||||||
const PeerConnectionE2EQualityTestFixture::VideoConfig& video_config);
|
|
||||||
|
|
||||||
Clock* const clock_;
|
Clock* const clock_;
|
||||||
TaskQueueFactory* const task_queue_factory_;
|
TaskQueueFactory* const task_queue_factory_;
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
|
#include "api/test/create_peer_connection_quality_test_frame_generator.h"
|
||||||
#include "test/testsupport/file_utils.h"
|
#include "test/testsupport/file_utils.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -134,34 +135,8 @@ void ValidateParams(
|
|||||||
video_config, (*peers[i]->video_generators())[j] != nullptr);
|
video_config, (*peers[i]->video_generators())[j] != nullptr);
|
||||||
|
|
||||||
if (video_config.screen_share_config) {
|
if (video_config.screen_share_config) {
|
||||||
if (video_config.screen_share_config->slides_yuv_file_names.empty()) {
|
ValidateScreenShareConfig(video_config,
|
||||||
if (video_config.screen_share_config->scrolling_params) {
|
*video_config.screen_share_config);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (video_config.simulcast_config) {
|
if (video_config.simulcast_config) {
|
||||||
has_simulcast = true;
|
has_simulcast = true;
|
||||||
|
Reference in New Issue
Block a user