From f14f94d617c22fffed3a96f61883e265205b9382 Mon Sep 17 00:00:00 2001 From: Arman Bahlakeh Date: Thu, 22 Oct 2026 19:16:32 +0200 Subject: [PATCH] MT#55283 transcode: do not write the sequencer position into the SRTP receive index stats->ext_seq has been the SRTP receive index since srtp_index moved into shm (08c7f5853d41). The transcode sequencer overwrote it after every emitted packet with its own roc<<16|seq, which lags the received packets and, whenever the sequencer emits a late or replayed packet with a lower sequence number, carries a roc that was incremented without a real wrap-around. packet_index() then estimated the wrong index, and once the sender's real roc reached 1 none of the fallback guesses matched, so every packet of the stream failed authentication until the call ended. packet_index() already maintains the index for every received packet, so drop the write. Also make the sequencer's own roc increment only on a forward wrap-around, never on a backwards step. Closes #2221 Change-Id: Ia38bf8cbc63dd3435717927f1adfd81ac94ea347 (cherry picked from commit 956d7add0900f4e18b302f0593cc50d301c66e1e) (cherry picked from commit ff56b32f8105920aa7c26d0dc6e22f2fe4fa51c0) --- daemon/codec.c | 5 ++++- lib/codeclib.c | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/daemon/codec.c b/daemon/codec.c index 68fd50e71..cfa1431fa 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -2422,7 +2422,10 @@ static int __handler_func_sequencer(struct media_packet *mp, struct transcode_pa } ssrc_in->packets_lost = seq->lost_count; - atomic_set_na(&ssrc_in->stats->ext_seq, seq->ext_seq); + // stats->ext_seq is the SRTP receive index (packet_index() in rtp.c and the + // kernel module) and is already updated for every received packet. The + // sequencer's position is an emission position that can legitimately move + // backwards, so it must not be written into the receive index. ilogs(transcoding, LOG_DEBUG, "Processing RTP packet: seq %u, TS %lu", packet->p.seq, packet->ts); diff --git a/lib/codeclib.c b/lib/codeclib.c index 8353b8535..231b2382b 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -590,7 +590,9 @@ out:; ps->a_nxt = -1u; unsigned int ext_seq = ps->roc << 16 | packet->seq; - while (ext_seq < ps->ext_seq) { + // a lower seq is a rollover only if it is far behind (forward wrap-around), + // not when a late or replayed packet is emitted + while (ext_seq < ps->ext_seq && ps->ext_seq - ext_seq >= 0x8000) { ps->roc++; ext_seq += 0x10000; }