⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pjsua.h

📁 基于sip协议的网络电话源码
💻 H
📖 第 1 页 / 共 5 页
字号:
    /**     * Application callback to receive various event notifications from     * the library.     */    pjsua_callback  cb;    /**     * Optional user agent string (default empty). If it's empty, no     * User-Agent header will be sent with outgoing requests.     */    pj_str_t	    user_agent;} pjsua_config;/** * Use this function to initialize pjsua config. * * @param cfg	pjsua config to be initialized. * * \par Python Sample Syntax: * The corresponding Python function creates an instance of the config and * initializes it to the default settings: * \code    cfg = py_pjsua.config_default() * \endcode */PJ_INLINE(void) pjsua_config_default(pjsua_config *cfg){    pj_bzero(cfg, sizeof(*cfg));    cfg->max_calls = 4;    cfg->thread_cnt = 1;}/** * Duplicate credential. * * @param pool	    The memory pool. * @param dst	    Destination credential. * @param src	    Source credential. * * \par Python: * Not applicable (for now). Probably we could just assign one credential * variable to another, but this has not been tested. */PJ_INLINE(void) pjsip_cred_dup( pj_pool_t *pool,				pjsip_cred_info *dst,				const pjsip_cred_info *src){    pj_strdup_with_null(pool, &dst->realm, &src->realm);    pj_strdup_with_null(pool, &dst->scheme, &src->scheme);    pj_strdup_with_null(pool, &dst->username, &src->username);    pj_strdup_with_null(pool, &dst->data, &src->data);}/** * Duplicate pjsua_config. * * @param pool	    The pool to get memory from. * @param dst	    Destination config. * @param src	    Source config. */PJ_INLINE(void) pjsua_config_dup(pj_pool_t *pool,				 pjsua_config *dst,				 const pjsua_config *src){    unsigned i;    pj_memcpy(dst, src, sizeof(*src));    for (i=0; i<src->outbound_proxy_cnt; ++i) {	pj_strdup_with_null(pool, &dst->outbound_proxy[i],			    &src->outbound_proxy[i]);    }    for (i=0; i<src->cred_count; ++i) {	pjsip_cred_dup(pool, &dst->cred_info[i], &src->cred_info[i]);    }    pj_strdup_with_null(pool, &dst->user_agent, &src->user_agent);}/** * This structure describes additional information to be sent with * outgoing SIP message. It can (optionally) be specified for example * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(), * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more. * * Application MUST call #pjsua_msg_data_init() to initialize this * structure before setting its values. * * \par Python Syntax * The data type in Python is <tt>py_pjsua.Msg_Data</tt>. Application is * recommended to instantiate the structure by using this construct: * \code    msg_data = py_pjsua.msg_data_init() * \endcode */typedef struct pjsua_msg_data{    /**     * Additional message headers as linked list.     *     * \par Python:     * This field is implemented as string linked-list in Python, where each     * string describes the header. For example:     \code	msg_data = py_pjsua.Msg_Data()	msg_data.hdr_list = ["Subject: Hello py_pjsua!", "Priority: very low"]     \endcode     */    pjsip_hdr	hdr_list;    /**     * MIME type of optional message body.      */    pj_str_t	content_type;    /**     * Optional message body.     */    pj_str_t	msg_body;} pjsua_msg_data;/** * Initialize message data. * * @param msg_data  Message data to be initialized. * * \par Python * The corresponding Python function creates and initializes the structure: * \code    msg_data = py_pjsua.msg_data_init() * \endcode */PJ_INLINE(void) pjsua_msg_data_init(pjsua_msg_data *msg_data){    pj_bzero(msg_data, sizeof(*msg_data));    pj_list_init(&msg_data->hdr_list);}/** * Instantiate pjsua application. Application must call this function before * calling any other functions, to make sure that the underlying libraries * are properly initialized. Once this function has returned success, * application must call pjsua_destroy() before quitting. * * @return		PJ_SUCCESS on success, or the appropriate error code. * * \par Python: * \code    status = py_pjsua.create() * \endcode */PJ_DECL(pj_status_t) pjsua_create(void);/* Forward declaration */typedef struct pjsua_media_config pjsua_media_config;/** * Initialize pjsua with the specified settings. All the settings are  * optional, and the default values will be used when the config is not * specified. * * Note that #pjsua_create() MUST be called before calling this function. * * @param ua_cfg	User agent configuration. * @param log_cfg	Optional logging configuration. * @param media_cfg	Optional media configuration. * * @return		PJ_SUCCESS on success, or the appropriate error code. * * \par Python: * The function is similar in Python: * \code    status = py_pjsua.init(ua_cfg, log_cfg, media_cfg) * \endcode * Note that \a ua_cfg, \a log_cfg, and \a media_cfg are optional, and * the Python script may pass None if it doesn't want to configure the  * setting. */PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,				const pjsua_logging_config *log_cfg,				const pjsua_media_config *media_cfg);/** * Application is recommended to call this function after all initialization * is done, so that the library can do additional checking set up * additional  * * Application may call this function anytime after #pjsua_init(). * * @return		PJ_SUCCESS on success, or the appropriate error code. * * \par Python: * The function is similar in Python: * \code    status = py_pjsua.start() * \endcode */PJ_DECL(pj_status_t) pjsua_start(void);/** * Destroy pjsua. Application is recommended to perform graceful shutdown * before calling this function (such as unregister the account from the SIP  * server, terminate presense subscription, and hangup active calls), however, * this function will do all of these if it finds there are active sessions * that need to be terminated. This function will approximately block for * one second to wait for replies from remote. * * Application.may safely call this function more than once if it doesn't * keep track of it's state. * * @return		PJ_SUCCESS on success, or the appropriate error code. * * \par Python: * The function is similar in Python: * \code    status = py_pjsua.destroy() * \endcode */PJ_DECL(pj_status_t) pjsua_destroy(void);/** * Poll pjsua for events, and if necessary block the caller thread for * the specified maximum interval (in miliseconds). * * Application doesn't normally need to call this function if it has * configured worker thread (\a thread_cnt field) in pjsua_config structure, * because polling then will be done by these worker threads instead. * * @param msec_timeout	Maximum time to wait, in miliseconds. * * @return  The number of events that have been handled during the *	    poll. Negative value indicates error, and application *	    can retrieve the error as (status = -return_value). * * \par Python: * The function is similar in Python: * \code    n = py_pjsua.handle_events(msec_timeout) * \endcode */PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);/** * Create memory pool to be used by the application. Once application * finished using the pool, it must be released with pj_pool_release(). * * @param name		Optional pool name. * @param init_size	Initial size of the pool. * @param increment	Increment size. * * @return		The pool, or NULL when there's no memory. * * \par Python: * Python script may also create a pool object from the script: * \code    pool = py_pjsua.pool_create(name, init_size, increment) * \endcode */PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,				      pj_size_t increment);/** * Application can call this function at any time (after pjsua_create(), of * course) to change logging settings. * * @param c		Logging configuration. * * @return		PJ_SUCCESS on success, or the appropriate error code. * * \par Python: * The function is similar in Python: * \code    status = py_pjsua.reconfigure_logging(log_cfg) * \endcode */PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);/** * Internal function to get SIP endpoint instance of pjsua, which is * needed for example to register module, create transports, etc. * Only valid after #pjsua_init() is called. *  * @return		SIP endpoint instance. * * \par Python: * Application may retrieve the SIP endpoint instance: * \code    endpt = py_pjsua.get_pjsip_endpt() * \endcode * However currently the object is just an opaque object and does not have * any use for Python scripts. */PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);/** * Internal function to get media endpoint instance. * Only valid after #pjsua_init() is called. * * @return		Media endpoint instance. * * \par Python: * Application may retrieve the media endpoint instance: * \code    endpt = py_pjsua.get_pjmedia_endpt() * \endcode * However currently the object is just an opaque object and does not have * any use for Python scripts. */PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);/** * Internal function to get PJSUA pool factory. * Only valid after #pjsua_create() is called. * * @return		Pool factory currently used by PJSUA. * * \par Python: * Application may retrieve the pool factory instance: * \code    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);/** * @} *//***************************************************************************** * 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;/** * This structure describes STUN configuration for SIP and media transport, * and is embedded inside pjsua_transport_config structure. */typedef struct pjsua_stun_config{    /**     * The first STUN server IP address or hostname.     */    pj_str_t	stun_srv1;    /**     * Port number of the first STUN server.     * If zero, default STUN port will be used.     */    unsigned	stun_port1;        /**     * Optional second STUN server IP address or hostname, for which the     * result of the mapping request will be compared to. If the value     * is empty, only one STUN server will be used.     */    pj_str_t	stun_srv2;    /**     * Port number of the second STUN server.     * If zero, default STUN port will be used.     */    unsigned	stun_port2;} pjsua_stun_config;/** * Call this function to initialize STUN config with default values. * STUN config is normally embedded inside pjsua_transport_config, so * normally there is no need to call this function and rather just * call pjsua_transport_config_default() instead. * * @param cfg	    The STUN config to be initialized. *

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -