[svn r523] Some addings on GObject gets/sets.
10 log.basicConfig(level=log.DEBUG,
11 format="%(asctime)s %(levelname)-8s %(message)s",
12 datefmt='%Y-%m-%d %H:%M:%S')
14 config = ConfigParser.ConfigParser()
15 config.read("stream.conf")
17 def load_module(pathlist, name):
18 fp, path, desc = imp.find_module(name, pathlist)
20 module = imp.load_module(name, fp, path, desc)
27 media_plugin = config.get("Media", "engine")
28 media_plugin_module = load_module(["./plugins/media"], media_plugin)
29 media = media_plugin_module.Media(config)
31 comm_plugin = config.get("Comm", "engine")
32 comm_plugin_module = load_module(["./plugins/comm"], comm_plugin)
33 server = comm_plugin_module.Server(config)
35 log.info("Starting GMyth-Stream server")
45 |-> used to setup transcoding and streaming parameters
46 |-> must be used before any "PLAY" command
49 file://file_name mux vcodec vbitrate fps acodec abitrate width height options
50 dvd://title_number mux vcodec vbitrate fps acodec abitrate width height options
53 |-> used to start transcoding and streaming of file
54 |-> must be used just if SETUP was used before
55 |-> after it, _must_ send STOP
58 |-> used to stop transcoding and streaming process
59 |-> must be used just if PLAY was used before
60 |-> must be used after PLAY
63 |-> used to quit the main loop (quit program)
68 def do_setup(server, filename, mux, vcodec, vbitrate, fps, acodec, abitrate,
69 width, height, *options):
72 ret = media.setup(filename, mux, vcodec, vbitrate, fps, acodec,
73 abitrate, width, height, nextport, options)
84 server.sendOk("%d" % nextport)
95 def do_list(server, *directory):
98 list_media_files(j, file_list)
118 def dispatch(server, msg):
121 log.error("Invalid client command format: %r" % msg)
122 server.sendNotOk("Invalid Format")
126 f = mapping.get(cmd, None)
128 log.error("Unknow command: %r" % msg)
129 server.sendNotOk("Unknow Command")
133 return f(server, *pieces[1:])
135 log.error("Could not execute %r: %s" % (msg, e))
136 server.sendNotOk(str(e))
141 while not server.finish:
142 conn, client, port = server.getRequest()
146 while not server.finish:
147 msg = server.getMsg()
151 log.info("Client %s sent command: %r" % (client, msg))
152 dispatch(server, msg)
155 log.info("Closing connection with %s" % (client,))
156 server.disconnect_client(conn)
159 log.info("Server stopped. Closing...")