author | rosfran |
Wed Apr 18 15:47:40 2007 +0100 (2007-04-18) | |
branch | trunk |
changeset 564 | 1b897f699097 |
parent 496 | 8f9fe41efa81 |
permissions | -rw-r--r-- |
morphbr@496 | 1 |
import os |
morphbr@496 | 2 |
import sys |
morphbr@496 | 3 |
import time |
morphbr@496 | 4 |
import socket |
morphbr@496 | 5 |
|
morphbr@496 | 6 |
|
morphbr@496 | 7 |
if len(sys.argv) < 2: |
morphbr@496 | 8 |
HOST = 'localhost' |
morphbr@516 | 9 |
PORT = 50000 |
morphbr@496 | 10 |
elif len(sys.argv) == 2: |
morphbr@496 | 11 |
HOST = sys.argv[1] |
morphbr@516 | 12 |
PORT = 50000 |
morphbr@496 | 13 |
else: |
morphbr@496 | 14 |
HOST = sys.argv[1] |
morphbr@496 | 15 |
PORT = int(sys.argv[2]) |
morphbr@496 | 16 |
|
morphbr@496 | 17 |
socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM) |
morphbr@496 | 18 |
socket.settimeout(10) |
morphbr@496 | 19 |
|
morphbr@496 | 20 |
try: |
morphbr@496 | 21 |
socket.connect( (HOST,PORT) ) |
morphbr@496 | 22 |
except: |
morphbr@496 | 23 |
print "\n--> Could not connect to ('%s':'%d')\n" % (HOST,PORT) |
morphbr@496 | 24 |
sys.exit(-1) |
morphbr@496 | 25 |
|
morphbr@496 | 26 |
|
morphbr@496 | 27 |
mplayer = os.popen("which mplayer").read().strip() |
morphbr@516 | 28 |
mplayer += " -idx - -vo x11 1> /dev/null" |
morphbr@496 | 29 |
pin, pout = os.popen2(mplayer) |
morphbr@496 | 30 |
|
morphbr@516 | 31 |
#teste = open("teste.avi", "w") |
morphbr@496 | 32 |
|
morphbr@516 | 33 |
data = socket.recv(4096) |
morphbr@496 | 34 |
i = 0 |
morphbr@496 | 35 |
|
morphbr@496 | 36 |
while (data != ""): |
morphbr@496 | 37 |
pin.write(data) |
morphbr@496 | 38 |
#teste.write(data) |
morphbr@516 | 39 |
data = socket.recv(4096) |
morphbr@516 | 40 |
#if (i == 500): |
morphbr@516 | 41 |
# socket.send("OK") |
morphbr@496 | 42 |
i += 1 |
morphbr@496 | 43 |
|
morphbr@496 | 44 |
pin.close() |
morphbr@496 | 45 |
socket.close() |
morphbr@516 | 46 |
#teste.close() |
morphbr@496 | 47 |
|
morphbr@496 | 48 |
# from select import select |
morphbr@496 | 49 |
# r, w, x = select([pout], []. [], 0) |
morphbr@496 | 50 |
# if pout in r: |
morphbr@496 | 51 |
# pout.read(32) |