Use predefined SdpVideoFormats when returning supported formats

The predefined SdpVideoFormats were not used everywhere,
which caused a discrepancy between send/receive capabilities
for AV1. This CL solves the immediate problems by making sure
send/receive capabilities for AV1 are reported the same way.

Fixed: chromium:331565934
Change-Id: I073091b7b5f987c7f434c17276fd84047ec723c2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/344681
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Johannes Kron <kron@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41991}
This commit is contained in:
Johannes Kron 2024-04-03 10:38:13 +00:00 committed by WebRTC LUCI CQ
parent 71566bc802
commit 82598402e0
7 changed files with 27 additions and 21 deletions

View File

@ -138,6 +138,13 @@ SdpVideoFormat::SdpVideoFormat(
parameters(parameters),
scalability_modes(scalability_modes) {}
SdpVideoFormat::SdpVideoFormat(
const SdpVideoFormat& format,
const absl::InlinedVector<ScalabilityMode, kScalabilityModeCount>& modes)
: SdpVideoFormat(format) {
scalability_modes = modes;
}
SdpVideoFormat::SdpVideoFormat(const SdpVideoFormat&) = default;
SdpVideoFormat::SdpVideoFormat(SdpVideoFormat&&) = default;
SdpVideoFormat& SdpVideoFormat::operator=(const SdpVideoFormat&) = default;

View File

@ -36,6 +36,14 @@ struct RTC_EXPORT SdpVideoFormat {
const CodecParameterMap& parameters,
const absl::InlinedVector<ScalabilityMode, kScalabilityModeCount>&
scalability_modes);
// Creates a new SdpVideoFormat object identical to the supplied
// SdpVideoFormat except the scalability_modes that are set to be the same as
// the supplied scalability modes.
SdpVideoFormat(
const SdpVideoFormat& format,
const absl::InlinedVector<ScalabilityMode, kScalabilityModeCount>&
scalability_modes);
SdpVideoFormat(const SdpVideoFormat&);
SdpVideoFormat(SdpVideoFormat&&);
SdpVideoFormat& operator=(const SdpVideoFormat&);

View File

@ -21,10 +21,7 @@
namespace webrtc {
struct Dav1dDecoderTemplateAdapter {
static std::vector<SdpVideoFormat> SupportedFormats() {
return {SdpVideoFormat("AV1"),
SdpVideoFormat(
"AV1", {{"profile",
AV1ProfileToString(AV1Profile::kProfile1).data()}})};
return {SdpVideoFormat::AV1Profile0(), SdpVideoFormat::AV1Profile1()};
}
static std::unique_ptr<VideoDecoder> CreateDecoder(

View File

@ -25,7 +25,7 @@ struct LibaomAv1EncoderTemplateAdapter {
static std::vector<SdpVideoFormat> SupportedFormats() {
absl::InlinedVector<ScalabilityMode, kScalabilityModeCount>
scalability_modes = LibaomAv1EncoderSupportedScalabilityModes();
return {SdpVideoFormat("AV1", CodecParameterMap(), scalability_modes)};
return {SdpVideoFormat(SdpVideoFormat::AV1Profile0(), scalability_modes)};
}
static std::unique_ptr<VideoEncoder> CreateEncoder(

View File

@ -29,7 +29,7 @@ struct LibvpxVp8EncoderTemplateAdapter {
scalability_modes.push_back(scalability_mode);
}
return {SdpVideoFormat("VP8", CodecParameterMap(), scalability_modes)};
return {SdpVideoFormat(SdpVideoFormat::VP8(), scalability_modes)};
}
static std::unique_ptr<VideoEncoder> CreateEncoder(

View File

@ -178,7 +178,9 @@ SdpVideoFormat CreateSdpVideoFormat(
return SdpVideoFormat(config.codec_name, codec_params);
} else if (config.codec_settings.codecType == kVideoCodecVP9) {
return SdpVideoFormat(config.codec_name, {{"profile-id", "0"}});
return SdpVideoFormat::VP9Profile0();
} else if (config.codec_settings.codecType == kVideoCodecAV1) {
return SdpVideoFormat::AV1Profile0();
}
return SdpVideoFormat(config.codec_name);

View File

@ -46,15 +46,11 @@ std::vector<SdpVideoFormat> SupportedVP9Codecs(bool add_scalability_modes) {
}
}
}
std::vector<SdpVideoFormat> supported_formats{SdpVideoFormat(
cricket::kVp9CodecName,
{{kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile0)}},
scalability_modes)};
std::vector<SdpVideoFormat> supported_formats{
SdpVideoFormat(SdpVideoFormat::VP9Profile0(), scalability_modes)};
if (vpx_supports_high_bit_depth) {
supported_formats.push_back(SdpVideoFormat(
cricket::kVp9CodecName,
{{kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile2)}},
scalability_modes));
supported_formats.push_back(
SdpVideoFormat(SdpVideoFormat::VP9Profile2(), scalability_modes));
}
return supported_formats;
@ -69,12 +65,8 @@ std::vector<SdpVideoFormat> SupportedVP9DecoderCodecs() {
// The WebRTC internal decoder supports VP9 profile 1 and 3. However, there's
// currently no way of sending VP9 profile 1 or 3 using the internal encoder.
// It would require extended support for I444, I422, and I440 buffers.
supported_formats.push_back(SdpVideoFormat(
cricket::kVp9CodecName,
{{kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile1)}}));
supported_formats.push_back(SdpVideoFormat(
cricket::kVp9CodecName,
{{kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile3)}}));
supported_formats.push_back(SdpVideoFormat::VP9Profile1());
supported_formats.push_back(SdpVideoFormat::VP9Profile3());
return supported_formats;
#else
return std::vector<SdpVideoFormat>();