From ce44eaf1d33e63f75295fdb0b3b1f6ae26d8977b Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 27 Mar 2018 13:14:04 -0400 Subject: [PATCH] fix RTP timestamps in G.729 decoder also fixes SRTP auth tag passed to transcoder closes #501 Change-Id: I2253d1372784d0332b8449f8fb8087a2f7e4c699 --- daemon/media_socket.c | 7 ++++++- lib/codeclib.c | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/daemon/media_socket.c b/daemon/media_socket.c index 2122981ae..ec04f4b7e 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -1360,8 +1360,13 @@ static int media_packet_decrypt(struct packet_handler_ctx *phc) /* return values are: 0 = forward packet, -1 = error/dont forward, * 1 = forward and push update to redis */ int ret = 0; - if (phc->decrypt_func) + if (phc->decrypt_func) { + str ori_s = phc->s; ret = phc->decrypt_func(&phc->s, phc->in_srtp, phc->mp.sfd, &phc->mp.fsin, &phc->mp.tv, phc->mp.ssrc_in); + // XXX for stripped auth tag and duplicate invokations of rtp_payload + // XXX transcoder uses phc->mp.payload + phc->mp.payload.len -= ori_s.len - phc->s.len; + } mutex_unlock(&phc->in_srtp->in_lock); diff --git a/lib/codeclib.c b/lib/codeclib.c index b00554e39..f820de992 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -1250,6 +1250,7 @@ static const char *bcg729_decoder_init(decoder_t *dec) { static int bcg729_decoder_input(decoder_t *dec, const str *data, GQueue *out) { str input = *data; + u_int64_t pts = dec->pts; while (input.len >= 2) { int frame_len = input.len >= 10 ? 10 : 2; @@ -1262,9 +1263,12 @@ static int bcg729_decoder_input(decoder_t *dec, const str *data, GQueue *out) { frame->format = AV_SAMPLE_FMT_S16; frame->sample_rate = dec->in_format.clockrate; // 8000 frame->channel_layout = av_get_default_channel_layout(dec->in_format.channels); // 1 channel + frame->pts = pts; if (av_frame_get_buffer(frame, 0) < 0) abort(); + pts += frame->nb_samples; + // XXX handle lost packets and comfort noise bcg729Decoder(dec->u.bcg729, (void *) inp_frame.s, inp_frame.len, 0, 0, 0, (void *) frame->extended_data[0]);