mirror of
https://github.com/vector-im/element-call.git
synced 2026-03-25 06:40:26 +00:00
25 lines
741 B
TypeScript
25 lines
741 B
TypeScript
/*
|
|
Copyright 2022-2024 New Vector Ltd.
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
Please see LICENSE in the repository root for full details.
|
|
*/
|
|
|
|
/**
|
|
* Finds a media device with label matching 'deviceName'
|
|
* @param deviceName The label of the device to look for
|
|
* @param kind The kind of media device to look for
|
|
* @param devices The list of devices to search
|
|
* @returns A matching media device or undefined if no matching device was found
|
|
*/
|
|
export function findDeviceByName(
|
|
deviceName: string,
|
|
kind: MediaDeviceKind,
|
|
devices: MediaDeviceInfo[],
|
|
): string | undefined {
|
|
const deviceInfo = devices.find(
|
|
(d) => d.kind === kind && d.label === deviceName,
|
|
);
|
|
return deviceInfo?.deviceId;
|
|
}
|