Hello!
I'm trying to destroy pipeline by setting NULL state in error message handler, but there is two sockets leak in each turn... Am I wrong and why? Code: -- #!/usr/bin/python # -*- encoding: utf-8 -*- import sys, os, errno, socket, time#!/usr/bin/python # -*- encoding: utf-8 -*- import sys, os, errno, socket, time import gi gi.require_version('Gst', '1.0') from gi.repository import Gst, GObject Gst.CLOCK_TIME_NONE = 2**64-1 # Fix, g-i (GstClockTime (-1)) def DEBUG(*x): print >>sys.stderr, "DEBUG:", ", ".join(str(e) for e in x) class Leak(): pipe = """ filesrc location=/tmp/leak-.mkv ! filesink location=/tmp/leak+.mkv """ def __init__(self): self.build() def build(self): self.pipeline = Gst.parse_launch(self.pipe) DEBUG("NEW pipeline: %x" % id(self.pipeline)) def onMessage(bus, message, self): if message.type == Gst.MessageType.ERROR: err, msg = message.parse_error() print >> sys.stderr, err.message self.shutdown() return False if message.type == Gst.MessageType.EOS: self.pipeline.set_state(Gst.State.NULL) DEBUG("onMessage", message.type) DEBUG("onMessage", message.type) return True self.pipeline.set_auto_flush_bus(True) bus = self.pipeline.get_bus() bus.connect("message", onMessage, self) bus.add_signal_watch() def play(self): if not self.pipeline: self.build() print self.pipeline.get_state(0) self.pipeline.set_state(Gst.State.PLAYING) return True def shutdown(self): #leak.pipeline.set_state(Gst.State.READY) leak.pipeline.set_state(Gst.State.NULL) leak.pipeline = None DEBUG("ERROR, pipeline destroyed") GObject.threads_init() loop = GObject.MainLoop() Gst.init(None) leak = Leak() leak.play() GObject.timeout_add(8000, Leak.play, leak) try: loop.run() except KeyboardInterrupt as e: pass finally: leak.shutdown() import gi gi.require_version('Gst', '1.0') from gi.repository import Gst, GObject Gst.CLOCK_TIME_NONE = 2**64-1 # Fix, g-i (GstClockTime (-1)) def DEBUG(*x): print >>sys.stderr, "DEBUG:", ", ".join(str(e) for e in x) class Leak(): pipe = """ filesrc location=/tmp/leak-.mkv ! filesink location=/tmp/leak+.mkv """ def __init__(self): self.build() def build(self): self.pipeline = Gst.parse_launch(self.pipe) DEBUG("NEW pipeline: %x" % id(self.pipeline)) def onMessage(bus, message, self): if message.type == Gst.MessageType.ERROR: err, msg = message.parse_error() print >> sys.stderr, err.message self.shutdown() return False if message.type == Gst.MessageType.EOS: self.pipeline.set_state(Gst.State.NULL) DEBUG("onMessage", message.type) DEBUG("onMessage", message.type) return True self.pipeline.set_auto_flush_bus(True) bus = self.pipeline.get_bus() bus.connect("message", onMessage, self) bus.add_signal_watch() def play(self): if not self.pipeline: self.build() print self.pipeline.get_state(0) self.pipeline.set_state(Gst.State.PLAYING) return True def shutdown(self): #leak.pipeline.set_state(Gst.State.READY) leak.pipeline.set_state(Gst.State.NULL) leak.pipeline = None DEBUG("ERROR, pipeline destroyed") GObject.threads_init() loop = GObject.MainLoop() Gst.init(None) leak = Leak() leak.play() GObject.timeout_add(8000, Leak.play, leak) try: loop.run() except KeyboardInterrupt as e: pass finally: leak.shutdown() -- _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |