Commit Graph

208 Commits

Author SHA1 Message Date
wm4 453fea87fa client API: create core thread at an earlier time
Create the core thread right in mpv_create(), and reduce what
mpv_initialize() does further. This is simpler, and allows the API user
to do more before calling mpv_initialize(). The latter is not the real
goal, rather we'd like mpv_intialize() reduced to do almost nothing. It
still does a lot, but nothing truly special anymore that is absolutely
required for basic mpv workings.

One thing we want the user to be able to do is changing properties
before mpv_initialize() to reduce the special status of
mpv_set_option().
2016-09-01 21:55:21 +02:00
wm4 b10dcecf7d client API: deprecate "no-..." option handling
The client API can do this (and there are apparently some libmpv using
projects which rely on this). But it's just unnecessary bloat as it
requires a separate code path from the option parser. It would be better
to remove this code. Formally deprecate it, including API bump and
warning in the API changes file to make it really clear.
2016-08-31 22:16:43 +02:00
wm4 56c52bd2e1 stream_cb: fix stale comment
Oops.
2016-08-08 10:34:12 +02:00
wm4 3a21d71ad0 client API: bump API for stream_cb
Forgotten in previous commit.

Also minor semi-related change: remove the extra "," from the
mpv_sub_api enum, which I accidentally added in the previous commit.
(C99 is fine with trailing ",", C89 strictly speaking not. So do
this for maximum compatibility.)
2016-08-07 19:42:20 +02:00
Aman Gupta 7ca4a453e0 client API: add stream_cb API for user-defined stream implementations
Based on #2630. Some heavy changes by committer.

Signed-off-by: wm4 <wm4@nowhere>
2016-08-07 19:33:20 +02:00
wm4 52a0cbe456 client API: fix indentation 2016-08-07 19:33:20 +02:00
wm4 5640ceb838 client API: add MPV_ERROR_GENERIC
Because why not.
2016-08-07 19:33:20 +02:00
Timotej Lazar 91a1b17104 Use - as command-name separator everywhere
Old-style commands using _ as separator (e.g. show_progress) were still
used in some places, including documentation and configuration files.
This commit updates all such instances to the new style (show-progress)
so that commands are easier to find in the manual.
2016-07-14 22:37:42 +02:00
wm4 26b6873ffd client API: remove "status" log level from mpv_request_event docs
Although it appears to be accepted by the function, MSGL_STATUS messages
are never passed to the client API. Consequently "status" has the same
meaning as "v" and is useless.
2016-07-08 16:10:57 +02:00
wm4 645a0d7791 client API: fully document opengl-cb hardware decoding interop
Document it exhaustively. Most of these issues were basically burried in
the code.
2016-06-01 22:33:36 +02:00
wm4 a9bd4535d2 client API: improve mpv_set_property() handling of MPV_FORMAT_NODE
If a mpv_node wrapped a string, the behavior was different from calling
mpv_set_property() with MPV_FORMAT_STRING directly. Change this.

The original intention was to be strict about types if MPV_FORMAT_NODE
is used. But I think the result was less than ideal, and the same change
towards less strict behavior was made to mpv_set_option() ages ago.
2016-04-15 11:32:40 +02:00
wm4 c8b6ca9070 qthelper: fix potential NULL deref in error path
Found by clang-tidy.
2016-03-22 10:01:59 +01:00
wm4 06fcabd06e DOCS: add some hints to the new examples repository 2016-03-10 21:59:21 +01:00
wm4 e1e052a58e client API: explain when mpv_create() can return NULL 2016-02-14 12:44:53 +01:00
Aman Gupta fccc3d3894 Fix some typos in code comments
Signed-off-by: wm4 <wm4@nowhere>
2015-12-21 22:28:12 +01:00
wm4 3dc0f2ecf0 vo_opengl_cb: make operation more similar to normal VOs
vo_opengl_cb is a special case, because we somehow have to render video
asynchronously, all while "trusting" the API user to do it correctly.
This didn't quite work, and a while ago a compromise using a timeout to
prevent theoretically possible deadlocks was added.

Make it even more synchronous. Basically, go all the way, and
synchronize rendering between VO and user renderer thread to the
full extent possible.

This means the silly frame queue is dropped, and we event attempt to
synchronize the GL SwapBuffer call (via mpv_opengl_cb_report_flip()).

The changes introduced with commit dc33eb56 are effectively dropped. I
don't even remember if they mattered.

In the future, we might make all VOs fetch asynchronously from a frame
queue, which would mostly remove the differences between vo_opengl and
vo_opengl_cb, but this will take a while (if it will even be done).
2015-11-09 20:51:57 +01:00
wm4 878f12885b client API: fix typo and wording in a comment 2015-10-22 19:36:38 +02:00
wm4 46c499d02a DOCS/client_api_examples/README: rewrite
The new one is much more detailed.

Also add part of it to the libmpv doxygen.
2015-10-10 15:44:27 +02:00
wm4 0e9cfa6b64 vo_opengl: add mechanism to retrieve Display from EGL context
The VAAPI EGL interop code will need access to the X11 Display. While
GLX could return it from the current GLX context, EGL has no such
mechanism. (At least no standard one supported by all implementations.)
So mpv makes up such a mechanism.

For internal purposes, this is very rather awkward solution, but it's
needed for libmpv anyway.
2015-09-25 00:20:11 +02:00
wm4 b14c9eb748 client API: rename GL_MP_D3D_interfaces
This is a pseudo-OpenGL extension for letting libmpv query native
windowing system handles from the API user. (It uses the OpenGL
extension mechanism because I'm lazy. In theory it would be nicer to let
the user pass them with mpv_opengl_cb_init_gl(), but this would require
a more intrusive API change to extend its argument list.)

The naming of the extension and associated function was unnecessarily
Windows specific (using "D3D"), even though it would work just fine for
other platforms. So deprecate the old names and introduce new ones. The
old ones still work.
2015-09-24 21:07:37 +02:00
wm4 b989bb96d1 client API: change subtle wording to different subtle wording
Make a difference between different mpv_handles pointing to the same mpv
core, or different mpv cores. While we're not explicit about it, at
least avoid that someone could misunderstand when really looking for the
case of mpv_handles pointing to the same core.
2015-08-12 23:04:05 +02:00
wm4 561416597e client API, dxva2: add a workaround for OpenGL fullscreen issues
This is basically a hack for drivers which prevent the mpv DXVA2 decoder
glue from working if OpenGL is in fullscreen mode.

Since it doesn't add any "hard" new API to the client API, some of the
code would be required for a true zero-copy hw decoding pipeline, and
sine it isn't too much code after all, this is probably acceptable.
2015-07-03 16:38:12 +02:00
wm4 23b83c6676 client API: allow using msg-level option for log messages
Client API users can enable log output with mpv_request_log_messages().
But you can enable only a single log level. This is normally enough, but
the --msg-level option (which controls the terminal log level) provides
more flexibility. Due to internal complexity, it would be hard to
provide the same flexibility for each client API handle. But there's a
simple way to achieve basically the same thing: add an option that sends
log messages to the API handle, which would also be printed to the
terminal as by --msg-level.

The only change is that we don't disable this logic if the terminal is
disabled. Instead we check for this before the message is output, which
in theory can lower performance if messages are being spammed. It could
be handled with some more effort, but the gain would be negligible.
2015-06-20 21:40:47 +02:00
wm4 e53cb0890e client API: add MPV_END_FILE_REASON_REDIRECT
Requested. Minor incompatible behavior change, as it was signalling
MPV_END_FILE_REASON_EOF previously.
2015-06-11 21:42:09 +02:00
wm4 4858c47e1c Always block SIGPIPE globally
OpenSSL and GnuTLS are still causing this problem (although FFmpeg could
be blamed as well - but not really). In particular, it was happening to
libmpv users and in cases the pseudo-gui profile is used. This was
because all signal handling is in the terminal code, so if terminal is
disabled, it won't be set. This was obviously a questionable shortcut.

Avoid further problems by always blocking the signal. This is done even
for libmpv, despite our policy of not messing with global state.

Explicitly document this in the libmpv docs. It turns out that a version
bump to 1.17 was forgotten for the addition of MPV_FORMAT_BYTE_ARRAY, so
document that change as part of 1.16.
2015-05-11 17:38:35 +02:00
wm4 3477088741 player: use profiles for libmpv and encoding defaults
The client API (libmpv) and encoding (--o) have slightly different
defaults from the command line player. Instead of doing a bunch of calls
to set the options explicitly, use profiles. This is simpler and has the
advantage that they can be listed on command line (instead of possibly
forcing the user to find and read the code to know all the details).
2015-05-07 21:26:11 +02:00
wm4 ccfe4d6418 client API: add MPV_FORMAT_BYTE_ARRAY type
This will be used in the following commit, which adds screenshot_raw.

The reasoning is that this will be better for binding scripting
languages.

One could special-case the screenshot_raw commit and define fixed
semantics for passing through a pointer using the current API, like
formatting a pointer as string. But that would be ridiculous and
unclean.
2015-04-20 23:09:34 +02:00
wm4 e76f6929e5 vo_opengl_cb: deprecate mpv_opengl_cb_render()
Its vp parameter made no sense anymore. Introduce a new one.
2015-04-09 19:31:01 +02:00
wm4 8dc7156bc0 vo_opengl_cb: add a function to report vsync time
And also let vo.c know of it.

Currently, this does not help much, but will facilitate future
improvements.
2015-04-09 19:30:26 +02:00
wm4 90adf2904e client API: clarify mpv_opengl_cb_render() viewport parameter
Basically, the idea behind the vp parameter is broken - I guess the
intention was to enable rendering to a specific subrectangle of the
target framebuffer, but there's nothing to specify the actual target
rectangle (the VO will still clear e.g. the borders between video and
framebuffer borders).

We're not going to keep the current semantics either with the upcoming
rework of vo_opengl, so declare this for broken. Maybe we can introduce
a function later which does this properly.
2015-03-09 22:51:28 +01:00
wm4 2e26639155 player, client API: refactor cplayer init, reduce client API differences
Move the command line parsing and some other things to the common init
routine shared between command line player and client API. This means
they're using almost exactly the same code now.

The main intended side effect is that the client API will load mpv.conf;
though still only if config loading is enabled.

(The cplayer still avoids creating an extra thread, passes a command
line, and prints an exit status to the terminal. It also has some
different defaults.)
2015-03-05 11:22:15 +01:00
wm4 d77fdc8f82 client API: hint that opengl_cb is an alternative to window embedding 2015-02-23 16:07:11 +01:00
wm4 a799a4c57f client API: clarify filename string encoding
Admittedly, the behavior on Windows is not quite straightforward. The
behavior on the other platforms is equivalent to fopen().

Fixes #1585.
2015-02-14 14:36:48 +01:00
wm4 ef827af06c client API: add mpv_wait_async_requests()
This does what it's documented to do.

The implementation reuses the code in mpv_detach_destroy(). Due to the
way async requests currently work, just sending a synchronous dummy
request (like a "ignore" command) would be enough to ensure
synchronization, but this code will continue to work even if this
changes.

The line "ctx->event_mask = 0;" is removed, but it shouldn't be needed.
(If a client is somehow very slow to terminate, this could silence an
annoying queue overflow message, but all in all it does nothing.)

Calling mpv_wait_async_requests() and mpv_wait_event() concurrently is
in theory allowed, so change pthread_cond_signal() to
pthread_cond_broadcast() to avoid missed wakeups.

As requested in issue #1542.
2015-02-02 18:07:37 +01:00
wm4 64f72687ce client API: notify API user on event queue overflow
Before this, we merely printed a message to the terminal. Now the API
user can determine this properly. This might be important for API users
which somehow maintain complex state, which all has to be invalidated if
(state-changing) events are missing due to an overflow.

This also forces the client API user to empty the event queue, which is
good, because otherwise the event queue would reach the "filled up"
state immediately again due to further asynchronous events being added
to the queue.

Also add some minor improvements to mpv_wait_event() documentation, and
some other minor cosmetic changes.
2015-01-19 21:26:42 +01:00
xylosper a4c0e254a3 vo_opengl_cb: make mpv_opengl_cb_render() return left frames
Instead of error code which was not helpful because it's always 0,
mpv_opengl_cb_render() returns the number of left frames in the
frame queue now.
2015-01-08 21:32:22 +01:00
wm4 a91f127246 client API: clarify some vo_opengl_cb requirements
Stupid drivers. I hope the problem described here isn't actually common.
2015-01-04 22:21:14 +01:00
wm4 84fe12fab5 client API: add function to create new mpv_handles from existing ones
This may or may not be useful for client API users.

Fold this API extension into the previous API bump. The previous bump
was only yesterday, so it's ok.
2014-12-31 20:50:06 +01:00
wm4 a850bf786e vo_opengl_cb: simplify API uninitialization
Until now, calling mpv_opengl_cb_uninit_gl() at a "bad moment" could
make the whole thing to explode. The API user was asked to avoid such
situations by calling it only in "good moments". But this was probably a
bit too subtle and could easily be overlooked.

Integrate the approach the qml example uses directly into the
implementation. If the OpenGL context is to be unitialized, forcefully
disable video, and block until this is done.
2014-12-31 20:31:19 +01:00
wm4 799e8861bb client API: qthelper: return NULL as handle if unset
Creating a plain Handle() should yield a NULL mpv_handle.

Also, remove the redundant non-const definition of the conversion
operator. At least in this situation it's not needed.

Also, add include guards around qthelper.hpp.
2014-12-30 23:28:07 +01:00
wm4 50c40b6ded client API: qthelper: add a refcounting wrapper around mpv_handle
This is useful to deal with crazy Qt object lifetime issues (the
following commit needs it).
2014-12-30 22:24:57 +01:00
wm4 7f36d1532e client API: document requirement to block SIGPIPE
I noticed that the IPC code does not use MSG_NOSIGNAL or SO_NOSIGPIPE.
The former is "only" POSIX 2008 and also requires switching to sendto(),
while the latter is even less portable.

Not going to bother with this obsolete 80ies crap, just block SIGPIPE,
and instruct client API users to do the same.
2014-12-24 13:25:33 +01:00
wm4 fb855b8659 client API: expose OpenGL renderer
This adds API to libmpv that lets host applications use the mpv opengl
renderer. This is a more flexible (and possibly more portable) option to
foreign window embedding (via --wid).

This assumes that methods like context sharing and multithreaded OpenGL
rendering are infeasible, and that a way is needed to integrate it with
an application that uses a single thread to render everything.

Add an example that does this with QtQuick/qml. The example is
relatively lazy, but still shows how relatively simple the integration
is. The FBO indirection could probably be avoided, but would require
more work (and would probably lead to worse QtQuick integration, because
it would have to ignore transformations like rotation).

Because this makes mpv directly use the host application's OpenGL
context, there is no platform specific code involved in mpv, except
for hw decoding interop.

main.qml is derived from some Qt example.

The following things are still missing:
- a way to do better video timing
- expose GL renderer options, allow changing them at runtime
- support for color equalizer controls
- support for screenshots
2014-12-09 17:59:04 +01:00
wm4 ae5df9be98 input, lua: redo input handling
Much of it is the same, but now there's the possibility to distinguish
key down/up events in the Lua API.
2014-11-23 15:13:35 +01:00
wm4 f5c2e3d6e2 client API: deprecate some events
Following the discussion in #1253.

The events won't be removed for a while, though. (Or maybe never, unless
we run out of bits for the uint64_t event mask.)

This is not a real change (the events still work, and the alternative
mechanisms were established a few API revisions earlier), but for the
sake of notifying API users, update DOCS/client-api-changes.rst.
2014-11-08 10:19:07 +01:00
wm4 e002ba74d3 client API: additional documentation comments
(I guess some of the mpv_event contents turned out relatively awkward.)
2014-11-07 16:21:51 +01:00
wm4 61b06f3756 client API: nothing uses the result parameter of mpv_command_node()
Add a comment about this to avoid confusing users of this function. The
parameter is essentially unused, but exists so that we don't need to
add extra APIs if the need for it arises.
2014-11-02 17:46:53 +01:00
wm4 8c3baffadb client API: qthelper: add set_option_variant() 2014-10-30 11:29:45 +01:00
wm4 65db3291b3 client API: better error reporting
Give somewhat more information on playback failure.
2014-10-28 20:30:12 +01:00
wm4 3cde02fe22 client API: add an enum for mpv_event_end_file.reason
Using magic integer values was an attempt to keep the API less verbose.
But it was probably not a good idea.

Reason 1 (restart) is not made explicit, because it is not used anymore
starting with the previous commit. For ABI compatibility, the value is
left as a hole in the enum.
2014-10-28 20:30:12 +01:00
wm4 98356b81b4 client API: clarify statement about thread-safety
The only reason for mpv_wait_event() not being thread-safe is that it
returns a pointer to a mpv_event struct member in the mpv_handle
context, which in turn is done for ABI-safety (user doesn't allocate or
manage the struct), and to avoid the need additional memory management.

Some users were interpreting this incorrectly.
2014-10-28 20:30:11 +01:00
wm4 fe5ba6e217 client API: qthelper: remove commented code
This is already taken care of by Q_DISABLE_COPY().
2014-10-14 22:05:15 +02:00
wm4 95dda1050d client API: qthelper: fix bugs
Pretty dumb oversights.
2014-10-14 13:20:05 +02:00
wm4 1c5dbdbfc2 client API: add qthelper.hpp
This provides some helper functions and classes for C++/Qt. As the top
of qthelper.hpp says, this is built on top of the client API, and is a
mere helper provided for convenience.

Maybe this should be a separate library, but on the other hand I don't
see much of a point in that. It's also header-only, but C++ people like
such things. This makes it easier for us, because we don't need to care
about ABI compatibility.

The client API doesn't change, but bump it so that those who are using
this header can declare a proper dependency.
2014-10-13 23:54:19 +02:00
James Ross-Gowan e48b2bd4d1 libmpv/mpv.def: add mpv_command_node[_async] 2014-10-12 00:56:40 +11:00
wm4 63e2b6c4ae client API: add mpv_command_node[_async]
Allows passing native types as arguments.

Also some minor doc improvements, including giving some (natural)
improvements to mpv_free_node_contents().

Note: mpv_command_node_async() is completely untested.
2014-10-11 00:33:09 +02:00
wm4 0ec5d35d57 client API: introduce numeric log levels
Maybe using strings for log levels was a mistake (too broad and too
impractical), so I'm adding numeric log level at least for the receiver
side. This makes it easier to map mpv log levels to other logging
systems.

I'm still too stingy to add a function to set the log level by a numeric
value, though.

The numeric values are not directly mapped to the internal mpv values,
because then almost every file in mpv would have to include the client
API header.

Coalesce this into API version 1.6, since 1.6 was bumped just yesterday.
2014-10-08 14:17:33 +02:00
wm4 f73778ad82 msg, client API: buffer partial lines
The API could return partial lines, meaning the message could stop
in the middle of a line, and the next message would have the rest of
it (or just the next part of it). This was a pain for the user, so do
the nasty task of buffering the lines ourselves.

Now only complete lines are sent. To make things even easier for the
API user, don't put multiple lines into a single event, but split them.

The terminal output code needed something similar (inserting a prefix
header on start of each line). To avoid code duplication, this commit
refactors the terminal output so that lines are split in a single
place.
2014-10-08 13:11:55 +02:00
wm4 046ad8c5ae msg: set an explicit overflow message
So client API users don't have to worry about this specifically.

Also document the overflow case. (Not sure if we really need to do
this; maybe it'd be better not to, since this just adds more noise
to the docs.)
2014-10-08 12:49:04 +02:00
wm4 5feec17ca8 client API: improve mpv_observe_property docs
Document the "normal" behavior (if MPV_FORMAT_NONE is not used) first,
and then introduce MPV_FORMAT_NONE as exception.

The actual semantics didn't change in mpv; this is only clarification.
2014-10-07 21:22:05 +02:00
wm4 128bb68d29 client API: clarify pause/unpause events, modify core-idle property
Whether you consider the semantics weird or not depends on your use
case, but I suppose it's a bit confusing anyway. At this point, we keep
MPV_EVENT_PAUSE/UNPAUSE for compatibility only.

Make the "core-idle" property somewhat more useful in this context.
2014-10-07 21:01:19 +02:00
wm4 3273db1ef7 client API, X11: change default keyboard input handling again
Commit 64b7811c tried to do the "right thing" with respect to whether
keyboard input should be enabled or not. It turns out that X11 does
something stupid by design. All modern toolkits work around this native
X11 behavior, but embedding breaks these workarounds.

The only way to handle this correctly is the XEmbed protocol. It needs
to be supported by the toolkit, and probably also some mpv support. But
Qt has inconsistent support for it. In Qt 4, a X11 specific embedding
widget was needed. Qt 5.0 doesn't support it at all. Qt 5.1 apparently
supports it via QWindow, but if it really does, I couldn't get it to
work.

So add a hack instead. The new --input-x11-keyboard option controls
whether mpv should enable keyboard input on the X11 window or not. In
the command line player, it's enabled by default, but in libmpv it's
disabled.

This hack has the same problem as all previous embedding had: move the
mouse outside of the window, and you don't get keyboard input anymore.
Likewise, mpv will steal all keyboard input from the parent application
as long as the mouse is inside of the mpv window.

Also see issue #1090.
2014-09-28 20:11:00 +02:00
wm4 64b7811c28 x11: when using --wid, inherit event flags from parent window
When embedding a X window, it's hard to control whether it receives
mouse/keyboard input or not. It seems the X protocol itself makes this
hard (basically due to the outdated design mismatching with modern
toolkits), and we have to take care of these things explicitly.

Simply do this by manually querying and using the parent window event
flags.

This restores some MPlayer behavior (it doesn't add back exactly the
same code, but it's very similar).

This probably has some potential to interfere with libmpv embedding, so
bump the client API minor.

CC: @mpv-player/stable (if applied, client-api-changes.rst has to be
    adjusted to include the 0.5.2 release)
2014-08-31 14:48:26 +02:00
wm4 a31330608b client API: adjust documentation for mpv_suspend()
It's not true anymore that the core will stop replying for 50ms
(waiting for video) without calling this function. Simplify the
documentation accordingly. Accessing properties that go through
the VO still have this problem, though.
2014-08-14 19:29:21 +02:00
wm4 7898169484 build: add hacks to force waf to generate valid .pc files
Don't like this? You're invited to fix this crap.
2014-08-07 23:45:40 +02:00
wm4 5a0db9bf8a build: move def file to libmpv/
This is more consistent with mpv.pc, which is also in libmpv/.
2014-08-05 20:02:41 +02:00
wm4 43ddf2099b client API: add and use the MPV_MAKE_VERSION macro
This is probably nicer. The actual version number doesn't change (other
than the minor being incremented).

The "| 0UL" is to make the type unsigned long int, like it was before.
2014-08-05 02:23:14 +02:00
wm4 0f5aed9c62 player: some further playloop cleanups
Handle --term-playing-msg at a better place.

Move MPV_EVENT_TICK hack into a separate function. Also add some words
to the client API that you shouldn't use it. (But better leave breaking
it for later.)

Handle --frames and frame_step differently. Remove the mess from the
playloop, and do it after frame display. Give up on the weird semantics
for audio-only mode (they didn't make sense anyway), and adjust the
manpage accordingly.
2014-08-03 20:31:00 +02:00
wm4 b4f24544bb client API: make "cache" property and similar observable
Achieve this by polling. Will be used by the OSC. Basically a bad hack -
but the point is that the mpv core itself is in the best position to
improve this later.
2014-07-31 04:19:41 +02:00
wm4 471dfba018 client API: fix typos in documentation 2014-07-30 03:33:37 +02:00
wm4 acd60736ef Remove stream_pts stuff
This was used by DVD/BD, but its usage was removed with one of the
previous commits.
2014-07-06 19:05:59 +02:00
wm4 0004aaf788 DOCS: add a file listing API changes for the client API 2014-07-03 01:26:19 +02:00
wm4 05fd3e701b client API: declare as stable
It is reasonably stable, so all further changes will be versioned.

Also change how the libmpv version number is generated. Fix the patch
version number to 0; I don't think we have a use for this. In
particular, the version doesn't version mpv, just the client API.
2014-06-20 19:26:04 +02:00
wm4 09dd1ed47c client API: minor documentation fixes/enhancements 2014-06-08 16:11:39 +02:00
wm4 5cc68c792b client API: restructure waiting, do log msg wakeup properly
Until now, availability of new log messages (through the mechanism
associated with mpv_request_log_messages()) did not wakeup the client
API properly. Commit 3b7402b5 was basically a hack to improve that
somewhat, but it wasn't a solution.

The main problem is that the client API itself is producing messages, so
the message callback would attempt to lock the client API lock,
resulting in a deadlock. Even if the lock was recursive, we'd run into
lock-order issues.

Solve this by using a separate lock for waiting and wakeup. Also, since
it's a natural addition, avoid redundant wakeups. This means the wakeup
callback as well as the wakeup pipe will be triggered only once until
the next mpv_wait_event() call happens.

This might make the wakeup callback be invoked in a reentrant way for
the first time, for example if a mpv_* function prints to a log. Adjust
the docs accordingly. (Note that non-reentrant beheavior was never
guaranteed - basically the wakeup callback is somewhat dangerous and
inconvenient.)

Also remove some traces of unneeded code. ctx->shutdown for one was
never set, and probably a leftover of an abandoned idea.
2014-06-07 23:16:46 +02:00
wm4 fca608ccb9 client API: rename mpv_destroy() to mpv_detach_destroy()
A bit verbose, but less misleading. In most cases, the API user probably
actually wants mpv_terminate_destroy() instead, so the less-useful
function shouldn't have a simnpler name anyway.
2014-06-07 20:25:48 +02:00
wm4 0b9468f65f client API: clarify mpv_get_wakeup_pipe docs
It wasn't necessarily clear how this works. Especially make clear that
the API user shouldn't expect that there's one byte per readable event
in the wakeup pipe. Actually, the reason why this currently won't work
is because property notifications can generate more events than wakeups.
The limit of 4096 is a more fundamental issue, but the event ringbuffer
is currently limited to 1000 entries anyway.

Also add some important comments to mpv_set_wakeup_callback.
2014-06-07 20:13:01 +02:00
wm4 500ce69a06 client API: add API function that ensures total destruction
mpv_destroy() should perhaps better be called mpv_detach(), because it
destroys only the handle, not necessarily the player. The player is only
terminated if a quit command is sent.

This function quits automatically, and additionally waits until the
player is completely destroyed. It removes the possibility that the
player core is still uninitializing, while all client handles are
already destroyed. (Although in practice, the difference is usually not
important.)
2014-06-07 15:57:54 +02:00
wm4 d64bd9efa1 client API: docs: some clarifications 2014-06-07 15:57:54 +02:00
wm4 a1000962e3 client API: change mpv_wait_event() timeout semantics
Now a negative timeout mean an infinite timeout. This is similar to the
poll() system call. Apparently this is more intuitive and less confusing
than specifying a "very high" value as timeout if you want to wait
forever.

For callers that never pass negative timeouts, nothing changes.
2014-06-07 15:57:47 +02:00
wm4 5a5a3c53f7 client API: report success status when running commands
Until now, an error was reported only if the command couldn't be parsed.
Attempt to do more fine-grained reporting. This is not necessarily
perfect, but it's an improvement.
2014-06-01 03:41:46 +02:00
wm4 537ac1a15f client API: add mpv_load_config_file()
This is probably a good idea, because it would make it easier for
software embedding mpv to configure the mpv parts, without requiring the
host program to provide explicit mechanisms for this (other than calling
mpv_load_config_file()).
2014-05-18 19:21:39 +02:00
wm4 e8a996cede client API: add chapter change event
Also works for mpv_observe_property() on the "chapter" property.
2014-04-27 22:28:07 +02:00
wm4 196619671d client API: remove mpv_event_pause_reason
And slightly adjust the semantics of MPV_EVENT_PAUSE/MPV_EVENT_UNPAUSE.

The real pause state can now be queried with the "core-idle" property,
the user pause state with the "pause" property, whether the player is
paused due to cache with "paused-for-cache", and the keep open event can
be guessed with the "eof-reached" property.
2014-04-14 22:33:41 +02:00
wm4 4e5cea86c2 client API: add mpv_get_wakeup_pipe convenience function
Should make integreating with some event loops easier. Untested.
2014-04-12 20:13:07 +02:00
wm4 86094c2c5a client API: include the reason in MPV_EVENT_END_FILE
Otherwise, the client API user could not know why playback was stopped.

Regarding the fact that 0 is used both for normal EOF and EOF on error:
this is because mplayer traditionally did not distinguish these, and in
general it's hard to tell the real reason. (There are various weird
corner cases which make it hard.)
2014-04-11 01:23:32 +02:00
wm4 fa35079361 client API: remove outdated comments 2014-04-11 00:12:35 +02:00
wm4 f0c8c26e29 client API: improve comments 2014-04-10 23:53:42 +02:00
wm4 89d400dc21 client API: avoid redundant property change events if possible
This is done simply by comparing the previous and current values. Do
this only if the requested format is not MPV_FORMAT_NONE.
2014-04-08 22:06:39 +02:00
wm4 49d1b42f70 client API: add a way to notify clients of property changes
This turned out ridiculously complex. I think it will have to be
simplified some day. Main reason for the complexity are:
- filtering properties by forcing clients to observe individual
  properties explicitly
  (to avoid spamming clients with changes they don't want)
- optional retrieval of property value with the notification
  (the basic idea was that this is more user friendly)
- allowing to the client to specify a format in which the value
  should be retrieved
  (because if a property changes its type, the client API couldn't
  convert it properly, and compatibility would break)

I don't know yet which of these are important, and everything could
change. In particular, the interface and semantics should be adjusted
to reduce the implementation complexity.

While I consider the API complete, there could (and probably will) be
bugs left. Also while the implementation is complete, it's inefficient.
The complexity of the property matching is O(a*b*c) with a clients,
b observed properties, and c properties changing at once. I threw away
an earlier implementation using bitmasks, because it was too unwieldy.
2014-04-06 03:22:49 +02:00
Alessandro Ghedini dfc57e6d32 libmpv: add pkg-config file 2014-03-11 19:15:42 +01:00
xylosper dd13e29cc2 client APIs: fix some typos 2014-02-28 20:54:47 +01:00
wm4 c30bf22d8d client API: rename MPV_EVENT_PLAYBACK_START, add MPV_EVENT_SEEK
Rename MPV_EVENT_PLAYBACK_START to MPV_EVENT_FILE_LOADED.

Add MPV_EVENT_SEEK and MPV_EVENT_PLAYBACK_RESTART.
2014-02-28 01:31:38 +01:00
wm4 f3c933e5d3 options: allow changing options at runtime
Allow changing all options at runtime, except some cherry-picked
options, which are disabled with M_OPT_FIXED.
2014-02-25 23:59:27 +01:00
wm4 279bd8db1f client API: change description of format conversions
This changed during the time between writing the comment, and finishing
up the implementation.

Although I'm still unsure about this.
2014-02-25 22:57:48 +01:00
wm4 0adb8a9aaf client API: report pause/unpause reason
Not sure about this... might redo.

At least this provides a case of a broadcasted event, which requires
per-event data allocation.

See github issue #576.
2014-02-24 22:50:25 +01:00
wm4 5d7007c644 client API: expose the internal clock
May or may not be useful in some ways.

We require a context parameter for this just to be sure, even if the
internal implementation currently doesn't.

That's one less mpv internal function for the Lua wrapper.
2014-02-24 22:50:25 +01:00
wm4 38a36fd7ea client API: add comment about character encoding issues
Also mention that NULL isn't valid. Although I'm not sure whether the
implementation strictly follows this (it should, but there are some
wacky corner cases).
2014-02-24 22:50:24 +01:00
wm4 43ad09393c client API: add more data formats, add a structured data type
This adds declarations for new formats. The implementation will be added
in the following commits. (It still compiles and runs with this commit,
because it adds constants only.)

The obvious new types are MPV_FORMAT_FLAG, MPV_FORMAT_INT64,
MPV_FORMAT_DOUBLE. MPV_FORMAT_FLAG is a boolean, but to avoid nasty ABI
issues or with languages that don't have a bool data type (C89), it uses
int. Thus the format is not named MPV_FORMAT_BOOL, to avoid confusion.

The MPV_FORMAT_NONE type (mpv_node) is a generic structured type, like a
variant or, say, JSON. It can store strings/bools/numbers, as well as
arrays and key/value pairs (with string keys only).

The MPV_FORMAT_NODE_ARRAY and MPV_FORMAT_NODE_MAP types are used
internally by mpv_node only and can't be used with most of the other API
(like mpv_set_property()) directly.
2014-02-24 20:50:47 +01:00
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
wm4 1e30048184 client API: fix a typo 2014-02-24 20:48:59 +01:00
wm4 47aeb22b75 client API: remove trailing "," from enums
This is allowed in C99 and C++11, but apparently not in C89 and C++98.

Make it conform to the older standards, since we want the client API
header to be highly portable.
2014-02-24 20:48:59 +01:00
wm4 4123c2a708 client API: spelling 2014-02-24 20:48:55 +01:00
wm4 0ad2211508 client API: add event for metadata changes 2014-02-19 16:00:37 +01:00
wm4 5fcf4b46f7 client API: add events for video and audio reconfig 2014-02-17 02:52:59 +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 5af8070a97 client API: fix description of mpv_event.error field
The description was a left over from an earlier iteration of the API.
2014-02-12 22:00:13 +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