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}
This commit is contained in:
@ -139,8 +139,10 @@ rtc_source_set("video_encoder_factory_template") {
|
|||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
":video_codecs_api",
|
":video_codecs_api",
|
||||||
|
"../../api:array_view",
|
||||||
"../../modules/video_coding/svc:scalability_mode_util",
|
"../../modules/video_coding/svc:scalability_mode_util",
|
||||||
]
|
]
|
||||||
|
|
||||||
absl_deps = [ "//third_party/abseil-cpp/absl/algorithm:container" ]
|
absl_deps = [ "//third_party/abseil-cpp/absl/algorithm:container" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/algorithm/container.h"
|
#include "absl/algorithm/container.h"
|
||||||
|
#include "api/array_view.h"
|
||||||
#include "api/video_codecs/video_encoder.h"
|
#include "api/video_codecs/video_encoder.h"
|
||||||
#include "api/video_codecs/video_encoder_factory.h"
|
#include "api/video_codecs/video_encoder_factory.h"
|
||||||
#include "modules/video_coding/svc/scalability_mode_util.h"
|
#include "modules/video_coding/svc/scalability_mode_util.h"
|
||||||
@ -62,9 +63,14 @@ class VideoEncoderFactoryTemplate : public VideoEncoderFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename V>
|
bool IsFormatInList(
|
||||||
bool IsFormatSupported(const SdpVideoFormat& format) const {
|
const SdpVideoFormat& format,
|
||||||
return absl::c_count(V::SupportedFormats(), format) > 0;
|
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>
|
template <typename V>
|
||||||
@ -83,7 +89,7 @@ class VideoEncoderFactoryTemplate : public VideoEncoderFactory {
|
|||||||
void GetSupportedFormatsInternal(std::vector<SdpVideoFormat>& formats) const {
|
void GetSupportedFormatsInternal(std::vector<SdpVideoFormat>& formats) const {
|
||||||
auto supported_formats = V::SupportedFormats();
|
auto supported_formats = V::SupportedFormats();
|
||||||
for (const auto& format : supported_formats) {
|
for (const auto& format : supported_formats) {
|
||||||
if (absl::c_count(formats, format) == 0) {
|
if (!IsFormatInList(format, formats)) {
|
||||||
formats.push_back(format);
|
formats.push_back(format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,7 +102,7 @@ class VideoEncoderFactoryTemplate : public VideoEncoderFactory {
|
|||||||
template <typename V, typename... Vs>
|
template <typename V, typename... Vs>
|
||||||
std::unique_ptr<VideoEncoder> CreateVideoEncoderInternal(
|
std::unique_ptr<VideoEncoder> CreateVideoEncoderInternal(
|
||||||
const SdpVideoFormat& format) {
|
const SdpVideoFormat& format) {
|
||||||
if (IsFormatSupported<V>(format)) {
|
if (IsFormatInList(format, V::SupportedFormats())) {
|
||||||
return V::CreateEncoder(format);
|
return V::CreateEncoder(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +117,7 @@ class VideoEncoderFactoryTemplate : public VideoEncoderFactory {
|
|||||||
CodecSupport QueryCodecSupportInternal(
|
CodecSupport QueryCodecSupportInternal(
|
||||||
const SdpVideoFormat& format,
|
const SdpVideoFormat& format,
|
||||||
const absl::optional<std::string>& scalability_mode) const {
|
const absl::optional<std::string>& scalability_mode) const {
|
||||||
if (IsFormatSupported<V>(format)) {
|
if (IsFormatInList(format, V::SupportedFormats())) {
|
||||||
return {.is_supported = IsScalabilityModeSupported<V>(scalability_mode)};
|
return {.is_supported = IsScalabilityModeSupported<V>(scalability_mode)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user