summaryrefslogtreecommitdiffstats
path: root/libmpv
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-03-22 17:05:01 +0100
committerwm4 <wm4@nowhere>2018-03-26 19:47:08 +0200
commit52dd38a48a4a94d1c477b62cebcd67b911eb27fa (patch)
treeff2449de78ae1a30af5fbb7c6e399172403549b4 /libmpv
parent0b4120919aa1e4e70b49dd3f93af0acddd7ea4d3 (diff)
downloadmpv-52dd38a48a4a94d1c477b62cebcd67b911eb27fa.tar.bz2
mpv-52dd38a48a4a94d1c477b62cebcd67b911eb27fa.tar.xz
client API: add a new way to pass X11 Display etc. to render API
Hardware decoding things often need access to additional handles from the windowing system, such as the X11 or Wayland display when using vaapi. The opengl-cb had nothing dedicated for this, and used the weird GL_MP_MPGetNativeDisplay GL extension (which was mpv specific and not officially registered with OpenGL). This was awkward, and a pain due to having to emulate GL context behavior (like needing a TLS variable to store context for the pseudo GL extension function). In addition (and not inherently due to this), we could pass only one resource from mpv builtin context backends to hwdecs. It was also all GL specific. Replace this with a newer mechanism. It works for all RA backends, not just GL. the API user can explicitly pass the objects at init time via mpv_render_context_create(). Multiple resources are naturally possible. The API uses MPV_RENDER_PARAM_* defines, but internally we use strings. This is done for 2 reasons: 1. trying to leave libmpv and internal mechanisms decoupled, 2. not having to add public API for some of the internal resource types (especially D3D/GL interop stuff). To remain sane, drop support for obscure half-working opengl-cb things, like the DRM interop (was missing necessary things), the RPI window thing (nobody used it), and obscure D3D interop things (not needed with ANGLE, others were undocumented). In order not to break ABI and the C API, we don't remove the associated structs from opengl_cb.h. The parts which are still needed (in particular DRM interop) needs to be ported to the render API.
Diffstat (limited to 'libmpv')
-rw-r--r--libmpv/client.h2
-rw-r--r--libmpv/opengl_cb.h55
-rw-r--r--libmpv/render.h12
-rw-r--r--libmpv/render_gl.h9
4 files changed, 20 insertions, 58 deletions
diff --git a/libmpv/client.h b/libmpv/client.h
index 1483f1afd6..12459f7a0d 100644
--- a/libmpv/client.h
+++ b/libmpv/client.h
@@ -210,7 +210,7 @@ extern "C" {
* relational operators (<, >, <=, >=).
*/
#define MPV_MAKE_VERSION(major, minor) (((major) << 16) | (minor) | 0UL)
-#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(1, 29)
+#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(1, 100)
/**
* The API user is allowed to "#define MPV_ENABLE_DEPRECATED 0" before
diff --git a/libmpv/opengl_cb.h b/libmpv/opengl_cb.h
index ce88a8570a..dd9ab2cf09 100644
--- a/libmpv/opengl_cb.h
+++ b/libmpv/opengl_cb.h
@@ -159,20 +159,9 @@ extern "C" {
* See below what names are defined. Usually, libmpv will use the native handle
* up until mpv_opengl_cb_uninit_gl() is called. If the name is not anything
* you know/expected, return NULL from the function.
- *
- * * Windowing system scaling
- * ------------------------------------
- *
- * When using GL, sometimes GL rendering window is upscaled to display buffer.
- * Typically with drm where GL framebuffer can be upscaled at later stage.
- * In That case glMPGetNativeDisplay("opengl-cb-window-pos") should return an
- * mpv_opengl_cb_window_pos struct pointer defined below.
- * Note : The intended use is for hardware overlays that might require
- * upscaling features (typically upscaling GL windows with drm to screen size).
- *
- * This is never used for GL rendering - only to map hardware overlays to
- * GL rendering (for backends which support it).
*/
+
+// Legacy - not supported anymore.
struct mpv_opengl_cb_window_pos {
int x; // left coordinates of window (usually 0)
int y; // top coordinates of window (usually 0)
@@ -180,22 +169,7 @@ struct mpv_opengl_cb_window_pos {
int height; // height of GL window
};
-/**
- * Windowing system interop on Intel/Linux with VAAPI
- * --------------------------------------------------
- *
- * The new VAAPI OpenGL interop requires an EGL context. EGL provides no way
- * to query the X11 Display associated to a specific EGL context, so this API
- * is used to pass it through.
- *
- * glMPGetNativeDisplay("x11") should return a X11 "Display*", which then will
- * be used to create the hardware decoder state.
- *
- * glMPGetNativeDisplay("wl") should return a Wayland "struct wl_display *".
- *
- * glMPGetNativeDisplay("opengl-cb-drm-params") should return an
- * mpv_opengl_cb_drm_params structure pointer :
- */
+// Legacy - not supported anymore.
struct mpv_opengl_cb_drm_params {
// DRM fd (int). set this to -1 if invalid.
int fd;
@@ -218,29 +192,6 @@ struct mpv_opengl_cb_drm_params {
* You should use ANGLE, and make sure your application and libmpv are linked
* to the same ANGLE DLLs. libmpv will pick the device context (needed for
* hardware decoding) from the current ANGLE EGL context.
- *
- * Windowing system interop on RPI
- * -------------------------------
- *
- * The RPI uses no proper interop, but hardware overlays instead. To place the
- * overlay correctly, you can communicate the window parameters as follows to
- * libmpv. glMPGetNativeDisplay("MPV_RPI_WINDOW") returns an array of type int
- * with the following 4 elements:
- * 0: display number (default 0)
- * 1: layer number of the GL layer - video will be placed in the layer
- * directly below (default: 0)
- * 2: absolute x position of the GL context (default: 0)
- * 3: absolute y position of the GL context (default: 0)
- * The (x,y) position must be the absolute screen pixel position of the
- * top/left pixel of the dispmanx layer used for the GL context. If you render
- * to a FBO, the position must be that of the final position of the FBO
- * contents on screen. You can't transform or scale the video other than what
- * mpv will render to the video overlay. The defaults are suitable for
- * rendering the video at fullscreen.
- * The parameters are checked on every draw by calling MPGetNativeDisplay and
- * checking the values in the returned array for changes. The returned array
- * must remain valid until the libmpv render function returns; then it can be
- * deallocated by the API user.
*/
/**
diff --git a/libmpv/render.h b/libmpv/render.h
index 75153befb8..cefe922b34 100644
--- a/libmpv/render.h
+++ b/libmpv/render.h
@@ -152,6 +152,18 @@ typedef enum mpv_render_param_type {
* This can be used for automatic gamma correction.
*/
MPV_RENDER_PARAM_AMBIENT_LIGHT = 7,
+ /**
+ * X11 Display, sometimes used for hwdec. Valid for
+ * mpv_render_context_create().
+ * Type: Display*
+ */
+ MPV_RENDER_PARAM_X11_DISPLAY = 8,
+ /**
+ * Wayland display, sometimes used for hwdec. Valid for
+ * mpv_render_context_create().
+ * Type: struct wl_display*
+ */
+ MPV_RENDER_PARAM_WL_DISPLAY = 9,
} mpv_render_param_type;
/**
diff --git a/libmpv/render_gl.h b/libmpv/render_gl.h
index 01c09e80df..a4872a066b 100644
--- a/libmpv/render_gl.h
+++ b/libmpv/render_gl.h
@@ -88,8 +88,9 @@ extern "C" {
* There may be certain requirements on the OpenGL implementation:
*
* - Windows: ANGLE is required (although in theory GL/DX interop could be used)
- * - Intel/Linux: EGL is required, and also a glMPGetNativeDisplay() callback
- * must be provided (see sections below)
+ * - Intel/Linux: EGL is required, and also the native display resource needs
+ * to be provided (e.g. MPV_RENDER_PARAM_X11_DISPLAY for X11 and
+ * MPV_RENDER_PARAM_WL_DISPLAY for Wayland)
* - nVidia/Linux: Both GLX and EGL should work (GLX is required if vdpau is
* used, e.g. due to old drivers.)
* - OSX: CGL is required (CGLGetCurrentContext() returning non-NULL)
@@ -118,9 +119,7 @@ typedef struct mpv_opengl_init_params {
*/
void *get_proc_address_ctx;
/**
- * This should not be used. The main purpose is signaling support for
- * "GL_MP_MPGetNativeDisplay", which is needed for compatibility with the
- * opengl_cb API only. Thus it's deprecated and will be removed or ignored
+ * This should not be used. It is deprecated and will be removed or ignored
* when the opengl_cb API is removed.
*/
const char *extra_exts;