TRTCCalling
is an open-source class based on two closed-source SDKs: Tencent Cloud Real-Time Communication (TRTC) and Instant Messaging (IM). It supports one-to-one audio/video calls. For detailed instructions how to implement it, please see Real-Time Audio Call (Flutter).
API | Description |
---|---|
sharedInstance | Gets a singleton. |
destroySharedInstance | Destroys a singleton. |
registerListener | Registers an event listener. |
unRegisterListener | Unregisters an event listener. |
destroy | Destroys an instance that is no longer needed. |
login | Logs in. All features can be used only after login. |
logout | Logs out. No calls can be made after logout. |
API | Description |
---|---|
call | Makes a one-to-one call. |
accept | Accepts the current call. |
reject | Declines the current call. |
hangup | Ends the current call. |
API | Description |
---|---|
setMicMute | Mutes the local mic. |
setHandsFree | Enables the hands-free mode. |
API | Description |
---|---|
onError | Callback for error. |
API | Description |
---|---|
onReject | The call was declined. |
onNoResp | The invitee did not answer. |
onLineBusy | The line is busy. |
API | Description |
---|---|
onInvited | An invitation was received. |
onCallingCancel | The call was canceled. |
onCallingTimeOut | The call timed out. |
API | Description |
---|---|
onUserEnter | A user joined the call. |
onUserLeave | A user left the call. |
onUserAudioAvailable | Whether a user is sending audio |
onUserVoiceVolume | Call volume of the user |
onCallEnd | The call ended. |
This API is used to get a singleton of the TRTCCalling
component.
static Future<TRTCCalling> sharedInstance();
This API is used to destroy a singleton of the TRTCCalling
component.
static void destroySharedInstance();
This API is used to destroy an instance that is no longer needed.
void destroy();
This API is used to register callbacks for TRTCCalling events. You can receive status notifications of TRTCCalling via TRTCCallingDelegate
.
void registerListener(VoiceListenerFunc func);
This API is used to unregister event callbacks.
void unRegisterListener(VoiceListenerFunc func);
This API is used to log in to the component.
Future<ActionCallback> login(int sdkAppId, String userId, String userSig);
The parameters are as detailed below:
Parameter | Type | Description |
---|---|---|
sdkAppID | int | You can view the SDKAppID via Application Management > Application Info in the TRTC console. |
userId | String | ID of the current user, which is a string that can contain only letters (a-z and A-Z), digits (0-9), hyphens (-), and underscores (_). |
userSig | String | Tencent Cloud's proprietary security protection signature. For more information on how to get it, please see How to Calculate UserSig. |
This API is used to log out of the component.
Future<ActionCallback> logout();
This API is used to make a one-to-one call. It can be called during a call to invite more users.
Future<ActionCallback> call(String userId, int type);
The parameters are as detailed below:
Parameter | Type | Description |
---|---|---|
userId | String | User ID of the callee |
type | int | 1 : audio call; 2 : video call |
This API is used to accept the current call. After receiving the onInvited()
callback, the invitee can call this API to accept the call.
Future<ActionCallback> accept();
This API is used to decline the current call. After receiving the onInvited()
callback, the invitee can call this API to decline the call.
Future<ActionCallback> reject();
This API is used to end the current call.
void hangup();
This API is used to mute the local mic.
void setMicMute(bool isMute);
The parameters are as detailed below:
Parameter | Type | Description |
---|---|---|
isMute | bool | true : mutes the mic; false : unmutes the mic. |
This API is used to enable the hands-free mode.
void setHandsFree(bool isHandsFree);
The parameters are as detailed below:
Parameter | Type | Description |
---|---|---|
isHandsFree | bool | true : enables the hands-free mode; false : disables the hands-free mode. |
TRTCCallingDelegate
Callback APIsCallback for error.
Note:This callback indicates that the SDK encountered an unrecoverable error. Such errors must be listened for, and UI reminders should be sent to users if necessary.
The parameters are as detailed below:
Parameter | Type | Description |
---|---|---|
code | int | Error code |
msg | String | Error message |
The call was declined.
The parameters are as detailed below:
Parameter | Type | Description |
---|---|---|
userId | String | User ID of the invitee who declined the call |
The invitee did not answer.
The parameters are as detailed below:
Parameter | Type | Description |
---|---|---|
userId | String | User ID of the invitee who did not answer |
The line is busy.
The parameters are as detailed below:
Parameter | Type | Description |
---|---|---|
userId | String | User ID of the invitee whose line is busy |
A call invitation was received.
The parameters are as detailed below:
Parameter | Type | Description |
---|---|---|
sponsor | String | User ID of the inviter |
userIds | List<String> | IDs of other users invited |
isFromGroup | bool | Whether it is a group call |
type | int | 1 : audio call; 2 : video call |
The call was canceled. The invitee will receive this callback if the inviter cancels the invitation before he or she handles it.
The call timed out.
A user joined the call.
The parameters are as detailed below:
Parameter | Type | Description |
---|---|---|
userId | String | ID of the user who joined the call |
A user left the call.
The parameters are as detailed below:
Parameter | Type | Description |
---|---|---|
userId | String | ID of the user who left the call |
Whether a user is sending audio.
The parameters are as detailed below:
Parameter | Type | Description |
---|---|---|
userId | String | User ID |
available | boolean | Whether the user has available audio |
Call volume of a user.
The parameters are as detailed below:
Parameter | Type | Description |
---|---|---|
userVolumes | List | Volume of every speaking user in the room. Value range: 0-100. |
totalVolume | int | Total volume of all remote users. Value range: 0-100. |
The call ended.
Was this page helpful?