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
Send OPTIONS/INFO/MESSAGE functions

Functions

int com.portsip.PortSipSdk.sendOptions (String to, String sdp)
 
int com.portsip.PortSipSdk.sendInfo (long sessionId, String mimeType, String subMimeType, String infoContents)
 
long com.portsip.PortSipSdk.sendMessage (long sessionId, String mimeType, String subMimeType, byte[] message, int messageLength)
 
long com.portsip.PortSipSdk.sendOutOfDialogMessage (String to, String mimeType, String subMimeType, boolean isSMS, byte[] message, int messageLength)
 
long com.portsip.PortSipSdk.setPresenceMode (int mode)
 
long com.portsip.PortSipSdk.setDefaultSubscriptionTime (int secs)
 
long com.portsip.PortSipSdk.setDefaultPublicationTime (int secs)
 
long com.portsip.PortSipSdk.presenceSubscribe (String contact, String subject)
 
int com.portsip.PortSipSdk.presenceTerminateSubscribe (long subscribeId)
 
int com.portsip.PortSipSdk.presenceAcceptSubscribe (long subscribeId)
 
int com.portsip.PortSipSdk.presenceRejectSubscribe (long subscribeId)
 
int com.portsip.PortSipSdk.setPresenceStatus (long subscribeId, String statusText)
 
long com.portsip.PortSipSdk.sendSubscription (String to, String eventName)
 Send a SUBSCRIBE message to subscribe an event. More...
 
int com.portsip.PortSipSdk.terminateSubscription (long subscribeId)
 

Detailed Description

Function Documentation

◆ sendOptions()

int com.portsip.PortSipSdk.sendOptions ( String  to,
String  sdp 
)

Send OPTIONS message.

Parameters
toThe recipient of OPTIONS message.
sdpThe SDP of OPTIONS message. It's optional if user does not want to send the SDP with OPTIONS message.
Returns
If the function succeeds, it will return value 0. If the function fails, it will return value a specific error code.

◆ sendInfo()

int com.portsip.PortSipSdk.sendInfo ( long  sessionId,
String  mimeType,
String  subMimeType,
String  infoContents 
)

Send a INFO message to remote side in dialog.

Parameters
sessionIdThe session ID of call.
mimeTypeThe mime type of INFO message.
subMimeTypeThe sub mime type of INFO message.
infoContentsThe contents that will be sent with INFO message.
Returns
If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

◆ sendMessage()

long com.portsip.PortSipSdk.sendMessage ( long  sessionId,
String  mimeType,
String  subMimeType,
byte []  message,
int  messageLength 
)

Send a MESSAGE message to remote side in dialog.

Parameters
sessionIdThe session ID of call.
mimeTypeThe mime type of MESSAGE message.
subMimeTypeThe sub mime type of MESSAGE message.
messageThe contents that will be sent with MESSAGE message. Binary data allowed.
messageLengthThe message size.
Returns
If the function succeeds, it will return a message ID that allows to track the message sending state in onSendMessageSuccess and onSendMessageFailure. If the function fails, it will return a specific error code that is less than 0.
Remarks
Example 1: Send a plain text message. Note: to send other languages text, please use the UTF8 to encode the message before sending.
sendMessage(sessionId, "text", "plain", "hello",6);
Example 2: Send a binary message.
sendMessage(sessionId, "application", "vnd.3gpp.sms", binData, binDataSize);

◆ sendOutOfDialogMessage()

long com.portsip.PortSipSdk.sendOutOfDialogMessage ( String  to,
String  mimeType,
String  subMimeType,
boolean  isSMS,
byte []  message,
int  messageLength 
)

Send a out of dialog MESSAGE message to remote side.

Parameters
toThe message receiver. Likes sip:recei.nosp@m.ver@.nosp@m.ports.nosp@m.ip.c.nosp@m.om
mimeTypeThe mime type of MESSAGE message.
subMimeTypeThe sub mime type of MESSAGE message.
isSMSSet to YES to specify "messagetype=SMS" in the To line, or NO to disable.
messageThe contents that will be sent with MESSAGE message. Binary data allowed.
messageLengthThe message size.
Returns
If the function succeeds, it will return a message ID that allows to track the message sending state in onSendOutOfMessageSuccess and onSendOutOfMessageFailure. If the function fails, it will return a specific error code that is less than 0.
Remarks
Example 1: Send a plain text message. Note: to send other languages text, please use the UTF8 to encode the message before sending.
sendOutOfDialogMessage("sip:user1@sip.portsip.com", "text", "plain", "hello", 6);
Example 2: Send a binary message.
sendOutOfDialogMessage("sip:user1@sip.portsip.com","application", "vnd.3gpp.sms", binData, binDataSize);

◆ setPresenceMode()

long com.portsip.PortSipSdk.setPresenceMode ( int  mode)

Indicate the SDK uses the P2P mode for presence or presence agent mode.

Parameters
mode0 - P2P mode; 1 - Presence Agent mode. Default is P2P mode.
Returns
If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.
Remarks
Since presence agent mode requires the PBX/Server support the PUBLISH, please ensure you have your server and PortSIP PBX support this feature. For more details please visit: https://www.portsip.com/portsip-pbx

◆ setDefaultSubscriptionTime()

long com.portsip.PortSipSdk.setDefaultSubscriptionTime ( int  secs)

Set the default expiration time to be used when creating a subscription.

Parameters
secsThe default expiration time of subscription.
Returns
If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

◆ setDefaultPublicationTime()

long com.portsip.PortSipSdk.setDefaultPublicationTime ( int  secs)

Set the default expiration time to be used when creating a publication.

Parameters
secsThe default expiration time of publication.
Returns
If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

◆ presenceSubscribe()

long com.portsip.PortSipSdk.presenceSubscribe ( String  contact,
String  subject 
)

Send a SUBSCRIBE message for presence to a contact.

Parameters
contactThe target contact, it must be in the format of sip:conta.nosp@m.ct00.nosp@m.1@sip.nosp@m..por.nosp@m.tsip..nosp@m.com.
subjectThis subject text will be inserted into the SUBSCRIBE message. For example: "Hello, I'm Jason".
The subject maybe is in UTF8 format. You should use UTF8 to decode it.
Returns
If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

◆ presenceTerminateSubscribe()

int com.portsip.PortSipSdk.presenceTerminateSubscribe ( long  subscribeId)

Terminate the given presence subscription.

Parameters
subscribeIdThe ID of the subscription.
Returns
If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

◆ presenceAcceptSubscribe()

int com.portsip.PortSipSdk.presenceAcceptSubscribe ( long  subscribeId)

Accept the presence SUBSCRIBE request which received from contact.

Parameters
subscribeIdSubscription ID. When receiving a SUBSCRIBE request from contact, the event onPresenceRecvSubscribe will be triggered. The event includes the subscription ID.
Returns
If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

◆ presenceRejectSubscribe()

int com.portsip.PortSipSdk.presenceRejectSubscribe ( long  subscribeId)

Reject a presence SUBSCRIBE request received from contact.

Parameters
subscribeIdSubscription ID. When receiving a SUBSCRIBE request from contact, the event onPresenceRecvSubscribe will be triggered. The event inclues the subscription ID.
Returns
If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

◆ setPresenceStatus()

int com.portsip.PortSipSdk.setPresenceStatus ( long  subscribeId,
String  statusText 
)

Send a NOTIFY message to contact to notify that presence status is online/offline/changed.

Parameters
subscribeIdSubscription ID. When receiving a SUBSCRIBE request from contact, the event onPresenceRecvSubscribe that includes the Subscription ID will be triggered.
statusTextThe state text of presence status. For example: "I'm here", offline must use "offline"
Returns
If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

◆ sendSubscription()

long com.portsip.PortSipSdk.sendSubscription ( String  to,
String  eventName 
)

Send a SUBSCRIBE message to subscribe an event.

Parameters
toThe user/extension will be subscribed.
eventNameThe event name to be subscribed.
Returns
If the function succeeds, it will return the ID of that SUBSCRIBE which is greater than 0. If the function fails, it will return a specific error code which is less than 0.
Remarks
Example 1, below code indicates that user/extension 101 is subscribed to MWI (Message Waiting notifications) for checking his voicemail: int32 mwiSubId = sendSubscription("sip:101@test.com", "message-summary");

Example 2, to monitor a user/extension call status, You can use code: sendSubscription(mSipLib, "100", "dialog"); Extension 100 refers to the user/extension to be monitored. Once being monitored, when extension 100 hold a call or is ringing, the onDialogStateUpdated callback will be triggered.

◆ terminateSubscription()

int com.portsip.PortSipSdk.terminateSubscription ( long  subscribeId)

Terminate the given subscription.

Parameters
subscribeIdThe ID of the subscription.
Returns
If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.
Remarks
For example, if you want stop check the MWI, use below code: