PortSIP VoIP SDK Manual for Android  16.2
PortSIP features our newest, supported, quality-assured VoIP SDK used by Several hundred companies around the world for easy VoIP application develop and quality-assured code.
Functions
Access SIP message header functions

Functions

String com.portsip.PortSipSdk.getSipMessageHeaderValue (String sipMessage, String headerName)
 
int com.portsip.PortSipSdk.addSipMessageHeader (long sessionId, String methodName, int msgType, String headerName, String headerValue)
 
int com.portsip.PortSipSdk.removeAddedSipMessageHeader (long addedSipMessageId)
 
void com.portsip.PortSipSdk.clearAddedSipMessageHeaders ()
 
int com.portsip.PortSipSdk.modifySipMessageHeader (long sessionId, String methodName, int msgType, String headerName, String headerValue)
 
int com.portsip.PortSipSdk.removeModifiedSipMessageHeader (long modifiedSipMessageId)
 
void com.portsip.PortSipSdk.clearModifiedSipMessageHeaders ()
 

Detailed Description

Function Documentation

◆ getSipMessageHeaderValue()

String com.portsip.PortSipSdk.getSipMessageHeaderValue ( String  sipMessage,
String  headerName 
)

Access the SIP header of SIP message.

Parameters
sipMessageThe SIP message.
headerNameThe header of which user wishes to access the SIP message.
Returns
String. The SIP header of SIP message.

◆ addSipMessageHeader()

int com.portsip.PortSipSdk.addSipMessageHeader ( long  sessionId,
String  methodName,
int  msgType,
String  headerName,
String  headerValue 
)

Add the SIP Message header into the specified outgoing SIP message.

Parameters
sessionIdAdd the header to the SIP message with the specified session Id only. By setting to -1, it will be added to all messages.
methodNameAdd the header to the SIP message with specified method name only. For example: "INVITE", "REGISTER", "INFO" etc. If "ALL" specified, it will add all SIP messages.
msgType1 refers to apply to the request message, 2 refers to apply to the response message, 3 refers to apply to both request and response.
headerNameThe header name which will appear in SIP message.
headerValueThe custom header value.
Returns
If the function succeeds, it will return the addedSipMessageId , which is greater than 0. If the function fails, it will return a specific error code.

◆ removeAddedSipMessageHeader()

int com.portsip.PortSipSdk.removeAddedSipMessageHeader ( long  addedSipMessageId)

Remove the headers (custom header) added by addSipMessageHeader.

Parameters
addedSipMessageIdThe addedSipMessageId return by addSipMessageHeader.
Returns
If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

◆ clearAddedSipMessageHeaders()

void com.portsip.PortSipSdk.clearAddedSipMessageHeaders ( )

Clear the added extension headers (custom headers)

Remarks
For example, we have added two custom headers into every outgoing SIP message and want to have them removed.
addSipMessageHeader(-1,"ALL",3,"Blling", "usd100.00");
addSipMessageHeader(-1,"ALL",3,"ServiceId", "8873456");
If this function is called, the added extension headers will no longer appear in outgoing SIP message.

◆ modifySipMessageHeader()

int com.portsip.PortSipSdk.modifySipMessageHeader ( long  sessionId,
String  methodName,
int  msgType,
String  headerName,
String  headerValue 
)

Modify the special SIP header value for every outgoing SIP message.

Parameters
sessionIdThe header to the SIP message with the specified session Id. By setting to -1, it will be added to all messages.
methodNameModify the header to the SIP message with specified method name only. For example: "INVITE", "REGISTER", "INFO" etc. If "ALL" specified, it will add all SIP messages.
msgType1 refers to apply to the request message, 2 refers to apply to the response message, 3 refers to apply to both request and response.
headerNameThe SIP header name of which the value will be modified.
headerValueThe heaver value to be modified.
Returns
If the function succeeds, it will return modifiedSipMessageId, which is greater than 0. If the function fails, it will return a specific error code.
Remarks
Example: modify "Expires" header and "User-Agent" header value for every outgoing SIP message:
modifySipMessageHeader(-1,"ALL",3, "Expires", "1000");
modifySipMessageHeader(-1,"ALL",3, "User-Agent", "MyTest Softphone 1.0");

◆ removeModifiedSipMessageHeader()

int com.portsip.PortSipSdk.removeModifiedSipMessageHeader ( long  modifiedSipMessageId)

Remove the headers (custom header) added by modifiedSipMessageId.

Parameters
modifiedSipMessageIdThe modifiedSipMessageId return by modifySipMessageHeader.
Returns
If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

◆ clearModifiedSipMessageHeaders()

void com.portsip.PortSipSdk.clearModifiedSipMessageHeaders ( )

Clear the modify headers value. Once cleared, it will no longer modify every outgoing SIP message header values.

Remarks
Example: modify two headers value for every outgoing SIP message and then clear it:
modifySipMessageHeader(-1,"ALL",3, "Expires", "1000");
modifySipMessageHeader(-1,"ALL",3, "User-Agent", "MyTest Softphone 1.0");
cleaModifyHeaders();