1
votes

I'm trying to realize a video meeting with node.js and webrtc. On node I'm trying to use node-webrtc (npm package wrtc, https://www.npmjs.com/package/wrtc) tht is the porting of the webrtc stack for nodejs. I don't want to use an external service nor a wrapper library that requires the integration of a client side library.

So, at the moment I can successfully make two peers communicate adopting a signaling channel based on websocket. They correctly exchange SDP with offer answer and start to exchange ice candidates. untile I get the stream or better the tracks from one of the two sides, and then I can create a viewer ( an HTML video tag ). I would prefer to handle by stream (even if I know the direct usage of addStream has been deprecated) just because I want to keep a "group" of audio+video track for each communication. So I can just use the addTrack and removeTrack. So for the P2P video call the things are working.

Now I implemented the same stack on the backend, the idea is to have a kind of relay server avoiding that a Peer has to send (upload) all the tracks to all the participant in a room. The idea is that a room is a webrtc peer itself (realized with node-webrtc) and then it relays the incoming tracks/stream to all the other participants.

The problem is that when I try to send a "received" track/stream to more than one peer I get an error like

DOMException: Failed to execute 'addTrack' on 'RTCPeerConnection': A sender already exists for the track. XXXXX

Looking on the web I see that it is a problem related to the negotiation, I would have to add a new RTCRtpTranceiver https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpTransceiver But it is not so clear to me how to do it. Is there an example on how to receive a stream/track from one RTCPeerConnection and forward it to multiple other RTCPeerConnections ? The simple addTrack is not working and raise the error above.

I've already verified the multiple video chat example on the official site of webrtc, but it differs because it simply sends the same localvideo to multiple peers (2 of them), not forwarding an incoming stream from another peer connection.

I also want to do that? Already found a solution for it?Herman Van Der Blom