hlsdemux2/m3u8: Implement EXT-X-GAP parsing
authorJan Schmidt <jan@centricular.com>
Tue, 7 Jun 2022 04:36:24 +0000 (14:36 +1000)
committerJan Schmidt <jan@centricular.com>
Fri, 4 Nov 2022 16:24:27 +0000 (03:24 +1100)
Read the EXT-X-GAP tag and set is_gap on the segment.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3314>

subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c
subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.h

index 0607d1e..89558a9 100644 (file)
@@ -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);
       }
index 41d8642..bbe1c1c 100644 (file)
@@ -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;