我们正在使用Pjsip-Framework(带有openssl的2.8版)开发适用于Android的Voip应用程序。在某些设备上,我们遇到以下问题: 成功建立Sip呼叫后,参与者之间不会互相听到。每当发生这种情况时,日志中就会出现以下消息:
sound_port.c EC suspended because of inactivity
在参与者可以互相听见的设备上,此消息后跟:
sound_port.c EC activated
此消息不会出现在受影响的设备上,或者会出现,但会延迟一分钟甚至更长的时间。
为激活声音端口,我们使用以下代码,该代码与PjSip Sampleapp中使用的代码相同:
@Override
public void onCallMediaState(OnCallMediaStateParam prm) {
CallInfo ci;
try {
ci = getInfo();
} catch (Exception e) {
return;
}
CallMediaInfoVector cmiv = ci.getMedia();
for (int i = 0; i < cmiv.size(); i++) {
CallMediaInfo cmi = cmiv.get(i);
if (cmi.getType() == pjmedia_type.PJMEDIA_TYPE_AUDIO &&
(cmi.getStatus() == pjsua_call_media_status.PJSUA_CALL_MEDIA_ACTIVE || cmi.getStatus() == pjsua_call_media_status.PJSUA_CALL_MEDIA_REMOTE_HOLD)) {
// unfortunately, on Java too, the returned Media cannot be
// downcasted to AudioMedia
Media m = getMedia(i);
AudioMedia am = AudioMedia.typecastFromMedia(m);
// connect ports
try {
MyApp.ep.audDevManager().getCaptureDevMedia().
startTransmit(am);
am.startTransmit(MyApp.ep.audDevManager().
getPlaybackDevMedia());
} catch (Exception e) {
continue;
}
} else if (cmi.getType() == pjmedia_type.PJMEDIA_TYPE_VIDEO &&
cmi.getStatus() == pjsua_call_media_status.PJSUA_CALL_MEDIA_ACTIVE && cmi.getVideoIncomingWindowId() != pjsua2.INVALID_ID) {
vidWin = new VideoWindow(cmi.getVideoIncomingWindowId());
vidPrev = new VideoPreview(cmi.getVideoCapDev());
}
}
MyApp.observer.notifyCallMediaState(this);
}
就像我说的那样,这段代码似乎可以在某些设备上运行,但在其他设备上却无法(可靠地)运行。任何帮助表示赞赏!