Dirvann / mediasoup-sfu-webrtc-video-rooms

A simple video conferencing example using the mediasoup sfu
Apache License 2.0
223 stars 79 forks source link

A conflict with the enumerateDevices if you have several camera devices #23

Open Madriix opened 2 years ago

Madriix commented 2 years ago

Hi

alt text

On Chrome I have several cameras, the Avermedia is a video card that broadcasts DTT channels on a computer instead of television. There's Manycam, that's my test webcam device. I have another camera, it's not plugged in, it's a real webcam.

I noticed that the Avermedia is always first, therefore it very often selects the Avermedia by default.

Here's how the conflict unfolds: 1) I turn on my camera (it selects the Manycam well) 2) If I want to turn the camera back on, this time it still selects Avermedia, but I would like it to select Manycam

As a result, customers cannot turn on their webcam if they have multiple devices

Do you have an idea to solve this?

Salutations

Madriix commented 2 years ago

I partially solved the problem. Here is what I did: 1) On Firefox everything is fine, but not on Chrome. I put a menu to choose the webcam device (but I haven't yet to choose the audio). Each time a client starts his webcam, then from time to time by default it offers him a popup with Sweetalert2 to choose the webcam. As soon as he ticks, he updates the "videoSelect" live and the camera starts with it.

2) I also removed "stream.getTracks()" here: https://github.com/Dirvann/mediasoup-sfu-webrtc-video-rooms/blob/master/public/index.js#L111 because the enumerateDevices on Firefox it doesn't show device names with "device.label" they are empty, and removing the getTracks fixes the problem.

It should be noted that I use the entire mediasoup-sfu-webrtc-video-rooms system except index.html and index.js which are heavily modified

miroslavpejic85 commented 2 years ago

You could use the local.storage to save you index -> deviceId you have selected, then reuse it, if it doesn't find it (device removed) use the default.