388 lines
13 KiB
Diff
388 lines
13 KiB
Diff
https://github.com/ozmartian/vidcutter/commit/1d88825feb5a73a50d019914ba9d0008562a58ce.patch
|
|
|
|
From 1d88825feb5a73a50d019914ba9d0008562a58ce Mon Sep 17 00:00:00 2001
|
|
From: Pete Alexandrou <pete@ozmartians.com>
|
|
Date: Tue, 22 Feb 2022 11:29:00 +1100
|
|
Subject: [PATCH] Patches to pympv to workaround opengl_cb deprecation from
|
|
libmpv
|
|
|
|
---
|
|
vidcutter/libs/pympv/client.pxd | 54 +-
|
|
vidcutter/libs/pympv/mpv.pyx | 192 +-
|
|
3 files changed, 21832 insertions(+), 24808 deletions(-)
|
|
|
|
diff --git a/vidcutter/libs/pympv/client.pxd b/vidcutter/libs/pympv/client.pxd
|
|
index befe219e..d9a8816f 100644
|
|
--- a/vidcutter/libs/pympv/client.pxd
|
|
+++ b/vidcutter/libs/pympv/client.pxd
|
|
@@ -112,9 +112,9 @@ cdef extern from "mpv/client.h":
|
|
|
|
int mpv_load_config_file(mpv_handle *ctx, const char *filename) nogil
|
|
|
|
- void mpv_suspend(mpv_handle *ctx) nogil
|
|
+ # void mpv_suspend(mpv_handle *ctx) nogil
|
|
|
|
- void mpv_resume(mpv_handle *ctx) nogil
|
|
+ # void mpv_resume(mpv_handle *ctx) nogil
|
|
|
|
int64_t mpv_get_time_us(mpv_handle *ctx) nogil
|
|
|
|
@@ -200,21 +200,21 @@ cdef extern from "mpv/client.h":
|
|
MPV_EVENT_START_FILE
|
|
MPV_EVENT_END_FILE
|
|
MPV_EVENT_FILE_LOADED
|
|
- MPV_EVENT_TRACKS_CHANGED
|
|
- MPV_EVENT_TRACK_SWITCHED
|
|
+ # MPV_EVENT_TRACKS_CHANGED
|
|
+ # MPV_EVENT_TRACK_SWITCHED
|
|
MPV_EVENT_IDLE
|
|
- MPV_EVENT_PAUSE
|
|
- MPV_EVENT_UNPAUSE
|
|
+ # MPV_EVENT_PAUSE
|
|
+ # MPV_EVENT_UNPAUSE
|
|
MPV_EVENT_TICK
|
|
- MPV_EVENT_SCRIPT_INPUT_DISPATCH
|
|
+ # MPV_EVENT_SCRIPT_INPUT_DISPATCH
|
|
MPV_EVENT_CLIENT_MESSAGE
|
|
MPV_EVENT_VIDEO_RECONFIG
|
|
MPV_EVENT_AUDIO_RECONFIG
|
|
- MPV_EVENT_METADATA_UPDATE
|
|
+ # MPV_EVENT_METADATA_UPDATE
|
|
MPV_EVENT_SEEK
|
|
MPV_EVENT_PLAYBACK_RESTART
|
|
MPV_EVENT_PROPERTY_CHANGE
|
|
- MPV_EVENT_CHAPTER_CHANGE
|
|
+ # MPV_EVENT_CHAPTER_CHANGE
|
|
|
|
const char *mpv_event_name(mpv_event_id event) nogil
|
|
|
|
@@ -249,9 +249,9 @@ cdef extern from "mpv/client.h":
|
|
int reason
|
|
int error
|
|
|
|
- cdef struct mpv_event_script_input_dispatch:
|
|
- int arg0
|
|
- const char *type
|
|
+ # cdef struct mpv_event_script_input_dispatch:
|
|
+ # int arg0
|
|
+ # const char *type
|
|
|
|
cdef struct mpv_event_client_message:
|
|
int num_args
|
|
@@ -282,27 +282,27 @@ cdef extern from "mpv/client.h":
|
|
|
|
void *mpv_get_sub_api(mpv_handle *ctx, mpv_sub_api sub_api) nogil
|
|
|
|
-cdef extern from "mpv/opengl_cb.h":
|
|
- struct mpv_opengl_cb_context:
|
|
- pass
|
|
+# cdef extern from "mpv/opengl_cb.h":
|
|
+# struct mpv_opengl_cb_context:
|
|
+# pass
|
|
|
|
- ctypedef void (*mpv_opengl_cb_update_fn)(void *cb_ctx) nogil
|
|
- ctypedef void *(*mpv_opengl_cb_get_proc_address_fn)(void *fn_ctx,
|
|
- const char *name) nogil
|
|
+# ctypedef void (*mpv_opengl_cb_update_fn)(void *cb_ctx) nogil
|
|
+# ctypedef void *(*mpv_opengl_cb_get_proc_address_fn)(void *fn_ctx,
|
|
+# const char *name) nogil
|
|
|
|
- void mpv_opengl_cb_set_update_callback(mpv_opengl_cb_context *ctx,
|
|
- mpv_opengl_cb_update_fn callback,
|
|
- void *callback_ctx) nogil
|
|
+# void mpv_opengl_cb_set_update_callback(mpv_opengl_cb_context *ctx,
|
|
+# mpv_opengl_cb_update_fn callback,
|
|
+# void *callback_ctx) nogil
|
|
|
|
- int mpv_opengl_cb_init_gl(mpv_opengl_cb_context *ctx, const char *exts,
|
|
- mpv_opengl_cb_get_proc_address_fn get_proc_address,
|
|
- void *get_proc_address_ctx) nogil
|
|
+# int mpv_opengl_cb_init_gl(mpv_opengl_cb_context *ctx, const char *exts,
|
|
+# mpv_opengl_cb_get_proc_address_fn get_proc_address,
|
|
+# void *get_proc_address_ctx) nogil
|
|
|
|
- int mpv_opengl_cb_draw(mpv_opengl_cb_context *ctx, int fbo, int w, int h) nogil
|
|
+# int mpv_opengl_cb_draw(mpv_opengl_cb_context *ctx, int fbo, int w, int h) nogil
|
|
|
|
- int mpv_opengl_cb_report_flip(mpv_opengl_cb_context *ctx, int64_t time) nogil
|
|
+# int mpv_opengl_cb_report_flip(mpv_opengl_cb_context *ctx, int64_t time) nogil
|
|
|
|
- int mpv_opengl_cb_uninit_gl(mpv_opengl_cb_context *ctx) nogil
|
|
+# int mpv_opengl_cb_uninit_gl(mpv_opengl_cb_context *ctx) nogil
|
|
|
|
|
|
cdef extern from "mpv/render.h":
|
|
diff --git a/vidcutter/libs/pympv/mpv.pyx b/vidcutter/libs/pympv/mpv.pyx
|
|
index 540ea649..8af2dcc7 100644
|
|
--- a/vidcutter/libs/pympv/mpv.pyx
|
|
+++ b/vidcutter/libs/pympv/mpv.pyx
|
|
@@ -30,8 +30,8 @@ from client cimport *
|
|
__version__ = "0.3.0"
|
|
__author__ = "Andre D"
|
|
|
|
-_REQUIRED_CAPI_MAJOR = 1
|
|
-_MIN_CAPI_MINOR = 9
|
|
+_REQUIRED_CAPI_MAJOR = 2
|
|
+_MIN_CAPI_MINOR = 0
|
|
|
|
cdef unsigned long _CAPI_VERSION
|
|
with nogil:
|
|
@@ -47,7 +47,7 @@ if _CAPI_MAJOR != _REQUIRED_CAPI_MAJOR or _CAPI_MINOR < _MIN_CAPI_MINOR:
|
|
)
|
|
|
|
cdef extern from "Python.h":
|
|
- void PyEval_InitThreads()
|
|
+ void Py_Initialize()
|
|
|
|
_is_py3 = sys.version_info >= (3,)
|
|
_strdec_err = "surrogateescape" if _is_py3 else "strict"
|
|
@@ -67,7 +67,7 @@ def _strenc(s):
|
|
# In python2, assume bytes and walk right through
|
|
return s
|
|
|
|
-PyEval_InitThreads()
|
|
+Py_Initialize()
|
|
|
|
class Errors:
|
|
"""Set of known error codes from MpvError and Event responses.
|
|
@@ -114,21 +114,21 @@ class Events:
|
|
start_file = MPV_EVENT_START_FILE
|
|
end_file = MPV_EVENT_END_FILE
|
|
file_loaded = MPV_EVENT_FILE_LOADED
|
|
- tracks_changed = MPV_EVENT_TRACKS_CHANGED
|
|
- tracks_switched = MPV_EVENT_TRACK_SWITCHED
|
|
+ # tracks_changed = MPV_EVENT_TRACKS_CHANGED
|
|
+ # tracks_switched = MPV_EVENT_TRACK_SWITCHED
|
|
idle = MPV_EVENT_IDLE
|
|
- pause = MPV_EVENT_PAUSE
|
|
- unpause = MPV_EVENT_UNPAUSE
|
|
+ # pause = MPV_EVENT_PAUSE
|
|
+ # unpause = MPV_EVENT_UNPAUSE
|
|
tick = MPV_EVENT_TICK
|
|
- script_input_dispatch = MPV_EVENT_SCRIPT_INPUT_DISPATCH
|
|
+ # script_input_dispatch = MPV_EVENT_SCRIPT_INPUT_DISPATCH
|
|
client_message = MPV_EVENT_CLIENT_MESSAGE
|
|
video_reconfig = MPV_EVENT_VIDEO_RECONFIG
|
|
audio_reconfig = MPV_EVENT_AUDIO_RECONFIG
|
|
- metadata_update = MPV_EVENT_METADATA_UPDATE
|
|
+ # metadata_update = MPV_EVENT_METADATA_UPDATE
|
|
seek = MPV_EVENT_SEEK
|
|
playback_restart = MPV_EVENT_PLAYBACK_RESTART
|
|
property_change = MPV_EVENT_PROPERTY_CHANGE
|
|
- chapter_change = MPV_EVENT_CHAPTER_CHANGE
|
|
+ # chapter_change = MPV_EVENT_CHAPTER_CHANGE
|
|
|
|
|
|
class LogLevels:
|
|
@@ -166,17 +166,17 @@ cdef class EndOfFileReached(object):
|
|
return self
|
|
|
|
|
|
-cdef class InputDispatch(object):
|
|
- """Data field for MPV_EVENT_SCRIPT_INPUT_DISPATCH events.
|
|
+# cdef class InputDispatch(object):
|
|
+# """Data field for MPV_EVENT_SCRIPT_INPUT_DISPATCH events.
|
|
|
|
- Wraps: mpv_event_script_input_dispatch
|
|
- """
|
|
- cdef public object arg0, type
|
|
+# Wraps: mpv_event_script_input_dispatch
|
|
+# """
|
|
+# cdef public object arg0, type
|
|
|
|
- cdef _init(self, mpv_event_script_input_dispatch* input):
|
|
- self.arg0 = input.arg0
|
|
- self.type = _strdec(input.type)
|
|
- return self
|
|
+# cdef _init(self, mpv_event_script_input_dispatch* input):
|
|
+# self.arg0 = input.arg0
|
|
+# self.type = _strdec(input.type)
|
|
+# return self
|
|
|
|
|
|
cdef class LogMessage(object):
|
|
@@ -276,8 +276,8 @@ cdef class Event(object):
|
|
return Property()._init(<mpv_event_property*>data)
|
|
elif self.id == MPV_EVENT_LOG_MESSAGE:
|
|
return LogMessage()._init(<mpv_event_log_message*>data)
|
|
- elif self.id == MPV_EVENT_SCRIPT_INPUT_DISPATCH:
|
|
- return InputDispatch()._init(<mpv_event_script_input_dispatch*>data)
|
|
+ # elif self.id == MPV_EVENT_SCRIPT_INPUT_DISPATCH:
|
|
+ # return InputDispatch()._init(<mpv_event_script_input_dispatch*>data)
|
|
elif self.id == MPV_EVENT_CLIENT_MESSAGE:
|
|
climsg = <mpv_event_client_message*>data
|
|
args = []
|
|
@@ -396,17 +396,17 @@ cdef class Context(object):
|
|
time = mpv_get_time_us(self._ctx)
|
|
return time
|
|
|
|
- def suspend(self):
|
|
- """Wraps: mpv_suspend"""
|
|
- assert self._ctx
|
|
- with nogil:
|
|
- mpv_suspend(self._ctx)
|
|
+ # def suspend(self):
|
|
+ # """Wraps: mpv_suspend"""
|
|
+ # assert self._ctx
|
|
+ # with nogil:
|
|
+ # mpv_suspend(self._ctx)
|
|
|
|
- def resume(self):
|
|
- """Wraps: mpv_resume"""
|
|
- assert self._ctx
|
|
- with nogil:
|
|
- mpv_resume(self._ctx)
|
|
+ # def resume(self):
|
|
+ # """Wraps: mpv_resume"""
|
|
+ # assert self._ctx
|
|
+ # with nogil:
|
|
+ # mpv_resume(self._ctx)
|
|
|
|
@_errors
|
|
def request_event(self, event, enable):
|
|
@@ -798,17 +798,17 @@ cdef class Context(object):
|
|
self.reply_userdata = None
|
|
self._ctx = NULL
|
|
|
|
- def opengl_cb_api(self):
|
|
- cdef void *cb
|
|
+ # def opengl_cb_api(self):
|
|
+ # cdef void *cb
|
|
|
|
- _ctx = mpv_get_sub_api(self._ctx, MPV_SUB_API_OPENGL_CB)
|
|
- if not _ctx:
|
|
- raise MPVError("OpenGL API not available")
|
|
+ # _ctx = mpv_get_sub_api(self._ctx, MPV_SUB_API_OPENGL_CB)
|
|
+ # if not _ctx:
|
|
+ # raise MPVError("OpenGL API not available")
|
|
|
|
- ctx = OpenGLContext()
|
|
- ctx._ctx = <mpv_opengl_cb_context*>_ctx
|
|
+ # ctx = OpenGLContext()
|
|
+ # ctx._ctx = <mpv_opengl_cb_context*>_ctx
|
|
|
|
- return ctx
|
|
+ # return ctx
|
|
|
|
def __dealloc__(self):
|
|
self.shutdown()
|
|
@@ -819,62 +819,62 @@ cdef void *_c_getprocaddress(void *ctx, const char *name) with gil:
|
|
cdef void _c_updatecb(void *ctx) with gil:
|
|
(<object>ctx)()
|
|
|
|
-cdef class OpenGLContext(object):
|
|
- cdef:
|
|
- mpv_opengl_cb_context *_ctx
|
|
- bint inited
|
|
- object update_cb
|
|
-
|
|
- def __init__(self):
|
|
- self.inited = False
|
|
- warnings.warn("OpenGLContext is deprecated, please switch to RenderContext", DeprecationWarning)
|
|
-
|
|
- def init_gl(self, exts, get_proc_address):
|
|
- exts = _strenc(exts) if exts is not None else None
|
|
- cdef char* extsc = NULL
|
|
- if exts is not None:
|
|
- extsc = exts
|
|
- with nogil:
|
|
- err = mpv_opengl_cb_init_gl(self._ctx, extsc, &_c_getprocaddress,
|
|
- <void *>get_proc_address)
|
|
- if err < 0:
|
|
- raise MPVError(err)
|
|
-
|
|
- self.inited = True
|
|
-
|
|
- def set_update_callback(self, cb):
|
|
- self.update_cb = cb
|
|
- with nogil:
|
|
- mpv_opengl_cb_set_update_callback(self._ctx, &_c_updatecb, <void *>cb)
|
|
-
|
|
- def draw(self, fbo, w, h):
|
|
- cdef:
|
|
- int fboc = fbo
|
|
- int wc = w
|
|
- int hc = h
|
|
- with nogil:
|
|
- err = mpv_opengl_cb_draw(self._ctx, fboc, wc, hc)
|
|
- if err < 0:
|
|
- raise MPVError(err)
|
|
-
|
|
- def report_flip(self, time):
|
|
- cdef int64_t ctime = time
|
|
- with nogil:
|
|
- err = mpv_opengl_cb_report_flip(self._ctx, ctime)
|
|
- if err < 0:
|
|
- raise MPVError(err)
|
|
-
|
|
- def uninit_gl(self):
|
|
- if not self.inited:
|
|
- return
|
|
- with nogil:
|
|
- err = mpv_opengl_cb_uninit_gl(self._ctx)
|
|
- if err < 0:
|
|
- raise MPVError(err)
|
|
- self.inited = False
|
|
-
|
|
- def __dealloc__(self):
|
|
- self.uninit_gl()
|
|
+# cdef class OpenGLContext(object):
|
|
+# cdef:
|
|
+# mpv_opengl_cb_context *_ctx
|
|
+# bint inited
|
|
+# object update_cb
|
|
+
|
|
+# def __init__(self):
|
|
+# self.inited = False
|
|
+# warnings.warn("OpenGLContext is deprecated, please switch to RenderContext", DeprecationWarning)
|
|
+
|
|
+# def init_gl(self, exts, get_proc_address):
|
|
+# exts = _strenc(exts) if exts is not None else None
|
|
+# cdef char* extsc = NULL
|
|
+# if exts is not None:
|
|
+# extsc = exts
|
|
+# with nogil:
|
|
+# err = mpv_opengl_cb_init_gl(self._ctx, extsc, &_c_getprocaddress,
|
|
+# <void *>get_proc_address)
|
|
+# if err < 0:
|
|
+# raise MPVError(err)
|
|
+
|
|
+# self.inited = True
|
|
+
|
|
+# def set_update_callback(self, cb):
|
|
+# self.update_cb = cb
|
|
+# with nogil:
|
|
+# mpv_opengl_cb_set_update_callback(self._ctx, &_c_updatecb, <void *>cb)
|
|
+
|
|
+# def draw(self, fbo, w, h):
|
|
+# cdef:
|
|
+# int fboc = fbo
|
|
+# int wc = w
|
|
+# int hc = h
|
|
+# with nogil:
|
|
+# err = mpv_opengl_cb_draw(self._ctx, fboc, wc, hc)
|
|
+# if err < 0:
|
|
+# raise MPVError(err)
|
|
+
|
|
+# def report_flip(self, time):
|
|
+# cdef int64_t ctime = time
|
|
+# with nogil:
|
|
+# err = mpv_opengl_cb_report_flip(self._ctx, ctime)
|
|
+# if err < 0:
|
|
+# raise MPVError(err)
|
|
+
|
|
+# def uninit_gl(self):
|
|
+# if not self.inited:
|
|
+# return
|
|
+# with nogil:
|
|
+# err = mpv_opengl_cb_uninit_gl(self._ctx)
|
|
+# if err < 0:
|
|
+# raise MPVError(err)
|
|
+# self.inited = False
|
|
+
|
|
+# def __dealloc__(self):
|
|
+# self.uninit_gl()
|
|
|
|
DEF MAX_RENDER_PARAMS = 32
|
|
|