diff -r 000000000000 -r 0e6de3b59f57 gmyth-stream/main.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/main.py Tue Mar 27 20:27:51 2007 +0100 @@ -0,0 +1,85 @@ + ''' + # GMyth-Stream + # + # @file main.py + # + # @brief

Plugin for GMyth-Stream + # + # Copyright (C) 2007 INdT - Instituto Nokia de Tecnologia. + # @author Artur Duque de Souza + # + # + # This program is free software; you can redistribute it and/or modify + # it under the terms of the GNU Lesser General Public License as published by + # the Free Software Foundation; either version 2 of the License, or + # (at your option) any later version. + # + # This program is distributed in the hope that it will be useful, + # but WITHOUT ANY WARRANTY; without even the implied warranty of + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + # GNU General Public License for more details. + # + # You should have received a copy of the GNU Lesser General Public License + # along with this program; if not, write to the Free Software + # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + # + ''' + +#!/usr/bin/python + +import sys +import os +import ConfigParser + +def now(): + return time.strftime("%Y-%m-%d %H:%M:%S"); + + +config = ConfigParser.ConfigParser() +config.read("stream.conf") + +media_plugin = config.get("Media", "engine") +exec("from plugins.media.%s import *" % media_plugin) + +media = Media(config) + +comm_plugin = config.get("Comm", "engine") +exec("from plugins.comm.%s import *" % comm_plugin) + +# Start Our Server: +server = Server(config) + +print "--> Starting the server..." + +while (server.finish == 0): + con, client = server.getRequest() + + while True: + msg = server.getMsg(1024).strip() + + if not msg: break + + elif (msg == "SETUP"): + setup = server.getMsg(1024).strip().split(" ") + media.setup(setup[0], setup[1], setup[2], \ + setup[3], setup[4], setup[5]) + + elif (msg == "PLAY"): + media.play() + + elif (msg == "STOP"): + media.stop() + + elif (msg == "CLOSE"): + server.finish = 1 + media.stop() + break + + print "[%s] %s: %s" % (now(), client, msg) + + print "[%s] Closing connection with %s" % (now(), client) + server.disconnect_client(con) + +server.stop() + +print "--> Server stopped..."