From edeff61b4c1b91d1d332097e6f62062013206d82 Mon Sep 17 00:00:00 2001 From: Tainan Felipe Date: Thu, 10 Apr 2025 16:37:23 -0300 Subject: [PATCH] Feat(plugin): Add set camera focus as ui-command --- src/ui-commands/camera/commands.ts | 27 ++++++++++++++++++++++++++- src/ui-commands/camera/enums.ts | 1 + src/ui-commands/camera/types.ts | 18 ++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/ui-commands/camera/commands.ts b/src/ui-commands/camera/commands.ts index a55be81c..e4315020 100644 --- a/src/ui-commands/camera/commands.ts +++ b/src/ui-commands/camera/commands.ts @@ -1,5 +1,5 @@ import { CameraEnum } from './enums'; -import { SetSelfViewDisableAllDevicesCommandArguments, SetSelfViewDisableCommandArguments } from './types'; +import { SetCameraFocusCommandArguments, SetSelfViewDisableAllDevicesCommandArguments, SetSelfViewDisableCommandArguments } from './types'; export const camera = { /** @@ -49,4 +49,29 @@ export const camera = { }), ); }, + /** + * Sets the in focus camera for a specific user. + * + * @param setSelfViewDisableCommandArguments: object with a + * boolean that tells whether to enable or disable the camera focus for specific user. + */ + setCameraFocus: ( + setCameraFocusCommandArguments: SetCameraFocusCommandArguments, + ) => { + const { + webcamSelector, + focus, + } = setCameraFocusCommandArguments; + window.dispatchEvent( + new CustomEvent< + SetCameraFocusCommandArguments + >(CameraEnum.SET_CAMERA_FOCUS, { + detail: { + focus, + webcamSelector, + }, + }), + ); + } +, }; diff --git a/src/ui-commands/camera/enums.ts b/src/ui-commands/camera/enums.ts index 875069b2..f05ae399 100644 --- a/src/ui-commands/camera/enums.ts +++ b/src/ui-commands/camera/enums.ts @@ -1,4 +1,5 @@ export enum CameraEnum { SET_SELF_VIEW_DISABLED_ALL_DEVICES = 'SET_SELF_VIEW_DISABLED_ALL_DEVICES_COMMAND', SET_SELF_VIEW_DISABLED = 'SET_SELF_VIEW_DISABLED_COMMAND', + SET_CAMERA_FOCUS = 'SET_CAMERA_FOCUS_COMMAND', } diff --git a/src/ui-commands/camera/types.ts b/src/ui-commands/camera/types.ts index 2c130feb..15385d85 100644 --- a/src/ui-commands/camera/types.ts +++ b/src/ui-commands/camera/types.ts @@ -7,6 +7,21 @@ export interface SetSelfViewDisableCommandArguments { streamId: string; } +interface ByUserId { + userId: string; +} + +interface ByStreamId { + streamId: string; +} + +export type ObjectTo = ByUserId | ByStreamId; + +export interface SetCameraFocusCommandArguments { + focus: boolean; + webcamSelector: ObjectTo[]; +} + export interface UiCommandsCameraObject { setSelfViewDisableAllDevices: ( setSelfViewDisableAllDevicesCommandArguments: SetSelfViewDisableAllDevicesCommandArguments @@ -14,4 +29,7 @@ export interface UiCommandsCameraObject { setSelfViewDisable: ( setSelfViewDisableAllDevicesCommandArguments: SetSelfViewDisableCommandArguments ) => void; + setCameraFocus: ( + setCameraFocusCommandArguments: SetCameraFocusCommandArguments + ) => void; }