我需要开发我的SIP客户端,它使用标准的SIP协议,但是使用自定义协议来处理媒体。
当我尝试发送INVITE时,我收到来自pjsip lib的错误消息,并且不发送数据包。 错误是:
初始化媒体频道时出错(PJ_EBUSY)
初始化lib的代码是:
pjsua_config cfg = new pjsua_config();
// SERVICE CONFIG
if (userAgentReceiver == null) {
userAgentReceiver = new UAStateReceiver();
userAgentReceiver.initService();
}
userAgentReceiver.reconfigure();
pjsua.setCallbackObject(userAgentReceiver);
// MAIN CONFIG
pjsua.config_default(cfg);
cfg.setCb(pjsuaConstants.WRAPPER_CALLBACK_STRUCT);
cfg.setUser_agent(pjsua.pj_str_copy("test"));
// We need at least one thread
int threadCount = 1;
cfg.setThread_cnt(threadCount);
cfg.setUse_srtp(pjmedia_srtp_use.PJMEDIA_SRTP_DISABLED);
cfg.setSrtp_secure_signaling(0);
cfg.setNat_type_in_sdp(0);
pjsip_timer_setting timerSetting = cfg.getTimer_setting();
int minSe = 100;
int sessExp = 1000;
if (minSe <= sessExp && minSe >= 90) {
timerSetting.setMin_se(minSe);
timerSetting.setSess_expires(sessExp);
cfg.setTimer_setting(timerSetting);
}
// LOGGING CONFIG
pjsua_logging_config logCfg = new pjsua_logging_config();
logCfg.setConsole_level(1);
logCfg.setLevel(1);
logCfg.setMsg_logging(pjsuaConstants.PJ_TRUE);
pjsua.logging_config_default(logCfg);
// MEDIA CONFIG
pjsua_media_config mediaCfg = new pjsua_media_config();
mediaCfg.setEnable_ice(pjsuaConstants.PJ_FALSE);
mediaCfg.setEnable_turn(pjsuaConstants.PJ_FALSE);
mediaCfg.setHas_ioqueue(pjsuaConstants.PJ_FALSE);
mediaCfg.setIce_no_rtcp(0);
mediaCfg.setMax_media_ports(0);
mediaCfg.setChannel_count(0);
pjsua.media_config_default(mediaCfg);
csipsimple_config cssCfg = new csipsimple_config();
pjsua.csipsimple_config_default(cssCfg);
// INITIALIZE
status = pjsua.csipsimple_init(cfg, logCfg, mediaCfg, cssCfg, context);
if (status != pjsuaConstants.PJ_SUCCESS) {
cleanPjsua();
return false;
}
注册代码(成功)是:
int[] accId = new int[1];
accId[0] = 1;
pjsua_acc_config cfg = new pjsua_acc_config();
pjsua.acc_config_default(cfg);
csipsimple_acc_config css_cfg = new csipsimple_acc_config();
pjsua.csipsimple_acc_config_default(css_cfg);
cfg.setPriority(100);
cfg.setId(pjsua.pj_str_copy("sip:" + sipUser + "@" + sipServer));
cfg.setReg_uri(pjsua.pj_str_copy("sip:" + sipServer));
cfg.setReg_timeout(60);
cfg.setCred_count(1);
cfg.setUse_rfc5626(pjsuaConstants.PJ_TRUE);
cfg.setReg_delay_before_refresh(60);
cfg.setPublish_enabled(0);
pjsua_transport_config cfgTrasport = new pjsua_transport_config();
int[] tId = new int[1];
int status;
pjsua.transport_config_default(cfgTrasport);
cfgTrasport.setPort(5060);
status = pjsua.transport_create(pjsip_transport_type_e.PJSIP_TRANSPORT_UDP, cfgTrasport, tId);
if (status != pjsuaConstants.PJ_SUCCESS) {
Platform.errorLog("pjsua.transport_create returned status="+status);
}
pjsip_cred_info cred_info = cfg.getCred_info();
cred_info.setRealm(pjsua.pj_str_copy(sipServer));
cred_info.setScheme(pjsua.pj_str_copy("digest"));
cred_info.setUsername(pjsua.pj_str_copy(sipUser));
cred_info.setData_type(pjsip_cred_data_type.PJSIP_CRED_DATA_PLAIN_PASSWD.swigValue());
cred_info.setData(pjsua.pj_str_copy(password));
cfg.setKa_interval(40);
pjsua.csipsimple_set_acc_user_data(cfg, css_cfg);
status = pjsua.acc_add(cfg, pjsuaConstants.PJ_FALSE, accId);
if (status == pjsuaConstants.PJ_SUCCESS) {
status = pjsua.acc_set_online_status(accId[0], 1);
Platform.infoLog("acc_set_online_status returned stauts="+status);
} else {
Platform.infoLog("Error status=" + status);
}
这是我的邀请代码:
pjsua.set_no_snd_dev();
pj_str_t uri = pjsua.pj_str_copy(callee);
// Nothing to do with this values
byte[] userData = new byte[1];
int[] callId = new int[1];
pjsua_call_setting cs = new pjsua_call_setting();
pjsua_msg_data msgData = new pjsua_msg_data();
// Call settings to add video
pjsua.call_setting_default(cs);
cs.setFlag(0);
// Msg data to add headers
pjsua.msg_data_init(msgData);
int status = pjsua.call_make_call(accountId, uri, cs, userData, msgData, callId);
你能看出什么是错的吗?
答案 0 :(得分:3)
pjsua.start()