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: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1346>
This commit is contained in:
Hosang Lee 2020-06-16 12:42:16 +09:00
parent 1d1b3eb8b4
commit d9dda36e02

View file

@ -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 */