import { BehaviorSubject, Subject, Subscription } from 'rxjs'; import { RBEvent } from '../../models/event.model'; import { Service } from '../../services/service'; export declare const VIRTUAL_BACKGROUND_SVC: string; /** * @module VirtualBackground * This service manages the statistics of the virtual background */ export declare const glsl: (template: { raw: readonly string[] | ArrayLike; }, ...substitutions: any[]) => string; export declare const segmentationDimensions: { model96: { height: number; width: number; }; model144: { height: number; width: number; }; }; export declare const VIRTUAL_BACKGROUND_TYPE: { IMAGE: string; BLUR: string; BLUR_PLUS: string; NONE: string; VIDEO: string; }; export interface Dimensions { height: number; width: number; } export interface Options { backgroundType: string; imgBg?: string; stream?: MediaStream; segmentationDimensions?: Dimensions; } export interface IVideoPipeline { init(): void; render(): void; cleanUp(): void; updatePostProcessingConfig(): void; } /** * @eventProperty */ export declare enum VirtualBackgroundServiceEvents { /** * @eventProperty * This `RBEvent` is sent when the virtuallBackgroundService stream is updated */ UPDATE_STREAM = "UPDATE_STREAM", /** * @eventProperty * This `RBEvent` is sent when the virtuallBackgroundService mirror style is updated */ UPDATE_STREAM_MIRROR = "UPDATE_STREAM_MIRROR" } export interface VirtualBackgroundService { /** * Subscribe to updates from the service (all events are of RBEvent type * @param handler - The call-back function that will be subscribed to the RxJS subject * @param eventNames - Array of event to listen */ start(): Promise; stop(): Promise; reconnect(): Promise; subscribe(handler: (event: RBEvent) => any, eventNames?: VirtualBackgroundServiceEvents | VirtualBackgroundServiceEvents[]): Subscription; startProcessStream(stream: MediaStream, serviceName?: string): Promise; stopProcessStream(): Promise; setBackgroundMode(mode: string, url?: string, stream?: MediaStream): Promise; setVideoAppearance(rect: number[]): any; getBackgroundMode(): any; setMirror(mirror: boolean): void; getMirror(): boolean; setFramerate(framerate: number): void; putAdminBackgroundImage(backgroundCompany: any): Promise; deleteAdminBackgroundImage(backgroundIdAdmin: string): Promise; putPersonnalBackgroundImage(backgroundUser: any, loadBgUrl: string): Promise; deletePersonnalBackgroundImage(backgroundIdUser: string): Promise; authorized(): boolean; backgroundImages: BehaviorSubject; loadBg: BehaviorSubject; } /** @internal */ export declare class VirtualBackgroundServiceRB extends Service implements VirtualBackgroundService { private settingsService; private profileService; private logger; private contactService; private authService; private errorHelperService; private xmppService; private videoPipeline; statsEnabledFlag: boolean; private statsInterval; private started; private stream; private modifiedStream; options: Options; segmentationPixelCount: number; tflite: any; backgroundImages: BehaviorSubject; loadBg: BehaviorSubject; gl: any; segmentationMaskCanvas: HTMLCanvasElement; private isStreamMirrored; simdSupported: boolean; segmentationTexture: WebGLTexture; personMaskTexture: WebGLTexture; private xmppSubscription; outputCanvasElement: HTMLCanvasElement | null; videoElement: HTMLVideoElement | null; testVideo: HTMLVideoElement | null; ctx: any; maskFrameTimerWorker: Worker; virtualImage: CanvasImageSource; virtualVideo: CanvasImageSource; rxSubject: Subject; texture: any; vertexShader: WebGLShader; outputMemoryOffset: number; webglFlag: boolean; webglAllowed: boolean; sigmaColor: any; sigmaSpace: any; coverageMax: any; coverageMin: any; lightWrapping: any; blendMode: any; private models; private settings; private tasksCanvas; private webglSubscription; static getInstance(): VirtualBackgroundServiceRB; static build(): VirtualBackgroundServiceRB; private constructor(); authorized(): boolean; subscribe(handler: (event: RBEvent) => any, eventNames?: VirtualBackgroundServiceEvents | VirtualBackgroundServiceEvents[]): Subscription; /****************************************************************************/ /** SERVICE LIFECYCLE */ /****************************************************************************/ /** * This async method has to be call to start the virtual Background Service */ start(): Promise; /** * This async method has to be call to stop the virtual Background Service */ stop(): Promise; /** * This async method has to be call to reconnect the virtual Background Service */ reconnect(): Promise; setVideoAppearance(_rect: number[]): void; /** * XMPP room event handler * @param stanza - the xmpp stanza event handler */ private onXmppEvent; /****************************************************************************/ /** PUBLIC STUFF */ /****************************************************************************/ /** * Start the process stream * @param stream - The MediaStream that we will process * @param serviceName - The name of service that calls the method (optional, for debug purpose) */ startProcessStream(stream: MediaStream, serviceName?: string): Promise; /** * Stop the effect of virtual Background */ stopProcessStream(): Promise; /** * Set the type and url of the virtual background * @param type - The type of virtual Background ('none", 'image', 'blur', 'blur-plus', 'video') * @param url -The url of virtual Background */ setBackgroundMode(type: string, url?: string, stream?: MediaStream): Promise; /** * Get the type and url od the virtual background */ getBackgroundMode(): any; /** * Set the stream in mirror mode or not * @param mirror - True if the stream is in mirror mode */ setMirror(mirror: boolean): void; /** * Return true if the stream is in mirror mode */ getMirror(): boolean; /** * Return true if the calculation of stats is activated */ enableStats(enabled: boolean): void; setFramerate(framerate: number): void; /****************************************************************************/ /** PRIVATE STUFF */ /****************************************************************************/ private webglAvailable; /** * Start the effect of Virtual Background * @returns {MediaStream} return a MediaStream with a AudioTrack */ private startEffect; /** * @function stopEffect * @instance * @private * @async * @description Stop the effect of Virtual Background */ private stopEffect; /** * @function setInputStream * @instance * @private * @async * @param {MediaStream} stream The MediaStream that we will process * @description Initialize the stream and the virtual background * @returns {Promise} return a promise of the modified MediaStream */ private setInputStream; /** * @function initVirtualBackground * @instance * @private * @async * @description initialize the virtual background according to the supported model */ private initVirtualBackground; /** * @function onMaskFrameTimer * @instance * @private * @param {any} response response * @description calls the renderMask function if the id is the expected one */ private onMaskFrameTimer; /** * @function wasmAvailable * @instance * @private * @returns {boolean} return true if webassembly is available */ private wasmAvailable; /** * @function simdAvailable * @instance * @private * @returns {boolean} return true if simd is available */ private simdAvailable; /** * @function render * @private * @async * @description calls the render function of canvas2D or Webgl2 to create the virtual background */ private render; /** * @function cleanUp * @private * @description calls the cleanUp function of the used context */ private cleanUp; /** * @function getBackgrounds * @instance * @private * @async * @description Asynchronous method to get the user's Background Images * @returns {Promise} List of the user's virtual Background */ private getBackgrounds; /** * Asynchronous method to add user's virtual background on server * @param backgroundUser - the background to add * @param loadBgUrl - the local path of the background to add */ putPersonnalBackgroundImage(backgroundUser: any, loadBgUrl: string): Promise; /** * Asynchronous method to delete user's virtual background on server * @param backgroundIdUser - the id's background to delete */ deletePersonnalBackgroundImage(backgroundIdUser: string): Promise; /****************************************************************************/ /** ADMIN */ /****************************************************************************/ /** * @function putAdminBackgroundImage * @instance * @public * @async * @description Asynchronous method to add company's virtual background on server * @param {any} backgroundCompany the background to add * @returns {void} Returns the server response */ putAdminBackgroundImage(backgroundCompany: any): Promise; /** * @function deleteAdminBackgroundImage * @instance * @public * @async * @description Asynchronous method to delete user's virtual background on server * @param {string} backgroundIdAdmin the id's background to delete */ deleteAdminBackgroundImage(backgroundIdAdmin: string): Promise; setSetting(key: string, value: string): void; getSetting(key: string): string; setPostProcessingValue(): void; } //# sourceMappingURL=virtualBackground.service.d.ts.map