peers / peerjs

Simple peer-to-peer with WebRTC.
https://peerjs.com
MIT License
12.17k stars 1.42k forks source link

on("stream") event should receive a unique MediaStream from a peer #639

Open baptisteArno opened 4 years ago

baptisteArno commented 4 years ago

on("stream") event currently receives 2 MediaStream objects from a unique peer. Both of these streams contain the audio and video tracks. We should only receive the MediaStream once.

Capture d’écran 2020-03-29 à 22 07 19
TbreezyF commented 4 years ago

You do have the MediaStream object sent once. The MediaStream however contains two tracks of type MediaStreamTrack. An audio and a video track

afrokick commented 4 years ago

Because we fire on('stream') when peerConnection.ontrack called, so it called twice per one MediaStream with two tracks.

https://github.com/peers/peerjs/blob/master/lib/negotiator.ts#L145-L154