Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/utils/webrtc/MediaDevicesManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,22 @@ MediaDevicesManager.prototype = {
this._addDevice(addedDevice)
})

this._populatePreferences(devices)

// Selecting preferred device in case it was removed/unplugged, or it is a first initialization after reload,
// or we add/plug preferred device and overwriting automatic selection
// If the preference list is empty the default device falls back to
// the first device of that kind found. This can happen, for
// example, when no permissions were given yet. In that case,
// according to the spec, a single device of each kind (if at least
// one device of that kind is available) with an empty deviceId is
// returned, which will not be registered in the preference list.
if (this.attributes.audioInputId === undefined || this.attributes.audioInputId === previousFirstAvailableAudioInputId) {
this.attributes.audioInputId = getFirstAvailableMediaDevice(devices, this._preferenceAudioInputList)
this.attributes.audioInputId = getFirstAvailableMediaDevice(devices, this._preferenceAudioInputList) || devices.find(device => device.kind === 'audioinput')?.deviceId
console.debug(listMediaDevices(this.attributes, this._preferenceAudioInputList, this._preferenceVideoInputList))
}
if (this.attributes.videoInputId === undefined || this.attributes.videoInputId === previousFirstAvailableVideoInputId) {
this.attributes.videoInputId = getFirstAvailableMediaDevice(devices, this._preferenceVideoInputList)
this.attributes.videoInputId = getFirstAvailableMediaDevice(devices, this._preferenceVideoInputList) || devices.find(device => device.kind === 'videoinput')?.deviceId
console.debug(listMediaDevices(this.attributes, this._preferenceAudioInputList, this._preferenceVideoInputList))
}

Expand All @@ -226,8 +234,6 @@ MediaDevicesManager.prototype = {
}

this._pendingEnumerateDevicesPromise = null

this._populatePreferences(devices)
}).catch(function(error) {
console.error('Could not update known media devices: ' + error.name + ': ' + error.message)

Expand Down