diff --git a/src/frontend/src/features/rooms/livekit/components/blur/BackgroundVirtualTrackProcessorJsWrapper.ts b/src/frontend/src/features/rooms/livekit/components/blur/BackgroundVirtualTrackProcessorJsWrapper.ts new file mode 100644 index 00000000..0a2525ad --- /dev/null +++ b/src/frontend/src/features/rooms/livekit/components/blur/BackgroundVirtualTrackProcessorJsWrapper.ts @@ -0,0 +1,61 @@ +import { ProcessorOptions, Track } from 'livekit-client' +import { + BackgroundOptions, + BackgroundProcessorInterface, + ProcessorType, +} from '.' +import { + BackgroundTransformer, + ProcessorWrapper, + VirtualBackground, +} from '@livekit/track-processors' + +export class BackgroundVirtualTrackProcessorJsWrapper + implements BackgroundProcessorInterface +{ + name = 'virtual' + + processor: ProcessorWrapper + + opts: BackgroundOptions + + constructor(opts: BackgroundOptions) { + this.processor = VirtualBackground(opts.imagePath!) + this.opts = opts + } + + async init(opts: ProcessorOptions) { + return this.processor.init(opts) + } + + async restart(opts: ProcessorOptions) { + return this.processor.restart(opts) + } + + async destroy() { + return this.processor.destroy() + } + + update(opts: BackgroundOptions): void { + this.processor.updateTransformerOptions(opts) + } + + get processedTrack() { + return this.processor.processedTrack + } + + get options() { + return (this.processor.transformer as BackgroundTransformer).options + } + + clone() { + return new BackgroundVirtualTrackProcessorJsWrapper(this.options) + } + + serialize() { + return { + type: ProcessorType.VIRTUAL, + options: this.options, + } + } +}