Alexandre Lision | 8af73cb | 2013-12-10 14:11:20 -0500 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
| 3 | * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) |
| 4 | * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | #ifndef __PJSIP_SIP_UA_LAYER_H__ |
| 21 | #define __PJSIP_SIP_UA_LAYER_H__ |
| 22 | |
| 23 | /** |
| 24 | * @file sip_ua_layer.h |
| 25 | * @brief SIP User Agent Layer Module |
| 26 | */ |
| 27 | #include <pjsip/sip_types.h> |
| 28 | |
| 29 | |
| 30 | PJ_BEGIN_DECL |
| 31 | |
| 32 | /** |
| 33 | * @defgroup PJSIP_UA Base User Agent Layer/Common Dialog Layer |
| 34 | * @brief Dialog management. |
| 35 | * |
| 36 | * This module provides basic dialog management, which is used by higher |
| 37 | * layer dialog usages such as INVITE sessions and SIP Event Subscription |
| 38 | * framework (RFC 3265). Application should link with <b>pjsip-core</b> |
| 39 | * library to use this base UA layer. The base UA layer module is initialized |
| 40 | * with #pjsip_ua_init_module(). |
| 41 | */ |
| 42 | |
| 43 | /** |
| 44 | * @defgroup PJSUA_UA SIP User Agent Module |
| 45 | * @ingroup PJSIP_UA |
| 46 | * @brief Provides dialog management. |
| 47 | * @{ |
| 48 | * |
| 49 | * Application MUST initialize the user agent layer module by calling |
| 50 | * #pjsip_ua_init_module() before using any of the dialog API, and link |
| 51 | * the application with with <b>pjsip-core</b> library. |
| 52 | */ |
| 53 | |
| 54 | /** User agent initialization parameter. */ |
| 55 | typedef struct pjsip_ua_init_param |
| 56 | { |
| 57 | /** Callback to be called when the UA layer detects that outgoing |
| 58 | * dialog has forked. |
| 59 | */ |
| 60 | pjsip_dialog* (*on_dlg_forked)(pjsip_dialog *first_set, pjsip_rx_data *res); |
| 61 | } pjsip_ua_init_param; |
| 62 | |
| 63 | /** |
| 64 | * Initialize user agent layer and register it to the specified endpoint. |
| 65 | * |
| 66 | * @param endpt The endpoint where the user agent will be |
| 67 | * registered. |
| 68 | * @param prm UA initialization parameter. |
| 69 | * |
| 70 | * @return PJ_SUCCESS on success. |
| 71 | */ |
| 72 | PJ_DECL(pj_status_t) pjsip_ua_init_module(pjsip_endpoint *endpt, |
| 73 | const pjsip_ua_init_param *prm); |
| 74 | |
| 75 | /** |
| 76 | * Get the instance of the user agent. |
| 77 | * |
| 78 | * @return The user agent module instance. |
| 79 | */ |
| 80 | PJ_DECL(pjsip_user_agent*) pjsip_ua_instance(void); |
| 81 | |
| 82 | |
| 83 | /** |
| 84 | * Retrieve the current number of dialog-set currently registered |
| 85 | * in the hash table. Note that dialog-set is different than dialog |
| 86 | * when the request forks. In this case, all dialogs created from |
| 87 | * the original request will belong to the same dialog set. When |
| 88 | * no forking occurs, the number of dialog sets will be equal to |
| 89 | * the number of dialogs. |
| 90 | * |
| 91 | * @return Number of dialog sets. |
| 92 | */ |
| 93 | PJ_DECL(pj_uint32_t) pjsip_ua_get_dlg_set_count(void); |
| 94 | |
| 95 | |
| 96 | /** |
| 97 | * Find a dialog with the specified Call-ID and tags properties. This |
| 98 | * function may optionally lock the matching dialog instance before |
| 99 | * returning it back to the caller. |
| 100 | * |
| 101 | * @param call_id The call ID to be matched. |
| 102 | * @param local_tag The local tag to be matched. |
| 103 | * @param remote_tag The remote tag to be matched. |
| 104 | * @param lock_dialog If non-zero, instruct the function to lock the |
| 105 | * matching dialog with #pjsip_dlg_inc_lock(). |
| 106 | * Application is responsible to release the dialog's |
| 107 | * lock after it has finished manipulating the dialog, |
| 108 | * by calling #pjsip_dlg_dec_lock(). |
| 109 | * |
| 110 | * @return The matching dialog instance, or NULL if no matching |
| 111 | * dialog is found. |
| 112 | */ |
| 113 | PJ_DECL(pjsip_dialog*) pjsip_ua_find_dialog(const pj_str_t *call_id, |
| 114 | const pj_str_t *local_tag, |
| 115 | const pj_str_t *remote_tag, |
| 116 | pj_bool_t lock_dialog); |
| 117 | |
| 118 | /** |
| 119 | * Destroy the user agent layer. |
| 120 | * |
| 121 | * @return PJ_SUCCESS on success. |
| 122 | */ |
| 123 | PJ_DECL(pj_status_t) pjsip_ua_destroy(void); |
| 124 | |
| 125 | /** |
| 126 | * Dump user agent contents (e.g. all dialogs). |
| 127 | * |
| 128 | * @param detail If non-zero, list of dialogs will be printed. |
| 129 | */ |
| 130 | PJ_DECL(void) pjsip_ua_dump(pj_bool_t detail); |
| 131 | |
| 132 | /** |
| 133 | * Get the endpoint instance of a user agent module. |
| 134 | * |
| 135 | * @param ua The user agent instance. |
| 136 | * |
| 137 | * @return The endpoint instance where the user agent is |
| 138 | * registered. |
| 139 | */ |
| 140 | PJ_DECL(pjsip_endpoint*) pjsip_ua_get_endpt(pjsip_user_agent *ua); |
| 141 | |
| 142 | |
| 143 | /** |
| 144 | * @} |
| 145 | */ |
| 146 | |
| 147 | |
| 148 | /* |
| 149 | * Internal (called by sip_dialog.c). |
| 150 | */ |
| 151 | |
| 152 | PJ_DECL(pj_status_t) pjsip_ua_register_dlg( pjsip_user_agent *ua, |
| 153 | pjsip_dialog *dlg ); |
| 154 | PJ_DECL(pj_status_t) pjsip_ua_unregister_dlg(pjsip_user_agent *ua, |
| 155 | pjsip_dialog *dlg ); |
| 156 | |
| 157 | |
| 158 | PJ_END_DECL |
| 159 | |
| 160 | |
| 161 | #endif /* __PJSIP_SIP_UA_LAYER_H__ */ |
| 162 | |