trtc-sdk-v5 5.3.0-beta.5 → 5.3.0-beta.6
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 +82 -15
- package/package.json +1 -1
- package/trtc.esm.js +17 -17
- package/trtc.js +1 -1
package/index.d.ts
CHANGED
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
declare interface LocalVideoConfig {
|
|
9
9
|
view?: string | HTMLElement | HTMLElement[] | null;
|
|
10
10
|
publish?: boolean;
|
|
11
|
+
mute?: boolean;
|
|
11
12
|
option?: {
|
|
12
13
|
cameraId?: string;
|
|
13
14
|
useFrontCamera?: boolean;
|
|
14
15
|
profile?: keyof typeof videoProfileMap | VideoProfile;
|
|
15
16
|
fillMode?: 'contain' | 'cover' | 'fill';
|
|
16
17
|
mirror?: boolean;
|
|
17
|
-
small?: keyof typeof videoProfileMap | VideoProfile;
|
|
18
|
+
small?: keyof typeof videoProfileMap | VideoProfile | boolean;
|
|
18
19
|
qosPreference?: typeof TRTCType.QOS_PREFERENCE_SMOOTH | typeof TRTCType.QOS_PREFERENCE_CLEAR;
|
|
19
20
|
videoTrack?: MediaStreamTrack;
|
|
20
21
|
};
|
|
@@ -84,6 +85,7 @@
|
|
|
84
85
|
}
|
|
85
86
|
declare interface LocalAudioConfig {
|
|
86
87
|
publish?: boolean;
|
|
88
|
+
mute?: boolean;
|
|
87
89
|
option?: {
|
|
88
90
|
microphoneId?: string;
|
|
89
91
|
profile?: keyof typeof audioProfileMap;
|
|
@@ -112,7 +114,6 @@
|
|
|
112
114
|
option?: {
|
|
113
115
|
volume?: number;
|
|
114
116
|
};
|
|
115
|
-
mediaTrack?: MediaStreamTrack | null;
|
|
116
117
|
}
|
|
117
118
|
declare interface StopRemoteAudioConfig {
|
|
118
119
|
userId: string;
|
|
@@ -726,17 +727,6 @@
|
|
|
726
727
|
* });
|
|
727
728
|
*/
|
|
728
729
|
readonly PUBLISH_STATE_CHANGED: "publish-state-changed";
|
|
729
|
-
/**
|
|
730
|
-
* @private
|
|
731
|
-
* @description 收到 SEI message<br>
|
|
732
|
-
* @default 'sei-message'
|
|
733
|
-
* @memberof module:EVENT
|
|
734
|
-
* @example
|
|
735
|
-
* trtc.on(TRTC.EVENT.SEI_MESSAGE, event => {
|
|
736
|
-
* console.log(`收到 ${event.userId} 的 sei message: ${event.data}`)
|
|
737
|
-
* })
|
|
738
|
-
*/
|
|
739
|
-
readonly SEI_MESSAGE: "sei-message";
|
|
740
730
|
/**
|
|
741
731
|
* @description 通话相关数据指标。<br>
|
|
742
732
|
*
|
|
@@ -751,6 +741,29 @@
|
|
|
751
741
|
* })
|
|
752
742
|
*/
|
|
753
743
|
readonly STATISTICS: "statistics";
|
|
744
|
+
/**
|
|
745
|
+
* @description 收到 SEI message<br>
|
|
746
|
+
* @default 'sei-message'
|
|
747
|
+
* @memberof module:EVENT
|
|
748
|
+
* @example
|
|
749
|
+
* trtc.on(TRTC.EVENT.SEI_MESSAGE, event => {
|
|
750
|
+
* console.log(`收到 ${event.userId} 的 sei message: ${event.data}, streamType: ${event.streamType}`)
|
|
751
|
+
* })
|
|
752
|
+
*/
|
|
753
|
+
readonly SEI_MESSAGE: "sei-message";
|
|
754
|
+
/**
|
|
755
|
+
* @private
|
|
756
|
+
* @description 收到新的 MediaStreamTrack 对象
|
|
757
|
+
* @default 'track'
|
|
758
|
+
* @memberof module:EVENT
|
|
759
|
+
* @example
|
|
760
|
+
* trtc.on(TRTC.EVENT.TRACK, event => {
|
|
761
|
+
* const isLocal = event.userId === ''; // userId === '' means event.track is a local track, otherwise it's a remote track
|
|
762
|
+
* const isSubStream = event.streamType === TRTC.TYPE.STREAM_TYPE_SUB; // Usually the sub stream is a screen-sharing video stream.
|
|
763
|
+
* const mediaStreamTrack = event.track;
|
|
764
|
+
* const kind = event.track.kind; // audio or video
|
|
765
|
+
* })
|
|
766
|
+
*/
|
|
754
767
|
readonly TRACK: "track";
|
|
755
768
|
};
|
|
756
769
|
declare interface TRTCEventTypes {
|
|
@@ -821,6 +834,7 @@
|
|
|
821
834
|
[TRTCEvent.SEI_MESSAGE]: [{
|
|
822
835
|
data: Uint8Array;
|
|
823
836
|
userId: string;
|
|
837
|
+
streamType: TRTCStreamType;
|
|
824
838
|
}];
|
|
825
839
|
[TRTCEvent.STATISTICS]: [statistics: TRTCStatistics];
|
|
826
840
|
[TRTCEvent.TRACK]: [{
|
|
@@ -978,6 +992,7 @@
|
|
|
978
992
|
*
|
|
979
993
|
* @param {object} [config] - 配置项
|
|
980
994
|
* @param {boolean} [config.publish] - 是否将本地音频发布到房间中,默认为true。若在进房前调用该接口,并且 publish = true,则在进房后 SDK 会自动发布。可监听该事件获取推流状态 {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}。
|
|
995
|
+
* @param {boolean} [config.mute] - 是否静音麦克风。参考:{@tutorial 15-basic-dynamic-add-video}。
|
|
981
996
|
* @param {object} [config.option] - 本地音频选项
|
|
982
997
|
* @param {string} [config.option.microphoneId]- 指定使用哪个麦克风
|
|
983
998
|
* @param {MediaStreamTrack} [config.option.audioTrack] - 自定义采集的 audioTrack。{@tutorial 20-advanced-customized-capture-rendering}。
|
|
@@ -1011,7 +1026,7 @@
|
|
|
1011
1026
|
* - 本方法采用增量更新方式:只更新传入的参数,不传入的参数保持不变。
|
|
1012
1027
|
* @param {object} [config]
|
|
1013
1028
|
* @param {boolean} [config.publish] - 是否将本地音频发布到房间中,默认为 true。可监听该事件获取推流状态 {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}。
|
|
1014
|
-
* @param {boolean} [config.mute] -
|
|
1029
|
+
* @param {boolean} [config.mute] - 是否静音麦克风。参考:{@tutorial 15-basic-dynamic-add-video}。
|
|
1015
1030
|
* @param {object} [config.option] - 本地音频配置
|
|
1016
1031
|
* @param {string} [config.option.microphoneId] - 指定使用哪个麦克风,用来切换麦克风。
|
|
1017
1032
|
* @param {MediaStreamTrack} [config.option.audioTrack] - 自定义采集的 audioTrack。 {@tutorial 20-advanced-customized-capture-rendering}。
|
|
@@ -1091,6 +1106,7 @@
|
|
|
1091
1106
|
* @param {object} [config]
|
|
1092
1107
|
* @param {string | HTMLElement | HTMLElement[] | null} [config.view] - 本地视频预览的 HTMLElement 实例或者 Id, 如果不传或传入 null, 则不会播放视频。
|
|
1093
1108
|
* @param {boolean} [config.publish] - 是否将本地视频发布到房间中。默认为 true,若在进房前调用该接口,SDK 会在进房成功后自动发布(若 publish=true)。可监听该事件获取推流状态 {@link module:EVENT.PUBLISH_STATE_CHANGED PUBLISH_STATE_CHANGED}。
|
|
1109
|
+
* @param {boolean} [config.mute] - 是否暂停摄像头采集,参考:{@tutorial 15-basic-dynamic-add-video}。
|
|
1094
1110
|
* @param {object} [config.option] - 本地视频配置
|
|
1095
1111
|
* @param {string} [config.option.cameraId] - 指定使用哪个摄像头,用于切换摄像头。
|
|
1096
1112
|
* @param {boolean} [config.option.useFrontCamera] - 是否使用前置摄像头
|
|
@@ -1467,6 +1483,57 @@
|
|
|
1467
1483
|
*/
|
|
1468
1484
|
getAudioTrack(userId?: string): MediaStreamTrack | null;
|
|
1469
1485
|
setCurrentSpeaker(speakerId: string): void;
|
|
1486
|
+
/**
|
|
1487
|
+
* 发送 SEI Message <br>
|
|
1488
|
+
*
|
|
1489
|
+
* 视频帧的头部有一个叫做 SEI 的头部数据块,该接口的原理就是利用这个被称为 SEI 的头部数据块,将您要发送的自定义信令嵌入其中,使其同视频帧一并发送出去。
|
|
1490
|
+
* SEI 消息可以伴随着视频帧一直传输到直播 CDN 上。
|
|
1491
|
+
*
|
|
1492
|
+
* 适用场景:视频画面的精准布局、歌词同步、直播答题等。
|
|
1493
|
+
* 调用时机:在 {@link TRTC#startLocalVideo trtc.startLocalVideo} 后调用。
|
|
1494
|
+
*
|
|
1495
|
+
*
|
|
1496
|
+
* 注意:
|
|
1497
|
+
* 1. 单次最大发送1KB(Byte),每秒最大调用次数30次,每秒最多发送8KB。
|
|
1498
|
+
* 2. 目前仅支持 Chrome 86+, Edge 86+, Opera 72+ 浏览器。
|
|
1499
|
+
* 3. 由于 SEI 跟随视频帧一起发送,视频帧有丢失的可能,因此 SEI 也可能丢失。可在使用频次限制范围内,增加发送次数,业务侧需要在接收端做消息去重。
|
|
1500
|
+
* 4. 没有推视频流时,无法发送 SEI;没有订阅视频流时,无法接收 SEI。
|
|
1501
|
+
* 5. 仅支持 H264 编码器发送 SEI。
|
|
1502
|
+
* 6. 小流暂不支持 SEI 收发。
|
|
1503
|
+
* @see {@link module:EVENT.SEI_MESSAGE TRTC.EVENT.SEI_MESSAGE}
|
|
1504
|
+
* @since v5.3.0
|
|
1505
|
+
* @param {ArrayBuffer} buffer 待发送的 SEI 数据
|
|
1506
|
+
* @param {Object=} options
|
|
1507
|
+
* @param {Number} options.seiPayloadType 设置 SEI payload type。SDK 默认使用自定义 payloadType 243,业务侧可使用该参数将 payloadType 设置为标准的 5。当业务侧使用 5 payloadType 时,需按照规范确保 `buffer` 的前16字节是业务侧自定义的 uuid。
|
|
1508
|
+
* @example
|
|
1509
|
+
* // 1. 开启 SEI
|
|
1510
|
+
* const trtc = TRTC.create({
|
|
1511
|
+
* enableSEI: true // 开启 SEI 收发功能
|
|
1512
|
+
* })
|
|
1513
|
+
*
|
|
1514
|
+
* // 2. 推流端发送 SEI
|
|
1515
|
+
* try {
|
|
1516
|
+
* await trtc.enterRoom({
|
|
1517
|
+
* userId: 'user_1',
|
|
1518
|
+
* roomId: 12345,
|
|
1519
|
+
* })
|
|
1520
|
+
* await trtc.startLocalVideo();
|
|
1521
|
+
* const unit8Array = new Uint8Array([1, 2, 3]);
|
|
1522
|
+
* trtc.sendSEIMessage(unit8Array.buffer);
|
|
1523
|
+
* // 消息已通过限制,等待后续视频帧发送。
|
|
1524
|
+
* } catch(error) {
|
|
1525
|
+
* // 发送失败,可能原因:当前浏览器不支持、参数校验未通过、未推流、没推视频流、调用次数超出限制、使用非 H264 编码器等。
|
|
1526
|
+
* console.warn(error);
|
|
1527
|
+
* }
|
|
1528
|
+
*
|
|
1529
|
+
* // 3. 拉流端接收 SEI
|
|
1530
|
+
* trtc.on(TRTC.EVENT.SEI_MESSAGE, event => {
|
|
1531
|
+
* console.warn(`收到 ${event.userId} 的 sei ${event.data}`);
|
|
1532
|
+
* })
|
|
1533
|
+
*/
|
|
1534
|
+
sendSEIMessage(buffer: ArrayBuffer, options?: {
|
|
1535
|
+
seiPayloadType: number;
|
|
1536
|
+
}): void;
|
|
1470
1537
|
static EVENT: {
|
|
1471
1538
|
readonly ERROR: "error";
|
|
1472
1539
|
readonly AUTOPLAY_FAILED: "autoplay-failed";
|
|
@@ -1538,8 +1605,8 @@
|
|
|
1538
1605
|
readonly SCREEN_SHARE_STOPPED: "screen-share-stopped";
|
|
1539
1606
|
readonly DEVICE_CHANGED: "device-changed";
|
|
1540
1607
|
readonly PUBLISH_STATE_CHANGED: "publish-state-changed";
|
|
1541
|
-
readonly SEI_MESSAGE: "sei-message";
|
|
1542
1608
|
readonly STATISTICS: "statistics";
|
|
1609
|
+
readonly SEI_MESSAGE: "sei-message";
|
|
1543
1610
|
readonly TRACK: "track";
|
|
1544
1611
|
};
|
|
1545
1612
|
static ERROR_CODE: {
|