async function initializeBackgroundBlur()

in src/providers/BackgroundBlurProvider/index.tsx [85:114]


  async function initializeBackgroundBlur(): Promise<BackgroundBlurProcessor | undefined>{
    console.log('Initializing background blur processor with ', spec, options);

    try {
      const createdProcessor = await BackgroundBlurVideoFrameProcessor.create(
        spec,
        options
      );
      // BackgroundBlurVideoFrameProcessor.create will return a NoOpVideoFrameProcessor
      // in the case that BackgroundBlurVideoFrameProcessor.isSupported() returns false.
      // BackgroundBlurVideoFrameProcessor.create() can also throw an error in case loading
      // the assets are not fetched successfully.
      if (createdProcessor instanceof NoOpVideoFrameProcessor) {
        console.warn(`Initialized NoOpVideoFrameProcessor.`);
        setProcessor(undefined);
        setIsBackgroundBlurSupported(false);
        return undefined;
      } else {
        console.log(`Initialized background blur processor: ${JSON.stringify(createdProcessor)}`);
        setProcessor(createdProcessor);
        setIsBackgroundBlurSupported(true);
        return createdProcessor;
      }
    } catch (error) {
      console.error(`Error creating a background blur video frame processor device`, error);
      setProcessor(undefined);
      setIsBackgroundBlurSupported(false);
      return undefined;
    }
  }