please select
RTC Engine
  • Overview
  • Web
    • Run Sample Demo
    • Integration
    • Basic Features
      • Screen Sharing
      • Live Streaming
      • Media Device
      • Audio Volume
      • Set Encoding Profile
      • Detect Network Quality
      • Detect Capabilities
    • Advance Features
      • Enable AI Denoiser
      • Enable Audio Mixer
      • Enable Watermark
      • Enable Virtual Background
      • Enable Beauty and Effects
      • Data Messages
      • Custom Capturing and Rendering
    • API List
    • Released Notes
    • Supported Platforms
    • Web FAQs
      • Optimize Multi-Person Video Calls
      • Handle Autoplay Restriction
      • Handle Firewall Restriction
      • Others
  • Android
    • Run Sample Code
    • Integration
    • Basic Features
      • Sensing Network Quality
      • Enabling Screen Sharing
      • Setting Video Quality
      • Rotating Videos
    • Advanced Features
      • Testing Newwork Quality
      • Custom Capturing and Rendering
      • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • TRTCCloud
      • TRTCStatistics
      • TRTCCloudListener
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • Type Definition
      • Deprecated Interface
      • Error Codes
    • Solution
      • Real-Time Chorus (TUIKaraoke)
        • Quick Integration
        • Implementation Steps
        • Song Synchronization
        • Lyric Synchronization
        • Vocal Synchronization
        • Mixing Stream Solution
        • TRTCKaraoke APIs
        • FAQs
    • Release Notes
  • iOS
    • Run Sample Code
    • Integration
    • Basic Features
      • Sensing Network Quality
      • Enabling Screen Sharing
      • Setting Video Quality
      • Rotating Videos
    • Advanced Features
      • Testing Network Quality
      • Custom Capturing and Rendering
      • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • TRTCCloud
      • TRTCCloudDelegate
      • TRTCStatistics
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • Type Definition
      • Deprecated Interface
      • ErrorCode
    • Solution
      • Quick Integration
      • Implementation Steps
      • Song Synchronization
      • Lyric Synchronization
      • Vocal Synchronization
      • Mixing Stream Solution
      • TRTCKaraoke APIs
      • FAQs
    • Release Notes
  • macOS
    • Run Sample Code
    • Integration
    • Basic Features
      • Sensing Network Quality
      • Enabling Screen Sharing
      • Sharing Computer Audio
      • Setting Video Quality
      • Rotating Videos
    • Advanced Features
      • Testing Hardware Devices
      • Testing Network Quality
      • Custom Capturing and Rendering
      • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • TRTCCloud
      • TRTCCloudDelegate
      • TRTCStatistics
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • Type Definition
      • Deprecated Interface
      • ErrorCode
      • Release Notes
    • Release Notes
  • Windows
    • Run Sample Code
    • Integration
    • Basic Features
      • Sensing Network Quality
      • Enabling Screen Sharing
      • Setting Video Quality
      • Rotating Videos
    • Advanced Features
      • Testing Hardware Devices
      • Testing Network Quality
      • Custom Capturing and Rendering
      • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • ITRTCCloud
      • ITRTCStatistics
      • TRTCCloudCallback
      • ITXAudioEffectManager
      • ITXDeviceManager
      • Type Definition
      • Deprecated Interface
      • Error Codes
    • Release Notes
  • Electron
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Sharing Computer Audio
      • 10.Setting Video Quality
      • 11.Rotating Videos
    • Client APIs
      • Overview
      • Error Codes
  • Flutter
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Sharing Computer Audio
      • 10.Setting Video Quality
      • 11.Rotating Videos
    • Client APIs
      • Overview
      • Error Codes
  • Unity
    • Integration
      • 1.API Examples
      • 2Importing the SDK
    • Client APIs
      • Overview
      • Error Codes
  • Qt
    • Integration
      • 1.Importing the SDK
  • Overview
    • Overview
  • Concepts
  • Features
  • Performance Statistics
  • Pricing
    • Free Minutes
    • RTC-Engine Monthly Packages
    • Billing Explanation for Subscription Package Duration
    • Pay-as-you-go
      • Billing of Audio and Video Duration
      • Billing of On-Cloud Recording and Recording Delivery
      • Billing of MixTranscoding and Relay to CDN
  • FAQs
    • FAQs for Beginners
    • Migration Guide
      • Twilio Video to Tencent RTC
      • Billing
      • Features
      • UserSig
      • Firewall Restrictions
      • How to Downsize Installation Package
      • TRTCCalling for Web
      • Audio and Video Quality
      • Others
RTC Engine

Data Messages

There are two ways to transfer your application data messages to the users in the room.

Demo



Custom Message

Supported SDK version: v5.6.0+
You should call this api after TRTC.enterRoom successfully.
The custom message will be sent in order and as reliably as possible, but it's possible to loss messages in a very bad network. The receiver will also receive the message in order.

Send Custom Message

Name
Type
Description
cmdId
number
required
message Id. Integer, range [1, 10].
You can set different cmdId for different types of messages to reduce the delay of transferring message.
data
ArrayBuffer
required
message data.
Maximum 1KB(Byte) sent in a single call.
Maximum 30 calls per second
Maximum 8KB sent per second.
const trtc = TRTC.create();
await trtc.enterRoom({ sdkAppId, userId, userSig, roomId: 12345 })
// send custom message
const data = new TextEncoder().encode('hello').buffer;
trtc.sendCustomMessage({ cmdId: 1, data });

Receive Custom Message

Listen for the event TRTC.EVENT.CUSTOM_MESSAGE to receive custom message.
// receive custom message
trtc.on(TRTC.EVENT.CUSTOM_MESSAGE, event => {
// event.userId: remote userId.
// event.cmdId: message cmdId.
// event.seq: message sequence number.
// event.data: custom message data, type is ArrayBuffer.
console.log(`received custom msg from ${event.userId}, message: ${new TextDecoder().decode(event.data)}`)
})

SEI Message

The header of a video frame has a header block called supplemental enhancement information (SEI). It is additional data inserted into the video bitstream to convey extra information. You can add a lot of information into SEI, such as parameters of the camera or encoder; time; closed captions; lyrics; and copyright info.

Send SEI Message

You can use trtc.sendSEIMessage to send SEI message. Because the SEI is inserted to the video stream, you should call it after you started local video.
// 1. enable SEI
const trtc = TRTC.create({ enableSEI: true })
// 2. enter room & start local video
await trtc.enterRoom({ sdkAppId, userId, userSig, roomId: 12345 })
await trtc.startLocalVideo();
// 3. send SEI
const unit8Array = new Uint8Array([1, 2, 3]);
trtc.sendSEIMessage(unit8Array.buffer);
Note:
1. Supported SDK version: v5.3.0+. Supported browsers: Chrome 86+, Edge 86+, Opera 72+ browsers(Chromium Based Browser M86+).
2. Maximum 1KB(Byte) sent in a single call, maximum 30 calls per second, maximum 8KB sent per second.
3. Since SEI is sent along with video frames, there is a possibility that video frames may be lost due to poor network, and therefore SEI may be lost as well. The number of times it can be sent can be increased within the frequency limit, and the business side needs to do message de-duplication on the receiving side.
4. SEI cannot be sent without trtc.startLocalVideo and cannot be received without trtc.startRemoteVideo.
5. Only H264 encoder is supported to send and receive SEI.

Receive SEI Message

// 1. enable SEI
const trtc = TRTC.create({ enableSEI: true })
// 2. receive SEI
trtc.on(TRTC.EVENT.SEI_MESSAGE, event => {
console.log(`received sei message from ${event.userId}, data: ${event.data}, streamType: ${event.streamType}`)
})