Commit Graph

156 Commits

Author SHA1 Message Date
wm4 1e27d130a2 client API: change semantics for MPV_FORMAT_STRING
With mpv_set_property(h, "property", MPV_FORMAT_STRING, ptr), ptr now
has to be of type char** instead of char*. This makes it more consistent
with mpv_get_property() and also non-pointer formats, which will be
introduced in the following commits. mpv_set_property() of course does
not change its interface (only its implementation is adjusted to keep
its interface).

This also affects mpv_set_option(), but again not
mpv_set_option_string().
2014-02-24 20:50:47 +01:00
xylosper 5cbef87c17 command: use DVD volume ID for media-title property
Signed-off-by: wm4 <wm4@nowhere>

Closes #582.
2014-02-23 18:16:24 +01:00
xylosper bb6b543812 command: provide per-file-options for loadfile command
Signed-off-by: wm4 <wm4@nowhere>

Closes #575. Minor changes over original pull request.
2014-02-23 17:49:34 +01:00
wm4 f5c781b0d5 command: remove special casing for strings in input commands
Until now, strings were the only allowed dynamically allocated argument
type in input commands. Extend it so that it works for any type. (The
string expansion in command.c is of course still string specific.)
2014-02-23 17:43:38 +01:00
wm4 f225b5fc00 command: don't use option name in properties
Some code accessed m_option.name to get the property name. (Maybe only
show_property_osd() had a significant use of it.) Remove that, and
remove setting names and dummy names as well.

The old code usually assumed that the name was set, and
show_property_osd() used it to get the proper name of deprecated
aliases.

The "vf" property was listed as "vf*". Not sure why that was done, but
it works without anyway.
2014-02-23 16:49:47 +01:00
wm4 641fdff65f lua: fix behavior if no script command handler is registered 2014-02-23 16:48:48 +01:00
wm4 98dc8206ae options: handle escape sequences in e.g. --playing-msg differently
M_OPT_PARSE_ESCAPES was pretty stupid, and broke the (useful) assumption
that string variables contain exactly the same value as set by the
option. Simplify it, and move escape handling to the place where it's
used.

Escape handling itself is not terribly useful, but still allows useful
things like multiline custom OSD with "\n".
2014-02-20 14:46:23 +01:00
wm4 857952dce3 input: check for abort cmd in multi-commands
MP_CMD_COMMAND_LIST commands (used to implement key bindings with
multiple commands) were not checked for abort commands. Implement it.

Remove the remarks about multi-commands being special from the manpage.
Seek coalescing is handled differently now, and the issue with abort
commands is fixed with this commit.
2014-02-20 13:40:32 +01:00
wm4 bda0e7da13 command: allow accessing metadata entries as list
Not sure about these deep path-names. Maybe "metadata/0" should work
instead of "metadata/list/0". I'm so unsure about it, that I'm leaving
it open.
2014-02-19 16:29:04 +01:00
wm4 844efa5431 command: move metadata entry access to metadata/by-key/
The old way still works, and is fine to use. Still discourage it,
because it might conflict with other ways to access this property, such
as the one added in the next commit.
2014-02-19 16:16:42 +01:00
wm4 0ad2211508 client API: add event for metadata changes 2014-02-19 16:00:37 +01:00
wm4 57c9f5236a input, dvdnav: fix osc stealing input from dvdnav
This is a regression introduced from moving Lua scripts (including the
OSC) to their own threads. Now OSC and dvdnav can add their bindings at
the same time without coordination, which seems to result in the OSC
winning most time, and thus overriding the dvdnav menu bindings.

Fix this by adding a flag that makes dvdnav menu bindings take priority
over all other bindings.
2014-02-19 15:40:04 +01:00
wm4 283139607c command: export list of editions as properties 2014-02-19 00:42:05 +01:00
wm4 dc0636102c command: export codec for each track 2014-02-19 00:42:05 +01:00
wm4 09d873d5d4 player: fix start time if timeline is used (ordered chapters, EDL)
When timeline was used, and the --start option was not used, the initial
seek (needed to switch to the first timeline segment) seeked to -1 due
to an oversight.
2014-02-19 00:41:34 +01:00
wm4 e6f543ebec edl: extend with chapter timestamps
Example see edl-mpv.rst.

What is this useful for? No clue...
2014-02-19 00:06:00 +01:00
wm4 d29661af8a edl: fix offset of user-visible chapters
Basically, chapter marks and chapter seek-points were incorrect, while
the rest worked.
2014-02-19 00:05:14 +01:00
wm4 5fcf4b46f7 client API: add events for video and audio reconfig 2014-02-17 02:52:59 +01:00
wm4 24fa69dbfa lua: add mechanism for script provided key bindings
There was already an undocumented mechanism provided by
mp.set_key_bindings and other functions, but this was relatively
verbose, and also weird. It was mainly to make the OSC happy (including
being efficient and supporting weird corner cases), while the new
functions try to be a bit simpler.

This also provides a way to let users rebind script-provided commands.

(This mechanism is less efficient, because it's O(n^2) for n added key
bindings, but it shouldn't matter.)
2014-02-17 02:52:58 +01:00
wm4 75d3267b43 client API: add a client message event
This comes with a "script_message" input command, which sends these
messages. Used by the following commits.
2014-02-17 02:52:58 +01:00
wm4 5fd661b50e lua: allow giving fallback values in get_property() calls
E.g. ``mp.get_property("foo", "value")`` will return ``value`` if the
property can't be read.
2014-02-17 02:52:58 +01:00
wm4 1fa8e2b602 lua: remove redundant inline documentation
Nobody will loom at this, and the proper documentation of these
functions is in lua.rst.
2014-02-17 02:52:58 +01:00
wm4 98349fa910 command: export chapter list as properties 2014-02-16 03:51:02 +01:00
wm4 e41d27c7db command: export playlist as properties 2014-02-16 03:51:02 +01:00
wm4 92133b1dcd command: expose track list as properties 2014-02-16 03:51:02 +01:00
wm4 c236cb7679 command: export more video params as properties
This uses the previously added sub-property mechanism to export a bunch
of stuff. For example, "video-params/w" now contains the video width.
2014-02-16 03:51:02 +01:00
wm4 ce6fb9175c options: make --no-config block all auto-loaded configuration files
Until now, the --no-config was explicitly checked in multiple places to
suppress loading of config files.

Add such a check to the config path code itself, and refuse to resolve
_any_ configuration file locations if the option is set.

osc.lua needs a small fixup, because it didn't handle the situation when
no path was returned. There may some of such cases in the C code too,
but I didn't find any on a quick look.
2014-02-14 14:01:27 +01:00
wm4 c2e8f8fb89 lua: auto-load scripts from ~/.mpv/lua/
This is like passing them to --lua.
2014-02-14 14:01:27 +01:00
wm4 414c4f9322 lua: make register_event() not overwrite previous event handler
Instead, chain them.

Note that there's no logic to prevent the other event handlers to be run
from an event handler (like it's popular in GUI toolkits), because I
think that's not very useful for this purpose.
2014-02-14 14:01:27 +01:00
wm4 098f0c67e6 player: select subtitles added with sub_add
In particular, this affects drag & drop of subtitles, which uses sub_add
internally. This will make the subtitles show up immediately, instead of
requiring manual selection of the added subtitle.

Might be not so ideal when adding multiple subtitles at once, because
that leads to multiple sub_add commands, and will end up with the last
subtitle instead of the first selected. But this is a minor detail.
2014-02-13 13:30:31 +01:00
wm4 b8901bf04d command: fix metadata property
This crashed when retrieving the raw property value. Oops.
2014-02-12 22:00:23 +01:00
wm4 623cffdce9 player: fix --force-window on OSX
The initialization code was split and refactored for the libmpv changes.
One change, moving a part of cocoa initialization, accidentally broke
--force-window on OSX, which creates a VO in a certain initialization
stage. We still don't know how cocoa should behave with libmpv, so fix
this with a hack to beat it back into working. Untested.
2014-02-11 20:11:05 +01:00
wm4 212d4e6061 lua: some minor API changes 2014-02-11 00:57:40 +01:00
wm4 33c6cbef3a lua: add set_property function 2014-02-11 00:23:10 +01:00
wm4 444f79d86f lua: change error behavior
Return the error Lua-style, instead of raising it as Lua error. This is
better, because raising errors is reserved for more "fatal" conditions.
Pretending they're exceptions and trying to do exception-style error
handling will just lead to pain in this language.
2014-02-11 00:10:25 +01:00
wm4 7a53dd5f2f lua: rename some API functions
send_command     -> command
send_commandv    -> commandv
get_timer        -> get_time
property_get     -> get_property
property_get_string -> get_property_osd
getopt           -> get_opt
2014-02-11 00:01:57 +01:00
wm4 3dd12104d9 build: add option to build a library
This library will export the client API functions.

Note that this doesn't allow compiling the command line player to link
against this library yet. The reason is that there's lots of weird stuff
required to setup the execution environment (mostly Windows and OSX
specifics), as well as things which are out of scope of the client API
and every application has to do on its own. However, since the mpv
command line player basically reuses functions from the mpv core to
implement these things, it's not very easy to separate the command
line player form the mpv core.
2014-02-10 21:25:22 +01:00
wm4 92a004bf87 lua: add a timer API 2014-02-10 21:07:23 +01:00
wm4 206616b697 lua: port to client API
This is partial only, and it still accesses some MPContext internals.
Specifically, chapter and track lists are still read directly, and OSD
access is special-cased too.

The OSC seems to work fine, except using the fast-forward/backward
buttons. These buttons behave differently, because the OSC code had
certain assumptions how often its update code is called.

The Lua interface changes slightly.

Note that this has the odd property that Lua script and video start
at the same time, asynchronously. If this becomes an issue, explicit
synchronization could be added.
2014-02-10 21:03:59 +01:00
wm4 88ae914b1e Add a client API
Add a client API, which is intended to be a stable API to get some rough
control over the player. Basically, it reflects what can be done with
input.conf commands or the old slavemode. It will replace the old
slavemode (and enable the implementation of a new slave protocol).
2014-02-10 21:01:35 +01:00
wm4 c6166ff448 timer: init only once
This avoids trouble if another mpv instance is initialized in the same
process.

Since timeBeginPeriod/timeEndPeriod are hereby not easily matched
anymore, use an atexit() handler to call timeEndPeriod, so that we
can be sure these calls are matched, even if we allow multiple
initializations later when introducing the client API.
2014-02-10 01:12:34 +01:00
wm4 8437356b6c options: add --no-terminal switch
Mostly useful for internal reasons. This code will be enabled by
default if mpv is started via the client API.
2014-02-10 00:14:52 +01:00
wm4 c0771b8144 player: fix an assert when reinitializing audio in some cases
This sometimes happened when changing playback speed (= reinitializing
audio) after seeking of playback start. The assertion in audio.c:441 was
triggered, because buffer_playable_samples wasn't reset correctly when
the audio buffer was cleared or shortened. The assertion is correct and
should hold up any time.
2014-02-09 18:59:44 +01:00
wm4 17ec073a15 player: handle seek delays differently
The code removed from handle_input_and_seek_coalesce() did two things:

1. If there's a queued seek, stop accepting non-seek commands, and delay
   them to the next playloop iteration.
2. If a seek is executing (i.e. the seek was unqueued, and now it's
   trying to decode and display the first video frame), stop accepting
   seek commands (and in fact all commands that were queued after the
   first seek command). This logic is disabled if seeking started longer
   than 300ms ago. (To avoid starvation.)

I'm not sure why 1. would be needed. It's still possible that a command
immediately executed after a seek command sees a "seeking in progress"
state, because it affects queued seeks only, and not seeks in progress.
Drop this code, since it can easily lead to input starvation, and I'm
not aware of any disadvantages.

The logic in 2. is good to make seeking behave much better, as it
guarantees that the video display is updated frequently. Keep the core
idea, but implement it differently. Now this logic is applied to seeks
only. Commands after the seek can execute freely, and like with 1., I
don't see a reason why they couldn't. However, in some cases, seeks are
supposed to be executed instantly, so queue_seek() needs an additional
parameter to signal the need for immediate update.

One nice thing is that commands like sub_seek automatically profit from
the seek delay logic. On the other hand, hitting chapter seek multiple
times still does not update the video on chapter boundaries (as it
should be).

Note that the main goal of this commit is actually simplification of the
input processing logic and to allow all commands to be executed
immediately.
2014-02-07 22:29:50 +01:00
wm4 eb1ec14b67 demux: handle tag updates differently
Instead of printing lines like:

    Demuxer info GENRE changed to Alternative Rock

Just output all tags once they change. The assumption is that individual
tags rarely change, while all tags change in the common case.

This changes tag updates to use polling. This could be fixed later,
although the ICY stuff makes it a bit painful, so maybe it will remain
this way.

Also remove DEMUXER_CTRL_UPDATE_INFO. This was intended to check for tag
updates, but now we use a different approach.
2014-02-06 13:41:20 +01:00
wm4 208c54a710 player: refresh OSD on track switching
Apparently, at least sub_reload was missing a refresh at all.
2014-02-03 22:01:09 +01:00
wm4 b270f5e177 command: output more information in colorspace properties and simplify
Instead of trying to be clever to avoid outputting redundant
information, simply output everything that we have.
2014-02-03 22:01:09 +01:00
James Ross-Gowan d26ee98fa6 w32: use safe DLL search paths everywhere
Windows applications that use LoadLibrary are vulnerable to DLL
preloading attacks if a malicious DLL with the same name as a system DLL
is placed in the current directory. mpv had some code to avoid this in
ao_wasapi.c. This commit just moves it to main.c, since there's no
reason it can't be used process-wide.

This change can affect how plugins are loaded in AviSynth, but it
shouldn't be a problem since MPC-HC also does this and it's a very
popular AviSynth client.
2014-01-27 10:04:29 +01:00
James Ross-Gowan 4c83a93617 w32: enable heap corruption detection
Enable the terminate-on-corruption feature. This is recommended for new
Windows applications and shouldn't cause a performance hit. It actually
shouldn't change anything for 64-bit builds, since Win64 has this
switched on by default.

See:
http://blogs.msdn.com/b/michael_howard/archive/2008/02/18/faq-about-heapsetinformation-in-windows-vista-and-heap-based-buffer-overruns.aspx
2014-01-27 10:04:29 +01:00
James Ross-Gowan c3bcc12a3c w32: don't disable the error reporting dialog
Windows users expect this when a program crashes. Without it, the
program just disappears. Also change the SetErrorMode call to use macros
instead of a hardcoded constant.
2014-01-27 10:04:29 +01:00