[vlc-commits] httplive: cache around 10 sec worth of segments instead of just 2

Ilkka Ollakka git at videolan.org
Sun Aug 18 21:43:45 CEST 2013


vlc/vlc-2.1 | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Mon Aug  5 19:30:32 2013 +0300| [dde798a991c24c54d45160a01130daf12a6cc935] | committer: Jean-Baptiste Kempf

httplive: cache around 10 sec worth of segments instead of just 2

(cherry picked from commit 37c8d257a4d8f1a7987b742e80e469eaa39d02ac)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.1.git/?a=commit;h=dde798a991c24c54d45160a01130daf12a6cc935
---

 modules/stream_filter/httplive.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index 08aa9cf..62f1a2a 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -1727,8 +1727,9 @@ static int Prefetch(stream_t *s, int *current)
     else if (vlc_array_count(hls->segments) == 1 && p_sys->b_live)
         msg_Warn(s, "Only 1 segment available to prefetch in live stream; may stall");
 
-    /* Download first 2 segments of this HLS stream if they exist */
-    for (int i = 0; i < __MIN(vlc_array_count(hls->segments), 2); i++)
+    /* Download ~10s worth of segments of this HLS stream if they exist */
+    unsigned segment_amount = (0.5f + 10/hls->duration);
+    for (int i = 0; i < __MIN(vlc_array_count(hls->segments), segment_amount); i++)
     {
         segment_t *segment = segment_GetSegment(hls, p_sys->download.segment);
         if (segment == NULL )



More information about the vlc-commits mailing list