m3u8demux2: Fix off-by-one and leak.

Fix an off-by-one in gst_hls_media_playlist_sync_to_playlist() that would ignore
the first fragment in the reference playlist.  The error was harmless, since we
expect the reference playlist to be older than the playlist we're
synchronising (so the first/oldest segment in the reference playlist will likely
not exist in the new playlist), so this is just for correctness.

Also fix a segment leak in gst_hls_media_playlist_advance_fragment() when
ignoring the partial_only segment.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883>
This commit is contained in:
Jan Schmidt 2022-08-12 05:00:32 +10:00 committed by GStreamer Marge Bot
parent 676fffd23c
commit 9848c1a1a1

View file

@ -1830,8 +1830,8 @@ retry_without_dsn:
* or a more recently fetched playlist from another rendition. In either case,
* it's best to start from the last segment of the (older) reference playlist and
* go backwards to find an overlap */
for (idx = reference->segments->len - 1; idx; idx--) {
cand = g_ptr_array_index (reference->segments, idx);
for (idx = reference->segments->len; idx; idx--) {
cand = g_ptr_array_index (reference->segments, idx - 1);
res = find_segment_in_playlist (playlist, cand, &is_before, &matched_pdt);
if (res)
break;
@ -1957,6 +1957,7 @@ gst_hls_media_playlist_advance_fragment (GstHLSMediaPlaylist * m3u8,
if (file && file->partial_only && !allow_partial_only_segment) {
GST_LOG
("Ignoring segment with only partials as full segment was requested");
gst_m3u8_media_segment_unref (file);
file = NULL;
}