From 0a54f5e741e395ffb14a1305529c70e817679596 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 6 Sep 2012 05:29:38 +0200 Subject: commands: remove legacy slave mode get commands These have been replaced by properties. Also remove some other slave- mode specific get commands that can be replaced by property uses. The get_metadata() function didn't actually contain anything useful, and just replicated code from other parts of mplayer. --- mplayer.c | 125 -------------------------------------------------------------- 1 file changed, 125 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index 7fa37641fc..d0abca3112 100644 --- a/mplayer.c +++ b/mplayer.c @@ -247,8 +247,6 @@ int use_filedir_conf; #include "mpcommon.h" #include "command.h" -#include "metadata.h" - static void reset_subtitles(struct MPContext *mpctx); static void reinit_subs(struct MPContext *mpctx); @@ -260,129 +258,6 @@ static float get_relative_time(struct MPContext *mpctx) return delta * 0.000001; } -static int is_valid_metadata_type(struct MPContext *mpctx, metadata_t type) -{ - switch (type) { - /* check for valid video stream */ - case META_VIDEO_CODEC: - case META_VIDEO_BITRATE: - case META_VIDEO_RESOLUTION: - if (!mpctx->sh_video) - return 0; - break; - - /* check for valid audio stream */ - case META_AUDIO_CODEC: - case META_AUDIO_BITRATE: - case META_AUDIO_SAMPLES: - if (!mpctx->sh_audio) - return 0; - break; - - /* check for valid demuxer */ - case META_INFO_TITLE: - case META_INFO_ARTIST: - case META_INFO_ALBUM: - case META_INFO_YEAR: - case META_INFO_COMMENT: - case META_INFO_TRACK: - case META_INFO_GENRE: - if (!mpctx->master_demuxer) - return 0; - break; - - default: - break; - } - - return 1; -} - -static char *get_demuxer_info(struct MPContext *mpctx, char *tag) -{ - char **info = mpctx->master_demuxer->info; - int n; - - if (!info || !tag) - return talloc_strdup(NULL, ""); - - for (n = 0; info[2 * n] != NULL; n++) - if (!strcasecmp(info[2 * n], tag)) - break; - - return talloc_strdup(NULL, info[2 * n + 1] ? info[2 * n + 1] : ""); -} - -char *get_metadata(struct MPContext *mpctx, metadata_t type) -{ - sh_audio_t * const sh_audio = mpctx->sh_audio; - sh_video_t * const sh_video = mpctx->sh_video; - - if (!is_valid_metadata_type(mpctx, type)) - return NULL; - - switch (type) { - case META_NAME: - return talloc_strdup(NULL, mp_basename(mpctx->filename)); - case META_VIDEO_CODEC: - if (sh_video->format == 0x10000001) - return talloc_strdup(NULL, "mpeg1"); - else if (sh_video->format == 0x10000002) - return talloc_strdup(NULL, "mpeg2"); - else if (sh_video->format == 0x10000004) - return talloc_strdup(NULL, "mpeg4"); - else if (sh_video->format == 0x10000005) - return talloc_strdup(NULL, "h264"); - else if (sh_video->format >= 0x20202020) - return talloc_asprintf(NULL, "%.4s", (char *) &sh_video->format); - else - return talloc_asprintf(NULL, "0x%08X", sh_video->format); - case META_VIDEO_BITRATE: - return talloc_asprintf(NULL, "%d kbps", - (int) (sh_video->i_bps * 8 / 1024)); - case META_VIDEO_RESOLUTION: - return talloc_asprintf(NULL, "%d x %d", sh_video->disp_w, - sh_video->disp_h); - case META_AUDIO_CODEC: - if (sh_audio->codec && sh_audio->codec->name) - return talloc_strdup(NULL, sh_audio->codec->name); - return talloc_strdup(NULL, ""); - case META_AUDIO_BITRATE: - return talloc_asprintf(NULL, "%d kbps", - (int) (sh_audio->i_bps * 8 / 1000)); - case META_AUDIO_SAMPLES: - return talloc_asprintf(NULL, "%d Hz, %d ch.", sh_audio->samplerate, - sh_audio->channels); - - /* check for valid demuxer */ - case META_INFO_TITLE: - return get_demuxer_info(mpctx, "Title"); - - case META_INFO_ARTIST: - return get_demuxer_info(mpctx, "Artist"); - - case META_INFO_ALBUM: - return get_demuxer_info(mpctx, "Album"); - - case META_INFO_YEAR: - return get_demuxer_info(mpctx, "Year"); - - case META_INFO_COMMENT: - return get_demuxer_info(mpctx, "Comment"); - - case META_INFO_TRACK: - return get_demuxer_info(mpctx, "Track"); - - case META_INFO_GENRE: - return get_demuxer_info(mpctx, "Genre"); - - default: - break; - } - - return talloc_strdup(NULL, ""); -} - static void print_stream(struct MPContext *mpctx, struct track *t, int id) { struct sh_stream *s = t->stream; -- cgit v1.2.3 From a668ae0ff90c43ebcdea4f581aef0c98aeebd382 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 9 Sep 2012 02:08:08 +0200 Subject: 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. --- mplayer.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index d0abca3112..2d1843203f 100644 --- a/mplayer.c +++ b/mplayer.c @@ -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, const char *fmt, va_list ap) { + if (level == OSD_LEVEL_INVISIBLE) + return; mp_osd_msg_t *msg = add_osd_msg(mpctx, id, level, time); msg->msg = talloc_vasprintf(msg, fmt, ap); } -- cgit v1.2.3 From 4e2fab5846d2fe7f51a799abb4118515efac854b Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 15 Sep 2012 01:10:59 +0200 Subject: commands: rename properties, update input.conf Use "-" instead of "_" in property names. The intent is that property names and options names should be the same (if they refer to the same thing), and options use "-" as word separator. Rename some other properties too, e.g. "switch_audio" -> "audio". Add a way to translate the old property names to the new ones, similar to the input command legacy bridge. Update input.conf. Use the new property names, and don't use legacy commands. --- mplayer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index 2d1843203f..d910611d71 100644 --- a/mplayer.c +++ b/mplayer.c @@ -1003,7 +1003,7 @@ void init_vo_spudec(struct MPContext *mpctx) if (vo_spudec != NULL) { mpctx->initialized_flags |= INITIALIZED_SPUDEC; - mp_property_do("sub_forced_only", M_PROPERTY_SET, &forced_subs_only, + mp_property_do("sub-forced-only", M_PROPERTY_SET, &forced_subs_only, mpctx); } } @@ -3486,7 +3486,7 @@ static void open_vobsubs_from_options(struct MPContext *mpctx) mpctx->initialized_flags |= INITIALIZED_VOBSUB; // TODO: let frontend do the selection vobsub_set_from_lang(vo_vobsub, mpctx->opts.sub_lang); - mp_property_do("sub_forced_only", M_PROPERTY_SET, &forced_subs_only, + mp_property_do("sub-forced-only", M_PROPERTY_SET, &forced_subs_only, mpctx); for (int i = 0; i < vobsub_get_indexes_count(vo_vobsub); i++) { -- cgit v1.2.3 From 6f1486b397d632feaa71f88b980491aea7b69256 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 17 Sep 2012 08:38:19 +0200 Subject: commands: replace --hardframedrop, change framedropping property Replace --hardframedrop with --framedrop=hard. Rename the framedrop property from "framedropping" to "framedrop" for the sake of making command line options have the same name as their corresponding property. Change the property to accept choice values instead of numeric values. Remove unused/forgotten auto_quality variable. --- mplayer.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index d910611d71..c90812e871 100644 --- a/mplayer.c +++ b/mplayer.c @@ -230,7 +230,6 @@ static int ignore_start = 0; double force_fps = 0; static int force_srate = 0; -int frame_dropping = 0; // option 0=no drop 1= drop vo 2= drop decode static int play_n_frames = -1; static int play_n_frames_mf = -1; @@ -1797,7 +1796,7 @@ static int check_framedrop(struct MPContext *mpctx, double frame_time) && !mpctx->restart_playback) { ++drop_frame_cnt; ++dropped_frames; - return frame_dropping; + return mpctx->opts.frame_dropping; } else dropped_frames = 0; } -- cgit v1.2.3 From 3d67041089c7945dcea0162c0038e495d588b379 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 18 Sep 2012 11:48:50 +0200 Subject: options: remove CONF_TYPE_POSITION This was the option parser for the off_t C type. These days, off_t is always int64_t, so replace all its uses by int64_t and CONF_TYPE_INT64. Fix the --sstep option. It used CONF_TYPE_INT with an off_t variable, which will result in invalid memory accesses. Make it use type double instead, which seems to make more sense for this option. --- mplayer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index c90812e871..376b243d58 100644 --- a/mplayer.c +++ b/mplayer.c @@ -204,8 +204,8 @@ static const char av_desync_help_text[] = _( static int drop_frame_cnt; // total number of dropped frames // seek: -static off_t seek_to_byte; -static off_t step_sec; +static int64_t seek_to_byte; +static double step_sec; static m_time_size_t end_at = { .type = END_AT_NONE, .pos = 0 }; -- cgit v1.2.3 From 1a5a7a49293c2c70a5caf9d51dad7bd5aa938471 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 18 Sep 2012 15:50:24 +0200 Subject: options: accept "yes" and "no" only for flags This removes the alternative values like "off", "0", "false" etc., and also the non-English versions of these. This is done for general consistency. It's better to have a single way of doing things when multiple ways don't add singificant value. Also update some choices for consistency. --- mplayer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index 376b243d58..4e59dd397e 100644 --- a/mplayer.c +++ b/mplayer.c @@ -2253,7 +2253,7 @@ int reinit_video_chain(struct MPContext *mpctx) &vf_info_ass, NULL }; char *vf_arg[] = { - "auto", "1", NULL + "auto", "yes", NULL }; int retcode = 0; struct vf_instance *vf_ass = vf_open_plugin_noerr(opts, libass_vfs, -- cgit v1.2.3 From 32c5a87a0131e33e592a2986a8d2d98f2ca963b9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 23 Sep 2012 23:00:54 +0200 Subject: commands: change property expansion format string This affects property format strings like they are used in the "show_text" input command, for --playing-msg, and other places. To quote the documentation comment on m_properties_expand_string(): ${NAME} is expanded to the value of property NAME. If NAME starts with '=', use the raw value of the property. ${NAME:STR} expands to the property, or STR if the property is not available. ${?NAME:STR} expands to STR if the property is available. ${!NAME:STR} expands to STR if the property is not available. STR is recursively expanded using the same rules. "$$" can be used to escape "$", and "$}" to escape "}". "$>" disables parsing of "$" for the rest of the string. Most importantly, "?(property:str)" becomes "${?property:str}". Make the simple fallback case easier, e.g. "${property:fallback}" instead of "${property}?(!property:fallback)". Add the ability to escape the format meta characters. "$" is used for escaping, because escaping with "\" is taken by the commands parser in the layer below. "$>" can be used to disable interpretation of format strings (of course escapes by the commands parser can't be canceled). By default, properties which are unavailable or don't exist are turned into a string signaling the status (e.g. "(unavailable)"), instead of an empty string. If an empty string is desired, this has to be done explicitly: "${property:}" (the fallback part is an empty string). Raw properties still return an empty string on error. m_properties_expand_string() now returns a talloc'ed pointer, instead of a malloc'ed one. --- mplayer.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index 4e59dd397e..13ce3c5ecc 100644 --- a/mplayer.c +++ b/mplayer.c @@ -2172,10 +2172,9 @@ static void vo_update_window_title(struct MPContext *mpctx) { if (!mpctx->video_out) return; - char *title = property_expand_string(mpctx, mpctx->opts.vo_wintitle); + char *title = mp_property_expand_string(mpctx, mpctx->opts.vo_wintitle); talloc_free(mpctx->video_out->window_title); - mpctx->video_out->window_title = talloc_strdup(mpctx->video_out, title); - free(title); + mpctx->video_out->window_title = talloc_steal(mpctx, title); } int reinit_video_chain(struct MPContext *mpctx) @@ -3876,9 +3875,9 @@ goto_enable_cache: #endif if (opts->playing_msg) { - char *msg = property_expand_string(mpctx, opts->playing_msg); + char *msg = mp_property_expand_string(mpctx, opts->playing_msg); mp_msg(MSGT_CPLAYER, MSGL_INFO, "%s", msg); - free(msg); + talloc_free(msg); } // Disable the term OSD in verbose mode -- cgit v1.2.3 From e79efd28f8f3f539ca976733ff4209e372dcb5ed Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 25 Sep 2012 03:24:38 +0200 Subject: commands: more user-control whether a command shows OSD bars/messages The "no-osd" prefix was introduced earlier to disable OSD selectively based on the key binding. Extend this, and allow the user to force display of an OSD bar ("osd-bar"), OSD message ("osd-msg") or both ("osd-msg-bar"). This changes mainly how property setting functions behave. The default behavior is still the same. --- mplayer.c | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index 13ce3c5ecc..ab78276a87 100644 --- a/mplayer.c +++ b/mplayer.c @@ -1425,6 +1425,35 @@ static void sadd_osd_status(char *buffer, int len, struct MPContext *mpctx, } } +// OSD messages initated by seeking commands are added lazily with this +// function, because multiple successive seek commands can be coalesced. +static void add_seek_osd_messages(struct MPContext *mpctx) +{ + if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_BAR) + set_osd_bar(mpctx, 0, "Position", 0, 100, get_percent_pos(mpctx)); + if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_TEXT) { + mp_osd_msg_t *msg = add_osd_msg(mpctx, OSD_MSG_TEXT, 1, + mpctx->opts.osd_duration); + msg->show_position = true; + } + if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_CHAPTER_TEXT) { + char *chapter = chapter_display_name(mpctx, get_current_chapter(mpctx)); + set_osd_tmsg(mpctx, OSD_MSG_TEXT, 1, mpctx->opts.osd_duration, + "Chapter: %s", chapter); + talloc_free(chapter); + } + assert(mpctx->master_demuxer); + if ((mpctx->add_osd_seek_info & OSD_SEEK_INFO_EDITION) + && mpctx->master_demuxer) + { + set_osd_tmsg(mpctx, OSD_MSG_TEXT, 1, mpctx->opts.osd_duration, + "Playing edition %d of %d.", + mpctx->master_demuxer->edition + 1, + mpctx->master_demuxer->num_editions); + } + mpctx->add_osd_seek_info = 0; +} + /** * \brief Update the OSD message line. * @@ -1439,10 +1468,7 @@ static void update_osd_msg(struct MPContext *mpctx) struct MPOpts *opts = &mpctx->opts; struct osd_state *osd = mpctx->osd; - if (mpctx->add_osd_seek_info) { - set_osd_bar(mpctx, 0, "Position", 0, 100, get_percent_pos(mpctx)); - mpctx->add_osd_seek_info = false; - } + add_seek_osd_messages(mpctx); // Look if we have a msg mp_osd_msg_t *msg = get_osd_msg(mpctx); @@ -1483,15 +1509,6 @@ static void update_osd_msg(struct MPContext *mpctx) } } -void mp_show_osd_progression(struct MPContext *mpctx) -{ - mp_osd_msg_t *msg = add_osd_msg(mpctx, OSD_MSG_TEXT, 1, - mpctx->opts.osd_duration); - msg->show_position = true; - - set_osd_bar(mpctx, 0, "Position", 0, 100, get_percent_pos(mpctx)); -} - void reinit_audio_chain(struct MPContext *mpctx) { struct MPOpts *opts = &mpctx->opts; @@ -3677,6 +3694,8 @@ static void play_current_file(struct MPContext *mpctx) encode_lavc_discontinuity(mpctx->encode_lavc_ctx); #endif + mpctx->add_osd_seek_info &= OSD_SEEK_INFO_EDITION; + m_config_enter_file_local(mpctx->mconfig); load_per_protocol_config(mpctx->mconfig, mpctx->filename); -- cgit v1.2.3 From fd56c168aedb41a7d98dc4af32644d970eb81331 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 2 Oct 2012 03:12:09 +0200 Subject: options: add --status-msg Replaces the status line with a custom string. This is probably useful for hacking old slave mode applications into working again. Even if not, this might be generally useful. --- mplayer.c | 57 +++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 22 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index ab78276a87..52316a8aa8 100644 --- a/mplayer.c +++ b/mplayer.c @@ -1042,6 +1042,30 @@ static void sadd_percentage(char *buf, int len, int percent) { saddf(buf, len, " (%d%%)", percent); } +static int get_term_width(void) +{ + get_screen_size(); + int width = screen_width > 0 ? screen_width : 80; +#if defined(__MINGW32__) || defined(__CYGWIN__) + /* Windows command line is broken (MinGW's rxvt works, but we + * should not depend on that). */ + width--; +#endif + return width; +} + +static void write_status_line(struct MPContext *mpctx, const char *line) +{ + if (erase_to_end_of_line) { + mp_msg(MSGT_STATUSLINE, MSGL_STATUS, + "%s%s\r", line, erase_to_end_of_line); + } else { + int pos = strlen(line); + int width = get_term_width() - pos; + mp_msg(MSGT_STATUSLINE, MSGL_STATUS, "%s%*s\r", line, width, ""); + } +} + static void print_status(struct MPContext *mpctx, double a_pos, bool at_frame) { struct MPOpts *opts = &mpctx->opts; @@ -1065,19 +1089,16 @@ static void print_status(struct MPContext *mpctx, double a_pos, bool at_frame) if (opts->quiet) return; - int width; - char *line; - get_screen_size(); - if (screen_width > 0) - width = screen_width; - else - width = 80; -#if defined(__MINGW32__) || defined(__CYGWIN__) - /* Windows command line is broken (MinGW's rxvt works, but we - * should not depend on that). */ - width--; -#endif - line = malloc(width + 1); // one additional char for the terminating null + if (opts->status_msg) { + char *r = mp_property_expand_string(mpctx, opts->status_msg); + write_status_line(mpctx, r); + talloc_free(r); + return; + } + + // one additional char for the terminating null + int width = get_term_width() + 1; + char *line = malloc(width); line[0] = '\0'; // Playback status @@ -1156,15 +1177,7 @@ static void print_status(struct MPContext *mpctx, double a_pos, bool at_frame) #endif // end - if (erase_to_end_of_line) { - mp_msg(MSGT_STATUSLINE, MSGL_STATUS, - "%s%s\r", line, erase_to_end_of_line); - } else { - int pos = strlen(line); - memset(&line[pos], ' ', width - pos); - line[width] = 0; - mp_msg(MSGT_STATUSLINE, MSGL_STATUS, "%s\r", line); - } + write_status_line(mpctx, line); free(line); } -- cgit v1.2.3 From c9df2c8bd83b31375a79ab2bc4f854a53ff019c1 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 11 Oct 2012 02:23:29 +0200 Subject: sub: add --ass-style-override option to disable style overrides There are a number of options which modify ASS subtitle rendering. Most of these do things that can interfere with the styling done by subtitle scripts, resulting in incorrect rendering. Add the --ass-style-override option to make it easy to disable all overrides. This helps trouble- shooting, and makes it more practical to use the override features. (You can simply toggle the ass-style-override property at runtime, should one of the style override options break subtitle rendering at a certain point.) This mainly affects whether most --ass-* options are applied, as well as --sub-pos. Some things, like explicit style overrides loaded with --ass-force-style, can't be changed at runtime using the ass-style-override property. --- mplayer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index 52316a8aa8..90e73bd7c8 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3739,7 +3739,8 @@ static void play_current_file(struct MPContext *mpctx) } #ifdef CONFIG_ASS - ass_set_style_overrides(mpctx->ass_library, opts->ass_force_style_list); + if (opts->ass_style_override) + ass_set_style_overrides(mpctx->ass_library, opts->ass_force_style_list); #endif if (mpctx->video_out && mpctx->video_out->config_ok) vo_control(mpctx->video_out, VOCTRL_RESUME, NULL); -- cgit v1.2.3