in packages/calling-stateful-client/src/DeviceManagerDeclarative.ts [196:259]
public get<P extends keyof DeviceManager>(target: DeviceManager, prop: P): any {
switch (prop) {
case 'getCameras': {
return this._context.withAsyncErrorTeedToState((): Promise<VideoDeviceInfo[]> => {
return target.getCameras().then((cameras: VideoDeviceInfo[]) => {
// Device Manager always has a camera with '' name if there are no real camera devices available.
// We don't want to show that in the UI.
const realCameras = cameras.filter((c) => !!c.name);
this._context.setDeviceManagerCameras(dedupeById(realCameras));
return realCameras;
});
}, 'DeviceManager.getCameras');
}
case 'getMicrophones': {
return this._context.withAsyncErrorTeedToState((): Promise<AudioDeviceInfo[]> => {
return target.getMicrophones().then((microphones: AudioDeviceInfo[]) => {
this._context.setDeviceManagerMicrophones(dedupeById(microphones));
return microphones;
});
}, 'DeviceManager.getMicrophones');
}
case 'getSpeakers': {
return this._context.withAsyncErrorTeedToState((): Promise<AudioDeviceInfo[]> => {
return target.getSpeakers().then((speakers: AudioDeviceInfo[]) => {
this._context.setDeviceManagerSpeakers(dedupeById(speakers));
return speakers;
});
}, 'DeviceManager.getSpeakers');
}
case 'selectMicrophone': {
return this._context.withAsyncErrorTeedToState(
(...args: Parameters<DeviceManager['selectMicrophone']>): Promise<void> => {
return target.selectMicrophone(...args).then(() => {
this._context.setDeviceManagerSelectedMicrophone(target.selectedMicrophone);
});
},
'DeviceManager.selectMicrophone'
);
}
case 'selectSpeaker': {
return this._context.withAsyncErrorTeedToState(
(...args: Parameters<DeviceManager['selectSpeaker']>): Promise<void> => {
return target.selectSpeaker(...args).then(() => {
this._context.setDeviceManagerSelectedSpeaker(target.selectedSpeaker);
});
},
'DeviceManager.selectSpeaker'
);
}
case 'askDevicePermission': {
return this._context.withAsyncErrorTeedToState(
(...args: Parameters<DeviceManager['askDevicePermission']>): Promise<DeviceAccess> => {
return target.askDevicePermission(...args).then(async (deviceAccess: DeviceAccess) => {
await this.updateDevicePermissionState(deviceAccess);
return deviceAccess;
});
},
'DeviceManager.askDevicePermission'
);
}
default:
return Reflect.get(target, prop);
}
}