hls: Exclusion of last three fragment in case of live playback
authorSeungha Yang <sh.yang@lge.com>
Tue, 24 Jan 2017 12:32:13 +0000 (21:32 +0900)
committerSebastian Dröge <sebastian@centricular.com>
Tue, 31 Jan 2017 11:23:34 +0000 (13:23 +0200)
HLS spec 6.3.3 is saying that
"the client SHOULD NOT choose a segment which starts less than
three target durations from the end of the Playlist file."

To ensure above statement, the third fragment from the end of playlist
should be excluded from seekable range and also from available starting fragment.
(i.e., the fourth fragment from end of playlist is the starting fragment).

https://bugzilla.gnome.org/show_bug.cgi?id=777682

ext/hls/gsthlsdemux.c
ext/hls/m3u8.c

index 44be04e..f0647fd 100644 (file)
@@ -1454,7 +1454,7 @@ retry:
         "sequence:%" G_GINT64_FORMAT " , first_sequence:%" G_GINT64_FORMAT
         " , last_sequence:%" G_GINT64_FORMAT, m3u8->sequence,
         first_sequence, last_sequence);
-    if (m3u8->sequence >= last_sequence - 3) {
+    if (m3u8->sequence > last_sequence - 3) {
       //demux->need_segment = TRUE;
       /* Make sure we never go below the minimum sequence number */
       m3u8->sequence = MAX (first_sequence, last_sequence - 3);
index 76cf50f..eca5291 100644 (file)
@@ -758,11 +758,8 @@ gst_m3u8_update (GstM3U8 * self, gchar * data)
       file = g_list_last (self->files);
 
       /* for live streams, start GST_M3U8_LIVE_MIN_FRAGMENT_DISTANCE from
-       * the end of the playlist. See section 6.3.3 of HLS draft. Note
-       * the -1, because GST_M3U8_LIVE_MIN_FRAGMENT_DISTANCE = 1 means
-       * start 1 target-duration from the end */
-      for (i = 0; i < GST_M3U8_LIVE_MIN_FRAGMENT_DISTANCE - 1 && file->prev;
-          ++i)
+       * the end of the playlist. See section 6.3.3 of HLS draft */
+      for (i = 0; i < GST_M3U8_LIVE_MIN_FRAGMENT_DISTANCE && file->prev; ++i)
         file = file->prev;
     } else {
       file = g_list_first (self->files);
@@ -1140,7 +1137,7 @@ gst_m3u8_get_seek_range (GstM3U8 * m3u8, gint64 * start, gint64 * stop)
   }
   count = g_list_length (m3u8->files);
 
-  for (walk = m3u8->files; walk && count >= min_distance; walk = walk->next) {
+  for (walk = m3u8->files; walk && count > min_distance; walk = walk->next) {
     file = walk->data;
     --count;
     duration += file->duration;