hlsdemux2/m3u8: Implement EXT-X-GAP parsing

Read the EXT-X-GAP tag and set is_gap on the segment.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3314>
This commit is contained in:
Jan Schmidt 2022-06-07 14:36:24 +10:00
parent 55db033570
commit 9f89b8e3ef
2 changed files with 8 additions and 0 deletions

View file

@ -488,6 +488,7 @@ gst_hls_media_playlist_parse (gchar * data, const gchar * uri,
GDateTime *date_time = NULL; GDateTime *date_time = NULL;
GstM3U8InitFile *last_init_file = NULL; GstM3U8InitFile *last_init_file = NULL;
GstM3U8MediaSegment *previous = NULL; GstM3U8MediaSegment *previous = NULL;
gboolean is_gap = FALSE;
GST_LOG ("uri: %s", uri); GST_LOG ("uri: %s", uri);
GST_LOG ("base_uri: %s", base_uri); GST_LOG ("base_uri: %s", base_uri);
@ -544,6 +545,7 @@ gst_hls_media_playlist_parse (gchar * data, const gchar * uri,
title = NULL; title = NULL;
discontinuity = FALSE; discontinuity = FALSE;
size = offset = -1; size = offset = -1;
is_gap = FALSE;
goto next_line; goto next_line;
} }
if (data != NULL) { if (data != NULL) {
@ -556,6 +558,8 @@ gst_hls_media_playlist_parse (gchar * data, const gchar * uri,
dsn, size, offset); dsn, size, offset);
self->duration += duration; self->duration += duration;
file->is_gap = is_gap;
/* set encryption params */ /* set encryption params */
if (current_key != NULL) { if (current_key != NULL) {
file->key = g_strdup (current_key); file->key = g_strdup (current_key);
@ -744,6 +748,8 @@ gst_hls_media_playlist_parse (gchar * data, const gchar * uri,
last_init_file = init_file; last_init_file = init_file;
} }
} else if (g_str_has_prefix (data_ext_x, "GAP:")) {
is_gap = TRUE;
} else { } else {
GST_LOG ("Ignored line: %s", data); GST_LOG ("Ignored line: %s", data);
} }

View file

@ -136,6 +136,8 @@ void gst_hls_media_playlist_unref (GstHLSMediaPlaylist * m3u8);
*/ */
struct _GstM3U8MediaSegment struct _GstM3U8MediaSegment
{ {
gboolean is_gap; /* TRUE if EXT-X-GAP was present for this segment */
gchar *title; gchar *title;
GstClockTimeDiff stream_time; /* Computed stream time */ GstClockTimeDiff stream_time; /* Computed stream time */
GstClockTime duration; GstClockTime duration;