Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebRTC - How to identify the source IDs (device IDs) for a MediaStream(Tracks)

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?

like image 486
zabumba Avatar asked Sep 28 '16 10:09

zabumba


2 Answers

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.

like image 162
Adrian Ber Avatar answered Nov 04 '22 07:11

Adrian Ber


.getSettings().deviceId on audio/video track (instance of MediaStreamTrack) will return deviceId that is same as deviceId returned from enumerateDevices()

like image 22
selvan Avatar answered Nov 04 '22 08:11

selvan