WebRTC logic for stream renegotiation (enable/disable video)

1.2k views Asked by At

I've been using SimpleWebRTC in my app for a while. It's very easy to setup and works well for simple apps. However, I need to be able to disable/enable video without affecting audio in my app, and this is where SimpleWebRTC falls short. Searching a few other StackOverflow questions revealed that this seems to be called 'renegotiation'.

Apparently up until relatively recently (last year or two?) browsers did not expose MediaStreamTracks (https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack), which made renegotiation impossible. Now this is apparently possible, but I don't see any wrapper library doing this. Actually, most of the popular WebRTC libraries don't seem to be maintained at all anymore.

Has anyone worked with stream renegotiation and can point me in the right direction, either to a library that implements it, a polyfill, or some guidance on how I can implement this via current WebRTC standards? I don't mind getting rid of a library in favor of barebones WebRTC, I'm just not sure what's the proper way of ending/starting connection consistently is, since implementations still seem finicky between browsers.

1

There are 1 answers

3
Philipp Hancke On

In particular for simplewebrtc there is https://simplewebrtc.com/notsosimple.html#mute It doesn't renegotiate but sets the MediaStreamTrack enabled attribute to false which sends black frames (low bandwidth). The downside is that if you mute the camera this way, the camera light will stay on.