HDLLinPhoneSDK/HDLLinPhoneSDK/HDLCallManager.swift | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HDLLinPhoneSDK/HDLLinPhoneSDK/HDLCoreManager.swift | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HDLLinPhoneSDK/HDLLinPhoneSDK/HDLCoreManagerDelegate.swift | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HDLLinPhoneSDK/HDLLinPhoneSDK/HDLLPOnMonitorViewController.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HDLLinPhoneSDK/HDLLinPhoneSDK/HDLLPOnMonitorViewController.m | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HDLLinPhoneSDK/HDLLinPhoneSDK/HDLLinPhoneSDK.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HDLLinPhoneSDK/HDLLinPhoneSDK/HDLLinPhoneSDK.m | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HDLLinPhoneSDK/HDLLinPhoneSDK/HDLLinphoneIntercomVC.m | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HDLLinPhoneSDK/HDLLinPhoneSDK/HDLLinphoneManager.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HDLLinPhoneSDK/HDLLinPhoneSDK/HDLLinphoneManager.m | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
HDLLinPhoneSDK/HDLLinPhoneSDK/HDLProviderDelegate.swift | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
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) } @@ -337,7 +338,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) HDLLinPhoneSDK/HDLLinPhoneSDK/HDLCoreManager.swift
@@ -25,7 +25,17 @@ } @objc private func iterate() { // var coreIterateTaskId:UIBackgroundTaskIdentifier = UIBackgroundTaskIdentifier(rawValue: 0) // coreIterateTaskId=UIApplication.shared.beginBackgroundTask(expirationHandler: { // UIApplication.shared.endBackgroundTask(coreIterateTaskId) // }) lc?.iterate() // if coreIterateTaskId != UIBackgroundTaskIdentifier.invalid { // UIApplication.shared.endBackgroundTask(coreIterateTaskId) // } } @objc func startIterateTimer() { @@ -50,4 +60,10 @@ lc?.stop() } } // // @objc func removeConfig(config:ProxyConfig) { // if (lc != nil) { // lc?.removeProxyConfig(config: config) // } // } } HDLLinPhoneSDK/HDLLinPhoneSDK/HDLCoreManagerDelegate.swift
@@ -31,7 +31,7 @@ HDLCallManager.setAppData(sCall: call, appData: appData) } HDLLinPhoneSDK.instance().isIncomingReceivedCallState=false print("cstate: \(cstate)") switch cstate { case .IncomingReceived: print("接收到通知") @@ -53,16 +53,18 @@ } } else { let state: UIApplication.State = UIApplication.shared.applicationState HDLCallManager.instance().displayIncomingCall(call: call, handle: address, hasVideo: video, callId: callId!) if state == .background{ // HDLCallManager.instance().displayIncomingCall(call: call, handle: address, hasVideo: video, callId: callId!) }else{ HDLCallManager.instance().displayIncomingCall(call: call, handle: address, hasVideo: true, callId: callId!) print("接收到通知2") // if state == .background{ // print("接收到通知3") //// HDLCallManager.instance().displayIncomingCall(call: call, handle: address, hasVideo: video, callId: callId!) // }else{ // HDLCallManager.instance().acceptCall(call: call, hasVideo: call.params?.videoEnabled ?? false) let dict: Dictionary<String, Any> = ["state":10,"cfg":"","message":"","callID":call.callLog?.callId ?? "","hasVideo":call.params?.videoEnabled ?? false] print("接收到通知4") let dict: Dictionary<String, Any> = ["state":10,"cfg":"","message":"","callID":call.callLog?.callId ?? "","hasVideo":call.params?.videoEnabled ?? false,"userName":call.remoteAddress?.username ?? ""] NotificationCenter.default.post(name: NSNotification.Name(rawValue: "LinphoneRegistrationUpdate"), object: nil, userInfo: dict) HDLLinPhoneSDK.instance().isIncomingReceivedCallState=true } // } } } break @@ -159,11 +161,17 @@ HDLCallManager.instance().requestTransaction(transaction, action: "endCall") } } let dict: Dictionary<String, Any> = ["state":11,"cfg":"","message":"","callID":call.callLog?.callId ?? "","hasVideo":call.params?.videoEnabled ?? false,"userName":call.remoteAddress?.username ?? ""] NotificationCenter.default.post(name: NSNotification.Name(rawValue: "LinphoneRegistrationUpdate"), object: nil, userInfo: dict) break case .Released: call.userData = nil print("release 了") let dict: Dictionary<String, Any> = ["state":12,"cfg":"","message":"","callID":call.callLog?.callId ?? "","hasVideo":call.params?.videoEnabled ?? false,"userName":call.remoteAddress?.username ?? ""] NotificationCenter.default.post(name: NSNotification.Name(rawValue: "LinphoneRegistrationUpdate"), object: nil, userInfo: dict) break case .Referred: print("Referred 了") HDLCallManager.instance().referedFromCall = call.callLog?.callId break default: HDLLinPhoneSDK/HDLLinPhoneSDK/HDLLPOnMonitorViewController.h
@@ -19,6 +19,8 @@ @property (strong, nonatomic) NSString *userName;//呼叫账号 @property (strong, nonatomic) NSString *titleName;//标题 -(void)showUIAlertViewWithBack:(NSString *)mes; #pragma mark 对外接口方法 HDLLinPhoneSDK/HDLLinPhoneSDK/HDLLPOnMonitorViewController.m
@@ -85,9 +85,21 @@ if (self.titleName&&self.titleName.length!=0) { self.titleUILabel.text=self.titleName; } [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(registrationUpdate:) name:@"LinphoneRegistrationUpdate" object:nil]; } - (void)registrationUpdate:(NSNotification *)notif { int state = [[notif.userInfo objectForKey:@"state"] intValue]; if(state==11){//挂断了 NSLog(@"挂断或出错了"); [self showUIAlertViewWithBack:@"监视结束"]; } } -(void)initLlanguage{ NSString *languageName = [[[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"] objectAtIndex:0]; HDLLinPhoneSDK/HDLLinPhoneSDK/HDLLinPhoneSDK.h
@@ -69,5 +69,21 @@ */ -(void)clearAllConfigs; /** *app进入后台 * */ -(void)enterBackground; /** *app唤醒 * */ -(void)becomactive; /** *程序暂行 * */ -(void)willResignActive; @end HDLLinPhoneSDK/HDLLinPhoneSDK/HDLLinPhoneSDK.m
@@ -11,6 +11,12 @@ #import "HDLLinphoneIntercomVC.h" #import "HDLLinPhoneCommon.h" #import "HDLLPOnMonitorViewController.h" @interface HDLLinPhoneSDK() //@property (nonatomic, strong) HDLLinphoneIntercomVC *IntercomVC; //@property (nonatomic, strong) HDLLPOnMonitorViewController *CallVC; @end @implementation HDLLinPhoneSDK + (instancetype)instance{ @@ -23,6 +29,8 @@ selector:@selector(registrationUpdate:) name:@"LinphoneRegistrationUpdate" object:nil]; // service.CallVC=nil; // service.IntercomVC=nil; }); return service; @@ -39,7 +47,9 @@ - (void)registrationUpdate:(NSNotification *)notif { LinphoneRegistrationState state = [[notif.userInfo objectForKey:@"state"] intValue]; if (state == LinphoneRegistrationFailed){ NSLog(@"登失败"); }else if (state == LinphoneRegistrationCleared){ NSLog(@"登录清空"); } else if (state == LinphoneRegistrationOk) { // HDLLinphoneIntercomVC *vc=[[HDLLinphoneIntercomVC alloc]init]; @@ -48,7 +58,10 @@ // }]; NSLog(@"登录成功啦"); }else if (state==10){//接收到呼叫通知 self.IsAutoJumpCallView=YES; // self.IsAutoJumpCallView=YES; NSString *userName=[NSString stringWithFormat:@"%@",[notif.userInfo objectForKey:@"userName"]]; [self.hdlLinphoneCallDelegate onIncomingCall:userName]; if(self.IsAutoJumpCallView){ NSString *callId=[NSString stringWithFormat:@"%@",[notif.userInfo objectForKey:@"callID"]]; BOOL hasVideo=(BOOL)[notif.userInfo objectForKey:@"hasVideo"]; @@ -57,12 +70,35 @@ vc.CallId=callId; vc.hasVideo=hasVideo; vc.hdlLinphoneCallDelegate=self.hdlLinphoneCallDelegate; vc.modalPresentationStyle = UIModalPresentationFullScreen; // self.IntercomVC=vc; [[HDLLinPhoneCommon topMostController] presentViewController:vc animated:YES completion:^{ }]; } }else if(state==11){//挂断了 // NSLog(@"挂断或出错了"); // if (self.IntercomVC) { // __weak typeof(self) weakSelf = self; // [self.IntercomVC dismissViewControllerAnimated:YES completion:^{ // weakSelf.IntercomVC=nil; // }]; // } // // if (self.CallVC) { // __weak typeof(self) weakSelf = self; // [self.CallVC dismissViewControllerAnimated:YES completion:^{ // weakSelf.CallVC=nil; // }]; // } }else if(state==12){//占线了 // NSLog(@"占线了"); // if (self.CallVC) { // [self.CallVC showUIAlertViewWithBack:@"监视结束"]; // } } } @@ -79,6 +115,7 @@ vc.modalPresentationStyle = UIModalPresentationFullScreen; vc.userName=username; vc.titleName=title; // self.CallVC=vc; [[HDLLinPhoneCommon topMostController] presentViewController:vc animated:YES completion:^{ }]; @@ -100,16 +137,29 @@ vc.hdlLinphoneCallDelegate=self.hdlLinphoneCallDelegate; vc.titleName=titleName; vc.modalPresentationStyle = UIModalPresentationFullScreen; // self.IntercomVC=vc; [[HDLLinPhoneCommon topMostController] presentViewController:vc animated:YES completion:^{ }]; } -(void)logoutAllLinphoneUser{ [HDLLinphoneManager.instance removeAllAccounts]; } -(void)clearAllConfigs{ } -(void)enterBackground{ [HDLLinphoneManager.instance enterBackgroundMode]; } -(void)becomactive{ [HDLLinphoneManager.instance becomeActive]; } -(void)willResignActive{ [HDLLinphoneManager.instance willResignActive]; } @end HDLLinPhoneSDK/HDLLinPhoneSDK/HDLLinphoneIntercomVC.m
@@ -77,8 +77,22 @@ self.titleUILabel.text=self.titleName; } // self.titleUILabel.text=self.titleName; [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(registrationUpdate:) name:@"LinphoneRegistrationUpdate" object:nil]; } - (void)registrationUpdate:(NSNotification *)notif { int state = [[notif.userInfo objectForKey:@"state"] intValue]; if(state==11){//挂断了 NSLog(@"挂断或出错了"); [self showUIAlertViewWithBack:@"通话结束"]; } } -(void)initLlanguage{ NSString *languageName = [[[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"] objectAtIndex:0]; @@ -629,6 +643,7 @@ } -(void)viewWillDisappear:(BOOL)animated{ NSLog(@"viewWillDisappear"); [super viewWillDisappear:animated]; [self stopPlaySystemSound]; //防止用户不按挂断,或者不等收到对方的挂断,点击返回按钮。 @@ -646,6 +661,8 @@ _countdownTimer = nil; // OK } [[NSNotificationCenter defaultCenter] removeObserver:self]; } @@ -711,7 +728,7 @@ #pragma 震动实现貌似和SDK冲突 不能实现震动 //开始播放的时候调用 -(void)startPlaySystemSound{ return; // return; // //震动的提示文件名放到资源目录下 // NSString *path = [[NSBundle mainBundle] pathForResource:@"ring" ofType:@"wav"]; // AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:path], &sound); @@ -724,13 +741,13 @@ //手动停止播放的时候调用 - (void)stopPlaySystemSound{ return; // return; NSLog(@"stop PlaySystemSound"); stopRingAndVibration(); HDLLPStopRingAndVibration(); } //停止响铃和震动,移除回调并处理掉铃声和震动 void stopRingAndVibration() { void HDLLPStopRingAndVibration() { AudioServicesRemoveSystemSoundCompletion(kSystemSoundID_Vibrate); // AudioServicesRemoveSystemSoundCompletion(sound); AudioServicesDisposeSystemSoundID(kSystemSoundID_Vibrate); HDLLinPhoneSDK/HDLLinPhoneSDK/HDLLinphoneManager.h
@@ -30,7 +30,15 @@ SystemSoundID vibrate; } LinphoneManagerSounds; @interface HDLLinphoneManager : NSObject typedef struct _CallContext { LinphoneCall* call; bool_t cameraIsEnabled; } CallContext; @interface HDLLinphoneManager : NSObject{ @public CallContext currentCallContextBeforeGoingBackground; } - (void)launchLinphoneCore; + (HDLLinphoneManager*)instance; + (NSString*)bundleFile:(NSString*)file; @@ -45,7 +53,11 @@ -(void)initalLinPhonal; -(void)snapShot;//视频截图 -(void)snapShotWithView:(UIView *)view;//视频截图 -(void)removeAllAccounts;//注销登录 -(void)clearConfigs;//清除配置表 - (BOOL)enterBackgroundMode; -(void)willResignActive; - (void)becomeActive ; @property (readonly) const char* frontCamId; @property (readonly) const char* backCamId; @property (readonly) LinphoneManagerSounds sounds; HDLLinPhoneSDK/HDLLinPhoneSDK/HDLLinphoneManager.m
@@ -34,6 +34,9 @@ @interface HDLLinphoneManager (){ LinphoneAccountCreator *account_creator; UIBackgroundTaskIdentifier pausedCallBgTask; UIBackgroundTaskIdentifier incallBgTask; NSDate *mLastKeepAliveDate; } @property(strong, nonatomic) AVAudioPlayer* messagePlayer; @@ -431,6 +434,7 @@ * grab, if any */ // [self iterate]; // start scheduler [HDLCoreManager.instance startIterateTimer]; } @@ -794,6 +798,7 @@ // reload address book to prepend proxy config domain to contacts' phone number // todo: STOP doing that! // [[LinphoneManager.instance fastAddressBook] fetchContactsInBackGroundThread]; NSLog(@"登录成功"); } } @@ -825,6 +830,7 @@ [HDLCallManager.instance terminateCallWithCall:call]; } -(void)acceptCall{ // [HDLCallManager configAudioSessionWithAudioSession:[AVAudioSession sharedInstance]]; LinphoneCall * call = linphone_core_get_current_call(theLinphoneCore); [HDLCallManager.instance acceptCallWithCall:call hasVideo:YES]; } @@ -1010,6 +1016,51 @@ UIImage *image= [HDLLinPhoneCommon captureImageFromView:view]; [HDLLinPhoneCommon saveImageToPhotosAlbum:image]; } -(void)removeAllAccounts{ const bctbx_list_t *accounts = linphone_core_get_proxy_config_list(theLinphoneCore); size_t count = bctbx_list_size(accounts); for (size_t i = 1; i <= count; i++, accounts = accounts->next) { LinphoneProxyConfig *config = (LinphoneProxyConfig *)accounts->data; if (config!=NULL) { //移除config linphone_core_remove_proxy_config(theLinphoneCore, config); const LinphoneAuthInfo *ai = linphone_proxy_config_find_auth_info(config); if (ai) { linphone_core_remove_auth_info(theLinphoneCore, ai); } } } } -(void)clearConfigs{ // const bctbx_list_t *proxies= // linphone_core_get_proxy_config_list(theLinphoneCore); // if (proxies==NULL) { // return; // } //// NSLog(@"list:%@",list); // while (proxies) { // LinphoneProxyConfig *config = proxies->data; // if (config!=NULL) { // const LinphoneAuthInfo *ai = linphone_proxy_config_find_auth_info(config); // if (ai) { // linphone_core_remove_auth_info(theLinphoneCore, ai); // } // //移除config // linphone_core_remove_proxy_config(theLinphoneCore, config); // } // // // proxies= proxies->next; // } } // C Function static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const char *message) { @@ -1089,6 +1140,192 @@ } } - (BOOL)enterBackgroundMode { linphone_core_enter_background(theLinphoneCore); // LinphoneProxyConfig *proxyCfg = linphone_core_get_default_proxy_config(theLinphoneCore); // BOOL shouldEnterBgMode = FALSE; // // // disable presence // [self enableProxyPublish:NO]; // // // handle proxy config if any // if (proxyCfg) { // const char *refkey = proxyCfg ? linphone_proxy_config_get_ref_key(proxyCfg) : NULL; // BOOL pushNotifEnabled = (refkey && strcmp(refkey, "push_notification") == 0); // if ([HDLConfigManager.instance lpConfigBoolForKeyWithKey:@"backgroundmode_preference"] || pushNotifEnabled) { // if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) { // // For registration register // [self refreshRegisters]; // } // } // // if ([HDLConfigManager.instance lpConfigBoolForKeyWithKey:@"voip_mode_preference"] && [HDLConfigManager.instance lpConfigBoolForKeyWithKey:@"backgroundmode_preference"] && !pushNotifEnabled) { // // Keep this!! Socket VoIP is deprecated after 9.0, but sometimes it's the only way to keep the phone background and receive the call. For example, when there is only local area network. // // register keepalive // NSLog(@"keepalive保活"); // if ([[UIApplication sharedApplication] // setKeepAliveTimeout:600 /*(NSTimeInterval)linphone_proxy_config_get_expires(proxyCfg)*/ // handler:^{ //// LOGW(@"keepalive handler"); // self->mLastKeepAliveDate = [NSDate date]; // if (theLinphoneCore == nil) { //// LOGW(@"It seems that Linphone BG mode was deactivated, just skipping"); // return; // } //// [_iapManager check]; // if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) { // // For registration register // [self refreshRegisters]; // } // linphone_core_iterate(theLinphoneCore); // }]) { // NSLog(@"keepalive handler succesfully registered"); // } else { //// LOGI(@"keepalive handler cannot be registered"); // } // shouldEnterBgMode = TRUE; // } // } // // LinphoneCall *currentCall = linphone_core_get_current_call(theLinphoneCore); // const bctbx_list_t *callList = linphone_core_get_calls(theLinphoneCore); // if (!currentCall // no active call // && callList // at least one call in a non active state // && bctbx_list_find_custom(callList, (bctbx_compare_func)comp_call_state_paused, NULL)) { // [self startCallPausedLongRunningTask]; // } // if (callList) // If at least one call exist, enter normal bg mode // shouldEnterBgMode = TRUE; // // // Stop the video preview // if (theLinphoneCore) { // linphone_core_enable_video_preview(theLinphoneCore, FALSE); // [self iterate]; // } // linphone_core_stop_dtmf_stream(theLinphoneCore); // //// LOGI(@"Entering [%s] bg mode", shouldEnterBgMode ? "normal" : "lite"); // if (!shouldEnterBgMode && floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) { // const char *refkey = proxyCfg ? linphone_proxy_config_get_ref_key(proxyCfg) : NULL; // BOOL pushNotifEnabled = (refkey && strcmp(refkey, "push_notification") == 0); // if (pushNotifEnabled) { //// LOGI(@"Keeping lc core to handle push"); // return YES; // } // return NO; // } return YES; } - (void)enableProxyPublish:(BOOL)enabled { if (linphone_core_get_global_state(theLinphoneCore) != LinphoneGlobalOn || !linphone_core_get_default_friend_list(theLinphoneCore)) { // LOGW(@"Not changing presence configuration because linphone core not ready yet"); return; } if ([HDLConfigManager.instance lpConfigBoolForKeyWithKey:@"publish_presence"]) { // set present to "tv", because "available" does not work yet if (enabled) { linphone_core_set_presence_model(theLinphoneCore, linphone_core_create_presence_model_with_activity(theLinphoneCore, LinphonePresenceActivityTV, NULL)); } const MSList *proxies = linphone_core_get_proxy_config_list(theLinphoneCore); while (proxies) { LinphoneProxyConfig *cfg = proxies->data; linphone_proxy_config_edit(cfg); linphone_proxy_config_enable_publish(cfg, enabled); linphone_proxy_config_done(cfg); proxies = proxies->next; } // force registration update first, then update friend list subscription [self iterate]; } linphone_core_enable_friend_list_subscription(theLinphoneCore, enabled && [HDLConfigManager.instance lpConfigBoolForKeyWithKey:@"use_rls_presence"]); } - (void)refreshRegisters { linphone_core_refresh_registers(theLinphoneCore); // just to make sure REGISTRATION is up to date } - (void)startCallPausedLongRunningTask { pausedCallBgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ // LOGW(@"Call cannot be paused any more, too late"); [[UIApplication sharedApplication] endBackgroundTask:self->pausedCallBgTask]; }]; // LOGI(@"Long running task started, remaining [%@] because at least one call is paused", // [LinphoneUtils intervalToString:[[UIApplication sharedApplication] backgroundTimeRemaining]]); } -(void)willResignActive{ LinphoneCall *call = linphone_core_get_current_call(theLinphoneCore); if (!call) return; /* save call context */ HDLLinphoneManager *instance = HDLLinphoneManager.instance; instance->currentCallContextBeforeGoingBackground.call = call; instance->currentCallContextBeforeGoingBackground.cameraIsEnabled = linphone_call_camera_enabled(call); const LinphoneCallParams *params = linphone_call_get_current_params(call); if (linphone_call_params_video_enabled(params)) linphone_call_enable_camera(call, false); } - (void)becomeActive { linphone_core_enter_foreground(theLinphoneCore); [self checkNewVersion]; // enable presence if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) { [self refreshRegisters]; } if (pausedCallBgTask) { [[UIApplication sharedApplication] endBackgroundTask:pausedCallBgTask]; pausedCallBgTask = 0; } if (incallBgTask) { [[UIApplication sharedApplication] endBackgroundTask:incallBgTask]; incallBgTask = 0; } /*IOS specific*/ linphone_core_start_dtmf_stream(theLinphoneCore); [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted){ }]; /*start the video preview in case we are in the main view*/ if (linphone_core_video_display_enabled(theLinphoneCore) && [HDLConfigManager.instance lpConfigBoolForKeyWithKey:@"preview_preference"]) { linphone_core_enable_video_preview(theLinphoneCore, TRUE); } /*check last keepalive handler date*/ if (mLastKeepAliveDate != Nil) { NSDate *current = [NSDate date]; if ([current timeIntervalSinceDate:mLastKeepAliveDate] > 700) { NSString *datestr = [mLastKeepAliveDate description]; // LOGW(@"keepalive handler was called for the last time at %@", datestr); } } [self enableProxyPublish:YES]; } - (void)checkNewVersion { // if (!CHECK_VERSION_UPDATE) // return; // if (theLinphoneCore == nil) // return; // NSString *curVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; // const char *curVersionCString = [curVersion cStringUsingEncoding:NSUTF8StringEncoding]; // linphone_core_check_for_update(theLinphoneCore, curVersionCString); } static int comp_call_state_paused(const LinphoneCall *call, const void *param) { return linphone_call_get_state(call) != LinphoneCallPaused; } @end HDLLinPhoneSDK/HDLLinPhoneSDK/HDLProviderDelegate.swift
@@ -75,13 +75,14 @@ let callInfo = callInfos[uuid] let callId = callInfo?.callId // HDLCallManager.instance().lc?.activateAudioSession(actived: true) provider.reportNewIncomingCall(with: uuid, update: update) { error in if error == nil { HDLCallManager.instance().providerDelegate.endCallNotExist(uuid: uuid, timeout: .now() + 20) } else { if (call == nil) { callInfo?.declined = true self.callInfos.updateValue(callInfo!, forKey: uuid) @@ -159,11 +160,12 @@ if (call == nil || call?.state != Call.State.IncomingReceived) { // The application is not yet registered or the call is not yet received, mark the call as accepted. The audio session must be configured here. HDLCallManager.configAudioSession(audioSession: AVAudioSession.sharedInstance()) print("进来这里了") callInfo?.accepted = true callInfos.updateValue(callInfo!, forKey: uuid) HDLCallManager.instance().providerDelegate.endCallNotExist(uuid: uuid, timeout: .now() + 10) } else { // HDLCallManager.instance().acceptCall(call: call!, hasVideo: call!.params?.videoEnabled ?? false) HDLCallManager.instance().acceptCall(call: call!, hasVideo: call!.params?.videoEnabled ?? false) } action.fulfill() } @@ -268,7 +270,7 @@ } func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) { print("didActivate"); HDLCallManager.instance().lc?.activateAudioSession(actived: true) }