Can mediaStream be sent via websocket to server?

3,111 views
Skip to first unread message

John Li

unread,
Mar 26, 2015, 2:49:23 PM3/26/15
to discuss...@googlegroups.com
I am new to webRTC, and please bear with me if my question is too stupid..
I am working with node and using socket io. I want to add webrtc element to my app, so i am thinking if it is possible to stream mediaStream blob via websocket to server, and let server emit the stream to all other connected sockets in a room??

My approach is get the mediaStream blob first
var audioStream = window.URL ? window.URL.createObjectURL(stream) : stream;

and then send via socket
socket.emit('audio',audioStream);

Obviously it doesnt work like this way, otherwise it will be too easy. I just want to know if this way is possible, because i know peerconnection between two browsers uses websocket, so why not do it thru server?  Any idea or suggestion is highly weclomed.


Nazmus Shakeeb

unread,
Mar 27, 2015, 6:37:00 AM3/27/15
to discuss...@googlegroups.com
>>Obviously it doesnt work like this way, otherwise it will be too easy. I just want to know if this way is possible,

While using webRTC  you can send media in two ways 

1. P2P
2. Relay ( TURN Server ) 

When one client sends P2P to other client, packet traverse less path so packet has delay. Users get good quality and less delay in this way. 

webRTC tries to make all the call P2P. About 80% of total calls are completed P2P.  There some NAT devices behind which webRTC can not make P2P call.

When webRTC can not make P2P , it uses relay. Relay is just like using other server ( you think it like websocket, but webRTC never uses websocket , it uses TURN )          


Relay is a very bad thing. It introduce delay. It involves setup and bandwidth  and maintenance cost and give worse quality.    


One should  only prefer using relay when he needs to send less data ( few kilobytes ) .

Eric Davies

unread,
Mar 27, 2015, 4:55:24 PM3/27/15
to discuss...@googlegroups.com
while you can't push media through a websocket in the way you desire,
you could achieve a similar effect using an SFU. Take a look at licode or jitsi.

John Li

unread,
Mar 27, 2015, 11:26:11 PM3/27/15
to discuss...@googlegroups.com
Thanks for the reply. After days research, i understand WebRTC way better. websockets can be used as signaling but not for streaming video or audio data.
Reply all
Reply to author
Forward
0 new messages