summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hervey <edward@centricular.com>2022-06-08 11:17:09 +0200
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2022-06-28 17:59:24 +0000
commite9f8c7d33a4305ccacd1f7a8c0907a293bfa8042 (patch)
tree45d66f446071d28d9c4210923d7cdad7165ac195
parent0a658840da1b1e31eed7841fb22ab9edc647876e (diff)
hlsdemux2: Improve media playlist updates
* When dealing with rendition streams, we attempt to synchronize the media playlist against the variant stream. This helps with speeding up the correct initial fragment search and avoids issues when streams at activated at a much later time. * Also add checks for variant stream existence before attempting to use them Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2679>
-rw-r--r--subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.c
index 1db3271d34..e191298215 100644
--- a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.c
+++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.c
@@ -1956,24 +1956,33 @@ gst_hls_demux_stream_update_media_playlist (GstHLSDemux * demux,
}
/* Synchronize playlist with previous one */
- if (stream->playlist) {
- if (!gst_hls_media_playlist_sync_to_playlist (new_playlist,
- stream->playlist)) {
- /* 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;
- }
+ if (stream->playlist
+ && !gst_hls_media_playlist_sync_to_playlist (new_playlist,
+ stream->playlist)) {
+ /* Failure to synchronize with the previous media playlist 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 (demux->main_stream->playlist
+ && !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;
+ }
+ } else if (!stream->is_variant && demux->main_stream->playlist) {
+ /* For initial rendition media playlist, attempt to synchronize the playlist
+ * against the variant stream. This is non-fatal if it fails. */
+ GST_DEBUG_OBJECT (stream,
+ "Attempting to synchronize initial rendition stream with variant stream");
+ gst_hls_media_playlist_sync_to_playlist (new_playlist,
+ demux->main_stream->playlist);
}
if (stream->current_segment) {