pjsip logo pjsip.org
Open source SIP stack and media stack for presence, im/instant messaging, and multimedia communication

HOME

SIP/media Features
High Performance SIP
Small Footprint SIP
Symbian Port

FAQ

Documentation

Licensing

Download

Development (Trac)

Projects using pjsip

Mailing List

Open Source Links


About: PJLIB, PJLIB-UTIL, PJSIP, and PJMEDIA are created by: Benny Prijono
<bennylp@pjsip.org>


 

Home --> Documentations --> PJSIP Reference

PJSUA-API Accounts Management
[PJSUA API - High Level Softphone API for C/C++ and Python]


Detailed Description

PJSUA accounts provide identity (or identities) of the user who is currently using the application. In SIP terms, the identity is used as the From header in outgoing requests.

PJSUA-API supports creating and managing multiple accounts. The maximum number of accounts is limited by a compile time constant PJSUA_MAX_ACC.

Account may or may not have client registration associated with it. An account is also associated with route set and some authentication credentials, which are used when sending SIP request messages using the account. An account also has presence's online status, which will be reported to remote peer when they subscribe to the account's presence, or which is published to a presence server if presence publication is enabled for the account.

At least one account MUST be created in the application. If no user association is required, application can create a userless account by calling pjsua_acc_add_local(). A userless account identifies local endpoint instead of a particular user, and it correspond with a particular transport instance.

Also one account must be set as the default account, which is used as the account to use when PJSUA fails to match a request with any other accounts.

When sending outgoing SIP requests (such as making calls or sending instant messages), normally PJSUA requires the application to specify which account to use for the request. If no account is specified, PJSUA may be able to select the account by matching the destination domain name, and fall back to default account when no match is found.


Data Structures

struct  pjsua_acc_config
struct  pjsua_acc_info

Defines

#define PJSUA_MAX_ACC   8
#define PJSUA_REG_INTERVAL   300
#define PJSUA_PUBLISH_EXPIRATION   600
#define PJSUA_DEFAULT_ACC_PRIORITY   0
#define PJSUA_SECURE_SCHEME   "sips"

Functions

void pjsua_acc_config_default (pjsua_acc_config *cfg)
void pjsua_acc_config_dup (pj_pool_t *pool, pjsua_acc_config *dst, const pjsua_acc_config *src)
unsigned pjsua_acc_get_count (void)
pj_bool_t pjsua_acc_is_valid (pjsua_acc_id acc_id)
pj_status_t pjsua_acc_set_default (pjsua_acc_id acc_id)
pjsua_acc_id pjsua_acc_get_default (void)
pj_status_t pjsua_acc_add (const pjsua_acc_config *acc_cfg, pj_bool_t is_default, pjsua_acc_id *p_acc_id)
pj_status_t pjsua_acc_add_local (pjsua_transport_id tid, pj_bool_t is_default, pjsua_acc_id *p_acc_id)
pj_status_t pjsua_acc_del (pjsua_acc_id acc_id)
pj_status_t pjsua_acc_modify (pjsua_acc_id acc_id, const pjsua_acc_config *acc_cfg)
pj_status_t pjsua_acc_set_online_status (pjsua_acc_id acc_id, pj_bool_t is_online)
pj_status_t pjsua_acc_set_online_status2 (pjsua_acc_id acc_id, pj_bool_t is_online, const pjrpid_element *pr)
pj_status_t pjsua_acc_set_registration (pjsua_acc_id acc_id, pj_bool_t renew)
pj_status_t pjsua_acc_get_info (pjsua_acc_id acc_id, pjsua_acc_info *info)
pj_status_t pjsua_enum_accs (pjsua_acc_id ids[], unsigned *count)
pj_status_t pjsua_acc_enum_info (pjsua_acc_info info[], unsigned *count)
pjsua_acc_id pjsua_acc_find_for_outgoing (const pj_str_t *url)
pjsua_acc_id pjsua_acc_find_for_incoming (pjsip_rx_data *rdata)
pj_status_t pjsua_acc_create_request (pjsua_acc_id acc_id, const pjsip_method *method, const pj_str_t *target, pjsip_tx_data **p_tdata)
pj_status_t pjsua_acc_create_uac_contact (pj_pool_t *pool, pj_str_t *contact, pjsua_acc_id acc_id, const pj_str_t *uri)
pj_status_t pjsua_acc_create_uas_contact (pj_pool_t *pool, pj_str_t *contact, pjsua_acc_id acc_id, pjsip_rx_data *rdata)
pj_status_t pjsua_acc_set_transport (pjsua_acc_id acc_id, pjsua_transport_id tp_id)


Define Documentation

#define PJSUA_MAX_ACC   8

Maximum accounts.

#define PJSUA_REG_INTERVAL   300

Default registration interval.

#define PJSUA_PUBLISH_EXPIRATION   600

Default PUBLISH expiration

#define PJSUA_DEFAULT_ACC_PRIORITY   0

Default account priority.

#define PJSUA_SECURE_SCHEME   "sips"

This macro specifies the URI scheme to use in Contact header when secure transport such as TLS is used. Application can specify either "sip" or "sips".


Function Documentation

void pjsua_acc_config_default ( pjsua_acc_config cfg  ) 

Call this function to initialize account config with default values.

Parameters:
cfg The account config to be initialized.
Python:
In Python, this function both creates and initializes the account config:
    acc_cfg = py_pjsua.acc_config_default()

void pjsua_acc_config_dup ( pj_pool_t pool,
pjsua_acc_config dst,
const pjsua_acc_config src 
)

Duplicate account config.

Parameters:
pool Pool to be used for duplicating the config.
dst Destination configuration.
src Source configuration.

unsigned pjsua_acc_get_count ( void   ) 

Get number of current accounts.

Returns:
Current number of accounts.
Python:
    count = py_pjsua.acc_get_count()

pj_bool_t pjsua_acc_is_valid ( pjsua_acc_id  acc_id  ) 

Check if the specified account ID is valid.

Parameters:
acc_id Account ID to check.
Returns:
Non-zero if account ID is valid.
Python:
    is_valid = py_pjsua.acc_is_valid(acc_id)

pj_status_t pjsua_acc_set_default ( pjsua_acc_id  acc_id  ) 

Set default account to be used when incoming and outgoing requests doesn't match any accounts.

Parameters:
acc_id The account ID to be used as default.
Returns:
PJ_SUCCESS on success.
Python:
    status = py_pjsua.acc_set_default(acc_id)

pjsua_acc_id pjsua_acc_get_default ( void   ) 

Get default account to be used when receiving incoming requests (calls), when the destination of the incoming call doesn't match any other accounts.

Returns:
The default account ID, or PJSUA_INVALID_ID if no default account is configured.
Python:
    acc_id = py_pjsua.acc_get_default()

pj_status_t pjsua_acc_add ( const pjsua_acc_config acc_cfg,
pj_bool_t  is_default,
pjsua_acc_id p_acc_id 
)

Add a new account to pjsua. PJSUA must have been initialized (with pjsua_init()) before calling this function. 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.

Parameters:
acc_cfg Account configuration.
is_default If non-zero, this account will be set as the default account. The default account will be used when sending outgoing requests (e.g. making call) when no account is specified, and when receiving incoming requests when the request does not match any accounts. It is recommended that default account is set to local/LAN account.
p_acc_id Pointer to receive account ID of the new account.
Returns:
PJ_SUCCESS on success, or the appropriate error code.
Python:
The function returns (status, account_id) tuple:
    status, account_id = py_pjsua.acc_add(acc_cfg, is_default)

pj_status_t pjsua_acc_add_local ( pjsua_transport_id  tid,
pj_bool_t  is_default,
pjsua_acc_id p_acc_id 
)

Add a local account. A local account is used to identify local endpoint instead of a specific user, and for this reason, a transport ID is needed to obtain the local address information.

Parameters:
tid Transport ID to generate account address.
is_default If non-zero, this account will be set as the default account. The default account will be used when sending outgoing requests (e.g. making call) when no account is specified, and when receiving incoming requests when the request does not match any accounts. It is recommended that default account is set to local/LAN account.
p_acc_id Pointer to receive account ID of the new account.
Returns:
PJ_SUCCESS on success, or the appropriate error code.
Python:
The function returns (status, account_id) tuple:
    status, account_id = py_pjsua.acc_add_local(tid, is_default)

pj_status_t pjsua_acc_del ( pjsua_acc_id  acc_id  ) 

Delete an account. This will unregister the account from the SIP server, if necessary, and terminate server side presence subscriptions associated with this account.

Parameters:
acc_id Id of the account to be deleted.
Returns:
PJ_SUCCESS on success, or the appropriate error code.
Python:
    status = py_pjsua.acc_del(acc_id)

pj_status_t pjsua_acc_modify ( pjsua_acc_id  acc_id,
const pjsua_acc_config acc_cfg 
)

Modify account information.

Parameters:
acc_id Id of the account to be modified.
acc_cfg New account configuration.
Returns:
PJ_SUCCESS on success, or the appropriate error code.
Python:
    status = py_pjsua.acc_modify(acc_id, acc_cfg)

pj_status_t pjsua_acc_set_online_status ( pjsua_acc_id  acc_id,
pj_bool_t  is_online 
)

Modify account's presence status to be advertised to remote/presence subscribers. This would trigger the sending of outgoing NOTIFY request if there are server side presence subscription for this account, and/or outgoing PUBLISH if presence publication is enabled for this account.

See also:
pjsua_acc_set_online_status2()
Parameters:
acc_id The account ID.
is_online True of false.
Returns:
PJ_SUCCESS on success, or the appropriate error code.
Python:
    status = py_pjsua.acc_set_online_status(acc_id, is_online)

pj_status_t pjsua_acc_set_online_status2 ( pjsua_acc_id  acc_id,
pj_bool_t  is_online,
const pjrpid_element pr 
)

Modify account's presence status to be advertised to remote/presence subscribers. This would trigger the sending of outgoing NOTIFY request if there are server side presence subscription for this account, and/or outgoing PUBLISH if presence publication is enabled for this account.

See also:
pjsua_acc_set_online_status()
Parameters:
acc_id The account ID.
is_online True of false.
pr Extended information in subset of RPID format which allows setting custom presence text.
Returns:
PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjsua_acc_set_registration ( pjsua_acc_id  acc_id,
pj_bool_t  renew 
)

Update registration or perform unregistration. If registration is configured for this account, then initial SIP REGISTER will be sent when the account is added with pjsua_acc_add(). Application normally only need to call this function if it wants to manually update the registration or to unregister from the server.

Parameters:
acc_id The account ID.
renew If renew argument is zero, this will start unregistration process.
Returns:
PJ_SUCCESS on success, or the appropriate error code.
Python:
    status = py_pjsua.acc_set_registration(acc_id, renew)

pj_status_t pjsua_acc_get_info ( pjsua_acc_id  acc_id,
pjsua_acc_info info 
)

Get information about the specified account.

Parameters:
acc_id Account identification.
info Pointer to receive account information.
Returns:
PJ_SUCCESS on success, or the appropriate error code.
Python:
    acc_info = py_pjsua.acc_get_info(acc_id)
The function returns None if account ID is not valid.

pj_status_t pjsua_enum_accs ( pjsua_acc_id  ids[],
unsigned *  count 
)

Enumerate all account currently active in the library. This will fill the array with the account Ids, and application can then query the account information for each id with pjsua_acc_get_info().

See also:
pjsua_acc_enum_info().
Parameters:
ids Array of account IDs to be initialized.
count In input, specifies the maximum number of elements. On return, it contains the actual number of elements.
Returns:
PJ_SUCCESS on success, or the appropriate error code.
Python:
The function takes no argument and returns list of account Ids:
  [acc_ids] = py_pjsua.enum_accs()

pj_status_t pjsua_acc_enum_info ( pjsua_acc_info  info[],
unsigned *  count 
)

Enumerate account informations.

Parameters:
info Array of account infos to be initialized.
count In input, specifies the maximum number of elements. On return, it contains the actual number of elements.
Returns:
PJ_SUCCESS on success, or the appropriate error code.
Python:
The function takes no argument and returns list of account infos:
    [acc_info] = py_pjsua.acc_enum_info()

pjsua_acc_id pjsua_acc_find_for_outgoing ( const pj_str_t url  ) 

This is an internal function to find the most appropriate account to used to reach to the specified URL.

Parameters:
url The remote URL to reach.
Returns:
Account id.
Python:
    acc_id = py_pjsua.acc_find_for_outgoing(url)

pjsua_acc_id pjsua_acc_find_for_incoming ( pjsip_rx_data rdata  ) 

This is an internal function to find the most appropriate account to be used to handle incoming calls.

Parameters:
rdata The incoming request message.
Returns:
Account id.
Python:
    acc_id = py_pjsua.acc_find_for_outgoing(url)

pj_status_t pjsua_acc_create_request ( pjsua_acc_id  acc_id,
const pjsip_method method,
const pj_str_t target,
pjsip_tx_data **  p_tdata 
)

Create arbitrary requests using the account. Application should only use this function to create auxiliary requests outside dialog, such as OPTIONS, and use the call or presence API to create dialog related requests.

Parameters:
acc_id The account ID.
method The SIP method of the request.
target Target URI.
p_tdata Pointer to receive the request.
Returns:
PJ_SUCCESS or the error code.

pj_status_t pjsua_acc_create_uac_contact ( pj_pool_t pool,
pj_str_t contact,
pjsua_acc_id  acc_id,
const pj_str_t uri 
)

Create a suitable URI to be put as Contact based on the specified target URI for the specified account.

Parameters:
pool Pool to allocate memory for the string.
contact The string where the Contact URI will be stored.
acc_id Account ID.
uri Destination URI of the request.
Returns:
PJ_SUCCESS on success, other on error.
Python:
This function is still experimental in Python:
    uri = py_pjsua.acc_create_uac_contact(pool, acc_id, uri)

pj_status_t pjsua_acc_create_uas_contact ( pj_pool_t pool,
pj_str_t contact,
pjsua_acc_id  acc_id,
pjsip_rx_data rdata 
)

Create a suitable URI to be put as Contact based on the information in the incoming request.

Parameters:
pool Pool to allocate memory for the string.
contact The string where the Contact URI will be stored.
acc_id Account ID.
rdata Incoming request.
Returns:
PJ_SUCCESS on success, other on error.
Python:
This function is still experimental in Python:
    uri = py_pjsua.acc_create_uas_contact(pool, acc_id, rdata)

pj_status_t pjsua_acc_set_transport ( pjsua_acc_id  acc_id,
pjsua_transport_id  tp_id 
)

Lock/bind this account to a specific transport/listener. Normally application shouldn't need to do this, as transports will be selected automatically by the stack according to the destination.

When account is locked/bound to a specific transport, all outgoing requests from this account will use the specified transport (this includes SIP registration, dialog (call and event subscription), and out-of-dialog requests such as MESSAGE).

Note that transport_id may be specified in pjsua_acc_config too.

Parameters:
acc_id The account ID.
tp_id The transport ID.
Returns:
PJ_SUCCESS on success.
Python:
Not yet implemented.

 


PJSIP Open Source, high performance, small footprint, and very very portable SIP stack
(C)2003-2008 Benny Prijono