mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-02 06:31:08 +00:00
Gst.py: add high-level helpers
This commit is contained in:
parent
6e51428cbd
commit
2e91b713f1
1 changed files with 36 additions and 0 deletions
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import inspect
|
import inspect
|
||||||
|
import itertools
|
||||||
from ..overrides import override
|
from ..overrides import override
|
||||||
from ..module import get_introspection_module
|
from ..module import get_introspection_module
|
||||||
|
|
||||||
|
@ -64,6 +65,18 @@ class Bin(Gst.Bin):
|
||||||
if not Gst.Bin.add(self, arg):
|
if not Gst.Bin.add(self, arg):
|
||||||
raise AddError(arg)
|
raise AddError(arg)
|
||||||
|
|
||||||
|
def make_and_add(self, factory_name, instance_name=None):
|
||||||
|
'''
|
||||||
|
@raises: Gst.AddError
|
||||||
|
'''
|
||||||
|
elem = Gst.ElementFactory.make(factory_name, instance_name)
|
||||||
|
if not elem:
|
||||||
|
raise AddError(
|
||||||
|
'No such element: {}'.format(factory_name))
|
||||||
|
self.add(elem)
|
||||||
|
return elem
|
||||||
|
|
||||||
|
|
||||||
Bin = override(Bin)
|
Bin = override(Bin)
|
||||||
__all__.append('Bin')
|
__all__.append('Bin')
|
||||||
|
|
||||||
|
@ -571,6 +584,29 @@ class ValueList(Gst.ValueList):
|
||||||
ValueList = override(ValueList)
|
ValueList = override(ValueList)
|
||||||
__all__.append('ValueList')
|
__all__.append('ValueList')
|
||||||
|
|
||||||
|
# From https://docs.python.org/3/library/itertools.html
|
||||||
|
|
||||||
|
|
||||||
|
def pairwise(iterable):
|
||||||
|
a, b = itertools.tee(iterable)
|
||||||
|
next(b, None)
|
||||||
|
return zip(a, b)
|
||||||
|
|
||||||
|
|
||||||
|
class Element(Gst.Element):
|
||||||
|
@staticmethod
|
||||||
|
def link_many(*args):
|
||||||
|
'''
|
||||||
|
@raises: Gst.LinkError
|
||||||
|
'''
|
||||||
|
for pair in pairwise(args):
|
||||||
|
if not pair[0].link(pair[1]):
|
||||||
|
raise LinkError(
|
||||||
|
'Failed to link {} and {}'.format(pair[0], pair[1]))
|
||||||
|
|
||||||
|
Element = override(Element)
|
||||||
|
__all__.append('Element')
|
||||||
|
|
||||||
|
|
||||||
def TIME_ARGS(time):
|
def TIME_ARGS(time):
|
||||||
if time == Gst.CLOCK_TIME_NONE:
|
if time == Gst.CLOCK_TIME_NONE:
|
||||||
|
|
Loading…
Reference in a new issue