Simple-peer: expose addStream on prototype

Created on 6 Dec 2015  路  6Comments  路  Source: feross/simple-peer

right now you can only specify the stream in the constructor

you should be able to do it lazily after the connection has been opened, that way you can start the connection process as soon as possible instead of handling camera access and connection in series

feature request help wanted

Most helpful comment

To force renegotation, I've been destroying and recreating Peer objects, and although this may involve slightly more renogiation than necessary it's been working for me.

If you're using react, check out the component I've wrapped it in to handle that logic for me https://github.com/ben-pr-p/assemble/blob/master/client/room/user-blob/webrtc/react-simple-peer.js

If you pass the component a new stream, it will handle renegotiation by destroying and recreating a Peer object internally.

All 6 comments

The downside of creating streams lazily is then you have to handle renegotiation.

As an alternative to renegotiation, it's possible to merge MediaStreams before passing them into simple-peer. You can add/remove streams to this merged stream as you please, without renegotiation.

Not the ideal solution, but it's a workaround for some usecases until the spec around multistreaming stabilizes.

Demo

To force renegotation, I've been destroying and recreating Peer objects, and although this may involve slightly more renogiation than necessary it's been working for me.

If you're using react, check out the component I've wrapped it in to handle that logic for me https://github.com/ben-pr-p/assemble/blob/master/client/room/user-blob/webrtc/react-simple-peer.js

If you pass the component a new stream, it will handle renegotiation by destroying and recreating a Peer object internally.

@RationalCoding I think your library looks like a promising solution for this problem, but I have a few questions:

  • Is the merging logic supported on the browsers that support WebRTC or just on Chrome?
  • Could you publish the source for your demo, I can't find it?
  • Is it possible to detect that there are "no streams in the merged stream"? Ie - that the host is currently not transmitting anything?

    • I guess this could be sent alongside the stream, on the data channel, but anyways...

Being solved at #250

Implemented in #250.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

scriptonist picture scriptonist  路  5Comments

sahil-devzila picture sahil-devzila  路  3Comments

saagarbethi picture saagarbethi  路  4Comments

adammw picture adammw  路  5Comments

measwel picture measwel  路  4Comments