|
@@ -44,19 +44,26 @@ export function getAudioOutputDeviceId() {
|
44
|
44
|
*
|
45
|
45
|
* @param {Object} state - The redux state.
|
46
|
46
|
* @param {string} label - The label.
|
|
47
|
+ * @param {string} kind - The type of the device. One of "audioInput",
|
|
48
|
+ * "audioOutput", and "videoInput". Also supported is all lowercase versions
|
|
49
|
+ * of the preceding types.
|
47
|
50
|
* @returns {string|undefined}
|
48
|
51
|
*/
|
49
|
|
-export function getDeviceIdByLabel(state: Object, label: string) {
|
50
|
|
- const types = [ 'audioInput', 'audioOutput', 'videoInput' ];
|
|
52
|
+export function getDeviceIdByLabel(state: Object, label: string, kind: string) {
|
|
53
|
+ const webrtcKindToJitsiKindTranslator = {
|
|
54
|
+ audioinput: 'audioInput',
|
|
55
|
+ audiooutput: 'audioOutput',
|
|
56
|
+ videoinput: 'videoInput'
|
|
57
|
+ };
|
51
|
58
|
|
52
|
|
- for (const type of types) {
|
53
|
|
- const device
|
54
|
|
- = (state['features/base/devices'].availableDevices[type] || [])
|
55
|
|
- .find(d => d.label === label);
|
|
59
|
+ const kindToSearch = webrtcKindToJitsiKindTranslator[kind] || kind;
|
56
|
60
|
|
57
|
|
- if (device) {
|
58
|
|
- return device.deviceId;
|
59
|
|
- }
|
|
61
|
+ const device
|
|
62
|
+ = (state['features/base/devices'].availableDevices[kindToSearch] || [])
|
|
63
|
+ .find(d => d.label === label);
|
|
64
|
+
|
|
65
|
+ if (device) {
|
|
66
|
+ return device.deviceId;
|
60
|
67
|
}
|
61
|
68
|
}
|
62
|
69
|
|