hlsdemux2: Expose EXT-X-PROGRAM-DATE-TIME as tags.
authorEnrique Ocaña González <eocanha@igalia.com>
Tue, 3 May 2022 16:36:54 +0000 (18:36 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 17 Nov 2022 22:11:12 +0000 (22:11 +0000)
This allows an application to use timestamps associated
with fragments.

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

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

index 280a420..0cf7a34 100644 (file)
@@ -192,6 +192,7 @@ gst_hls_demux_stream_init (GstHLSDemuxStream * stream)
   stream->do_typefind = TRUE;
   stream->reset_pts = TRUE;
   stream->presentation_offset = 60 * GST_SECOND;
+  stream->pdt_tag_sent = FALSE;
 }
 
 typedef struct _GstHLSDemux2 GstHLSDemux2;
@@ -1683,8 +1684,9 @@ gst_hls_demux_stream_data_received (GstAdaptiveDemux2Stream * stream,
 {
   GstHLSDemuxStream *hls_stream = GST_HLS_DEMUX_STREAM_CAST (stream);
   GstHLSDemux *hlsdemux = GST_HLS_DEMUX_CAST (stream->demux);
+  GstM3U8MediaSegment *file = hls_stream->current_segment;
 
-  if (hls_stream->current_segment == NULL)
+  if (file == NULL)
     return GST_ADAPTIVE_DEMUX_FLOW_LOST_SYNC;
 
   if (hls_stream->current_offset == -1)
@@ -1727,6 +1729,14 @@ gst_hls_demux_stream_data_received (GstAdaptiveDemux2Stream * stream,
       return GST_FLOW_OK;
   }
 
+  if (!hls_stream->pdt_tag_sent && file != NULL && file->datetime != NULL) {
+    gst_adaptive_demux2_stream_set_tags (stream,
+        gst_tag_list_new (GST_TAG_DATE_TIME,
+            gst_date_time_new_from_g_date_time (g_date_time_ref
+                (file->datetime)), NULL));
+    hls_stream->pdt_tag_sent = TRUE;
+  }
+
   return gst_hls_demux_stream_handle_buffer (stream, buffer, FALSE);
 }
 
@@ -2598,6 +2608,14 @@ gst_hls_demux_reset (GstAdaptiveDemux * ademux)
 
   GST_DEBUG_OBJECT (demux, "resetting");
 
+  if (ademux->input_period) {
+    GList *walk;
+    for (walk = ademux->input_period->streams; walk != NULL; walk = walk->next) {
+      GstHLSDemuxStream *hls_stream = GST_HLS_DEMUX_STREAM_CAST (walk->data);
+      hls_stream->pdt_tag_sent = FALSE;
+    }
+  }
+
   if (demux->master) {
     gst_hls_master_playlist_unref (demux->master);
     demux->master = NULL;
index 1d7f7db..d4acf75 100644 (file)
@@ -168,6 +168,8 @@ struct _GstHLSDemuxStream
    * "output" stream times. Not enabled (i.e 0) if variant is ISOBMFF
    */
   GstClockTime presentation_offset;
+
+  gboolean pdt_tag_sent;
 };
 
 typedef struct {