From ef67d76b0f66179c1542635817e6645f34c6669b Mon Sep 17 00:00:00 2001 From: KaustubhKumar05 Date: Wed, 22 May 2024 16:53:53 +0530 Subject: [PATCH] fix: use canvasstream --- packages/hms-virtual-background/src/HMSEffectsPlugin.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/hms-virtual-background/src/HMSEffectsPlugin.ts b/packages/hms-virtual-background/src/HMSEffectsPlugin.ts index 846033dd5d..b7231ce660 100644 --- a/packages/hms-virtual-background/src/HMSEffectsPlugin.ts +++ b/packages/hms-virtual-background/src/HMSEffectsPlugin.ts @@ -114,6 +114,7 @@ export class HMSEffectsPlugin implements HMSMediaStreamPlugin { this.effects.setBackground(this.background); }); } + getBlurAmount() { return this.blurAmount; } @@ -138,9 +139,13 @@ export class HMSEffectsPlugin implements HMSMediaStreamPlugin { } }; this.effects.clear(); + const { height, width } = stream.getVideoTracks()[0].getSettings(); + const canvas = document.createElement('canvas'); + canvas.width = width!; + canvas.height = height!; this.effects.useStream(stream); - // getStream potentially returns null - return this.effects.getStream() || stream; + this.effects.toCanvas(canvas); + return canvas.captureStream(30) || stream; } stop() {