m3u8: Don't try to match URIs when we have media sequences

It is legal for a stream to reuse segments (marking discontinuities as
needed). Uplynk delivers such playlists for their placeholder loops.

Leave the URI scanning in place for playlists which have no
EXT-X-MEDIA-SEQUENCE tag. This should be harmless since the spec
requires these playlists to not be missing segments (RFC8216 6.2.2),
so we should be always matching on the first segment.

https://bugzilla.gnome.org/show_bug.cgi?id=788417
This commit is contained in:
Jan Alexander Steffens (heftig) 2017-09-27 09:27:12 +02:00 committed by Sebastian Dröge
parent 025633b162
commit 7690a4a521

View file

@ -321,8 +321,8 @@ check_media_seqnums (GstM3U8 * self, GList * previous_files)
return TRUE; return TRUE;
} }
/* Find first case of higher/equal sequence number in new playlist or /* Find first case of higher/equal sequence number in new playlist.
* same URI. From there on we can linearly step ahead */ * From there on we can linearly step ahead */
for (l = self->files; l; l = l->next) { for (l = self->files; l; l = l->next) {
gboolean match = FALSE; gboolean match = FALSE;
@ -330,7 +330,7 @@ check_media_seqnums (GstM3U8 * self, GList * previous_files)
for (m = previous_files; m; m = m->next) { for (m = previous_files; m; m = m->next) {
f2 = m->data; f2 = m->data;
if (f1->sequence >= f2->sequence || g_str_equal (f1->uri, f2->uri)) { if (f1->sequence >= f2->sequence) {
match = TRUE; match = TRUE;
break; break;
} }
@ -345,7 +345,7 @@ check_media_seqnums (GstM3U8 * self, GList * previous_files)
if (!l) { if (!l) {
/* No match, no sequence in the new playlist was higher than /* No match, no sequence in the new playlist was higher than
* any in the old, and no URI was found again. This is bad! */ * any in the old. This is bad! */
GST_ERROR ("Media sequences inconsistent, ignoring"); GST_ERROR ("Media sequences inconsistent, ignoring");
return FALSE; return FALSE;
} }
@ -354,27 +354,16 @@ check_media_seqnums (GstM3U8 * self, GList * previous_files)
f1 = l->data; f1 = l->data;
f2 = m->data; f2 = m->data;
if (f1->sequence == f2->sequence) { if (f1->sequence == f2->sequence && !g_str_equal (f1->uri, f2->uri)) {
if (!g_str_equal (f1->uri, f2->uri)) { /* Same sequence, different URI. This is bad! */
/* Same sequence, different URI. This is bad! */ GST_ERROR ("Media sequences inconsistent, ignoring");
GST_ERROR ("Media sequences inconsistent, ignoring"); return FALSE;
return FALSE; } else if (f1->sequence < f2->sequence) {
} else { /* Not same sequence but by construction sequence must be higher in the
/* Good case, we advance and check the next one */ * new one. All good in that case, if it isn't then this means that
} * sequence numbers are decreasing or files were inserted */
} else if (g_str_equal (f1->uri, f2->uri)) {
/* Same URIs but different sequences, this is bad! */
GST_ERROR ("Media sequences inconsistent, ignoring"); GST_ERROR ("Media sequences inconsistent, ignoring");
return FALSE; return FALSE;
} else {
/* Not same URI, not same sequence but by construction sequence
* must be higher in the new one. All good in that case, if it
* isn't then this means that sequence numbers are decreasing
* or files were inserted */
if (f1->sequence < f2->sequence) {
GST_ERROR ("Media sequences inconsistent, ignoring");
return FALSE;
}
} }
} }