From 950de61b9032247c937711ff7077e4c1a7332e0d Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 14 Mar 2025 10:04:40 -0400 Subject: [PATCH] MT#55283 add T.38 fill-in This triggers an initial "no carrier" indication if the sender is slow to start PCM. Change-Id: I3513efafae06f992b3c9abd58b8ec797320c3b56 (cherry picked from commit dafb68ef80000a9137a0ecc0a64693b089f37e68) (cherry picked from commit d0c557a7dc06be11a377f4c127765f24c5f8e02d) --- daemon/t38.c | 9 +++++++++ include/t38.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/daemon/t38.c b/daemon/t38.c index 2aaaf6380..99da98668 100644 --- a/daemon/t38.c +++ b/daemon/t38.c @@ -272,6 +272,7 @@ static bool t38_pcm_player(struct media_player *mp) { int16_t smp[80]; int num = t38_gateway_tx(tg->gw, smp, 80); if (num <= 0) { + ilog(LOG_DEBUG, "No T.38 PCM samples generated"); // use a fixed interval of 10 ms timeval_add_usec(&mp->next_run, 10000); timerthread_obj_schedule_abs(&mp->tt_obj, &mp->next_run); @@ -287,6 +288,12 @@ static bool t38_pcm_player(struct media_player *mp) { unsigned long long pts = tg->pts; tg->pts += num; + // handle fill-in + if (timeval_diff(&rtpe_now, &tg->last_rx_ts) > 30000) { + ilog(LOG_DEBUG, "Adding T.38 fill-in samples"); + t38_gateway_rx_fillin(tg->gw, 80); + } + mutex_unlock(&tg->lock); // this reschedules our player as well @@ -516,6 +523,8 @@ int t38_gateway_input_samples(struct t38_gateway *tg, int16_t amp[], int len) { ilog(LOG_WARN | LOG_FLAG_LIMIT, "%i PCM samples were not processed by the T.38 gateway", left); + tg->last_rx_ts = rtpe_now; + mutex_unlock(&tg->lock); return 0; diff --git a/include/t38.h b/include/t38.h index cc7a3d4bd..5d3dfc07a 100644 --- a/include/t38.h +++ b/include/t38.h @@ -64,6 +64,9 @@ struct t38_gateway { // player for PCM data struct media_player *pcm_player; unsigned long long pts; + + // to handle PCM fill-in + struct timeval last_rx_ts; }; void t38_init(void);