Report error messages and EOS from gstreamer bus.
[toast/stream2beamer.git] / lagarde.py
index 140ccd8d64d6e8ae8ab7c75bfa40afaebf52b78c..28cff738cbfc6377427af3ffa4c5cf208e70c301 100755 (executable)
@@ -102,12 +102,13 @@ class Lagarde:
         try:
             while True:
                 if bus.have_pending():
         try:
             while True:
                 if bus.have_pending():
-                    msg = bus.pop()  # Gst.Message, has to be unref'ed.
-                    if msg.type != Gst.MessageType.STATE_CHANGED:
-                        # log.info(f'Receive Gst.Message: {msg.type}, {msg.seqnum}, {msg.get_structure()}')
-                        # log.info(f'{webrtcbin.props.signaling_state} {webrtcbin.props.ice_gathering_state} {webrtcbin.props.ice_connection_state}')
-                        # Gst.Message.unref(msg)
-                        pass
+                    msg = bus.pop()
+                    if msg.type == Gst.MessageType.ERROR:
+                        log.error(f'Error from gstreamer message bus: {msg.get_structure()}')
+                        return
+                    elif msg.type == Gst.MessageType.EOS:  # end of stream
+                        log.info(f'Gstreamer message bus reports end of stream')
+                        return
                 elif self.sdp_offer is not None:
                     res, sm = GstSdp.SDPMessage.new()
                     assert res == GstSdp.SDPResult.OK
                 elif self.sdp_offer is not None:
                     res, sm = GstSdp.SDPMessage.new()
                     assert res == GstSdp.SDPResult.OK