Support Virtual Background image

pull/713/head
pabloFuente 2022-04-06 19:54:31 +02:00
parent 19f4f607b1
commit 41f53b9895
3 changed files with 18 additions and 5 deletions

View File

@ -336,7 +336,7 @@ export class Stream {
} }
} }
if (type === 'VB:blur') { if (type.startsWith('VB:')) {
// Client filters // Client filters
@ -353,7 +353,7 @@ export class Stream {
return reject(new OpenViduError(OpenViduErrorName.STREAM_MANAGER_HAS_NO_VIDEO_ELEMENT, 'The StreamManager requires some video element to be attached to it in order to apply a Virtual Background filter')); return reject(new OpenViduError(OpenViduErrorName.STREAM_MANAGER_HAS_NO_VIDEO_ELEMENT, 'The StreamManager requires some video element to be attached to it in order to apply a Virtual Background filter'));
} }
logger.info('Applying client filter to stream ' + this.streamId); logger.info('Applying Virtual Background to stream ' + this.streamId);
const afterScriptLoaded = async () => { const afterScriptLoaded = async () => {
try { try {
@ -382,7 +382,20 @@ export class Stream {
const optionsVB = options as VirtualBackgroundOptions; const optionsVB = options as VirtualBackgroundOptions;
const response: { video: HTMLVideoElement, canvas: HTMLCanvasElement } = await VB.backgroundBlur(optionsVB); let response: { video: HTMLVideoElement, canvas: HTMLCanvasElement };
switch (type) {
case 'VB:blur': {
response = await VB.backgroundBlur(optionsVB);
break;
}
case 'VB:image': {
response = await VB.backgroundImage(optionsVB);
break;
}
default:
throw new Error('Unknown Virtual Background filter: ' + type);
}
this.virtualBackgroundSinkElements = { VB, ...response }; this.virtualBackgroundSinkElements = { VB, ...response };
videoClone.style.display = 'none'; videoClone.style.display = 'none';

View File

@ -18,7 +18,7 @@
import { VirtualBackgroundOptions } from './VirtualBackgroundOptions'; import { VirtualBackgroundOptions } from './VirtualBackgroundOptions';
/** /**
* See [[Stream.applyFilter]] * Options to apply to a Virtual Background Image filter. See [[Stream.applyFilter]]
*/ */
export interface VirtualBackgroundImageOptions extends VirtualBackgroundOptions { export interface VirtualBackgroundImageOptions extends VirtualBackgroundOptions {
/** /**

View File

@ -16,7 +16,7 @@
*/ */
/** /**
* See [[Stream.applyFilter]] * Options to apply to a Virtual Background filter. See [[Stream.applyFilter]]
*/ */
export interface VirtualBackgroundOptions { export interface VirtualBackgroundOptions {
/** /**