Compare only SdpVideoFormat::name and SdpVideoFormat::parameters in the VideoEncoderFactoryTemplate. Since https://webrtc-review.googlesource.com/c/src/+/267780 supported scalability modes are also used to compare for equality between SdpVideoFormats(?). Bug: webrtc:14267, webrtc:13573 Change-Id: I2f3c2fca93bac6fadd222f776f672c9bd3f1de0a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/268304 Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Commit-Queue: Philip Eliasson <philipel@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37510}
diff --git a/api/video_codecs/BUILD.gn b/api/video_codecs/BUILD.gn index 4c91482..872e164 100644 --- a/api/video_codecs/BUILD.gn +++ b/api/video_codecs/BUILD.gn
@@ -139,8 +139,10 @@ deps = [ ":video_codecs_api", + "../../api:array_view", "../../modules/video_coding/svc:scalability_mode_util", ] + absl_deps = [ "//third_party/abseil-cpp/absl/algorithm:container" ] }
diff --git a/api/video_codecs/video_encoder_factory_template.h b/api/video_codecs/video_encoder_factory_template.h index 4913039..b167ccd 100644 --- a/api/video_codecs/video_encoder_factory_template.h +++ b/api/video_codecs/video_encoder_factory_template.h
@@ -16,6 +16,7 @@ #include <vector> #include "absl/algorithm/container.h" +#include "api/array_view.h" #include "api/video_codecs/video_encoder.h" #include "api/video_codecs/video_encoder_factory.h" #include "modules/video_coding/svc/scalability_mode_util.h" @@ -62,9 +63,14 @@ } private: - template <typename V> - bool IsFormatSupported(const SdpVideoFormat& format) const { - return absl::c_count(V::SupportedFormats(), format) > 0; + bool IsFormatInList( + const SdpVideoFormat& format, + rtc::ArrayView<const SdpVideoFormat> supported_formats) const { + return absl::c_any_of( + supported_formats, [&](const SdpVideoFormat& supported_format) { + return supported_format.name == format.name && + supported_format.parameters == format.parameters; + }); } template <typename V> @@ -83,7 +89,7 @@ void GetSupportedFormatsInternal(std::vector<SdpVideoFormat>& formats) const { auto supported_formats = V::SupportedFormats(); for (const auto& format : supported_formats) { - if (absl::c_count(formats, format) == 0) { + if (!IsFormatInList(format, formats)) { formats.push_back(format); } } @@ -96,7 +102,7 @@ template <typename V, typename... Vs> std::unique_ptr<VideoEncoder> CreateVideoEncoderInternal( const SdpVideoFormat& format) { - if (IsFormatSupported<V>(format)) { + if (IsFormatInList(format, V::SupportedFormats())) { return V::CreateEncoder(format); } @@ -111,7 +117,7 @@ CodecSupport QueryCodecSupportInternal( const SdpVideoFormat& format, const absl::optional<std::string>& scalability_mode) const { - if (IsFormatSupported<V>(format)) { + if (IsFormatInList(format, V::SupportedFormats())) { return {.is_supported = IsScalabilityModeSupported<V>(scalability_mode)}; }