[vlc-devel] [PATCH 08/48] hls: Choose best stream

Jean-Paul Saman jpsaman at videolan.org
Tue Jan 10 13:57:41 CET 2012


On Mon, Jan 9, 2012 at 4:16 PM, Hugo Beauzée-Luyssen <beauze.h at gmail.com> wrote:
> From: Luc Saillard <luc.saillard at sfr.com>
>
> ---
>  modules/stream_filter/httplive.c |   28 ++++++++++++++++++++++++++--
>  1 files changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
> index 35d5da2..ff386ce 100644
> --- a/modules/stream_filter/httplive.c
> +++ b/modules/stream_filter/httplive.c
> @@ -1373,7 +1373,7 @@ static int hls_ReloadPlaylist(stream_t *s)
>         return VLC_ENOMEM;
>
>     int count = vlc_array_count(p_sys->hls_stream);
> -    for (int n = 0; n < count; n++)
> +    for (int n = p_sys->playback.stream; n < count; n++)

This is an error I think. Remove it from this patch.

>     {
>         int err;
>         hls_stream_t *hls = vlc_array_item_at_index(p_sys->hls_stream, n);
> @@ -1424,6 +1424,26 @@ fail:
>     return VLC_EGENERIC;
>  }
>
> +static void hls_ChooseDefaultStream(stream_sys_t *p_sys)
> +{
> +        uint64_t current_bw = 0;
> +       unsigned int n;
> +       unsigned int stream = 0;
> +
> +        int count = vlc_array_count(p_sys->hls_stream);
> +        for (n = 0; n < count; n++)
> +        {
> +                hls_stream_t *hls = hls_Get(p_sys->hls_stream, n);
> +                if (hls && hls->bandwidth > current_bw) {
> +                       stream = n;
> +                        current_bw = hls->bandwidth;
> +                }
> +        }
> +       p_sys->playback.stream = stream;
> +       p_sys->download.stream = stream;
> +}
> +
> +
>  /****************************************************************************
>  * hls_Thread
>  ****************************************************************************/
> @@ -1506,6 +1526,9 @@ static int hls_DownloadSegmentData(stream_t *s, hls_stream_t *hls, segment_t *se
>     msg_Info(s, "downloaded segment %d from stream %d",
>                 segment->sequence, *cur_stream);
>
> +    /* Do not change bandwidth */
> +    return VLC_SUCCESS;
> +
>     /* check for division by zero */
>     double ms = (double)duration / 1000.0; /* ms */
>     if (ms <= 0.0)
> @@ -1924,7 +1947,8 @@ static int Open(vlc_object_t *p_this)
>     free(buffer);
>
>     /* Choose first HLS stream to start with */
> -    int current = p_sys->playback.stream = 0;
> +    hls_ChooseDefaultStream(p_sys);
> +    int current = p_sys->playback.stream;
>     p_sys->playback.segment = p_sys->download.segment = ChooseSegment(s, current);
>
>     /* manage encryption key if needed */
> --
> 1.7.8.3
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> http://mailman.videolan.org/listinfo/vlc-devel

Function ChooseDefaultStream() looks OK. However I am not sure where
the bandwidth measurement is based upon at this particular time in
execution.

Kind regards,

Jean-Paul Saman



More information about the vlc-devel mailing list