diff --git a/daemon/codec.c b/daemon/codec.c index 43bcab2c00..aac6fa2bd9 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -4732,7 +4732,7 @@ static void codec_store_find_matching_codecs(GQueue *out_compat, struct rtp_payl ensure_codec_def(pt2, cs->media); int match; if (pt) - match = rtp_payload_type_fmt_eq(pt, pt2); + match = rtp_payload_type_fmt_cmp(pt, pt2); else match = (str_cmp_str(codec, &pt2->encoding) == 0) ? 0 : -1; if (match == 0) { diff --git a/lib/rtplib.c b/lib/rtplib.c index fbfda7a152..f1b3b89215 100644 --- a/lib/rtplib.c +++ b/lib/rtplib.c @@ -145,6 +145,7 @@ const struct rtp_payload_type *rtp_get_rfc_codec(const str *codec) { } // helper function: matches only basic params, without matching payload type number +__attribute__((nonnull(1, 2))) static bool rtp_payload_type_fmt_eq_nf(const struct rtp_payload_type *a, const struct rtp_payload_type *b) { if (a->clock_rate != b->clock_rate) return false; @@ -157,7 +158,7 @@ static bool rtp_payload_type_fmt_eq_nf(const struct rtp_payload_type *a, const s // matches basic params and format params, but not payload type number // returns matching val as per format_cmp_f -int rtp_payload_type_fmt_eq(const struct rtp_payload_type *a, const struct rtp_payload_type *b) { +int rtp_payload_type_fmt_cmp(const struct rtp_payload_type *a, const struct rtp_payload_type *b) { if (!rtp_payload_type_fmt_eq_nf(a, b)) return -1; if (a->codec_def && a->codec_def == b->codec_def) { @@ -171,21 +172,21 @@ int rtp_payload_type_fmt_eq(const struct rtp_payload_type *a, const struct rtp_p return 0; } bool rtp_payload_type_fmt_eq_exact(const struct rtp_payload_type *a, const struct rtp_payload_type *b) { - return rtp_payload_type_fmt_eq(a, b) == 0; + return rtp_payload_type_fmt_cmp(a, b) == 0; } bool rtp_payload_type_fmt_eq_compat(const struct rtp_payload_type *a, const struct rtp_payload_type *b) { - return rtp_payload_type_fmt_eq(a, b) >= 0; + return rtp_payload_type_fmt_cmp(a, b) >= 0; } bool rtp_payload_type_eq_exact(const struct rtp_payload_type *a, const struct rtp_payload_type *b) { if (a->payload_type != b->payload_type) return false; - return rtp_payload_type_fmt_eq(a, b) == 0; + return rtp_payload_type_fmt_cmp(a, b) == 0; } bool rtp_payload_type_eq_compat(const struct rtp_payload_type *a, const struct rtp_payload_type *b) { if (a->payload_type != b->payload_type) return false; - return rtp_payload_type_fmt_eq(a, b) >= 0; + return rtp_payload_type_fmt_cmp(a, b) >= 0; } // same as rtp_payload_type_fmt_eq_nf plus matching payload type number diff --git a/lib/rtplib.h b/lib/rtplib.h index 8325efa12b..fa02a084e8 100644 --- a/lib/rtplib.h +++ b/lib/rtplib.h @@ -125,13 +125,19 @@ const struct rtp_payload_type *rtp_get_rfc_codec(const str *codec); // if not `exact` then also returns true if `a` is compatible with `b` // matches all params +__attribute__((nonnull(1, 2))) bool rtp_payload_type_eq_exact(const struct rtp_payload_type *a, const struct rtp_payload_type *b); +__attribute__((nonnull(1, 2))) bool rtp_payload_type_eq_compat(const struct rtp_payload_type *a, const struct rtp_payload_type *b); // matches only basic params and payload type number +__attribute__((nonnull(1, 2))) bool rtp_payload_type_eq_nf(const struct rtp_payload_type *, const struct rtp_payload_type *); // matches all params except payload type number -int rtp_payload_type_fmt_eq(const struct rtp_payload_type *a, const struct rtp_payload_type *b); +__attribute__((nonnull(1, 2))) +int rtp_payload_type_fmt_cmp(const struct rtp_payload_type *a, const struct rtp_payload_type *b); +__attribute__((nonnull(1, 2))) bool rtp_payload_type_fmt_eq_exact(const struct rtp_payload_type *a, const struct rtp_payload_type *b); +__attribute__((nonnull(1, 2))) bool rtp_payload_type_fmt_eq_compat(const struct rtp_payload_type *a, const struct rtp_payload_type *b);