From 7ebc418a65f28e392a800ba844d40e206749d3d1 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 (cherry picked from commit d3992101bdc96767c819b19b36284385ec0fb7b3) --- daemon/codec.c | 5 +++-- include/call.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/daemon/codec.c b/daemon/codec.c index 2339d9f90..7ad0406ba 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -192,8 +192,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; @@ -351,6 +350,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 @@ -513,6 +513,7 @@ 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_clear_full(&m->codec_handlers_store, __codec_handler_free); } diff --git a/include/call.h b/include/call.h index 25e5fe488..34ceb6973 100644 --- a/include/call.h +++ b/include/call.h @@ -339,6 +339,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;