def on_qos(self, bus: Gst.Bus, message: Gst.Message) -> None: """ Handler for `qos` messages By default it will parse the error message, log to `error` and append to `self.errors` """ live, running_time, stream_time, timestamp, duration = message.parse_qos( ) logger.warning( "Qos message: live:%s - running:%s - stream:%s - timestamp:%s - duration:%s received from %s on %s", live, running_time, stream_time, timestamp, duration, message.src.get_name(), bus)
def bus_call(bus: Gst.Bus, message: Gst.Message, loop: GLib.MainLoop): # https://stackoverflow.com/questions/49858346/how-te-retrieve-stream-statistics-in-gstreamer t = message.type sys.stdout.write("Received message from -> %s \n" % (message.src.name)) if t == Gst.MessageType.EOS: sys.stdout.write("End-of-stream\n") elif t == Gst.MessageType.ERROR: err, debug = message.parse_error() sys.stderr.write("Error: %s: %s\n" % (err, debug)) elif t == Gst.MessageType.WARNING: # Handle warnings err, debug = message.parse_warning() sys.stderr.write("Warning: %s: %s\n" % (err, debug)) # https://git.smart-cactus.org/ben/cam-stream/blob/0483fa5d3bb82e8a4212d7190d4541ed4d0653d5/stream.py elif t == Gst.MessageType.STATE_CHANGED: sys.stderr.write('state changed: %s\n' % (message.parse_state_changed(), )) elif t == Gst.MessageType.STREAM_STATUS: sys.stderr.write('stream status: %s\n' % (message.parse_stream_status(), )) elif t == Gst.MessageType.QOS: # Handle Qus live, running_time, stream_time, timestamp, duration = message.parse_qos( ) #sys.stderr.write("Qos Message: live %r, running_time %i, stream_time %i, timestamp: %i, duration: %i \n" % (live, running_time, stream_time, timestamp, duration)) #sys.stderr.write('qos: %s' % (message.parse_qos(),)) elif t == Gst.MessageType.ELEMENT: sys.stderr.write('Element message: %s\n' % (message.get_structure().to_string(), )) elif t == Gst.MessageType.BUFFERING: sys.stderr.write('Buffering message: %s\n' % (message.get_structure().to_string(), )) elif t == Gst.MessageType.PROGRESS: sys.stderr.write('Progress message: %s\n' % (message.get_structure().to_string(), )) else: sys.stderr.write('Bus message: %s: %s \n' % (message.timestamp, t)) pprint(message) return True