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 Video 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 |
---|---|
startRemoteView | Renders the camera data of a remote user in the specified TXCloudVideoView . |
stopRemoteView | Stops rendering the data of a remote user. |
API | Description |
---|---|
openCamera | Turns on the camera and renders the camera data in the specified TXCloudVideoView . |
switchCamera | Switches between the front and rear cameras. |
closeCamera | Turns off the camera. |
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 |
onUserVideoAvailable | Whether a user is sending video |
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 signature. For more information on how to get it, please see 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 render the camera data of a remote user in the specified TRTCCloudVideoView
.
void startRemoteView(String userId, int streamType, int viewId);
The parameters are as detailed below:
Parameter | Type | Description |
---|---|---|
userId | String | ID of the remote user |
streamType | int | Video stream type of the userId specified for stopping watching |
viewId | int | viewId called back by TRTCCloudVideoView , the control that carries the video image |
This API is used to stop rendering the data of a remote user.
void stopRemoteView(String userId, int streamType);
The parameters are as detailed below:
Parameter | Type | Description |
---|---|---|
userId | String | ID of the remote user |
streamType | int | Type of video stream of the specified userId to stop rendering |
This API is used to turn on the camera and render data in the specified TRTCCloudVideoView
.
void openCamera(bool isFrontCamera, int viewId);
The parameters are as detailed below:
Parameter | Type | Description |
---|---|---|
isFrontCamera | bool | true : turns on the front camera; false : turns on the rear camera. |
viewId | int | viewId returned by TRTCCloudVideoView , the class that loads video images |
This API is used to switch between the front and rear cameras.
void switchCamera(bool isFrontCamera);
The parameters are as detailed below:
Parameter | Type | Description |
---|---|---|
isFrontCamera | bool | true : switches to the front camera; false : switches to the rear camera. |
This API is used to turn the camera off.
void closeCamera();
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 |
Whether a user is sending video. After receiving this callback, you can call startRemoteView
to render the remote user's video.
The parameters are as detailed below:
Parameter | Type | Description |
---|---|---|
userId | String | User ID |
available | boolean | Whether the user has available video |
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?