Pjsip Android:如何添加授权标头以进行邀请

时间:2014-12-17 23:28:22

标签: android pjsip

你能帮我吗?我正在使用Android的Pjsua2示例应用程序。我有疑问 - 如何添加授权标题以进行邀请?

INVITE sip:+791595XXXXX@call.com SIP/2.0
Via: SIP/2.0/UDP 95.37.XXX.XX:6000;rport;branch=z9hG4bKPjnWXRln66GYHHtnajQrPPm1ntV4PglwP6
Max-Forwards: 70
From: sip:localhost;tag=tufoJTZhvC15.yGisp-ZSzr7nTxLnfz3
To: sip:+791595XXXXX@call.com
Contact: <sip:95.37.XXX.XX:6000;ob>
Call-ID: v6TibFrvaRatCbTPe5tYjWUEsT067Nkl
CSeq: 1245 INVITE
Route: <sip:call.com;lr>
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800
Min-SE: 90
User-Agent: Pjsua2 Android 2.3-svn
Content-Type: application/sdp
Content-Length:   825

请帮助我!

1 个答案:

答案 0 :(得分:0)

在发送INVITE之前,您需要先注册。在REGISTER消息中,您可以添加Authorization标头。成功注册授权后,如果需要,PJSIP将自动在INVITE中发送授权标头。

以下是一个例子:

app = new MyApp(); 
app.init(MainActivity.this); 
accCfg = new AccountConfig(); 
accCfg.setIdUri(acc_id); 
accCfg.getRegConfig().setRegistrarUri("sip:" + domain); 
AuthCredInfo cred = new AuthCredInfo("Digest", "*", username, 0, password);
accCfg.getSipConfig().getAuthCreds().add(cred);
accCfg.getSipConfig().getProxies().add(proxy);
accCfg.getNatConfig().setIceEnabled(true);
account = app.addAcc(accCfg);