From 59f9c7ce585aca756404d06b1cf8e375f3f6739b Mon Sep 17 00:00:00 2001 From: Grzegorz Sluja <grzegorz.sluja@iopsys.eu> Date: Thu, 2 Nov 2023 10:44:04 +0000 Subject: [PATCH] Fix sequence number used by asterisk for outgoing RTP packets There was no audio for 3-way conference when sRTP is used. For 2-way calls frame->seqno is taken from DSP and is used by asterisk for the sequence number in RTP headers. However for 3-way conference the sequence number is generated by asterisk and it has to be greater than the previous value, otherwise libsrtp refuses to forward 'too old' RTP packets. --- res/res_rtp_asterisk.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c index b0fab6c435..33ac842a81 100644 --- a/res/res_rtp_asterisk.c +++ b/res/res_rtp_asterisk.c @@ -5126,7 +5126,12 @@ static int rtp_raw_write(struct ast_rtp_instance *instance, struct ast_frame *fr rtp->ssrc = frame->ssrc; } - put_unaligned_uint32(rtpheader, htonl((2 << 30) | (ext << 28) | (codec << 16) | (frame->seqno ? frame->seqno : seqno) | (mark << 23))); + if (frame->seqno) + rtp->seqno = frame->seqno; + else + rtp->seqno++; + + put_unaligned_uint32(rtpheader, htonl((2 << 30) | (ext << 28) | (codec << 16) | (rtp->seqno) | (mark << 23))); put_unaligned_uint32(rtpheader + 4, htonl(frame->ts ? frame->ts : rtp->lastts)); put_unaligned_uint32(rtpheader + 8, htonl(rtp->ssrc)); -- GitLab