def _probe_callback_fakesrc(self, pad, buffer): self.failUnless(isinstance(pad, gst.Pad)) self.failUnless(isinstance(buffer, gst.Buffer)) self._got_fakesrc_buffer += 1 gst.debug('fakesrc sent buffer %r, %d total sent' % ( buffer, self._got_fakesrc_buffer)) return True
def testTrueProbe(self): probe_id = self.src.add_event_probe(self._probe_handler, True) self.event = gst.event_new_eos() gst.debug('created new eos %r, id %x' % ( self.event, id(self.event))) self.assertEquals(self.event.__grefcount__, 1) # a True probe lets it pass self.assertEquals(self.src.push_event(self.event), True) # one refcount is held by our scope, another is held on # self.events through _probe self.assertEquals(self.event.__grefcount__, 2) # they are not the same Python object ... self.failIf(self.event is self.events[0]) self.failIf(id(self.event) == id(self.events[0])) # ... but they wrap the same GstEvent self.assertEquals(repr(self.event), repr(self.events[0])) self.failUnless(self.event == self.events[0]) self.src.remove_buffer_probe(probe_id) self.assertEquals(len(self.events), 1) self.events = None self.assertEquals(self.event.__grefcount__, 1) # the event has reffed the src pad as the src of the event self.assertEquals(self.src.__grefcount__, 2) # clear it self.event = None self.assertEquals(self.src.__grefcount__, 1)
def testTrueProbe(self): probe_id = self.src.add_event_probe(self._probe_handler, True) self.event = gst.event_new_eos() gst.debug('created new eos %r, id %x' % (self.event, id(self.event))) self.assertEquals(self.event.__grefcount__, 1) # a True probe lets it pass self.assertEquals(self.src.push_event(self.event), True) # one refcount is held by our scope, another is held on # self.events through _probe self.assertEquals(self.event.__grefcount__, 2) # they are not the same Python object ... self.failIf(self.event is self.events[0]) self.failIf(id(self.event) == id(self.events[0])) # ... but they wrap the same GstEvent self.assertEquals(repr(self.event), repr(self.events[0])) self.failUnless(self.event == self.events[0]) self.src.remove_buffer_probe(probe_id) self.assertEquals(len(self.events), 1) self.events = None self.assertEquals(self.event.__grefcount__, 1) # the event has reffed the src pad as the src of the event self.assertEquals(self.src.__grefcount__, 2) # clear it self.event = None self.assertEquals(self.src.__grefcount__, 1)
def _probe_callback_fakesrc(self, pad, buffer): self.failUnless(isinstance(pad, gst.Pad)) self.failUnless(isinstance(buffer, gst.Buffer)) self._got_fakesrc_buffer += 1 gst.debug('fakesrc sent buffer %r, %d total sent' % (buffer, self._got_fakesrc_buffer)) return True
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 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 _handoff_callback_fakesink(self, sink, buffer, pad): self.failUnless(isinstance(buffer, gst.Buffer)) self.failUnless(isinstance(pad, gst.Pad)) self._got_fakesink_buffer += 1 gst.debug('fakesink got buffer %r, %d total received' % ( buffer, self._got_fakesrc_buffer)) gst.debug('pad %r, py refcount %d, go rc %d, gst rc %d' % ( pad, sys.getrefcount(pad), pad.__grefcount__, pad.__gstrefcount__)) return True
def _handoff_callback_fakesink(self, sink, buffer, pad): self.failUnless(isinstance(buffer, gst.Buffer)) self.failUnless(isinstance(pad, gst.Pad)) self._got_fakesink_buffer += 1 gst.debug('fakesink got buffer %r, %d total received' % (buffer, self._got_fakesrc_buffer)) gst.debug('pad %r, py refcount %d, go rc %d, gst rc %d' % (pad, sys.getrefcount(pad), pad.__grefcount__, pad.__gstrefcount__)) return True
def testBufferingStatsMessage(self): if hasattr(gst.Message, 'set_buffering_stats'): gst.debug("Creating buffering message") m = gst.message_new_buffering(self.element, 50) gst.debug("Setting stats") m.set_buffering_stats(gst.BUFFERING_LIVE, 30, 1024, 123456) self.assertEquals(m.type, gst.MESSAGE_BUFFERING) mode, ain, aout, left = m.parse_buffering_stats() self.assertEquals(mode, gst.BUFFERING_LIVE) self.assertEquals(ain, 30) self.assertEquals(aout, 1024) self.assertEquals(left, 123456)
def testQuery(self): gst.debug('querying fakesrc in FORMAT_BYTES') res = self.element.query_position(gst.FORMAT_BYTES) self.assertEquals(self.pipeline.__gstrefcount__, 1) self.assertEquals(sys.getrefcount(self.pipeline), pygobject_2_13 and 2 or 3) self.assertEquals(self.element.__gstrefcount__, 2) self.assertEquals(sys.getrefcount(self.element), pygobject_2_13 and 2 or 3) assert res assert res[0] == 0 self.assertRaises(gst.QueryError, self.element.query_position, gst.FORMAT_TIME) self.gccollect()
def testFalseProbe(self): probe_id = self.src.add_event_probe(self._probe_handler, False) self.event = gst.event_new_eos() gst.debug('created new eos %r, id %x' % ( self.event, id(self.event))) self.assertEquals(self.event.__grefcount__, 1) # a false probe return drops the event and returns False self.assertEquals(self.src.push_event(self.event), False) # one ref in our local scope, another in self.events self.assertEquals(self.event.__grefcount__, 2) self.assertEquals(self.sink.__grefcount__, 1) self.src.remove_buffer_probe(probe_id)
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, pen = 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 == self.final: self.loop.quit() return True
def testProbeLink(self): id = self.src.add_buffer_probe(self._probe_handler) self.buffer = gst.Buffer() self.assertEquals(self.buffer.__grefcount__, 1) gst.debug('pushing buffer on linked pad, no probe') self.assertEquals(self.src.push(self.buffer), gst.FLOW_OK) gst.debug('pushed buffer on linked pad, no probe') # one refcount is held by our scope, another is held on # self.buffers through _chain_func self.assertEquals(self.buffer.__grefcount__, 2) self.assertEquals(len(self.buffers), 1) self.buffers = None self.assertEquals(self.buffer.__grefcount__, 1)
def testConstructor(self): # first style uses gst_pad_new gst.debug('creating pad with name src') pad = gst.Pad("src", 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('creating pad with no name') self.failUnless(gst.Pad(None, gst.PAD_SRC)) self.failUnless(gst.Pad(name=None, direction=gst.PAD_SRC)) self.failUnless(gst.Pad(direction=gst.PAD_SRC, name=None)) self.failUnless(gst.Pad(direction=gst.PAD_SRC, name="src"))
def testEventSeek(self): # this event only serves to change the rate of data transfer event = gst.event_new_seek(1.0, gst.FORMAT_BYTES, gst.SEEK_FLAG_FLUSH, gst.SEEK_TYPE_NONE, 0, gst.SEEK_TYPE_NONE, 0) # FIXME: but basesrc goes into an mmap/munmap spree, needs to be fixed event = gst.event_new_seek(1.0, gst.FORMAT_BYTES, gst.SEEK_FLAG_FLUSH, gst.SEEK_TYPE_SET, 0, gst.SEEK_TYPE_NONE, 0) assert event gst.debug('sending event') self.sink.send_event(event) gst.debug('sent event') self.assertEqual(event.parse_seek(), (1.0, gst.FORMAT_BYTES, gst.SEEK_FLAG_FLUSH, gst.SEEK_TYPE_SET, 0, gst.SEEK_TYPE_NONE, 0))
def testFalseProbe(self): probe_id = self.src.add_event_probe(self._probe_handler, False) self.event = gst.event_new_eos() gst.debug('created new eos %r, id %x' % (self.event, id(self.event))) self.assertEquals(self.event.__grefcount__, 1) # a false probe return drops the event and returns False self.assertEquals(self.src.push_event(self.event), False) # one ref in our local scope, another in self.events self.assertEquals(self.event.__grefcount__, 2) self.assertEquals(self.sink.__grefcount__, 1) # the event has reffed the src pad as the src of the event self.assertEquals(self.src.__grefcount__, 2) # remove the event from existence self.event = None self.events = None self.assertEquals(self.src.__grefcount__, 1) self.src.remove_buffer_probe(probe_id)
def testFalseProbe(self): probe_id = self.src.add_event_probe(self._probe_handler, False) self.event = gst.event_new_eos() gst.debug("created new eos %r, id %x" % (self.event, id(self.event))) self.assertEquals(self.event.__grefcount__, 1) # a false probe return drops the event and returns False self.assertEquals(self.src.push_event(self.event), False) # one ref in our local scope, another in self.events self.assertEquals(self.event.__grefcount__, 2) self.assertEquals(self.sink.__grefcount__, 1) # the event has reffed the src pad as the src of the event self.assertEquals(self.src.__grefcount__, 2) # remove the event from existence self.event = None self.events = None self.assertEquals(self.src.__grefcount__, 1) self.src.remove_buffer_probe(probe_id)
def tearDown(self): # FIXME: fix the refcount issues with the bus/pipeline # flush the bus to be able to assert on the pipeline refcount #while self.pipeline.__gstrefcount__ > 1: self.gccollect() # one for the pipeline, two for the snake # three for the watch now shake shake shake but don't you self.assertEquals(self.bus.__gstrefcount__, 3) self.failUnless(gobject.source_remove(self.handler)) self.assertEquals(self.bus.__gstrefcount__, 2) self.gccollect() gst.debug('THOMAS: pipeline rc %d' % self.pipeline.__gstrefcount__) #self.assertEquals(self.pipeline.__gstrefcount__, 1) del self.pipeline self.gccollect() #self.assertEquals(self.bus.__gstrefcount__, 2) del self.bus self.gccollect()
def testBufferclip(self): assert hasattr(gst.audio, "buffer_clip") # create a segment segment = gst.Segment() gst.debug("Created the new segment") # we'll put a new segment of 500ms to 1000ms segment.set_newsegment(False, 1.0, gst.FORMAT_TIME, 0, -1, 0) gst.debug("Initialized the new segment") # create a new dummy buffer b = gst.Buffer("this is a really useless line") gst.debug("Created the buffer") # clip... which shouldn't do anything b2 = gst.audio.buffer_clip(b, segment, 44100, 8) gst.debug("DONE !")
def tearDown(self): # Refcount must be either 1 or 2, to allow for a possibly still running # state-recalculation thread 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.fakesrc.__gstrefcount__, 2) self.assertEquals(sys.getrefcount(self.fakesrc), pygobject_2_13 and 2 or 3) gst.debug('deleting pipeline') del self.pipeline self.gccollect() self.assertEquals(self.fakesrc.__gstrefcount__, 1) # parent gone self.assertEquals(self.fakesink.__gstrefcount__, 1) # parent gone self.assertEquals(sys.getrefcount(self.fakesrc), pygobject_2_13 and 2 or 3) self.assertEquals(sys.getrefcount(self.fakesink), pygobject_2_13 and 2 or 3) gst.debug('deleting fakesrc') del self.fakesrc self.gccollect() gst.debug('deleting fakesink') del self.fakesink self.gccollect() TestCase.tearDown(self)
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 tearDown(self): gst.debug('setting pipeline to NULL') self.pipeline.set_state(gst.STATE_NULL) gst.debug('set pipeline to NULL') # FIXME: wait for state change thread to die while self.pipeline.__gstrefcount__ > 1: gst.debug('waiting for self.pipeline G rc to drop to 1') time.sleep(0.1) self.assertEquals(self.pipeline.__gstrefcount__, 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 testNoProbe(self): self.buffer = gst.Buffer() gst.debug("created new buffer %r, id %x" % (self.buffer, id(self.buffer))) self.assertEquals(self.buffer.__grefcount__, 1) gst.debug("pushing buffer on linked pad, no probe") self.assertEquals(self.src.push(self.buffer), gst.FLOW_OK) gst.debug("pushed buffer on linked pad, no probe") # one refcount is held by our scope, another is held on # self.buffers through _chain_func self.assertEquals(self.buffer.__grefcount__, 2) self.assertEquals(len(self.buffers), 1) self.buffers = None self.assertEquals(self.buffer.__grefcount__, 1)
def testNoProbe(self): self.event = gst.event_new_eos() gst.debug("created new eos %r, id %x" % (self.event, id(self.event))) self.assertEquals(self.event.__grefcount__, 1) gst.debug("pushing event on linked pad, no probe") self.assertEquals(self.src.push_event(self.event), True) gst.debug("pushed event on linked pad, no probe") # one refcount is held by our scope self.assertEquals(self.event.__grefcount__, 1) # the event has reffed the src pad as the src of the event self.assertEquals(self.src.__grefcount__, 2) # clear it self.event = None self.assertEquals(self.src.__grefcount__, 1)
def testNoProbe(self): self.buffer = gst.Buffer() gst.debug('created new buffer %r, id %x' % (self.buffer, id(self.buffer))) self.assertEquals(self.buffer.__grefcount__, 1) gst.debug('pushing buffer on linked pad, no probe') self.assertEquals(self.src.push(self.buffer), gst.FLOW_OK) gst.debug('pushed buffer on linked pad, no probe') # one refcount is held by our scope, another is held on # self.buffers through _chain_func self.assertEquals(self.buffer.__grefcount__, 2) self.assertEquals(len(self.buffers), 1) self.buffers = None self.assertEquals(self.buffer.__grefcount__, 1)
def testNoProbe(self): self.event = gst.event_new_eos() gst.debug('created new eos %r, id %x' % (self.event, id(self.event))) self.assertEquals(self.event.__grefcount__, 1) gst.debug('pushing event on linked pad, no probe') self.assertEquals(self.src.push_event(self.event), True) gst.debug('pushed event on linked pad, no probe') # one refcount is held by our scope self.assertEquals(self.event.__grefcount__, 1) # the event has reffed the src pad as the src of the event self.assertEquals(self.src.__grefcount__, 2) # clear it self.event = None self.assertEquals(self.src.__grefcount__, 1)
def testFakeSrcProbeOnceKeep(self): self.fakesrc.set_property('num-buffers', 1) self.fakesink.set_property('signal-handoffs', True) self.fakesink.connect('handoff', self._handoff_callback_fakesink) pad = self.fakesrc.get_pad('src') id = pad.add_buffer_probe(self._probe_callback_fakesrc) self._got_fakesrc_buffer = 0 self._got_fakesink_buffer = 0 self.pipeline.set_state(gst.STATE_PLAYING) while not self._got_fakesrc_buffer: gst.debug('waiting for fakesrc buffer') pass while not self._got_fakesink_buffer: gst.debug('waiting for fakesink buffer') pass gst.debug('got buffers from fakesrc and fakesink') self.assertEquals(self._got_fakesink_buffer, 1) pad.remove_buffer_probe(id) self.pipeline.set_state(gst.STATE_NULL)
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 tearDown(self): # Refcount must be either 1 or 2, to allow for a possibly still running # state-recalculation thread 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.fakesrc.__gstrefcount__, 2) self.assertEquals(sys.getrefcount(self.fakesrc), pygobject_2_13 and 2 or 3) gst.debug('deleting pipeline') del self.pipeline self.gccollect() self.assertEquals(self.fakesrc.__gstrefcount__, 1) # parent gone self.assertEquals(self.fakesink.__gstrefcount__, 1) # parent gone self.assertEquals(sys.getrefcount(self.fakesrc), pygobject_2_13 and 2 or 3) self.assertEquals(sys.getrefcount(self.fakesink), pygobject_2_13 and 2 or 3) gst.debug('deleting fakesrc') del self.fakesrc self.gccollect() gst.debug('deleting fakesink') del self.fakesink self.gccollect() TestCase.tearDown(self)
def _src_buffer_probe_cb(self, pad, buffer): gst.debug("received probe on pad %r" % pad) self._probed = True gst.debug('adding sink bin') self.pipeline.add(self.sink) # this seems to get rid of the warnings about pushing on an unactivated # pad gst.debug('setting sink state') # FIXME: attempt one: sync to current pending state of bin (res, cur, pen) = self.pipeline.get_state(timeout=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(target) gst.debug('linking') self.src.link(self.sink) gst.debug('removing buffer probe id %r' % self._probe_id) pad.remove_buffer_probe(self._probe_id) self._probe_id = None gst.debug('done')
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.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 _chain_func(self, pad, buffer): gst.debug('got buffer %r, id %x, with GMO rc %d'% ( buffer, id(buffer), buffer.__grefcount__)) self.buffers.append(buffer) return gst.FLOW_OK
def _sink_handoff_cb(self, sink, buffer, pad): gst.debug('received handoff on pad %r' % pad) self._handoffs += 1
def _probe_handler(self, pad, event, ret): gst.debug("probed, pad %r, event %r" % (pad, event)) self.events.append(event) return ret
def _chain_func(self, pad, buffer): gst.debug('got buffer %r, id %x, with GMO rc %d' % (buffer, id(buffer), buffer.__grefcount__)) self.buffers.append(buffer) return gst.FLOW_OK