geut / discovery-swarm-webrtc

discovery-swarm for WebRTC
MIT License
94 stars 23 forks source link

peer.addStream() does not work #16

Closed dmaretskyi closed 4 years ago

dmaretskyi commented 4 years ago

Version: v3.0.0-beta.1

simple-peer's API to add a new media stream to existing connection does not work. The added stream does not appear in any way on the other side.

I've traced the issue down to signals not being properly forwarded after the connection is already established. When I add a new media stream simple-peer tries to re-negotiate sending a new offer. But because of this line https://github.com/geut/socket-signal/blob/master/lib/client.js#L273. The signals are not forwarded after the safe-connect event is emitted.

tinchoz49 commented 4 years ago

Thanks @Marik-D to report this, I never test the addStream API with socket-signal I will add support for media streams.

tinchoz49 commented 4 years ago

Working on a fix here: https://github.com/geut/socket-signal/issues/1

I will be publish a new version today. One important thing here is that addStream needs to run a negotiation of signal offer/answer again over the peer, that initially means: talk with the signal server again

But there is another approach, we can reuse the data channel (the connection that we already have) to exchange the new signal offer/answer data so that means every addStream runs full P2P without the need of a signal server. That's what I'm doing now.

tinchoz49 commented 4 years ago

@Marik-D can you test the package by installing: npm install git://github.com:geut/discovery-swarm-webrtc.git#tinchoz49/next

It has the socket-signal updated with the media stream support.

dmaretskyi commented 4 years ago

The new version seems to work. Thanks!