mirror of
https://github.com/mpv-player/mpv
synced 2024-12-25 16:33:02 +00:00
commands: change input commands to make OSD usage explicit
Most input commands had their own policy whether to display an OSD message for user feedback or not. Some commands had two variants, one that showed an OSD message and one that didn't (e.g. step_property_osd and step_property). Change it such that all commands show a message on the OSD. Add a "no-osd" modifier that disables OSD for that command. Rename the "step_property" and "step_property_osd" command to "switch", and rename "set_property" and "set_property_osd" to "set". Note that commands which haven't used OSD before still don't use OSD. That will possibly be fixed later. (E.g. "screenshot" could display an OSD message instead of just printing a message on the terminal.) The chapter and edition properties still produce OSD messages even with "no-osd", because they don't map so well to the property_osd_display[] mechanism.
This commit is contained in:
parent
6096966dee
commit
a668ae0ff9
68
command.c
68
command.c
@ -558,7 +558,6 @@ static int mp_property_editions(m_option_t *prop, int action, void *arg,
|
|||||||
static int mp_property_angle(m_option_t *prop, int action, void *arg,
|
static int mp_property_angle(m_option_t *prop, int action, void *arg,
|
||||||
MPContext *mpctx)
|
MPContext *mpctx)
|
||||||
{
|
{
|
||||||
struct MPOpts *opts = &mpctx->opts;
|
|
||||||
struct demuxer *demuxer = mpctx->master_demuxer;
|
struct demuxer *demuxer = mpctx->master_demuxer;
|
||||||
int angle = -1;
|
int angle = -1;
|
||||||
int angles;
|
int angles;
|
||||||
@ -618,8 +617,6 @@ static int mp_property_angle(m_option_t *prop, int action, void *arg,
|
|||||||
resync_audio_stream(sh_audio);
|
resync_audio_stream(sh_audio);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_osd_tmsg(mpctx, OSD_MSG_TEXT, 1, opts->osd_duration,
|
|
||||||
"Angle: %d/%d", angle, angles);
|
|
||||||
return M_PROPERTY_OK;
|
return M_PROPERTY_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1897,6 +1894,7 @@ static struct property_osd_display {
|
|||||||
{ "saturation", _("Saturation"), .osd_progbar = OSD_SATURATION },
|
{ "saturation", _("Saturation"), .osd_progbar = OSD_SATURATION },
|
||||||
{ "hue", _("Hue"), .osd_progbar = OSD_HUE },
|
{ "hue", _("Hue"), .osd_progbar = OSD_HUE },
|
||||||
{ "vsync", _("VSync: %s") },
|
{ "vsync", _("VSync: %s") },
|
||||||
|
{ "angle", _("Angle: %s") },
|
||||||
// subs
|
// subs
|
||||||
{ "sub", _("Subtitles: %s") },
|
{ "sub", _("Subtitles: %s") },
|
||||||
{ "sub_pos", _("Sub position: %s/100") },
|
{ "sub_pos", _("Sub position: %s/100") },
|
||||||
@ -2065,31 +2063,32 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
|||||||
sh_audio_t *const sh_audio = mpctx->sh_audio;
|
sh_audio_t *const sh_audio = mpctx->sh_audio;
|
||||||
sh_video_t *const sh_video = mpctx->sh_video;
|
sh_video_t *const sh_video = mpctx->sh_video;
|
||||||
int osd_duration = opts->osd_duration;
|
int osd_duration = opts->osd_duration;
|
||||||
|
int osdl = cmd->on_osd ? 1 : OSD_LEVEL_INVISIBLE;
|
||||||
int case_fallthrough_hack = 0;
|
int case_fallthrough_hack = 0;
|
||||||
switch (cmd->id) {
|
switch (cmd->id) {
|
||||||
case MP_CMD_SEEK: {
|
case MP_CMD_SEEK: {
|
||||||
mpctx->add_osd_seek_info = true;
|
|
||||||
float v = cmd->args[0].v.f;
|
float v = cmd->args[0].v.f;
|
||||||
int abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0;
|
int abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0;
|
||||||
int exact = (cmd->nargs > 2) ? cmd->args[2].v.i : 0;
|
int exact = (cmd->nargs > 2) ? cmd->args[2].v.i : 0;
|
||||||
|
int function;
|
||||||
if (abs == 2) { // Absolute seek to a timestamp in seconds
|
if (abs == 2) { // Absolute seek to a timestamp in seconds
|
||||||
queue_seek(mpctx, MPSEEK_ABSOLUTE, v, exact);
|
queue_seek(mpctx, MPSEEK_ABSOLUTE, v, exact);
|
||||||
mpctx->osd_function = v > get_current_time(mpctx) ?
|
function = v > get_current_time(mpctx) ? OSD_FFW : OSD_REW;
|
||||||
OSD_FFW : OSD_REW;
|
|
||||||
} else if (abs) { /* Absolute seek by percentage */
|
} else if (abs) { /* Absolute seek by percentage */
|
||||||
queue_seek(mpctx, MPSEEK_FACTOR, v / 100.0, exact);
|
queue_seek(mpctx, MPSEEK_FACTOR, v / 100.0, exact);
|
||||||
mpctx->osd_function = OSD_FFW; // Direction isn't set correctly
|
function = OSD_FFW; // Direction isn't set correctly
|
||||||
} else {
|
} else {
|
||||||
queue_seek(mpctx, MPSEEK_RELATIVE, v, exact);
|
queue_seek(mpctx, MPSEEK_RELATIVE, v, exact);
|
||||||
mpctx->osd_function = (v > 0) ? OSD_FFW : OSD_REW;
|
function = (v > 0) ? OSD_FFW : OSD_REW;
|
||||||
|
}
|
||||||
|
if (cmd->on_osd) {
|
||||||
|
mpctx->add_osd_seek_info = true;
|
||||||
|
mpctx->osd_function = function;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MP_CMD_SET_PROPERTY_OSD:
|
case MP_CMD_SET: {
|
||||||
case_fallthrough_hack = 1;
|
|
||||||
|
|
||||||
case MP_CMD_SET_PROPERTY: {
|
|
||||||
int r = mp_property_do(cmd->args[0].v.s, M_PROPERTY_PARSE,
|
int r = mp_property_do(cmd->args[0].v.s, M_PROPERTY_PARSE,
|
||||||
cmd->args[1].v.s, mpctx);
|
cmd->args[1].v.s, mpctx);
|
||||||
if (r == M_PROPERTY_UNKNOWN)
|
if (r == M_PROPERTY_UNKNOWN)
|
||||||
@ -2099,7 +2098,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
|||||||
mp_msg(MSGT_CPLAYER, MSGL_WARN,
|
mp_msg(MSGT_CPLAYER, MSGL_WARN,
|
||||||
"Failed to set property '%s' to '%s'.\n",
|
"Failed to set property '%s' to '%s'.\n",
|
||||||
cmd->args[0].v.s, cmd->args[1].v.s);
|
cmd->args[0].v.s, cmd->args[1].v.s);
|
||||||
else if (case_fallthrough_hack)
|
else if (cmd->on_osd)
|
||||||
show_property_osd(mpctx, cmd->args[0].v.s);
|
show_property_osd(mpctx, cmd->args[0].v.s);
|
||||||
if (r <= 0)
|
if (r <= 0)
|
||||||
mp_msg(MSGT_GLOBAL, MSGL_INFO,
|
mp_msg(MSGT_GLOBAL, MSGL_INFO,
|
||||||
@ -2107,10 +2106,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MP_CMD_STEP_PROPERTY_OSD:
|
case MP_CMD_SWITCH: {
|
||||||
case_fallthrough_hack = 1;
|
|
||||||
|
|
||||||
case MP_CMD_STEP_PROPERTY: {
|
|
||||||
void *arg = NULL;
|
void *arg = NULL;
|
||||||
int r, i;
|
int r, i;
|
||||||
double d;
|
double d;
|
||||||
@ -2149,7 +2145,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
|||||||
mp_msg(MSGT_CPLAYER, MSGL_WARN,
|
mp_msg(MSGT_CPLAYER, MSGL_WARN,
|
||||||
"Failed to increment property '%s' by %f.\n",
|
"Failed to increment property '%s' by %f.\n",
|
||||||
cmd->args[0].v.s, cmd->args[1].v.f);
|
cmd->args[0].v.s, cmd->args[1].v.f);
|
||||||
else if (case_fallthrough_hack)
|
else if (cmd->on_osd)
|
||||||
show_property_osd(mpctx, cmd->args[0].v.s);
|
show_property_osd(mpctx, cmd->args[0].v.s);
|
||||||
if (r <= 0)
|
if (r <= 0)
|
||||||
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_ERROR=%s\n",
|
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_ERROR=%s\n",
|
||||||
@ -2209,7 +2205,8 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
|||||||
case MP_CMD_SPEED_INCR: {
|
case MP_CMD_SPEED_INCR: {
|
||||||
float v = cmd->args[0].v.f;
|
float v = cmd->args[0].v.f;
|
||||||
mp_property_do("speed", M_PROPERTY_STEP_UP, &v, mpctx);
|
mp_property_do("speed", M_PROPERTY_STEP_UP, &v, mpctx);
|
||||||
show_property_osd(mpctx, "speed");
|
if (cmd->on_osd)
|
||||||
|
show_property_osd(mpctx, "speed");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2221,7 +2218,8 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
|||||||
if (case_fallthrough_hack)
|
if (case_fallthrough_hack)
|
||||||
v *= mpctx->opts.playback_speed;
|
v *= mpctx->opts.playback_speed;
|
||||||
mp_property_do("speed", M_PROPERTY_SET, &v, mpctx);
|
mp_property_do("speed", M_PROPERTY_SET, &v, mpctx);
|
||||||
show_property_osd(mpctx, "speed");
|
if (cmd->on_osd)
|
||||||
|
show_property_osd(mpctx, "speed");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2267,7 +2265,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (available)
|
if (available)
|
||||||
set_osd_tmsg(mpctx, OSD_MSG_SUB_DELAY, 1, osd_duration,
|
set_osd_tmsg(mpctx, OSD_MSG_SUB_DELAY, osdl, osd_duration,
|
||||||
"Sub delay: %d ms", ROUND(sub_delay * 1000));
|
"Sub delay: %d ms", ROUND(sub_delay * 1000));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2282,9 +2280,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
|||||||
opts->osd_level = (opts->osd_level + 1) % (max + 1);
|
opts->osd_level = (opts->osd_level + 1) % (max + 1);
|
||||||
else
|
else
|
||||||
opts->osd_level = v > max ? max : v;
|
opts->osd_level = v > max ? max : v;
|
||||||
/* Show OSD state when disabled, but not when an explicit
|
if (cmd->on_osd && opts->osd_level <= 1)
|
||||||
argument is given to the OSD command, i.e. in slave mode. */
|
|
||||||
if (v == -1 && opts->osd_level <= 1)
|
|
||||||
set_osd_tmsg(mpctx, OSD_MSG_OSD_STATUS, 0, osd_duration,
|
set_osd_tmsg(mpctx, OSD_MSG_OSD_STATUS, 0, osd_duration,
|
||||||
"OSD: %s",
|
"OSD: %s",
|
||||||
opts->osd_level ? mp_gtext("enabled") :
|
opts->osd_level ? mp_gtext("enabled") :
|
||||||
@ -2386,7 +2382,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
|||||||
else
|
else
|
||||||
radio_step_channel(mpctx->stream, RADIO_CHANNEL_LOWER);
|
radio_step_channel(mpctx->stream, RADIO_CHANNEL_LOWER);
|
||||||
if (radio_get_channel_name(mpctx->stream)) {
|
if (radio_get_channel_name(mpctx->stream)) {
|
||||||
set_osd_tmsg(OSD_MSG_RADIO_CHANNEL, 1, osd_duration,
|
set_osd_tmsg(OSD_MSG_RADIO_CHANNEL, osdl, osd_duration,
|
||||||
"Channel: %s",
|
"Channel: %s",
|
||||||
radio_get_channel_name(mpctx->stream));
|
radio_get_channel_name(mpctx->stream));
|
||||||
}
|
}
|
||||||
@ -2397,7 +2393,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
|||||||
if (mpctx->stream && mpctx->stream->type == STREAMTYPE_RADIO) {
|
if (mpctx->stream && mpctx->stream->type == STREAMTYPE_RADIO) {
|
||||||
radio_set_channel(mpctx->stream, cmd->args[0].v.s);
|
radio_set_channel(mpctx->stream, cmd->args[0].v.s);
|
||||||
if (radio_get_channel_name(mpctx->stream)) {
|
if (radio_get_channel_name(mpctx->stream)) {
|
||||||
set_osd_tmsg(OSD_MSG_RADIO_CHANNEL, 1, osd_duration,
|
set_osd_tmsg(OSD_MSG_RADIO_CHANNEL, osdl, osd_duration,
|
||||||
"Channel: %s",
|
"Channel: %s",
|
||||||
radio_get_channel_name(mpctx->stream));
|
radio_get_channel_name(mpctx->stream));
|
||||||
}
|
}
|
||||||
@ -2426,7 +2422,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
|||||||
#ifdef CONFIG_PVR
|
#ifdef CONFIG_PVR
|
||||||
else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
|
else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
|
||||||
pvr_set_freq(mpctx->stream, ROUND(cmd->args[0].v.f));
|
pvr_set_freq(mpctx->stream, ROUND(cmd->args[0].v.f));
|
||||||
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s",
|
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, osdl, osd_duration, "%s: %s",
|
||||||
pvr_get_current_channelname(mpctx->stream),
|
pvr_get_current_channelname(mpctx->stream),
|
||||||
pvr_get_current_stationname(mpctx->stream));
|
pvr_get_current_stationname(mpctx->stream));
|
||||||
}
|
}
|
||||||
@ -2439,7 +2435,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
|||||||
#ifdef CONFIG_PVR
|
#ifdef CONFIG_PVR
|
||||||
else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
|
else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
|
||||||
pvr_force_freq_step(mpctx->stream, ROUND(cmd->args[0].v.f));
|
pvr_force_freq_step(mpctx->stream, ROUND(cmd->args[0].v.f));
|
||||||
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: f %d",
|
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, osdl, osd_duration, "%s: f %d",
|
||||||
pvr_get_current_channelname(mpctx->stream),
|
pvr_get_current_channelname(mpctx->stream),
|
||||||
pvr_get_current_frequency(mpctx->stream));
|
pvr_get_current_frequency(mpctx->stream));
|
||||||
}
|
}
|
||||||
@ -2460,7 +2456,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
|||||||
tv_step_channel(get_tvh(mpctx), TV_CHANNEL_LOWER);
|
tv_step_channel(get_tvh(mpctx), TV_CHANNEL_LOWER);
|
||||||
}
|
}
|
||||||
if (tv_channel_list) {
|
if (tv_channel_list) {
|
||||||
set_osd_tmsg(mpctx, OSD_MSG_TV_CHANNEL, 1, osd_duration,
|
set_osd_tmsg(mpctx, OSD_MSG_TV_CHANNEL, osdl, osd_duration,
|
||||||
"Channel: %s", tv_channel_current->name);
|
"Channel: %s", tv_channel_current->name);
|
||||||
//vo_osd_changed(OSDTYPE_SUBTITLE);
|
//vo_osd_changed(OSDTYPE_SUBTITLE);
|
||||||
}
|
}
|
||||||
@ -2469,7 +2465,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
|||||||
else if (mpctx->stream &&
|
else if (mpctx->stream &&
|
||||||
mpctx->stream->type == STREAMTYPE_PVR) {
|
mpctx->stream->type == STREAMTYPE_PVR) {
|
||||||
pvr_set_channel_step(mpctx->stream, cmd->args[0].v.i);
|
pvr_set_channel_step(mpctx->stream, cmd->args[0].v.i);
|
||||||
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s",
|
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, osdl, osd_duration, "%s: %s",
|
||||||
pvr_get_current_channelname(mpctx->stream),
|
pvr_get_current_channelname(mpctx->stream),
|
||||||
pvr_get_current_stationname(mpctx->stream));
|
pvr_get_current_stationname(mpctx->stream));
|
||||||
}
|
}
|
||||||
@ -2498,7 +2494,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
|||||||
if (get_tvh(mpctx)) {
|
if (get_tvh(mpctx)) {
|
||||||
tv_set_channel(get_tvh(mpctx), cmd->args[0].v.s);
|
tv_set_channel(get_tvh(mpctx), cmd->args[0].v.s);
|
||||||
if (tv_channel_list) {
|
if (tv_channel_list) {
|
||||||
set_osd_tmsg(mpctx, OSD_MSG_TV_CHANNEL, 1, osd_duration,
|
set_osd_tmsg(mpctx, OSD_MSG_TV_CHANNEL, osdl, osd_duration,
|
||||||
"Channel: %s", tv_channel_current->name);
|
"Channel: %s", tv_channel_current->name);
|
||||||
//vo_osd_changed(OSDTYPE_SUBTITLE);
|
//vo_osd_changed(OSDTYPE_SUBTITLE);
|
||||||
}
|
}
|
||||||
@ -2506,7 +2502,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
|||||||
#ifdef CONFIG_PVR
|
#ifdef CONFIG_PVR
|
||||||
else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
|
else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
|
||||||
pvr_set_channel(mpctx->stream, cmd->args[0].v.s);
|
pvr_set_channel(mpctx->stream, cmd->args[0].v.s);
|
||||||
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s",
|
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, osdl, osd_duration, "%s: %s",
|
||||||
pvr_get_current_channelname(mpctx->stream),
|
pvr_get_current_channelname(mpctx->stream),
|
||||||
pvr_get_current_stationname(mpctx->stream));
|
pvr_get_current_stationname(mpctx->stream));
|
||||||
}
|
}
|
||||||
@ -2531,7 +2527,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
|||||||
if (get_tvh(mpctx)) {
|
if (get_tvh(mpctx)) {
|
||||||
tv_last_channel(get_tvh(mpctx));
|
tv_last_channel(get_tvh(mpctx));
|
||||||
if (tv_channel_list) {
|
if (tv_channel_list) {
|
||||||
set_osd_tmsg(mpctx, OSD_MSG_TV_CHANNEL, 1, osd_duration,
|
set_osd_tmsg(mpctx, OSD_MSG_TV_CHANNEL, osdl, osd_duration,
|
||||||
"Channel: %s", tv_channel_current->name);
|
"Channel: %s", tv_channel_current->name);
|
||||||
//vo_osd_changed(OSDTYPE_SUBTITLE);
|
//vo_osd_changed(OSDTYPE_SUBTITLE);
|
||||||
}
|
}
|
||||||
@ -2539,7 +2535,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
|||||||
#ifdef CONFIG_PVR
|
#ifdef CONFIG_PVR
|
||||||
else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
|
else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
|
||||||
pvr_set_lastchannel(mpctx->stream);
|
pvr_set_lastchannel(mpctx->stream);
|
||||||
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, 1, osd_duration, "%s: %s",
|
set_osd_msg(mpctx, OSD_MSG_TV_CHANNEL, osdl, osd_duration, "%s: %s",
|
||||||
pvr_get_current_channelname(mpctx->stream),
|
pvr_get_current_channelname(mpctx->stream),
|
||||||
pvr_get_current_stationname(mpctx->stream));
|
pvr_get_current_stationname(mpctx->stream));
|
||||||
}
|
}
|
||||||
@ -2599,9 +2595,9 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
|
|||||||
mp_msg(MSGT_CPLAYER, MSGL_INFO, "Setting vo cmd line to '%s'.\n",
|
mp_msg(MSGT_CPLAYER, MSGL_INFO, "Setting vo cmd line to '%s'.\n",
|
||||||
s);
|
s);
|
||||||
if (vo_control(mpctx->video_out, VOCTRL_SET_COMMAND_LINE, s) > 0) {
|
if (vo_control(mpctx->video_out, VOCTRL_SET_COMMAND_LINE, s) > 0) {
|
||||||
set_osd_msg(mpctx, OSD_MSG_TEXT, 1, osd_duration, "vo='%s'", s);
|
set_osd_msg(mpctx, OSD_MSG_TEXT, osdl, osd_duration, "vo='%s'", s);
|
||||||
} else {
|
} else {
|
||||||
set_osd_msg(mpctx, OSD_MSG_TEXT, 1, osd_duration, "Failed!");
|
set_osd_msg(mpctx, OSD_MSG_TEXT, osdl, osd_duration, "Failed!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -138,11 +138,9 @@ static const mp_cmd_t mp_cmds[] = {
|
|||||||
{ MP_CMD_RUN, "run", { ARG_STRING } },
|
{ MP_CMD_RUN, "run", { ARG_STRING } },
|
||||||
|
|
||||||
{ MP_CMD_KEYDOWN_EVENTS, "key_down_event", { ARG_INT } },
|
{ MP_CMD_KEYDOWN_EVENTS, "key_down_event", { ARG_INT } },
|
||||||
{ MP_CMD_SET_PROPERTY, "set_property", { ARG_STRING, ARG_STRING } },
|
{ MP_CMD_SET, "set", { ARG_STRING, ARG_STRING } },
|
||||||
{ MP_CMD_SET_PROPERTY_OSD, "set_property_osd", { ARG_STRING, ARG_STRING } },
|
|
||||||
{ MP_CMD_GET_PROPERTY, "get_property", { ARG_STRING } },
|
{ MP_CMD_GET_PROPERTY, "get_property", { ARG_STRING } },
|
||||||
{ MP_CMD_STEP_PROPERTY, "step_property", { ARG_STRING, OARG_FLOAT(0), OARG_INT(0) } },
|
{ MP_CMD_SWITCH, "switch", { ARG_STRING, OARG_FLOAT(0), OARG_INT(0) } },
|
||||||
{ MP_CMD_STEP_PROPERTY_OSD, "step_property_osd", { ARG_STRING, OARG_FLOAT(0), OARG_INT(0) } },
|
|
||||||
|
|
||||||
{ MP_CMD_SET_MOUSE_POS, "set_mouse_pos", { ARG_INT, ARG_INT } },
|
{ MP_CMD_SET_MOUSE_POS, "set_mouse_pos", { ARG_INT, ARG_INT } },
|
||||||
|
|
||||||
@ -164,40 +162,44 @@ static const mp_cmd_t mp_cmds[] = {
|
|||||||
struct legacy_cmd {
|
struct legacy_cmd {
|
||||||
const char *old, *new;
|
const char *old, *new;
|
||||||
};
|
};
|
||||||
#define LEGACY_STEP(old) {old, "step_property_osd " old}
|
#define LEGACY_STEP(old) {old, "switch " old}
|
||||||
static const struct legacy_cmd legacy_cmds[] = {
|
static const struct legacy_cmd legacy_cmds[] = {
|
||||||
LEGACY_STEP("loop"),
|
LEGACY_STEP("loop"),
|
||||||
{"seek_chapter", "step_property_osd chapter"},
|
{"seek_chapter", "switch chapter"},
|
||||||
{"switch_angle", "step_property_osd angle"},
|
{"switch_angle", "switch angle"},
|
||||||
LEGACY_STEP("pause"),
|
LEGACY_STEP("pause"),
|
||||||
LEGACY_STEP("volume"),
|
LEGACY_STEP("volume"),
|
||||||
LEGACY_STEP("mute"),
|
LEGACY_STEP("mute"),
|
||||||
LEGACY_STEP("audio_delay"),
|
LEGACY_STEP("audio_delay"),
|
||||||
LEGACY_STEP("switch_audio"),
|
LEGACY_STEP("switch_audio"),
|
||||||
LEGACY_STEP("balance"),
|
LEGACY_STEP("balance"),
|
||||||
{"vo_fullscreen", "step_property fullscreen"},
|
{"vo_fullscreen", "no-osd switch fullscreen"},
|
||||||
LEGACY_STEP("panscan"),
|
LEGACY_STEP("panscan"),
|
||||||
{"vo_ontop", "step_property_osd ontop"},
|
{"vo_ontop", "switch ontop"},
|
||||||
{"vo_rootwin", "step_property_osd rootwin"},
|
{"vo_rootwin", "switch rootwin"},
|
||||||
{"vo_border", "step_property_osd border"},
|
{"vo_border", "switch border"},
|
||||||
{"frame_drop", "step_property_osd framedropping"},
|
{"frame_drop", "switch framedropping"},
|
||||||
LEGACY_STEP("gamma"),
|
LEGACY_STEP("gamma"),
|
||||||
LEGACY_STEP("brightness"),
|
LEGACY_STEP("brightness"),
|
||||||
LEGACY_STEP("contrast"),
|
LEGACY_STEP("contrast"),
|
||||||
LEGACY_STEP("saturation"),
|
LEGACY_STEP("saturation"),
|
||||||
LEGACY_STEP("hue"),
|
LEGACY_STEP("hue"),
|
||||||
{"switch_vsync", "step_property_osd vsync"},
|
{"switch_vsync", "switch vsync"},
|
||||||
{"sub_select", "step_property_osd sub"},
|
{"sub_select", "switch sub"},
|
||||||
LEGACY_STEP("sub_pos"),
|
LEGACY_STEP("sub_pos"),
|
||||||
LEGACY_STEP("sub_delay"),
|
LEGACY_STEP("sub_delay"),
|
||||||
LEGACY_STEP("sub_visibility"),
|
LEGACY_STEP("sub_visibility"),
|
||||||
{"forced_subs_only", "step_property_osd sub_forced_only"},
|
{"forced_subs_only", "switch sub_forced_only"},
|
||||||
LEGACY_STEP("sub_scale"),
|
LEGACY_STEP("sub_scale"),
|
||||||
LEGACY_STEP("ass_use_margins"),
|
LEGACY_STEP("ass_use_margins"),
|
||||||
{"tv_set_brightness", "tv_brightness"},
|
{"tv_set_brightness", "tv_brightness"},
|
||||||
{"tv_set_hue", "tv_hue"},
|
{"tv_set_hue", "tv_hue"},
|
||||||
{"tv_set_saturation", "tv_saturation"},
|
{"tv_set_saturation", "tv_saturation"},
|
||||||
{"tv_set_contrast", "tv_contrast"},
|
{"tv_set_contrast", "tv_contrast"},
|
||||||
|
{"step_property_osd", "switch"},
|
||||||
|
{"step_property", "no-osd switch"},
|
||||||
|
{"set_property", "no-osd set"},
|
||||||
|
{"set_property_osd", "set"},
|
||||||
{"pt_step 1", "playlist_next"},
|
{"pt_step 1", "playlist_next"},
|
||||||
{"pt_step -1", "playlist_prev"},
|
{"pt_step -1", "playlist_prev"},
|
||||||
{0}
|
{0}
|
||||||
@ -686,18 +688,31 @@ int mp_input_add_key_fd(struct input_ctx *ictx, int fd, int select,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *skip_ws(char *str)
|
||||||
|
{
|
||||||
|
while (str[0] == ' ' || str[0] == '\t')
|
||||||
|
++str;
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *skip_no_ws(char *str)
|
||||||
|
{
|
||||||
|
while (str[0] && !(str[0] == ' ' || str[0] == '\t'))
|
||||||
|
++str;
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
mp_cmd_t *mp_input_parse_cmd(char *str)
|
mp_cmd_t *mp_input_parse_cmd(char *str)
|
||||||
{
|
{
|
||||||
int i, l;
|
int i, l;
|
||||||
int pausing = 0;
|
int pausing = 0;
|
||||||
|
int on_osd = MP_ON_OSD_AUTO;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
const mp_cmd_t *cmd_def;
|
const mp_cmd_t *cmd_def;
|
||||||
mp_cmd_t *cmd = NULL;
|
mp_cmd_t *cmd = NULL;
|
||||||
void *tmp = NULL;
|
void *tmp = NULL;
|
||||||
|
|
||||||
// Ignore heading spaces.
|
str = skip_ws(str);
|
||||||
while (str[0] == ' ' || str[0] == '\t')
|
|
||||||
++str;
|
|
||||||
|
|
||||||
if (strncmp(str, "pausing ", 8) == 0) {
|
if (strncmp(str, "pausing ", 8) == 0) {
|
||||||
pausing = 1;
|
pausing = 1;
|
||||||
@ -713,6 +728,8 @@ mp_cmd_t *mp_input_parse_cmd(char *str)
|
|||||||
str = &str[19];
|
str = &str[19];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
str = skip_ws(str);
|
||||||
|
|
||||||
for (const struct legacy_cmd *entry = legacy_cmds; entry->old; entry++) {
|
for (const struct legacy_cmd *entry = legacy_cmds; entry->old; entry++) {
|
||||||
size_t old_len = strlen(entry->old);
|
size_t old_len = strlen(entry->old);
|
||||||
if (strncasecmp(entry->old, str, old_len) == 0) {
|
if (strncasecmp(entry->old, str, old_len) == 0) {
|
||||||
@ -725,7 +742,14 @@ mp_cmd_t *mp_input_parse_cmd(char *str)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr = str + strcspn(str, "\t ");
|
str = skip_ws(str);
|
||||||
|
|
||||||
|
if (strncmp(str, "no-osd ", 7) == 0) {
|
||||||
|
on_osd = MP_ON_OSD_NO;
|
||||||
|
str = &str[7];
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr = skip_no_ws(str);
|
||||||
if (*ptr != 0)
|
if (*ptr != 0)
|
||||||
l = ptr - str;
|
l = ptr - str;
|
||||||
else
|
else
|
||||||
@ -735,7 +759,8 @@ mp_cmd_t *mp_input_parse_cmd(char *str)
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
for (i = 0; mp_cmds[i].name != NULL; i++) {
|
for (i = 0; mp_cmds[i].name != NULL; i++) {
|
||||||
if (strncasecmp(mp_cmds[i].name, str, l) == 0)
|
const char *cmd = mp_cmds[i].name;
|
||||||
|
if (strncasecmp(cmd, str, l) == 0 && strlen(cmd) == l)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -749,6 +774,7 @@ mp_cmd_t *mp_input_parse_cmd(char *str)
|
|||||||
.id = cmd_def->id,
|
.id = cmd_def->id,
|
||||||
.name = talloc_strdup(cmd, cmd_def->name),
|
.name = talloc_strdup(cmd, cmd_def->name),
|
||||||
.pausing = pausing,
|
.pausing = pausing,
|
||||||
|
.on_osd = on_osd,
|
||||||
};
|
};
|
||||||
|
|
||||||
ptr = str;
|
ptr = str;
|
||||||
|
@ -51,8 +51,7 @@ enum mp_command_type {
|
|||||||
MP_CMD_RUN,
|
MP_CMD_RUN,
|
||||||
MP_CMD_SUB_LOAD,
|
MP_CMD_SUB_LOAD,
|
||||||
MP_CMD_KEYDOWN_EVENTS,
|
MP_CMD_KEYDOWN_EVENTS,
|
||||||
MP_CMD_SET_PROPERTY,
|
MP_CMD_SET,
|
||||||
MP_CMD_SET_PROPERTY_OSD,
|
|
||||||
MP_CMD_GET_PROPERTY,
|
MP_CMD_GET_PROPERTY,
|
||||||
MP_CMD_OSD_SHOW_PROPERTY_TEXT,
|
MP_CMD_OSD_SHOW_PROPERTY_TEXT,
|
||||||
MP_CMD_OSD_SHOW_PROGRESSION,
|
MP_CMD_OSD_SHOW_PROGRESSION,
|
||||||
@ -60,8 +59,7 @@ enum mp_command_type {
|
|||||||
MP_CMD_RADIO_SET_CHANNEL,
|
MP_CMD_RADIO_SET_CHANNEL,
|
||||||
MP_CMD_RADIO_SET_FREQ,
|
MP_CMD_RADIO_SET_FREQ,
|
||||||
MP_CMD_SET_MOUSE_POS,
|
MP_CMD_SET_MOUSE_POS,
|
||||||
MP_CMD_STEP_PROPERTY,
|
MP_CMD_SWITCH,
|
||||||
MP_CMD_STEP_PROPERTY_OSD,
|
|
||||||
MP_CMD_RADIO_STEP_FREQ,
|
MP_CMD_RADIO_STEP_FREQ,
|
||||||
MP_CMD_TV_STEP_FREQ,
|
MP_CMD_TV_STEP_FREQ,
|
||||||
MP_CMD_TV_START_SCAN,
|
MP_CMD_TV_START_SCAN,
|
||||||
@ -104,6 +102,11 @@ enum mp_command_type {
|
|||||||
// Key FIFO was full - release events may be lost, zero button-down status
|
// Key FIFO was full - release events may be lost, zero button-down status
|
||||||
#define MP_INPUT_RELEASE_ALL -5
|
#define MP_INPUT_RELEASE_ALL -5
|
||||||
|
|
||||||
|
enum mp_on_osd {
|
||||||
|
MP_ON_OSD_NO = 0,
|
||||||
|
MP_ON_OSD_AUTO,
|
||||||
|
};
|
||||||
|
|
||||||
enum mp_input_section_flags {
|
enum mp_input_section_flags {
|
||||||
// If a key binding is not defined in the current section, search the
|
// If a key binding is not defined in the current section, search the
|
||||||
// default section for it ("default" refers to bindings with no section
|
// default section for it ("default" refers to bindings with no section
|
||||||
@ -129,6 +132,7 @@ typedef struct mp_cmd {
|
|||||||
struct mp_cmd_arg args[MP_CMD_MAX_ARGS];
|
struct mp_cmd_arg args[MP_CMD_MAX_ARGS];
|
||||||
int nargs;
|
int nargs;
|
||||||
int pausing;
|
int pausing;
|
||||||
|
enum mp_on_osd on_osd;
|
||||||
struct mp_cmd *queue_next;
|
struct mp_cmd *queue_next;
|
||||||
} mp_cmd_t;
|
} mp_cmd_t;
|
||||||
|
|
||||||
|
1
mp_osd.h
1
mp_osd.h
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#define MAX_OSD_LEVEL 3
|
#define MAX_OSD_LEVEL 3
|
||||||
#define MAX_TERM_OSD_LEVEL 1
|
#define MAX_TERM_OSD_LEVEL 1
|
||||||
|
#define OSD_LEVEL_INVISIBLE 4
|
||||||
|
|
||||||
struct MPContext;
|
struct MPContext;
|
||||||
|
|
||||||
|
@ -1240,6 +1240,8 @@ static mp_osd_msg_t *add_osd_msg(struct MPContext *mpctx, int id, int level,
|
|||||||
static void set_osd_msg_va(struct MPContext *mpctx, int id, int level, int time,
|
static void set_osd_msg_va(struct MPContext *mpctx, int id, int level, int time,
|
||||||
const char *fmt, va_list ap)
|
const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
|
if (level == OSD_LEVEL_INVISIBLE)
|
||||||
|
return;
|
||||||
mp_osd_msg_t *msg = add_osd_msg(mpctx, id, level, time);
|
mp_osd_msg_t *msg = add_osd_msg(mpctx, id, level, time);
|
||||||
msg->msg = talloc_vasprintf(msg, fmt, ap);
|
msg->msg = talloc_vasprintf(msg, fmt, ap);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user