- Clone address in startCall to avoid potential crash with c pointer beeing unrefed.

- Do not force unwrap of incoming call that could be nil
This commit is contained in:
Christophe Deschamps 2024-10-15 09:27:14 +02:00
parent 414e0f613d
commit 25dd82a4da
2 changed files with 19 additions and 18 deletions

View file

@ -271,12 +271,11 @@ import AVFoundation
// for outgoing call. There is not yet callId
@objc func startCall(addr: OpaquePointer?, isSas: Bool, isVideo: Bool, isConference: Bool = false) {
if (addr == nil) {
guard addr != nil, let sAddr = Address.getSwiftObject(cObject: addr!).clone() else {
Log.i("Can not start a call with null address!")
return
}
let sAddr = Address.getSwiftObject(cObject: addr!)
if (CallManager.callKitEnabled() && !CallManager.instance().nextCallIsTransfer && lc?.conference?.isIn != true) {
let uuid = UUID()
let name = FastAddressBook.displayName(for: addr) ?? "unknow"

View file

@ -209,23 +209,25 @@ extension ProviderDelegate: CXProviderDelegate {
let callId = callInfo?.callId
Log.directLog(BCTBX_LOG_MESSAGE, text: "CallKit: answer call with call-id: \(String(describing: callId)) and UUID: \(uuid.description).")
let call = CallManager.instance().callByCallId(callId: callId)
if (UIApplication.shared.applicationState != .active) {
CallManager.instance().backgroundContextCall = call
CallManager.instance().backgroundContextCameraIsEnabled = call?.params?.videoEnabled == true || call?.callLog?.wasConference() == true
/*if #available(iOS 16.0, *) {
if (call?.cameraEnabled == true) {
call?.cameraEnabled = AVCaptureSession().isMultitaskingCameraAccessSupported
}
} else {
call?.cameraEnabled = false // Disable camera while app is not on foreground
}*/
if let call = CallManager.instance().callByCallId(callId: callId) {
if (UIApplication.shared.applicationState != .active) {
CallManager.instance().backgroundContextCall = call
CallManager.instance().backgroundContextCameraIsEnabled = call.params?.videoEnabled == true || call.callLog?.wasConference() == true
/*if #available(iOS 16.0, *) {
if (call?.cameraEnabled == true) {
call?.cameraEnabled = AVCaptureSession().isMultitaskingCameraAccessSupported
}
} else {
call?.cameraEnabled = false // Disable camera while app is not on foreground
}*/
}
CallManager.instance().callkitAudioSessionActivated = false
CallManager.instance().lc?.configureAudioSession()
CallManager.instance().acceptCall(call: call, hasVideo: call.params?.videoEnabled ?? false)
action.fulfill()
} else {
endCall(uuid: uuid)
}
CallManager.instance().callkitAudioSessionActivated = false
CallManager.instance().lc?.configureAudioSession()
CallManager.instance().acceptCall(call: call!, hasVideo: call!.params?.videoEnabled ?? false)
action.fulfill()
}
func provider(_ provider: CXProvider, perform action: CXSetHeldCallAction) {