working version

This commit is contained in:
Timo
2024-12-19 17:39:34 +01:00
parent 7c985b0d9c
commit e0f4bf8eab
2 changed files with 18 additions and 7 deletions

View File

@@ -6,8 +6,9 @@ Please see LICENSE in the repository root for full details.
*/ */
import { import {
BackgroundBlur as backgroundBlur,
type ProcessorWrapper,
type BackgroundOptions, type BackgroundOptions,
ProcessorWrapper,
} from "@livekit/track-processors"; } from "@livekit/track-processors";
import { import {
createContext, createContext,
@@ -25,7 +26,6 @@ import {
backgroundBlur as backgroundBlurSettings, backgroundBlur as backgroundBlurSettings,
useSetting, useSetting,
} from "../settings/settings"; } from "../settings/settings";
import { BlurBackgroundTransformer } from "./BlurBackgroundTransformer";
type ProcessorState = { type ProcessorState = {
supported: boolean | undefined; supported: boolean | undefined;
@@ -89,10 +89,15 @@ export const ProcessorProvider: FC<Props> = ({ children }) => {
if (!shouldCheckSupport) return; if (!shouldCheckSupport) return;
try { try {
if (!blur.current) { if (!blur.current) {
blur.current = new ProcessorWrapper( // TODO: move to our own local version of the transformer.
new BlurBackgroundTransformer({ blurRadius: 15 }), // Currently this is broken: error when trying to pipe IndexSizeError: Failed to construct 'ImageData': The source width is zero or not a number.
"background-blur", // blur.current = new ProcessorWrapper(
); // new BlurBackgroundTransformer({}),
// "background-blur",
// );
// eslint-disable-next-line new-cap
blur.current = backgroundBlur();
} }
setProcessorState({ setProcessorState({
checkSupported, checkSupported,

View File

@@ -134,8 +134,14 @@ export function useLiveKit(
Array.from(room.localParticipant.videoTrackPublications.values()).find( Array.from(room.localParticipant.videoTrackPublications.values()).find(
(v) => v.source === Track.Source.Camera, (v) => v.source === Track.Source.Camera,
)?.track as LocalVideoTrack | null, )?.track as LocalVideoTrack | null,
[room.localParticipant.videoTrackPublications], [
room.localParticipant.videoTrackPublications,
// We need to update on map changes
// eslint-disable-next-line react-hooks/exhaustive-deps
room.localParticipant.videoTrackPublications.keys(),
],
); );
useTrackProcessorSync(videoTrack); useTrackProcessorSync(videoTrack);
const connectionState = useECConnectionState( const connectionState = useECConnectionState(