gmyth-stream/main.py
author morphbr
Tue Mar 27 23:57:42 2007 +0100 (2007-03-27)
branchtrunk
changeset 466 a7aba7d166fb
parent 453 a806d8ad0ff0
child 470 57833200a415
permissions -rwxr-xr-x
[svn r471] - Added plugins/media/ffmpeg.py
- Added tests/client_ffmpeg.py (To test ffmpeg plugin using mplayer)
- Bug fixes inside gmyth-stream
     1 #!/usr/bin/python
     2 
     3 import sys
     4 import os
     5 import ConfigParser
     6 
     7 def now():
     8     return time.strftime("%Y-%m-%d %H:%M:%S");
     9 
    10 
    11 config = ConfigParser.ConfigParser()
    12 config.read("stream.conf")
    13 
    14 media_plugin = config.get("Media", "engine")
    15 exec("from plugins.media.%s import *" % media_plugin)
    16 
    17 media = Media(config)
    18 
    19 comm_plugin = config.get("Comm", "engine")
    20 exec("from plugins.comm.%s import *" % comm_plugin)
    21 
    22 # Start Our Server:
    23 server = Server(config)
    24 
    25 print "--> Starting the server..."
    26 
    27 while (server.finish == 0):
    28     con, client = server.getRequest()
    29 
    30     while True:
    31         msg = server.getMsg(1024).strip()
    32 
    33         if not msg: break
    34 
    35         elif (msg == "SETUP"):
    36             setup = server.getMsg(1024).strip().split(" ")
    37             media.setup(setup[0], setup[1], setup[2], \
    38                         setup[3], setup[4], setup[5],
    39                         setup[6], setup[7], setup[8],
    40                         setup[9])
    41 
    42         elif (msg == "PLAY"):
    43             media.play()
    44 
    45         elif (msg == "STOP"):
    46             media.stop()
    47 
    48         elif (msg == "CLOSE"):
    49             server.finish = 1
    50             media.stop()
    51             break
    52 
    53         print "[%s] %s: %s" % (now(), client, msg)
    54 
    55     print "[%s] Closing connection with %s" % (now(), client)
    56     server.disconnect_client(con)
    57 
    58 server.stop()
    59 del(server)
    60 print "--> Server stopped..."