gmyth-stream/tests/client_ffmpeg.py
author rosfran
Mon Apr 02 20:48:43 2007 +0100 (2007-04-02)
branchtrunk
changeset 480 f6fc378c70e5
parent 474 07c12d2ceddf
permissions -rw-r--r--
[svn r485] Exprimental function to get all the channel names.
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@478
    32
i = 0
morphbr@478
    33
morphbr@466
    34
while (data != ""):
morphbr@466
    35
    pin.write(data)
morphbr@470
    36
    data = socket.recv(1024)
morphbr@478
    37
    if (i == 500):
morphbr@478
    38
        socket.send("OK")
morphbr@478
    39
    i += 1
morphbr@466
    40
morphbr@470
    41
pin.close()
morphbr@471
    42
socket.close()
morphbr@470
    43
morphbr@474
    44
morphbr@470
    45
# from select import select
morphbr@470
    46
# r, w, x = select([pout], []. [], 0)
morphbr@470
    47
# if pout in r:
morphbr@470
    48
#     pout.read(32)