2013-12-26 16:10:35 +00:00
|
|
|
/*
|
2015-04-13 07:36:54 +00:00
|
|
|
* This file is part of mpv.
|
2013-12-26 16:10:35 +00:00
|
|
|
*
|
input: change license to LGPL
cehoyos adds the step_property command in 7a71da01d, and it could be
argued that copyright of this still applies to the later add/cycle
commands (a668ae0ff90c4). While I'm not sure if this is really the case,
stay conservative for now and mark these commands as GPL-only. Mark the
command.c code too, although that is not being relicensed yet.
I'm leaving the MP_CMD_* enum items, as they are obviously different.
In commit 116ca0c7682, "veal" (essentially an anonymous author) adds an
"osd_show_property_text" command (well, the commit message says "based
on" that person's code, so it's not clear how much is from him or from
albeu, who agreed to LGPL). This was later merged again with the
"osd_show_text" command, and then all original code was removed in
commit 58cc0f637f, so I claim that no copyright applies anymore. (Though
technically the input.conf addition still might be copyrighted, so I'm
just dropping it to get rid of the thought.)
"kiriuja" added 2f376d1b39 (sub_load etc.) and be54f4813 (switch_audio).
The latter is gone. I would argue that the former is fully rewritten
with commits b7052b431c9 and 0f155921b0. But like in the step_property
case, I will be overly conservative for now, and mark them as GPL-only,
as this is potentially shaky and should be thought through first. (Not
bothering with the command define/enum in the header, as it will be
unused in LGPL mode anyway.)
keycodes.c/h can be GPL, except for commit 2b1f95dcc2f8, which is a
patch by someone who wasn't asked yet. Before doing something radical, I
will wait for a reply.
2017-06-19 11:02:35 +00:00
|
|
|
* mpv is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2013-12-26 16:10:35 +00:00
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* mpv is distributed in the hope that it will be useful,
|
2013-12-26 16:10:35 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
input: change license to LGPL
cehoyos adds the step_property command in 7a71da01d, and it could be
argued that copyright of this still applies to the later add/cycle
commands (a668ae0ff90c4). While I'm not sure if this is really the case,
stay conservative for now and mark these commands as GPL-only. Mark the
command.c code too, although that is not being relicensed yet.
I'm leaving the MP_CMD_* enum items, as they are obviously different.
In commit 116ca0c7682, "veal" (essentially an anonymous author) adds an
"osd_show_property_text" command (well, the commit message says "based
on" that person's code, so it's not clear how much is from him or from
albeu, who agreed to LGPL). This was later merged again with the
"osd_show_text" command, and then all original code was removed in
commit 58cc0f637f, so I claim that no copyright applies anymore. (Though
technically the input.conf addition still might be copyrighted, so I'm
just dropping it to get rid of the thought.)
"kiriuja" added 2f376d1b39 (sub_load etc.) and be54f4813 (switch_audio).
The latter is gone. I would argue that the former is fully rewritten
with commits b7052b431c9 and 0f155921b0. But like in the step_property
case, I will be overly conservative for now, and mark them as GPL-only,
as this is potentially shaky and should be thought through first. (Not
bothering with the command define/enum in the header, as it will be
unused in LGPL mode anyway.)
keycodes.c/h can be GPL, except for commit 2b1f95dcc2f8, which is a
patch by someone who wasn't asked yet. Before doing something radical, I
will wait for a reply.
2017-06-19 11:02:35 +00:00
|
|
|
* GNU Lesser General Public License for more details.
|
2013-12-26 16:10:35 +00:00
|
|
|
*
|
input: change license to LGPL
cehoyos adds the step_property command in 7a71da01d, and it could be
argued that copyright of this still applies to the later add/cycle
commands (a668ae0ff90c4). While I'm not sure if this is really the case,
stay conservative for now and mark these commands as GPL-only. Mark the
command.c code too, although that is not being relicensed yet.
I'm leaving the MP_CMD_* enum items, as they are obviously different.
In commit 116ca0c7682, "veal" (essentially an anonymous author) adds an
"osd_show_property_text" command (well, the commit message says "based
on" that person's code, so it's not clear how much is from him or from
albeu, who agreed to LGPL). This was later merged again with the
"osd_show_text" command, and then all original code was removed in
commit 58cc0f637f, so I claim that no copyright applies anymore. (Though
technically the input.conf addition still might be copyrighted, so I'm
just dropping it to get rid of the thought.)
"kiriuja" added 2f376d1b39 (sub_load etc.) and be54f4813 (switch_audio).
The latter is gone. I would argue that the former is fully rewritten
with commits b7052b431c9 and 0f155921b0. But like in the step_property
case, I will be overly conservative for now, and mark them as GPL-only,
as this is potentially shaky and should be thought through first. (Not
bothering with the command define/enum in the header, as it will be
unused in LGPL mode anyway.)
keycodes.c/h can be GPL, except for commit 2b1f95dcc2f8, which is a
patch by someone who wasn't asked yet. Before doing something radical, I
will wait for a reply.
2017-06-19 11:02:35 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
2017-06-20 08:14:48 +00:00
|
|
|
*
|
|
|
|
* Parts under HAVE_GPL are licensed under GNU General Public License.
|
2013-12-26 16:10:35 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <limits.h>
|
|
|
|
|
input: change license to LGPL
cehoyos adds the step_property command in 7a71da01d, and it could be
argued that copyright of this still applies to the later add/cycle
commands (a668ae0ff90c4). While I'm not sure if this is really the case,
stay conservative for now and mark these commands as GPL-only. Mark the
command.c code too, although that is not being relicensed yet.
I'm leaving the MP_CMD_* enum items, as they are obviously different.
In commit 116ca0c7682, "veal" (essentially an anonymous author) adds an
"osd_show_property_text" command (well, the commit message says "based
on" that person's code, so it's not clear how much is from him or from
albeu, who agreed to LGPL). This was later merged again with the
"osd_show_text" command, and then all original code was removed in
commit 58cc0f637f, so I claim that no copyright applies anymore. (Though
technically the input.conf addition still might be copyrighted, so I'm
just dropping it to get rid of the thought.)
"kiriuja" added 2f376d1b39 (sub_load etc.) and be54f4813 (switch_audio).
The latter is gone. I would argue that the former is fully rewritten
with commits b7052b431c9 and 0f155921b0. But like in the step_property
case, I will be overly conservative for now, and mark them as GPL-only,
as this is potentially shaky and should be thought through first. (Not
bothering with the command define/enum in the header, as it will be
unused in LGPL mode anyway.)
keycodes.c/h can be GPL, except for commit 2b1f95dcc2f8, which is a
patch by someone who wasn't asked yet. Before doing something radical, I
will wait for a reply.
2017-06-19 11:02:35 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2013-12-26 16:10:35 +00:00
|
|
|
#include "common/common.h"
|
|
|
|
#include "common/msg.h"
|
|
|
|
#include "options/m_option.h"
|
|
|
|
|
|
|
|
#include "input.h"
|
|
|
|
#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_MAX_ARGS arguments.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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))
|
2015-03-04 16:21:02 +00:00
|
|
|
#define OARG_FLAGS(def, c) OPT_FLAGS(ARG(i), 0, c, OPTDEF_INT(def))
|
2014-10-22 05:58:38 +00:00
|
|
|
#define OARG_STRING(def) OPT_STRING(ARG(s), 0, OPTDEF_STR(def))
|
2013-12-26 16:10:35 +00:00
|
|
|
|
|
|
|
#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,
|
2015-03-04 16:21:02 +00:00
|
|
|
OARG_FLAGS(4|0, ({"relative", 4|0}, {"-", 4|0},
|
|
|
|
{"absolute-percent", 4|1},
|
|
|
|
{"absolute", 4|2},
|
2015-05-18 20:56:56 +00:00
|
|
|
{"relative-percent", 4|3},
|
2015-03-04 16:21:02 +00:00
|
|
|
{"keyframes", 32|8},
|
|
|
|
{"exact", 32|16})),
|
|
|
|
// backwards compatibility only
|
|
|
|
OARG_CHOICE(0, ({"unused", 0}, {"default-precise", 0},
|
|
|
|
{"keyframes", 32|8},
|
|
|
|
{"exact", 32|16})),
|
2013-12-26 16:10:35 +00:00
|
|
|
},
|
|
|
|
.allow_auto_repeat = true,
|
2017-04-24 12:04:25 +00:00
|
|
|
.scalable = true,
|
2013-12-26 16:10:35 +00:00
|
|
|
},
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_REVERT_SEEK, "revert-seek", {
|
2015-03-04 16:21:02 +00:00
|
|
|
OARG_FLAGS(0, ({"mark", 1})),
|
2014-12-17 21:56:45 +00:00
|
|
|
}},
|
2015-07-11 18:07:58 +00:00
|
|
|
{ MP_CMD_QUIT, "quit", { OARG_INT(0) } },
|
|
|
|
{ MP_CMD_QUIT_WATCH_LATER, "quit-watch-later", { OARG_INT(0) } },
|
2013-12-26 16:10:35 +00:00
|
|
|
{ MP_CMD_STOP, "stop", },
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_FRAME_STEP, "frame-step", .allow_auto_repeat = true,
|
2014-11-24 15:48:34 +00:00
|
|
|
.on_updown = true },
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_FRAME_BACK_STEP, "frame-back-step", .allow_auto_repeat = true },
|
|
|
|
{ MP_CMD_PLAYLIST_NEXT, "playlist-next", {
|
2015-03-04 16:21:02 +00:00
|
|
|
OARG_CHOICE(0, ({"weak", 0},
|
2015-03-04 16:20:58 +00:00
|
|
|
{"force", 1})),
|
2013-12-26 16:10:35 +00:00
|
|
|
}},
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_PLAYLIST_PREV, "playlist-prev", {
|
2015-03-04 16:20:58 +00:00
|
|
|
OARG_CHOICE(0, ({"weak", 0},
|
|
|
|
{"force", 1})),
|
2013-12-26 16:10:35 +00:00
|
|
|
}},
|
2015-05-25 19:59:44 +00:00
|
|
|
{ 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 },
|
2017-06-23 12:27:53 +00:00
|
|
|
#if HAVE_GPL
|
2013-12-26 16:10:35 +00:00
|
|
|
{ MP_CMD_OSD, "osd", { OARG_INT(-1) } },
|
2017-06-23 12:27:53 +00:00
|
|
|
#endif
|
2015-05-25 19:59:44 +00:00
|
|
|
{ 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) },
|
2013-12-26 16:10:35 +00:00
|
|
|
.allow_auto_repeat = true},
|
2017-03-26 17:29:10 +00:00
|
|
|
{ MP_CMD_EXPAND_TEXT, "expand-text", { ARG_STRING } },
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_SHOW_PROGRESS, "show-progress", .allow_auto_repeat = true},
|
input: change license to LGPL
cehoyos adds the step_property command in 7a71da01d, and it could be
argued that copyright of this still applies to the later add/cycle
commands (a668ae0ff90c4). While I'm not sure if this is really the case,
stay conservative for now and mark these commands as GPL-only. Mark the
command.c code too, although that is not being relicensed yet.
I'm leaving the MP_CMD_* enum items, as they are obviously different.
In commit 116ca0c7682, "veal" (essentially an anonymous author) adds an
"osd_show_property_text" command (well, the commit message says "based
on" that person's code, so it's not clear how much is from him or from
albeu, who agreed to LGPL). This was later merged again with the
"osd_show_text" command, and then all original code was removed in
commit 58cc0f637f, so I claim that no copyright applies anymore. (Though
technically the input.conf addition still might be copyrighted, so I'm
just dropping it to get rid of the thought.)
"kiriuja" added 2f376d1b39 (sub_load etc.) and be54f4813 (switch_audio).
The latter is gone. I would argue that the former is fully rewritten
with commits b7052b431c9 and 0f155921b0. But like in the step_property
case, I will be overly conservative for now, and mark them as GPL-only,
as this is potentially shaky and should be thought through first. (Not
bothering with the command define/enum in the header, as it will be
unused in LGPL mode anyway.)
keycodes.c/h can be GPL, except for commit 2b1f95dcc2f8, which is a
patch by someone who wasn't asked yet. Before doing something radical, I
will wait for a reply.
2017-06-19 11:02:35 +00:00
|
|
|
#if HAVE_GPL
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_SUB_ADD, "sub-add", { ARG_STRING,
|
2014-10-23 11:11:41 +00:00
|
|
|
OARG_CHOICE(0, ({"select", 0}, {"auto", 1}, {"cached", 2})),
|
2014-10-22 05:58:38 +00:00
|
|
|
OARG_STRING(""), OARG_STRING("") } },
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_SUB_REMOVE, "sub-remove", { OARG_INT(-1) } },
|
input: change license to LGPL
cehoyos adds the step_property command in 7a71da01d, and it could be
argued that copyright of this still applies to the later add/cycle
commands (a668ae0ff90c4). While I'm not sure if this is really the case,
stay conservative for now and mark these commands as GPL-only. Mark the
command.c code too, although that is not being relicensed yet.
I'm leaving the MP_CMD_* enum items, as they are obviously different.
In commit 116ca0c7682, "veal" (essentially an anonymous author) adds an
"osd_show_property_text" command (well, the commit message says "based
on" that person's code, so it's not clear how much is from him or from
albeu, who agreed to LGPL). This was later merged again with the
"osd_show_text" command, and then all original code was removed in
commit 58cc0f637f, so I claim that no copyright applies anymore. (Though
technically the input.conf addition still might be copyrighted, so I'm
just dropping it to get rid of the thought.)
"kiriuja" added 2f376d1b39 (sub_load etc.) and be54f4813 (switch_audio).
The latter is gone. I would argue that the former is fully rewritten
with commits b7052b431c9 and 0f155921b0. But like in the step_property
case, I will be overly conservative for now, and mark them as GPL-only,
as this is potentially shaky and should be thought through first. (Not
bothering with the command define/enum in the header, as it will be
unused in LGPL mode anyway.)
keycodes.c/h can be GPL, except for commit 2b1f95dcc2f8, which is a
patch by someone who wasn't asked yet. Before doing something radical, I
will wait for a reply.
2017-06-19 11:02:35 +00:00
|
|
|
#endif
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_SUB_RELOAD, "sub-reload", { OARG_INT(-1) } },
|
2013-12-26 16:10:35 +00:00
|
|
|
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_TV_LAST_CHANNEL, "tv-last-channel", },
|
2013-12-26 16:10:35 +00:00
|
|
|
|
|
|
|
{ MP_CMD_SCREENSHOT, "screenshot", {
|
2015-03-04 16:21:02 +00:00
|
|
|
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})),
|
2013-12-26 16:10:35 +00:00
|
|
|
}},
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_SCREENSHOT_TO_FILE, "screenshot-to-file", {
|
2013-12-26 16:10:35 +00:00
|
|
|
ARG_STRING,
|
|
|
|
OARG_CHOICE(2, ({"video", 0},
|
|
|
|
{"window", 1},
|
|
|
|
{"subtitles", 2})),
|
|
|
|
}},
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_SCREENSHOT_RAW, "screenshot-raw", {
|
2015-04-20 21:11:03 +00:00
|
|
|
OARG_CHOICE(2, ({"video", 0},
|
|
|
|
{"window", 1},
|
|
|
|
{"subtitles", 2})),
|
|
|
|
}},
|
2013-12-26 16:10:35 +00:00
|
|
|
{ MP_CMD_LOADFILE, "loadfile", {
|
|
|
|
ARG_STRING,
|
2015-03-04 16:20:58 +00:00
|
|
|
OARG_CHOICE(0, ({"replace", 0},
|
|
|
|
{"append", 1},
|
2014-07-22 22:20:53 +00:00
|
|
|
{"append-play", 2})),
|
2014-02-24 22:02:20 +00:00
|
|
|
OPT_KEYVALUELIST(ARG(str_list), MP_CMD_OPT_ARG),
|
2013-12-26 16:10:35 +00:00
|
|
|
}},
|
|
|
|
{ MP_CMD_LOADLIST, "loadlist", {
|
|
|
|
ARG_STRING,
|
2015-03-04 16:20:58 +00:00
|
|
|
OARG_CHOICE(0, ({"replace", 0},
|
|
|
|
{"append", 1})),
|
2013-12-26 16:10:35 +00:00
|
|
|
}},
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_PLAYLIST_CLEAR, "playlist-clear", },
|
|
|
|
{ MP_CMD_PLAYLIST_REMOVE, "playlist-remove", {
|
2013-12-26 16:10:35 +00:00
|
|
|
ARG_CHOICE_OR_INT(0, INT_MAX, ({"current", -1})),
|
|
|
|
}},
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_PLAYLIST_MOVE, "playlist-move", { ARG_INT, ARG_INT } },
|
2013-12-26 16:10:35 +00:00
|
|
|
{ MP_CMD_RUN, "run", { ARG_STRING, ARG_STRING }, .vararg = true },
|
|
|
|
|
|
|
|
{ MP_CMD_SET, "set", { ARG_STRING, ARG_STRING } },
|
input: change license to LGPL
cehoyos adds the step_property command in 7a71da01d, and it could be
argued that copyright of this still applies to the later add/cycle
commands (a668ae0ff90c4). While I'm not sure if this is really the case,
stay conservative for now and mark these commands as GPL-only. Mark the
command.c code too, although that is not being relicensed yet.
I'm leaving the MP_CMD_* enum items, as they are obviously different.
In commit 116ca0c7682, "veal" (essentially an anonymous author) adds an
"osd_show_property_text" command (well, the commit message says "based
on" that person's code, so it's not clear how much is from him or from
albeu, who agreed to LGPL). This was later merged again with the
"osd_show_text" command, and then all original code was removed in
commit 58cc0f637f, so I claim that no copyright applies anymore. (Though
technically the input.conf addition still might be copyrighted, so I'm
just dropping it to get rid of the thought.)
"kiriuja" added 2f376d1b39 (sub_load etc.) and be54f4813 (switch_audio).
The latter is gone. I would argue that the former is fully rewritten
with commits b7052b431c9 and 0f155921b0. But like in the step_property
case, I will be overly conservative for now, and mark them as GPL-only,
as this is potentially shaky and should be thought through first. (Not
bothering with the command define/enum in the header, as it will be
unused in LGPL mode anyway.)
keycodes.c/h can be GPL, except for commit 2b1f95dcc2f8, which is a
patch by someone who wasn't asked yet. Before doing something radical, I
will wait for a reply.
2017-06-19 11:02:35 +00:00
|
|
|
#if HAVE_GPL
|
2015-09-10 12:15:12 +00:00
|
|
|
{ MP_CMD_ADD, "add", { ARG_STRING, OARG_DOUBLE(1) },
|
2017-04-24 12:04:25 +00:00
|
|
|
.allow_auto_repeat = true,
|
|
|
|
.scalable = true,
|
|
|
|
},
|
2013-12-26 16:10:35 +00:00
|
|
|
{ MP_CMD_CYCLE, "cycle", {
|
|
|
|
ARG_STRING,
|
|
|
|
OARG_CYCLEDIR(1),
|
|
|
|
},
|
2017-04-24 12:04:25 +00:00
|
|
|
.allow_auto_repeat = true,
|
|
|
|
.scalable = true,
|
2013-12-26 16:10:35 +00:00
|
|
|
},
|
input: change license to LGPL
cehoyos adds the step_property command in 7a71da01d, and it could be
argued that copyright of this still applies to the later add/cycle
commands (a668ae0ff90c4). While I'm not sure if this is really the case,
stay conservative for now and mark these commands as GPL-only. Mark the
command.c code too, although that is not being relicensed yet.
I'm leaving the MP_CMD_* enum items, as they are obviously different.
In commit 116ca0c7682, "veal" (essentially an anonymous author) adds an
"osd_show_property_text" command (well, the commit message says "based
on" that person's code, so it's not clear how much is from him or from
albeu, who agreed to LGPL). This was later merged again with the
"osd_show_text" command, and then all original code was removed in
commit 58cc0f637f, so I claim that no copyright applies anymore. (Though
technically the input.conf addition still might be copyrighted, so I'm
just dropping it to get rid of the thought.)
"kiriuja" added 2f376d1b39 (sub_load etc.) and be54f4813 (switch_audio).
The latter is gone. I would argue that the former is fully rewritten
with commits b7052b431c9 and 0f155921b0. But like in the step_property
case, I will be overly conservative for now, and mark them as GPL-only,
as this is potentially shaky and should be thought through first. (Not
bothering with the command define/enum in the header, as it will be
unused in LGPL mode anyway.)
keycodes.c/h can be GPL, except for commit 2b1f95dcc2f8, which is a
patch by someone who wasn't asked yet. Before doing something radical, I
will wait for a reply.
2017-06-19 11:02:35 +00:00
|
|
|
#endif
|
2013-12-26 16:10:35 +00:00
|
|
|
{ MP_CMD_MULTIPLY, "multiply", { ARG_STRING, ARG_DOUBLE },
|
|
|
|
.allow_auto_repeat = true},
|
|
|
|
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_CYCLE_VALUES, "cycle-values", { ARG_STRING, ARG_STRING, ARG_STRING },
|
2014-09-12 23:10:58 +00:00
|
|
|
.vararg = true},
|
2013-12-26 16:10:35 +00:00
|
|
|
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_ENABLE_INPUT_SECTION, "enable-section", {
|
2013-12-26 16:10:35 +00:00
|
|
|
ARG_STRING,
|
2015-08-05 22:31:47 +00:00
|
|
|
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})),
|
2013-12-26 16:10:35 +00:00
|
|
|
}},
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_DISABLE_INPUT_SECTION, "disable-section", { ARG_STRING } },
|
2015-08-05 21:55:16 +00:00
|
|
|
{ MP_CMD_DEFINE_INPUT_SECTION, "define-section", {
|
|
|
|
ARG_STRING,
|
|
|
|
ARG_STRING,
|
|
|
|
OARG_CHOICE(1, ({"default", 1},
|
|
|
|
{"force", 0})),
|
|
|
|
}},
|
2013-12-26 16:10:35 +00:00
|
|
|
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_AB_LOOP, "ab-loop", },
|
2014-11-18 20:33:15 +00:00
|
|
|
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_DROP_BUFFERS, "drop-buffers", },
|
2014-11-20 21:41:50 +00:00
|
|
|
|
2013-12-26 16:10:35 +00:00
|
|
|
{ MP_CMD_AF, "af", { ARG_STRING, ARG_STRING } },
|
2016-01-22 19:36:54 +00:00
|
|
|
{ MP_CMD_AF_COMMAND, "af-command", { ARG_STRING, ARG_STRING, ARG_STRING } },
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_AO_RELOAD, "ao-reload", },
|
2013-12-26 16:10:35 +00:00
|
|
|
|
|
|
|
{ MP_CMD_VF, "vf", { ARG_STRING, ARG_STRING } },
|
2016-01-22 15:18:28 +00:00
|
|
|
{ MP_CMD_VF_COMMAND, "vf-command", { ARG_STRING, ARG_STRING, ARG_STRING } },
|
2013-12-26 16:10:35 +00:00
|
|
|
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_SCRIPT_BINDING, "script-binding", { ARG_STRING },
|
2014-11-24 15:48:34 +00:00
|
|
|
.allow_auto_repeat = true, .on_updown = true},
|
2014-11-24 15:47:03 +00:00
|
|
|
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_SCRIPT_MESSAGE, "script-message", { ARG_STRING }, .vararg = true },
|
|
|
|
{ MP_CMD_SCRIPT_MESSAGE_TO, "script-message-to", { ARG_STRING, ARG_STRING },
|
2014-02-17 01:33:47 +00:00
|
|
|
.vararg = true },
|
2013-12-26 16:10:35 +00:00
|
|
|
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_OVERLAY_ADD, "overlay-add",
|
2013-12-26 16:10:35 +00:00
|
|
|
{ ARG_INT, ARG_INT, ARG_INT, ARG_STRING, ARG_INT, ARG_STRING, ARG_INT,
|
|
|
|
ARG_INT, ARG_INT }},
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_OVERLAY_REMOVE, "overlay-remove", { ARG_INT } },
|
2013-12-26 16:10:35 +00:00
|
|
|
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_WRITE_WATCH_LATER_CONFIG, "write-watch-later-config", },
|
2014-05-26 16:11:02 +00:00
|
|
|
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_HOOK_ADD, "hook-add", { ARG_STRING, ARG_INT, ARG_INT } },
|
|
|
|
{ MP_CMD_HOOK_ACK, "hook-ack", { ARG_STRING } },
|
command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.
Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:
-- type ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
-- param is "0", the user-chosen ID from the hook_add command
-- param2 is the magic value that has to be passed to finish
-- the hook
mp.resume_all()
-- do something, maybe set options that are reset on end:
mp.set_property("file-local-options/name", "value")
-- or change the URL that's being opened:
local url = mp.get_property("stream-open-filename")
mp.set_property("stream-open-filename", url .. ".png")
-- let the player (or the next script) continue
mp.commandv("hook_ack", param2)
end)
2014-10-15 21:09:53 +00:00
|
|
|
|
2015-01-23 20:45:13 +00:00
|
|
|
{ MP_CMD_MOUSE, "mouse", {
|
|
|
|
ARG_INT, ARG_INT, // coordinate (x, y)
|
|
|
|
OARG_INT(-1), // button number
|
|
|
|
OARG_CHOICE(0, ({"single", 0},
|
|
|
|
{"double", 1})),
|
|
|
|
}},
|
2015-06-10 23:56:56 +00:00
|
|
|
{ MP_CMD_KEYPRESS, "keypress", { ARG_STRING } },
|
|
|
|
{ MP_CMD_KEYDOWN, "keydown", { ARG_STRING } },
|
|
|
|
{ MP_CMD_KEYUP, "keyup", { OARG_STRING("") } },
|
2015-01-23 20:45:13 +00:00
|
|
|
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_AUDIO_ADD, "audio-add", { ARG_STRING,
|
2015-02-03 08:15:14 +00:00
|
|
|
OARG_CHOICE(0, ({"select", 0}, {"auto", 1}, {"cached", 2})),
|
|
|
|
OARG_STRING(""), OARG_STRING("") } },
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_AUDIO_REMOVE, "audio-remove", { OARG_INT(-1) } },
|
|
|
|
{ MP_CMD_AUDIO_RELOAD, "audio-reload", { OARG_INT(-1) } },
|
2015-02-03 08:15:14 +00:00
|
|
|
|
2015-05-25 19:59:44 +00:00
|
|
|
{ MP_CMD_RESCAN_EXTERNAL_FILES, "rescan-external-files", {
|
2015-04-28 20:05:07 +00:00
|
|
|
OARG_CHOICE(1, ({"keep-selection", 0},
|
2015-02-16 21:06:41 +00:00
|
|
|
{"reselect", 1})),
|
|
|
|
}},
|
|
|
|
|
2016-09-17 19:01:59 +00:00
|
|
|
{ MP_CMD_APPLY_PROFILE, "apply-profile", {ARG_STRING } },
|
|
|
|
|
2016-09-22 18:43:33 +00:00
|
|
|
{ MP_CMD_LOAD_SCRIPT, "load-script", {ARG_STRING} },
|
|
|
|
|
2013-12-26 16:10:35 +00:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
#undef OPT_BASE_STRUCT
|
|
|
|
#undef ARG
|
|
|
|
|
|
|
|
// Map legacy commands to proper commands
|
|
|
|
struct legacy_cmd {
|
|
|
|
const char *old, *new;
|
|
|
|
};
|
|
|
|
static const struct legacy_cmd legacy_cmds[] = {
|
|
|
|
{"loop", "cycle loop"},
|
|
|
|
{"seek_chapter", "add chapter"},
|
|
|
|
{"switch_angle", "cycle angle"},
|
|
|
|
{"pause", "cycle pause"},
|
|
|
|
{"volume", "add volume"},
|
|
|
|
{"mute", "cycle mute"},
|
|
|
|
{"audio_delay", "add audio-delay"},
|
|
|
|
{"switch_audio", "cycle audio"},
|
|
|
|
{"balance", "add balance"},
|
|
|
|
{"vo_fullscreen", "cycle fullscreen"},
|
|
|
|
{"panscan", "add panscan"},
|
|
|
|
{"vo_ontop", "cycle ontop"},
|
|
|
|
{"vo_border", "cycle border"},
|
|
|
|
{"frame_drop", "cycle framedrop"},
|
|
|
|
{"gamma", "add gamma"},
|
|
|
|
{"brightness", "add brightness"},
|
|
|
|
{"contrast", "add contrast"},
|
|
|
|
{"saturation", "add saturation"},
|
|
|
|
{"hue", "add hue"},
|
|
|
|
{"switch_vsync", "cycle vsync"},
|
2016-07-14 18:04:59 +00:00
|
|
|
{"sub_load", "sub-add"},
|
2013-12-26 16:10:35 +00:00
|
|
|
{"sub_select", "cycle sub"},
|
|
|
|
{"sub_pos", "add sub-pos"},
|
|
|
|
{"sub_delay", "add sub-delay"},
|
|
|
|
{"sub_visibility", "cycle sub-visibility"},
|
|
|
|
{"forced_subs_only", "cycle sub-forced-only"},
|
|
|
|
{"sub_scale", "add sub-scale"},
|
|
|
|
{"ass_use_margins", "cycle ass-use-margins"},
|
|
|
|
{"tv_set_brightness", "add tv-brightness"},
|
|
|
|
{"tv_set_hue", "add tv-hue"},
|
|
|
|
{"tv_set_saturation", "add tv-saturation"},
|
|
|
|
{"tv_set_contrast", "add tv-contrast"},
|
|
|
|
{"step_property_osd", "cycle"},
|
|
|
|
{"step_property", "no-osd cycle"},
|
|
|
|
{"set_property", "no-osd set"},
|
|
|
|
{"set_property_osd", "set"},
|
|
|
|
{"speed_set", "set speed"},
|
2015-05-25 19:59:44 +00:00
|
|
|
{"osd_show_text", "show-text"},
|
|
|
|
{"osd_show_property_text", "show-text"},
|
|
|
|
{"osd_show_progression", "show-progress"},
|
|
|
|
{"show_chapters_osd", "show-text ${chapter-list}"},
|
|
|
|
{"show_chapters", "show-text ${chapter-list}"},
|
|
|
|
{"show_tracks_osd", "show-text ${track-list}"},
|
|
|
|
{"show_tracks", "show-text ${track-list}"},
|
|
|
|
{"show_playlist", "show-text ${playlist}"},
|
2013-12-26 16:10:35 +00:00
|
|
|
{"speed_mult", "multiply speed"},
|
|
|
|
|
|
|
|
// Approximate (can fail if user added additional whitespace)
|
2015-05-25 19:59:44 +00:00
|
|
|
{"pt_step 1", "playlist-next"},
|
|
|
|
{"pt_step -1", "playlist-prev"},
|
2013-12-26 16:10:35 +00:00
|
|
|
// Switch_ratio without argument resets aspect ratio
|
|
|
|
{"switch_ratio ", "set aspect "},
|
|
|
|
{"switch_ratio", "set aspect 0"},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
bool mp_replace_legacy_cmd(void *t, bstr *s)
|
|
|
|
{
|
|
|
|
for (const struct legacy_cmd *entry = legacy_cmds; entry->old; entry++) {
|
|
|
|
bstr old = bstr0(entry->old);
|
|
|
|
if (bstrcasecmp(bstr_splice(*s, 0, old.len), old) == 0) {
|
|
|
|
bstr rest = bstr_cut(*s, old.len);
|
|
|
|
*s = bstr0(talloc_asprintf(t, "%s%.*s", entry->new, BSTR_P(rest)));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-09-13 14:47:30 +00:00
|
|
|
// 0: no, 1: maybe, 2: sure
|
|
|
|
static int is_abort_cmd(struct mp_cmd *cmd)
|
2013-12-26 16:10:35 +00:00
|
|
|
{
|
2014-09-13 14:47:30 +00:00
|
|
|
switch (cmd->id) {
|
2013-12-26 16:10:35 +00:00
|
|
|
case MP_CMD_QUIT:
|
2014-09-13 12:10:10 +00:00
|
|
|
case MP_CMD_QUIT_WATCH_LATER:
|
|
|
|
case MP_CMD_STOP:
|
2014-09-13 14:47:30 +00:00
|
|
|
return 2;
|
2013-12-26 16:10:35 +00:00
|
|
|
case MP_CMD_PLAYLIST_NEXT:
|
|
|
|
case MP_CMD_PLAYLIST_PREV:
|
2014-09-13 14:47:30 +00:00
|
|
|
return 1;
|
|
|
|
case MP_CMD_COMMAND_LIST:;
|
|
|
|
int r = 0;
|
|
|
|
for (struct mp_cmd *sub = cmd->args[0].v.p; sub; sub = sub->queue_next) {
|
2014-09-13 16:41:34 +00:00
|
|
|
int x = is_abort_cmd(sub);
|
2014-09-13 14:47:30 +00:00
|
|
|
r = MPMAX(r, x);
|
|
|
|
}
|
|
|
|
return r;
|
2013-12-26 16:10:35 +00:00
|
|
|
}
|
2014-09-13 14:47:30 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool mp_input_is_maybe_abort_cmd(struct mp_cmd *cmd)
|
|
|
|
{
|
|
|
|
return is_abort_cmd(cmd) >= 1;
|
2013-12-26 16:10:35 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 12:38:39 +00:00
|
|
|
bool mp_input_is_abort_cmd(struct mp_cmd *cmd)
|
|
|
|
{
|
2014-09-13 14:47:30 +00:00
|
|
|
return is_abort_cmd(cmd) >= 2;
|
2014-02-20 12:38:39 +00:00
|
|
|
}
|
|
|
|
|
2014-05-26 19:49:14 +00:00
|
|
|
bool mp_input_is_repeatable_cmd(struct mp_cmd *cmd)
|
|
|
|
{
|
|
|
|
return (cmd->def && cmd->def->allow_auto_repeat) ||
|
2014-11-20 22:41:01 +00:00
|
|
|
cmd->id == MP_CMD_COMMAND_LIST ||
|
|
|
|
(cmd->flags & MP_ALLOW_REPEAT);
|
2014-05-26 19:49:14 +00:00
|
|
|
}
|
|
|
|
|
2017-04-24 12:04:25 +00:00
|
|
|
bool mp_input_is_scalable_cmd(struct mp_cmd *cmd)
|
|
|
|
{
|
|
|
|
return cmd->def && cmd->def->scalable;
|
|
|
|
}
|
|
|
|
|
2013-12-26 16:10:35 +00:00
|
|
|
void mp_print_cmd_list(struct mp_log *out)
|
|
|
|
{
|
|
|
|
for (int i = 0; mp_cmds[i].name; i++) {
|
|
|
|
const struct mp_cmd_def *def = &mp_cmds[i];
|
|
|
|
mp_info(out, "%-20.20s", def->name);
|
|
|
|
for (int j = 0; j < MP_CMD_MAX_ARGS && def->args[j].type; j++) {
|
|
|
|
const char *type = def->args[j].type->name;
|
|
|
|
if (def->args[j].defval)
|
|
|
|
mp_info(out, " [%s]", type);
|
|
|
|
else
|
|
|
|
mp_info(out, " %s", type);
|
|
|
|
}
|
|
|
|
mp_info(out, "\n");
|
|
|
|
}
|
|
|
|
}
|