dai-shi / remote-faces

A tool for Working From Home: Share your webcam images with your colleagues
https://remote-faces.js.org
MIT License
96 stars 10 forks source link

[Network] Improve internal audio on/off handling #95

Open dai-shi opened 4 years ago

dai-shi commented 4 years ago

Currently, audio track is added regardless of "Mic On" flag, which allows users to speak instantly after they enable the mic. This is done by track.enabled = true/false. ref: https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack

It looks like even if the track is not enabled, the RTCSender transmits some bytes. Can we improve it by using sender.replaceTrack instead? How can we make an empty audio track at the start?

dai-shi commented 4 years ago
new AudioContext().createMediaStreamDestination().stream;

to create an empty audio stream.

We could use Audio API to create stream/track, instead of sender.replaceTrack.