Add H264Encoder::Create()

Most of the usage of the H264Encoder::Create(codec) method passes a
simple codec with just the H264 codec name. This simplified the call
sites in many places and removes references to the codec types.

Bug: webrtc:15214
Change-Id: I4039c0be4ce6e3147c14c7853df4635f344b7d70
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/307222
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40214}
This commit is contained in:
Florent Castelli 2023-05-31 12:44:32 +00:00 committed by WebRTC LUCI CQ
parent 811e24a117
commit 5278b39fab
10 changed files with 20 additions and 13 deletions

View File

@ -121,6 +121,10 @@ std::vector<SdpVideoFormat> SupportedH264DecoderCodecs() {
return supportedCodecs;
}
std::unique_ptr<H264Encoder> H264Encoder::Create() {
return Create(cricket::CreateVideoCodec(cricket::kH264CodecName));
}
std::unique_ptr<H264Encoder> H264Encoder::Create(
const cricket::VideoCodec& codec) {
RTC_DCHECK(H264Encoder::IsSupported());

View File

@ -24,7 +24,7 @@ namespace {
std::unique_ptr<SimulcastTestFixture> CreateSpecificSimulcastTestFixture() {
std::unique_ptr<VideoEncoderFactory> encoder_factory =
std::make_unique<FunctionVideoEncoderFactory>(
[]() { return H264Encoder::Create(cricket::VideoCodec("H264")); });
[]() { return H264Encoder::Create(); });
std::unique_ptr<VideoDecoderFactory> decoder_factory =
std::make_unique<FunctionVideoDecoderFactory>(
[]() { return H264Decoder::Create(); });

View File

@ -52,6 +52,7 @@ std::vector<SdpVideoFormat> SupportedH264DecoderCodecs();
class RTC_EXPORT H264Encoder : public VideoEncoder {
public:
static std::unique_ptr<H264Encoder> Create(const cricket::VideoCodec& codec);
static std::unique_ptr<H264Encoder> Create();
// If H.264 is supported (any implementation).
static bool IsSupported();
static bool SupportsScalabilityMode(ScalabilityMode scalability_mode);

View File

@ -34,7 +34,7 @@ namespace webrtc {
class TestH264Impl : public VideoCodecUnitTest {
protected:
std::unique_ptr<VideoEncoder> CreateEncoder() override {
return H264Encoder::Create(cricket::VideoCodec(cricket::kH264CodecName));
return H264Encoder::Create();
}
std::unique_ptr<VideoDecoder> CreateDecoder() override {

View File

@ -202,9 +202,7 @@ TEST_F(IvfVideoFrameGeneratorTest, Vp9) {
#if defined(WEBRTC_USE_H264)
TEST_F(IvfVideoFrameGeneratorTest, H264) {
CreateTestVideoFile(
VideoCodecType::kVideoCodecH264,
H264Encoder::Create(cricket::VideoCodec(cricket::kH264CodecName)));
CreateTestVideoFile(VideoCodecType::kVideoCodecH264, H264Encoder::Create());
IvfVideoFrameGenerator generator(file_name_);
for (size_t i = 0; i < video_frames_.size(); ++i) {
auto& expected_frame = video_frames_[i];

View File

@ -841,6 +841,7 @@ if (rtc_include_tests) {
"../call/adaptation:resource_adaptation_test_utilities",
"../common_video",
"../common_video/test:utilities",
"../media:codec",
"../media:media_constants",
"../media:rtc_audio_video",
"../media:rtc_internal_video_codecs",

View File

@ -15,6 +15,8 @@
#include "api/video/color_space.h"
#include "api/video/video_rotation.h"
#include "common_video/test/utilities.h"
#include "media/base/codec.h"
#include "media/base/media_constants.h"
#include "media/engine/internal_decoder_factory.h"
#include "media/engine/internal_encoder_factory.h"
#include "modules/video_coding/codecs/h264/include/h264.h"
@ -245,7 +247,7 @@ INSTANTIATE_TEST_SUITE_P(
TEST_P(EndToEndTestH264, SendsAndReceivesH264) {
test::FunctionVideoEncoderFactory encoder_factory(
[]() { return H264Encoder::Create(cricket::VideoCodec("H264")); });
[]() { return H264Encoder::Create(); });
test::FunctionVideoDecoderFactory decoder_factory(
[]() { return H264Decoder::Create(); });
CodecObserver test(500, kVideoRotation_0, absl::nullopt, "H264",
@ -255,7 +257,7 @@ TEST_P(EndToEndTestH264, SendsAndReceivesH264) {
TEST_P(EndToEndTestH264, SendsAndReceivesH264VideoRotation90) {
test::FunctionVideoEncoderFactory encoder_factory(
[]() { return H264Encoder::Create(cricket::VideoCodec("H264")); });
[]() { return H264Encoder::Create(); });
test::FunctionVideoDecoderFactory decoder_factory(
[]() { return H264Decoder::Create(); });
CodecObserver test(5, kVideoRotation_90, absl::nullopt, "H264",
@ -264,7 +266,8 @@ TEST_P(EndToEndTestH264, SendsAndReceivesH264VideoRotation90) {
}
TEST_P(EndToEndTestH264, SendsAndReceivesH264PacketizationMode0) {
cricket::VideoCodec codec = cricket::VideoCodec("H264");
cricket::VideoCodec codec =
cricket::CreateVideoCodec(cricket::kH264CodecName);
codec.SetParam(cricket::kH264FmtpPacketizationMode, "0");
test::FunctionVideoEncoderFactory encoder_factory(
[codec]() { return H264Encoder::Create(codec); });
@ -276,7 +279,8 @@ TEST_P(EndToEndTestH264, SendsAndReceivesH264PacketizationMode0) {
}
TEST_P(EndToEndTestH264, SendsAndReceivesH264PacketizationMode1) {
cricket::VideoCodec codec = cricket::VideoCodec("H264");
cricket::VideoCodec codec =
cricket::CreateVideoCodec(cricket::kH264CodecName);
codec.SetParam(cricket::kH264FmtpPacketizationMode, "1");
test::FunctionVideoEncoderFactory encoder_factory(
[codec]() { return H264Encoder::Create(codec); });

View File

@ -207,7 +207,7 @@ void MultiCodecReceiveTest::RunTestWithCodecs(
return VP9Encoder::Create();
}
if (format.name == "H264") {
return H264Encoder::Create(cricket::VideoCodec("H264"));
return H264Encoder::Create();
}
RTC_DCHECK_NOTREACHED() << format.name;
return nullptr;

View File

@ -93,7 +93,7 @@ class ScalingObserver : public test::SendTest {
if (format.name == "VP9")
return VP9Encoder::Create();
if (format.name == "H264")
return H264Encoder::Create(cricket::VideoCodec("H264"));
return H264Encoder::Create();
RTC_DCHECK_NOTREACHED() << format.name;
return nullptr;
}),

View File

@ -8772,8 +8772,7 @@ class VideoStreamEncoderWithRealEncoderTest
encoder = CreateLibaomAv1Encoder();
break;
case kVideoCodecH264:
encoder =
H264Encoder::Create(cricket::VideoCodec(cricket::kH264CodecName));
encoder = H264Encoder::Create();
break;
case kVideoCodecMultiplex:
mock_encoder_factory_for_multiplex_ =