1.1 --- a/gmyth-stream/server/main.py Wed Apr 04 16:47:00 2007 +0100
1.2 +++ b/gmyth-stream/server/main.py Wed Apr 04 17:08:11 2007 +0100
1.3 @@ -21,7 +21,7 @@
1.4
1.5 lib.log("Starting GMyth-Stream server")
1.6
1.7 -while (server.finish == 0):
1.8 +while (server.finish is 0):
1.9 con, client = server.getRequest()
1.10
1.11 while True:
1.12 @@ -31,17 +31,17 @@
1.13
1.14 lib.log("Received %s from: %s" % (msg, client) )
1.15
1.16 - if (msg == "SETUP"):
1.17 + if msg is "SETUP":
1.18 setup = server.getMsg(1024).strip().split(" ")
1.19 size = len(setup)
1.20 options = []
1.21
1.22 - if ( size < 10 ):
1.23 + if size < 10:
1.24 server.sendMsg(lib.log("Wrong SETUP command from: %s" % client[0]))
1.25
1.26 else:
1.27
1.28 - if ( size > 10 ):
1.29 + if size > 10:
1.30 i = 10
1.31 while (i < size):
1.32 options.append(setup[i])
1.33 @@ -52,21 +52,21 @@
1.34 setup[6], setup[7], setup[8],
1.35 setup[9], options)
1.36
1.37 - if (ret == 0):
1.38 + if ret is 0:
1.39 server.Ack("SETUP")
1.40 else:
1.41 server.sendMsg(lib.log(ret))
1.42
1.43
1.44 - elif (msg == "PLAY"):
1.45 + elif msg is "PLAY":
1.46 media.play()
1.47 server.Ack("PLAY")
1.48
1.49 - elif (msg == "STOP"):
1.50 + elif msg is "STOP":
1.51 media.stop()
1.52 server.Ack("STOP")
1.53
1.54 - elif (msg == "CLOSE"):
1.55 + elif msg is "CLOSE":
1.56 server.finish = 1
1.57 media.stop()
1.58 server.Ack("CLOSE")
2.1 --- a/gmyth-stream/server/plugins/media/mencoder.py Wed Apr 04 16:47:00 2007 +0100
2.2 +++ b/gmyth-stream/server/plugins/media/mencoder.py Wed Apr 04 17:08:11 2007 +0100
2.3 @@ -9,7 +9,7 @@
2.4 from select import *
2.5 from subprocess import *
2.6
2.7 -class Media:
2.8 +class Media(object):
2.9
2.10 def __init__(self, config):
2.11
2.12 @@ -33,22 +33,24 @@
2.13
2.14 for opt in options:
2.15
2.16 - if (opt == "file" or opt == "dvd"):
2.17 - if (self.acodec == "mp3lame"):
2.18 + if opt is "file" or opt is "dvd":
2.19 +
2.20 + if self.acodec is "mp3lame":
2.21 audio = "-oac mp3lame -lameopts cbr:br=%s vol=5" % self.abitrate
2.22 else:
2.23 audio = "-oac lavc -lavcopts acodec=%s:abitrate=%s" % (\
2.24 self.acodec, self.abitrate)
2.25
2.26 - if (opt == "file"):
2.27 +
2.28 + if opt is "file":
2.29 self.kind = "file"
2.30 - self.args += " %s -mf fps=%s -of %s -noodml %s"\
2.31 + self.args += " %s -mf fps=%s -of %s %s"\
2.32 " -ovc lavc -lavcopts vcodec=%s:vbitrate=%s -vf scale=%s:%s"\
2.33 " -o %s 1> /dev/null 2> /dev/null" % (
2.34 self.filename, self.fps, self.mux, audio, self.vcodec,
2.35 self.vbitrate, self.width, self.height, self.fifo)
2.36
2.37 - elif (opt == "dvd"):
2.38 + elif opt is "dvd":
2.39 self.kind = "dvd"
2.40 self.args += " dvd://%s -alang %s -vf scale=%s:%s %s"\
2.41 " -of %s -ovc lavc -lavcopts vcodec=%s:vbitrate=%s -o %s"\
2.42 @@ -56,19 +58,26 @@
2.43 self.filename, self.language, self.width, self.height, audio,
2.44 self.mux, self.vcodec, self.vbitrate, self.fifo, self.fps)
2.45
2.46 - elif (opt == "local"):
2.47 + elif opt is "local":
2.48 self.mplayer = os.popen("which mplayer").read().strip()
2.49
2.50 - elif (opt.find("language=") >= 0):
2.51 + elif opt.find("language=") >= 0:
2.52 try:
2.53 self.language = opt.split("=")[1]
2.54 except:
2.55 lib.log("Bad language option")
2.56
2.57 + elif opt.find("format=") >= 0:
2.58 + try:
2.59 + self.mux += " -mpegopts format=%s" % opt.split("=")[1]
2.60 + except:
2.61 + lib.log("Bad format option")
2.62 +
2.63
2.64 def run_mplayer(self):
2.65 msg = "%s 1>/dev/null 2>/dev/null" % self.filename
2.66 - if (self.kind == "dvd"):
2.67 +
2.68 + if self.kind is "dvd":
2.69 msg = "dvd://" + msg
2.70
2.71 self.mplayer += " " + msg
2.72 @@ -94,15 +103,16 @@
2.73 self.kind = ""
2.74 self.set_args(options)
2.75
2.76 - if (self.kind == "file" and not os.path.exists(self.filename)):
2.77 + if self.kind is "file" and not os.path.exists(self.filename):
2.78 msg = "File requested does not exist. SETUP failed."
2.79 lib.log(msg)
2.80 return msg
2.81
2.82 # good one: /tmp/dvb.mpg avi mpeg4 400 25 mp3lame 192 320 240 5000
2.83 + #4 mpeg mpeg1video 400 25 mp3lame 192 400 240 5000 language=en local dvd
2.84 self.path = self.config.get("Mencoder", "path")
2.85
2.86 - if (self.socket != None):
2.87 + if self.socket is not None:
2.88 del(self.socket)
2.89
2.90 self.socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
2.91 @@ -128,7 +138,7 @@
2.92
2.93 self.child_pid = os.fork()
2.94
2.95 - if (self.child_pid == 0):
2.96 + if self.child_pid is 0:
2.97 conn,addr= self.socket.accept()
2.98 lib.log("Sending Data to client: %s" % addr[0])
2.99
2.100 @@ -136,13 +146,13 @@
2.101 conn.settimeout(5)
2.102 retry = 0
2.103
2.104 - while( data != "" and retry < 5):
2.105 + while data is not "" and retry < 5:
2.106 try:
2.107 conn.send(data)
2.108 r, w, x = select([conn], [], [], 0)
2.109 if conn in r:
2.110 back = conn.recv(1024)
2.111 - if (back == "OK" and self.mplayer and not self.mplayer_pid):
2.112 + if back is "OK" and self.mplayer and not self.mplayer_pid:
2.113 self.run_mplayer()
2.114
2.115 except socket.error:
2.116 @@ -151,7 +161,7 @@
2.117
2.118 data = fifo.read(1024)
2.119
2.120 - if (retry < 5):
2.121 + if retry < 5:
2.122 lib.log("Finished sending Data to client: %s" % addr[0])
2.123 else:
2.124 lib.log("Client timed out")
2.125 @@ -166,10 +176,10 @@
2.126 except:
2.127 lib.log("Trying to stop before playing...")
2.128
2.129 - if (self.socket != None):
2.130 + if self.socket is not None:
2.131 lib.log("Closing socket")
2.132 self.socket.close()
2.133
2.134 lib.log("Trying to stop Mencoder process")
2.135 - if (self.child_pid != None):
2.136 + if self.child_pid is not None:
2.137 os.kill(self.child_pid, signal.SIGABRT)
3.1 --- a/gmyth-stream/server/stream.conf Wed Apr 04 16:47:00 2007 +0100
3.2 +++ b/gmyth-stream/server/stream.conf Wed Apr 04 17:08:11 2007 +0100
3.3 @@ -4,7 +4,7 @@
3.4
3.5
3.6 [Media]
3.7 -engine = gstreamer
3.8 +engine = mencoder
3.9
3.10
3.11 [Vlc]