我正在使用 Pjsip(v2.6) 进行 VoIP 音频和视频通话。
我在第一个来电视频通话中遇到问题。当我注册用户并进行视频通话时,它总是失败。
当我调试我的代码时,我发现我收到的 CallMediaInfo 状态为PJSUA_CALL_MEDIA_NONE。当我第二次尝试时,我收到了PJSUA_CALL_MEDIA_ACTIVE并显示了预览。
这是我的makeCall代码:
fun makeCall(id: String, isVideo: Boolean) {
video = isVideo
val buddyUri = "sip:$CALLEE@$URI"
val call = MyCall(account, -1)
val prm = CallOpParam(true)
val callSettings = prm.opt
if (isVideo) {
callSettings.videoCount = 1
callSettings.audioCount = 1
} else {
callSettings.audioCount = 1
callSettings.videoCount = 0
}
try {
call.makeCall(buddyUri, prm)
} catch (e: Exception) {
call.delete()
}
currentCall = call
}
这是我执行 Incoming_Call 通知的代码:
if (m?.what == Constants.MSGTYPE.INCOMING_CALL) {
/* Incoming call */
val call = m.obj as MyCall
val prm = CallOpParam()
/* Only one call at anytime */
if (currentCall != null) {
call.delete()
return true
}
/* Answer with ringing */
prm.statusCode = pjsip_status_code.PJSIP_SC_RINGING
try {
val callSetting = prm.opt
callSetting?.audioCount = 1
if (video) {
callSetting?.videoCount = 1
} else callSetting?.videoCount = 0
call.answer(prm)
} catch (e: Exception) {
println(e)
}
currentCall = call
if (call.info.remOfferer && call.info.remVideoCount == 1L) {
// start Video Activity
} else {
// start Audio Activity
}
}
当我接听电话时,我收到了 onCallMediaState 回调:
override fun onCallMediaState(prm: OnCallMediaStateParam) {
val ci: CallInfo
try {
ci = info
} catch (e: Exception) {
return
}
val cmiv = ci.media
for (i in 0 until cmiv!!.size()) {
val cmi = cmiv.get(i.toInt())
if (cmi.type == pjmedia_type.PJMEDIA_TYPE_AUDIO && (cmi.status == pjsua_call_media_status.PJSUA_CALL_MEDIA_ACTIVE || cmi.status == pjsua_call_media_status.PJSUA_CALL_MEDIA_REMOTE_HOLD)) {
LogUtils.e("AANAL onCallMediaState Audio")
handleAudioMedia(getMedia(i))
} else if (cmi.type == pjmedia_type.PJMEDIA_TYPE_VIDEO &&
// cmi.status == pjsua_call_media_status.PJSUA_CALL_MEDIA_ACTIVE &&
cmi.videoIncomingWindowId != pjsua2.INVALID_ID) {
LogUtils.e("AANAL onCallMediaState Video")
handleVideoMedia(cmi)
}
}
MyApp.observer.notifyCallMediaState(this)
}
谁能帮我这个?
先感谢您!