From c39e332e50d4589cf92662ba3ad1c9640f7c82fe Mon Sep 17 00:00:00 2001 From: rcombs Date: Tue, 21 Feb 2023 15:23:29 -0600 Subject: [PATCH] demux_lavf: report program_id This can be useful in stream selection. --- demux/demux.c | 1 + demux/demux_lavf.c | 3 +++ demux/stheader.h | 1 + 3 files changed, 5 insertions(+) diff --git a/demux/demux.c b/demux/demux.c index cac2f74ec8..45184e60f6 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -978,6 +978,7 @@ struct sh_stream *demux_alloc_sh_stream(enum stream_type type) .index = -1, .ff_index = -1, // may be overwritten by demuxer .demuxer_id = -1, // ... same + .program_id = -1, // ... same .codec = talloc_zero(sh, struct mp_codec_params), .tags = talloc_zero(sh, struct mp_tags), }; diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index efe7f45ae9..ec5716c634 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -832,6 +832,9 @@ static void handle_new_stream(demuxer_t *demuxer, int i) if (lang && lang->value && strcmp(lang->value, "und") != 0) sh->lang = talloc_strdup(sh, lang->value); sh->hls_bitrate = dict_get_decimal(st->metadata, "variant_bitrate", 0); + AVProgram *prog = av_find_program_from_stream(avfc, NULL, i); + if (prog) + sh->program_id = prog->id; sh->missing_timestamps = !!(priv->avif_flags & AVFMT_NOTIMESTAMPS); mp_tags_copy_from_av_dictionary(sh->tags, st->metadata); demux_add_sh_stream(demuxer, sh); diff --git a/demux/stheader.h b/demux/stheader.h index 8d2129e05b..447bc0aa1f 100644 --- a/demux/stheader.h +++ b/demux/stheader.h @@ -51,6 +51,7 @@ struct sh_stream { bool image; // video stream is an image bool still_image; // video stream contains still images int hls_bitrate; + int program_id; struct mp_tags *tags;