Once I have established a WebRTC connection, I can getLocalStreams
and getRemoteStreams
.
The streams have their own ID. Each stream is made of audio/video tracks MediaStreamTrack
.
I'd like to be able to identify the device/source (ID) used for each track in order to avoid adding a stream that was already added to the connection.
In other word, I was thinking to make a check in connection.onaddstream
that the stream track is not already present in my list of local or remote streams.
Any suggestions?
For each MediaStreamTrack
you can call .getCapabilities().deviceId
to get the deviceId.
But I'm not sure if you can use the same device id within the same browser twice.
.getSettings().deviceId on audio/video track (instance of MediaStreamTrack) will return deviceId that is same as deviceId returned from enumerateDevices()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With