Introduce "well-known" SdpVideoFormat codecs

describing video codecs with their parameters as static members of SdpVideoFormat:
  static const SdpVideoFormat VP8();
  static const SdpVideoFormat H264();
  static const SdpVideoFormat VP9Profile0();
  static const SdpVideoFormat VP9Profile1();
  static const SdpVideoFormat VP9Profile2();
  static const SdpVideoFormat VP9Profile3();
  static const SdpVideoFormat AV1Profile0();
  static const SdpVideoFormat AV1Profile1();
This removes the need to craft instances of these by hand.

BUG=webrtc:15703

Change-Id: I2171e08b48ec98f18424f53f3b5d6d148130532e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/337441
Commit-Queue: Philipp Hancke <phancke@microsoft.com>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41833}
This commit is contained in:
Philipp Hancke 2024-02-27 12:18:33 +01:00 committed by WebRTC LUCI CQ
parent 2825f0a7bb
commit bbff58d935
26 changed files with 151 additions and 109 deletions

View file

@ -192,6 +192,60 @@ bool operator==(const SdpVideoFormat& a, const SdpVideoFormat& b) {
a.scalability_modes == b.scalability_modes; a.scalability_modes == b.scalability_modes;
} }
const SdpVideoFormat SdpVideoFormat::VP8() {
return SdpVideoFormat(cricket::kVp8CodecName, {});
}
const SdpVideoFormat SdpVideoFormat::H264() {
// H264 will typically require more tweaking like setting
// * packetization-mode (which defaults to 0 but 1 is more common)
// * level-asymmetry-allowed (which defaults to 0 but 1 is more common)
// * profile-level-id of which there are many.
return SdpVideoFormat(cricket::kH264CodecName, {});
}
const SdpVideoFormat SdpVideoFormat::VP9Profile0() {
return SdpVideoFormat(
cricket::kVp9CodecName,
{{kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile0)}});
}
const SdpVideoFormat SdpVideoFormat::VP9Profile1() {
return SdpVideoFormat(
cricket::kVp9CodecName,
{{kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile1)}});
}
const SdpVideoFormat SdpVideoFormat::VP9Profile2() {
return SdpVideoFormat(
cricket::kVp9CodecName,
{{kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile2)}});
}
const SdpVideoFormat SdpVideoFormat::VP9Profile3() {
return SdpVideoFormat(
cricket::kVp9CodecName,
{{kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile3)}});
}
const SdpVideoFormat SdpVideoFormat::AV1Profile0() {
// https://aomediacodec.github.io/av1-rtp-spec/#72-sdp-parameters
return SdpVideoFormat(cricket::kAv1CodecName,
{{cricket::kAv1FmtpProfile,
AV1ProfileToString(AV1Profile::kProfile0).data()},
{cricket::kAv1FmtpLevelIdx, "5"},
{cricket::kAv1FmtpTier, "0"}});
}
const SdpVideoFormat SdpVideoFormat::AV1Profile1() {
// https://aomediacodec.github.io/av1-rtp-spec/#72-sdp-parameters
return SdpVideoFormat(cricket::kAv1CodecName,
{{cricket::kAv1FmtpProfile,
AV1ProfileToString(AV1Profile::kProfile1).data()},
{cricket::kAv1FmtpLevelIdx, "5"},
{cricket::kAv1FmtpTier, "0"}});
}
absl::optional<SdpVideoFormat> FuzzyMatchSdpVideoFormat( absl::optional<SdpVideoFormat> FuzzyMatchSdpVideoFormat(
rtc::ArrayView<const SdpVideoFormat> supported_formats, rtc::ArrayView<const SdpVideoFormat> supported_formats,
const SdpVideoFormat& format) { const SdpVideoFormat& format) {

View file

@ -62,6 +62,16 @@ struct RTC_EXPORT SdpVideoFormat {
std::string name; std::string name;
CodecParameterMap parameters; CodecParameterMap parameters;
absl::InlinedVector<ScalabilityMode, kScalabilityModeCount> scalability_modes; absl::InlinedVector<ScalabilityMode, kScalabilityModeCount> scalability_modes;
// Well-known video codecs and their format parameters.
static const SdpVideoFormat VP8();
static const SdpVideoFormat H264();
static const SdpVideoFormat VP9Profile0();
static const SdpVideoFormat VP9Profile1();
static const SdpVideoFormat VP9Profile2();
static const SdpVideoFormat VP9Profile3();
static const SdpVideoFormat AV1Profile0();
static const SdpVideoFormat AV1Profile1();
}; };
// For not so good reasons sometimes additional parameters are added to an // For not so good reasons sometimes additional parameters are added to an

View file

@ -21,7 +21,7 @@
namespace webrtc { namespace webrtc {
struct LibvpxVp8DecoderTemplateAdapter { struct LibvpxVp8DecoderTemplateAdapter {
static std::vector<SdpVideoFormat> SupportedFormats() { static std::vector<SdpVideoFormat> SupportedFormats() {
return {SdpVideoFormat("VP8")}; return {SdpVideoFormat::VP8()};
} }
static std::unique_ptr<VideoDecoder> CreateDecoder( static std::unique_ptr<VideoDecoder> CreateDecoder(

View file

@ -1188,7 +1188,7 @@ TEST_F(CallPerfTest, TestEncodeFramerateVp8Simulcast) {
test::FunctionVideoEncoderFactory encoder_factory( test::FunctionVideoEncoderFactory encoder_factory(
[&internal_encoder_factory]() { [&internal_encoder_factory]() {
return std::make_unique<SimulcastEncoderAdapter>( return std::make_unique<SimulcastEncoderAdapter>(
&internal_encoder_factory, SdpVideoFormat("VP8")); &internal_encoder_factory, SdpVideoFormat::VP8());
}); });
TestEncodeFramerate(&encoder_factory, "VP8", TestEncodeFramerate(&encoder_factory, "VP8",
@ -1200,7 +1200,7 @@ TEST_F(CallPerfTest, TestEncodeFramerateVp8SimulcastLowerInputFps) {
test::FunctionVideoEncoderFactory encoder_factory( test::FunctionVideoEncoderFactory encoder_factory(
[&internal_encoder_factory]() { [&internal_encoder_factory]() {
return std::make_unique<SimulcastEncoderAdapter>( return std::make_unique<SimulcastEncoderAdapter>(
&internal_encoder_factory, SdpVideoFormat("VP8")); &internal_encoder_factory, SdpVideoFormat::VP8());
}); });
TestEncodeFramerate(&encoder_factory, "VP8", TestEncodeFramerate(&encoder_factory, "VP8",

View file

@ -44,18 +44,15 @@ std::unique_ptr<VideoDecoder> CreateDav1dDecoder() {
std::vector<SdpVideoFormat> InternalDecoderFactory::GetSupportedFormats() std::vector<SdpVideoFormat> InternalDecoderFactory::GetSupportedFormats()
const { const {
std::vector<SdpVideoFormat> formats; std::vector<SdpVideoFormat> formats;
formats.push_back(SdpVideoFormat(cricket::kVp8CodecName)); formats.push_back(SdpVideoFormat::VP8());
for (const SdpVideoFormat& format : SupportedVP9DecoderCodecs()) for (const SdpVideoFormat& format : SupportedVP9DecoderCodecs())
formats.push_back(format); formats.push_back(format);
for (const SdpVideoFormat& h264_format : SupportedH264DecoderCodecs()) for (const SdpVideoFormat& h264_format : SupportedH264DecoderCodecs())
formats.push_back(h264_format); formats.push_back(h264_format);
if (kDav1dIsIncluded) { if (kDav1dIsIncluded) {
formats.push_back(SdpVideoFormat(cricket::kAv1CodecName)); formats.push_back(SdpVideoFormat::AV1Profile0());
formats.push_back( formats.push_back(SdpVideoFormat::AV1Profile1());
SdpVideoFormat(cricket::kAv1CodecName,
{{cricket::kAv1FmtpProfile,
AV1ProfileToString(AV1Profile::kProfile1).data()}}));
} }
return formats; return formats;

View file

@ -61,27 +61,23 @@ TEST(InternalDecoderFactoryTest, Vp8) {
const Environment env = CreateEnvironment(); const Environment env = CreateEnvironment();
InternalDecoderFactory factory; InternalDecoderFactory factory;
std::unique_ptr<VideoDecoder> decoder = std::unique_ptr<VideoDecoder> decoder =
factory.Create(env, SdpVideoFormat(cricket::kVp8CodecName)); factory.Create(env, SdpVideoFormat::VP8());
EXPECT_TRUE(decoder); EXPECT_TRUE(decoder);
} }
TEST(InternalDecoderFactoryTest, Vp9Profile0) { TEST(InternalDecoderFactoryTest, Vp9Profile0) {
const Environment env = CreateEnvironment(); const Environment env = CreateEnvironment();
InternalDecoderFactory factory; InternalDecoderFactory factory;
std::unique_ptr<VideoDecoder> decoder = factory.Create( std::unique_ptr<VideoDecoder> decoder =
env, SdpVideoFormat(cricket::kVp9CodecName, factory.Create(env, SdpVideoFormat::VP9Profile0());
{{kVP9FmtpProfileId,
VP9ProfileToString(VP9Profile::kProfile0)}}));
EXPECT_EQ(static_cast<bool>(decoder), kVp9Enabled); EXPECT_EQ(static_cast<bool>(decoder), kVp9Enabled);
} }
TEST(InternalDecoderFactoryTest, Vp9Profile1) { TEST(InternalDecoderFactoryTest, Vp9Profile1) {
const Environment env = CreateEnvironment(); const Environment env = CreateEnvironment();
InternalDecoderFactory factory; InternalDecoderFactory factory;
std::unique_ptr<VideoDecoder> decoder = factory.Create( std::unique_ptr<VideoDecoder> decoder =
env, SdpVideoFormat(cricket::kVp9CodecName, factory.Create(env, SdpVideoFormat::VP9Profile1());
{{kVP9FmtpProfileId,
VP9ProfileToString(VP9Profile::kProfile1)}}));
EXPECT_EQ(static_cast<bool>(decoder), kVp9Enabled); EXPECT_EQ(static_cast<bool>(decoder), kVp9Enabled);
} }
@ -89,7 +85,7 @@ TEST(InternalDecoderFactoryTest, H264) {
const Environment env = CreateEnvironment(); const Environment env = CreateEnvironment();
InternalDecoderFactory factory; InternalDecoderFactory factory;
std::unique_ptr<VideoDecoder> decoder = std::unique_ptr<VideoDecoder> decoder =
factory.Create(env, SdpVideoFormat(cricket::kH264CodecName)); factory.Create(env, SdpVideoFormat::H264());
EXPECT_EQ(static_cast<bool>(decoder), kH264Enabled); EXPECT_EQ(static_cast<bool>(decoder), kH264Enabled);
} }
@ -99,7 +95,7 @@ TEST(InternalDecoderFactoryTest, Av1Profile0) {
if (kDav1dIsIncluded) { if (kDav1dIsIncluded) {
EXPECT_THAT(factory.GetSupportedFormats(), EXPECT_THAT(factory.GetSupportedFormats(),
Contains(Field(&SdpVideoFormat::name, cricket::kAv1CodecName))); Contains(Field(&SdpVideoFormat::name, cricket::kAv1CodecName)));
EXPECT_TRUE(factory.Create(env, SdpVideoFormat(cricket::kAv1CodecName))); EXPECT_TRUE(factory.Create(env, SdpVideoFormat::AV1Profile0()));
} else { } else {
EXPECT_THAT( EXPECT_THAT(
factory.GetSupportedFormats(), factory.GetSupportedFormats(),
@ -127,53 +123,51 @@ TEST(InternalDecoderFactoryTest, Av1) {
TEST(InternalDecoderFactoryTest, Av1Profile1_Dav1dDecoderTrialEnabled) { TEST(InternalDecoderFactoryTest, Av1Profile1_Dav1dDecoderTrialEnabled) {
const Environment env = CreateEnvironment(); const Environment env = CreateEnvironment();
InternalDecoderFactory factory; InternalDecoderFactory factory;
std::unique_ptr<VideoDecoder> decoder = factory.Create( std::unique_ptr<VideoDecoder> decoder =
env, factory.Create(env, SdpVideoFormat::AV1Profile1());
SdpVideoFormat(cricket::kAv1CodecName,
{{cricket::kAv1FmtpProfile,
AV1ProfileToString(AV1Profile::kProfile1).data()}}));
EXPECT_EQ(static_cast<bool>(decoder), kDav1dIsIncluded); EXPECT_EQ(static_cast<bool>(decoder), kDav1dIsIncluded);
} }
TEST(InternalDecoderFactoryTest, QueryCodecSupportNoReferenceScaling) { TEST(InternalDecoderFactoryTest, QueryCodecSupportNoReferenceScaling) {
InternalDecoderFactory factory; InternalDecoderFactory factory;
EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat(cricket::kVp8CodecName), EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat::VP8(),
/*reference_scaling=*/false), /*reference_scaling=*/false),
Support(kSupported)); Support(kSupported));
EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat(cricket::kVp9CodecName), EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat::VP9Profile0(),
/*reference_scaling=*/false), /*reference_scaling=*/false),
Support(kVp9Enabled ? kSupported : kUnsupported)); Support(kVp9Enabled ? kSupported : kUnsupported));
EXPECT_THAT(factory.QueryCodecSupport( EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat::VP9Profile1(),
SdpVideoFormat(cricket::kVp9CodecName, /*reference_scaling=*/false),
{{kVP9FmtpProfileId,
VP9ProfileToString(VP9Profile::kProfile1)}}),
/*reference_scaling=*/false),
Support(kVp9Enabled ? kSupported : kUnsupported)); Support(kVp9Enabled ? kSupported : kUnsupported));
#if defined(RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY) #if defined(RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY)
EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat(cricket::kAv1CodecName), EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat::AV1Profile0(),
/*reference_scaling=*/false), /*reference_scaling=*/false),
Support(kSupported)); Support(kSupported));
EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat::AV1Profile1(),
/*reference_scaling=*/false),
Support(kSupported));
#endif #endif
} }
TEST(InternalDecoderFactoryTest, QueryCodecSupportReferenceScaling) { TEST(InternalDecoderFactoryTest, QueryCodecSupportReferenceScaling) {
InternalDecoderFactory factory; InternalDecoderFactory factory;
// VP9 and AV1 support for spatial layers. // VP9 and AV1 support for spatial layers.
EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat(cricket::kVp9CodecName), EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat::VP9Profile0(),
/*reference_scaling=*/true), /*reference_scaling=*/true),
Support(kVp9Enabled ? kSupported : kUnsupported)); Support(kVp9Enabled ? kSupported : kUnsupported));
#if defined(RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY) #if defined(RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY)
EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat(cricket::kAv1CodecName), EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat::AV1Profile0(),
/*reference_scaling=*/true), /*reference_scaling=*/true),
Support(kSupported)); Support(kSupported));
#endif #endif
// Invalid config even though VP8 and H264 are supported. // Invalid config even though VP8 and H264 are supported.
EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat(cricket::kH264CodecName), EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat::H264(),
/*reference_scaling=*/true), /*reference_scaling=*/true),
Support(kUnsupported)); Support(kUnsupported));
EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat(cricket::kVp8CodecName), EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat::VP8(),
/*reference_scaling=*/true), /*reference_scaling=*/true),
Support(kUnsupported)); Support(kUnsupported));
} }

View file

@ -48,7 +48,7 @@ MATCHER_P(Support, expected, "") {
TEST(InternalEncoderFactoryTest, Vp8) { TEST(InternalEncoderFactoryTest, Vp8) {
InternalEncoderFactory factory; InternalEncoderFactory factory;
std::unique_ptr<VideoEncoder> encoder = std::unique_ptr<VideoEncoder> encoder =
factory.CreateVideoEncoder(SdpVideoFormat(cricket::kVp8CodecName)); factory.CreateVideoEncoder(SdpVideoFormat::VP8());
EXPECT_TRUE(encoder); EXPECT_TRUE(encoder);
} }
@ -56,9 +56,7 @@ TEST(InternalEncoderFactoryTest, Vp9Profile0) {
InternalEncoderFactory factory; InternalEncoderFactory factory;
if (kVp9Enabled) { if (kVp9Enabled) {
std::unique_ptr<VideoEncoder> encoder = std::unique_ptr<VideoEncoder> encoder =
factory.CreateVideoEncoder(SdpVideoFormat( factory.CreateVideoEncoder(SdpVideoFormat::VP9Profile0());
cricket::kVp9CodecName,
{{kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile0)}}));
EXPECT_TRUE(encoder); EXPECT_TRUE(encoder);
} else { } else {
EXPECT_THAT( EXPECT_THAT(
@ -71,7 +69,7 @@ TEST(InternalEncoderFactoryTest, H264) {
InternalEncoderFactory factory; InternalEncoderFactory factory;
if (kH264Enabled) { if (kH264Enabled) {
std::unique_ptr<VideoEncoder> encoder = std::unique_ptr<VideoEncoder> encoder =
factory.CreateVideoEncoder(SdpVideoFormat(cricket::kH264CodecName)); factory.CreateVideoEncoder(SdpVideoFormat::H264());
EXPECT_TRUE(encoder); EXPECT_TRUE(encoder);
} else { } else {
EXPECT_THAT( EXPECT_THAT(
@ -94,25 +92,20 @@ TEST(InternalEncoderFactoryTest, H265IsNotEnabled) {
TEST(InternalEncoderFactoryTest, QueryCodecSupportWithScalabilityMode) { TEST(InternalEncoderFactoryTest, QueryCodecSupportWithScalabilityMode) {
InternalEncoderFactory factory; InternalEncoderFactory factory;
// VP8 and VP9 supported for singles spatial layers. // VP8 and VP9 supported for singles spatial layers.
EXPECT_THAT( EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat::VP8(), "L1T2"),
factory.QueryCodecSupport(SdpVideoFormat(cricket::kVp8CodecName), "L1T2"), Support(kSupported));
Support(kSupported)); EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat::VP9Profile0(), "L1T3"),
EXPECT_THAT( Support(kVp9Enabled ? kSupported : kUnsupported));
factory.QueryCodecSupport(SdpVideoFormat(cricket::kVp9CodecName), "L1T3"),
Support(kVp9Enabled ? kSupported : kUnsupported));
// VP9 support for spatial layers. // VP9 support for spatial layers.
EXPECT_THAT( EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat::VP9Profile0(), "L3T3"),
factory.QueryCodecSupport(SdpVideoFormat(cricket::kVp9CodecName), "L3T3"), Support(kVp9Enabled ? kSupported : kUnsupported));
Support(kVp9Enabled ? kSupported : kUnsupported));
// Invalid scalability modes even though VP8 and H264 are supported. // Invalid scalability modes even though VP8 and H264 are supported.
EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat(cricket::kH264CodecName), EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat::H264(), "L2T2"),
"L2T2"), Support(kUnsupported));
EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat::VP8(), "L3T3"),
Support(kUnsupported)); Support(kUnsupported));
EXPECT_THAT(
factory.QueryCodecSupport(SdpVideoFormat(cricket::kVp8CodecName), "L3T3"),
Support(kUnsupported));
} }
#if defined(RTC_USE_LIBAOM_AV1_ENCODER) #if defined(RTC_USE_LIBAOM_AV1_ENCODER)
@ -120,32 +113,30 @@ TEST(InternalEncoderFactoryTest, Av1) {
InternalEncoderFactory factory; InternalEncoderFactory factory;
EXPECT_THAT(factory.GetSupportedFormats(), EXPECT_THAT(factory.GetSupportedFormats(),
Contains(Field(&SdpVideoFormat::name, cricket::kAv1CodecName))); Contains(Field(&SdpVideoFormat::name, cricket::kAv1CodecName)));
EXPECT_TRUE( EXPECT_TRUE(factory.CreateVideoEncoder(SdpVideoFormat::AV1Profile0()));
factory.CreateVideoEncoder(SdpVideoFormat(cricket::kAv1CodecName)));
} }
TEST(InternalEncoderFactoryTest, QueryCodecSupportNoScalabilityModeAv1) { TEST(InternalEncoderFactoryTest, QueryCodecSupportNoScalabilityModeAv1) {
InternalEncoderFactory factory; InternalEncoderFactory factory;
EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat(cricket::kAv1CodecName), EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat::AV1Profile0(),
/*scalability_mode=*/absl::nullopt), /*scalability_mode=*/absl::nullopt),
Support(kSupported)); Support(kSupported));
} }
TEST(InternalEncoderFactoryTest, QueryCodecSupportNoScalabilityMode) { TEST(InternalEncoderFactoryTest, QueryCodecSupportNoScalabilityMode) {
InternalEncoderFactory factory; InternalEncoderFactory factory;
EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat(cricket::kVp8CodecName), EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat::VP8(),
/*scalability_mode=*/absl::nullopt), /*scalability_mode=*/absl::nullopt),
Support(kSupported)); Support(kSupported));
EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat(cricket::kVp9CodecName), EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat::VP9Profile0(),
/*scalability_mode=*/absl::nullopt), /*scalability_mode=*/absl::nullopt),
Support(kVp9Enabled ? kSupported : kUnsupported)); Support(kVp9Enabled ? kSupported : kUnsupported));
} }
TEST(InternalEncoderFactoryTest, QueryCodecSupportWithScalabilityModeAv1) { TEST(InternalEncoderFactoryTest, QueryCodecSupportWithScalabilityModeAv1) {
InternalEncoderFactory factory; InternalEncoderFactory factory;
EXPECT_THAT( EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat::AV1Profile0(), "L2T1"),
factory.QueryCodecSupport(SdpVideoFormat(cricket::kAv1CodecName), "L2T1"), Support(kSupported));
Support(kSupported));
} }
#endif // defined(RTC_USE_LIBAOM_AV1_ENCODER) #endif // defined(RTC_USE_LIBAOM_AV1_ENCODER)

View file

@ -58,8 +58,7 @@ std::unique_ptr<SimulcastTestFixture> CreateSpecificSimulcastTestFixture(
std::make_unique<FunctionVideoEncoderFactory>( std::make_unique<FunctionVideoEncoderFactory>(
[internal_encoder_factory]() { [internal_encoder_factory]() {
return std::make_unique<SimulcastEncoderAdapter>( return std::make_unique<SimulcastEncoderAdapter>(
internal_encoder_factory, internal_encoder_factory, SdpVideoFormat::VP8());
SdpVideoFormat(cricket::kVp8CodecName));
}); });
std::unique_ptr<VideoDecoderFactory> decoder_factory = std::unique_ptr<VideoDecoderFactory> decoder_factory =
std::make_unique<FunctionVideoDecoderFactory>( std::make_unique<FunctionVideoDecoderFactory>(
@ -68,7 +67,7 @@ std::unique_ptr<SimulcastTestFixture> CreateSpecificSimulcastTestFixture(
}); });
return CreateSimulcastTestFixture(std::move(encoder_factory), return CreateSimulcastTestFixture(std::move(encoder_factory),
std::move(decoder_factory), std::move(decoder_factory),
SdpVideoFormat(cricket::kVp8CodecName)); SdpVideoFormat::VP8());
} }
} // namespace } // namespace
@ -355,8 +354,7 @@ class MockVideoEncoder : public VideoEncoder {
std::vector<SdpVideoFormat> MockVideoEncoderFactory::GetSupportedFormats() std::vector<SdpVideoFormat> MockVideoEncoderFactory::GetSupportedFormats()
const { const {
std::vector<SdpVideoFormat> formats = {SdpVideoFormat("VP8")}; return {SdpVideoFormat::VP8()};
return formats;
} }
std::unique_ptr<VideoEncoder> MockVideoEncoderFactory::CreateVideoEncoder( std::unique_ptr<VideoEncoder> MockVideoEncoderFactory::CreateVideoEncoder(

View file

@ -1623,7 +1623,7 @@ class WebRtcVideoChannelEncodedFrameCallbackTest : public ::testing::Test {
const std::vector<webrtc::SdpVideoFormat> const std::vector<webrtc::SdpVideoFormat>
WebRtcVideoChannelEncodedFrameCallbackTest::kSdpVideoFormats = { WebRtcVideoChannelEncodedFrameCallbackTest::kSdpVideoFormats = {
webrtc::SdpVideoFormat("VP8")}; webrtc::SdpVideoFormat::VP8()};
TEST_F(WebRtcVideoChannelEncodedFrameCallbackTest, TEST_F(WebRtcVideoChannelEncodedFrameCallbackTest,
SetEncodedFrameBufferFunction_DefaultStream) { SetEncodedFrameBufferFunction_DefaultStream) {
@ -2564,9 +2564,8 @@ TEST_F(WebRtcVideoChannelBaseTest, RequestEncoderSwitchStrictPreference) {
ASSERT_TRUE(codec); ASSERT_TRUE(codec);
EXPECT_EQ("VP8", codec->name); EXPECT_EQ("VP8", codec->name);
SendImpl()->RequestEncoderSwitch( SendImpl()->RequestEncoderSwitch(webrtc::SdpVideoFormat::VP9Profile1(),
webrtc::SdpVideoFormat("VP9", {{"profile-id", "1"}}), /*allow_default_fallback=*/false);
/*allow_default_fallback=*/false);
time_controller_.AdvanceTime(kFrameDuration); time_controller_.AdvanceTime(kFrameDuration);
// VP9 profile_id=1 is not available. Default fallback is not allowed. Switch // VP9 profile_id=1 is not available. Default fallback is not allowed. Switch
@ -2575,9 +2574,8 @@ TEST_F(WebRtcVideoChannelBaseTest, RequestEncoderSwitchStrictPreference) {
ASSERT_TRUE(codec); ASSERT_TRUE(codec);
EXPECT_EQ("VP8", codec->name); EXPECT_EQ("VP8", codec->name);
SendImpl()->RequestEncoderSwitch( SendImpl()->RequestEncoderSwitch(webrtc::SdpVideoFormat::VP9Profile0(),
webrtc::SdpVideoFormat("VP9", {{"profile-id", "0"}}), /*allow_default_fallback=*/false);
/*allow_default_fallback=*/false);
time_controller_.AdvanceTime(kFrameDuration); time_controller_.AdvanceTime(kFrameDuration);
// VP9 profile_id=0 is available. Switch encoder. // VP9 profile_id=0 is available. Switch encoder.
@ -9769,7 +9767,7 @@ TEST_F(WebRtcVideoChannelBaseTest, EncoderSelectorSwitchCodec) {
webrtc::MockEncoderSelector encoder_selector; webrtc::MockEncoderSelector encoder_selector;
EXPECT_CALL(encoder_selector, OnAvailableBitrate) EXPECT_CALL(encoder_selector, OnAvailableBitrate)
.WillRepeatedly(Return(webrtc::SdpVideoFormat("VP9"))); .WillRepeatedly(Return(webrtc::SdpVideoFormat::VP9Profile0()));
send_channel_->SetEncoderSelector(kSsrc, &encoder_selector); send_channel_->SetEncoderSelector(kSsrc, &encoder_selector);
time_controller_.AdvanceTime(kFrameDuration); time_controller_.AdvanceTime(kFrameDuration);

View file

@ -30,7 +30,7 @@ std::unique_ptr<SimulcastTestFixture> CreateSpecificSimulcastTestFixture() {
[]() { return H264Decoder::Create(); }); []() { return H264Decoder::Create(); });
return CreateSimulcastTestFixture(std::move(encoder_factory), return CreateSimulcastTestFixture(std::move(encoder_factory),
std::move(decoder_factory), std::move(decoder_factory),
SdpVideoFormat("H264")); SdpVideoFormat::H264());
} }
} // namespace } // namespace

View file

@ -366,7 +366,7 @@ TEST(VideoCodecTestLibvpx, MAYBE_SimulcastVP8) {
std::unique_ptr<VideoEncoderFactory> adapted_encoder_factory = std::unique_ptr<VideoEncoderFactory> adapted_encoder_factory =
std::make_unique<FunctionVideoEncoderFactory>([&]() { std::make_unique<FunctionVideoEncoderFactory>([&]() {
return std::make_unique<SimulcastEncoderAdapter>( return std::make_unique<SimulcastEncoderAdapter>(
&internal_encoder_factory, SdpVideoFormat(cricket::kVp8CodecName)); &internal_encoder_factory, SdpVideoFormat::VP8());
}); });
std::unique_ptr<InternalDecoderFactory> internal_decoder_factory( std::unique_ptr<InternalDecoderFactory> internal_decoder_factory(
new InternalDecoderFactory()); new InternalDecoderFactory());

View file

@ -32,7 +32,7 @@ std::unique_ptr<SimulcastTestFixture> CreateSpecificSimulcastTestFixture() {
}); });
return CreateSimulcastTestFixture(std::move(encoder_factory), return CreateSimulcastTestFixture(std::move(encoder_factory),
std::move(decoder_factory), std::move(decoder_factory),
SdpVideoFormat("VP8")); SdpVideoFormat::VP8());
} }
} // namespace } // namespace

View file

@ -52,8 +52,7 @@ id<RTC_OBJC_TYPE(RTCVideoDecoderFactory)> CreateErrorDecoderFactory() {
std::unique_ptr<webrtc::VideoDecoder> GetObjCDecoder( std::unique_ptr<webrtc::VideoDecoder> GetObjCDecoder(
id<RTC_OBJC_TYPE(RTCVideoDecoderFactory)> factory) { id<RTC_OBJC_TYPE(RTCVideoDecoderFactory)> factory) {
webrtc::ObjCVideoDecoderFactory decoder_factory(factory); webrtc::ObjCVideoDecoderFactory decoder_factory(factory);
return decoder_factory.Create(webrtc::CreateEnvironment(), return decoder_factory.Create(webrtc::CreateEnvironment(), webrtc::SdpVideoFormat::H264());
webrtc::SdpVideoFormat(cricket::kH264CodecName));
} }
#pragma mark - #pragma mark -

View file

@ -35,7 +35,7 @@ std::unique_ptr<SimulcastTestFixture> CreateSpecificSimulcastTestFixture() {
[]() { return std::make_unique<FakeVp8Decoder>(); }); []() { return std::make_unique<FakeVp8Decoder>(); });
return CreateSimulcastTestFixture(std::move(encoder_factory), return CreateSimulcastTestFixture(std::move(encoder_factory),
std::move(decoder_factory), std::move(decoder_factory),
SdpVideoFormat("VP8")); SdpVideoFormat::VP8());
} }
} // namespace } // namespace

View file

@ -22,7 +22,7 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
VideoReceiveStreamInterface::Config vp8_config(&(stream_state->transport)); VideoReceiveStreamInterface::Config vp8_config(&(stream_state->transport));
VideoReceiveStreamInterface::Decoder vp8_decoder; VideoReceiveStreamInterface::Decoder vp8_decoder;
vp8_decoder.video_format = SdpVideoFormat("VP8"); vp8_decoder.video_format = SdpVideoFormat::VP8();
vp8_decoder.payload_type = 125; vp8_decoder.payload_type = 125;
vp8_config.decoders.push_back(std::move(vp8_decoder)); vp8_config.decoders.push_back(std::move(vp8_decoder));

View file

@ -22,7 +22,7 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
VideoReceiveStreamInterface::Config vp9_config(&(stream_state->transport)); VideoReceiveStreamInterface::Config vp9_config(&(stream_state->transport));
VideoReceiveStreamInterface::Decoder vp9_decoder; VideoReceiveStreamInterface::Decoder vp9_decoder;
vp9_decoder.video_format = SdpVideoFormat("VP9"); vp9_decoder.video_format = SdpVideoFormat::VP9Profile0();
vp9_decoder.payload_type = 124; vp9_decoder.payload_type = 124;
vp9_config.decoders.push_back(std::move(vp9_decoder)); vp9_config.decoders.push_back(std::move(vp9_decoder));

View file

@ -567,14 +567,14 @@ void PeerConnectionE2EQualityTest::SetPeerCodecPreferences(TestPeer* peer) {
peer->params().video_codecs, true, peer->params().use_ulp_fec, peer->params().video_codecs, true, peer->params().use_ulp_fec,
peer->params().use_flex_fec, peer->params().use_flex_fec,
peer->pc_factory() peer->pc_factory()
->GetRtpSenderCapabilities(cricket::MediaType::MEDIA_TYPE_VIDEO) ->GetRtpReceiverCapabilities(cricket::MediaType::MEDIA_TYPE_VIDEO)
.codecs); .codecs);
std::vector<RtpCodecCapability> without_rtx_video_capabilities = std::vector<RtpCodecCapability> without_rtx_video_capabilities =
FilterVideoCodecCapabilities( FilterVideoCodecCapabilities(
peer->params().video_codecs, false, peer->params().use_ulp_fec, peer->params().video_codecs, false, peer->params().use_ulp_fec,
peer->params().use_flex_fec, peer->params().use_flex_fec,
peer->pc_factory() peer->pc_factory()
->GetRtpSenderCapabilities(cricket::MediaType::MEDIA_TYPE_VIDEO) ->GetRtpReceiverCapabilities(cricket::MediaType::MEDIA_TYPE_VIDEO)
.codecs); .codecs);
// Set codecs for transceivers // Set codecs for transceivers

View file

@ -179,7 +179,7 @@ class FakeVideoEncoderFactory : public VideoEncoderFactory {
public: public:
FakeVideoEncoderFactory(Clock* clock) : clock_(clock) {} FakeVideoEncoderFactory(Clock* clock) : clock_(clock) {}
std::vector<SdpVideoFormat> GetSupportedFormats() const override { std::vector<SdpVideoFormat> GetSupportedFormats() const override {
return {SdpVideoFormat("VP8")}; return {SdpVideoFormat::VP8()};
} }
std::unique_ptr<VideoEncoder> CreateVideoEncoder( std::unique_ptr<VideoEncoder> CreateVideoEncoder(
const SdpVideoFormat& format) override { const SdpVideoFormat& format) override {
@ -193,7 +193,7 @@ class FakeVideoEncoderFactory : public VideoEncoderFactory {
class FakeVideoDecoderFactory : public VideoDecoderFactory { class FakeVideoDecoderFactory : public VideoDecoderFactory {
public: public:
std::vector<SdpVideoFormat> GetSupportedFormats() const override { std::vector<SdpVideoFormat> GetSupportedFormats() const override {
return {SdpVideoFormat("VP8")}; return {SdpVideoFormat::VP8()};
} }
std::unique_ptr<VideoDecoder> Create(const Environment& env, std::unique_ptr<VideoDecoder> Create(const Environment& env,
const SdpVideoFormat& format) override { const SdpVideoFormat& format) override {

View file

@ -48,7 +48,7 @@ class VideoCodecTester {
}; };
struct EncodingSettings { struct EncodingSettings {
SdpVideoFormat sdp_video_format = SdpVideoFormat("VP8"); SdpVideoFormat sdp_video_format = SdpVideoFormat::VP8();
ScalabilityMode scalability_mode = ScalabilityMode::kL1T1; ScalabilityMode scalability_mode = ScalabilityMode::kL1T1;
struct LayerSettings { struct LayerSettings {

View file

@ -652,7 +652,7 @@ TEST_P(VideoCodecTesterTestPacing, PaceDecode) {
decoder_settings.pacing_settings = pacing_settings; decoder_settings.pacing_settings = pacing_settings;
std::vector<Frame> frames = std::vector<Frame> frames =
VideoCodecTester::RunDecodeTest(env_, &video_source, &decoder_factory, VideoCodecTester::RunDecodeTest(env_, &video_source, &decoder_factory,
decoder_settings, SdpVideoFormat("VP8")) decoder_settings, SdpVideoFormat::VP8())
->Slice(/*filter=*/{}, /*merge=*/false); ->Slice(/*filter=*/{}, /*merge=*/false);
ASSERT_THAT(frames, SizeIs(kNumFrames)); ASSERT_THAT(frames, SizeIs(kNumFrames));
EXPECT_NEAR((frames[1].decode_start - frames[0].decode_start).ms(), EXPECT_NEAR((frames[1].decode_start - frames[0].decode_start).ms(),

View file

@ -107,7 +107,7 @@ void HistogramTest::VerifyHistogramStats(bool use_rtx,
send_config->encoder_settings.encoder_factory = &encoder_factory_; send_config->encoder_settings.encoder_factory = &encoder_factory_;
send_config->rtp.payload_name = "VP8"; send_config->rtp.payload_name = "VP8";
encoder_config->codec_type = kVideoCodecVP8; encoder_config->codec_type = kVideoCodecVP8;
(*receive_configs)[0].decoders[0].video_format = SdpVideoFormat("VP8"); (*receive_configs)[0].decoders[0].video_format = SdpVideoFormat::VP8();
(*receive_configs)[0].rtp.red_payload_type = (*receive_configs)[0].rtp.red_payload_type =
test::VideoTestConstants::kRedPayloadType; test::VideoTestConstants::kRedPayloadType;
(*receive_configs)[0].rtp.ulpfec_payload_type = (*receive_configs)[0].rtp.ulpfec_payload_type =

View file

@ -469,7 +469,7 @@ void RetransmissionEndToEndTest::DecodesRetransmittedFrame(bool enable_rtx,
send_config->encoder_settings.encoder_factory = &encoder_factory_; send_config->encoder_settings.encoder_factory = &encoder_factory_;
send_config->rtp.payload_name = "VP8"; send_config->rtp.payload_name = "VP8";
encoder_config->codec_type = kVideoCodecVP8; encoder_config->codec_type = kVideoCodecVP8;
(*receive_configs)[0].decoders[0].video_format = SdpVideoFormat("VP8"); (*receive_configs)[0].decoders[0].video_format = SdpVideoFormat::VP8();
} }
void OnFrameGeneratorCapturerCreated( void OnFrameGeneratorCapturerCreated(

View file

@ -390,7 +390,7 @@ TEST_P(PictureIdTest, ContinuousAfterReconfigureSimulcastEncoderAdapter) {
test::FunctionVideoEncoderFactory encoder_factory( test::FunctionVideoEncoderFactory encoder_factory(
[&internal_encoder_factory]() { [&internal_encoder_factory]() {
return std::make_unique<SimulcastEncoderAdapter>( return std::make_unique<SimulcastEncoderAdapter>(
&internal_encoder_factory, SdpVideoFormat("VP8")); &internal_encoder_factory, SdpVideoFormat::VP8());
}); });
SetupEncoder(&encoder_factory, "VP8"); SetupEncoder(&encoder_factory, "VP8");
TestPictureIdContinuousAfterReconfigure({1, 3, 3, 1, 1}); TestPictureIdContinuousAfterReconfigure({1, 3, 3, 1, 1});
@ -403,7 +403,7 @@ TEST_P(PictureIdTest,
test::FunctionVideoEncoderFactory encoder_factory( test::FunctionVideoEncoderFactory encoder_factory(
[&internal_encoder_factory]() { [&internal_encoder_factory]() {
return std::make_unique<SimulcastEncoderAdapter>( return std::make_unique<SimulcastEncoderAdapter>(
&internal_encoder_factory, SdpVideoFormat("VP8")); &internal_encoder_factory, SdpVideoFormat::VP8());
}); });
SetupEncoder(&encoder_factory, "VP8"); SetupEncoder(&encoder_factory, "VP8");
TestPictureIdIncreaseAfterRecreateStreams({1, 3, 3, 1, 1}); TestPictureIdIncreaseAfterRecreateStreams({1, 3, 3, 1, 1});
@ -414,7 +414,7 @@ TEST_P(PictureIdTest, ContinuousAfterStreamCountChangeSimulcastEncoderAdapter) {
test::FunctionVideoEncoderFactory encoder_factory( test::FunctionVideoEncoderFactory encoder_factory(
[&internal_encoder_factory]() { [&internal_encoder_factory]() {
return std::make_unique<SimulcastEncoderAdapter>( return std::make_unique<SimulcastEncoderAdapter>(
&internal_encoder_factory, SdpVideoFormat("VP8")); &internal_encoder_factory, SdpVideoFormat::VP8());
}); });
// Make sure that the picture id is not reset if the stream count goes // Make sure that the picture id is not reset if the stream count goes
// down and then up. // down and then up.

View file

@ -238,7 +238,7 @@ class VideoReceiveStream2Test : public ::testing::TestWithParam<bool> {
config_.renderer = &fake_renderer_; config_.renderer = &fake_renderer_;
VideoReceiveStreamInterface::Decoder h264_decoder; VideoReceiveStreamInterface::Decoder h264_decoder;
h264_decoder.payload_type = 99; h264_decoder.payload_type = 99;
h264_decoder.video_format = SdpVideoFormat("H264"); h264_decoder.video_format = SdpVideoFormat::H264();
h264_decoder.video_format.parameters.insert( h264_decoder.video_format.parameters.insert(
{"sprop-parameter-sets", "Z0IACpZTBYmI,aMljiA=="}); {"sprop-parameter-sets", "Z0IACpZTBYmI,aMljiA=="});
VideoReceiveStreamInterface::Decoder h265_decoder; VideoReceiveStreamInterface::Decoder h265_decoder;

View file

@ -4214,7 +4214,7 @@ TEST_F(VideoSendStreamTest, TestTemporalLayersVp8) {
test::FunctionVideoEncoderFactory encoder_factory( test::FunctionVideoEncoderFactory encoder_factory(
[&internal_encoder_factory]() { [&internal_encoder_factory]() {
return std::make_unique<SimulcastEncoderAdapter>( return std::make_unique<SimulcastEncoderAdapter>(
&internal_encoder_factory, SdpVideoFormat("VP8")); &internal_encoder_factory, SdpVideoFormat::VP8());
}); });
TestTemporalLayers(&encoder_factory, "VP8", TestTemporalLayers(&encoder_factory, "VP8",
@ -4227,7 +4227,7 @@ TEST_F(VideoSendStreamTest, TestTemporalLayersVp8Simulcast) {
test::FunctionVideoEncoderFactory encoder_factory( test::FunctionVideoEncoderFactory encoder_factory(
[&internal_encoder_factory]() { [&internal_encoder_factory]() {
return std::make_unique<SimulcastEncoderAdapter>( return std::make_unique<SimulcastEncoderAdapter>(
&internal_encoder_factory, SdpVideoFormat("VP8")); &internal_encoder_factory, SdpVideoFormat::VP8());
}); });
TestTemporalLayers(&encoder_factory, "VP8", TestTemporalLayers(&encoder_factory, "VP8",
@ -4240,7 +4240,7 @@ TEST_F(VideoSendStreamTest, TestTemporalLayersVp8SimulcastWithDifferentNumTls) {
test::FunctionVideoEncoderFactory encoder_factory( test::FunctionVideoEncoderFactory encoder_factory(
[&internal_encoder_factory]() { [&internal_encoder_factory]() {
return std::make_unique<SimulcastEncoderAdapter>( return std::make_unique<SimulcastEncoderAdapter>(
&internal_encoder_factory, SdpVideoFormat("VP8")); &internal_encoder_factory, SdpVideoFormat::VP8());
}); });
TestTemporalLayers(&encoder_factory, "VP8", TestTemporalLayers(&encoder_factory, "VP8",
@ -4262,7 +4262,7 @@ TEST_F(VideoSendStreamTest, TestScalabilityModeVp8L1T2) {
test::FunctionVideoEncoderFactory encoder_factory( test::FunctionVideoEncoderFactory encoder_factory(
[&internal_encoder_factory]() { [&internal_encoder_factory]() {
return std::make_unique<SimulcastEncoderAdapter>( return std::make_unique<SimulcastEncoderAdapter>(
&internal_encoder_factory, SdpVideoFormat("VP8")); &internal_encoder_factory, SdpVideoFormat::VP8());
}); });
TestTemporalLayers(&encoder_factory, "VP8", TestTemporalLayers(&encoder_factory, "VP8",
@ -4274,7 +4274,7 @@ TEST_F(VideoSendStreamTest, TestScalabilityModeVp8Simulcast) {
test::FunctionVideoEncoderFactory encoder_factory( test::FunctionVideoEncoderFactory encoder_factory(
[&internal_encoder_factory]() { [&internal_encoder_factory]() {
return std::make_unique<SimulcastEncoderAdapter>( return std::make_unique<SimulcastEncoderAdapter>(
&internal_encoder_factory, SdpVideoFormat("VP8")); &internal_encoder_factory, SdpVideoFormat::VP8());
}); });
TestTemporalLayers(&encoder_factory, "VP8", TestTemporalLayers(&encoder_factory, "VP8",
@ -4287,7 +4287,7 @@ TEST_F(VideoSendStreamTest, TestScalabilityModeVp8SimulcastWithDifferentMode) {
test::FunctionVideoEncoderFactory encoder_factory( test::FunctionVideoEncoderFactory encoder_factory(
[&internal_encoder_factory]() { [&internal_encoder_factory]() {
return std::make_unique<SimulcastEncoderAdapter>( return std::make_unique<SimulcastEncoderAdapter>(
&internal_encoder_factory, SdpVideoFormat("VP8")); &internal_encoder_factory, SdpVideoFormat::VP8());
}); });
TestTemporalLayers(&encoder_factory, "VP8", TestTemporalLayers(&encoder_factory, "VP8",

View file

@ -131,12 +131,13 @@ class VideoStreamDecoderImplTest : public ::testing::Test {
public: public:
VideoStreamDecoderImplTest() VideoStreamDecoderImplTest()
: time_controller_(Timestamp::Seconds(0)), : time_controller_(Timestamp::Seconds(0)),
video_stream_decoder_(&callbacks_, video_stream_decoder_(
&decoder_factory_, &callbacks_,
time_controller_.GetTaskQueueFactory(), &decoder_factory_,
{{1, std::make_pair(SdpVideoFormat("VP8"), 1)}, time_controller_.GetTaskQueueFactory(),
{2, std::make_pair(SdpVideoFormat("AV1"), 1)}}, {{1, std::make_pair(SdpVideoFormat::VP8(), 1)},
&field_trials_) { {2, std::make_pair(SdpVideoFormat::AV1Profile0(), 1)}},
&field_trials_) {
// Set the min playout delay to a value greater than zero to not activate // Set the min playout delay to a value greater than zero to not activate
// the low-latency renderer. // the low-latency renderer.
video_stream_decoder_.SetMinPlayoutDelay(TimeDelta::Millis(10)); video_stream_decoder_.SetMinPlayoutDelay(TimeDelta::Millis(10));