UNPKG

@tencentcloud/roomkit-electron-vue3

Version:

<h1 align="center"> TUIRoomKit</h1> Conference (TUIRoomKit) is a product suitable for multi-person audio and video conversation scenarios such as business meetings, webinars, and online education. By integrating this product, you can add room management,

113 lines (112 loc) 3.05 kB
var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); import useGetRoomEngine from "../../../hooks/useRoomEngine.mjs"; import logger from "../../../utils/common/logger/index.mjs"; import { getResourcePath, getPluginPath } from "./usePluginConfig.mjs"; const roomEngine = useGetRoomEngine(); class BeautyPlugin { constructor() { __publicField(this, "plugin"); __publicField(this, "pluginEnabled"); __publicField(this, "pluginId"); this.pluginEnabled = false; this.pluginId = ""; } initPlugin(licenseURL, licenseKey) { if (!this.plugin) { this.createPlugin(); } const resourcePath = getResourcePath(); if (this.plugin) { this.plugin.setParameter( JSON.stringify({ licenseURL, licenseKey, resPath: resourcePath }) ); } } unInitPlugin() { this.destroyPlugin(); } setParameter(params) { if (!this.plugin) { return; } if (!this.pluginEnabled) { this.pluginEnabled = true; this.plugin.enable(); } this.plugin.setParameter(params); } clearBeautyEffect() { if (!this.plugin) { logger.log("clearBeautyEffect failed, plugin has not init"); return; } const beautySetting = [ { category: 4, effKey: "", effValue: 0, resPath: "", bgPath: "" } ]; this.plugin.setParameter( JSON.stringify({ beautySetting }) ); this.plugin.setParameter( JSON.stringify({ control: { clearEffect: true } }) ); this.pluginEnabled = false; this.plugin.disable(); } createPlugin() { var _a; const trtcCloud = (_a = roomEngine.instance) == null ? void 0 : _a.getTRTCCloud(); if (!trtcCloud) { logger.error("trtcCloud is null"); return; } trtcCloud.setPluginCallback( (pluginId, errorCode, msg) => { logger.log( `plugin callback, pluginId:${pluginId}, errorCode:${errorCode}, msg:${msg}` ); } ); const pluginPath = getPluginPath(); const currentCamera = trtcCloud.getCurrentCameraDevice(); this.pluginId = currentCamera ? currentCamera.deviceId : ""; trtcCloud.initPluginManager({ pixelFormat: 3, bufferType: 1 }); this.plugin = trtcCloud.addPlugin({ id: this.pluginId, path: pluginPath, type: 1 }); } destroyPlugin() { var _a; if (!this.plugin) { return; } const trtcCloud = (_a = roomEngine.instance) == null ? void 0 : _a.getTRTCCloud(); if (!trtcCloud) { logger.error("trtcCloud is null"); return; } this.plugin.disable(); trtcCloud.removePlugin(this.pluginId); this.plugin = null; } } const plugin = new BeautyPlugin(); export { BeautyPlugin, plugin };