hlsdemux2: Use variant stream as support for synchronizing playlists
authorEdward Hervey <edward@centricular.com>
Wed, 1 Jun 2022 13:45:23 +0000 (15:45 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 28 Jun 2022 17:59:23 +0000 (17:59 +0000)
When matching playlists, there is a possibility that rendition streams will not
have been updated in time (for example because that stream started later, or
playback was paused). This would cause several playback failures and seeking
failures.

In order to still fall back on our feet, attempt to synchronize that rendition
playlist against the current variant playlist. This will attempt to match the
stream time using SN/DNS/PDT/...

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

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

index 23ee1ae..e21264c 100644 (file)
@@ -1955,10 +1955,20 @@ gst_hls_demux_stream_update_media_playlist (GstHLSDemux * demux,
   if (stream->playlist) {
     if (!gst_hls_media_playlist_sync_to_playlist (new_playlist,
             stream->playlist)) {
-      /* FIXME : We need to have a way to re-calculate sync ! */
-      GST_ERROR_OBJECT (stream,
-          "Could not synchronize new playlist with previous one !");
-      return FALSE;
+      /* Failure to sync is only fatal for variant streams. */
+      if (stream->is_variant) {
+        GST_ERROR_OBJECT (stream,
+            "Could not synchronize new variant playlist with previous one !");
+        return FALSE;
+      }
+      /* For rendition streams, we can attempt synchronization against the
+       * variant playlist which is constantly updated */
+      if (!gst_hls_media_playlist_sync_to_playlist (new_playlist,
+              demux->main_stream->playlist)) {
+        GST_ERROR_OBJECT (stream,
+            "Could not do fallback synchronization of rendition stream to variant stream");
+        return FALSE;
+      }
     }
   }