Browse Source

TT#76711 convert codec handlers hash table to direct hash

Change-Id: Ieeb8183cd8041a10e311fb4f2fe6b92bbc5ad8bb
changes/80/38280/6
Richard Fuchs 6 years ago
parent
commit
d847d26e0b
2 changed files with 8 additions and 8 deletions
  1. +7
    -7
      daemon/codec.c
  2. +1
    -1
      t/transcode-test.c

+ 7
- 7
daemon/codec.c View File

@ -382,9 +382,8 @@ static void __check_send_codecs(struct call_media *receiver, struct call_media *
// even if the receiver can receive the same codec that the sink can
// send, we might still have it configured as a transcoder due to
// always-transcode in the offer
// XXX codec_handlers can be converted to g_direct_hash table
struct codec_handler *ch_recv =
g_hash_table_lookup(sink->codec_handlers, &recv_pt->payload_type);
g_hash_table_lookup(sink->codec_handlers, GINT_TO_POINTER(recv_pt->payload_type));
if (!ch_recv)
continue;
if (ch_recv->transcoder) {
@ -525,7 +524,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(g_int_hash, g_int_equal);
receiver->codec_handlers = g_hash_table_new(g_direct_hash, g_direct_equal);
MEDIA_CLEAR(receiver, TRANSCODE);
receiver->rtcp_handler = NULL;
@ -599,21 +598,22 @@ void codec_handlers_update(struct call_media *receiver, struct call_media *sink,
// first, make sure we have a codec_handler struct for this
__ensure_codec_def(pt, receiver);
struct codec_handler *handler;
handler = g_hash_table_lookup(receiver->codec_handlers, &pt->payload_type);
handler = g_hash_table_lookup(receiver->codec_handlers, GINT_TO_POINTER(pt->payload_type));
if (handler) {
// make sure existing handler matches this PT
if (rtp_payload_type_cmp(pt, &handler->source_pt)) {
ilog(LOG_DEBUG, "Resetting codec handler for PT %u", pt->payload_type);
handler = NULL;
g_atomic_pointer_set(&receiver->codec_handler_cache, NULL);
g_hash_table_remove(receiver->codec_handlers, &pt->payload_type);
g_hash_table_remove(receiver->codec_handlers, GINT_TO_POINTER(pt->payload_type));
}
}
if (!handler) {
ilog(LOG_DEBUG, "Creating codec handler for " STR_FORMAT,
STR_FMT(&pt->encoding_with_params));
handler = __handler_new(pt);
g_hash_table_insert(receiver->codec_handlers, &handler->source_pt.payload_type,
g_hash_table_insert(receiver->codec_handlers,
GINT_TO_POINTER(handler->source_pt.payload_type),
handler);
g_queue_push_tail(&receiver->codec_handlers_store, handler);
}
@ -784,7 +784,7 @@ struct codec_handler *codec_handler_get(struct call_media *m, int payload_type)
if (G_UNLIKELY(!m->codec_handlers))
goto out;
h = g_hash_table_lookup(m->codec_handlers, &payload_type);
h = g_hash_table_lookup(m->codec_handlers, GINT_TO_POINTER(payload_type));
if (!h)
goto out;


+ 1
- 1
t/transcode-test.c View File

@ -141,7 +141,7 @@ static void __expect(const char *file, int line, GQueue *dumper, const char *cod
static void __check_encoder(const char *file, int line, struct call_media *m, int in_pt, int out_pt,
int out_bitrate)
{
struct codec_handler *ch = g_hash_table_lookup(m->codec_handlers, &in_pt);
struct codec_handler *ch = g_hash_table_lookup(m->codec_handlers, GINT_TO_POINTER(in_pt));
printf("running test %s:%i\n", file, line);
assert(ch->source_pt.payload_type == in_pt);
if (ch->dest_pt.payload_type != out_pt || ch->dest_pt.bitrate != out_bitrate) {


Loading…
Cancel
Save