📄 pjsua.h
字号:
#ifndef PJSUA_DEFAULT_ACC_PRIORITY
# define PJSUA_DEFAULT_ACC_PRIORITY 0
#endif
/**
* This structure describes account configuration to be specified when
* adding a new account with #pjsua_acc_add(). Application MUST initialize
* this structure first by calling #pjsua_acc_config_default().
*
* \par Python:
* The data type in Python is <tt>py_pjsua.Acc_Config</tt>, but normally
* application can just use the snippet below to create and initialize
* the account config:
* \code
acc_cfg = py_pjsua.acc_config_default()
* \endcode
*/
typedef struct pjsua_acc_config
{
/**
* Account priority, which is used to control the order of matching
* incoming/outgoing requests. The higher the number means the higher
* the priority is, and the account will be matched first.
*/
int priority;
/**
* The full SIP URL for the account. The value can take name address or
* URL format, and will look something like "sip:account@serviceprovider".
*
* This field is mandatory.
*/
pj_str_t id;
/**
* This is the URL to be put in the request URI for the registration,
* and will look something like "sip:serviceprovider".
*
* This field should be specified if registration is desired. If the
* value is empty, no account registration will be performed.
*/
pj_str_t reg_uri;
/**
* If this flag is set, the presence information of this account will
* be PUBLISH-ed to the server where the account belongs.
*/
pj_bool_t publish_enabled;
/**
* Optional URI to be put as Contact for this account. It is recommended
* that this field is left empty, so that the value will be calculated
* automatically based on the transport address.
*/
pj_str_t force_contact;
/**
* Number of proxies in the proxy array below.
*
* \par Python:
* Not applicable, as \a proxy is implemented as list of strings.
*/
unsigned proxy_cnt;
/**
* Optional URI of the proxies to be visited for all outgoing requests
* that are using this account (REGISTER, INVITE, etc). Application need
* to specify these proxies if the service provider requires that requests
* destined towards its network should go through certain proxies first
* (for example, border controllers).
*
* These proxies will be put in the route set for this account, with
* maintaining the orders (the first proxy in the array will be visited
* first). If global outbound proxies are configured in pjsua_config,
* then these account proxies will be placed after the global outbound
* proxies in the routeset.
*
* \par Python:
* This will be list of strings.
*/
pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
/**
* Optional interval for registration, in seconds. If the value is zero,
* default interval will be used (PJSUA_REG_INTERVAL, 55 seconds).
*/
unsigned reg_timeout;
/**
* Number of credentials in the credential array.
*
* \par Python:
* Not applicable, since \a cred_info is a list of credentials.
*/
unsigned cred_count;
/**
* Array of credentials. If registration is desired, normally there should
* be at least one credential specified, to successfully authenticate
* against the service provider. More credentials can be specified, for
* example when the requests are expected to be challenged by the
* proxies in the route set.
*
* \par Python:
* This field is a list of credentials.
*/
pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
/**
* Optionally bind this account to specific transport. This normally is
* not a good idea, as account should be able to send requests using
* any available transports according to the destination. But some
* application may want to have explicit control over the transport to
* use, so in that case it can set this field.
*
* Default: -1 (PJSUA_INVALID_ID)
*
* @see pjsua_acc_set_transport()
*/
pjsua_transport_id transport_id;
} pjsua_acc_config;
/**
* Call this function to initialize account config with default values.
*
* @param cfg The account config to be initialized.
*
* \par Python:
* In Python, this function both creates and initializes the account
* config:
* \code
acc_cfg = py_pjsua.acc_config_default()
* \endcode
*/
PJ_INLINE(void) pjsua_acc_config_default(pjsua_acc_config *cfg)
{
pj_bzero(cfg, sizeof(*cfg));
cfg->reg_timeout = PJSUA_REG_INTERVAL;
cfg->transport_id = PJSUA_INVALID_ID;
}
/**
* Account info. Application can query account info by calling
* #pjsua_acc_get_info().
*
* \par Python:
* The data type in Python is <tt>py_pjsua.Acc_Info</tt>.
*/
typedef struct pjsua_acc_info
{
/**
* The account ID.
*/
pjsua_acc_id id;
/**
* Flag to indicate whether this is the default account.
*/
pj_bool_t is_default;
/**
* Account URI
*/
pj_str_t acc_uri;
/**
* Flag to tell whether this account has registration setting
* (reg_uri is not empty).
*/
pj_bool_t has_registration;
/**
* An up to date expiration interval for account registration session.
*/
int expires;
/**
* Last registration status code. If status code is zero, the account
* is currently not registered. Any other value indicates the SIP
* status code of the registration.
*/
pjsip_status_code status;
/**
* String describing the registration status.
*/
pj_str_t status_text;
/**
* Presence online status for this account.
*/
pj_bool_t online_status;
/**
* Buffer that is used internally to store the status text.
*/
char buf_[PJ_ERR_MSG_SIZE];
} pjsua_acc_info;
/**
* Get number of current accounts.
*
* @return Current number of accounts.
*
* \par Python:
* \code
count = py_pjsua.acc_get_count()
* \endcode
*/
PJ_DECL(unsigned) pjsua_acc_get_count(void);
/**
* Check if the specified account ID is valid.
*
* @param acc_id Account ID to check.
*
* @return Non-zero if account ID is valid.
*
* \par Python:
* \code
is_valid = py_pjsua.acc_is_valid(acc_id)
* \endcode
*/
PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
/**
* Set default account to be used when incoming and outgoing
* requests doesn't match any accounts.
*
* @param acc_id The account ID to be used as default.
*
* @return PJ_SUCCESS on success.
*
* \par Python:
* \code
status = py_pjsua.acc_set_default(acc_id)
* \endcode
*/
PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
/**
* Get default account to be used when receiving incoming requests (calls),
* when the destination of the incoming call doesn't match any other
* accounts.
*
* @return The default account ID, or PJSUA_INVALID_ID if no
* default account is configured.
*
* \par Python:
* \code
acc_id = py_pjsua.acc_get_default()
* \endcode
*/
PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
/**
* 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.
*
*
* @param acc_cfg Account configuration.
* @param 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.
* @param p_acc_id Pointer to receive account ID of the new account.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*
* \par Python:
* The function returns (status, account_id) tuple:
* \code
status, account_id = py_pjsua.acc_add(acc_cfg, is_default)
* \endcode
*/
PJ_DECL(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 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.
*
* @param tid Transport ID to generate account address.
* @param 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.
* @param p_acc_id Pointer to receive account ID of the new account.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*
* \par Python:
* The function returns (status, account_id) tuple:
* \code
status, account_id = py_pjsua.acc_add_local(tid, is_default)
* \endcode
*/
PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
pj_bool_t is_default,
pjsua_acc_id *p_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.
*
* @param acc_id Id of the account to be deleted.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*
* \par Python:
* \code
status = py_pjsua.acc_del(acc_id)
* \endcode
*/
PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
/**
* Modify account information.
*
* @param acc_id Id of the account to be modified.
* @param acc_cfg New account configuration.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*
* \par Python:
* \code
status = py_pjsua.acc_modify(acc_id, acc_cfg)
* \endcode
*/
PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
const pjsua_acc_config *acc_cfg);
/**
* 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.
*
* @param acc_id The account ID.
* @param is_online True of false.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*
* \par Python:
* \code
status = py_pjsua.acc_set_online_status(acc_id, is_online)
* \endcode
*/
PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
pj_bool_t is_online);
/**
* 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.
*
* @param acc_id The account ID.
* @param renew If renew argument is zero, this will start
* unregistration process.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*
* \par Python:
* \code
status = py_pjsua.acc_set_registration(acc_id, renew)
* \endcode
*/
PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
pj_bool_t renew);
/**
* Get information about the specified account.
*
* @param acc_id Account identification.
* @param info Pointer to receive account information.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*
* \par Python:
* \code
acc_info = py_pjsua.acc_get_info(acc_id)
* \endcode
* The function returns None if account ID is not valid.
*/
PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
pjsua_acc_info *info);
/**
* 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 pjsua_acc_enum_info().
*
* @param ids Array of account IDs to be initialized.
* @param count In input, specifies the maximum number of elements.
* On return, it contains the actual number of elements.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*
* \par Python:
* The function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -