wxr
2024-12-03 cb9232b3ab413fae7bcc2b94abd70f18ca02b263
HDLLinPhoneSDK/HDLLinPhoneSDK/HDLCallManager.swift
@@ -176,9 +176,9 @@
        providerDelegate.callInfos.updateValue(callInfo, forKey: uuid)
        providerDelegate.uuids.updateValue(uuid, forKey: callId)
        let state: UIApplication.State = UIApplication.shared.applicationState
        if state == .background{
            providerDelegate.reportIncomingCall(call:call, uuid: uuid, handle: handle, hasVideo: hasVideo)
        }
//        if state == .background{
//            providerDelegate.reportIncomingCall(call:call, uuid: uuid, handle: handle, hasVideo: hasVideo)
//        }
//        providerDelegate.reportIncomingCall(call:call, uuid: uuid, handle: handle, hasVideo: hasVideo)
    }
    
@@ -202,6 +202,7 @@
        }
        let call = Call.getSwiftObject(cObject: call!)
        acceptCall(call: call, hasVideo: hasVideo)
//        HDLCallManager.instance().lc?.activateAudioSession(actived: true)
    }
    
    
@@ -239,6 +240,9 @@
        let sAddr = Address.getSwiftObject(cObject: addr!)
        if (HDLCallManager.callKitEnabled() && !HDLCallManager.instance().nextCallIsTransfer) {
            print("callKitEnabled")
//            HDLCallManager.configAudioSession(audioSession: AVAudioSession.sharedInstance())
            let uuid = UUID()
            let name = "unknow"
            let handle = CXHandle(type: .generic, value: name)
@@ -251,6 +255,7 @@
            requestTransaction(transaction, action: "startCall")
        }else {
            print("doCall")
            try? doCall(addr: sAddr, isSas: isSas)
        }
    }
@@ -285,6 +290,7 @@
                lcallParams.mediaEncryption = .ZRTP
            }
            lcallParams.videoEnabled=true;
            let call = HDLCallManager.instance().lc!.inviteAddressWithParams(addr: addr, params: lcallParams)
            if (call != nil) {
                // The LinphoneCallAppData object should be set on call creation with callback
@@ -337,7 +343,7 @@
    }
    // To be removed.
    static func configAudioSession(audioSession: AVAudioSession) {
    @objc static func configAudioSession(audioSession: AVAudioSession) {
        do {
            try audioSession.setCategory(AVAudioSession.Category.playAndRecord, mode: AVAudioSession.Mode.voiceChat, options: AVAudioSession.CategoryOptions(rawValue: AVAudioSession.CategoryOptions.allowBluetooth.rawValue | AVAudioSession.CategoryOptions.allowBluetoothA2DP.rawValue))
            try audioSession.setMode(AVAudioSession.Mode.voiceChat)
@@ -360,6 +366,20 @@
        } catch {
           
        }
//        LinphoneCall *currentcall = linphone_core_get_current_call(LC);
//        if (linphone_core_is_in_conference(LC) ||                                           // In conference
//            (linphone_core_get_conference_size(LC) > 0 && [UIHangUpButton callCount] == 0) // Only one conf
//            ) {
//            LinphoneManager.instance.conf = TRUE;
//            linphone_core_terminate_conference(LC);
//        } else if (currentcall != NULL) {
//            linphone_call_terminate(currentcall);
//        } else {
//            const MSList *calls = linphone_core_get_calls(LC);
//            if (bctbx_list_size(calls) == 1) { // Only one call
//                linphone_call_terminate((LinphoneCall *)(calls->data));
//            }
//        }
        if (UIApplication.shared.applicationState == .background) {
            HDLCoreManager.instance().stopLinphoneCore()
        }