Skip to content

Commit

Permalink
MT#55283 rename rtp_payload_type_fmt_eq
Browse files Browse the repository at this point in the history
... to _cmp as it better matches its return value.

Also annotate these functions with nonnull.

Change-Id: Iebc725e011bab60ecf089407f16efce0accaf133
  • Loading branch information
rfuchs committed Aug 18, 2023
1 parent 2364464 commit 19a0b93
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion daemon/codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 6 additions & 5 deletions lib/rtplib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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
Expand Down
8 changes: 7 additions & 1 deletion lib/rtplib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);


Expand Down

0 comments on commit 19a0b93

Please sign in to comment.