Skip to content

armgit / meet

Public Imported from GitHub
0

Open source video conferencing app powered by LiveKit. Built with Django and React.

✨(front) add BackgroundVirtualTrackProcessorJsWrapper

Nathan Vasse465bf293f0db
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<BackgroundOptions>
+
+ opts: BackgroundOptions
+
+ constructor(opts: BackgroundOptions) {
+ this.processor = VirtualBackground(opts.imagePath!)
+ this.opts = opts
+ }
+
+ async init(opts: ProcessorOptions<Track.Kind>) {
+ return this.processor.init(opts)
+ }
+
+ async restart(opts: ProcessorOptions<Track.Kind>) {
+ 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,
+ }
+ }
+}