Commit f426cd4b authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen Committed by Jean-Baptiste Kempf

hls: Ensure streams are sorted by bandwidth.

THe standard doesn't guaranty anything, but the code assumes it.
(cherry picked from commit e2942aee)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent e8ac4ada
...@@ -953,6 +953,13 @@ static int parse_Discontinuity(stream_t *s, hls_stream_t *hls, char *p_read) ...@@ -953,6 +953,13 @@ static int parse_Discontinuity(stream_t *s, hls_stream_t *hls, char *p_read)
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static int hls_CompareStreams( const void* a, const void* b )
{
hls_stream_t* stream_a = *(hls_stream_t**)a;
hls_stream_t* stream_b = *(hls_stream_t**)b;
return stream_a->bandwidth > stream_b->bandwidth;
}
/* The http://tools.ietf.org/html/draft-pantos-http-live-streaming-04#page-8 /* The http://tools.ietf.org/html/draft-pantos-http-live-streaming-04#page-8
* document defines the following new tags: EXT-X-TARGETDURATION, * document defines the following new tags: EXT-X-TARGETDURATION,
* EXT-X-MEDIA-SEQUENCE, EXT-X-KEY, EXT-X-PROGRAM-DATE-TIME, EXT-X- * EXT-X-MEDIA-SEQUENCE, EXT-X-KEY, EXT-X-PROGRAM-DATE-TIME, EXT-X-
...@@ -1977,6 +1984,10 @@ static int Open(vlc_object_t *p_this) ...@@ -1977,6 +1984,10 @@ static int Open(vlc_object_t *p_this)
goto fail; goto fail;
} }
free(buffer); free(buffer);
/* HLS standard doesn't provide any guaranty about streams
being sorted by bandwidth, so we sort them */
qsort( p_sys->hls_stream->pp_elems, p_sys->hls_stream->i_count,
sizeof( hls_stream_t* ), &hls_CompareStreams );
/* Choose first HLS stream to start with */ /* Choose first HLS stream to start with */
int current = p_sys->playback.stream = 0; int current = p_sys->playback.stream = 0;
......
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