VideoCall
) and audio call (AudioCall
) are the call modes, and interactive video streaming (Live
) and interactive audio streaming (VoiceChatRoom
) are the live streaming modes.
The call modes allow a maximum of 300 users in each TRTC room, and up to 50 of them can speak at the same time. The call modes are suitable for scenarios such as one-to-one video calls, video conferencing with up to 300 participants, online medical consultation, remote interviews, video customer service, and online Werewolf playing.Podfile
file in the root directory of your project and add the code below.Podfile
file in the directory, run the pod init
command to create one and add the code below.target 'Your Project' dopod 'TXLiteAVSDK_TRTC'end
pod install
Info.plist
file.Key | Value |
Privacy - Camera Usage Description | The reason for requesting camera permission, for example, “camera access is required to capture video” |
Privacy - Microphone Usage Description | The reason for requesting mic permission, for example, “mic access is required to capture audio” |
TRTCCloud
instance.// Create a `TRTCCloud` instance_trtcCloud = [TRTCCloud sharedInstance];_trtcCloud.delegate = self;
delegate
to subscribe to event callbacks and listen for event and error notifications.// Error events must be listened for and captured, and error messages should be sent to users.- (void)onError:(TXLiteAVError)errCode errMsg:(NSString *)errMsg extInfo:(NSDictionary *)extInfo {if (ERR_ROOM_ENTER_FAIL == errCode) {[self toastTip:@"Failed to enter room"];[self.trtcCloud exitRoom];}}
TRTCParams
Parameter | Type | Description | Example |
sdkAppId | Number | 1400000123 | |
userId | String | Can contain only letters (a-z and A-Z), digits (0-9), underscores, and hyphens. We recommend you set it based on your business account system. | test_user_001 |
userSig | String | eJyrVareCeYrSy1SslI... | |
roomId | Number | Numeric room ID. For string-type room ID, use strRoomId in TRTCParams . | 29834 |
userId
cannot be in the same room at the same time as it will cause a conflict.roomId
field in TRTCParams
. If the room does not exist, the SDK will create a room whose room number is the value of roomId
.appScene
parameter according to your actual application scenario. Inappropriate appScene
values may lead to increased lag or decreased clarity.TRTCAppScene.videoCall
.TRTCAppScene.audioCall
.onEnterRoom(result)
callback. If result
is greater than 0, room entry succeeds, and the value of result
indicates the time (ms) room entry takes; if result
is less than 0, room entry fails, and the value is the error code for the failure.- (void)enterRoom() {TRTCParams *params = [TRTCParams new];params.sdkAppId = SDKAppID;params.roomId = _roomId;params.userId = _userId;params.role = TRTCRoleAnchor;params.userSig = [GenerateTestUserSig genTestUserSig:params.userId];[self.trtcCloud enterRoom:params appScene:TRTCAppSceneVideoCall];}- (void)onEnterRoom:(NSInteger)result {if (result > 0) {[self toastTip:@"Entered room successfully"];} else {[self toastTip:@"Failed to enter room"];}}
onError
callback, which contains errCode
(error code), errMsg
(error message), and extraInfo
(reserved parameter).exitRoom
to exit the room before entering another room.appScene
must be the same on each client. Inconsistent appScene
may cause unexpected problems.userId
), or muteAllRemoteAudio(true) to mute all remote users. The SDK will stop pulling the audio data of the user(s).view
.Fill
: aspect fill. The image may be scaled up and cropped, but there are no black bars.Fit
: aspect fit. The image may be scaled down to ensure that it’s displayed in its entirety, and there may be black bars.userId
) or stopAllRemoteView() to block the video data of all remote users. The SDK will stop pulling the video data of the user(s).// Sample code: subscribe to or unsubscribe from the video image of a remote user based on the notification received- (void)onUserVideoAvailable:(NSString *)userId available:(BOOL)available {UIView* remoteView = remoteViewDic[userId];if (available) {[_trtcCloud startRemoteView:userId streamType:TRTCVideoStreamTypeSmall view:remoteView];} else {[_trtcCloud stopRemoteView:userId streamType:TRTCVideoStreamTypeSmall];}}
startRemoteView()
to subscribe to the video stream immediately after receiving the onUserVideoAvailable()
event callback, the SDK will stop pulling the remote video within 5 seconds.Fill
: aspect fill. The image may be scaled up and cropped, but there are no black bars.Fit
: aspect fit. The image may be scaled down to ensure that it’s displayed in its entirety, and there may be black bars.// Sample code: publish the local audio/video stream[self.trtcCloud startLocalPreview:_isFrontCamera view:self.view];[self.trtcCloud startLocalAudio:TRTCAudioQualityMusic];
// Please wait for the `onExitRoom` callback after calling the room exit API.[self.trtcCloud exitRoom];- (void)onExitRoom:(NSInteger)reason {NSLog(@"Exited room: reason: %ld", reason)}
onExitRoom
callback to start other SDKs; otherwise, the device busy error may occur.
Was this page helpful?