feross / simple-peer

📡 Simple WebRTC video, voice, and data channels

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

peer.addStream(stream) doesn't raise event one other peer

Gruski opened this issue · comments

using: v9.11.0
library directly referenced: <script src="simplepeer.min.js"></script>

peer.addStream(stream) call on the initiator peer doesn't raise peer.on('stream', ...) event on the other peer after successful data connection. When stream is passed through the initiator peer constructor, the event does get raised. I was expecting the same to happen when peer.addStream(stream) was called in situations where the stream is no yet known at peer construction time.

Also when inspecting the 'peer' object in the console, after the peer.addStream() is called, the "streams" prop, which is an array, still has a length of 0. No stream is added. Probably a regression bug.

I am having the same problem. Looking at #370 if a peer connection with no stream is initialized and the streams added later, we are supposed to pass constraints into our constructors:

var p1 = new Peer({initiator:true, offerConstraints: { offerToReceiveVideo: false, offerToReceiveAudio: false }) var p2 = new Peer({initiator:false, answerConstraints: { offerToReceiveVideo: false, offerToReceiveAudio: false })

Then once the new stream is to be added, before doing so the initiator must be signaled to accept audio/video using the setConstraints method:

var newConstraints = { offerToReceiveAudio: true, offerToReceiveVideo: true } signalingChannel.send('requestToChangeConstraints', newConstraints) this.peer.addStream(stream); signalingChannel.on('requestToChangeConstraints', (newConstraints) { this.peer.setConstraints(newConstraints); })

However when I do it, newConstraints, offerToReceiveAudio, and offerToReceiveVideo are all undefined. I'm thinking there is probably a new way of doing it, but can't tell from the readme and am unable to find more detailed documentation.

any updates on this one ?