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.
- package/liteav/vod_player.js +19 -30
- package/package.json +1 -1
- package/scripts/constant.js +3 -1
- package/scripts/download.js +42 -2
- package/scripts/utils.js +9 -2
package/liteav/vod_player.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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.
|
|
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.
|
|
150
|
+
this.renderer.destroy();
|
|
162
151
|
this.renderer = null;
|
|
163
152
|
}
|
|
164
153
|
catch (err) {
|
package/package.json
CHANGED
package/scripts/constant.js
CHANGED
package/scripts/download.js
CHANGED
|
@@ -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
|
-
|
|
85
|
-
|
|
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
|
};
|