I am working on wireless communications project. There is a transmitter and a receiver in my system. At the transmitter side, I transmit a video streaming which is streamed by VLC from a hardware board. At the receiver side, 2nd hardware board receives the data and feed it to the computer via USB. If I save the received data as a file, say rxdata, I can use VLC play it directly. Or, I open a VLC server, like vlc udp://@:2009. Then, open a VLC client, like vlc rxdata --sout '#duplicate{dst=std{access=udp,mux=ts,dst=:2009}}'. There is no problem to play it.
However, what I need here is not a file, which means I need to write the received data to a socket client over UDP rather than a file. The client code is attached below.
Code: Select all
# the client, which is part of my receiver code written in Python
def main():
......
def rx_callback(ok, payload):
......
print "ok = %5s pktno = %4d n_rcvd = %4d n_right = %4d" % (ok,
pktno, n_rcvd, n_right)
rxdata.append(payload[2:]) #rxdata is my received data, then I feed these data to a socket client
clientHost = 'localhost' # servername is localhost'
clientPort = 2009 # use arbitrary port > 1024
dgramSock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM ) # create a UDP socket
dgramSock.connect((clientHost,clientPort)) # connect to server on the port
for ndx_data in rxdata:
dgramSock.sendto( ndx_data, (clientHost, clientPort) ) # send the data
data = dgramSock.recv(4096) # receive up to 4096 bytes
#print data
dgramSock.close()
.......
1, I don't think the client and the server(VLC) are connected via UDP. How should I set up the connection?
2, Is it correct that I write the received data to a client UDP socket?
I am looking forward to any reply.
Appreciate,
Brook