From 38890bdb5bd4780d8e6ce52ed6f86e17c646f7f6 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 13 Nov 2020 13:14:25 -0500 Subject: [PATCH] TT#100200 split out supp codec finding routine Change-Id: If67b2c713918085d5d54c2d74661fc667eb97336 --- daemon/codec.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/daemon/codec.c b/daemon/codec.c index 7ff8dbc8b..f0dde7346 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -478,6 +478,23 @@ static void __check_send_codecs(struct call_media *receiver, struct call_media * } } +static int __supp_payload_type(GHashTable *supplemental_sinks, struct rtp_payload_type *pref_dest_codec, + const char *codec) +{ + GHashTable *supp_sinks = g_hash_table_lookup(supplemental_sinks, codec); + if (!supp_sinks) + return -1; + if (!g_hash_table_size(supp_sinks) || !pref_dest_codec) + return -1; + + // find the codec entry with a matching clock rate + struct rtp_payload_type *pt = g_hash_table_lookup(supp_sinks, + GUINT_TO_POINTER(pref_dest_codec->clock_rate)); + if (!pt) + return -1; + return pt->payload_type; +} + static int __dtmf_payload_type(GHashTable *supplemental_sinks, struct rtp_payload_type *pref_dest_codec) { GHashTable *dtmf_sinks = g_hash_table_lookup(supplemental_sinks, "telephone-event"); if (!dtmf_sinks) @@ -485,19 +502,14 @@ static int __dtmf_payload_type(GHashTable *supplemental_sinks, struct rtp_payloa if (!g_hash_table_size(dtmf_sinks) || !pref_dest_codec) return -1; - int dtmf_payload_type = -1; + int dtmf_payload_type = __supp_payload_type(supplemental_sinks, pref_dest_codec, "telephone-event"); - // find the telephone-event codec entry with a matching clock rate - struct rtp_payload_type *pt = g_hash_table_lookup(dtmf_sinks, - GUINT_TO_POINTER(pref_dest_codec->clock_rate)); - if (!pt) + if (dtmf_payload_type == -1) ilog(LOG_INFO, "Not transcoding PCM DTMF tones to telephone-event packets as " "no payload type with a matching clock rate for '" STR_FORMAT "' was found", STR_FMT(&pref_dest_codec->encoding_with_params)); - else { - dtmf_payload_type = pt->payload_type; + else ilog(LOG_DEBUG, "Output DTMF payload type is %i", dtmf_payload_type); - } return dtmf_payload_type; }