Commit Graph

63 Commits

Author SHA1 Message Date
wang-bin 52de5ea6ad DOCS/client_api_examples: add qt widget + opengl-cb example 2015-10-11 13:58:09 +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 cb1c072534 vo_opengl: remove sharpen scalers, add sharpen sub-option
This turns the old scalers (inherited from MPlayer) into a pre-
processing step (after color conversion and before scaling). The code
for the "sharpen5" scaler is reused for this.

The main reason MPlayer implemented this as scalers was perhaps because
FBOs were too expensive, and making it a scaler allowed to implement
this in 1 pass. But unsharp masking is not really a scaler, and I would
guess the result is more like combining bilinear scaling and unsharp
masking.
2015-09-23 22:43:27 +02:00
wm4 a6694b7b96 DOCS/client_api_examples/sdl: make the window resizable 2015-09-04 22:38:19 +02:00
wm4 41d7989800 DOCS/client_api_examples/sdl: don't curse the mainloop
Fix a typo, and also reword another comment.
2015-08-17 23:56:56 +02:00
wm4 ed09e78fb9 DOCS/client_api_examples/sdl: add more explanation comments 2015-08-12 23:04:26 +02:00
wm4 b103a8e113 DOCS/client_api_examples/sdl: don't load file before GL init
Could lead to failure because it's essentially a race condition.
2015-08-11 19:02:25 +02:00
wm4 f6a354e846 DOCS/client_api_examples: add SDL OpenGL example 2015-08-11 01:23:09 +02:00
Stefano Pigozzi b50390d5da DOCS: fix wrong libmpv's cocoa example comment
libmpv can be embedded in a cocoa view (without the mpv window). This has been
the case for serveral months, and the comment is just wrong now.
2015-05-27 14:34:42 +02:00
torque 36b1b84216 DOCS/client_api_examples/cocoa-openglcb: do initial flush correctly. 2015-05-23 19:21:10 +02:00
wm4 cbaa8d65fc DOCS/client_api_examples: cocoa: minor fixes
Cocoa needs to be linked explicitly.

EXIT_SUCCESS is pretty pointless, and the same file uses exit(1) in
other places.
2015-05-21 22:45:56 +02:00
torque 83012fd77a DOCS/client_api_examples: add opengl-cb-based cocoa example.
Contains a basic toggle button that pauses the video.
2015-05-21 22:29:57 +02:00
torque 5d2a2c7fc2 DOCS/client_api_examples: Qt: force qmake to use pkg-config. 2015-05-16 20:56:44 +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
Stefano Pigozzi 03a69bac95 cocoa: remove the setNextKeyView hack
Just use makeFirstResponder on the mpv events view from client code
if you need the built in keyboard events (this is easier for dealing with view
nesting).
2015-02-28 14:55:32 +01:00
Stefano Pigozzi 721e430cd2 examples/cocoabasic: allow to send stop command 2015-02-28 14:19:26 +01:00
wm4 cf395e1754 DOCS/client_api_examples/simple: fix option
"input-x11-keyboard" still works, but is a deprecated alias with the
same functionality.
2015-02-23 16:08:38 +01:00
wm4 17e1e9f486 manpage: minor changes
Mostly related to vo_opengl.

Fix the opengl lscale option in the qml example too.
2015-01-23 17:41:50 +01:00
wm4 a0ed62fc1d build: remove bogus client API examples build
The symlink trick made waf go crazy (deleting source files, getting
tangled up in infinite recursion... I wish I was joking). This means we
still can't build the client API examples in a reasonable way using the
include files of the local repository (instead of globally installed
headers). Not building them at all is better than deleting source files.

Instead, provide some manual instructions how to build each example
(except for the Qt examples, which provide qmake project files).
2015-01-23 15:32:23 +01:00
wm4 c88b535c46 DOCS/client_api_examples: fix locale nonsense in qml examples
The Qt example already does this. I hoped this was restricted to
QApplication only, but apparently Qt repeated this mistake with
QGuiApplication (QGuiApplication was specifically added for QtQuick at a
much later point, even though QApplication inherits from it).
2015-01-15 20:08:57 +01:00
wm4 3c3883ebe1 DOCS/client_api_examples: qml_direct: QWindow::size() is not thread-safe
We still keep the window pointer, because we want to call
QQuickWindow::resetOpenGLState() (which runs on the rendering thread
only). Interesting mess...
2015-01-09 16:00:16 +01:00
wm4 803e579ff5 DOCS/client_api_examples: qml: reduce number of files
This is annoying.
2015-01-09 15:49:34 +01:00
wm4 f551fbaa25 DOCS/client_api_examples: add an alternative qml example
This one avoids use of a FBO. It's less flexible, because it uses works
around the whole QML rendering API. It seems to be the only way to get
OpenGL rendering without any indirections, though.

Parts of this example were insipired by Qt's "Squircle" example.

Also add a README file with a short description of each example, to
reduce the initial confusing.
2015-01-08 02:40:30 +01:00
wm4 c3db52a0bf DOCS/client_api_examples: qml: add test for gamma control
Provides a dumb test for the functionality added in the previous commit.
2015-01-06 17:35:10 +01:00
wm4 0488829185 DOCS/client_api_examples: qtexample: demonstrate multiple mpv instances
Multiple client API contexts can exist in the same process.
2015-01-06 11:56:10 +01:00
wm4 6719662fed DOCS/client_api_examples: qml: add test for vo_cmdline 2015-01-05 15:26:57 +01:00
wm4 4ed0907f2d build: try to make examples build both in-tree and out-of-tree
The examples simple.c and cocoabasic.m can be compiled without
installing libmpv. But also, they didn't use the correct include path
libmpv programs normally use, so they couldn't be built with a properly
installed system-libmpv. That's pretty bad for examples, which are
supposed to show how to use libmpv correctly.

So do some bullshit that symlinks libmpv to a "mpv" include directory
under the build directory. This name-mismatch is a direct consequence of
the bullshit done in 499a6758 (requested in #539 for dumb reasons). (We
don't want to name the client API headers directory "mpv", because that
would be too unspecific, and clashes with having the mpv binary in the
same directory.)

If you have spaces or other "unusual" characters in your paths, the
build will break, because I couldn't find out where waf hides its
function to escape shell parameters (or a way to invoke programs
without involving the shell). Neither does such a thing to be
documented, nor do they seem to have a clear way to do this in
their code.

This also doesn't compile the Qt examples, because everything becomes
even more terrible from there on.
2015-01-02 00:00:03 +01:00
wm4 da4f722579 DOCS/client_api_examples: move all examples into their own subdirs
Also get rid of shared.h; it actually doesn't have much value. Just copy
the tiny function it contained into the 2 files which used it.
2015-01-01 23:08:15 +01:00
wm4 9aa1d71147 DOCS/client_api_examples: don't throw char* in C++ code
C++ is the worst language ever, and allows throwing any type, even if it
doesn't make sense. In this case, we were throwing char*, which the
runtime typically treats as opaque, instead of printing it as message if
such an exception was not caught.
2015-01-01 22:56:57 +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 628f1dcb42 DOCS/client_api_examples: add an explicit license
IANAL, but we don't give a shit what you do with this code.
2014-12-30 22:47:50 +01:00
wm4 38976703ca DOCS/client_api_examples: qtexample: use queued signals
Use queued signals instead of QEvent for the wakeup notification. This
is slightly nicer, and reduces the chance that the event (QEvent::User)
could clash with other code using the same event.

Also switch to modern connect() syntax.
2014-12-30 22:40:25 +01:00
wm4 10f51a8c57 DOCS/client_api_examples: qtquick: fix destruction
Destruction (e.g. when closing the window) was a bit broken. This commit
fixes some possible crashes, and should make lifetime management
relatively sane. (Still a bit complex, though. Maybe this code should be
moved into a tiny library.)

QtQuick runs the renderer on a separate thread. This thread is rather
loosely connected to the main thread. The loose separation is enforced
by the API, which also makes coordination of initialization and
destruction harder. Throw refcounting at the problem, which fixes it.
The refcounting wrapper introduced in the previous commit is used for
this.

Also contains some general cleanups.
2014-12-30 22:40:25 +01:00
wm4 543ef1fd2e DOCS/client_api_examples: remove nonsense
I thought setSamples() was some funky abstraction to set the number of
components, but it's actually something else.

Also fix the include paths.
2014-12-09 22:53:34 +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
Stefano Pigozzi 58effd3fec libmpv: cocoa: add basic menu 2014-10-27 19:14:55 +01:00
wm4 fd7bf67019 DOCS/client_api_examples: qtexample: don't require Qt 5.x
Exclude the worthless Qt 5.0-only demo code on Qt 4.x.
2014-10-17 22:36:23 +02:00
Stefano Pigozzi eb902efb04 cocoa: allow mouse events to bubble up with no-input-cursor
Previously we didn't report events to the core, but still prevented the events
to travel on the responder chain.
2014-10-17 19:19:45 +02:00
wm4 63f103e05d DOCS/client_api_examples: qtexample: set a magic Qt flag
Otherwise, other magic Qt stuff can be magically broken.

(No, I don't know the real reasons for this.)
2014-10-16 21:19:30 +02:00
wm4 b836a2295c DOCS/client_api_examples: qtexample: embedding works on Cocoa 2014-10-16 21:18:01 +02:00
wm4 cb6be26181 DOCS/client_api_examples: qtexample: remove debugging code
Forgotten.
2014-10-14 13:20:24 +02:00
wm4 2ad0be8592 DOCS/client_api_examples: qtexample: stuff
Dump chapters and track list to the log for demo purposes.

Compile in debug mode.
2014-10-13 23:55:57 +02:00
Stefano Pigozzi c2eca2e4b7 libmpv/cocoa: allow clients to use mpv event system
This allows mpv's view to take key and send events to mpv's core.
To set key status correctly, clients must call -[NSWindow selectNextKeyView:]
during reconfig on the main thread. All is 'documented' in the cocoabasic
example.

If someone knows a better way to handle giving key to the embedded view,
let me know!
2014-10-12 00:19:44 +02:00
Stefano Pigozzi ca353fcf92 libmpv/cocoa: make global events work and get rid of is_cplayer
After @frau's split of macosx_events from macosx_application, `is_cplayer' is
not needed anymore. At the moment only global events such as Media Keys and
Apple Remote work, because the VO-level ones were hardcoded to be disabled.
(that will be fix in a later commit ).
2014-10-09 22:14:41 +02:00
wm4 e294656cb1 client API: rename --input-x11-keyboard to --input-vo-keyboard
Apparently we need this for Cocoa too. (The option was X11 specific in
the hope that only X11 would need this hack.)
2014-10-09 18:28:37 +02:00
Stefano Pigozzi 69fa956f50 cocoa: allow to embed into an arbitrary NSView
Basically add if guards on all the problematic features. I'm still thinking
about a better way to handle this, but for the time being, this will do.
2014-10-08 19:38:35 +02:00
wm4 ab5d58c3d9 DOCS/client_api_examples: qtexample: add a log window
For the purpose of demonstration.

Also make the windows larger. I'm not exactly sure how Qt determines
the default window sizes, but here they are a bit tiny, so force them
larger.
2014-10-08 13:34:06 +02:00
James Ross-Gowan 9541537e32 DOCS/client_api_examples: qtexample: set the locale
QApplication sets the locale, so change the LC_NUMERIC category back to
"C" for libmpv.

See: http://qt-project.org/doc/qt-5/qcoreapplication.html#locale-settings
2014-10-07 08:45:48 +02:00
Stefano Pigozzi 7968814470 cocoa: fix some pointer casts to be 32bit safe
credits: wm4
2014-10-05 15:22:17 +02:00