in apps/meeting/src/components/MeetingControls/VideoInputTransformControl.tsx [76:110]
async function toggleBackgroundBlur() {
let current = activeVideoDevice;
if (isLoading) {
return;
}
try {
setIsLoading(true);
if (!isVideoTransformDevice(current)) {
// Enable video transform on the default device.
current = await createBackgroundBlurDevice(current) as VideoTransformDevice;
meetingManager.logger?.info('Video filter turned on - selecting video transform device: ' + JSON.stringify(current));
} else {
// Switch back to intrinsicDevice.
const intrinsicDevice = await current.intrinsicDevice();
// Stop existing VideoTransformDevice.
await current.stop();
current = intrinsicDevice;
// Switch to background blur device if old selection was background replacement otherwise switch to default intrinsic device.
if (activeVideoTransformOption === VideoTransformOptions.Replacement) {
current = await createBackgroundBlurDevice(current) as VideoTransformDevice;
meetingManager.logger?.info('Video filter was turned on - video transform device: ' + JSON.stringify(current));
} else {
meetingManager.logger?.info('Video filter was turned off - selecting inner device: ' + JSON.stringify(current));
}
}
// Use the new created video device as input.
await meetingManager.selectVideoInputDevice(current);
// Update the current selected transform.
setActiveVideoTransformOption(activeVideoTransformOption => activeVideoTransformOption === VideoTransformOptions.Blur ? VideoTransformOptions.None : VideoTransformOptions.Blur);
} catch (e) {
console.error('Error trying to toggle background blur', e);
} finally {
setIsLoading(false);
}
}