[svn r484] Added gmyth_util_get_channel_list to the gmyth_util.h; removes static_mutex locking/unlocking from the gmyth_util.
2 import SimpleXMLRPCServer
7 def __init__(self, recv_pool, send_pool):
8 self.recv_pool = recv_pool
9 self.send_pool = send_pool
10 self.getMsg = self.sendMsg
12 def _listMethods(self):
13 return ['setup', 'play', 'stop', 'close', 'getMsg']
15 def _methodHelp(self, method):
18 return "Setup the Media: setup( filename, mux, vcodec, vbitrate, fps, acodec, abitrate, width, height, port"
19 elif method == 'play':
20 return "Play the Media: play()"
21 elif method == 'stop':
22 return "Stop the Media: stop()"
23 elif method == 'close':
24 return "Close the connection: close()"
25 elif method == 'getMsg':
26 return "Return the first message in the pool: getMsg()"
28 # By convention, return empty
29 # string if no help is available
32 def setup(self, filename, mux, vcodec, vbitrate,\
33 fps, acodec, abitrate, width, height, port):
34 self.recv_pool.append("SETUP")
35 self.recv_pool.append("%s %s %s %s %s %s %s" % (filename, mux, vcodec, vbitrate,\
36 fps, acodec, abitrate, width, height, port)
40 self.recv_pool.append("PLAY")
44 self.recv_pool.append("STOP")
48 self.recv_pool.append("CLOSE")
52 if self.send_pool != []:
53 return self.send_pool.pop(0)
60 def __init__(self, config):
61 self.host = 'localhost'
62 self.port = int(config.get("Comm", "port"))
67 self.handler = Handler(self.recv_pool, self.send_pool)
69 self.xmlrpc = SimpleXMLRPCServer.SimpleXMLRPCServer((self.host, self.port))
70 self.xmlrpc.register_instance(self.handler)
73 def getMsg(self, size):
74 if self.recv_pool != []:
75 return self.recv_pool.pop(0)
79 def sendMsg(self, msg):
80 self.send_pool.append(msg)
82 def Ack(self, command):
83 msg = "[%s] Command %s received" % (lib.now(), command)
84 self.sendMsg(msg + "\n")
87 self.xmlrpc.handle_request()
88 return (0, "RPC Client")
90 def disconnect_client(self, connection):
94 self.xmlrpc.server_close()