Extend test::FunctionVideoDecoderFactory to propagate Environment
To reduce number calls to the CreateVideoDecoder Bug: webrtc:15791 Change-Id: I5d6ecc2e5e68165d4e012b3ad7edb6eaa40e1913 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/336420 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#41706}
This commit is contained in:
parent
15062c8739
commit
61b1f53a4c
@ -18,6 +18,7 @@ rtc_library("function_video_factory") {
|
||||
|
||||
deps = [
|
||||
"../../../rtc_base:checks",
|
||||
"../../environment",
|
||||
"../../video_codecs:video_codecs_api",
|
||||
]
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "api/environment/environment.h"
|
||||
#include "api/video_codecs/sdp_video_format.h"
|
||||
#include "api/video_codecs/video_decoder.h"
|
||||
#include "api/video_codecs/video_decoder_factory.h"
|
||||
@ -29,17 +30,20 @@ class FunctionVideoDecoderFactory final : public VideoDecoderFactory {
|
||||
public:
|
||||
explicit FunctionVideoDecoderFactory(
|
||||
std::function<std::unique_ptr<VideoDecoder>()> create)
|
||||
: create_([create = std::move(create)](const SdpVideoFormat&) {
|
||||
: create_([create = std::move(create)](const Environment&,
|
||||
const SdpVideoFormat&) {
|
||||
return create();
|
||||
}) {}
|
||||
explicit FunctionVideoDecoderFactory(
|
||||
std::function<std::unique_ptr<VideoDecoder>(const SdpVideoFormat&)>
|
||||
std::function<std::unique_ptr<VideoDecoder>(const Environment&,
|
||||
const SdpVideoFormat&)>
|
||||
create)
|
||||
: create_(std::move(create)) {}
|
||||
FunctionVideoDecoderFactory(
|
||||
std::function<std::unique_ptr<VideoDecoder>()> create,
|
||||
std::vector<SdpVideoFormat> sdp_video_formats)
|
||||
: create_([create = std::move(create)](const SdpVideoFormat&) {
|
||||
: create_([create = std::move(create)](const Environment&,
|
||||
const SdpVideoFormat&) {
|
||||
return create();
|
||||
}),
|
||||
sdp_video_formats_(std::move(sdp_video_formats)) {}
|
||||
@ -48,13 +52,14 @@ class FunctionVideoDecoderFactory final : public VideoDecoderFactory {
|
||||
return sdp_video_formats_;
|
||||
}
|
||||
|
||||
std::unique_ptr<VideoDecoder> CreateVideoDecoder(
|
||||
const SdpVideoFormat& format) override {
|
||||
return create_(format);
|
||||
std::unique_ptr<VideoDecoder> Create(const Environment& env,
|
||||
const SdpVideoFormat& format) override {
|
||||
return create_(env, format);
|
||||
}
|
||||
|
||||
private:
|
||||
const std::function<std::unique_ptr<VideoDecoder>(const SdpVideoFormat&)>
|
||||
const std::function<std::unique_ptr<VideoDecoder>(const Environment& env,
|
||||
const SdpVideoFormat&)>
|
||||
create_;
|
||||
const std::vector<SdpVideoFormat> sdp_video_formats_;
|
||||
};
|
||||
|
||||
@ -820,6 +820,8 @@ if (rtc_include_tests) {
|
||||
"../../api:mock_video_decoder",
|
||||
"../../api:mock_video_encoder",
|
||||
"../../api:simulcast_test_fixture_api",
|
||||
"../../api/environment",
|
||||
"../../api/environment:environment_factory",
|
||||
"../../api/video:encoded_image",
|
||||
"../../api/video:video_frame",
|
||||
"../../api/video:video_rtp_headers",
|
||||
|
||||
@ -15,6 +15,8 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "api/environment/environment.h"
|
||||
#include "api/environment/environment_factory.h"
|
||||
#include "api/video/encoded_image.h"
|
||||
#include "api/video_codecs/sdp_video_format.h"
|
||||
#include "api/video_codecs/video_encoder.h"
|
||||
@ -258,8 +260,9 @@ SimulcastTestFixtureImpl::SimulcastTestFixtureImpl(
|
||||
std::unique_ptr<VideoDecoderFactory> decoder_factory,
|
||||
SdpVideoFormat video_format)
|
||||
: codec_type_(PayloadStringToCodecType(video_format.name)) {
|
||||
Environment env = CreateEnvironment();
|
||||
encoder_ = encoder_factory->CreateVideoEncoder(video_format);
|
||||
decoder_ = decoder_factory->CreateVideoDecoder(video_format);
|
||||
decoder_ = decoder_factory->Create(env, video_format);
|
||||
SetUpCodec((codec_type_ == kVideoCodecVP8 || codec_type_ == kVideoCodecH264)
|
||||
? kDefaultTemporalLayerProfile
|
||||
: kNoTemporalLayerProfile);
|
||||
|
||||
@ -519,6 +519,7 @@ if (rtc_include_tests) {
|
||||
"../api:rtc_event_log_output_file",
|
||||
"../api:test_dependency_factory",
|
||||
"../api:video_quality_test_fixture_api",
|
||||
"../api/environment",
|
||||
"../api/numerics",
|
||||
"../api/rtc_event_log:rtc_event_log_factory",
|
||||
"../api/task_queue",
|
||||
|
||||
@ -213,7 +213,8 @@ void MultiCodecReceiveTest::RunTestWithCodecs(
|
||||
return nullptr;
|
||||
});
|
||||
test::FunctionVideoDecoderFactory decoder_factory(
|
||||
[](const SdpVideoFormat& format) -> std::unique_ptr<VideoDecoder> {
|
||||
[](const Environment& env,
|
||||
const SdpVideoFormat& format) -> std::unique_ptr<VideoDecoder> {
|
||||
if (format.name == "VP8") {
|
||||
return VP8Decoder::Create();
|
||||
}
|
||||
|
||||
@ -294,6 +294,7 @@ void PressEnterToContinue(TaskQueueBase* /*task_queue*/) {
|
||||
} // namespace
|
||||
|
||||
std::unique_ptr<VideoDecoder> VideoQualityTest::CreateVideoDecoder(
|
||||
const Environment& env,
|
||||
const SdpVideoFormat& format) {
|
||||
std::unique_ptr<VideoDecoder> decoder;
|
||||
if (format.name == "multiplex") {
|
||||
@ -302,7 +303,7 @@ std::unique_ptr<VideoDecoder> VideoQualityTest::CreateVideoDecoder(
|
||||
} else if (format.name == "FakeCodec") {
|
||||
decoder = webrtc::FakeVideoDecoderFactory::CreateVideoDecoder();
|
||||
} else {
|
||||
decoder = decoder_factory_->CreateVideoDecoder(format);
|
||||
decoder = decoder_factory_->Create(env, format);
|
||||
}
|
||||
if (!params_.logging.encoded_frame_base_path.empty()) {
|
||||
rtc::StringBuilder str;
|
||||
@ -375,9 +376,10 @@ VideoQualityTest::VideoQualityTest(
|
||||
std::unique_ptr<InjectionComponents> injection_components)
|
||||
: clock_(Clock::GetRealTimeClock()),
|
||||
task_queue_factory_(CreateDefaultTaskQueueFactory()),
|
||||
video_decoder_factory_([this](const SdpVideoFormat& format) {
|
||||
return this->CreateVideoDecoder(format);
|
||||
}),
|
||||
video_decoder_factory_(
|
||||
[this](const Environment& env, const SdpVideoFormat& format) {
|
||||
return this->CreateVideoDecoder(env, format);
|
||||
}),
|
||||
video_encoder_factory_([this](const SdpVideoFormat& format) {
|
||||
return this->CreateVideoEncoder(format, nullptr);
|
||||
}),
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "api/environment/environment.h"
|
||||
#include "api/fec_controller.h"
|
||||
#include "api/rtc_event_log/rtc_event_log_factory.h"
|
||||
#include "api/task_queue/task_queue_base.h"
|
||||
@ -79,6 +80,7 @@ class VideoQualityTest : public test::CallTest,
|
||||
size_t video_idx);
|
||||
void SetupThumbnailCapturers(size_t num_thumbnail_streams);
|
||||
std::unique_ptr<VideoDecoder> CreateVideoDecoder(
|
||||
const Environment& env,
|
||||
const SdpVideoFormat& format);
|
||||
std::unique_ptr<VideoEncoder> CreateVideoEncoder(const SdpVideoFormat& format,
|
||||
VideoAnalyzer* analyzer);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user