fix calls

This commit is contained in:
Danmei Chen 2020-04-15 15:09:32 +02:00
parent dca88588d4
commit 44354f4f5e
7 changed files with 19 additions and 25 deletions

View file

@ -354,8 +354,7 @@ import AVFoundation
Log.directLog(BCTBX_LOG_ERROR, text: "Failed to terminate call failed because \(error)")
}
if (UIApplication.shared.applicationState == .background) {
CoreManager.instance().stopIterateTimer()
lc!.stop()
CoreManager.instance().stopLinphoneCore()
}
}
}

View file

@ -56,4 +56,11 @@ import linphonesw
timer.invalidate()
}
}
@objc func stopLinphoneCore() {
if (lc?.callsNb == 0) {
stopIterateTimer()
lc?.stop()
}
}
}

View file

@ -58,13 +58,8 @@
- (void)applicationDidEnterBackground:(UIApplication *)application {
LOGI(@"%@", NSStringFromSelector(_cmd));
[LinphoneManager.instance enterBackgroundMode];
LinphoneCall *call = linphone_core_get_current_call(LC);
if (!call) {
dispatch_async(dispatch_get_main_queue(), ^{
[LinphoneManager.instance stopLinphoneCore];
});
}
[CoreManager.instance stopLinphoneCore];
}
- (void)applicationWillEnterForeground:(UIApplication *)application {

View file

@ -120,7 +120,6 @@ typedef struct _LinphoneManagerSounds {
- (void)launchLinphoneCore;
- (void)destroyLinphoneCore;
- (void)startLinphoneCore;
- (void)stopLinphoneCore;
- (BOOL)resignActive;
- (void)becomeActive;
- (BOOL)enterBackgroundMode;

View file

@ -1274,11 +1274,6 @@ void popup_link_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreat
[CoreManager.instance startIterateTimer];
}
- (void)stopLinphoneCore {
[CoreManager.instance stopIterateTimer];
linphone_core_stop([LinphoneManager getLc]);
}
- (void)createLinphoneCore {
[self migrationAllPre];
if (theLinphoneCore != nil) {

View file

@ -441,7 +441,7 @@ static RootViewManager *rootViewManagerInstance = nil;
case LinphoneCallReleased:
if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
dispatch_async(dispatch_get_main_queue(), ^{
[LinphoneManager.instance stopLinphoneCore];
[CoreManager.instance stopLinphoneCore];
});
}
break;

View file

@ -89,6 +89,14 @@ 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 {
DispatchQueue.main.asyncAfter(deadline: .now() + 60) {// in 30 second
if (CallManager.instance().lc?.callsNb == 0 && !CallManager.instance().providerDelegate.callInfos.isEmpty ) {
Log.directLog(BCTBX_LOG_MESSAGE, text: "CallKit: end call which does not exist.")
for suuid in CallManager.instance().providerDelegate.uuids.values {
CallManager.instance().providerDelegate.endCallForError(uuid: suuid, endedAt: .init(), endedReason: .declinedElsewhere)
}
}
}
} 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)]")
if (call == nil) {
@ -104,15 +112,6 @@ class ProviderDelegate: NSObject {
}
}
}
DispatchQueue.main.asyncAfter(deadline: .now() + 30) {// in 30 second
if (CallManager.instance().lc?.callsNb == 0 && !CallManager.instance().providerDelegate.callInfos.isEmpty ) {
Log.directLog(BCTBX_LOG_MESSAGE, text: "CallKit: end call which does not exist.")
for suuid in CallManager.instance().providerDelegate.uuids.values {
CallManager.instance().providerDelegate.endCallForError(uuid: suuid, endedAt: .init(), endedReason: .declinedElsewhere)
}
}
}
}
func updateCall(uuid: UUID, handle: String, hasVideo: Bool = false) {