Skip to content

Commit

Permalink
fix: use canvasstream
Browse files Browse the repository at this point in the history
  • Loading branch information
KaustubhKumar05 committed May 22, 2024
1 parent e743e5b commit ef67d76
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/hms-virtual-background/src/HMSEffectsPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export class HMSEffectsPlugin implements HMSMediaStreamPlugin {
this.effects.setBackground(this.background);
});
}

getBlurAmount() {
return this.blurAmount;
}
Expand All @@ -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() {
Expand Down

0 comments on commit ef67d76

Please sign in to comment.