Update InternalEncoderFactory to implement non-deprecated variant of CreateVideoEncoder
Bug: webrtc:15860
Change-Id: I7511ac501bdcb6319546265c6212a639576859d7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/343764
Auto-Submit: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41988}
diff --git a/media/engine/internal_encoder_factory.cc b/media/engine/internal_encoder_factory.cc
index 7b5fc24..398926a 100644
--- a/media/engine/internal_encoder_factory.cc
+++ b/media/engine/internal_encoder_factory.cc
@@ -14,7 +14,9 @@
#include <string>
#include <vector>
-#include "absl/strings/match.h"
+#include "absl/types/optional.h"
+#include "api/environment/environment.h"
+#include "api/video_codecs/sdp_video_format.h"
#include "api/video_codecs/video_encoder_factory.h"
#include "api/video_codecs/video_encoder_factory_template.h"
#if defined(RTC_USE_LIBAOM_AV1_ENCODER)
@@ -45,12 +47,12 @@
return Factory().GetSupportedFormats();
}
-std::unique_ptr<VideoEncoder> InternalEncoderFactory::CreateVideoEncoder(
+std::unique_ptr<VideoEncoder> InternalEncoderFactory::Create(
+ const Environment& env,
const SdpVideoFormat& format) {
auto original_format =
FuzzyMatchSdpVideoFormat(Factory().GetSupportedFormats(), format);
- return original_format ? Factory().CreateVideoEncoder(*original_format)
- : nullptr;
+ return original_format ? Factory().Create(env, *original_format) : nullptr;
}
VideoEncoderFactory::CodecSupport InternalEncoderFactory::QueryCodecSupport(
diff --git a/media/engine/internal_encoder_factory.h b/media/engine/internal_encoder_factory.h
index 25480d0..1d79d3c 100644
--- a/media/engine/internal_encoder_factory.h
+++ b/media/engine/internal_encoder_factory.h
@@ -15,6 +15,9 @@
#include <string>
#include <vector>
+#include "absl/types/optional.h"
+#include "api/environment/environment.h"
+#include "api/video_codecs/sdp_video_format.h"
#include "api/video_codecs/video_encoder_factory.h"
#include "rtc_base/system/rtc_export.h"
@@ -25,8 +28,8 @@
CodecSupport QueryCodecSupport(
const SdpVideoFormat& format,
absl::optional<std::string> scalability_mode) const override;
- std::unique_ptr<VideoEncoder> CreateVideoEncoder(
- const SdpVideoFormat& format) override;
+ std::unique_ptr<VideoEncoder> Create(const Environment& env,
+ const SdpVideoFormat& format) override;
};
} // namespace webrtc
diff --git a/media/engine/internal_encoder_factory_unittest.cc b/media/engine/internal_encoder_factory_unittest.cc
index 7846bd3..c13c528 100644
--- a/media/engine/internal_encoder_factory_unittest.cc
+++ b/media/engine/internal_encoder_factory_unittest.cc
@@ -10,6 +10,7 @@
#include "media/engine/internal_encoder_factory.h"
+#include "api/environment/environment_factory.h"
#include "api/video_codecs/sdp_video_format.h"
#include "api/video_codecs/video_encoder.h"
#include "api/video_codecs/vp9_profile.h"
@@ -48,7 +49,7 @@
TEST(InternalEncoderFactoryTest, Vp8) {
InternalEncoderFactory factory;
std::unique_ptr<VideoEncoder> encoder =
- factory.CreateVideoEncoder(SdpVideoFormat::VP8());
+ factory.Create(CreateEnvironment(), SdpVideoFormat::VP8());
EXPECT_TRUE(encoder);
}
@@ -56,7 +57,7 @@
InternalEncoderFactory factory;
if (kVp9Enabled) {
std::unique_ptr<VideoEncoder> encoder =
- factory.CreateVideoEncoder(SdpVideoFormat::VP9Profile0());
+ factory.Create(CreateEnvironment(), SdpVideoFormat::VP9Profile0());
EXPECT_TRUE(encoder);
} else {
EXPECT_THAT(
@@ -69,7 +70,7 @@
InternalEncoderFactory factory;
if (kH264Enabled) {
std::unique_ptr<VideoEncoder> encoder =
- factory.CreateVideoEncoder(SdpVideoFormat::H264());
+ factory.Create(CreateEnvironment(), SdpVideoFormat::H264());
EXPECT_TRUE(encoder);
} else {
EXPECT_THAT(
@@ -81,8 +82,8 @@
// At current stage H.265 is not supported by internal encoder factory.
TEST(InternalEncoderFactoryTest, H265IsNotEnabled) {
InternalEncoderFactory factory;
- std::unique_ptr<VideoEncoder> encoder =
- factory.CreateVideoEncoder(SdpVideoFormat(cricket::kH265CodecName));
+ std::unique_ptr<VideoEncoder> encoder = factory.Create(
+ CreateEnvironment(), SdpVideoFormat(cricket::kH265CodecName));
EXPECT_EQ(static_cast<bool>(encoder), kH265Enabled);
EXPECT_THAT(
factory.GetSupportedFormats(),
@@ -113,7 +114,8 @@
InternalEncoderFactory factory;
EXPECT_THAT(factory.GetSupportedFormats(),
Contains(Field(&SdpVideoFormat::name, cricket::kAv1CodecName)));
- EXPECT_TRUE(factory.CreateVideoEncoder(SdpVideoFormat::AV1Profile0()));
+ EXPECT_TRUE(
+ factory.Create(CreateEnvironment(), SdpVideoFormat::AV1Profile0()));
}
TEST(InternalEncoderFactoryTest, QueryCodecSupportNoScalabilityModeAv1) {