vlc | branch: master | Jean-Paul Saman <[email protected]> | Wed Dec  1 
14:01:47 2010 +0100| [4e8e992bf0634077156a7a743cd6f8c2844a7b7b] | committer: 
Jean-Paul Saman 

stream_filter/httplive.c: HLS streams are in no particular order in the .m3u8 
file

Take into account that HLS streams with bandwidth specified are not in ascending
(or descending) order. Choose really the best wrt to measurements.

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

 modules/stream_filter/httplive.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index d2b4ad9..e984dd1 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -825,6 +825,7 @@ static int BandwidthAdaptation(stream_t *s, int progid, 
uint64_t *bandwidth)
     stream_sys_t *p_sys = s->p_sys;
     int candidate = -1;
     uint64_t bw = *bandwidth;
+    uint64_t bw_candidate = 0;
 
     int count = vlc_array_count(p_sys->hls_stream);
     for (int n = 0; n < count; n++)
@@ -836,15 +837,16 @@ static int BandwidthAdaptation(stream_t *s, int progid, 
uint64_t *bandwidth)
         /* only consider streams with the same PROGRAM-ID */
         if (hls->id == progid)
         {
-            if (bw >= hls->bandwidth)
+            if ((bw >= hls->bandwidth) && (bw_candidate < hls->bandwidth))
             {
                 msg_Dbg(s, "candidate %d bandwidth (bits/s) %"PRIu64" >= 
%"PRIu64,
                          n, bw, hls->bandwidth); /* bits / s */
-                *bandwidth = hls->bandwidth;
+                bw_candidate = hls->bandwidth;
                 candidate = n; /* possible candidate */
             }
         }
     }
+    *bandwidth = bw_candidate;
     return candidate;
 }
 

_______________________________________________
vlc-commits mailing list
[email protected]
http://mailman.videolan.org/listinfo/vlc-commits

Reply via email to