summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-09-01 20:00:43 +0200
committerwm4 <wm4@nowhere>2016-09-01 20:00:43 +0200
commitd32bee5f019f2c51839df16b7c7955dc33651cbe (patch)
tree96424f3477a67ca6b5f6220295bf4c906ac6106a
parent17dbb39dec1fcd3280f86e480a7191b6f78cbbcc (diff)
downloadmpv-d32bee5f019f2c51839df16b7c7955dc33651cbe.tar.bz2
mpv-d32bee5f019f2c51839df16b7c7955dc33651cbe.tar.xz
command: add options to property list
Now options are accessible through the property list as well, which unifies them to a degree. Not all options support runtime changes (meaning affected components need to be restarted for the options to take effects). Remove from the manpage those properties which are cleanly mapped to options anyway. From the user-perspective they're just options available through the property interface.
-rw-r--r--DOCS/interface-changes.rst2
-rw-r--r--DOCS/man/input.rst173
-rw-r--r--DOCS/man/options.rst5
-rw-r--r--options/m_config.c12
-rw-r--r--options/m_config.h5
-rw-r--r--options/m_option.h3
-rw-r--r--options/m_property.c4
-rw-r--r--options/m_property.h3
-rw-r--r--options/options.c27
-rw-r--r--options/options.h1
-rw-r--r--player/client.c4
-rw-r--r--player/command.c129
-rw-r--r--player/command.h4
-rw-r--r--player/main.c4
14 files changed, 160 insertions, 216 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index f3861c7b82..fd4193a4e9 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -25,6 +25,8 @@ Interface changes
at parsing time). This does not affect options which start with "--no-",
but do not use the mechanism for negation options.
(Also see client API change for API version 1.23.)
+ - add almost all options to the property list, meaning you can change
+ options without adding "options/" to the property name
--- mpv 0.20.0 ---
- add --image-display-duration option - this also means that image duration
is not influenced by --mf-fps anymore in the general case (this is an
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index 5892649fe5..fbc7c8faa3 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -838,20 +838,12 @@ an option at runtime.
Property list
-------------
-``osd-level`` (RW)
- See ``--osd-level``.
+.. note::
-``osd-scale`` (RW)
- OSD font size multiplier, see ``--osd-scale``.
-
-``loop`` (RW)
- See ``--loop``.
-
-``loop-file`` (RW)
- See ``--loop-file`` (uses ``yes``/``no``).
-
-``speed`` (RW)
- See ``--speed``.
+ Most options can be set as runtime via properties as well. Just remove the
+ leading ``--`` from the option name. These are not documented. Only
+ properties which do not exist as option with the same name, or which have
+ very different behavior from the options are documented below.
``audio-speed-correction``, ``video-speed-correction``
Factor multiplied with ``speed`` at which the player attempts to play the
@@ -1078,10 +1070,6 @@ Property list
"title" MPV_FORMAT_STRING
"default" MPV_FORMAT_FLAG
-``ab-loop-a``, ``ab-loop-b`` (RW)
- Set/get A-B loop points. See corresponding options and ``ab-loop`` command
- for details.
-
``angle`` (RW)
Current DVD angle.
@@ -1154,9 +1142,6 @@ Property list
``af-metadata/<filter-label>``
Equivalent to ``vf-metadata/<filter-label>``, but for audio filters.
-``pause`` (RW)
- Pause status. This is usually ``yes`` or ``no``. See ``--pause``.
-
``idle``
Return ``yes`` if no file is loaded, but the player is staying around
because of the ``--idle`` option.
@@ -1236,25 +1221,12 @@ Property list
is loaded, or when switching ordered chapter segments. This is because
the same underlying code is used for seeking and resyncing.)
-``hr-seek`` (RW)
- See ``--hr-seek``.
-
``mixer-active``
Return ``yes`` if the audio mixer is active, ``no`` otherwise.
This option is relatively useless. Before mpv 0.18.1, it could be used to
infer behavior of the ``volume`` property.
-``volume`` (RW)
- Current volume (see ``--volume`` for details).
-
-``volume-max`` (RW)
- Current maximum value the volume property can be set to. (Equivalent to the
- ``--volume-max`` option.)
-
-``mute`` (RW)
- Current mute status (``yes``/``no``).
-
``ao-volume`` (RW)
System volume. This property is available only if mpv audio output is
currently active, and only if the underlying implementation supports volume
@@ -1266,9 +1238,6 @@ Property list
Similar to ``ao-volume``, but controls the mute state. May be unimplemented
even if ``ao-volume`` works.
-``audio-delay`` (RW)
- See ``--audio-delay``.
-
``audio-codec``
Audio codec selected for decoding.
@@ -1316,28 +1285,6 @@ Property list
Same as ``audio-params``, but the format of the data written to the audio
API.
-``aid`` (RW)
- Current audio track (similar to ``--aid``).
-
-``audio`` (RW)
- Alias for ``aid``.
-
-``balance`` (RW)
- Audio channel balance. (The implementation of this feature is rather odd.
- It doesn't change the volumes of each channel, but instead sets up a pan
- matrix to mix the left and right channels.)
-
- Deprecated.
-
-``fullscreen`` (RW)
- See ``--fullscreen``.
-
-``deinterlace`` (RW)
- See ``--deinterlace``.
-
-``field-dominance`` (RW)
- See ``--field-dominance``
-
``colormatrix`` (R)
Redirects to ``video-params/colormatrix``. This parameter (as well as
similar ones) can be overridden with the ``format`` video filter.
@@ -1345,42 +1292,9 @@ Property list
``colormatrix-input-range`` (R)
See ``colormatrix``.
-``video-output-levels`` (RW)
- See ``--video-output-levels``,
-
``colormatrix-primaries`` (R)
See ``colormatrix``.
-``taskbar-progress`` (RW)
- See ``--taskbar-progress``.
-
-``ontop`` (RW)
- See ``--ontop``.
-
-``border`` (RW)
- See ``--border``.
-
-``on-all-workspaces`` (RW)
- See ``--on-all-workspaces``. Unsetting may not work on all WMs.
-
-``framedrop`` (RW)
- See ``--framedrop``.
-
-``gamma`` (RW)
- See ``--gamma``.
-
-``brightness`` (RW)
- See ``--brightness``.
-
-``contrast`` (RW)
- See ``--contrast``.
-
-``saturation`` (RW)
- See ``--saturation``.
-
-``hue`` (RW)
- See ``--hue``.
-
``hwdec`` (RW)
Reflects the ``--hwdec`` option.
@@ -1431,9 +1345,6 @@ Property list
while no video is being decoded. All this reflects how detecting hw decoders
are detected and used internally in mpv.
-``panscan`` (RW)
- See ``--panscan``.
-
``video-format``
Video format as string.
@@ -1600,6 +1511,9 @@ Property list
``video-aspect`` (RW)
Video aspect, see ``--video-aspect``.
+ If video is active, this reports the effective aspect value, instead of
+ the value of the ``--video-aspect`` option.
+
``osd-width``, ``osd-height``
Last known OSD width (can be 0). This is needed if you want to use the
``overlay-add`` command. It gives you the actual OSD size, which can be
@@ -1608,24 +1522,6 @@ Property list
``osd-par``
Last known OSD display pixel aspect (can be 0).
-``vid`` (RW)
- Current video track (similar to ``--vid``).
-
-``video`` (RW)
- Alias for ``vid``.
-
-``video-align-x``, ``video-align-y`` (RW)
- See ``--video-align-x`` and ``--video-align-y``.
-
-``video-pan-x``, ``video-pan-y`` (RW)
- See ``--video-pan-x`` and ``--video-pan-y``.
-
-``video-zoom`` (RW)
- See ``--video-zoom``.
-
-``video-unscaled`` (W)
- See ``--video-unscaled``.
-
``program`` (W)
Switch TS program (write-only).
@@ -1638,36 +1534,6 @@ Property list
On write, a channel-switch to the named channel on the same
card is performed. Can also be used for channel switching.
-``sid`` (RW)
- Current subtitle track (similar to ``--sid``).
-
-``secondary-sid`` (RW)
- Secondary subtitle track (see ``--secondary-sid``).
-
-``sub`` (RW)
- Alias for ``sid``.
-
-``sub-delay`` (RW)
- See ``--sub-delay``.
-
-``sub-pos`` (RW)
- See ``--sub-pos``.
-
-``sub-visibility`` (RW)
- See ``--sub-visibility``.
-
-``sub-forced-only`` (RW)
- See ``--sub-forced-only``.
-
-``sub-scale`` (RW)
- Subtitle font size multiplier.
-
-``ass-force-margins`` (RW)
- See ``--ass-force-margins``.
-
-``sub-use-margins`` (RW)
- See ``--sub-use-margins``.
-
``sub-text``
Return the current subtitle text. Formatting is stripped. If a subtitle
is selected, but no text is currently visible, or the subtitle is not
@@ -1675,12 +1541,6 @@ Property list
This property is experimental and might be removed in the future.
-``ass-vsfilter-aspect-compat`` (RW)
- See ``--ass-vsfilter-aspect-compat``.
-
-``ass-style-override`` (RW)
- See ``--ass-style-override``.
-
``stream-capture`` (RW)
A filename, see ``--stream-capture``. Setting this will start capture using
the given filename. Setting it to an empty string will stop it.
@@ -1891,11 +1751,8 @@ Property list
"title" MPV_FORMAT_STRING
"time" MPV_FORMAT_DOUBLE
-``af`` (RW)
- See ``--af`` and the ``af`` command.
-
-``vf`` (RW)
- See ``--vf`` and the ``vf`` command.
+``af``, ``vf`` (RW)
+ See ``--vf``/``--af`` and the ``vf``/``af`` command.
When querying the property with the client API using ``MPV_FORMAT_NODE``,
or with Lua ``mp.get_property_native``, this will return a mpv_node with
@@ -1913,12 +1770,6 @@ Property list
It's also possible to write the property using this format.
-``video-rotate`` (RW)
- See ``--video-rotate`` option.
-
-``video-stereo-mode`` (RW)
- See ``--video-stereo-mode`` option.
-
``seekable``
Return whether it's generally possible to seek in the current file.
@@ -2158,6 +2009,10 @@ Property list
require reloading the file for changes to take effect. If there is an
equivalent property, prefer setting the property instead.
+ There shouldn't be any reason to access ``options/<name>`` instead of
+ ``<name>``, except in situations in which the properties have different
+ behavior or conflicting semantics.
+
``file-local-options/<name>``
Similar to ``options/<name>``, but when setting an option through this
property, the option is reset to its old value once the current file has
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index b4a49a75db..e723d5cbbe 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -1091,7 +1091,10 @@ Audio
Since mpv 0.18.1, this always controls the internal mixer (aka "softvol").
``--balance=<value>``
- How much left/right channels contribute to the audio.
+ How much left/right channels contribute to the audio. (The implementation
+ of this feature is rather odd. It doesn't change the volumes of each
+ channel, but instead sets up a pan matrix to mix the left and right
+ channels.)
Deprecated.
diff --git a/options/m_config.c b/options/m_config.c
index 352965ea47..d4c19808b0 100644
--- a/options/m_config.c
+++ b/options/m_config.c
@@ -447,6 +447,16 @@ struct m_config_option *m_config_get_co(const struct m_config *config,
return NULL;
}
+int m_config_get_co_count(struct m_config *config)
+{
+ return config->num_opts;
+}
+
+struct m_config_option *m_config_get_co_index(struct m_config *config, int index)
+{
+ return &config->opts[index];
+}
+
const char *m_config_get_positional_option(const struct m_config *config, int p)
{
int pos = 0;
@@ -509,7 +519,7 @@ static void handle_on_set(struct m_config *config, struct m_config_option *co,
mp_msg_update_msglevels(config->global);
}
-// The type data points to is as in: m_config_get_co(config, name)->opt
+// The type data points to is as in: co->opt
int m_config_set_option_raw(struct m_config *config, struct m_config_option *co,
void *data, int flags)
{
diff --git a/options/m_config.h b/options/m_config.h
index e6d093582f..4ac673859f 100644
--- a/options/m_config.h
+++ b/options/m_config.h
@@ -136,7 +136,7 @@ enum {
};
// Flags for safe option setting during runtime.
-#define M_SETOPT_RUNTIME (M_SETOPT_NO_FIXED | M_SETOPT_NO_PRE_PARSE)
+#define M_SETOPT_RUNTIME M_SETOPT_NO_FIXED
// Set the named option to the given string.
// flags: combination of M_SETOPT_* flags (0 for normal operation)
@@ -176,6 +176,9 @@ int m_config_parse_suboptions(struct m_config *config, char *name,
struct m_config_option *m_config_get_co(const struct m_config *config,
struct bstr name);
+int m_config_get_co_count(struct m_config *config);
+struct m_config_option *m_config_get_co_index(struct m_config *config, int index);
+
// Return the n-th option by position. n==0 is the first option. If there are
// less than (n + 1) options, return NULL.
const char *m_config_get_positional_option(const struct m_config *config, int n);
diff --git a/options/m_option.h b/options/m_option.h
index 2901cb6288..548db319a1 100644
--- a/options/m_option.h
+++ b/options/m_option.h
@@ -371,6 +371,9 @@ struct m_option {
// Logging-related option - used to update log/terminal settings eagerly
#define M_OPT_TERM (1 << 12)
+// Do not add as property.
+#define M_OPT_NOPROP (1 << 13)
+
// These are kept for compatibility with older code.
#define CONF_MIN M_OPT_MIN
#define CONF_MAX M_OPT_MAX
diff --git a/options/m_property.c b/options/m_property.c
index 4ed4f5f586..13d3844671 100644
--- a/options/m_property.c
+++ b/options/m_property.c
@@ -36,8 +36,8 @@
#include "common/msg.h"
#include "common/common.h"
-static struct m_property *m_property_list_find(const struct m_property *list,
- const char *name)
+struct m_property *m_property_list_find(const struct m_property *list,
+ const char *name)
{
for (int n = 0; list && list[n].name; n++) {
if (strcmp(list[n].name, name) == 0)
diff --git a/options/m_property.h b/options/m_property.h
index 42fe1c7ecf..0f8230608b 100644
--- a/options/m_property.h
+++ b/options/m_property.h
@@ -128,6 +128,9 @@ struct m_property {
void *priv;
};
+struct m_property *m_property_list_find(const struct m_property *list,
+ const char *name);
+
// Access a property.
// action: one of m_property_action
// ctx: opaque value passed through to property implementation
diff --git a/options/options.c b/options/options.c
index 7b0f3c43e1..2aff813a25 100644
--- a/options/options.c
+++ b/options/options.c
@@ -187,22 +187,25 @@ const m_option_t mp_opts[] = {
{ "profile", CONF_TYPE_STRING_LIST, M_OPT_FIXED, .offset = -1},
{ "show-profile", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_FIXED, .offset = -1},
{ "list-options", CONF_TYPE_STORE, CONF_NOCFG | M_OPT_FIXED, .offset = -1},
+ OPT_FLAG("list-properties", property_print_help,
+ CONF_NOCFG | M_OPT_FIXED | M_OPT_NOPROP),
OPT_FLAG("shuffle", shuffle, 0),
// ------------------------- common options --------------------
- OPT_FLAG("quiet", quiet, CONF_GLOBAL),
- OPT_FLAG_STORE("really-quiet", verbose, CONF_GLOBAL | CONF_PRE_PARSE, -10),
+ OPT_FLAG("quiet", quiet, CONF_GLOBAL | M_OPT_NOPROP),
+ OPT_FLAG_STORE("really-quiet", verbose,
+ CONF_GLOBAL | CONF_PRE_PARSE | M_OPT_NOPROP, -10),
OPT_FLAG("terminal", use_terminal, CONF_GLOBAL | CONF_PRE_PARSE | M_OPT_TERM),
- OPT_GENERAL(char**, "msg-level", msg_levels, CONF_GLOBAL|CONF_PRE_PARSE |
- M_OPT_TERM, .type = &m_option_type_msglevels),
+ OPT_GENERAL(char**, "msg-level", msg_levels, CONF_PRE_PARSE | M_OPT_TERM,
+ .type = &m_option_type_msglevels),
OPT_STRING("dump-stats", dump_stats, CONF_GLOBAL | CONF_PRE_PARSE),
- OPT_FLAG("msg-color", msg_color, CONF_GLOBAL | CONF_PRE_PARSE | M_OPT_TERM),
- OPT_STRING("log-file", log_file, CONF_GLOBAL | CONF_PRE_PARSE | M_OPT_FILE),
- OPT_FLAG("msg-module", msg_module, CONF_GLOBAL | M_OPT_TERM),
- OPT_FLAG("msg-time", msg_time, CONF_GLOBAL | M_OPT_TERM),
+ OPT_FLAG("msg-color", msg_color, CONF_PRE_PARSE | M_OPT_TERM),
+ OPT_STRING("log-file", log_file, CONF_PRE_PARSE | M_OPT_FILE),
+ OPT_FLAG("msg-module", msg_module, M_OPT_TERM),
+ OPT_FLAG("msg-time", msg_time, M_OPT_TERM),
#ifdef _WIN32
- OPT_CHOICE("priority", w32_priority, 0,
+ OPT_CHOICE("priority", w32_priority, CONF_GLOBAL,
({"no", 0},
{"realtime", REALTIME_PRIORITY_CLASS},
{"high", HIGH_PRIORITY_CLASS},
@@ -479,7 +482,8 @@ const m_option_t mp_opts[] = {
OPT_CHOICE("softvol", softvol, 0,
({"no", SOFTVOL_NO},
{"yes", SOFTVOL_YES},
- {"auto", SOFTVOL_AUTO})),
+ {"auto", SOFTVOL_AUTO}),
+ .deprecation_message = "no replacement"),
OPT_FLOATRANGE("volume-max", softvol_max, 0, 100, 1000),
// values <0 for volume and mute are legacy and ignored
OPT_FLOATRANGE("volume", softvol_volume, 0, -1, 1000),
@@ -621,7 +625,7 @@ const m_option_t mp_opts[] = {
OPT_FLAG("input-terminal", consolecontrols, CONF_GLOBAL),
OPT_STRING("input-file", input_file, M_OPT_FILE | M_OPT_GLOBAL),
- OPT_STRING("input-ipc-server", ipc_path, M_OPT_FILE),
+ OPT_STRING("input-ipc-server", ipc_path, M_OPT_FILE | M_OPT_FIXED),
OPT_SUBSTRUCT("screenshot", screenshot_image_opts, image_writer_conf, 0),
OPT_STRING("screenshot-template", screenshot_template, 0),
@@ -629,7 +633,6 @@ const m_option_t mp_opts[] = {
OPT_SUBSTRUCT("input", input_opts, input_config, 0),
- OPT_PRINT("list-properties", property_print_help),
OPT_PRINT("list-protocols", stream_print_proto_list),
OPT_PRINT("help", print_help),
OPT_PRINT("h", print_help),
diff --git a/options/options.h b/options/options.h
index 130ab4c1cf..1a2bfa68c8 100644
--- a/options/options.h
+++ b/options/options.h
@@ -64,6 +64,7 @@ struct mp_cache_opts {
};
typedef struct MPOpts {
+ int property_print_help;
int use_terminal;
char *dump_stats;
int verbose;
diff --git a/player/client.c b/player/client.c
index b34247d730..df3aa01739 100644
--- a/player/client.c
+++ b/player/client.c
@@ -1319,7 +1319,7 @@ int mpv_observe_property(mpv_handle *ctx, uint64_t userdata,
*prop = (struct observe_property){
.client = ctx,
.name = talloc_strdup(prop, name),
- .id = mp_get_property_id(name),
+ .id = mp_get_property_id(ctx->mpctx, name),
.event_mask = mp_get_property_event_mask(name),
.reply_id = userdata,
.format = format,
@@ -1377,7 +1377,7 @@ static void mark_property_changed(struct mpv_handle *client, int index)
void mp_client_property_change(struct MPContext *mpctx, const char *name)
{
struct mp_client_api *clients = mpctx->clients;
- int id = mp_get_property_id(name);
+ int id = mp_get_property_id(mpctx, name);
pthread_mutex_lock(&clients->lock);
diff --git a/player/command.c b/player/command.c
index 7a6820af3e..0d8767e922 100644
--- a/player/command.c
+++ b/player/command.c
@@ -69,6 +69,9 @@
#include "core.h"
struct command_ctx {
+ // All properties, terminated with a {0} item.
+ struct m_property *properties;
+
bool is_idle;
double last_seek_time;
@@ -251,11 +254,12 @@ static char *format_delay(double time)
}
// Property-option bridge. (Maps the property to the option with the same name.)
-static int mp_property_generic_option(void *ctx, struct m_property *prop,
- int action, void *arg)
+static int mp_property_generic_option_do(void *ctx, struct m_property *prop,
+ int action, void *arg, bool force)
{
MPContext *mpctx = ctx;
const char *optname = prop->name;
+ int flags = mpctx->initialized && !force ? M_SETOPT_RUNTIME : 0;
struct m_config_option *opt = m_config_get_co(mpctx->mconfig,
bstr0(optname));
@@ -272,12 +276,36 @@ static int mp_property_generic_option(void *ctx, struct m_property *prop,
m_option_copy(opt->opt, arg, valptr);
return M_PROPERTY_OK;
case M_PROPERTY_SET:
- m_option_copy(opt->opt, valptr, arg);
+ if (m_config_set_option_raw(mpctx->mconfig, opt, arg, flags) < 0)
+ return M_PROPERTY_ERROR;
return M_PROPERTY_OK;
}
return M_PROPERTY_NOT_IMPLEMENTED;
}
+static int mp_property_generic_option(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ return mp_property_generic_option_do(ctx, prop, action, arg, true);
+}
+
+static int mp_property_generic_option_bridge(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ return mp_property_generic_option_do(ctx, prop, action, arg, false);
+}
+
+// Dumb special-case: the option name ends in a "*".
+static int mp_property_generic_option_star(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ struct m_property prop2 = *prop;
+ char name[80];
+ snprintf(name, sizeof(name), "%s*", prop->name);
+ prop2.name = name;
+ return mp_property_generic_option_bridge(ctx, &prop2, action, arg);
+}
+
/// Playback speed (RW)
static int mp_property_playback_speed(void *ctx, struct m_property *prop,
int action, void *arg)
@@ -3639,11 +3667,12 @@ static int mp_property_option_info(void *ctx, struct m_property *prop,
return M_PROPERTY_NOT_IMPLEMENTED;
}
-static const struct m_property mp_properties[];
-
static int mp_property_list(void *ctx, struct m_property *prop,
int action, void *arg)
{
+ struct MPContext *mpctx = ctx;
+ struct command_ctx *cmd = mpctx->command_ctx;
+
switch (action) {
case M_PROPERTY_GET_TYPE:
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
@@ -3651,9 +3680,9 @@ static int mp_property_list(void *ctx, struct m_property *prop,
case M_PROPERTY_GET: {
char **list = NULL;
int num = 0;
- for (int n = 0; mp_properties[n].name; n++) {
+ for (int n = 0; cmd->properties[n].name; n++) {
MP_TARRAY_APPEND(NULL, list, num,
- talloc_strdup(NULL, mp_properties[n].name));
+ talloc_strdup(NULL, cmd->properties[n].name));
}
MP_TARRAY_APPEND(NULL, list, num, NULL);
*(char ***)arg = list;
@@ -3686,15 +3715,10 @@ static int mp_profile_list(void *ctx, struct m_property *prop,
#define M_PROPERTY_DEPRECATED_ALIAS(name, real_property) \
{(name), mp_property_deprecated_alias, .priv = (real_property)}
-/// All properties available in MPlayer.
-/** \ingroup Properties
- */
-static const struct m_property mp_properties[] = {
+// Base list of properties. This does not include option-mapped properties.
+static const struct m_property mp_properties_base[] = {
// General
- {"osd-level", mp_property_generic_option},
{"osd-scale", property_osd_helper},
- {"loop", mp_property_generic_option},
- {"loop-file", mp_property_generic_option},
{"speed", mp_property_playback_speed},
{"audio-speed-correction", mp_property_av_speed_correction, .priv = "a"},
{"video-speed-correction", mp_property_av_speed_correction, .priv = "v"},
@@ -3706,12 +3730,12 @@ static const struct m_property mp_properties[] = {
{"media-title", mp_property_media_title},
{"stream-path", mp_property_stream_path},
{"stream-capture", mp_property_stream_capture},
- {"demuxer", mp_property_demuxer},
+ {"demuxer", mp_property_demuxer}, // conflicts with option
{"file-format", mp_property_file_format},
{"stream-pos", mp_property_stream_pos},
{"stream-end", mp_property_stream_end},
{"duration", mp_property_duration},
- M_PROPERTY_DEPRECATED_ALIAS("length", "duration"),
+ M_PROPERTY_DEPRECATED_ALIAS("length", "duration"), // conflicts with option
{"avsync", mp_property_avsync},
{"total-avsync-change", mp_property_total_avsync_change},
{"drop-frame-count", mp_property_drop_frame_cnt},
@@ -3742,7 +3766,7 @@ static const struct m_property mp_properties[] = {
{"eof-reached", mp_property_eof_reached},
{"seeking", mp_property_seeking},
{"playback-abort", mp_property_playback_abort},
- {"cache", mp_property_cache},
+ {"cache", mp_property_cache}, // conflicts with option
{"cache-free", mp_property_cache_free},
{"cache-used", mp_property_cache_used},
{"cache-size", mp_property_cache_size},
@@ -3753,11 +3777,10 @@ static const struct m_property mp_properties[] = {
{"demuxer-cache-idle", mp_property_demuxer_cache_idle},
{"cache-buffering-state", mp_property_cache_buffering},
{"paused-for-cache", mp_property_paused_for_cache},
- {"hr-seek", mp_property_generic_option},
{"clock", mp_property_clock},
{"seekable", mp_property_seekable},
{"partially-seekable", mp_property_partially_seekable},
- {"idle", mp_property_idle},
+ {"idle", mp_property_idle}, // conflicts with option
{"chapter-list", mp_property_list_chapters},
{"track-list", property_list_tracks},
@@ -3772,7 +3795,6 @@ static const struct m_property mp_properties[] = {
// Audio
{"mixer-active", mp_property_mixer_active},
{"volume", mp_property_volume},
- {"volume-max", mp_property_generic_option},
{"mute", mp_property_mute},
{"ao-volume", mp_property_ao_volume},
{"ao-mute", mp_property_ao_mute},
@@ -3781,6 +3803,7 @@ static const struct m_property mp_properties[] = {
{"audio-codec", mp_property_audio_codec},
{"audio-params", mp_property_audio_params},
{"audio-out-params", mp_property_audio_out_params},
+ // conflicts with option
M_PROPERTY_DEPRECATED_ALIAS("audio-samplerate", "audio-params/samplerate"),
M_PROPERTY_DEPRECATED_ALIAS("audio-channels", "audio-params/channel-count"),
{"aid", mp_property_audio},
@@ -3793,12 +3816,10 @@ static const struct m_property mp_properties[] = {
// Video
{"fullscreen", mp_property_fullscreen},
{"deinterlace", mp_property_deinterlace},
- {"field-dominance", mp_property_generic_option},
{"taskbar-progress", mp_property_taskbar_progress},
{"ontop", mp_property_ontop},
{"border", mp_property_border},
{"on-all-workspaces", mp_property_all_workspaces},
- {"framedrop", mp_property_generic_option},
{"gamma", mp_property_video_color},
{"brightness", mp_property_video_color},
{"contrast", mp_property_video_color},
@@ -3827,7 +3848,7 @@ static const struct m_property mp_properties[] = {
{"vo-configured", mp_property_vo_configured},
{"vo-performance", mp_property_vo_performance},
{"current-vo", mp_property_vo},
- {"fps", mp_property_fps},
+ {"fps", mp_property_fps}, // conflicts with option
{"estimated-vf-fps", mp_property_vf_fps},
{"video-aspect", mp_property_aspect},
{"vid", mp_property_video},
@@ -3924,18 +3945,18 @@ static const struct m_property mp_properties[] = {
{"property-list", mp_property_list},
{"profile-list", mp_profile_list},
- // compatibility
M_PROPERTY_ALIAS("video", "vid"),
M_PROPERTY_ALIAS("audio", "aid"),
M_PROPERTY_ALIAS("sub", "sid"),
+
+ // compatibility
M_PROPERTY_ALIAS("colormatrix", "video-params/colormatrix"),
M_PROPERTY_ALIAS("colormatrix-input-range", "video-params/colorlevels"),
M_PROPERTY_ALIAS("colormatrix-primaries", "video-params/primaries"),
M_PROPERTY_ALIAS("colormatrix-gamma", "video-params/gamma"),
+ // conflicts with option
M_PROPERTY_DEPRECATED_ALIAS("audio-format", "audio-codec-name"),
-
- {0},
};
// Each entry describes which properties an event (possibly) changes.
@@ -4013,10 +4034,11 @@ uint64_t mp_get_property_event_mask(const char *name)
// Return an ID for the property. It might not be unique, but is good enough
// for property change handling. Return -1 if property unknown.
-int mp_get_property_id(const char *name)
+int mp_get_property_id(struct MPContext *mpctx, const char *name)
{
- for (int n = 0; mp_properties[n].name; n++) {
- if (match_property(mp_properties[n].name, name))
+ struct command_ctx *ctx = mpctx->command_ctx;
+ for (int n = 0; ctx->properties[n].name; n++) {
+ if (match_property(ctx->properties[n].name, name))
return n;
}
return -1;
@@ -4042,7 +4064,8 @@ static bool is_property_set(int action, void *val)
int mp_property_do(const char *name, int action, void *val,
struct MPContext *ctx)
{
- int r = m_property_do(ctx->log, mp_properties, name, action, val, ctx);
+ struct command_ctx *cmd = ctx->command_ctx;
+ int r = m_property_do(ctx->log, cmd->properties, name, action, val, ctx);
if (r == M_PROPERTY_OK && is_property_set(action, val))
mp_notify_property(ctx, (char *)name);
if (mp_msg_test(ctx->log, MSGL_V) && is_property_set(action, val)) {
@@ -4067,7 +4090,8 @@ int mp_property_do(const char *name, int action, void *val,
char *mp_property_expand_string(struct MPContext *mpctx, const char *str)
{
- return m_properties_expand_string(mp_properties, str, mpctx);
+ struct command_ctx *ctx = mpctx->command_ctx;
+ return m_properties_expand_string(ctx->properties, str, mpctx);
}
// Before expanding properties, parse C-style escapes like "\n"
@@ -4091,12 +4115,12 @@ char *mp_property_expand_escaped_string(struct MPContext *mpctx, const char *str
return r;
}
-void property_print_help(struct mp_log *log)
+void property_print_help(struct MPContext *mpctx)
{
- m_properties_print_help_list(log, mp_properties);
+ struct command_ctx *ctx = mpctx->command_ctx;
+ m_properties_print_help_list(mpctx->log, ctx->properties);
}
-
/* List of default ways to show a property on OSD.
*
* If osd_progbar is set, a bar showing the current position between min/max
@@ -5424,10 +5448,43 @@ void command_uninit(struct MPContext *mpctx)
void command_init(struct MPContext *mpctx)
{
- mpctx->command_ctx = talloc(NULL, struct command_ctx);
- *mpctx->command_ctx = (struct command_ctx){
+ struct command_ctx *ctx = talloc(NULL, struct command_ctx);
+ *ctx = (struct command_ctx){
.last_seek_pts = MP_NOPTS_VALUE,
};
+ mpctx->command_ctx = ctx;
+
+ int num_base = MP_ARRAY_SIZE(mp_properties_base);
+ int num_opts = m_config_get_co_count(mpctx->mconfig);
+ ctx->properties =
+ talloc_zero_array(ctx, struct m_property, num_base + num_opts + 1);
+ memcpy(ctx->properties, mp_properties_base, sizeof(mp_properties_base));
+
+ int count = num_base;
+ for (int n = 0; n < num_opts; n++) {
+ struct m_config_option *co = m_config_get_co_index(mpctx->mconfig, n);
+ assert(co->name[0]);
+ if (!co->data || (co->opt->flags & M_OPT_NOPROP) ||
+ (co->opt->type->flags & M_OPT_TYPE_HAS_CHILD))
+ continue;
+
+ struct m_property prop = {
+ .name = co->name,
+ .call = mp_property_generic_option_bridge,
+ };
+
+ bstr bname = bstr0(prop.name);
+ if (bstr_eatend0(&bname, "*")) {
+ prop.name = bstrto0(ctx, bname);
+ prop.call = mp_property_generic_option_star;
+ }
+
+ // The option might be covered by a manual property already.
+ if (m_property_list_find(ctx->properties, prop.name))
+ continue;
+
+ ctx->properties[count++] = prop;
+ }
}
static void command_event(struct MPContext *mpctx, int event, void *arg)
diff --git a/player/command.h b/player/command.h
index 9ffa5c1340..c082d8d0d7 100644
--- a/player/command.h
+++ b/player/command.h<