@cloudroom/electron-rtcsdk
Version:
这是一款在线音视频SDK插件,您可以从README.md中获取演示demo
963 lines (950 loc) • 29.1 kB
JavaScript
const { EventEmitter } = require('events');
const { version } = require('./package.json');
const VideoUI = require('./videoUI');
let RTCElectronSDK = "";
let os = require("os");
if (os.platform() === "win32") {
if (process.arch === "x64") {
RTCElectronSDK = "./win/x86_64/RTC_Electron_SDK";
} else {
RTCElectronSDK = "./win/x86/RTC_Electron_SDK";
}
} else if (os.platform() === "darwin") {
RTCElectronSDK = "./mac/x86_64/RTC_Electron_SDK";
} else if (os.platform() == "linux") {
if (process.arch == "x64") {
RTCElectronSDK = "./linux/x86_64/RTC_Electron_SDK";
} else if (process.arch == "arm64" || process.arch == "aarch64") {
RTCElectronSDK = "./linux/aarch64/RTC_Electron_SDK";
} else if (process.arch == "armv7l" || process.arch == "arm") {
RTCElectronSDK = "./linux/armv7l/RTC_Electron_SDK";
} else {
console.log("arch: " + process.arch);
throw "Platform not supported";
}
} else {
throw "Platform not supported";
}
const RTCSDK = require(RTCElectronSDK);
class CRVideoSDK extends EventEmitter {
constructor() {
super();
this.sdk_engine = null;
this._markList = null;
this.myUserID = null;
}
//初始化
init({
path,
enableHardwareAcceleration = false,
jsonParam = ''
} = {}) {
try {
console.log('init')
const sdk_engine = new RTCSDK.CRVideoSDK_Node(path, jsonParam);
this.sdk_engine = sdk_engine;
console.log("enableHardwareAcceleration", enableHardwareAcceleration);
this.hardwareAcceleration = enableHardwareAcceleration;
this.videoUIList = new Map();
this.writeLog(1, `[Electron] init: ${JSON.stringify({
enableHardwareAcceleration,
version
})}`);
sdk_engine.onDispatch(function (msgSN) {
sdk_engine.dealCRMsg(msgSN);
});
this._initEventHandler();
return 0;
} catch (error) {
console.error(error)
return 1;
}
}
uninit() {
console.log('uninit')
this.sdk_engine.destroy();
this.sdk_engine = null;
}
// 获取SDK版本号
getVersion() {
return version;
}
/**
* 创建视图组件
* @param {DOM} view div元素
* @param {Object} callBackObj 回调函数集合
* @returns 视图对象
*/
createVideoUI(view, callBackObj) {
if (!view) return;
const videoUI = new VideoUI(this, view, callBackObj);
this.videoUIList.set(videoUI.id, videoUI);
return videoUI;
}
/**
* 收到流数据
* @param {string} id view唯一标识id
* @param {Object} frame 流数据
*/
_onRenderFrameReceived(id, frame) {
let videoUI = this._getVideoUI(id);
videoUI && videoUI._render(frame);
}
/**
* @private
*/
_removeRender(id) {
if (!this.videoUIList.has(id)) {
return;
}
const videoUI = this.videoUIList.get(id);
this.videoUIList.delete(videoUI.id);
}
/**
* @private
*/
_getVideoUI(id) {
return this.videoUIList.get(id);
}
//test
onAudioFrameObserver() {
return this.sdk_engine.onAudioFrameObserver();
}
//test
setNetworkProxy(proxy) {
this.sdk_engine.setNetworkProxy(proxy);
}
//登录
login(loginDat, cookie = '') {
this.myUserID = loginDat._userID;
return this.sdk_engine.login(loginDat, cookie);
}
//注销
logout() {
return this.sdk_engine.logout();
}
//更新Token, 防止token因过期而掉线。
updateToken(token) {
this.sdk_engine.updateToken(token);
}
//test
getUserAuthErrCode() {
return this.sdk_engine.getUserAuthErrCode();
}
//test
getUserAuthErrDesc(DNDStatus, cookie = "") {
return this.sdk_engine.getUserAuthErrDesc(DNDStatus, cookie);
}
//test
setDNDStatus(DNDStatus, cookie = "") {
this.sdk_engine.setDNDStatus(DNDStatus, cookie);
}
//获取本AppID下的所有登录用户的状态信息
getUserStatus(cookie = "") {
this.sdk_engine.getUserStatus(cookie);
}
//获取本AppID下指定用户的在线状态
getOneUserStatus(userId, cookie = "") {
this.sdk_engine.getOneUserStatus(userId, cookie);
}
//开启AppID下的用户登录状态消息推送
startUserStatusNotify(cookie = "") {
this.sdk_engine.startUserStatusNotify(cookie);
}
//关闭appID下的用户在线状态消息推送
stopUserStatusNotify(cookie = "") {
this.sdk_engine.stopUserStatusNotify(cookie);
}
//创建房间
createMeeting(cookie = '') {
return this.sdk_engine.createMeeting(null, cookie);
}
//test
destroyMeeting(meetID, cookie = "") {
this.sdk_engine.destroyMeeting(meetID, cookie);
}
//test
sendCmd(targetUserId, data, cookie = "") {
return this.sdk_engine.sendCmd(targetUserId, data, cookie);
}
//test
sendBuffer(targetUserId, data, cookie = "") {
return this.sdk_engine.sendBuffer(targetUserId, data, cookie);
}
//test
sendFile(targetUserId, fileName, cookie = "") {
return this.sdk_engine.sendFile(targetUserId, fileName, cookie);
}
//test
cancelSend(sendID, cookie = "") {
this.sdk_engine.cancelSend(sendID, cookie);
}
//test
writeLog(level, log) {
this.sdk_engine.writeLog(level, log);
}
//进入会议
enterMeeting(meetId, nickName = '') {
this._markList = null;
return this.sdk_engine.enterMeeting(meetId, nickName);
}
//退出会议
exitMeeting() {
return this.sdk_engine.exitMeeting();
}
//test
getNetState() {
return this.sdk_engine.getNetState();
}
//检查用户是否在房间中
isUserInMeeting(userId) {
return this.sdk_engine.isUserInMeeting(userId);
}
//获取房间中所有所有成员信息
getAllMembers() {
return this.sdk_engine.getAllMembers();
}
//获取房间中指定成员信息
getMemberInfo(userId) {
return this.sdk_engine.getMemberInfo(userId);
}
//test
setNickName(userId, nickName) {
this.sdk_engine.setNickName(userId, nickName);
}
//踢出成员
kickout(userId) {
this.sdk_engine.kickout(userId);
}
//发送房间内群消息
sendMeetingCustomMsg(msg, cookie) {
this.sdk_engine.sendMeetingCustomMsg(msg, cookie);
}
//获取系统麦克风设备列表
getAudioMics() {
return this.sdk_engine.getAudioMics();
}
//获取系统扬声器设备
getAudioSpks() {
return this.sdk_engine.getAudioSpks();
}
//获取当前音频配置
getAudioCfg() {
return this.sdk_engine.getAudioCfg();
}
//设置音频参数
setAudioCfg(config) {
this.sdk_engine.setAudioCfg(config);
}
//设置麦克风音量
setMicVolume(val) {
this.sdk_engine.setMicVolume(val);
}
//获取麦克风音量
getMicVolume() {
return this.sdk_engine.getMicVolume();
}
//设置扬声器音量
setSpkVolume(val) {
this.sdk_engine.setSpkVolume(val);
}
//获取扬声器音量
getSpkVolume() {
return this.sdk_engine.getSpkVolume();
}
//设置扬声器静音
setSpeakerMute(bool) {
this.sdk_engine.setSpeakerMute(bool);
}
//获取扬声器静音状态
getSpeakerMute() {
return this.sdk_engine.getSpeakerMute();
}
//test
getLocMicDevEnergy() {
return this.sdk_engine.getLocMicDevEnergy();
}
//test
getUserMicEnergy(userId) {
return this.sdk_engine.getUserMicEnergy(userId);
}
//打开指定人的麦克风
openMic(userId) {
this.sdk_engine.openMic(userId);
}
//关闭指定人的麦克风
closeMic(userId) {
this.sdk_engine.closeMic(userId);
}
//test
getMicStatus(userId) {
return this.sdk_engine.getMicStatus(userId);
}
//test
closeAllMic() {
this.sdk_engine.closeAllMic();
}
//开始本地语音环回测试
startEchoTest() {
return this.sdk_engine.startEchoTest();
}
//停止本地语音环回测试
stopEchoTest() {
this.sdk_engine.stopEchoTest();
}
//获取本地语音环回测试状态
isEchoTesting() {
return this.sdk_engine.isEchoTesting();
}
//设置目标用户变声
setVoiceChange(userId, type) {
this.sdk_engine.setVoiceChange(userId, type);
}
//获取目标用户变声类型
getVoiceChangeType(userId) {
return this.sdk_engine.getVoiceChangeType(userId);
}
//test
setCustomAudioCapture(enable, param) {
return this.sdk_engine.setCustomAudioCapture(enable, param);
}
//test
pushCustomAudioDat(frm) {
return this.sdk_engine.pushCustomAudioDat(frm);
}
//test
setCustomAudioPlayback(enable, param) {
return this.sdk_engine.setCustomAudioPlayback(enable, param);
}
//test
pullCustomAudioDat(frm) {
return this.sdk_engine.pullCustomAudioDat(frm);
}
//获取成员的摄像头列表
getAllVideoInfo(userId) {
return this.sdk_engine.getAllVideoInfo(userId);
}
//设置本地视频全局配置
setVideoCfg(config) {
return this.sdk_engine.setVideoCfg(config);
}
//获取本地视频全局配置
getVideoCfg() {
return this.sdk_engine.getVideoCfg();
}
//配置本地默认摄像头
setDefaultVideo(camId) {
return this.sdk_engine.setDefaultVideo(camId);
}
//获取本地或他人的默认摄像头
getDefaultVideo(userId) {
return this.sdk_engine.getDefaultVideo(userId);
}
//配置本地多摄像头
setMutiVideos(moreVideoIDs) {
this.sdk_engine.setMutiVideos(moreVideoIDs);
}
//获取本地的或他人的多摄像头
getMutiVideos(userId) {
return this.sdk_engine.getMutiVideos(userId);
}
//设置本地指定设备私有配置,没有配置时,使用全局配置;
setLocVideoAttributes(videoID, jsonAttributes) {
return this.sdk_engine.setLocVideoAttributes(videoID, JSON.stringify(jsonAttributes));
}
//获取本地指定设备私有配置
getLocVideoAttributes(videoID) {
return JSON.parse(this.sdk_engine.getLocVideoAttributes(videoID));
}
// 打开指定人的摄像头
openVideo(userId) {
this.sdk_engine.openVideo(userId);
}
//关闭指定人的摄像头
closeVideo(userId) {
this.sdk_engine.closeVideo(userId);
}
//test
getVideoStatus(userId) {
return this.sdk_engine.getVideoStatus(userId);
}
//设置本地视频效果
setVideoEffects(efs) {
this.sdk_engine.setVideoEffects(efs);
}
//获取本地视频效果配置
getVideoEffects() {
return this.sdk_engine.getVideoEffects();
}
//添加网络摄像头
addIPCam(url, jsonParam) {
return this.sdk_engine.addIPCam(url, jsonParam);
}
//删除网络摄像头
delIPCam(videoID) {
this.sdk_engine.delIPCam(videoID);
}
//添加桌面摄像头
createScreenCamDev(camName, monitor) {
return this.sdk_engine.createScreenCamDev(camName, monitor);
}
//test
updateScreenCamDev(videoID, monitor) {
return this.sdk_engine.updateScreenCamDev(videoID, monitor);
}
//删除桌面摄像头
destroyScreenCamDev(videoID) {
this.sdk_engine.destroyScreenCamDev(videoID);
}
//添加自定义摄像头
createCustomVideoDev(camName, pixFmt, width, height, extParams) {
return this.sdk_engine.createCustomVideoDev(camName, pixFmt, width, height, extParams);
}
//删除自定义摄像头
destroyCustomVideoDev(videoID) {
this.sdk_engine.destroyCustomVideoDev(videoID);
}
//送入自定义摄像头数据
inputCustomVideoDat(videoID, frame) {
return this.sdk_engine.inputCustomVideoDat(videoID, frame);
}
//开启美颜功能
startBeauty(params) {
return this.sdk_engine.startBeauty(JSON.stringify(params));
}
//停止美颜功能
stopBeauty() {
this.sdk_engine.stopBeauty();
}
//获取美颜功能是否开启
isBeautyStarted() {
return this.sdk_engine.isBeautyStarted();
}
//更新美颜参数
updateBeautyParams(params) {
return this.sdk_engine.updateBeautyParams(JSON.stringify(params));
}
//获取当前美颜参数
getBeautyParams() {
const beautyParams = this.sdk_engine.getBeautyParams()
if (!beautyParams) return null;
return JSON.parse(beautyParams);
}
//开启虚拟背景
startVirtualBackground(params) {
return this.sdk_engine.startVirtualBackground(JSON.stringify(params));
}
//停止虚拟背景
stopVirtualBackground() {
this.sdk_engine.stopVirtualBackground();
}
//获取虚拟背景是否开启
isVirtualBackgroundStarted() {
return this.sdk_engine.isVirtualBackgroundStarted();
}
//更新虚拟背景参数
updateVirtualBackgroundParams() {
return JSON.stringify(this.sdk_engine.updateVirtualBackgroundParams());
}
//获取当前虚拟背景参数
getVirtualBackgroundParams() {
return JSON.parse(this.sdk_engine.getVirtualBackgroundParams());
}
/**
* 获取屏幕采集源列表
* @param {Object} thumbSize 采集源的缩略图的目标尺寸(宽高单位为像素),例如:{ width: 190, height: 108 }。SDK 会在保证原图不变形的前提下,缩放原图,使图片最长边和目标尺寸的最长边的长度一致。例如,原图宽高为 400 × 300,thumbSize 为 100 x 100,缩略图实际尺寸为 100 × 75。如果目标尺寸大于原图尺寸,缩略图即为原图,SDK 不进行缩放操作。
* @param {Object} iconSize 采集源的图标的目标尺寸(宽高单位为像素),例如:{ width: 32, height: 32 }。SDK 会在保证原图不变形的前提下,缩放原图,使图片最长边和目标尺寸的最长边的长度一致。例如,原图宽高为 400 × 300,iconSize 为 100 x 100,图标实际尺寸为 100 × 75。如果目标尺寸大于原图尺寸,图标即为原图,SDK 不进行缩放操作。
* @param {Number} types 采集源类型, 1:屏幕 2:窗口 3:屏幕+窗口
* @returns {Array} 采集源列表
*/
getScreenCaptureSources(thumbSize, iconSize, types = 3) {
return this.sdk_engine.getScreenCaptureSources(thumbSize, iconSize, types);
}
//设置屏幕共享配置
setScreenShareCfg(config) {
this.sdk_engine.setScreenShareCfg(config);
}
//获取屏幕共享配置
getScreenShareCfg() {
return this.sdk_engine.getScreenShareCfg();
}
//获取屏幕共享信息
getScreenShareInfo() {
return this.sdk_engine.getScreenShareInfo();
}
// 开始屏幕共享
startScreenShare() {
this.sdk_engine.startScreenShare();
}
// 停止屏幕共享
stopScreenShare() {
this.sdk_engine.stopScreenShare();
}
//暂停共享,true:共享暂停、false:正常共享
pauseScreenShare(bPause) {
this.sdk_engine.pauseScreenShare(bPause);
}
//test
setCustomizeCatchScreen(bCustomize) {
this.sdk_engine.setCustomizeCatchScreen(bCustomize);
}
//屏幕共享赋予控制权限
giveCtrlRight(userId) {
this.sdk_engine.giveCtrlRight(userId);
}
//屏幕共享收回控制权限
releaseCtrlRight(userId) {
this.sdk_engine.releaseCtrlRight(userId);
}
//发送鼠标控制消息
sendMouseCtrlMsg(msgType, keyType, ptX, ptY) {
this.sdk_engine.sendMouseCtrlMsg(msgType, keyType, ptX, ptY);
}
//发送键盘控制消息
sendKeyCtrlMsg(msgType, vk, bExtendedKey = 0) {
this.sdk_engine.sendKeyCtrlMsg(msgType, vk, bExtendedKey);
}
//开启屏幕共享标注
startScreenMark() {
this.sdk_engine.startScreenMark();
}
//停止屏幕共享标注
stopScreenMark() {
this.sdk_engine.stopScreenMark();
}
//清空屏幕共享标注
clearScreenMarks() {
this.sdk_engine.clearScreenMarks();
}
//test
setMediaCfg(jsonCfg) {
return this.sdk_engine.setMediaCfg(jsonCfg);
}
//test
getMediaCfg() {
return this.sdk_engine.getMediaCfg();
}
//开始影音共享
startPlayMedia(filename, bLocPlay = false, bPauseWhenFinished = false) {
this.sdk_engine.startPlayMedia(filename, bLocPlay, bPauseWhenFinished);
}
//停止影音共享
stopPlayMedia() {
this.sdk_engine.stopPlayMedia();
}
//暂停影音共享
pausePlayMedia(bPause) {
this.sdk_engine.pausePlayMedia(bPause);
}
//设置播放位置
setMediaPlayPos(ms) {
this.sdk_engine.setMediaPlayPos(ms);
}
//获取当前影音共享信息
getMediaInfo() {
return this.sdk_engine.getMediaInfo();
}
//test
setMediaVolume(volume) {
this.sdk_engine.setMediaVolume(volume);
}
//test
getMediaVolume() {
return this.sdk_engine.getMediaVolume();
}
//创建本地混图器
createLocMixer(mixerId, mixerCfg, mixerContent) {
return this.sdk_engine.createLocMixer(mixerId, mixerCfg, mixerContent);
}
//更新本地混图内容
updateLocMixerContent(mixerId, mixerContent) {
return this.sdk_engine.updateLocMixerContent(mixerId, mixerContent);
}
//添加混图器输出(本地文件或推流地址)
addLocMixerOutput(mixerId, mixerOutput) {
return this.sdk_engine.addLocMixerOutput(mixerId, mixerOutput);
}
//移除混图器输出
rmLocMixerOutput(mixerId, nameOrUrls) {
this.sdk_engine.rmLocMixerOutput(mixerId, nameOrUrls);
}
//消毁本地混图器
destroyLocMixer(mixerId) {
this.sdk_engine.destroyLocMixer(mixerId);
}
//获取混图器状态
getLocMixerState(mixerId) {
return this.sdk_engine.getLocMixerState(mixerId);
}
//test
setPicResource(picID, frm) {
this.sdk_engine.setPicResource(picID, frm);
}
//创建云端混图器
createCloudMixer(cfg) {
return this.sdk_engine.createCloudMixer(cfg);
}
//更新云端混图器
updateCloudMixerContent(mixerId, cfg) {
return this.sdk_engine.updateCloudMixerContent(mixerId, cfg);
}
//消毁云端混图器
destroyCloudMixer(mixerId) {
return this.sdk_engine.destroyCloudMixer(mixerId);
}
//获取云端混图器信息
getCloudMixerInfo(mixerId) {
return this.sdk_engine.getCloudMixerInfo(mixerId);
}
//获取所有云端混图器
getAllCloudMixerInfo() {
return this.sdk_engine.getAllCloudMixerInfo();
}
//获取所有房间属性
getMeetingAllAttrs() {
this.sdk_engine.getMeetingAllAttrs();
}
//获取部份房间属性
getMeetingAttrs(jsonKeys, cookie) {
this.sdk_engine.getMeetingAttrs(jsonKeys, cookie);
}
//重置所有房间属性
setMeetingAttrs(jsonAttrs, options, cookie) {
this.sdk_engine.setMeetingAttrs(jsonAttrs, options, cookie);
}
// 增加或者更新房间属性
addOrUpdateMeetingAttrs(jsonAttrs, options, cookie) {
this.sdk_engine.addOrUpdateMeetingAttrs(jsonAttrs, options, cookie);
}
//删除房间属性
delMeetingAttrs(jsonKeys, options, cookie) {
this.sdk_engine.delMeetingAttrs(jsonKeys, options, cookie);
}
//清空房间属性
clearMeetingAttrs(options, cookie) {
this.sdk_engine.clearMeetingAttrs(options, cookie);
}
//获取指定用户的所有属性
getUserAttrs(jsonUIds, jsonKeys, cookie) {
this.sdk_engine.getUserAttrs(jsonUIds, jsonKeys, cookie);
}
//重置指定用户的属性
setUserAttrs(uid, jsonAttrs, options, cookie) {
this.sdk_engine.setUserAttrs(uid, jsonAttrs, options, cookie);
}
//添加或更新指定用户的属性
addOrUpdateUserAttrs(uid, jsonAttrs, options, cookie) {
this.sdk_engine.addOrUpdateUserAttrs(uid, jsonAttrs, options, cookie);
}
//删除指定用户的属性
delUserAttrs(uid, jsonKeys, options, cookie) {
this.sdk_engine.delUserAttrs(uid, jsonKeys, options, cookie);
}
//清空指定用户的属性
clearUserAttrs(uid, options, cookie) {
this.sdk_engine.clearUserAttrs(uid, options, cookie);
}
//清空所有用户的属性
clearAllUserAttrs(options, cookie) {
this.sdk_engine.clearAllUserAttrs(options, cookie);
}
//test
call(calledUserID, meetObj, usrExtDat = "", cookie = "") {
return this.sdk_engine.call(calledUserID, meetObj, usrExtDat, cookie);
}
//test
acceptCall(callID, meetObj, usrExtDat = "", cookie = "") {
this.sdk_engine.acceptCall(callID, meetObj, usrExtDat, cookie);
}
//test
rejectCall(callID, usrExtDat = "", cookie = "") {
this.sdk_engine.rejectCall(callID, usrExtDat, cookie);
}
//test
hangupCall(callID, usrExtDat = "", cookie = "") {
this.sdk_engine.hangupCall(callID, usrExtDat, cookie);
}
//test
callMoreParty(calledUserID, meetObj, usrExtDat = "", cookie = "") {
return this.sdk_engine.callMoreParty(calledUserID, meetObj, usrExtDat, cookie);
}
//test
cancelCallMoreParty(callID, usrExtDat = "", cookie = "") {
this.sdk_engine.cancelCallMoreParty(callID, usrExtDat, cookie);
}
//test
invite(invitedUserID, usrExtDat = "", cookie = "") {
return this.sdk_engine.invite(invitedUserID, usrExtDat, cookie);
}
//test
acceptInvite(inviteID, usrExtDat = "", cookie = "") {
this.sdk_engine.acceptInvite(inviteID, usrExtDat, cookie);
}
//test
rejectInvite(inviteID, usrExtDat = "", cookie = "") {
this.sdk_engine.rejectInvite(inviteID, usrExtDat, cookie);
}
//test
cancelInvite(inviteID, usrExtDat = "", cookie = "") {
this.sdk_engine.cancelInvite(inviteID, usrExtDat, cookie);
}
//test
initQueueDat(cookie = "") {
this.sdk_engine.initQueueDat();
}
//test
getAllQueueInfo() {
return this.sdk_engine.getAllQueueInfo();
}
//test
getQueueStatus(queID) {
return this.sdk_engine.getQueueStatus(queID);
}
//test
getQueuingInfo() {
this.sdk_engine.getQueuingInfo();
}
//test
getServingQueues() {
return this.sdk_engine.getServingQueues();
}
//test
startQueuing(queID, usrExtDat = "", cookie = "") {
return this.sdk_engine.startQueuing(queID, usrExtDat, cookie);
}
//test
stopQueuing(cookie = "") {
this.sdk_engine.stopQueuing(cookie);
}
//test
startService(queID, priority = 0, cookie = "") {
this.sdk_engine.startService(queID, priority, cookie);
}
//test
stopService(queID, cookie = "") {
this.sdk_engine.stopService(queID, cookie);
}
//test
reqAssignUser(queID, userId, cookie = "") {
if (queID || userId) {
this.sdk_engine.reqAssignUser2(queID, userId, cookie);
} else {
this.sdk_engine.reqAssignUser(cookie);
}
}
//test
acceptAssignUser(queID, userId, cookie = "") {
this.sdk_engine.acceptAssignUser(queID, userId, cookie);
}
//test
rejectAssignUser(queID, userId, cookie = "") {
this.sdk_engine.rejectAssignUser(queID, userId, cookie);
}
/**
* init event handler
* @private
*/
_initEventHandler() {
this.sdk_engine.onRenderFrameDat((id, frame) => {
this._onRenderFrameReceived(id, frame);
});
this.sdk_engine.onEvent('notifySendScreenMarkData', (json) => {
const data = JSON.parse(json);
data.points = data.points.map(num => [num >> 16, num & 0xFFFF])
console.log('notifySendScreenMarkData', data)
if (!this._markList) {
this._markList = [];
}
this._markList.push(data);
this.videoUIList.forEach(videoUI => {
videoUI._onScreenMarkData(data);
})
});
this.sdk_engine.onEvent('notifyScreenMarkStarted', () => {
console.log('notifyScreenMarkStarted')
this._markList = [];
this.videoUIList.forEach(videoUI => {
videoUI._onScreenMarkStarted();
})
});
this.sdk_engine.onEvent('startScreenMarkRslt', (sdkErr) => {
console.log('startScreenMarkRslt')
if (sdkErr !== 0) return;
this._markList = [];
this.videoUIList.forEach(videoUI => {
videoUI._onScreenMarkStarted();
})
});
this.sdk_engine.onEvent('notifyScreenMarkStopped', () => {
console.log('notifyScreenMarkStopped')
this._markList = null;
this.videoUIList.forEach(videoUI => {
videoUI._onScreenMarkStopped();
})
});
this.sdk_engine.onEvent('stopScreenMarkRslt', (sdkErr) => {
console.log('stopScreenMarkRslt')
this._markList = null;
if (sdkErr === 0) {
this.videoUIList.forEach(videoUI => {
videoUI._onScreenMarkStopped();
})
}
});
this.sdk_engine.onEvent('notifyDelScreenMarkData', (jsonDelMarkId, oprUserID) => {
console.log('notifyDelScreenMarkData')
if (!this._markList) return;
const delIdList = JSON.parse(jsonDelMarkId);
this._markList = this._markList.filter(data => delIdList.indexOf(data.markid) === -1);
this.videoUIList.forEach(videoUI => {
videoUI._onScreenMarkDel(delIdList, oprUserID);
})
});
this.sdk_engine.onEvent('notifyClearScreenMarks', () => {
console.log('notifyClearScreenMarks')
this._markList = null;
this.videoUIList.forEach(videoUI => {
videoUI._onScreenMarkClear();
})
});
[
"loginRslt",
"notifyTokenWillExpire",
"notifyLineOff",
"setDNDStatusRslt",
"getUserStatusSuccess",
"getUserStatusFail",
"notifyUserStatus",
"startUserStatusNotifyRslt",
"stopUserStatusNotifyRslt",
"createMeetingSuccess",
"createMeetingFail",
"destroyMeetingRslt",
"sendCmdRlst",
"sendBufferRlst",
"sendFileRlst",
"cancelSendRlst",
"notifySendProgress",
"notifyCmdData",
"notifyBufferData",
"notifyFileData",
"customHttpReqRslt",
"enterMeetingRslt",
"notifyNetStateChanged",
"notifyMeetingStopped",
"notifyMeetingDropped",
"notifyUserEnterMeeting",
"notifyUserLeftMeeting",
"setNickNameRslt",
"notifyNickNameChanged",
"kickoutRslt",
"sendMeetingCustomMsgRslt",
"notifyMeetingCustomMsg",
"notifyAudioDevChanged",
"notifyAudioErr",
"notifyMicStatusChanged",
"notifyMicEnergy",
"notifyCloseAllMic",
"notifySetVoiceChange",
"notifyEchoTestState",
"notifyVideoDevChanged",
"notifyDefaultVideoChanged",
"openVideoDevRslt",
"notifyVideoStatusChanged",
"startScreenShareRslt",
"stopScreenShareRslt",
"notifyScreenShareStarted",
"notifyScreenShareStopped",
"notifyGiveCtrlRight",
"notifyReleaseCtrlRight",
"startPlayMediaFail",
"notifyMediaStart",
"notifyMediaOpened",
"notifyMediaStop",
"notifyMediaPause",
"notifyLocMixerStateChanged",
"notifyLocMixerOutputInfo",
"createCloudMixerFailed",
"notifyCloudMixerStateChanged",
"notifyCloudMixerOutputInfoChanged",
"notifyCloudMixerInfoChanged",
"getMeetingAllAttrsSuccess",
"getMeetingAllAttrsFail",
"getMeetingAttrsSuccess",
"getMeetingAttrsFail",
"setMeetingAttrsRslt",
"addOrUpdateMeetingAttrsRslt",
"delMeetingAttrsRslt",
"clearMeetingAttrsRslt",
"notifyMeetingAttrsChanged",
"getUserAttrsSuccess",
"getUserAttrsFail",
"setUserAttrsRslt",
"addOrUpdateUserAttrsRslt",
"delUserAttrsRslt",
"clearAllUserAttrsRslt",
"clearUserAttrsRslt",
"notifyUserAttrsChanged",
"callRslt",
"acceptCallRslt",
"rejectCallRslt",
"hangupCallRslt",
"notifyCallIn",
"notifyCallAccepted",
"notifyCallRejected",
"notifyCallHungup",
"callMorePartyRslt",
"cancelCallMorePartyRslt",
"notifyCallMorePartyStatus",
"inviteRslt",
"cancelInviteRslt",
"acceptInviteRslt",
"rejectInviteRslt",
"notifyInviteIn",
"notifyInviteAccepted",
"notifyInviteRejected",
"notifyInviteCanceled",
"initQueueDatRslt",
"notifyQueueStatusChanged",
"notifyQueuingInfoChanged",
"startQueuingRslt",
"stopQueuingRslt",
"startServiceRslt",
"stopServiceRslt",
"acceptAssignUserRslt",
"rejectAssignUserRslt",
"reqAssignUserRslt",
"notifyAutoAssignUser",
"notifyAssignUserCanceled",
"notifyUserEnterQueue",
"notifyUserLeaveQueue",
].forEach(item => {
this.sdk_engine.onEvent(item, (...arg) => {
if (['notifyMicEnergy'].indexOf(item) === -1) {
console.log(item, arg)
}
try {
this.emit(item, ...arg)
} catch (error) {
console.error(error);
}
})
})
}
}
// 透明单例设计模式
let NativeCRVideoSDK = (function () {
let instance = null;
return class SDK {
constructor() {
return SDK.getInstance();
}
static getInstance() {
if (!instance) {
instance = new CRVideoSDK();
}
return instance;
}
};
})();
module.exports = NativeCRVideoSDK;