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

📄 sip_transport.h

📁 基于sip协议的网络电话源码
💻 H
📖 第 1 页 / 共 3 页
字号:
			    const pj_sockaddr_t *rem_addr,			    int addr_len,			    void *token,			    void (*callback)(pjsip_transport *transport,					     void *token, 					     pj_ssize_t sent_bytes));    /**     * Instruct the transport to initiate graceful shutdown procedure.     * After all objects release their reference to this transport,     * the transport will be deleted.     *     * Note that application MUST use #pjsip_transport_shutdown() instead.     *     * @param transport	    The transport.     *     * @return		    PJ_SUCCESS on success.     */    pj_status_t (*do_shutdown)(pjsip_transport *transport);    /**     * Forcefully destroy this transport regardless whether there are     * objects that currently use this transport. This function should only     * be called by transport manager or other internal objects (such as the     * transport itself) who know what they're doing. Application should use     * #pjsip_transport_shutdown() instead.     *     * @param transport	    The transport.     *     * @return		    PJ_SUCCESS on success.     */    pj_status_t (*destroy)(pjsip_transport *transport);    /*     * Application may extend this structure..     */};/** * Register a transport instance to the transport manager. This function * is normally called by the transport instance when it is created * by application. * * @param mgr		The transport manager. * @param tp		The new transport to be registered. * * @return		PJ_SUCCESS on success. */PJ_DECL(pj_status_t) pjsip_transport_register( pjsip_tpmgr *mgr,					       pjsip_transport *tp );/** * Start graceful shutdown procedure for this transport. After graceful * shutdown has been initiated, no new reference can be obtained for * the transport. However, existing objects that currently uses the * transport may still use this transport to send and receive packets. * * After all objects release their reference to this transport, * the transport will be destroyed immediately. * * @param tp		    The transport. * * @return		    PJ_SUCCESS on success. */PJ_DECL(pj_status_t) pjsip_transport_shutdown(pjsip_transport *tp);/** * Destroy a transport when there is no object currently uses the transport. * This function is normally called internally by transport manager or the * transport itself. Application should use #pjsip_transport_shutdown() * instead. * * @param tp		The transport instance. * * @return		PJ_SUCCESS on success or the appropriate error code. *			Some of possible errors are PJSIP_EBUSY if the  *			transport's reference counter is not zero. */PJ_DECL(pj_status_t) pjsip_transport_destroy( pjsip_transport *tp);/** * Add reference counter to the specified transport. Any objects that wishes * to keep the reference of the transport MUST increment the transport's * reference counter to prevent it from being destroyed. * * @param tp		The transport instance. * * @return		PJ_SUCCESS on success or the appropriate error code. */PJ_DECL(pj_status_t) pjsip_transport_add_ref( pjsip_transport *tp );/** * Decrement reference counter of the specified transport. When an object no * longer want to keep the reference to the transport, it must decrement the * reference counter. When the reference counter of the transport reaches  * zero, the transport manager will start the idle timer to destroy the * transport if no objects acquire the reference counter during the idle * interval. * * @param tp		The transport instance. * * @return		PJ_SUCCESS on success. */PJ_DECL(pj_status_t) pjsip_transport_dec_ref( pjsip_transport *tp );/** * This function is called by transport instances to report an incoming  * packet to the transport manager. The transport manager then would try to * parse all SIP messages in the packet, and for each parsed SIP message, it * would report the message to the SIP endpoint (#pjsip_endpoint). * * @param mgr		The transport manager instance. * @param rdata		The receive data buffer containing the packet. The *			transport MUST fully initialize tp_info and pkt_info *			member of the rdata. * * @return		The number of bytes successfully processed from the *			packet. If the transport is datagram oriented, the *			value will be equal to the size of the packet. For *			stream oriented transport (e.g. TCP, TLS), the value *			returned may be less than the packet size, if  *			partial message is received. The transport then MUST *			keep the remainder part and report it again to *			this function once more data/packet is received. */PJ_DECL(pj_ssize_t) pjsip_tpmgr_receive_packet(pjsip_tpmgr *mgr,					       pjsip_rx_data *rdata);/***************************************************************************** * * TRANSPORT FACTORY * *****************************************************************************//** * A transport factory is normally used for connection oriented transports * (such as TCP or TLS) to create instances of transports. It registers * a new transport type to the transport manager, and the transport manager * would ask the factory to create a transport instance when it received * command from application to send a SIP message using the specified * transport type. */struct pjsip_tpfactory{    /** This list is managed by transport manager. */    PJ_DECL_LIST_MEMBER(struct pjsip_tpfactory);    char		    obj_name[PJ_MAX_OBJ_NAME];	/**< Name.	*/    pj_pool_t		   *pool;	    /**< Owned memory pool.	*/    pj_lock_t		   *lock;	    /**< Lock object.		*/    pjsip_transport_type_e  type;	    /**< Transport type.	*/    char		   *type_name;      /**< Type string name.	*/    unsigned		    flag;	    /**< Transport flag.	*/    pj_sockaddr		    local_addr;	    /**< Bound address.		*/    pjsip_host_port	    addr_name;	    /**< Published name.	*/    /**     * Create new outbound connection.     * Note that the factory is responsible for both creating the     * transport and registering it to the transport manager.     */    pj_status_t (*create_transport)(pjsip_tpfactory *factory,				    pjsip_tpmgr *mgr,				    pjsip_endpoint *endpt,				    const pj_sockaddr *rem_addr,				    int addr_len,				    pjsip_transport **transport);    /**     * Destroy the listener.     */    pj_status_t (*destroy)(pjsip_tpfactory *factory);    /*     * Application may extend this structure..     */};/** * Register a transport factory. * * @param mgr		The transport manager. * @param tpf		Transport factory. * * @return		PJ_SUCCESS if listener was successfully created. */PJ_DECL(pj_status_t) pjsip_tpmgr_register_tpfactory(pjsip_tpmgr *mgr,						    pjsip_tpfactory *tpf);/** * Unregister factory. * * @param mgr		The transport manager. * @param tpf		Transport factory. * * @return		PJ_SUCCESS is sucessfully unregistered. */PJ_DECL(pj_status_t) pjsip_tpmgr_unregister_tpfactory(pjsip_tpmgr *mgr,						      pjsip_tpfactory *tpf);/***************************************************************************** * * TRANSPORT MANAGER * *****************************************************************************//** * Create a new transport manager. * * @param pool	    Pool. * @param endpt	    Endpoint instance. * @param rx_cb	    Callback to receive incoming message. * @param tx_cb	    Callback to be called before transport manager is sending *		    outgoing message. * @param p_mgr	    Pointer to receive the new transport manager. * * @return	    PJ_SUCCESS or the appropriate error code on error. */PJ_DECL(pj_status_t) pjsip_tpmgr_create( pj_pool_t *pool,					 pjsip_endpoint * endpt,					 void (*rx_cb)(pjsip_endpoint*,						       pj_status_t,						       pjsip_rx_data *),					 pj_status_t (*tx_cb)(pjsip_endpoint*,							      pjsip_tx_data*),					 pjsip_tpmgr **p_mgr);/** * Find out the appropriate local address info (IP address and port) to * advertise in Contact header based on the remote address to be  * contacted. The local address info would be the address name of the * transport or listener which will be used to send the request. * * In this implementation, it will only select the transport based on * the transport type in the request. * * @param tpmgr	    The transport manager. * @param pool	    Pool to allocate memory for the IP address. * @param type	    Destination address to contact. * @param sel	    Optional pointer to prefered transport, if any. * @param ip_addr   Pointer to receive the IP address. * @param port	    Pointer to receive the port number. * * @return	    PJ_SUCCESS, or the appropriate error code. */PJ_DECL(pj_status_t) pjsip_tpmgr_find_local_addr( pjsip_tpmgr *tpmgr,						  pj_pool_t *pool,						  pjsip_transport_type_e type,						  const pjsip_tpselector *sel,						  pj_str_t *ip_addr,						  int *port);/** * Destroy transport manager. */PJ_DECL(pj_status_t) pjsip_tpmgr_destroy(pjsip_tpmgr *mgr);/** * Dump transport info. */PJ_DECL(void) pjsip_tpmgr_dump_transports(pjsip_tpmgr *mgr);/***************************************************************************** * * PUBLIC API * *****************************************************************************//** * Find transport to be used to send message to remote destination. If no * suitable transport is found, a new one will be created. * * This is an internal function since normally application doesn't have access * to transport manager. Application should use pjsip_endpt_acquire_transport() * instead. * * @param mgr	    The transport manager instance. * @param type	    The type of transport to be acquired. * @param remote    The remote address to send message to. * @param addr_len  Length of the remote address. * @param sel	    Optional pointer to transport selector instance which is *		    used to find explicit transport, if required. * @param tp	    Pointer to receive the transport instance, if one is found. * * @return	    PJ_SUCCESS on success, or the appropriate error code. */PJ_DECL(pj_status_t) pjsip_tpmgr_acquire_transport(pjsip_tpmgr *mgr,						   pjsip_transport_type_e type,						   const pj_sockaddr_t *remote,						   int addr_len,						   const pjsip_tpselector *sel,						   pjsip_transport **tp);/** * Send a SIP message using the specified transport. */PJ_DECL(pj_status_t) pjsip_transport_send( pjsip_transport *tr, 					   pjsip_tx_data *tdata,					   const pj_sockaddr_t *addr,					   int addr_len,					   void *token,					   void (*cb)(void *token, 						      pjsip_tx_data *tdata,						      pj_ssize_t bytes_sent));/** * @} */PJ_END_DECL#endif	/* __PJSIP_SIP_TRANSPORT_H__ */

⌨️ 快捷键说明

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