From d3992101bdc96767c819b19b36284385ec0fb7b3 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Mon, 3 Feb 2020 12:17:33 -0500 Subject: [PATCH] TT#75352 add a storage container for codec handlers The hash table cannot be used for storage any more as entries can be removed on demand (64e56d7) but can be cached in packet->handler at the same time. Possibly fixes #915 Change-Id: Ic74703b1a57294bfd704b6cddcd666d6063f510a --- daemon/codec.c | 16 ++++++---------- include/call.h | 1 + 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/daemon/codec.c b/daemon/codec.c index 2e1b00803..735c674a5 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -287,9 +287,7 @@ static void __dtmf_dsp_shutdown(struct call_media *sink, int payload_type) { if (!sink->codec_handlers) return; - GList *list = g_hash_table_get_values(sink->codec_handlers); - - for (GList *l = list; l; l = l->next) { + for (GList *l = sink->codec_handlers_store.head; l; l = l->next) { struct codec_handler *handler = l->data; if (!handler->transcoder) continue; @@ -303,8 +301,6 @@ static void __dtmf_dsp_shutdown(struct call_media *sink, int payload_type) { payload_type); handler->dtmf_payload_type = -1; } - - g_list_free(list); } @@ -498,7 +494,6 @@ static void __check_dtmf_injector(const struct sdp_ng_flags *flags, struct call_ if (!rtp_payload_type_cmp(pref_dest_codec, &receiver->dtmf_injector->dest_pt)) return; - codec_handler_free(receiver->dtmf_injector); receiver->dtmf_injector = NULL; } @@ -522,6 +517,7 @@ static void __check_dtmf_injector(const struct sdp_ng_flags *flags, struct call_ receiver->dtmf_injector = __handler_new(&src_pt); __make_transcoder(receiver->dtmf_injector, pref_dest_codec, output_transcoders, dtmf_payload_type, 0); receiver->dtmf_injector->func = handler_func_inject_dtmf; + g_queue_push_tail(&receiver->codec_handlers_store, receiver->dtmf_injector); } // call must be locked in W @@ -529,8 +525,7 @@ void codec_handlers_update(struct call_media *receiver, struct call_media *sink, const struct sdp_ng_flags *flags) { if (!receiver->codec_handlers) - receiver->codec_handlers = g_hash_table_new_full(g_int_hash, g_int_equal, - NULL, __codec_handler_free); + receiver->codec_handlers = g_hash_table_new(g_int_hash, g_int_equal); MEDIA_CLEAR(receiver, TRANSCODE); receiver->rtcp_handler = NULL; @@ -620,6 +615,7 @@ void codec_handlers_update(struct call_media *receiver, struct call_media *sink, handler = __handler_new(pt); g_hash_table_insert(receiver->codec_handlers, &handler->source_pt.payload_type, handler); + g_queue_push_tail(&receiver->codec_handlers_store, handler); } // check our own support for this codec @@ -808,9 +804,9 @@ void codec_handlers_free(struct call_media *m) { g_hash_table_destroy(m->codec_handlers); m->codec_handlers = NULL; m->codec_handler_cache = NULL; + g_queue_free_full(&m->codec_handlers_store, __codec_handler_free); #ifdef WITH_TRANSCODING - if (m->dtmf_injector) - codec_handler_free(m->dtmf_injector); + m->dtmf_injector = NULL; #endif } diff --git a/include/call.h b/include/call.h index 022ed8391..82589e127 100644 --- a/include/call.h +++ b/include/call.h @@ -320,6 +320,7 @@ struct call_media { GHashTable *codec_handlers; // int payload type -> struct codec_handler // XXX combine this with 'codecs_recv' hash table? + GQueue codec_handlers_store; // storage for struct codec_handler volatile struct codec_handler *codec_handler_cache; struct rtcp_handler *rtcp_handler; struct codec_handler *dtmf_injector;