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

📄 sip_endpoint.h

📁 基于sip协议的网络电话源码
💻 H
📖 第 1 页 / 共 2 页
字号:
/* $Id: sip_endpoint.h 974 2007-02-19 01:13:53Z bennylp $ *//*  * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  */#ifndef __PJSIP_SIP_ENDPOINT_H__#define __PJSIP_SIP_ENDPOINT_H__/** * @file sip_endpoint.h * @brief SIP Endpoint. */#include <pjsip/sip_transport.h>#include <pjsip/sip_resolve.h>/** * @defgroup PJSIP_CORE_CORE At the Very Core * @ingroup PJSIP_CORE * @brief The very core of PJSIP. */PJ_BEGIN_DECL/** * @defgroup PJSIP_ENDPT Endpoint * @ingroup PJSIP_CORE_CORE * @brief The master, owner of all objects * * SIP Endpoint instance (pjsip_endpoint) can be viewed as the master/owner of * all SIP objects in an application. It performs the following roles: *  - it manages the allocation/deallocation of memory pools for all objects. *  - it manages listeners and transports, and how they are used by  *    transactions. *  - it receives incoming messages from transport layer and automatically *    dispatches them to the correct transaction (or create a new one). *  - it has a single instance of timer management (timer heap). *  - it manages modules, which is the primary means of extending the library. *  - it provides single polling function for all objects and distributes  *    events. *  - it automatically handles incoming requests which can not be handled by *    existing modules (such as when incoming request has unsupported method). *  - and so on.. * * Theoritically application can have multiple instances of SIP endpoint,  * although it's not clear why application may want to do it. * * @{ *//** * Create an instance of SIP endpoint from the specified pool factory. * The pool factory reference then will be kept by the endpoint, so that  * future memory allocations by SIP components will be taken from the same * pool factory. * * @param pf	        Pool factory that will be used for the lifetime of  *                      endpoint. * @param name          Optional name to be specified for the endpoint. *                      If this parameter is NULL, then the name will use *                      local host name. * @param endpt         Pointer to receive endpoint instance. * * @return              PJ_SUCCESS on success. */PJ_DECL(pj_status_t) pjsip_endpt_create(pj_pool_factory *pf,					const char *name,                                        pjsip_endpoint **endpt);/** * Destroy endpoint instance. Application must make sure that all pending * transactions have been terminated properly, because this function does not * check for the presence of pending transactions. * * @param endpt		The SIP endpoint to be destroyed. */PJ_DECL(void) pjsip_endpt_destroy(pjsip_endpoint *endpt);/** * Get endpoint name. * * @param endpt         The SIP endpoint instance. * * @return              Endpoint name, as was registered during endpoint *                      creation. The string is NULL terminated. */PJ_DECL(const pj_str_t*) pjsip_endpt_name(const pjsip_endpoint *endpt);/** * Poll for events. Application must call this function periodically to ensure * that all events from both transports and timer heap are handled in timely * manner.  This function, like all other endpoint functions, is thread safe,  * and application may have more than one thread concurrently calling this function. * * @param endpt		The endpoint. * @param max_timeout	Maximum time to wait for events, or NULL to wait forever *			until event is received. * * @return		PJ_SUCCESS on success. */PJ_DECL(pj_status_t) pjsip_endpt_handle_events( pjsip_endpoint *endpt, 					        const pj_time_val *max_timeout);/** * Handle events with additional info about number of events that * have been handled. * * @param endpt		The endpoint. * @param max_timeout	Maximum time to wait for events, or NULL to wait forever *			until event is received. * @param count		Optional argument to receive the number of events that *			have been handled by the function. * * @return		PJ_SUCCESS on success. */PJ_DECL(pj_status_t) pjsip_endpt_handle_events2(pjsip_endpoint *endpt,					        const pj_time_val *max_timeout,					        unsigned *count);/** * Schedule timer to endpoint's timer heap. Application must poll the endpoint * periodically (by calling #pjsip_endpt_handle_events) to ensure that the * timer events are handled in timely manner. When the timeout for the timer * has elapsed, the callback specified in the entry argument will be called. * This function, like all other endpoint functions, is thread safe. * * @param endpt	    The endpoint. * @param entry	    The timer entry. * @param delay	    The relative delay of the timer. * @return	    PJ_OK (zero) if successfull. */PJ_DECL(pj_status_t) pjsip_endpt_schedule_timer( pjsip_endpoint *endpt,						 pj_timer_entry *entry,						 const pj_time_val *delay );/** * Cancel the previously registered timer. * This function, like all other endpoint functions, is thread safe. * * @param endpt	    The endpoint. * @param entry	    The timer entry previously registered. */PJ_DECL(void) pjsip_endpt_cancel_timer( pjsip_endpoint *endpt, 					pj_timer_entry *entry );/** * Register new module to the endpoint. * The endpoint will then call the load and start function in the module to  * properly initialize the module, and assign a unique module ID for the  * module. * * @param endpt		The endpoint. * @param module	The module to be registered. * * @return		PJ_SUCCESS on success. */PJ_DECL(pj_status_t) pjsip_endpt_register_module( pjsip_endpoint *endpt,						  pjsip_module *module );/** * Unregister a module from the endpoint. * The endpoint will then call the stop and unload function in the module to  * properly shutdown the module. * * @param endpt		The endpoint. * @param module	The module to be registered. * * @return		PJ_SUCCESS on success. */PJ_DECL(pj_status_t) pjsip_endpt_unregister_module( pjsip_endpoint *endpt,						    pjsip_module *module );/** * Create pool from the endpoint. All SIP components should allocate their * memory pool by calling this function, to make sure that the pools are * allocated from the same pool factory. This function, like all other endpoint * functions, is thread safe. * * @param endpt		The SIP endpoint. * @param pool_name	Name to be assigned to the pool. * @param initial	The initial size of the pool. * @param increment	The resize size. * @return		Memory pool, or NULL on failure. * * @see pj_pool_create */PJ_DECL(pj_pool_t*) pjsip_endpt_create_pool( pjsip_endpoint *endpt,					     const char *pool_name,					     pj_size_t initial,					     pj_size_t increment );/** * Return back pool to endpoint to be released back to the pool factory. * This function, like all other endpoint functions, is thread safe. * * @param endpt	    The endpoint. * @param pool	    The pool to be destroyed. */PJ_DECL(void) pjsip_endpt_release_pool( pjsip_endpoint *endpt,					pj_pool_t *pool );/** * Create a new transaction. After creating the transaction, application MUST * initialize the transaction as either UAC or UAS (by calling * #pjsip_tsx_init_uac or #pjsip_tsx_init_uas), then must register the  * transaction to endpoint with #pjsip_endpt_register_tsx. * This function, like all other endpoint functions, is thread safe. * * @param endpt	    The SIP endpoint. * @param p_tsx	    Pointer to receive the transaction. * * @return	    PJ_SUCCESS or the appropriate error code. */PJ_DECL(pj_status_t) pjsip_endpt_create_tsx(pjsip_endpoint *endpt,					    pjsip_transaction **p_tsx);/** * Find transaction in endpoint's transaction table by the transaction's key. * This function normally is only used by modules. The key for a transaction * can be created by calling #pjsip_tsx_create_key. * * @param endpt	    The endpoint instance. * @param key	    Transaction key, as created with #pjsip_tsx_create_key. * * @return	    The transaction, or NULL if it's not found. */PJ_DECL(pjsip_transaction*) pjsip_endpt_find_tsx( pjsip_endpoint *endpt,					          const pj_str_t *key );/** * Register the transaction to the endpoint's transaction table. * This function should only be used internally by the stack. * * @param endpt	    The SIP endpoint. * @param tsx	    The transaction. */PJ_DECL(void) pjsip_endpt_register_tsx( pjsip_endpoint *endpt,					pjsip_transaction *tsx);/** * Forcefull destroy the transaction. This function should only be used * internally by the stack. * * @param endpt	    The endpoint. * @param tsx	    The transaction to destroy. */PJ_DECL(void) pjsip_endpt_destroy_tsx( pjsip_endpoint *endpt,				      pjsip_transaction *tsx);

⌨️ 快捷键说明

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