UNPKG

@100mslive/hms-video-store

Version:

@100mslive Core SDK which abstracts the complexities of webRTC while providing a reactive store for data management with a unidirectional data flow

79 lines (78 loc) 3.44 kB
import { EventBus } from '../events/EventBus'; import { DeviceMap, SelectedDevices } from '../interfaces'; import { Store } from '../sdk/store'; interface HMSDeviceManager extends DeviceMap { outputDevice?: MediaDeviceInfo; hasWebcamPermission: boolean; hasMicrophonePermission: boolean; } export declare class DeviceManager implements HMSDeviceManager { private store; private eventBus; audioInput: InputDeviceInfo[]; audioOutput: MediaDeviceInfo[]; videoInput: InputDeviceInfo[]; outputDevice?: MediaDeviceInfo; hasWebcamPermission: boolean; hasMicrophonePermission: boolean; currentSelection: SelectedDevices; private readonly TAG; private initialized; private videoInputChanged; private audioInputChanged; private earpieceSelected; private timer; constructor(store: Store, eventBus: EventBus); updateOutputDevice: (deviceId?: string, isUserSelection?: boolean) => Promise<MediaDeviceInfo | undefined>; init(force?: boolean, logAnalytics?: boolean): Promise<void>; getDevices(): DeviceMap; cleanup(): void; getCurrentSelection: () => SelectedDevices; private createIdentifier; private computeChange; private enumerateDevices; /** * For example, if a different device, say OBS is selected as default from chrome settings, when you do getUserMedia with default, that is not the device * you get. So update to the browser settings default device * Update only when initial deviceId is not passed */ private updateToActualDefaultDevice; private handleDeviceChange; /** * Function to get the device after device change * Chrome and Edge provide a default device from which we select the actual device * Firefox and safari give 0th device as system default * @returns {MediaDeviceInfo} */ getNewAudioInputDevice(): InputDeviceInfo | undefined; /** * This method is to select the input/output from same group * same group meaning both input/output are of same device * This method might override the default coming from browser and system so as to select options from same * device type. This is required in certain cases where browser's default is not correct. * Algo: * 1. find the non default input device if selected one is default by matching device label * 2. find the corresponding output device which has the same group id or same label * 3. select the previous selected device if nothing was found * 4. select the default one if no matching device was found and previous device doesn't exist anymore * 5. select the first option if there is no default */ setOutputDevice(deviceChange?: boolean): Promise<void>; private handleAudioInputDeviceChange; private handleVideoInputDeviceChange; getManuallySelectedAudioDevice(): InputDeviceInfo | undefined; categorizeAudioInputDevices(): { bluetoothDevice: InputDeviceInfo | null; speakerPhone: InputDeviceInfo | null; wired: InputDeviceInfo | null; earpiece: InputDeviceInfo | null; }; private startPollingForDevices; /** * Mweb is not able to play via call channel by default, this is to switch from media channel to call channel */ autoSelectAudioOutput: (delay?: number) => Promise<void>; private getAudioOutputDeviceMatchingInput; private logDevices; } export {};