Add GL API stuff
This commit is contained in:
parent
dfdc201ac7
commit
a960a2ed4e
1 changed files with 22 additions and 2 deletions
24
mpv.py
24
mpv.py
|
|
@ -18,6 +18,9 @@ else:
|
||||||
class MpvHandle(c_void_p):
|
class MpvHandle(c_void_p):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class MpvOpenGLCbContext(c_void_p):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ErrorCode(object):
|
class ErrorCode(object):
|
||||||
""" For documentation on these, see mpv's libmpv/client.h """
|
""" 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,
|
CLIENT_MESSAGE, VIDEO_RECONFIG, AUDIO_RECONFIG, METADATA_UPDATE, SEEK, PLAYBACK_RESTART, PROPERTY_CHANGE,
|
||||||
CHAPTER_CHANGE )
|
CHAPTER_CHANGE )
|
||||||
|
|
||||||
|
class MpvSubApi(c_int):
|
||||||
|
MPV_SUB_API_OPENGL_CB = 1
|
||||||
|
|
||||||
class MpvEvent(Structure):
|
class MpvEvent(Structure):
|
||||||
_fields_ = [('event_id', MpvEventID),
|
_fields_ = [('event_id', MpvEventID),
|
||||||
('error', c_int),
|
('error', c_int),
|
||||||
|
|
@ -181,12 +187,14 @@ class MpvEventClientMessage(Structure):
|
||||||
|
|
||||||
WakeupCallback = CFUNCTYPE(None, c_void_p)
|
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)
|
func = getattr(backend, name)
|
||||||
if res is not None:
|
if res is not None:
|
||||||
func.restype = res
|
func.restype = res
|
||||||
func.argtypes = [MpvHandle] + args
|
func.argtypes = [context] + args
|
||||||
def wrapper(*args):
|
def wrapper(*args):
|
||||||
if res is not None:
|
if res is not None:
|
||||||
return func(*args)
|
return func(*args)
|
||||||
|
|
@ -194,6 +202,9 @@ def _handle_func(name, args=[], res=None):
|
||||||
ErrorCode.raise_for_ec(func, *args)
|
ErrorCode.raise_for_ec(func, *args)
|
||||||
globals()['_'+name] = wrapper
|
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
|
backend.mpv_client_api_version.restype = c_ulong
|
||||||
def _mpv_client_api_version():
|
def _mpv_client_api_version():
|
||||||
ver = backend.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_set_wakeup_callback', [WakeupCallback, c_void_p], c_int)
|
||||||
_handle_func('mpv_get_wakeup_pipe', [], 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):
|
class ynbool(object):
|
||||||
def __init__(self, val=False):
|
def __init__(self, val=False):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue