[vlc-devel] [PATCH 24/48] hls: Reuse adaptive bitrate

Hugo Beauzée-Luyssen beauze.h at gmail.com
Mon Jan 9 16:16:33 CET 2012


From: Luc Saillard <luc.saillard at sfr.com>

---
 modules/stream_filter/httplive.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index 1dc75a0..40a124a 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -148,6 +148,7 @@ struct stream_sys_t
     bool        b_aesmsg;   /* only print one time that the media is encrypted */
     bool        b_quit;
     bool        b_reset;    /* Set to true when a stream should be reset */
+    bool        b_dont_change_bitrate;
 };
 
 /****************************************************************************
@@ -1549,7 +1550,8 @@ static int hls_DownloadSegmentData(stream_t *s, hls_stream_t *hls, segment_t *se
     /* Do not change bandwidth */
     return VLC_SUCCESS;
 
-    return VLC_SUCCESS;
+    if (p_sys->b_dont_change_bitrate)
+        return VLC_SUCCESS;
 
     /* check for division by zero */
     double ms = (double)duration / 1000.0; /* ms */
@@ -1736,16 +1738,13 @@ again:
     if (hls_DownloadSegmentData(s, hls, segment, current) != VLC_SUCCESS)
         return VLC_EGENERIC;
 
-    /* Fast start, don't prefetch others segments */
-    if (!p_sys->b_live)
-      return VLC_SUCCESS;
-
     /* Found better bandwidth match, try again */
     if (*current != stream)
         goto again;
 
     /* Download first 2 segments of this HLS stream */
     stream = *current;
+    return VLC_SUCCESS;
     for (int i = 0; i < 2; i++)
     {
         segment_t *segment = segment_GetSegment(hls, p_sys->download.segment);
@@ -1955,6 +1954,7 @@ static int OpenWithPlaylist(stream_t *s, const char *m3u8_playlist)
     p_sys->b_aesmsg = false;
     p_sys->b_quit = false;
     p_sys->b_reset = false;
+    p_sys->b_dont_change_bitrate = false;
 
     p_sys->hls_stream = vlc_array_new();
     if (p_sys->hls_stream == NULL)
@@ -1988,7 +1988,7 @@ static int OpenWithPlaylist(stream_t *s, const char *m3u8_playlist)
 
     /* Choose first HLS stream to start with */
     hls_ChooseDefaultStream(p_sys);
-    int current = p_sys->playback.stream = p_sys->b_live ? 3 : 0;
+    int current = p_sys->playback.stream = 0;
     p_sys->playback.segment = p_sys->download.segment = ChooseSegment(s, current);
     if (p_sys->b_meta && !hls_Get(p_sys->hls_stream, current))
         goto fail;
@@ -2004,14 +2004,13 @@ static int OpenWithPlaylist(stream_t *s, const char *m3u8_playlist)
         msg_Warn(s, "less data than 3 times 'target duration' available for live playback, playback may stall");
     }
 
-#if 0
     if (Prefetch(s, &current) != VLC_SUCCESS)
     {
         msg_Err(s, "fetching first segment failed.");
         goto fail;
     }
-#endif
 
+    p_sys->b_dont_change_bitrate = true;
 
     p_sys->download.stream = current;
     p_sys->playback.stream = current;
-- 
1.7.8.3




More information about the vlc-devel mailing list