我已经成功地将Linphone 与它们的依赖关系集成到了我的项目中。
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.But的凭据时,它完全正常,当我尝试使用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")
}
}
}发布于 2022-09-23 12:02:06
我认为您的问题是,您试图手动设置DNS服务器。尝试删除代码的这一部分:
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())
Linphone已经处理了这个部分。
否则看上去没问题。如果问题持续存在,则启用调试日志
Factory.instance().setLogCollectionPath(context.filesDir.absolutePath)
Factory.instance().enableLogCollection(LogCollectionState.Enabled)
Factory.instance().setLoggerDomain(appName)
Factory.instance().enableLogcatLogs(true)
Factory.instance().loggingService.setLogLevel(LogLevel.Message)
并把它们连接起来。
https://stackoverflow.com/questions/73825489
复制相似问题