wrap state_change_async and show that it works

Original commit message from CVS:
wrap state_change_async and show that it works
This commit is contained in:
Thomas Vander Stichele 2005-09-12 18:19:08 +00:00
parent a74cc80a77
commit 9aa8bb0b72
3 changed files with 51 additions and 0 deletions

View file

@ -1,3 +1,9 @@
2005-09-12 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/gst.defs:
* testsuite/test_pipeline.py:
wrap state_change_async and show that it works
2005-09-12 Thomas Vander Stichele <thomas at apestaart dot org>
* examples/vumeter.py:

View file

@ -1055,6 +1055,15 @@
)
)
(define-method set_state_async
(of-object "GstElement")
(c-name "gst_element_set_state_async")
(return-type "GstStateChangeReturn")
(parameters
'("GstState" "state")
)
)
(define-method abort_state
(of-object "GstElement")
(c-name "gst_element_abort_state")

View file

@ -24,6 +24,8 @@ import time
from common import gst, unittest
import gobject
class PipelineConstructor(unittest.TestCase):
def testGoodConstructor(self):
name = 'test-pipeline'
@ -51,6 +53,40 @@ class Pipeline(unittest.TestCase):
self.assertEqual(self.pipeline.get_state(None)[1], gst.STATE_PLAYING)
self.pipeline.set_state(gst.STATE_NULL)
self.assertEqual(self.pipeline.get_state(None)[1], gst.STATE_NULL)
class PipelineAndBus(unittest.TestCase):
def setUp(self):
self.pipeline = gst.Pipeline('test-pipeline')
self.pipeline.set_property('play-timeout', 0L)
source = gst.element_factory_make('fakesrc', 'source')
sink = gst.element_factory_make('fakesink', 'sink')
self.pipeline.add_many(source, sink)
gst.element_link_many(source, sink)
self.bus = self.pipeline.get_bus()
self.bus.add_watch(self._message_received)
self.loop = gobject.MainLoop()
def _message_received(self, bus, message):
gst.debug('received message: %s, %s' % (
message.src.get_path_string(), message.type.value_nicks[1]))
t = message.type
if t == gst.MESSAGE_STATE_CHANGED:
old, new = message.parse_state_changed()
gst.debug('%r state change from %r to %r' % (
message.src.get_path_string(), old, new))
if message.src == self.pipeline and new == gst.STATE_PLAYING:
self.loop.quit()
return True
def testPlaying(self):
ret = self.pipeline.set_state_async(gst.STATE_PLAYING)
self.assertEquals(ret, gst.STATE_CHANGE_ASYNC)
# go into a main loop to wait for messages
self.loop.run()
if __name__ == "__main__":
unittest.main()