1.1 --- a/gmyth-stream/client/src/gmyth-stream-client.c Wed Apr 18 23:13:26 2007 +0100
1.2 +++ b/gmyth-stream/client/src/gmyth-stream-client.c Thu Apr 19 15:13:48 2007 +0100
1.3 @@ -171,7 +171,8 @@
1.4
1.5 close (priv->sock->fd);
1.6 //shutdown (priv->sock->fd, SHUT_RDWR);
1.7 - priv->sock->fd = -1;
1.8 + g_free(priv->sock);
1.9 + priv->sock = NULL;
1.10 priv->connected = FALSE;
1.11 }
1.12
2.1 --- a/gmyth-stream/server/0.2/lib/server.py Wed Apr 18 23:13:26 2007 +0100
2.2 +++ b/gmyth-stream/server/0.2/lib/server.py Thu Apr 19 15:13:48 2007 +0100
2.3 @@ -138,9 +138,9 @@
2.4 if body:
2.5 self.wfile.write("""\
2.6 <html>
2.7 - <head><title>Catota Server</title></head>
2.8 + <head><title>GMyth-Streamer Server</title></head>
2.9 <body>
2.10 -<h1>Welcome to Catota Server</h1>
2.11 +<h1>Welcome to GMyth-Streamer Server</h1>
2.12 <ul>
2.13 """)
2.14 self._nav_items()
2.15 @@ -160,7 +160,7 @@
2.16 if body:
2.17 self.wfile.write("""\
2.18 <html>
2.19 - <head><title>Catota Server</title></head>
2.20 + <head><title>GMyth-Streamer Server</title></head>
2.21 <body>
2.22 <h1>Play</h1>
2.23 <form action="/stream.do" method="GET">
2.24 @@ -186,9 +186,9 @@
2.25 if body:
2.26 self.wfile.write("""\
2.27 <html>
2.28 - <head><title>Catota Server Exited</title></head>
2.29 + <head><title>GMyth-Streamer Server Exited</title></head>
2.30 <body>
2.31 - <h1>Catota is not running anymore</h1>
2.32 + <h1>GMyth-Streamer is not running anymore</h1>
2.33 </body>
2.34 </html>
2.35 """)
2.36 @@ -205,9 +205,9 @@
2.37 self.server.stop_transcoders()
2.38 self.wfile.write("""\
2.39 <html>
2.40 - <head><title>Catota Server Stopped Transcoders</title></head>
2.41 + <head><title>GMyth-Streamer Server Stopped Transcoders</title></head>
2.42 <body>
2.43 - <h1>Catota stopped running transcoders</h1>
2.44 + <h1>GMyth-Streamer stopped running transcoders</h1>
2.45 <ul>
2.46 """)
2.47 self._nav_items()
2.48 @@ -227,9 +227,9 @@
2.49 if body:
2.50 self.wfile.write("""\
2.51 <html>
2.52 - <head><title>Catota Server Stopped Transcoders</title></head>
2.53 + <head><title>GMyth-Streamer Server Stopped Transcoders</title></head>
2.54 <body>
2.55 - <h1>Catota stopped running transcoders:</h1>
2.56 + <h1>GMyth-Streamer stopped running transcoders:</h1>
2.57 <ul>
2.58 """)
2.59 transcoders = self.server.get_transcoders()
2.60 @@ -246,7 +246,6 @@
2.61 for t, r in transcoders:
2.62 if r.client_address == addr:
2.63 t.stop()
2.64 - self.server.del_transcoders(self, t)
2.65 self.wfile.write("""\
2.66 <li>%s: %s:%s</li>
2.67 """ % (t, addr[0], addr[1]))
2.68 @@ -284,9 +283,9 @@
2.69 if body:
2.70 self.wfile.write("""\
2.71 <html>
2.72 - <head><title>Catota Server Status</title></head>
2.73 + <head><title>GMyth-Streamer Server Status</title></head>
2.74 <body>
2.75 - <h1>Catota Status</h1>
2.76 + <h1>GMyth-Streamer Status</h1>
2.77 """)
2.78 tl = self.server.get_transcoders()
2.79 if not tl:
3.1 --- a/gmyth-stream/server/0.2/plugins/transcoders/mencoder.py Wed Apr 18 23:13:26 2007 +0100
3.2 +++ b/gmyth-stream/server/0.2/plugins/transcoders/mencoder.py Thu Apr 19 15:13:48 2007 +0100
3.3 @@ -8,76 +8,136 @@
3.4
3.5 class TranscoderMencoder(server.Transcoder):
3.6 mencoder_path = utils.which("mencoder")
3.7 - def_mencoder_outfile = os.path.join(os.path.sep, "tmp",
3.8 - "mencoder-fifo-%(uid)s-%(pid)s")
3.9 name = "mencoder"
3.10 priority = -1
3.11
3.12 + def _setup_params(self):
3.13 + params_first = self.params_first
3.14 +
3.15 + # general_opts
3.16 + self.args["local"] = params_first("local", False)
3.17 + self.args["language"] = params_first("language", False)
3.18 + self.args["subtitle"] = params_first("subtitle", False)
3.19 + self.args["format"] = params_first("format", "")
3.20 + self.args["outfile"] = params_first("outfile", "-")
3.21 +
3.22 + # input_opt
3.23 + self.args["type"] = params_first("type", "file")
3.24 + self.args["input"] = params_first("input", "-")
3.25 +
3.26 + # audio_opts
3.27 + self.args["acodec"] = params_first("acodec", "mp2")
3.28 + self.args["abitrate"] = params_first("abitrate", 192)
3.29 + self.args["volume"] = params_first("volume", 5)
3.30 +
3.31 + # video_opts
3.32 + self.args["mux"] = params_first("mux", "mpeg")
3.33 + self.args["fps"] = params_first("fps", 25)
3.34 + self.args["vcodec"] = params_first("vcodec", "mpeg1video")
3.35 + self.args["vbitrate"] = params_first("vbitrate", 400)
3.36 + self.args["width"] = params_first("width", 320)
3.37 + self.args["height"] = params_first("height", 240)
3.38 + # _setup_params()
3.39 +
3.40 +
3.41 + def _setup_audio(self):
3.42 + if self.args["acodec"] == "mp3lame":
3.43 + audio = "-oac mp3lame -lameopts cbr:br=%s vol=%s" % (
3.44 + self.args["abitrate"], self.args["volume"])
3.45 + else:
3.46 + audio = "-oac lavc -lavcopts acodec=%s:abitrate=%s" % (
3.47 + self.args["acodec"], self.args["abitrate"])
3.48 +
3.49 + return audio
3.50 + # _setup_audio()
3.51 +
3.52 +
3.53 + def _setup_video(self):
3.54 + video = " -of %s" % self.mux
3.55 + video += " -ofps %s" % self.fps
3.56 +
3.57 + vcodec = self.args["vcodec"]
3.58 + if vcodec == "nuv" or vcodec == "xvid"\
3.59 + or vcodec == "qtvideo" or vcodec == "copy":
3.60 + video += " -ovc %s" % vcodec
3.61 + else:
3.62 + video += " -ovc lavc -lavcopts vcodec=%s:vbitrate=%s" % (
3.63 + vcodec, self.args["vbitrate"])
3.64 +
3.65 + video += " %s" % self.args["format"]
3.66 + video += " -vf scale=%s:%s" % (self.args["width"], self.args["height"])
3.67 +
3.68 + return video
3.69 + # _setup_video()
3.70 +
3.71 +
3.72 + def _arg_append(self, args, options):
3.73 + for arg in shlex.split(options)
3.74 + args.append(arg)
3.75 + # arg_append()
3.76 +
3.77 + def _setup_mencoder_opts(self, args):
3.78 + args.append(self.mencoder_path)
3.79 + args.append("-")
3.80 +
3.81 + if self.args["language"]:
3.82 + self._arg_append(args, "-alang %s" % self.args["language"])
3.83 +
3.84 + if self.args["subtitle"]:
3.85 + self._arg_append(args, "-slang %s" % self.args["subtitle"])
3.86 + self._arg_append(args, "-subfps %s" % self.args["fps"])
3.87 +
3.88 + self._arg_append(args, "-idx")
3.89 + self._arg_append(args, self._setup_audio)
3.90 + self._arg_append(args, self._setup_video)
3.91 +
3.92 + self._arg_append(args, "-really-quiet")
3.93 + self._arg_append(args, "-o %s" % self.args["outfile"])
3.94 + self._arg_append(args, "2> %s" % os.devnull)
3.95 + # _setup_args()
3.96 +
3.97 +
3.98 + def _setup_filename(self):
3.99 + _type = self.args["type"]
3.100 +
3.101 + if _type == "file":
3.102 + if not os.path.exists(self.args["input"]):
3.103 + raise IOError, "File requested does not exist."
3.104 +
3.105 + elif _type == "dvd":
3.106 + self.args["input"] = "dvd://".join(self.args["input"])
3.107 +
3.108 + elif _type == "myth":
3.109 + self.args["input"] = "myth://".join(self.args["input"])
3.110 + self.gst_pipe = os.pipe()
3.111 + # _setup_filename()
3.112 +
3.113 +
3.114 def __init__(self, params):
3.115 server.Transcoder.__init__(self, params)
3.116 self.proc = None
3.117 self.args = None
3.118 + self.mencoder_opts = None
3.119
3.120 - vars = {"uid": os.getuid(), "pid": os.getpid()}
3.121 - mencoder_outfile_base = self.def_mencoder_outfile % vars
3.122 - mencoder_outfile = mencoder_outfile_base
3.123 - i = 0
3.124 - while os.path.exists(mencoder_outfile):
3.125 - i += 1
3.126 - mencoder_outfile = mencoder_outfile_base + ".%s" % i
3.127 + try:
3.128 + self._setup_params()
3.129 + self._setup_filename()
3.130 + self._setup_mencoder_opts(self.mencoder_opts)
3.131 + except Exception, e:
3.132 + self.log.error(e)
3.133 + return False
3.134
3.135 - self.mencoder_outfile = mencoder_outfile
3.136 - os.mkfifo(self.mencoder_outfile)
3.137 -
3.138 - args = [self.mencoder_path, "-really-quiet",
3.139 - "-o", self.mencoder_outfile]
3.140 -
3.141 - params_first = self.params_first
3.142 -
3.143 - type = params_first("type")
3.144 - location = params_first("location")
3.145 - args.append("%s://%s" % (type, location))
3.146 -
3.147 - mux = params_first("mux", "avi")
3.148 - args.extend(["-of", mux])
3.149 -
3.150 - acodec = params_first("acodec", "mp3")
3.151 - abitrate = params_first("abitrate", "128")
3.152 - if acodec == "mp3lame":
3.153 - args.extend(["-oac", "mp3lame", "-lameopts",
3.154 - "cbr:br=%s" % abitrate])
3.155 - else:
3.156 - args.extend(["-oac", "lavc", "-lavcopts",
3.157 - "acodec=%s:abitrate=%s" % (acodec, abitrate)])
3.158 -
3.159 - vcodec = params_first("vcodec", "mpeg4")
3.160 - vbitrate = params_first("vbitrate", "400")
3.161 - args.extend(["-ovc", "lavc", "-lavcopts",
3.162 - "vcodec=%s:vbitrate=%s" % (vcodec, vbitrate)])
3.163 -
3.164 - fps = params_first("fps", "24")
3.165 - args.extend(["-ofps", fps])
3.166 -
3.167 - width = params_first("width", "320")
3.168 - height = params_first("height", "240")
3.169 - args.extend(["-vf", "scale=%s:%s" % (width, height)])
3.170 -
3.171 - self.args = args
3.172 + return True
3.173 # __init__()
3.174
3.175
3.176 - def _unlink_fifo(self):
3.177 - try:
3.178 - os.unlink(self.mencoder_outfile)
3.179 - except Exception, e:
3.180 - pass
3.181 - # _unlink_fifo()
3.182 -
3.183 -
3.184 def start(self, outfd):
3.185 cmd = " ".join(self.args)
3.186 self.log.info("Mencoder: %s" % cmd)
3.187
3.188 + if self.args["type"] == "file":
3.189 + _input = open(self.args["input"])
3.190 +
3.191 try:
3.192 self.proc = subprocess.Popen(self.args, close_fds=True)
3.193 except Exception, e:
3.194 @@ -96,10 +156,8 @@
3.195 outfd.write(d)
3.196 except Exception, e:
3.197 self.log.error("Problems handling data: %s" % e)
3.198 - self._unlink_fifo()
3.199 return False
3.200
3.201 - self._unlink_fifo()
3.202 return True
3.203 # start()
3.204
3.205 @@ -117,7 +175,6 @@
3.206 pass
3.207
3.208 self.proc = None
3.209 + # stop()
3.210
3.211 - self._unlink_fifo()
3.212 - # stop()
3.213 # TranscoderMencoder