mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-30 12:49:40 +00:00
testsuite/test_ghostpad.py: add handoff to count received buffers
Original commit message from CVS: 2005-10-06 Thomas Vander Stichele <thomas at apestaart dot org> * testsuite/test_ghostpad.py: add handoff to count received buffers
This commit is contained in:
parent
40af7772e9
commit
13301b0a39
2 changed files with 40 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
2005-10-06 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* testsuite/test_ghostpad.py:
|
||||
add handoff to count received buffers
|
||||
|
||||
2005-10-06 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* gst/gst.override:
|
||||
|
|
|
@ -42,6 +42,12 @@ class SinkBin(gst.Bin):
|
|||
pad = sink.get_pad("sink")
|
||||
ghostpad = gst.GhostPad("sink", pad)
|
||||
self.add_pad(ghostpad)
|
||||
self.sink = sink
|
||||
|
||||
def connect_handoff(self, cb, *args, **kwargs):
|
||||
self.sink.set_property('signal-handoffs', True)
|
||||
self.sink.connect('handoff', cb, *args, **kwargs)
|
||||
|
||||
gobject.type_register(SinkBin)
|
||||
|
||||
|
||||
|
@ -88,6 +94,8 @@ class PipeTest(TestCase):
|
|||
def testBinState(self):
|
||||
self.pipeline.add(self.src, self.sink)
|
||||
self.src.link(self.sink)
|
||||
self.sink.connect_handoff(self._sink_handoff_cb)
|
||||
self._handoffs = 0
|
||||
|
||||
self.pipeline.set_state_async(gst.STATE_PLAYING)
|
||||
while True:
|
||||
|
@ -95,6 +103,9 @@ class PipeTest(TestCase):
|
|||
if ret == gst.STATE_CHANGE_SUCCESS and cur == gst.STATE_PLAYING:
|
||||
break
|
||||
|
||||
while self._handoffs < 10:
|
||||
pass
|
||||
|
||||
self.pipeline.set_state_async(gst.STATE_NULL)
|
||||
while True:
|
||||
(ret, cur, pen) = self.pipeline.get_state(timeout=None)
|
||||
|
@ -104,6 +115,10 @@ class PipeTest(TestCase):
|
|||
def testProbedLink(self):
|
||||
self.pipeline.add(self.src)
|
||||
pad = self.src.get_pad("src")
|
||||
|
||||
self.sink.connect_handoff(self._sink_handoff_cb)
|
||||
self._handoffs = 0
|
||||
|
||||
# FIXME: adding a probe to the ghost pad does not work atm
|
||||
# id = pad.add_buffer_probe(self._src_buffer_probe_cb)
|
||||
realpad = pad.get_target()
|
||||
|
@ -120,6 +135,9 @@ class PipeTest(TestCase):
|
|||
while not self._probed:
|
||||
pass
|
||||
|
||||
while self._handoffs < 10:
|
||||
pass
|
||||
|
||||
self.pipeline.set_state_async(gst.STATE_NULL)
|
||||
while True:
|
||||
(ret, cur, pen) = self.pipeline.get_state(timeout=None)
|
||||
|
@ -133,7 +151,19 @@ class PipeTest(TestCase):
|
|||
self.pipeline.add(self.sink)
|
||||
# this seems to get rid of the warnings about pushing on an unactivated
|
||||
# pad
|
||||
self.sink.set_state(gst.STATE_PAUSED)
|
||||
gst.debug('setting sink state')
|
||||
|
||||
# FIXME: attempt one: sync to current pending state of bin
|
||||
(res, cur, pen) = self.pipeline.get_state(timeout=0.0)
|
||||
target = pen
|
||||
if target == gst.STATE_VOID_PENDING:
|
||||
target = cur
|
||||
gst.debug("setting sink state to %r" % target)
|
||||
# FIXME: the following print can cause a lock-up; why ?
|
||||
# print target
|
||||
# if we don't set async, it will possibly end up in PAUSED
|
||||
self.sink.set_state_async(target)
|
||||
|
||||
gst.debug('linking')
|
||||
self.src.link(self.sink)
|
||||
gst.debug('removing buffer probe id %r' % self._probe_id)
|
||||
|
@ -141,5 +171,9 @@ class PipeTest(TestCase):
|
|||
self._probe_id = None
|
||||
gst.debug('done')
|
||||
|
||||
def _sink_handoff_cb(self, sink, pad, buffer):
|
||||
gst.debug('received handoff on pad %r' % pad)
|
||||
self._handoffs += 1
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in a new issue