tags:

views:

505

answers:

3

Hi guys! I was wondering if it's possibile to create a client (or a web-client) that can connect two users and then it sends their webcam stream to each other. This should happen without using Red5 or any other flash/media server. What protocol can I use? What api etc...

+1  A: 

As a super simple method, look at UDP tutorials:

http://msdn.microsoft.com/en-us/library/system.net.sockets.udpclient.aspx

If UDP ends up being a bit too unreliable (it does not guarantee the data will arrive where it is sent) you could also try TCP connections.

However, one of the biggest issues you'll hit is trying to get through NAT. Most firewalls will block incoming data unless there is an established connection going out first. You can use UPnP to get around this but it will probably take a bit of code:

http://www.codeproject.com/KB/IP/upnpnattraversal.aspx

Hope this helps. With UDP you're looking at just about 10 lines of code to send and receive data, with TCP is a bit more, but more reliable. Google both of those for more info.

From there it's fairly simple. You get the data from the webcam. Save it to a MemoryStream (System.IO) as a .jpg. Then send that data via TCP or UDP.

Timothy Baldridge
+1  A: 

You will likely want to use TCP or UDP directly, and send/recieve the raw bytes. Any higher level protocols will simply be unnecessary overhead

Pete
Some of the other answers' points about NAT are worth reading - at least one of the clients will need to open a reliable port at a known address/number that the other can connect to.
Pete
A: 

I have one thing to add, in order to get two clients, both behind their respective firewalls to talk to each other using UDP, you need to do NAT traversal. This is how Skype works.

STUN Article

unclepaul84