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.21 kB
"use strict"; 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); Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const useRoomEngine = require("../../../hooks/useRoomEngine.js"); const index = require("../../../utils/common/logger/index.js"); const usePluginConfig = require("./usePluginConfig.js"); const roomEngine = useRoomEngine.default(); 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 = usePluginConfig.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) { index.default.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) { index.default.error("trtcCloud is null"); return; } trtcCloud.setPluginCallback( (pluginId, errorCode, msg) => { index.default.log( `plugin callback, pluginId:${pluginId}, errorCode:${errorCode}, msg:${msg}` ); } ); const pluginPath = usePluginConfig.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) { index.default.error("trtcCloud is null"); return; } this.plugin.disable(); trtcCloud.removePlugin(this.pluginId); this.plugin = null; } } const plugin = new BeautyPlugin(); exports.BeautyPlugin = BeautyPlugin; exports.plugin = plugin;