gmyth-stream/server/0.1/tests/client.py
author morphbr
Mon Apr 30 18:16:36 2007 +0100 (2007-04-30)
branchtrunk
changeset 605 4dd9bf602c18
permissions -rw-r--r--
[svn r611] * GMyth-Streamer
- updated mencoder plugin

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