mirror of
https://github.com/element-hq/element-call.git
synced 2026-10-23 06:32:24 +00:00
Tidy the background effect pipeline after review
- The Vite transform wrapper takes Vite's own types, with no cast. - The pipeline's options are compared with deepCompare, not as JSON. - Renames `attached` to `enable` and shortens the pipeline's doc comment. - Drops a comment that blamed an ended track on the pipeline's queue. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
e2b89a64b9
commit
ce41fee6ff
3 files changed
+11
-21
No files matched your search
@@ -76,8 +76,6 @@ export function applyProcessor(
|
||||
}
|
||||
const track = videoTrack.mediaStreamTrack;
|
||||
videoTrack.setProcessor(processor).catch((e) => {
|
||||
// The pipeline builds one track at a time, so a track can end while its
|
||||
// build waits a turn. The camera's next track attaches it again.
|
||||
if (track.readyState === "ended")
|
||||
logger.debug("Video processor not attached: the track ended first");
|
||||
else logger.warn("Failed to attach video processor", e);
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
type SwitchBackgroundProcessorOptions,
|
||||
} from "@livekit/track-processors";
|
||||
import { logger } from "matrix-js-sdk/lib/logger";
|
||||
import { deepCompare } from "matrix-js-sdk/lib/utils";
|
||||
|
||||
import { type Behavior } from "./Behavior";
|
||||
import { type ObservableScope } from "./ObservableScope";
|
||||
@@ -23,11 +24,7 @@ export interface BackgroundEffectsOptions {
|
||||
supported: boolean;
|
||||
/** Whether blur is chosen. */
|
||||
blur$: Behavior<boolean>;
|
||||
/**
|
||||
* Shared by the pre-join preview and the call. Building or destroying it is
|
||||
* what primes it, and a primed pipeline lets its next frame through
|
||||
* untouched, so it is switched rather than rebuilt.
|
||||
*/
|
||||
/** The background processor pipeline to be switched between effects. */
|
||||
pipeline: BackgroundProcessorWrapper;
|
||||
}
|
||||
|
||||
@@ -45,9 +42,9 @@ export class BackgroundEffects {
|
||||
(previous, wanted) => {
|
||||
// Attached the first time an effect is wanted and never detached
|
||||
// after, so someone who never turns one on pays for none of it.
|
||||
const attached =
|
||||
const enable =
|
||||
previous.processor !== undefined || (supported && wanted);
|
||||
return { supported, processor: attached ? pipeline : undefined };
|
||||
return { supported, processor: enable ? pipeline : undefined };
|
||||
},
|
||||
{ supported, processor: undefined },
|
||||
),
|
||||
@@ -61,7 +58,7 @@ export class BackgroundEffects {
|
||||
map(([, blur]): SwitchBackgroundProcessorOptions =>
|
||||
blur ? { mode: "background-blur", blurRadius } : { mode: "disabled" },
|
||||
),
|
||||
distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)),
|
||||
distinctUntilChanged(deepCompare),
|
||||
scope.bind(),
|
||||
)
|
||||
.subscribe((options) => {
|
||||
|
||||
Reference in new issue
Block a user