def setUp(self): 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.fakesrc = gst.element_factory_make('fakesrc') self.fakesink = gst.element_factory_make('fakesink') self.assertEquals(self.fakesrc.__gstrefcount__, 1) self.assertEquals(sys.getrefcount(self.fakesrc), pygobject_2_13 and 2 or 3) self.pipeline.add(self.fakesrc, self.fakesink) self.assertEquals(self.fakesrc.__gstrefcount__, 2) # added self.assertEquals(sys.getrefcount(self.fakesrc), pygobject_2_13 and 2 or 3) self.assertEquals(self.fakesink.__gstrefcount__, 2) # added self.assertEquals(sys.getrefcount(self.fakesink), pygobject_2_13 and 2 or 3) self.fakesrc.link(self.fakesink) self.assertEquals(self.pipeline.__gstrefcount__, 1) self.assertEquals(sys.getrefcount(self.pipeline), pygobject_2_13 and 2 or 3) self.assertEquals(self.fakesrc.__gstrefcount__, 2) self.assertEquals(sys.getrefcount(self.fakesrc), pygobject_2_13 and 2 or 3) self.assertEquals(self.fakesink.__gstrefcount__, 2) self.assertEquals(sys.getrefcount(self.fakesink), pygobject_2_13 and 2 or 3)
def testFake(self): src = gst.element_factory_make("fakesrc") sink = gst.element_factory_make("fakesink") self.bin.add(src) # bin will go to paused, src pad task will start and error out self.bin.set_state(gst.STATE_PAUSED) ret = self.bin.get_state() self.assertEquals(ret[0], gst.STATE_CHANGE_SUCCESS) self.assertEquals(ret[1], gst.STATE_PAUSED) self.assertEquals(ret[2], gst.STATE_VOID_PENDING) # adding the sink will cause the bin to go in preroll mode gst.debug("adding sink and setting to PAUSED, should cause preroll") self.bin.add(sink) sink.set_state(gst.STATE_PAUSED) ret = self.bin.get_state(timeout=0) self.assertEquals(ret[0], gst.STATE_CHANGE_ASYNC) self.assertEquals(ret[1], gst.STATE_PAUSED) self.assertEquals(ret[2], gst.STATE_PAUSED) # to actually complete preroll, we need to link and re-enable fakesrc src.set_state(gst.STATE_READY) src.link(sink) src.set_state(gst.STATE_PAUSED) ret = self.bin.get_state() self.assertEquals(ret[0], gst.STATE_CHANGE_SUCCESS) self.assertEquals(ret[1], gst.STATE_PAUSED) self.assertEquals(ret[2], gst.STATE_VOID_PENDING) self.bin.set_state(gst.STATE_NULL) self.bin.get_state()
def testMany(self): src = gst.element_factory_make('fakesrc') sink = gst.element_factory_make('fakesink') self.bin.add(src, sink) self.assertRaises(gst.AddError, self.bin.add, src, sink) self.bin.remove(src, sink) self.assertRaises(gst.RemoveError, self.bin.remove, src, sink)
def testMany(self): src = gst.element_factory_make("fakesrc") sink = gst.element_factory_make("fakesink") self.bin.add(src, sink) self.assertRaises(gst.AddError, self.bin.add, src, sink) self.bin.remove(src, sink) self.assertRaises(gst.RemoveError, self.bin.remove, src, sink)
def testFake(self): src = gst.element_factory_make('fakesrc') sink = gst.element_factory_make('fakesink') self.bin.add(src) # bin will go to paused, src pad task will start and error out self.bin.set_state(gst.STATE_PAUSED) ret = self.bin.get_state() self.assertEquals(ret[0], gst.STATE_CHANGE_SUCCESS) self.assertEquals(ret[1], gst.STATE_PAUSED) self.assertEquals(ret[2], gst.STATE_VOID_PENDING) # adding the sink will cause the bin to go in preroll mode gst.debug('adding sink and setting to PAUSED, should cause preroll') self.bin.add(sink) sink.set_state(gst.STATE_PAUSED) ret = self.bin.get_state(timeout=0) self.assertEquals(ret[0], gst.STATE_CHANGE_ASYNC) self.assertEquals(ret[1], gst.STATE_PAUSED) self.assertEquals(ret[2], gst.STATE_PAUSED) # to actually complete preroll, we need to link and re-enable fakesrc src.set_state(gst.STATE_READY) src.link(sink) src.set_state(gst.STATE_PAUSED) ret = self.bin.get_state() self.assertEquals(ret[0], gst.STATE_CHANGE_SUCCESS) self.assertEquals(ret[1], gst.STATE_PAUSED) self.assertEquals(ret[2], gst.STATE_VOID_PENDING) self.bin.set_state(gst.STATE_NULL) self.bin.get_state()
def setUp(self): self.gctrack() self.pipeline = gst.Pipeline('test-pipeline') source = gst.element_factory_make('fakesrc', 'source') source.set_property('num-buffers', 5) sink = gst.element_factory_make('fakesink', 'sink') self.pipeline.add(source, sink) gst.element_link_many(source, sink)
def setUp(self): TestCase.setUp(self) self.pipeline = gst.Pipeline('test-pipeline') source = gst.element_factory_make('fakesrc', 'source') sink = gst.element_factory_make('fakesink', 'sink') self.pipeline.add(source, sink) gst.element_link_many(source, sink) self.bus = self.pipeline.get_bus() self.assertEquals(self.bus.__gstrefcount__, 2) self.handler = self.bus.add_watch(self._message_received) self.assertEquals(self.bus.__gstrefcount__, 3) self.assertEquals(self.pipeline.__gstrefcount__, 1) self.loop = gobject.MainLoop()
def setUp(self): TestCase.setUp(self) self.pipeline = gst.Pipeline() self.src = gst.element_factory_make('fakesrc') self.src.set_property('num-buffers', 10) self.pipeline.add(self.src) self.srcpad = self.src.get_pad('src')
def prepare(self): sink = gst.element_factory_make('fakesink') self.add(sink) pad = sink.get_pad("sink") ghostpad = gst.GhostPad("sink", pad) self.add_pad(ghostpad) self.sink = sink
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 testDebug(self): e = gst.element_factory_make('fakesrc') e.error('I am an error string') e.warning('I am a warning string') e.info('I am an info string') e.debug('I am a debug string') e.log('I am a log string') e.debug('I am a formatted %s %s' % ('log', 'string'))
def FIXME_testXOverlay(self): # obviously a testsuite is not allowed to instantiate this # since it needs a running X or will fail. find some way to # deal with that. element = gst.element_factory_make('xvimagesink') assert isinstance(element, gst.Element) assert isinstance(element, gst.interfaces.XOverlay) element.set_xwindow_id(0L)
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 testLinkFiltered(self): # a filtered link uses capsfilter and thus needs a bin bin = gst.Bin() src = gst.element_factory_make('fakesrc') sink = gst.element_factory_make('fakesink') bin.add(src, sink) caps = gst.caps_from_string("audio/x-raw-int") self.failUnless(src.link(sink, caps)) # DANGER WILL. src is not actually connected to sink, since # there's a capsfilter in the way. What a leaky abstraction. # FIXME # src.unlink(sink) # instead, mess with pads directly pad = src.get_pad('src') pad.unlink(pad.get_peer()) pad = sink.get_pad('sink') pad.get_peer().unlink(pad)
def testSubSubClass(self): # Edward is worried that a subclass of a subclass will screw up # the refcounting wrt. GST_BUS_DROP p = TestPipeSubSub() u = gst.element_factory_make('uridecodebin') self.assertEquals(u.__grefcount__, 1) self.failIf(getattr(p, 'type', None)) p.add(u) self.assertEquals(getattr(p, 'type', None), gst.MESSAGE_CLOCK_PROVIDE) self.assertEquals(u.__grefcount__, 2) del p self.assertEquals(u.__grefcount__, 1)
def testSubClass(self): p = TestPipeSub() u = gst.element_factory_make('uridecodebin') self.assertEquals(u.__grefcount__, 1) self.failIf(getattr(p, 'type', None)) # adding uridecodebin triggers a clock-provide message; # this message should be dropped, and thus not affect # the refcount of u beyond the parenting. p.add(u) self.assertEquals(getattr(p, 'type', None), gst.MESSAGE_CLOCK_PROVIDE) self.assertEquals(u.__grefcount__, 2) del p self.assertEquals(u.__grefcount__, 1)
def _buffer_probe_cb(self, pad, buffer): self.failUnless(self._newsegment) # fake autoplugging by now putting in a fakesink sink = gst.element_factory_make('fakesink') self.pipeline.add(sink) self.src.link(sink) sink.set_state(gst.STATE_PLAYING) pad = sink.get_pad('sink') pad.send_event(self._newsegment) # we don't want to be called again self.srcpad.remove_buffer_probe(self._buffer_probe_id) self._had_buffer = True # now let the buffer through return True
def testIteratePadsFakeSink(self): fakesink = gst.element_factory_make('fakesink') pads = list(fakesink.pads()) sinkpad = fakesink.get_pad('sink') self.assertEqual(len(pads), 1) self.assertEqual(pads[0], sinkpad) srcpads = list(fakesink.src_pads()) self.assertEqual(srcpads, []) sinkpads = list(fakesink.sink_pads()) self.assertEqual(len(sinkpads), 1) self.assertEqual(sinkpads[0], sinkpad) self.assertEqual(len(list(fakesink)), 1) for pad in fakesink: self.assertEqual(pad, sinkpad) break else: raise AssertionError
def testPropertyMarshalling(self): try: obj = gst.element_factory_make("videoparse") except gst.ElementNotFoundError: # no videoparse and I don't know of any elements in core or -base using # fraction properties. Skip this test. return value = obj.props.framerate self.failUnlessEqual(value.num, 25) self.failUnlessEqual(value.denom, 1) obj.props.framerate = gst.Fraction(2, 1) value = obj.props.framerate self.failUnlessEqual(value.num, 2) self.failUnlessEqual(value.denom, 1) def bad(): obj.props.framerate = 1 self.failUnlessRaises(TypeError, bad) value = obj.props.framerate self.failUnlessEqual(value.num, 2) self.failUnlessEqual(value.denom, 1)
def testAddPad(self): # add a pad to an element e = gst.element_factory_make('fakesrc') self.assertEquals(sys.getrefcount(e), pygobject_2_13 and 2 or 3) self.assertEquals(e.__gstrefcount__, 1) gst.debug('creating pad with name mypad') pad = gst.Pad("mypad", gst.PAD_SRC) self.failUnless(pad) self.assertEquals(sys.getrefcount(pad), pygobject_2_13 and 2 or 3) self.assertEquals(pad.__gstrefcount__, 1) gst.debug('adding pad to element') e.add_pad(pad) self.assertEquals(sys.getrefcount(e), pygobject_2_13 and 2 or 3) self.assertEquals(e.__gstrefcount__, 1) self.assertEquals(sys.getrefcount(pad), pygobject_2_13 and 2 or 3) self.assertEquals(pad.__gstrefcount__, 2) # added to element gst.debug('deleting element and collecting') self.gccollect() del e if not pygobject_2_13: # the element will be collected at 'del e' if we're using # pygobject >= 2.13.0 self.assertEquals(self.gccollect(), 1) # collected the element self.assertEquals(sys.getrefcount(pad), pygobject_2_13 and 2 or 3) self.assertEquals(pad.__gstrefcount__, 1) # removed from element gst.debug('deleting pad and collecting') del pad if not pygobject_2_13: # the pad will be collected at 'del pad' if we're using # pygobject >= 2.13.0 self.assertEquals(self.gccollect(), 1) # collected the pad gst.debug('going into teardown')
def prepare(self): src = gst.element_factory_make('fakesrc') self.add(src) pad = src.get_pad("src") ghostpad = gst.GhostPad("src", pad) self.add_pad(ghostpad)
def testLink(self): src = gst.element_factory_make('fakesrc') sink = gst.element_factory_make('fakesink') self.failUnless(src.link(sink))
def testConstruct(self): queue = gst.element_factory_make('queue') assert queue.get_name() == 'queue0' self.assertEquals(queue.__gstrefcount__, 1)
def testGoodConstructor(self): element = gst.element_factory_make(self.name, self.alias) assert element is not None, 'element is None' assert isinstance(element, gst.Element) assert element.get_name() == self.alias
def testLinkPads(self): src = gst.element_factory_make('fakesrc') sink = gst.element_factory_make('fakesink') # print src.__gstrefcount__ self.failUnless(src.link_pads("src", sink, "sink")) src.unlink_pads("src", sink, "sink")