func joinCall()

in AzureCommunicationUI/sdk/AzureCommunicationUICalling/Sources/Service/Calling/AzureCommunicationCalling/CallingSDKWrapper.swift [72:132]


    func joinCall(isCameraPreferred: Bool, isAudioPreferred: Bool) async throws {
        logger.debug( "Joining call")
        let joinCallOptions = JoinCallOptions()

        // to fix iOS 15 issue
        // by default on iOS 15 calling SDK incoming type is raw video
        // because of this on iOS 15 remote video start event is not received
        let incomingVideoOptions = IncomingVideoOptions()
        incomingVideoOptions.streamType = .remoteIncoming

        if isCameraPreferred,
           let localVideoStream = localVideoStream {
            let localVideoStreamArray = [localVideoStream]

            let videoOptions = OutgoingVideoOptions()
            videoOptions.streams = localVideoStreamArray
            joinCallOptions.outgoingVideoOptions = videoOptions
        }

        joinCallOptions.outgoingAudioOptions = OutgoingAudioOptions()
        joinCallOptions.outgoingAudioOptions?.muted = !isAudioPreferred
        joinCallOptions.incomingVideoOptions = incomingVideoOptions
        if let remoteInfo = callKitRemoteInfo {
            let callKitRemoteInfo = AzureCommunicationCalling.CallKitRemoteInfo()
                callKitRemoteInfo.displayName = remoteInfo.displayName
                callKitRemoteInfo.handle = remoteInfo.handle
                joinCallOptions.callKitRemoteInfo = callKitRemoteInfo
        }
        var joinLocator: JoinMeetingLocator
        if callConfiguration.compositeCallType == .groupCall,
           let groupId = callConfiguration.groupId {
            joinLocator = GroupCallLocator(groupId: groupId)
        } else if callConfiguration.compositeCallType == .teamsMeeting,
                  let meetingLink = callConfiguration.meetingLink {
            joinLocator = TeamsMeetingLinkLocator(
                meetingLink: meetingLink.trimmingCharacters(in: .whitespacesAndNewlines))
        } else if callConfiguration.compositeCallType == .teamsMeeting,
            let meetingId = callConfiguration.meetingId?.trimmingCharacters(in: .whitespacesAndNewlines),
            let meetingPasscode = callConfiguration.meetingPasscode?.trimmingCharacters(in: .whitespacesAndNewlines) {
             joinLocator = TeamsMeetingIdLocator(with: meetingId, passcode: meetingPasscode)
        } else if callConfiguration.compositeCallType == .roomsCall,
                  let roomId = callConfiguration.roomId {
            joinLocator = RoomCallLocator(roomId: roomId.trimmingCharacters(in: .whitespacesAndNewlines))
        } else {
            logger.error("Invalid groupID / meeting link")
            throw CallCompositeInternalError.callJoinFailed
        }

        do {
            let callAgent = try await callingSDKInitializer.setupCallAgent()
            let joinedCall = try await callAgent.join(with: joinLocator, joinCallOptions: joinCallOptions)
            if let callingEventsHandler = self.callingEventsHandler as? CallingSDKEventsHandler {
                joinedCall.delegate = callingEventsHandler
            }
            call = joinedCall
            setupFeatures()
        } catch {
            logger.error( "Join call failed")
            throw CallCompositeInternalError.callJoinFailed
        }
    }