From da06ed217b6f3b042fa4f6b73e71546ceff334ce Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 12 May 2021 13:30:44 -0400 Subject: [PATCH] TT#122401 add ptime to DTX trigger Change-Id: I96aabff398cbe296243d8bdf7499468c6da96352 --- daemon/codec.c | 2 +- lib/codeclib.c | 15 ++++++++------- lib/codeclib.h | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/daemon/codec.c b/daemon/codec.c index 1f0bbb3ca..9eef109a3 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -2580,7 +2580,7 @@ static void __dtx_send_later(struct timerthread_queue *ttq, void *p) { // synthetic packet mp_copy.rtp->seq_num += htons(1); - ret = decoder_dtx(ch->decoder, ts, + ret = decoder_dtx(ch->decoder, ts, dtxb->ptime, ch->handler->packet_decoded, ch, &mp_copy); if (ret) ilogs(dtx, LOG_WARN | LOG_FLAG_LIMIT, diff --git a/lib/codeclib.c b/lib/codeclib.c index f5aded111..1be5ca58b 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -61,7 +61,7 @@ static int cn_decoder_input(decoder_t *dec, const str *data, GQueue *out); static int format_cmp_ignore(const struct rtp_payload_type *, const struct rtp_payload_type *); -static int amr_dtx(decoder_t *, GQueue *); +static int amr_dtx(decoder_t *, GQueue *, int); @@ -682,7 +682,7 @@ err: return -1; } -static int __decoder_input_data(decoder_t *dec, const str *data, unsigned long ts, +static int __decoder_input_data(decoder_t *dec, const str *data, unsigned long ts, int ptime, int (*callback)(decoder_t *, AVFrame *, void *u1, void *u2), void *u1, void *u2) { GQueue frames = G_QUEUE_INIT; @@ -719,7 +719,7 @@ static int __decoder_input_data(decoder_t *dec, const str *data, unsigned long t if (data) dec->def->codec_type->decoder_input(dec, data, &frames); else - dec->def->dtx(dec, &frames); + dec->def->dtx(dec, &frames, ptime); AVFrame *frame; int ret = 0; @@ -743,12 +743,12 @@ int decoder_input_data(decoder_t *dec, const str *data, unsigned long ts, { if (!data || !data->s || !data->len) return 0; - return __decoder_input_data(dec, data, ts, callback, u1, u2); + return __decoder_input_data(dec, data, ts, 0, callback, u1, u2); } -int decoder_dtx(decoder_t *dec, unsigned long ts, +int decoder_dtx(decoder_t *dec, unsigned long ts, int ptime, int (*callback)(decoder_t *, AVFrame *, void *u1, void *u2), void *u1, void *u2) { - return __decoder_input_data(dec, NULL, ts, callback, u1, u2); + return __decoder_input_data(dec, NULL, ts, ptime, callback, u1, u2); } @@ -2113,7 +2113,8 @@ static int packetizer_amr(AVPacket *pkt, GString *buf, str *output, encoder_t *e return 0; } -static int amr_dtx(decoder_t *dec, GQueue *out) { +static int amr_dtx(decoder_t *dec, GQueue *out, int ptime) { + // ignore ptime, must be 20 ilog(LOG_DEBUG, "pushing empty/lost frame to AMR decoder"); unsigned char frame_buf[1]; frame_buf[0] = 0xf << 3; // no data diff --git a/lib/codeclib.h b/lib/codeclib.h index e85cae2af..33f4989fa 100644 --- a/lib/codeclib.h +++ b/lib/codeclib.h @@ -72,7 +72,7 @@ typedef void format_init_f(struct rtp_payload_type *); typedef void set_enc_options_f(encoder_t *, const str *, const str *); typedef void set_dec_options_f(decoder_t *, const str *, const str *); typedef int format_cmp_f(const struct rtp_payload_type *, const struct rtp_payload_type *); -typedef int decoder_dtx_f(decoder_t *, GQueue *); +typedef int decoder_dtx_f(decoder_t *, GQueue *, int); @@ -280,7 +280,7 @@ decoder_t *decoder_new_fmtp(const codec_def_t *def, int clockrate, int channels, void decoder_close(decoder_t *dec); int decoder_input_data(decoder_t *dec, const str *data, unsigned long ts, int (*callback)(decoder_t *, AVFrame *, void *u1, void *u2), void *u1, void *u2); -int decoder_dtx(decoder_t *dec, unsigned long ts, +int decoder_dtx(decoder_t *dec, unsigned long ts, int ptime, int (*callback)(decoder_t *, AVFrame *, void *u1, void *u2), void *u1, void *u2);