aboutsummaryrefslogtreecommitdiff
path: root/media
diff options
context:
space:
mode:
authorphilipel <philipel@webrtc.org>2022-10-18 16:05:38 +0200
committerWebRTC LUCI CQ <webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-10-25 08:30:25 +0000
commit99c4c73dbfa097a56e5da9f52a151c0db026f1ab (patch)
treedc024d3840e748d25936a1178be0fac7d2c769e7 /media
parent4349137885ae6a9be0b5102dc7d1d7c5f1a8157a (diff)
downloadwebrtc-99c4c73dbfa097a56e5da9f52a151c0db026f1ab.tar.gz
Add FuzzyMatchSdpVideoFormat convenience function for VideoEncoderFactoryTemplate.
Bug: webrtc:13573 Change-Id: I6813f2a2524271be7862b700da4831575ec6e206 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/279701 Commit-Queue: Xavier Lepaul‎ <xalep@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#38463}
Diffstat (limited to 'media')
-rw-r--r--media/engine/internal_encoder_factory.cc32
1 files changed, 4 insertions, 28 deletions
diff --git a/media/engine/internal_encoder_factory.cc b/media/engine/internal_encoder_factory.cc
index 4243f52481..7b5fc24e0a 100644
--- a/media/engine/internal_encoder_factory.cc
+++ b/media/engine/internal_encoder_factory.cc
@@ -38,32 +38,6 @@ using Factory =
webrtc::LibaomAv1EncoderTemplateAdapter,
#endif
webrtc::LibvpxVp9EncoderTemplateAdapter>;
-
-absl::optional<SdpVideoFormat> MatchOriginalFormat(
- const SdpVideoFormat& format) {
- const auto supported_formats = Factory().GetSupportedFormats();
-
- absl::optional<SdpVideoFormat> res;
- int best_parameter_match = 0;
- for (const auto& supported_format : supported_formats) {
- if (absl::EqualsIgnoreCase(supported_format.name, format.name)) {
- int matching_parameters = 0;
- for (const auto& kv : supported_format.parameters) {
- auto it = format.parameters.find(kv.first);
- if (it != format.parameters.end() && it->second == kv.second) {
- matching_parameters += 1;
- }
- }
-
- if (!res || matching_parameters > best_parameter_match) {
- res = supported_format;
- best_parameter_match = matching_parameters;
- }
- }
- }
-
- return res;
-}
} // namespace
std::vector<SdpVideoFormat> InternalEncoderFactory::GetSupportedFormats()
@@ -73,7 +47,8 @@ std::vector<SdpVideoFormat> InternalEncoderFactory::GetSupportedFormats()
std::unique_ptr<VideoEncoder> InternalEncoderFactory::CreateVideoEncoder(
const SdpVideoFormat& format) {
- auto original_format = MatchOriginalFormat(format);
+ auto original_format =
+ FuzzyMatchSdpVideoFormat(Factory().GetSupportedFormats(), format);
return original_format ? Factory().CreateVideoEncoder(*original_format)
: nullptr;
}
@@ -81,7 +56,8 @@ std::unique_ptr<VideoEncoder> InternalEncoderFactory::CreateVideoEncoder(
VideoEncoderFactory::CodecSupport InternalEncoderFactory::QueryCodecSupport(
const SdpVideoFormat& format,
absl::optional<std::string> scalability_mode) const {
- auto original_format = MatchOriginalFormat(format);
+ auto original_format =
+ FuzzyMatchSdpVideoFormat(Factory().GetSupportedFormats(), format);
return original_format
? Factory().QueryCodecSupport(*original_format, scalability_mode)
: VideoEncoderFactory::CodecSupport{.is_supported = false};