Methods
_formatTime() → {string}
Format seconds to "MM:SS" format.
Returns:
- Type:
-
string
(private) _normalize(account, destination) → {string}
Normalize Destination URI
- Source:
Parameters:
Name | Type | Description |
---|---|---|
account |
||
destination |
string
|
Returns:
- Type:
-
string
(private) _onCallChanged(data)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
data |
Object
|
Fires:
(private) _onCallReceived(data)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
data |
Object
|
Fires:
(private) _onCallScreenLocked(lock)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
lock |
bool |
Fires:
(private) _onCallTerminated(data)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
data |
Object
|
Fires:
(private) _onConnectivityChanged(available)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
available |
bool |
Fires:
(private) _onConnectivityChanged(data)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
data |
Object
|
Fires:
(private) _onMessageReceived(data)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
data |
Object
|
Fires:
(private) _onRegistrationChanged(data)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
data |
Object
|
Fires:
answerCall(call) → {Promise}
Send response to incoming INVITE request.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
call |
Call
|
Call instance |
Returns:
- Type:
-
Promise
changeNetworkConfiguration(configuration) → {Promise}
- Source:
Parameters:
Name | Type | Description |
---|---|---|
configuration |
Returns:
- Type:
-
Promise
changeServiceConfiguration(configuration) → {Promise}
- Source:
Parameters:
Name | Type | Description |
---|---|---|
configuration |
Returns:
- Type:
-
Promise
createAccount(configuration) → {Promise}
Add a new account. If registration is configured for this account, this function would also start the SIP registration session with the SIP registrar server. This SIP registration session will be maintained internally by the library, and application doesn't need to do anything to maintain the registration session.
An example configuration: { name: "John Doe", username: "100", domain: "pbx.com", password: "XXXXXX",
proxy: "192.168.100.1:5060", // default disabled. transport: "TCP", // default TCP regServer: "pbx.com", // default taken from domain regTimeout: 300, // default 300 }
- Source:
Parameters:
Name | Type | Description |
---|---|---|
configuration |
Object
|
Returns:
- Type:
-
Promise
declineCall(call) → {Promise}
Hangup call by using Decline (603) method.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
call |
Call
|
Call instance |
Returns:
- Type:
-
Promise
deleteAccount(account) → {Promise}
Delete an account. This will unregister the account from the SIP server, if necessary, and terminate server side presence subscriptions associated with this account.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
account |
Account
|
Returns:
- Type:
-
Promise
dtmfCall(call, digits) → {Promise}
Send DTMF digits to remote using RFC 2833 payload formats.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
call |
Call
|
Call instance |
digits |
String
|
DTMF string digits to be sent as described on RFC 2833 section 3.10. |
Returns:
- Type:
-
Promise
getAccountId() → {int}
The account ID where this message belongs.
- Source:
Returns:
- Type:
-
int
getAccountId() → {int}
The account ID where this call belongs.
Returns:
- Type:
-
int
getAudioCount() → {int}
Number of simultaneous active audio streams for this call. If zero - audio is disabled in this call.
Returns:
- Type:
-
int
getBody() → {String}
Message body, or NULL if no message body is attached to this mesage.
- Source:
Returns:
- Type:
-
String
getConnectDuration() → {int}
Up-to-date call connected duration (zero when call is not established)
Returns:
- Type:
-
int
getContactParams() → {String}
Additional parameters that will be appended in the Contact header for this account.
- Source:
Returns:
- Type:
-
String
getContactUri() → {String}
The Contact URI of the sender, if present.
- Source:
Returns:
- Type:
-
String
getContactUriParams() → {String}
Additional URI parameters that will be appended in the Contact URI for this account.
- Source:
Returns:
- Type:
-
String
getContentType() → {String}
MIME type of the message.
- Source:
Returns:
- Type:
-
String
getDomain() → {int|null}
Domain specified in Endpoint.createAccount().
- Source:
Returns:
- Type:
-
int
|null
getFormattedConnectDuration() → {string}
Call duration in "MM:SS" format.
Returns:
- Type:
-
string
getFormattedTotalDuration() → {string}
Call duration in "MM:SS" format.
Returns:
- Type:
-
string
getFromName() → {String}
Sender name, or NULL if no name specified in URI.
- Source:
Returns:
- Type:
-
String
getLastReason() → {string}
The reason phrase describing the last status.
Returns:
- Type:
-
string
getLastStatusCode() → {string}
Last status code heard, which can be used as cause code. Possible values:
- PJSIP_SC_TRYING / 100
- PJSIP_SC_RINGING / 180
- PJSIP_SC_CALL_BEING_FORWARDED / 181
- PJSIP_SC_QUEUED / 182
- PJSIP_SC_PROGRESS / 183
- PJSIP_SC_OK / 200
- PJSIP_SC_ACCEPTED / 202
- PJSIP_SC_MULTIPLE_CHOICES / 300
- PJSIP_SC_MOVED_PERMANENTLY / 301
- PJSIP_SC_MOVED_TEMPORARILY / 302
- PJSIP_SC_USE_PROXY / 305
- PJSIP_SC_ALTERNATIVE_SERVICE / 380
- PJSIP_SC_BAD_REQUEST / 400
- PJSIP_SC_UNAUTHORIZED / 401
- PJSIP_SC_PAYMENT_REQUIRED / 402
- PJSIP_SC_FORBIDDEN / 403
- PJSIP_SC_NOT_FOUND / 404
- PJSIP_SC_METHOD_NOT_ALLOWED / 405
- PJSIP_SC_NOT_ACCEPTABLE / 406
- PJSIP_SC_PROXY_AUTHENTICATION_REQUIRED / 407
- PJSIP_SC_REQUEST_TIMEOUT / 408
- PJSIP_SC_GONE / 410
- PJSIP_SC_REQUEST_ENTITY_TOO_LARGE / 413
- PJSIP_SC_REQUEST_URI_TOO_LONG / 414
- PJSIP_SC_UNSUPPORTED_MEDIA_TYPE / 415
- PJSIP_SC_UNSUPPORTED_URI_SCHEME / 416
- PJSIP_SC_BAD_EXTENSION / 420
- PJSIP_SC_EXTENSION_REQUIRED / 421
- PJSIP_SC_SESSION_TIMER_TOO_SMALL / 422
- PJSIP_SC_INTERVAL_TOO_BRIEF / 423
- PJSIP_SC_TEMPORARILY_UNAVAILABLE / 480
- PJSIP_SC_CALL_TSX_DOES_NOT_EXIST / 481
- PJSIP_SC_LOOP_DETECTED / 482
- PJSIP_SC_TOO_MANY_HOPS / 483
- PJSIP_SC_ADDRESS_INCOMPLETE / 484
- PJSIP_AC_AMBIGUOUS / 485
- PJSIP_SC_BUSY_HERE / 486
- PJSIP_SC_REQUEST_TERMINATED / 487
- PJSIP_SC_NOT_ACCEPTABLE_HERE / 488
- PJSIP_SC_BAD_EVENT / 489
- PJSIP_SC_REQUEST_UPDATED / 490
- PJSIP_SC_REQUEST_PENDING / 491
- PJSIP_SC_UNDECIPHERABLE / 493
- PJSIP_SC_INTERNAL_SERVER_ERROR / 500
- PJSIP_SC_NOT_IMPLEMENTED / 501
- PJSIP_SC_BAD_GATEWAY / 502
- PJSIP_SC_SERVICE_UNAVAILABLE / 503
- PJSIP_SC_SERVER_TIMEOUT / 504
- PJSIP_SC_VERSION_NOT_SUPPORTED / 505
- PJSIP_SC_MESSAGE_TOO_LARGE / 513
- PJSIP_SC_PRECONDITION_FAILURE / 580
- PJSIP_SC_BUSY_EVERYWHERE / 600
- PJSIP_SC_DECLINE / 603
- PJSIP_SC_DOES_NOT_EXIST_ANYWHERE / 604
- PJSIP_SC_NOT_ACCEPTABLE_ANYWHERE / 606
- PJSIP_SC_TSX_TIMEOUT / PJSIP_SC_REQUEST_TIMEOUT
- PJSIP_SC_TSX_TRANSPORT_ERROR / PJSIP_SC_SERVICE_UNAVAILABLE
Returns:
- Type:
-
string
getLocalContact() → {String}
Local Contact. TODO: Provide example
Returns:
- Type:
-
String
getLocalUri() → {String}
Local URI. TODO: Provide example
Returns:
- Type:
-
String
getName() → {String}
Full name specified in Endpoint.createAccount().
- Source:
Returns:
- Type:
-
String
getPassword() → {String}
Password specified in Endpoint.createAccount().
- Source:
Returns:
- Type:
-
String
getProxy() → {String}
Proxy specified in Endpoint.createAccount().
- Source:
Returns:
- Type:
-
String
getReason() → {String|null}
Reason phrase received.
- Source:
Returns:
- Type:
-
String
|null
getRegistration() → {AccountRegistration}
Account registration status.
- Source:
Returns:
- Type:
-
AccountRegistration
getRegServer() → {String}
Port specified in Endpoint.createAccount().
- Source:
Returns:
- Type:
-
String
getRegTimeout() → {String}
Port specified in Endpoint.createAccount().
- Source:
Returns:
- Type:
-
String
getRemoteAudioCount() → {int}
Number of audio streams offered by remote.
Returns:
- Type:
-
int
getRemoteContact() → {String}
Remote contact. TODO: Provide example
Returns:
- Type:
-
String
getRemoteName() → {String}
Callee name. Could be null if no name specified in URI.
Returns:
- Type:
-
String
getRemoteOfferer() → {boolean}
Flag if remote was SDP offerer
Returns:
- Type:
-
boolean
getRemoteUri() → {String}
Remote URI. TODO: Provide example
Returns:
- Type:
-
String
getRemoteVideoCount() → {int}
Number of video streams offered by remote.
Returns:
- Type:
-
int
getState() → {String}
Invite session state.
PJSIP_INV_STATE_NULL Before INVITE is sent or received PJSIP_INV_STATE_CALLING After INVITE is sent PJSIP_INV_STATE_INCOMING After INVITE is received. PJSIP_INV_STATE_EARLY After response with To tag. PJSIP_INV_STATE_CONNECTING After 2xx is sent/received. PJSIP_INV_STATE_CONFIRMED After ACK is sent/received. PJSIP_INV_STATE_DISCONNECTED Session is terminated.
Returns:
- Type:
-
String
getStateText() → {String}
Text describing the state.
Returns:
- Type:
-
String
getStatus() → {string|null}
Last registration status code (SIP status codes according to RFC 3261). If status code is empty, the account is currently not registered. Any other value indicates the SIP status code of the registration.
- Source:
Returns:
- Type:
-
string
|null
getStatusText() → {string|null}
String describing the registration status.
- Source:
Returns:
- Type:
-
string
|null
getTotalDuration() → {int}
Up-to-date call duration in seconds. Use local time to calculate actual call duration.
Returns:
- Type:
-
int
getToUri() → {String}
URI of the destination message.
- Source:
Returns:
- Type:
-
String
getTransport() → {String}
Transport specified in Endpoint.createAccount().
- Source:
Returns:
- Type:
-
String
getURI() → {String}
This is the URL to be put in the request URI for the registration, and will look something like "sip:serviceprovider".
- Source:
Returns:
- Type:
-
String
getUsername() → {String}
Username specified in Endpoint.createAccount().
- Source:
Returns:
- Type:
-
String
getVideoCount() → {*}
Number of simultaneous active video streams for this call. If zero - video is disabled in this call.
Returns:
- Type:
-
*
hangupCall(call) → {Promise}
Hangup call by using method that is appropriate according to the call state.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
call |
Call
|
Call instance |
Returns:
- Type:
-
Promise
holdCall(call) → {Promise}
Put the specified call on hold. This will send re-INVITE with the appropriate SDP to inform remote that the call is being put on hold.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
call |
Call
|
Call instance |
Returns:
- Type:
-
Promise
isActive()
Flag to tell whether this account is currently registered (has active registration session).
- Source:
Returns:
boolean
makeCall(account, destination, callSettings, msgSettings)
Make an outgoing call to the specified URI. Available call settings:
- audioCount - Number of simultaneous active audio streams for this call. Setting this to zero will disable audio in this call.
- videoCount - Number of simultaneous active video streams for this call. Setting this to zero will disable video in this call. -
- Source:
Parameters:
Name | Type | Description |
---|---|---|
account |
Account
|
|
destination |
String
|
Destination SIP URI. |
callSettings |
PjSipCallSetttings
|
Outgoing call settings. |
msgSettings |
PjSipMsgData
|
Outgoing call additional information to be sent with outgoing SIP message. |
muteCall(call) → {Promise}
- Source:
Parameters:
Name | Type | Description |
---|---|---|
call |
Call
|
Call instance |
Returns:
- Type:
-
Promise
redirectCall(account, call, destination) → {Promise}
Redirect (forward) specified call to destination. This function will send response to INVITE to instruct remote call party to redirect incoming call to the specified destination/target.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
account |
Account
|
Account associated with call. |
call |
Call
|
The call to be transferred. |
destination |
URI of new target to be contacted. The URI may be in name address or addr-spec format. |
Returns:
- Type:
-
Promise
registerAccount(account, bool) → {Promise}
Update registration or perform unregistration. If registration is configured for this account, then initial SIP REGISTER will be sent when the account is added. Application normally only need to call this function if it wants to manually update the registration or to unregister from the server.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
account |
Account
|
|
bool |
renew If renew argument is zero, this will start unregistration process. |
Returns:
- Type:
-
Promise
start() → {Promise}
Returns a Promise that will be resolved once PjSip module is initialized. Do not call any function while library is not initialized.
- Source:
Returns:
- Type:
-
Promise
unholdCall(call) → {Promise}
Release the specified call from hold. This will send re-INVITE with the appropriate SDP to inform remote that the call is resumed.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
call |
Call
|
Call instance |
Returns:
- Type:
-
Promise
unMuteCall(call) → {Promise}
- Source:
Parameters:
Name | Type | Description |
---|---|---|
call |
Call
|
Call instance |
Returns:
- Type:
-
Promise
useEarpiece(call) → {Promise}
- Source:
Parameters:
Name | Type | Description |
---|---|---|
call |
Call
|
Call instance |
Returns:
- Type:
-
Promise
useSpeaker(call) → {Promise}
- Source:
Parameters:
Name | Type | Description |
---|---|---|
call |
Call
|
Call instance |
Returns:
- Type:
-
Promise
xferCall(account, call, destination) → {Promise}
Initiate call transfer to the specified address. This function will send REFER request to instruct remote call party to initiate a new INVITE session to the specified destination/target.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
account |
Account
|
Account associated with call. |
call |
Call
|
The call to be transferred. |
destination |
URI of new target to be contacted. The URI may be in name address or addr-spec format. |
Returns:
- Type:
-
Promise
xferReplacesCall(call, destCall) → {Promise}
Initiate attended call transfer. This function will send REFER request to instruct remote call party to initiate new INVITE session to the URL of destCall. The party at destCall then should "replace" the call with us with the new call from the REFER recipient.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
call |
Call
|
The call to be transferred. |
destCall |
Call
|
The call to be transferred. |
Returns:
- Type:
-
Promise
Type Definitions
PjSipCallSetttings
An additional information to be sent with outgoing SIP message. It can (optionally) be specified for example with #Endpoint.makeCall(), #Endpoint.answerCall(), #Endpoint.hangupCall(),
#Endpoint.holdCall() and many more.
Properties:
Name | Type | Description |
---|---|---|
flag |
number
|
Bitmask of #pjsua_call_flag constants. |
req_keyframe_method |
number
|
This flag controls what methods to request keyframe are allowed on the call. |
aud_cnt |
number
|
Number of simultaneous active audio streams for this call. Setting this to zero will disable audio in this call. |
vid_cnt |
number
|
Number of simultaneous active video streams for this call. Setting this to zero will disable video in this call. |
- Source:
Type:
-
Object
PjSipHdrList
SIP headers object, where each key is a header name and value is a header value. Example: { "X-Custom-Header": "Test Header Value", "X-Custom-ID": "Awesome Header" }
- Source:
Type:
-
Object
PjSipMsgData
An additional information to be sent with outgoing SIP message. It can (optionally) be specified for example with #Endpoint.makeCall(), #Endpoint.answerCall(), #Endpoint.hangupCall(),
#Endpoint.holdCall() and many more.
Properties:
Name | Type | Description |
---|---|---|
target_uri |
String
|
Indicates whether the Courage component is present. |
hdr_list |
PjSipHdrList
|
Additional message headers as linked list. |
content_type |
String
|
MIME type of optional message body. |
msg_body |
String
|
MIME type of optional message body. |
- Source:
Type:
-
Object