diff -r 7a0c3906dce2 -r 178207a9cd61 gmyth-stream/server/main.py --- a/gmyth-stream/server/main.py Wed Apr 04 18:05:44 2007 +0100 +++ b/gmyth-stream/server/main.py Thu Apr 05 15:26:47 2007 +0100 @@ -21,8 +21,42 @@ lib.log("Starting GMyth-Stream server") + +''' +PROTOCOL DESCRIPTION +===================== + +COMMAND OPTIONS + +-> SETUP DESCRIPTION +|-> used to setup transcoding and streaming parameters +|-> must be used before any "PLAY" command +|-> e.g: + +file://file_name mux vcodec vbitrate fps acodec abitrate width height options +dvd://title_number mux vcodec vbitrate fps acodec abitrate width height options + +-> PLAY DESCRIPTION + |-> used to start transcoding and streaming of file + |-> must be used just if SETUP was used before + |-> after it, _must_ send STOP + +-> STOP DESCRIPTION + |-> used to stop transcoding and streaming process + |-> must be used just if PLAY was used before + |-> must be used after PLAY + +-> QUIT DESCRIPTION + |-> used to quit the main loop (quit program) + +''' +nextport = 0 + while (server.finish == 0): - con, client = server.getRequest() + conn, client, port = server.getRequest() + server.sendMsg("Welcome to GMyth-Streamer Master") + if nextport == 0: + nextport = port while True: msg = server.getMsg(1024).strip() @@ -47,10 +81,11 @@ options.append(setup[i]) i += 1 + nextport += 1 ret = media.setup(setup[0], setup[1], setup[2], \ setup[3], setup[4], setup[5], setup[6], setup[7], setup[8], - setup[9], options) + nextport, options) if ret == 0: server.Ack("SETUP") @@ -61,19 +96,20 @@ elif msg == "PLAY": media.play() server.Ack("PLAY") + server.sendMsg("STREAM PORT=%d" % nextport) elif msg == "STOP": media.stop() server.Ack("STOP") - elif msg == "CLOSE": + elif msg == "QUIT": server.finish = 1 media.stop() - server.Ack("CLOSE") + server.Ack("QUIT") break lib.log("Closing connection with %s" % client[0]) - server.disconnect_client(con) + server.disconnect_client(conn) server.stop() del(server)