trtc-electron-sdk 10.9.405 → 10.9.501-beta.0

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.
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.VodPlayer = exports.PlayerEvents = void 0;
7
4
  const events_1 = require("events");
8
- const Render_1 = __importDefault(require("./Render"));
5
+ const Renderer_1 = require("./Renderer");
6
+ const trtc_define_1 = require("./trtc_define");
9
7
  var PlayerEvents;
10
8
  (function (PlayerEvents) {
11
9
  PlayerEvents["onVodPlayerStarted"] = "onVodPlayerStarted";
@@ -85,7 +83,7 @@ class VodPlayer extends events_1.EventEmitter {
85
83
  this.nativeVodPlayer.unpublishAudio();
86
84
  }
87
85
  setVodPlayerRenderCallback() {
88
- let callback = (width, height, timestamp, rotation, data) => {
86
+ const callback = (width, height, timestamp, rotation, data) => {
89
87
  this._renderVodVideoFrame({
90
88
  data, width, height,
91
89
  timestamp, rotation
@@ -96,7 +94,7 @@ class VodPlayer extends events_1.EventEmitter {
96
94
  });
97
95
  }
98
96
  setVodEventCallback() {
99
- let eventCallback = (eventName, param) => {
97
+ const eventCallback = (eventName, param) => {
100
98
  if (eventName === PlayerEvents.onVodPlayerStarted) {
101
99
  const msLength = param;
102
100
  this.emit(eventName, msLength);
@@ -123,42 +121,33 @@ class VodPlayer extends events_1.EventEmitter {
123
121
  this.nativeVodPlayer.setVodEventCallback(eventCallback);
124
122
  }
125
123
  _renderVodVideoFrame(frame) {
126
- const { data, width, height, timestamp, rotation } = frame;
127
124
  if (!this.renderer || !this.view) {
128
125
  return;
129
126
  }
130
- const newData = data.slice(0); // Electron 12 及以下版本,来自底层的帧数据必须复制一次,否则 WebGL 渲染阶段会奔溃
131
- const realRotation = rotation * 90; //ratation是0, 1, 2, 3. 绘制内部使用0, 90, 180, 270
132
- let ylen = width * height;
133
- let ulen = width * height / 4;
134
- let ydata = new Uint8Array(newData, 0, ylen);
135
- let udata = new Uint8Array(newData, ylen, ulen);
136
- let vdata = new Uint8Array(newData, ylen + ulen, ulen);
137
- this.renderer.drawFrame({
138
- width: width,
139
- height: height,
140
- rotation: realRotation,
141
- timestamp: timestamp,
142
- yUint8Array: ydata,
143
- uUint8Array: udata,
144
- vUint8Array: vdata,
145
- isNeedRotate: false
146
- });
147
- ydata = null;
148
- udata = null;
149
- vdata = null;
127
+ const { data, width, height, timestamp, rotation } = frame;
128
+ if (data) {
129
+ const newData = data.slice(0); // Electron 12 及以下版本,来自底层的帧数据必须复制一次,否则 WebGL 渲染阶段会奔溃
130
+ const realRotation = rotation * 90; //ratation是0, 1, 2, 3. 绘制内部使用0, 90, 180, 270
131
+ this.renderer.drawFrame({
132
+ data: newData,
133
+ width,
134
+ height,
135
+ timestamp,
136
+ rotation: realRotation,
137
+ isNeedRotate: false,
138
+ });
139
+ }
150
140
  }
151
141
  _initRender(view) {
152
142
  if (this.renderer) {
153
143
  this.destroyRender();
154
144
  }
155
- this.renderer = new Render_1.default.GlRenderer();
156
145
  view.innerHTML = ''; // 事先清空一下,避免画面叠加
157
- this.renderer.bind(view);
146
+ this.renderer = (0, Renderer_1.createRenderer)(trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420, view);
158
147
  }
159
148
  destroyRender() {
160
149
  try {
161
- this.renderer.unbind();
150
+ this.renderer.destroy();
162
151
  this.renderer = null;
163
152
  }
164
153
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trtc-electron-sdk",
3
- "version": "10.9.405",
3
+ "version": "10.9.501-beta.0",
4
4
  "description": "trtc electron sdk",
5
5
  "main": "./liteav/trtc.js",
6
6
  "types": "./liteav/trtc.d.ts",
@@ -3,5 +3,7 @@ module.exports.Platform = {
3
3
  MACOS_ARM: 'mac-arm64',
4
4
  WINDOWS32: 'win32',
5
5
  WINDOWS64: 'win64',
6
- UNSUPPORTED: 'unsupported'
6
+ UNSUPPORTED: 'unsupported',
7
+ LINUX_X64: 'linux-x64',
8
+ LINUX_ARM64: 'linux-arm64',
7
9
  };
@@ -81,8 +81,9 @@ const main = () => {
81
81
  signale.success(`copy success! - ${platform}`);
82
82
 
83
83
  if (platform === Platform.WINDOWS32 || platform === Platform.WINDOWS64) {
84
- rimraf.sync(outputDir); // windows 下
85
- } else {
84
+ // windows 下
85
+ rimraf.sync(outputDir);
86
+ } else if (platform === 'mac' || platform === 'mac-arm64') {
86
87
  // mac 下
87
88
  const arch = archType;
88
89
  fs.copySync(
@@ -133,6 +134,45 @@ const main = () => {
133
134
  .catch(err => {
134
135
  signale.fatal(`download error! - mac ${anotherPlatform}`, err);
135
136
  });
137
+ } else if (platform === 'linux-x64' || platform === 'linux-arm64') {
138
+ // Linux 下
139
+ const arch = process.arch;
140
+ fs.copySync(
141
+ path.join(outputDir, './build/Release'),
142
+ path.join(buildDir, 'Release', arch)
143
+ );
144
+ signale.success(`copy success! - linux ${arch}`, '\n');
145
+
146
+ let anotherPlatform, anotherArch;
147
+ if (arch === 'x64') {
148
+ // download arm64
149
+ anotherPlatform = Platform.LINUX_ARM64;
150
+ anotherArch = 'arm64';
151
+ } else {
152
+ // arch = arm64, download x64
153
+ anotherPlatform = Platform.LINUX_X64;
154
+ anotherArch = 'x64';
155
+ }
156
+ const anotherDownloadUrl = `https://web.sdk.qcloud.com/trtc/electron/download/${name}/${version}/${name}-${anotherPlatform}-${version}.zip`;
157
+ signale.info('Download Url =', anotherDownloadUrl, '\n');
158
+ signale.pending(`Downloading C++ addon Electron SDK... ${anotherArch}\n`);
159
+ download(anotherDownloadUrl, path.join(outputDir, anotherPlatform), {
160
+ strip: 0,
161
+ extract: true
162
+ }).then(() => {
163
+ signale.success(`Download finished - linux ${anotherArch}`);
164
+ fs.copySync(
165
+ path.join(outputDir, anotherPlatform, '/build/Release'),
166
+ path.join(buildDir, 'Release', anotherArch)
167
+ );
168
+ signale.success(`copy success! - linux ${anotherArch}`);
169
+
170
+ rimraf.sync(outputDir);
171
+ }).catch(err => {
172
+ signale.fatal(`download error! - linux ${anotherPlatform}`, err);
173
+ })
174
+ } else {
175
+ signale.warn(`Not supported platform: ${platform}`);
136
176
  }
137
177
  }).catch(err => {
138
178
  signale.fatal(`Failed! Download error - ${platform}`, err);
package/scripts/utils.js CHANGED
@@ -47,13 +47,20 @@ module.exports.detectOS = (archType = '', platformType = '') => {
47
47
  } else {
48
48
  return Platform.MACOS_ARM;
49
49
  }
50
- }
51
- if (platform === 'win32') {
50
+ } else if (platform === 'win32') {
52
51
  if (arch === 'x64') {
53
52
  return Platform.WINDOWS64;
54
53
  } else {
55
54
  return Platform.WINDOWS32;
56
55
  }
56
+ } else if (platform === 'linux') {
57
+ if (arch === 'x64') {
58
+ return Platform.LINUX_X64;
59
+ } else if (arch === 'arm64') {
60
+ return Platform.LINUX_ARM64;
61
+ } else {
62
+ // unsupported
63
+ }
57
64
  }
58
65
  return Platform.UNSUPPORTED;
59
66
  };