diff mbox

[FFmpeg-devel] avformat/hls allow playback when some variant streams are unavailable

Message ID CACVg+Hvp3e1rRtpVL+oBfybm_wLox-B8qP=M0Xa+YwT=Baq88Q@mail.gmail.com
State New
Headers show

Commit Message

Tim Hunt April 13, 2017, 4:33 p.m. UTC
Not sure if it was email formatting or editor setting. Is this patch ok?

On Thu, Apr 13, 2017 at 5:24 PM, Michael Niedermayer <michael@niedermayer.cc
> wrote:

> On Thu, Apr 13, 2017 at 04:14:46PM +0100, Tim Hunt wrote:
> > My last patch was slightly convoluted and really dumb.
> >
> > I suspect it impacts on a couple of checks for
> > variants[0]->playlists[0]->finished and the problem will be when a non
> live
> > stream has two variants using EXT-X-ENDLIST and the first stream in the
> > playlist is down? Not sure how to approach this, will look into it more
> > later.
> >
> > ---
> >  libavformat/hls.c | 17 +++++++++++------
> >  1 file changed, 11 insertions(+), 6 deletions(-)
> >
> > diff --git a/libavformat/hls.c b/libavformat/hls.c
> > index bac53a4..26b8751 100644
> > --- a/libavformat/hls.c
> > +++ b/libavformat/hls.c
> > @@ -1611,7 +1611,7 @@ static int hls_read_header(AVFormatContext *s)
> >      void *u = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb;
> >      HLSContext *c = s->priv_data;
> >      int ret = 0, i;
> > -    int highest_cur_seq_no = 0;
> > +    int highest_cur_seq_no = 0, found_segments;
> >
> >      c->ctx                = s;
> >      c->interrupt_callback = &s->interrupt_callback;
> > @@ -1652,14 +1652,20 @@ static int hls_read_header(AVFormatContext *s)
> >      /* If the playlist only contained playlists (Master Playlist),
> >       * parse each individual playlist. */
> >      if (c->n_playlists > 1 || c->playlists[0]->n_segments == 0) {
> > +        found_segments = -1;
> > +
>
> >          for (i = 0; i < c->n_playlists; i++) {
> >              struct playlist *pls = c->playlists[i];
> > -            if ((ret = parse_playlist(c, pls->url, pls, NULL)) < 0)
> > -                goto fail;
> > +            if (parse_playlist(c, pls->url, pls, NULL) == 0 &&
> > pls->n_segments > 0)
> > +                found_segments = 1;
>
> this patch is corrupted by newlines
>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Old school: Use the lowest level language in which you can solve the
> problem
>             conveniently.
> New school: Use the highest level language in which the latest
> supercomputer
>             can solve the problem without the user falling asleep waiting.
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
diff mbox

Patch

From cc20762ec30e3021b4593fb89c681f5000ddb1fe Mon Sep 17 00:00:00 2001
From: Tim Hunt <tnhunt@gmail.com>
Date: Thu, 13 Apr 2017 15:35:07 +0100
Subject: [PATCH] avformat/hls allow playback of variant streams when some
 missing

ticket #2617
---
 libavformat/hls.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index bac53a4..26b8751 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1611,7 +1611,7 @@  static int hls_read_header(AVFormatContext *s)
     void *u = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb;
     HLSContext *c = s->priv_data;
     int ret = 0, i;
-    int highest_cur_seq_no = 0;
+    int highest_cur_seq_no = 0, found_segments;
 
     c->ctx                = s;
     c->interrupt_callback = &s->interrupt_callback;
@@ -1652,14 +1652,20 @@  static int hls_read_header(AVFormatContext *s)
     /* If the playlist only contained playlists (Master Playlist),
      * parse each individual playlist. */
     if (c->n_playlists > 1 || c->playlists[0]->n_segments == 0) {
+        found_segments = -1;
+
         for (i = 0; i < c->n_playlists; i++) {
             struct playlist *pls = c->playlists[i];
-            if ((ret = parse_playlist(c, pls->url, pls, NULL)) < 0)
-                goto fail;
+            if (parse_playlist(c, pls->url, pls, NULL) == 0 && pls->n_segments > 0)
+                found_segments = 1;
         }
-    }
 
-    if (c->variants[0]->playlists[0]->n_segments == 0) {
+        if(found_segments == -1) {
+            av_log(NULL, AV_LOG_WARNING, "Empty playlist\n");
+            ret = AVERROR_EOF;
+            goto fail;
+        }
+    } else if (c->variants[0]->playlists[0]->n_segments == 0) {
         av_log(NULL, AV_LOG_WARNING, "Empty playlist\n");
         ret = AVERROR_EOF;
         goto fail;
@@ -1805,7 +1811,6 @@  static int hls_read_header(AVFormatContext *s)
     }
 
     update_noheader_flag(s);
-
     return 0;
 fail:
     hls_close(s);
-- 
2.7.4