in AzureCommunicationUI/sdk/AzureCommunicationUICalling/Sources/Service/Calling/AzureCommunicationCalling/CallingSDKWrapper.swift [182:236]
func incomingCall(isCameraPreferred: Bool, isAudioPreferred: Bool) async throws {
logger.debug( "incoming call")
do {
let callAgent = try await callingSDKInitializer.setupCallAgent()
call = callAgent.calls.first
// call is not accepted by callkit
if call == nil && callingSDKInitializer.getIncomingCall()?.id == callConfiguration.callId {
logger.debug( "accept incoming call")
let options = AcceptCallOptions()
let incomingVideoOptions = IncomingVideoOptions()
incomingVideoOptions.streamType = .remoteIncoming
if isCameraPreferred,
let localVideoStream = localVideoStream {
let localVideoStreamArray = [localVideoStream]
let videoOptions = OutgoingVideoOptions()
videoOptions.streams = localVideoStreamArray
options.outgoingVideoOptions = videoOptions
}
options.outgoingAudioOptions = OutgoingAudioOptions()
options.outgoingAudioOptions?.muted = !isAudioPreferred
options.incomingVideoOptions = incomingVideoOptions
if let remoteInfo = callKitRemoteInfo {
let callKitRemoteInfo = AzureCommunicationCalling.CallKitRemoteInfo()
callKitRemoteInfo.displayName = remoteInfo.displayName
callKitRemoteInfo.handle = remoteInfo.handle
options.callKitRemoteInfo = callKitRemoteInfo
}
if let incomngCall = callingSDKInitializer.getIncomingCall() {
do {
call = try await incomngCall.accept(options: options)
} catch let error as NSError {
logger.debug( "call error \(error.localizedDescription) \(error.code)")
throw CallCompositeInternalError.callJoinFailed
}
} else {
throw CallCompositeInternalError.callJoinFailed
}
} else {
if call == nil || call?.id != callConfiguration.callId {
throw CallCompositeInternalError.callJoinFailed
}
}
callingSDKInitializer.onIncomingCallAccpeted()
if let callingEventsHandler = self.callingEventsHandler as? CallingSDKEventsHandler,
let call = call {
call.delegate = callingEventsHandler
}
setupFeatures()
} catch {
logger.error( "incoming call join failed")
throw CallCompositeInternalError.callJoinFailed
}
}