trtc-electron-sdk 9.3.112-beta.0 → 9.3.112-beta.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.
@@ -74,7 +74,6 @@ class Renderer {
74
74
  this.yuv = null;
75
75
  this.element = null;
76
76
  this.canvas = null;
77
- this.view = null;
78
77
  }
79
78
  refreshCanvas() {
80
79
  }
@@ -109,11 +108,49 @@ class Renderer {
109
108
  this.canvas.style.transform = 'rotateY(180deg)';
110
109
  }
111
110
  }
111
+ _adjustImageData(imageData) {
112
+ const { width, height, yUint8Array, uUint8Array, vUint8Array } = imageData;
113
+ const widthBase = 8;
114
+ const w8Modulo = width % widthBase;
115
+ if (w8Modulo !== 0) {
116
+ const newWidth = width - w8Modulo;
117
+ const newYSize = newWidth * height;
118
+ const newYArrayBuffer = new ArrayBuffer(newYSize);
119
+ const newYUint8Array = new Uint8Array(newYArrayBuffer);
120
+ let oldIndex = -1, newIndex = -1;
121
+ for (let h = 0; h < height; h += 1) {
122
+ for (let w = 0; w < newWidth; w += 1) {
123
+ oldIndex = width * h + w;
124
+ newIndex = newWidth * h + w;
125
+ newYUint8Array[newIndex] = yUint8Array[oldIndex];
126
+ }
127
+ }
128
+ const oldChromaWidth = width / 2;
129
+ const newChromaWidth = newWidth / 2;
130
+ const chromaHeight = height / 2;
131
+ const newChromaSize = newChromaWidth * chromaHeight;
132
+ const newUArrayBuffer = new ArrayBuffer(newChromaSize);
133
+ const newUInt8Array = new Uint8Array(newUArrayBuffer);
134
+ const newVArrayBuffer = new ArrayBuffer(newChromaSize);
135
+ const newVInt8Array = new Uint8Array(newVArrayBuffer);
136
+ for (let h = 0; h < chromaHeight; h += 1) {
137
+ for (let w = 0; w < newChromaWidth; w += 1) {
138
+ oldIndex = oldChromaWidth * h + w;
139
+ newIndex = newChromaWidth * h + w;
140
+ newUInt8Array[newIndex] = uUint8Array[oldIndex];
141
+ newVInt8Array[newIndex] = vUint8Array[oldIndex];
142
+ }
143
+ }
144
+ return Object.assign(Object.assign({}, imageData), { width: newWidth, height, yUint8Array: newYUint8Array, uUint8Array: newUInt8Array, vUint8Array: newVInt8Array });
145
+ }
146
+ return imageData;
147
+ }
112
148
  drawFrame(imageData) {
113
149
  if (!this.ready) {
114
150
  this.ready = true;
115
151
  this.event.emit('ready');
116
152
  }
153
+ imageData = this._adjustImageData(imageData);
117
154
  const mirror = 0;
118
155
  const contentWidth = imageData.width;
119
156
  const contentHeight = imageData.height;
package/liteav/trtc.d.ts CHANGED
@@ -39,6 +39,7 @@ declare class TRTCCloud extends EventEmitter {
39
39
  private audioQuality;
40
40
  private bgmId;
41
41
  private playAudioEffectIdList;
42
+ private enableRenderFrame;
42
43
  constructor();
43
44
  /**
44
45
  * 创建 TRTCCloud 对象单例
@@ -1977,6 +1978,7 @@ declare class TRTCCloud extends EventEmitter {
1977
1978
  createPlugin(pluginId: string): PluginInfo;
1978
1979
  setPluginCallback(pluginCb: (pluginId: string, errorCode: number, msg: string) => void): void;
1979
1980
  getKey(uid: string, type: TRTCVideoStreamType): string;
1981
+ setEnableRenderFrame(enable: boolean): void;
1980
1982
  /**
1981
1983
  * 判断是否支持webGL
1982
1984
  * @returns {boolean}
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,6 +120,7 @@ class TRTCCloud extends events_1.EventEmitter {
116
120
  // 生成一个足够大, 不会与用户输入重复的 id
117
121
  this.bgmId = 1 << 29;
118
122
  this.playAudioEffectIdList = [];
123
+ this.enableRenderFrame = true;
119
124
  this.initEventHandler();
120
125
  console.log('constructor render:' + this.renderMode + '|sdk version:' + pkg.version +
121
126
  '|native sdk version:' + this.rtcCloud.getSDKVersion());
@@ -3098,7 +3103,9 @@ class TRTCCloud extends events_1.EventEmitter {
3098
3103
  this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
3099
3104
  }
3100
3105
  this.rtcCloud.addLocalVideoRenderCallback((id, type, width, height, timestamp, rotation, data) => {
3101
- this._onRenderFrame(id, type, width, height, timestamp, rotation, data);
3106
+ if (this.enableRenderFrame) {
3107
+ this._onRenderFrame(id, type, width, height, timestamp, rotation, data);
3108
+ }
3102
3109
  }, this.pixelformate);
3103
3110
  }
3104
3111
  addRemoteVideoRenderCallback(userid) {
@@ -3109,7 +3116,9 @@ class TRTCCloud extends events_1.EventEmitter {
3109
3116
  this.pixelformate = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
3110
3117
  }
3111
3118
  this.rtcCloud.addRemoteVideoRenderCallback(userid, (id, type, width, height, timestamp, rotation, data) => {
3112
- this._onRenderFrame(id, type, width, height, timestamp, rotation, data);
3119
+ if (this.enableRenderFrame) {
3120
+ this._onRenderFrame(id, type, width, height, timestamp, rotation, data);
3121
+ }
3113
3122
  }, this.pixelformate);
3114
3123
  }
3115
3124
  //----------------------------------//
@@ -3180,6 +3189,10 @@ class TRTCCloud extends events_1.EventEmitter {
3180
3189
  getKey(uid, type) {
3181
3190
  return String(uid) + '_' + String(type);
3182
3191
  }
3192
+ setEnableRenderFrame(enable) {
3193
+ console.log('setEnableRenderFrame:' + enable);
3194
+ this.enableRenderFrame = enable;
3195
+ }
3183
3196
  /**
3184
3197
  * 判断是否支持webGL
3185
3198
  * @returns {boolean}
@@ -3309,7 +3322,7 @@ class TRTCCloud extends events_1.EventEmitter {
3309
3322
  let ulen = width * height / 4;
3310
3323
  let ydata = new Uint8Array(data, 0, ylen);
3311
3324
  let udata = new Uint8Array(data, ylen, ulen);
3312
- let vdata = new Uint8Array(data, ylen + ulen, data.le);
3325
+ let vdata = new Uint8Array(data, ylen + ulen, ulen);
3313
3326
  renderer.drawFrame({
3314
3327
  width: width,
3315
3328
  height: height,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trtc-electron-sdk",
3
- "version": "9.3.112-beta.0",
3
+ "version": "9.3.112-beta.3",
4
4
  "description": "trtc electron sdk",
5
5
  "main": "./liteav/trtc.js",
6
6
  "types": "./liteav/trtc.d.ts",