[vlc-devel] [PATCH] Find the optimal stream given the measured bandwidth

Brian.Kurle at arrisi.com Brian.Kurle at arrisi.com
Wed Dec 1 22:09:25 CET 2010


From: Brian Kurle <Brian.Kurle at arrisi.com>

Takes into account that the variant playlist is not required to have the
streams listed in ascending or descending order.
---
 modules/stream_filter/httplive.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index e5829bc..52863a5 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -823,6 +823,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 optimal_bw = 0;
 
     int count = vlc_array_count(p_sys->hls_stream);
     for (int n = 0; n < count; n++)
@@ -834,10 +835,14 @@ 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)
+            /* Check to see that the bandwidth candidate is less than the
+             * measured bandwidth, but greater than the last candidate
+             */
+            if (bw <= hls->bandwidth && hls->bandwidth >= optimal_bw)
             {
                 msg_Dbg(s, "candidate %d bandwidth (bits/s) %"PRIu64" >= %"PRIu64,
                          n, bw, hls->bandwidth); /* bits / s */
+                optimal_bw =    /* got a match, save the current optimal candidate */
                 *bandwidth = hls->bandwidth;
                 candidate = n; /* possible candidate */
             }
-- 
1.7.1




More information about the vlc-devel mailing list