このページは現在英語版のみで提供されており、日本語版も近日中に提供される予定です。ご利用いただきありがとうございます。

TUIVideoEffectPluginManager

Introduction

TUIVideoEffectPluginManager is a video effect plugin manager that supports integration with third-party libraries to achieve personalized processing of video data, such as connecting to third-party beauty libraries.
Installation
// npm
npm i @tencentcloud/tuiroom-engine-electron@2.4.0-alpha.3 --save

// pnpm
pnpm i @tencentcloud/tuiroom-engine-electron@2.4.0-alpha.3 --save

// yarn
yarn add @tencentcloud/tuiroom-engine-electron@2.4.0-alpha.3

Example code:
import TUIRoomEngine, {
TUIVideoEffectPluginManager,
TUIVideoEffectPlugin,
TUIVideoPixelFormat
} from '@tencentcloud/tuiroom-engine-electron';

const videoEffectPluginManager: TUIVideoEffectPluginManager = TUIRoomEngine.getVideoEffectPluginManager();

videoEffectPluginManager.setVideoPluginFormat(TUIVideoPixelFormat.kVideoPixelFormat_I420);

videoEffectPluginManager.setCallback((pluginId: string, errorCode: number, errorMessage: string) => {
console.log(`plugin event - pluginId : ${pluginId}, errorCode : ${errorCode}, errorMessage : ${errorMessage}`);
});

const cameraId = ''; // Camera ID. TUIDeviceManager.getDevicesList() can get all the camera connected to your computer.
const pluginId = `${cameraId}-${new Date().getTime()}`; // ID can any string but unique between multiple plugins
const plugin: TUIVideoEffectPlugin | null = videoEffectPluginManager.addVideoPlugin({
pluginId: pluginId,
deviceId: cameraId,
path: '', // Path to the customer-developed video data preprocessing library file
});

if (plugin) {
plugin.enable(true);
plugin.setParameter('{}'); // JSON string
}

API

TRTCVideoEffectPluginManager

Video effects plugin manager
Method
Description
Set the basic parameters of the video effect plugin
Add a video effect plugin
Remove a video effect plugin
Set the callback function for the video effect plugin

TUIVideoEffectPlugin

Video effect plugin
Attribute
Type
Description
id
string
Plugin ID
deviceId
string
Camera device ID
Method
Description
enable
Enable video effect plugin
Set video effect parameter

Enumerations

Enum
Description
Video pixel format

API explaination

setVideoPluginFormat

Set video effect plugin parameter
import TUIRoomEngine, {
TUIVideoEffectPluginManager,
TUIVideoPixelFormat
} from '@tencentcloud/tuiroom-engine-electron';

const videoEffectPluginManager: TUIVideoEffectPluginManager = TUIRoomEngine.getVideoEffectPluginManager();

videoEffectPluginManager.setVideoPluginFormat(TUIVideoPixelFormat.kVideoPixelFormat_I420);
Parameters
Parameter
Type
Validation
Default value
Description
pixelFormat
-
-
Video pixel format
Return void

addVideoPlugin

import TUIRoomEngine, {
TUIVideoEffectPluginManager,
TUIVideoEffectPlugin,
TUIVideoPixelFormat
} from '@tencentcloud/tuiroom-engine-electron';

const videoEffectPluginManager: TUIVideoEffectPluginManager = TUIRoomEngine.getVideoEffectPluginManager();

videoEffectPluginManager.setVideoPluginFormat(TUIVideoPixelFormat.kVideoPixelFormat_I420);

videoEffectPluginManager.setCallback((pluginId: string, errorCode: number, errorMessage: string) => {
console.log(`plugin event, pluginId : ${pluginId}, errorCode : ${errorCode}, errorMessage : ${errorMessage}`);
});

const cameraId = ''; // Camera ID. TUIDeviceManager.getDevicesList() can get all the camera connected to your computer.
const pluginId = `${cameraId}-${new Date().getTime()}`; // ID can any string but unique between multiple plugins
const plugin: TUIVideoEffectPlugin | null = videoEffectPluginManager.addVideoPlugin({
pluginId: pluginId,
deviceId: cameraId,
path: '', // Path to the customer-developed video data preprocessing library file
});

if (plugin) {
plugin.enable(true);
plugin.setParameter('{}'); // JSON string
}
Parameters
Parameter
Type
Validation
Default value
Description
options
Record<string, string>
-
-
Video effect plugin parameters
options.pluginId
string
-
-
Video effect plugin ID
options.deviceId
string
-
-
Camera device ID
options.path
string
-
-
Path to the video effect plugin dynamic library, dll file on Windows platform, dylib file on Mac platform

removeVideoPlugin

Remove video effect plugin
import TUIRoomEngine, {
TUIVideoEffectPluginManager,
TUIVideoEffectPlugin
} from '@tencentcloud/tuiroom-engine-electron';

const videoEffectPluginManager: TUIVideoEffectPluginManager = TUIRoomEngine.getVideoEffectPluginManager();
const plugin: TUIVideoEffectPlugin;
if (plugin) {
videoEffectPluginManager.removeVideoPlugin(plugin.id, plugin.deviceId);
}
Parameters
Parameter
Type
Validation
Default value
Description
pluginId
string
-
-
Plugin ID
deviceId
string
-
-
Camera device ID
Return void

setCallback

Set the callback function for the video effect plugin
import TUIRoomEngine, {
TUIVideoEffectPluginManager,
} from '@tencentcloud/tuiroom-engine-electron';

const videoEffectPluginManager: TUIVideoEffectPluginManager = TUIRoomEngine.getVideoEffectPluginManager();
videoEffectPluginManager.setCallback((pluginId: string, errorCode: number, errorMessage: string) => {
console.log(`plugin event, pluginId : ${pluginId}, errorCode : ${errorCode}, errorMessage : ${errorMessage}`);
});
Parameters
Parameter
Type
Validation
Default value
Description
callback
(pluginId: string, errorCode: number, errorMessage: string) => void
-
-
Callback function
pluginId - Plugin ID
errorCode - Error code. 0, -1, -2, -3, -4, -5 are internally defined error codes by the SDK, other error codes are custom error codes defined by the plugin. Note: Error codes from -1000 to 1000 are reserved by the SDK, please use error codes outside this range in user-defined plugins.
0 indicates addVideoPlugin successfully
-1 Plugin library error
-2 Plugin library lacks plugin creation function
-3 Creation function execution failed
-4 Plugin initialization function execution failed
-5 Plugin resource loading function execution failed
errorMessage - Error message
Return void

enable

Enable or disable video effect plugin
Parameters
Parameter
Type
Validation
Default value
Description
flag
boolean
-
-
Whether to enable
Return void

setParameter

Set video effect parameter
import TUIRoomEngine, {
TUIVideoEffectPluginManager,
TUIVideoEffectPlugin,
TUIVideoPixelFormat
} from '@tencentcloud/tuiroom-engine-electron';

const videoEffectPluginManager: TUIVideoEffectPluginManager = TUIRoomEngine.getVideoEffectPluginManager();

videoEffectPluginManager.setVideoPluginFormat(TUIVideoPixelFormat.kVideoPixelFormat_I420);

videoEffectPluginManager.setCallback((pluginId: string, errorCode: number, errorMessage: string) => {
console.log(`plugin event, pluginId : ${pluginId}, errorCode : ${errorCode}, errorMessage : ${errorMessage}`);
});

const cameraId = ''; // Camera ID. TUIDeviceManager.getDevicesList() can get all the camera connected to your computer.
const pluginId = `${cameraId}-${new Date().getTime()}`; // ID can any string but unique between multiple plugins
const plugin: TUIVideoEffectPlugin | null = videoEffectPluginManager.addVideoPlugin({
pluginId: pluginId,
deviceId: cameraId,
path: '', // Path to the customer-developed video data preprocessing library file
});

if (plugin) {
plugin.enable(true);
plugin.setParameter('{}'); // JSON string
}
Parameters
Parameter
Type
Validation
Default value
Description
param
string
Supports JSON.parse() deserialization
-
JSON string, refer to the dynamic library passed to the video effect processing
Return void

Enumerations explaination

TUIVideoPixelFormat

Video data format
Enumeration item
Type
Description
TUIVideoPixelFormat_I420
number
I420
TUIVideoPixelFormat_BGRA32
number
BGRA32
TUIVideoPixelFormat_RGBA32
number
RGBA32