aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--input/cmd_list.c215
-rw-r--r--player/command.c216
2 files changed, 216 insertions, 215 deletions
diff --git a/input/cmd_list.c b/input/cmd_list.c
index 5e1780c24c..8896db3480 100644
--- a/input/cmd_list.c
+++ b/input/cmd_list.c
@@ -27,221 +27,6 @@
#include "cmd_list.h"
#include "cmd_parse.h"
-// This does not specify the real destination of the command parameter values,
-// it just provides a dummy for the OPT_ macros.
-#define OPT_BASE_STRUCT struct mp_cmd_arg
-#define ARG(t) "", v. t
-
-/* This array defines all known commands.
- * The first field is an id used to recognize the command.
- * The second is the command name used in slave mode and input.conf.
- * Then comes the definition of each argument, first mandatory arguments
- * (ARG_INT, ARG_FLOAT, ARG_STRING) if any, then optional arguments
- * (OARG_INT(default), etc) if any. The command will be given the default
- * argument value if the user didn't give enough arguments to specify it.
- * A command can take a maximum of MP_CMD_DEF_MAX_ARGS arguments, or more
- * if the command uses varargs.
- */
-
-#define ARG_INT OPT_INT(ARG(i), 0)
-#define ARG_FLOAT OPT_FLOAT(ARG(f), 0)
-#define ARG_DOUBLE OPT_DOUBLE(ARG(d), 0)
-#define ARG_STRING OPT_STRING(ARG(s), 0)
-#define ARG_CHOICE(c) OPT_CHOICE(ARG(i), 0, c)
-#define ARG_CHOICE_OR_INT(...) OPT_CHOICE_OR_INT(ARG(i), 0, __VA_ARGS__)
-#define ARG_TIME OPT_TIME(ARG(d), 0)
-#define OARG_DOUBLE(def) OPT_DOUBLE(ARG(d), 0, OPTDEF_DOUBLE(def))
-#define OARG_INT(def) OPT_INT(ARG(i), 0, OPTDEF_INT(def))
-#define OARG_CHOICE(def, c) OPT_CHOICE(ARG(i), 0, c, OPTDEF_INT(def))
-#define OARG_FLAGS(def, c) OPT_FLAGS(ARG(i), 0, c, OPTDEF_INT(def))
-#define OARG_STRING(def) OPT_STRING(ARG(s), 0, OPTDEF_STR(def))
-
-#define OARG_CYCLEDIR(def) OPT_CYCLEDIR(ARG(d), 0, OPTDEF_DOUBLE(def))
-
-const struct mp_cmd_def mp_cmds[] = {
- { MP_CMD_IGNORE, "ignore", },
-
- { MP_CMD_SEEK, "seek", {
- ARG_TIME,
- OARG_FLAGS(4|0, ({"relative", 4|0}, {"-", 4|0},
- {"absolute-percent", 4|1},
- {"absolute", 4|2},
- {"relative-percent", 4|3},
- {"keyframes", 32|8},
- {"exact", 32|16})),
- // backwards compatibility only
- OARG_CHOICE(0, ({"unused", 0}, {"default-precise", 0},
- {"keyframes", 32|8},
- {"exact", 32|16})),
- },
- .allow_auto_repeat = true,
- .scalable = true,
- },
- { MP_CMD_REVERT_SEEK, "revert-seek", {
- OARG_FLAGS(0, ({"mark", 1})),
- }},
- { MP_CMD_QUIT, "quit", { OARG_INT(0) } },
- { MP_CMD_QUIT_WATCH_LATER, "quit-watch-later", { OARG_INT(0) } },
- { MP_CMD_STOP, "stop", },
- { MP_CMD_FRAME_STEP, "frame-step", .allow_auto_repeat = true,
- .on_updown = true },
- { MP_CMD_FRAME_BACK_STEP, "frame-back-step", .allow_auto_repeat = true },
- { MP_CMD_PLAYLIST_NEXT, "playlist-next", {
- OARG_CHOICE(0, ({"weak", 0},
- {"force", 1})),
- }},
- { MP_CMD_PLAYLIST_PREV, "playlist-prev", {
- OARG_CHOICE(0, ({"weak", 0},
- {"force", 1})),
- }},
- { MP_CMD_PLAYLIST_SHUFFLE, "playlist-shuffle", },
- { MP_CMD_SUB_STEP, "sub-step", { ARG_INT }, .allow_auto_repeat = true },
- { MP_CMD_SUB_SEEK, "sub-seek", { ARG_INT }, .allow_auto_repeat = true },
- { MP_CMD_PRINT_TEXT, "print-text", { ARG_STRING }, .allow_auto_repeat = true },
- { MP_CMD_SHOW_TEXT, "show-text", { ARG_STRING, OARG_INT(-1), OARG_INT(0) },
- .allow_auto_repeat = true},
- { MP_CMD_EXPAND_TEXT, "expand-text", { ARG_STRING } },
- { MP_CMD_SHOW_PROGRESS, "show-progress", .allow_auto_repeat = true},
- { MP_CMD_SUB_ADD, "sub-add", { ARG_STRING,
- OARG_CHOICE(0, ({"select", 0}, {"auto", 1}, {"cached", 2})),
- OARG_STRING(""), OARG_STRING("") } },
- { MP_CMD_SUB_REMOVE, "sub-remove", { OARG_INT(-1) } },
- { MP_CMD_SUB_RELOAD, "sub-reload", { OARG_INT(-1) } },
-
- { MP_CMD_TV_LAST_CHANNEL, "tv-last-channel", },
-
- { MP_CMD_SCREENSHOT, "screenshot", {
- OARG_FLAGS(4|2, ({"video", 4|0}, {"-", 4|0},
- {"window", 4|1},
- {"subtitles", 4|2},
- {"each-frame", 8})),
- // backwards compatibility
- OARG_CHOICE(0, ({"unused", 0}, {"single", 0},
- {"each-frame", 8})),
- }},
- { MP_CMD_SCREENSHOT_TO_FILE, "screenshot-to-file", {
- ARG_STRING,
- OARG_CHOICE(2, ({"video", 0},
- {"window", 1},
- {"subtitles", 2})),
- }},
- { MP_CMD_SCREENSHOT_RAW, "screenshot-raw", {
- OARG_CHOICE(2, ({"video", 0},
- {"window", 1},
- {"subtitles", 2})),
- }},
- { MP_CMD_LOADFILE, "loadfile", {
- ARG_STRING,
- OARG_CHOICE(0, ({"replace", 0},
- {"append", 1},
- {"append-play", 2})),
- OPT_KEYVALUELIST(ARG(str_list), MP_CMD_OPT_ARG),
- }},
- { MP_CMD_LOADLIST, "loadlist", {
- ARG_STRING,
- OARG_CHOICE(0, ({"replace", 0},
- {"append", 1})),
- }},
- { MP_CMD_PLAYLIST_CLEAR, "playlist-clear", },
- { MP_CMD_PLAYLIST_REMOVE, "playlist-remove", {
- ARG_CHOICE_OR_INT(0, INT_MAX, ({"current", -1})),
- }},
- { MP_CMD_PLAYLIST_MOVE, "playlist-move", { ARG_INT, ARG_INT } },
- { MP_CMD_RUN, "run", { ARG_STRING, ARG_STRING }, .vararg = true },
-
- { MP_CMD_SET, "set", { ARG_STRING, ARG_STRING } },
- { MP_CMD_CHANGE_LIST, "change-list", { ARG_STRING, ARG_STRING, ARG_STRING } },
- { MP_CMD_ADD, "add", { ARG_STRING, OARG_DOUBLE(1) },
- .allow_auto_repeat = true,
- .scalable = true,
- },
- { MP_CMD_CYCLE, "cycle", {
- ARG_STRING,
- OARG_CYCLEDIR(1),
- },
- .allow_auto_repeat = true,
- .scalable = true,
- },
- { MP_CMD_MULTIPLY, "multiply", { ARG_STRING, ARG_DOUBLE },
- .allow_auto_repeat = true},
-
- { MP_CMD_CYCLE_VALUES, "cycle-values", { ARG_STRING, ARG_STRING, ARG_STRING },
- .vararg = true},
-
- { MP_CMD_ENABLE_INPUT_SECTION, "enable-section", {
- ARG_STRING,
- OARG_FLAGS(0, ({"default", 0},
- {"exclusive", MP_INPUT_EXCLUSIVE},
- {"allow-hide-cursor", MP_INPUT_ALLOW_HIDE_CURSOR},
- {"allow-vo-dragging", MP_INPUT_ALLOW_VO_DRAGGING})),
- }},
- { MP_CMD_DISABLE_INPUT_SECTION, "disable-section", { ARG_STRING } },
- { MP_CMD_DEFINE_INPUT_SECTION, "define-section", {
- ARG_STRING,
- ARG_STRING,
- OARG_CHOICE(1, ({"default", 1},
- {"force", 0})),
- }},
-
- { MP_CMD_AB_LOOP, "ab-loop", },
-
- { MP_CMD_DROP_BUFFERS, "drop-buffers", },
-
- { MP_CMD_AF, "af", { ARG_STRING, ARG_STRING } },
- { MP_CMD_AF_COMMAND, "af-command", { ARG_STRING, ARG_STRING, ARG_STRING } },
- { MP_CMD_AO_RELOAD, "ao-reload", },
-
- { MP_CMD_VF, "vf", { ARG_STRING, ARG_STRING } },
- { MP_CMD_VF_COMMAND, "vf-command", { ARG_STRING, ARG_STRING, ARG_STRING } },
-
- { MP_CMD_SCRIPT_BINDING, "script-binding", { ARG_STRING },
- .allow_auto_repeat = true, .on_updown = true},
-
- { MP_CMD_SCRIPT_MESSAGE, "script-message", { ARG_STRING }, .vararg = true },
- { MP_CMD_SCRIPT_MESSAGE_TO, "script-message-to", { ARG_STRING, ARG_STRING },
- .vararg = true },
-
- { MP_CMD_OVERLAY_ADD, "overlay-add",
- { ARG_INT, ARG_INT, ARG_INT, ARG_STRING, ARG_INT, ARG_STRING, ARG_INT,
- ARG_INT, ARG_INT }},
- { MP_CMD_OVERLAY_REMOVE, "overlay-remove", { ARG_INT } },
-
- { MP_CMD_WRITE_WATCH_LATER_CONFIG, "write-watch-later-config", },
-
- { MP_CMD_HOOK_ADD, "hook-add", { ARG_STRING, ARG_INT, ARG_INT } },
- { MP_CMD_HOOK_ACK, "hook-ack", { ARG_INT } },
-
- { MP_CMD_MOUSE, "mouse", {
- ARG_INT, ARG_INT, // coordinate (x, y)
- OARG_INT(-1), // button number
- OARG_CHOICE(0, ({"single", 0},
- {"double", 1})),
- }},
- { MP_CMD_KEYPRESS, "keypress", { ARG_STRING } },
- { MP_CMD_KEYDOWN, "keydown", { ARG_STRING } },
- { MP_CMD_KEYUP, "keyup", { OARG_STRING("") } },
-
- { MP_CMD_AUDIO_ADD, "audio-add", { ARG_STRING,
- OARG_CHOICE(0, ({"select", 0}, {"auto", 1}, {"cached", 2})),
- OARG_STRING(""), OARG_STRING("") } },
- { MP_CMD_AUDIO_REMOVE, "audio-remove", { OARG_INT(-1) } },
- { MP_CMD_AUDIO_RELOAD, "audio-reload", { OARG_INT(-1) } },
-
- { MP_CMD_RESCAN_EXTERNAL_FILES, "rescan-external-files", {
- OARG_CHOICE(1, ({"keep-selection", 0},
- {"reselect", 1})),
- }},
-
- { MP_CMD_APPLY_PROFILE, "apply-profile", {ARG_STRING } },
-
- { MP_CMD_LOAD_SCRIPT, "load-script", {ARG_STRING} },
-
- {0}
-};
-
-#undef OPT_BASE_STRUCT
-#undef ARG
-
// Map legacy commands to proper commands
struct legacy_cmd {
const char *old, *new;
diff --git a/player/command.c b/player/command.c
index a21fc53abb..c35cbec06a 100644
--- a/player/command.c
+++ b/player/command.c
@@ -5612,6 +5612,222 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
return 0;
}
+
+// This does not specify the real destination of the command parameter values,
+// it just provides a dummy for the OPT_ macros.
+#define OPT_BASE_STRUCT struct mp_cmd_arg
+#define ARG(t) "", v. t
+
+/* This array defines all known commands.
+ * The first field is an id used to recognize the command.
+ * The second is the command name used in slave mode and input.conf.
+ * Then comes the definition of each argument, first mandatory arguments
+ * (ARG_INT, ARG_FLOAT, ARG_STRING) if any, then optional arguments
+ * (OARG_INT(default), etc) if any. The command will be given the default
+ * argument value if the user didn't give enough arguments to specify it.
+ * A command can take a maximum of MP_CMD_DEF_MAX_ARGS arguments, or more
+ * if the command uses varargs.
+ */
+
+#define ARG_INT OPT_INT(ARG(i), 0)
+#define ARG_FLOAT OPT_FLOAT(ARG(f), 0)
+#define ARG_DOUBLE OPT_DOUBLE(ARG(d), 0)
+#define ARG_STRING OPT_STRING(ARG(s), 0)
+#define ARG_CHOICE(c) OPT_CHOICE(ARG(i), 0, c)
+#define ARG_CHOICE_OR_INT(...) OPT_CHOICE_OR_INT(ARG(i), 0, __VA_ARGS__)
+#define ARG_TIME OPT_TIME(ARG(d), 0)
+#define OARG_DOUBLE(def) OPT_DOUBLE(ARG(d), 0, OPTDEF_DOUBLE(def))
+#define OARG_INT(def) OPT_INT(ARG(i), 0, OPTDEF_INT(def))
+#define OARG_CHOICE(def, c) OPT_CHOICE(ARG(i), 0, c, OPTDEF_INT(def))
+#define OARG_FLAGS(def, c) OPT_FLAGS(ARG(i), 0, c, OPTDEF_INT(def))
+#define OARG_STRING(def) OPT_STRING(ARG(s), 0, OPTDEF_STR(def))
+
+#define OARG_CYCLEDIR(def) OPT_CYCLEDIR(ARG(d), 0, OPTDEF_DOUBLE(def))
+
+const struct mp_cmd_def mp_cmds[] = {
+ { MP_CMD_IGNORE, "ignore", },
+
+ { MP_CMD_SEEK, "seek", {
+ ARG_TIME,
+ OARG_FLAGS(4|0, ({"relative", 4|0}, {"-", 4|0},
+ {"absolute-percent", 4|1},
+ {"absolute", 4|2},
+ {"relative-percent", 4|3},
+ {"keyframes", 32|8},
+ {"exact", 32|16})),
+ // backwards compatibility only
+ OARG_CHOICE(0, ({"unused", 0}, {"default-precise", 0},
+ {"keyframes", 32|8},
+ {"exact", 32|16})),
+ },
+ .allow_auto_repeat = true,
+ .scalable = true,
+ },
+ { MP_CMD_REVERT_SEEK, "revert-seek", {
+ OARG_FLAGS(0, ({"mark", 1})),
+ }},
+ { MP_CMD_QUIT, "quit", { OARG_INT(0) } },
+ { MP_CMD_QUIT_WATCH_LATER, "quit-watch-later", { OARG_INT(0) } },
+ { MP_CMD_STOP, "stop", },
+ { MP_CMD_FRAME_STEP, "frame-step", .allow_auto_repeat = true,
+ .on_updown = true },
+ { MP_CMD_FRAME_BACK_STEP, "frame-back-step", .allow_auto_repeat = true },
+ { MP_CMD_PLAYLIST_NEXT, "playlist-next", {
+ OARG_CHOICE(0, ({"weak", 0},
+ {"force", 1})),
+ }},
+ { MP_CMD_PLAYLIST_PREV, "playlist-prev", {
+ OARG_CHOICE(0, ({"weak", 0},
+ {"force", 1})),
+ }},
+ { MP_CMD_PLAYLIST_SHUFFLE, "playlist-shuffle", },
+ { MP_CMD_SUB_STEP, "sub-step", { ARG_INT }, .allow_auto_repeat = true },
+ { MP_CMD_SUB_SEEK, "sub-seek", { ARG_INT }, .allow_auto_repeat = true },
+ { MP_CMD_PRINT_TEXT, "print-text", { ARG_STRING }, .allow_auto_repeat = true },
+ { MP_CMD_SHOW_TEXT, "show-text", { ARG_STRING, OARG_INT(-1), OARG_INT(0) },
+ .allow_auto_repeat = true},
+ { MP_CMD_EXPAND_TEXT, "expand-text", { ARG_STRING } },
+ { MP_CMD_SHOW_PROGRESS, "show-progress", .allow_auto_repeat = true},
+ { MP_CMD_SUB_ADD, "sub-add", { ARG_STRING,
+ OARG_CHOICE(0, ({"select", 0}, {"auto", 1}, {"cached", 2})),
+ OARG_STRING(""), OARG_STRING("") } },
+ { MP_CMD_SUB_REMOVE, "sub-remove", { OARG_INT(-1) } },
+ { MP_CMD_SUB_RELOAD, "sub-reload", { OARG_INT(-1) } },
+
+ { MP_CMD_TV_LAST_CHANNEL, "tv-last-channel", },
+
+ { MP_CMD_SCREENSHOT, "screenshot", {
+ OARG_FLAGS(4|2, ({"video", 4|0}, {"-", 4|0},
+ {"window", 4|1},
+ {"subtitles", 4|2},
+ {"each-frame", 8})),
+ // backwards compatibility
+ OARG_CHOICE(0, ({"unused", 0}, {"single", 0},
+ {"each-frame", 8})),
+ }},
+ { MP_CMD_SCREENSHOT_TO_FILE, "screenshot-to-file", {
+ ARG_STRING,
+ OARG_CHOICE(2, ({"video", 0},
+ {"window", 1},
+ {"subtitles", 2})),
+ }},
+ { MP_CMD_SCREENSHOT_RAW, "screenshot-raw", {
+ OARG_CHOICE(2, ({"video", 0},
+ {"window", 1},
+ {"subtitles", 2})),
+ }},
+ { MP_CMD_LOADFILE, "loadfile", {
+ ARG_STRING,
+ OARG_CHOICE(0, ({"replace", 0},
+ {"append", 1},
+ {"append-play", 2})),
+ OPT_KEYVALUELIST(ARG(str_list), MP_CMD_OPT_ARG),
+ }},
+ { MP_CMD_LOADLIST, "loadlist", {
+ ARG_STRING,
+ OARG_CHOICE(0, ({"replace", 0},
+ {"append", 1})),
+ }},
+ { MP_CMD_PLAYLIST_CLEAR, "playlist-clear", },
+ { MP_CMD_PLAYLIST_REMOVE, "playlist-remove", {
+ ARG_CHOICE_OR_INT(0, INT_MAX, ({"current", -1})),
+ }},
+ { MP_CMD_PLAYLIST_MOVE, "playlist-move", { ARG_INT, ARG_INT } },
+ { MP_CMD_RUN, "run", { ARG_STRING, ARG_STRING }, .vararg = true },
+
+ { MP_CMD_SET, "set", { ARG_STRING, ARG_STRING } },
+ { MP_CMD_CHANGE_LIST, "change-list", { ARG_STRING, ARG_STRING, ARG_STRING } },
+ { MP_CMD_ADD, "add", { ARG_STRING, OARG_DOUBLE(1) },
+ .allow_auto_repeat = true,
+ .scalable = true,
+ },
+ { MP_CMD_CYCLE, "cycle", {
+ ARG_STRING,
+ OARG_CYCLEDIR(1),
+ },
+ .allow_auto_repeat = true,
+ .scalable = true,
+ },
+ { MP_CMD_MULTIPLY, "multiply", { ARG_STRING, ARG_DOUBLE },
+ .allow_auto_repeat = true},
+
+ { MP_CMD_CYCLE_VALUES, "cycle-values", { ARG_STRING, ARG_STRING, ARG_STRING },
+ .vararg = true},
+
+ { MP_CMD_ENABLE_INPUT_SECTION, "enable-section", {
+ ARG_STRING,
+ OARG_FLAGS(0, ({"default", 0},
+ {"exclusive", MP_INPUT_EXCLUSIVE},
+ {"allow-hide-cursor", MP_INPUT_ALLOW_HIDE_CURSOR},
+ {"allow-vo-dragging", MP_INPUT_ALLOW_VO_DRAGGING})),
+ }},
+ { MP_CMD_DISABLE_INPUT_SECTION, "disable-section", { ARG_STRING } },
+ { MP_CMD_DEFINE_INPUT_SECTION, "define-section", {
+ ARG_STRING,
+ ARG_STRING,
+ OARG_CHOICE(1, ({"default", 1},
+ {"force", 0})),
+ }},
+
+ { MP_CMD_AB_LOOP, "ab-loop", },
+
+ { MP_CMD_DROP_BUFFERS, "drop-buffers", },
+
+ { MP_CMD_AF, "af", { ARG_STRING, ARG_STRING } },
+ { MP_CMD_AF_COMMAND, "af-command", { ARG_STRING, ARG_STRING, ARG_STRING } },
+ { MP_CMD_AO_RELOAD, "ao-reload", },
+
+ { MP_CMD_VF, "vf", { ARG_STRING, ARG_STRING } },
+ { MP_CMD_VF_COMMAND, "vf-command", { ARG_STRING, ARG_STRING, ARG_STRING } },
+
+ { MP_CMD_SCRIPT_BINDING, "script-binding", { ARG_STRING },
+ .allow_auto_repeat = true, .on_updown = true},
+
+ { MP_CMD_SCRIPT_MESSAGE, "script-message", { ARG_STRING }, .vararg = true },
+ { MP_CMD_SCRIPT_MESSAGE_TO, "script-message-to", { ARG_STRING, ARG_STRING },
+ .vararg = true },
+
+ { MP_CMD_OVERLAY_ADD, "overlay-add",
+ { ARG_INT, ARG_INT, ARG_INT, ARG_STRING, ARG_INT, ARG_STRING, ARG_INT,
+ ARG_INT, ARG_INT }},
+ { MP_CMD_OVERLAY_REMOVE, "overlay-remove", { ARG_INT } },
+
+ { MP_CMD_WRITE_WATCH_LATER_CONFIG, "write-watch-later-config", },
+
+ { MP_CMD_HOOK_ADD, "hook-add", { ARG_STRING, ARG_INT, ARG_INT } },
+ { MP_CMD_HOOK_ACK, "hook-ack", { ARG_INT } },
+
+ { MP_CMD_MOUSE, "mouse", {
+ ARG_INT, ARG_INT, // coordinate (x, y)
+ OARG_INT(-1), // button number
+ OARG_CHOICE(0, ({"single", 0},
+ {"double", 1})),
+ }},
+ { MP_CMD_KEYPRESS, "keypress", { ARG_STRING } },
+ { MP_CMD_KEYDOWN, "keydown", { ARG_STRING } },
+ { MP_CMD_KEYUP, "keyup", { OARG_STRING("") } },
+
+ { MP_CMD_AUDIO_ADD, "audio-add", { ARG_STRING,
+ OARG_CHOICE(0, ({"select", 0}, {"auto", 1}, {"cached", 2})),
+ OARG_STRING(""), OARG_STRING("") } },
+ { MP_CMD_AUDIO_REMOVE, "audio-remove", { OARG_INT(-1) } },
+ { MP_CMD_AUDIO_RELOAD, "audio-reload", { OARG_INT(-1) } },
+
+ { MP_CMD_RESCAN_EXTERNAL_FILES, "rescan-external-files", {
+ OARG_CHOICE(1, ({"keep-selection", 0},
+ {"reselect", 1})),
+ }},
+
+ { MP_CMD_APPLY_PROFILE, "apply-profile", {ARG_STRING } },
+
+ { MP_CMD_LOAD_SCRIPT, "load-script", {ARG_STRING} },
+
+ {0}
+};
+
+#undef OPT_BASE_STRUCT
+#undef ARG
+
void command_uninit(struct MPContext *mpctx)
{
overlay_uninit(mpctx);