Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnssi Hannula <anssi.hannula@iki.fi>2017-11-19 21:11:49 +0300
committerAnssi Hannula <anssi.hannula@iki.fi>2017-11-28 13:47:42 +0300
commit143552095dae9698f3779e93dd08548f46dc5686 (patch)
tree5a49581c8aa9f9c3eda294bdab9374d8aeef2719 /libavformat/hls.c
parent1dff9adcb934175fe1beb14ee139ad0636daa29d (diff)
avformat/hls: Obey AVProgram discard flags
Currently HLS demuxer only obeys AVStream discard flags but not AVProgram (which bandwidth variants appear as) discard flags. Fix that.
Diffstat (limited to 'libavformat/hls.c')
-rw-r--r--libavformat/hls.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/libavformat/hls.c b/libavformat/hls.c
index 4f8f6b0a80..ab6ff187a6 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1260,7 +1260,10 @@ static int64_t default_reload_interval(struct playlist *pls)
static int playlist_needed(struct playlist *pls)
{
- int i;
+ AVFormatContext *s = pls->parent;
+ int i, j;
+ int stream_needed = 0;
+ int first_st;
/* If there is no context or streams yet, the playlist is needed */
if (!pls->ctx || !pls->n_main_streams)
@@ -1269,12 +1272,35 @@ static int playlist_needed(struct playlist *pls)
/* check if any of the streams in the playlist are needed */
for (i = 0; i < pls->n_main_streams; i++) {
if (pls->main_streams[i]->discard < AVDISCARD_ALL) {
- /* some stream needed => playlist needed */
- return 1;
+ stream_needed = 1;
+ break;
+ }
+ }
+
+ /* If all streams in the playlist were discarded, the playlist is not
+ * needed (regardless of whether whole programs are discarded or not). */
+ if (!stream_needed)
+ return 0;
+
+ /* Otherwise, check if all the programs (variants) this playlist is in are
+ * discarded. Since all streams in the playlist are part of the same programs
+ * we can just check the programs of the first stream. */
+
+ first_st = pls->main_streams[0]->index;
+
+ for (i = 0; i < s->nb_programs; i++) {
+ AVProgram *program = s->programs[i];
+ if (program->discard < AVDISCARD_ALL) {
+ for (j = 0; j < program->nb_stream_indexes; j++) {
+ if (program->stream_index[j] == first_st) {
+ /* playlist is in an undiscarded program */
+ return 1;
+ }
+ }
}
}
- /* No streams were needed */
+ /* some streams were not discarded but all the programs were */
return 0;
}