diff --git a/daemon/codec.c b/daemon/codec.c index 8180bb53b..1871dd873 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -74,6 +74,7 @@ struct dtx_buffer { int tspp; // timestamp increment per packet struct call *call; unsigned long ts; + time_t start; }; struct dtx_entry { struct timerthread_queue_entry ttq_entry; @@ -1908,9 +1909,10 @@ static void __dtx_send_later(struct timerthread_queue *ttq, void *p) { unsigned long dtxe_ts = dtxe->ts; mutex_lock(&dtxb->lock); + unsigned int diff = rtpe_now.tv_sec - dtxb->start; unsigned long dtxb_ts = dtxb->ts; - if (dtxe_ts == dtxb_ts) { + if (dtxe_ts == dtxb_ts && (rtpe_config.max_dtx <= 0 || diff < rtpe_config.max_dtx)) { ilog(LOG_DEBUG, "RTP media for TS %lu+ missing, triggering DTX", dtxe_ts); @@ -2301,6 +2303,7 @@ static int packet_decode(struct codec_ssrc_handler *ch, struct transcode_packet mutex_lock(&dtxb->lock); if (ts != dtxb->ts) dtxb->ts = ts; + dtxb->start = rtpe_now.tv_sec; mutex_unlock(&dtxb->lock); struct dtx_entry *dtxe = g_slice_alloc0(sizeof(*dtxe)); diff --git a/daemon/main.c b/daemon/main.c index cfc862fca..f304a7ab8 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -79,6 +79,7 @@ struct rtpengine_config rtpe_config = { .media_num_threads = -1, .dtls_rsa_key_size = 2048, .dtls_signature = 256, + .max_dtx = 30, }; static void sighandler(gpointer x) { @@ -461,6 +462,7 @@ static void options(int *argc, char ***argv) { { "http-threads", 0,0, G_OPTION_ARG_INT, &rtpe_config.http_threads,"Number of worker threads for HTTP and WS","INT"}, #ifdef WITH_TRANSCODING { "dtx-delay", 0,0, G_OPTION_ARG_INT, &rtpe_config.dtx_delay, "Delay in milliseconds to trigger DTX handling","INT"}, + { "max-dtx", 0,0, G_OPTION_ARG_INT, &rtpe_config.max_dtx, "Maximum duration of DTX handling", "INT"}, #endif { NULL, } diff --git a/daemon/rtpengine.pod b/daemon/rtpengine.pod index 13888f442..a2dd9cfc6 100644 --- a/daemon/rtpengine.pod +++ b/daemon/rtpengine.pod @@ -738,6 +738,13 @@ time during a transmission gap, for example by generating comfort noise. The delay should be configured to just slightly more than the expected incoming jitter. +=item B<--max-dtx=>I + +Maximum duration for DTX handling in seconds. If no further RTP media is +received within this time frame, then DTX processing will stop. Can be set to +zero or negative to disable and keep DTX processing on indefinitely. Defaults +to 30 seconds. + =back =head1 INTERFACES diff --git a/include/main.h b/include/main.h index 5ff524609..ab8d6f53c 100644 --- a/include/main.h +++ b/include/main.h @@ -107,6 +107,7 @@ struct rtpengine_config { char *https_key; int http_threads; int dtx_delay; + int max_dtx; };