1-to-1 call
This page describes the current public 1-to-1 calling capabilities in Nexconn Call SDK for iOS.
Key types
| Type | Description |
|---|---|
NCCallEngine | Call entry point. Starts, accepts, and ends calls, controls devices, and queries call logs. |
NCCallSession | Current call session object. Includes callId, callType, mediaType, participants, and related data. |
NCCallUser | Participant state object. |
NCCallEventDelegate | Delegate for incoming calls, connected calls, ended calls, participant state changes, and call logs. |
NCCallAPIResultDelegate | Asynchronous result delegate for startCall, acceptCall, endCall, media switching, and related APIs. |
Add delegates
NCCallEngine *engine = [NCCallEngine sharedInstance];
[engine setCallEventsDelegate:self];
[engine setAPIResultListener:self];
If you need quality metrics, also set:
[engine setConnectionQualityDelegate:self];
Set video views
Use NCCallLocalVideoView for the local preview and NCCallRemoteVideoView for the remote stream:
NCCallLocalVideoView *localView = [NCCallLocalVideoView new];
localView.userId = self.currentUserId;
localView.renderMode = NCCallRenderModeAspectFit;
NCCallRemoteVideoView *remoteView = [NCCallRemoteVideoView new];
remoteView.userId = self.remoteUserId;
remoteView.renderMode = NCCallRenderModeAspectFit;
remoteView.isTiny = NO;
NCCallEngine *engine = [NCCallEngine sharedInstance];
[engine setVideoView:localView];
[engine setVideoView:remoteView];
If you no longer need to show a remote user's video, call:
[[NCCallEngine sharedInstance] removeVideoView:self.remoteUserId];
Start a 1-to-1 call
For a 1-to-1 call, callType must be NCCallSingleType, and userIds must contain exactly one remote user.
[[NCCallEngine sharedInstance] startCall:@[self.remoteUserId]
callType:NCCallSingleType
mediaType:NCCallAudioVideoMediaType];
If you need to pass push fields or business extra data, use NCCallPushConfig or NCCallOption:
NCCallPushConfig *pushConfig = [NCCallPushConfig new];
pushConfig.pushTitle = @"New call invitation";
pushConfig.pushContent = @"Please answer";
[[NCCallEngine sharedInstance] startCall:@[self.remoteUserId]
callType:NCCallSingleType
mediaType:NCCallAudioVideoMediaType
pushConfig:pushConfig
extra:@"business-extra"];
Receive and accept an incoming call
The callee receives the incoming call through didCallReceived:extra::
- (void)didCallReceived:(NCCallSession *)session extra:(NSString *)extra {
[[NCCallEngine sharedInstance] acceptCall:session.callId];
}
If you need to attach push fields when accepting the call, use acceptCall:pushConfig:.
End the call
[[NCCallEngine sharedInstance] endCall];
// Or
[[NCCallEngine sharedInstance] endCall:callId];
The asynchronous result is returned through didEndCall:callId:, and the call end event is returned through didCallEnded:reason:.
Control devices during the call
Microphone and speaker
NCCallEngine *engine = [NCCallEngine sharedInstance];
engine.enableMicrophone = YES;
engine.enableSpeaker = YES;
Camera
[[NCCallEngine sharedInstance] enableCamera:YES];
[[NCCallEngine sharedInstance] switchCamera];
The current header comments indicate that the camera is enabled by default after a video call is connected.
Audio and video configuration
Before the call is connected, configure capture parameters through setVideoConfig: and setAudioConfig::
NCCallVideoConfig *videoConfig = [NCCallVideoConfig new];
videoConfig.videoResolution = NCCallVideoResolution640x480;
videoConfig.frameRate = NCCallVideoFrameRate15;
videoConfig.minVideoBitrate = 200;
videoConfig.maxVideoBitrate = 900;
[[NCCallEngine sharedInstance] setVideoConfig:videoConfig];
NCCallAudioConfig *audioConfig = [NCCallAudioConfig new];
audioConfig.audioQuality = NCCallAudioQualitySpeech;
audioConfig.audioScenario = NCCallAudioScenarioDefault;
[[NCCallEngine sharedInstance] setAudioConfig:audioConfig];
Switch media type
1-to-1 calls support switching between audio and audio-video modes.
Send a change request
[[NCCallEngine sharedInstance] requestChangeMediaType:NCCallAudioVideoMediaType];
The result is returned through didRequestChangeMediaType:code:transactionId:callId:.
Receive and respond to a request
- (void)didMediaTypeChangeRequestReceived:(NCCallMediaType)mediaType
transactionId:(NSString *)transactionId
userId:(NSString *)userId {
[[NCCallEngine sharedInstance] replyChangeMediaType:transactionId isAgreed:YES];
}
The final result is returned through didMediaTypeChangeResultReceived:transactionId:userId:code:. To cancel an existing request, call cancelChangeMediaType:.
Call logs
Call log callbacks after the call ends
didLocalCallLogReceived:didServerCallLogReceived:
Query history with pagination
[[NCCallEngine sharedInstance] getHistoryCallLogsWithTime:-1
count:20
order:1];
The result is returned through didGetHistoryCallLogs:hasMore:syncTime:order:code:. In the current documentation:
0: ascending1: descending
Delete logs
[[NCCallEngine sharedInstance] deleteCallLogsForMe:@[callId]];
[[NCCallEngine sharedInstance] deleteAllCallLogsForMe];
Quality metrics and capture delegates
If you need volume or network quality metrics, set NCCallConnectionQualityDelegate. If you need local captured audio and video frames, set:
setVideoFrameCaptureDelegate:setAudioFrameCaptureDelegate: