gmyth-stream/tests/client_ffmpeg.py
author morphbr
Fri Mar 30 04:12:52 2007 +0100 (2007-03-30)
branchtrunk
changeset 470 57833200a415
parent 466 a7aba7d166fb
child 471 2eef40885322
permissions -rw-r--r--
[svn r475] Regarding GMyth-Stream:

- Bug fixes
- Better error handling
- Return messages to client
- Created a lib.py with common functions
- Improved API of comm plugins
     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 = 5000
    10 elif len(sys.argv) == 2:
    11     HOST = sys.argv[1]
    12     PORT = 5000
    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 += " - 1> /dev/null"
    29 pin, pout = os.popen2(mplayer)
    30 
    31 data = socket.recv(1024)
    32 while (data != ""):
    33     pin.write(data)
    34     data = socket.recv(1024)
    35 
    36 pin.close()
    37 pout.close()
    38 
    39 
    40 # from select import select
    41 # r, w, x = select([pout], []. [], 0)
    42 # if pout in r:
    43 #     pout.read(32)