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
pull/2241/head
Jorge Leal 2 weeks ago committed by Richard Fuchs
parent 0f8ade7de4
commit 89589b77e4

@ -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;

Loading…
Cancel
Save