diff -r f4927ca53da7 -r 549c4664701e gmyth-stream/server/0.2/plugins/transcoders/gstreamer.py --- a/gmyth-stream/server/0.2/plugins/transcoders/gstreamer.py Thu Apr 19 16:14:41 2007 +0100 +++ b/gmyth-stream/server/0.2/plugins/transcoders/gstreamer.py Mon Apr 23 21:08:07 2007 +0100 @@ -30,11 +30,7 @@ self.Vbin = vbin self.Sink = sink self.Loop = gobject.MainLoop() - self.ACaps = "" - self.VCaps = "" self.Ready = False - self.Connection = None - self.Addr = None # __init__() # StreamData() @@ -47,13 +43,12 @@ self.connection = None self.addr = None self.ready = False - - self.log.info("Params for Gstreamer: %s" % self.params) + self.log.debug("Params for Gstreamer: %s" % self.params) # __init__() def _create_start_elements(self, uri): - self.log.info("Opening Uri:" + uri) + self.log.debug("Opening Uri:" + uri) src = gst.element_make_from_uri(gst.URI_SRC, uri, "src") decode = gst.element_factory_make("decodebin", "decode") mux = gst.element_factory_make("ffmux_mpeg", "mux") @@ -76,18 +71,18 @@ vencode.set_property ("quantizer", 5) if None in [vbin, vqueue, vrate, vencode, vqueue_src]: - self.log.info("Fail to create video encode elements.") + self.log.error("Fail to create video encode elements.") return False vbin.add(vqueue) if int(width) > 0 and int(height) > 0: - self.log.info(("Formating output to %d / %d" %(int(width), int(height)))) + self.log.debug("Formating output to %d / %d" % ( int(width), int(height))) vscale = gst.element_factory_make("ffvideoscale", "vscale") vbin.add(vscale); if not vqueue.link(vscale): - self.log.info("Fail to link video elements") + self.log.error("Fail to link video elements") return False vbin.add(colorspace) @@ -95,7 +90,7 @@ if not vscale.link(colorspace, \ gst.caps_from_string("video/x-raw-yuv,width=(int)%d,height=(int)%d" %(\ int(width), int(height)))): - self.log.info("Fail to link video elements") + self.log.error("Fail to link video elements") return False else: vbin.add(colorspace) @@ -103,16 +98,16 @@ vbin.add(vrate, vencode, vqueue_src) if not colorspace.link(vrate): - self.log.info("Fail to colorspace with vrate") + self.log.error("Fail to colorspace with vrate") return False if not vrate.link(vencode, \ gst.caps_from_string("video/x-raw-yuv,framerate=(fraction)10/1")): - self.log.info("Fail to link vrate element") + self.log.error("Fail to link vrate element") return False if not vencode.link(vqueue_src): - self.log.info("Fail to link video encode with queue") + self.log.error("Fail to link video encode with queue") return False vbin.add_pad(gst.GhostPad("sink", vqueue.get_pad("sink"))) @@ -129,32 +124,32 @@ #aencode = gst.element_factory_make("ffenc_mp2", "aencode") aencode = gst.element_factory_make("lame", "aencode") aqueue_src = gst.element_factory_make("queue", "aqueue_src") - + if None in [abin, aqueue, aencode, aqueue_src]: - self.log.info("Fail to create video encode elements.") + self.log.error("Fail to create video encode elements.") return False - #aencode.set_property ("bitrate", 32) + #aencode.set_property ("bitrate", 32) #aencode.set_property ("vbr-quality", 2) abin.add(aqueue, aconvert, aencode, aqueue_src) - self.log.info ("Link queue -> aconvert") + self.log.debug("Link queue -> aconvert") if not aqueue.link (aconvert): - self.log.info("Fail to link queue video") + self.log.error("Fail to link queue video") return False - self.log.info ("Link aconvert -> aencode") + self.log.debug("Link aconvert -> aencode") if not aconvert.link (aencode): - self.log.info("Fail to link video elements") + self.log.error("Fail to link video elements") return False - self.log.info ("Link aencode -> aqueue_src") + self.log.debug("Link aencode -> aqueue_src") if not aencode.link (aqueue_src): - self.log.info("Fail to link aencode -> aqueue_src") + self.log.error("Fail to link aencode -> aqueue_src") return False - self.log.info ("Link:OK") + self.log.debug("Link:OK") ghost_sink = gst.GhostPad("sink", aqueue.get_pad("sink")) ghost_src = gst.GhostPad("src", aqueue_src.get_pad("src")) @@ -207,11 +202,11 @@ video_pad = vbin.get_pad("src") if audio_pad.link(mux_audio) != gst.PAD_LINK_OK: - self.log.info("Fail to link audio with mux") + self.log.error("Fail to link audio with mux") return False if video_pad.link(mux_video) != gst.PAD_LINK_OK: - self.log.info("Fail to link audio with mux") + self.log.error("Fail to link audio with mux") return False self.stream_data = self.StreamData(self.log, pipe, abin, vbin, sink) @@ -231,7 +226,7 @@ def __on_bus_message(self, bus, message, stream_data): t = message.type - self.log.info ("__on_bus_message") + self.log.debug("__on_bus_message") if t == gst.MESSAGE_STATE_CHANGED: oldstate = -1 @@ -278,20 +273,20 @@ def __on_decode_new_pad(self, decode, pad, arg1, stream_data): caps = pad.get_caps().to_string() - self.log.info("New pad " + caps) + self.log.debug("New pad " + caps) if caps.rfind("audio") != -1: apad = stream_data.Abin.get_pad("sink") if pad.link(apad) != gst.PAD_LINK_OK: - self.log.info("Error on link audio pad") + self.log.error("Error on link audio pad") return None elif caps.rfind("video") != -1: vpad = stream_data.Vbin.get_pad("sink") if pad.link(vpad) != gst.PAD_LINK_OK: - self.log.info("Error on link video pad") + self.log.error("Error on link video pad") return None else: - self.log.info("Invalid caps") - self.log.info("Linked") + self.log.error("Invalid caps") + self.log.debug("Linked") # __on_decode_new_pad @@ -305,15 +300,13 @@ params_first("abitrate", 192000), params_first("width", 320), params_first("height", 240), params_first("options", "")) - self.log.info("Play %s", outfd.fileno()) + self.log.debug("Play %s", outfd.fileno()) self.stream_data.Sink.set_property("fd", outfd.fileno()) self.log.info("Setting Pipeline state to PLAYING") self.stream_data.Pipe.set_state(gst.STATE_PLAYING) # keep playing until EOS self.stream_data.Loop.run() - self.log.info("quit loop") - return True # start()