morphbr@565: import os
morphbr@565: import sys
morphbr@565: import time
morphbr@565: import socket
morphbr@565: 
morphbr@565: 
morphbr@565: if len(sys.argv) < 2:
morphbr@565:     HOST = 'localhost'
morphbr@565:     PORT = 50000
morphbr@565: elif len(sys.argv) == 2:
morphbr@565:     HOST = sys.argv[1]
morphbr@565:     PORT = 50000
morphbr@565: else:
morphbr@565:     HOST = sys.argv[1]
morphbr@565:     PORT = int(sys.argv[2])
morphbr@565: 
morphbr@565: socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
morphbr@565: socket.settimeout(10)
morphbr@565: 
morphbr@565: try:
morphbr@565:     socket.connect( (HOST,PORT) )
morphbr@565: except:
morphbr@565:     print "\n--> Could not connect to ('%s':'%d')\n" % (HOST,PORT)
morphbr@565:     sys.exit(-1)
morphbr@565: 
morphbr@565: 
morphbr@565: mplayer = os.popen("which mplayer").read().strip()
morphbr@565: mplayer += " -idx - -vo x11 1> /dev/null"
morphbr@565: pin, pout = os.popen2(mplayer)
morphbr@565: 
morphbr@565: #teste = open("teste.avi", "w")
morphbr@565: 
morphbr@565: data = socket.recv(4096)
morphbr@565: i = 0
morphbr@565: 
morphbr@565: while (data != ""):
morphbr@565:     pin.write(data)
morphbr@565:     #teste.write(data)
morphbr@565:     data = socket.recv(4096)
morphbr@565:     #if (i == 500):
morphbr@565:     #    socket.send("OK")
morphbr@565:     i += 1
morphbr@565: 
morphbr@565: pin.close()
morphbr@565: socket.close()
morphbr@565: #teste.close()
morphbr@565: 
morphbr@565: # from select import select
morphbr@565: # r, w, x = select([pout], []. [], 0)
morphbr@565: # if pout in r:
morphbr@565: #     pout.read(32)