diff --git a/daemon/codec.c b/daemon/codec.c index e6bbe1bd1..43b08b586 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -419,7 +419,7 @@ static void __make_transcoder(struct codec_handler *handler, struct rtp_payload_ // don't reset handler if it already matches what we want if (!handler->transcoder) goto reset; - if (rtp_payload_type_cmp(dest, &handler->dest_pt)) + if (!rtp_payload_type_eq(dest, &handler->dest_pt)) goto reset; if (handler->handler_func != handler_func_transcode) goto reset; @@ -651,7 +651,7 @@ static int __unused_pt_number(struct call_media *media, struct call_media *other next: // is this actually the same? - if (pt && !rtp_payload_type_cmp_nf(pt, pt_match)) + if (pt && rtp_payload_type_eq_nf(pt, pt_match)) break; num++; if (num < 96) // if an RFC type was taken already @@ -707,7 +707,7 @@ static struct codec_handler *__get_pt_handler(struct call_media *receiver, struc handler = codec_handler_lookup(receiver->codec_handlers, pt->payload_type, sink); if (handler) { // make sure existing handler matches this PT - if (rtp_payload_type_cmp(pt, &handler->source_pt)) { + if (!rtp_payload_type_eq(pt, &handler->source_pt)) { ilogs(codec, LOG_DEBUG, "Resetting codec handler for PT %i", pt->payload_type); g_hash_table_remove(receiver->codec_handlers, handler); __handler_shutdown(handler); @@ -1069,7 +1069,7 @@ bool codec_handlers_update(struct call_media *receiver, struct call_media *sink, sink_pt = g_hash_table_lookup(sink->codecs.codecs, GINT_TO_POINTER(pt->payload_type)); // is it actually the same? - if (sink_pt && rtp_payload_type_cmp(pt, sink_pt)) + if (sink_pt && !rtp_payload_type_eq(pt, sink_pt)) sink_pt = NULL; } @@ -1196,7 +1196,7 @@ bool codec_handlers_update(struct call_media *receiver, struct call_media *sink, // different codecs? this will only be true for non-supplemental codecs // XXX needs more intelligent fmtp matching - if (rtp_payload_type_cmp_nf(pt, sink_pt)) + if (!rtp_payload_type_eq_nf(pt, sink_pt)) goto transcode; // supplemental codecs are always matched up. we want them as passthrough if @@ -4894,7 +4894,7 @@ bool codec_store_is_full_answer(const struct codec_store *src, const struct code const struct rtp_payload_type *src_pt = l->data; const struct rtp_payload_type *dst_pt = g_hash_table_lookup(dst->codecs, GINT_TO_POINTER(src_pt->payload_type)); - if (!dst_pt || rtp_payload_type_cmp(src_pt, dst_pt)) { + if (!dst_pt || !rtp_payload_type_eq(src_pt, dst_pt)) { ilogs(codec, LOG_DEBUG, "Source codec " STR_FORMAT " is not present in the answer", STR_FMT(&src_pt->encoding_with_params)); return false; diff --git a/daemon/media_player.c b/daemon/media_player.c index 5b1990299..f2d3ae340 100644 --- a/daemon/media_player.c +++ b/daemon/media_player.c @@ -308,8 +308,8 @@ found: // if we already have a handler, see if anything needs changing if (mp->handler) { - if (rtp_payload_type_cmp(&mp->handler->dest_pt, dst_pt) - || rtp_payload_type_cmp(&mp->handler->source_pt, src_pt)) + if (!rtp_payload_type_eq(&mp->handler->dest_pt, dst_pt) + || !rtp_payload_type_eq(&mp->handler->source_pt, src_pt)) { ilog(LOG_DEBUG, "Resetting codec handler for media player"); codec_handler_free(&mp->handler); diff --git a/lib/rtplib.c b/lib/rtplib.c index 3889374e9..96de9ae54 100644 --- a/lib/rtplib.c +++ b/lib/rtplib.c @@ -144,28 +144,28 @@ const struct rtp_payload_type *rtp_get_rfc_codec(const str *codec) { return NULL; } -int rtp_payload_type_cmp(const struct rtp_payload_type *a, const struct rtp_payload_type *b) { - if (rtp_payload_type_cmp_nf(a, b)) - return 1; +bool rtp_payload_type_eq(const struct rtp_payload_type *a, const struct rtp_payload_type *b) { + if (!rtp_payload_type_eq_nf(a, b)) + return false; if (a->codec_def && a->codec_def == b->codec_def) { if (a->codec_def->format_cmp) - return a->codec_def->format_cmp(a, b); + return a->codec_def->format_cmp(a, b) == 0; } if (!a->codec_def) // ignore format of codecs we don't know - return 0; + return true; if (str_cmp_str(&a->format_parameters, &b->format_parameters)) - return 1; - return 0; + return false; + return true; } -int rtp_payload_type_cmp_nf(const struct rtp_payload_type *a, const struct rtp_payload_type *b) { +bool rtp_payload_type_eq_nf(const struct rtp_payload_type *a, const struct rtp_payload_type *b) { if (a->payload_type != b->payload_type) - return 1; + return false; if (a->clock_rate != b->clock_rate) - return 1; + return false; if (a->channels != b->channels) - return 1; + return false; if (str_casecmp_str(&a->encoding, &b->encoding)) - return 1; - return 0; + return false; + return true; } diff --git a/lib/rtplib.h b/lib/rtplib.h index c28710d54..d40076b02 100644 --- a/lib/rtplib.h +++ b/lib/rtplib.h @@ -2,6 +2,7 @@ #define _RTPLIB_H_ #include +#include #include "str.h" @@ -74,8 +75,8 @@ int rtp_padding(const struct rtp_header *header, str *payload); const struct rtp_payload_type *rtp_get_rfc_payload_type(unsigned int type); const struct rtp_payload_type *rtp_get_rfc_codec(const str *codec); -int rtp_payload_type_cmp(const struct rtp_payload_type *, const struct rtp_payload_type *); -int rtp_payload_type_cmp_nf(const struct rtp_payload_type *, const struct rtp_payload_type *); +bool rtp_payload_type_eq(const struct rtp_payload_type *, const struct rtp_payload_type *); +bool rtp_payload_type_eq_nf(const struct rtp_payload_type *, const struct rtp_payload_type *); #endif