trtc-electron-sdk 9.3.111-beta.0 → 9.3.301

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 CHANGED
@@ -39,7 +39,7 @@ declare class TRTCCloud extends EventEmitter {
39
39
  private audioQuality;
40
40
  private bgmId;
41
41
  private playAudioEffectIdList;
42
- private isStartLocalPreview;
42
+ private enableRenderFrame;
43
43
  constructor();
44
44
  /**
45
45
  * 创建 TRTCCloud 对象单例
@@ -1978,6 +1978,7 @@ declare class TRTCCloud extends EventEmitter {
1978
1978
  createPlugin(pluginId: string): PluginInfo;
1979
1979
  setPluginCallback(pluginCb: (pluginId: string, errorCode: number, msg: string) => void): void;
1980
1980
  getKey(uid: string, type: TRTCVideoStreamType): string;
1981
+ setEnableRenderFrame(enable: boolean): void;
1981
1982
  /**
1982
1983
  * 判断是否支持webGL
1983
1984
  * @returns {boolean}
@@ -2005,6 +2006,5 @@ declare class TRTCCloud extends EventEmitter {
2005
2006
  _YUV2RGBA(width: number, height: number, buffer: ArrayBufferLike): Uint8ClampedArray;
2006
2007
  _BGRA2RGBA(data: ArrayBuffer, width: number, height: number): Uint8ClampedArray;
2007
2008
  _isMacPlatform(): boolean;
2008
- _isLocalUser(uid: string): boolean;
2009
2009
  }
2010
2010
  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.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
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];
@@ -116,7 +120,7 @@ class TRTCCloud extends events_1.EventEmitter {
116
120
  // 生成一个足够大, 不会与用户输入重复的 id
117
121
  this.bgmId = 1 << 29;
118
122
  this.playAudioEffectIdList = [];
119
- this.isStartLocalPreview = false;
123
+ this.enableRenderFrame = true;
120
124
  this.initEventHandler();
121
125
  console.log('constructor render:' + this.renderMode + '|sdk version:' + pkg.version +
122
126
  '|native sdk version:' + this.rtcCloud.getSDKVersion());
@@ -161,7 +165,6 @@ class TRTCCloud extends events_1.EventEmitter {
161
165
  */
162
166
  destroy() {
163
167
  this.firstVideoFrameList = [];
164
- this.isStartLocalPreview = false;
165
168
  this.playAudioEffectIdList = [];
166
169
  this.rtcCloud.destroy();
167
170
  }
@@ -420,7 +423,6 @@ class TRTCCloud extends events_1.EventEmitter {
420
423
  */
421
424
  handleOnExitRoom(reason) {
422
425
  this.firstVideoFrameList = [];
423
- this.isStartLocalPreview = false;
424
426
  this.fire('onExitRoom', reason);
425
427
  }
426
428
  /**
@@ -1426,7 +1428,6 @@ class TRTCCloud extends events_1.EventEmitter {
1426
1428
  let key = this.getKey('local_video', trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
1427
1429
  this._initRender(key, view);
1428
1430
  }
1429
- this.isStartLocalPreview = true;
1430
1431
  this.rtcCloud.startLocalPreview();
1431
1432
  this.addLocalVideoRenderCallback();
1432
1433
  }
@@ -1441,9 +1442,8 @@ class TRTCCloud extends events_1.EventEmitter {
1441
1442
  let key = this.getKey('local_video', trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
1442
1443
  this._destroyRender(key, null);
1443
1444
  this.rtcCloud.stopLocalPreview();
1444
- this.isStartLocalPreview = false;
1445
- this.firstVideoFrameList = this.firstVideoFrameList.filter((item) => {
1446
- return !(this._isLocalUser(item.uid) && item.type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
1445
+ this.firstVideoFrameList = this.firstVideoFrameList.filter(function (item) {
1446
+ return !('' === item.uid && item.type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
1447
1447
  });
1448
1448
  }
1449
1449
  /**
@@ -2960,8 +2960,8 @@ class TRTCCloud extends events_1.EventEmitter {
2960
2960
  let key = this.getKey('camera_device_test_view', trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
2961
2961
  this._destroyRender(key, null);
2962
2962
  this.rtcCloud.stopCameraDeviceTest();
2963
- this.firstVideoFrameList = this.firstVideoFrameList.filter((item) => {
2964
- return !(this._isLocalUser(item.uid) && item.type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
2963
+ this.firstVideoFrameList = this.firstVideoFrameList.filter(function (item) {
2964
+ return !('' === item.uid && item.type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
2965
2965
  });
2966
2966
  }
2967
2967
  /**
@@ -3103,7 +3103,9 @@ class TRTCCloud extends events_1.EventEmitter {
3103
3103
  this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
3104
3104
  }
3105
3105
  this.rtcCloud.addLocalVideoRenderCallback((id, type, width, height, timestamp, rotation, data) => {
3106
- this._onRenderFrame(id, type, width, height, timestamp, rotation, data);
3106
+ if (this.enableRenderFrame) {
3107
+ this._onRenderFrame(id, type, width, height, timestamp, rotation, data);
3108
+ }
3107
3109
  }, this.pixelformate);
3108
3110
  }
3109
3111
  addRemoteVideoRenderCallback(userid) {
@@ -3114,7 +3116,9 @@ class TRTCCloud extends events_1.EventEmitter {
3114
3116
  this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
3115
3117
  }
3116
3118
  this.rtcCloud.addRemoteVideoRenderCallback(userid, (id, type, width, height, timestamp, rotation, data) => {
3117
- this._onRenderFrame(id, type, width, height, timestamp, rotation, data);
3119
+ if (this.enableRenderFrame) {
3120
+ this._onRenderFrame(id, type, width, height, timestamp, rotation, data);
3121
+ }
3118
3122
  }, this.pixelformate);
3119
3123
  }
3120
3124
  //----------------------------------//
@@ -3185,6 +3189,10 @@ class TRTCCloud extends events_1.EventEmitter {
3185
3189
  getKey(uid, type) {
3186
3190
  return String(uid) + '_' + String(type);
3187
3191
  }
3192
+ setEnableRenderFrame(enable) {
3193
+ console.log('setEnableRenderFrame:' + enable);
3194
+ this.enableRenderFrame = enable;
3195
+ }
3188
3196
  /**
3189
3197
  * 判断是否支持webGL
3190
3198
  * @returns {boolean}
@@ -3220,7 +3228,6 @@ class TRTCCloud extends events_1.EventEmitter {
3220
3228
  return this.streams.get(key);
3221
3229
  }
3222
3230
  _onRenderFrame(uid, type, width, height, timestamp, rotation, data) {
3223
- const isCurrentLocalUser = this._isLocalUser(uid);
3224
3231
  // 由于 mac 监听自定义渲染回调后不会回调 onFirstVideoFrame ,所以在这里自己实现回调 onFirstVideoFrame
3225
3232
  if (this._isMacPlatform()) {
3226
3233
  setImmediate(() => {
@@ -3228,14 +3235,12 @@ class TRTCCloud extends events_1.EventEmitter {
3228
3235
  return uid === item.uid && type === item.type;
3229
3236
  });
3230
3237
  if (index === -1) {
3231
- if (!isCurrentLocalUser || this.isStartLocalPreview) {
3232
- this.emit('onFirstVideoFrame', uid, type, width, height);
3233
- this.firstVideoFrameList.push({ uid: uid, type: type });
3234
- }
3238
+ this.emit('onFirstVideoFrame', uid, type, width, height);
3239
+ this.firstVideoFrameList.push({ uid: uid, type: type });
3235
3240
  }
3236
3241
  });
3237
3242
  }
3238
- if (isCurrentLocalUser) {
3243
+ if (uid.length == 0) {
3239
3244
  if (this.isExternalRenderEnabled) {
3240
3245
  this.fire(CUSTOM_VIDEO_DATA, {
3241
3246
  uid: '', type, rotation, timestamp,
@@ -3476,9 +3481,6 @@ class TRTCCloud extends events_1.EventEmitter {
3476
3481
  _isMacPlatform() {
3477
3482
  return process.platform == 'darwin';
3478
3483
  }
3479
- _isLocalUser(uid) {
3480
- return uid === '';
3481
- }
3482
3484
  }
3483
3485
  class VideoRenderCallback {
3484
3486
  constructor() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trtc-electron-sdk",
3
- "version": "9.3.111-beta.0",
3
+ "version": "9.3.301",
4
4
  "description": "trtc electron sdk",
5
5
  "main": "./liteav/trtc.js",
6
6
  "types": "./liteav/trtc.d.ts",