📄 pjsua.h
字号:
endpt = py_pjsua.get_pool_factory()
* \endcode
* However currently the object is just an opaque object and does not have
* any use for Python scripts.
*/
PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
/*****************************************************************************
* Utilities.
*
*/
/**
* This is a utility function to verify that valid SIP url is given. If the
* URL is valid, PJ_SUCCESS will be returned.
*
* @param url The URL, as NULL terminated string.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*
* \par Python:
* \code
status = py_pjsua.verify_sip_url(url)
* \endcode
*/
PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
/**
* This is a utility function to display error message for the specified
* error code. The error message will be sent to the log.
*
* @param sender The log sender field.
* @param title Message title for the error.
* @param status Status code.
*
* \par Python:
* \code
py_pjsua.perror(sender, title, status)
* \endcode
*/
PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
pj_status_t status);
/**
* This is a utility function to dump the stack states to log, using
* verbosity level 3.
*
* @param detail Will print detailed output (such as list of
* SIP transactions) when non-zero.
*/
PJ_DECL(void) pjsua_dump(pj_bool_t detail);
/**
* @}
*/
/*****************************************************************************
* TRANSPORT API
*/
/**
* @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
* @ingroup PJSUA_LIB
* @brief API for managing SIP transports
* @{
*
* PJSUA-API supports creating multiple transport instances, for example UDP,
* TCP, and TLS transport. SIP transport must be created before adding an
* account.
*/
/** SIP transport identification.
*/
typedef int pjsua_transport_id;
/**
* Transport configuration for creating transports for both SIP
* and media. Before setting some values to this structure, application
* MUST call #pjsua_transport_config_default() to initialize its
* values with default settings.
*
* \par Python:
* The data type in Python is <tt>py_pjsua.Transport_Config</tt>,
* although application can just do this to create the instance:
* \code
transport_cfg = py_pjsua.transport_config_default()
* \endcode
*/
typedef struct pjsua_transport_config
{
/**
* UDP port number to bind locally. This setting MUST be specified
* even when default port is desired. If the value is zero, the
* transport will be bound to any available port, and application
* can query the port by querying the transport info.
*/
unsigned port;
/**
* Optional address to advertise as the address of this transport.
* Application can specify any address or hostname for this field,
* for example it can point to one of the interface address in the
* system, or it can point to the public address of a NAT router
* where port mappings have been configured for the application.
*
* Note: this option can be used for both UDP and TCP as well!
*/
pj_str_t public_addr;
/**
* Optional address where the socket should be bound to. This option
* SHOULD only be used to selectively bind the socket to particular
* interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
* published address of a transport (the public_addr field should be
* used for that purpose).
*
* Note that unlike public_addr field, the address (or hostname) here
* MUST correspond to the actual interface address in the host, since
* this address will be specified as bind() argument.
*/
pj_str_t bound_addr;
/**
* This specifies TLS settings for TLS transport. It is only be used
* when this transport config is being used to create a SIP TLS
* transport.
*/
pjsip_tls_setting tls_setting;
} pjsua_transport_config;
/**
* Call this function to initialize UDP config with default values.
*
* @param cfg The UDP config to be initialized.
*
* \par Python:
* The corresponding Python function is rather different:
* \code
transport_cfg = py_pjsua.transport_config_default()
* \endcode
*/
PJ_INLINE(void) pjsua_transport_config_default(pjsua_transport_config *cfg)
{
pj_bzero(cfg, sizeof(*cfg));
pjsip_tls_setting_default(&cfg->tls_setting);
}
/**
* Duplicate transport config.
*
* @param pool The pool.
* @param dst The destination config.
* @param src The source config.
*
* \par Python:
* Not applicable. One should be able to just copy one variable instance
* to another in Python.
*/
PJ_INLINE(void) pjsua_transport_config_dup(pj_pool_t *pool,
pjsua_transport_config *dst,
const pjsua_transport_config *src)
{
PJ_UNUSED_ARG(pool);
pj_memcpy(dst, src, sizeof(*src));
}
/**
* This structure describes transport information returned by
* #pjsua_transport_get_info() function.
*
* \par Python:
* The corresponding data type in Python is <tt>py_pjsua.Transport_Info</tt>.
*/
typedef struct pjsua_transport_info
{
/**
* PJSUA transport identification.
*/
pjsua_transport_id id;
/**
* Transport type.
*/
pjsip_transport_type_e type;
/**
* Transport type name.
*/
pj_str_t type_name;
/**
* Transport string info/description.
*/
pj_str_t info;
/**
* Transport flag (see ##pjsip_transport_flags_e).
*/
unsigned flag;
/**
* Local address length.
*/
unsigned addr_len;
/**
* Local/bound address.
*/
pj_sockaddr local_addr;
/**
* Published address (or transport address name).
*/
pjsip_host_port local_name;
/**
* Current number of objects currently referencing this transport.
*/
unsigned usage_count;
} pjsua_transport_info;
/**
* Create and start a new SIP transport according to the specified
* settings.
*
* @param type Transport type.
* @param cfg Transport configuration.
* @param p_id Optional pointer to receive transport ID.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*
* \par Python:
* The corresponding Python function returns (status,id) tuple:
* \code
status, transport_id = py_pjsua.transport_create(type, cfg)
* \endcode
*/
PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
const pjsua_transport_config *cfg,
pjsua_transport_id *p_id);
/**
* Register transport that has been created by application. This function
* is useful if application wants to implement custom SIP transport and use
* it with pjsua.
*
* @param tp Transport instance.
* @param p_id Optional pointer to receive transport ID.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*
* \par Python:
* Not applicable (for now), because one cannot create a custom transport
* from Python script.
*/
PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
pjsua_transport_id *p_id);
/**
* Enumerate all transports currently created in the system. This function
* will return all transport IDs, and application may then call
* #pjsua_transport_get_info() function to retrieve detailed information
* about the transport.
*
* @param id Array to receive transport ids.
* @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 returns list of integers representing transport ids:
* \code
[int] = py_pjsua.enum_transports()
* \endcode
*/
PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
unsigned *count );
/**
* Get information about transports.
*
* @param id Transport ID.
* @param info Pointer to receive transport info.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*
* \par Python:
* \code
transport_info = py_pjsua.transport_get_info(id)
* \endcode
* The Python function returns None on error.
*/
PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
pjsua_transport_info *info);
/**
* Disable a transport or re-enable it. By default transport is always
* enabled after it is created. Disabling a transport does not necessarily
* close the socket, it will only discard incoming messages and prevent
* the transport from being used to send outgoing messages.
*
* @param id Transport ID.
* @param enabled Non-zero to enable, zero to disable.
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*
* \par Python:
* \code
status = py_pjsua.transport_set_enable(id, enabled)
* \endcode
*/
PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
pj_bool_t enabled);
/**
* Close the transport. If transport is forcefully closed, it will be
* immediately closed, and any pending transactions that are using the
* transport may not terminate properly (it may even crash). Otherwise,
* the system will wait until all transactions are closed while preventing
* new users from using the transport, and will close the transport when
* it is safe to do so.
*
* @param id Transport ID.
* @param force Non-zero to immediately close the transport. This
* is not recommended!
*
* @return PJ_SUCCESS on success, or the appropriate error code.
*
* \par Python:
* \code
status = py_pjsua.transport_close(id, force)
* \endcode
*/
PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
pj_bool_t force );
/**
* @}
*/
/*****************************************************************************
* ACCOUNT API
*/
/**
* @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
* @ingroup PJSUA_LIB
* @brief PJSUA Accounts management
* @{
*
* PJSUA accounts provide identity (or identities) of the user who is currently
* using the application. In SIP terms, the identity is used as the <b>From</b>
* header in outgoing requests.
*
* PJSUA-API supports creating and managing multiple accounts. The maximum
* number of accounts is limited by a compile time constant
* <tt>PJSUA_MAX_ACC</tt>.
*
* Account may or may not have client registration associated with it.
* An account is also associated with <b>route set</b> and some <b>authentication
* credentials</b>, which are used when sending SIP request messages using the
* account. An account also has presence's <b>online status</b>, 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 <b>default account</b>, 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.
*/
/**
* Maximum accounts.
*/
#ifndef PJSUA_MAX_ACC
# define PJSUA_MAX_ACC 8
#endif
/**
* Default registration interval.
*/
#ifndef PJSUA_REG_INTERVAL
# define PJSUA_REG_INTERVAL 55
#endif
/**
* Default PUBLISH expiration
*/
#ifndef PJSUA_PUBLISH_EXPIRATION
# define PJSUA_PUBLISH_EXPIRATION 600
#endif
/**
* Default account priority.
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -