summaryrefslogtreecommitdiff
path: root/mpv.py
diff options
context:
space:
mode:
authorjaseg <code@jaseg.net>2016-08-05 02:27:11 +0200
committerjaseg <code@jaseg.net>2016-08-05 02:35:00 +0200
commita960a2ed4e89272b0b1c4ad03900870c386262f0 (patch)
tree4826093a2a6c34dc579e8a9aebdff4bdf6853dda /mpv.py
parentdfdc201ac7d394138bc825960b185027010aaf8b (diff)
downloadpython-mpv-a960a2ed4e89272b0b1c4ad03900870c386262f0.tar.gz
python-mpv-a960a2ed4e89272b0b1c4ad03900870c386262f0.tar.bz2
python-mpv-a960a2ed4e89272b0b1c4ad03900870c386262f0.zip
Add GL API stuff
Diffstat (limited to 'mpv.py')
-rw-r--r--mpv.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/mpv.py b/mpv.py
index 08e9cdd..674e204 100644
--- a/mpv.py
+++ b/mpv.py
@@ -18,6 +18,9 @@ else:
class MpvHandle(c_void_p):
pass
+class MpvOpenGLCbContext(c_void_p):
+ pass
+
class ErrorCode(object):
""" For documentation on these, see mpv's libmpv/client.h """
@@ -111,6 +114,9 @@ class MpvEventID(c_int):
CLIENT_MESSAGE, VIDEO_RECONFIG, AUDIO_RECONFIG, METADATA_UPDATE, SEEK, PLAYBACK_RESTART, PROPERTY_CHANGE,
CHAPTER_CHANGE )
+class MpvSubApi(c_int):
+ MPV_SUB_API_OPENGL_CB = 1
+
class MpvEvent(Structure):
_fields_ = [('event_id', MpvEventID),
('error', c_int),
@@ -181,12 +187,14 @@ class MpvEventClientMessage(Structure):
WakeupCallback = CFUNCTYPE(None, c_void_p)
+OpenGlCbUpdateFn = CFUNCTYPE(None, c_void_p)
+OpenGlCbGetProcAddrFn = CFUNCTYPE(None, c_void_p, c_char_p)
-def _handle_func(name, args=[], res=None):
+def _handle_func(name, args=[], res=None, context=MpvHandle):
func = getattr(backend, name)
if res is not None:
func.restype = res
- func.argtypes = [MpvHandle] + args
+ func.argtypes = [context] + args
def wrapper(*args):
if res is not None:
return func(*args)
@@ -194,6 +202,9 @@ def _handle_func(name, args=[], res=None):
ErrorCode.raise_for_ec(func, *args)
globals()['_'+name] = wrapper
+def _handle_gl_func(name, args=[], res=None):
+ _handle_func(name, args, res, MpvOpenGLCbContext)
+
backend.mpv_client_api_version.restype = c_ulong
def _mpv_client_api_version():
ver = backend.mpv_client_api_version()
@@ -247,6 +258,15 @@ _handle_func('mpv_wakeup', [], c_int)
_handle_func('mpv_set_wakeup_callback', [WakeupCallback, c_void_p], c_int)
_handle_func('mpv_get_wakeup_pipe', [], c_int)
+_handle_func('mpv_get_sub_api', [MpvSubApi], c_void_p)
+
+_handle_gl_func('mpv_opengl_cb_set_update_callback', [OpenGlCbUpdateFn, c_void_p])
+_handle_gl_func('mpv_opengl_cb_init_gl', [c_char_p, OpenGlCbGetProcAddrFn, c_void_p], c_int)
+_handle_gl_func('mpv_opengl_cb_draw', [c_int, c_int, c_int], c_int);
+_handle_gl_func('mpv_opengl_cb_render', [c_int, c_int], c_int);
+_handle_gl_func('mpv_opengl_cb_report_flip', [c_ulonglong], c_int);
+_handle_gl_func('mpv_opengl_cb_uninit_gl', [], c_int);
+
class ynbool(object):
def __init__(self, val=False):