From d45880ab5c8041077a08d24ce8bededaa6ab67b7 Mon Sep 17 00:00:00 2001 From: Nathan Vasse Date: Mon, 20 Jan 2025 17:59:17 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F(front)=20add=20clone=20metho?= =?UTF-8?q?d=20to=20processors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to make new processor instance between pre join and room in order to apply effects. --- .../components/blur/BackgroundBlurCustomProcessor.ts | 4 ++++ .../blur/BackgroundBlurTrackProcessorJsWrapper.ts | 9 +++++++++ .../src/features/rooms/livekit/components/blur/index.ts | 1 + 3 files changed, 14 insertions(+) diff --git a/src/frontend/src/features/rooms/livekit/components/blur/BackgroundBlurCustomProcessor.ts b/src/frontend/src/features/rooms/livekit/components/blur/BackgroundBlurCustomProcessor.ts index eba10993..2c907e17 100644 --- a/src/frontend/src/features/rooms/livekit/components/blur/BackgroundBlurCustomProcessor.ts +++ b/src/frontend/src/features/rooms/livekit/components/blur/BackgroundBlurCustomProcessor.ts @@ -278,4 +278,8 @@ export class BackgroundBlurCustomProcessor this.timerWorker?.terminate() this.imageSegmenter?.close() } + + clone() { + return new BackgroundBlurCustomProcessor(this.options) + } } diff --git a/src/frontend/src/features/rooms/livekit/components/blur/BackgroundBlurTrackProcessorJsWrapper.ts b/src/frontend/src/features/rooms/livekit/components/blur/BackgroundBlurTrackProcessorJsWrapper.ts index e409074c..a2420e7c 100644 --- a/src/frontend/src/features/rooms/livekit/components/blur/BackgroundBlurTrackProcessorJsWrapper.ts +++ b/src/frontend/src/features/rooms/livekit/components/blur/BackgroundBlurTrackProcessorJsWrapper.ts @@ -18,8 +18,11 @@ export class BackgroundBlurTrackProcessorJsWrapper processor: ProcessorWrapper + opts: BackgroundOptions + constructor(opts: BackgroundOptions) { this.processor = BackgroundBlur(opts.blurRadius) + this.opts = opts } async init(opts: ProcessorOptions) { @@ -45,4 +48,10 @@ export class BackgroundBlurTrackProcessorJsWrapper get options() { return (this.processor.transformer as BackgroundTransformer).options } + + clone() { + return new BackgroundBlurTrackProcessorJsWrapper({ + blurRadius: this.options!.blurRadius, + }) + } } diff --git a/src/frontend/src/features/rooms/livekit/components/blur/index.ts b/src/frontend/src/features/rooms/livekit/components/blur/index.ts index 7ab10dbb..eae30b65 100644 --- a/src/frontend/src/features/rooms/livekit/components/blur/index.ts +++ b/src/frontend/src/features/rooms/livekit/components/blur/index.ts @@ -11,6 +11,7 @@ export interface BackgroundBlurProcessorInterface extends TrackProcessor { update(opts: BackgroundOptions): void options: BackgroundOptions + clone(): BackgroundBlurProcessorInterface } export class BackgroundBlurFactory {