[vlc-devel] [PATCH] VLC unable to play HLS live stream
Avishay Spitzer
savishay at gmail.com
Mon Aug 19 09:11:41 CEST 2013
Ilkka,
I implemented with a condition variable as you asked. Tested on Ubuntu and
Windows 7 and it works ok.
Please let me know if you have any comments.
Regards,
Avishay
On Thu, Aug 15, 2013 at 12:11 PM, Ilkka Ollakka <ileoo at videolan.org> wrote:
> On Thu, Aug 15, 2013 at 10:13:29AM -0400, Avishay Spitzer wrote:
> > Ilkka,
>
> Hi,
>
> > Are you suggesting adding a new condition variable on which read will
> wait
> > until download thread signals?
>
> Yes, I think it would be better aproach as it avoids polling. Ofcourse
> it needs timeout value so it won't get stuck.
>
>
> > > 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
>
>
>
> --
> Ilkka Ollakka
> <gorgo> what do you get when someone cracks your debian machine ?
> <gorgo> mashed potato...
>
> _______________________________________________
> 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/20130819/e7d38015/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-In-case-of-live-streams-the-reload-thread-did-not-wa.patch
Type: application/octet-stream
Size: 2948 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20130819/e7d38015/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Bug-fix-HLS-module-does-not-block-until-data-is-avai.patch
Type: application/octet-stream
Size: 4956 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20130819/e7d38015/attachment-0001.obj>
More information about the vlc-devel
mailing list