[vlc-commits] commit: stream_filter/httplive.c: Use first HLS stream in . m3u8 as starting point. (Jean-Paul Saman )

git at videolan.org git at videolan.org
Tue Dec 14 13:23:05 CET 2010


vlc | branch: master | Jean-Paul Saman <jean-paul.saman at m2x.nl> | Tue Dec 14 12:05:00 2010 +0100| [c44a8218833415bb456a9c708165c482eaeb3971] | committer: Jean-Paul Saman 

stream_filter/httplive.c: Use first HLS stream in .m3u8 as starting point.

Determine which HLS stream can be served best by this server. If found, then download
the first two segments and start playback.

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

 modules/stream_filter/httplive.c |   42 ++++++++++++++++---------------------
 1 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index 89ed7d0..9ceb8e1 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -965,35 +965,29 @@ static void* hls_Thread(vlc_object_t *p_this)
 static int Prefetch(stream_t *s, int *current)
 {
     stream_sys_t *p_sys = s->p_sys;
-    int i_segment = p_sys->segment;
+    int stream;
 
     /* Try to pick best matching stream */
-    int count = vlc_array_count(p_sys->hls_stream);
-    for (int stream = 0; stream < count; stream++)
-    {
-        hls_stream_t *hls = hls_Get(p_sys->hls_stream, stream);
-        if (hls == NULL)
-            return VLC_EGENERIC;
-
-        segment_t *segment = segment_GetSegment(hls,i_segment);
-        if (segment == NULL )
-            return VLC_EGENERIC;
+again:
+    stream = *current;
 
-        if (Download(s, hls, segment, &stream) != VLC_SUCCESS)
-            return VLC_EGENERIC;
+    hls_stream_t *hls = hls_Get(p_sys->hls_stream, *current);
+    if (hls == NULL)
+        return VLC_EGENERIC;
 
-        i_segment++;
+    segment_t *segment = segment_GetSegment(hls,  p_sys->segment);
+    if (segment == NULL )
+        return VLC_EGENERIC;
 
-        /* */
-        *current = stream;
-    }
+    if (Download(s, hls, segment, current) != VLC_SUCCESS)
+        return VLC_EGENERIC;
 
-    /* Download first 3 segments of this HLS stream */
-    hls_stream_t *hls = hls_Get(p_sys->hls_stream, *current);
-    if (hls == NULL)
-        return VLC_EGENERIC; /* FIXME: */
+    /* Found better bandwidth match, try again */
+    if (*current != stream)
+        goto again;
 
-    for (int i = 0; i < 3; i++)
+    /* Download first 2 segments of this HLS stream */
+    for (int i = 0; i < 2; i++)
     {
         segment_t *segment = segment_GetSegment(hls, p_sys->segment);
         if (segment == NULL )
@@ -1210,8 +1204,8 @@ static int Open(vlc_object_t *p_this)
         goto fail;
     }
 
-    /* */
-    int current = p_sys->current = hls_LowestBandwidthStream(p_sys->hls_stream);
+    /* Choose first HLS stream to start with */
+    int current = p_sys->current = 0;
     p_sys->segment = 0;
 
     if (Prefetch(s, &current) != VLC_SUCCESS)



More information about the vlc-commits mailing list