def tearDown(self): gst.info("tearDown") self.assertTrue(self.pipeline.__gstrefcount__ >= 1 and self.pipeline.__gstrefcount__ <= 2) self.assertEquals(sys.getrefcount(self.pipeline), pygobject_2_13 and 2 or 3) self.assertEquals(self.src.__gstrefcount__, 2) self.assertEquals(sys.getrefcount(self.src), pygobject_2_13 and 2 or 3) self.assertEquals(self.sink.__gstrefcount__, 2) self.assertEquals(sys.getrefcount(self.sink), 3) gst.debug('deleting pipeline') del self.pipeline self.gccollect() self.assertEquals(self.src.__gstrefcount__, 1) # parent gone self.assertEquals(self.sink.__gstrefcount__, 1) # parent gone self.assertEquals(sys.getrefcount(self.src), pygobject_2_13 and 2 or 3) self.assertEquals(sys.getrefcount(self.sink), pygobject_2_13 and 2 or 3) gst.debug('deleting src') del self.src self.gccollect() gst.debug('deleting sink') del self.sink self.gccollect() TestCase.tearDown(self)
def setUp(self): TestCase.setUp(self) gst.info("start") self.filename = tempfile.mktemp() open(self.filename, 'w').write(''.join(map(str, range(10)))) self.pipeline = gst.parse_launch('filesrc name=source location=%s blocksize=1 ! fakesink signal-handoffs=1 name=sink' % self.filename) self.source = self.pipeline.get_by_name('source') self.sink = self.pipeline.get_by_name('sink') self.sigid = self.sink.connect('handoff', self.handoff_cb) self.bus = self.pipeline.get_bus()
def setUp(self): TestCase.setUp(self) gst.info("start") self.filename = tempfile.mktemp() open(self.filename, 'w').write(''.join(map(str, range(10)))) self.pipeline = gst.parse_launch( 'filesrc name=source location=%s blocksize=1 ! fakesink signal-handoffs=1 name=sink' % self.filename) self.source = self.pipeline.get_by_name('source') self.sink = self.pipeline.get_by_name('sink') self.sigid = self.sink.connect('handoff', self.handoff_cb) self.bus = self.pipeline.get_bus()
def setUp(self): gst.info("setUp") TestCase.setUp(self) self.pipeline = gst.Pipeline() self.assertEquals(self.pipeline.__gstrefcount__, 1) self.assertEquals(sys.getrefcount(self.pipeline), pygobject_2_13 and 2 or 3) self.src = SrcBin() self.src.prepare() self.sink = SinkBin() self.sink.prepare() self.assertEquals(self.src.__gstrefcount__, 1) self.assertEquals(sys.getrefcount(self.src), pygobject_2_13 and 2 or 3) self.assertEquals(self.sink.__gstrefcount__, 1) self.assertEquals(sys.getrefcount(self.sink), pygobject_2_13 and 2 or 3) gst.info("end of SetUp")
def testApplication(self): self.loop = gobject.MainLoop() gst.info("creating new pipeline") bin = gst.Pipeline() bus = bin.get_bus() bus.add_signal_watch() self.got_message = False bus.connect('message::application', self.message_application_cb) struc = gst.Structure("foo") msg = gst.message_new_application(bin, struc) # the bus is flushing in NULL, so we need to set the pipeline to READY bin.set_state(gst.STATE_READY) bus.post(msg) self.loop.run() bus.remove_signal_watch() bin.set_state(gst.STATE_NULL) self.failUnless(self.got_message == True) self.gccollect()
def testADumbExample(self): gst.info("creating pipeline") pipeline = gst.parse_launch("fakesrc ! fakesink") gst.info("pipeliner:%s" % pipeline.__gstrefcount__) bus = pipeline.get_bus() gst.info("got bus, pipeliner:%d, busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__))
def testBufferCaps(self): buffer = gst.Buffer() caps = gst.caps_from_string('foo/blah') gst.info("before settings caps") buffer.set_caps(caps) gst.info("after settings caps") c = buffer.get_caps() gst.info("after getting caps") self.assertEquals(caps, c)
def tearDown(self): gst.info("tearDown") self.assertTrue (self.pipeline.__gstrefcount__ >= 1 and self.pipeline.__gstrefcount__ <= 2) self.assertEquals(sys.getrefcount(self.pipeline), pygobject_2_13 and 2 or 3) self.assertEquals(self.src.__gstrefcount__, 2) self.assertEquals(sys.getrefcount(self.src), pygobject_2_13 and 2 or 3) self.assertEquals(self.sink.__gstrefcount__, 2) self.assertEquals(sys.getrefcount(self.sink), 3) gst.debug('deleting pipeline') del self.pipeline self.gccollect() self.assertEquals(self.src.__gstrefcount__, 1) # parent gone self.assertEquals(self.sink.__gstrefcount__, 1) # parent gone self.assertEquals(sys.getrefcount(self.src), pygobject_2_13 and 2 or 3) self.assertEquals(sys.getrefcount(self.sink), pygobject_2_13 and 2 or 3) gst.debug('deleting src') del self.src self.gccollect() gst.debug('deleting sink') del self.sink self.gccollect() TestCase.tearDown(self)
def testGoodConstructor(self): loop = gobject.MainLoop() gst.info("creating pipeline") pipeline = gst.parse_launch("fakesrc ! fakesink") gst.info("getting bus") bus = pipeline.get_bus() gst.info("got bus") gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) self.assertEquals(bus.__gstrefcount__, 2) self.assertEquals(pipeline.__gstrefcount__, 1) gst.info("about to add a watch on the bus") watch_id = bus.connect("message", self._message_received, pipeline, loop, "one") bus.add_signal_watch() gst.info("added a watch on the bus") gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) self.assertEquals(bus.__gstrefcount__, 3) self.assertEquals(pipeline.__gstrefcount__, 1) gst.info("setting to playing") ret = pipeline.set_state(gst.STATE_PLAYING) gst.info("set to playing %s, loop.run" % ret) gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) loop.run() gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) gst.info("setting to paused") ret = pipeline.set_state(gst.STATE_PAUSED) gst.info("set to paused %s, loop.run" % ret) gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) loop.run() gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) gst.info("setting to ready") ret = pipeline.set_state(gst.STATE_READY) gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) gst.info("set to READY %s, loop.run" % ret) loop.run() gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) gst.info("setting to NULL") ret = pipeline.set_state(gst.STATE_NULL) gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) gst.info("set to NULL %s" % ret) self.gccollect() self.assertEquals(bus.__gstrefcount__, 3) # FIXME: state change thread needs to die while pipeline.__gstrefcount__ > 1: gst.debug('waiting for pipeline refcount to drop') time.sleep(0.1) self.assertEquals(pipeline.__gstrefcount__, 1) gst.info("about to remove the watch id") gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) bus.remove_signal_watch() gst.info("bus watch id removed") bus.disconnect(watch_id) gst.info("disconnected callback") gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) self.gccollect() gst.info("pipeliner:%d/%d busr:%d" % (pipeline.__gstrefcount__, pipeline.__grefcount__, bus.__gstrefcount__)) self.assertEquals(bus.__gstrefcount__, 2) self.assertEquals(pipeline.__gstrefcount__, 1) gst.info("removing pipeline") del pipeline gst.info("pipeline removed") gst.info("busr:%d" % bus.__gstrefcount__) self.gccollect() # flush the bus bus.set_flushing(True) bus.set_flushing(False) self.gccollect() # FIXME: refcount is still 2 self.assertEquals(bus.__gstrefcount__, 1)
def testEOS(self): gst.info("creating new bin") b = gst.Bin() gst.info("creating new EOS message from that bin") m = gst.message_new_eos(b) gst.info("got message : %s" % m)
def message_application_cb(self, bus, message): gst.info("got application message") self.got_message = True self.loop.quit()
def testGoodConstructor(self): loop = gobject.MainLoop() gst.info("creating pipeline") pipeline = gst.parse_launch("fakesrc ! fakesink") gst.info("getting bus") bus = pipeline.get_bus() gst.info("got bus") gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) self.assertEquals(bus.__gstrefcount__, 2) self.assertEquals(pipeline.__gstrefcount__, 1) gst.info("about to add a watch on the bus") watch_id = bus.add_watch(self._message_received, pipeline, loop, "one") gst.info("added a watch on the bus") gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) self.assertEquals(bus.__gstrefcount__, 3) self.assertEquals(pipeline.__gstrefcount__, 1) gst.info("setting to playing") ret = pipeline.set_state(gst.STATE_PLAYING) gst.info("set to playing %s, loop.run" % ret) gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) loop.run() gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) gst.info("setting to paused") ret = pipeline.set_state(gst.STATE_PAUSED) gst.info("set to paused %s, loop.run" % ret) gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) loop.run() gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) gst.info("setting to ready") ret = pipeline.set_state(gst.STATE_READY) gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) gst.info("set to READY %s, loop.run" % ret) loop.run() gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) gst.info("setting to NULL") ret = pipeline.set_state(gst.STATE_NULL) gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) gst.info("set to NULL %s" % ret) self.gccollect() self.assertEquals(bus.__gstrefcount__, 3) self.assertEquals(pipeline.__gstrefcount__, 1) gst.info("about to remove the watch id") gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) self.failUnless(gobject.source_remove(watch_id)) gst.info("bus watch id removed") gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) self.gccollect() gst.info("pipeliner:%d/%d busr:%d" % (pipeline.__gstrefcount__, pipeline.__grefcount__, bus.__gstrefcount__)) self.assertEquals(bus.__gstrefcount__, 2) self.assertEquals(pipeline.__gstrefcount__, 1) gst.info("removing pipeline") del pipeline gst.info("pipeline removed") gst.info("busr:%d" % bus.__gstrefcount__) self.gccollect() # flush the bus bus.set_flushing(True) bus.set_flushing(False) self.gccollect() # FIXME: refcount is still 2 self.assertEquals(bus.__gstrefcount__, 1)
def testGoodConstructor(self): loop = gobject.MainLoop() gst.info ("creating pipeline") pipeline = gst.parse_launch("fakesrc ! fakesink") gst.info ("getting bus") bus = pipeline.get_bus() gst.info ("got bus") gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) self.assertEquals(bus.__gstrefcount__, 2) self.assertEquals(pipeline.__gstrefcount__, 1) gst.info ("about to add a watch on the bus") watch_id = bus.connect("message", self._message_received, pipeline, loop, "one") bus.add_signal_watch() gst.info ("added a watch on the bus") gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) self.assertEquals(bus.__gstrefcount__, 3) self.assertEquals(pipeline.__gstrefcount__, 1) gst.info("setting to playing") ret = pipeline.set_state(gst.STATE_PLAYING) gst.info("set to playing %s, loop.run" % ret) gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) loop.run() gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) gst.info("setting to paused") ret = pipeline.set_state(gst.STATE_PAUSED) gst.info("set to paused %s, loop.run" % ret) gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) loop.run() gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) gst.info("setting to ready") ret = pipeline.set_state(gst.STATE_READY) gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) gst.info("set to READY %s, loop.run" % ret) loop.run() gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) gst.info("setting to NULL") ret = pipeline.set_state(gst.STATE_NULL) gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) gst.info("set to NULL %s" % ret) self.gccollect() self.assertEquals(bus.__gstrefcount__, 3) # FIXME: state change thread needs to die while pipeline.__gstrefcount__ > 1: gst.debug('waiting for pipeline refcount to drop') time.sleep(0.1) self.assertEquals(pipeline.__gstrefcount__, 1) gst.info("about to remove the watch id") gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) bus.remove_signal_watch() gst.info("bus watch id removed") bus.disconnect(watch_id) gst.info("disconnected callback") gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) self.gccollect() gst.info("pipeliner:%d/%d busr:%d" % (pipeline.__gstrefcount__, pipeline.__grefcount__, bus.__gstrefcount__)) self.assertEquals(bus.__gstrefcount__, 2) self.assertEquals(pipeline.__gstrefcount__, 1) gst.info("removing pipeline") del pipeline gst.info("pipeline removed") gst.info("busr:%d" % bus.__gstrefcount__) self.gccollect() # flush the bus bus.set_flushing(True) bus.set_flushing(False) self.gccollect() # FIXME: refcount is still 2 self.assertEquals(bus.__gstrefcount__, 1)
def testGoodConstructor(self): loop = gobject.MainLoop() gst.info ("creating pipeline") pipeline = gst.parse_launch("fakesrc ! fakesink") gst.info ("getting bus") bus = pipeline.get_bus() gst.info ("got bus") gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) self.assertEquals(bus.__gstrefcount__, 2) self.assertEquals(pipeline.__gstrefcount__, 1) gst.info ("about to add a watch on the bus") watch_id = bus.add_watch(self._message_received, pipeline, loop, "one") gst.info ("added a watch on the bus") gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) self.assertEquals(bus.__gstrefcount__, 3) self.assertEquals(pipeline.__gstrefcount__, 1) gst.info("setting to playing") ret = pipeline.set_state(gst.STATE_PLAYING) gst.info("set to playing %s, loop.run" % ret) gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) loop.run() gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) gst.info("setting to paused") ret = pipeline.set_state(gst.STATE_PAUSED) gst.info("set to paused %s, loop.run" % ret) gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) loop.run() gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) gst.info("setting to ready") ret = pipeline.set_state(gst.STATE_READY) gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) gst.info("set to READY %s, loop.run" % ret) loop.run() gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) gst.info("setting to NULL") ret = pipeline.set_state(gst.STATE_NULL) gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) gst.info("set to NULL %s" % ret) self.gccollect() self.assertEquals(bus.__gstrefcount__, 3) self.assertEquals(pipeline.__gstrefcount__, 1) gst.info("about to remove the watch id") gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) self.failUnless(gobject.source_remove(watch_id)) gst.info("bus watch id removed") gst.info("pipeliner:%d busr:%d" % (pipeline.__gstrefcount__, bus.__gstrefcount__)) self.gccollect() gst.info("pipeliner:%d/%d busr:%d" % (pipeline.__gstrefcount__, pipeline.__grefcount__, bus.__gstrefcount__)) self.assertEquals(bus.__gstrefcount__, 2) self.assertEquals(pipeline.__gstrefcount__, 1) gst.info("removing pipeline") del pipeline gst.info("pipeline removed") gst.info("busr:%d" % bus.__gstrefcount__) self.gccollect() # flush the bus bus.set_flushing(True) bus.set_flushing(False) self.gccollect() # FIXME: refcount is still 2 self.assertEquals(bus.__gstrefcount__, 1)
def testError(self): gst.info("creating fakesrc") src = gst.element_factory_make("fakesrc", "name") gst.info("creating fakesink") sink = gst.element_factory_make("fakesink", "name") gst.info("adding src:%d to bin" % src.__gstrefcount__) self.assertEqual(src.__gstrefcount__, 1) self.bin.add(src) self.assertEqual(src.__gstrefcount__, 2) gst.info("added src:%d" % src.__gstrefcount__) self.assertRaises(gst.AddError, self.bin.add, sink) self.assertRaises(gst.AddError, self.bin.add, src) self.assertRaises(gst.RemoveError, self.bin.remove, sink) gst.info("removing src") self.bin.remove(src) gst.info("removed") self.assertRaises(gst.RemoveError, self.bin.remove, src)
def testError(self): gst.info("creating fakesrc") src = gst.element_factory_make('fakesrc', 'name') gst.info("creating fakesink") sink = gst.element_factory_make('fakesink', 'name') gst.info("adding src:%d to bin" % src.__gstrefcount__) self.assertEqual(src.__gstrefcount__, 1) self.bin.add(src) self.assertEqual(src.__gstrefcount__, 2) gst.info("added src:%d" % src.__gstrefcount__) self.assertRaises(gst.AddError, self.bin.add, sink) self.assertRaises(gst.AddError, self.bin.add, src) self.assertRaises(gst.RemoveError, self.bin.remove, sink) gst.info("removing src") self.bin.remove(src) gst.info("removed") self.assertRaises(gst.RemoveError, self.bin.remove, src)