Browse Source

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 d3992101bd)
changes/92/37292/3
Richard Fuchs 6 years ago
parent
commit
5c6fd39cf6
2 changed files with 5 additions and 7 deletions
  1. +4
    -7
      daemon/codec.c
  2. +1
    -0
      include/call.h

+ 4
- 7
daemon/codec.c View File

@ -283,9 +283,7 @@ static void __dtmf_dsp_shutdown(struct call_media *sink, int payload_type) {
if (!sink->codec_handlers) if (!sink->codec_handlers)
return; 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; struct codec_handler *handler = l->data;
if (!handler->transcoder) if (!handler->transcoder)
continue; continue;
@ -299,8 +297,6 @@ static void __dtmf_dsp_shutdown(struct call_media *sink, int payload_type) {
payload_type); payload_type);
handler->dtmf_payload_type = -1; handler->dtmf_payload_type = -1;
} }
g_list_free(list);
} }
// call must be locked in W // call must be locked in W
@ -308,8 +304,7 @@ void codec_handlers_update(struct call_media *receiver, struct call_media *sink,
const struct sdp_ng_flags *flags) const struct sdp_ng_flags *flags)
{ {
if (!receiver->codec_handlers) 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); MEDIA_CLEAR(receiver, TRANSCODE);
receiver->rtcp_handler = NULL; receiver->rtcp_handler = NULL;
@ -536,6 +531,7 @@ void codec_handlers_update(struct call_media *receiver, struct call_media *sink,
handler = __handler_new(pt); handler = __handler_new(pt);
g_hash_table_insert(receiver->codec_handlers, &handler->source_pt.payload_type, g_hash_table_insert(receiver->codec_handlers, &handler->source_pt.payload_type,
handler); handler);
g_queue_push_tail(&receiver->codec_handlers_store, handler);
} }
// check our own support for this codec // check our own support for this codec
@ -717,6 +713,7 @@ void codec_handlers_free(struct call_media *m) {
g_hash_table_destroy(m->codec_handlers); g_hash_table_destroy(m->codec_handlers);
m->codec_handlers = NULL; m->codec_handlers = NULL;
m->codec_handler_cache = NULL; m->codec_handler_cache = NULL;
g_queue_clear_full(&m->codec_handlers_store, __codec_handler_free);
} }


+ 1
- 0
include/call.h View File

@ -319,6 +319,7 @@ struct call_media {
GHashTable *codec_handlers; // int payload type -> struct codec_handler GHashTable *codec_handlers; // int payload type -> struct codec_handler
// XXX combine this with 'codecs_recv' hash table? // XXX combine this with 'codecs_recv' hash table?
GQueue codec_handlers_store; // storage for struct codec_handler
volatile struct codec_handler *codec_handler_cache; volatile struct codec_handler *codec_handler_cache;
struct rtcp_handler *rtcp_handler; struct rtcp_handler *rtcp_handler;


Loading…
Cancel
Save