Skip to content

Commit 02ce1f7

Browse files
committed
Document the background transformer a bit better
1 parent e88e0b1 commit 02ce1f7

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/livekit/BlurBackgroundTransformer.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,16 @@ interface WasmFileset {
2121
wasmBinaryPath: string;
2222
}
2323

24-
// n.b. this only includes the SIMD versions of the WASM files which have good support:
25-
// https://caniuse.com/?search=simd
24+
// The MediaPipe package, by default, ships some alternative versions of the
25+
// WASM files which avoid SIMD for compatibility with older browsers. But SIMD
26+
// in WASM is actually fine by our support policy, so we include just the SIMD
27+
// versions.
28+
// It's really not ideal that we have to reference these internal files from
29+
// MediaPipe and depend on node_modules having this specific structure. It's
30+
// easy to see this breaking if our dependencies changed and MediaPipe were
31+
// no longer hoisted, or if we switched to another dependency loader such as
32+
// Yarn PnP.
33+
// https://github.com/google-ai-edge/mediapipe/issues/5961
2634
const wasmFileset: WasmFileset = {
2735
wasmLoaderPath: new URL(
2836
"../../node_modules/@mediapipe/tasks-vision/wasm/vision_wasm_internal.js",
@@ -34,12 +42,20 @@ const wasmFileset: WasmFileset = {
3442
).href,
3543
};
3644

45+
/**
46+
* Track processor that applies effects such as blurring to a user's background.
47+
*
48+
* This is just like LiveKit's prebuilt BackgroundTransformer except that it
49+
* loads the segmentation models from our own bundle rather than as an external
50+
* resource fetched from the public internet.
51+
*/
3752
export class BlurBackgroundTransformer extends BackgroundTransformer {
3853
public async init({
3954
outputCanvas,
4055
inputElement: inputVideo,
4156
}: VideoTransformerInitOptions): Promise<void> {
42-
// call super.super.init()
57+
// Call super.super.init() since we're totally replacing the init method of
58+
// BackgroundTransformer here, rather than extending it
4359
await VideoTransformer.prototype.init.call(this, {
4460
outputCanvas,
4561
inputElement: inputVideo,

0 commit comments

Comments
 (0)