summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/input.rst25
-rw-r--r--options/m_option.c2
-rw-r--r--options/m_property.h2
-rw-r--r--player/command.c34
4 files changed, 60 insertions, 3 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index db544d3ddd..65e734187a 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -1446,7 +1446,15 @@ Property list
Additional per-option information.
This has a number of sub-properties. Replace ``<name>`` with the name of
- a top-level option.
+ a top-level option. No guarantee of stability is given to any of these
+ sub-properties - they may change radically in the feature.
+
+ ``option-info/<name>/name``
+ Returns the name of the option.
+
+ ``option-info/<name>/type``
+ Return the name of the option type, like ``String`` or ``Integer``.
+ For many complex types, this isn't very accurate.
``option-info/<name>/set-from-commandline``
@@ -1454,6 +1462,21 @@ Property list
``no`` otherwise. What this is set to if the option is e.g. changed
at runtime is left undefined (meaning it could change in the future).
+ ``option-info/<name>/default-value``
+ The default value of the option. May not always be available.
+
+ ``option-info/<name>/min``, ``option-info/<name>/max``
+ Integer minimum and maximum values allowed for the option. Only
+ available if the options are numeric, and the minimum/maximum has been
+ set internally. It's also possible that only one of these is set.
+
+ ``option-info/<name>/choices``
+ If the option is a choice option, the possible choices. Choices that
+ are integers may or may not be included (they can be implied by ``min``
+ and ``max``). Note that options which behave like choice options, but
+ are not actual choice options internally, may not have this info
+ available.
+
``property-list``
Return the list of top-level properties.
diff --git a/options/m_option.c b/options/m_option.c
index 37186d01cc..97ba467ed4 100644
--- a/options/m_option.c
+++ b/options/m_option.c
@@ -696,7 +696,7 @@ static char *print_choice(const m_option_t *opt, const void *val)
}
const struct m_option_type m_option_type_choice = {
- .name = "String", // same as arbitrary strings in option list for now
+ .name = "Choice",
.size = sizeof(int),
.parse = parse_choice,
.print = print_choice,
diff --git a/options/m_property.h b/options/m_property.h
index b7dbcfb378..0336677f46 100644
--- a/options/m_property.h
+++ b/options/m_property.h
@@ -189,6 +189,8 @@ struct m_sub_property {
.type = {.type = CONF_TYPE_STRING}, .value = {.string = (char *)(s)}
#define SUB_PROP_FLOAT(f) \
.type = {.type = CONF_TYPE_FLOAT}, .value = {.float_ = (f)}
+#define SUB_PROP_DOUBLE(f) \
+ .type = {.type = CONF_TYPE_DOUBLE}, .value = {.double_ = (f)}
#define SUB_PROP_FLAG(f) \
.type = {.type = CONF_TYPE_FLAG}, .value = {.flag = (f)}
diff --git a/player/command.c b/player/command.c
index f60dfc6194..8881d1f845 100644
--- a/player/command.c
+++ b/player/command.c
@@ -3017,14 +3017,46 @@ static int mp_property_option_info(void *ctx, struct m_property *prop,
if (!co)
return M_PROPERTY_UNKNOWN;
+ union m_option_value def = {0};
+ if (co->default_data)
+ memcpy(&def, co->default_data, co->opt->type->size);
+
+ const struct m_option *opt = co->opt;
+ bool has_minmax =
+ opt->type == &m_option_type_int ||
+ opt->type == &m_option_type_int64 ||
+ opt->type == &m_option_type_float ||
+ opt->type == &m_option_type_double;
+ char **choices = NULL;
+
+ if (opt->type == &m_option_type_choice) {
+ has_minmax = true;
+ struct m_opt_choice_alternatives *alt = opt->priv;
+ int num = 0;
+ for ( ; alt->name; alt++)
+ MP_TARRAY_APPEND(NULL, choices, num, alt->name);
+ MP_TARRAY_APPEND(NULL, choices, num, NULL);
+ }
+
struct m_sub_property props[] = {
+ {"name", SUB_PROP_STR(co->name)},
+ {"type", SUB_PROP_STR(opt->type->name)},
{"set-from-commandline", SUB_PROP_FLAG(co->is_set_from_cmdline)},
+ {"default-value", *opt, def},
+ {"min", SUB_PROP_DOUBLE(opt->min),
+ .unavailable = !(has_minmax && (opt->flags & M_OPT_MIN))},
+ {"max", SUB_PROP_DOUBLE(opt->max),
+ .unavailable = !(has_minmax && (opt->flags & M_OPT_MAX))},
+ {"choices", .type = {.type = CONF_TYPE_STRING_LIST},
+ .value = {.string_list = choices}, .unavailable = !choices},
{0}
};
struct m_property_action_arg next_ka = *ka;
next_ka.key = rem;
- return m_property_read_sub(props, M_PROPERTY_KEY_ACTION, &next_ka);
+ int r = m_property_read_sub(props, M_PROPERTY_KEY_ACTION, &next_ka);
+ talloc_free(choices);
+ return r;
}
}
return M_PROPERTY_NOT_IMPLEMENTED;