1

Consider the following bus_call function for Gstreamer pipelines:

import sys
from gi.repository import Gst


def bus_call(bus, message: Gst.Message, loop):
    t = message.type
    if t == Gst.MessageType.EOS:
        print("Bus call: End-of-stream\n")
        # loop.quit()
    elif t == Gst.MessageType.WARNING:
        err, debug = message.parse_warning()
        sys.stderr.write("Bus call: Warning: %s: %s\n" % (err, debug))
    elif t == Gst.MessageType.ERROR:
        err, debug = message.parse_error()
        sys.stderr.write("Bus call: Error: %s: %s\n" % (err, debug))
        # loop.quit()
    elif t == Gst.MessageType.BUFFERING:
        print("Bus call: Buffering\n")
    elif t == Gst.MessageType.STATE_CHANGED:
        old_state, new_state, pending_state = message.parse_state_changed()
        print((
            f"Bus call: Pipeline state changed from {old_state.value_nick} to {new_state.value_nick} "
            f"(pending {pending_state.value_nick})"
        ))
    else:
        print(f"Bus call: {message}\n")
    return True

How can I print a meaningful message in the else branch? As it is, only the Python object information is shown:

Bus call: <Gst.Message object at 0x7f86401db100 (GstMessage at 0x7f8818036eb0)>
user1315621
  • 3,044
  • 9
  • 42
  • 86

0 Answers0