Files
element-call/src/utils/media.ts

24 lines
656 B
TypeScript
Raw Normal View History

/*
Copyright 2022-2024 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only
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 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,
2023-10-11 10:42:04 -04:00
devices: MediaDeviceInfo[],
): string | undefined {
const deviceInfo = devices.find(
2023-10-11 10:42:04 -04:00
(d) => d.kind === kind && d.label === deviceName,
);
return deviceInfo?.deviceId;
}