From 9f89b8e3ef0970897c428049362b8bff60715cc7 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Tue, 7 Jun 2022 14:36:24 +1000 Subject: [PATCH] hlsdemux2/m3u8: Implement EXT-X-GAP parsing Read the EXT-X-GAP tag and set is_gap on the segment. Part-of: --- subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c | 6 ++++++ subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c index 0607d1ee5c..89558a9e21 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c @@ -488,6 +488,7 @@ gst_hls_media_playlist_parse (gchar * data, const gchar * uri, GDateTime *date_time = NULL; GstM3U8InitFile *last_init_file = NULL; GstM3U8MediaSegment *previous = NULL; + gboolean is_gap = FALSE; GST_LOG ("uri: %s", uri); GST_LOG ("base_uri: %s", base_uri); @@ -544,6 +545,7 @@ gst_hls_media_playlist_parse (gchar * data, const gchar * uri, title = NULL; discontinuity = FALSE; size = offset = -1; + is_gap = FALSE; goto next_line; } if (data != NULL) { @@ -556,6 +558,8 @@ gst_hls_media_playlist_parse (gchar * data, const gchar * uri, dsn, size, offset); self->duration += duration; + file->is_gap = is_gap; + /* set encryption params */ if (current_key != NULL) { 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; } + } else if (g_str_has_prefix (data_ext_x, "GAP:")) { + is_gap = TRUE; } else { GST_LOG ("Ignored line: %s", data); } diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.h b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.h index 41d864218f..bbe1c1cda2 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.h +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.h @@ -136,6 +136,8 @@ void gst_hls_media_playlist_unref (GstHLSMediaPlaylist * m3u8); */ struct _GstM3U8MediaSegment { + gboolean is_gap; /* TRUE if EXT-X-GAP was present for this segment */ + gchar *title; GstClockTimeDiff stream_time; /* Computed stream time */ GstClockTime duration;