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}
diff --git a/modules/video_coding/codecs/h264/h264.cc b/modules/video_coding/codecs/h264/h264.cc
index 23580d7..5b9f033 100644
--- a/modules/video_coding/codecs/h264/h264.cc
+++ b/modules/video_coding/codecs/h264/h264.cc
@@ -121,6 +121,10 @@
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());
diff --git a/modules/video_coding/codecs/h264/h264_simulcast_unittest.cc b/modules/video_coding/codecs/h264/h264_simulcast_unittest.cc
index 2acb629..e191f51 100644
--- a/modules/video_coding/codecs/h264/h264_simulcast_unittest.cc
+++ b/modules/video_coding/codecs/h264/h264_simulcast_unittest.cc
@@ -24,7 +24,7 @@
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(); });
diff --git a/modules/video_coding/codecs/h264/include/h264.h b/modules/video_coding/codecs/h264/include/h264.h
index 2635b53..025a6ba 100644
--- a/modules/video_coding/codecs/h264/include/h264.h
+++ b/modules/video_coding/codecs/h264/include/h264.h
@@ -52,6 +52,7 @@
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);
diff --git a/modules/video_coding/codecs/h264/test/h264_impl_unittest.cc b/modules/video_coding/codecs/h264/test/h264_impl_unittest.cc
index 595e627..b8dc859 100644
--- a/modules/video_coding/codecs/h264/test/h264_impl_unittest.cc
+++ b/modules/video_coding/codecs/h264/test/h264_impl_unittest.cc
@@ -34,7 +34,7 @@
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 {
diff --git a/test/testsupport/ivf_video_frame_generator_unittest.cc b/test/testsupport/ivf_video_frame_generator_unittest.cc
index ca5e0b5..d6227b9 100644
--- a/test/testsupport/ivf_video_frame_generator_unittest.cc
+++ b/test/testsupport/ivf_video_frame_generator_unittest.cc
@@ -202,9 +202,7 @@
#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];
diff --git a/video/BUILD.gn b/video/BUILD.gn
index 0fec262..54291e4 100644
--- a/video/BUILD.gn
+++ b/video/BUILD.gn
@@ -841,6 +841,7 @@
"../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",
diff --git a/video/end_to_end_tests/codec_tests.cc b/video/end_to_end_tests/codec_tests.cc
index c56e7c5..60a0bc8 100644
--- a/video/end_to_end_tests/codec_tests.cc
+++ b/video/end_to_end_tests/codec_tests.cc
@@ -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 @@
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, 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, 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, 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); });
diff --git a/video/end_to_end_tests/multi_codec_receive_tests.cc b/video/end_to_end_tests/multi_codec_receive_tests.cc
index e850a11..377209b 100644
--- a/video/end_to_end_tests/multi_codec_receive_tests.cc
+++ b/video/end_to_end_tests/multi_codec_receive_tests.cc
@@ -207,7 +207,7 @@
return VP9Encoder::Create();
}
if (format.name == "H264") {
- return H264Encoder::Create(cricket::VideoCodec("H264"));
+ return H264Encoder::Create();
}
RTC_DCHECK_NOTREACHED() << format.name;
return nullptr;
diff --git a/video/quality_scaling_tests.cc b/video/quality_scaling_tests.cc
index b6f1575..c31e6b2 100644
--- a/video/quality_scaling_tests.cc
+++ b/video/quality_scaling_tests.cc
@@ -93,7 +93,7 @@
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;
}),
diff --git a/video/video_stream_encoder_unittest.cc b/video/video_stream_encoder_unittest.cc
index 2800f2b..b9d376d 100644
--- a/video/video_stream_encoder_unittest.cc
+++ b/video/video_stream_encoder_unittest.cc
@@ -8772,8 +8772,7 @@
encoder = CreateLibaomAv1Encoder();
break;
case kVideoCodecH264:
- encoder =
- H264Encoder::Create(cricket::VideoCodec(cricket::kH264CodecName));
+ encoder = H264Encoder::Create();
break;
case kVideoCodecMultiplex:
mock_encoder_factory_for_multiplex_ =