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
changes/91/37291/5
Richard Fuchs 6 years ago
parent
commit
7e0b2c4ac3
2 changed files with 7 additions and 10 deletions
  1. +6
    -10
      daemon/codec.c
  2. +1
    -0
      include/call.h

+ 6
- 10
daemon/codec.c View File

@ -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_clear_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
}


+ 1
- 0
include/call.h View File

@ -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;


Loading…
Cancel
Save