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 = [
|
deps = [
|
||||||
"../../../rtc_base:checks",
|
"../../../rtc_base:checks",
|
||||||
|
"../../environment",
|
||||||
"../../video_codecs:video_codecs_api",
|
"../../video_codecs:video_codecs_api",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "api/environment/environment.h"
|
||||||
#include "api/video_codecs/sdp_video_format.h"
|
#include "api/video_codecs/sdp_video_format.h"
|
||||||
#include "api/video_codecs/video_decoder.h"
|
#include "api/video_codecs/video_decoder.h"
|
||||||
#include "api/video_codecs/video_decoder_factory.h"
|
#include "api/video_codecs/video_decoder_factory.h"
|
||||||
@ -29,17 +30,20 @@ class FunctionVideoDecoderFactory final : public VideoDecoderFactory {
|
|||||||
public:
|
public:
|
||||||
explicit FunctionVideoDecoderFactory(
|
explicit FunctionVideoDecoderFactory(
|
||||||
std::function<std::unique_ptr<VideoDecoder>()> create)
|
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();
|
return create();
|
||||||
}) {}
|
}) {}
|
||||||
explicit FunctionVideoDecoderFactory(
|
explicit FunctionVideoDecoderFactory(
|
||||||
std::function<std::unique_ptr<VideoDecoder>(const SdpVideoFormat&)>
|
std::function<std::unique_ptr<VideoDecoder>(const Environment&,
|
||||||
|
const SdpVideoFormat&)>
|
||||||
create)
|
create)
|
||||||
: create_(std::move(create)) {}
|
: create_(std::move(create)) {}
|
||||||
FunctionVideoDecoderFactory(
|
FunctionVideoDecoderFactory(
|
||||||
std::function<std::unique_ptr<VideoDecoder>()> create,
|
std::function<std::unique_ptr<VideoDecoder>()> create,
|
||||||
std::vector<SdpVideoFormat> sdp_video_formats)
|
std::vector<SdpVideoFormat> sdp_video_formats)
|
||||||
: create_([create = std::move(create)](const SdpVideoFormat&) {
|
: create_([create = std::move(create)](const Environment&,
|
||||||
|
const SdpVideoFormat&) {
|
||||||
return create();
|
return create();
|
||||||
}),
|
}),
|
||||||
sdp_video_formats_(std::move(sdp_video_formats)) {}
|
sdp_video_formats_(std::move(sdp_video_formats)) {}
|
||||||
@ -48,13 +52,14 @@ class FunctionVideoDecoderFactory final : public VideoDecoderFactory {
|
|||||||
return sdp_video_formats_;
|
return sdp_video_formats_;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<VideoDecoder> CreateVideoDecoder(
|
std::unique_ptr<VideoDecoder> Create(const Environment& env,
|
||||||
const SdpVideoFormat& format) override {
|
const SdpVideoFormat& format) override {
|
||||||
return create_(format);
|
return create_(env, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::function<std::unique_ptr<VideoDecoder>(const SdpVideoFormat&)>
|
const std::function<std::unique_ptr<VideoDecoder>(const Environment& env,
|
||||||
|
const SdpVideoFormat&)>
|
||||||
create_;
|
create_;
|
||||||
const std::vector<SdpVideoFormat> sdp_video_formats_;
|
const std::vector<SdpVideoFormat> sdp_video_formats_;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -820,6 +820,8 @@ if (rtc_include_tests) {
|
|||||||
"../../api:mock_video_decoder",
|
"../../api:mock_video_decoder",
|
||||||
"../../api:mock_video_encoder",
|
"../../api:mock_video_encoder",
|
||||||
"../../api:simulcast_test_fixture_api",
|
"../../api:simulcast_test_fixture_api",
|
||||||
|
"../../api/environment",
|
||||||
|
"../../api/environment:environment_factory",
|
||||||
"../../api/video:encoded_image",
|
"../../api/video:encoded_image",
|
||||||
"../../api/video:video_frame",
|
"../../api/video:video_frame",
|
||||||
"../../api/video:video_rtp_headers",
|
"../../api/video:video_rtp_headers",
|
||||||
|
|||||||
@ -15,6 +15,8 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "api/environment/environment.h"
|
||||||
|
#include "api/environment/environment_factory.h"
|
||||||
#include "api/video/encoded_image.h"
|
#include "api/video/encoded_image.h"
|
||||||
#include "api/video_codecs/sdp_video_format.h"
|
#include "api/video_codecs/sdp_video_format.h"
|
||||||
#include "api/video_codecs/video_encoder.h"
|
#include "api/video_codecs/video_encoder.h"
|
||||||
@ -258,8 +260,9 @@ SimulcastTestFixtureImpl::SimulcastTestFixtureImpl(
|
|||||||
std::unique_ptr<VideoDecoderFactory> decoder_factory,
|
std::unique_ptr<VideoDecoderFactory> decoder_factory,
|
||||||
SdpVideoFormat video_format)
|
SdpVideoFormat video_format)
|
||||||
: codec_type_(PayloadStringToCodecType(video_format.name)) {
|
: codec_type_(PayloadStringToCodecType(video_format.name)) {
|
||||||
|
Environment env = CreateEnvironment();
|
||||||
encoder_ = encoder_factory->CreateVideoEncoder(video_format);
|
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)
|
SetUpCodec((codec_type_ == kVideoCodecVP8 || codec_type_ == kVideoCodecH264)
|
||||||
? kDefaultTemporalLayerProfile
|
? kDefaultTemporalLayerProfile
|
||||||
: kNoTemporalLayerProfile);
|
: kNoTemporalLayerProfile);
|
||||||
|
|||||||
@ -519,6 +519,7 @@ if (rtc_include_tests) {
|
|||||||
"../api:rtc_event_log_output_file",
|
"../api:rtc_event_log_output_file",
|
||||||
"../api:test_dependency_factory",
|
"../api:test_dependency_factory",
|
||||||
"../api:video_quality_test_fixture_api",
|
"../api:video_quality_test_fixture_api",
|
||||||
|
"../api/environment",
|
||||||
"../api/numerics",
|
"../api/numerics",
|
||||||
"../api/rtc_event_log:rtc_event_log_factory",
|
"../api/rtc_event_log:rtc_event_log_factory",
|
||||||
"../api/task_queue",
|
"../api/task_queue",
|
||||||
|
|||||||
@ -213,7 +213,8 @@ void MultiCodecReceiveTest::RunTestWithCodecs(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
});
|
});
|
||||||
test::FunctionVideoDecoderFactory decoder_factory(
|
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") {
|
if (format.name == "VP8") {
|
||||||
return VP8Decoder::Create();
|
return VP8Decoder::Create();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -294,6 +294,7 @@ void PressEnterToContinue(TaskQueueBase* /*task_queue*/) {
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
std::unique_ptr<VideoDecoder> VideoQualityTest::CreateVideoDecoder(
|
std::unique_ptr<VideoDecoder> VideoQualityTest::CreateVideoDecoder(
|
||||||
|
const Environment& env,
|
||||||
const SdpVideoFormat& format) {
|
const SdpVideoFormat& format) {
|
||||||
std::unique_ptr<VideoDecoder> decoder;
|
std::unique_ptr<VideoDecoder> decoder;
|
||||||
if (format.name == "multiplex") {
|
if (format.name == "multiplex") {
|
||||||
@ -302,7 +303,7 @@ std::unique_ptr<VideoDecoder> VideoQualityTest::CreateVideoDecoder(
|
|||||||
} else if (format.name == "FakeCodec") {
|
} else if (format.name == "FakeCodec") {
|
||||||
decoder = webrtc::FakeVideoDecoderFactory::CreateVideoDecoder();
|
decoder = webrtc::FakeVideoDecoderFactory::CreateVideoDecoder();
|
||||||
} else {
|
} else {
|
||||||
decoder = decoder_factory_->CreateVideoDecoder(format);
|
decoder = decoder_factory_->Create(env, format);
|
||||||
}
|
}
|
||||||
if (!params_.logging.encoded_frame_base_path.empty()) {
|
if (!params_.logging.encoded_frame_base_path.empty()) {
|
||||||
rtc::StringBuilder str;
|
rtc::StringBuilder str;
|
||||||
@ -375,9 +376,10 @@ VideoQualityTest::VideoQualityTest(
|
|||||||
std::unique_ptr<InjectionComponents> injection_components)
|
std::unique_ptr<InjectionComponents> injection_components)
|
||||||
: clock_(Clock::GetRealTimeClock()),
|
: clock_(Clock::GetRealTimeClock()),
|
||||||
task_queue_factory_(CreateDefaultTaskQueueFactory()),
|
task_queue_factory_(CreateDefaultTaskQueueFactory()),
|
||||||
video_decoder_factory_([this](const SdpVideoFormat& format) {
|
video_decoder_factory_(
|
||||||
return this->CreateVideoDecoder(format);
|
[this](const Environment& env, const SdpVideoFormat& format) {
|
||||||
}),
|
return this->CreateVideoDecoder(env, format);
|
||||||
|
}),
|
||||||
video_encoder_factory_([this](const SdpVideoFormat& format) {
|
video_encoder_factory_([this](const SdpVideoFormat& format) {
|
||||||
return this->CreateVideoEncoder(format, nullptr);
|
return this->CreateVideoEncoder(format, nullptr);
|
||||||
}),
|
}),
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "api/environment/environment.h"
|
||||||
#include "api/fec_controller.h"
|
#include "api/fec_controller.h"
|
||||||
#include "api/rtc_event_log/rtc_event_log_factory.h"
|
#include "api/rtc_event_log/rtc_event_log_factory.h"
|
||||||
#include "api/task_queue/task_queue_base.h"
|
#include "api/task_queue/task_queue_base.h"
|
||||||
@ -79,6 +80,7 @@ class VideoQualityTest : public test::CallTest,
|
|||||||
size_t video_idx);
|
size_t video_idx);
|
||||||
void SetupThumbnailCapturers(size_t num_thumbnail_streams);
|
void SetupThumbnailCapturers(size_t num_thumbnail_streams);
|
||||||
std::unique_ptr<VideoDecoder> CreateVideoDecoder(
|
std::unique_ptr<VideoDecoder> CreateVideoDecoder(
|
||||||
|
const Environment& env,
|
||||||
const SdpVideoFormat& format);
|
const SdpVideoFormat& format);
|
||||||
std::unique_ptr<VideoEncoder> CreateVideoEncoder(const SdpVideoFormat& format,
|
std::unique_ptr<VideoEncoder> CreateVideoEncoder(const SdpVideoFormat& format,
|
||||||
VideoAnalyzer* analyzer);
|
VideoAnalyzer* analyzer);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user