diff --git a/daemon/codec.c b/daemon/codec.c index 16806ff3f..ffd19775b 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -14,6 +14,7 @@ #include "dtmflib.h" #include "t38.h" #include "media_player.h" +#include "timerthread.h" @@ -108,6 +109,10 @@ struct codec_tracker { }; + +static struct timerthread codec_timers_thread; + + static codec_handler_func handler_func_passthrough_ssrc; static codec_handler_func handler_func_transcode; static codec_handler_func handler_func_playback; @@ -2766,3 +2771,20 @@ void codec_rtp_payload_types(struct call_media *media, struct call_media *other_ g_hash_table_destroy(stripped); g_hash_table_destroy(masked); } + +void codecs_init(void) { +#ifdef WITH_TRANSCODING + timerthread_init(&codec_timers_thread, timerthread_queue_run); +#endif +} +void codecs_cleanup(void) { +#ifdef WITH_TRANSCODING + timerthread_free(&codec_timers_thread); +#endif +} +void codec_timers_loop(void *p) { +#ifdef WITH_TRANSCODING + ilog(LOG_DEBUG, "codec_timers_loop"); + timerthread_run(&codec_timers_thread); +#endif +} diff --git a/daemon/main.c b/daemon/main.c index aae07865f..81ed4b784 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -48,6 +48,7 @@ #include "dtmf.h" #include "jitter_buffer.h" #include "websocket.h" +#include "codec.h" @@ -840,6 +841,7 @@ static void init_everything(void) { dtmf_init(); jitter_buffer_init(); t38_init(); + codecs_init(); } @@ -1025,6 +1027,7 @@ int main(int argc, char **argv) { if (rtpe_config.jb_length > 0) thread_create_detach_prio(jitter_buffer_loop, NULL, rtpe_config.scheduling, rtpe_config.priority); + thread_create_detach_prio(codec_timers_loop, NULL, rtpe_config.scheduling, rtpe_config.priority); } @@ -1071,6 +1074,7 @@ int main(int argc, char **argv) { ice_free(); dtls_cert_free(); control_ng_cleanup(); + codecs_cleanup(); redis_close(rtpe_redis); if (rtpe_redis_write != rtpe_redis) diff --git a/include/codec.h b/include/codec.h index 2ed37cedb..469d91a88 100644 --- a/include/codec.h +++ b/include/codec.h @@ -61,6 +61,10 @@ struct codec_packet { }; +void codecs_init(void); +void codecs_cleanup(void); +void codec_timers_loop(void *); + struct codec_handler *codec_handler_get(struct call_media *, int payload_type); void codec_handlers_free(struct call_media *); struct codec_handler *codec_handler_make_playback(const struct rtp_payload_type *src_pt,