|
@@ -51,10 +51,11 @@ function getNewAudioOutputDevice(newDevices) {
|
51
|
51
|
* list of available devices has been changed.
|
52
|
52
|
* @param {MediaDeviceInfo[]} newDevices
|
53
|
53
|
* @param {JitsiLocalTrack} localAudio
|
|
54
|
+ * @param {boolean} newLabel
|
54
|
55
|
* @returns {string|undefined} - ID of new microphone device to use, undefined
|
55
|
56
|
* if audio input device should not be changed.
|
56
|
57
|
*/
|
57
|
|
-function getNewAudioInputDevice(newDevices, localAudio) {
|
|
58
|
+function getNewAudioInputDevice(newDevices, localAudio, newLabel) {
|
58
|
59
|
const availableAudioInputDevices = newDevices.filter(
|
59
|
60
|
d => d.kind === 'audioinput');
|
60
|
61
|
const selectedAudioInputDeviceId = getUserSelectedMicDeviceId(APP.store.getState());
|
|
@@ -75,7 +76,8 @@ function getNewAudioInputDevice(newDevices, localAudio) {
|
75
|
76
|
return availableAudioInputDevices[0].deviceId;
|
76
|
77
|
}
|
77
|
78
|
} else if (selectedAudioInputDevice
|
78
|
|
- && selectedAudioInputDeviceId !== localAudio.getDeviceId()) {
|
|
79
|
+ && selectedAudioInputDeviceId !== localAudio.getDeviceId()
|
|
80
|
+ && !newLabel) {
|
79
|
81
|
|
80
|
82
|
// And here we handle case when we already have some device working,
|
81
|
83
|
// but we plug-in a "preferred" (previously selected in settings, stored
|
|
@@ -89,10 +91,11 @@ function getNewAudioInputDevice(newDevices, localAudio) {
|
89
|
91
|
* list of available devices has been changed.
|
90
|
92
|
* @param {MediaDeviceInfo[]} newDevices
|
91
|
93
|
* @param {JitsiLocalTrack} localVideo
|
|
94
|
+ * @param {boolean} newLabel
|
92
|
95
|
* @returns {string|undefined} - ID of new camera device to use, undefined
|
93
|
96
|
* if video input device should not be changed.
|
94
|
97
|
*/
|
95
|
|
-function getNewVideoInputDevice(newDevices, localVideo) {
|
|
98
|
+function getNewVideoInputDevice(newDevices, localVideo, newLabel) {
|
96
|
99
|
const availableVideoInputDevices = newDevices.filter(
|
97
|
100
|
d => d.kind === 'videoinput');
|
98
|
101
|
const selectedVideoInputDeviceId = getUserSelectedCameraDeviceId(APP.store.getState());
|
|
@@ -113,7 +116,8 @@ function getNewVideoInputDevice(newDevices, localVideo) {
|
113
|
116
|
return availableVideoInputDevices[0].deviceId;
|
114
|
117
|
}
|
115
|
118
|
} else if (selectedVideoInputDevice
|
116
|
|
- && selectedVideoInputDeviceId !== localVideo.getDeviceId()) {
|
|
119
|
+ && selectedVideoInputDeviceId !== localVideo.getDeviceId()
|
|
120
|
+ && !newLabel) {
|
117
|
121
|
// And here we handle case when we already have some device working,
|
118
|
122
|
// but we plug-in a "preferred" (previously selected in settings, stored
|
119
|
123
|
// in local storage) device.
|
|
@@ -139,14 +143,42 @@ export default {
|
139
|
143
|
newDevices,
|
140
|
144
|
isSharingScreen,
|
141
|
145
|
localVideo,
|
142
|
|
- localAudio) {
|
|
146
|
+ localAudio,
|
|
147
|
+ newLabels) {
|
143
|
148
|
return {
|
144
|
|
- audioinput: getNewAudioInputDevice(newDevices, localAudio),
|
145
|
|
- videoinput: isSharingScreen ? undefined : getNewVideoInputDevice(newDevices, localVideo),
|
|
149
|
+ audioinput: getNewAudioInputDevice(newDevices, localAudio, newLabels),
|
|
150
|
+ videoinput: isSharingScreen ? undefined : getNewVideoInputDevice(newDevices, localVideo, newLabels),
|
146
|
151
|
audiooutput: getNewAudioOutputDevice(newDevices)
|
147
|
152
|
};
|
148
|
153
|
},
|
149
|
154
|
|
|
155
|
+ /**
|
|
156
|
+ * Checks if the only difference between an object of known devices compared
|
|
157
|
+ * to an array of new devices are only the labels for the devices.
|
|
158
|
+ * @param {Object} oldDevices
|
|
159
|
+ * @param {MediaDeviceInfo[]} newDevices
|
|
160
|
+ * @returns {boolean}
|
|
161
|
+ */
|
|
162
|
+ newDeviceListAddedLabelsOnly(oldDevices, newDevices) {
|
|
163
|
+ const oldDevicesFlattend = oldDevices.audioInput.concat(oldDevices.audioOutput).concat(oldDevices.videoInput);
|
|
164
|
+
|
|
165
|
+ if (oldDevicesFlattend.length !== newDevices.length) {
|
|
166
|
+ return false;
|
|
167
|
+ }
|
|
168
|
+ oldDevicesFlattend.forEach(oldDevice => {
|
|
169
|
+ if (oldDevice.label !== '') {
|
|
170
|
+ return false;
|
|
171
|
+ }
|
|
172
|
+ const newDevice = newDevices.find(nd => nd.deviceId === oldDevice.deviceId);
|
|
173
|
+
|
|
174
|
+ if (!newDevice || newDevice.label === '') {
|
|
175
|
+ return false;
|
|
176
|
+ }
|
|
177
|
+ });
|
|
178
|
+
|
|
179
|
+ return true;
|
|
180
|
+ },
|
|
181
|
+
|
150
|
182
|
/**
|
151
|
183
|
* Tries to create new local tracks for new devices obtained after device
|
152
|
184
|
* list changed. Shows error dialog in case of failures.
|