From 89589b77e404e64159b8be97a7e6fa59f46898b8 Mon Sep 17 00:00:00 2001 From: Jorge Leal Date: Fri, 6 Nov 2026 08:48:37 +0100 Subject: [PATCH] MT#55283 Do not re-base a fixed egress SSRC on an empty egress counter Closes #2238 On a change of source, a fixed egress SSRC carries the sequence numbering across by re-basing seq_diff on the egress counter (ext_seq). When nothing has been counted under the SSRC yet, that counter is 0 and the re-base restarts the sequence at 1. Under the unchanged SSRC the receiver sees a jump back; with SRTP downstream the replay protection may discard the stream for a long while. Re-base only once something has been counted under the SSRC; until then keep the offset in use. Together with the previous commit an empty counter now only means a leg that has not sent anything yet. Change-Id: I05ef221a5a2db016a24099037b20ec91c9cb884d --- daemon/media_socket.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/daemon/media_socket.c b/daemon/media_socket.c index 668e32222..53639bb0d 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -3083,8 +3083,16 @@ static void media_packet_rtp_out(struct packet_handler_ctx *phc, struct sink_han /* the egress sequence counter lives in memory shared with * the kernel module, so it stays current even while the * stream is offloaded and userspace sees no packets */ - uint16_t last = atomic_get_na(&so->stats->ext_seq); - so->seq_diff = last + 1 - seq; + uint32_t last = atomic_get_na(&so->stats->ext_seq); + /* Nothing counted under this SSRC yet: there is no + * numbering to carry on from, so keep the offset in use. + * Re-basing on an empty counter restarts the sequence at + * 1, which a fixed SSRC makes look like a jump back to + * whoever is downstream. Every plain RTP output keeps the + * egress index (see __sh_noop_index), so an empty counter + * means a leg that has sent nothing yet. */ + if (last) + so->seq_diff = (uint16_t) (last + 1) - seq; } so->fixed_in_ssrc = in_ssrc; so->fixed_in_ssrc_set = true;