Пример #1
0
 def on_message(self, bus, message):
     #log("on_message(%s, %s)", bus, message)
     t = message.type
     if t == gst.MESSAGE_EOS:
         self.pipeline.set_state(gst.STATE_NULL)
         log.info("sound source EOS")
         self.state = "stopped"
         self.emit("state-changed", self.state)
     elif t == gst.MESSAGE_ERROR:
         self.pipeline.set_state(gst.STATE_NULL)
         err, details = message.parse_error()
         log.error("sound source pipeline error: %s / %s", err, details)
         self.state = "error"
         self.emit("state-changed", self.state)
     elif t == gst.MESSAGE_TAG:
         if message.structure.has_field("bitrate"):
             new_bitrate = int(message.structure["bitrate"])
             self.update_bitrate(new_bitrate)
         elif message.structure.has_field("codec"):
             desc = message.structure["codec"]
             if self.codec_description != desc:
                 log.info("codec: %s", desc)
                 self.codec_description = desc
         elif message.structure.has_field("audio-codec"):
             desc = message.structure["audio-codec"]
             if self.codec_description != desc:
                 log.info("using audio codec: %s", desc)
                 self.codec_description = desc
         elif message.structure.has_field("mode"):
             mode = message.structure["mode"]
             if self.codec_mode != mode:
                 log("mode: %s", mode)
                 self.codec_mode = mode
         else:
             log.info("unknown tag message: %s", message)
     elif t == gst.MESSAGE_STREAM_STATUS:
         log("stream status: %s", message)
     elif t in (gst.MESSAGE_LATENCY, gst.MESSAGE_ASYNC_DONE,
                gst.MESSAGE_NEW_CLOCK):
         log("%s", message)
     elif t == gst.MESSAGE_STATE_CHANGED:
         if isinstance(message.src, gst.Pipeline):
             _, new_state, _ = message.parse_state_changed()
             log("new-state=%s", gst.element_state_get_name(new_state))
             self.state = self.do_get_state(new_state)
             self.emit("state-changed", self.state)
         else:
             log("state changed: %s", message)
     elif t == gst.MESSAGE_DURATION:
         d = message.parse_duration()
         log("duration changed: %s", d)
     elif t == gst.MESSAGE_LATENCY:
         log.info("Latency message from %s: %s", message.src, message)
     elif t == gst.MESSAGE_WARNING:
         w = message.parse_warning()
         log.warn("pipeline warning: %s", w[0].message)
         log.info("pipeline warning: %s", w[1:])
     else:
         log.info("unhandled bus message type %s: %s / %s", t, message,
                  message.structure)
Пример #2
0
 def on_message(self, bus, message):
     #log("on_message(%s, %s)", bus, message)
     t = message.type
     if t == gst.MESSAGE_EOS:
         self.pipeline.set_state(gst.STATE_NULL)
         log.info("sound source EOS")
         self.state = "stopped"
         self.emit("state-changed", self.state)
     elif t == gst.MESSAGE_ERROR:
         self.pipeline.set_state(gst.STATE_NULL)
         err, details = message.parse_error()
         log.error("sound source pipeline error: %s / %s", err, details)
         self.state = "error"
         self.emit("state-changed", self.state)
     elif t == gst.MESSAGE_TAG:
         if message.structure.has_field("bitrate"):
             new_bitrate = int(message.structure["bitrate"])
             self.update_bitrate(new_bitrate)
         elif message.structure.has_field("codec"):
             desc = message.structure["codec"]
             if self.codec_description!=desc:
                 log.info("codec: %s", desc)
                 self.codec_description = desc
         elif message.structure.has_field("audio-codec"):
             desc = message.structure["audio-codec"]
             if self.codec_description!=desc:
                 log.info("using audio codec: %s", desc)
                 self.codec_description = desc
         elif message.structure.has_field("mode"):
             mode = message.structure["mode"]
             if self.codec_mode!=mode:
                 log("mode: %s", mode)
                 self.codec_mode = mode
         else:
             log.info("unknown tag message: %s", message)
     elif t == gst.MESSAGE_STREAM_STATUS:
         log("stream status: %s", message)
     elif t in (gst.MESSAGE_LATENCY, gst.MESSAGE_ASYNC_DONE, gst.MESSAGE_NEW_CLOCK):
         log("%s", message)
     elif t == gst.MESSAGE_STATE_CHANGED:
         if isinstance(message.src, gst.Pipeline):
             _, new_state, _ = message.parse_state_changed()
             log("new-state=%s", gst.element_state_get_name(new_state))
             self.state = self.do_get_state(new_state)
             self.emit("state-changed", self.state)
         else:
             log("state changed: %s", message)
     elif t == gst.MESSAGE_DURATION:
         d = message.parse_duration()
         log("duration changed: %s", d)
     elif t == gst.MESSAGE_LATENCY:
         log.info("Latency message from %s: %s", message.src, message)
     elif t == gst.MESSAGE_WARNING:
         w = message.parse_warning()
         log.warn("pipeline warning: %s", w[0].message)
         log.info("pipeline warning: %s", w[1:])
     else:
         log.info("unhandled bus message type %s: %s / %s", t, message, message.structure)
Пример #3
0
 def on_message(self, bus, message):
     #log("on_message(%s, %s)", bus, message)
     t = message.type
     if t == gst.MESSAGE_EOS:
         self.pipeline.set_state(gst.STATE_NULL)
         log.info("sound source EOS")
         self.state = "stopped"
         self.idle_emit("state-changed", self.state)
     elif t == gst.MESSAGE_ERROR:
         self.pipeline.set_state(gst.STATE_NULL)
         err, details = message.parse_error()
         log.error("sound source pipeline error: %s / %s", err, details)
         self.state = "error"
         self.idle_emit("state-changed", self.state)
     elif t == gst.MESSAGE_TAG:
         try:
             #Gst 0.10:
             assert message.structure is not None, "test for pygst / 0.10"
             self.parse_message0(message)
         except:
             #Gst 1.0:
             self.parse_message1(message)
     elif t == gst.MESSAGE_STREAM_STATUS:
         log("stream status: %s", message)
     elif t == gst.MESSAGE_STREAM_START:
         log("stream start: %s", message)
     elif t in (gst.MESSAGE_LATENCY, gst.MESSAGE_ASYNC_DONE, gst.MESSAGE_NEW_CLOCK):
         log("%s", message)
     elif t == gst.MESSAGE_STATE_CHANGED:
         if isinstance(message.src, gst.Pipeline):
             _, new_state, _ = message.parse_state_changed()
             log("new-state=%s", gst.element_state_get_name(new_state))
             self.state = self.do_get_state(new_state)
             self.idle_emit("state-changed", self.state)
         else:
             log("state changed: %s", message)
     elif t == gst.MESSAGE_DURATION:
         d = message.parse_duration()
         try:
             v = d[1]
             if v>0:
                 log("duration changed: %s", v)
         except:
             log("duration changed: %s", d)
     elif t == gst.MESSAGE_LATENCY:
         log.info("Latency message from %s: %s", message.src, message)
     elif t == gst.MESSAGE_INFO:
         log.info("Sound pipeline message: %s", message)
     elif t == gst.MESSAGE_WARNING:
         w = message.parse_warning()
         log.warn("pipeline warning: %s", w[0].message)
         log.info("pipeline warning: %s", w[1:])
     else:
         log.info("unhandled bus message type %s: %s", t, message)
     self.emit_info()
Пример #4
0
 def on_message(self, bus, message):
     #log("on_message(%s, %s)", bus, message)
     t = message.type
     if t == gst.MESSAGE_EOS:
         self.pipeline.set_state(gst.STATE_NULL)
         log.info("sound source EOS")
         self.state = "stopped"
         self.emit("state-changed", self.state)
     elif t == gst.MESSAGE_ERROR:
         self.pipeline.set_state(gst.STATE_NULL)
         err, details = message.parse_error()
         log.error("sound source pipeline error: %s / %s", err, details)
         self.state = "error"
         self.emit("state-changed", self.state)
     elif t == gst.MESSAGE_TAG:
         try:
             #Gst 0.10:
             assert message.structure is not None, "test for pygst / 0.10"
             self.parse_message0(message)
         except:
             #Gst 1.0:
             self.parse_message1(message)
     elif t == gst.MESSAGE_STREAM_STATUS:
         log("stream status: %s", message)
     elif t == gst.MESSAGE_STREAM_START:
         log("stream start: %s", message)
     elif t in (gst.MESSAGE_LATENCY, gst.MESSAGE_ASYNC_DONE, gst.MESSAGE_NEW_CLOCK):
         log("%s", message)
     elif t == gst.MESSAGE_STATE_CHANGED:
         if isinstance(message.src, gst.Pipeline):
             _, new_state, _ = message.parse_state_changed()
             log("new-state=%s", gst.element_state_get_name(new_state))
             self.state = self.do_get_state(new_state)
             self.emit("state-changed", self.state)
         else:
             log("state changed: %s", message)
     elif t == gst.MESSAGE_DURATION:
         d = message.parse_duration()
         log("duration changed: %s", d)
     elif t == gst.MESSAGE_LATENCY:
         log.info("Latency message from %s: %s", message.src, message)
     elif t == gst.MESSAGE_INFO:
         log.info("Sound pipeline message: %s", message)
     elif t == gst.MESSAGE_WARNING:
         w = message.parse_warning()
         log.warn("pipeline warning: %s", w[0].message)
         log.info("pipeline warning: %s", w[1:])
     else:
         log.info("unhandled bus message type %s: %s", t, message)