【发布时间】:2022-09-23 20:02:06
【问题描述】:
我已经成功整合Linphone SDK在我的项目中与他们的依赖。
implementation \'org.linphone:linphone-sdk-android:5.1.59\'
// Adding this dependency allows the linphone-sdk to automatically handle audio focus
implementation \'androidx.media:media:1.6.0\'
并且在使用 linphone 的凭据时它完全可以正常工作。但是当我尝试使用我们的 PBX 的 sip 凭据时它会抛出io错误
我已经测试了我们本地网络的凭据Linphone安卓应用它工作正常。但是当尝试登录我的应用程序时它会引发错误。
我已添加此代码以在 SIP 中登录。
fun login(domain: String, username: String, password: String) {
val mgr: ConnectivityManager =
getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val listAddress: MutableList<String> = ArrayList()
mgr.getLinkProperties(mgr.activeNetwork)?.let{network->
network.dnsServers.forEach {
it.hostAddress?.let { it1 -> listAddress.add(it1) }
}
}
core.setDnsServers(listAddress.map { it }.toTypedArray())
val authInfo =
Factory.instance().createAuthInfo(username, null, password, null, null, domain, null)
val params = core.createAccountParams()
val senderUri = \"sip:$username@$domain\"
val identity = Factory.instance().createAddress(senderUri)
params.identityAddress = identity
val address = Factory.instance().createAddress(\"sip:$domain\")
address?.transport = TransportType.Tls
params.serverAddress = address
params.isOutboundProxyEnabled = true
params.isRegisterEnabled = true
val account = core.createAccount(params)
getInstance().core.addAuthInfo(authInfo)
getInstance().core.addAccount(account)
getInstance().core.defaultAccount = account
core.start()
account.addListener { _, state, message ->
Log.e(TAG, \"login: state $state $message\" )
if (\"$state\" == \"Failed\") {
Utils().showShortToast(getInstance(), \"Registration Failed\")
} else if (\"$state\" == \"Ok\") {
Utils().showShortToast(getInstance(), \"Registration Success\")
}
}
}
标签: android sip linphone sip-server linphone-sdk