trtc-sdk-v5 5.5.3-beta.3 → 5.6.0-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/index.d.ts CHANGED
@@ -785,6 +785,20 @@
785
785
  * })
786
786
  */
787
787
  readonly TRACK: "track";
788
+ /**
789
+ * @since v5.6.0
790
+ * @description received a new custom message.
791
+ * @default 'custom-message'
792
+ * @memberof module:EVENT
793
+ * @example
794
+ * trtc.on(TRTC.EVENT.CUSTOM_MESSAGE, event => {
795
+ * // event.userId: remote userId.
796
+ * // event.cmdId: message cmdId.
797
+ * // event.seq: message sequence number.
798
+ * // event.message: custom message data, type is ArrayBuffer.
799
+ * })
800
+ */
801
+ readonly CUSTOM_MESSAGE: "custom-message";
788
802
  };
789
803
  declare interface TRTCEventTypes {
790
804
  [TRTCEvent.ERROR]: [RtcError];
@@ -862,6 +876,7 @@
862
876
  streamType?: TRTCStreamType;
863
877
  track: MediaStreamTrack;
864
878
  }];
879
+ [TRTCEvent.CUSTOM_MESSAGE]: [CustomMessage];
865
880
  }
866
881
  class TRTC extends EventEmitter<TRTCEventTypes> {
867
882
  /**
@@ -1501,6 +1516,28 @@
1501
1516
  * trtc.off('*');
1502
1517
  */
1503
1518
  off<T extends keyof TRTCEventTypes>(event: T | '*', handler: T extends '*' ? never : (...args: TRTCEventTypes[T]) => void, context?: any): this;
1519
+ /**
1520
+ * Get audio track
1521
+ *
1522
+ * @returns {MediaStreamTrack?} Audio track
1523
+ * @param {Object|string} [config] If not passed, get the local microphone audioTrack
1524
+ * @param {string} [config.userId] If not passed or passed an empty string, get the local audioTrack. Pass the userId of the remote user to get the remote user's audioTrack.
1525
+ * @param {STREAM_TYPE_MAIN|STREAM_TYPE_SUB} [config.streamType] - stream type:
1526
+ * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (user's microphone)(default)
1527
+ * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (user's screen sharing audio). Only works for local screen sharing audio because there is only one remote audioTrack, and there is no distinction between Main and Sub for remote audioTrack.
1528
+ * @memberof TRTC
1529
+ * @example
1530
+ * // Version before v5.4.3
1531
+ * trtc.getAudioTrack(); // Get local microphone audioTrack, captured by trtc.startLocalAudio()
1532
+ * trtc.getAudioTrack('remoteUserId'); // Get remote audioTrack
1533
+ *
1534
+ * // Since v5.4.3+, you can get local screen audioTrack by passing the streamType = TRTC.STREAM_TYPE_SUB
1535
+ * trtc.getAudioTrack({ streamType: TRTC.STREAM_TYPE_SUB });
1536
+ */
1537
+ getAudioTrack(configOrUserId?: {
1538
+ userId?: string;
1539
+ streamType?: TRTCStreamType;
1540
+ } | string): MediaStreamTrack | null;
1504
1541
  /**
1505
1542
  * Get video track
1506
1543
  *
@@ -1526,27 +1563,23 @@
1526
1563
  streamType?: TRTCStreamType;
1527
1564
  }): MediaStreamTrack | null;
1528
1565
  /**
1529
- * Get audio track
1530
- *
1531
- * @returns {MediaStreamTrack?} Audio track
1532
- * @param {Object|string} [config] If not passed, get the local microphone audioTrack
1533
- * @param {string} [config.userId] If not passed or passed an empty string, get the local audioTrack. Pass the userId of the remote user to get the remote user's audioTrack.
1534
- * @param {STREAM_TYPE_MAIN|STREAM_TYPE_SUB} [config.streamType] - stream type:
1535
- * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream (user's microphone)(default)
1536
- * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream (user's screen sharing audio). Only works for local screen sharing audio because there is only one remote audioTrack, and there is no distinction between Main and Sub for remote audioTrack.
1537
- * @memberof TRTC
1566
+ * Get video snapshot <br>
1567
+ * Notice: must play the video before it can obtain the snapshot. If there is no playback, an empty string will be returned.
1568
+ * @param {string} config.userId - Remote user ID
1569
+ * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} config.streamType
1570
+ * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream
1571
+ * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream
1572
+ * @since 5.4.0
1538
1573
  * @example
1539
- * // Version before v5.4.3
1540
- * trtc.getAudioTrack(); // Get local microphone audioTrack, captured by trtc.startLocalAudio()
1541
- * trtc.getAudioTrack('remoteUserId'); // Get remote audioTrack
1542
- *
1543
- * // Since v5.4.3+, you can get local screen audioTrack by passing the streamType = TRTC.STREAM_TYPE_SUB
1544
- * trtc.getAudioTrack({ streamType: TRTC.STREAM_TYPE_SUB });
1574
+ * // get self main stream video frame
1575
+ * trtc.getVideoSnapshot()
1576
+ * // get self sub stream video frame
1577
+ * trtc.getVideoSnapshot({streamType:TRTC.TYPE.STREAM_TYPE_SUB})
1578
+ * // get remote user main stream video frame
1579
+ * trtc.getVideoSnapshot({userId: 'remote userId', streamType:TRTC.TYPE.STREAM_TYPE_MAIN})
1580
+ * @memberof TRTC
1545
1581
  */
1546
- getAudioTrack(configOrUserId?: {
1547
- userId?: string;
1548
- streamType?: TRTCStreamType;
1549
- } | string): MediaStreamTrack | null;
1582
+ getVideoSnapshot(config?: VideoFrameConfig): string;
1550
1583
  setCurrentSpeaker(speakerId: string): void;
1551
1584
  /**
1552
1585
  * Send SEI Message <br>
@@ -1599,23 +1632,39 @@
1599
1632
  seiPayloadType: number;
1600
1633
  }): void;
1601
1634
  /**
1602
- * Get video snapshot <br>
1603
- * Notice: must play the video before it can obtain the snapshot. If there is no playback, an empty string will be returned.
1604
- * @param {string} config.userId - Remote user ID
1605
- * @param {TRTC.TYPE.STREAM_TYPE_MAIN|TRTC.TYPE.STREAM_TYPE_SUB} config.streamType
1606
- * - {@link module:TYPE.STREAM_TYPE_MAIN TRTC.TYPE.STREAM_TYPE_MAIN}: Main stream
1607
- * - {@link module:TYPE.STREAM_TYPE_SUB TRTC.TYPE.STREAM_TYPE_SUB}: Sub stream
1608
- * @since 5.4.0
1635
+ * Send Custom Message to all remote users in the room. <br>
1636
+ *
1637
+ * Note:
1638
+ *
1639
+ * 1. Only {@link module:TYPE.ROLE_ANCHOR TRTC.TYPE.ROLE_ANCHOR} can call sendCustomMessage.
1640
+ * 2. You should call this api after {@link TRTC#enterRoom TRTC.enterRoom} successfully.
1641
+ * @since v5.6.0
1642
+ * @see Listen for the event {@link module:EVENT.CUSTOM_MESSAGE TRTC.EVENT.CUSTOM_MESSAGE} to receive custom message.
1643
+ * @param {object} data
1644
+ * @param {number} data.cmdId message Id. Integer, range [1, 10]. You can set different cmdId for different types of messages to reduce the delay of transferring message.
1645
+ * @param {ArrayBuffer} data.message - message content. <br/>
1646
+ * - Maximum 1KB(Byte) sent in a single call.
1647
+ * - Maximum 30 calls per second
1648
+ * - Maximum 8KB sent per second.
1649
+ * @param {boolean} [data.ordered=true] - Send messages in order and as reliably as possible. The receiver will also receive the message in order.
1609
1650
  * @example
1610
- * // get self main stream video frame
1611
- * trtc.getVideoSnapshot()
1612
- * // get self sub stream video frame
1613
- * trtc.getVideoSnapshot({streamType:TRTC.TYPE.STREAM_TYPE_SUB})
1614
- * // get remote user main stream video frame
1615
- * trtc.getVideoSnapshot({userId: 'remote userId', streamType:TRTC.TYPE.STREAM_TYPE_MAIN})
1616
- * @memberof TRTC
1651
+ * // send custom message
1652
+ * trtc.sendCustomMessage({
1653
+ * cmdId: 1,
1654
+ * message: new TextEncoder().encode('hello').buffer,
1655
+ * ordered: true,
1656
+ * });
1657
+ *
1658
+ * // receive custom message
1659
+ * trtc.on(TRTC.EVENT.CUSTOM_MESSAGE, event => {
1660
+ * // event.userId: remote userId.
1661
+ * // event.cmdId: message cmdId.
1662
+ * // event.seq: message sequence number.
1663
+ * // event.message: custom message data, type is ArrayBuffer.
1664
+ * console.log(`received custom msg from ${event.userId}, message: ${new TextDecoder().decode(event.message)}`)
1665
+ * })
1617
1666
  */
1618
- getVideoSnapshot(config?: VideoFrameConfig): string;
1667
+ sendCustomMessage(data: CustomMessageData): void;
1619
1668
  static EVENT: {
1620
1669
  readonly ERROR: "error";
1621
1670
  readonly AUTOPLAY_FAILED: "autoplay-failed";
@@ -1637,6 +1686,7 @@
1637
1686
  readonly STATISTICS: "statistics";
1638
1687
  readonly SEI_MESSAGE: "sei-message";
1639
1688
  readonly TRACK: "track";
1689
+ readonly CUSTOM_MESSAGE: "custom-message";
1640
1690
  };
1641
1691
  static ERROR_CODE: {
1642
1692
  INVALID_PARAMETER: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trtc-sdk-v5",
3
- "version": "5.5.3-beta.3",
3
+ "version": "5.6.0-beta.2",
4
4
  "description": "Tencent Cloud RTC SDK for Web",
5
5
  "main": "trtc.js",
6
6
  "types": "index.d.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/cdn-streaming",
3
- "version": "5.5.1",
3
+ "version": "5.5.2",
4
4
  "description": "TRTC Web SDK 5.x CDN streaming plugin",
5
5
  "main": "./cdn-streaming.esm.js",
6
6
  "author": "longyuqi <longyuqi@tencent.com>",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/beauty",
3
- "version": "5.5.1",
3
+ "version": "5.5.2",
4
4
  "description": "TRTC Web SDK 5.x beauty plugin",
5
5
  "main": "./beauty.esm.js",
6
6
  "author": "longyuqi <longyuqi@tencent.com>",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/virtual-background",
3
- "version": "5.5.1",
3
+ "version": "5.5.2",
4
4
  "description": "TRTC Web SDK 5.x virtual background plugin",
5
5
  "main": "./virtual-background.esm.js",
6
6
  "author": "longyuqi <longyuqi@tencent.com>",