trtc-electron-sdk 9.3.8-alpha.2 → 9.3.8-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/liteav/trtc.d.ts +1 -6
- package/liteav/trtc.js +12 -86
- package/package.json +1 -1
package/liteav/trtc.d.ts
CHANGED
|
@@ -39,9 +39,7 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
39
39
|
private audioQuality;
|
|
40
40
|
private bgmId;
|
|
41
41
|
private playAudioEffectIdList;
|
|
42
|
-
|
|
43
|
-
private enableRenderFrame;
|
|
44
|
-
constructor(enableDebug?: boolean);
|
|
42
|
+
constructor();
|
|
45
43
|
/**
|
|
46
44
|
* 创建 TRTCCloud 对象单例
|
|
47
45
|
* @returns {TRTCCloud}
|
|
@@ -1979,7 +1977,6 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
1979
1977
|
createPlugin(pluginId: string): PluginInfo;
|
|
1980
1978
|
setPluginCallback(pluginCb: (pluginId: string, errorCode: number, msg: string) => void): void;
|
|
1981
1979
|
getKey(uid: string, type: TRTCVideoStreamType): string;
|
|
1982
|
-
setEnableRenderFrame(enable: boolean): void;
|
|
1983
1980
|
/**
|
|
1984
1981
|
* 判断是否支持webGL
|
|
1985
1982
|
* @returns {boolean}
|
|
@@ -2007,7 +2004,5 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
2007
2004
|
_YUV2RGBA(width: number, height: number, buffer: ArrayBufferLike): Uint8ClampedArray;
|
|
2008
2005
|
_BGRA2RGBA(data: ArrayBuffer, width: number, height: number): Uint8ClampedArray;
|
|
2009
2006
|
_isMacPlatform(): boolean;
|
|
2010
|
-
_getFeaturesSetting(): void;
|
|
2011
|
-
_isEnableFeature(featureKey: string): boolean;
|
|
2012
2007
|
}
|
|
2013
2008
|
export default TRTCCloud;
|
package/liteav/trtc.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -90,7 +94,7 @@ let oriRtcCloud = null;
|
|
|
90
94
|
*
|
|
91
95
|
*/
|
|
92
96
|
class TRTCCloud extends events_1.EventEmitter {
|
|
93
|
-
constructor(
|
|
97
|
+
constructor() {
|
|
94
98
|
super();
|
|
95
99
|
oriRtcCloud = new trtc.NodeRTCCloud(pkg.version);
|
|
96
100
|
this.rtcCloud = Object.assign({}, oriRtcCloud, {
|
|
@@ -116,11 +120,6 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
116
120
|
// 生成一个足够大, 不会与用户输入重复的 id
|
|
117
121
|
this.bgmId = 1 << 29;
|
|
118
122
|
this.playAudioEffectIdList = [];
|
|
119
|
-
this.features = null;
|
|
120
|
-
this.enableRenderFrame = true;
|
|
121
|
-
if (enableDebug) {
|
|
122
|
-
this._getFeaturesSetting();
|
|
123
|
-
}
|
|
124
123
|
this.initEventHandler();
|
|
125
124
|
console.log('constructor render:' + this.renderMode + '|sdk version:' + pkg.version +
|
|
126
125
|
'|native sdk version:' + this.rtcCloud.getSDKVersion());
|
|
@@ -1423,20 +1422,13 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1423
1422
|
* @param {HTMLElement} view - 承载预览画面的 DOM
|
|
1424
1423
|
*/
|
|
1425
1424
|
startLocalPreview(view) {
|
|
1426
|
-
if (!this._isEnableFeature('localVideoJS')) {
|
|
1427
|
-
return;
|
|
1428
|
-
}
|
|
1429
1425
|
if (view !== undefined) {
|
|
1430
1426
|
if (view !== null) {
|
|
1431
1427
|
let key = this.getKey('local_video', trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
|
|
1432
|
-
|
|
1433
|
-
this._initRender(key, view);
|
|
1434
|
-
}
|
|
1428
|
+
this._initRender(key, view);
|
|
1435
1429
|
}
|
|
1436
1430
|
this.rtcCloud.startLocalPreview();
|
|
1437
|
-
|
|
1438
|
-
this.addLocalVideoRenderCallback();
|
|
1439
|
-
}
|
|
1431
|
+
this.addLocalVideoRenderCallback();
|
|
1440
1432
|
}
|
|
1441
1433
|
else {
|
|
1442
1434
|
console.error('startLocalPreview, view is undefined!');
|
|
@@ -1474,9 +1466,6 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1474
1466
|
* @param {TRTCVideoStreamType} streamType - 视频流类型
|
|
1475
1467
|
*/
|
|
1476
1468
|
startRemoteView(userId, view, streamType) {
|
|
1477
|
-
if (!this._isEnableFeature('remoteVideoJS')) {
|
|
1478
|
-
return;
|
|
1479
|
-
}
|
|
1480
1469
|
if (streamType === undefined) {
|
|
1481
1470
|
streamType = this.priorRemoteVideoStreamType;
|
|
1482
1471
|
}
|
|
@@ -1489,13 +1478,9 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1489
1478
|
bindStreamType = trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig;
|
|
1490
1479
|
}
|
|
1491
1480
|
const key = this.getKey(userId, bindStreamType);
|
|
1492
|
-
|
|
1493
|
-
this._initRender(key, view);
|
|
1494
|
-
}
|
|
1495
|
-
}
|
|
1496
|
-
if (this._isEnableFeature('addRemoteVideoRenderCallback')) {
|
|
1497
|
-
this.addRemoteVideoRenderCallback(userId);
|
|
1481
|
+
this._initRender(key, view);
|
|
1498
1482
|
}
|
|
1483
|
+
this.addRemoteVideoRenderCallback(userId);
|
|
1499
1484
|
this.rtcCloud.startRemoteView(userId, streamType);
|
|
1500
1485
|
}
|
|
1501
1486
|
else {
|
|
@@ -3117,9 +3102,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3117
3102
|
this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
|
|
3118
3103
|
}
|
|
3119
3104
|
this.rtcCloud.addLocalVideoRenderCallback((id, type, width, height, timestamp, rotation, data) => {
|
|
3120
|
-
|
|
3121
|
-
this._onRenderFrame(id, type, width, height, timestamp, rotation, data);
|
|
3122
|
-
}
|
|
3105
|
+
this._onRenderFrame(id, type, width, height, timestamp, rotation, data);
|
|
3123
3106
|
}, this.pixelformate);
|
|
3124
3107
|
}
|
|
3125
3108
|
addRemoteVideoRenderCallback(userid) {
|
|
@@ -3130,9 +3113,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3130
3113
|
this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
|
|
3131
3114
|
}
|
|
3132
3115
|
this.rtcCloud.addRemoteVideoRenderCallback(userid, (id, type, width, height, timestamp, rotation, data) => {
|
|
3133
|
-
|
|
3134
|
-
this._onRenderFrame(id, type, width, height, timestamp, rotation, data);
|
|
3135
|
-
}
|
|
3116
|
+
this._onRenderFrame(id, type, width, height, timestamp, rotation, data);
|
|
3136
3117
|
}, this.pixelformate);
|
|
3137
3118
|
}
|
|
3138
3119
|
//----------------------------------//
|
|
@@ -3145,9 +3126,6 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3145
3126
|
* - 2 yuvcanvs
|
|
3146
3127
|
*/
|
|
3147
3128
|
setRenderMode(mode = 1) {
|
|
3148
|
-
if (!this._isEnableFeature('enableRenderModeJS')) {
|
|
3149
|
-
return;
|
|
3150
|
-
}
|
|
3151
3129
|
if (this.renderMode !== mode) {
|
|
3152
3130
|
this.renderMode = mode;
|
|
3153
3131
|
// 遍历原有的renderer,改为新的渲染模式
|
|
@@ -3165,35 +3143,20 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3165
3143
|
// plugin apis
|
|
3166
3144
|
//----------------------------------//
|
|
3167
3145
|
initPluginManager() {
|
|
3168
|
-
if (!this._isEnableFeature('enablePluginJS')) {
|
|
3169
|
-
return;
|
|
3170
|
-
}
|
|
3171
3146
|
this.rtcCloud.initializePluginManager();
|
|
3172
3147
|
}
|
|
3173
3148
|
destroyPluginManager() {
|
|
3174
|
-
if (!this._isEnableFeature('enablePluginJS')) {
|
|
3175
|
-
return;
|
|
3176
|
-
}
|
|
3177
3149
|
this.rtcCloud.releasePluginManager();
|
|
3178
3150
|
}
|
|
3179
3151
|
addPlugin(plugin) {
|
|
3180
|
-
if (!this._isEnableFeature('enablePluginJS')) {
|
|
3181
|
-
return;
|
|
3182
|
-
}
|
|
3183
3152
|
// type: 1 表示美颜插件
|
|
3184
3153
|
const pluginType = plugin.type || 1;
|
|
3185
3154
|
this.rtcCloud.registerPlugin(plugin.id, plugin.path, pluginType);
|
|
3186
3155
|
}
|
|
3187
3156
|
removePlugin(id) {
|
|
3188
|
-
if (!this._isEnableFeature('enablePluginJS')) {
|
|
3189
|
-
return;
|
|
3190
|
-
}
|
|
3191
3157
|
this.rtcCloud.unregisterPlugin(id);
|
|
3192
3158
|
}
|
|
3193
3159
|
getPluginList() {
|
|
3194
|
-
if (!this._isEnableFeature('enablePluginJS')) {
|
|
3195
|
-
return [];
|
|
3196
|
-
}
|
|
3197
3160
|
return this.rtcCloud.getPlugins().map((item) => {
|
|
3198
3161
|
return this.createPlugin(item.id);
|
|
3199
3162
|
});
|
|
@@ -3216,19 +3179,11 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3216
3179
|
};
|
|
3217
3180
|
}
|
|
3218
3181
|
setPluginCallback(pluginCb) {
|
|
3219
|
-
if (!this._isEnableFeature('enablePluginJS')) {
|
|
3220
|
-
return;
|
|
3221
|
-
}
|
|
3222
3182
|
this.rtcCloud.setPluginCallback(pluginCb);
|
|
3223
3183
|
}
|
|
3224
3184
|
getKey(uid, type) {
|
|
3225
3185
|
return String(uid) + '_' + String(type);
|
|
3226
3186
|
}
|
|
3227
|
-
setEnableRenderFrame(enable) {
|
|
3228
|
-
if (this._isEnableFeature('enableRenderFrameJS')) {
|
|
3229
|
-
this.enableRenderFrame = enable;
|
|
3230
|
-
}
|
|
3231
|
-
}
|
|
3232
3187
|
/**
|
|
3233
3188
|
* 判断是否支持webGL
|
|
3234
3189
|
* @returns {boolean}
|
|
@@ -3517,35 +3472,6 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3517
3472
|
_isMacPlatform() {
|
|
3518
3473
|
return process.platform == 'darwin';
|
|
3519
3474
|
}
|
|
3520
|
-
_getFeaturesSetting() {
|
|
3521
|
-
const start = Date.now();
|
|
3522
|
-
fetch('https://web.sdk.qcloud.com/trtc/electron/setting/xiaoe.json', {
|
|
3523
|
-
cache: 'no-cache'
|
|
3524
|
-
})
|
|
3525
|
-
.then((response) => {
|
|
3526
|
-
const contentType = response.headers.get('content-type');
|
|
3527
|
-
if (!contentType || !contentType.includes('application/json')) {
|
|
3528
|
-
throw new TypeError("Oops, we haven't got JSON!");
|
|
3529
|
-
}
|
|
3530
|
-
return response.json();
|
|
3531
|
-
}).then(data => {
|
|
3532
|
-
this.features = data;
|
|
3533
|
-
const experimentApi = {
|
|
3534
|
-
'api': 'setFeatureEnable',
|
|
3535
|
-
'params': this.features
|
|
3536
|
-
};
|
|
3537
|
-
console.log('_getFeaturesSetting: ', this.features);
|
|
3538
|
-
this.callExperimentalAPI(JSON.stringify(experimentApi));
|
|
3539
|
-
this.emit('onReady', this.features, Date.now() - start);
|
|
3540
|
-
})
|
|
3541
|
-
.catch(error => console.error(error));
|
|
3542
|
-
}
|
|
3543
|
-
_isEnableFeature(featureKey) {
|
|
3544
|
-
if (!this.features || this.features[featureKey] === undefined) {
|
|
3545
|
-
return true;
|
|
3546
|
-
}
|
|
3547
|
-
return this.features[featureKey] === 1;
|
|
3548
|
-
}
|
|
3549
3475
|
}
|
|
3550
3476
|
class VideoRenderCallback {
|
|
3551
3477
|
constructor() {
|