mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
terminate callkit when register failed or cleared
This commit is contained in:
parent
dccab97503
commit
1ff46fe25f
2 changed files with 19 additions and 2 deletions
|
|
@ -46,6 +46,7 @@ import AVFoundation
|
|||
@objc var alreadyRegisteredForNotification: Bool = false
|
||||
var referedFromCall: String?
|
||||
var referedToCall: String?
|
||||
var endCallkit: Bool = false
|
||||
|
||||
|
||||
fileprivate override init() {
|
||||
|
|
@ -400,6 +401,18 @@ import AVFoundation
|
|||
|
||||
class CoreManagerDelegate: CoreDelegate {
|
||||
static var speaker_already_enabled : Bool = false
|
||||
|
||||
override func onRegistrationStateChanged(lc: Core, cfg: ProxyConfig, cstate: RegistrationState, message: String) {
|
||||
if lc.proxyConfigList.count == 1 && (cstate == .Failed || cstate == .Cleared){
|
||||
// terminate callkit immediately when registration failed or cleared, supporting single proxy configuration
|
||||
CallManager.instance().endCallkit = true
|
||||
for call in CallManager.instance().providerDelegate.uuids {
|
||||
CallManager.instance().providerDelegate.endCall(uuid: call.value)
|
||||
}
|
||||
} else {
|
||||
CallManager.instance().endCallkit = false
|
||||
}
|
||||
}
|
||||
|
||||
override func onCallStateChanged(lc: Core, call: Call, cstate: Call.State, message: String) {
|
||||
let addr = call.remoteAddress;
|
||||
|
|
|
|||
|
|
@ -89,7 +89,11 @@ class ProviderDelegate: NSObject {
|
|||
Log.directLog(BCTBX_LOG_MESSAGE, text: "CallKit: report new incoming call with call-id: [\(String(describing: callId))] and UUID: [\(uuid.description)]")
|
||||
provider.reportNewIncomingCall(with: uuid, update: update) { error in
|
||||
if error == nil {
|
||||
CallManager.instance().providerDelegate.endCallNotExist(uuid: uuid, timeout: .now() + 20)
|
||||
if CallManager.instance().endCallkit {
|
||||
CallManager.instance().providerDelegate.endCall(uuid: uuid)
|
||||
} else {
|
||||
CallManager.instance().providerDelegate.endCallNotExist(uuid: uuid, timeout: .now() + 20)
|
||||
}
|
||||
} else {
|
||||
Log.directLog(BCTBX_LOG_ERROR, text: "CallKit: cannot complete incoming call with call-id: [\(String(describing: callId))] and UUID: [\(uuid.description)] from [\(handle)] caused by [\(error!.localizedDescription)]")
|
||||
let code = (error as NSError?)?.code
|
||||
|
|
@ -124,7 +128,7 @@ class ProviderDelegate: NSObject {
|
|||
}
|
||||
|
||||
func endCall(uuid: UUID) {
|
||||
provider.reportCall(with: uuid, endedAt: .init(), reason: .declinedElsewhere)
|
||||
provider.reportCall(with: uuid, endedAt: .init(), reason: .failed)
|
||||
}
|
||||
|
||||
func endCallNotExist(uuid: UUID, timeout: DispatchTime) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue