[vlc-devel] [PATCH] VLC unable to play HLS live stream

Avishay Spitzer savishay at gmail.com
Thu Aug 15 16:13:29 CEST 2013


Ilkka,

Are you suggesting adding a new condition variable on which read will wait
until download thread signals?

Regards,
Avishay



On Thu, Aug 15, 2013 at 8:05 AM, Ilkka Ollakka <ileoo at videolan.org> wrote:

>
> Hi,
>
> I think it would be better to implement this with signal wait with
> timeout instead of polling. So download thread would signal that new
> stuff is ready.
>
> On Thu, Aug 15, 2013 at 06:52:09AM -0400, Avishay Spitzer wrote:
> > From 768e199c6ac6d539f1a00606a26a905a5f1b1886 Mon Sep 17 00:00:00 2001
> > From: Avishay Spitzer <savishay at gmail.com>
> > Date: Thu, 15 Aug 2013 06:41:35 -0400
> > Subject: [PATCH 2/2] Added a retry mechanism with backoff to the read
> >  function of HLS module to handle situations where
> >  stream packets may delay due to slow connections or
> >  short playlists. In case hls_Read returns 0, the read
> >  function will wait until new data arrives.
>
> > ---
> >  modules/stream_filter/httplive.c |   48
> +++++++++++++++++++++++++++++++++-----
> >  1 file changed, 42 insertions(+), 6 deletions(-)
>
> > diff --git a/modules/stream_filter/httplive.c
> b/modules/stream_filter/httplive.c
> > index ed708bf..62ab17b 100644
> > --- a/modules/stream_filter/httplive.c
> > +++ b/modules/stream_filter/httplive.c
> > @@ -2280,16 +2280,52 @@ static int Read(stream_t *s, void *buffer,
> unsigned int i_read)
> >  {
> >      stream_sys_t *p_sys = s->p_sys;
> >      ssize_t length = 0;
> > +    uint32_t retries_counter = 0, aggregate_delay = 0;
>
> >      assert(p_sys->hls_stream);
>
> > -    if (p_sys->b_error)
> > -        return 0;
> > +    while (length == 0)
> > +    {
> > +     // In case an error occurred or the stream was closed return 0
> > +        if (p_sys->b_error || !vlc_object_alive(s))
> > +            return 0;
>
> > -    /* NOTE: buffer might be NULL if caller wants to skip data */
> > -    length = hls_Read(s, (uint8_t*) buffer, i_read);
> > -    if (length < 0)
> > -        return 0;
> > +             /* NOTE: buffer might be NULL if caller wants to skip data
> */
> > +             length = hls_Read(s, (uint8_t*) buffer, i_read);
> > +
> > +             // An error has occurred in hls_Read
> > +             if (length < 0)
> > +                     return 0;
> > +
> > +             // No data is available yet so we need to wait until new
> data will arrive.
> > +             // We use a retry mechanism with increasing backoff (up to
> 100ms per single sleep)
> > +             if (length == 0)
> > +             {
> > +             uint32_t delay = 0;
> > +
> > +                     retries_counter++;
> > +
> > +                     if (retries_counter < 10)
> > +                             delay = 10; // ms
> > +                     else if (retries_counter < 25)
> > +                             delay = 25; // ms
> > +                     else if (retries_counter < 100)
> > +                             delay = 50; // ms
> > +                     else
> > +                             delay = 100; // ms
> > +
> > +                     aggregate_delay += delay;
> > +
> > +                     msleep(delay * 1000);
> > +             }
> > +    }
> > +
> > +    if (retries_counter > 0)
> > +    {
> > +             msg_Info(s, "got data after %u retries (delay of [%u]ms)",
> > +                             retries_counter,
> > +                             aggregate_delay);
> > +    }
>
> >      p_sys->playback.offset += length;
> >      return length;
> --
> Ilkka Ollakka
> Is a computer language with goto's totally Wirth-less?
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20130815/129fa9bc/attachment.html>


More information about the vlc-devel mailing list