mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-13 19:05:37 +00:00
overrides: implement the python iterator protocol for Gst.Iterator
So that you can use: for value in gst_iterator: ...
This commit is contained in:
parent
0b0202cfbe
commit
501db56597
1 changed files with 20 additions and 0 deletions
|
@ -77,6 +77,26 @@ class Caps(Gst.Caps):
|
|||
Caps = override(Caps)
|
||||
__all__.append('Caps')
|
||||
|
||||
class IteratorError(Exception):
|
||||
pass
|
||||
__all__.append('IteratorError')
|
||||
|
||||
class Iterator(Gst.Iterator):
|
||||
def __iter__(self):
|
||||
while True:
|
||||
result, value = self.next()
|
||||
if result == Gst.IteratorResult.DONE:
|
||||
break
|
||||
|
||||
if result != Gst.IteratorResult.OK:
|
||||
raise IteratorError(result)
|
||||
|
||||
yield value
|
||||
|
||||
Iterator = override(Iterator)
|
||||
__all__.append('Iterator')
|
||||
|
||||
|
||||
class ElementFactory(Gst.ElementFactory):
|
||||
|
||||
# ElementFactory
|
||||
|
|
Loading…
Reference in a new issue