diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
commit | da4c7e7ed675c3bf405668739c3012d140856109 (patch) | |
tree | cdd868dba063fecba609a1d819de271f0d51b23e /third_party/libwebrtc/media/base/codec.cc | |
parent | Adding upstream version 125.0.3. (diff) | |
download | firefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip |
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/media/base/codec.cc')
-rw-r--r-- | third_party/libwebrtc/media/base/codec.cc | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/third_party/libwebrtc/media/base/codec.cc b/third_party/libwebrtc/media/base/codec.cc index c4e1c6f1f3..d18baf7132 100644 --- a/third_party/libwebrtc/media/base/codec.cc +++ b/third_party/libwebrtc/media/base/codec.cc @@ -15,6 +15,9 @@ #include "api/audio_codecs/audio_format.h" #include "api/video_codecs/av1_profile.h" #include "api/video_codecs/h264_profile_level_id.h" +#ifdef RTC_ENABLE_H265 +#include "api/video_codecs/h265_profile_tier_level.h" +#endif #include "api/video_codecs/vp9_profile.h" #include "media/base/media_constants.h" #include "rtc_base/checks.h" @@ -25,7 +28,8 @@ namespace cricket { namespace { -std::string GetH264PacketizationModeOrDefault(const CodecParameterMap& params) { +std::string GetH264PacketizationModeOrDefault( + const webrtc::CodecParameterMap& params) { auto it = params.find(kH264FmtpPacketizationMode); if (it != params.end()) { return it->second; @@ -35,18 +39,36 @@ std::string GetH264PacketizationModeOrDefault(const CodecParameterMap& params) { return "0"; } -bool IsSameH264PacketizationMode(const CodecParameterMap& left, - const CodecParameterMap& right) { +bool IsSameH264PacketizationMode(const webrtc::CodecParameterMap& left, + const webrtc::CodecParameterMap& right) { return GetH264PacketizationModeOrDefault(left) == GetH264PacketizationModeOrDefault(right); } +#ifdef RTC_ENABLE_H265 +std::string GetH265TxModeOrDefault(const webrtc::CodecParameterMap& params) { + auto it = params.find(kH265FmtpTxMode); + if (it != params.end()) { + return it->second; + } + // If TxMode is not present, a value of "SRST" must be inferred. + // https://tools.ietf.org/html/rfc7798@section-7.1 + return "SRST"; +} + +bool IsSameH265TxMode(const webrtc::CodecParameterMap& left, + const webrtc::CodecParameterMap& right) { + return absl::EqualsIgnoreCase(GetH265TxModeOrDefault(left), + GetH265TxModeOrDefault(right)); +} +#endif + // Some (video) codecs are actually families of codecs and rely on parameters // to distinguish different incompatible family members. bool IsSameCodecSpecific(const std::string& name1, - const CodecParameterMap& params1, + const webrtc::CodecParameterMap& params1, const std::string& name2, - const CodecParameterMap& params2) { + const webrtc::CodecParameterMap& params2) { // The names might not necessarily match, so check both. auto either_name_matches = [&](const std::string name) { return absl::EqualsIgnoreCase(name, name1) || @@ -59,6 +81,12 @@ bool IsSameCodecSpecific(const std::string& name1, return webrtc::VP9IsSameProfile(params1, params2); if (either_name_matches(kAv1CodecName)) return webrtc::AV1IsSameProfile(params1, params2); +#ifdef RTC_ENABLE_H265 + if (either_name_matches(kH265CodecName)) { + return webrtc::H265IsSameProfileTierLevel(params1, params2) && + IsSameH265TxMode(params1, params2); + } +#endif return true; } @@ -222,7 +250,7 @@ bool Codec::MatchesRtpCodec(const webrtc::RtpCodec& codec_capability) const { } bool Codec::GetParam(const std::string& name, std::string* out) const { - CodecParameterMap::const_iterator iter = params.find(name); + webrtc::CodecParameterMap::const_iterator iter = params.find(name); if (iter == params.end()) return false; *out = iter->second; @@ -230,7 +258,7 @@ bool Codec::GetParam(const std::string& name, std::string* out) const { } bool Codec::GetParam(const std::string& name, int* out) const { - CodecParameterMap::const_iterator iter = params.find(name); + webrtc::CodecParameterMap::const_iterator iter = params.find(name); if (iter == params.end()) return false; return rtc::FromString(iter->second, out); @@ -283,7 +311,8 @@ webrtc::RtpCodecParameters Codec::ToCodecParameters() const { } bool Codec::IsMediaCodec() const { - return !IsResiliencyCodec(); + return !IsResiliencyCodec() && + !absl::EqualsIgnoreCase(name, kComfortNoiseCodecName); } bool Codec::IsResiliencyCodec() const { |