4 # @file plugins/comm/xmlrpc.py
6 # @brief <p> Plugin for GMyth-Stream
8 # Copyright (C) 2007 INdT - Instituto Nokia de Tecnologia.
9 # @author Artur Duque de Souza <artur.souza@indt.org.br>
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU Lesser General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU Lesser General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 import SimpleXMLRPCServer
33 def __init__(self, pool):
36 def _listMethods(self):
37 return ['Setup', 'Play', 'Stop', 'Close']
39 def _methodHelp(self, method):
42 return "Setup the Media: Setup(filename,codec,bitrate,widht,height,port)"
43 elif method == 'Play':
44 return "Play the Media: Play()"
45 elif method == 'Stop':
46 return "Stop the Media: Stop()"
47 elif method == 'Close':
48 return "Close the connection: Close()"
50 # By convention, return empty
51 # string if no help is available
55 def Setup(self, filename, codec, bitrate, width, height, port):
56 self.pool.append("SETUP")
57 self.pool.append("%s %s %s %s %s %s" % (filename, codec, bitrate,\
62 self.pool.append("PLAY")
66 self.pool.append("STOP")
70 self.pool.append("CLOSE")
76 def __init__(self, config):
77 self.host = 'localhost'
78 self.port = int(config.get("Comm", "port"))
82 self.handler = Handler(self.pool)
84 self.xmlrpc = SimpleXMLRPCServer.SimpleXMLRPCServer((self.host, self.port))
85 self.xmlrpc.register_instance(self.handler)
88 def getMsg(self, size):
90 return self.pool.pop(0)
95 self.xmlrpc.handle_request()
96 return (0, "RPC Client")
98 def disconnect_client(self, connection):
102 self.xmlrpc.server_close()