1.1 --- a/gmyth-stream/server/0.2/plugins/transcoders/mencoder.py Tue May 15 14:41:04 2007 +0100
1.2 +++ b/gmyth-stream/server/0.2/plugins/transcoders/mencoder.py Tue May 15 22:14:04 2007 +0100
1.3 @@ -7,6 +7,7 @@
1.4
1.5 import lib.utils as utils
1.6 import lib.server as server
1.7 +import plugins.transcoders.mencoder_lib.mythtv as mythtv
1.8
1.9 from select import select
1.10
1.11 @@ -33,11 +34,6 @@
1.12 self.args["subtitle"] = params_first("subtitle", False)
1.13 self.args["format"] = params_first("format", "mpeg1")
1.14 self.args["outfile"] = params_first("outfile", "-")
1.15 - self.args["sendback"] = params_first("sendback", True)
1.16 -
1.17 - # handle sendback variable
1.18 - if self.args["sendback"] == "False":
1.19 - self.args["sendback"] = False
1.20
1.21 # input_opt
1.22 uri = params_first("uri", "file:-").split(":", 1)
1.23 @@ -200,8 +196,6 @@
1.24 os.write(stdw, data_in)
1.25 total_read += 4096
1.26 d = stdout.read(4096)
1.27 - if self.args["sendback"]:
1.28 - outfd.write(d)
1.29 self.status = total_read * 100 / size
1.30 else:
1.31 finished = True
1.32 @@ -209,8 +203,6 @@
1.33
1.34 else:
1.35 d = stdout.read(4096)
1.36 - if self.args["sendback"] and d != "":
1.37 - outfd.write(d)
1.38
1.39 except Exception, e:
1.40 self.log.error("Problems handling data: %s" % e)
1.41 @@ -218,9 +210,6 @@
1.42 return False
1.43
1.44 self.log.info("%s: Finished sending data to client" % repr(self))
1.45 - if not self.args["sendback"]:
1.46 - outfd.write("DONE")
1.47 -
1.48 return True
1.49 # _start_outfile()
1.50
1.51 @@ -241,59 +230,6 @@
1.52 return True
1.53 # _start()
1.54
1.55 - def _start_myth(self, outfd):
1.56 - # gmyth-cat -h 192.168.1.124 -p 6543 -c 111
1.57 - # gmyth-cat -h 192.168.1.124 -p 6543 -f file.nuv
1.58 - # myth://IP:PORT:type:file
1.59 - host = self.args["gmyth-cat"][0]
1.60 - port = self.args["gmyth-cat"][1]
1.61 - kind = self.args["gmyth-cat"][2]
1.62 - fchan = self.args["gmyth-cat"][3]
1.63 -
1.64 - gmyth_cat = utils.which("gmyth-cat")
1.65 - opts = [gmyth_cat, "-h", host, "-p", port, "-" + kind, fchan]
1.66 -
1.67 - try:
1.68 - self.gmyth = subprocess.Popen(opts, stdout=subprocess.PIPE,
1.69 - stderr=subprocess.PIPE,
1.70 - close_fds=True)
1.71 - except Exception, e:
1.72 - self.log.error("Error executing gmyth-cat: %s" % e)
1.73 - return False
1.74 -
1.75 - err = self.gmyth.stderr
1.76 -
1.77 - if not self._run_mencoder(input=self.gmyth.stdout,
1.78 - output=subprocess.PIPE):
1.79 - return False
1.80 -
1.81 - if kind == "f":
1.82 - partial = 0
1.83 - size = err.read(20).split("\n")[0].split("Size:")[1]
1.84 - self.log.debug("Size of file: %s" % size)
1.85 - flags = fcntl.fcntl (err, fcntl.F_GETFL, 0) | os.O_NONBLOCK
1.86 - fcntl.fcntl(err, fcntl.F_SETFL, flags)
1.87 -
1.88 - try:
1.89 - while self.proc and self.proc.poll() == None:
1.90 - r, w, x = select([err, self.proc.stdout], [], [], 0)
1.91 - if self.proc.stdout in r:
1.92 - d = self.proc.stdout.read(4096)
1.93 - outfd.write(d)
1.94 -
1.95 - if err in r and kind == "f":
1.96 - partial = err.read(50).split("\n")[-2]
1.97 - if partial != "":
1.98 - utils.progress_bar(self.log, int(partial), int(size), 50)
1.99 -
1.100 -
1.101 - except Exception, e:
1.102 - self.log.error("Problems handling data: %s" % e)
1.103 - return False
1.104 -
1.105 - return True
1.106 - # _start_myth()
1.107 -
1.108 def _run_mencoder(self, input=None, output=None):
1.109 try:
1.110 self.proc = subprocess.Popen(self.mencoder_opts, stdin=input,
1.111 @@ -315,7 +251,7 @@
1.112 ret = self._start(outfd)
1.113
1.114 elif self.args["type"] == "myth":
1.115 - ret = self._start_myth(outfd)
1.116 + ret = mythtv.start_myth(self, outfd)
1.117
1.118 else:
1.119 ret = self._start_outfile(outfd)