trtc-electron-sdk 11.7.603 → 11.8.112-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/VideoRenderControl/LocalVideoRenderController.d.ts +21 -0
- package/liteav/VideoRenderControl/LocalVideoRenderController.js +82 -0
- package/liteav/VideoRenderControl/type.d.ts +4 -0
- package/liteav/VideoRenderControl/type.js +8 -0
- package/liteav/logger.js +1 -1
- package/liteav/trtc.d.ts +53 -3
- package/liteav/trtc.js +105 -39
- package/liteav/trtc_define.d.ts +73 -6
- package/liteav/trtc_define.js +48 -6
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import TRTCCloud from '../trtc';
|
|
2
|
+
declare class LocalVideoRenderController {
|
|
3
|
+
private logPrefix;
|
|
4
|
+
private trtcCloud;
|
|
5
|
+
private currentState;
|
|
6
|
+
private isExternalRenderEnabled;
|
|
7
|
+
private isLocalPreviewStarted;
|
|
8
|
+
private hasLocalPreviewView;
|
|
9
|
+
private isLocalSharingStarted;
|
|
10
|
+
private hasLocalSharingView;
|
|
11
|
+
constructor(trtcCloud: TRTCCloud);
|
|
12
|
+
startLocalPreview(views: Array<HTMLElement> | HTMLElement | null): void;
|
|
13
|
+
stopLocalPreview(): void;
|
|
14
|
+
updateLocalView(views: Array<HTMLElement> | HTMLElement | null): void;
|
|
15
|
+
startScreenCapture(view?: HTMLElement | null): void;
|
|
16
|
+
stopScreenCapture(): void;
|
|
17
|
+
setExternalRenderEnabled(enabled: boolean): void;
|
|
18
|
+
private update;
|
|
19
|
+
private calcTargetState;
|
|
20
|
+
}
|
|
21
|
+
export default LocalVideoRenderController;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const type_1 = require("./type");
|
|
7
|
+
const logger_1 = __importDefault(require("../logger"));
|
|
8
|
+
class LocalVideoRenderController {
|
|
9
|
+
constructor(trtcCloud) {
|
|
10
|
+
this.logPrefix = '[LocalVideoRenderController]';
|
|
11
|
+
this.trtcCloud = trtcCloud;
|
|
12
|
+
this.currentState = type_1.LocalVideoRenderCallbackState.NotListening;
|
|
13
|
+
this.isExternalRenderEnabled = false;
|
|
14
|
+
this.isLocalPreviewStarted = false;
|
|
15
|
+
this.hasLocalPreviewView = false;
|
|
16
|
+
this.isLocalSharingStarted = false;
|
|
17
|
+
this.hasLocalSharingView = false;
|
|
18
|
+
}
|
|
19
|
+
startLocalPreview(views) {
|
|
20
|
+
this.isLocalPreviewStarted = true;
|
|
21
|
+
this.hasLocalPreviewView = views !== null && views !== undefined;
|
|
22
|
+
if (Array.isArray(views)) {
|
|
23
|
+
this.hasLocalPreviewView = views.length >= 1;
|
|
24
|
+
}
|
|
25
|
+
this.update();
|
|
26
|
+
}
|
|
27
|
+
stopLocalPreview() {
|
|
28
|
+
this.isLocalPreviewStarted = false;
|
|
29
|
+
this.hasLocalPreviewView = false;
|
|
30
|
+
this.update();
|
|
31
|
+
}
|
|
32
|
+
updateLocalView(views) {
|
|
33
|
+
this.hasLocalPreviewView = views !== null && views !== undefined;
|
|
34
|
+
if (Array.isArray(views)) {
|
|
35
|
+
this.hasLocalPreviewView = views.length >= 1;
|
|
36
|
+
}
|
|
37
|
+
this.update();
|
|
38
|
+
}
|
|
39
|
+
startScreenCapture(view = null) {
|
|
40
|
+
this.isLocalSharingStarted = true;
|
|
41
|
+
this.hasLocalSharingView = view !== null && view !== undefined;
|
|
42
|
+
this.update();
|
|
43
|
+
}
|
|
44
|
+
stopScreenCapture() {
|
|
45
|
+
this.isLocalSharingStarted = false;
|
|
46
|
+
this.hasLocalSharingView = false;
|
|
47
|
+
this.update();
|
|
48
|
+
}
|
|
49
|
+
setExternalRenderEnabled(enabled) {
|
|
50
|
+
this.isExternalRenderEnabled = enabled;
|
|
51
|
+
}
|
|
52
|
+
update() {
|
|
53
|
+
const targetState = this.calcTargetState();
|
|
54
|
+
if (targetState !== this.currentState) {
|
|
55
|
+
if (targetState === type_1.LocalVideoRenderCallbackState.NotListening) {
|
|
56
|
+
logger_1.default.log(`${this.logPrefix}update not listening`);
|
|
57
|
+
this.trtcCloud.removeLocalVideoRenderCallback();
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
logger_1.default.log(`${this.logPrefix}update listening`);
|
|
61
|
+
this.trtcCloud.addLocalVideoRenderCallback();
|
|
62
|
+
}
|
|
63
|
+
this.currentState = targetState;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
calcTargetState() {
|
|
70
|
+
if (this.isExternalRenderEnabled) {
|
|
71
|
+
return type_1.LocalVideoRenderCallbackState.Listening;
|
|
72
|
+
}
|
|
73
|
+
if (this.isLocalPreviewStarted && this.hasLocalPreviewView) {
|
|
74
|
+
return type_1.LocalVideoRenderCallbackState.Listening;
|
|
75
|
+
}
|
|
76
|
+
if (this.isLocalSharingStarted && this.hasLocalSharingView) {
|
|
77
|
+
return type_1.LocalVideoRenderCallbackState.Listening;
|
|
78
|
+
}
|
|
79
|
+
return type_1.LocalVideoRenderCallbackState.NotListening;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.default = LocalVideoRenderController;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocalVideoRenderCallbackState = void 0;
|
|
4
|
+
var LocalVideoRenderCallbackState;
|
|
5
|
+
(function (LocalVideoRenderCallbackState) {
|
|
6
|
+
LocalVideoRenderCallbackState[LocalVideoRenderCallbackState["Listening"] = 1] = "Listening";
|
|
7
|
+
LocalVideoRenderCallbackState[LocalVideoRenderCallbackState["NotListening"] = 2] = "NotListening";
|
|
8
|
+
})(LocalVideoRenderCallbackState = exports.LocalVideoRenderCallbackState || (exports.LocalVideoRenderCallbackState = {}));
|
package/liteav/logger.js
CHANGED
package/liteav/trtc.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { TRTCConfig } from './Renderer/util';
|
|
4
|
-
import { AudioMusicParam, Rect, TRTCAppScene, TRTCAudioEffectParam, TRTCAudioQuality, TRTCBeautyStyle, TRTCDeviceState, TRTCDeviceType, TRTCLogLevel, TRTCRenderParams, TRTCRoleType, TRTCSpeedTestResult, TRTCStatistics, TRTCSwitchRoomParam, TRTCVideoBufferType, TRTCVideoFillMode, TRTCAudioFrame, TRTCVideoPixelFormat, TRTCVideoRotation, TRTCVideoStreamType, TRTCVolumeInfo, TRTCWaterMarkSrcType, TRTCQualityInfo, TRTCPluginType, TRTCPluginInfo, TRTCVideoProcessPluginOptions, TRTCMediaEncryptDecryptPluginOptions, TRTCAudioRecordingParams, TRTCScreenCaptureSourceInfo, TRTCScreenCaptureProperty, TRTCSpeedTestParams, TRTCRecordType, TRTCDeviceInfo, TRTCCameraCaptureParams, TRTCImageBuffer, TRTCInitConfig, TRTCAudioParallelParams, TRTCVoiceReverbType, TRTCMusicPlayObserver } from './trtc_define';
|
|
4
|
+
import { AudioMusicParam, Rect, TRTCAppScene, TRTCAudioEffectParam, TRTCAudioQuality, TRTCBeautyStyle, TRTCDeviceState, TRTCDeviceType, TRTCLogLevel, TRTCRenderParams, TRTCRoleType, TRTCSpeedTestResult, TRTCStatistics, TRTCSwitchRoomParam, TRTCVideoBufferType, TRTCVideoFillMode, TRTCAudioFrame, TRTCVideoPixelFormat, TRTCVideoRotation, TRTCVideoStreamType, TRTCVolumeInfo, TRTCWaterMarkSrcType, TRTCQualityInfo, TRTCPluginType, TRTCPluginInfo, TRTCVideoProcessPluginOptions, TRTCMediaEncryptDecryptPluginOptions, TRTCAudioRecordingParams, TRTCScreenCaptureSourceInfo, TRTCScreenCaptureProperty, TRTCSpeedTestParams, TRTCRecordType, TRTCDeviceInfo, TRTCCameraCaptureParams, TRTCImageBuffer, TRTCInitConfig, TRTCAudioParallelParams, TRTCVoiceReverbType, TRTCMusicPlayObserver, TRTCAudioFrameCallback } from './trtc_define';
|
|
5
5
|
export * from './trtc_define';
|
|
6
6
|
export * from './trtc_code';
|
|
7
7
|
export * from './vod_player';
|
|
@@ -40,6 +40,7 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
40
40
|
private videoProcessBufferType;
|
|
41
41
|
private videoProcessPixelFormat;
|
|
42
42
|
private videoRenderFPS;
|
|
43
|
+
private localVideoRenderController;
|
|
43
44
|
private localRotation;
|
|
44
45
|
private localMirrorType;
|
|
45
46
|
private remoteMainStreamFillMode;
|
|
@@ -1895,6 +1896,51 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
1895
1896
|
* @returns {Number} - 时间戳(单位:ms)
|
|
1896
1897
|
*/
|
|
1897
1898
|
generateCustomPTS(): number;
|
|
1899
|
+
/**
|
|
1900
|
+
* 设置音频数据自定义回调
|
|
1901
|
+
*
|
|
1902
|
+
* 设置该回调之后,SDK 内部会把音频数据(PCM 格式)回调出来,包括:
|
|
1903
|
+
* {onCapturedAudioFrame}:本地麦克风采集到的音频数据回调
|
|
1904
|
+
* - {onLocalProcessedAudioFrame}:本地采集并经过音频模块前处理后的音频数据回调
|
|
1905
|
+
* - {onPlayAudioFrame}:混音前的每一路远程用户的音频数据
|
|
1906
|
+
* - {onMixedPlayAudioFrame}:将各路音频混合之后并最终要由系统播放出的音频数据回调
|
|
1907
|
+
* - {onMixedAllAudioFrame}:SDK 所有音频混合后的音频数据(包括采集到的和待播放的)
|
|
1908
|
+
*
|
|
1909
|
+
* 注意: 设置回调为空即代表停止自定义音频回调,反之,设置回调不为空则代表启动自定义音频回调。
|
|
1910
|
+
*
|
|
1911
|
+
* @example
|
|
1912
|
+
* import TRTCCloud from 'trtc-electron-sdk';
|
|
1913
|
+
*
|
|
1914
|
+
* const rtcCloud = TRTCCloud.getTRTCShareInstance();
|
|
1915
|
+
*
|
|
1916
|
+
* onCapturedAudioFrame(frame: TRTCAudioFrame) {}
|
|
1917
|
+
* onLocalProcessedAudioFrame(frame: TRTCAudioFrame) {}
|
|
1918
|
+
* onPlayAudioFrame(frame: TRTCAudioFrame, userId: string) {}
|
|
1919
|
+
* onMixedPlayAudioFrame(frame: TRTCAudioFrame) {}
|
|
1920
|
+
* onMixedAllAudioFrame(frame: TRTCAudioFrame) {}
|
|
1921
|
+
*
|
|
1922
|
+
* // 设置音频数据自定义回调
|
|
1923
|
+
* rtcCloud.setAudioFrameCallback({
|
|
1924
|
+
* onCapturedAudioFrame: onCapturedAudioFrame,
|
|
1925
|
+
* onLocalProcessedAudioFrame: onLocalProcessedAudioFrame,
|
|
1926
|
+
* onPlayAudioFrame: onPlayAudioFrame,
|
|
1927
|
+
* onMixedPlayAudioFrame: onMixedPlayAudioFrame,
|
|
1928
|
+
* onMixedAllAudioFrame: onMixedAllAudioFrame,
|
|
1929
|
+
* });
|
|
1930
|
+
*
|
|
1931
|
+
* // 取消音频数据自定义回调
|
|
1932
|
+
* rtcCloud.setAudioFrameCallback({
|
|
1933
|
+
* onCapturedAudioFrame: null,
|
|
1934
|
+
* onLocalProcessedAudioFrame: null,
|
|
1935
|
+
* onPlayAudioFrame: null,
|
|
1936
|
+
* onMixedPlayAudioFrame: null,
|
|
1937
|
+
* onMixedAllAudioFrame: null,
|
|
1938
|
+
* });
|
|
1939
|
+
*
|
|
1940
|
+
* @param {TRTCAudioFrameCallback} callback - 音频数据自定义回调对象。
|
|
1941
|
+
*
|
|
1942
|
+
*/
|
|
1943
|
+
setAudioFrameCallback(callback: TRTCAudioFrameCallback): void;
|
|
1898
1944
|
/**
|
|
1899
1945
|
* @private
|
|
1900
1946
|
* 设置本地视频自定义渲染(Electron 平台下不可用)
|
|
@@ -1906,7 +1952,7 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
1906
1952
|
* @param {Fuction} callback 自定义渲染回调
|
|
1907
1953
|
* @return {Number} 0:成功;<0:错误
|
|
1908
1954
|
*/
|
|
1909
|
-
setLocalVideoRenderCallback(pixelFormat: TRTCVideoPixelFormat, bufferType: TRTCVideoBufferType, callback: () => void):
|
|
1955
|
+
setLocalVideoRenderCallback(pixelFormat: TRTCVideoPixelFormat, bufferType: TRTCVideoBufferType, callback: () => void): number;
|
|
1910
1956
|
/**
|
|
1911
1957
|
* @private
|
|
1912
1958
|
* 设置远端视频自定义渲染(Electron 平台下不可用)
|
|
@@ -1921,7 +1967,7 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
1921
1967
|
* @param {Function} callback 自定义渲染回调
|
|
1922
1968
|
* @return {Number} 0:成功;<0:错误
|
|
1923
1969
|
*/
|
|
1924
|
-
setRemoteVideoRenderCallback(userId: string, pixelFormat: TRTCVideoPixelFormat, bufferType: TRTCVideoBufferType, callback: () => void):
|
|
1970
|
+
setRemoteVideoRenderCallback(userId: string, pixelFormat: TRTCVideoPixelFormat, bufferType: TRTCVideoBufferType, callback: () => void): number;
|
|
1925
1971
|
/**
|
|
1926
1972
|
* 发送自定义消息给房间内所有用户
|
|
1927
1973
|
*
|
|
@@ -2359,8 +2405,12 @@ declare class TRTCCloud extends EventEmitter {
|
|
|
2359
2405
|
* @param {String} jsonStr - 接口及参数描述的 JSON 字符串
|
|
2360
2406
|
*/
|
|
2361
2407
|
callExperimentalAPI(jsonStr: string): void;
|
|
2408
|
+
private _localVideoRenderCallback;
|
|
2362
2409
|
addLocalVideoRenderCallback(): void;
|
|
2410
|
+
removeLocalVideoRenderCallback(): void;
|
|
2411
|
+
private _remoteVideoRenderCallback;
|
|
2363
2412
|
addRemoteVideoRenderCallback(userId: string): void;
|
|
2413
|
+
removeRemoteVideoRenderCallback(userId: string): void;
|
|
2364
2414
|
/**
|
|
2365
2415
|
* 废弃接口:选择绘制的模式 (webgl/yuvcanvs/)
|
|
2366
2416
|
*
|
package/liteav/trtc.js
CHANGED
|
@@ -35,6 +35,7 @@ const YCbCr_1 = __importDefault(require("yuv-canvas/src/YCbCr"));
|
|
|
35
35
|
const trtc_define_1 = require("./trtc_define");
|
|
36
36
|
const validate_util_1 = require("./validate-util");
|
|
37
37
|
const logger_1 = __importStar(require("./logger"));
|
|
38
|
+
const LocalVideoRenderController_1 = __importDefault(require("./VideoRenderControl/LocalVideoRenderController"));
|
|
38
39
|
const NodeTRTCEngine = require('../build/Release/trtc_electron_sdk.node');
|
|
39
40
|
const pkg = require('../package.json');
|
|
40
41
|
__exportStar(require("./trtc_define"), exports);
|
|
@@ -206,6 +207,9 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
206
207
|
this.videoRenderFPS = 15;
|
|
207
208
|
this.setVideoRenderFPS(this.videoRenderFPS);
|
|
208
209
|
this.callExperimentalAPI("{\"api\":\"setCurrentEnvironment\",\"params\" :{\"electron\":true}}");
|
|
210
|
+
this._localVideoRenderCallback = this._localVideoRenderCallback.bind(this);
|
|
211
|
+
this._remoteVideoRenderCallback = this._remoteVideoRenderCallback.bind(this);
|
|
212
|
+
this.localVideoRenderController = new LocalVideoRenderController_1.default(this);
|
|
209
213
|
if (!TRTCCloud.sharedTRTCCloudInstance) {
|
|
210
214
|
TRTCCloud.sharedTRTCCloudInstance = this;
|
|
211
215
|
}
|
|
@@ -277,6 +281,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
277
281
|
}
|
|
278
282
|
setExternalRenderEnabled(enabled) {
|
|
279
283
|
this.isExternalRenderEnabled = enabled;
|
|
284
|
+
this.localVideoRenderController.setExternalRenderEnabled(enabled);
|
|
280
285
|
if (this.isExternalRenderEnabled) {
|
|
281
286
|
this.pixelFormat = trtc_define_1.TRTCVideoPixelFormat.TRTCVideoPixelFormat_RGBA32;
|
|
282
287
|
this.pixelLength = 4;
|
|
@@ -1792,7 +1797,6 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1792
1797
|
this.rtcCloud.setLocalVideoBuffer('', this.localVideoBufferMap.big.buffer, trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig, this.localVideoBufferMap.big.width, this.localVideoBufferMap.big.height, this.localVideoBufferMap.big.pixelFormat, this.localVideoBufferMap.big.id);
|
|
1793
1798
|
}
|
|
1794
1799
|
this.rtcCloud.startLocalPreview();
|
|
1795
|
-
this.addLocalVideoRenderCallback();
|
|
1796
1800
|
}
|
|
1797
1801
|
/**
|
|
1798
1802
|
* 启动本地摄像头采集和预览
|
|
@@ -1817,6 +1821,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1817
1821
|
else {
|
|
1818
1822
|
this._startLocalPreview([]);
|
|
1819
1823
|
}
|
|
1824
|
+
this.localVideoRenderController.startLocalPreview(views);
|
|
1820
1825
|
}
|
|
1821
1826
|
else {
|
|
1822
1827
|
this.logger.error('startLocalPreview parameter is undefined, it should be Array<HTMLElement>, HTMLElement or null');
|
|
@@ -1829,6 +1834,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1829
1834
|
this.logger.debug(`stopLocalPreview`);
|
|
1830
1835
|
const key = this._getKey(LOCAL_USER_VIDEO_ID, trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig);
|
|
1831
1836
|
this._destroyRenderer(key, null);
|
|
1837
|
+
this.localVideoRenderController.stopLocalPreview();
|
|
1832
1838
|
this.rtcCloud.stopLocalPreview();
|
|
1833
1839
|
if (this.localVideoBufferMap.big.buffer) {
|
|
1834
1840
|
this.rtcCloud.setLocalVideoBuffer('', this.localVideoBufferMap.big.buffer, trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig, 0, 0, this.localVideoBufferMap.big.pixelFormat, this.localVideoBufferMap.big.id);
|
|
@@ -1862,6 +1868,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
1862
1868
|
else {
|
|
1863
1869
|
this._destroyRenderer(key, null);
|
|
1864
1870
|
}
|
|
1871
|
+
this.localVideoRenderController.updateLocalView(views);
|
|
1865
1872
|
}
|
|
1866
1873
|
else {
|
|
1867
1874
|
this.logger.error('updateLocalView parameter is undefined, it should be Array<HTMLElement>, HTMLElement or null');
|
|
@@ -3142,7 +3149,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3142
3149
|
const key = this._getKey(LOCAL_USER_VIDEO_ID, type);
|
|
3143
3150
|
this._initRenderer(key, [view]);
|
|
3144
3151
|
}
|
|
3145
|
-
this.
|
|
3152
|
+
this.localVideoRenderController.startScreenCapture(view);
|
|
3146
3153
|
}
|
|
3147
3154
|
if (params) {
|
|
3148
3155
|
this.rtcCloud.startScreenCapture(type, params);
|
|
@@ -3169,6 +3176,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3169
3176
|
stopScreenCapture() {
|
|
3170
3177
|
const key = this._getKey(LOCAL_USER_VIDEO_ID, this.screenCaptureStreamType);
|
|
3171
3178
|
this._destroyRenderer(key, null);
|
|
3179
|
+
this.localVideoRenderController.stopScreenCapture();
|
|
3172
3180
|
this.rtcCloud.stopScreenCapture();
|
|
3173
3181
|
this.screenCaptureStreamType = trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub;
|
|
3174
3182
|
}
|
|
@@ -3387,6 +3395,53 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3387
3395
|
generateCustomPTS() {
|
|
3388
3396
|
return this.rtcCloud.generateCustomPTS();
|
|
3389
3397
|
}
|
|
3398
|
+
/**
|
|
3399
|
+
* 设置音频数据自定义回调
|
|
3400
|
+
*
|
|
3401
|
+
* 设置该回调之后,SDK 内部会把音频数据(PCM 格式)回调出来,包括:
|
|
3402
|
+
* {onCapturedAudioFrame}:本地麦克风采集到的音频数据回调
|
|
3403
|
+
* - {onLocalProcessedAudioFrame}:本地采集并经过音频模块前处理后的音频数据回调
|
|
3404
|
+
* - {onPlayAudioFrame}:混音前的每一路远程用户的音频数据
|
|
3405
|
+
* - {onMixedPlayAudioFrame}:将各路音频混合之后并最终要由系统播放出的音频数据回调
|
|
3406
|
+
* - {onMixedAllAudioFrame}:SDK 所有音频混合后的音频数据(包括采集到的和待播放的)
|
|
3407
|
+
*
|
|
3408
|
+
* 注意: 设置回调为空即代表停止自定义音频回调,反之,设置回调不为空则代表启动自定义音频回调。
|
|
3409
|
+
*
|
|
3410
|
+
* @example
|
|
3411
|
+
* import TRTCCloud from 'trtc-electron-sdk';
|
|
3412
|
+
*
|
|
3413
|
+
* const rtcCloud = TRTCCloud.getTRTCShareInstance();
|
|
3414
|
+
*
|
|
3415
|
+
* onCapturedAudioFrame(frame: TRTCAudioFrame) {}
|
|
3416
|
+
* onLocalProcessedAudioFrame(frame: TRTCAudioFrame) {}
|
|
3417
|
+
* onPlayAudioFrame(frame: TRTCAudioFrame, userId: string) {}
|
|
3418
|
+
* onMixedPlayAudioFrame(frame: TRTCAudioFrame) {}
|
|
3419
|
+
* onMixedAllAudioFrame(frame: TRTCAudioFrame) {}
|
|
3420
|
+
*
|
|
3421
|
+
* // 设置音频数据自定义回调
|
|
3422
|
+
* rtcCloud.setAudioFrameCallback({
|
|
3423
|
+
* onCapturedAudioFrame: onCapturedAudioFrame,
|
|
3424
|
+
* onLocalProcessedAudioFrame: onLocalProcessedAudioFrame,
|
|
3425
|
+
* onPlayAudioFrame: onPlayAudioFrame,
|
|
3426
|
+
* onMixedPlayAudioFrame: onMixedPlayAudioFrame,
|
|
3427
|
+
* onMixedAllAudioFrame: onMixedAllAudioFrame,
|
|
3428
|
+
* });
|
|
3429
|
+
*
|
|
3430
|
+
* // 取消音频数据自定义回调
|
|
3431
|
+
* rtcCloud.setAudioFrameCallback({
|
|
3432
|
+
* onCapturedAudioFrame: null,
|
|
3433
|
+
* onLocalProcessedAudioFrame: null,
|
|
3434
|
+
* onPlayAudioFrame: null,
|
|
3435
|
+
* onMixedPlayAudioFrame: null,
|
|
3436
|
+
* onMixedAllAudioFrame: null,
|
|
3437
|
+
* });
|
|
3438
|
+
*
|
|
3439
|
+
* @param {TRTCAudioFrameCallback} callback - 音频数据自定义回调对象。
|
|
3440
|
+
*
|
|
3441
|
+
*/
|
|
3442
|
+
setAudioFrameCallback(callback) {
|
|
3443
|
+
this.rtcCloud.setAudioFrameCallback(callback.onCapturedAudioFrame, callback.onLocalProcessedAudioFrame, callback.onPlayAudioFrame, callback.onMixedPlayAudioFrame, callback.onMixedAllAudioFrame);
|
|
3444
|
+
}
|
|
3390
3445
|
/**
|
|
3391
3446
|
* @private
|
|
3392
3447
|
* 设置本地视频自定义渲染(Electron 平台下不可用)
|
|
@@ -4102,56 +4157,67 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
4102
4157
|
//
|
|
4103
4158
|
/////////////////////////////////////////////////////////////////////////////////
|
|
4104
4159
|
///------------------------内部方法-----------------------------
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
if (
|
|
4109
|
-
if (
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
this._onRenderFrame(id, type, width, height, timestamp, rotation, this.localVideoBufferMap.big.buffer);
|
|
4118
|
-
}
|
|
4119
|
-
else {
|
|
4120
|
-
this.logger.log(`${id} ${type} video buffer reallocated`);
|
|
4121
|
-
}
|
|
4160
|
+
_localVideoRenderCallback(args) {
|
|
4161
|
+
const [id, type, width, height, timestamp, rotation, valid, bufferId] = args;
|
|
4162
|
+
if (this.enableRenderFrame) {
|
|
4163
|
+
if (valid === true) {
|
|
4164
|
+
if (this.isScreenCapturing
|
|
4165
|
+
&& this.screenCaptureStreamType === type
|
|
4166
|
+
&& this.localVideoBufferMap.sub
|
|
4167
|
+
&& this.localVideoBufferMap.sub.id === bufferId) {
|
|
4168
|
+
this._onRenderFrame(id, type, width, height, timestamp, rotation, this.localVideoBufferMap.sub.buffer);
|
|
4169
|
+
}
|
|
4170
|
+
else if (this.localVideoBufferMap.big.id === bufferId) {
|
|
4171
|
+
this._onRenderFrame(id, type, width, height, timestamp, rotation, this.localVideoBufferMap.big.buffer);
|
|
4122
4172
|
}
|
|
4123
4173
|
else {
|
|
4124
|
-
this.
|
|
4174
|
+
this.logger.log(`${id} ${type} video buffer reallocated`);
|
|
4125
4175
|
}
|
|
4126
4176
|
}
|
|
4127
|
-
|
|
4177
|
+
else {
|
|
4178
|
+
this.handleVideoSizeChange(id, type, width, height);
|
|
4179
|
+
}
|
|
4180
|
+
}
|
|
4128
4181
|
}
|
|
4129
|
-
|
|
4130
|
-
this.rtcCloud.
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4182
|
+
addLocalVideoRenderCallback() {
|
|
4183
|
+
this.rtcCloud.addLocalVideoRenderCallback(this._localVideoRenderCallback, this.pixelFormat);
|
|
4184
|
+
}
|
|
4185
|
+
removeLocalVideoRenderCallback() {
|
|
4186
|
+
this.rtcCloud.removeLocalVideoRenderCallback();
|
|
4187
|
+
}
|
|
4188
|
+
_remoteVideoRenderCallback(args) {
|
|
4189
|
+
const [id, type, width, height, timestamp, rotation, valid, bufferId] = args;
|
|
4190
|
+
if (this.enableRenderFrame) {
|
|
4191
|
+
if (valid === true) {
|
|
4192
|
+
const remoteUserVideoBuffers = this.remoteVideoBufferMap.get(id);
|
|
4193
|
+
if (remoteUserVideoBuffers) {
|
|
4194
|
+
if (type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeBig && remoteUserVideoBuffers.big && remoteUserVideoBuffers.big.id === bufferId) {
|
|
4195
|
+
this._onRenderFrame(id, type, width, height, timestamp, rotation, remoteUserVideoBuffers.big.buffer);
|
|
4196
|
+
}
|
|
4197
|
+
else if (type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSmall && remoteUserVideoBuffers.small && remoteUserVideoBuffers.small.id === bufferId) {
|
|
4198
|
+
this._onRenderFrame(id, type, width, height, timestamp, rotation, remoteUserVideoBuffers.small.buffer);
|
|
4199
|
+
}
|
|
4200
|
+
else if (type === trtc_define_1.TRTCVideoStreamType.TRTCVideoStreamTypeSub && remoteUserVideoBuffers.sub && remoteUserVideoBuffers.sub.id === bufferId) {
|
|
4201
|
+
this._onRenderFrame(id, type, width, height, timestamp, rotation, remoteUserVideoBuffers.sub.buffer);
|
|
4145
4202
|
}
|
|
4146
4203
|
else {
|
|
4147
4204
|
this.logger.log(`${id} ${type} video buffer reallocated`);
|
|
4148
4205
|
}
|
|
4149
4206
|
}
|
|
4150
4207
|
else {
|
|
4151
|
-
this.
|
|
4208
|
+
this.logger.warn(`no remote video render for frame:`, args);
|
|
4152
4209
|
}
|
|
4153
4210
|
}
|
|
4154
|
-
|
|
4211
|
+
else {
|
|
4212
|
+
this.handleVideoSizeChange(id, type, width, height);
|
|
4213
|
+
}
|
|
4214
|
+
}
|
|
4215
|
+
}
|
|
4216
|
+
addRemoteVideoRenderCallback(userId) {
|
|
4217
|
+
this.rtcCloud.addRemoteVideoRenderCallback(userId, this._remoteVideoRenderCallback, this.pixelFormat);
|
|
4218
|
+
}
|
|
4219
|
+
removeRemoteVideoRenderCallback(userId) {
|
|
4220
|
+
this.rtcCloud.removeRemoteVideoRenderCallback(userId);
|
|
4155
4221
|
}
|
|
4156
4222
|
//----------------------------------//
|
|
4157
4223
|
// Render Mode API
|
package/liteav/trtc_define.d.ts
CHANGED
|
@@ -438,12 +438,21 @@ export declare class TRTCQualityInfo {
|
|
|
438
438
|
*
|
|
439
439
|
* @param {String} userId - 说话者的 userId,字符编码格式是 UTF-8
|
|
440
440
|
* @param {Number} volume - 说话者的音量, 取值范围0 - 100
|
|
441
|
+
* @param {Number} vad - 是否检测到人声,0:非人声 1:人声
|
|
442
|
+
* @param {Number} pitch - 本地用户的人声频率(单位:Hz),取值范围[0 - 4000],对于远端用户,该值始终为0。
|
|
443
|
+
* @param {Float32Array} spectrumData - 音频频谱数据是将音频数据在频率域中的分布,划分为 256 个频率段,使用 spectrumData 记录各个频率段的能量值,每个能量值的取值范围为 [-300, 0],单位为 dBFS。
|
|
444
|
+
本地频谱使用编码前的音频数据计算,会受到本地采集音量、BGM等影响;远端频谱使用接收到的音频数据计算,本地调整远端播放音量等操作不会对其产生影响。
|
|
445
|
+
* @param {Number} spectrumDataLength - spectrumDataLength 记录音频频谱数据的长度,为 256。
|
|
441
446
|
*
|
|
442
447
|
*/
|
|
443
448
|
export declare class TRTCVolumeInfo {
|
|
444
449
|
userId: string;
|
|
445
450
|
volume: number;
|
|
446
|
-
|
|
451
|
+
vad: number;
|
|
452
|
+
pitch: number;
|
|
453
|
+
spectrumData: Float32Array;
|
|
454
|
+
spectrumDataLength: number;
|
|
455
|
+
constructor(userId?: string, volume?: number, vad?: number, pitch?: number, spectrumData?: Float32Array, spectrumDataLength?: number);
|
|
447
456
|
}
|
|
448
457
|
/**
|
|
449
458
|
* 测速参数
|
|
@@ -752,10 +761,16 @@ export declare class TRTCLocalStatistics {
|
|
|
752
761
|
* 远端成员的音视频统计信息
|
|
753
762
|
*
|
|
754
763
|
* @param {String} userId - 用户 ID,指定是哪个用户的视频流
|
|
755
|
-
* @param {Number}
|
|
756
|
-
*
|
|
757
|
-
*
|
|
758
|
-
*
|
|
764
|
+
* @param {Number} audioPacketLoss - 音频流的总丢包率(%)
|
|
765
|
+
* audioPacketLoss 代表音频流历经`主播>云端>观众`这样一条完整的传输链路后,最终在观众端统计到的丢包率。
|
|
766
|
+
* audioPacketLoss 越小越好,丢包率为0即表示该路音频流的所有数据均已经完整地到达了观众端。
|
|
767
|
+
* 如果出现了 downLoss == 0 但 audioPacketLoss != 0 的情况,说明该路音频流在“云端=>观众”这一段链路上没有出现丢包,
|
|
768
|
+
* 但是在`主播>云端`这一段链路上出现了不可恢复的丢包。
|
|
769
|
+
* @param {Number} videoPacketLoss - 该路视频流的总丢包率(%)
|
|
770
|
+
* videoPacketLoss 代表该路视频流历经`主播>云端>观众`这样一条完整的传输链路后,最终在观众端统计到的丢包率。
|
|
771
|
+
* videoPacketLoss 越小越好,丢包率为0即表示该路视频流的所有数据均已经完整地到达了观众端。
|
|
772
|
+
* 如果出现了 downLoss == 0 但 videoPacketLoss != 0 的情况,说明该路视频流在`云端>观众`这一段链路上没有出现丢包,
|
|
773
|
+
* 但是在`主播>云端`这一段链路上出现了不可恢复的丢包。
|
|
759
774
|
* @param {Number} width - 视频宽度
|
|
760
775
|
* @param {Number} height - 视频高度
|
|
761
776
|
* @param {Number} frameRate - 接收帧率(fps)
|
|
@@ -763,10 +778,21 @@ export declare class TRTCLocalStatistics {
|
|
|
763
778
|
* @param {Number} audioSampleRate - 音频采样率(Hz)
|
|
764
779
|
* @param {Number} audioBitrate - 音频码率(Kbps)
|
|
765
780
|
* @param {Number} jitterBufferDelay - 播放时延(ms)
|
|
781
|
+
* @param {Number} point2PointDelay - 端到端延迟(ms)
|
|
782
|
+
* point2PointDelay 代表 “主播=>云端=>观众” 的延迟,更准确地说,它代表了“采集=>编码=>网络传输=>接收=>缓冲=>解码=>播放” 全链路的延迟。
|
|
783
|
+
* point2PointDelay 需要本地和远端的 SDK 均为 8.5 及以上的版本才生效,若远端用户为 8.5 以前的版本,此数值会一直为0,代表无意义。
|
|
766
784
|
* @param {Number} audioTotalBlockTime - 音频播放卡顿累计时长(ms)
|
|
767
785
|
* @param {Number} audioBlockRate - 音频播放卡顿率,音频卡顿累计时长占音频总播放时长的百分比 (%)
|
|
768
786
|
* @param {Number} videoTotalBlockTime - 视频播放卡顿累计时长(ms)
|
|
769
787
|
* @param {Number} videoBlockRate - 视频播放卡顿率,视频卡顿累计时长占音频总播放时长的百分比(%)
|
|
788
|
+
* @param {Number} finalLoss - 该线路的总丢包率(%)。已废弃,不推荐使用;建议使用 audioPacketLoss、videoPacketLoss 替代
|
|
789
|
+
* @param {Number} remoteNetworkUplinkLoss - 该用户从 SDK 到云端的上行丢包率,单位 (%)
|
|
790
|
+
* 该数值越小越好,如果 remoteNetworkUplinkLoss 为 0%,则意味着上行链路的网络质量很好,上传到云端的数据包基本不发生丢失。
|
|
791
|
+
* 如果 remoteNetworkUplinkLoss 为 30%,则意味着 SDK 向云端发送的音视频数据包中,会有 30% 丢失在传输链路中。
|
|
792
|
+
* @param {Number} remoteNetworkRTT - 该用户从 SDK 到云端的往返延时,单位 ms
|
|
793
|
+
* 该数值代表从 SDK 发送一个网络包到云端,再从云端回送一个网络包到 SDK 的总计耗时,也就是一个网络包经历 “SDK=>云端=>SDK” 的总耗时。
|
|
794
|
+
* 该数值越小越好:如果 remoteNetworkRTT < 50ms,意味着较低的音视频通话延迟;如果 remoteNetworkRTT > 200ms,则意味着较高的音视频通话延迟。
|
|
795
|
+
* 需要特别解释的是,remoteNetworkRTT 代表 “SDK=>云端=>SDK” 的总耗时,所以不需要区分 remoteNetworkUpRTT 和 remoteNetworkDownRTT
|
|
770
796
|
* @param {TRTCVideoStreamType} streamType - 流类型(大画面 | 小画面 | 辅路画面)
|
|
771
797
|
*
|
|
772
798
|
*/
|
|
@@ -785,7 +811,12 @@ export declare class TRTCRemoteStatistics {
|
|
|
785
811
|
videoTotalBlockTime: number;
|
|
786
812
|
videoBlockRate: number;
|
|
787
813
|
streamType: TRTCVideoStreamType;
|
|
788
|
-
|
|
814
|
+
audioPacketLoss: number;
|
|
815
|
+
videoPacketLoss: number;
|
|
816
|
+
point2PointDelay: number;
|
|
817
|
+
remoteNetworkUplinkLoss: number;
|
|
818
|
+
remoteNetworkRTT: number;
|
|
819
|
+
constructor(userId?: string, finalLoss?: number, width?: number, height?: number, frameRate?: number, videoBitrate?: number, audioSampleRate?: number, audioBitrate?: number, jitterBufferDelay?: number, audioTotalBlockTime?: number, audioBlockRate?: number, videoTotalBlockTime?: number, videoBlockRate?: number, streamType?: TRTCVideoStreamType, audioPacketLoss?: number, videoPacketLoss?: number, point2PointDelay?: number, remoteNetworkUplinkLoss?: number, remoteNetworkRTT?: number);
|
|
789
820
|
}
|
|
790
821
|
/**
|
|
791
822
|
* 统计数据
|
|
@@ -870,6 +901,42 @@ export declare type TRTCMusicPlayObserver = {
|
|
|
870
901
|
*/
|
|
871
902
|
onComplete: (id: number, errCode: number) => void | null;
|
|
872
903
|
};
|
|
904
|
+
/**
|
|
905
|
+
* 音频数据自定义回调事件监听器类型定义
|
|
906
|
+
*/
|
|
907
|
+
export declare type TRTCAudioFrameCallback = {
|
|
908
|
+
/**
|
|
909
|
+
* 本地采集并经过音频模块前处理后的音频数据回调
|
|
910
|
+
* @param {TRTCAudioFrame} frame - PCM 格式的音频数据帧(只读)
|
|
911
|
+
* @returns
|
|
912
|
+
*/
|
|
913
|
+
onCapturedAudioFrame: (frame: TRTCAudioFrame) => void | null;
|
|
914
|
+
/**
|
|
915
|
+
* 本地采集并经过音频模块前处理、音效处理和混 BGM 后的音频数据回调
|
|
916
|
+
* @param {TRTCAudioFrame} frame - PCM 格式的音频数据帧(只读)
|
|
917
|
+
* @returns
|
|
918
|
+
*/
|
|
919
|
+
onLocalProcessedAudioFrame: (frame: TRTCAudioFrame) => void | null;
|
|
920
|
+
/**
|
|
921
|
+
* 混音前的每一路远程用户的音频数据
|
|
922
|
+
* @param {TRTCAudioFrame} frame - PCM 格式的音频数据帧(只读)
|
|
923
|
+
* @param {String} userId - 用户ID
|
|
924
|
+
* @returns
|
|
925
|
+
*/
|
|
926
|
+
onPlayAudioFrame: (frame: TRTCAudioFrame, userId: string) => void | null;
|
|
927
|
+
/**
|
|
928
|
+
* 将各路待播放音频混合之后并在最终提交系统播放之前的数据回调
|
|
929
|
+
* @param {TRTCAudioFrame} frame - PCM 格式的音频数据帧(只读)
|
|
930
|
+
* @returns
|
|
931
|
+
*/
|
|
932
|
+
onMixedPlayAudioFrame: (frame: TRTCAudioFrame) => void | null;
|
|
933
|
+
/**
|
|
934
|
+
* SDK 所有音频混合后的音频数据(包括采集到的和待播放的)
|
|
935
|
+
* @param {TRTCAudioFrame} frame - PCM 格式的音频数据帧(只读)
|
|
936
|
+
* @returns
|
|
937
|
+
*/
|
|
938
|
+
onMixedAllAudioFrame: (frame: TRTCAudioFrame) => void | null;
|
|
939
|
+
};
|
|
873
940
|
/**
|
|
874
941
|
* 房间切换参数
|
|
875
942
|
*
|
package/liteav/trtc_define.js
CHANGED
|
@@ -994,12 +994,21 @@ exports.TRTCQualityInfo = TRTCQualityInfo;
|
|
|
994
994
|
*
|
|
995
995
|
* @param {String} userId - 说话者的 userId,字符编码格式是 UTF-8
|
|
996
996
|
* @param {Number} volume - 说话者的音量, 取值范围0 - 100
|
|
997
|
+
* @param {Number} vad - 是否检测到人声,0:非人声 1:人声
|
|
998
|
+
* @param {Number} pitch - 本地用户的人声频率(单位:Hz),取值范围[0 - 4000],对于远端用户,该值始终为0。
|
|
999
|
+
* @param {Float32Array} spectrumData - 音频频谱数据是将音频数据在频率域中的分布,划分为 256 个频率段,使用 spectrumData 记录各个频率段的能量值,每个能量值的取值范围为 [-300, 0],单位为 dBFS。
|
|
1000
|
+
本地频谱使用编码前的音频数据计算,会受到本地采集音量、BGM等影响;远端频谱使用接收到的音频数据计算,本地调整远端播放音量等操作不会对其产生影响。
|
|
1001
|
+
* @param {Number} spectrumDataLength - spectrumDataLength 记录音频频谱数据的长度,为 256。
|
|
997
1002
|
*
|
|
998
1003
|
*/
|
|
999
1004
|
class TRTCVolumeInfo {
|
|
1000
|
-
constructor(userId = '', volume = 0) {
|
|
1005
|
+
constructor(userId = '', volume = 0, vad = 0, pitch = 0, spectrumData = new Float32Array(0), spectrumDataLength = 0) {
|
|
1001
1006
|
this.userId = userId;
|
|
1002
1007
|
this.volume = volume;
|
|
1008
|
+
this.vad = vad;
|
|
1009
|
+
this.pitch = pitch;
|
|
1010
|
+
this.spectrumData = spectrumData;
|
|
1011
|
+
this.spectrumDataLength = spectrumDataLength;
|
|
1003
1012
|
}
|
|
1004
1013
|
}
|
|
1005
1014
|
exports.TRTCVolumeInfo = TRTCVolumeInfo;
|
|
@@ -1457,10 +1466,16 @@ exports.TRTCLocalStatistics = TRTCLocalStatistics;
|
|
|
1457
1466
|
* 远端成员的音视频统计信息
|
|
1458
1467
|
*
|
|
1459
1468
|
* @param {String} userId - 用户 ID,指定是哪个用户的视频流
|
|
1460
|
-
* @param {Number}
|
|
1461
|
-
*
|
|
1462
|
-
*
|
|
1463
|
-
*
|
|
1469
|
+
* @param {Number} audioPacketLoss - 音频流的总丢包率(%)
|
|
1470
|
+
* audioPacketLoss 代表音频流历经`主播>云端>观众`这样一条完整的传输链路后,最终在观众端统计到的丢包率。
|
|
1471
|
+
* audioPacketLoss 越小越好,丢包率为0即表示该路音频流的所有数据均已经完整地到达了观众端。
|
|
1472
|
+
* 如果出现了 downLoss == 0 但 audioPacketLoss != 0 的情况,说明该路音频流在“云端=>观众”这一段链路上没有出现丢包,
|
|
1473
|
+
* 但是在`主播>云端`这一段链路上出现了不可恢复的丢包。
|
|
1474
|
+
* @param {Number} videoPacketLoss - 该路视频流的总丢包率(%)
|
|
1475
|
+
* videoPacketLoss 代表该路视频流历经`主播>云端>观众`这样一条完整的传输链路后,最终在观众端统计到的丢包率。
|
|
1476
|
+
* videoPacketLoss 越小越好,丢包率为0即表示该路视频流的所有数据均已经完整地到达了观众端。
|
|
1477
|
+
* 如果出现了 downLoss == 0 但 videoPacketLoss != 0 的情况,说明该路视频流在`云端>观众`这一段链路上没有出现丢包,
|
|
1478
|
+
* 但是在`主播>云端`这一段链路上出现了不可恢复的丢包。
|
|
1464
1479
|
* @param {Number} width - 视频宽度
|
|
1465
1480
|
* @param {Number} height - 视频高度
|
|
1466
1481
|
* @param {Number} frameRate - 接收帧率(fps)
|
|
@@ -1468,15 +1483,26 @@ exports.TRTCLocalStatistics = TRTCLocalStatistics;
|
|
|
1468
1483
|
* @param {Number} audioSampleRate - 音频采样率(Hz)
|
|
1469
1484
|
* @param {Number} audioBitrate - 音频码率(Kbps)
|
|
1470
1485
|
* @param {Number} jitterBufferDelay - 播放时延(ms)
|
|
1486
|
+
* @param {Number} point2PointDelay - 端到端延迟(ms)
|
|
1487
|
+
* point2PointDelay 代表 “主播=>云端=>观众” 的延迟,更准确地说,它代表了“采集=>编码=>网络传输=>接收=>缓冲=>解码=>播放” 全链路的延迟。
|
|
1488
|
+
* point2PointDelay 需要本地和远端的 SDK 均为 8.5 及以上的版本才生效,若远端用户为 8.5 以前的版本,此数值会一直为0,代表无意义。
|
|
1471
1489
|
* @param {Number} audioTotalBlockTime - 音频播放卡顿累计时长(ms)
|
|
1472
1490
|
* @param {Number} audioBlockRate - 音频播放卡顿率,音频卡顿累计时长占音频总播放时长的百分比 (%)
|
|
1473
1491
|
* @param {Number} videoTotalBlockTime - 视频播放卡顿累计时长(ms)
|
|
1474
1492
|
* @param {Number} videoBlockRate - 视频播放卡顿率,视频卡顿累计时长占音频总播放时长的百分比(%)
|
|
1493
|
+
* @param {Number} finalLoss - 该线路的总丢包率(%)。已废弃,不推荐使用;建议使用 audioPacketLoss、videoPacketLoss 替代
|
|
1494
|
+
* @param {Number} remoteNetworkUplinkLoss - 该用户从 SDK 到云端的上行丢包率,单位 (%)
|
|
1495
|
+
* 该数值越小越好,如果 remoteNetworkUplinkLoss 为 0%,则意味着上行链路的网络质量很好,上传到云端的数据包基本不发生丢失。
|
|
1496
|
+
* 如果 remoteNetworkUplinkLoss 为 30%,则意味着 SDK 向云端发送的音视频数据包中,会有 30% 丢失在传输链路中。
|
|
1497
|
+
* @param {Number} remoteNetworkRTT - 该用户从 SDK 到云端的往返延时,单位 ms
|
|
1498
|
+
* 该数值代表从 SDK 发送一个网络包到云端,再从云端回送一个网络包到 SDK 的总计耗时,也就是一个网络包经历 “SDK=>云端=>SDK” 的总耗时。
|
|
1499
|
+
* 该数值越小越好:如果 remoteNetworkRTT < 50ms,意味着较低的音视频通话延迟;如果 remoteNetworkRTT > 200ms,则意味着较高的音视频通话延迟。
|
|
1500
|
+
* 需要特别解释的是,remoteNetworkRTT 代表 “SDK=>云端=>SDK” 的总耗时,所以不需要区分 remoteNetworkUpRTT 和 remoteNetworkDownRTT
|
|
1475
1501
|
* @param {TRTCVideoStreamType} streamType - 流类型(大画面 | 小画面 | 辅路画面)
|
|
1476
1502
|
*
|
|
1477
1503
|
*/
|
|
1478
1504
|
class TRTCRemoteStatistics {
|
|
1479
|
-
constructor(userId = '', finalLoss = 0, width = 0, height = 0, frameRate = 0, videoBitrate = 0, audioSampleRate = 0, audioBitrate = 0, jitterBufferDelay = 0, audioTotalBlockTime = 0, audioBlockRate = 0, videoTotalBlockTime = 0, videoBlockRate = 0, streamType = TRTCVideoStreamType.TRTCVideoStreamTypeBig) {
|
|
1505
|
+
constructor(userId = '', finalLoss = 0, width = 0, height = 0, frameRate = 0, videoBitrate = 0, audioSampleRate = 0, audioBitrate = 0, jitterBufferDelay = 0, audioTotalBlockTime = 0, audioBlockRate = 0, videoTotalBlockTime = 0, videoBlockRate = 0, streamType = TRTCVideoStreamType.TRTCVideoStreamTypeBig, audioPacketLoss = 0, videoPacketLoss = 0, point2PointDelay = 0, remoteNetworkUplinkLoss = 0, remoteNetworkRTT = 0) {
|
|
1480
1506
|
this.userId = userId;
|
|
1481
1507
|
this.finalLoss = finalLoss;
|
|
1482
1508
|
this.width = width;
|
|
@@ -1491,6 +1517,11 @@ class TRTCRemoteStatistics {
|
|
|
1491
1517
|
this.videoTotalBlockTime = videoTotalBlockTime;
|
|
1492
1518
|
this.videoBlockRate = videoBlockRate;
|
|
1493
1519
|
this.streamType = streamType;
|
|
1520
|
+
this.audioPacketLoss = audioPacketLoss;
|
|
1521
|
+
this.videoPacketLoss = videoPacketLoss;
|
|
1522
|
+
this.point2PointDelay = point2PointDelay;
|
|
1523
|
+
this.remoteNetworkUplinkLoss = remoteNetworkUplinkLoss;
|
|
1524
|
+
this.remoteNetworkRTT = remoteNetworkRTT;
|
|
1494
1525
|
}
|
|
1495
1526
|
}
|
|
1496
1527
|
exports.TRTCRemoteStatistics = TRTCRemoteStatistics;
|
|
@@ -1586,6 +1617,17 @@ exports.AudioMusicParam = AudioMusicParam;
|
|
|
1586
1617
|
* @property {TRTCMusicEvent~onComplete|null} onComplete - 背景音乐播放完毕事件。
|
|
1587
1618
|
*/
|
|
1588
1619
|
const TRTCMusicPlayObserver_HACK_JSDOC = null;
|
|
1620
|
+
/**
|
|
1621
|
+
* 音频数据自定义回调
|
|
1622
|
+
*
|
|
1623
|
+
* @typedef {Object} TRTCAudioFrameCallback
|
|
1624
|
+
* @property {TRTCAudioFrameCallback~onCapturedAudioFrame|null} onCapturedAudioFrame - 本地采集并经过音频模块前处理后的音频数据回调。
|
|
1625
|
+
* @property {TRTCAudioFrameCallback~onLocalProcessedAudioFrame|null} onLocalProcessedAudioFrame - 本地采集并经过音频模块前处理、音效处理和混 BGM 后的音频数据回调。
|
|
1626
|
+
* @property {TRTCAudioFrameCallback~onPlayAudioFrame|null} onPlayAudioFrame - 混音前的每一路远程用户的音频数据。
|
|
1627
|
+
* @property {TRTCAudioFrameCallback~onMixedPlayAudioFrame|null} onMixedPlayAudioFrame - 将各路待播放音频混合之后并在最终提交系统播放之前的数据回调。
|
|
1628
|
+
* @property {TRTCAudioFrameCallback~onMixedAllAudioFrame|null} onMixedAllAudioFrame - SDK 所有音频混合后的音频数据(包括采集到的和待播放的)。
|
|
1629
|
+
*/
|
|
1630
|
+
const TRTCAudioFrameCallback_HACK_JSDOC = null;
|
|
1589
1631
|
/**
|
|
1590
1632
|
* 房间切换参数
|
|
1591
1633
|
*
|