This document helps you move a Web app from the Twilio Video SDK to the Tencent RTC Engine SDK. It covers key architecture differences, step-by-step migration instructions, practical feature examples, and advanced feature comparisons to help you migrate smoothly.
If you’re starting a new project with Tencent RTC Engine, begin with the Integration Guide. For a high-level introduction, see the Product Overview.
Core concepts and architecture differences
Concept Comparison
This section maps key concepts between Tencent RTC Engine and Twilio Video. For Tencent RTC terminology, see Basic Concepts.
Concept
Tencent RTC Engine
Twilio Video
Description
Room
Room
Room
The session space that connects RTC participants. Tencent RTC uses roomId (number) or strRoomId (string); Twilio uses name (string).
User
User
Participant
All users participating in audio/video calls.
Anchor
Anchor
-
User type with permission to publish streams; can send and receive audio/video streams.
Audience
Audience
-
User type that can only receive audio/video streams.
Application Identifier
SDKAppID
Account SID
Unique identifier for the application.
Authentication Credential
UserSig
Access Token
Credential used for client authentication.
User Identifier
userId
Identity
Unique identifier for each user.
Technical Architecture Differences
Twilio Video Architecture
Twilio Video uses a track-based architecture:
You explicitly create LocalAudioTrack and LocalVideoTrack.
You call connect(token, { tracks }) and pass the local tracks to publish audio/video.
You subscribe to remote tracks via events such as room.on('participantConnected') or TrackPublication.on('subscribed').
You render media in the DOM using MediaTrack.attach(someHtmlElement).
Tencent RTC Engine Architecture
Tencent RTC Engine uses an API-driven architecture:
You create a client with TRTC.create() and call APIs such as startLocalVideo() / startLocalAudio() to capture and publish.
You listen for remote availability events (for example, TRTC.EVENT.REMOTE_VIDEO_AVAILABLE) and then call startRemoteVideo().
You generally don’t manage track objects yourself. For advanced scenarios, you can still access underlying tracks via getAudioTrack() and getVideoTrack().
This API design is more streamlined, while still providing access to underlying tracks for advanced scenarios.
Migration Preparation
Step 1. Activate the Service
To use Tencent RTC Engine services, create an application and obtain credentials by following these steps:
3. In the popup, enter your application name, select RTC Engine, and click Create.
4. After the application is created, retrieve these credentials from Basic Information:
SDKAppID: Automatically generated; uniquely identifies your Tencent RTC application.
SDKSecretKey: Used to generate secure UserSig credentials for accessing Tencent RTC services.
Note:
Authentication Comparison: Twilio Video uses Access Token for authentication, whereas Tencent RTC uses UserSig. Both are time-limited credentials generated on the server side, but the generation methods differ. See UserSig Authentication Documentation.
Use trtc.enterRoom() to create and join a room. Choose from the following scenarios:
RTC Room Scenario (Default)
Interactive Live Streaming Scenario
When the scene parameter is set to TRTC.TYPE.SCENE_RTC or omitted, a real-time audio/video room is created (default). This mode supports up to 300 participants, with up to 50 users able to publish streams.
// Set room entry parameters
const options ={
sdkAppId:2000000000,// Your SDKAppID
userId:'your_user_id',// User ID
userSig:'your_usersig',// UserSig generated with SDKSecretKey and userId
strRoomId:'room_id',// Room ID (string)
// scene: TRTC.TYPE.SCENE_RTC // Optional, defaults to real-time audio/video
};
// To use a numeric room ID, set options.roomId = 123456; roomId takes precedence if both are set.
try{
await trtc.enterRoom(options);
console.log('Joined RTC room successfully.');
}catch(err){
console.error('Failed to join RTC room, err='+ err);
}
If the scene parameter is set to TRTC.TYPE.SCENE_LIVE, an interactive live streaming room is created. This mode supports up to 100,000 participants. Specify the role field to define the user's role when joining. Use trtc.switchRole() to change roles in the room.
// Set room entry parameters
const options ={
sdkAppId:2000000000,// Your SDKAppID
userId:'your_user_id',// User ID
userSig:'your_usersig',// UserSig generated with SDKSecretKey and userId
strRoomId:'room_id',// Room ID (string)
scene:TRTC.TYPE.SCENE_LIVE,// Interactive live streaming scenario
role:TRTC.TYPE.ROLE_ANCHOR// Join as anchor (default), can publish streams
// role: TRTC.TYPE.ROLE_AUDIENCE // Join as audience, can only watch remote streams
};
// To use a numeric room ID, set options.roomId = 123456; roomId takes precedence if both are set.
try{
await trtc.enterRoom(options);
console.log('Joined live room successfully.');
}catch(err){
console.error('Failed to join live room, err='+ err);
}
Step 7. Capture and Publish Local Audio/Video Streams
// By default, remote audio streams are automatically played. To block playback, see Step 10 and call muteRemoteAudio(userId, true).
Step 9. Mute/Unmute Local Audio/Video
Twilio Video
localVideoTrack.disable();// Pause publishing local video stream
localVideoTrack.enable();// Resume publishing local video stream
localAudioTrack.disable();// Pause publishing local audio stream
localAudioTrack.enable();// Resume publishing local audio stream
Tencent RTC Engine
Use trtc.updateLocalAudio() and trtc.updateLocalVideo() to temporarily mute or unmute the microphone and camera. This does not stop device capture, but pauses it at the software layer for faster resume.
await trtc.updateLocalVideo({mute:true});// Pause publishing local video stream
await trtc.updateLocalVideo({mute:false});// Resume publishing local video stream
await trtc.updateLocalAudio({mute:true});// Pause publishing local audio stream
await trtc.updateLocalAudio({mute:false});// Resume publishing local audio stream
Step 10. Mute/Unmute Remote Audio/Video
Twilio Video
// Twilio Video SDK does not provide a direct API to mute RemoteAudioTrack or RemoteVideoTrack
// You can manually remove the corresponding render node at the HTML level to achieve the same effect
Enable or disable local screen sharing with trtc.startScreenShare() and trtc.stopScreenShare(). When enabled, remote users receive the TRTC.EVENT.REMOTE_VIDEO_AVAILABLE event with streamType as TRTC.TYPE.STREAM_TYPE_SUB. Use trtc.startRemoteVideo() to pull the screen sharing stream.
How does Twilio's Room Name (string) map to TRTC's Room ID?
TRTC supports two types of room identifiers:
Numeric Room ID (roomId): Integer range 1 to 4294967294 (recommended).
String Room ID (strRoomId): Up to 64 bytes; supports letters, numbers, and select special characters.
If your Twilio project uses string room names, map them directly to strRoomId.
Note:
Within a single TRTC application, roomId and strRoomId cannot be mixed; they are not interoperable. If both are set in trtc.enterRoom(), roomId takes precedence.
Why does remote audio not require manual subscription in TRTC?
Twilio Video requires manual handling of remote audio via remoteParticipant.on('trackSubscribed'). In TRTC, remote audio streams are automatically played when the user joins the room. To control playback for a specific user, use muteRemoteAudio(userId, true/false).
More Information
Refer to the API Reference for a complete function list and descriptions. For more integration guidance, see Other Issues.