Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
Benny Prijono | 844653c | 2008-12-23 17:27:53 +0000 | [diff] [blame] | 3 | * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) |
Benny Prijono | 32177c0 | 2008-06-20 22:44:47 +0000 | [diff] [blame] | 4 | * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 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 __PJSUA_H__ |
| 21 | #define __PJSUA_H__ |
| 22 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 23 | /** |
| 24 | * @file pjsua.h |
| 25 | * @brief PJSUA API. |
| 26 | */ |
| 27 | |
| 28 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 29 | /* Include all PJSIP core headers. */ |
| 30 | #include <pjsip.h> |
| 31 | |
| 32 | /* Include all PJMEDIA headers. */ |
| 33 | #include <pjmedia.h> |
| 34 | |
Benny Prijono | 1f9afba | 2006-02-10 15:57:32 +0000 | [diff] [blame] | 35 | /* Include all PJMEDIA-CODEC headers. */ |
| 36 | #include <pjmedia-codec.h> |
| 37 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 38 | /* Include all PJSIP-UA headers */ |
| 39 | #include <pjsip_ua.h> |
| 40 | |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 41 | /* Include all PJSIP-SIMPLE headers */ |
| 42 | #include <pjsip_simple.h> |
| 43 | |
Benny Prijono | 4ab9fbb | 2007-10-12 12:14:27 +0000 | [diff] [blame] | 44 | /* Include all PJNATH headers */ |
| 45 | #include <pjnath.h> |
| 46 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 47 | /* Include all PJLIB-UTIL headers. */ |
| 48 | #include <pjlib-util.h> |
| 49 | |
| 50 | /* Include all PJLIB headers. */ |
| 51 | #include <pjlib.h> |
| 52 | |
| 53 | |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 54 | PJ_BEGIN_DECL |
| 55 | |
| 56 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 57 | /** |
Benny Prijono | 58163a2 | 2009-06-03 08:40:24 +0000 | [diff] [blame] | 58 | * @defgroup PJSUA_LIB PJSUA API - High Level Softphone API |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 59 | * @brief Very high level API for constructing SIP UA applications. |
| 60 | * @{ |
| 61 | * |
Benny Prijono | 58163a2 | 2009-06-03 08:40:24 +0000 | [diff] [blame] | 62 | * @section pjsua_api_intro A SIP User Agent API for C/C++ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 63 | * |
Benny Prijono | 58163a2 | 2009-06-03 08:40:24 +0000 | [diff] [blame] | 64 | * PJSUA API is very high level API for constructing SIP multimedia user agent |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 65 | * applications. It wraps together the signaling and media functionalities |
| 66 | * into an easy to use call API, provides account management, buddy |
| 67 | * management, presence, instant messaging, along with multimedia |
| 68 | * features such as conferencing, file streaming, local playback, |
| 69 | * voice recording, and so on. |
| 70 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 71 | * @subsection pjsua_for_c_cpp C/C++ Binding |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 72 | * Application must link with <b>pjsua-lib</b> to use this API. In addition, |
| 73 | * this library depends on the following libraries: |
| 74 | * - <b>pjsip-ua</b>, |
| 75 | * - <b>pjsip-simple</b>, |
| 76 | * - <b>pjsip-core</b>, |
| 77 | * - <b>pjmedia</b>, |
| 78 | * - <b>pjmedia-codec</b>, |
| 79 | * - <b>pjlib-util</b>, and |
| 80 | * - <b>pjlib</b>, |
| 81 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 82 | * so application must also link with these libraries as well. For more |
| 83 | * information, please refer to |
| 84 | * <A HREF="http://www.pjsip.org/using.htm">Getting Started with PJSIP</A> |
| 85 | * page. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 86 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 87 | * @section pjsua_samples |
| 88 | * |
Benny Prijono | 58163a2 | 2009-06-03 08:40:24 +0000 | [diff] [blame] | 89 | * Few samples are provided: |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 90 | * |
| 91 | - @ref page_pjsip_sample_simple_pjsuaua_c\n |
| 92 | Very simple SIP User Agent with registration, call, and media, using |
| 93 | PJSUA-API, all in under 200 lines of code. |
| 94 | |
| 95 | - @ref page_pjsip_samples_pjsua\n |
| 96 | This is the reference implementation for PJSIP and PJMEDIA. |
| 97 | PJSUA is a console based application, designed to be simple enough |
| 98 | to be readble, but powerful enough to demonstrate all features |
| 99 | available in PJSIP and PJMEDIA.\n |
| 100 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 101 | * @section root_using_pjsua_lib Using PJSUA API |
| 102 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 103 | * Please refer to @ref PJSUA_LIB_BASE on how to create and initialize the API. |
| 104 | * And then see the Modules on the bottom of this page for more information |
| 105 | * about specific subject. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 106 | */ |
| 107 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 108 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 109 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 110 | /***************************************************************************** |
| 111 | * BASE API |
| 112 | */ |
| 113 | |
Benny Prijono | f04ffdd | 2006-02-21 00:11:18 +0000 | [diff] [blame] | 114 | /** |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 115 | * @defgroup PJSUA_LIB_BASE PJSUA-API Basic API |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 116 | * @ingroup PJSUA_LIB |
| 117 | * @brief Basic application creation/initialization, logging configuration, etc. |
| 118 | * @{ |
| 119 | * |
| 120 | * The base PJSUA API controls PJSUA creation, initialization, and startup, and |
| 121 | * also provides various auxiliary functions. |
| 122 | * |
| 123 | * @section using_pjsua_lib Using PJSUA Library |
| 124 | * |
| 125 | * @subsection creating_pjsua_lib Creating PJSUA |
| 126 | * |
Benny Prijono | 58163a2 | 2009-06-03 08:40:24 +0000 | [diff] [blame] | 127 | * Before anything else, application must create PJSUA by calling |
| 128 | * #pjsua_create(). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 129 | * This, among other things, will initialize PJLIB, which is crucial before |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 130 | * any PJLIB functions can be called, PJLIB-UTIL, and create a SIP endpoint. |
| 131 | * |
| 132 | * After this function is called, application can create a memory pool (with |
| 133 | * #pjsua_pool_create()) and read configurations from command line or file to |
| 134 | * build the settings to initialize PJSUA below. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 135 | * |
| 136 | * @subsection init_pjsua_lib Initializing PJSUA |
| 137 | * |
| 138 | * After PJSUA is created, application can initialize PJSUA by calling |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 139 | * #pjsua_init(). This function takes several optional configuration settings |
| 140 | * in the argument, if application wants to set them. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 141 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 142 | * @subsubsection init_pjsua_lib_c_cpp PJSUA-LIB Initialization (in C) |
| 143 | * Sample code to initialize PJSUA in C code: |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 144 | \code |
| 145 | |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 146 | #include <pjsua-lib/pjsua.h> |
| 147 | |
| 148 | #define THIS_FILE __FILE__ |
| 149 | |
| 150 | static pj_status_t app_init(void) |
| 151 | { |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 152 | pjsua_config ua_cfg; |
| 153 | pjsua_logging_config log_cfg; |
| 154 | pjsua_media_config media_cfg; |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 155 | pj_status_t status; |
| 156 | |
| 157 | // Must create pjsua before anything else! |
| 158 | status = pjsua_create(); |
| 159 | if (status != PJ_SUCCESS) { |
| 160 | pjsua_perror(THIS_FILE, "Error initializing pjsua", status); |
| 161 | return status; |
| 162 | } |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 163 | |
| 164 | // Initialize configs with default settings. |
| 165 | pjsua_config_default(&ua_cfg); |
| 166 | pjsua_logging_config_default(&log_cfg); |
| 167 | pjsua_media_config_default(&media_cfg); |
| 168 | |
| 169 | // At the very least, application would want to override |
| 170 | // the call callbacks in pjsua_config: |
| 171 | ua_cfg.cb.on_incoming_call = ... |
| 172 | ua_cfg.cb.on_call_state = .. |
| 173 | ... |
| 174 | |
| 175 | // Customize other settings (or initialize them from application specific |
| 176 | // configuration file): |
| 177 | ... |
| 178 | |
| 179 | // Initialize pjsua |
| 180 | status = pjsua_init(&ua_cfg, &log_cfg, &media_cfg); |
| 181 | if (status != PJ_SUCCESS) { |
| 182 | pjsua_perror(THIS_FILE, "Error initializing pjsua", status); |
| 183 | return status; |
| 184 | } |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 185 | . |
| 186 | ... |
| 187 | } |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 188 | \endcode |
| 189 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 190 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 191 | |
| 192 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 193 | * @subsection other_init_pjsua_lib Other Initialization |
| 194 | * |
| 195 | * After PJSUA is initialized with #pjsua_init(), application will normally |
| 196 | * need/want to perform the following tasks: |
| 197 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 198 | * - create SIP transport with #pjsua_transport_create(). Application would |
| 199 | * to call #pjsua_transport_create() for each transport types that it |
| 200 | * wants to support (for example, UDP, TCP, and TLS). Please see |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 201 | * @ref PJSUA_LIB_TRANSPORT section for more info. |
| 202 | * - create one or more SIP accounts with #pjsua_acc_add() or |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 203 | * #pjsua_acc_add_local(). The SIP account is used for registering with |
| 204 | * the SIP server, if any. Please see @ref PJSUA_LIB_ACC for more info. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 205 | * - add one or more buddies with #pjsua_buddy_add(). Please see |
| 206 | * @ref PJSUA_LIB_BUDDY section for more info. |
| 207 | * - optionally configure the sound device, codec settings, and other |
| 208 | * media settings. Please see @ref PJSUA_LIB_MEDIA for more info. |
| 209 | * |
| 210 | * |
| 211 | * @subsection starting_pjsua_lib Starting PJSUA |
| 212 | * |
| 213 | * After all initializations have been done, application must call |
| 214 | * #pjsua_start() to start PJSUA. This function will check that all settings |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 215 | * have been properly configured, and apply default settings when they haven't, |
| 216 | * or report error status when it is unable to recover from missing settings. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 217 | * |
| 218 | * Most settings can be changed during run-time. For example, application |
| 219 | * may add, modify, or delete accounts, buddies, or change media settings |
| 220 | * during run-time. |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 221 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 222 | * @subsubsection starting_pjsua_lib_c C Example for Starting PJSUA |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 223 | * Sample code: |
| 224 | \code |
| 225 | static pj_status_t app_run(void) |
| 226 | { |
| 227 | pj_status_t status; |
| 228 | |
| 229 | // Start pjsua |
| 230 | status = pjsua_start(); |
| 231 | if (status != PJ_SUCCESS) { |
| 232 | pjsua_destroy(); |
| 233 | pjsua_perror(THIS_FILE, "Error starting pjsua", status); |
| 234 | return status; |
| 235 | } |
| 236 | |
| 237 | // Run application loop |
| 238 | while (1) { |
| 239 | char choice[10]; |
| 240 | |
| 241 | printf("Select menu: "); |
| 242 | fgets(choice, sizeof(choice), stdin); |
| 243 | ... |
| 244 | } |
| 245 | } |
| 246 | \endcode |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 247 | |
Benny Prijono | f04ffdd | 2006-02-21 00:11:18 +0000 | [diff] [blame] | 248 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 249 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 250 | /** Constant to identify invalid ID for all sorts of IDs. */ |
| 251 | #define PJSUA_INVALID_ID (-1) |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 252 | |
| 253 | /** Call identification */ |
| 254 | typedef int pjsua_call_id; |
| 255 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 256 | /** Account identification */ |
| 257 | typedef int pjsua_acc_id; |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 258 | |
| 259 | /** Buddy identification */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 260 | typedef int pjsua_buddy_id; |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 261 | |
| 262 | /** File player identification */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 263 | typedef int pjsua_player_id; |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 264 | |
| 265 | /** File recorder identification */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 266 | typedef int pjsua_recorder_id; |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 267 | |
| 268 | /** Conference port identification */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 269 | typedef int pjsua_conf_port_id; |
| 270 | |
Benny Prijono | 63fba01 | 2008-07-17 14:19:10 +0000 | [diff] [blame] | 271 | /** Opaque declaration for server side presence subscription */ |
| 272 | typedef struct pjsua_srv_pres pjsua_srv_pres; |
| 273 | |
| 274 | /** Forward declaration for pjsua_msg_data */ |
| 275 | typedef struct pjsua_msg_data pjsua_msg_data; |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 276 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 277 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 278 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 279 | * Maximum proxies in account. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 280 | */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 281 | #ifndef PJSUA_ACC_MAX_PROXIES |
| 282 | # define PJSUA_ACC_MAX_PROXIES 8 |
| 283 | #endif |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 284 | |
Benny Prijono | d817965 | 2008-01-23 20:39:07 +0000 | [diff] [blame] | 285 | #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 286 | |
Benny Prijono | d817965 | 2008-01-23 20:39:07 +0000 | [diff] [blame] | 287 | /** |
| 288 | * Default value of SRTP mode usage. Valid values are PJMEDIA_SRTP_DISABLED, |
| 289 | * PJMEDIA_SRTP_OPTIONAL, and PJMEDIA_SRTP_MANDATORY. |
| 290 | */ |
| 291 | #ifndef PJSUA_DEFAULT_USE_SRTP |
| 292 | #define PJSUA_DEFAULT_USE_SRTP PJMEDIA_SRTP_DISABLED |
| 293 | #endif |
| 294 | |
| 295 | /** |
| 296 | * Default value of secure signaling requirement for SRTP. |
| 297 | * Valid values are: |
| 298 | * 0: SRTP does not require secure signaling |
| 299 | * 1: SRTP requires secure transport such as TLS |
| 300 | * 2: SRTP requires secure end-to-end transport (SIPS) |
| 301 | */ |
| 302 | #ifndef PJSUA_DEFAULT_SRTP_SECURE_SIGNALING |
| 303 | #define PJSUA_DEFAULT_SRTP_SECURE_SIGNALING 1 |
| 304 | #endif |
| 305 | |
| 306 | #endif |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 307 | |
| 308 | /** |
Benny Prijono | 07fe230 | 2010-06-24 12:33:18 +0000 | [diff] [blame] | 309 | * Controls whether PJSUA-LIB should add ICE media feature tag |
| 310 | * parameter (the ";+sip.ice" parameter) to Contact header if ICE |
| 311 | * is enabled in the config. |
| 312 | * |
| 313 | * Default: 1 |
| 314 | */ |
| 315 | #ifndef PJSUA_ADD_ICE_TAGS |
| 316 | # define PJSUA_ADD_ICE_TAGS 1 |
| 317 | #endif |
| 318 | |
Sauw Ming | 844c1c9 | 2010-09-07 05:12:02 +0000 | [diff] [blame] | 319 | /** |
| 320 | * Timeout value used to acquire mutex lock on a particular call. |
| 321 | * |
| 322 | * Default: 2000 ms |
| 323 | */ |
| 324 | #ifndef PJSUA_ACQUIRE_CALL_TIMEOUT |
| 325 | # define PJSUA_ACQUIRE_CALL_TIMEOUT 2000 |
| 326 | #endif |
| 327 | |
Benny Prijono | 07fe230 | 2010-06-24 12:33:18 +0000 | [diff] [blame] | 328 | |
| 329 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 330 | * Logging configuration, which can be (optionally) specified when calling |
| 331 | * #pjsua_init(). Application must call #pjsua_logging_config_default() to |
| 332 | * initialize this structure with the default values. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 333 | */ |
| 334 | typedef struct pjsua_logging_config |
| 335 | { |
| 336 | /** |
| 337 | * Log incoming and outgoing SIP message? Yes! |
| 338 | */ |
| 339 | pj_bool_t msg_logging; |
| 340 | |
| 341 | /** |
| 342 | * Input verbosity level. Value 5 is reasonable. |
| 343 | */ |
| 344 | unsigned level; |
| 345 | |
| 346 | /** |
| 347 | * Verbosity level for console. Value 4 is reasonable. |
| 348 | */ |
| 349 | unsigned console_level; |
| 350 | |
| 351 | /** |
| 352 | * Log decoration. |
| 353 | */ |
| 354 | unsigned decor; |
| 355 | |
| 356 | /** |
| 357 | * Optional log filename. |
| 358 | */ |
| 359 | pj_str_t log_filename; |
| 360 | |
| 361 | /** |
Benny Prijono | dbe3f4b | 2009-05-07 16:56:04 +0000 | [diff] [blame] | 362 | * Additional flags to be given to #pj_file_open() when opening |
| 363 | * the log file. By default, the flag is PJ_O_WRONLY. Application |
| 364 | * may set PJ_O_APPEND here so that logs are appended to existing |
| 365 | * file instead of overwriting it. |
| 366 | * |
| 367 | * Default is 0. |
| 368 | */ |
| 369 | unsigned log_file_flags; |
| 370 | |
| 371 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 372 | * Optional callback function to be called to write log to |
| 373 | * application specific device. This function will be called for |
| 374 | * log messages on input verbosity level. |
| 375 | */ |
Benny Prijono | fe7d87b | 2007-11-29 11:35:44 +0000 | [diff] [blame] | 376 | void (*cb)(int level, const char *data, int len); |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 377 | |
| 378 | |
| 379 | } pjsua_logging_config; |
| 380 | |
| 381 | |
| 382 | /** |
| 383 | * Use this function to initialize logging config. |
| 384 | * |
| 385 | * @param cfg The logging config to be initialized. |
| 386 | */ |
Benny Prijono | 1f61a8f | 2007-08-16 10:11:44 +0000 | [diff] [blame] | 387 | PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg); |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 388 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 389 | |
| 390 | /** |
| 391 | * Use this function to duplicate logging config. |
| 392 | * |
| 393 | * @param pool Pool to use. |
| 394 | * @param dst Destination config. |
| 395 | * @param src Source config. |
| 396 | */ |
Benny Prijono | 1f61a8f | 2007-08-16 10:11:44 +0000 | [diff] [blame] | 397 | PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool, |
| 398 | pjsua_logging_config *dst, |
| 399 | const pjsua_logging_config *src); |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 400 | |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 401 | |
| 402 | /** |
Benny Prijono | 4dd961b | 2009-10-26 11:21:37 +0000 | [diff] [blame] | 403 | * Structure to be passed on MWI callback. |
| 404 | */ |
| 405 | typedef struct pjsua_mwi_info |
| 406 | { |
| 407 | pjsip_evsub *evsub; /**< Event subscription session, for |
| 408 | reference. */ |
| 409 | pjsip_rx_data *rdata; /**< The received NOTIFY request. */ |
| 410 | } pjsua_mwi_info; |
| 411 | |
| 412 | |
| 413 | /** |
Nanang Izzuddin | 4ea1bcc | 2010-09-28 04:57:01 +0000 | [diff] [blame] | 414 | * Structure to be passed on registration callback. |
| 415 | */ |
| 416 | typedef struct pjsua_reg_info |
| 417 | { |
| 418 | struct pjsip_regc_cbparam *cbparam; /**< Parameters returned by |
| 419 | registration callback. */ |
| 420 | } pjsua_reg_info; |
| 421 | |
| 422 | |
| 423 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 424 | * This structure describes application callback to receive various event |
| 425 | * notification from PJSUA-API. All of these callbacks are OPTIONAL, |
| 426 | * although definitely application would want to implement some of |
| 427 | * the important callbacks (such as \a on_incoming_call). |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 428 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 429 | typedef struct pjsua_callback |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 430 | { |
| 431 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 432 | * Notify application when invite state has changed. |
| 433 | * Application may then query the call info to get the |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 434 | * detail call states by calling pjsua_call_get_info() function. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 435 | * |
| 436 | * @param call_id The call index. |
| 437 | * @param e Event which causes the call state to change. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 438 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 439 | void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e); |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 440 | |
| 441 | /** |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 442 | * Notify application on incoming call. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 443 | * |
| 444 | * @param acc_id The account which match the incoming call. |
| 445 | * @param call_id The call id that has just been created for |
| 446 | * the call. |
| 447 | * @param rdata The incoming INVITE request. |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 448 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 449 | void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id, |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 450 | pjsip_rx_data *rdata); |
| 451 | |
| 452 | /** |
Benny Prijono | feb69f4 | 2007-10-05 09:12:26 +0000 | [diff] [blame] | 453 | * This is a general notification callback which is called whenever |
| 454 | * a transaction within the call has changed state. Application can |
| 455 | * implement this callback for example to monitor the state of |
| 456 | * outgoing requests, or to answer unhandled incoming requests |
| 457 | * (such as INFO) with a final response. |
| 458 | * |
| 459 | * @param call_id Call identification. |
| 460 | * @param tsx The transaction which has changed state. |
| 461 | * @param e Transaction event that caused the state change. |
| 462 | */ |
| 463 | void (*on_call_tsx_state)(pjsua_call_id call_id, |
| 464 | pjsip_transaction *tsx, |
| 465 | pjsip_event *e); |
| 466 | |
| 467 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 468 | * Notify application when media state in the call has changed. |
| 469 | * Normal application would need to implement this callback, e.g. |
Benny Prijono | 6ba8c54 | 2007-10-16 01:34:14 +0000 | [diff] [blame] | 470 | * to connect the call's media to sound device. When ICE is used, |
| 471 | * this callback will also be called to report ICE negotiation |
| 472 | * failure. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 473 | * |
| 474 | * @param call_id The call index. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 475 | */ |
| 476 | void (*on_call_media_state)(pjsua_call_id call_id); |
| 477 | |
Benny Prijono | fc13bf6 | 2008-02-20 08:56:15 +0000 | [diff] [blame] | 478 | |
| 479 | /** |
| 480 | * Notify application when media session is created and before it is |
| 481 | * registered to the conference bridge. Application may return different |
| 482 | * media port if it has added media processing port to the stream. This |
| 483 | * media port then will be added to the conference bridge instead. |
| 484 | * |
| 485 | * @param call_id Call identification. |
| 486 | * @param sess Media session for the call. |
| 487 | * @param stream_idx Stream index in the media session. |
| 488 | * @param p_port On input, it specifies the media port of the |
| 489 | * stream. Application may modify this pointer to |
| 490 | * point to different media port to be registered |
| 491 | * to the conference bridge. |
Benny Prijono | fc13bf6 | 2008-02-20 08:56:15 +0000 | [diff] [blame] | 492 | */ |
| 493 | void (*on_stream_created)(pjsua_call_id call_id, |
| 494 | pjmedia_session *sess, |
| 495 | unsigned stream_idx, |
| 496 | pjmedia_port **p_port); |
| 497 | |
| 498 | /** |
| 499 | * Notify application when media session has been unregistered from the |
| 500 | * conference bridge and about to be destroyed. |
| 501 | * |
| 502 | * @param call_id Call identification. |
| 503 | * @param sess Media session for the call. |
| 504 | * @param stream_idx Stream index in the media session. |
Benny Prijono | fc13bf6 | 2008-02-20 08:56:15 +0000 | [diff] [blame] | 505 | */ |
| 506 | void (*on_stream_destroyed)(pjsua_call_id call_id, |
| 507 | pjmedia_session *sess, |
| 508 | unsigned stream_idx); |
| 509 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 510 | /** |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 511 | * Notify application upon incoming DTMF digits. |
| 512 | * |
| 513 | * @param call_id The call index. |
| 514 | * @param digit DTMF ASCII digit. |
| 515 | */ |
| 516 | void (*on_dtmf_digit)(pjsua_call_id call_id, int digit); |
| 517 | |
| 518 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 519 | * Notify application on call being transfered (i.e. REFER is received). |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 520 | * Application can decide to accept/reject transfer request |
Benny Prijono | c54dcb3 | 2008-04-08 23:33:15 +0000 | [diff] [blame] | 521 | * by setting the code (default is 202). When this callback |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 522 | * is not defined, the default behavior is to accept the |
| 523 | * transfer. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 524 | * |
| 525 | * @param call_id The call index. |
| 526 | * @param dst The destination where the call will be |
| 527 | * transfered to. |
| 528 | * @param code Status code to be returned for the call transfer |
| 529 | * request. On input, it contains status code 200. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 530 | */ |
Benny Prijono | 4ddad2c | 2006-10-18 17:16:34 +0000 | [diff] [blame] | 531 | void (*on_call_transfer_request)(pjsua_call_id call_id, |
| 532 | const pj_str_t *dst, |
| 533 | pjsip_status_code *code); |
| 534 | |
| 535 | /** |
| 536 | * Notify application of the status of previously sent call |
| 537 | * transfer request. Application can monitor the status of the |
| 538 | * call transfer request, for example to decide whether to |
| 539 | * terminate existing call. |
| 540 | * |
| 541 | * @param call_id Call ID. |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 542 | * @param st_code Status progress of the transfer request. |
| 543 | * @param st_text Status progress text. |
Benny Prijono | 4ddad2c | 2006-10-18 17:16:34 +0000 | [diff] [blame] | 544 | * @param final If non-zero, no further notification will |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 545 | * be reported. The st_code specified in |
Benny Prijono | 4ddad2c | 2006-10-18 17:16:34 +0000 | [diff] [blame] | 546 | * this callback is the final status. |
| 547 | * @param p_cont Initially will be set to non-zero, application |
| 548 | * can set this to FALSE if it no longer wants |
| 549 | * to receie further notification (for example, |
| 550 | * after it hangs up the call). |
| 551 | */ |
| 552 | void (*on_call_transfer_status)(pjsua_call_id call_id, |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 553 | int st_code, |
| 554 | const pj_str_t *st_text, |
Benny Prijono | 4ddad2c | 2006-10-18 17:16:34 +0000 | [diff] [blame] | 555 | pj_bool_t final, |
| 556 | pj_bool_t *p_cont); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 557 | |
| 558 | /** |
Benny Prijono | 053f522 | 2006-11-11 16:16:04 +0000 | [diff] [blame] | 559 | * Notify application about incoming INVITE with Replaces header. |
| 560 | * Application may reject the request by setting non-2xx code. |
| 561 | * |
| 562 | * @param call_id The call ID to be replaced. |
| 563 | * @param rdata The incoming INVITE request to replace the call. |
| 564 | * @param st_code Status code to be set by application. Application |
| 565 | * should only return a final status (200-699). |
| 566 | * @param st_text Optional status text to be set by application. |
| 567 | */ |
| 568 | void (*on_call_replace_request)(pjsua_call_id call_id, |
| 569 | pjsip_rx_data *rdata, |
| 570 | int *st_code, |
| 571 | pj_str_t *st_text); |
| 572 | |
| 573 | /** |
| 574 | * Notify application that an existing call has been replaced with |
| 575 | * a new call. This happens when PJSUA-API receives incoming INVITE |
| 576 | * request with Replaces header. |
| 577 | * |
| 578 | * After this callback is called, normally PJSUA-API will disconnect |
| 579 | * \a old_call_id and establish \a new_call_id. |
| 580 | * |
| 581 | * @param old_call_id Existing call which to be replaced with the |
| 582 | * new call. |
| 583 | * @param new_call_id The new call. |
| 584 | * @param rdata The incoming INVITE with Replaces request. |
| 585 | */ |
| 586 | void (*on_call_replaced)(pjsua_call_id old_call_id, |
| 587 | pjsua_call_id new_call_id); |
| 588 | |
| 589 | |
| 590 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 591 | * Notify application when registration status has changed. |
| 592 | * Application may then query the account info to get the |
| 593 | * registration details. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 594 | * |
Nanang Izzuddin | 4ea1bcc | 2010-09-28 04:57:01 +0000 | [diff] [blame] | 595 | * @param acc_id The account ID. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 596 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 597 | void (*on_reg_state)(pjsua_acc_id acc_id); |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 598 | |
| 599 | /** |
Nanang Izzuddin | 4ea1bcc | 2010-09-28 04:57:01 +0000 | [diff] [blame] | 600 | * Notify application when registration status has changed. |
| 601 | * Application may inspect the registration info to get the |
| 602 | * registration status details. |
| 603 | * |
| 604 | * @param acc_id The account ID. |
| 605 | * @param info The registration info. |
| 606 | */ |
| 607 | void (*on_reg_state2)(pjsua_acc_id acc_id, pjsua_reg_info *info); |
| 608 | |
| 609 | /** |
Benny Prijono | 63fba01 | 2008-07-17 14:19:10 +0000 | [diff] [blame] | 610 | * Notification when incoming SUBSCRIBE request is received. Application |
| 611 | * may use this callback to authorize the incoming subscribe request |
| 612 | * (e.g. ask user permission if the request should be granted). |
| 613 | * |
| 614 | * If this callback is not implemented, all incoming presence subscription |
| 615 | * requests will be accepted. |
| 616 | * |
| 617 | * If this callback is implemented, application has several choices on |
| 618 | * what to do with the incoming request: |
| 619 | * - it may reject the request immediately by specifying non-200 class |
| 620 | * final response in the \a code argument. |
| 621 | * - it may immediately accept the request by specifying 200 as the |
| 622 | * \a code argument. This is the default value if application doesn't |
| 623 | * set any value to the \a code argument. In this case, the library |
| 624 | * will automatically send NOTIFY request upon returning from this |
| 625 | * callback. |
| 626 | * - it may delay the processing of the request, for example to request |
| 627 | * user permission whether to accept or reject the request. In this |
| 628 | * case, the application MUST set the \a code argument to 202, and |
| 629 | * later calls #pjsua_pres_notify() to accept or reject the |
| 630 | * subscription request. |
| 631 | * |
| 632 | * Any \a code other than 200 and 202 will be treated as 200. |
| 633 | * |
| 634 | * Application MUST return from this callback immediately (e.g. it must |
| 635 | * not block in this callback while waiting for user confirmation). |
| 636 | * |
| 637 | * @param srv_pres Server presence subscription instance. If |
| 638 | * application delays the acceptance of the request, |
| 639 | * it will need to specify this object when calling |
| 640 | * #pjsua_pres_notify(). |
| 641 | * @param acc_id Account ID most appropriate for this request. |
| 642 | * @param buddy_id ID of the buddy matching the sender of the |
| 643 | * request, if any, or PJSUA_INVALID_ID if no |
| 644 | * matching buddy is found. |
| 645 | * @param from The From URI of the request. |
| 646 | * @param rdata The incoming request. |
| 647 | * @param code The status code to respond to the request. The |
| 648 | * default value is 200. Application may set this |
| 649 | * to other final status code to accept or reject |
| 650 | * the request. |
| 651 | * @param reason The reason phrase to respond to the request. |
| 652 | * @param msg_data If the application wants to send additional |
| 653 | * headers in the response, it can put it in this |
| 654 | * parameter. |
| 655 | */ |
| 656 | void (*on_incoming_subscribe)(pjsua_acc_id acc_id, |
| 657 | pjsua_srv_pres *srv_pres, |
| 658 | pjsua_buddy_id buddy_id, |
| 659 | const pj_str_t *from, |
| 660 | pjsip_rx_data *rdata, |
| 661 | pjsip_status_code *code, |
| 662 | pj_str_t *reason, |
| 663 | pjsua_msg_data *msg_data); |
| 664 | |
| 665 | /** |
| 666 | * Notification when server side subscription state has changed. |
| 667 | * This callback is optional as application normally does not need |
| 668 | * to do anything to maintain server side presence subscription. |
| 669 | * |
| 670 | * @param acc_id The account ID. |
| 671 | * @param srv_pres Server presence subscription object. |
| 672 | * @param remote_uri Remote URI string. |
| 673 | * @param state New subscription state. |
| 674 | * @param event PJSIP event that triggers the state change. |
| 675 | */ |
| 676 | void (*on_srv_subscribe_state)(pjsua_acc_id acc_id, |
| 677 | pjsua_srv_pres *srv_pres, |
| 678 | const pj_str_t *remote_uri, |
| 679 | pjsip_evsub_state state, |
| 680 | pjsip_event *event); |
| 681 | |
| 682 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 683 | * Notify application when the buddy state has changed. |
| 684 | * Application may then query the buddy into to get the details. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 685 | * |
| 686 | * @param buddy_id The buddy id. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 687 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 688 | void (*on_buddy_state)(pjsua_buddy_id buddy_id); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 689 | |
Benny Prijono | 6349989 | 2010-10-12 12:45:15 +0000 | [diff] [blame^] | 690 | |
| 691 | /** |
| 692 | * Notify application when the state of client subscription session |
| 693 | * associated with a buddy has changed. Application may use this |
| 694 | * callback to retrieve more detailed information about the state |
| 695 | * changed event. |
| 696 | * |
| 697 | * @param buddy_id The buddy id. |
| 698 | * @param sub Event subscription session. |
| 699 | * @param event The event which triggers state change event. |
| 700 | */ |
| 701 | void (*on_buddy_evsub_state)(pjsua_buddy_id buddy_id, |
| 702 | pjsip_evsub *sub, |
| 703 | pjsip_event *event); |
| 704 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 705 | /** |
| 706 | * Notify application on incoming pager (i.e. MESSAGE request). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 707 | * Argument call_id will be -1 if MESSAGE request is not related to an |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 708 | * existing call. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 709 | * |
Benny Prijono | bbeb399 | 2007-05-21 13:48:35 +0000 | [diff] [blame] | 710 | * See also \a on_pager2() callback for the version with \a pjsip_rx_data |
| 711 | * passed as one of the argument. |
| 712 | * |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 713 | * @param call_id Containts the ID of the call where the IM was |
| 714 | * sent, or PJSUA_INVALID_ID if the IM was sent |
| 715 | * outside call context. |
| 716 | * @param from URI of the sender. |
| 717 | * @param to URI of the destination message. |
| 718 | * @param contact The Contact URI of the sender, if present. |
| 719 | * @param mime_type MIME type of the message. |
| 720 | * @param body The message content. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 721 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 722 | void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from, |
| 723 | const pj_str_t *to, const pj_str_t *contact, |
| 724 | const pj_str_t *mime_type, const pj_str_t *body); |
| 725 | |
| 726 | /** |
Benny Prijono | bbeb399 | 2007-05-21 13:48:35 +0000 | [diff] [blame] | 727 | * This is the alternative version of the \a on_pager() callback with |
| 728 | * \a pjsip_rx_data argument. |
| 729 | * |
| 730 | * @param call_id Containts the ID of the call where the IM was |
| 731 | * sent, or PJSUA_INVALID_ID if the IM was sent |
| 732 | * outside call context. |
| 733 | * @param from URI of the sender. |
| 734 | * @param to URI of the destination message. |
| 735 | * @param contact The Contact URI of the sender, if present. |
| 736 | * @param mime_type MIME type of the message. |
| 737 | * @param body The message content. |
| 738 | * @param rdata The incoming MESSAGE request. |
Benny Prijono | ba736c4 | 2008-07-10 20:45:03 +0000 | [diff] [blame] | 739 | * @param acc_id Account ID most suitable for this message. |
Benny Prijono | bbeb399 | 2007-05-21 13:48:35 +0000 | [diff] [blame] | 740 | */ |
| 741 | void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from, |
| 742 | const pj_str_t *to, const pj_str_t *contact, |
| 743 | const pj_str_t *mime_type, const pj_str_t *body, |
Benny Prijono | ba736c4 | 2008-07-10 20:45:03 +0000 | [diff] [blame] | 744 | pjsip_rx_data *rdata, pjsua_acc_id acc_id); |
Benny Prijono | bbeb399 | 2007-05-21 13:48:35 +0000 | [diff] [blame] | 745 | |
| 746 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 747 | * Notify application about the delivery status of outgoing pager |
Benny Prijono | 4da0b1d | 2007-06-11 18:22:54 +0000 | [diff] [blame] | 748 | * request. See also on_pager_status2() callback for the version with |
| 749 | * \a pjsip_rx_data in the argument list. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 750 | * |
| 751 | * @param call_id Containts the ID of the call where the IM was |
| 752 | * sent, or PJSUA_INVALID_ID if the IM was sent |
| 753 | * outside call context. |
| 754 | * @param to Destination URI. |
| 755 | * @param body Message body. |
| 756 | * @param user_data Arbitrary data that was specified when sending |
| 757 | * IM message. |
| 758 | * @param status Delivery status. |
| 759 | * @param reason Delivery status reason. |
| 760 | */ |
| 761 | void (*on_pager_status)(pjsua_call_id call_id, |
| 762 | const pj_str_t *to, |
| 763 | const pj_str_t *body, |
| 764 | void *user_data, |
| 765 | pjsip_status_code status, |
| 766 | const pj_str_t *reason); |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 767 | |
| 768 | /** |
Benny Prijono | 4da0b1d | 2007-06-11 18:22:54 +0000 | [diff] [blame] | 769 | * Notify application about the delivery status of outgoing pager |
| 770 | * request. |
| 771 | * |
| 772 | * @param call_id Containts the ID of the call where the IM was |
| 773 | * sent, or PJSUA_INVALID_ID if the IM was sent |
| 774 | * outside call context. |
| 775 | * @param to Destination URI. |
| 776 | * @param body Message body. |
| 777 | * @param user_data Arbitrary data that was specified when sending |
| 778 | * IM message. |
| 779 | * @param status Delivery status. |
| 780 | * @param reason Delivery status reason. |
Benny Prijono | 0a98200 | 2007-06-12 16:22:09 +0000 | [diff] [blame] | 781 | * @param tdata The original MESSAGE request. |
Benny Prijono | 4da0b1d | 2007-06-11 18:22:54 +0000 | [diff] [blame] | 782 | * @param rdata The incoming MESSAGE response, or NULL if the |
| 783 | * message transaction fails because of time out |
| 784 | * or transport error. |
Benny Prijono | ba736c4 | 2008-07-10 20:45:03 +0000 | [diff] [blame] | 785 | * @param acc_id Account ID from this the instant message was |
| 786 | * send. |
Benny Prijono | 4da0b1d | 2007-06-11 18:22:54 +0000 | [diff] [blame] | 787 | */ |
| 788 | void (*on_pager_status2)(pjsua_call_id call_id, |
| 789 | const pj_str_t *to, |
| 790 | const pj_str_t *body, |
| 791 | void *user_data, |
| 792 | pjsip_status_code status, |
| 793 | const pj_str_t *reason, |
Benny Prijono | 0a98200 | 2007-06-12 16:22:09 +0000 | [diff] [blame] | 794 | pjsip_tx_data *tdata, |
Benny Prijono | ba736c4 | 2008-07-10 20:45:03 +0000 | [diff] [blame] | 795 | pjsip_rx_data *rdata, |
| 796 | pjsua_acc_id acc_id); |
Benny Prijono | 4da0b1d | 2007-06-11 18:22:54 +0000 | [diff] [blame] | 797 | |
| 798 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 799 | * Notify application about typing indication. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 800 | * |
| 801 | * @param call_id Containts the ID of the call where the IM was |
| 802 | * sent, or PJSUA_INVALID_ID if the IM was sent |
| 803 | * outside call context. |
| 804 | * @param from URI of the sender. |
| 805 | * @param to URI of the destination message. |
| 806 | * @param contact The Contact URI of the sender, if present. |
| 807 | * @param is_typing Non-zero if peer is typing, or zero if peer |
| 808 | * has stopped typing a message. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 809 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 810 | void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from, |
| 811 | const pj_str_t *to, const pj_str_t *contact, |
| 812 | pj_bool_t is_typing); |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 813 | |
Benny Prijono | 6ba8c54 | 2007-10-16 01:34:14 +0000 | [diff] [blame] | 814 | /** |
Benny Prijono | ba736c4 | 2008-07-10 20:45:03 +0000 | [diff] [blame] | 815 | * Notify application about typing indication. |
| 816 | * |
| 817 | * @param call_id Containts the ID of the call where the IM was |
| 818 | * sent, or PJSUA_INVALID_ID if the IM was sent |
| 819 | * outside call context. |
| 820 | * @param from URI of the sender. |
| 821 | * @param to URI of the destination message. |
| 822 | * @param contact The Contact URI of the sender, if present. |
| 823 | * @param is_typing Non-zero if peer is typing, or zero if peer |
| 824 | * has stopped typing a message. |
| 825 | * @param rdata The received request. |
| 826 | * @param acc_id Account ID most suitable for this message. |
| 827 | */ |
| 828 | void (*on_typing2)(pjsua_call_id call_id, const pj_str_t *from, |
| 829 | const pj_str_t *to, const pj_str_t *contact, |
| 830 | pj_bool_t is_typing, pjsip_rx_data *rdata, |
| 831 | pjsua_acc_id acc_id); |
| 832 | |
| 833 | /** |
Benny Prijono | 6ba8c54 | 2007-10-16 01:34:14 +0000 | [diff] [blame] | 834 | * Callback when the library has finished performing NAT type |
| 835 | * detection. |
| 836 | * |
| 837 | * @param res NAT detection result. |
| 838 | */ |
| 839 | void (*on_nat_detect)(const pj_stun_nat_detect_result *res); |
| 840 | |
Benny Prijono | 5e51a4e | 2008-11-27 00:06:46 +0000 | [diff] [blame] | 841 | /** |
| 842 | * This callback is called when the call is about to resend the |
| 843 | * INVITE request to the specified target, following the previously |
| 844 | * received redirection response. |
| 845 | * |
| 846 | * Application may accept the redirection to the specified target |
| 847 | * (the default behavior if this callback is implemented), reject |
| 848 | * this target only and make the session continue to try the next |
| 849 | * target in the list if such target exists, stop the whole |
| 850 | * redirection process altogether and cause the session to be |
| 851 | * disconnected, or defer the decision to ask for user confirmation. |
| 852 | * |
| 853 | * This callback is optional. If this callback is not implemented, |
| 854 | * the default behavior is to NOT follow the redirection response. |
| 855 | * |
| 856 | * @param call_id The call ID. |
| 857 | * @param target The current target to be tried. |
Benny Prijono | 08a48b8 | 2008-11-27 12:42:07 +0000 | [diff] [blame] | 858 | * @param e The event that caused this callback to be called. |
| 859 | * This could be the receipt of 3xx response, or |
| 860 | * 4xx/5xx response received for the INVITE sent to |
| 861 | * subsequent targets, or NULL if this callback is |
| 862 | * called from within #pjsua_call_process_redirect() |
| 863 | * context. |
| 864 | * |
| 865 | * @return Action to be performed for the target. Set this |
Benny Prijono | 5e51a4e | 2008-11-27 00:06:46 +0000 | [diff] [blame] | 866 | * parameter to one of the value below: |
| 867 | * - PJSIP_REDIRECT_ACCEPT: immediately accept the |
| 868 | * redirection (default value). When set, the |
| 869 | * call will immediately resend INVITE request |
| 870 | * to the target. |
| 871 | * - PJSIP_REDIRECT_REJECT: immediately reject this |
| 872 | * target. The call will continue retrying with |
| 873 | * next target if present, or disconnect the call |
| 874 | * if there is no more target to try. |
| 875 | * - PJSIP_REDIRECT_STOP: stop the whole redirection |
| 876 | * process and immediately disconnect the call. The |
| 877 | * on_call_state() callback will be called with |
| 878 | * PJSIP_INV_STATE_DISCONNECTED state immediately |
| 879 | * after this callback returns. |
| 880 | * - PJSIP_REDIRECT_PENDING: set to this value if |
| 881 | * no decision can be made immediately (for example |
| 882 | * to request confirmation from user). Application |
| 883 | * then MUST call #pjsua_call_process_redirect() |
| 884 | * to either accept or reject the redirection upon |
| 885 | * getting user decision. |
Benny Prijono | 5e51a4e | 2008-11-27 00:06:46 +0000 | [diff] [blame] | 886 | */ |
Benny Prijono | 08a48b8 | 2008-11-27 12:42:07 +0000 | [diff] [blame] | 887 | pjsip_redirect_op (*on_call_redirected)(pjsua_call_id call_id, |
| 888 | const pjsip_uri *target, |
| 889 | const pjsip_event *e); |
Benny Prijono | 5e51a4e | 2008-11-27 00:06:46 +0000 | [diff] [blame] | 890 | |
Benny Prijono | 4dd961b | 2009-10-26 11:21:37 +0000 | [diff] [blame] | 891 | /** |
| 892 | * This callback is called when a NOTIFY request for message summary / |
| 893 | * message waiting indication is received. |
| 894 | * |
| 895 | * @param acc_id The account ID. |
| 896 | * @param mwi_info Structure containing details of the event, |
| 897 | * including the received NOTIFY request in the |
| 898 | * \a rdata field. |
| 899 | */ |
| 900 | void (*on_mwi_info)(pjsua_acc_id acc_id, pjsua_mwi_info *mwi_info); |
| 901 | |
Nanang Izzuddin | 2fb937e | 2010-02-24 05:43:34 +0000 | [diff] [blame] | 902 | /** |
| 903 | * This callback is called when transport state is changed. See also |
| 904 | * #pjsip_tp_state_callback. |
Nanang Izzuddin | 2fb937e | 2010-02-24 05:43:34 +0000 | [diff] [blame] | 905 | */ |
Nanang Izzuddin | 5e69da5 | 2010-02-25 11:58:19 +0000 | [diff] [blame] | 906 | pjsip_tp_state_callback on_transport_state; |
Nanang Izzuddin | 2fb937e | 2010-02-24 05:43:34 +0000 | [diff] [blame] | 907 | |
Benny Prijono | 4d6ff4d | 2010-06-19 12:35:33 +0000 | [diff] [blame] | 908 | /** |
| 909 | * This callback is called to report error in ICE media transport. |
| 910 | * Currently it is used to report TURN Refresh error. |
| 911 | * |
| 912 | * @param index Transport index. |
| 913 | * @param op Operation which trigger the failure. |
| 914 | * @param status Error status. |
| 915 | * @param param Additional info about the event. Currently this will |
| 916 | * always be set to NULL. |
| 917 | */ |
| 918 | void (*on_ice_transport_error)(int index, pj_ice_strans_op op, |
| 919 | pj_status_t status, void *param); |
| 920 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 921 | } pjsua_callback; |
| 922 | |
| 923 | |
Nanang Izzuddin | 742ef4b | 2010-09-07 09:36:15 +0000 | [diff] [blame] | 924 | /** |
| 925 | * This enumeration specifies the usage of SIP Session Timers extension. |
| 926 | */ |
| 927 | typedef enum pjsua_sip_timer_use |
| 928 | { |
| 929 | /** |
| 930 | * When this flag is specified, Session Timers will not be used in any |
| 931 | * session, except it is explicitly required in the remote request. |
| 932 | */ |
| 933 | PJSUA_SIP_TIMER_INACTIVE, |
| 934 | |
| 935 | /** |
| 936 | * When this flag is specified, Session Timers will be used in all |
| 937 | * sessions whenever remote supports and uses it. |
| 938 | */ |
| 939 | PJSUA_SIP_TIMER_OPTIONAL, |
| 940 | |
| 941 | /** |
| 942 | * When this flag is specified, Session Timers support will be |
| 943 | * a requirement for the remote to be able to establish a session. |
| 944 | */ |
| 945 | PJSUA_SIP_TIMER_REQUIRED, |
| 946 | |
| 947 | /** |
| 948 | * When this flag is specified, Session Timers will always be used |
| 949 | * in all sessions, regardless whether remote supports/uses it or not. |
| 950 | */ |
| 951 | PJSUA_SIP_TIMER_ALWAYS |
| 952 | |
| 953 | } pjsua_sip_timer_use; |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 954 | |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 955 | |
| 956 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 957 | * This structure describes the settings to control the API and |
| 958 | * user agent behavior, and can be specified when calling #pjsua_init(). |
| 959 | * Before setting the values, application must call #pjsua_config_default() |
| 960 | * to initialize this structure with the default values. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 961 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 962 | typedef struct pjsua_config |
| 963 | { |
| 964 | |
| 965 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 966 | * Maximum calls to support (default: 4). The value specified here |
| 967 | * must be smaller than the compile time maximum settings |
| 968 | * PJSUA_MAX_CALLS, which by default is 32. To increase this |
| 969 | * limit, the library must be recompiled with new PJSUA_MAX_CALLS |
| 970 | * value. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 971 | */ |
| 972 | unsigned max_calls; |
| 973 | |
| 974 | /** |
| 975 | * Number of worker threads. Normally application will want to have at |
| 976 | * least one worker thread, unless when it wants to poll the library |
| 977 | * periodically, which in this case the worker thread can be set to |
| 978 | * zero. |
| 979 | */ |
| 980 | unsigned thread_cnt; |
| 981 | |
| 982 | /** |
Benny Prijono | fa9e5b1 | 2006-10-08 12:39:34 +0000 | [diff] [blame] | 983 | * Number of nameservers. If no name server is configured, the SIP SRV |
| 984 | * resolution would be disabled, and domain will be resolved with |
| 985 | * standard pj_gethostbyname() function. |
| 986 | */ |
| 987 | unsigned nameserver_count; |
| 988 | |
| 989 | /** |
| 990 | * Array of nameservers to be used by the SIP resolver subsystem. |
| 991 | * The order of the name server specifies the priority (first name |
| 992 | * server will be used first, unless it is not reachable). |
| 993 | */ |
| 994 | pj_str_t nameserver[4]; |
| 995 | |
| 996 | /** |
Benny Prijono | 91d06b6 | 2008-09-20 12:16:56 +0000 | [diff] [blame] | 997 | * Force loose-route to be used in all route/proxy URIs (outbound_proxy |
| 998 | * and account's proxy settings). When this setting is enabled, the |
| 999 | * library will check all the route/proxy URIs specified in the settings |
| 1000 | * and append ";lr" parameter to the URI if the parameter is not present. |
| 1001 | * |
| 1002 | * Default: 1 |
| 1003 | */ |
| 1004 | pj_bool_t force_lr; |
| 1005 | |
| 1006 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1007 | * Number of outbound proxies in the \a outbound_proxy array. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1008 | */ |
| 1009 | unsigned outbound_proxy_cnt; |
| 1010 | |
| 1011 | /** |
| 1012 | * Specify the URL of outbound proxies to visit for all outgoing requests. |
| 1013 | * The outbound proxies will be used for all accounts, and it will |
| 1014 | * be used to build the route set for outgoing requests. The final |
| 1015 | * route set for outgoing requests will consists of the outbound proxies |
| 1016 | * and the proxy configured in the account. |
| 1017 | */ |
| 1018 | pj_str_t outbound_proxy[4]; |
| 1019 | |
Benny Prijono | c97608e | 2007-03-23 16:34:20 +0000 | [diff] [blame] | 1020 | /** |
Benny Prijono | bb995fd | 2009-08-12 11:03:23 +0000 | [diff] [blame] | 1021 | * Warning: deprecated, please use \a stun_srv field instead. To maintain |
| 1022 | * backward compatibility, if \a stun_srv_cnt is zero then the value of |
| 1023 | * this field will be copied to \a stun_srv field, if present. |
| 1024 | * |
Benny Prijono | ebbf689 | 2007-03-24 17:37:25 +0000 | [diff] [blame] | 1025 | * Specify domain name to be resolved with DNS SRV resolution to get the |
Benny Prijono | f76e139 | 2008-06-06 14:51:48 +0000 | [diff] [blame] | 1026 | * address of the STUN server. Alternatively application may specify |
| 1027 | * \a stun_host instead. |
Benny Prijono | ebbf689 | 2007-03-24 17:37:25 +0000 | [diff] [blame] | 1028 | * |
| 1029 | * If DNS SRV resolution failed for this domain, then DNS A resolution |
| 1030 | * will be performed only if \a stun_host is specified. |
Benny Prijono | c97608e | 2007-03-23 16:34:20 +0000 | [diff] [blame] | 1031 | */ |
Benny Prijono | ebbf689 | 2007-03-24 17:37:25 +0000 | [diff] [blame] | 1032 | pj_str_t stun_domain; |
| 1033 | |
| 1034 | /** |
Benny Prijono | bb995fd | 2009-08-12 11:03:23 +0000 | [diff] [blame] | 1035 | * Warning: deprecated, please use \a stun_srv field instead. To maintain |
| 1036 | * backward compatibility, if \a stun_srv_cnt is zero then the value of |
| 1037 | * this field will be copied to \a stun_srv field, if present. |
| 1038 | * |
Benny Prijono | af09dc3 | 2007-04-22 12:48:30 +0000 | [diff] [blame] | 1039 | * Specify STUN server to be used, in "HOST[:PORT]" format. If port is |
| 1040 | * not specified, default port 3478 will be used. |
Benny Prijono | ebbf689 | 2007-03-24 17:37:25 +0000 | [diff] [blame] | 1041 | */ |
| 1042 | pj_str_t stun_host; |
| 1043 | |
| 1044 | /** |
Benny Prijono | bb995fd | 2009-08-12 11:03:23 +0000 | [diff] [blame] | 1045 | * Number of STUN server entries in \a stun_srv array. |
| 1046 | */ |
| 1047 | unsigned stun_srv_cnt; |
| 1048 | |
| 1049 | /** |
| 1050 | * Array of STUN servers to try. The library will try to resolve and |
| 1051 | * contact each of the STUN server entry until it finds one that is |
| 1052 | * usable. Each entry may be a domain name, host name, IP address, and |
| 1053 | * it may contain an optional port number. For example: |
| 1054 | * - "pjsip.org" (domain name) |
| 1055 | * - "sip.pjsip.org" (host name) |
| 1056 | * - "pjsip.org:33478" (domain name and a non-standard port number) |
| 1057 | * - "10.0.0.1:3478" (IP address and port number) |
| 1058 | * |
| 1059 | * When nameserver is configured in the \a pjsua_config.nameserver field, |
| 1060 | * if entry is not an IP address, it will be resolved with DNS SRV |
| 1061 | * resolution first, and it will fallback to use DNS A resolution if this |
| 1062 | * fails. Port number may be specified even if the entry is a domain name, |
| 1063 | * in case the DNS SRV resolution should fallback to a non-standard port. |
| 1064 | * |
| 1065 | * When nameserver is not configured, entries will be resolved with |
| 1066 | * #pj_gethostbyname() if it's not an IP address. Port number may be |
| 1067 | * specified if the server is not listening in standard STUN port. |
| 1068 | */ |
| 1069 | pj_str_t stun_srv[8]; |
| 1070 | |
| 1071 | /** |
| 1072 | * This specifies if the library startup should ignore failure with the |
| 1073 | * STUN servers. If this is set to PJ_FALSE, the library will refuse to |
| 1074 | * start if it fails to resolve or contact any of the STUN servers. |
| 1075 | * |
| 1076 | * Default: PJ_TRUE |
| 1077 | */ |
| 1078 | pj_bool_t stun_ignore_failure; |
| 1079 | |
| 1080 | /** |
Benny Prijono | 91a6a17 | 2007-10-31 08:59:29 +0000 | [diff] [blame] | 1081 | * Support for adding and parsing NAT type in the SDP to assist |
| 1082 | * troubleshooting. The valid values are: |
| 1083 | * - 0: no information will be added in SDP, and parsing is disabled. |
Benny Prijono | 6ba8c54 | 2007-10-16 01:34:14 +0000 | [diff] [blame] | 1084 | * - 1: only the NAT type number is added. |
| 1085 | * - 2: add both NAT type number and name. |
| 1086 | * |
Benny Prijono | 91a6a17 | 2007-10-31 08:59:29 +0000 | [diff] [blame] | 1087 | * Default: 1 |
Benny Prijono | 6ba8c54 | 2007-10-16 01:34:14 +0000 | [diff] [blame] | 1088 | */ |
| 1089 | int nat_type_in_sdp; |
| 1090 | |
| 1091 | /** |
Benny Prijono | dcfc0ba | 2007-09-30 16:50:27 +0000 | [diff] [blame] | 1092 | * Specify whether support for reliable provisional response (100rel and |
| 1093 | * PRACK) should be required by default. Note that this setting can be |
| 1094 | * further customized in account configuration (#pjsua_acc_config). |
| 1095 | * |
| 1096 | * Default: PJ_FALSE |
| 1097 | */ |
| 1098 | pj_bool_t require_100rel; |
| 1099 | |
Nanang Izzuddin | 59dffb1 | 2009-08-11 12:42:38 +0000 | [diff] [blame] | 1100 | /** |
Nanang Izzuddin | 742ef4b | 2010-09-07 09:36:15 +0000 | [diff] [blame] | 1101 | * Specify the usage of Session Timers for all sessions. See the |
| 1102 | * #pjsua_sip_timer_use for possible values. Note that this setting can be |
| 1103 | * further customized in account configuration (#pjsua_acc_config). |
Nanang Izzuddin | 59dffb1 | 2009-08-11 12:42:38 +0000 | [diff] [blame] | 1104 | * |
Nanang Izzuddin | 742ef4b | 2010-09-07 09:36:15 +0000 | [diff] [blame] | 1105 | * Default: PJSUA_SIP_TIMER_OPTIONAL |
Nanang Izzuddin | 59dffb1 | 2009-08-11 12:42:38 +0000 | [diff] [blame] | 1106 | */ |
Nanang Izzuddin | 742ef4b | 2010-09-07 09:36:15 +0000 | [diff] [blame] | 1107 | pjsua_sip_timer_use use_timer; |
Nanang Izzuddin | 59dffb1 | 2009-08-11 12:42:38 +0000 | [diff] [blame] | 1108 | |
| 1109 | /** |
Benny Prijono | fe1bd34 | 2009-11-20 23:33:07 +0000 | [diff] [blame] | 1110 | * Handle unsolicited NOTIFY requests containing message waiting |
| 1111 | * indication (MWI) info. Unsolicited MWI is incoming NOTIFY requests |
| 1112 | * which are not requested by client with SUBSCRIBE request. |
| 1113 | * |
| 1114 | * If this is enabled, the library will respond 200/OK to the NOTIFY |
| 1115 | * request and forward the request to \a on_mwi_info() callback. |
| 1116 | * |
| 1117 | * See also \a mwi_enabled field #on pjsua_acc_config. |
| 1118 | * |
| 1119 | * Default: PJ_TRUE |
| 1120 | * |
| 1121 | */ |
| 1122 | pj_bool_t enable_unsolicited_mwi; |
| 1123 | |
| 1124 | /** |
Nanang Izzuddin | 65add62 | 2009-08-11 16:26:20 +0000 | [diff] [blame] | 1125 | * Specify Session Timer settings, see #pjsip_timer_setting. |
Nanang Izzuddin | 59dffb1 | 2009-08-11 12:42:38 +0000 | [diff] [blame] | 1126 | * Note that this setting can be further customized in account |
| 1127 | * configuration (#pjsua_acc_config). |
Nanang Izzuddin | 59dffb1 | 2009-08-11 12:42:38 +0000 | [diff] [blame] | 1128 | */ |
Nanang Izzuddin | 65add62 | 2009-08-11 16:26:20 +0000 | [diff] [blame] | 1129 | pjsip_timer_setting timer_setting; |
Nanang Izzuddin | 59dffb1 | 2009-08-11 12:42:38 +0000 | [diff] [blame] | 1130 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1131 | /** |
| 1132 | * Number of credentials in the credential array. |
| 1133 | */ |
| 1134 | unsigned cred_count; |
| 1135 | |
| 1136 | /** |
| 1137 | * Array of credentials. These credentials will be used by all accounts, |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1138 | * and can be used to authenticate against outbound proxies. If the |
| 1139 | * credential is specific to the account, then application should set |
| 1140 | * the credential in the pjsua_acc_config rather than the credential |
| 1141 | * here. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1142 | */ |
| 1143 | pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES]; |
| 1144 | |
| 1145 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1146 | * Application callback to receive various event notifications from |
| 1147 | * the library. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1148 | */ |
| 1149 | pjsua_callback cb; |
| 1150 | |
Benny Prijono | 5631561 | 2006-07-18 14:39:40 +0000 | [diff] [blame] | 1151 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1152 | * Optional user agent string (default empty). If it's empty, no |
| 1153 | * User-Agent header will be sent with outgoing requests. |
Benny Prijono | 5631561 | 2006-07-18 14:39:40 +0000 | [diff] [blame] | 1154 | */ |
| 1155 | pj_str_t user_agent; |
| 1156 | |
Benny Prijono | d817965 | 2008-01-23 20:39:07 +0000 | [diff] [blame] | 1157 | #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) |
| 1158 | /** |
| 1159 | * Specify default value of secure media transport usage. |
| 1160 | * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and |
| 1161 | * PJMEDIA_SRTP_MANDATORY. |
| 1162 | * |
| 1163 | * Note that this setting can be further customized in account |
| 1164 | * configuration (#pjsua_acc_config). |
| 1165 | * |
| 1166 | * Default: #PJSUA_DEFAULT_USE_SRTP |
| 1167 | */ |
| 1168 | pjmedia_srtp_use use_srtp; |
| 1169 | |
| 1170 | /** |
| 1171 | * Specify whether SRTP requires secure signaling to be used. This option |
| 1172 | * is only used when \a use_srtp option above is non-zero. |
| 1173 | * |
| 1174 | * Valid values are: |
| 1175 | * 0: SRTP does not require secure signaling |
| 1176 | * 1: SRTP requires secure transport such as TLS |
| 1177 | * 2: SRTP requires secure end-to-end transport (SIPS) |
| 1178 | * |
| 1179 | * Note that this setting can be further customized in account |
| 1180 | * configuration (#pjsua_acc_config). |
| 1181 | * |
| 1182 | * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING |
| 1183 | */ |
| 1184 | int srtp_secure_signaling; |
Nanang Izzuddin | d89cc3a | 2010-05-13 05:22:51 +0000 | [diff] [blame] | 1185 | |
| 1186 | /** |
| 1187 | * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose |
| 1188 | * duplicated media in SDP offer, i.e: unsecured and secured version. |
| 1189 | * Otherwise, the SDP media will be composed as unsecured media but |
| 1190 | * with SDP "crypto" attribute. |
| 1191 | * |
| 1192 | * Default: PJ_FALSE |
| 1193 | */ |
| 1194 | pj_bool_t srtp_optional_dup_offer; |
Benny Prijono | d817965 | 2008-01-23 20:39:07 +0000 | [diff] [blame] | 1195 | #endif |
| 1196 | |
Benny Prijono | 3c5e28b | 2008-09-24 10:10:15 +0000 | [diff] [blame] | 1197 | /** |
| 1198 | * Disconnect other call legs when more than one 2xx responses for |
| 1199 | * outgoing INVITE are received due to forking. Currently the library |
| 1200 | * is not able to handle simultaneous forked media, so disconnecting |
| 1201 | * the other call legs is necessary. |
| 1202 | * |
| 1203 | * With this setting enabled, the library will handle only one of the |
| 1204 | * connected call leg, and the other connected call legs will be |
| 1205 | * disconnected. |
| 1206 | * |
| 1207 | * Default: PJ_TRUE (only disable this setting for testing purposes). |
| 1208 | */ |
| 1209 | pj_bool_t hangup_forked_call; |
| 1210 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1211 | } pjsua_config; |
| 1212 | |
| 1213 | |
| 1214 | /** |
| 1215 | * Use this function to initialize pjsua config. |
| 1216 | * |
| 1217 | * @param cfg pjsua config to be initialized. |
| 1218 | */ |
Benny Prijono | 1f61a8f | 2007-08-16 10:11:44 +0000 | [diff] [blame] | 1219 | PJ_DECL(void) pjsua_config_default(pjsua_config *cfg); |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1220 | |
| 1221 | |
Benny Prijono | a7b376b | 2008-01-25 16:06:33 +0000 | [diff] [blame] | 1222 | /** The implementation has been moved to sip_auth.h */ |
Benny Prijono | 7977f9f | 2007-10-10 11:37:56 +0000 | [diff] [blame] | 1223 | #define pjsip_cred_dup pjsip_cred_info_dup |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1224 | |
| 1225 | |
| 1226 | /** |
| 1227 | * Duplicate pjsua_config. |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1228 | * |
| 1229 | * @param pool The pool to get memory from. |
| 1230 | * @param dst Destination config. |
| 1231 | * @param src Source config. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1232 | */ |
Benny Prijono | 1f61a8f | 2007-08-16 10:11:44 +0000 | [diff] [blame] | 1233 | PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool, |
| 1234 | pjsua_config *dst, |
| 1235 | const pjsua_config *src); |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1236 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1237 | |
| 1238 | /** |
| 1239 | * This structure describes additional information to be sent with |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1240 | * outgoing SIP message. It can (optionally) be specified for example |
| 1241 | * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(), |
| 1242 | * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more. |
| 1243 | * |
| 1244 | * Application MUST call #pjsua_msg_data_init() to initialize this |
| 1245 | * structure before setting its values. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1246 | */ |
Benny Prijono | 63fba01 | 2008-07-17 14:19:10 +0000 | [diff] [blame] | 1247 | struct pjsua_msg_data |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1248 | { |
| 1249 | /** |
Benny Prijono | c92ca5c | 2007-06-11 17:03:41 +0000 | [diff] [blame] | 1250 | * Additional message headers as linked list. Application can add |
| 1251 | * headers to the list by creating the header, either from the heap/pool |
| 1252 | * or from temporary local variable, and add the header using |
| 1253 | * linked list operation. See pjsip_apps.c for some sample codes. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1254 | */ |
| 1255 | pjsip_hdr hdr_list; |
| 1256 | |
| 1257 | /** |
| 1258 | * MIME type of optional message body. |
| 1259 | */ |
| 1260 | pj_str_t content_type; |
| 1261 | |
| 1262 | /** |
Benny Prijono | 1c1d734 | 2010-08-01 09:48:51 +0000 | [diff] [blame] | 1263 | * Optional message body to be added to the message, only when the |
| 1264 | * message doesn't have a body. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1265 | */ |
| 1266 | pj_str_t msg_body; |
| 1267 | |
Benny Prijono | 1c1d734 | 2010-08-01 09:48:51 +0000 | [diff] [blame] | 1268 | /** |
| 1269 | * Content type of the multipart body. If application wants to send |
| 1270 | * multipart message bodies, it puts the parts in \a parts and set |
| 1271 | * the content type in \a multipart_ctype. If the message already |
| 1272 | * contains a body, the body will be added to the multipart bodies. |
| 1273 | */ |
| 1274 | pjsip_media_type multipart_ctype; |
| 1275 | |
| 1276 | /** |
| 1277 | * List of multipart parts. If application wants to send multipart |
| 1278 | * message bodies, it puts the parts in \a parts and set the content |
| 1279 | * type in \a multipart_ctype. If the message already contains a body, |
| 1280 | * the body will be added to the multipart bodies. |
| 1281 | */ |
| 1282 | pjsip_multipart_part multipart_parts; |
Benny Prijono | 63fba01 | 2008-07-17 14:19:10 +0000 | [diff] [blame] | 1283 | }; |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1284 | |
| 1285 | |
| 1286 | /** |
| 1287 | * Initialize message data. |
| 1288 | * |
| 1289 | * @param msg_data Message data to be initialized. |
| 1290 | */ |
Benny Prijono | 1f61a8f | 2007-08-16 10:11:44 +0000 | [diff] [blame] | 1291 | PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data); |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 1292 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 1293 | |
| 1294 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1295 | * Instantiate pjsua application. Application must call this function before |
| 1296 | * calling any other functions, to make sure that the underlying libraries |
| 1297 | * are properly initialized. Once this function has returned success, |
| 1298 | * application must call pjsua_destroy() before quitting. |
| 1299 | * |
| 1300 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 1301 | */ |
| 1302 | PJ_DECL(pj_status_t) pjsua_create(void); |
| 1303 | |
| 1304 | |
Benny Prijono | a7b376b | 2008-01-25 16:06:33 +0000 | [diff] [blame] | 1305 | /** Forward declaration */ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1306 | typedef struct pjsua_media_config pjsua_media_config; |
| 1307 | |
| 1308 | |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 1309 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1310 | * Initialize pjsua with the specified settings. All the settings are |
| 1311 | * optional, and the default values will be used when the config is not |
| 1312 | * specified. |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 1313 | * |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1314 | * Note that #pjsua_create() MUST be called before calling this function. |
| 1315 | * |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1316 | * @param ua_cfg User agent configuration. |
| 1317 | * @param log_cfg Optional logging configuration. |
| 1318 | * @param media_cfg Optional media configuration. |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 1319 | * |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1320 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 1321 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1322 | PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg, |
| 1323 | const pjsua_logging_config *log_cfg, |
| 1324 | const pjsua_media_config *media_cfg); |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 1325 | |
| 1326 | |
| 1327 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1328 | * Application is recommended to call this function after all initialization |
| 1329 | * is done, so that the library can do additional checking set up |
| 1330 | * additional |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 1331 | * |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1332 | * Application may call this function anytime after #pjsua_init(). |
| 1333 | * |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1334 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 1335 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 1336 | PJ_DECL(pj_status_t) pjsua_start(void); |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 1337 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1338 | |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 1339 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1340 | * Destroy pjsua. Application is recommended to perform graceful shutdown |
| 1341 | * before calling this function (such as unregister the account from the SIP |
| 1342 | * server, terminate presense subscription, and hangup active calls), however, |
| 1343 | * this function will do all of these if it finds there are active sessions |
| 1344 | * that need to be terminated. This function will approximately block for |
| 1345 | * one second to wait for replies from remote. |
| 1346 | * |
| 1347 | * Application.may safely call this function more than once if it doesn't |
| 1348 | * keep track of it's state. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1349 | * |
| 1350 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 1351 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 1352 | PJ_DECL(pj_status_t) pjsua_destroy(void); |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 1353 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1354 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1355 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1356 | * Poll pjsua for events, and if necessary block the caller thread for |
| 1357 | * the specified maximum interval (in miliseconds). |
| 1358 | * |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1359 | * Application doesn't normally need to call this function if it has |
| 1360 | * configured worker thread (\a thread_cnt field) in pjsua_config structure, |
| 1361 | * because polling then will be done by these worker threads instead. |
| 1362 | * |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1363 | * @param msec_timeout Maximum time to wait, in miliseconds. |
| 1364 | * |
| 1365 | * @return The number of events that have been handled during the |
| 1366 | * poll. Negative value indicates error, and application |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1367 | * can retrieve the error as (status = -return_value). |
Benny Prijono | b9b32ab | 2006-06-01 12:28:44 +0000 | [diff] [blame] | 1368 | */ |
| 1369 | PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout); |
| 1370 | |
| 1371 | |
| 1372 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1373 | * Create memory pool to be used by the application. Once application |
| 1374 | * finished using the pool, it must be released with pj_pool_release(). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1375 | * |
| 1376 | * @param name Optional pool name. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1377 | * @param init_size Initial size of the pool. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1378 | * @param increment Increment size. |
| 1379 | * |
| 1380 | * @return The pool, or NULL when there's no memory. |
| 1381 | */ |
| 1382 | PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size, |
| 1383 | pj_size_t increment); |
| 1384 | |
| 1385 | |
| 1386 | /** |
| 1387 | * Application can call this function at any time (after pjsua_create(), of |
| 1388 | * course) to change logging settings. |
| 1389 | * |
| 1390 | * @param c Logging configuration. |
| 1391 | * |
| 1392 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1393 | */ |
| 1394 | PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c); |
| 1395 | |
| 1396 | |
| 1397 | /** |
| 1398 | * Internal function to get SIP endpoint instance of pjsua, which is |
| 1399 | * needed for example to register module, create transports, etc. |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1400 | * Only valid after #pjsua_init() is called. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1401 | * |
| 1402 | * @return SIP endpoint instance. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1403 | */ |
| 1404 | PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void); |
| 1405 | |
| 1406 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1407 | * Internal function to get media endpoint instance. |
| 1408 | * Only valid after #pjsua_init() is called. |
| 1409 | * |
| 1410 | * @return Media endpoint instance. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1411 | */ |
| 1412 | PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void); |
| 1413 | |
Benny Prijono | 97b8717 | 2006-08-24 14:25:14 +0000 | [diff] [blame] | 1414 | /** |
| 1415 | * Internal function to get PJSUA pool factory. |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1416 | * Only valid after #pjsua_create() is called. |
Benny Prijono | 97b8717 | 2006-08-24 14:25:14 +0000 | [diff] [blame] | 1417 | * |
| 1418 | * @return Pool factory currently used by PJSUA. |
| 1419 | */ |
| 1420 | PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void); |
| 1421 | |
| 1422 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1423 | |
| 1424 | /***************************************************************************** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1425 | * Utilities. |
| 1426 | * |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1427 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1428 | |
| 1429 | /** |
Benny Prijono | bb995fd | 2009-08-12 11:03:23 +0000 | [diff] [blame] | 1430 | * This structure is used to represent the result of the STUN server |
| 1431 | * resolution and testing, the #pjsua_resolve_stun_servers() function. |
| 1432 | * This structure will be passed in #pj_stun_resolve_cb callback. |
| 1433 | */ |
| 1434 | typedef struct pj_stun_resolve_result |
| 1435 | { |
| 1436 | /** |
| 1437 | * Arbitrary data that was passed to #pjsua_resolve_stun_servers() |
| 1438 | * function. |
| 1439 | */ |
| 1440 | void *token; |
| 1441 | |
| 1442 | /** |
| 1443 | * This will contain PJ_SUCCESS if at least one usable STUN server |
| 1444 | * is found, otherwise it will contain the last error code during |
| 1445 | * the operation. |
| 1446 | */ |
| 1447 | pj_status_t status; |
| 1448 | |
| 1449 | /** |
| 1450 | * The server name that yields successful result. This will only |
| 1451 | * contain value if status is successful. |
| 1452 | */ |
| 1453 | pj_str_t name; |
| 1454 | |
| 1455 | /** |
| 1456 | * The server IP address. This will only contain value if status |
| 1457 | * is successful. |
| 1458 | */ |
| 1459 | pj_sockaddr addr; |
| 1460 | |
| 1461 | } pj_stun_resolve_result; |
| 1462 | |
| 1463 | |
| 1464 | /** |
| 1465 | * Typedef of callback to be registered to #pjsua_resolve_stun_servers(). |
| 1466 | */ |
| 1467 | typedef void (*pj_stun_resolve_cb)(const pj_stun_resolve_result *result); |
| 1468 | |
| 1469 | /** |
Benny Prijono | 4ab9fbb | 2007-10-12 12:14:27 +0000 | [diff] [blame] | 1470 | * This is a utility function to detect NAT type in front of this |
| 1471 | * endpoint. Once invoked successfully, this function will complete |
Benny Prijono | 6ba8c54 | 2007-10-16 01:34:14 +0000 | [diff] [blame] | 1472 | * asynchronously and report the result in \a on_nat_detect() callback |
| 1473 | * of pjsua_callback. |
Benny Prijono | 4ab9fbb | 2007-10-12 12:14:27 +0000 | [diff] [blame] | 1474 | * |
Benny Prijono | 6ba8c54 | 2007-10-16 01:34:14 +0000 | [diff] [blame] | 1475 | * After NAT has been detected and the callback is called, application can |
| 1476 | * get the detected NAT type by calling #pjsua_get_nat_type(). Application |
| 1477 | * can also perform NAT detection by calling #pjsua_detect_nat_type() |
| 1478 | * again at later time. |
Benny Prijono | 4ab9fbb | 2007-10-12 12:14:27 +0000 | [diff] [blame] | 1479 | * |
Benny Prijono | 6ba8c54 | 2007-10-16 01:34:14 +0000 | [diff] [blame] | 1480 | * Note that STUN must be enabled to run this function successfully. |
| 1481 | * |
| 1482 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 4ab9fbb | 2007-10-12 12:14:27 +0000 | [diff] [blame] | 1483 | */ |
Benny Prijono | 6ba8c54 | 2007-10-16 01:34:14 +0000 | [diff] [blame] | 1484 | PJ_DECL(pj_status_t) pjsua_detect_nat_type(void); |
| 1485 | |
| 1486 | |
| 1487 | /** |
| 1488 | * Get the NAT type as detected by #pjsua_detect_nat_type() function. |
| 1489 | * This function will only return useful NAT type after #pjsua_detect_nat_type() |
| 1490 | * has completed successfully and \a on_nat_detect() callback has been called. |
| 1491 | * |
| 1492 | * @param type NAT type. |
| 1493 | * |
| 1494 | * @return When detection is in progress, this function will |
| 1495 | * return PJ_EPENDING and \a type will be set to |
| 1496 | * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been |
| 1497 | * detected successfully, this function will return |
| 1498 | * PJ_SUCCESS and \a type will be set to the correct |
| 1499 | * value. Other return values indicate error and |
| 1500 | * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN. |
Benny Prijono | 91a6a17 | 2007-10-31 08:59:29 +0000 | [diff] [blame] | 1501 | * |
| 1502 | * @see pjsua_call_get_rem_nat_type() |
Benny Prijono | 6ba8c54 | 2007-10-16 01:34:14 +0000 | [diff] [blame] | 1503 | */ |
| 1504 | PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type); |
Benny Prijono | 4ab9fbb | 2007-10-12 12:14:27 +0000 | [diff] [blame] | 1505 | |
| 1506 | |
| 1507 | /** |
Benny Prijono | bb995fd | 2009-08-12 11:03:23 +0000 | [diff] [blame] | 1508 | * Auxiliary function to resolve and contact each of the STUN server |
| 1509 | * entries (sequentially) to find which is usable. The #pjsua_init() must |
| 1510 | * have been called before calling this function. |
| 1511 | * |
| 1512 | * @param count Number of STUN server entries to try. |
| 1513 | * @param srv Array of STUN server entries to try. Please see |
| 1514 | * the \a stun_srv field in the #pjsua_config |
| 1515 | * documentation about the format of this entry. |
| 1516 | * @param wait Specify non-zero to make the function block until |
| 1517 | * it gets the result. In this case, the function |
| 1518 | * will block while the resolution is being done, |
| 1519 | * and the callback will be called before this function |
| 1520 | * returns. |
| 1521 | * @param token Arbitrary token to be passed back to application |
| 1522 | * in the callback. |
| 1523 | * @param cb Callback to be called to notify the result of |
| 1524 | * the function. |
| 1525 | * |
| 1526 | * @return If \a wait parameter is non-zero, this will return |
| 1527 | * PJ_SUCCESS if one usable STUN server is found. |
| 1528 | * Otherwise it will always return PJ_SUCCESS, and |
| 1529 | * application will be notified about the result in |
| 1530 | * the callback. |
| 1531 | */ |
| 1532 | PJ_DECL(pj_status_t) pjsua_resolve_stun_servers(unsigned count, |
| 1533 | pj_str_t srv[], |
| 1534 | pj_bool_t wait, |
| 1535 | void *token, |
| 1536 | pj_stun_resolve_cb cb); |
| 1537 | |
| 1538 | /** |
| 1539 | * Cancel pending STUN resolution which match the specified token. |
| 1540 | * |
| 1541 | * @param token The token to match. This token was given to |
| 1542 | * #pjsua_resolve_stun_servers() |
| 1543 | * @param notify_cb Boolean to control whether the callback should |
| 1544 | * be called for cancelled resolutions. When the |
| 1545 | * callback is called, the status in the result |
| 1546 | * will be set as PJ_ECANCELLED. |
| 1547 | * |
| 1548 | * @return PJ_SUCCESS if there is at least one pending STUN |
| 1549 | * resolution cancelled, or PJ_ENOTFOUND if there is |
| 1550 | * no matching one, or other error. |
| 1551 | */ |
| 1552 | PJ_DECL(pj_status_t) pjsua_cancel_stun_resolution(void *token, |
| 1553 | pj_bool_t notify_cb); |
| 1554 | |
| 1555 | |
| 1556 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1557 | * This is a utility function to verify that valid SIP url is given. If the |
Benny Prijono | c754578 | 2010-09-28 07:43:18 +0000 | [diff] [blame] | 1558 | * URL is a valid SIP/SIPS scheme, PJ_SUCCESS will be returned. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1559 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1560 | * @param url The URL, as NULL terminated string. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1561 | * |
| 1562 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | c754578 | 2010-09-28 07:43:18 +0000 | [diff] [blame] | 1563 | * |
| 1564 | * @see pjsua_verify_url() |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1565 | */ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1566 | PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1567 | |
| 1568 | |
| 1569 | /** |
Benny Prijono | c754578 | 2010-09-28 07:43:18 +0000 | [diff] [blame] | 1570 | * This is a utility function to verify that valid URI is given. Unlike |
| 1571 | * pjsua_verify_sip_url(), this function will return PJ_SUCCESS if tel: URI |
| 1572 | * is given. |
| 1573 | * |
| 1574 | * @param url The URL, as NULL terminated string. |
| 1575 | * |
| 1576 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1577 | * |
| 1578 | * @see pjsua_verify_sip_url() |
| 1579 | */ |
| 1580 | PJ_DECL(pj_status_t) pjsua_verify_url(const char *url); |
| 1581 | |
| 1582 | |
| 1583 | /** |
Benny Prijono | 73bb723 | 2009-10-20 13:56:26 +0000 | [diff] [blame] | 1584 | * Schedule a timer entry. Note that the timer callback may be executed |
| 1585 | * by different thread, depending on whether worker thread is enabled or |
| 1586 | * not. |
| 1587 | * |
| 1588 | * @param entry Timer heap entry. |
| 1589 | * @param delay The interval to expire. |
| 1590 | * |
| 1591 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1592 | * |
| 1593 | * @see pjsip_endpt_schedule_timer() |
| 1594 | */ |
| 1595 | PJ_DECL(pj_status_t) pjsua_schedule_timer(pj_timer_entry *entry, |
| 1596 | const pj_time_val *delay); |
| 1597 | |
| 1598 | |
| 1599 | /** |
| 1600 | * Cancel the previously scheduled timer. |
| 1601 | * |
| 1602 | * @param entry Timer heap entry. |
| 1603 | * |
| 1604 | * @see pjsip_endpt_cancel_timer() |
| 1605 | */ |
| 1606 | PJ_DECL(void) pjsua_cancel_timer(pj_timer_entry *entry); |
| 1607 | |
| 1608 | |
| 1609 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1610 | * This is a utility function to display error message for the specified |
| 1611 | * error code. The error message will be sent to the log. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1612 | * |
| 1613 | * @param sender The log sender field. |
| 1614 | * @param title Message title for the error. |
| 1615 | * @param status Status code. |
| 1616 | */ |
| 1617 | PJ_DECL(void) pjsua_perror(const char *sender, const char *title, |
| 1618 | pj_status_t status); |
| 1619 | |
| 1620 | |
Benny Prijono | da9785b | 2007-04-02 20:43:06 +0000 | [diff] [blame] | 1621 | /** |
| 1622 | * This is a utility function to dump the stack states to log, using |
| 1623 | * verbosity level 3. |
| 1624 | * |
| 1625 | * @param detail Will print detailed output (such as list of |
| 1626 | * SIP transactions) when non-zero. |
| 1627 | */ |
| 1628 | PJ_DECL(void) pjsua_dump(pj_bool_t detail); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1629 | |
| 1630 | /** |
| 1631 | * @} |
| 1632 | */ |
| 1633 | |
| 1634 | |
| 1635 | |
| 1636 | /***************************************************************************** |
| 1637 | * TRANSPORT API |
| 1638 | */ |
| 1639 | |
| 1640 | /** |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1641 | * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1642 | * @ingroup PJSUA_LIB |
| 1643 | * @brief API for managing SIP transports |
| 1644 | * @{ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1645 | * |
| 1646 | * PJSUA-API supports creating multiple transport instances, for example UDP, |
| 1647 | * TCP, and TLS transport. SIP transport must be created before adding an |
| 1648 | * account. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1649 | */ |
| 1650 | |
| 1651 | |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1652 | /** SIP transport identification. |
| 1653 | */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1654 | typedef int pjsua_transport_id; |
| 1655 | |
| 1656 | |
| 1657 | /** |
Benny Prijono | 0a5cad8 | 2006-09-26 13:21:02 +0000 | [diff] [blame] | 1658 | * Transport configuration for creating transports for both SIP |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1659 | * and media. Before setting some values to this structure, application |
| 1660 | * MUST call #pjsua_transport_config_default() to initialize its |
| 1661 | * values with default settings. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1662 | */ |
| 1663 | typedef struct pjsua_transport_config |
| 1664 | { |
| 1665 | /** |
| 1666 | * UDP port number to bind locally. This setting MUST be specified |
| 1667 | * even when default port is desired. If the value is zero, the |
| 1668 | * transport will be bound to any available port, and application |
| 1669 | * can query the port by querying the transport info. |
| 1670 | */ |
| 1671 | unsigned port; |
| 1672 | |
| 1673 | /** |
Benny Prijono | 0a5cad8 | 2006-09-26 13:21:02 +0000 | [diff] [blame] | 1674 | * Optional address to advertise as the address of this transport. |
| 1675 | * Application can specify any address or hostname for this field, |
| 1676 | * for example it can point to one of the interface address in the |
| 1677 | * system, or it can point to the public address of a NAT router |
| 1678 | * where port mappings have been configured for the application. |
| 1679 | * |
| 1680 | * Note: this option can be used for both UDP and TCP as well! |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1681 | */ |
Benny Prijono | 0a5cad8 | 2006-09-26 13:21:02 +0000 | [diff] [blame] | 1682 | pj_str_t public_addr; |
| 1683 | |
| 1684 | /** |
| 1685 | * Optional address where the socket should be bound to. This option |
| 1686 | * SHOULD only be used to selectively bind the socket to particular |
| 1687 | * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the |
| 1688 | * published address of a transport (the public_addr field should be |
| 1689 | * used for that purpose). |
| 1690 | * |
| 1691 | * Note that unlike public_addr field, the address (or hostname) here |
| 1692 | * MUST correspond to the actual interface address in the host, since |
| 1693 | * this address will be specified as bind() argument. |
| 1694 | */ |
| 1695 | pj_str_t bound_addr; |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1696 | |
| 1697 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1698 | * This specifies TLS settings for TLS transport. It is only be used |
| 1699 | * when this transport config is being used to create a SIP TLS |
| 1700 | * transport. |
Benny Prijono | 6e0e54b | 2006-12-08 21:58:31 +0000 | [diff] [blame] | 1701 | */ |
Benny Prijono | f3bbc13 | 2006-12-25 06:43:59 +0000 | [diff] [blame] | 1702 | pjsip_tls_setting tls_setting; |
Benny Prijono | 6e0e54b | 2006-12-08 21:58:31 +0000 | [diff] [blame] | 1703 | |
Benny Prijono | 4d79b0f | 2009-10-25 09:02:07 +0000 | [diff] [blame] | 1704 | /** |
| 1705 | * QoS traffic type to be set on this transport. When application wants |
| 1706 | * to apply QoS tagging to the transport, it's preferable to set this |
| 1707 | * field rather than \a qos_param fields since this is more portable. |
| 1708 | * |
| 1709 | * Default is QoS not set. |
| 1710 | */ |
| 1711 | pj_qos_type qos_type; |
| 1712 | |
| 1713 | /** |
| 1714 | * Set the low level QoS parameters to the transport. This is a lower |
| 1715 | * level operation than setting the \a qos_type field and may not be |
| 1716 | * supported on all platforms. |
| 1717 | * |
| 1718 | * Default is QoS not set. |
| 1719 | */ |
| 1720 | pj_qos_params qos_params; |
| 1721 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1722 | } pjsua_transport_config; |
| 1723 | |
| 1724 | |
| 1725 | /** |
| 1726 | * Call this function to initialize UDP config with default values. |
| 1727 | * |
| 1728 | * @param cfg The UDP config to be initialized. |
| 1729 | */ |
Benny Prijono | 1f61a8f | 2007-08-16 10:11:44 +0000 | [diff] [blame] | 1730 | PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1731 | |
| 1732 | |
| 1733 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1734 | * Duplicate transport config. |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1735 | * |
| 1736 | * @param pool The pool. |
| 1737 | * @param dst The destination config. |
| 1738 | * @param src The source config. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1739 | */ |
Benny Prijono | 1f61a8f | 2007-08-16 10:11:44 +0000 | [diff] [blame] | 1740 | PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool, |
| 1741 | pjsua_transport_config *dst, |
| 1742 | const pjsua_transport_config *src); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1743 | |
| 1744 | |
| 1745 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1746 | * This structure describes transport information returned by |
| 1747 | * #pjsua_transport_get_info() function. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1748 | */ |
| 1749 | typedef struct pjsua_transport_info |
| 1750 | { |
| 1751 | /** |
| 1752 | * PJSUA transport identification. |
| 1753 | */ |
| 1754 | pjsua_transport_id id; |
| 1755 | |
| 1756 | /** |
| 1757 | * Transport type. |
| 1758 | */ |
| 1759 | pjsip_transport_type_e type; |
| 1760 | |
| 1761 | /** |
| 1762 | * Transport type name. |
| 1763 | */ |
| 1764 | pj_str_t type_name; |
| 1765 | |
| 1766 | /** |
| 1767 | * Transport string info/description. |
| 1768 | */ |
| 1769 | pj_str_t info; |
| 1770 | |
| 1771 | /** |
| 1772 | * Transport flag (see ##pjsip_transport_flags_e). |
| 1773 | */ |
| 1774 | unsigned flag; |
| 1775 | |
| 1776 | /** |
| 1777 | * Local address length. |
| 1778 | */ |
| 1779 | unsigned addr_len; |
| 1780 | |
| 1781 | /** |
| 1782 | * Local/bound address. |
| 1783 | */ |
| 1784 | pj_sockaddr local_addr; |
| 1785 | |
| 1786 | /** |
| 1787 | * Published address (or transport address name). |
| 1788 | */ |
| 1789 | pjsip_host_port local_name; |
| 1790 | |
| 1791 | /** |
| 1792 | * Current number of objects currently referencing this transport. |
| 1793 | */ |
| 1794 | unsigned usage_count; |
| 1795 | |
| 1796 | |
| 1797 | } pjsua_transport_info; |
| 1798 | |
| 1799 | |
| 1800 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1801 | * Create and start a new SIP transport according to the specified |
| 1802 | * settings. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1803 | * |
| 1804 | * @param type Transport type. |
| 1805 | * @param cfg Transport configuration. |
| 1806 | * @param p_id Optional pointer to receive transport ID. |
| 1807 | * |
| 1808 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1809 | */ |
| 1810 | PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type, |
| 1811 | const pjsua_transport_config *cfg, |
| 1812 | pjsua_transport_id *p_id); |
| 1813 | |
| 1814 | /** |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1815 | * Register transport that has been created by application. This function |
| 1816 | * is useful if application wants to implement custom SIP transport and use |
| 1817 | * it with pjsua. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1818 | * |
| 1819 | * @param tp Transport instance. |
| 1820 | * @param p_id Optional pointer to receive transport ID. |
| 1821 | * |
| 1822 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1823 | */ |
| 1824 | PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp, |
| 1825 | pjsua_transport_id *p_id); |
| 1826 | |
| 1827 | |
| 1828 | /** |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1829 | * Enumerate all transports currently created in the system. This function |
| 1830 | * will return all transport IDs, and application may then call |
| 1831 | * #pjsua_transport_get_info() function to retrieve detailed information |
| 1832 | * about the transport. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1833 | * |
| 1834 | * @param id Array to receive transport ids. |
| 1835 | * @param count In input, specifies the maximum number of elements. |
| 1836 | * On return, it contains the actual number of elements. |
| 1837 | * |
| 1838 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1839 | */ |
| 1840 | PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[], |
| 1841 | unsigned *count ); |
| 1842 | |
| 1843 | |
| 1844 | /** |
| 1845 | * Get information about transports. |
| 1846 | * |
| 1847 | * @param id Transport ID. |
| 1848 | * @param info Pointer to receive transport info. |
| 1849 | * |
| 1850 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1851 | */ |
| 1852 | PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id, |
| 1853 | pjsua_transport_info *info); |
| 1854 | |
| 1855 | |
| 1856 | /** |
| 1857 | * Disable a transport or re-enable it. By default transport is always |
| 1858 | * enabled after it is created. Disabling a transport does not necessarily |
| 1859 | * close the socket, it will only discard incoming messages and prevent |
| 1860 | * the transport from being used to send outgoing messages. |
| 1861 | * |
| 1862 | * @param id Transport ID. |
| 1863 | * @param enabled Non-zero to enable, zero to disable. |
| 1864 | * |
| 1865 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1866 | */ |
| 1867 | PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id, |
| 1868 | pj_bool_t enabled); |
| 1869 | |
| 1870 | |
| 1871 | /** |
| 1872 | * Close the transport. If transport is forcefully closed, it will be |
| 1873 | * immediately closed, and any pending transactions that are using the |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1874 | * transport may not terminate properly (it may even crash). Otherwise, |
| 1875 | * the system will wait until all transactions are closed while preventing |
| 1876 | * new users from using the transport, and will close the transport when |
| 1877 | * it is safe to do so. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1878 | * |
| 1879 | * @param id Transport ID. |
| 1880 | * @param force Non-zero to immediately close the transport. This |
| 1881 | * is not recommended! |
| 1882 | * |
| 1883 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1884 | */ |
| 1885 | PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id, |
| 1886 | pj_bool_t force ); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1887 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1888 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1889 | * @} |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1890 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1891 | |
| 1892 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1893 | |
| 1894 | |
| 1895 | /***************************************************************************** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1896 | * ACCOUNT API |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 1897 | */ |
| 1898 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1899 | |
| 1900 | /** |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1901 | * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1902 | * @ingroup PJSUA_LIB |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1903 | * @brief PJSUA Accounts management |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1904 | * @{ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1905 | * |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1906 | * PJSUA accounts provide identity (or identities) of the user who is currently |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1907 | * using the application. In SIP terms, the identity is used as the <b>From</b> |
| 1908 | * header in outgoing requests. |
| 1909 | * |
| 1910 | * PJSUA-API supports creating and managing multiple accounts. The maximum |
| 1911 | * number of accounts is limited by a compile time constant |
| 1912 | * <tt>PJSUA_MAX_ACC</tt>. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1913 | * |
| 1914 | * Account may or may not have client registration associated with it. |
| 1915 | * An account is also associated with <b>route set</b> and some <b>authentication |
| 1916 | * credentials</b>, which are used when sending SIP request messages using the |
| 1917 | * account. An account also has presence's <b>online status</b>, which |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1918 | * will be reported to remote peer when they subscribe to the account's |
| 1919 | * presence, or which is published to a presence server if presence |
| 1920 | * publication is enabled for the account. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1921 | * |
| 1922 | * At least one account MUST be created in the application. If no user |
| 1923 | * association is required, application can create a userless account by |
| 1924 | * calling #pjsua_acc_add_local(). A userless account identifies local endpoint |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1925 | * instead of a particular user, and it correspond with a particular |
| 1926 | * transport instance. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1927 | * |
| 1928 | * Also one account must be set as the <b>default account</b>, which is used as |
| 1929 | * the account to use when PJSUA fails to match a request with any other |
| 1930 | * accounts. |
| 1931 | * |
| 1932 | * When sending outgoing SIP requests (such as making calls or sending |
| 1933 | * instant messages), normally PJSUA requires the application to specify |
| 1934 | * which account to use for the request. If no account is specified, |
| 1935 | * PJSUA may be able to select the account by matching the destination |
| 1936 | * domain name, and fall back to default account when no match is found. |
| 1937 | */ |
| 1938 | |
| 1939 | /** |
| 1940 | * Maximum accounts. |
| 1941 | */ |
| 1942 | #ifndef PJSUA_MAX_ACC |
| 1943 | # define PJSUA_MAX_ACC 8 |
| 1944 | #endif |
| 1945 | |
| 1946 | |
| 1947 | /** |
| 1948 | * Default registration interval. |
| 1949 | */ |
| 1950 | #ifndef PJSUA_REG_INTERVAL |
Benny Prijono | bddef2c | 2007-10-31 13:28:08 +0000 | [diff] [blame] | 1951 | # define PJSUA_REG_INTERVAL 300 |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1952 | #endif |
| 1953 | |
| 1954 | |
| 1955 | /** |
Benny Prijono | 384dab4 | 2009-10-14 01:58:04 +0000 | [diff] [blame] | 1956 | * Default maximum time to wait for account unregistration transactions to |
| 1957 | * complete during library shutdown sequence. |
| 1958 | * |
| 1959 | * Default: 4000 (4 seconds) |
| 1960 | */ |
| 1961 | #ifndef PJSUA_UNREG_TIMEOUT |
| 1962 | # define PJSUA_UNREG_TIMEOUT 4000 |
| 1963 | #endif |
| 1964 | |
| 1965 | |
| 1966 | /** |
Benny Prijono | 3a5e1ab | 2006-08-15 20:26:34 +0000 | [diff] [blame] | 1967 | * Default PUBLISH expiration |
| 1968 | */ |
| 1969 | #ifndef PJSUA_PUBLISH_EXPIRATION |
Benny Prijono | 53984d1 | 2009-04-28 22:19:49 +0000 | [diff] [blame] | 1970 | # define PJSUA_PUBLISH_EXPIRATION PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED |
Benny Prijono | 3a5e1ab | 2006-08-15 20:26:34 +0000 | [diff] [blame] | 1971 | #endif |
| 1972 | |
| 1973 | |
| 1974 | /** |
Benny Prijono | 093d302 | 2006-09-24 00:07:11 +0000 | [diff] [blame] | 1975 | * Default account priority. |
| 1976 | */ |
| 1977 | #ifndef PJSUA_DEFAULT_ACC_PRIORITY |
| 1978 | # define PJSUA_DEFAULT_ACC_PRIORITY 0 |
| 1979 | #endif |
| 1980 | |
| 1981 | |
| 1982 | /** |
Benny Prijono | 8058a62 | 2007-06-08 04:37:05 +0000 | [diff] [blame] | 1983 | * This macro specifies the URI scheme to use in Contact header |
| 1984 | * when secure transport such as TLS is used. Application can specify |
| 1985 | * either "sip" or "sips". |
| 1986 | */ |
| 1987 | #ifndef PJSUA_SECURE_SCHEME |
Benny Prijono | 4c82c1e | 2008-10-16 08:14:51 +0000 | [diff] [blame] | 1988 | # define PJSUA_SECURE_SCHEME "sip" |
Benny Prijono | 8058a62 | 2007-06-08 04:37:05 +0000 | [diff] [blame] | 1989 | #endif |
| 1990 | |
| 1991 | |
| 1992 | /** |
Benny Prijono | 534a9ba | 2009-10-13 14:01:59 +0000 | [diff] [blame] | 1993 | * Maximum time to wait for unpublication transaction(s) to complete |
| 1994 | * during shutdown process, before sending unregistration. The library |
| 1995 | * tries to wait for the unpublication (un-PUBLISH) to complete before |
| 1996 | * sending REGISTER request to unregister the account, during library |
| 1997 | * shutdown process. If the value is set too short, it is possible that |
| 1998 | * the unregistration is sent before unpublication completes, causing |
| 1999 | * unpublication request to fail. |
| 2000 | * |
| 2001 | * Default: 2000 (2 seconds) |
| 2002 | */ |
| 2003 | #ifndef PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC |
| 2004 | # define PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC 2000 |
| 2005 | #endif |
| 2006 | |
| 2007 | |
| 2008 | /** |
Nanang Izzuddin | 36dd5b6 | 2010-03-30 11:13:59 +0000 | [diff] [blame] | 2009 | * Default auto retry re-registration interval, in seconds. Set to 0 |
| 2010 | * to disable this. Application can set the timer on per account basis |
| 2011 | * by setting the pjsua_acc_config.reg_retry_interval field instead. |
| 2012 | * |
| 2013 | * Default: 300 (5 minutes) |
| 2014 | */ |
| 2015 | #ifndef PJSUA_REG_RETRY_INTERVAL |
| 2016 | # define PJSUA_REG_RETRY_INTERVAL 300 |
| 2017 | #endif |
| 2018 | |
| 2019 | |
| 2020 | /** |
Benny Prijono | c6d5fdc | 2010-06-20 08:58:26 +0000 | [diff] [blame] | 2021 | * This macro specifies the default value for \a contact_rewrite_method |
| 2022 | * field in pjsua_acc_config. I specifies how Contact update will be |
| 2023 | * done with the registration, if \a allow_contact_rewrite is enabled in |
| 2024 | * the account config. |
| 2025 | * |
| 2026 | * If set to 1, the Contact update will be done by sending unregistration |
| 2027 | * to the currently registered Contact, while simultaneously sending new |
| 2028 | * registration (with different Call-ID) for the updated Contact. |
| 2029 | * |
| 2030 | * If set to 2, the Contact update will be done in a single, current |
| 2031 | * registration session, by removing the current binding (by setting its |
| 2032 | * Contact's expires parameter to zero) and adding a new Contact binding, |
| 2033 | * all done in a single request. |
| 2034 | * |
| 2035 | * Value 1 is the legacy behavior. |
| 2036 | * |
| 2037 | * Default value: 2 |
| 2038 | */ |
| 2039 | #ifndef PJSUA_CONTACT_REWRITE_METHOD |
| 2040 | # define PJSUA_CONTACT_REWRITE_METHOD 2 |
| 2041 | #endif |
| 2042 | |
| 2043 | |
| 2044 | /** |
Benny Prijono | 29c8ca3 | 2010-06-22 06:02:13 +0000 | [diff] [blame] | 2045 | * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that |
| 2046 | * the global outbound proxy list should be added to the REGISTER request. |
| 2047 | */ |
| 2048 | #define PJSUA_REG_USE_OUTBOUND_PROXY 1 |
| 2049 | |
| 2050 | |
| 2051 | /** |
| 2052 | * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that |
| 2053 | * the account proxy list should be added to the REGISTER request. |
| 2054 | */ |
| 2055 | #define PJSUA_REG_USE_ACC_PROXY 2 |
| 2056 | |
| 2057 | |
| 2058 | /** |
Benny Prijono | dd63b99 | 2010-10-01 02:03:42 +0000 | [diff] [blame] | 2059 | * This enumeration specifies how we should offer call hold request to |
| 2060 | * remote peer. The default value is set by compile time constant |
| 2061 | * PJSUA_CALL_HOLD_TYPE_DEFAULT, and application may control the setting |
| 2062 | * on per-account basis by manipulating \a call_hold_type field in |
| 2063 | * #pjsua_acc_config. |
| 2064 | */ |
| 2065 | typedef enum pjsua_call_hold_type |
| 2066 | { |
| 2067 | /** |
| 2068 | * This will follow RFC 3264 recommendation to use a=sendonly, |
| 2069 | * a=recvonly, and a=inactive attribute as means to signal call |
| 2070 | * hold status. This is the correct value to use. |
| 2071 | */ |
| 2072 | PJSUA_CALL_HOLD_TYPE_RFC3264, |
| 2073 | |
| 2074 | /** |
| 2075 | * This will use the old and deprecated method as specified in RFC 2543, |
| 2076 | * and will offer c=0.0.0.0 in the SDP instead. Using this has many |
| 2077 | * drawbacks such as inability to keep the media transport alive while |
| 2078 | * the call is being put on hold, and should only be used if remote |
| 2079 | * does not understand RFC 3264 style call hold offer. |
| 2080 | */ |
| 2081 | PJSUA_CALL_HOLD_TYPE_RFC2543 |
| 2082 | |
| 2083 | } pjsua_call_hold_type; |
| 2084 | |
| 2085 | |
| 2086 | /** |
| 2087 | * Specify the default call hold type to be used in #pjsua_acc_config. |
| 2088 | * |
| 2089 | * Default is PJSUA_CALL_HOLD_TYPE_RFC3264, and there's no reason to change |
| 2090 | * this except if you're communicating with an old/non-standard peer. |
| 2091 | */ |
| 2092 | #ifndef PJSUA_CALL_HOLD_TYPE_DEFAULT |
| 2093 | # define PJSUA_CALL_HOLD_TYPE_DEFAULT PJSUA_CALL_HOLD_TYPE_RFC3264 |
| 2094 | #endif |
| 2095 | |
| 2096 | |
| 2097 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2098 | * This structure describes account configuration to be specified when |
| 2099 | * adding a new account with #pjsua_acc_add(). Application MUST initialize |
| 2100 | * this structure first by calling #pjsua_acc_config_default(). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2101 | */ |
| 2102 | typedef struct pjsua_acc_config |
| 2103 | { |
Benny Prijono | 093d302 | 2006-09-24 00:07:11 +0000 | [diff] [blame] | 2104 | /** |
Benny Prijono | 705e784 | 2008-07-21 18:12:51 +0000 | [diff] [blame] | 2105 | * Arbitrary user data to be associated with the newly created account. |
| 2106 | * Application may set this later with #pjsua_acc_set_user_data() and |
| 2107 | * retrieve it with #pjsua_acc_get_user_data(). |
| 2108 | */ |
| 2109 | void *user_data; |
| 2110 | |
| 2111 | /** |
Benny Prijono | 093d302 | 2006-09-24 00:07:11 +0000 | [diff] [blame] | 2112 | * Account priority, which is used to control the order of matching |
| 2113 | * incoming/outgoing requests. The higher the number means the higher |
| 2114 | * the priority is, and the account will be matched first. |
| 2115 | */ |
| 2116 | int priority; |
| 2117 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2118 | /** |
| 2119 | * The full SIP URL for the account. The value can take name address or |
| 2120 | * URL format, and will look something like "sip:account@serviceprovider". |
| 2121 | * |
| 2122 | * This field is mandatory. |
| 2123 | */ |
| 2124 | pj_str_t id; |
| 2125 | |
| 2126 | /** |
| 2127 | * This is the URL to be put in the request URI for the registration, |
| 2128 | * and will look something like "sip:serviceprovider". |
| 2129 | * |
| 2130 | * This field should be specified if registration is desired. If the |
| 2131 | * value is empty, no account registration will be performed. |
| 2132 | */ |
| 2133 | pj_str_t reg_uri; |
| 2134 | |
Nanang Izzuddin | 60e8aa9 | 2010-09-28 10:48:48 +0000 | [diff] [blame] | 2135 | /** |
| 2136 | * The optional custom SIP headers to be put in the registration |
| 2137 | * request. |
| 2138 | */ |
| 2139 | pjsip_hdr reg_hdr_list; |
| 2140 | |
Benny Prijono | 3a5e1ab | 2006-08-15 20:26:34 +0000 | [diff] [blame] | 2141 | /** |
Benny Prijono | fe1bd34 | 2009-11-20 23:33:07 +0000 | [diff] [blame] | 2142 | * Subscribe to message waiting indication events (RFC 3842). |
| 2143 | * |
| 2144 | * See also \a enable_unsolicited_mwi field on #pjsua_config. |
Benny Prijono | 4dd961b | 2009-10-26 11:21:37 +0000 | [diff] [blame] | 2145 | * |
| 2146 | * Default: no |
| 2147 | */ |
| 2148 | pj_bool_t mwi_enabled; |
| 2149 | |
| 2150 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2151 | * If this flag is set, the presence information of this account will |
| 2152 | * be PUBLISH-ed to the server where the account belongs. |
Benny Prijono | 48ab2b7 | 2007-11-08 09:24:30 +0000 | [diff] [blame] | 2153 | * |
| 2154 | * Default: PJ_FALSE |
Benny Prijono | 3a5e1ab | 2006-08-15 20:26:34 +0000 | [diff] [blame] | 2155 | */ |
| 2156 | pj_bool_t publish_enabled; |
| 2157 | |
Benny Prijono | fe04fb5 | 2007-08-24 08:28:52 +0000 | [diff] [blame] | 2158 | /** |
Benny Prijono | fe50c9e | 2009-10-12 07:44:14 +0000 | [diff] [blame] | 2159 | * Event publication options. |
| 2160 | */ |
| 2161 | pjsip_publishc_opt publish_opt; |
| 2162 | |
| 2163 | /** |
Benny Prijono | 534a9ba | 2009-10-13 14:01:59 +0000 | [diff] [blame] | 2164 | * Maximum time to wait for unpublication transaction(s) to complete |
| 2165 | * during shutdown process, before sending unregistration. The library |
| 2166 | * tries to wait for the unpublication (un-PUBLISH) to complete before |
| 2167 | * sending REGISTER request to unregister the account, during library |
| 2168 | * shutdown process. If the value is set too short, it is possible that |
| 2169 | * the unregistration is sent before unpublication completes, causing |
| 2170 | * unpublication request to fail. |
| 2171 | * |
| 2172 | * Default: PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC |
| 2173 | */ |
| 2174 | unsigned unpublish_max_wait_time_msec; |
| 2175 | |
| 2176 | /** |
Benny Prijono | 48ab2b7 | 2007-11-08 09:24:30 +0000 | [diff] [blame] | 2177 | * Authentication preference. |
| 2178 | */ |
| 2179 | pjsip_auth_clt_pref auth_pref; |
| 2180 | |
| 2181 | /** |
Benny Prijono | fe04fb5 | 2007-08-24 08:28:52 +0000 | [diff] [blame] | 2182 | * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value |
| 2183 | * is not specified, a random string will be used. |
| 2184 | */ |
| 2185 | pj_str_t pidf_tuple_id; |
| 2186 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2187 | /** |
| 2188 | * Optional URI to be put as Contact for this account. It is recommended |
| 2189 | * that this field is left empty, so that the value will be calculated |
| 2190 | * automatically based on the transport address. |
| 2191 | */ |
Benny Prijono | b4a17c9 | 2006-07-10 14:40:21 +0000 | [diff] [blame] | 2192 | pj_str_t force_contact; |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2193 | |
| 2194 | /** |
Nanang Izzuddin | e2c7e85 | 2009-08-04 14:36:17 +0000 | [diff] [blame] | 2195 | * Additional parameters that will be appended in the Contact header |
Benny Prijono | 30fe485 | 2008-12-10 16:54:16 +0000 | [diff] [blame] | 2196 | * for this account. This will affect the Contact header in all SIP |
| 2197 | * messages sent on behalf of this account, including but not limited to |
| 2198 | * REGISTER, INVITE, and SUBCRIBE requests or responses. |
| 2199 | * |
| 2200 | * The parameters should be preceeded by semicolon, and all strings must |
| 2201 | * be properly escaped. Example: |
| 2202 | * ";my-param=X;another-param=Hi%20there" |
| 2203 | */ |
| 2204 | pj_str_t contact_params; |
| 2205 | |
| 2206 | /** |
Nanang Izzuddin | e2c7e85 | 2009-08-04 14:36:17 +0000 | [diff] [blame] | 2207 | * Additional URI parameters that will be appended in the Contact URI |
| 2208 | * for this account. This will affect the Contact URI in all SIP |
| 2209 | * messages sent on behalf of this account, including but not limited to |
| 2210 | * REGISTER, INVITE, and SUBCRIBE requests or responses. |
| 2211 | * |
| 2212 | * The parameters should be preceeded by semicolon, and all strings must |
| 2213 | * be properly escaped. Example: |
| 2214 | * ";my-param=X;another-param=Hi%20there" |
| 2215 | */ |
| 2216 | pj_str_t contact_uri_params; |
| 2217 | |
| 2218 | /** |
Benny Prijono | dcfc0ba | 2007-09-30 16:50:27 +0000 | [diff] [blame] | 2219 | * Specify whether support for reliable provisional response (100rel and |
| 2220 | * PRACK) should be required for all sessions of this account. |
| 2221 | * |
| 2222 | * Default: PJ_FALSE |
| 2223 | */ |
| 2224 | pj_bool_t require_100rel; |
| 2225 | |
| 2226 | /** |
Nanang Izzuddin | 742ef4b | 2010-09-07 09:36:15 +0000 | [diff] [blame] | 2227 | * Specify the usage of Session Timers for all sessions. See the |
| 2228 | * #pjsua_sip_timer_use for possible values. |
Nanang Izzuddin | 59dffb1 | 2009-08-11 12:42:38 +0000 | [diff] [blame] | 2229 | * |
Nanang Izzuddin | 742ef4b | 2010-09-07 09:36:15 +0000 | [diff] [blame] | 2230 | * Default: PJSUA_SIP_TIMER_OPTIONAL |
Nanang Izzuddin | 59dffb1 | 2009-08-11 12:42:38 +0000 | [diff] [blame] | 2231 | */ |
Nanang Izzuddin | 742ef4b | 2010-09-07 09:36:15 +0000 | [diff] [blame] | 2232 | pjsua_sip_timer_use use_timer; |
Nanang Izzuddin | 59dffb1 | 2009-08-11 12:42:38 +0000 | [diff] [blame] | 2233 | |
| 2234 | /** |
Nanang Izzuddin | 65add62 | 2009-08-11 16:26:20 +0000 | [diff] [blame] | 2235 | * Specify Session Timer settings, see #pjsip_timer_setting. |
Nanang Izzuddin | 59dffb1 | 2009-08-11 12:42:38 +0000 | [diff] [blame] | 2236 | */ |
Nanang Izzuddin | 65add62 | 2009-08-11 16:26:20 +0000 | [diff] [blame] | 2237 | pjsip_timer_setting timer_setting; |
Nanang Izzuddin | 59dffb1 | 2009-08-11 12:42:38 +0000 | [diff] [blame] | 2238 | |
| 2239 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2240 | * Number of proxies in the proxy array below. |
| 2241 | */ |
| 2242 | unsigned proxy_cnt; |
| 2243 | |
| 2244 | /** |
| 2245 | * Optional URI of the proxies to be visited for all outgoing requests |
| 2246 | * that are using this account (REGISTER, INVITE, etc). Application need |
| 2247 | * to specify these proxies if the service provider requires that requests |
| 2248 | * destined towards its network should go through certain proxies first |
| 2249 | * (for example, border controllers). |
| 2250 | * |
| 2251 | * These proxies will be put in the route set for this account, with |
| 2252 | * maintaining the orders (the first proxy in the array will be visited |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2253 | * first). If global outbound proxies are configured in pjsua_config, |
| 2254 | * then these account proxies will be placed after the global outbound |
| 2255 | * proxies in the routeset. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2256 | */ |
| 2257 | pj_str_t proxy[PJSUA_ACC_MAX_PROXIES]; |
| 2258 | |
| 2259 | /** |
| 2260 | * Optional interval for registration, in seconds. If the value is zero, |
Benny Prijono | bddef2c | 2007-10-31 13:28:08 +0000 | [diff] [blame] | 2261 | * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2262 | */ |
| 2263 | unsigned reg_timeout; |
| 2264 | |
Benny Prijono | 384dab4 | 2009-10-14 01:58:04 +0000 | [diff] [blame] | 2265 | /** |
| 2266 | * Specify the maximum time to wait for unregistration requests to |
| 2267 | * complete during library shutdown sequence. |
| 2268 | * |
| 2269 | * Default: PJSUA_UNREG_TIMEOUT |
| 2270 | */ |
| 2271 | unsigned unreg_timeout; |
| 2272 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2273 | /** |
| 2274 | * Number of credentials in the credential array. |
| 2275 | */ |
| 2276 | unsigned cred_count; |
| 2277 | |
| 2278 | /** |
| 2279 | * Array of credentials. If registration is desired, normally there should |
| 2280 | * be at least one credential specified, to successfully authenticate |
| 2281 | * against the service provider. More credentials can be specified, for |
| 2282 | * example when the requests are expected to be challenged by the |
| 2283 | * proxies in the route set. |
| 2284 | */ |
| 2285 | pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES]; |
| 2286 | |
Benny Prijono | 62c5c5b | 2007-01-13 23:22:40 +0000 | [diff] [blame] | 2287 | /** |
| 2288 | * Optionally bind this account to specific transport. This normally is |
| 2289 | * not a good idea, as account should be able to send requests using |
| 2290 | * any available transports according to the destination. But some |
| 2291 | * application may want to have explicit control over the transport to |
| 2292 | * use, so in that case it can set this field. |
| 2293 | * |
| 2294 | * Default: -1 (PJSUA_INVALID_ID) |
| 2295 | * |
| 2296 | * @see pjsua_acc_set_transport() |
| 2297 | */ |
| 2298 | pjsua_transport_id transport_id; |
| 2299 | |
Benny Prijono | 15b0230 | 2007-09-27 14:07:07 +0000 | [diff] [blame] | 2300 | /** |
Benny Prijono | cca2e43 | 2010-02-25 09:33:18 +0000 | [diff] [blame] | 2301 | * This option is used to update the transport address and the Contact |
Benny Prijono | e8554ef | 2008-03-22 09:33:52 +0000 | [diff] [blame] | 2302 | * header of REGISTER request. When this option is enabled, the library |
| 2303 | * will keep track of the public IP address from the response of REGISTER |
| 2304 | * request. Once it detects that the address has changed, it will |
| 2305 | * unregister current Contact, update the Contact with transport address |
| 2306 | * learned from Via header, and register a new Contact to the registrar. |
| 2307 | * This will also update the public name of UDP transport if STUN is |
Benny Prijono | cca2e43 | 2010-02-25 09:33:18 +0000 | [diff] [blame] | 2308 | * configured. |
Benny Prijono | 15b0230 | 2007-09-27 14:07:07 +0000 | [diff] [blame] | 2309 | * |
Benny Prijono | c6d5fdc | 2010-06-20 08:58:26 +0000 | [diff] [blame] | 2310 | * See also contact_rewrite_method field. |
| 2311 | * |
Benny Prijono | 15b0230 | 2007-09-27 14:07:07 +0000 | [diff] [blame] | 2312 | * Default: 1 (yes) |
| 2313 | */ |
Benny Prijono | e8554ef | 2008-03-22 09:33:52 +0000 | [diff] [blame] | 2314 | pj_bool_t allow_contact_rewrite; |
Benny Prijono | 15b0230 | 2007-09-27 14:07:07 +0000 | [diff] [blame] | 2315 | |
Benny Prijono | bddef2c | 2007-10-31 13:28:08 +0000 | [diff] [blame] | 2316 | /** |
Benny Prijono | c6d5fdc | 2010-06-20 08:58:26 +0000 | [diff] [blame] | 2317 | * Specify how Contact update will be done with the registration, if |
| 2318 | * \a allow_contact_rewrite is enabled. |
| 2319 | * |
| 2320 | * If set to 1, the Contact update will be done by sending unregistration |
| 2321 | * to the currently registered Contact, while simultaneously sending new |
| 2322 | * registration (with different Call-ID) for the updated Contact. |
| 2323 | * |
| 2324 | * If set to 2, the Contact update will be done in a single, current |
| 2325 | * registration session, by removing the current binding (by setting its |
| 2326 | * Contact's expires parameter to zero) and adding a new Contact binding, |
| 2327 | * all done in a single request. |
| 2328 | * |
| 2329 | * Value 1 is the legacy behavior. |
| 2330 | * |
| 2331 | * Default value: PJSUA_CONTACT_REWRITE_METHOD (2) |
| 2332 | */ |
| 2333 | int contact_rewrite_method; |
| 2334 | |
| 2335 | /** |
Benny Prijono | bddef2c | 2007-10-31 13:28:08 +0000 | [diff] [blame] | 2336 | * Set the interval for periodic keep-alive transmission for this account. |
| 2337 | * If this value is zero, keep-alive will be disabled for this account. |
| 2338 | * The keep-alive transmission will be sent to the registrar's address, |
| 2339 | * after successful registration. |
| 2340 | * |
Benny Prijono | bddef2c | 2007-10-31 13:28:08 +0000 | [diff] [blame] | 2341 | * Default: 15 (seconds) |
| 2342 | */ |
| 2343 | unsigned ka_interval; |
| 2344 | |
| 2345 | /** |
| 2346 | * Specify the data to be transmitted as keep-alive packets. |
| 2347 | * |
| 2348 | * Default: CR-LF |
| 2349 | */ |
| 2350 | pj_str_t ka_data; |
| 2351 | |
Benny Prijono | d817965 | 2008-01-23 20:39:07 +0000 | [diff] [blame] | 2352 | #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) |
| 2353 | /** |
| 2354 | * Specify whether secure media transport should be used for this account. |
| 2355 | * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and |
| 2356 | * PJMEDIA_SRTP_MANDATORY. |
| 2357 | * |
| 2358 | * Default: #PJSUA_DEFAULT_USE_SRTP |
| 2359 | */ |
| 2360 | pjmedia_srtp_use use_srtp; |
| 2361 | |
| 2362 | /** |
| 2363 | * Specify whether SRTP requires secure signaling to be used. This option |
| 2364 | * is only used when \a use_srtp option above is non-zero. |
| 2365 | * |
| 2366 | * Valid values are: |
| 2367 | * 0: SRTP does not require secure signaling |
| 2368 | * 1: SRTP requires secure transport such as TLS |
| 2369 | * 2: SRTP requires secure end-to-end transport (SIPS) |
| 2370 | * |
| 2371 | * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING |
| 2372 | */ |
| 2373 | int srtp_secure_signaling; |
Nanang Izzuddin | d89cc3a | 2010-05-13 05:22:51 +0000 | [diff] [blame] | 2374 | |
| 2375 | /** |
| 2376 | * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose |
| 2377 | * duplicated media in SDP offer, i.e: unsecured and secured version. |
| 2378 | * Otherwise, the SDP media will be composed as unsecured media but |
| 2379 | * with SDP "crypto" attribute. |
| 2380 | * |
| 2381 | * Default: PJ_FALSE |
| 2382 | */ |
| 2383 | pj_bool_t srtp_optional_dup_offer; |
Benny Prijono | d817965 | 2008-01-23 20:39:07 +0000 | [diff] [blame] | 2384 | #endif |
| 2385 | |
Nanang Izzuddin | 36dd5b6 | 2010-03-30 11:13:59 +0000 | [diff] [blame] | 2386 | /** |
| 2387 | * Specify interval of auto registration retry upon registration failure |
| 2388 | * (including caused by transport problem), in second. Set to 0 to |
| 2389 | * disable auto re-registration. |
| 2390 | * |
| 2391 | * Default: #PJSUA_REG_RETRY_INTERVAL |
| 2392 | */ |
| 2393 | unsigned reg_retry_interval; |
| 2394 | |
| 2395 | /** |
| 2396 | * Specify whether calls of the configured account should be dropped |
| 2397 | * after registration failure and an attempt of re-registration has |
| 2398 | * also failed. |
| 2399 | * |
| 2400 | * Default: PJ_FALSE (disabled) |
| 2401 | */ |
| 2402 | pj_bool_t drop_calls_on_reg_fail; |
| 2403 | |
Benny Prijono | 29c8ca3 | 2010-06-22 06:02:13 +0000 | [diff] [blame] | 2404 | /** |
| 2405 | * Specify how the registration uses the outbound and account proxy |
| 2406 | * settings. This controls if and what Route headers will appear in |
| 2407 | * the REGISTER request of this account. The value is bitmask combination |
| 2408 | * of PJSUA_REG_USE_OUTBOUND_PROXY and PJSUA_REG_USE_ACC_PROXY bits. |
| 2409 | * If the value is set to 0, the REGISTER request will not use any proxy |
| 2410 | * (i.e. it will not have any Route headers). |
| 2411 | * |
| 2412 | * Default: 3 (PJSUA_REG_USE_OUTBOUND_PROXY | PJSUA_REG_USE_ACC_PROXY) |
| 2413 | */ |
| 2414 | unsigned reg_use_proxy; |
| 2415 | |
Nanang Izzuddin | 5e39a2b | 2010-09-20 06:13:02 +0000 | [diff] [blame] | 2416 | #if defined(PJMEDIA_STREAM_ENABLE_KA) && (PJMEDIA_STREAM_ENABLE_KA != 0) |
| 2417 | /** |
| 2418 | * Specify whether stream keep-alive and NAT hole punching with |
| 2419 | * non-codec-VAD mechanism (see @ref PJMEDIA_STREAM_ENABLE_KA) is enabled |
| 2420 | * for this account. |
| 2421 | * |
| 2422 | * Default: PJ_FALSE (disabled) |
| 2423 | */ |
| 2424 | pj_bool_t use_stream_ka; |
| 2425 | #endif |
| 2426 | |
Benny Prijono | dd63b99 | 2010-10-01 02:03:42 +0000 | [diff] [blame] | 2427 | /** |
| 2428 | * Specify how to offer call hold to remote peer. Please see the |
| 2429 | * documentation on #pjsua_call_hold_type for more info. |
| 2430 | * |
| 2431 | * Default: PJSUA_CALL_HOLD_TYPE_DEFAULT |
| 2432 | */ |
| 2433 | pjsua_call_hold_type call_hold_type; |
| 2434 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2435 | } pjsua_acc_config; |
| 2436 | |
| 2437 | |
| 2438 | /** |
| 2439 | * Call this function to initialize account config with default values. |
| 2440 | * |
| 2441 | * @param cfg The account config to be initialized. |
| 2442 | */ |
Benny Prijono | 1f61a8f | 2007-08-16 10:11:44 +0000 | [diff] [blame] | 2443 | PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2444 | |
| 2445 | |
| 2446 | /** |
Benny Prijono | bddef2c | 2007-10-31 13:28:08 +0000 | [diff] [blame] | 2447 | * Duplicate account config. |
| 2448 | * |
| 2449 | * @param pool Pool to be used for duplicating the config. |
| 2450 | * @param dst Destination configuration. |
| 2451 | * @param src Source configuration. |
| 2452 | */ |
| 2453 | PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool, |
| 2454 | pjsua_acc_config *dst, |
| 2455 | const pjsua_acc_config *src); |
| 2456 | |
| 2457 | |
| 2458 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2459 | * Account info. Application can query account info by calling |
| 2460 | * #pjsua_acc_get_info(). |
| 2461 | */ |
| 2462 | typedef struct pjsua_acc_info |
| 2463 | { |
| 2464 | /** |
| 2465 | * The account ID. |
| 2466 | */ |
| 2467 | pjsua_acc_id id; |
| 2468 | |
| 2469 | /** |
| 2470 | * Flag to indicate whether this is the default account. |
| 2471 | */ |
| 2472 | pj_bool_t is_default; |
| 2473 | |
| 2474 | /** |
| 2475 | * Account URI |
| 2476 | */ |
| 2477 | pj_str_t acc_uri; |
| 2478 | |
| 2479 | /** |
| 2480 | * Flag to tell whether this account has registration setting |
| 2481 | * (reg_uri is not empty). |
| 2482 | */ |
| 2483 | pj_bool_t has_registration; |
| 2484 | |
| 2485 | /** |
| 2486 | * An up to date expiration interval for account registration session. |
| 2487 | */ |
| 2488 | int expires; |
| 2489 | |
| 2490 | /** |
| 2491 | * Last registration status code. If status code is zero, the account |
| 2492 | * is currently not registered. Any other value indicates the SIP |
| 2493 | * status code of the registration. |
| 2494 | */ |
| 2495 | pjsip_status_code status; |
| 2496 | |
| 2497 | /** |
Sauw Ming | 48f6dbf | 2010-09-07 05:10:25 +0000 | [diff] [blame] | 2498 | * Last registration error code. When the status field contains a SIP |
| 2499 | * status code that indicates a registration failure, last registration |
| 2500 | * error code contains the error code that causes the failure. In any |
| 2501 | * other case, its value is zero. |
| 2502 | */ |
| 2503 | pj_status_t reg_last_err; |
| 2504 | |
| 2505 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2506 | * String describing the registration status. |
| 2507 | */ |
| 2508 | pj_str_t status_text; |
| 2509 | |
| 2510 | /** |
| 2511 | * Presence online status for this account. |
| 2512 | */ |
| 2513 | pj_bool_t online_status; |
| 2514 | |
| 2515 | /** |
Benny Prijono | 4461c7d | 2007-08-25 13:36:15 +0000 | [diff] [blame] | 2516 | * Presence online status text. |
| 2517 | */ |
| 2518 | pj_str_t online_status_text; |
| 2519 | |
| 2520 | /** |
| 2521 | * Extended RPID online status information. |
| 2522 | */ |
| 2523 | pjrpid_element rpid; |
| 2524 | |
| 2525 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2526 | * Buffer that is used internally to store the status text. |
| 2527 | */ |
| 2528 | char buf_[PJ_ERR_MSG_SIZE]; |
| 2529 | |
| 2530 | } pjsua_acc_info; |
| 2531 | |
| 2532 | |
| 2533 | |
| 2534 | /** |
| 2535 | * Get number of current accounts. |
| 2536 | * |
| 2537 | * @return Current number of accounts. |
| 2538 | */ |
| 2539 | PJ_DECL(unsigned) pjsua_acc_get_count(void); |
| 2540 | |
| 2541 | |
| 2542 | /** |
| 2543 | * Check if the specified account ID is valid. |
| 2544 | * |
| 2545 | * @param acc_id Account ID to check. |
| 2546 | * |
| 2547 | * @return Non-zero if account ID is valid. |
| 2548 | */ |
| 2549 | PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id); |
| 2550 | |
| 2551 | |
| 2552 | /** |
Benny Prijono | 21b9ad9 | 2006-08-15 13:11:22 +0000 | [diff] [blame] | 2553 | * Set default account to be used when incoming and outgoing |
| 2554 | * requests doesn't match any accounts. |
| 2555 | * |
| 2556 | * @param acc_id The account ID to be used as default. |
| 2557 | * |
| 2558 | * @return PJ_SUCCESS on success. |
| 2559 | */ |
| 2560 | PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id); |
| 2561 | |
| 2562 | |
| 2563 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2564 | * Get default account to be used when receiving incoming requests (calls), |
| 2565 | * when the destination of the incoming call doesn't match any other |
| 2566 | * accounts. |
Benny Prijono | 21b9ad9 | 2006-08-15 13:11:22 +0000 | [diff] [blame] | 2567 | * |
| 2568 | * @return The default account ID, or PJSUA_INVALID_ID if no |
| 2569 | * default account is configured. |
| 2570 | */ |
| 2571 | PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void); |
| 2572 | |
| 2573 | |
| 2574 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2575 | * Add a new account to pjsua. PJSUA must have been initialized (with |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2576 | * #pjsua_init()) before calling this function. If registration is configured |
| 2577 | * for this account, this function would also start the SIP registration |
| 2578 | * session with the SIP registrar server. This SIP registration session |
| 2579 | * will be maintained internally by the library, and application doesn't |
| 2580 | * need to do anything to maintain the registration session. |
| 2581 | * |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2582 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 2583 | * @param acc_cfg Account configuration. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2584 | * @param is_default If non-zero, this account will be set as the default |
| 2585 | * account. The default account will be used when sending |
| 2586 | * outgoing requests (e.g. making call) when no account is |
| 2587 | * specified, and when receiving incoming requests when the |
| 2588 | * request does not match any accounts. It is recommended |
| 2589 | * that default account is set to local/LAN account. |
| 2590 | * @param p_acc_id Pointer to receive account ID of the new account. |
| 2591 | * |
| 2592 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2593 | */ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 2594 | PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg, |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2595 | pj_bool_t is_default, |
| 2596 | pjsua_acc_id *p_acc_id); |
| 2597 | |
| 2598 | |
| 2599 | /** |
| 2600 | * Add a local account. A local account is used to identify local endpoint |
| 2601 | * instead of a specific user, and for this reason, a transport ID is needed |
| 2602 | * to obtain the local address information. |
| 2603 | * |
| 2604 | * @param tid Transport ID to generate account address. |
| 2605 | * @param is_default If non-zero, this account will be set as the default |
| 2606 | * account. The default account will be used when sending |
| 2607 | * outgoing requests (e.g. making call) when no account is |
| 2608 | * specified, and when receiving incoming requests when the |
| 2609 | * request does not match any accounts. It is recommended |
| 2610 | * that default account is set to local/LAN account. |
| 2611 | * @param p_acc_id Pointer to receive account ID of the new account. |
| 2612 | * |
| 2613 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2614 | */ |
| 2615 | PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid, |
| 2616 | pj_bool_t is_default, |
| 2617 | pjsua_acc_id *p_acc_id); |
| 2618 | |
| 2619 | /** |
Benny Prijono | 705e784 | 2008-07-21 18:12:51 +0000 | [diff] [blame] | 2620 | * Set arbitrary data to be associated with the account. |
| 2621 | * |
| 2622 | * @param acc_id The account ID. |
| 2623 | * @param user_data User/application data. |
| 2624 | * |
| 2625 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2626 | */ |
| 2627 | PJ_DECL(pj_status_t) pjsua_acc_set_user_data(pjsua_acc_id acc_id, |
| 2628 | void *user_data); |
| 2629 | |
| 2630 | |
| 2631 | /** |
| 2632 | * Retrieve arbitrary data associated with the account. |
| 2633 | * |
| 2634 | * @param acc_id The account ID. |
| 2635 | * |
| 2636 | * @return The user data. In the case where the account ID is |
| 2637 | * not valid, NULL is returned. |
| 2638 | */ |
| 2639 | PJ_DECL(void*) pjsua_acc_get_user_data(pjsua_acc_id acc_id); |
| 2640 | |
| 2641 | |
| 2642 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2643 | * Delete an account. This will unregister the account from the SIP server, |
| 2644 | * if necessary, and terminate server side presence subscriptions associated |
| 2645 | * with this account. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2646 | * |
| 2647 | * @param acc_id Id of the account to be deleted. |
| 2648 | * |
| 2649 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2650 | */ |
| 2651 | PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id); |
| 2652 | |
| 2653 | |
| 2654 | /** |
| 2655 | * Modify account information. |
| 2656 | * |
| 2657 | * @param acc_id Id of the account to be modified. |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 2658 | * @param acc_cfg New account configuration. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2659 | * |
| 2660 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2661 | */ |
| 2662 | PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id, |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 2663 | const pjsua_acc_config *acc_cfg); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2664 | |
| 2665 | |
| 2666 | /** |
| 2667 | * Modify account's presence status to be advertised to remote/presence |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2668 | * subscribers. This would trigger the sending of outgoing NOTIFY request |
Benny Prijono | 4461c7d | 2007-08-25 13:36:15 +0000 | [diff] [blame] | 2669 | * if there are server side presence subscription for this account, and/or |
| 2670 | * outgoing PUBLISH if presence publication is enabled for this account. |
| 2671 | * |
| 2672 | * @see pjsua_acc_set_online_status2() |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2673 | * |
| 2674 | * @param acc_id The account ID. |
| 2675 | * @param is_online True of false. |
| 2676 | * |
| 2677 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2678 | */ |
| 2679 | PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id, |
| 2680 | pj_bool_t is_online); |
| 2681 | |
Benny Prijono | 4461c7d | 2007-08-25 13:36:15 +0000 | [diff] [blame] | 2682 | /** |
| 2683 | * Modify account's presence status to be advertised to remote/presence |
| 2684 | * subscribers. This would trigger the sending of outgoing NOTIFY request |
| 2685 | * if there are server side presence subscription for this account, and/or |
| 2686 | * outgoing PUBLISH if presence publication is enabled for this account. |
| 2687 | * |
| 2688 | * @see pjsua_acc_set_online_status() |
| 2689 | * |
| 2690 | * @param acc_id The account ID. |
| 2691 | * @param is_online True of false. |
| 2692 | * @param pr Extended information in subset of RPID format |
| 2693 | * which allows setting custom presence text. |
| 2694 | * |
| 2695 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2696 | */ |
| 2697 | PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id, |
| 2698 | pj_bool_t is_online, |
| 2699 | const pjrpid_element *pr); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2700 | |
| 2701 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2702 | * Update registration or perform unregistration. If registration is |
| 2703 | * configured for this account, then initial SIP REGISTER will be sent |
| 2704 | * when the account is added with #pjsua_acc_add(). Application normally |
| 2705 | * only need to call this function if it wants to manually update the |
| 2706 | * registration or to unregister from the server. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2707 | * |
| 2708 | * @param acc_id The account ID. |
| 2709 | * @param renew If renew argument is zero, this will start |
| 2710 | * unregistration process. |
| 2711 | * |
| 2712 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2713 | */ |
| 2714 | PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id, |
| 2715 | pj_bool_t renew); |
| 2716 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2717 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2718 | * Get information about the specified account. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2719 | * |
| 2720 | * @param acc_id Account identification. |
| 2721 | * @param info Pointer to receive account information. |
| 2722 | * |
| 2723 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2724 | */ |
| 2725 | PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id, |
| 2726 | pjsua_acc_info *info); |
| 2727 | |
| 2728 | |
| 2729 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2730 | * Enumerate all account currently active in the library. This will fill |
| 2731 | * the array with the account Ids, and application can then query the |
| 2732 | * account information for each id with #pjsua_acc_get_info(). |
| 2733 | * |
| 2734 | * @see pjsua_acc_enum_info(). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2735 | * |
| 2736 | * @param ids Array of account IDs to be initialized. |
| 2737 | * @param count In input, specifies the maximum number of elements. |
| 2738 | * On return, it contains the actual number of elements. |
| 2739 | * |
| 2740 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2741 | */ |
| 2742 | PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[], |
| 2743 | unsigned *count ); |
| 2744 | |
| 2745 | |
| 2746 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2747 | * Enumerate account informations. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2748 | * |
| 2749 | * @param info Array of account infos to be initialized. |
| 2750 | * @param count In input, specifies the maximum number of elements. |
| 2751 | * On return, it contains the actual number of elements. |
| 2752 | * |
| 2753 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2754 | */ |
| 2755 | PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[], |
| 2756 | unsigned *count ); |
| 2757 | |
| 2758 | |
| 2759 | /** |
| 2760 | * This is an internal function to find the most appropriate account to |
| 2761 | * used to reach to the specified URL. |
| 2762 | * |
| 2763 | * @param url The remote URL to reach. |
| 2764 | * |
| 2765 | * @return Account id. |
| 2766 | */ |
| 2767 | PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url); |
| 2768 | |
| 2769 | |
| 2770 | /** |
| 2771 | * This is an internal function to find the most appropriate account to be |
| 2772 | * used to handle incoming calls. |
| 2773 | * |
| 2774 | * @param rdata The incoming request message. |
| 2775 | * |
| 2776 | * @return Account id. |
| 2777 | */ |
| 2778 | PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata); |
| 2779 | |
| 2780 | |
Benny Prijono | c570f2d | 2006-07-18 00:33:02 +0000 | [diff] [blame] | 2781 | /** |
Benny Prijono | fff245c | 2007-04-02 11:44:47 +0000 | [diff] [blame] | 2782 | * Create arbitrary requests using the account. Application should only use |
| 2783 | * this function to create auxiliary requests outside dialog, such as |
| 2784 | * OPTIONS, and use the call or presence API to create dialog related |
| 2785 | * requests. |
| 2786 | * |
| 2787 | * @param acc_id The account ID. |
| 2788 | * @param method The SIP method of the request. |
| 2789 | * @param target Target URI. |
| 2790 | * @param p_tdata Pointer to receive the request. |
| 2791 | * |
| 2792 | * @return PJ_SUCCESS or the error code. |
| 2793 | */ |
| 2794 | PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id, |
| 2795 | const pjsip_method *method, |
| 2796 | const pj_str_t *target, |
| 2797 | pjsip_tx_data **p_tdata); |
| 2798 | |
| 2799 | |
| 2800 | /** |
Nanang Izzuddin | 5af37ff | 2009-08-05 18:41:23 +0000 | [diff] [blame] | 2801 | * Create a suitable Contact header value, based on the specified target URI |
| 2802 | * for the specified account. |
Benny Prijono | c570f2d | 2006-07-18 00:33:02 +0000 | [diff] [blame] | 2803 | * |
| 2804 | * @param pool Pool to allocate memory for the string. |
Nanang Izzuddin | 5af37ff | 2009-08-05 18:41:23 +0000 | [diff] [blame] | 2805 | * @param contact The string where the Contact will be stored. |
Benny Prijono | c570f2d | 2006-07-18 00:33:02 +0000 | [diff] [blame] | 2806 | * @param acc_id Account ID. |
| 2807 | * @param uri Destination URI of the request. |
| 2808 | * |
| 2809 | * @return PJ_SUCCESS on success, other on error. |
| 2810 | */ |
| 2811 | PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool, |
| 2812 | pj_str_t *contact, |
| 2813 | pjsua_acc_id acc_id, |
| 2814 | const pj_str_t *uri); |
| 2815 | |
| 2816 | |
| 2817 | |
| 2818 | /** |
Nanang Izzuddin | 5af37ff | 2009-08-05 18:41:23 +0000 | [diff] [blame] | 2819 | * Create a suitable Contact header value, based on the information in the |
| 2820 | * incoming request. |
Benny Prijono | c570f2d | 2006-07-18 00:33:02 +0000 | [diff] [blame] | 2821 | * |
| 2822 | * @param pool Pool to allocate memory for the string. |
Nanang Izzuddin | 5af37ff | 2009-08-05 18:41:23 +0000 | [diff] [blame] | 2823 | * @param contact The string where the Contact will be stored. |
Benny Prijono | c570f2d | 2006-07-18 00:33:02 +0000 | [diff] [blame] | 2824 | * @param acc_id Account ID. |
| 2825 | * @param rdata Incoming request. |
| 2826 | * |
| 2827 | * @return PJ_SUCCESS on success, other on error. |
| 2828 | */ |
| 2829 | PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool, |
| 2830 | pj_str_t *contact, |
| 2831 | pjsua_acc_id acc_id, |
| 2832 | pjsip_rx_data *rdata ); |
| 2833 | |
| 2834 | |
Benny Prijono | 62c5c5b | 2007-01-13 23:22:40 +0000 | [diff] [blame] | 2835 | /** |
| 2836 | * Lock/bind this account to a specific transport/listener. Normally |
| 2837 | * application shouldn't need to do this, as transports will be selected |
| 2838 | * automatically by the stack according to the destination. |
| 2839 | * |
| 2840 | * When account is locked/bound to a specific transport, all outgoing |
| 2841 | * requests from this account will use the specified transport (this |
| 2842 | * includes SIP registration, dialog (call and event subscription), and |
| 2843 | * out-of-dialog requests such as MESSAGE). |
| 2844 | * |
| 2845 | * Note that transport_id may be specified in pjsua_acc_config too. |
| 2846 | * |
| 2847 | * @param acc_id The account ID. |
| 2848 | * @param tp_id The transport ID. |
| 2849 | * |
| 2850 | * @return PJ_SUCCESS on success. |
| 2851 | */ |
| 2852 | PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id, |
| 2853 | pjsua_transport_id tp_id); |
| 2854 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2855 | |
| 2856 | /** |
| 2857 | * @} |
| 2858 | */ |
| 2859 | |
| 2860 | |
| 2861 | /***************************************************************************** |
| 2862 | * CALLS API |
| 2863 | */ |
| 2864 | |
| 2865 | |
| 2866 | /** |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 2867 | * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2868 | * @ingroup PJSUA_LIB |
| 2869 | * @brief Call manipulation. |
| 2870 | * @{ |
| 2871 | */ |
| 2872 | |
| 2873 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2874 | * Maximum simultaneous calls. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2875 | */ |
| 2876 | #ifndef PJSUA_MAX_CALLS |
| 2877 | # define PJSUA_MAX_CALLS 32 |
| 2878 | #endif |
| 2879 | |
| 2880 | |
| 2881 | |
| 2882 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2883 | * This enumeration specifies the media status of a call, and it's part |
| 2884 | * of pjsua_call_info structure. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2885 | */ |
| 2886 | typedef enum pjsua_call_media_status |
| 2887 | { |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2888 | /** Call currently has no media */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2889 | PJSUA_CALL_MEDIA_NONE, |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2890 | |
| 2891 | /** The media is active */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2892 | PJSUA_CALL_MEDIA_ACTIVE, |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2893 | |
| 2894 | /** The media is currently put on hold by local endpoint */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2895 | PJSUA_CALL_MEDIA_LOCAL_HOLD, |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2896 | |
| 2897 | /** The media is currently put on hold by remote endpoint */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2898 | PJSUA_CALL_MEDIA_REMOTE_HOLD, |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2899 | |
Benny Prijono | 096c56c | 2007-09-15 08:30:16 +0000 | [diff] [blame] | 2900 | /** The media has reported error (e.g. ICE negotiation) */ |
| 2901 | PJSUA_CALL_MEDIA_ERROR |
| 2902 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2903 | } pjsua_call_media_status; |
| 2904 | |
| 2905 | |
| 2906 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2907 | * This structure describes the information and current status of a call. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2908 | */ |
| 2909 | typedef struct pjsua_call_info |
| 2910 | { |
| 2911 | /** Call identification. */ |
| 2912 | pjsua_call_id id; |
| 2913 | |
| 2914 | /** Initial call role (UAC == caller) */ |
| 2915 | pjsip_role_e role; |
| 2916 | |
Benny Prijono | 9031551 | 2006-09-14 16:05:16 +0000 | [diff] [blame] | 2917 | /** The account ID where this call belongs. */ |
| 2918 | pjsua_acc_id acc_id; |
| 2919 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2920 | /** Local URI */ |
| 2921 | pj_str_t local_info; |
| 2922 | |
| 2923 | /** Local Contact */ |
| 2924 | pj_str_t local_contact; |
| 2925 | |
| 2926 | /** Remote URI */ |
| 2927 | pj_str_t remote_info; |
| 2928 | |
| 2929 | /** Remote contact */ |
| 2930 | pj_str_t remote_contact; |
| 2931 | |
| 2932 | /** Dialog Call-ID string. */ |
| 2933 | pj_str_t call_id; |
| 2934 | |
| 2935 | /** Call state */ |
| 2936 | pjsip_inv_state state; |
| 2937 | |
| 2938 | /** Text describing the state */ |
| 2939 | pj_str_t state_text; |
| 2940 | |
| 2941 | /** Last status code heard, which can be used as cause code */ |
| 2942 | pjsip_status_code last_status; |
| 2943 | |
| 2944 | /** The reason phrase describing the status. */ |
| 2945 | pj_str_t last_status_text; |
| 2946 | |
| 2947 | /** Call media status. */ |
| 2948 | pjsua_call_media_status media_status; |
| 2949 | |
| 2950 | /** Media direction */ |
| 2951 | pjmedia_dir media_dir; |
| 2952 | |
| 2953 | /** The conference port number for the call */ |
| 2954 | pjsua_conf_port_id conf_slot; |
| 2955 | |
| 2956 | /** Up-to-date call connected duration (zero when call is not |
| 2957 | * established) |
| 2958 | */ |
| 2959 | pj_time_val connect_duration; |
| 2960 | |
| 2961 | /** Total call duration, including set-up time */ |
| 2962 | pj_time_val total_duration; |
| 2963 | |
| 2964 | /** Internal */ |
| 2965 | struct { |
| 2966 | char local_info[128]; |
| 2967 | char local_contact[128]; |
| 2968 | char remote_info[128]; |
| 2969 | char remote_contact[128]; |
| 2970 | char call_id[128]; |
| 2971 | char last_status_text[128]; |
| 2972 | } buf_; |
| 2973 | |
| 2974 | } pjsua_call_info; |
| 2975 | |
| 2976 | |
| 2977 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 2978 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2979 | * Get maximum number of calls configured in pjsua. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2980 | * |
| 2981 | * @return Maximum number of calls configured. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2982 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 2983 | PJ_DECL(unsigned) pjsua_call_get_max_count(void); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2984 | |
| 2985 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2986 | * Get number of currently active calls. |
| 2987 | * |
| 2988 | * @return Number of currently active calls. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2989 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 2990 | PJ_DECL(unsigned) pjsua_call_get_count(void); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2991 | |
| 2992 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2993 | * Enumerate all active calls. Application may then query the information and |
| 2994 | * state of each call by calling #pjsua_call_get_info(). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2995 | * |
| 2996 | * @param ids Array of account IDs to be initialized. |
| 2997 | * @param count In input, specifies the maximum number of elements. |
| 2998 | * On return, it contains the actual number of elements. |
| 2999 | * |
| 3000 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3001 | */ |
| 3002 | PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[], |
| 3003 | unsigned *count); |
| 3004 | |
| 3005 | |
| 3006 | /** |
| 3007 | * Make outgoing call to the specified URI using the specified account. |
| 3008 | * |
| 3009 | * @param acc_id The account to be used. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3010 | * @param dst_uri URI to be put in the To header (normally is the same |
| 3011 | * as the target URI). |
| 3012 | * @param options Options (must be zero at the moment). |
| 3013 | * @param user_data Arbitrary user data to be attached to the call, and |
| 3014 | * can be retrieved later. |
| 3015 | * @param msg_data Optional headers etc to be added to outgoing INVITE |
| 3016 | * request, or NULL if no custom header is desired. |
| 3017 | * @param p_call_id Pointer to receive call identification. |
| 3018 | * |
| 3019 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3020 | */ |
| 3021 | PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id, |
| 3022 | const pj_str_t *dst_uri, |
| 3023 | unsigned options, |
| 3024 | void *user_data, |
| 3025 | const pjsua_msg_data *msg_data, |
| 3026 | pjsua_call_id *p_call_id); |
| 3027 | |
| 3028 | |
| 3029 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3030 | * Check if the specified call has active INVITE session and the INVITE |
| 3031 | * session has not been disconnected. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3032 | * |
| 3033 | * @param call_id Call identification. |
| 3034 | * |
| 3035 | * @return Non-zero if call is active. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3036 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3037 | PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3038 | |
| 3039 | |
| 3040 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3041 | * Check if call has an active media session. |
| 3042 | * |
| 3043 | * @param call_id Call identification. |
| 3044 | * |
| 3045 | * @return Non-zero if yes. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3046 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3047 | PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3048 | |
| 3049 | |
| 3050 | /** |
Benny Prijono | cf986c4 | 2008-09-02 11:25:07 +0000 | [diff] [blame] | 3051 | * Retrieve the media session associated with this call. Note that the media |
| 3052 | * session may not be available depending on the current call's media status |
| 3053 | * (the pjsua_call_media_status information in pjsua_call_info). Application |
| 3054 | * may use the media session to retrieve more detailed information about the |
| 3055 | * call's media. |
| 3056 | * |
| 3057 | * @param call_id Call identification. |
| 3058 | * |
| 3059 | * @return Call media session. |
| 3060 | */ |
| 3061 | PJ_DECL(pjmedia_session*) pjsua_call_get_media_session(pjsua_call_id call_id); |
| 3062 | |
| 3063 | |
| 3064 | /** |
| 3065 | * Retrieve the media transport instance that is used for this call. |
| 3066 | * Application may use the media transport to query more detailed information |
| 3067 | * about the media transport. |
| 3068 | * |
| 3069 | * @param cid Call identification (the call_id). |
| 3070 | * |
| 3071 | * @return Call media transport. |
| 3072 | */ |
| 3073 | PJ_DECL(pjmedia_transport*) pjsua_call_get_media_transport(pjsua_call_id cid); |
| 3074 | |
| 3075 | |
| 3076 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3077 | * Get the conference port identification associated with the call. |
| 3078 | * |
| 3079 | * @param call_id Call identification. |
| 3080 | * |
| 3081 | * @return Conference port ID, or PJSUA_INVALID_ID when the |
| 3082 | * media has not been established or is not active. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3083 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3084 | PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id); |
| 3085 | |
| 3086 | /** |
| 3087 | * Obtain detail information about the specified call. |
| 3088 | * |
| 3089 | * @param call_id Call identification. |
| 3090 | * @param info Call info to be initialized. |
| 3091 | * |
| 3092 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3093 | */ |
| 3094 | PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id, |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3095 | pjsua_call_info *info); |
| 3096 | |
Nanang Izzuddin | 2a1b9ee | 2010-06-03 10:41:32 +0000 | [diff] [blame] | 3097 | /** |
| 3098 | * Check if remote peer support the specified capability. |
| 3099 | * |
| 3100 | * @param call_id Call identification. |
| 3101 | * @param htype The header type to be checked, which value may be: |
| 3102 | * - PJSIP_H_ACCEPT |
| 3103 | * - PJSIP_H_ALLOW |
| 3104 | * - PJSIP_H_SUPPORTED |
| 3105 | * @param hname If htype specifies PJSIP_H_OTHER, then the header |
| 3106 | * name must be supplied in this argument. Otherwise the |
| 3107 | * value must be set to NULL. |
| 3108 | * @param token The capability token to check. For example, if \a |
| 3109 | * htype is PJSIP_H_ALLOW, then \a token specifies the |
| 3110 | * method names; if \a htype is PJSIP_H_SUPPORTED, then |
| 3111 | * \a token specifies the extension names such as |
| 3112 | * "100rel". |
| 3113 | * |
| 3114 | * @return PJSIP_DIALOG_CAP_SUPPORTED if the specified capability |
| 3115 | * is explicitly supported, see @pjsip_dialog_cap_status |
| 3116 | * for more info. |
| 3117 | */ |
| 3118 | PJ_DECL(pjsip_dialog_cap_status) pjsua_call_remote_has_cap( |
| 3119 | pjsua_call_id call_id, |
| 3120 | int htype, |
| 3121 | const pj_str_t *hname, |
| 3122 | const pj_str_t *token); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3123 | |
| 3124 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3125 | * Attach application specific data to the call. Application can then |
| 3126 | * inspect this data by calling #pjsua_call_get_user_data(). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3127 | * |
| 3128 | * @param call_id Call identification. |
| 3129 | * @param user_data Arbitrary data to be attached to the call. |
| 3130 | * |
| 3131 | * @return The user data. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3132 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3133 | PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id, |
| 3134 | void *user_data); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3135 | |
| 3136 | |
| 3137 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3138 | * Get user data attached to the call, which has been previously set with |
| 3139 | * #pjsua_call_set_user_data(). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3140 | * |
| 3141 | * @param call_id Call identification. |
| 3142 | * |
| 3143 | * @return The user data. |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 3144 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3145 | PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id); |
Benny Prijono | 84126ab | 2006-02-09 09:30:09 +0000 | [diff] [blame] | 3146 | |
| 3147 | |
| 3148 | /** |
Benny Prijono | 91a6a17 | 2007-10-31 08:59:29 +0000 | [diff] [blame] | 3149 | * Get the NAT type of remote's endpoint. This is a proprietary feature |
| 3150 | * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp |
| 3151 | * is set in #pjsua_config. |
| 3152 | * |
| 3153 | * This function can only be called after SDP has been received from remote, |
| 3154 | * which means for incoming call, this function can be called as soon as |
| 3155 | * call is received as long as incoming call contains SDP, and for outgoing |
| 3156 | * call, this function can be called only after SDP is received (normally in |
| 3157 | * 200/OK response to INVITE). As a general case, application should call |
| 3158 | * this function after or in \a on_call_media_state() callback. |
| 3159 | * |
| 3160 | * @param call_id Call identification. |
| 3161 | * @param p_type Pointer to store the NAT type. Application can then |
| 3162 | * retrieve the string description of the NAT type |
| 3163 | * by calling pj_stun_get_nat_name(). |
| 3164 | * |
| 3165 | * @return PJ_SUCCESS on success. |
| 3166 | * |
| 3167 | * @see pjsua_get_nat_type(), nat_type_in_sdp |
| 3168 | */ |
| 3169 | PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id, |
| 3170 | pj_stun_nat_type *p_type); |
| 3171 | |
| 3172 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3173 | * Send response to incoming INVITE request. Depending on the status |
| 3174 | * code specified as parameter, this function may send provisional |
| 3175 | * response, establish the call, or terminate the call. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3176 | * |
| 3177 | * @param call_id Incoming call identification. |
| 3178 | * @param code Status code, (100-699). |
| 3179 | * @param reason Optional reason phrase. If NULL, default text |
| 3180 | * will be used. |
| 3181 | * @param msg_data Optional list of headers etc to be added to outgoing |
| 3182 | * response message. |
| 3183 | * |
| 3184 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 3185 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3186 | PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id, |
| 3187 | unsigned code, |
| 3188 | const pj_str_t *reason, |
| 3189 | const pjsua_msg_data *msg_data); |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 3190 | |
| 3191 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3192 | * Hangup call by using method that is appropriate according to the |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3193 | * call state. This function is different than answering the call with |
| 3194 | * 3xx-6xx response (with #pjsua_call_answer()), in that this function |
| 3195 | * will hangup the call regardless of the state and role of the call, |
| 3196 | * while #pjsua_call_answer() only works with incoming calls on EARLY |
| 3197 | * state. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3198 | * |
| 3199 | * @param call_id Call identification. |
| 3200 | * @param code Optional status code to be sent when we're rejecting |
| 3201 | * incoming call. If the value is zero, "603/Decline" |
| 3202 | * will be sent. |
| 3203 | * @param reason Optional reason phrase to be sent when we're rejecting |
| 3204 | * incoming call. If NULL, default text will be used. |
| 3205 | * @param msg_data Optional list of headers etc to be added to outgoing |
| 3206 | * request/response message. |
| 3207 | * |
| 3208 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 3209 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3210 | PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id, |
| 3211 | unsigned code, |
| 3212 | const pj_str_t *reason, |
| 3213 | const pjsua_msg_data *msg_data); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 3214 | |
Benny Prijono | 5e51a4e | 2008-11-27 00:06:46 +0000 | [diff] [blame] | 3215 | /** |
| 3216 | * Accept or reject redirection response. Application MUST call this function |
| 3217 | * after it signaled PJSIP_REDIRECT_PENDING in the \a on_call_redirected() |
| 3218 | * callback, to notify the call whether to accept or reject the redirection |
| 3219 | * to the current target. Application can use the combination of |
| 3220 | * PJSIP_REDIRECT_PENDING command in \a on_call_redirected() callback and |
| 3221 | * this function to ask for user permission before redirecting the call. |
| 3222 | * |
| 3223 | * Note that if the application chooses to reject or stop redirection (by |
| 3224 | * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the |
| 3225 | * call disconnection callback will be called before this function returns. |
| 3226 | * And if the application rejects the target, the \a on_call_redirected() |
| 3227 | * callback may also be called before this function returns if there is |
| 3228 | * another target to try. |
| 3229 | * |
| 3230 | * @param call_id The call ID. |
| 3231 | * @param cmd Redirection operation to be applied to the current |
| 3232 | * target. The semantic of this argument is similar |
| 3233 | * to the description in the \a on_call_redirected() |
| 3234 | * callback, except that the PJSIP_REDIRECT_PENDING is |
| 3235 | * not accepted here. |
| 3236 | * |
| 3237 | * @return PJ_SUCCESS on successful operation. |
| 3238 | */ |
| 3239 | PJ_DECL(pj_status_t) pjsua_call_process_redirect(pjsua_call_id call_id, |
| 3240 | pjsip_redirect_op cmd); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 3241 | |
| 3242 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3243 | * Put the specified call on hold. This will send re-INVITE with the |
| 3244 | * appropriate SDP to inform remote that the call is being put on hold. |
| 3245 | * The final status of the request itself will be reported on the |
| 3246 | * \a on_call_media_state() callback, which inform the application that |
| 3247 | * the media state of the call has changed. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3248 | * |
| 3249 | * @param call_id Call identification. |
| 3250 | * @param msg_data Optional message components to be sent with |
| 3251 | * the request. |
| 3252 | * |
| 3253 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 3254 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3255 | PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id, |
| 3256 | const pjsua_msg_data *msg_data); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 3257 | |
| 3258 | |
| 3259 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3260 | * Send re-INVITE to release hold. |
| 3261 | * The final status of the request itself will be reported on the |
| 3262 | * \a on_call_media_state() callback, which inform the application that |
| 3263 | * the media state of the call has changed. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3264 | * |
| 3265 | * @param call_id Call identification. |
| 3266 | * @param unhold If this argument is non-zero and the call is locally |
| 3267 | * held, this will release the local hold. |
| 3268 | * @param msg_data Optional message components to be sent with |
| 3269 | * the request. |
| 3270 | * |
| 3271 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 3272 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3273 | PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id, |
| 3274 | pj_bool_t unhold, |
| 3275 | const pjsua_msg_data *msg_data); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 3276 | |
Benny Prijono | c08682e | 2007-10-04 06:17:58 +0000 | [diff] [blame] | 3277 | /** |
| 3278 | * Send UPDATE request. |
| 3279 | * |
| 3280 | * @param call_id Call identification. |
| 3281 | * @param options Must be zero for now. |
| 3282 | * @param msg_data Optional message components to be sent with |
| 3283 | * the request. |
| 3284 | * |
| 3285 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3286 | */ |
| 3287 | PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id, |
| 3288 | unsigned options, |
| 3289 | const pjsua_msg_data *msg_data); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 3290 | |
| 3291 | /** |
Benny Prijono | 053f522 | 2006-11-11 16:16:04 +0000 | [diff] [blame] | 3292 | * Initiate call transfer to the specified address. This function will send |
| 3293 | * REFER request to instruct remote call party to initiate a new INVITE |
| 3294 | * session to the specified destination/target. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3295 | * |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3296 | * If application is interested to monitor the successfulness and |
| 3297 | * the progress of the transfer request, it can implement |
| 3298 | * \a on_call_transfer_status() callback which will report the progress |
| 3299 | * of the call transfer request. |
| 3300 | * |
Benny Prijono | 053f522 | 2006-11-11 16:16:04 +0000 | [diff] [blame] | 3301 | * @param call_id The call id to be transfered. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3302 | * @param dest Address of new target to be contacted. |
| 3303 | * @param msg_data Optional message components to be sent with |
| 3304 | * the request. |
| 3305 | * |
| 3306 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 3307 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3308 | PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id, |
| 3309 | const pj_str_t *dest, |
| 3310 | const pjsua_msg_data *msg_data); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3311 | |
| 3312 | /** |
Benny Prijono | 053f522 | 2006-11-11 16:16:04 +0000 | [diff] [blame] | 3313 | * Flag to indicate that "Require: replaces" should not be put in the |
| 3314 | * outgoing INVITE request caused by REFER request created by |
| 3315 | * #pjsua_call_xfer_replaces(). |
| 3316 | */ |
| 3317 | #define PJSUA_XFER_NO_REQUIRE_REPLACES 1 |
| 3318 | |
| 3319 | /** |
| 3320 | * Initiate attended call transfer. This function will send REFER request |
| 3321 | * to instruct remote call party to initiate new INVITE session to the URL |
| 3322 | * of \a dest_call_id. The party at \a dest_call_id then should "replace" |
| 3323 | * the call with us with the new call from the REFER recipient. |
| 3324 | * |
| 3325 | * @param call_id The call id to be transfered. |
| 3326 | * @param dest_call_id The call id to be replaced. |
| 3327 | * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES |
| 3328 | * to suppress the inclusion of "Require: replaces" in |
| 3329 | * the outgoing INVITE request created by the REFER |
| 3330 | * request. |
| 3331 | * @param msg_data Optional message components to be sent with |
| 3332 | * the request. |
| 3333 | * |
| 3334 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3335 | */ |
| 3336 | PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id, |
| 3337 | pjsua_call_id dest_call_id, |
| 3338 | unsigned options, |
| 3339 | const pjsua_msg_data *msg_data); |
| 3340 | |
| 3341 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3342 | * Send DTMF digits to remote using RFC 2833 payload formats. |
| 3343 | * |
| 3344 | * @param call_id Call identification. |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 3345 | * @param digits DTMF string digits to be sent. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3346 | * |
| 3347 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3348 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3349 | PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id, |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3350 | const pj_str_t *digits); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 3351 | |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 3352 | /** |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 3353 | * Send instant messaging inside INVITE session. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3354 | * |
| 3355 | * @param call_id Call identification. |
| 3356 | * @param mime_type Optional MIME type. If NULL, then "text/plain" is |
| 3357 | * assumed. |
| 3358 | * @param content The message content. |
| 3359 | * @param msg_data Optional list of headers etc to be included in outgoing |
| 3360 | * request. The body descriptor in the msg_data is |
| 3361 | * ignored. |
| 3362 | * @param user_data Optional user data, which will be given back when |
| 3363 | * the IM callback is called. |
| 3364 | * |
| 3365 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 3366 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3367 | PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id, |
| 3368 | const pj_str_t *mime_type, |
| 3369 | const pj_str_t *content, |
| 3370 | const pjsua_msg_data *msg_data, |
| 3371 | void *user_data); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 3372 | |
| 3373 | |
| 3374 | /** |
| 3375 | * Send IM typing indication inside INVITE session. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3376 | * |
| 3377 | * @param call_id Call identification. |
| 3378 | * @param is_typing Non-zero to indicate to remote that local person is |
| 3379 | * currently typing an IM. |
| 3380 | * @param msg_data Optional list of headers etc to be included in outgoing |
| 3381 | * request. |
| 3382 | * |
| 3383 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 3384 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3385 | PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id, |
| 3386 | pj_bool_t is_typing, |
| 3387 | const pjsua_msg_data*msg_data); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 3388 | |
| 3389 | /** |
Benny Prijono | feb69f4 | 2007-10-05 09:12:26 +0000 | [diff] [blame] | 3390 | * Send arbitrary request with the call. This is useful for example to send |
| 3391 | * INFO request. Note that application should not use this function to send |
| 3392 | * requests which would change the invite session's state, such as re-INVITE, |
| 3393 | * UPDATE, PRACK, and BYE. |
| 3394 | * |
| 3395 | * @param call_id Call identification. |
| 3396 | * @param method SIP method of the request. |
| 3397 | * @param msg_data Optional message body and/or list of headers to be |
| 3398 | * included in outgoing request. |
| 3399 | * |
| 3400 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3401 | */ |
| 3402 | PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id, |
| 3403 | const pj_str_t *method, |
| 3404 | const pjsua_msg_data *msg_data); |
| 3405 | |
| 3406 | |
| 3407 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3408 | * Terminate all calls. This will initiate #pjsua_call_hangup() for all |
| 3409 | * currently active calls. |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 3410 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 3411 | PJ_DECL(void) pjsua_call_hangup_all(void); |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 3412 | |
| 3413 | |
Benny Prijono | b9b32ab | 2006-06-01 12:28:44 +0000 | [diff] [blame] | 3414 | /** |
| 3415 | * Dump call and media statistics to string. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3416 | * |
| 3417 | * @param call_id Call identification. |
| 3418 | * @param with_media Non-zero to include media information too. |
| 3419 | * @param buffer Buffer where the statistics are to be written to. |
| 3420 | * @param maxlen Maximum length of buffer. |
| 3421 | * @param indent Spaces for left indentation. |
| 3422 | * |
| 3423 | * @return PJ_SUCCESS on success. |
Benny Prijono | b9b32ab | 2006-06-01 12:28:44 +0000 | [diff] [blame] | 3424 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3425 | PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id, |
| 3426 | pj_bool_t with_media, |
| 3427 | char *buffer, |
| 3428 | unsigned maxlen, |
| 3429 | const char *indent); |
Benny Prijono | b9b32ab | 2006-06-01 12:28:44 +0000 | [diff] [blame] | 3430 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3431 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3432 | * @} |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3433 | */ |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 3434 | |
| 3435 | |
| 3436 | /***************************************************************************** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3437 | * BUDDY API |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 3438 | */ |
| 3439 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3440 | |
| 3441 | /** |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 3442 | * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3443 | * @ingroup PJSUA_LIB |
| 3444 | * @brief Buddy management, buddy's presence, and instant messaging. |
| 3445 | * @{ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 3446 | * |
| 3447 | * This section describes PJSUA-APIs related to buddies management, |
| 3448 | * presence management, and instant messaging. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3449 | */ |
| 3450 | |
| 3451 | /** |
| 3452 | * Max buddies in buddy list. |
| 3453 | */ |
| 3454 | #ifndef PJSUA_MAX_BUDDIES |
| 3455 | # define PJSUA_MAX_BUDDIES 256 |
| 3456 | #endif |
| 3457 | |
| 3458 | |
| 3459 | /** |
Benny Prijono | 6ab0532 | 2009-10-21 03:03:06 +0000 | [diff] [blame] | 3460 | * This specifies how long the library should wait before retrying failed |
| 3461 | * SUBSCRIBE request, and there is no rule to automatically resubscribe |
| 3462 | * (for example, no "retry-after" parameter in Subscription-State header). |
| 3463 | * |
| 3464 | * This also controls the duration before failed PUBLISH request will be |
| 3465 | * retried. |
Benny Prijono | a17496a | 2007-10-31 10:20:31 +0000 | [diff] [blame] | 3466 | * |
| 3467 | * Default: 300 seconds |
| 3468 | */ |
| 3469 | #ifndef PJSUA_PRES_TIMER |
| 3470 | # define PJSUA_PRES_TIMER 300 |
| 3471 | #endif |
| 3472 | |
| 3473 | |
| 3474 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3475 | * This structure describes buddy configuration when adding a buddy to |
| 3476 | * the buddy list with #pjsua_buddy_add(). Application MUST initialize |
| 3477 | * the structure with #pjsua_buddy_config_default() to initialize this |
| 3478 | * structure with default configuration. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3479 | */ |
| 3480 | typedef struct pjsua_buddy_config |
| 3481 | { |
| 3482 | /** |
| 3483 | * Buddy URL or name address. |
| 3484 | */ |
| 3485 | pj_str_t uri; |
| 3486 | |
| 3487 | /** |
| 3488 | * Specify whether presence subscription should start immediately. |
| 3489 | */ |
| 3490 | pj_bool_t subscribe; |
| 3491 | |
Benny Prijono | 705e784 | 2008-07-21 18:12:51 +0000 | [diff] [blame] | 3492 | /** |
| 3493 | * Specify arbitrary application data to be associated with with |
| 3494 | * the buddy object. |
| 3495 | */ |
| 3496 | void *user_data; |
| 3497 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3498 | } pjsua_buddy_config; |
| 3499 | |
| 3500 | |
| 3501 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3502 | * This enumeration describes basic buddy's online status. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3503 | */ |
| 3504 | typedef enum pjsua_buddy_status |
| 3505 | { |
| 3506 | /** |
| 3507 | * Online status is unknown (possibly because no presence subscription |
| 3508 | * has been established). |
| 3509 | */ |
| 3510 | PJSUA_BUDDY_STATUS_UNKNOWN, |
| 3511 | |
| 3512 | /** |
Benny Prijono | fc24e69 | 2007-01-27 18:31:51 +0000 | [diff] [blame] | 3513 | * Buddy is known to be online. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3514 | */ |
| 3515 | PJSUA_BUDDY_STATUS_ONLINE, |
| 3516 | |
| 3517 | /** |
| 3518 | * Buddy is offline. |
| 3519 | */ |
| 3520 | PJSUA_BUDDY_STATUS_OFFLINE, |
| 3521 | |
| 3522 | } pjsua_buddy_status; |
| 3523 | |
| 3524 | |
| 3525 | |
| 3526 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3527 | * This structure describes buddy info, which can be retrieved by calling |
| 3528 | * #pjsua_buddy_get_info(). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3529 | */ |
| 3530 | typedef struct pjsua_buddy_info |
| 3531 | { |
| 3532 | /** |
| 3533 | * The buddy ID. |
| 3534 | */ |
| 3535 | pjsua_buddy_id id; |
| 3536 | |
| 3537 | /** |
| 3538 | * The full URI of the buddy, as specified in the configuration. |
| 3539 | */ |
| 3540 | pj_str_t uri; |
| 3541 | |
| 3542 | /** |
| 3543 | * Buddy's Contact, only available when presence subscription has |
| 3544 | * been established to the buddy. |
| 3545 | */ |
| 3546 | pj_str_t contact; |
| 3547 | |
| 3548 | /** |
| 3549 | * Buddy's online status. |
| 3550 | */ |
| 3551 | pjsua_buddy_status status; |
| 3552 | |
| 3553 | /** |
| 3554 | * Text to describe buddy's online status. |
| 3555 | */ |
| 3556 | pj_str_t status_text; |
| 3557 | |
| 3558 | /** |
| 3559 | * Flag to indicate that we should monitor the presence information for |
| 3560 | * this buddy (normally yes, unless explicitly disabled). |
| 3561 | */ |
| 3562 | pj_bool_t monitor_pres; |
| 3563 | |
| 3564 | /** |
Benny Prijono | 63fba01 | 2008-07-17 14:19:10 +0000 | [diff] [blame] | 3565 | * If \a monitor_pres is enabled, this specifies the last state of the |
| 3566 | * presence subscription. If presence subscription session is currently |
| 3567 | * active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence |
| 3568 | * subscription request has been rejected, the value will be |
| 3569 | * PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be |
| 3570 | * specified in \a sub_term_reason. |
| 3571 | */ |
| 3572 | pjsip_evsub_state sub_state; |
| 3573 | |
| 3574 | /** |
Benny Prijono | d06d8c5 | 2009-06-30 13:53:47 +0000 | [diff] [blame] | 3575 | * String representation of subscription state. |
| 3576 | */ |
| 3577 | const char *sub_state_name; |
| 3578 | |
| 3579 | /** |
Benny Prijono | 73bb723 | 2009-10-20 13:56:26 +0000 | [diff] [blame] | 3580 | * Specifies the last presence subscription termination code. This would |
| 3581 | * return the last status of the SUBSCRIBE request. If the subscription |
| 3582 | * is terminated with NOTIFY by the server, this value will be set to |
| 3583 | * 200, and subscription termination reason will be given in the |
| 3584 | * \a sub_term_reason field. |
| 3585 | */ |
| 3586 | unsigned sub_term_code; |
| 3587 | |
| 3588 | /** |
| 3589 | * Specifies the last presence subscription termination reason. If |
Benny Prijono | 63fba01 | 2008-07-17 14:19:10 +0000 | [diff] [blame] | 3590 | * presence subscription is currently active, the value will be empty. |
| 3591 | */ |
| 3592 | pj_str_t sub_term_reason; |
| 3593 | |
| 3594 | /** |
Benny Prijono | 4461c7d | 2007-08-25 13:36:15 +0000 | [diff] [blame] | 3595 | * Extended RPID information about the person. |
| 3596 | */ |
| 3597 | pjrpid_element rpid; |
| 3598 | |
| 3599 | /** |
Benny Prijono | 28add7e | 2009-06-15 16:03:40 +0000 | [diff] [blame] | 3600 | * Extended presence info. |
| 3601 | */ |
| 3602 | pjsip_pres_status pres_status; |
| 3603 | |
| 3604 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3605 | * Internal buffer. |
| 3606 | */ |
Benny Prijono | 4461c7d | 2007-08-25 13:36:15 +0000 | [diff] [blame] | 3607 | char buf_[512]; |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3608 | |
| 3609 | } pjsua_buddy_info; |
| 3610 | |
| 3611 | |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 3612 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3613 | * Set default values to the buddy config. |
| 3614 | */ |
Benny Prijono | 1f61a8f | 2007-08-16 10:11:44 +0000 | [diff] [blame] | 3615 | PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg); |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3616 | |
| 3617 | |
| 3618 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3619 | * Get total number of buddies. |
| 3620 | * |
| 3621 | * @return Number of buddies. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3622 | */ |
| 3623 | PJ_DECL(unsigned) pjsua_get_buddy_count(void); |
| 3624 | |
| 3625 | |
| 3626 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3627 | * Check if buddy ID is valid. |
| 3628 | * |
| 3629 | * @param buddy_id Buddy ID to check. |
| 3630 | * |
| 3631 | * @return Non-zero if buddy ID is valid. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3632 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3633 | PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id); |
| 3634 | |
| 3635 | |
| 3636 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3637 | * Enumerate all buddy IDs in the buddy list. Application then can use |
| 3638 | * #pjsua_buddy_get_info() to get the detail information for each buddy |
| 3639 | * id. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3640 | * |
| 3641 | * @param ids Array of ids to be initialized. |
| 3642 | * @param count On input, specifies max elements in the array. |
| 3643 | * On return, it contains actual number of elements |
| 3644 | * that have been initialized. |
| 3645 | * |
| 3646 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3647 | */ |
| 3648 | PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[], |
| 3649 | unsigned *count); |
| 3650 | |
| 3651 | /** |
Benny Prijono | 705e784 | 2008-07-21 18:12:51 +0000 | [diff] [blame] | 3652 | * Find the buddy ID with the specified URI. |
| 3653 | * |
| 3654 | * @param uri The buddy URI. |
| 3655 | * |
| 3656 | * @return The buddy ID, or PJSUA_INVALID_ID if not found. |
| 3657 | */ |
| 3658 | PJ_DECL(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri); |
| 3659 | |
| 3660 | |
| 3661 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3662 | * Get detailed buddy info. |
| 3663 | * |
| 3664 | * @param buddy_id The buddy identification. |
| 3665 | * @param info Pointer to receive information about buddy. |
| 3666 | * |
| 3667 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3668 | */ |
| 3669 | PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id, |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3670 | pjsua_buddy_info *info); |
| 3671 | |
| 3672 | /** |
Benny Prijono | 705e784 | 2008-07-21 18:12:51 +0000 | [diff] [blame] | 3673 | * Set the user data associated with the buddy object. |
| 3674 | * |
| 3675 | * @param buddy_id The buddy identification. |
| 3676 | * @param user_data Arbitrary application data to be associated with |
| 3677 | * the buddy object. |
| 3678 | * |
| 3679 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3680 | */ |
| 3681 | PJ_DECL(pj_status_t) pjsua_buddy_set_user_data(pjsua_buddy_id buddy_id, |
| 3682 | void *user_data); |
| 3683 | |
| 3684 | |
| 3685 | /** |
| 3686 | * Get the user data associated with the budy object. |
| 3687 | * |
| 3688 | * @param buddy_id The buddy identification. |
| 3689 | * |
| 3690 | * @return The application data. |
| 3691 | */ |
| 3692 | PJ_DECL(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id); |
| 3693 | |
| 3694 | |
| 3695 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3696 | * Add new buddy to the buddy list. If presence subscription is enabled |
| 3697 | * for this buddy, this function will also start the presence subscription |
| 3698 | * session immediately. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3699 | * |
Benny Prijono | a7b376b | 2008-01-25 16:06:33 +0000 | [diff] [blame] | 3700 | * @param buddy_cfg Buddy configuration. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3701 | * @param p_buddy_id Pointer to receive buddy ID. |
| 3702 | * |
| 3703 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3704 | */ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 3705 | PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg, |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3706 | pjsua_buddy_id *p_buddy_id); |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 3707 | |
| 3708 | |
| 3709 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3710 | * Delete the specified buddy from the buddy list. Any presence subscription |
| 3711 | * to this buddy will be terminated. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3712 | * |
| 3713 | * @param buddy_id Buddy identification. |
| 3714 | * |
| 3715 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 3716 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3717 | PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3718 | |
| 3719 | |
| 3720 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3721 | * Enable/disable buddy's presence monitoring. Once buddy's presence is |
| 3722 | * subscribed, application will be informed about buddy's presence status |
| 3723 | * changed via \a on_buddy_state() callback. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3724 | * |
| 3725 | * @param buddy_id Buddy identification. |
| 3726 | * @param subscribe Specify non-zero to activate presence subscription to |
| 3727 | * the specified buddy. |
| 3728 | * |
| 3729 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3730 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3731 | PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id, |
| 3732 | pj_bool_t subscribe); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3733 | |
| 3734 | |
| 3735 | /** |
Benny Prijono | 1086143 | 2007-10-31 10:54:53 +0000 | [diff] [blame] | 3736 | * Update the presence information for the buddy. Although the library |
| 3737 | * periodically refreshes the presence subscription for all buddies, some |
| 3738 | * application may want to refresh the buddy's presence subscription |
| 3739 | * immediately, and in this case it can use this function to accomplish |
| 3740 | * this. |
| 3741 | * |
| 3742 | * Note that the buddy's presence subscription will only be initiated |
| 3743 | * if presence monitoring is enabled for the buddy. See |
| 3744 | * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription |
| 3745 | * for the buddy is already active, this function will not do anything. |
| 3746 | * |
| 3747 | * Once the presence subscription is activated successfully for the buddy, |
| 3748 | * application will be notified about the buddy's presence status in the |
| 3749 | * on_buddy_state() callback. |
| 3750 | * |
| 3751 | * @param buddy_id Buddy identification. |
| 3752 | * |
| 3753 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3754 | */ |
| 3755 | PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id); |
| 3756 | |
| 3757 | |
| 3758 | /** |
Benny Prijono | 63fba01 | 2008-07-17 14:19:10 +0000 | [diff] [blame] | 3759 | * Send NOTIFY to inform account presence status or to terminate server |
| 3760 | * side presence subscription. If application wants to reject the incoming |
| 3761 | * request, it should set the \a state to PJSIP_EVSUB_STATE_TERMINATED. |
| 3762 | * |
| 3763 | * @param acc_id Account ID. |
| 3764 | * @param srv_pres Server presence subscription instance. |
| 3765 | * @param state New state to set. |
| 3766 | * @param state_str Optionally specify the state string name, if state |
| 3767 | * is not "active", "pending", or "terminated". |
| 3768 | * @param reason If the new state is PJSIP_EVSUB_STATE_TERMINATED, |
| 3769 | * optionally specify the termination reason. |
| 3770 | * @param with_body If the new state is PJSIP_EVSUB_STATE_TERMINATED, |
| 3771 | * this specifies whether the NOTIFY request should |
| 3772 | * contain message body containing account's presence |
| 3773 | * information. |
| 3774 | * @param msg_data Optional list of headers to be sent with the NOTIFY |
| 3775 | * request. |
| 3776 | * |
| 3777 | * @return PJ_SUCCESS on success. |
| 3778 | */ |
| 3779 | PJ_DECL(pj_status_t) pjsua_pres_notify(pjsua_acc_id acc_id, |
| 3780 | pjsua_srv_pres *srv_pres, |
| 3781 | pjsip_evsub_state state, |
| 3782 | const pj_str_t *state_str, |
| 3783 | const pj_str_t *reason, |
| 3784 | pj_bool_t with_body, |
| 3785 | const pjsua_msg_data *msg_data); |
| 3786 | |
| 3787 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3788 | * Dump presence subscriptions to log. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3789 | * |
| 3790 | * @param verbose Yes or no. |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 3791 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3792 | PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose); |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 3793 | |
| 3794 | |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 3795 | /** |
| 3796 | * The MESSAGE method (defined in pjsua_im.c) |
| 3797 | */ |
| 3798 | extern const pjsip_method pjsip_message_method; |
| 3799 | |
| 3800 | |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 3801 | |
| 3802 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3803 | * Send instant messaging outside dialog, using the specified account for |
| 3804 | * route set and authentication. |
| 3805 | * |
| 3806 | * @param acc_id Account ID to be used to send the request. |
| 3807 | * @param to Remote URI. |
| 3808 | * @param mime_type Optional MIME type. If NULL, then "text/plain" is |
| 3809 | * assumed. |
| 3810 | * @param content The message content. |
| 3811 | * @param msg_data Optional list of headers etc to be included in outgoing |
| 3812 | * request. The body descriptor in the msg_data is |
| 3813 | * ignored. |
| 3814 | * @param user_data Optional user data, which will be given back when |
| 3815 | * the IM callback is called. |
| 3816 | * |
| 3817 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 3818 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3819 | PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id, |
| 3820 | const pj_str_t *to, |
| 3821 | const pj_str_t *mime_type, |
| 3822 | const pj_str_t *content, |
| 3823 | const pjsua_msg_data *msg_data, |
| 3824 | void *user_data); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 3825 | |
| 3826 | |
| 3827 | /** |
| 3828 | * Send typing indication outside dialog. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3829 | * |
| 3830 | * @param acc_id Account ID to be used to send the request. |
| 3831 | * @param to Remote URI. |
| 3832 | * @param is_typing If non-zero, it tells remote person that local person |
| 3833 | * is currently composing an IM. |
| 3834 | * @param msg_data Optional list of headers etc to be added to outgoing |
| 3835 | * request. |
| 3836 | * |
| 3837 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 3838 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3839 | PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id, |
| 3840 | const pj_str_t *to, |
| 3841 | pj_bool_t is_typing, |
| 3842 | const pjsua_msg_data *msg_data); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 3843 | |
| 3844 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 3845 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3846 | /** |
| 3847 | * @} |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3848 | */ |
| 3849 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3850 | |
| 3851 | /***************************************************************************** |
| 3852 | * MEDIA API |
| 3853 | */ |
| 3854 | |
| 3855 | |
| 3856 | /** |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 3857 | * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3858 | * @ingroup PJSUA_LIB |
| 3859 | * @brief Media manipulation. |
| 3860 | * @{ |
| 3861 | * |
| 3862 | * PJSUA has rather powerful media features, which are built around the |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 3863 | * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV |
| 3864 | * players, WAV playlist, file recorders, sound device, tone generators, etc) |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3865 | * are terminated in the conference bridge, and application can manipulate |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 3866 | * the interconnection between these terminations freely. |
| 3867 | * |
| 3868 | * The conference bridge provides powerful switching and mixing functionality |
| 3869 | * for application. With the conference bridge, each conference slot (e.g. |
| 3870 | * a call) can transmit to multiple destinations, and one destination can |
| 3871 | * receive from multiple sources. If more than one media terminations are |
| 3872 | * terminated in the same slot, the conference bridge will mix the signal |
| 3873 | * automatically. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3874 | * |
| 3875 | * Application connects one media termination/slot to another by calling |
| 3876 | * #pjsua_conf_connect() function. This will establish <b>unidirectional</b> |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 3877 | * media flow from the source termination to the sink termination. To |
| 3878 | * establish bidirectional media flow, application wound need to make another |
| 3879 | * call to #pjsua_conf_connect(), this time inverting the source and |
| 3880 | * destination slots in the parameter. |
| 3881 | * |
| 3882 | * For example, to stream a WAV file to remote call, application may use |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3883 | * the following steps: |
| 3884 | * |
| 3885 | \code |
| 3886 | |
| 3887 | pj_status_t stream_to_call( pjsua_call_id call_id ) |
| 3888 | { |
| 3889 | pjsua_player_id player_id; |
| 3890 | |
| 3891 | status = pjsua_player_create("mysong.wav", 0, NULL, &player_id); |
| 3892 | if (status != PJ_SUCCESS) |
| 3893 | return status; |
| 3894 | |
| 3895 | status = pjsua_conf_connect( pjsua_player_get_conf_port(), |
| 3896 | pjsua_call_get_conf_port() ); |
| 3897 | } |
| 3898 | \endcode |
| 3899 | * |
| 3900 | * |
| 3901 | * Other features of PJSUA media: |
| 3902 | * - efficient N to M interconnections between media terminations. |
| 3903 | * - media termination can be connected to itself to create loopback |
| 3904 | * media. |
| 3905 | * - the media termination may have different clock rates, and resampling |
| 3906 | * will be done automatically by conference bridge. |
| 3907 | * - media terminations may also have different frame time; the |
| 3908 | * conference bridge will perform the necessary bufferring to adjust |
| 3909 | * the difference between terminations. |
| 3910 | * - interconnections are removed automatically when media termination |
| 3911 | * is removed from the bridge. |
| 3912 | * - sound device may be changed even when there are active media |
| 3913 | * interconnections. |
| 3914 | * - correctly report call's media quality (in #pjsua_call_dump()) from |
| 3915 | * RTCP packet exchange. |
| 3916 | */ |
| 3917 | |
| 3918 | /** |
Benny Prijono | 37c710b | 2008-01-10 12:09:26 +0000 | [diff] [blame] | 3919 | * Max ports in the conference bridge. This setting is the default value |
| 3920 | * for pjsua_media_config.max_media_ports. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3921 | */ |
| 3922 | #ifndef PJSUA_MAX_CONF_PORTS |
Benny Prijono | 12a669c | 2006-11-23 07:32:13 +0000 | [diff] [blame] | 3923 | # define PJSUA_MAX_CONF_PORTS 254 |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3924 | #endif |
| 3925 | |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3926 | /** |
Benny Prijono | 37c710b | 2008-01-10 12:09:26 +0000 | [diff] [blame] | 3927 | * The default clock rate to be used by the conference bridge. This setting |
| 3928 | * is the default value for pjsua_media_config.clock_rate. |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3929 | */ |
Benny Prijono | 12a669c | 2006-11-23 07:32:13 +0000 | [diff] [blame] | 3930 | #ifndef PJSUA_DEFAULT_CLOCK_RATE |
| 3931 | # define PJSUA_DEFAULT_CLOCK_RATE 16000 |
| 3932 | #endif |
| 3933 | |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3934 | /** |
Benny Prijono | 37c710b | 2008-01-10 12:09:26 +0000 | [diff] [blame] | 3935 | * Default frame length in the conference bridge. This setting |
| 3936 | * is the default value for pjsua_media_config.audio_frame_ptime. |
| 3937 | */ |
| 3938 | #ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME |
Nanang Izzuddin | af97484 | 2008-05-08 09:51:16 +0000 | [diff] [blame] | 3939 | # define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20 |
Benny Prijono | 37c710b | 2008-01-10 12:09:26 +0000 | [diff] [blame] | 3940 | #endif |
| 3941 | |
| 3942 | |
| 3943 | /** |
| 3944 | * Default codec quality settings. This setting is the default value |
| 3945 | * for pjsua_media_config.quality. |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3946 | */ |
Benny Prijono | 12a669c | 2006-11-23 07:32:13 +0000 | [diff] [blame] | 3947 | #ifndef PJSUA_DEFAULT_CODEC_QUALITY |
Nanang Izzuddin | 9dbad15 | 2008-06-10 18:56:10 +0000 | [diff] [blame] | 3948 | # define PJSUA_DEFAULT_CODEC_QUALITY 8 |
Benny Prijono | 12a669c | 2006-11-23 07:32:13 +0000 | [diff] [blame] | 3949 | #endif |
| 3950 | |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3951 | /** |
Benny Prijono | 37c710b | 2008-01-10 12:09:26 +0000 | [diff] [blame] | 3952 | * Default iLBC mode. This setting is the default value for |
| 3953 | * pjsua_media_config.ilbc_mode. |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3954 | */ |
Benny Prijono | 12a669c | 2006-11-23 07:32:13 +0000 | [diff] [blame] | 3955 | #ifndef PJSUA_DEFAULT_ILBC_MODE |
Benny Prijono | 37c710b | 2008-01-10 12:09:26 +0000 | [diff] [blame] | 3956 | # define PJSUA_DEFAULT_ILBC_MODE 30 |
Benny Prijono | 12a669c | 2006-11-23 07:32:13 +0000 | [diff] [blame] | 3957 | #endif |
| 3958 | |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3959 | /** |
Benny Prijono | 37c710b | 2008-01-10 12:09:26 +0000 | [diff] [blame] | 3960 | * The default echo canceller tail length. This setting |
| 3961 | * is the default value for pjsua_media_config.ec_tail_len. |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3962 | */ |
Benny Prijono | 12a669c | 2006-11-23 07:32:13 +0000 | [diff] [blame] | 3963 | #ifndef PJSUA_DEFAULT_EC_TAIL_LEN |
Benny Prijono | 427439c | 2007-10-21 09:41:24 +0000 | [diff] [blame] | 3964 | # define PJSUA_DEFAULT_EC_TAIL_LEN 200 |
Benny Prijono | 12a669c | 2006-11-23 07:32:13 +0000 | [diff] [blame] | 3965 | #endif |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3966 | |
| 3967 | |
| 3968 | /** |
Benny Prijono | cba59d9 | 2007-02-16 09:22:56 +0000 | [diff] [blame] | 3969 | * The maximum file player. |
| 3970 | */ |
| 3971 | #ifndef PJSUA_MAX_PLAYERS |
| 3972 | # define PJSUA_MAX_PLAYERS 32 |
| 3973 | #endif |
| 3974 | |
| 3975 | |
| 3976 | /** |
| 3977 | * The maximum file player. |
| 3978 | */ |
| 3979 | #ifndef PJSUA_MAX_RECORDERS |
| 3980 | # define PJSUA_MAX_RECORDERS 32 |
| 3981 | #endif |
| 3982 | |
| 3983 | |
| 3984 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3985 | * This structure describes media configuration, which will be specified |
| 3986 | * when calling #pjsua_init(). Application MUST initialize this structure |
| 3987 | * by calling #pjsua_media_config_default(). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3988 | */ |
| 3989 | struct pjsua_media_config |
| 3990 | { |
| 3991 | /** |
| 3992 | * Clock rate to be applied to the conference bridge. |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3993 | * If value is zero, default clock rate will be used |
| 3994 | * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3995 | */ |
| 3996 | unsigned clock_rate; |
| 3997 | |
| 3998 | /** |
Benny Prijono | f3758ee | 2008-02-26 15:32:16 +0000 | [diff] [blame] | 3999 | * Clock rate to be applied when opening the sound device. |
| 4000 | * If value is zero, conference bridge clock rate will be used. |
| 4001 | */ |
| 4002 | unsigned snd_clock_rate; |
| 4003 | |
| 4004 | /** |
Benny Prijono | 7d60d05 | 2008-03-29 12:24:20 +0000 | [diff] [blame] | 4005 | * Channel count be applied when opening the sound device and |
| 4006 | * conference bridge. |
| 4007 | */ |
| 4008 | unsigned channel_count; |
| 4009 | |
| 4010 | /** |
Benny Prijono | cf0b4b2 | 2007-10-06 17:31:09 +0000 | [diff] [blame] | 4011 | * Specify audio frame ptime. The value here will affect the |
| 4012 | * samples per frame of both the sound device and the conference |
| 4013 | * bridge. Specifying lower ptime will normally reduce the |
| 4014 | * latency. |
| 4015 | * |
Benny Prijono | 37c710b | 2008-01-10 12:09:26 +0000 | [diff] [blame] | 4016 | * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME |
Benny Prijono | cf0b4b2 | 2007-10-06 17:31:09 +0000 | [diff] [blame] | 4017 | */ |
| 4018 | unsigned audio_frame_ptime; |
| 4019 | |
| 4020 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4021 | * Specify maximum number of media ports to be created in the |
| 4022 | * conference bridge. Since all media terminate in the bridge |
| 4023 | * (calls, file player, file recorder, etc), the value must be |
| 4024 | * large enough to support all of them. However, the larger |
| 4025 | * the value, the more computations are performed. |
Benny Prijono | 37c710b | 2008-01-10 12:09:26 +0000 | [diff] [blame] | 4026 | * |
| 4027 | * Default value: PJSUA_MAX_CONF_PORTS |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4028 | */ |
| 4029 | unsigned max_media_ports; |
| 4030 | |
| 4031 | /** |
| 4032 | * Specify whether the media manager should manage its own |
| 4033 | * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created |
| 4034 | * and at least one worker thread will be created too. If no, |
| 4035 | * the RTP/RTCP sockets will share the same ioqueue as SIP sockets, |
| 4036 | * and no worker thread is needed. |
| 4037 | * |
| 4038 | * Normally application would say yes here, unless it wants to |
| 4039 | * run everything from a single thread. |
| 4040 | */ |
| 4041 | pj_bool_t has_ioqueue; |
| 4042 | |
| 4043 | /** |
| 4044 | * Specify the number of worker threads to handle incoming RTP |
| 4045 | * packets. A value of one is recommended for most applications. |
| 4046 | */ |
| 4047 | unsigned thread_cnt; |
| 4048 | |
Benny Prijono | 0498d90 | 2006-06-19 14:49:14 +0000 | [diff] [blame] | 4049 | /** |
| 4050 | * Media quality, 0-10, according to this table: |
Benny Prijono | 7ca96da | 2006-08-07 12:11:40 +0000 | [diff] [blame] | 4051 | * 5-10: resampling use large filter, |
| 4052 | * 3-4: resampling use small filter, |
Benny Prijono | 0498d90 | 2006-06-19 14:49:14 +0000 | [diff] [blame] | 4053 | * 1-2: resampling use linear. |
| 4054 | * The media quality also sets speex codec quality/complexity to the |
| 4055 | * number. |
| 4056 | * |
Benny Prijono | 7097299 | 2006-08-05 11:13:58 +0000 | [diff] [blame] | 4057 | * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY). |
Benny Prijono | 0498d90 | 2006-06-19 14:49:14 +0000 | [diff] [blame] | 4058 | */ |
| 4059 | unsigned quality; |
Benny Prijono | 0a12f00 | 2006-07-26 17:05:39 +0000 | [diff] [blame] | 4060 | |
| 4061 | /** |
Benny Prijono | cf0b4b2 | 2007-10-06 17:31:09 +0000 | [diff] [blame] | 4062 | * Specify default codec ptime. |
Benny Prijono | 0a12f00 | 2006-07-26 17:05:39 +0000 | [diff] [blame] | 4063 | * |
| 4064 | * Default: 0 (codec specific) |
| 4065 | */ |
| 4066 | unsigned ptime; |
| 4067 | |
| 4068 | /** |
| 4069 | * Disable VAD? |
| 4070 | * |
| 4071 | * Default: 0 (no (meaning VAD is enabled)) |
| 4072 | */ |
| 4073 | pj_bool_t no_vad; |
Benny Prijono | 00cae61 | 2006-07-31 15:19:36 +0000 | [diff] [blame] | 4074 | |
| 4075 | /** |
| 4076 | * iLBC mode (20 or 30). |
| 4077 | * |
Benny Prijono | 37c710b | 2008-01-10 12:09:26 +0000 | [diff] [blame] | 4078 | * Default: 30 (PJSUA_DEFAULT_ILBC_MODE) |
Benny Prijono | 00cae61 | 2006-07-31 15:19:36 +0000 | [diff] [blame] | 4079 | */ |
| 4080 | unsigned ilbc_mode; |
| 4081 | |
| 4082 | /** |
| 4083 | * Percentage of RTP packet to drop in TX direction |
| 4084 | * (to simulate packet lost). |
| 4085 | * |
| 4086 | * Default: 0 |
| 4087 | */ |
| 4088 | unsigned tx_drop_pct; |
| 4089 | |
| 4090 | /** |
| 4091 | * Percentage of RTP packet to drop in RX direction |
| 4092 | * (to simulate packet lost). |
| 4093 | * |
| 4094 | * Default: 0 |
| 4095 | */ |
| 4096 | unsigned rx_drop_pct; |
| 4097 | |
Benny Prijono | c8e24a1 | 2006-08-02 18:22:22 +0000 | [diff] [blame] | 4098 | /** |
Benny Prijono | 5da5043 | 2006-08-07 10:24:52 +0000 | [diff] [blame] | 4099 | * Echo canceller options (see #pjmedia_echo_create()) |
| 4100 | * |
| 4101 | * Default: 0. |
| 4102 | */ |
| 4103 | unsigned ec_options; |
| 4104 | |
| 4105 | /** |
Benny Prijono | c8e24a1 | 2006-08-02 18:22:22 +0000 | [diff] [blame] | 4106 | * Echo canceller tail length, in miliseconds. |
| 4107 | * |
Benny Prijono | 669643c | 2006-09-20 20:02:18 +0000 | [diff] [blame] | 4108 | * Default: PJSUA_DEFAULT_EC_TAIL_LEN |
Benny Prijono | c8e24a1 | 2006-08-02 18:22:22 +0000 | [diff] [blame] | 4109 | */ |
| 4110 | unsigned ec_tail_len; |
Benny Prijono | 1d0ca0c | 2006-11-21 09:06:47 +0000 | [diff] [blame] | 4111 | |
Benny Prijono | 10454dc | 2009-02-21 14:21:59 +0000 | [diff] [blame] | 4112 | /** |
| 4113 | * Audio capture buffer length, in milliseconds. |
| 4114 | * |
| 4115 | * Default: PJMEDIA_SND_DEFAULT_REC_LATENCY |
| 4116 | */ |
| 4117 | unsigned snd_rec_latency; |
| 4118 | |
| 4119 | /** |
| 4120 | * Audio playback buffer length, in milliseconds. |
| 4121 | * |
| 4122 | * Default: PJMEDIA_SND_DEFAULT_PLAY_LATENCY |
| 4123 | */ |
| 4124 | unsigned snd_play_latency; |
| 4125 | |
Benny Prijono | 1d0ca0c | 2006-11-21 09:06:47 +0000 | [diff] [blame] | 4126 | /** |
| 4127 | * Jitter buffer initial prefetch delay in msec. The value must be |
| 4128 | * between jb_min_pre and jb_max_pre below. |
| 4129 | * |
| 4130 | * Default: -1 (to use default stream settings, currently 150 msec) |
| 4131 | */ |
| 4132 | int jb_init; |
| 4133 | |
| 4134 | /** |
| 4135 | * Jitter buffer minimum prefetch delay in msec. |
| 4136 | * |
| 4137 | * Default: -1 (to use default stream settings, currently 60 msec) |
| 4138 | */ |
| 4139 | int jb_min_pre; |
| 4140 | |
| 4141 | /** |
| 4142 | * Jitter buffer maximum prefetch delay in msec. |
| 4143 | * |
| 4144 | * Default: -1 (to use default stream settings, currently 240 msec) |
| 4145 | */ |
| 4146 | int jb_max_pre; |
| 4147 | |
| 4148 | /** |
| 4149 | * Set maximum delay that can be accomodated by the jitter buffer msec. |
| 4150 | * |
| 4151 | * Default: -1 (to use default stream settings, currently 360 msec) |
| 4152 | */ |
| 4153 | int jb_max; |
| 4154 | |
Benny Prijono | c97608e | 2007-03-23 16:34:20 +0000 | [diff] [blame] | 4155 | /** |
| 4156 | * Enable ICE |
| 4157 | */ |
| 4158 | pj_bool_t enable_ice; |
| 4159 | |
| 4160 | /** |
Benny Prijono | 329d638 | 2009-05-29 13:04:03 +0000 | [diff] [blame] | 4161 | * Set the maximum number of host candidates. |
| 4162 | * |
| 4163 | * Default: -1 (maximum not set) |
Benny Prijono | c97608e | 2007-03-23 16:34:20 +0000 | [diff] [blame] | 4164 | */ |
Benny Prijono | 329d638 | 2009-05-29 13:04:03 +0000 | [diff] [blame] | 4165 | int ice_max_host_cands; |
| 4166 | |
| 4167 | /** |
| 4168 | * ICE session options. |
| 4169 | */ |
| 4170 | pj_ice_sess_options ice_opt; |
Benny Prijono | f76e139 | 2008-06-06 14:51:48 +0000 | [diff] [blame] | 4171 | |
| 4172 | /** |
Benny Prijono | 551af42 | 2008-08-07 09:55:52 +0000 | [diff] [blame] | 4173 | * Disable RTCP component. |
| 4174 | * |
| 4175 | * Default: no |
| 4176 | */ |
| 4177 | pj_bool_t ice_no_rtcp; |
| 4178 | |
| 4179 | /** |
Benny Prijono | f76e139 | 2008-06-06 14:51:48 +0000 | [diff] [blame] | 4180 | * Enable TURN relay candidate in ICE. |
| 4181 | */ |
| 4182 | pj_bool_t enable_turn; |
| 4183 | |
| 4184 | /** |
| 4185 | * Specify TURN domain name or host name, in in "DOMAIN:PORT" or |
| 4186 | * "HOST:PORT" format. |
| 4187 | */ |
| 4188 | pj_str_t turn_server; |
| 4189 | |
| 4190 | /** |
| 4191 | * Specify the connection type to be used to the TURN server. Valid |
| 4192 | * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP. |
| 4193 | * |
| 4194 | * Default: PJ_TURN_TP_UDP |
| 4195 | */ |
| 4196 | pj_turn_tp_type turn_conn_type; |
| 4197 | |
| 4198 | /** |
| 4199 | * Specify the credential to authenticate with the TURN server. |
| 4200 | */ |
| 4201 | pj_stun_auth_cred turn_auth_cred; |
Nanang Izzuddin | 68559c3 | 2008-06-13 17:01:46 +0000 | [diff] [blame] | 4202 | |
| 4203 | /** |
| 4204 | * Specify idle time of sound device before it is automatically closed, |
Benny Prijono | f798e50 | 2009-03-09 13:08:16 +0000 | [diff] [blame] | 4205 | * in seconds. Use value -1 to disable the auto-close feature of sound |
| 4206 | * device |
Nanang Izzuddin | 68559c3 | 2008-06-13 17:01:46 +0000 | [diff] [blame] | 4207 | * |
Benny Prijono | f798e50 | 2009-03-09 13:08:16 +0000 | [diff] [blame] | 4208 | * Default : 1 |
Nanang Izzuddin | 68559c3 | 2008-06-13 17:01:46 +0000 | [diff] [blame] | 4209 | */ |
| 4210 | int snd_auto_close_time; |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4211 | }; |
| 4212 | |
| 4213 | |
| 4214 | /** |
| 4215 | * Use this function to initialize media config. |
| 4216 | * |
| 4217 | * @param cfg The media config to be initialized. |
| 4218 | */ |
Benny Prijono | 1f61a8f | 2007-08-16 10:11:44 +0000 | [diff] [blame] | 4219 | PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4220 | |
| 4221 | |
| 4222 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 4223 | * This structure describes codec information, which can be retrieved by |
| 4224 | * calling #pjsua_enum_codecs(). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4225 | */ |
| 4226 | typedef struct pjsua_codec_info |
| 4227 | { |
| 4228 | /** |
| 4229 | * Codec unique identification. |
| 4230 | */ |
| 4231 | pj_str_t codec_id; |
| 4232 | |
| 4233 | /** |
| 4234 | * Codec priority (integer 0-255). |
| 4235 | */ |
| 4236 | pj_uint8_t priority; |
| 4237 | |
| 4238 | /** |
| 4239 | * Internal buffer. |
| 4240 | */ |
| 4241 | char buf_[32]; |
| 4242 | |
| 4243 | } pjsua_codec_info; |
| 4244 | |
| 4245 | |
| 4246 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 4247 | * This structure descibes information about a particular media port that |
| 4248 | * has been registered into the conference bridge. Application can query |
| 4249 | * this info by calling #pjsua_conf_get_port_info(). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4250 | */ |
| 4251 | typedef struct pjsua_conf_port_info |
| 4252 | { |
| 4253 | /** Conference port number. */ |
| 4254 | pjsua_conf_port_id slot_id; |
| 4255 | |
| 4256 | /** Port name. */ |
| 4257 | pj_str_t name; |
| 4258 | |
| 4259 | /** Clock rate. */ |
| 4260 | unsigned clock_rate; |
| 4261 | |
| 4262 | /** Number of channels. */ |
| 4263 | unsigned channel_count; |
| 4264 | |
| 4265 | /** Samples per frame */ |
| 4266 | unsigned samples_per_frame; |
| 4267 | |
| 4268 | /** Bits per sample */ |
| 4269 | unsigned bits_per_sample; |
| 4270 | |
| 4271 | /** Number of listeners in the array. */ |
| 4272 | unsigned listener_cnt; |
| 4273 | |
| 4274 | /** Array of listeners (in other words, ports where this port is |
| 4275 | * transmitting to. |
| 4276 | */ |
| 4277 | pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS]; |
| 4278 | |
| 4279 | } pjsua_conf_port_info; |
| 4280 | |
| 4281 | |
| 4282 | /** |
| 4283 | * This structure holds information about custom media transport to |
| 4284 | * be registered to pjsua. |
| 4285 | */ |
| 4286 | typedef struct pjsua_media_transport |
| 4287 | { |
| 4288 | /** |
| 4289 | * Media socket information containing the address information |
| 4290 | * of the RTP and RTCP socket. |
| 4291 | */ |
| 4292 | pjmedia_sock_info skinfo; |
| 4293 | |
| 4294 | /** |
| 4295 | * The media transport instance. |
| 4296 | */ |
| 4297 | pjmedia_transport *transport; |
| 4298 | |
| 4299 | } pjsua_media_transport; |
| 4300 | |
| 4301 | |
| 4302 | |
| 4303 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4304 | /** |
| 4305 | * Get maxinum number of conference ports. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4306 | * |
| 4307 | * @return Maximum number of ports in the conference bridge. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4308 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4309 | PJ_DECL(unsigned) pjsua_conf_get_max_ports(void); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4310 | |
| 4311 | |
| 4312 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4313 | * Get current number of active ports in the bridge. |
| 4314 | * |
| 4315 | * @return The number. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4316 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4317 | PJ_DECL(unsigned) pjsua_conf_get_active_ports(void); |
| 4318 | |
| 4319 | |
| 4320 | /** |
| 4321 | * Enumerate all conference ports. |
| 4322 | * |
| 4323 | * @param id Array of conference port ID to be initialized. |
| 4324 | * @param count On input, specifies max elements in the array. |
| 4325 | * On return, it contains actual number of elements |
| 4326 | * that have been initialized. |
| 4327 | * |
| 4328 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4329 | */ |
| 4330 | PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[], |
| 4331 | unsigned *count); |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 4332 | |
| 4333 | |
| 4334 | /** |
| 4335 | * Get information about the specified conference port |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4336 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4337 | * @param port_id Port identification. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4338 | * @param info Pointer to store the port info. |
| 4339 | * |
| 4340 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 4341 | */ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4342 | PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id, |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 4343 | pjsua_conf_port_info *info); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4344 | |
| 4345 | |
| 4346 | /** |
Benny Prijono | e909eac | 2006-07-27 22:04:56 +0000 | [diff] [blame] | 4347 | * Add arbitrary media port to PJSUA's conference bridge. Application |
| 4348 | * can use this function to add the media port that it creates. For |
| 4349 | * media ports that are created by PJSUA-LIB (such as calls, file player, |
| 4350 | * or file recorder), PJSUA-LIB will automatically add the port to |
| 4351 | * the bridge. |
| 4352 | * |
| 4353 | * @param pool Pool to use. |
| 4354 | * @param port Media port to be added to the bridge. |
| 4355 | * @param p_id Optional pointer to receive the conference |
| 4356 | * slot id. |
| 4357 | * |
| 4358 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4359 | */ |
| 4360 | PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool, |
| 4361 | pjmedia_port *port, |
| 4362 | pjsua_conf_port_id *p_id); |
| 4363 | |
| 4364 | |
| 4365 | /** |
| 4366 | * Remove arbitrary slot from the conference bridge. Application should only |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 4367 | * call this function if it registered the port manually with previous call |
| 4368 | * to #pjsua_conf_add_port(). |
Benny Prijono | e909eac | 2006-07-27 22:04:56 +0000 | [diff] [blame] | 4369 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4370 | * @param port_id The slot id of the port to be removed. |
Benny Prijono | e909eac | 2006-07-27 22:04:56 +0000 | [diff] [blame] | 4371 | * |
| 4372 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4373 | */ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4374 | PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id); |
Benny Prijono | e909eac | 2006-07-27 22:04:56 +0000 | [diff] [blame] | 4375 | |
| 4376 | |
| 4377 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4378 | * Establish unidirectional media flow from souce to sink. One source |
| 4379 | * may transmit to multiple destinations/sink. And if multiple |
| 4380 | * sources are transmitting to the same sink, the media will be mixed |
| 4381 | * together. Source and sink may refer to the same ID, effectively |
| 4382 | * looping the media. |
| 4383 | * |
| 4384 | * If bidirectional media flow is desired, application needs to call |
| 4385 | * this function twice, with the second one having the arguments |
| 4386 | * reversed. |
| 4387 | * |
| 4388 | * @param source Port ID of the source media/transmitter. |
| 4389 | * @param sink Port ID of the destination media/received. |
| 4390 | * |
| 4391 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4392 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4393 | PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source, |
| 4394 | pjsua_conf_port_id sink); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4395 | |
| 4396 | |
| 4397 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4398 | * Disconnect media flow from the source to destination port. |
| 4399 | * |
| 4400 | * @param source Port ID of the source media/transmitter. |
| 4401 | * @param sink Port ID of the destination media/received. |
| 4402 | * |
| 4403 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4404 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4405 | PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source, |
| 4406 | pjsua_conf_port_id sink); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4407 | |
| 4408 | |
Benny Prijono | 6dd967c | 2006-12-26 02:27:14 +0000 | [diff] [blame] | 4409 | /** |
| 4410 | * Adjust the signal level to be transmitted from the bridge to the |
| 4411 | * specified port by making it louder or quieter. |
| 4412 | * |
| 4413 | * @param slot The conference bridge slot number. |
| 4414 | * @param level Signal level adjustment. Value 1.0 means no level |
| 4415 | * adjustment, while value 0 means to mute the port. |
| 4416 | * |
| 4417 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4418 | */ |
| 4419 | PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot, |
| 4420 | float level); |
| 4421 | |
| 4422 | /** |
| 4423 | * Adjust the signal level to be received from the specified port (to |
| 4424 | * the bridge) by making it louder or quieter. |
| 4425 | * |
| 4426 | * @param slot The conference bridge slot number. |
| 4427 | * @param level Signal level adjustment. Value 1.0 means no level |
| 4428 | * adjustment, while value 0 means to mute the port. |
| 4429 | * |
| 4430 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4431 | */ |
| 4432 | PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot, |
| 4433 | float level); |
| 4434 | |
| 4435 | /** |
| 4436 | * Get last signal level transmitted to or received from the specified port. |
| 4437 | * The signal level is an integer value in zero to 255, with zero indicates |
| 4438 | * no signal, and 255 indicates the loudest signal level. |
| 4439 | * |
| 4440 | * @param slot The conference bridge slot number. |
| 4441 | * @param tx_level Optional argument to receive the level of signal |
| 4442 | * transmitted to the specified port (i.e. the direction |
| 4443 | * is from the bridge to the port). |
| 4444 | * @param rx_level Optional argument to receive the level of signal |
| 4445 | * received from the port (i.e. the direction is from the |
| 4446 | * port to the bridge). |
| 4447 | * |
| 4448 | * @return PJ_SUCCESS on success. |
| 4449 | */ |
| 4450 | PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot, |
| 4451 | unsigned *tx_level, |
| 4452 | unsigned *rx_level); |
| 4453 | |
Benny Prijono | 6dd967c | 2006-12-26 02:27:14 +0000 | [diff] [blame] | 4454 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4455 | /***************************************************************************** |
Benny Prijono | a66c331 | 2007-01-21 23:12:40 +0000 | [diff] [blame] | 4456 | * File player and playlist. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4457 | */ |
| 4458 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4459 | /** |
Benny Prijono | a66c331 | 2007-01-21 23:12:40 +0000 | [diff] [blame] | 4460 | * Create a file player, and automatically add this player to |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4461 | * the conference bridge. |
| 4462 | * |
| 4463 | * @param filename The filename to be played. Currently only |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4464 | * WAV files are supported, and the WAV file MUST be |
| 4465 | * formatted as 16bit PCM mono/single channel (any |
| 4466 | * clock rate is supported). |
Benny Prijono | 58add7c | 2008-01-18 13:24:07 +0000 | [diff] [blame] | 4467 | * @param options Optional option flag. Application may specify |
| 4468 | * PJMEDIA_FILE_NO_LOOP to prevent playback loop. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4469 | * @param p_id Pointer to receive player ID. |
| 4470 | * |
| 4471 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4472 | */ |
| 4473 | PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename, |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4474 | unsigned options, |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4475 | pjsua_player_id *p_id); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4476 | |
| 4477 | |
| 4478 | /** |
Benny Prijono | a66c331 | 2007-01-21 23:12:40 +0000 | [diff] [blame] | 4479 | * Create a file playlist media port, and automatically add the port |
| 4480 | * to the conference bridge. |
| 4481 | * |
| 4482 | * @param file_names Array of file names to be added to the play list. |
| 4483 | * Note that the files must have the same clock rate, |
| 4484 | * number of channels, and number of bits per sample. |
| 4485 | * @param file_count Number of files in the array. |
| 4486 | * @param label Optional label to be set for the media port. |
| 4487 | * @param options Optional option flag. Application may specify |
| 4488 | * PJMEDIA_FILE_NO_LOOP to prevent looping. |
| 4489 | * @param p_id Optional pointer to receive player ID. |
| 4490 | * |
| 4491 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4492 | */ |
| 4493 | PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[], |
| 4494 | unsigned file_count, |
| 4495 | const pj_str_t *label, |
| 4496 | unsigned options, |
| 4497 | pjsua_player_id *p_id); |
| 4498 | |
| 4499 | /** |
| 4500 | * Get conference port ID associated with player or playlist. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4501 | * |
| 4502 | * @param id The file player ID. |
| 4503 | * |
| 4504 | * @return Conference port ID associated with this player. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4505 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 4506 | PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4507 | |
| 4508 | |
| 4509 | /** |
Benny Prijono | a66c331 | 2007-01-21 23:12:40 +0000 | [diff] [blame] | 4510 | * Get the media port for the player or playlist. |
Benny Prijono | 469b152 | 2006-12-26 03:05:17 +0000 | [diff] [blame] | 4511 | * |
| 4512 | * @param id The player ID. |
| 4513 | * @param p_port The media port associated with the player. |
| 4514 | * |
| 4515 | * @return PJ_SUCCESS on success. |
| 4516 | */ |
Benny Prijono | 58add7c | 2008-01-18 13:24:07 +0000 | [diff] [blame] | 4517 | PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id, |
Benny Prijono | 469b152 | 2006-12-26 03:05:17 +0000 | [diff] [blame] | 4518 | pjmedia_port **p_port); |
| 4519 | |
| 4520 | /** |
Benny Prijono | a66c331 | 2007-01-21 23:12:40 +0000 | [diff] [blame] | 4521 | * Set playback position. This operation is not valid for playlist. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4522 | * |
| 4523 | * @param id The file player ID. |
| 4524 | * @param samples The playback position, in samples. Application can |
| 4525 | * specify zero to re-start the playback. |
| 4526 | * |
| 4527 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4528 | */ |
| 4529 | PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id, |
| 4530 | pj_uint32_t samples); |
| 4531 | |
| 4532 | |
| 4533 | /** |
Benny Prijono | a66c331 | 2007-01-21 23:12:40 +0000 | [diff] [blame] | 4534 | * Close the file of playlist, remove the player from the bridge, and free |
| 4535 | * resources associated with the file player or playlist. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4536 | * |
| 4537 | * @param id The file player ID. |
| 4538 | * |
| 4539 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4540 | */ |
| 4541 | PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id); |
| 4542 | |
| 4543 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4544 | /***************************************************************************** |
| 4545 | * File recorder. |
| 4546 | */ |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4547 | |
| 4548 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4549 | * Create a file recorder, and automatically connect this recorder to |
Benny Prijono | c95a0f0 | 2007-04-09 07:06:08 +0000 | [diff] [blame] | 4550 | * the conference bridge. The recorder currently supports recording WAV file. |
| 4551 | * The type of the recorder to use is determined by the extension of the file |
| 4552 | * (e.g. ".wav"). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4553 | * |
Benny Prijono | b3cdb2b | 2006-10-19 15:49:47 +0000 | [diff] [blame] | 4554 | * @param filename Output file name. The function will determine the |
| 4555 | * default format to be used based on the file extension. |
Benny Prijono | c95a0f0 | 2007-04-09 07:06:08 +0000 | [diff] [blame] | 4556 | * Currently ".wav" is supported on all platforms. |
Benny Prijono | 8f31052 | 2006-10-20 11:08:49 +0000 | [diff] [blame] | 4557 | * @param enc_type Optionally specify the type of encoder to be used to |
| 4558 | * compress the media, if the file can support different |
| 4559 | * encodings. This value must be zero for now. |
| 4560 | * @param enc_param Optionally specify codec specific parameter to be |
Benny Prijono | c95a0f0 | 2007-04-09 07:06:08 +0000 | [diff] [blame] | 4561 | * passed to the file writer. |
Benny Prijono | 8f31052 | 2006-10-20 11:08:49 +0000 | [diff] [blame] | 4562 | * For .WAV recorder, this value must be NULL. |
| 4563 | * @param max_size Maximum file size. Specify zero or -1 to remove size |
| 4564 | * limitation. This value must be zero or -1 for now. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4565 | * @param options Optional options. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4566 | * @param p_id Pointer to receive the recorder instance. |
| 4567 | * |
| 4568 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4569 | */ |
| 4570 | PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename, |
Benny Prijono | 8f31052 | 2006-10-20 11:08:49 +0000 | [diff] [blame] | 4571 | unsigned enc_type, |
| 4572 | void *enc_param, |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4573 | pj_ssize_t max_size, |
| 4574 | unsigned options, |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4575 | pjsua_recorder_id *p_id); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4576 | |
| 4577 | |
| 4578 | /** |
| 4579 | * Get conference port associated with recorder. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4580 | * |
| 4581 | * @param id The recorder ID. |
| 4582 | * |
| 4583 | * @return Conference port ID associated with this recorder. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4584 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 4585 | PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4586 | |
| 4587 | |
| 4588 | /** |
Benny Prijono | 469b152 | 2006-12-26 03:05:17 +0000 | [diff] [blame] | 4589 | * Get the media port for the recorder. |
| 4590 | * |
| 4591 | * @param id The recorder ID. |
| 4592 | * @param p_port The media port associated with the recorder. |
| 4593 | * |
| 4594 | * @return PJ_SUCCESS on success. |
| 4595 | */ |
| 4596 | PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id, |
| 4597 | pjmedia_port **p_port); |
| 4598 | |
| 4599 | |
| 4600 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4601 | * Destroy recorder (this will complete recording). |
| 4602 | * |
| 4603 | * @param id The recorder ID. |
| 4604 | * |
| 4605 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4606 | */ |
| 4607 | PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id); |
| 4608 | |
| 4609 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4610 | /***************************************************************************** |
| 4611 | * Sound devices. |
| 4612 | */ |
| 4613 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4614 | /** |
Benny Prijono | f798e50 | 2009-03-09 13:08:16 +0000 | [diff] [blame] | 4615 | * Enum all audio devices installed in the system. |
| 4616 | * |
| 4617 | * @param info Array of info to be initialized. |
| 4618 | * @param count On input, specifies max elements in the array. |
| 4619 | * On return, it contains actual number of elements |
| 4620 | * that have been initialized. |
| 4621 | * |
| 4622 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4623 | */ |
| 4624 | PJ_DECL(pj_status_t) pjsua_enum_aud_devs(pjmedia_aud_dev_info info[], |
| 4625 | unsigned *count); |
| 4626 | |
| 4627 | /** |
| 4628 | * Enum all sound devices installed in the system (old API). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4629 | * |
| 4630 | * @param info Array of info to be initialized. |
| 4631 | * @param count On input, specifies max elements in the array. |
| 4632 | * On return, it contains actual number of elements |
| 4633 | * that have been initialized. |
| 4634 | * |
| 4635 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4636 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4637 | PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[], |
| 4638 | unsigned *count); |
Benny Prijono | a3cbb1c | 2006-08-25 12:41:05 +0000 | [diff] [blame] | 4639 | |
| 4640 | /** |
| 4641 | * Get currently active sound devices. If sound devices has not been created |
| 4642 | * (for example when pjsua_start() is not called), it is possible that |
| 4643 | * the function returns PJ_SUCCESS with -1 as device IDs. |
| 4644 | * |
| 4645 | * @param capture_dev On return it will be filled with device ID of the |
| 4646 | * capture device. |
| 4647 | * @param playback_dev On return it will be filled with device ID of the |
| 4648 | * device ID of the playback device. |
| 4649 | * |
| 4650 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4651 | */ |
| 4652 | PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev, |
| 4653 | int *playback_dev); |
| 4654 | |
| 4655 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4656 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4657 | * Select or change sound device. Application may call this function at |
| 4658 | * any time to replace current sound device. |
| 4659 | * |
| 4660 | * @param capture_dev Device ID of the capture device. |
| 4661 | * @param playback_dev Device ID of the playback device. |
| 4662 | * |
| 4663 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4664 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4665 | PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev, |
| 4666 | int playback_dev); |
| 4667 | |
| 4668 | |
| 4669 | /** |
| 4670 | * Set pjsua to use null sound device. The null sound device only provides |
| 4671 | * the timing needed by the conference bridge, and will not interract with |
| 4672 | * any hardware. |
| 4673 | * |
| 4674 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4675 | */ |
| 4676 | PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void); |
| 4677 | |
| 4678 | |
Benny Prijono | e909eac | 2006-07-27 22:04:56 +0000 | [diff] [blame] | 4679 | /** |
| 4680 | * Disconnect the main conference bridge from any sound devices, and let |
| 4681 | * application connect the bridge to it's own sound device/master port. |
| 4682 | * |
| 4683 | * @return The port interface of the conference bridge, |
| 4684 | * so that application can connect this to it's own |
| 4685 | * sound device or master port. |
| 4686 | */ |
| 4687 | PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void); |
| 4688 | |
| 4689 | |
Benny Prijono | f20687a | 2006-08-04 18:27:19 +0000 | [diff] [blame] | 4690 | /** |
Benny Prijono | e506c8c | 2009-03-10 13:28:43 +0000 | [diff] [blame] | 4691 | * Change the echo cancellation settings. |
Benny Prijono | f798e50 | 2009-03-09 13:08:16 +0000 | [diff] [blame] | 4692 | * |
| 4693 | * The behavior of this function depends on whether the sound device is |
| 4694 | * currently active, and if it is, whether device or software AEC is |
| 4695 | * being used. |
Benny Prijono | 10454dc | 2009-02-21 14:21:59 +0000 | [diff] [blame] | 4696 | * |
| 4697 | * If the sound device is currently active, and if the device supports AEC, |
| 4698 | * this function will forward the change request to the device and it will |
| 4699 | * be up to the device on whether support the request. If software AEC is |
| 4700 | * being used (the software EC will be used if the device does not support |
| 4701 | * AEC), this function will change the software EC settings. In all cases, |
| 4702 | * the setting will be saved for future opening of the sound device. |
| 4703 | * |
| 4704 | * If the sound device is not currently active, this will only change the |
| 4705 | * default AEC settings and the setting will be applied next time the |
| 4706 | * sound device is opened. |
Benny Prijono | f20687a | 2006-08-04 18:27:19 +0000 | [diff] [blame] | 4707 | * |
| 4708 | * @param tail_ms The tail length, in miliseconds. Set to zero to |
| 4709 | * disable AEC. |
Benny Prijono | a7b376b | 2008-01-25 16:06:33 +0000 | [diff] [blame] | 4710 | * @param options Options to be passed to pjmedia_echo_create(). |
Benny Prijono | 5da5043 | 2006-08-07 10:24:52 +0000 | [diff] [blame] | 4711 | * Normally the value should be zero. |
Benny Prijono | f20687a | 2006-08-04 18:27:19 +0000 | [diff] [blame] | 4712 | * |
| 4713 | * @return PJ_SUCCESS on success. |
| 4714 | */ |
Benny Prijono | 5da5043 | 2006-08-07 10:24:52 +0000 | [diff] [blame] | 4715 | PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options); |
Benny Prijono | f20687a | 2006-08-04 18:27:19 +0000 | [diff] [blame] | 4716 | |
| 4717 | |
| 4718 | /** |
Benny Prijono | e506c8c | 2009-03-10 13:28:43 +0000 | [diff] [blame] | 4719 | * Get current echo canceller tail length. |
Benny Prijono | f20687a | 2006-08-04 18:27:19 +0000 | [diff] [blame] | 4720 | * |
| 4721 | * @param p_tail_ms Pointer to receive the tail length, in miliseconds. |
| 4722 | * If AEC is disabled, the value will be zero. |
| 4723 | * |
| 4724 | * @return PJ_SUCCESS on success. |
| 4725 | */ |
Benny Prijono | 22dfe59 | 2006-08-06 12:07:13 +0000 | [diff] [blame] | 4726 | PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms); |
Benny Prijono | f20687a | 2006-08-04 18:27:19 +0000 | [diff] [blame] | 4727 | |
| 4728 | |
Nanang Izzuddin | 0cb3b02 | 2009-02-27 17:37:35 +0000 | [diff] [blame] | 4729 | /** |
Benny Prijono | f798e50 | 2009-03-09 13:08:16 +0000 | [diff] [blame] | 4730 | * Check whether the sound device is currently active. The sound device |
| 4731 | * may be inactive if the application has set the auto close feature to |
| 4732 | * non-zero (the snd_auto_close_time setting in #pjsua_media_config), or |
| 4733 | * if null sound device or no sound device has been configured via the |
| 4734 | * #pjsua_set_no_snd_dev() function. |
Nanang Izzuddin | 0cb3b02 | 2009-02-27 17:37:35 +0000 | [diff] [blame] | 4735 | */ |
Benny Prijono | f798e50 | 2009-03-09 13:08:16 +0000 | [diff] [blame] | 4736 | PJ_DECL(pj_bool_t) pjsua_snd_is_active(void); |
| 4737 | |
| 4738 | |
| 4739 | /** |
| 4740 | * Configure sound device setting to the sound device being used. If sound |
| 4741 | * device is currently active, the function will forward the setting to the |
| 4742 | * sound device instance to be applied immediately, if it supports it. |
| 4743 | * |
| 4744 | * The setting will be saved for future opening of the sound device, if the |
| 4745 | * "keep" argument is set to non-zero. If the sound device is currently |
| 4746 | * inactive, and the "keep" argument is false, this function will return |
| 4747 | * error. |
| 4748 | * |
| 4749 | * Note that in case the setting is kept for future use, it will be applied |
| 4750 | * to any devices, even when application has changed the sound device to be |
| 4751 | * used. |
| 4752 | * |
Benny Prijono | e506c8c | 2009-03-10 13:28:43 +0000 | [diff] [blame] | 4753 | * Note also that the echo cancellation setting should be set with |
| 4754 | * #pjsua_set_ec() API instead. |
| 4755 | * |
Benny Prijono | f798e50 | 2009-03-09 13:08:16 +0000 | [diff] [blame] | 4756 | * See also #pjmedia_aud_stream_set_cap() for more information about setting |
| 4757 | * an audio device capability. |
| 4758 | * |
| 4759 | * @param cap The sound device setting to change. |
| 4760 | * @param pval Pointer to value. Please see #pjmedia_aud_dev_cap |
| 4761 | * documentation about the type of value to be |
| 4762 | * supplied for each setting. |
| 4763 | * @param keep Specify whether the setting is to be kept for future |
| 4764 | * use. |
| 4765 | * |
| 4766 | * @return PJ_SUCCESS on success or the appropriate error code. |
| 4767 | */ |
| 4768 | PJ_DECL(pj_status_t) pjsua_snd_set_setting(pjmedia_aud_dev_cap cap, |
| 4769 | const void *pval, |
| 4770 | pj_bool_t keep); |
| 4771 | |
| 4772 | /** |
| 4773 | * Retrieve a sound device setting. If sound device is currently active, |
| 4774 | * the function will forward the request to the sound device. If sound device |
| 4775 | * is currently inactive, and if application had previously set the setting |
| 4776 | * and mark the setting as kept, then that setting will be returned. |
| 4777 | * Otherwise, this function will return error. |
| 4778 | * |
Benny Prijono | e506c8c | 2009-03-10 13:28:43 +0000 | [diff] [blame] | 4779 | * Note that echo cancellation settings should be retrieved with |
| 4780 | * #pjsua_get_ec_tail() API instead. |
| 4781 | * |
Benny Prijono | f798e50 | 2009-03-09 13:08:16 +0000 | [diff] [blame] | 4782 | * @param cap The sound device setting to retrieve. |
| 4783 | * @param pval Pointer to receive the value. |
| 4784 | * Please see #pjmedia_aud_dev_cap documentation about |
| 4785 | * the type of value to be supplied for each setting. |
| 4786 | * |
| 4787 | * @return PJ_SUCCESS on success or the appropriate error code. |
| 4788 | */ |
| 4789 | PJ_DECL(pj_status_t) pjsua_snd_get_setting(pjmedia_aud_dev_cap cap, |
| 4790 | void *pval); |
Nanang Izzuddin | 0cb3b02 | 2009-02-27 17:37:35 +0000 | [diff] [blame] | 4791 | |
| 4792 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4793 | /***************************************************************************** |
| 4794 | * Codecs. |
| 4795 | */ |
| 4796 | |
| 4797 | /** |
| 4798 | * Enum all supported codecs in the system. |
| 4799 | * |
| 4800 | * @param id Array of ID to be initialized. |
| 4801 | * @param count On input, specifies max elements in the array. |
| 4802 | * On return, it contains actual number of elements |
| 4803 | * that have been initialized. |
| 4804 | * |
| 4805 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4806 | */ |
| 4807 | PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[], |
| 4808 | unsigned *count ); |
| 4809 | |
| 4810 | |
| 4811 | /** |
| 4812 | * Change codec priority. |
| 4813 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4814 | * @param codec_id Codec ID, which is a string that uniquely identify |
| 4815 | * the codec (such as "speex/8000"). Please see pjsua |
| 4816 | * manual or pjmedia codec reference for details. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4817 | * @param priority Codec priority, 0-255, where zero means to disable |
| 4818 | * the codec. |
| 4819 | * |
| 4820 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4821 | */ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4822 | PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id, |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4823 | pj_uint8_t priority ); |
| 4824 | |
| 4825 | |
| 4826 | /** |
| 4827 | * Get codec parameters. |
| 4828 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4829 | * @param codec_id Codec ID. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4830 | * @param param Structure to receive codec parameters. |
| 4831 | * |
| 4832 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4833 | */ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4834 | PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id, |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4835 | pjmedia_codec_param *param ); |
| 4836 | |
| 4837 | |
| 4838 | /** |
| 4839 | * Set codec parameters. |
| 4840 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4841 | * @param codec_id Codec ID. |
Nanang Izzuddin | 06839e7 | 2010-01-27 11:48:31 +0000 | [diff] [blame] | 4842 | * @param param Codec parameter to set. Set to NULL to reset |
| 4843 | * codec parameter to library default settings. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4844 | * |
| 4845 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4846 | */ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4847 | PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id, |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4848 | const pjmedia_codec_param *param); |
| 4849 | |
| 4850 | |
| 4851 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4852 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4853 | /** |
| 4854 | * Create UDP media transports for all the calls. This function creates |
| 4855 | * one UDP media transport for each call. |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 4856 | * |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4857 | * @param cfg Media transport configuration. The "port" field in the |
| 4858 | * configuration is used as the start port to bind the |
| 4859 | * sockets. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4860 | * |
| 4861 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 4862 | */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4863 | PJ_DECL(pj_status_t) |
| 4864 | pjsua_media_transports_create(const pjsua_transport_config *cfg); |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 4865 | |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 4866 | |
| 4867 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4868 | * Register custom media transports to be used by calls. There must |
| 4869 | * enough media transports for all calls. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4870 | * |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4871 | * @param tp The media transport array. |
| 4872 | * @param count Number of elements in the array. This number MUST |
| 4873 | * match the number of maximum calls configured when |
| 4874 | * pjsua is created. |
| 4875 | * @param auto_delete Flag to indicate whether the transports should be |
| 4876 | * destroyed when pjsua is shutdown. |
| 4877 | * |
| 4878 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 4879 | */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4880 | PJ_DECL(pj_status_t) |
| 4881 | pjsua_media_transports_attach( pjsua_media_transport tp[], |
| 4882 | unsigned count, |
| 4883 | pj_bool_t auto_delete); |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 4884 | |
| 4885 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4886 | /** |
| 4887 | * @} |
| 4888 | */ |
| 4889 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 4890 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 4891 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4892 | /** |
| 4893 | * @} |
| 4894 | */ |
| 4895 | |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4896 | PJ_END_DECL |
| 4897 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4898 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 4899 | #endif /* __PJSUA_H__ */ |