st2022-1-fecdec: fix packet trimming

g_sequence_remove_range's end iter is exclusive, so if one
wants to remove that item as well, it should be called with
the next iter.

This could in theory fix an issue where:

* The sequence isn't entirely trimmed, with an old item lingering

* Following FEC packets are immediately discarded because they
  arrived later than corresponding media packets, long enough for
  seqnums to wrap around

* We now try to reconstruct a media packet with a completely obsolete
  FEC packet, chaos ensues.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1341>
This commit is contained in:
Mathieu Duponchelle 2021-11-12 03:17:44 +01:00 committed by GStreamer Marge Bot
parent d2fd5f1534
commit 792fb05cec

View file

@ -221,7 +221,8 @@ trim_items (GstRTPST_2022_1_FecDec * dec)
GST_TRACE_OBJECT (dec, GST_TRACE_OBJECT (dec,
"Trimming packets up to %" GST_TIME_FORMAT " (seq: %u)", "Trimming packets up to %" GST_TIME_FORMAT " (seq: %u)",
GST_TIME_ARGS (GST_BUFFER_DTS_OR_PTS (item->buffer)), item->seq); GST_TIME_ARGS (GST_BUFFER_DTS_OR_PTS (item->buffer)), item->seq);
g_sequence_remove_range (g_sequence_get_begin_iter (dec->packets), iter); g_sequence_remove_range (g_sequence_get_begin_iter (dec->packets),
g_sequence_iter_next (iter));
} }
} }
@ -263,7 +264,7 @@ trim_fec_items (GstRTPST_2022_1_FecDec * dec, guint D)
D ? "row" : "column", D ? "row" : "column",
GST_TIME_ARGS (GST_BUFFER_DTS_OR_PTS (item->buffer)), item->seq); GST_TIME_ARGS (GST_BUFFER_DTS_OR_PTS (item->buffer)), item->seq);
g_sequence_remove_range (g_sequence_get_begin_iter (dec->fec_packets[D]), g_sequence_remove_range (g_sequence_get_begin_iter (dec->fec_packets[D]),
iter); g_sequence_iter_next (iter));
} }
} }