Linphone で必要なときに SIP から登録解除して再登録する方法はありますか?
登録解除機能が見つかりません。
そのためにリンフォンコアを完全に破壊する必要がありますか?
または、よりソフトなソリューションはありますか?
現在、iOS で実装しようとしていますが、後で追加のプラットフォームでこれが必要になります。
ありがとうございました。
// Get the default proxyCfg in Linphone
LinphoneProxyConfig* proxyCfg = NULL;
linphone_core_get_default_proxy([LinphoneManager getLc], &proxyCfg);
// To unregister from SIP
linphone_proxy_config_edit(proxyCfg);
linphone_proxy_config_enable_register(proxyCfg, false);
linphone_proxy_config_done(proxyCfg);
// And re-register when want
linphone_proxy_config_edit(proxyCfg);
linphone_proxy_config_enable_register(proxyCfg, true);
linphone_proxy_config_done(proxyCfg);
linphoneを使って登録解除する方法があります。
LinphoneProxyConfig を取得する
LinphoneProxyConfig* proxyCfg = NULL;
linphone_core_get_default_proxy([LinphoneManager getLc], &proxyCfg);
SIP から登録解除するには
linphone_proxy_config_edit(proxyCfg); /*start editing proxy configuration*/
linphone_proxy_config_enable_publish(proxyCfg, TRUE);
linphone_proxy_config_set_publish_expires(proxyCfg, 0);
linphone_proxy_config_enable_register(proxyCfg,FALSE); /*de-activate registration for this proxy config*/
linphone_proxy_config_done(proxyCfg); /*initiate REGISTER with expire = 0*/
while(linphone_proxy_config_get_state(proxyCfg) != LinphoneRegistrationCleared){
NSLog(@"state = %i",linphone_proxy_config_get_state(proxyCfg));
linphone_core_iterate(lc); /*to make sure we receive call backs before shutting down*/
ms_usleep(100000);
}
ただし、アプリがフォアグラウンドの場合にのみ機能します。OS が何らかの理由でアプリを強制終了すると、バックグラウンドで強制終了されます。通知はありません。SIGKILL シグナルをキャッチすることはできません。kill の man ページを見てください。
登録解除は正確に与えられていません。sip 拡張機能を削除してから、リフレッシュ レジスタを呼び出します。ソフトフォンが sip から登録解除されました
[[NSUserDefaults standardUserDefaults] setObject:@"" forKey:@"username_preference"];
if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]
&& [UIApplication sharedApplication].applicationState == UIApplicationStateBackground
&& [[NSUserDefaults standardUserDefaults] boolForKey:@"disable_autoboot_preference"]) {
// autoboot disabled, doing nothing
return;
} else if ([SipManager instance] == nil) {
[self startApplication:caldelegate];
}
[[LinphoneManager instance] becomeActive];
if (callCenter == nil) {
callCenter = [[CTCallCenter alloc] init];
callCenter.callEventHandler = ^(CTCall* call) {
// post on main thread
[self performSelectorOnMainThread:@selector(handleGSMCallInteration:)
withObject:callCenter
waitUntilDone:YES];
};
}
// check call state at startup
[self handleGSMCallInteration:callCenter];
LinphoneCore* lc = [SipManager getLc];
LinphoneCall* call = linphone_core_get_current_call(lc);
if (call == NULL)
return;
SipManager* instance = [SipManager instance];
if (call == instance->currentCallContextBeforeGoingBackground.call) {
const LinphoneCallParams* params = linphone_call_get_current_params(call);
if (linphone_call_params_video_enabled(params)) {
linphone_call_enable_camera(
call,
instance->currentCallContextBeforeGoingBackground.cameraIsEnabled);
}
instance->currentCallContextBeforeGoingBackground.call = 0;
}