ソースを参照

update fix in 5.0.28 build 4

alqindiirsyam 3 ヶ月 前
コミット
99279acc16

+ 7 - 7
NexilisLite/NexilisLite/Source/APIS.swift

@@ -1523,7 +1523,7 @@ public class APIS: NSObject {
     
     public static var notifTimer = Timer()
     public static var stopNotif = false
-    public static var afterEnterForeground = false
+//    public static var afterEnterForeground = false
     public static func enterForeground() {
         APIS.checkNotificationPermission(completion: { isAllowed in
             if !isAllowed {
@@ -1550,15 +1550,15 @@ public class APIS: NSObject {
         checkDataForShareExtension()
         UIApplication.shared.applicationIconBadgeNumber = 0
         UNUserNotificationCenter.current().removeAllDeliveredNotifications()
-        afterEnterForeground = true
+//        afterEnterForeground = true
     }
     
     public static func willEnterForeground() {
-        if APIS.uuidCall != nil {
-            CallManager.shared.endCall(uuid: APIS.uuidCall!) {
-                APIS.uuidCall = nil
-            }
-        }
+//        if APIS.uuidCall != nil {
+//            CallManager.shared.endCall(uuid: APIS.uuidCall!) {
+//                APIS.uuidCall = nil
+//            }
+//        }
     }
     
     private static func checkNotificationPermission(completion: @escaping (Bool) -> Void) {

+ 5 - 20
NexilisLite/NexilisLite/Source/View/Call/CallManager.swift

@@ -25,7 +25,11 @@ public class CallManager: NSObject, ObservableObject {
         providerConfiguration.supportsVideo = true
         providerConfiguration.maximumCallsPerCallGroup = 1
         providerConfiguration.supportedHandleTypes = [.generic]
-        providerConfiguration.iconTemplateImageData = nil
+        if let logoImage = UIImage(named: "pb_ball", in: Bundle.resourceBundle(for: Nexilis.self), with: nil) {
+            if let imageData = logoImage.pngData() {
+                providerConfiguration.iconTemplateImageData = imageData
+            }
+        }
         
         
         provider = CXProvider(configuration: providerConfiguration)
@@ -67,10 +71,6 @@ extension CallManager: CXProviderDelegate {
     }
     
     public func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
-//        let audioSession = AVAudioSession.sharedInstance()
-//        try? audioSession.setCategory(.playAndRecord, mode: .default, options: [.allowBluetooth, .defaultToSpeaker])
-//        try? audioSession.setActive(true)
-//        
         let uuid = action.callUUID
         if let callInfo = activeCalls[uuid] {
             self.activeCalls[uuid]?.isAccepted = true
@@ -114,11 +114,6 @@ extension CallManager: CXProviderDelegate {
                     })
                     return
                 }
-//                let vc = UIViewController()
-//                vc.modalPresentationStyle = .fullScreen
-//                if #available(iOS 15.0, *) {
-//                    rootWindowScene()?.keyWindow?.topVC().present(vc, animated: false)
-//                }
                 if UIApplication.shared.visibleViewController?.navigationController != nil {
                     UIApplication.shared.visibleViewController?.navigationController?.present(controller, animated: true, completion: nil)
                 } else {
@@ -192,16 +187,6 @@ extension CallManager: CXProviderDelegate {
     }
 }
 
-private extension UIWindow {
-    func topVC() -> UIViewController {
-        var top = rootViewController!
-        while let next = top.presentedViewController {
-            top = next
-        }
-        return top
-    }
-}
-
 struct CallInfo {
     let uuid: UUID
     let callerId: String

+ 20 - 2
NexilisLite/NexilisLite/Source/View/Call/QmeraAudioViewController.swift

@@ -318,6 +318,7 @@ class QmeraAudioViewController: UIViewController {
             let audioSession = AVAudioSession.sharedInstance()
             try audioSession.setCategory(.playAndRecord, mode: .default, options: [.allowBluetooth])
             try audioSession.overrideOutputAudioPort(.speaker)
+            try audioSession.setPreferredSampleRate(44100)
             try audioSession.setActive(true)
         } catch {
         }
@@ -421,7 +422,24 @@ class QmeraAudioViewController: UIViewController {
                 }
             } else if autoAcceptAPN {
                 DispatchQueue.global().async {
-                    while API.nGetCLXConnState() == 0 || !APIS.afterEnterForeground {
+                    do {
+                        if API.nGetCLXConnState() == 0 {
+                            let id = Utils.getConnectionID()
+                            try API.initConnection(sAPIK: Nexilis.sAPIKey, cbiI: Callback(), sTCPAddr: Nexilis.ADDRESS, nTCPPort: Nexilis.PORT, sUserID: id, sStartWH: "09:00")
+                        }
+                    } catch {
+                        
+                    }
+                    let audioSession = AVAudioSession.sharedInstance()
+                    do {
+                        try audioSession.setCategory(.playAndRecord, mode: .default, options: [.allowBluetooth])
+                        try audioSession.overrideOutputAudioPort(.speaker)
+                        try audioSession.setPreferredSampleRate(44100)
+                        try audioSession.setActive(true)
+                    } catch {
+                        print("Audio session error: \(error)")
+                    }
+                    while API.nGetCLXConnState() == 0 {
                         Thread.sleep(forTimeInterval : 0.3)
                     }
                     _ = Nexilis.write(message: CoreMessage_TMessageBank.getNotifyCalling(fPin: u.pin, lPin: User.getMyPin()!, type: "1"))
@@ -1053,7 +1071,7 @@ class QmeraAudioViewController: UIViewController {
 //                    } while (QmeraAudioViewController.isLoop)
 //                }
                 DispatchQueue.main.async { [self] in
-                    QmeraAudioViewController.bSpeakerPhone = true
+                    QmeraAudioViewController.bSpeakerPhone = APIS.checkAppStateisBackground() ? false : true
                     didSpeaker(sender: nil)
                 }
             } else if state == Nexilis.AUDIO_CALL_RINGING || (!ticketId.isEmpty && state == Nexilis.VIDEO_CALL_RINGING) {

+ 24 - 1
NexilisLite/NexilisLite/Source/View/Call/QmeraVideoViewController.swift

@@ -202,6 +202,7 @@ class QmeraVideoViewController: UIViewController {
             let audioSession = AVAudioSession.sharedInstance()
             try audioSession.setCategory(.playAndRecord, mode: .default, options: .allowBluetooth)
             try audioSession.overrideOutputAudioPort(.speaker)
+            try audioSession.setPreferredSampleRate(48000)
             try audioSession.setActive(true)
         } catch {
         }
@@ -242,7 +243,24 @@ class QmeraVideoViewController: UIViewController {
         }
         if autoAcceptAPN {
             DispatchQueue.global().async {
-                while API.nGetCLXConnState() == 0 || !APIS.afterEnterForeground {
+                do {
+                    if API.nGetCLXConnState() == 0 {
+                        let id = Utils.getConnectionID()
+                        try API.initConnection(sAPIK: Nexilis.sAPIKey, cbiI: Callback(), sTCPAddr: Nexilis.ADDRESS, nTCPPort: Nexilis.PORT, sUserID: id, sStartWH: "09:00")
+                    }
+                } catch {
+                    
+                }
+                let audioSession = AVAudioSession.sharedInstance()
+                do {
+                    try audioSession.setCategory(.playAndRecord, mode: .default, options: [.allowBluetooth])
+                    try audioSession.overrideOutputAudioPort(.speaker)
+                    try audioSession.setPreferredSampleRate(48000)
+                    try audioSession.setActive(true)
+                } catch {
+                    print("Audio session error: \(error)")
+                }
+                while API.nGetCLXConnState() == 0 {
                     Thread.sleep(forTimeInterval : 0.3)
                 }
                 _ = Nexilis.writeSync(message: CoreMessage_TMessageBank.getNotifyCalling(fPin: self.fPin, lPin: User.getMyPin()!, type: "2"))
@@ -1105,6 +1123,11 @@ class QmeraVideoViewController: UIViewController {
             }
         }
         API.terminateCall(sParty: nil)
+        if APIS.uuidCall != nil {
+            CallManager.shared.endCall(uuid: APIS.uuidCall!) {
+                APIS.uuidCall = nil
+            }
+        }
         cameraView.image = nil
         zoomView.image = nil
         listRemoteViewFix.removeAll()