1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/gmyth-stream/server/tests/client_ffmpeg.py Tue Apr 03 16:43:11 2007 +0100
1.3 @@ -0,0 +1,48 @@
1.4 +import os
1.5 +import sys
1.6 +import time
1.7 +import socket
1.8 +
1.9 +
1.10 +if len(sys.argv) < 2:
1.11 + HOST = 'localhost'
1.12 + PORT = 5000
1.13 +elif len(sys.argv) == 2:
1.14 + HOST = sys.argv[1]
1.15 + PORT = 5000
1.16 +else:
1.17 + HOST = sys.argv[1]
1.18 + PORT = int(sys.argv[2])
1.19 +
1.20 +socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
1.21 +socket.settimeout(10)
1.22 +
1.23 +try:
1.24 + socket.connect( (HOST,PORT) )
1.25 +except:
1.26 + print "\n--> Could not connect to ('%s':'%d')\n" % (HOST,PORT)
1.27 + sys.exit(-1)
1.28 +
1.29 +
1.30 +mplayer = os.popen("which mplayer").read().strip()
1.31 +mplayer += " - 1> /dev/null"
1.32 +pin, pout = os.popen2(mplayer)
1.33 +
1.34 +data = socket.recv(1024)
1.35 +i = 0
1.36 +
1.37 +while (data != ""):
1.38 + pin.write(data)
1.39 + data = socket.recv(1024)
1.40 + if (i == 500):
1.41 + socket.send("OK")
1.42 + i += 1
1.43 +
1.44 +pin.close()
1.45 +socket.close()
1.46 +
1.47 +
1.48 +# from select import select
1.49 +# r, w, x = select([pout], []. [], 0)
1.50 +# if pout in r:
1.51 +# pout.read(32)