gmyth-stream/tests/client_ffmpeg.py
author renatofilho
Mon Apr 02 16:02:03 2007 +0100 (2007-04-02)
branchtrunk
changeset 476 f9330272e09d
parent 471 2eef40885322
child 478 d220053366be
permissions -rw-r--r--
[svn r481] implemented dynamic index table
morphbr@466
     1
import os
morphbr@470
     2
import sys
morphbr@466
     3
import time
morphbr@466
     4
import socket
morphbr@466
     5
morphbr@466
     6
morphbr@470
     7
if len(sys.argv) < 2:
morphbr@470
     8
    HOST = 'localhost'
morphbr@470
     9
    PORT = 5000
morphbr@470
    10
elif len(sys.argv) == 2:
morphbr@470
    11
    HOST = sys.argv[1]
morphbr@470
    12
    PORT = 5000
morphbr@470
    13
else:
morphbr@470
    14
    HOST = sys.argv[1]
morphbr@470
    15
    PORT = int(sys.argv[2])
morphbr@466
    16
morphbr@470
    17
socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
morphbr@470
    18
socket.settimeout(10)
morphbr@470
    19
morphbr@470
    20
try:
morphbr@470
    21
    socket.connect( (HOST,PORT) )
morphbr@470
    22
except:
morphbr@470
    23
    print "\n--> Could not connect to ('%s':'%d')\n" % (HOST,PORT)
morphbr@470
    24
    sys.exit(-1)
morphbr@470
    25
morphbr@466
    26
morphbr@466
    27
mplayer = os.popen("which mplayer").read().strip()
morphbr@470
    28
mplayer += " - 1> /dev/null"
morphbr@466
    29
pin, pout = os.popen2(mplayer)
morphbr@466
    30
morphbr@470
    31
data = socket.recv(1024)
morphbr@466
    32
while (data != ""):
morphbr@466
    33
    pin.write(data)
morphbr@470
    34
    data = socket.recv(1024)
morphbr@466
    35
morphbr@470
    36
pin.close()
morphbr@474
    37
#pout.close()
morphbr@471
    38
socket.close()
morphbr@470
    39
morphbr@474
    40
morphbr@470
    41
# from select import select
morphbr@470
    42
# r, w, x = select([pout], []. [], 0)
morphbr@470
    43
# if pout in r:
morphbr@470
    44
#     pout.read(32)