trtc-electron-sdk 11.2.118-beta.3 → 11.3.502-beta.1
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/Renderer/Canvas2DRenderer/index.d.ts +1 -0
- package/liteav/Renderer/Canvas2DRenderer/index.js +8 -0
- package/liteav/Renderer/Canvas3DRenderer/index.d.ts +1 -0
- package/liteav/Renderer/Canvas3DRenderer/index.js +11 -1
- package/liteav/Renderer/IRenderer.d.ts +1 -0
- package/liteav/Renderer/VideoRenderer/index.d.ts +1 -0
- package/liteav/Renderer/VideoRenderer/index.js +8 -0
- package/liteav/trtc.d.ts +15 -14
- package/liteav/trtc.js +70 -106
- package/liteav/trtc_define.d.ts +13 -0
- package/liteav/validate-util.d.ts +1 -0
- package/liteav/validate-util.js +5 -1
- package/package.json +1 -1
|
@@ -41,9 +41,13 @@ class Canvas2dRenderer {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
unbind() {
|
|
44
|
+
var _a;
|
|
44
45
|
if (this.viewWrapper && this.viewContainer && this.viewWrapper.parentElement === this.viewContainer) {
|
|
45
46
|
this.viewContainer.removeChild(this.viewWrapper);
|
|
46
47
|
}
|
|
48
|
+
else {
|
|
49
|
+
console.warn("trtc: Canvas2DRenderer unbind error: remove viewWrapper error", this.viewWrapper, this.viewContainer, (_a = this.viewContainer) === null || _a === void 0 ? void 0 : _a.parentElement);
|
|
50
|
+
}
|
|
47
51
|
this.viewContainer = null;
|
|
48
52
|
this.yuv = null;
|
|
49
53
|
}
|
|
@@ -209,6 +213,10 @@ class Canvas2dRenderer {
|
|
|
209
213
|
}
|
|
210
214
|
return data;
|
|
211
215
|
}
|
|
216
|
+
isValid(viewContainer) {
|
|
217
|
+
var _a;
|
|
218
|
+
return viewContainer === this.viewContainer && this.viewContainer === ((_a = this.viewWrapper) === null || _a === void 0 ? void 0 : _a.parentElement);
|
|
219
|
+
}
|
|
212
220
|
destroy() {
|
|
213
221
|
this.unbind();
|
|
214
222
|
this.viewWrapper = null;
|
|
@@ -84,16 +84,22 @@ class Canvas3dRenderer {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
unbind() {
|
|
87
|
-
var _a;
|
|
87
|
+
var _a, _b;
|
|
88
88
|
(_a = this.canvas3DRenderer) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
89
89
|
this.canvas3DRenderer = null;
|
|
90
90
|
if (this.canvas && this.viewWrapper && this.canvas.parentElement === this.viewWrapper) {
|
|
91
91
|
this.viewWrapper.removeChild(this.canvas);
|
|
92
92
|
}
|
|
93
|
+
else {
|
|
94
|
+
console.warn("trtc: Canvas3DRenderer unbind error: remove canvas error", this.canvas, this.viewWrapper);
|
|
95
|
+
}
|
|
93
96
|
this.canvas = null;
|
|
94
97
|
if (this.viewWrapper && this.viewContainer && this.viewWrapper.parentElement === this.viewContainer) {
|
|
95
98
|
this.viewContainer.removeChild(this.viewWrapper);
|
|
96
99
|
}
|
|
100
|
+
else {
|
|
101
|
+
console.warn("trtc: Canvas3DRenderer unbind error: remove viewWrapper error", this.viewWrapper, this.viewContainer, (_b = this.viewContainer) === null || _b === void 0 ? void 0 : _b.parentElement);
|
|
102
|
+
}
|
|
97
103
|
this.viewContainer = null;
|
|
98
104
|
}
|
|
99
105
|
drawFrame(frameData) {
|
|
@@ -198,6 +204,10 @@ class Canvas3dRenderer {
|
|
|
198
204
|
throw new Error('canvas element not exist');
|
|
199
205
|
}
|
|
200
206
|
}
|
|
207
|
+
isValid(viewContainer) {
|
|
208
|
+
var _a;
|
|
209
|
+
return viewContainer === this.viewContainer && this.viewContainer === ((_a = this.viewWrapper) === null || _a === void 0 ? void 0 : _a.parentElement);
|
|
210
|
+
}
|
|
201
211
|
destroy() {
|
|
202
212
|
if (this.viewWrapper) {
|
|
203
213
|
this.unbind();
|
|
@@ -20,6 +20,7 @@ declare class VideoRenderer implements IRenderer {
|
|
|
20
20
|
_drawFrameNonH264(frameData: TFrameData): Promise<void>;
|
|
21
21
|
_getPixelFormat(): string;
|
|
22
22
|
_updateVideoStyle(options: TCanvasImageSourceStyleOptions): void;
|
|
23
|
+
isValid(viewContainer: HTMLElement): boolean;
|
|
23
24
|
destroy(): void;
|
|
24
25
|
}
|
|
25
26
|
export default VideoRenderer;
|
|
@@ -52,9 +52,13 @@ class VideoRenderer {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
unbind() {
|
|
55
|
+
var _a;
|
|
55
56
|
if (this.viewWrapper && this.viewContainer && this.viewWrapper.parentElement === this.viewContainer) {
|
|
56
57
|
this.viewContainer.removeChild(this.viewWrapper);
|
|
57
58
|
}
|
|
59
|
+
else {
|
|
60
|
+
console.warn("trtc: Canvas3DRenderer unbind error: remove viewWrapper error", this.viewWrapper, this.viewContainer, (_a = this.viewContainer) === null || _a === void 0 ? void 0 : _a.parentElement);
|
|
61
|
+
}
|
|
58
62
|
this.viewContainer = null;
|
|
59
63
|
}
|
|
60
64
|
drawFrame(frameData) {
|
|
@@ -140,6 +144,10 @@ class VideoRenderer {
|
|
|
140
144
|
throw new Error('video element not exist');
|
|
141
145
|
}
|
|
142
146
|
}
|
|
147
|
+
isValid(viewContainer) {
|
|
148
|
+
var _a;
|
|
149
|
+
return viewContainer === this.viewContainer && this.viewContainer === ((_a = this.viewWrapper) === null || _a === void 0 ? void 0 : _a.parentElement);
|
|
150
|
+
}
|
|
143
151
|
destroy() {
|
|
144
152
|
this.unbind();
|
|
145
153
|
this.viewWrapper = null;
|
package/liteav/trtc.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { VodPlayer } from './vod_player';
|
|
4
|
-
import { AudioMusicParam, Rect, TRTCAppScene, TRTCAudioEffectParam, TRTCAudioQuality, TRTCBeautyStyle, TRTCDeviceState, TRTCDeviceType, TRTCLogLevel, TRTCRenderParams, TRTCRoleType, TRTCSwitchRoomParam, TRTCVideoBufferType, TRTCVideoFillMode,
|
|
4
|
+
import { AudioMusicParam, Rect, TRTCAppScene, TRTCAudioEffectParam, TRTCAudioQuality, TRTCBeautyStyle, TRTCDeviceState, TRTCDeviceType, TRTCLogLevel, TRTCRenderParams, TRTCRoleType, TRTCSwitchRoomParam, TRTCVideoBufferType, TRTCVideoFillMode, TRTCVideoPixelFormat, TRTCVideoRotation, TRTCVideoStreamType, TRTCWaterMarkSrcType, PluginInfo, TRTCAudioRecordingParams, TRTCScreenCaptureSourceInfo, TRTCScreenCaptureProperty, TRTCSpeedTestParams, TRTCRecordType, TRTCDeviceInfo, TRTCCameraCaptureParams, TRTCImageBuffer, TRTCInitConfig } from './trtc_define';
|
|
5
5
|
export * from './trtc_define';
|
|
6
6
|
export * from './trtc_code';
|
|
7
7
|
export * from './vod_player';
|
|
@@ -20,7 +20,6 @@ export * from './vod_player';
|
|
|
20
20
|
declare class TRTCCloud extends EventEmitter {
|
|
21
21
|
private rtcCloud;
|
|
22
22
|
private videoRendererMap;
|
|
23
|
-
private firstVideoFrameList;
|
|
24
23
|
private playStreamType;
|
|
25
24
|
private localFillMode;
|
|
26
25
|
private remoteFillModeMap;
|
|
@@ -49,12 +48,12 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
49
48
|
private audioQuality;
|
|
50
49
|
private bgmId;
|
|
51
50
|
private playAudioEffectIdList;
|
|
52
|
-
constructor();
|
|
51
|
+
constructor(config?: TRTCInitConfig);
|
|
53
52
|
/**
|
|
54
53
|
* 创建 TRTCCloud 对象单例
|
|
55
54
|
* @returns {TRTCCloud}
|
|
56
55
|
*/
|
|
57
|
-
static getTRTCShareInstance(): TRTCCloud;
|
|
56
|
+
static getTRTCShareInstance(config?: TRTCInitConfig): TRTCCloud;
|
|
58
57
|
/**
|
|
59
58
|
* 释放 TRTCCloud 对象并清理资源
|
|
60
59
|
*/
|
|
@@ -112,8 +111,9 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
112
111
|
* @event TRTCCallback#onWarning
|
|
113
112
|
* @param {Number} warningCode - 警告码
|
|
114
113
|
* @param {String} warningMsg - 警告信息
|
|
114
|
+
* @param {Any} extra - 补充信息
|
|
115
115
|
*/
|
|
116
|
-
handleOnWarning(warningCode: number, warningMsg: string, extra:
|
|
116
|
+
handleOnWarning(warningCode: number, warningMsg: string, extra: any): void;
|
|
117
117
|
/**
|
|
118
118
|
* 已加入房间的回调
|
|
119
119
|
*
|
|
@@ -2269,7 +2269,7 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
2269
2269
|
getKey(uid: string, type: TRTCVideoStreamType): string;
|
|
2270
2270
|
setEnableRenderFrame(enable: boolean): void;
|
|
2271
2271
|
private _getRendererMap;
|
|
2272
|
-
_onRenderFrame
|
|
2272
|
+
private _onRenderFrame;
|
|
2273
2273
|
private _onRealRender;
|
|
2274
2274
|
private _createVideoRenderer;
|
|
2275
2275
|
private _initRenderer;
|
|
@@ -2283,14 +2283,15 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
2283
2283
|
* @private
|
|
2284
2284
|
* @throws {Error}
|
|
2285
2285
|
*/
|
|
2286
|
-
_writefile
|
|
2287
|
-
_writeLog
|
|
2288
|
-
_onUserRenderCallback
|
|
2289
|
-
_initImageData
|
|
2290
|
-
_YUV2RGBA
|
|
2291
|
-
_BGRA2RGBA
|
|
2292
|
-
_RGBA2BGRA
|
|
2293
|
-
_isMacPlatform
|
|
2286
|
+
private _writefile;
|
|
2287
|
+
private _writeLog;
|
|
2288
|
+
private _onUserRenderCallback;
|
|
2289
|
+
private _initImageData;
|
|
2290
|
+
private _YUV2RGBA;
|
|
2291
|
+
private _BGRA2RGBA;
|
|
2292
|
+
private _RGBA2BGRA;
|
|
2293
|
+
private _isMacPlatform;
|
|
2294
|
+
private _setRemoteVideoBuffer;
|
|
2294
2295
|
}
|
|
2295
2296
|
export default TRTCCloud;
|
|
2296
2297
|
export * from './LocalMediaTranscoder';
|
package/liteav/trtc.js
CHANGED
|
@@ -154,15 +154,14 @@ let oriRtcCloud = null;
|
|
|
154
154
|
*/
|
|
155
155
|
class TRTCCloud extends events_1.EventEmitter {
|
|
156
156
|
// 兼容 8.0 以下版本, 记录内部状态变量 --end
|
|
157
|
-
constructor() {
|
|
157
|
+
constructor(config) {
|
|
158
158
|
super();
|
|
159
159
|
const componentNO = getComponentNO();
|
|
160
|
-
oriRtcCloud = new trtc.NodeRTCCloud(pkg.version, componentNO);
|
|
160
|
+
oriRtcCloud = new trtc.NodeRTCCloud(Object.assign({ jsVersion: pkg.version, componentNO }, config));
|
|
161
161
|
this.rtcCloud = Object.assign({}, oriRtcCloud, {
|
|
162
162
|
onlineLog: undefined
|
|
163
163
|
});
|
|
164
164
|
this.videoRendererMap = new Map();
|
|
165
|
-
this.firstVideoFrameList = [];
|
|
166
165
|
this.playStreamType = trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig;
|
|
167
166
|
this.pixelFormat = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
|
|
168
167
|
this.pixelLength = 1.5;
|
|
@@ -187,7 +186,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
187
186
|
this.isScreenCapturing = false;
|
|
188
187
|
this.isCaptureLocalVideoEnabled = false;
|
|
189
188
|
this.videoProcessBufferType = trtc_define_1.TRTCVideoBufferType.TRTCVideoBufferType_Buffer;
|
|
190
|
-
this.videoProcessPixelFormat = trtc_define_1.TRTCVideoPixelFormat.
|
|
189
|
+
this.videoProcessPixelFormat = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
|
|
191
190
|
this.initEventHandler();
|
|
192
191
|
console.log('trtc:constructor pixelFormat:' + this.pixelFormat + '|sdk version:' + pkg.version +
|
|
193
192
|
'|native sdk version:' + this.rtcCloud.getSDKVersion());
|
|
@@ -206,9 +205,9 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
206
205
|
* 创建 TRTCCloud 对象单例
|
|
207
206
|
* @returns {TRTCCloud}
|
|
208
207
|
*/
|
|
209
|
-
static getTRTCShareInstance() {
|
|
208
|
+
static getTRTCShareInstance(config) {
|
|
210
209
|
if (!trtcCloudInstance) {
|
|
211
|
-
trtcCloudInstance = new TRTCCloud();
|
|
210
|
+
trtcCloudInstance = new TRTCCloud(config);
|
|
212
211
|
}
|
|
213
212
|
return trtcCloudInstance;
|
|
214
213
|
}
|
|
@@ -255,7 +254,6 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
255
254
|
* 清理资源
|
|
256
255
|
*/
|
|
257
256
|
destroy() {
|
|
258
|
-
this.firstVideoFrameList = [];
|
|
259
257
|
this.playAudioEffectIdList = [];
|
|
260
258
|
this.remoteFillModeMap.clear();
|
|
261
259
|
// this.destroyLocalMediaTranscoder();
|
|
@@ -478,6 +476,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
478
476
|
* @event TRTCCallback#onWarning
|
|
479
477
|
* @param {Number} warningCode - 警告码
|
|
480
478
|
* @param {String} warningMsg - 警告信息
|
|
479
|
+
* @param {Any} extra - 补充信息
|
|
481
480
|
*/
|
|
482
481
|
handleOnWarning(warningCode, warningMsg, extra) {
|
|
483
482
|
this.fire('onWarning', warningCode, warningMsg, extra);
|
|
@@ -525,7 +524,6 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
525
524
|
* @param {Number} reason - 离开房间原因,0:主动调用 exitRoom 退房;1:被服务器踢出当前房间;2:当前房间整个被解散。
|
|
526
525
|
*/
|
|
527
526
|
handleOnExitRoom(reason) {
|
|
528
|
-
this.firstVideoFrameList = [];
|
|
529
527
|
this.fire('onExitRoom', reason);
|
|
530
528
|
}
|
|
531
529
|
/**
|
|
@@ -635,11 +633,6 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
635
633
|
*/
|
|
636
634
|
handleOnUserVideoAvailable(userId, available) {
|
|
637
635
|
if (available == 0) {
|
|
638
|
-
if (this._isMacPlatform()) {
|
|
639
|
-
this.firstVideoFrameList = this.firstVideoFrameList.filter(function (item) {
|
|
640
|
-
return !(userId === item.uid && item.type !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub);
|
|
641
|
-
});
|
|
642
|
-
}
|
|
643
636
|
const remoteUserVideoBuffers = remoteVideoBufferMap.get(userId);
|
|
644
637
|
if (remoteUserVideoBuffers) {
|
|
645
638
|
if (remoteUserVideoBuffers.big) {
|
|
@@ -666,11 +659,6 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
666
659
|
*/
|
|
667
660
|
handleOnUserSubStreamAvailable(userId, available) {
|
|
668
661
|
if (available == 0) {
|
|
669
|
-
if (this._isMacPlatform()) {
|
|
670
|
-
this.firstVideoFrameList = this.firstVideoFrameList.filter(function (item) {
|
|
671
|
-
return !(userId === item.uid && item.type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub);
|
|
672
|
-
});
|
|
673
|
-
}
|
|
674
662
|
if (screenVideoBufferMap.has(userId)) {
|
|
675
663
|
const targetVideoBuffer = screenVideoBufferMap.get(userId);
|
|
676
664
|
if (targetVideoBuffer && targetVideoBuffer.buffer) {
|
|
@@ -707,6 +695,9 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
707
695
|
* @param {Number} height - 画面高度
|
|
708
696
|
*/
|
|
709
697
|
handleOnFirstVideoFrame(userId, streamType, width, height) {
|
|
698
|
+
if (userId) {
|
|
699
|
+
this._setRemoteVideoBuffer(userId, streamType);
|
|
700
|
+
}
|
|
710
701
|
this.fire('onFirstVideoFrame', userId, streamType, width, height);
|
|
711
702
|
}
|
|
712
703
|
/**
|
|
@@ -1808,9 +1799,6 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1808
1799
|
const key = this.getKey(LOCAL_USER_VIDEO_ID, trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
|
|
1809
1800
|
this._destroyRenderer(key, null);
|
|
1810
1801
|
this.rtcCloud.stopLocalPreview();
|
|
1811
|
-
this.firstVideoFrameList = this.firstVideoFrameList.filter(function (item) {
|
|
1812
|
-
return !('' === item.uid && item.type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
|
|
1813
|
-
});
|
|
1814
1802
|
if (localVideoBuffer.buffer) {
|
|
1815
1803
|
this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, 0, 0, localVideoBuffer.pixelFormat, localVideoBuffer.id);
|
|
1816
1804
|
localVideoBuffer.buffer = null;
|
|
@@ -1920,47 +1908,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1920
1908
|
this._initRenderer(key, views);
|
|
1921
1909
|
// view 为 null 时,可能启动了自定义渲染,所以 Buffer 还是要创建,否则自定义渲染就拿不到数据;
|
|
1922
1910
|
// view 非 null 时,当然必须创建 Buffer
|
|
1923
|
-
|
|
1924
|
-
userId: userId,
|
|
1925
|
-
id: (0, util_1.generateUniqueId)(),
|
|
1926
|
-
streamType: streamType,
|
|
1927
|
-
width: DEFAULT_VIDEO_WIDTH,
|
|
1928
|
-
height: DEFAULT_VIDEO_HEIGHT,
|
|
1929
|
-
pixelFormat: this.pixelFormat,
|
|
1930
|
-
});
|
|
1931
|
-
if (streamType !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub) {
|
|
1932
|
-
const remoteUserVideoBuffers = remoteVideoBufferMap.get(userId);
|
|
1933
|
-
if (!remoteUserVideoBuffers) {
|
|
1934
|
-
// Buffer 不存在时才新建,否则只能在 handleVideoSizeChange 事件中重新申请 Buffer
|
|
1935
|
-
if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig) {
|
|
1936
|
-
remoteVideoBufferMap.set(userId, { big: videoBufferInfo });
|
|
1937
|
-
}
|
|
1938
|
-
else if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall) {
|
|
1939
|
-
remoteVideoBufferMap.set(userId, { small: videoBufferInfo });
|
|
1940
|
-
}
|
|
1941
|
-
this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat, videoBufferInfo.id);
|
|
1942
|
-
}
|
|
1943
|
-
else {
|
|
1944
|
-
if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && !remoteUserVideoBuffers.big) {
|
|
1945
|
-
remoteUserVideoBuffers.big = videoBufferInfo;
|
|
1946
|
-
this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat, videoBufferInfo.id);
|
|
1947
|
-
}
|
|
1948
|
-
else if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && !remoteUserVideoBuffers.small) {
|
|
1949
|
-
remoteUserVideoBuffers.small = videoBufferInfo;
|
|
1950
|
-
this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat, videoBufferInfo.id);
|
|
1951
|
-
}
|
|
1952
|
-
}
|
|
1953
|
-
}
|
|
1954
|
-
else {
|
|
1955
|
-
// 远端屏幕分享
|
|
1956
|
-
// Buffer 为 null 时才新建,否则只能在 handleVideoSizeChange 事件中重新申请 Buffer
|
|
1957
|
-
let targetVideoBuffer = screenVideoBufferMap.get(userId);
|
|
1958
|
-
if (!targetVideoBuffer || !targetVideoBuffer.buffer) {
|
|
1959
|
-
targetVideoBuffer = videoBufferInfo;
|
|
1960
|
-
this.rtcCloud.setSubVideoBuffer(targetVideoBuffer.userId, targetVideoBuffer.buffer, targetVideoBuffer.streamType, targetVideoBuffer.width, targetVideoBuffer.height, targetVideoBuffer.pixelFormat, targetVideoBuffer.id);
|
|
1961
|
-
screenVideoBufferMap.set(userId, targetVideoBuffer);
|
|
1962
|
-
}
|
|
1963
|
-
}
|
|
1911
|
+
this._setRemoteVideoBuffer(userId, streamType);
|
|
1964
1912
|
this.addRemoteVideoRenderCallback(userId);
|
|
1965
1913
|
this.rtcCloud.startRemoteView(userId, streamType);
|
|
1966
1914
|
}
|
|
@@ -2358,29 +2306,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
2358
2306
|
* - TRTCVideoStreamTypeSmall: 小画面视频流
|
|
2359
2307
|
*/
|
|
2360
2308
|
setRemoteVideoStreamType(userId, streamType) {
|
|
2361
|
-
|
|
2362
|
-
if (remoteUserVideoBuffers) {
|
|
2363
|
-
const videoBufferInfo = new trtc_define_1.VideoBufferInfo({
|
|
2364
|
-
userId: userId,
|
|
2365
|
-
id: (0, util_1.generateUniqueId)(),
|
|
2366
|
-
streamType: streamType,
|
|
2367
|
-
width: DEFAULT_VIDEO_WIDTH,
|
|
2368
|
-
height: DEFAULT_VIDEO_HEIGHT,
|
|
2369
|
-
pixelFormat: this.pixelFormat,
|
|
2370
|
-
});
|
|
2371
|
-
if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && !remoteUserVideoBuffers.big) {
|
|
2372
|
-
remoteUserVideoBuffers.big = videoBufferInfo;
|
|
2373
|
-
this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat, videoBufferInfo.id);
|
|
2374
|
-
}
|
|
2375
|
-
else if (streamType === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && !remoteUserVideoBuffers.small) {
|
|
2376
|
-
remoteUserVideoBuffers.small = videoBufferInfo;
|
|
2377
|
-
this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat, videoBufferInfo.id);
|
|
2378
|
-
}
|
|
2379
|
-
else {
|
|
2380
|
-
videoBufferInfo.buffer = null;
|
|
2381
|
-
videoBufferInfo.id = 0;
|
|
2382
|
-
}
|
|
2383
|
-
}
|
|
2309
|
+
this._setRemoteVideoBuffer(userId, streamType);
|
|
2384
2310
|
this.rtcCloud.setRemoteVideoStreamType(userId, streamType);
|
|
2385
2311
|
}
|
|
2386
2312
|
/**
|
|
@@ -3826,9 +3752,6 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3826
3752
|
const key = this.getKey(CAMERA_DEVICE_TEST_VIEW, trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
|
|
3827
3753
|
this._destroyRenderer(key, null);
|
|
3828
3754
|
this.rtcCloud.stopCameraDeviceTest();
|
|
3829
|
-
this.firstVideoFrameList = this.firstVideoFrameList.filter(function (item) {
|
|
3830
|
-
return !('' === item.uid && item.type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
|
|
3831
|
-
});
|
|
3832
3755
|
if (cameraTestVideoBuffer.buffer) {
|
|
3833
3756
|
this.rtcCloud.setCameraTestVideoBuffer(cameraTestVideoBuffer.buffer, 0, 0, cameraTestVideoBuffer.pixelFormat, cameraTestVideoBuffer.id);
|
|
3834
3757
|
cameraTestVideoBuffer.buffer = null;
|
|
@@ -4041,7 +3964,6 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
4041
3964
|
* @ignore
|
|
4042
3965
|
*/
|
|
4043
3966
|
initPluginManager(options) {
|
|
4044
|
-
const defaultPixelFormat = !this._isMacPlatform() ? trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_RGBA32 : trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_BGRA32;
|
|
4045
3967
|
if (options) {
|
|
4046
3968
|
if (options.bufferType && options.bufferType === trtc_define_1.TRTCVideoBufferType.TRTCVideoBufferType_Texture) {
|
|
4047
3969
|
this.videoProcessBufferType = options.bufferType;
|
|
@@ -4053,12 +3975,12 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
4053
3975
|
this.videoProcessPixelFormat = options.pixelFormat;
|
|
4054
3976
|
}
|
|
4055
3977
|
else {
|
|
4056
|
-
this.videoProcessPixelFormat =
|
|
3978
|
+
this.videoProcessPixelFormat = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
|
|
4057
3979
|
}
|
|
4058
3980
|
}
|
|
4059
3981
|
}
|
|
4060
3982
|
else {
|
|
4061
|
-
this.videoProcessPixelFormat =
|
|
3983
|
+
this.videoProcessPixelFormat = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_I420;
|
|
4062
3984
|
this.videoProcessBufferType = trtc_define_1.TRTCVideoBufferType.TRTCVideoBufferType_Buffer;
|
|
4063
3985
|
}
|
|
4064
3986
|
this.rtcCloud.initializePluginManager(this.videoProcessPixelFormat, this.videoProcessBufferType);
|
|
@@ -4137,18 +4059,6 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
4137
4059
|
return this.videoRendererMap.get(key);
|
|
4138
4060
|
}
|
|
4139
4061
|
_onRenderFrame(uid, type, width, height, timestamp, rotation, data) {
|
|
4140
|
-
// 由于 mac 监听自定义渲染回调后不会回调 onFirstVideoFrame ,所以在这里自己实现回调 onFirstVideoFrame
|
|
4141
|
-
if (this._isMacPlatform()) {
|
|
4142
|
-
setImmediate(() => {
|
|
4143
|
-
const index = this.firstVideoFrameList.findIndex(function (item) {
|
|
4144
|
-
return uid === item.uid && type === item.type;
|
|
4145
|
-
});
|
|
4146
|
-
if (index === -1) {
|
|
4147
|
-
this.emit('onFirstVideoFrame', uid, type, width, height);
|
|
4148
|
-
this.firstVideoFrameList.push({ uid: uid, type: type });
|
|
4149
|
-
}
|
|
4150
|
-
});
|
|
4151
|
-
}
|
|
4152
4062
|
if (uid.length == 0 && this.isCaptureLocalVideoEnabled) {
|
|
4153
4063
|
this.fire(LOCAL_VIDEO_DATA, {
|
|
4154
4064
|
uid: '', type, rotation, timestamp,
|
|
@@ -4246,6 +4156,9 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
4246
4156
|
}
|
|
4247
4157
|
}
|
|
4248
4158
|
_createVideoRenderer(view, key) {
|
|
4159
|
+
if (view.childElementCount > 0) {
|
|
4160
|
+
console.warn("trtc: clear HTML element content:", view);
|
|
4161
|
+
}
|
|
4249
4162
|
view.innerHTML = ''; // 事先清空一下,避免画面叠加
|
|
4250
4163
|
const renderer = (0, Renderer_1.createRenderer)(this.pixelFormat, view);
|
|
4251
4164
|
if (key === this.getKey(LOCAL_USER_VIDEO_ID, trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig)) {
|
|
@@ -4262,11 +4175,11 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
4262
4175
|
_initRenderer(key, views) {
|
|
4263
4176
|
let rendererMap = this.videoRendererMap.get(key);
|
|
4264
4177
|
if (rendererMap) {
|
|
4265
|
-
rendererMap.forEach((value,
|
|
4266
|
-
if (views.indexOf(
|
|
4178
|
+
rendererMap.forEach((value, innerKey, map) => {
|
|
4179
|
+
if (views.indexOf(innerKey) === -1 || !value.isValid(innerKey)) {
|
|
4267
4180
|
try {
|
|
4268
4181
|
value.destroy();
|
|
4269
|
-
map.delete(
|
|
4182
|
+
map.delete(innerKey);
|
|
4270
4183
|
}
|
|
4271
4184
|
catch (err) {
|
|
4272
4185
|
console.error("trtc:_initRenderer destroy render error:", err);
|
|
@@ -4440,6 +4353,57 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
4440
4353
|
_isMacPlatform() {
|
|
4441
4354
|
return process.platform == 'darwin';
|
|
4442
4355
|
}
|
|
4356
|
+
_setRemoteVideoBuffer(userId, streamType) {
|
|
4357
|
+
const videoBufferInfo = new trtc_define_1.VideoBufferInfo({
|
|
4358
|
+
userId: userId,
|
|
4359
|
+
id: (0, util_1.generateUniqueId)(),
|
|
4360
|
+
streamType: streamType,
|
|
4361
|
+
width: DEFAULT_VIDEO_WIDTH,
|
|
4362
|
+
height: DEFAULT_VIDEO_HEIGHT,
|
|
4363
|
+
pixelFormat: this.pixelFormat,
|
|
4364
|
+
});
|
|
4365
|
+
const remoteUserVideoBuffers = remoteVideoBufferMap.get(userId);
|
|
4366
|
+
let screenVideoBuffer = screenVideoBufferMap.get(userId);
|
|
4367
|
+
switch (streamType) {
|
|
4368
|
+
case trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig:
|
|
4369
|
+
if (!remoteUserVideoBuffers) {
|
|
4370
|
+
remoteVideoBufferMap.set(userId, { big: videoBufferInfo });
|
|
4371
|
+
}
|
|
4372
|
+
else if (!remoteUserVideoBuffers.big) {
|
|
4373
|
+
remoteUserVideoBuffers.big = videoBufferInfo;
|
|
4374
|
+
}
|
|
4375
|
+
else {
|
|
4376
|
+
videoBufferInfo.buffer = null;
|
|
4377
|
+
}
|
|
4378
|
+
videoBufferInfo.buffer && this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat, videoBufferInfo.id);
|
|
4379
|
+
break;
|
|
4380
|
+
case trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall:
|
|
4381
|
+
if (!remoteUserVideoBuffers) {
|
|
4382
|
+
remoteVideoBufferMap.set(userId, { small: videoBufferInfo });
|
|
4383
|
+
}
|
|
4384
|
+
else if (!remoteUserVideoBuffers.small) {
|
|
4385
|
+
remoteUserVideoBuffers.small = videoBufferInfo;
|
|
4386
|
+
}
|
|
4387
|
+
else {
|
|
4388
|
+
videoBufferInfo.buffer = null;
|
|
4389
|
+
}
|
|
4390
|
+
videoBufferInfo.buffer && this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat, videoBufferInfo.id);
|
|
4391
|
+
break;
|
|
4392
|
+
case trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub:
|
|
4393
|
+
if (!screenVideoBuffer) {
|
|
4394
|
+
screenVideoBuffer = videoBufferInfo;
|
|
4395
|
+
this.rtcCloud.setSubVideoBuffer(screenVideoBuffer.userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, screenVideoBuffer.width, screenVideoBuffer.height, screenVideoBuffer.pixelFormat, screenVideoBuffer.id);
|
|
4396
|
+
screenVideoBufferMap.set(userId, screenVideoBuffer);
|
|
4397
|
+
}
|
|
4398
|
+
else {
|
|
4399
|
+
videoBufferInfo.buffer = null;
|
|
4400
|
+
}
|
|
4401
|
+
break;
|
|
4402
|
+
default:
|
|
4403
|
+
videoBufferInfo.buffer = null;
|
|
4404
|
+
break;
|
|
4405
|
+
}
|
|
4406
|
+
}
|
|
4443
4407
|
}
|
|
4444
4408
|
class VideoRenderCallback {
|
|
4445
4409
|
constructor() {
|
package/liteav/trtc_define.d.ts
CHANGED
|
@@ -822,3 +822,16 @@ export declare class VideoBufferInfo {
|
|
|
822
822
|
pixelFormat: TRTCVideoPixelFormat;
|
|
823
823
|
});
|
|
824
824
|
}
|
|
825
|
+
export interface TRTCInitConfig {
|
|
826
|
+
networkProxy?: {
|
|
827
|
+
host: string;
|
|
828
|
+
port: number;
|
|
829
|
+
username: string;
|
|
830
|
+
password: string;
|
|
831
|
+
config: {
|
|
832
|
+
supportHttps: boolean;
|
|
833
|
+
supportTcp: boolean;
|
|
834
|
+
supportUdp: boolean;
|
|
835
|
+
};
|
|
836
|
+
};
|
|
837
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function isNumber(args: any): boolean;
|
|
2
|
+
export declare function isString(args: any): boolean;
|
|
2
3
|
export declare function isNull(args: any): boolean;
|
|
3
4
|
export declare function isUndefined(args: any): boolean;
|
|
4
5
|
export declare function isExist(args: any): boolean;
|
package/liteav/validate-util.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isExist = exports.isUndefined = exports.isNull = exports.isNumber = void 0;
|
|
3
|
+
exports.isExist = exports.isUndefined = exports.isNull = exports.isString = exports.isNumber = void 0;
|
|
4
4
|
function isNumber(args) {
|
|
5
5
|
return typeof args === 'number';
|
|
6
6
|
}
|
|
7
7
|
exports.isNumber = isNumber;
|
|
8
|
+
function isString(args) {
|
|
9
|
+
return typeof args === 'string';
|
|
10
|
+
}
|
|
11
|
+
exports.isString = isString;
|
|
8
12
|
function isNull(args) {
|
|
9
13
|
return args === null;
|
|
10
14
|
}
|