From d9dda36e02c82eb91a6b946d9a2a66c71ecef00b Mon Sep 17 00:00:00 2001 From: Hosang Lee Date: Tue, 16 Jun 2020 12:42:16 +0900 Subject: [PATCH] smoothstreaming: start closer to the edge in live streams It is more appropriate to start closer to the live edge in live streams. Some live streams maintain a large dvr window (over few hours in some cases), so starting from the first fragment will be too far away from the live edge. Part-of: --- ext/smoothstreaming/gstmssmanifest.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ext/smoothstreaming/gstmssmanifest.c b/ext/smoothstreaming/gstmssmanifest.c index 5d195eb996..0ab4096e3d 100644 --- a/ext/smoothstreaming/gstmssmanifest.c +++ b/ext/smoothstreaming/gstmssmanifest.c @@ -54,6 +54,8 @@ GST_DEBUG_CATEGORY_EXTERN (mssdemux_debug); #define MSS_PROP_TIMESCALE "TimeScale" #define MSS_PROP_URL "Url" +#define GST_MSSMANIFEST_LIVE_MIN_FRAGMENT_DISTANCE 3 + typedef struct _GstMssStreamFragment { guint number; @@ -286,7 +288,21 @@ _gst_mss_stream_init (GstMssManifest * manifest, GstMssStream * stream, if (builder.fragments) { stream->fragments = g_list_reverse (builder.fragments); - stream->current_fragment = stream->fragments; + if (manifest->is_live) { + GList *iter = g_list_last (stream->fragments); + gint i; + + for (i = 0; i < GST_MSSMANIFEST_LIVE_MIN_FRAGMENT_DISTANCE; i++) { + if (g_list_previous (iter)) { + iter = g_list_previous (iter); + } else { + break; + } + } + stream->current_fragment = iter; + } else { + stream->current_fragment = stream->fragments; + } } /* order them from smaller to bigger based on bitrates */