codec_comparators.h (2077B)
1 /* 2 * Copyright 2024 The WebRTC Project Authors. All rights reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef MEDIA_BASE_CODEC_COMPARATORS_H_ 12 #define MEDIA_BASE_CODEC_COMPARATORS_H_ 13 14 #include <optional> 15 #include <vector> 16 17 #include "api/rtp_parameters.h" 18 #include "media/base/codec.h" 19 20 namespace webrtc { 21 22 // Comparison used for the Codec::Matches function 23 bool MatchesWithCodecRules(const Codec& left_codec, const Codec& codec); 24 25 // Comparison that also checks on codecs referenced by PT in the 26 // fmtp line, as used with RED and RTX "codecs". 27 bool MatchesWithReferenceAttributes(const Codec& left_codec, 28 const Codec& right_codec); 29 30 // Finds a codec in `codecs2` that matches `codec_to_match`, which is 31 // a member of `codecs1`. If `codec_to_match` is an RED or RTX codec, both 32 // the codecs themselves and their associated codecs must match. 33 // The purpose of this function is that codecs1 and codecs2 are different 34 // PT numbering spaces, and it is trying to find the codec in codecs2 35 // that has the same functionality as `codec_to_match` so that its PT 36 // can be used in place of the original. 37 std::optional<Codec> FindMatchingCodec(const std::vector<Codec>& codecs1, 38 const std::vector<Codec>& codecs2, 39 const Codec& codec_to_match); 40 41 // Similar to `Codec::MatchesRtpCodec` but not an exact match of parameters. 42 // Unspecified parameters are treated as default. 43 bool IsSameRtpCodec(const Codec& codec, const RtpCodec& rtp_codec); 44 45 // Similar to `IsSameRtpCodec` but ignoring the level related parameter. 46 bool IsSameRtpCodecIgnoringLevel(const Codec& codec, const RtpCodec& rtp_codec); 47 } // namespace webrtc 48 49 #endif // MEDIA_BASE_CODEC_COMPARATORS_H_