Commit 4e8e992b authored by Jean-Paul Saman's avatar 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.
parent fa6e476e
...@@ -825,6 +825,7 @@ static int BandwidthAdaptation(stream_t *s, int progid, uint64_t *bandwidth) ...@@ -825,6 +825,7 @@ static int BandwidthAdaptation(stream_t *s, int progid, uint64_t *bandwidth)
stream_sys_t *p_sys = s->p_sys; stream_sys_t *p_sys = s->p_sys;
int candidate = -1; int candidate = -1;
uint64_t bw = *bandwidth; uint64_t bw = *bandwidth;
uint64_t bw_candidate = 0;
int count = vlc_array_count(p_sys->hls_stream); int count = vlc_array_count(p_sys->hls_stream);
for (int n = 0; n < count; n++) for (int n = 0; n < count; n++)
...@@ -836,15 +837,16 @@ static int BandwidthAdaptation(stream_t *s, int progid, uint64_t *bandwidth) ...@@ -836,15 +837,16 @@ static int BandwidthAdaptation(stream_t *s, int progid, uint64_t *bandwidth)
/* only consider streams with the same PROGRAM-ID */ /* only consider streams with the same PROGRAM-ID */
if (hls->id == progid) 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, msg_Dbg(s, "candidate %d bandwidth (bits/s) %"PRIu64" >= %"PRIu64,
n, bw, hls->bandwidth); /* bits / s */ n, bw, hls->bandwidth); /* bits / s */
*bandwidth = hls->bandwidth; bw_candidate = hls->bandwidth;
candidate = n; /* possible candidate */ candidate = n; /* possible candidate */
} }
} }
} }
*bandwidth = bw_candidate;
return candidate; return candidate;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment