Reputation: 35
Below is my source code for pjsip calling -
String buddy_uri = item.get("uri");
SipHeaderVector sipHeaderVector = new SipHeaderVector(2);
SipHeader sipHeader1 = new SipHeader();
sipHeader1.setHName("Header1");
sipHeader1.setHValue("Value1");
SipHeader sipHeader2 = new SipHeader();
sipHeader.setHName("Header2");
sipHeader.setHValue("Value2");
sipHeaderVector.set(0,sipHeader1);
sipHeaderVector.set(1,sipHeader2);
MyCall call = new MyCall(account, -1);
CallOpParam prm = new CallOpParam(true);
SipTxOption sipTxOption = new SipTxOption();
sipTxOption.setHeaders(sipHeaderVector);
prm.setTxOption(sipTxOption);
try {
call.makeCall(buddy_uri, prm);
} catch (Exception e) {
call.delete();
return;
}
Above is a code for PJSIP calling by passing custom headers. Unfortunately, authentication is failing as it seems header values are not going in request.
Is above code correct for passing custom headers and their respective values as followed all the documentation of C++ provided by pjsua to pass headers but seems call is not established and asking for some pin which is required on server for authentication via headers.
can some one help???
Upvotes: 0
Views: 1791
Reputation: 1687
I'm not using for passing the arguments the SipTxOption
. Here is my working example that works:
CallOpParam prm = new CallOpParam(true);
SipHeaderVector shv = new SipHeaderVector();
SipHeader sh = new SipHeader();
sh.setHName("headerName");
sh.setHValue("headerValue");
// add the sip header to the vector
shv.add(sh);
// set headers to the parameter object
prm.getTxOption().setHeaders(shv);
// make call using the desired parameters
try {
call.makeCall(buddy_uri, prm);
} catch (Exception e) {
call.delete();
return;
}
But in order for the SipHeaders
to be other party you have to edit the extensions_macro.conf
to forward the custom headers. You can accomplish this by writing:
exten => s,n,SIPAddHeader(headerName: ${SIP_HEADER(headerName)})
You can also check this thread for some other clarifications.
Hope it helps.
Upvotes: 4