[svn r596] Fixed memory leak when dealocating GMythChannelInfo.
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,"\
19 " fps, acodec, abitrate, width, height, port, options"
20 elif method == 'play':
21 return "Play the Media: play()"
22 elif method == 'stop':
23 return "Stop the Media: stop()"
24 elif method == 'close':
25 return "Close the connection: close()"
26 elif method == 'getMsg':
27 return "Return the first message in the pool: getMsg()"
29 # By convention, return empty
30 # string if no help is available
33 def setup(self, filename, mux, vcodec, vbitrate,\
34 fps, acodec, abitrate, width, height, port, options):
36 msg = "%s %s %s %s %s %s %s" % (filename, mux, vcodec, vbitrate,\
37 fps, acodec, abitrate, width, height, port)
43 self.recv_pool.append("SETUP")
44 self.recv_pool.append(msg)
48 self.recv_pool.append("PLAY")
52 self.recv_pool.append("STOP")
56 self.recv_pool.append("CLOSE")
60 if self.send_pool != []:
61 return self.send_pool.pop(0)
68 def __init__(self, config):
69 self.host = 'localhost'
70 self.port = int(config.get("Comm", "port"))
75 self.handler = Handler(self.recv_pool, self.send_pool)
77 self.xmlrpc = SimpleXMLRPCServer.SimpleXMLRPCServer((self.host, self.port))
78 self.xmlrpc.register_instance(self.handler)
81 def getMsg(self, size):
82 if self.recv_pool != []:
83 return self.recv_pool.pop(0)
87 def sendMsg(self, msg):
88 self.send_pool.append(msg)
90 def Ack(self, command):
91 msg = "[%s] Command %s received" % (lib.now(), command)
92 self.sendMsg(msg + "\n")
95 self.xmlrpc.handle_request()
96 return (0, "RPC Client")
98 def disconnect_client(self, connection):
102 self.xmlrpc.server_close()