Commit Graph

33875 Commits

Author SHA1 Message Date
wm4 1d1f59234b commands: move legacy property wrapper to m_property.c 2012-10-12 10:10:33 +02:00
wm4 12da72e135 commands: sub_step takes only one argument 2012-10-12 10:10:33 +02:00
wm4 a2adb6b333 TOOLS/mplayer2_identify.sh: program property is not readable
And it never was. This property is write-only and exists only for
setting the program. Making it readable is possible, but would require
demuxer changes.
2012-10-12 10:10:32 +02:00
wm4 503b124659 commands: disable deprecation warnings
This disables warning messages when the legacy input command bridge is
used. For now, user input.confs should just keep working as if nothing
has changed. The deprecation warnings will be enabled again at a later
point, and the legacy bridge will be eventually removed.
2012-10-12 10:10:32 +02:00
wm4 ea90bdbfa2 commands: rename show_tracks/chapters_osd command 2012-10-12 10:10:32 +02:00
wm4 4f1aad1f06 commands: attempt to fix "program" property
The user-visible track IDs are normalized and don't match with whatever
the demuxer uses.

Completely untested. It might actually work with both demux_lavf and
demux_ts.
2012-10-12 10:10:32 +02:00
wm4 8fc2aef3b7 commands: don't use dummy option declaration for properties
The property-to-option bridge (when properties change values normally
set by the command line parser) uses M_PROPERTY_GET_TYPE to get the
exact option type. In these cases, the entry in mp_properties[] is
unused, except for the name field and the property callback. Instead,
mp_property_generic_option() implements M_PROPERTY_GET_TYPE and returns
the m_option as defined in cfg-mplayer.h. However, if a property is
unavailable, mp_property_generic_option() is never actually called, and
M_PROPERTY_GET_TYPE will return the dummy option entry.

We could make sure that the dummy option entry equals the option entry
defined in cfg-mplayer.h. But this would duplicate all information.

Add a dummy option type m_option_type_dummy, which is used by entries
using the property-to-option bridge. Make M_PROPERTY_GET_TYPE fail if
this type is encountered.

This dummy should never be used, as it isn
2012-10-12 10:10:32 +02:00
wm4 46e8d33809 commands: make exact seeking default bindings not use OSD
The OSD bar is very annoying when seeking. Especially when the seeks
are very small, the OSD doesn't show any interesting information. The
exact seeking commands are a use case where the user definitely never
wants to see a seek bar.
2012-10-12 10:10:32 +02:00
wm4 e79efd28f8 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.
2012-10-12 10:10:32 +02:00
wm4 88849fd1d4 commands: add choice type to input commands
Allow using the choice type (as it used for command line) for arguments
of input commands. Change the magic integer arguments of some commands
(like seek) to use choices instead. The old numeric values are still
allowed (but only those which made sense before, not arbitrary
integers).

In order to do this, remove the input.c specific types (like
MP_CMD_ARG_INT) completely and specify commands using the m_option
types.

Also, add the special choice "-" to some arguments. It's supposed to
signify the default value, so arguments can be easily skipped. Maybe the
choice option should recognize this and not change the previous value,
but we'll leave this for later.

For now, leave compatibility integer values for all new choice
arguments, e.g. "0" maps to 0. We could let the choice option type do
this automatically, but we don't, because we want user input values and
internal mplayer values decoupled in general. The compatibility options
will be removed one day, too.

Also, remove optional args for strings - would require either annoying
additional code, or copying strings twice. It's not used, so remove it.
2012-10-12 10:10:32 +02:00
wm4 a441cd3eeb m_option.h: separate creating choices array into M_CHOICES macro
Reduces code duplication, increases reusability.
2012-10-12 10:10:32 +02:00
wm4 38a8a8d3d2 talloc: fix strndup group of functions
This bug has been fixed years ago in upstream talloc.
2012-10-12 10:10:32 +02:00
wm4 32c5a87a01 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.
2012-10-12 10:10:32 +02:00
wm4 df2b0f9948 Fix MP_TARRAY_GROW macro
This macro is supposed to make sure an array has enough memory allocated
for a given number of elements. Unfortunately, a condition was inverted
(I... what???). It only allocated if there was still enough memory left,
or only one additional element had to be allocated.

Since this macro was only used by MP_TARRAY_APPEND, this case was never
actually triggered. It's still utter non-sense.
2012-10-12 10:10:32 +02:00
wm4 0de86f5bf3 input: warn about non-existing commands, add explicit "ignore" command
If a command is not found, warn about it at loading time (just like
other command parsing errors are printed at loading time).

Add an explicit "ignore" command. input.conf instructs users to use this
command to cancel out existing mapping. This clashed with the
warning added in this commit. Make "ignore" a real command and remove
the specialcasing for it from get_cmd_from_keys(). Now "ignore" is
ignored because it's not handled in command.c.
2012-10-12 10:10:32 +02:00
wm4 d232012287 input: handle escapes always in command parser
Previously, both the command parser and property expansion
(m_properties_expand_string) handled escapes with '\'. Move all escape
handling into the command parser, and remove it from the property code.

This removes the need to escape strings twice for commands that use
property expansion.

The command parser is practically rewritten: it uses m_option for the
actual parsing, and reduces hackish C-string handling.
2012-10-12 10:10:32 +02:00
wm4 84af173380 commands: cosmetics: rename things
This is Better (tm).

The only actual change is that with M_PROPERTY_SET_STRING, the option
parser will use the property name, instead whatever was set in the
name field of the option returned by M_PROPERTY_GET_TYPE. In most cases,
these should be the same, though.
2012-10-12 10:10:32 +02:00
wm4 b591688a27 input: verify input.conf on loading
When input.conf is loaded, verify each command and print a warning if
it's invalid or uses legacy commands. This is done for both the user's
and the embedded config files.

The diff is a bit noisy, because mp_input_parse_cmd() is changed to take
a bstr as argument instead of a char*.
2012-10-12 10:10:32 +02:00
wm4 45b432f4c3 commands: replace "switch" with "add" and "cycle"
Now it depends on the command whether a property wraps around, or stops
at min/max valid property value.

For practically all properties, it's quite unambiguous what the "switch"
command should have done, and there's technically no need to replace it
with these new commands. More over, most properties that cycle are
boolean anyway. But it seems more orthogonal to make the difference
explicit, rather than hardcoding it. Having different commands also
makes it more explicit to the user what these commands do, both just due
to the naming, and what wrapping policy is used. The code is simpler
too.
2012-10-12 10:10:31 +02:00
wm4 9939776e5e commands: make "aspect" property writeable, replaces "switch_ratio"
Move the code for "switch_ratio" to the M_PROPERTY_SET case of the
"aspect" property. The rules are exactly the same, e.g. setting a ratio
smaller than 0.1 sets the pixel aspect ratio to 1:1. For now, we define
that writing "0" sets the PAR to 1:1, and disallow -1 (possibly reserve
it to reset to default aspect ratio).
2012-10-12 10:10:31 +02:00
wm4 d356219824 commands: remove M_PROPERTY_SWITCH from edition property
Instead, communicate the new value range with M_PROPERTY_GET_TYPE. Add
M_PROPERTY_GET_WRAP to allow properties to enable cycling instead of
stopping at min/max.
2012-10-12 10:10:31 +02:00
wm4 74adc534b9 commands: make M_PROPERTY_GET_TYPE return an option copy
Change the type of the arg for this action from m_option** to m_option*.
This makes it easier to change some aspects of the option dynamically.
2012-10-12 10:10:31 +02:00
wm4 e4dda184aa commands: cosmetics: reindent colormatrix property 2012-10-12 10:10:31 +02:00
wm4 d7207b4cbc commands: don't replicate mapping to option in levels_property_helper
This should be done by mp_property_generic_option() only. Also reindent
levels_property_helper() to make it a little bit more readable.

Remove the m_option_get_ptr() function, which doesn't really make sense
anymore.
2012-10-12 10:10:31 +02:00
wm4 ed8e738e0f commands: cosmetic changes mostly to m_property.h
The Doxygen-style documentation comments were nothing but bloat.

Also move mp_property_do() and mp_property_print() to command.h, where
they should belong, and fix their argument types. m_property.c/h is
supposed to be generic, while command.h provides declarations specific
to the mplayer core.
2012-10-12 10:10:31 +02:00
wm4 d6dad9e934 commands: remove fallback for M_PROPERTY_PARSE and M_PROPERTY_TO_STRING
These should never be overridden by property implementations anyway,
because it would likely result in inconsistencies. The right way to do
this is adding a new m_option type.

Also some cosmetics.
2012-10-12 10:10:31 +02:00
wm4 dec53f760e commands: add more property-option bridge uses, rename some options
Make more properties use the property-to-option bridge to reduce code
size and to enforce consistency. Some options are renamed to the same
as the properties (the property names are better in all cases).

Do some other minor cleanups. One bigger issue was memory management of
strings: M_PROPERTY_TO_STRING assumed the strings were statically
allocated, and no dynamic allocations could be returned. Fix this in
case the need for such properties arises in the future. Get rid of
m_property_string_ro(), because it's not always clear that the "action"
parameter is M_PROPERTY_SET and the string argument will be used.
2012-10-12 10:10:31 +02:00
wm4 28f43ce9a9 commands: minor improvement to error message
Also remove two slave mode messages.
2012-10-12 10:10:31 +02:00
wm4 86ed6efd8a commands: handle property clamping in m_option
Instead of clamping property values to the valid range in each property
implementation, handle it in the property layer. The functionality to
handle clamping for each type is in m_option.c.

It's not really clear whether this is really needed. Normally, the raw
values for M_PROPERTY_SET come only from m_option_type.parse (setting
properties as string) or from m_option_parse.add (using the "switch"
input command). However, since this was already done before, and since
we _really_ want to be sure only to write valid values, add this code
anyway. The newly added warnings/error messages should never actually
be printed during normal operation and are for debugging (if they
happen, we definitely want to see them).
2012-10-12 10:10:31 +02:00
wm4 426640204b options: simplify somewhat by introducing a union for option values
The m_option_value union is supposed to contain a field for each
possible option type (as long as it actually stores data). This helps
avoiding silly temporary memory alocations. Using a pointer to an union
and to a field of the union interchangeably should be allowed by
standard C.
2012-10-12 10:10:31 +02:00
wm4 1a5a7a4929 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.
2012-10-12 10:10:31 +02:00
wm4 69ce4591d0 commands: generally handle property formatting with m_option
Use the m_option code by default to format property values, instead of
having separate code in m_property.

To facilitate that, add a pretty_print callback to option types. These
format values in a more human readable and user friendly way, as opposed
to the print callback, which produces parseable values.

This also changes the strings used with flags. Instead of "enabled" and
"disabled", flags are formatted as "yes" and "no". (We could use the
pretty_print callback to deal with this, but we don't for consistency.)
2012-10-12 10:10:31 +02:00
wm4 f607d104b6 commands: remove pointless NULL checks
Most property implementations checked whether the "arg" parameter was
NULL. This is entirely pointless, because NULL is actually never pased.
It was inconsistently done, too. Remove the checks.
2012-10-12 10:10:31 +02:00
wm4 cac7702565 commands: handle property stepping in a generic way
Instead of forcing each property implementation implement its own logic
for M_PROPERTY_STEP_UP/M_PROPERTY_STEP_DOWN, handle it in the generic
property code.

Rename the M_PROPERTY_STEP_UP command to M_PROPERTY_SWITCH (the other
property command, M_PROPERTY_STEP_DOWN, isn't needed anymore: stepping
downwards is done by passing a negative argument). Always use double as
argument type; it makes the code easier, and covers all property types.
Move the code which does the actual type-specific value stepping to
m_option.c (the idea is that m_option handles types).

Some properties still have custom handlers implemented with
M_PROPERTY_SWITCH. They can't be mapped to the generic mechanism,
because their value range is dynamic or entirely unknown.

For some properties, the default step stride is changed to 1. This is no
issue, because the default bindings in input.conf all use an explicit
stride in the affected cases.
2012-10-12 10:10:31 +02:00
wm4 3d67041089 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.
2012-10-12 10:10:30 +02:00
wm4 10437c35df commands: rename "osdlevel" option and property, make it a choice
Rename both the option and property to "osd-level", which fits a bit
better with the general naming scheme. Make it a choice instead of an
integer range. I failed to come up with good names for the various
levels, so leave them as-is.

Remove the useless property handler for the "loop" property too.
2012-10-12 10:10:30 +02:00
wm4 6f1486b397 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.
2012-10-12 10:10:30 +02:00
wm4 a59eee4893 commands: remove third parameter for "switch"
This could change the direction (i.e. invoke STEP_PROPERTY_DOWN), but
you can just pass a negative value as second argument instead.
2012-10-12 10:10:30 +02:00
wm4 a749c61437 commands: rename osd_show_[property_]text and osd_show_progression
osd_show_[property_]text => show_text
osd_show_progression => show_progress

show_text, osd_show_property_text and osd_show_text both map to the
code for the previous osd_show_property_text. The only special thing
about osd_show_text is that you don't need to escape "$". Also,
unfortunately osd_show_property_text requires escaping things twice,
one time for the command parser, and the other time for the property
formatting code, while osd_show_text needed only one level of escaping.
2012-10-12 10:10:30 +02:00
wm4 950999dd7b commands: remove speed_set/speed_incr commands
Redundant with set/switch commands.
2012-10-12 10:10:30 +02:00
wm4 4e2fab5846 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.
2012-10-12 10:10:30 +02:00
wm4 cd25a671b5 commands: remove unimplemented "use_master" command
The implementation for this command was removed in 2002.
2012-10-12 10:10:30 +02:00
wm4 a668ae0ff9 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.
2012-10-12 10:10:30 +02:00
wm4 6096966dee commands: minor cleanup for property_osd_display array
Make the definition more compact and less confusing by omitting rarely
used fields. Avoid having to initialize osd_id with -1 in every entry
by making 0 an unused OSD ID instead.
2012-10-12 10:10:30 +02:00
wm4 e41378ea71 commands: simplify legacy command-to-property bridge
There are many input commands which are redundant to properties. They
were parsed like normal commands, but set_property_command() in
command.c handled them automatically using the property mechanism. This
still required having the command specifications around, and the code in
command.c was quite messy.

Replace this with a text based replacement mechanism. Some corner cases
are not handled: commands of form "seek_chapter 3 1" are supposed to set
the "chapter" property to 3. This use is probably rare, and doesn't show
up in the default input.conf.

The reason compatibility is kept is because breaking input.conf is quite
annoying, so a minimal effort is made to avoid this. Currently we print
an annoying warning every time a legacy command is used, though.

Also add a compatibility entry for "pt_step", which was removed some
time ago. Variations in whitespace are not handled, but it's good enough
to deal with old input.conf entries.
2012-10-12 10:10:30 +02:00
wm4 0a54f5e741 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.
2012-10-12 10:10:28 +02:00
wm4 65adad50ab mplayer: unbreak OSD with CONFIG_ENCODING undefined
Basically, the encoding code path wanted to set osdlevel=0 as default,
while normal playback needs osdlevel=1. For this purpose, osdlevel was
set to -1 (i.e. invalid) initially to detect whether the --osdlevel
option was explicitly set. When encoding was not configured
(CONFIG_ENCODING undefined), the osdlevel value was not set from
-1 to 1 properly, and the OSD remained invisible by default.

Fix this by getting rid of this logic. It shouldn't be needed, since
osdlevel=1 never shows any OSD messages without user interaction.
Should this ever change, we could still check whether encoding is in
progress, or add another option to allow OSD rendering during encoding.
2012-09-18 21:08:20 +02:00
wm4 f5f0c66d1f options: rename noconfig to no-config, nocache to no-cache
This how it's supposed to be. The manpage has the correct names.
2012-09-18 21:08:20 +02:00
Stefano Pigozzi 09c5324314 cocoa_common: make fullscreen menubar/dock hiding conditional
cocoa_common was hiding the dock and menubar unconditionally when
going fullscreen. This means they were hidden even if they weren't on
the screen mplayer2 was going fullscreen on, resulting in poor user
experience.

Change the fullscreen function in the cocoa backend to check that
mplayer2 is on the same screen as the menubar/dock before hiding them.
2012-09-18 21:08:20 +02:00
Rudolf Polzer f5b8b6ac12 encode: video encoding now supported using mencoder-like options 2012-09-18 21:08:20 +02:00