mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-27 18:50:48 +00:00
overrides: Try hard to make the query writable in the pad query function
Summary: We know that the bindings will get an extra ref but we know that it is not actually needed, so we are safe to decrease the refcount by one in that particular context making sure we give PyGI its ref back when we are done. Reviewers: Mathieu_Du Differential Revision: http://phabricator.freedesktop.org/D41 https://bugzilla.gnome.org/show_bug.cgi?id=746329
This commit is contained in:
parent
025b7cfbea
commit
3d19875eb7
1 changed files with 29 additions and 3 deletions
|
@ -25,6 +25,7 @@
|
||||||
# any later version.
|
# any later version.
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
from inspect import signature
|
||||||
from ..overrides import override
|
from ..overrides import override
|
||||||
from ..importer import modules
|
from ..importer import modules
|
||||||
|
|
||||||
|
@ -99,12 +100,27 @@ class Pad(Gst.Pad):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._real_chain_func = None
|
self._real_chain_func = None
|
||||||
self._real_event_func = None
|
self._real_event_func = None
|
||||||
|
self._real_query_func = None
|
||||||
|
|
||||||
def _chain_override(self, pad, parent, buf):
|
def _chain_override(self, pad, parent, buf):
|
||||||
return self._real_chain_func(pad, buf)
|
return self._real_chain_func(pad, buf)
|
||||||
|
|
||||||
def _event_override(self, pad, parent, buf):
|
def _event_override(self, pad, parent, event):
|
||||||
return self._real_event_func(pad, buf)
|
return self._real_event_func(pad, event)
|
||||||
|
|
||||||
|
def _query_override(self, pad, parent, query):
|
||||||
|
query.mini_object.refcount -= 1
|
||||||
|
n_params = len(signature(self._real_query_func).parameters)
|
||||||
|
if n_params == 2:
|
||||||
|
res = self._real_query_func(pad, query)
|
||||||
|
elif n_params == 3:
|
||||||
|
res = self._real_query_func(pad, parent, query)
|
||||||
|
else:
|
||||||
|
raise TypeError("Invalid query method %s, 2 or 3 arguments requiered"
|
||||||
|
% self._real_query_func)
|
||||||
|
query.mini_object.refcount += 1
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
def set_chain_function(self, func):
|
def set_chain_function(self, func):
|
||||||
self._real_chain_func = func
|
self._real_chain_func = func
|
||||||
|
@ -114,6 +130,14 @@ class Pad(Gst.Pad):
|
||||||
self._real_event_func = func
|
self._real_event_func = func
|
||||||
self.set_event_function_full(self._event_override, None)
|
self.set_event_function_full(self._event_override, None)
|
||||||
|
|
||||||
|
def set_query_function(self, func):
|
||||||
|
self._real_query_func = func
|
||||||
|
self.set_query_function_full(self._chain_override, None)
|
||||||
|
|
||||||
|
def set_query_function_full(self, func, udata):
|
||||||
|
self._real_query_func = func
|
||||||
|
self._real_set_query_function_full(self._query_override, None)
|
||||||
|
|
||||||
def query_caps(self, filter=None):
|
def query_caps(self, filter=None):
|
||||||
return Gst.Pad.query_caps(self, filter)
|
return Gst.Pad.query_caps(self, filter)
|
||||||
|
|
||||||
|
@ -123,6 +147,7 @@ class Pad(Gst.Pad):
|
||||||
raise LinkError(ret)
|
raise LinkError(ret)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
Pad._real_set_query_function_full = Gst.Pad.set_query_function_full
|
||||||
Pad = override(Pad)
|
Pad = override(Pad)
|
||||||
__all__.append('Pad')
|
__all__.append('Pad')
|
||||||
|
|
||||||
|
@ -131,7 +156,7 @@ class GhostPad(Gst.GhostPad):
|
||||||
if direction is None:
|
if direction is None:
|
||||||
if target is None:
|
if target is None:
|
||||||
raise TypeError('you must pass at least one of target'
|
raise TypeError('you must pass at least one of target'
|
||||||
'and direction')
|
'and direction')
|
||||||
direction = target.props.direction
|
direction = target.props.direction
|
||||||
|
|
||||||
Gst.GhostPad.__init__(self, name=name, direction=direction)
|
Gst.GhostPad.__init__(self, name=name, direction=direction)
|
||||||
|
@ -199,6 +224,7 @@ __all__.append('Pipeline')
|
||||||
class Structure(Gst.Structure):
|
class Structure(Gst.Structure):
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
return self.get_value(key)
|
return self.get_value(key)
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
return self.set_value(key, value)
|
return self.set_value(key, value)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue