gmyth-stream/server/main.py
branchtrunk
changeset 504 2b5355061b66
parent 498 7a0c3906dce2
child 511 16312d0021cb
     1.1 --- a/gmyth-stream/server/main.py	Wed Apr 04 18:05:44 2007 +0100
     1.2 +++ b/gmyth-stream/server/main.py	Wed Apr 04 23:30:44 2007 +0100
     1.3 @@ -21,8 +21,42 @@
     1.4  
     1.5  lib.log("Starting GMyth-Stream server")
     1.6  
     1.7 +
     1.8 +'''
     1.9 +PROTOCOL DESCRIPTION
    1.10 +=====================
    1.11 +
    1.12 +COMMAND OPTIONS
    1.13 +
    1.14 +-> SETUP DESCRIPTION
    1.15 +|-> used to setup transcoding and streaming parameters
    1.16 +|-> must be used before any "PLAY" command
    1.17 +|-> e.g:
    1.18 +
    1.19 +file://file_name mux vcodec vbitrate fps acodec abitrate width height options
    1.20 +dvd://title_number mux vcodec vbitrate fps acodec abitrate width height options
    1.21 +
    1.22 +-> PLAY DESCRIPTION
    1.23 + |-> used to start transcoding and streaming of file
    1.24 + |-> must be used just if SETUP was used before
    1.25 + |-> after it, _must_ send STOP
    1.26 +
    1.27 +-> STOP DESCRIPTION
    1.28 + |-> used to stop transcoding and streaming process
    1.29 + |-> must be used just if PLAY was used before
    1.30 + |-> must be used after PLAY
    1.31 +
    1.32 +-> QUIT DESCRIPTION
    1.33 + |-> used to quit the main loop (quit program)
    1.34 +
    1.35 +'''
    1.36 +nextport = 0
    1.37 +
    1.38  while (server.finish == 0):
    1.39 -    con, client = server.getRequest()
    1.40 +    conn, client, port = server.getRequest()
    1.41 +    server.sendMsg("Welcome to GMyth-Streamer Master")
    1.42 +    if nextport == 0:
    1.43 +        nextport = port
    1.44  
    1.45      while True:
    1.46          msg = server.getMsg(1024).strip()
    1.47 @@ -47,10 +81,11 @@
    1.48                          options.append(setup[i])
    1.49                          i += 1
    1.50  
    1.51 +                nextport += 1
    1.52                  ret = media.setup(setup[0], setup[1], setup[2], \
    1.53                                    setup[3], setup[4], setup[5],
    1.54                                    setup[6], setup[7], setup[8],
    1.55 -                                  setup[9], options)
    1.56 +                                  nextport, options)
    1.57  
    1.58                  if ret == 0:
    1.59                      server.Ack("SETUP")
    1.60 @@ -61,19 +96,20 @@
    1.61          elif msg == "PLAY":
    1.62              media.play()
    1.63              server.Ack("PLAY")
    1.64 +            server.sendMsg("STREAM PORT=%d" % nextport)
    1.65  
    1.66          elif msg == "STOP":
    1.67              media.stop()
    1.68              server.Ack("STOP")
    1.69  
    1.70 -        elif msg == "CLOSE":
    1.71 +        elif msg == "QUIT":
    1.72              server.finish = 1
    1.73              media.stop()
    1.74 -            server.Ack("CLOSE")
    1.75 +            server.Ack("QUIT")
    1.76              break
    1.77  
    1.78      lib.log("Closing connection with %s" % client[0])
    1.79 -    server.disconnect_client(con)
    1.80 +    server.disconnect_client(conn)
    1.81  
    1.82  server.stop()
    1.83  del(server)