From 5016a1e4a6118e1b91b1ee1ca5221ae09cf8753e Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 4 Jan 2020 19:47:36 +0100 Subject: demux: add per-demuxer sub-options Until now, they were all just added to options.c (e.g. demux_mkv_conf). This adds a mechanism which can be used to add future options in a (very) slightly more elegant way. --- demux/demux.c | 11 +++++++++++ demux/demux.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/demux/demux.c b/demux/demux.c index c96ff51ca9..a5a287e8bd 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -105,6 +105,8 @@ struct demux_opts { #define MAX_BYTES MPMIN(INT64_MAX, SIZE_MAX / 2) +static bool get_demux_sub_opts(int index, const struct m_sub_options **sub); + const struct m_sub_options demux_conf = { .opts = (const struct m_option[]){ OPT_CHOICE("cache", enable_cache, 0, @@ -151,6 +153,7 @@ const struct m_sub_options demux_conf = { }, .meta_cp = "utf-8", }, + .get_sub_options = get_demux_sub_opts, }; struct demux_internal { @@ -4498,3 +4501,11 @@ static void demux_convert_tags_charset(struct demuxer *demuxer) talloc_free(data); } + +static bool get_demux_sub_opts(int index, const struct m_sub_options **sub) +{ + if (!demuxer_list[index]) + return false; + *sub = demuxer_list[index]->options; + return true; +} diff --git a/demux/demux.h b/demux/demux.h index 4c15e074c2..c94f690da0 100644 --- a/demux/demux.h +++ b/demux/demux.h @@ -98,6 +98,9 @@ typedef struct demuxer_desc { const char *name; // Demuxer name, used with -demuxer switch const char *desc; // Displayed to user + // If non-NULL, these are added to the global option list. + const struct m_sub_options *options; + // Return 0 on success, otherwise -1 int (*open)(struct demuxer *demuxer, enum demux_check check); // The following functions are all optional -- cgit v1.2.3