trtc-sdk-v5 5.2.0-beta.6 → 5.2.0-beta.9

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/index.d.ts CHANGED
@@ -301,7 +301,85 @@
301
301
  'AIDenoiser': undefined;
302
302
  'CDNStreaming': CDNStreamingOptions;
303
303
  };
304
+ declare interface TRTCStatistics {
305
+ rtt: number;
306
+ downLoss: number;
307
+ upLoss: number;
308
+ bytesSent: number;
309
+ bytesReceived: number;
310
+ localStatistics: LocalStatistic;
311
+ remoteStatistics: RemoteStatistic[];
312
+ }
313
+ interface LocalStatistic {
314
+ audio: {
315
+ bitrate: number;
316
+ audioLevel: number;
317
+ };
318
+ video: {
319
+ width: number;
320
+ height: number;
321
+ frameRate: number;
322
+ bitrate: number;
323
+ videoType: TRTCVideoType;
324
+ }[];
325
+ }
326
+ declare enum TRTCVideoType {
327
+ Big = "big",
328
+ Small = "small",
329
+ Sub = "sub"
330
+ }
331
+ interface RemoteStatistic {
332
+ audio: {
333
+ bitrate: number;
334
+ audioLevel: number;
335
+ };
336
+ video: {
337
+ width: number;
338
+ height: number;
339
+ frameRate: number;
340
+ bitrate: number;
341
+ videoType: TRTCVideoType;
342
+ }[];
343
+ userId: string;
344
+ }
304
345
 
346
+ /**
347
+ * @typedef TRTCStatistics TRTC 通话统计信息
348
+ * @property {number} rtt 从 SDK 与 云端的往返延时(一个网络包经历 “SDK -> 云端 -> SDK” 的总耗时),单位 ms。
349
+ * @property {number} upLoss 从 SDK 到云端的上行丢包率,单位 (%)
350
+ * @property {number} downLoss 从云端到 SDK 的下行丢包率,单位 (%)
351
+ * @property {number} bytesSent 总发送字节数(包含信令数据和音视频数据),单位:字节数(Bytes)。
352
+ * @property {number} bytesReceived 总接收字节数(包含信令数据和音视频数据),单位:字节数(Bytes)。
353
+ * @property {TRTCLocalStatistics} localStatistics 本地的音视频统计信息
354
+ * @property {TRTCRemoteStatistics[]} remoteStatistics 远端的音视频统计信息
355
+ */
356
+ /**
357
+ * 本地的音视频统计信息
358
+ * @typedef TRTCLocalStatistics
359
+ * @property {TRTCAudioStatistic} audio 本地音频统计信息
360
+ * @property {TRTCVideoStatistic[]} video 本地视频统计信息
361
+ */
362
+ /**
363
+ * 远端的音视频统计信息
364
+ * @typedef TRTCRemoteStatistics
365
+ * @property {string} userId 远端用户的 userId
366
+ * @property {TRTCAudioStatistic} audio 远端音频统计信息
367
+ * @property {TRTCVideoStatistic[]} video 远端视频统计信息
368
+ */
369
+ /**
370
+ * 音频统计信息
371
+ * @typedef TRTCAudioStatistic
372
+ * @property {number} bitrate 音频码率,单位:Kbps
373
+ * @property {number} audioLevel 音量大小,0 ~ 1 的浮点数。
374
+ */
375
+ /** 视频统计信息
376
+ * @typedef TRTCVideoStatistic
377
+ * @property {number} bitrate 视频码率,单位:Kbps
378
+ * @property {number} width 视频宽度
379
+ * @property {number} height 视频高度
380
+ * @property {number} frameRate 视频帧率
381
+ * @property {'big'|'small'|'sub'} videoType 视频类型,大流、小流、辅流。
382
+ */
305
383
  /**
306
384
  * **TRTC事件列表**<br>
307
385
  * <br>
@@ -339,7 +417,7 @@
339
417
  * @example
340
418
  * trtc.on(TRTC.EVENT.AUTOPLAY_FAILED, event => {
341
419
  * // 引导用户点击页面,当用户点击页面时,SDK 会自动恢复播放。
342
- * // v5.1.3+
420
+ * // 自 v5.1.3+ 新增 userId 参数,表示哪个用户出现自动播放失败。
343
421
  * console.log(event.userId);
344
422
  * });
345
423
  */
@@ -652,6 +730,20 @@
652
730
  * })
653
731
  */
654
732
  readonly SEI_MESSAGE: "sei-message";
733
+ /**
734
+ * @description 通话相关数据指标。<br>
735
+ *
736
+ * - 监听该事件后,SDK 会以 2s 一次的频率定时抛出该事件。
737
+ * - 您可以从该事件中可以获取通话的网络质量(rtt、丢包率)、上行和下行的音视频统计信息(音量大小、宽高、帧率、码率)等信息。详细参数说明请参考:{@link TRTCStatistics}
738
+ * @default 'statistics'
739
+ * @since v5.2.0
740
+ * @memberof module:EVENT
741
+ * @example
742
+ * trtc.on(TRTC.EVENT.STATISTICS, statistics => {
743
+ * console.warn(statistics.rtt, statistics.upLoss, statistics.downLoss);
744
+ * })
745
+ */
746
+ readonly STATISTICS: "statistics";
655
747
  };
656
748
  declare interface TRTCEventTypes {
657
749
  [TRTCEvent.ERROR]: [RtcError];
@@ -722,6 +814,7 @@
722
814
  data: Uint8Array;
723
815
  userId: string;
724
816
  }];
817
+ [TRTCEvent.STATISTICS]: [statistics: TRTCStatistics];
725
818
  }
726
819
  class TRTC extends EventEmitter<TRTCEventTypes> {
727
820
  /**
@@ -871,7 +964,7 @@
871
964
  * - 一个 trtc 实例只能开启一路麦克风,若您需要在已经开启一路麦克风的情况下,再开启一路麦克风用于测试,可以创建多个 trtc 实例实现。
872
965
  *
873
966
  * @param {object} [config] - 配置项
874
- * @param {boolean} [config.publish] - 是否将本地音频发布到房间中,默认为true。若在进房前调用该接口,并且 publish = true,则在进房后 SDK 会自动发布。
967
+ * @param {boolean} [config.publish] - 是否将本地音频发布到房间中,默认为true。若在进房前调用该接口,并且 publish = true,则在进房后 SDK 会自动发布。可监听该事件获取推流状态 {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}。
875
968
  * @param {object} [config.option] - 本地音频选项
876
969
  * @param {string} [config.option.microphoneId]- 指定使用哪个麦克风
877
970
  * @param {MediaStreamTrack} [config.option.audioTrack] - 自定义采集的 audioTrack。{@tutorial 20-advanced-customized-capture-rendering}。
@@ -903,7 +996,7 @@
903
996
  * - 调用时机:该接口需在 {@link TRTC#startLocalAudio startLocalAudio()} 成功后调用,可以多次调用。
904
997
  * - 本方法采用增量更新方式:只更新传入的参数,不传入的参数保持不变。
905
998
  * @param {object} [config]
906
- * @param {boolean} [config.publish] - 是否将本地音频发布到房间中,默认为 true
999
+ * @param {boolean} [config.publish] - 是否将本地音频发布到房间中,默认为 true。可监听该事件获取推流状态 {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}。
907
1000
  * @param {boolean} [config.mute] - 静音麦克风。参考:{@tutorial 15-basic-dynamic-add-video}。
908
1001
  * @param {object} [config.option] - 本地音频配置
909
1002
  * @param {string} [config.option.microphoneId] - 指定使用哪个麦克风,用来切换麦克风。
@@ -981,7 +1074,7 @@
981
1074
  *
982
1075
  * @param {object} [config]
983
1076
  * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - 本地视频预览的 HTMLElement 实例或者 Id, 如果不传或传入 null, 则不会播放视频。
984
- * @param {boolean} [config.publish] - 是否将本地视频发布到房间中。默认为 true,若在进房前调用该接口,SDK 会在进房成功后自动发布(若 publish=true)。
1077
+ * @param {boolean} [config.publish] - 是否将本地视频发布到房间中。默认为 true,若在进房前调用该接口,SDK 会在进房成功后自动发布(若 publish=true)。可监听该事件获取推流状态 {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}。
985
1078
  * @param {object} [config.option] - 本地视频配置
986
1079
  * @param {string} [config.option.cameraId] - 指定使用哪个摄像头,用于切换摄像头。
987
1080
  * @param {boolean} [config.option.useFrontCamera] - 是否使用前置摄像头
@@ -1033,7 +1126,7 @@
1033
1126
  * - 本方法采用增量更新方式:只更新传入的参数,不传入的参数保持不变。
1034
1127
  * @param {object} [config]
1035
1128
  * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - 预览摄像头的 HTMLElement 实例或者 Id, 如果不传或传入null, 则不会渲染视频, 但会仍然会推流消耗带宽的容器
1036
- * @param {boolean} [config.publish] - 是否将本地视频发布到房间中。默认为 true,若在进房前调用该接口,SDK 会在进房成功后自动发布。
1129
+ * @param {boolean} [config.publish] - 是否将本地视频发布到房间中。可监听该事件获取推流状态 {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}。
1037
1130
  * @param {boolean} [config.mute] - 是否暂停摄像头采集,参考:{@tutorial 15-basic-dynamic-add-video}。
1038
1131
  * @param {object} [config.option] - 本地视频配置
1039
1132
  * @param {string} [config.option.cameraId] - 指定使用哪个摄像头,
@@ -1101,7 +1194,7 @@
1101
1194
  * - 开启屏幕分享后,房间内其他用户会收到 {@link module:EVENT.REMOTE_VIDEO_AVAILABLE REMOTE_VIDEO_AVAILABLE} 事件,streamType 为 {@link module:TYPE.STREAM_TYPE_SUB STREAM_TYPE_SUB},其他用户可以通过 {@link TRTC#startRemoteVideo startRemoteVideo} 播放屏幕分享。
1102
1195
  * @param {object} [config]
1103
1196
  * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - 预览本地屏幕分享的 HTMLElement 实例或 Id, 如果不传或传入 null, 则不会渲染本地屏幕分享。
1104
- * @param {boolean} [config.publish] - 是否将屏幕分享发布到房间中。默认为 true,若在进房前调用该接口,SDK 会在进房成功后自动发布。
1197
+ * @param {boolean} [config.publish] - 是否将屏幕分享发布到房间中。默认为 true,若在进房前调用该接口,SDK 会在进房成功后自动发布。可监听该事件获取推流状态 {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}。
1105
1198
  * @param {object} [config.option] - 屏幕分享配置
1106
1199
  * @param {boolean} [config.option.systemAudio] - 是否采集系统声音,默认为 false。
1107
1200
  * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - 视频填充模式。默认为 `contain`,参考 {@link https://developer.mozilla.org/zh-CN/docs/Web/CSS/object-fit CSS object-fit} 属性。
@@ -1128,7 +1221,7 @@
1128
1221
  * - 本方法采用增量更新方式:只更新传入的参数,不传入的参数保持不变。
1129
1222
  * @param {object} [config]
1130
1223
  * @param {string | HTMLElement | HTMLElement[] | null} [config.view] - 屏幕分享预览的 HTMLElement 实例或 Id, 如果不传或传入 null, 则不会渲染屏幕分享。
1131
- * @param {boolean} [config.publish] - 是否将屏幕分享发布到房间中
1224
+ * @param {boolean} [config.publish] - 是否将屏幕分享发布到房间中。可监听该事件获取推流状态 {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}。
1132
1225
  * @param {object} [config.option] - 屏幕分享配置
1133
1226
  * @param {'contain' | 'cover' | 'fill'} [config.option.fillMode] - 视频填充模式。默认为 `contain`,参考 {@link https://developer.mozilla.org/zh-CN/docs/Web/CSS/object-fit CSS object-fit} 属性。
1134
1227
  * @param {QOS_PREFERENCE_SMOOTH|QOS_PREFERENCE_CLEAR} [config.option.qosPreference] - 设置弱网时,视频编码策略。流畅度优先({@link module:TYPE.QOS_PREFERENCE_SMOOTH QOS_PREFERENCE_SMOOTH})或 (默认)清晰度优先({@link module:TYPE.QOS_PREFERENCE_CLEAR QOS_PREFERENCE_CLEAR})
@@ -1408,6 +1501,7 @@
1408
1501
  readonly DEVICE_CHANGED: "device-changed";
1409
1502
  readonly PUBLISH_STATE_CHANGED: "publish-state-changed";
1410
1503
  readonly SEI_MESSAGE: "sei-message";
1504
+ readonly STATISTICS: "statistics";
1411
1505
  };
1412
1506
  static ERROR_CODE: {
1413
1507
  INVALID_PARAMETER: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trtc-sdk-v5",
3
- "version": "5.2.0-beta.6",
3
+ "version": "5.2.0-beta.9",
4
4
  "description": "Tencent Cloud RTC SDK for Web",
5
5
  "main": "trtc.js",
6
6
  "types": "index.d.ts",