diff --git a/daemon/codec.c b/daemon/codec.c index e48a1c3e3..7c616db43 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -766,33 +766,44 @@ next: } - -#endif - - -// call must be locked in R -struct codec_handler *codec_handler_get(struct call_media *m, int payload_type) { -#ifdef WITH_TRANSCODING +static struct codec_handler *codec_handler_get_rtp(struct call_media *m, int payload_type) { struct codec_handler *h; if (payload_type < 0) - goto out; + return NULL; h = g_atomic_pointer_get(&m->codec_handler_cache); if (G_LIKELY(G_LIKELY(h) && G_LIKELY(h->source_pt.payload_type == payload_type))) return h; if (G_UNLIKELY(!m->codec_handlers)) - goto out; + return NULL; h = g_hash_table_lookup(m->codec_handlers, GINT_TO_POINTER(payload_type)); if (!h) - goto out; + return NULL; g_atomic_pointer_set(&m->codec_handler_cache, h); return h; +} + +#endif + + +// call must be locked in R +struct codec_handler *codec_handler_get(struct call_media *m, int payload_type) { +#ifdef WITH_TRANSCODING + struct codec_handler *ret = NULL; + + if (!m->protocol) + goto out; + + if (m->protocol->rtp) + ret = codec_handler_get_rtp(m, payload_type); out: + if (ret) + return ret; if (MEDIA_ISSET(m, TRANSCODE)) return &codec_handler_stub_ssrc; #endif diff --git a/t/transcode-test.c b/t/transcode-test.c index b450185a9..6bd3c34d0 100644 --- a/t/transcode-test.c +++ b/t/transcode-test.c @@ -61,9 +61,11 @@ static void __start(const char *file, int line) { ml_A = (struct call_monologue) {0,}; str_init(&ml_A.tag, "tag_A"); media_A->monologue = &ml_A; + media_A->protocol = &transport_protocols[PROTO_RTP_AVP]; ml_B = (struct call_monologue) {0,}; str_init(&ml_B.tag, "tag_B"); media_B->monologue = &ml_B; + media_B->protocol = &transport_protocols[PROTO_RTP_AVP]; g_queue_init(&rtp_types); // parsed from received SDP flags.codec_strip = g_hash_table_new_full(str_hash, str_equal, str_slice_free, NULL); flags.codec_mask = g_hash_table_new_full(str_hash, str_equal, str_slice_free, NULL);