diff -r 76a3f315ef42 -r 76b9c97faada gmyth-stream/server/0.2/plugins/transcoders/mencoder.py --- a/gmyth-stream/server/0.2/plugins/transcoders/mencoder.py Tue May 15 14:41:04 2007 +0100 +++ b/gmyth-stream/server/0.2/plugins/transcoders/mencoder.py Tue May 15 20:16:26 2007 +0100 @@ -7,6 +7,7 @@ import lib.utils as utils import lib.server as server +import plugins.transcoders.mencoder_lib.mythtv as mythtv from select import select @@ -33,11 +34,6 @@ self.args["subtitle"] = params_first("subtitle", False) self.args["format"] = params_first("format", "mpeg1") self.args["outfile"] = params_first("outfile", "-") - self.args["sendback"] = params_first("sendback", True) - - # handle sendback variable - if self.args["sendback"] == "False": - self.args["sendback"] = False # input_opt uri = params_first("uri", "file:-").split(":", 1) @@ -200,8 +196,6 @@ os.write(stdw, data_in) total_read += 4096 d = stdout.read(4096) - if self.args["sendback"]: - outfd.write(d) self.status = total_read * 100 / size else: finished = True @@ -209,8 +203,6 @@ else: d = stdout.read(4096) - if self.args["sendback"] and d != "": - outfd.write(d) except Exception, e: self.log.error("Problems handling data: %s" % e) @@ -218,9 +210,6 @@ return False self.log.info("%s: Finished sending data to client" % repr(self)) - if not self.args["sendback"]: - outfd.write("DONE") - return True # _start_outfile() @@ -241,59 +230,6 @@ return True # _start() - def _start_myth(self, outfd): - # gmyth-cat -h 192.168.1.124 -p 6543 -c 111 - # gmyth-cat -h 192.168.1.124 -p 6543 -f file.nuv - # myth://IP:PORT:type:file - host = self.args["gmyth-cat"][0] - port = self.args["gmyth-cat"][1] - kind = self.args["gmyth-cat"][2] - fchan = self.args["gmyth-cat"][3] - - gmyth_cat = utils.which("gmyth-cat") - opts = [gmyth_cat, "-h", host, "-p", port, "-" + kind, fchan] - - try: - self.gmyth = subprocess.Popen(opts, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - close_fds=True) - except Exception, e: - self.log.error("Error executing gmyth-cat: %s" % e) - return False - - err = self.gmyth.stderr - - if not self._run_mencoder(input=self.gmyth.stdout, - output=subprocess.PIPE): - return False - - if kind == "f": - partial = 0 - size = err.read(20).split("\n")[0].split("Size:")[1] - self.log.debug("Size of file: %s" % size) - flags = fcntl.fcntl (err, fcntl.F_GETFL, 0) | os.O_NONBLOCK - fcntl.fcntl(err, fcntl.F_SETFL, flags) - - try: - while self.proc and self.proc.poll() == None: - r, w, x = select([err, self.proc.stdout], [], [], 0) - if self.proc.stdout in r: - d = self.proc.stdout.read(4096) - outfd.write(d) - - if err in r and kind == "f": - partial = err.read(50).split("\n")[-2] - if partial != "": - utils.progress_bar(self.log, int(partial), int(size), 50) - - - except Exception, e: - self.log.error("Problems handling data: %s" % e) - return False - - return True - # _start_myth() - def _run_mencoder(self, input=None, output=None): try: self.proc = subprocess.Popen(self.mencoder_opts, stdin=input, @@ -315,7 +251,7 @@ ret = self._start(outfd) elif self.args["type"] == "myth": - ret = self._start_myth(outfd) + ret = mythtv.start_myth(self, outfd) else: ret = self._start_outfile(outfd)