diff -r 000000000000 -r fb0bf39636d6 gmyth-stream/server/0.1/plugins/media/vlc.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gmyth-stream/server/0.1/plugins/media/vlc.py Mon Apr 30 16:04:20 2007 +0100 @@ -0,0 +1,80 @@ +import os +import sys +import time +import socket +import ConfigParser + +class Media: + + def __init__(self, config): + + self.config = config + self.pipe = "" + self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + + self.path = config.get("Vlc", "path") + self.host = config.get("Vlc", "host") + self.port = int(config.get("Vlc", "port")) + self.pwd = config.get("Vlc", "pwd") + + # exec VLC + pid = os.fork() + if (pid == 0): + #child + print "ESTOU EM CHILD" + self.path += " -I telnet -d 1> /dev/null 2> /dev/null &" + os.system(self.path) + sys.exit(0) + else: + print "ESTOU EM PARENT 1" + time.sleep(3) + print "ESTOU EM PARENT 2" + self.sock.connect( (self.host, self.port) ) + self.sock.send("%s\n" % self.pwd) + + + def insert_file(self, filename): + + self.sock.send("setup output0 input %s\n" % filename) + + + + def setup(self, filename, mux, vcodec, vbitrate,\ + fps, acodec, abitrate, width, height, port): + + self.filename = filename + self.mux = mux + self.vcodec = vcodec + self.vbitrate = int(vbitrate) + self.fps = int(fps) + self.acodec = acodec + self.abitrate = int(abitrate) + self.width = int(width) + self.height = int(height) + + self.port = int(port) + + + self.pipe = "#transcode{vcodec=%s,vb=%d,"\ + "fps=25.0,scale=1,acodec=mpga,"\ + "ab=64,channels=1,width=%d,height=%d}"\ + ":duplicate{dst=std{access=http,"\ + "mux=mpeg1,dst=:%d}}" % (self.vcodec, self.vbitrate,\ + self.widht, self.height,\ + self.port) + + self.sock.send("setup output0 broadcast %s\n" % self.pipe) + self.insert_file(self.filename) + + def play(self): + + print "Trying to play: %s" % self.pipe + self.sock.send("control output0 play\n") + + + def stop(self): + + print "Trying to stop: %s" % self.pipe + self.sock.send("control output0 stop\n") + +