Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send MediaStream through NodeJS

I have the MediaStream object returned from getUserMedia and can show it in my own screen.

The thing is, I don't know how to *send / pipe / stream/ * that MediaStream from Point A through NodeJS using socket.io to Point B.

My code right now is:

// Cámara
if (navigator.getUserMedia) {
navigator.getUserMedia({audio: true, video: true}, function(stream) {

    video.src = URL.createObjectURL(stream) || window.URL.createObjectURL(stream);

    webcamstream = stream;                  

}, onVideoFail);
} else {
   alert ('failed');
}

});

function onVideoFail(e) {
    console.log('webcam fail!', e);
};

I need the way to make this stream being sent constantly to other user using NodeJS.

like image 275
Axel Avatar asked Aug 30 '14 23:08

Axel


2 Answers

  • The comment made in the answer for Audio and video conference with NodeJS are still valid

  • if you were to send the streams through socket.io instead of a peer connection, in any case that would be the raw video content (bytes). You would lose:

    • the streaming part (RTP/RTCP), and corresponding packet loss cancellation
    • the bandwidth adaptation
    • the encryption (DTLS)
    • the media engine (jitter correction, …)

    over webRTC.

  • why not implement an SFU in node.js? Use node.js/socket.io for the signaling (i.e. the initial handshake) but also use node.js as a peer connection endpoint which relays/routes the media stream to (an)other(s) peer(s)? You would have an intermediate server like you seem to want, and all the advantages of webRTC.

  • another solution is to use an MCU, google webrtc+mcu and you will find many.
like image 173
Dr. Alex Gouaillard Avatar answered Oct 27 '22 20:10

Dr. Alex Gouaillard


this might be a little late, but there's now a library called wrtc/node-webrtc. use that! https://github.com/node-webrtc/node-webrtc

like image 1
Mikey Avatar answered Oct 27 '22 21:10

Mikey