Mercurial > mplayer.hg
changeset 15706:c6bedab03c97
Add sub_load and sub_remove slave commands.
Patch by kiriuja [mplayer-patches at en-directo dot net]
author | reimar |
---|---|
date | Thu, 09 Jun 2005 20:13:53 +0000 |
parents | e7dcc698718b |
children | 8c7268bfe792 |
files | DOCS/tech/slave.txt help/help_mp-en.h input/input.c input/input.h mplayer.c |
diffstat | 5 files changed, 77 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/DOCS/tech/slave.txt Thu Jun 09 17:07:10 2005 +0000 +++ b/DOCS/tech/slave.txt Thu Jun 09 20:13:53 2005 +0000 @@ -76,6 +76,14 @@ Step forward in the subtitle list by <value> steps or backwards if <value> is negative. +sub_load <subtitle_file> + Loads subtitles from <subtitle_file>. + +sub_remove [<value>] + If the <value> argument is present and non-negative, removes the subtitle + file with index <value>. If the argument is omitted or negative, removes + all subtitle files. + osd [<level>] Toggle OSD mode or set it to level when <level> >= 0.
--- a/help/help_mp-en.h Thu Jun 09 17:07:10 2005 +0000 +++ b/help/help_mp-en.h Thu Jun 09 20:13:53 2005 +0000 @@ -152,6 +152,7 @@ " won't help unless you provide this information when reporting a possible bug.\n" #define MSGTR_LoadingConfig "Loading config '%s'\n" #define MSGTR_AddedSubtitleFile "SUB: added subtitle file (%d): %s\n" +#define MSGTR_RemovedSubtitleFile "SUB: removed subtitle file (%d): %s\n" #define MSGTR_ErrorOpeningOutputFile "Error opening file [%s] for writing!\n" #define MSGTR_CommandLine "CommandLine:" #define MSGTR_RTCDeviceNotOpenable "Failed to open %s: %s (it should be readable by the user.)\n"
--- a/input/input.c Thu Jun 09 17:07:10 2005 +0000 +++ b/input/input.c Thu Jun 09 20:13:53 2005 +0000 @@ -77,6 +77,8 @@ { MP_CMD_SUB_POS, "sub_pos", 1, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, { MP_CMD_SUB_ALIGNMENT, "sub_alignment",0, { {MP_CMD_ARG_INT,{-1}}, {-1,{0}} } }, { MP_CMD_SUB_VISIBILITY, "sub_visibility", 0, { {-1,{0}} } }, + { MP_CMD_SUB_LOAD, "sub_load", 1, { {MP_CMD_ARG_STRING,{0}}, {-1,{0}} } }, + { MP_CMD_SUB_REMOVE, "sub_remove", 0, { {MP_CMD_ARG_INT,{-1}}, {-1,{0}} } }, { MP_CMD_SUB_SELECT, "vobsub_lang", 0, { { MP_CMD_ARG_INT,{-2} }, {-1,{0}} } }, // for compatibility { MP_CMD_SUB_SELECT, "sub_select", 0, { { MP_CMD_ARG_INT,{-2} }, {-1,{0}} } }, { MP_CMD_SUB_LOG, "sub_log", 0, { {-1,{0}} } },
--- a/input/input.h Thu Jun 09 17:07:10 2005 +0000 +++ b/input/input.h Thu Jun 09 20:13:53 2005 +0000 @@ -65,6 +65,8 @@ #define MP_CMD_SUB_LOG 61 #define MP_CMD_SWITCH_AUDIO 62 #define MP_CMD_GET_TIME_POS 63 +#define MP_CMD_SUB_LOAD 64 +#define MP_CMD_SUB_REMOVE 65 #define MP_CMD_GUI_EVENTS 5000 #define MP_CMD_GUI_LOADFILE 5001
--- a/mplayer.c Thu Jun 09 17:07:10 2005 +0000 +++ b/mplayer.c Thu Jun 09 20:13:53 2005 +0000 @@ -3378,6 +3378,70 @@ } #endif } break; + case MP_CMD_SUB_LOAD: + { +#ifdef USE_SUB + if (sh_video) { + int n = set_of_sub_size; + add_subtitles(cmd->args[0].v.s, sh_video->fps, 0); + if (n != set_of_sub_size) { + if (global_sub_indices[SUB_SOURCE_SUBS] < 0) + global_sub_indices[SUB_SOURCE_SUBS] = global_sub_size; + ++global_sub_size; + } + } +#endif + } break; + case MP_CMD_SUB_REMOVE: + { +#ifdef USE_SUB + if (sh_video) { + int v = cmd->args[0].v.i; + sub_data *subd; + if (v < 0) { + for (v = 0; v < set_of_sub_size; ++v) { + subd = set_of_subtitles[v]; + mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_RemovedSubtitleFile, v + 1, subd->filename); + sub_free(subd); + set_of_subtitles[v] = NULL; + } + global_sub_indices[SUB_SOURCE_SUBS] = -1; + global_sub_size -= set_of_sub_size; + set_of_sub_size = 0; + if (set_of_sub_pos >= 0) { + global_sub_pos = -2; + vo_sub_last = vo_sub = NULL; + vo_osd_changed(OSDTYPE_SUBTITLE); + vo_update_osd(sh_video->disp_w, sh_video->disp_h); + mp_input_queue_cmd(mp_input_parse_cmd("sub_select")); + } + } + else if (v < set_of_sub_size) { + subd = set_of_subtitles[v]; + mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_RemovedSubtitleFile, v + 1, subd->filename); + sub_free(subd); + if (set_of_sub_pos == v) { + global_sub_pos = -2; + vo_sub_last = vo_sub = NULL; + vo_osd_changed(OSDTYPE_SUBTITLE); + vo_update_osd(sh_video->disp_w, sh_video->disp_h); + mp_input_queue_cmd(mp_input_parse_cmd("sub_select")); + } + else if (set_of_sub_pos > v) { + --set_of_sub_pos; + --global_sub_pos; + } + while (++v < set_of_sub_size) + set_of_subtitles[v - 1] = set_of_subtitles[v]; + --set_of_sub_size; + --global_sub_size; + if (set_of_sub_size <= 0) + global_sub_indices[SUB_SOURCE_SUBS] = -1; + set_of_subtitles[set_of_sub_size] = NULL; + } + } +#endif + } break; case MP_CMD_GET_SUB_VISIBILITY: { #ifdef USE_SUB