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}
This commit is contained in:
parent
6f68254ac3
commit
80256a017d
@ -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 @@ std::vector<SdpVideoFormat> InternalEncoderFactory::GetSupportedFormats()
|
||||
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(
|
||||
|
||||
@ -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 @@ class RTC_EXPORT InternalEncoderFactory : public VideoEncoderFactory {
|
||||
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
|
||||
|
||||
@ -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 @@ MATCHER_P(Support, expected, "") {
|
||||
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 @@ TEST(InternalEncoderFactoryTest, Vp9Profile0) {
|
||||
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 @@ TEST(InternalEncoderFactoryTest, H264) {
|
||||
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 @@ TEST(InternalEncoderFactoryTest, H264) {
|
||||
// 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 @@ TEST(InternalEncoderFactoryTest, Av1) {
|
||||
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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user