diff mbox series

[FFmpeg-devel,1/1] avformat hls check discard state of streams always

Message ID 20200501152436.50352-2-hello.vectronic@gmail.com
State New
Headers show
Series avformat hls check discard state of streams always
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

vectronic May 1, 2020, 3:24 p.m. UTC
The discard needs to be checked on a stream even after the first packet is read. The first packet has already been read as part of calling avformat_find_stream_info. This means that setting AVStream->discard on a stream after having determined the stream info for the HLS package had no effect and unwanted packets were returned by subsequent calls to hls_read_packet.

Signed-off-by: vectronic <hello.vectronic@gmail.com>
---
 libavformat/hls.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/hls.c b/libavformat/hls.c
index fc45719d1c..0740e9c546 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -2014,7 +2014,7 @@  fail:
     return ret;
 }
 
-static int recheck_discard_flags(AVFormatContext *s, int first)
+static int recheck_discard_flags(AVFormatContext *s)
 {
     HLSContext *c = s->priv_data;
     int i, changed = 0;
@@ -2041,7 +2041,7 @@  static int recheck_discard_flags(AVFormatContext *s, int first)
                 pls->seek_stream_index = -1;
             }
             av_log(s, AV_LOG_INFO, "Now receiving playlist %d, segment %d\n", i, pls->cur_seq_no);
-        } else if (first && !cur_needed && pls->needed) {
+        } else if (!cur_needed && pls->needed) {
             ff_format_io_close(pls->parent, &pls->input);
             pls->input_read_done = 0;
             ff_format_io_close(pls->parent, &pls->input_next);
@@ -2101,7 +2101,7 @@  static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
     HLSContext *c = s->priv_data;
     int ret, i, minplaylist = -1;
 
-    recheck_discard_flags(s, c->first_packet);
+    recheck_discard_flags(s);
     c->first_packet = 0;
 
     for (i = 0; i < c->n_playlists; i++) {