trtc-electron-sdk 10.2.0-beta.1 → 10.3.8-beta.2
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 +14 -6
- package/liteav/trtc.js +71 -51
- package/package.json +1 -1
package/liteav/trtc.d.ts
CHANGED
|
@@ -1886,7 +1886,15 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
1886
1886
|
*/
|
|
1887
1887
|
stopSpeedTest(): void;
|
|
1888
1888
|
/**
|
|
1889
|
-
* 13.3
|
|
1889
|
+
* 13.3 设置 SDK 使用的音频设备根据跟随系统默认设备
|
|
1890
|
+
*
|
|
1891
|
+
* @param {TRTCDeviceType} deviceType - 设备类型
|
|
1892
|
+
* @param {Boolean} enable - 是否跟随系统默认的音频设备。 true:跟随, 当系统默认音频设备发生改变时,SDK 立即切换音频设备; false:不跟随, 只有当 SDK 使用的音频设备被移除后或插入新的音频设备为系统默认设备时,SDK 才切换至系统默认的音频设备。
|
|
1893
|
+
*
|
|
1894
|
+
*/
|
|
1895
|
+
enableFollowingDefaultAudioDevice(deviceType: TRTCDeviceType, enable: boolean): void;
|
|
1896
|
+
/**
|
|
1897
|
+
* 13.4 开始进行摄像头测试
|
|
1890
1898
|
*
|
|
1891
1899
|
* 会触发 onFirstVideoFrame 回调接口
|
|
1892
1900
|
*
|
|
@@ -1896,11 +1904,11 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
1896
1904
|
*/
|
|
1897
1905
|
startCameraDeviceTest(view: HTMLElement): void;
|
|
1898
1906
|
/**
|
|
1899
|
-
* 13.
|
|
1907
|
+
* 13.5 停止摄像头测试
|
|
1900
1908
|
*/
|
|
1901
1909
|
stopCameraDeviceTest(): void;
|
|
1902
1910
|
/**
|
|
1903
|
-
* 13.
|
|
1911
|
+
* 13.6 开始进行麦克风测试
|
|
1904
1912
|
*
|
|
1905
1913
|
* 回调接口 onTestMicVolume 获取测试数据
|
|
1906
1914
|
*
|
|
@@ -1910,11 +1918,11 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
1910
1918
|
*/
|
|
1911
1919
|
startMicDeviceTest(interval: number): void;
|
|
1912
1920
|
/**
|
|
1913
|
-
* 13.
|
|
1921
|
+
* 13.7 停止麦克风测试
|
|
1914
1922
|
*/
|
|
1915
1923
|
stopMicDeviceTest(): void;
|
|
1916
1924
|
/**
|
|
1917
|
-
* 13.
|
|
1925
|
+
* 13.8 开始进行扬声器测试
|
|
1918
1926
|
*
|
|
1919
1927
|
* 回调接口 onTestSpeakerVolume 获取测试数据
|
|
1920
1928
|
*
|
|
@@ -1924,7 +1932,7 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
1924
1932
|
*/
|
|
1925
1933
|
startSpeakerDeviceTest(testAudioFilePath: string): void;
|
|
1926
1934
|
/**
|
|
1927
|
-
* 13.
|
|
1935
|
+
* 13.9 停止扬声器测试
|
|
1928
1936
|
*/
|
|
1929
1937
|
stopSpeakerDeviceTest(): void;
|
|
1930
1938
|
/**
|
package/liteav/trtc.js
CHANGED
|
@@ -1040,13 +1040,16 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1040
1040
|
*/
|
|
1041
1041
|
handleOnScreenCaptureStarted() {
|
|
1042
1042
|
this.isScreenCapturing = true;
|
|
1043
|
-
|
|
1044
|
-
screenVideoBuffer.
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1043
|
+
// 只有在 Buffer 为 null 时才新建,否则只能在 onVideoSizeChange 事件中重新申请 Buffer
|
|
1044
|
+
if (!screenVideoBuffer.buffer) {
|
|
1045
|
+
screenVideoBuffer.userId = '';
|
|
1046
|
+
screenVideoBuffer.streamType = this.screenCaptureStreamType;
|
|
1047
|
+
screenVideoBuffer.buffer = (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, screenVideoBuffer.userId, screenVideoBuffer.streamType);
|
|
1048
|
+
screenVideoBuffer.pixelFormat = this.pixelformate;
|
|
1049
|
+
screenVideoBuffer.width = DEFAULT_VIDEO_WIDTH;
|
|
1050
|
+
screenVideoBuffer.height = DEFAULT_VIDEO_HEIGHT;
|
|
1051
|
+
this.rtcCloud.setSubVideoBuffer('', screenVideoBuffer.buffer, screenVideoBuffer.streamType, screenVideoBuffer.width, screenVideoBuffer.height, screenVideoBuffer.pixelFormat);
|
|
1052
|
+
}
|
|
1050
1053
|
this.fire('onScreenCaptureStarted');
|
|
1051
1054
|
}
|
|
1052
1055
|
/**
|
|
@@ -1171,10 +1174,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1171
1174
|
this.fire('onSystemAudioLoopbackError', errCode);
|
|
1172
1175
|
}
|
|
1173
1176
|
handleOnVideoSizeChange(userId, streamType, width, height) {
|
|
1174
|
-
if (
|
|
1175
|
-
return;
|
|
1176
|
-
}
|
|
1177
|
-
if (userId) {
|
|
1177
|
+
if (userId && userId !== CAMERA_DEVICE_TEST_ID) {
|
|
1178
1178
|
if (streamType !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub) {
|
|
1179
1179
|
const videoBufferInfo = remoteVideoBufferMap.get(userId);
|
|
1180
1180
|
if (videoBufferInfo) {
|
|
@@ -1185,9 +1185,6 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1185
1185
|
videoBufferInfo.pixelFormat = this.pixelformate;
|
|
1186
1186
|
this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, streamType, width, height, videoBufferInfo.pixelFormat);
|
|
1187
1187
|
}
|
|
1188
|
-
else {
|
|
1189
|
-
// 宽高尺寸未变,不用重新分配Buffer
|
|
1190
|
-
}
|
|
1191
1188
|
}
|
|
1192
1189
|
else {
|
|
1193
1190
|
console.error(`trtc:onVideoSizeChange error: ${userId} ${streamType} buffer not exist`);
|
|
@@ -1217,17 +1214,8 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1217
1214
|
}
|
|
1218
1215
|
}
|
|
1219
1216
|
else {
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
if (localVideoBuffer.width !== width || localVideoBuffer.height !== height) {
|
|
1223
|
-
localVideoBuffer.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, localVideoBuffer.userId, streamType);
|
|
1224
|
-
localVideoBuffer.width = width;
|
|
1225
|
-
localVideoBuffer.height = height;
|
|
1226
|
-
localVideoBuffer.pixelFormat = this.pixelformate;
|
|
1227
|
-
this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, width, height, localVideoBuffer.pixelFormat);
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
else if (cameraTestVideoBuffer.buffer) {
|
|
1217
|
+
if (userId === CAMERA_DEVICE_TEST_ID) {
|
|
1218
|
+
// 摄像头检测
|
|
1231
1219
|
if (cameraTestVideoBuffer.width !== width || cameraTestVideoBuffer.height !== height) {
|
|
1232
1220
|
cameraTestVideoBuffer.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, cameraTestVideoBuffer.userId, streamType);
|
|
1233
1221
|
cameraTestVideoBuffer.width = width;
|
|
@@ -1236,6 +1224,16 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1236
1224
|
this.rtcCloud.setCameraTestVideoBuffer(cameraTestVideoBuffer.buffer, width, height, cameraTestVideoBuffer.pixelFormat);
|
|
1237
1225
|
}
|
|
1238
1226
|
}
|
|
1227
|
+
else {
|
|
1228
|
+
// 本地摄像头
|
|
1229
|
+
if (localVideoBuffer.width !== width || localVideoBuffer.height !== height) {
|
|
1230
|
+
localVideoBuffer.buffer = (0, util_1.allocBuffer)(width * height * this.pixelLength, localVideoBuffer.userId, streamType);
|
|
1231
|
+
localVideoBuffer.width = width;
|
|
1232
|
+
localVideoBuffer.height = height;
|
|
1233
|
+
localVideoBuffer.pixelFormat = this.pixelformate;
|
|
1234
|
+
this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, width, height, localVideoBuffer.pixelFormat);
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1239
1237
|
}
|
|
1240
1238
|
}
|
|
1241
1239
|
}
|
|
@@ -1601,13 +1599,16 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1601
1599
|
this._initRender(key, view);
|
|
1602
1600
|
}
|
|
1603
1601
|
// view 为 null 时,可能启动了自定义渲染,所以 Buffer 还是要创建,否则自定义渲染就拿不到数据;
|
|
1604
|
-
// view 非 null 时,当然必须创建 Buffer
|
|
1605
|
-
|
|
1606
|
-
localVideoBuffer.buffer
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1602
|
+
// view 非 null 时,当然必须创建 Buffer
|
|
1603
|
+
// 只有在 Buffer 为 null 时才新建,否则只能在 onVideoSizeChange 事件中重新申请 Buffer
|
|
1604
|
+
if (!localVideoBuffer.buffer) {
|
|
1605
|
+
localVideoBuffer.streamType = trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig;
|
|
1606
|
+
localVideoBuffer.buffer = (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, localVideoBuffer.userId, localVideoBuffer.streamType);
|
|
1607
|
+
localVideoBuffer.pixelFormat = this.pixelformate;
|
|
1608
|
+
localVideoBuffer.width = DEFAULT_VIDEO_WIDTH;
|
|
1609
|
+
localVideoBuffer.height = DEFAULT_VIDEO_HEIGHT;
|
|
1610
|
+
this.rtcCloud.setLocalVideoBuffer(localVideoBuffer.buffer, localVideoBuffer.width, localVideoBuffer.height, localVideoBuffer.pixelFormat);
|
|
1611
|
+
}
|
|
1611
1612
|
this.rtcCloud.startLocalPreview();
|
|
1612
1613
|
this.addLocalVideoRenderCallback();
|
|
1613
1614
|
}
|
|
@@ -1670,7 +1671,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1670
1671
|
this._initRender(key, view);
|
|
1671
1672
|
}
|
|
1672
1673
|
// view 为 null 时,可能启动了自定义渲染,所以 Buffer 还是要创建,否则自定义渲染就拿不到数据;
|
|
1673
|
-
// view 非 null 时,当然必须创建 Buffer
|
|
1674
|
+
// view 非 null 时,当然必须创建 Buffer
|
|
1674
1675
|
const videoBufferInfo = {
|
|
1675
1676
|
userId: userId,
|
|
1676
1677
|
buffer: (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, userId, streamType),
|
|
@@ -1680,13 +1681,19 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1680
1681
|
pixelFormat: this.pixelformate,
|
|
1681
1682
|
};
|
|
1682
1683
|
if (streamType !== trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub) {
|
|
1683
|
-
remoteVideoBufferMap.
|
|
1684
|
-
|
|
1684
|
+
if (!remoteVideoBufferMap.get(userId)) {
|
|
1685
|
+
// Buffer 不存在时才新建,否则只能在 onVideoSizeChange 事件中重新申请 Buffer
|
|
1686
|
+
remoteVideoBufferMap.set(userId, videoBufferInfo);
|
|
1687
|
+
this.rtcCloud.setRemoteVideoBuffer(userId, videoBufferInfo.buffer, videoBufferInfo.streamType, videoBufferInfo.width, videoBufferInfo.height, videoBufferInfo.pixelFormat);
|
|
1688
|
+
}
|
|
1685
1689
|
}
|
|
1686
1690
|
else {
|
|
1687
1691
|
// 远端屏幕分享
|
|
1688
|
-
|
|
1689
|
-
|
|
1692
|
+
// Buffer 为 null 时才新建,否则只能在 onVideoSizeChange 事件中重新申请 Buffer
|
|
1693
|
+
if (!screenVideoBuffer.buffer) {
|
|
1694
|
+
Object.assign(screenVideoBuffer, videoBufferInfo);
|
|
1695
|
+
this.rtcCloud.setSubVideoBuffer(screenVideoBuffer.userId, screenVideoBuffer.buffer, screenVideoBuffer.streamType, screenVideoBuffer.width, screenVideoBuffer.height, screenVideoBuffer.pixelFormat);
|
|
1696
|
+
}
|
|
1690
1697
|
}
|
|
1691
1698
|
this.addRemoteVideoRenderCallback(userId);
|
|
1692
1699
|
this.rtcCloud.startRemoteView(userId, streamType);
|
|
@@ -3220,7 +3227,17 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3220
3227
|
this.rtcCloud.stopSpeedTest();
|
|
3221
3228
|
}
|
|
3222
3229
|
/**
|
|
3223
|
-
* 13.3
|
|
3230
|
+
* 13.3 设置 SDK 使用的音频设备根据跟随系统默认设备
|
|
3231
|
+
*
|
|
3232
|
+
* @param {TRTCDeviceType} deviceType - 设备类型
|
|
3233
|
+
* @param {Boolean} enable - 是否跟随系统默认的音频设备。 true:跟随, 当系统默认音频设备发生改变时,SDK 立即切换音频设备; false:不跟随, 只有当 SDK 使用的音频设备被移除后或插入新的音频设备为系统默认设备时,SDK 才切换至系统默认的音频设备。
|
|
3234
|
+
*
|
|
3235
|
+
*/
|
|
3236
|
+
enableFollowingDefaultAudioDevice(deviceType, enable) {
|
|
3237
|
+
this.rtcCloud.enableFollowingDefaultAudioDevice(deviceType, enable);
|
|
3238
|
+
}
|
|
3239
|
+
/**
|
|
3240
|
+
* 13.4 开始进行摄像头测试
|
|
3224
3241
|
*
|
|
3225
3242
|
* 会触发 onFirstVideoFrame 回调接口
|
|
3226
3243
|
*
|
|
@@ -3236,13 +3253,16 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3236
3253
|
const renderer = this.streams.get(key);
|
|
3237
3254
|
renderer.setContentMode(trtc_define_1.TRTCVideoFillMode.TRTCVideoFillMode_Fill);
|
|
3238
3255
|
}
|
|
3239
|
-
|
|
3240
|
-
cameraTestVideoBuffer.
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3256
|
+
// Buffer 为 null 时才新建,否则只能在 onVideoSizeChange 事件中重新申请 Buffer
|
|
3257
|
+
if (!cameraTestVideoBuffer.buffer) {
|
|
3258
|
+
const streamType = trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig;
|
|
3259
|
+
cameraTestVideoBuffer.streamType = streamType;
|
|
3260
|
+
cameraTestVideoBuffer.pixelFormat = this.pixelformate;
|
|
3261
|
+
cameraTestVideoBuffer.buffer = (0, util_1.allocBuffer)(DEFAULT_VIDEO_WIDTH * DEFAULT_VIDEO_HEIGHT * this.pixelLength, cameraTestVideoBuffer.userId, streamType);
|
|
3262
|
+
cameraTestVideoBuffer.width = DEFAULT_VIDEO_WIDTH;
|
|
3263
|
+
cameraTestVideoBuffer.height = DEFAULT_VIDEO_HEIGHT;
|
|
3264
|
+
this.rtcCloud.setCameraTestVideoBuffer(cameraTestVideoBuffer.buffer, cameraTestVideoBuffer.width, cameraTestVideoBuffer.height, cameraTestVideoBuffer.pixelFormat);
|
|
3265
|
+
}
|
|
3246
3266
|
this.rtcCloud.startCameraDeviceTest((id, type, width, height, timestamp, rotation) => {
|
|
3247
3267
|
if (this.enableRenderFrame) {
|
|
3248
3268
|
this._onRenderFrame(id, type, width, height, timestamp, rotation, cameraTestVideoBuffer.buffer);
|
|
@@ -3254,7 +3274,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3254
3274
|
}
|
|
3255
3275
|
}
|
|
3256
3276
|
/**
|
|
3257
|
-
* 13.
|
|
3277
|
+
* 13.5 停止摄像头测试
|
|
3258
3278
|
*/
|
|
3259
3279
|
stopCameraDeviceTest() {
|
|
3260
3280
|
let key = this.getKey(CAMERA_DEVICE_TEST_VIEW, trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
|
|
@@ -3269,7 +3289,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3269
3289
|
}
|
|
3270
3290
|
}
|
|
3271
3291
|
/**
|
|
3272
|
-
* 13.
|
|
3292
|
+
* 13.6 开始进行麦克风测试
|
|
3273
3293
|
*
|
|
3274
3294
|
* 回调接口 onTestMicVolume 获取测试数据
|
|
3275
3295
|
*
|
|
@@ -3281,13 +3301,13 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3281
3301
|
this.rtcCloud.startMicDeviceTest(interval);
|
|
3282
3302
|
}
|
|
3283
3303
|
/**
|
|
3284
|
-
* 13.
|
|
3304
|
+
* 13.7 停止麦克风测试
|
|
3285
3305
|
*/
|
|
3286
3306
|
stopMicDeviceTest() {
|
|
3287
3307
|
this.rtcCloud.stopMicDeviceTest();
|
|
3288
3308
|
}
|
|
3289
3309
|
/**
|
|
3290
|
-
* 13.
|
|
3310
|
+
* 13.8 开始进行扬声器测试
|
|
3291
3311
|
*
|
|
3292
3312
|
* 回调接口 onTestSpeakerVolume 获取测试数据
|
|
3293
3313
|
*
|
|
@@ -3300,7 +3320,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3300
3320
|
this.rtcCloud.startSpeakerDeviceTest(testAudioFilePath);
|
|
3301
3321
|
}
|
|
3302
3322
|
/**
|
|
3303
|
-
* 13.
|
|
3323
|
+
* 13.9 停止扬声器测试
|
|
3304
3324
|
*/
|
|
3305
3325
|
stopSpeakerDeviceTest() {
|
|
3306
3326
|
this.rtcCloud.stopSpeakerDeviceTest();
|
|
@@ -3768,7 +3788,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3768
3788
|
renderer = new Render_1.default.RGBRenderer(); // RGBA32 Canvas 2D
|
|
3769
3789
|
}
|
|
3770
3790
|
else if (this.renderMode === 4) {
|
|
3771
|
-
renderer = new Render_1.default.Canvas3DRGBARenderer(); // RGBA canvas 3D
|
|
3791
|
+
renderer = new Render_1.default.Canvas3DRGBARenderer(); // RGBA canvas 3D
|
|
3772
3792
|
}
|
|
3773
3793
|
else if (this.renderMode === 5) {
|
|
3774
3794
|
renderer = new Render_1.default.I420VideoRenderer(); // I420 video(html)
|