Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
| 3 | * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
| 19 | #ifndef __PJSUA_H__ |
| 20 | #define __PJSUA_H__ |
| 21 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 22 | /** |
| 23 | * @file pjsua.h |
| 24 | * @brief PJSUA API. |
| 25 | */ |
| 26 | |
| 27 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 28 | /* Include all PJSIP core headers. */ |
| 29 | #include <pjsip.h> |
| 30 | |
| 31 | /* Include all PJMEDIA headers. */ |
| 32 | #include <pjmedia.h> |
| 33 | |
Benny Prijono | 1f9afba | 2006-02-10 15:57:32 +0000 | [diff] [blame] | 34 | /* Include all PJMEDIA-CODEC headers. */ |
| 35 | #include <pjmedia-codec.h> |
| 36 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 37 | /* Include all PJSIP-UA headers */ |
| 38 | #include <pjsip_ua.h> |
| 39 | |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 40 | /* Include all PJSIP-SIMPLE headers */ |
| 41 | #include <pjsip_simple.h> |
| 42 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 43 | /* Include all PJLIB-UTIL headers. */ |
| 44 | #include <pjlib-util.h> |
| 45 | |
| 46 | /* Include all PJLIB headers. */ |
| 47 | #include <pjlib.h> |
| 48 | |
| 49 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 50 | /** |
| 51 | * @defgroup PJSUA_LIB PJSUA API |
| 52 | * @ingroup PJSIP |
| 53 | * @brief Very high level API for constructing SIP UA applications. |
| 54 | * @{ |
| 55 | * |
| 56 | * PJSUA API is very high level API for constructing SIP user agent |
| 57 | * applications. It wraps together the signaling and media functionalities |
| 58 | * into an easy to use call API, provides account management, buddy |
| 59 | * management, presence, instant messaging, along with multimedia |
| 60 | * features such as conferencing, file streaming, local playback, |
| 61 | * voice recording, and so on. |
| 62 | * |
| 63 | * Application must link with <b>pjsua-lib</b> to use this API. In addition, |
| 64 | * this library depends on the following libraries: |
| 65 | * - <b>pjsip-ua</b>, |
| 66 | * - <b>pjsip-simple</b>, |
| 67 | * - <b>pjsip-core</b>, |
| 68 | * - <b>pjmedia</b>, |
| 69 | * - <b>pjmedia-codec</b>, |
| 70 | * - <b>pjlib-util</b>, and |
| 71 | * - <b>pjlib</b>, |
| 72 | * |
| 73 | * so application must also link with these libraries as well. |
| 74 | * |
| 75 | * @section root_using_pjsua_lib Using PJSUA API |
| 76 | * |
| 77 | * Please refer to @ref using_pjsua_lib on how to use PJSUA API. |
| 78 | */ |
| 79 | |
Benny Prijono | 1a01ad3 | 2006-02-07 21:13:28 +0000 | [diff] [blame] | 80 | PJ_BEGIN_DECL |
| 81 | |
Benny Prijono | 632ce71 | 2006-02-09 14:01:40 +0000 | [diff] [blame] | 82 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 83 | /** Forward declaration */ |
| 84 | typedef struct pjsua_media_config pjsua_media_config; |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 85 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 86 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 87 | /***************************************************************************** |
| 88 | * BASE API |
| 89 | */ |
| 90 | |
Benny Prijono | f04ffdd | 2006-02-21 00:11:18 +0000 | [diff] [blame] | 91 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 92 | * @defgroup PJSUA_LIB_BASE Base API |
| 93 | * @ingroup PJSUA_LIB |
| 94 | * @brief Basic application creation/initialization, logging configuration, etc. |
| 95 | * @{ |
| 96 | * |
| 97 | * The base PJSUA API controls PJSUA creation, initialization, and startup, and |
| 98 | * also provides various auxiliary functions. |
| 99 | * |
| 100 | * @section using_pjsua_lib Using PJSUA Library |
| 101 | * |
| 102 | * @subsection creating_pjsua_lib Creating PJSUA |
| 103 | * |
| 104 | * Before anything else, application must create PJSUA by calling #pjsua_create(). |
| 105 | * This, among other things, will initialize PJLIB, which is crucial before |
| 106 | * any PJLIB functions can be called. |
| 107 | * |
| 108 | * @subsection init_pjsua_lib Initializing PJSUA |
| 109 | * |
| 110 | * After PJSUA is created, application can initialize PJSUA by calling |
| 111 | * #pjsua_init(). This function takes several configuration settings in the |
| 112 | * argument, so application normally would want to set these configuration |
| 113 | * before passing them to #pjsua_init(). |
| 114 | * |
| 115 | * Sample code to initialize PJSUA: |
| 116 | \code |
| 117 | |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 118 | #include <pjsua-lib/pjsua.h> |
| 119 | |
| 120 | #define THIS_FILE __FILE__ |
| 121 | |
| 122 | static pj_status_t app_init(void) |
| 123 | { |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 124 | pjsua_config ua_cfg; |
| 125 | pjsua_logging_config log_cfg; |
| 126 | pjsua_media_config media_cfg; |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 127 | pj_status_t status; |
| 128 | |
| 129 | // Must create pjsua before anything else! |
| 130 | status = pjsua_create(); |
| 131 | if (status != PJ_SUCCESS) { |
| 132 | pjsua_perror(THIS_FILE, "Error initializing pjsua", status); |
| 133 | return status; |
| 134 | } |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 135 | |
| 136 | // Initialize configs with default settings. |
| 137 | pjsua_config_default(&ua_cfg); |
| 138 | pjsua_logging_config_default(&log_cfg); |
| 139 | pjsua_media_config_default(&media_cfg); |
| 140 | |
| 141 | // At the very least, application would want to override |
| 142 | // the call callbacks in pjsua_config: |
| 143 | ua_cfg.cb.on_incoming_call = ... |
| 144 | ua_cfg.cb.on_call_state = .. |
| 145 | ... |
| 146 | |
| 147 | // Customize other settings (or initialize them from application specific |
| 148 | // configuration file): |
| 149 | ... |
| 150 | |
| 151 | // Initialize pjsua |
| 152 | status = pjsua_init(&ua_cfg, &log_cfg, &media_cfg); |
| 153 | if (status != PJ_SUCCESS) { |
| 154 | pjsua_perror(THIS_FILE, "Error initializing pjsua", status); |
| 155 | return status; |
| 156 | } |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 157 | . |
| 158 | ... |
| 159 | } |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 160 | \endcode |
| 161 | * |
| 162 | * @subsection other_init_pjsua_lib Other Initialization |
| 163 | * |
| 164 | * After PJSUA is initialized with #pjsua_init(), application will normally |
| 165 | * need/want to perform the following tasks: |
| 166 | * |
| 167 | * - create SIP transport with #pjsua_transport_create(). Please see |
| 168 | * @ref PJSUA_LIB_TRANSPORT section for more info. |
| 169 | * - create one or more SIP accounts with #pjsua_acc_add() or |
| 170 | * #pjsua_acc_add_local(). Please see @ref PJSUA_LIB_ACC for more info. |
| 171 | * - add one or more buddies with #pjsua_buddy_add(). Please see |
| 172 | * @ref PJSUA_LIB_BUDDY section for more info. |
| 173 | * - optionally configure the sound device, codec settings, and other |
| 174 | * media settings. Please see @ref PJSUA_LIB_MEDIA for more info. |
| 175 | * |
| 176 | * |
| 177 | * @subsection starting_pjsua_lib Starting PJSUA |
| 178 | * |
| 179 | * After all initializations have been done, application must call |
| 180 | * #pjsua_start() to start PJSUA. This function will check that all settings |
| 181 | * are properly configured, and apply default settings when it's not, or |
| 182 | * report error status when it is unable to recover from missing setting. |
| 183 | * |
| 184 | * Most settings can be changed during run-time. For example, application |
| 185 | * may add, modify, or delete accounts, buddies, or change media settings |
| 186 | * during run-time. |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 187 | * |
| 188 | * Sample code: |
| 189 | \code |
| 190 | static pj_status_t app_run(void) |
| 191 | { |
| 192 | pj_status_t status; |
| 193 | |
| 194 | // Start pjsua |
| 195 | status = pjsua_start(); |
| 196 | if (status != PJ_SUCCESS) { |
| 197 | pjsua_destroy(); |
| 198 | pjsua_perror(THIS_FILE, "Error starting pjsua", status); |
| 199 | return status; |
| 200 | } |
| 201 | |
| 202 | // Run application loop |
| 203 | while (1) { |
| 204 | char choice[10]; |
| 205 | |
| 206 | printf("Select menu: "); |
| 207 | fgets(choice, sizeof(choice), stdin); |
| 208 | ... |
| 209 | } |
| 210 | } |
| 211 | \endcode |
Benny Prijono | f04ffdd | 2006-02-21 00:11:18 +0000 | [diff] [blame] | 212 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 213 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 214 | /** Constant to identify invalid ID for all sorts of IDs. */ |
| 215 | #define PJSUA_INVALID_ID (-1) |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 216 | |
| 217 | /** Call identification */ |
| 218 | typedef int pjsua_call_id; |
| 219 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 220 | /** Account identification */ |
| 221 | typedef int pjsua_acc_id; |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 222 | |
| 223 | /** Buddy identification */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 224 | typedef int pjsua_buddy_id; |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 225 | |
| 226 | /** File player identification */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 227 | typedef int pjsua_player_id; |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 228 | |
| 229 | /** File recorder identification */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 230 | typedef int pjsua_recorder_id; |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 231 | |
| 232 | /** Conference port identification */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 233 | typedef int pjsua_conf_port_id; |
| 234 | |
| 235 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 236 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 237 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 238 | * Maximum proxies in account. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 239 | */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 240 | #ifndef PJSUA_ACC_MAX_PROXIES |
| 241 | # define PJSUA_ACC_MAX_PROXIES 8 |
| 242 | #endif |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 243 | |
| 244 | |
| 245 | |
| 246 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 247 | * Logging configuration, which can be (optionally) specified when calling |
| 248 | * #pjsua_init(). Application must call #pjsua_logging_config_default() to |
| 249 | * initialize this structure with the default values. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 250 | */ |
| 251 | typedef struct pjsua_logging_config |
| 252 | { |
| 253 | /** |
| 254 | * Log incoming and outgoing SIP message? Yes! |
| 255 | */ |
| 256 | pj_bool_t msg_logging; |
| 257 | |
| 258 | /** |
| 259 | * Input verbosity level. Value 5 is reasonable. |
| 260 | */ |
| 261 | unsigned level; |
| 262 | |
| 263 | /** |
| 264 | * Verbosity level for console. Value 4 is reasonable. |
| 265 | */ |
| 266 | unsigned console_level; |
| 267 | |
| 268 | /** |
| 269 | * Log decoration. |
| 270 | */ |
| 271 | unsigned decor; |
| 272 | |
| 273 | /** |
| 274 | * Optional log filename. |
| 275 | */ |
| 276 | pj_str_t log_filename; |
| 277 | |
| 278 | /** |
| 279 | * Optional callback function to be called to write log to |
| 280 | * application specific device. This function will be called for |
| 281 | * log messages on input verbosity level. |
| 282 | */ |
| 283 | void (*cb)(int level, const char *data, pj_size_t len); |
| 284 | |
| 285 | |
| 286 | } pjsua_logging_config; |
| 287 | |
| 288 | |
| 289 | /** |
| 290 | * Use this function to initialize logging config. |
| 291 | * |
| 292 | * @param cfg The logging config to be initialized. |
| 293 | */ |
| 294 | PJ_INLINE(void) pjsua_logging_config_default(pjsua_logging_config *cfg) |
| 295 | { |
Benny Prijono | ac623b3 | 2006-07-03 15:19:31 +0000 | [diff] [blame] | 296 | pj_bzero(cfg, sizeof(*cfg)); |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 297 | |
| 298 | cfg->msg_logging = PJ_TRUE; |
| 299 | cfg->level = 5; |
| 300 | cfg->console_level = 4; |
| 301 | cfg->decor = PJ_LOG_HAS_SENDER | PJ_LOG_HAS_TIME | |
| 302 | PJ_LOG_HAS_MICRO_SEC | PJ_LOG_HAS_NEWLINE; |
| 303 | } |
| 304 | |
| 305 | /** |
| 306 | * Use this function to duplicate logging config. |
| 307 | * |
| 308 | * @param pool Pool to use. |
| 309 | * @param dst Destination config. |
| 310 | * @param src Source config. |
| 311 | */ |
| 312 | PJ_INLINE(void) pjsua_logging_config_dup(pj_pool_t *pool, |
| 313 | pjsua_logging_config *dst, |
| 314 | const pjsua_logging_config *src) |
| 315 | { |
| 316 | pj_memcpy(dst, src, sizeof(*src)); |
| 317 | pj_strdup_with_null(pool, &dst->log_filename, &src->log_filename); |
| 318 | } |
| 319 | |
| 320 | |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 321 | |
| 322 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 323 | * This structure describes application callback to receive various event |
| 324 | * notification from PJSUA-API. All of these callbacks are OPTIONAL, |
| 325 | * although definitely application would want to implement some of |
| 326 | * the important callbacks (such as \a on_incoming_call). |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 327 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 328 | typedef struct pjsua_callback |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 329 | { |
| 330 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 331 | * Notify application when invite state has changed. |
| 332 | * Application may then query the call info to get the |
| 333 | * detail call states. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 334 | * |
| 335 | * @param call_id The call index. |
| 336 | * @param e Event which causes the call state to change. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 337 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 338 | void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e); |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 339 | |
| 340 | /** |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 341 | * Notify application on incoming call. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 342 | * |
| 343 | * @param acc_id The account which match the incoming call. |
| 344 | * @param call_id The call id that has just been created for |
| 345 | * the call. |
| 346 | * @param rdata The incoming INVITE request. |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 347 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 348 | 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] | 349 | pjsip_rx_data *rdata); |
| 350 | |
| 351 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 352 | * Notify application when media state in the call has changed. |
| 353 | * Normal application would need to implement this callback, e.g. |
| 354 | * to connect the call's media to sound device. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 355 | * |
| 356 | * @param call_id The call index. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 357 | */ |
| 358 | void (*on_call_media_state)(pjsua_call_id call_id); |
| 359 | |
| 360 | /** |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 361 | * Notify application upon incoming DTMF digits. |
| 362 | * |
| 363 | * @param call_id The call index. |
| 364 | * @param digit DTMF ASCII digit. |
| 365 | */ |
| 366 | void (*on_dtmf_digit)(pjsua_call_id call_id, int digit); |
| 367 | |
| 368 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 369 | * Notify application on call being transfered (i.e. REFER is received). |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 370 | * Application can decide to accept/reject transfer request |
| 371 | * by setting the code (default is 200). When this callback |
| 372 | * is not defined, the default behavior is to accept the |
| 373 | * transfer. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 374 | * |
| 375 | * @param call_id The call index. |
| 376 | * @param dst The destination where the call will be |
| 377 | * transfered to. |
| 378 | * @param code Status code to be returned for the call transfer |
| 379 | * request. On input, it contains status code 200. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 380 | */ |
Benny Prijono | 4ddad2c | 2006-10-18 17:16:34 +0000 | [diff] [blame] | 381 | void (*on_call_transfer_request)(pjsua_call_id call_id, |
| 382 | const pj_str_t *dst, |
| 383 | pjsip_status_code *code); |
| 384 | |
| 385 | /** |
| 386 | * Notify application of the status of previously sent call |
| 387 | * transfer request. Application can monitor the status of the |
| 388 | * call transfer request, for example to decide whether to |
| 389 | * terminate existing call. |
| 390 | * |
| 391 | * @param call_id Call ID. |
| 392 | * @param status_code Status progress of the transfer request. |
| 393 | * @param status_text Status progress text. |
| 394 | * @param final If non-zero, no further notification will |
| 395 | * be reported. The status_code specified in |
| 396 | * this callback is the final status. |
| 397 | * @param p_cont Initially will be set to non-zero, application |
| 398 | * can set this to FALSE if it no longer wants |
| 399 | * to receie further notification (for example, |
| 400 | * after it hangs up the call). |
| 401 | */ |
| 402 | void (*on_call_transfer_status)(pjsua_call_id call_id, |
| 403 | int status_code, |
| 404 | const pj_str_t *status_text, |
| 405 | pj_bool_t final, |
| 406 | pj_bool_t *p_cont); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 407 | |
| 408 | /** |
Benny Prijono | 053f522 | 2006-11-11 16:16:04 +0000 | [diff] [blame] | 409 | * Notify application about incoming INVITE with Replaces header. |
| 410 | * Application may reject the request by setting non-2xx code. |
| 411 | * |
| 412 | * @param call_id The call ID to be replaced. |
| 413 | * @param rdata The incoming INVITE request to replace the call. |
| 414 | * @param st_code Status code to be set by application. Application |
| 415 | * should only return a final status (200-699). |
| 416 | * @param st_text Optional status text to be set by application. |
| 417 | */ |
| 418 | void (*on_call_replace_request)(pjsua_call_id call_id, |
| 419 | pjsip_rx_data *rdata, |
| 420 | int *st_code, |
| 421 | pj_str_t *st_text); |
| 422 | |
| 423 | /** |
| 424 | * Notify application that an existing call has been replaced with |
| 425 | * a new call. This happens when PJSUA-API receives incoming INVITE |
| 426 | * request with Replaces header. |
| 427 | * |
| 428 | * After this callback is called, normally PJSUA-API will disconnect |
| 429 | * \a old_call_id and establish \a new_call_id. |
| 430 | * |
| 431 | * @param old_call_id Existing call which to be replaced with the |
| 432 | * new call. |
| 433 | * @param new_call_id The new call. |
| 434 | * @param rdata The incoming INVITE with Replaces request. |
| 435 | */ |
| 436 | void (*on_call_replaced)(pjsua_call_id old_call_id, |
| 437 | pjsua_call_id new_call_id); |
| 438 | |
| 439 | |
| 440 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 441 | * Notify application when registration status has changed. |
| 442 | * Application may then query the account info to get the |
| 443 | * registration details. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 444 | * |
| 445 | * @param acc_id Account ID. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 446 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 447 | void (*on_reg_state)(pjsua_acc_id acc_id); |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 448 | |
| 449 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 450 | * Notify application when the buddy state has changed. |
| 451 | * Application may then query the buddy into to get the details. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 452 | * |
| 453 | * @param buddy_id The buddy id. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 454 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 455 | void (*on_buddy_state)(pjsua_buddy_id buddy_id); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 456 | |
| 457 | /** |
| 458 | * Notify application on incoming pager (i.e. MESSAGE request). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 459 | * 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] | 460 | * existing call. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 461 | * |
| 462 | * @param call_id Containts the ID of the call where the IM was |
| 463 | * sent, or PJSUA_INVALID_ID if the IM was sent |
| 464 | * outside call context. |
| 465 | * @param from URI of the sender. |
| 466 | * @param to URI of the destination message. |
| 467 | * @param contact The Contact URI of the sender, if present. |
| 468 | * @param mime_type MIME type of the message. |
| 469 | * @param body The message content. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 470 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 471 | void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from, |
| 472 | const pj_str_t *to, const pj_str_t *contact, |
| 473 | const pj_str_t *mime_type, const pj_str_t *body); |
| 474 | |
| 475 | /** |
| 476 | * Notify application about the delivery status of outgoing pager |
| 477 | * request. |
| 478 | * |
| 479 | * @param call_id Containts the ID of the call where the IM was |
| 480 | * sent, or PJSUA_INVALID_ID if the IM was sent |
| 481 | * outside call context. |
| 482 | * @param to Destination URI. |
| 483 | * @param body Message body. |
| 484 | * @param user_data Arbitrary data that was specified when sending |
| 485 | * IM message. |
| 486 | * @param status Delivery status. |
| 487 | * @param reason Delivery status reason. |
| 488 | */ |
| 489 | void (*on_pager_status)(pjsua_call_id call_id, |
| 490 | const pj_str_t *to, |
| 491 | const pj_str_t *body, |
| 492 | void *user_data, |
| 493 | pjsip_status_code status, |
| 494 | const pj_str_t *reason); |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 495 | |
| 496 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 497 | * Notify application about typing indication. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 498 | * |
| 499 | * @param call_id Containts the ID of the call where the IM was |
| 500 | * sent, or PJSUA_INVALID_ID if the IM was sent |
| 501 | * outside call context. |
| 502 | * @param from URI of the sender. |
| 503 | * @param to URI of the destination message. |
| 504 | * @param contact The Contact URI of the sender, if present. |
| 505 | * @param is_typing Non-zero if peer is typing, or zero if peer |
| 506 | * has stopped typing a message. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 507 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 508 | void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from, |
| 509 | const pj_str_t *to, const pj_str_t *contact, |
| 510 | pj_bool_t is_typing); |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 511 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 512 | } pjsua_callback; |
| 513 | |
| 514 | |
| 515 | |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 516 | |
| 517 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 518 | * This structure describes the settings to control the API and |
| 519 | * user agent behavior, and can be specified when calling #pjsua_init(). |
| 520 | * Before setting the values, application must call #pjsua_config_default() |
| 521 | * to initialize this structure with the default values. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 522 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 523 | typedef struct pjsua_config |
| 524 | { |
| 525 | |
| 526 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 527 | * Maximum calls to support (default: 4). The value specified here |
| 528 | * must be smaller than the compile time maximum settings |
| 529 | * PJSUA_MAX_CALLS, which by default is 32. To increase this |
| 530 | * limit, the library must be recompiled with new PJSUA_MAX_CALLS |
| 531 | * value. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 532 | */ |
| 533 | unsigned max_calls; |
| 534 | |
| 535 | /** |
| 536 | * Number of worker threads. Normally application will want to have at |
| 537 | * least one worker thread, unless when it wants to poll the library |
| 538 | * periodically, which in this case the worker thread can be set to |
| 539 | * zero. |
| 540 | */ |
| 541 | unsigned thread_cnt; |
| 542 | |
| 543 | /** |
Benny Prijono | fa9e5b1 | 2006-10-08 12:39:34 +0000 | [diff] [blame] | 544 | * Number of nameservers. If no name server is configured, the SIP SRV |
| 545 | * resolution would be disabled, and domain will be resolved with |
| 546 | * standard pj_gethostbyname() function. |
| 547 | */ |
| 548 | unsigned nameserver_count; |
| 549 | |
| 550 | /** |
| 551 | * Array of nameservers to be used by the SIP resolver subsystem. |
| 552 | * The order of the name server specifies the priority (first name |
| 553 | * server will be used first, unless it is not reachable). |
| 554 | */ |
| 555 | pj_str_t nameserver[4]; |
| 556 | |
| 557 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 558 | * Number of outbound proxies in the \a outbound_proxy array. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 559 | */ |
| 560 | unsigned outbound_proxy_cnt; |
| 561 | |
| 562 | /** |
| 563 | * Specify the URL of outbound proxies to visit for all outgoing requests. |
| 564 | * The outbound proxies will be used for all accounts, and it will |
| 565 | * be used to build the route set for outgoing requests. The final |
| 566 | * route set for outgoing requests will consists of the outbound proxies |
| 567 | * and the proxy configured in the account. |
| 568 | */ |
| 569 | pj_str_t outbound_proxy[4]; |
| 570 | |
| 571 | /** |
| 572 | * Number of credentials in the credential array. |
| 573 | */ |
| 574 | unsigned cred_count; |
| 575 | |
| 576 | /** |
| 577 | * Array of credentials. These credentials will be used by all accounts, |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 578 | * and can be used to authenticate against outbound proxies. If the |
| 579 | * credential is specific to the account, then application should set |
| 580 | * the credential in the pjsua_acc_config rather than the credential |
| 581 | * here. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 582 | */ |
| 583 | pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES]; |
| 584 | |
| 585 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 586 | * Application callback to receive various event notifications from |
| 587 | * the library. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 588 | */ |
| 589 | pjsua_callback cb; |
| 590 | |
Benny Prijono | 5631561 | 2006-07-18 14:39:40 +0000 | [diff] [blame] | 591 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 592 | * Optional user agent string (default empty). If it's empty, no |
| 593 | * User-Agent header will be sent with outgoing requests. |
Benny Prijono | 5631561 | 2006-07-18 14:39:40 +0000 | [diff] [blame] | 594 | */ |
| 595 | pj_str_t user_agent; |
| 596 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 597 | } pjsua_config; |
| 598 | |
| 599 | |
| 600 | /** |
| 601 | * Use this function to initialize pjsua config. |
| 602 | * |
| 603 | * @param cfg pjsua config to be initialized. |
| 604 | */ |
| 605 | PJ_INLINE(void) pjsua_config_default(pjsua_config *cfg) |
| 606 | { |
Benny Prijono | ac623b3 | 2006-07-03 15:19:31 +0000 | [diff] [blame] | 607 | pj_bzero(cfg, sizeof(*cfg)); |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 608 | |
| 609 | cfg->max_calls = 4; |
| 610 | cfg->thread_cnt = 1; |
| 611 | } |
| 612 | |
| 613 | |
| 614 | /** |
| 615 | * Duplicate credential. |
| 616 | */ |
| 617 | PJ_INLINE(void) pjsip_cred_dup( pj_pool_t *pool, |
| 618 | pjsip_cred_info *dst, |
| 619 | const pjsip_cred_info *src) |
| 620 | { |
| 621 | pj_strdup_with_null(pool, &dst->realm, &src->realm); |
| 622 | pj_strdup_with_null(pool, &dst->scheme, &src->scheme); |
| 623 | pj_strdup_with_null(pool, &dst->username, &src->username); |
| 624 | pj_strdup_with_null(pool, &dst->data, &src->data); |
| 625 | |
| 626 | } |
| 627 | |
| 628 | |
| 629 | /** |
| 630 | * Duplicate pjsua_config. |
| 631 | */ |
| 632 | PJ_INLINE(void) pjsua_config_dup(pj_pool_t *pool, |
| 633 | pjsua_config *dst, |
| 634 | const pjsua_config *src) |
| 635 | { |
| 636 | unsigned i; |
| 637 | |
| 638 | pj_memcpy(dst, src, sizeof(*src)); |
| 639 | |
| 640 | for (i=0; i<src->outbound_proxy_cnt; ++i) { |
| 641 | pj_strdup_with_null(pool, &dst->outbound_proxy[i], |
| 642 | &src->outbound_proxy[i]); |
| 643 | } |
| 644 | |
| 645 | for (i=0; i<src->cred_count; ++i) { |
| 646 | pjsip_cred_dup(pool, &dst->cred_info[i], &src->cred_info[i]); |
| 647 | } |
Benny Prijono | 5631561 | 2006-07-18 14:39:40 +0000 | [diff] [blame] | 648 | |
| 649 | pj_strdup_with_null(pool, &dst->user_agent, &src->user_agent); |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 650 | } |
| 651 | |
| 652 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 653 | |
| 654 | /** |
| 655 | * This structure describes additional information to be sent with |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 656 | * outgoing SIP message. It can (optionally) be specified for example |
| 657 | * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(), |
| 658 | * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more. |
| 659 | * |
| 660 | * Application MUST call #pjsua_msg_data_init() to initialize this |
| 661 | * structure before setting its values. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 662 | */ |
| 663 | typedef struct pjsua_msg_data |
| 664 | { |
| 665 | /** |
| 666 | * Additional message headers as linked list. |
| 667 | */ |
| 668 | pjsip_hdr hdr_list; |
| 669 | |
| 670 | /** |
| 671 | * MIME type of optional message body. |
| 672 | */ |
| 673 | pj_str_t content_type; |
| 674 | |
| 675 | /** |
| 676 | * Optional message body. |
| 677 | */ |
| 678 | pj_str_t msg_body; |
| 679 | |
| 680 | } pjsua_msg_data; |
| 681 | |
| 682 | |
| 683 | /** |
| 684 | * Initialize message data. |
| 685 | * |
| 686 | * @param msg_data Message data to be initialized. |
| 687 | */ |
| 688 | PJ_INLINE(void) pjsua_msg_data_init(pjsua_msg_data *msg_data) |
| 689 | { |
Benny Prijono | ac623b3 | 2006-07-03 15:19:31 +0000 | [diff] [blame] | 690 | pj_bzero(msg_data, sizeof(*msg_data)); |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 691 | pj_list_init(&msg_data->hdr_list); |
| 692 | } |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 693 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 694 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 695 | |
| 696 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 697 | * Instantiate pjsua application. Application must call this function before |
| 698 | * calling any other functions, to make sure that the underlying libraries |
| 699 | * are properly initialized. Once this function has returned success, |
| 700 | * application must call pjsua_destroy() before quitting. |
| 701 | * |
| 702 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 703 | */ |
| 704 | PJ_DECL(pj_status_t) pjsua_create(void); |
| 705 | |
| 706 | |
| 707 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 708 | * Initialize pjsua with the specified settings. All the settings are |
| 709 | * optional, and the default values will be used when the config is not |
| 710 | * specified. |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 711 | * |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 712 | * Note that #pjsua_create() MUST be called before calling this function. |
| 713 | * |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 714 | * @param ua_cfg User agent configuration. |
| 715 | * @param log_cfg Optional logging configuration. |
| 716 | * @param media_cfg Optional media configuration. |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 717 | * |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 718 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 719 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 720 | PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg, |
| 721 | const pjsua_logging_config *log_cfg, |
| 722 | const pjsua_media_config *media_cfg); |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 723 | |
| 724 | |
| 725 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 726 | * Application is recommended to call this function after all initialization |
| 727 | * is done, so that the library can do additional checking set up |
| 728 | * additional |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 729 | * |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 730 | * Application may call this function anytime after #pjsua_init(). |
| 731 | * |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 732 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 733 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 734 | PJ_DECL(pj_status_t) pjsua_start(void); |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 735 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 736 | |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 737 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 738 | * Destroy pjsua. Application is recommended to perform graceful shutdown |
| 739 | * before calling this function (such as unregister the account from the SIP |
| 740 | * server, terminate presense subscription, and hangup active calls), however, |
| 741 | * this function will do all of these if it finds there are active sessions |
| 742 | * that need to be terminated. This function will approximately block for |
| 743 | * one second to wait for replies from remote. |
| 744 | * |
| 745 | * Application.may safely call this function more than once if it doesn't |
| 746 | * keep track of it's state. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 747 | * |
| 748 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 749 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 750 | PJ_DECL(pj_status_t) pjsua_destroy(void); |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 751 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 752 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 753 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 754 | * Poll pjsua for events, and if necessary block the caller thread for |
| 755 | * the specified maximum interval (in miliseconds). |
| 756 | * |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 757 | * Application doesn't normally need to call this function if it has |
| 758 | * configured worker thread (\a thread_cnt field) in pjsua_config structure, |
| 759 | * because polling then will be done by these worker threads instead. |
| 760 | * |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 761 | * @param msec_timeout Maximum time to wait, in miliseconds. |
| 762 | * |
| 763 | * @return The number of events that have been handled during the |
| 764 | * poll. Negative value indicates error, and application |
| 765 | * can retrieve the error as (err = -return_value). |
Benny Prijono | b9b32ab | 2006-06-01 12:28:44 +0000 | [diff] [blame] | 766 | */ |
| 767 | PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout); |
| 768 | |
| 769 | |
| 770 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 771 | * Create memory pool to be used by the application. Once application |
| 772 | * finished using the pool, it must be released with pj_pool_release(). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 773 | * |
| 774 | * @param name Optional pool name. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 775 | * @param init_size Initial size of the pool. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 776 | * @param increment Increment size. |
| 777 | * |
| 778 | * @return The pool, or NULL when there's no memory. |
| 779 | */ |
| 780 | PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size, |
| 781 | pj_size_t increment); |
| 782 | |
| 783 | |
| 784 | /** |
| 785 | * Application can call this function at any time (after pjsua_create(), of |
| 786 | * course) to change logging settings. |
| 787 | * |
| 788 | * @param c Logging configuration. |
| 789 | * |
| 790 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 791 | */ |
| 792 | PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c); |
| 793 | |
| 794 | |
| 795 | /** |
| 796 | * Internal function to get SIP endpoint instance of pjsua, which is |
| 797 | * needed for example to register module, create transports, etc. |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 798 | * Only valid after #pjsua_init() is called. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 799 | * |
| 800 | * @return SIP endpoint instance. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 801 | */ |
| 802 | PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void); |
| 803 | |
| 804 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 805 | * Internal function to get media endpoint instance. |
| 806 | * Only valid after #pjsua_init() is called. |
| 807 | * |
| 808 | * @return Media endpoint instance. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 809 | */ |
| 810 | PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void); |
| 811 | |
Benny Prijono | 97b8717 | 2006-08-24 14:25:14 +0000 | [diff] [blame] | 812 | /** |
| 813 | * Internal function to get PJSUA pool factory. |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 814 | * Only valid after #pjsua_create() is called. |
Benny Prijono | 97b8717 | 2006-08-24 14:25:14 +0000 | [diff] [blame] | 815 | * |
| 816 | * @return Pool factory currently used by PJSUA. |
| 817 | */ |
| 818 | PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void); |
| 819 | |
| 820 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 821 | |
| 822 | /***************************************************************************** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 823 | * Utilities. |
| 824 | * |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 825 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 826 | |
| 827 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 828 | * This is a utility function to verify that valid SIP url is given. If the |
| 829 | * URL is valid, PJ_SUCCESS will be returned. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 830 | * |
| 831 | * @param c_url The URL, as NULL terminated string. |
| 832 | * |
| 833 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 834 | */ |
| 835 | PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *c_url); |
| 836 | |
| 837 | |
| 838 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 839 | * This is a utility function to display error message for the specified |
| 840 | * error code. The error message will be sent to the log. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 841 | * |
| 842 | * @param sender The log sender field. |
| 843 | * @param title Message title for the error. |
| 844 | * @param status Status code. |
| 845 | */ |
| 846 | PJ_DECL(void) pjsua_perror(const char *sender, const char *title, |
| 847 | pj_status_t status); |
| 848 | |
| 849 | |
| 850 | |
| 851 | |
| 852 | /** |
| 853 | * @} |
| 854 | */ |
| 855 | |
| 856 | |
| 857 | |
| 858 | /***************************************************************************** |
| 859 | * TRANSPORT API |
| 860 | */ |
| 861 | |
| 862 | /** |
| 863 | * @defgroup PJSUA_LIB_TRANSPORT Signaling Transport |
| 864 | * @ingroup PJSUA_LIB |
| 865 | * @brief API for managing SIP transports |
| 866 | * @{ |
| 867 | * SIP transport must be created before adding an account. SIP transport is |
| 868 | * created by calling #pjsua_transport_create() function. |
| 869 | */ |
| 870 | |
| 871 | |
| 872 | /** SIP transport identification */ |
| 873 | typedef int pjsua_transport_id; |
| 874 | |
| 875 | |
| 876 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 877 | * This structure describes STUN configuration for SIP and media transport, |
| 878 | * and is embedded inside pjsua_transport_config structure. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 879 | */ |
| 880 | typedef struct pjsua_stun_config |
| 881 | { |
| 882 | /** |
| 883 | * The first STUN server IP address or hostname. |
| 884 | */ |
| 885 | pj_str_t stun_srv1; |
| 886 | |
| 887 | /** |
| 888 | * Port number of the first STUN server. |
| 889 | * If zero, default STUN port will be used. |
| 890 | */ |
| 891 | unsigned stun_port1; |
| 892 | |
| 893 | /** |
| 894 | * Optional second STUN server IP address or hostname, for which the |
| 895 | * result of the mapping request will be compared to. If the value |
| 896 | * is empty, only one STUN server will be used. |
| 897 | */ |
| 898 | pj_str_t stun_srv2; |
| 899 | |
| 900 | /** |
| 901 | * Port number of the second STUN server. |
| 902 | * If zero, default STUN port will be used. |
| 903 | */ |
| 904 | unsigned stun_port2; |
| 905 | |
| 906 | } pjsua_stun_config; |
| 907 | |
| 908 | |
| 909 | |
| 910 | /** |
| 911 | * Call this function to initialize STUN config with default values. |
| 912 | * |
| 913 | * @param cfg The STUN config to be initialized. |
| 914 | */ |
| 915 | PJ_INLINE(void) pjsua_stun_config_default(pjsua_stun_config *cfg) |
| 916 | { |
Benny Prijono | ac623b3 | 2006-07-03 15:19:31 +0000 | [diff] [blame] | 917 | pj_bzero(cfg, sizeof(*cfg)); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 918 | } |
| 919 | |
| 920 | |
| 921 | /** |
Benny Prijono | 0a5cad8 | 2006-09-26 13:21:02 +0000 | [diff] [blame] | 922 | * Transport configuration for creating transports for both SIP |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 923 | * and media. Before setting some values to this structure, application |
| 924 | * MUST call #pjsua_transport_config_default() to initialize its |
| 925 | * values with default settings. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 926 | */ |
| 927 | typedef struct pjsua_transport_config |
| 928 | { |
| 929 | /** |
| 930 | * UDP port number to bind locally. This setting MUST be specified |
| 931 | * even when default port is desired. If the value is zero, the |
| 932 | * transport will be bound to any available port, and application |
| 933 | * can query the port by querying the transport info. |
| 934 | */ |
| 935 | unsigned port; |
| 936 | |
| 937 | /** |
Benny Prijono | 0a5cad8 | 2006-09-26 13:21:02 +0000 | [diff] [blame] | 938 | * Optional address to advertise as the address of this transport. |
| 939 | * Application can specify any address or hostname for this field, |
| 940 | * for example it can point to one of the interface address in the |
| 941 | * system, or it can point to the public address of a NAT router |
| 942 | * where port mappings have been configured for the application. |
| 943 | * |
| 944 | * 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] | 945 | */ |
Benny Prijono | 0a5cad8 | 2006-09-26 13:21:02 +0000 | [diff] [blame] | 946 | pj_str_t public_addr; |
| 947 | |
| 948 | /** |
| 949 | * Optional address where the socket should be bound to. This option |
| 950 | * SHOULD only be used to selectively bind the socket to particular |
| 951 | * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the |
| 952 | * published address of a transport (the public_addr field should be |
| 953 | * used for that purpose). |
| 954 | * |
| 955 | * Note that unlike public_addr field, the address (or hostname) here |
| 956 | * MUST correspond to the actual interface address in the host, since |
| 957 | * this address will be specified as bind() argument. |
| 958 | */ |
| 959 | pj_str_t bound_addr; |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 960 | |
| 961 | /** |
| 962 | * Flag to indicate whether STUN should be used. |
| 963 | */ |
| 964 | pj_bool_t use_stun; |
| 965 | |
| 966 | /** |
| 967 | * STUN configuration, must be specified when STUN is used. |
| 968 | */ |
| 969 | pjsua_stun_config stun_config; |
| 970 | |
Benny Prijono | 6e0e54b | 2006-12-08 21:58:31 +0000 | [diff] [blame] | 971 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 972 | * This specifies TLS settings for TLS transport. It is only be used |
| 973 | * when this transport config is being used to create a SIP TLS |
| 974 | * transport. |
Benny Prijono | 6e0e54b | 2006-12-08 21:58:31 +0000 | [diff] [blame] | 975 | */ |
Benny Prijono | f3bbc13 | 2006-12-25 06:43:59 +0000 | [diff] [blame] | 976 | pjsip_tls_setting tls_setting; |
Benny Prijono | 6e0e54b | 2006-12-08 21:58:31 +0000 | [diff] [blame] | 977 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 978 | } pjsua_transport_config; |
| 979 | |
| 980 | |
| 981 | /** |
| 982 | * Call this function to initialize UDP config with default values. |
| 983 | * |
| 984 | * @param cfg The UDP config to be initialized. |
| 985 | */ |
| 986 | PJ_INLINE(void) pjsua_transport_config_default(pjsua_transport_config *cfg) |
| 987 | { |
Benny Prijono | ac623b3 | 2006-07-03 15:19:31 +0000 | [diff] [blame] | 988 | pj_bzero(cfg, sizeof(*cfg)); |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 989 | pjsua_stun_config_default(&cfg->stun_config); |
Benny Prijono | f3bbc13 | 2006-12-25 06:43:59 +0000 | [diff] [blame] | 990 | pjsip_tls_setting_default(&cfg->tls_setting); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 991 | } |
| 992 | |
| 993 | |
| 994 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 995 | * This is a utility function to normalize STUN config. It's only |
| 996 | * used internally by the library. |
| 997 | * |
| 998 | * @param cfg The STUN config to be initialized. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 999 | */ |
| 1000 | PJ_INLINE(void) pjsua_normalize_stun_config( pjsua_stun_config *cfg ) |
| 1001 | { |
| 1002 | if (cfg->stun_srv1.slen) { |
| 1003 | |
| 1004 | if (cfg->stun_port1 == 0) |
| 1005 | cfg->stun_port1 = 3478; |
| 1006 | |
| 1007 | if (cfg->stun_srv2.slen == 0) { |
| 1008 | cfg->stun_srv2 = cfg->stun_srv1; |
| 1009 | cfg->stun_port2 = cfg->stun_port1; |
| 1010 | } else { |
| 1011 | if (cfg->stun_port2 == 0) |
| 1012 | cfg->stun_port2 = 3478; |
| 1013 | } |
| 1014 | |
| 1015 | } else { |
| 1016 | cfg->stun_port1 = 0; |
| 1017 | cfg->stun_srv2.slen = 0; |
| 1018 | cfg->stun_port2 = 0; |
| 1019 | } |
| 1020 | } |
| 1021 | |
| 1022 | |
| 1023 | /** |
| 1024 | * Duplicate transport config. |
| 1025 | */ |
| 1026 | PJ_INLINE(void) pjsua_transport_config_dup(pj_pool_t *pool, |
| 1027 | pjsua_transport_config *dst, |
| 1028 | const pjsua_transport_config *src) |
| 1029 | { |
| 1030 | pj_memcpy(dst, src, sizeof(*src)); |
| 1031 | |
| 1032 | if (src->stun_config.stun_srv1.slen) { |
| 1033 | pj_strdup_with_null(pool, &dst->stun_config.stun_srv1, |
| 1034 | &src->stun_config.stun_srv1); |
| 1035 | } |
| 1036 | |
| 1037 | if (src->stun_config.stun_srv2.slen) { |
| 1038 | pj_strdup_with_null(pool, &dst->stun_config.stun_srv2, |
| 1039 | &src->stun_config.stun_srv2); |
| 1040 | } |
| 1041 | |
| 1042 | pjsua_normalize_stun_config(&dst->stun_config); |
| 1043 | } |
| 1044 | |
| 1045 | |
| 1046 | |
| 1047 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1048 | * This structure describes transport information returned by |
| 1049 | * #pjsua_transport_get_info() function. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1050 | */ |
| 1051 | typedef struct pjsua_transport_info |
| 1052 | { |
| 1053 | /** |
| 1054 | * PJSUA transport identification. |
| 1055 | */ |
| 1056 | pjsua_transport_id id; |
| 1057 | |
| 1058 | /** |
| 1059 | * Transport type. |
| 1060 | */ |
| 1061 | pjsip_transport_type_e type; |
| 1062 | |
| 1063 | /** |
| 1064 | * Transport type name. |
| 1065 | */ |
| 1066 | pj_str_t type_name; |
| 1067 | |
| 1068 | /** |
| 1069 | * Transport string info/description. |
| 1070 | */ |
| 1071 | pj_str_t info; |
| 1072 | |
| 1073 | /** |
| 1074 | * Transport flag (see ##pjsip_transport_flags_e). |
| 1075 | */ |
| 1076 | unsigned flag; |
| 1077 | |
| 1078 | /** |
| 1079 | * Local address length. |
| 1080 | */ |
| 1081 | unsigned addr_len; |
| 1082 | |
| 1083 | /** |
| 1084 | * Local/bound address. |
| 1085 | */ |
| 1086 | pj_sockaddr local_addr; |
| 1087 | |
| 1088 | /** |
| 1089 | * Published address (or transport address name). |
| 1090 | */ |
| 1091 | pjsip_host_port local_name; |
| 1092 | |
| 1093 | /** |
| 1094 | * Current number of objects currently referencing this transport. |
| 1095 | */ |
| 1096 | unsigned usage_count; |
| 1097 | |
| 1098 | |
| 1099 | } pjsua_transport_info; |
| 1100 | |
| 1101 | |
| 1102 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1103 | * Create and start a new SIP transport according to the specified |
| 1104 | * settings. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1105 | * |
| 1106 | * @param type Transport type. |
| 1107 | * @param cfg Transport configuration. |
| 1108 | * @param p_id Optional pointer to receive transport ID. |
| 1109 | * |
| 1110 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1111 | */ |
| 1112 | PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type, |
| 1113 | const pjsua_transport_config *cfg, |
| 1114 | pjsua_transport_id *p_id); |
| 1115 | |
| 1116 | /** |
| 1117 | * Register transport that has been created by application. |
| 1118 | * |
| 1119 | * @param tp Transport instance. |
| 1120 | * @param p_id Optional pointer to receive transport ID. |
| 1121 | * |
| 1122 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1123 | */ |
| 1124 | PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp, |
| 1125 | pjsua_transport_id *p_id); |
| 1126 | |
| 1127 | |
| 1128 | /** |
| 1129 | * Enumerate all transports currently created in the system. |
| 1130 | * |
| 1131 | * @param id Array to receive transport ids. |
| 1132 | * @param count In input, specifies the maximum number of elements. |
| 1133 | * On return, it contains the actual number of elements. |
| 1134 | * |
| 1135 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1136 | */ |
| 1137 | PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[], |
| 1138 | unsigned *count ); |
| 1139 | |
| 1140 | |
| 1141 | /** |
| 1142 | * Get information about transports. |
| 1143 | * |
| 1144 | * @param id Transport ID. |
| 1145 | * @param info Pointer to receive transport info. |
| 1146 | * |
| 1147 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1148 | */ |
| 1149 | PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id, |
| 1150 | pjsua_transport_info *info); |
| 1151 | |
| 1152 | |
| 1153 | /** |
| 1154 | * Disable a transport or re-enable it. By default transport is always |
| 1155 | * enabled after it is created. Disabling a transport does not necessarily |
| 1156 | * close the socket, it will only discard incoming messages and prevent |
| 1157 | * the transport from being used to send outgoing messages. |
| 1158 | * |
| 1159 | * @param id Transport ID. |
| 1160 | * @param enabled Non-zero to enable, zero to disable. |
| 1161 | * |
| 1162 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1163 | */ |
| 1164 | PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id, |
| 1165 | pj_bool_t enabled); |
| 1166 | |
| 1167 | |
| 1168 | /** |
| 1169 | * Close the transport. If transport is forcefully closed, it will be |
| 1170 | * immediately closed, and any pending transactions that are using the |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1171 | * transport may not terminate properly (it may even crash). Otherwise, |
| 1172 | * the system will wait until all transactions are closed while preventing |
| 1173 | * new users from using the transport, and will close the transport when |
| 1174 | * it is safe to do so. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1175 | * |
| 1176 | * @param id Transport ID. |
| 1177 | * @param force Non-zero to immediately close the transport. This |
| 1178 | * is not recommended! |
| 1179 | * |
| 1180 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1181 | */ |
| 1182 | PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id, |
| 1183 | pj_bool_t force ); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1184 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1185 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1186 | * @} |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1187 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1188 | |
| 1189 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1190 | |
| 1191 | |
| 1192 | /***************************************************************************** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1193 | * ACCOUNT API |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 1194 | */ |
| 1195 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1196 | |
| 1197 | /** |
| 1198 | * @defgroup PJSUA_LIB_ACC Account Management |
| 1199 | * @ingroup PJSUA_LIB |
| 1200 | * @brief PJSUA supports multiple accounts.. |
| 1201 | * @{ |
| 1202 | * PJSUA accounts provide identity (or identities) of the user who is currently |
| 1203 | * using the application. More than one account maybe created with PJSUA. |
| 1204 | * |
| 1205 | * Account may or may not have client registration associated with it. |
| 1206 | * An account is also associated with <b>route set</b> and some <b>authentication |
| 1207 | * credentials</b>, which are used when sending SIP request messages using the |
| 1208 | * account. An account also has presence's <b>online status</b>, which |
| 1209 | * will be reported to remote peer when the subscribe to the account's |
| 1210 | * presence. |
| 1211 | * |
| 1212 | * At least one account MUST be created in the application. If no user |
| 1213 | * association is required, application can create a userless account by |
| 1214 | * calling #pjsua_acc_add_local(). A userless account identifies local endpoint |
| 1215 | * instead of a particular user. |
| 1216 | * |
| 1217 | * Also one account must be set as the <b>default account</b>, which is used as |
| 1218 | * the account to use when PJSUA fails to match a request with any other |
| 1219 | * accounts. |
| 1220 | * |
| 1221 | * When sending outgoing SIP requests (such as making calls or sending |
| 1222 | * instant messages), normally PJSUA requires the application to specify |
| 1223 | * which account to use for the request. If no account is specified, |
| 1224 | * PJSUA may be able to select the account by matching the destination |
| 1225 | * domain name, and fall back to default account when no match is found. |
| 1226 | */ |
| 1227 | |
| 1228 | /** |
| 1229 | * Maximum accounts. |
| 1230 | */ |
| 1231 | #ifndef PJSUA_MAX_ACC |
| 1232 | # define PJSUA_MAX_ACC 8 |
| 1233 | #endif |
| 1234 | |
| 1235 | |
| 1236 | /** |
| 1237 | * Default registration interval. |
| 1238 | */ |
| 1239 | #ifndef PJSUA_REG_INTERVAL |
| 1240 | # define PJSUA_REG_INTERVAL 55 |
| 1241 | #endif |
| 1242 | |
| 1243 | |
| 1244 | /** |
Benny Prijono | 3a5e1ab | 2006-08-15 20:26:34 +0000 | [diff] [blame] | 1245 | * Default PUBLISH expiration |
| 1246 | */ |
| 1247 | #ifndef PJSUA_PUBLISH_EXPIRATION |
| 1248 | # define PJSUA_PUBLISH_EXPIRATION 600 |
| 1249 | #endif |
| 1250 | |
| 1251 | |
| 1252 | /** |
Benny Prijono | 093d302 | 2006-09-24 00:07:11 +0000 | [diff] [blame] | 1253 | * Default account priority. |
| 1254 | */ |
| 1255 | #ifndef PJSUA_DEFAULT_ACC_PRIORITY |
| 1256 | # define PJSUA_DEFAULT_ACC_PRIORITY 0 |
| 1257 | #endif |
| 1258 | |
| 1259 | |
| 1260 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1261 | * This structure describes account configuration to be specified when |
| 1262 | * adding a new account with #pjsua_acc_add(). Application MUST initialize |
| 1263 | * this structure first by calling #pjsua_acc_config_default(). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1264 | */ |
| 1265 | typedef struct pjsua_acc_config |
| 1266 | { |
Benny Prijono | 093d302 | 2006-09-24 00:07:11 +0000 | [diff] [blame] | 1267 | /** |
| 1268 | * Account priority, which is used to control the order of matching |
| 1269 | * incoming/outgoing requests. The higher the number means the higher |
| 1270 | * the priority is, and the account will be matched first. |
| 1271 | */ |
| 1272 | int priority; |
| 1273 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1274 | /** |
| 1275 | * The full SIP URL for the account. The value can take name address or |
| 1276 | * URL format, and will look something like "sip:account@serviceprovider". |
| 1277 | * |
| 1278 | * This field is mandatory. |
| 1279 | */ |
| 1280 | pj_str_t id; |
| 1281 | |
| 1282 | /** |
| 1283 | * This is the URL to be put in the request URI for the registration, |
| 1284 | * and will look something like "sip:serviceprovider". |
| 1285 | * |
| 1286 | * This field should be specified if registration is desired. If the |
| 1287 | * value is empty, no account registration will be performed. |
| 1288 | */ |
| 1289 | pj_str_t reg_uri; |
| 1290 | |
Benny Prijono | 3a5e1ab | 2006-08-15 20:26:34 +0000 | [diff] [blame] | 1291 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1292 | * If this flag is set, the presence information of this account will |
| 1293 | * be PUBLISH-ed to the server where the account belongs. |
Benny Prijono | 3a5e1ab | 2006-08-15 20:26:34 +0000 | [diff] [blame] | 1294 | */ |
| 1295 | pj_bool_t publish_enabled; |
| 1296 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1297 | /** |
| 1298 | * Optional URI to be put as Contact for this account. It is recommended |
| 1299 | * that this field is left empty, so that the value will be calculated |
| 1300 | * automatically based on the transport address. |
| 1301 | */ |
Benny Prijono | b4a17c9 | 2006-07-10 14:40:21 +0000 | [diff] [blame] | 1302 | pj_str_t force_contact; |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1303 | |
| 1304 | /** |
| 1305 | * Number of proxies in the proxy array below. |
| 1306 | */ |
| 1307 | unsigned proxy_cnt; |
| 1308 | |
| 1309 | /** |
| 1310 | * Optional URI of the proxies to be visited for all outgoing requests |
| 1311 | * that are using this account (REGISTER, INVITE, etc). Application need |
| 1312 | * to specify these proxies if the service provider requires that requests |
| 1313 | * destined towards its network should go through certain proxies first |
| 1314 | * (for example, border controllers). |
| 1315 | * |
| 1316 | * These proxies will be put in the route set for this account, with |
| 1317 | * maintaining the orders (the first proxy in the array will be visited |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1318 | * first). If global outbound proxies are configured in pjsua_config, |
| 1319 | * then these account proxies will be placed after the global outbound |
| 1320 | * proxies in the routeset. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1321 | */ |
| 1322 | pj_str_t proxy[PJSUA_ACC_MAX_PROXIES]; |
| 1323 | |
| 1324 | /** |
| 1325 | * Optional interval for registration, in seconds. If the value is zero, |
| 1326 | * default interval will be used (PJSUA_REG_INTERVAL, 55 seconds). |
| 1327 | */ |
| 1328 | unsigned reg_timeout; |
| 1329 | |
| 1330 | /** |
| 1331 | * Number of credentials in the credential array. |
| 1332 | */ |
| 1333 | unsigned cred_count; |
| 1334 | |
| 1335 | /** |
| 1336 | * Array of credentials. If registration is desired, normally there should |
| 1337 | * be at least one credential specified, to successfully authenticate |
| 1338 | * against the service provider. More credentials can be specified, for |
| 1339 | * example when the requests are expected to be challenged by the |
| 1340 | * proxies in the route set. |
| 1341 | */ |
| 1342 | pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES]; |
| 1343 | |
Benny Prijono | 62c5c5b | 2007-01-13 23:22:40 +0000 | [diff] [blame] | 1344 | /** |
| 1345 | * Optionally bind this account to specific transport. This normally is |
| 1346 | * not a good idea, as account should be able to send requests using |
| 1347 | * any available transports according to the destination. But some |
| 1348 | * application may want to have explicit control over the transport to |
| 1349 | * use, so in that case it can set this field. |
| 1350 | * |
| 1351 | * Default: -1 (PJSUA_INVALID_ID) |
| 1352 | * |
| 1353 | * @see pjsua_acc_set_transport() |
| 1354 | */ |
| 1355 | pjsua_transport_id transport_id; |
| 1356 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1357 | } pjsua_acc_config; |
| 1358 | |
| 1359 | |
| 1360 | /** |
| 1361 | * Call this function to initialize account config with default values. |
| 1362 | * |
| 1363 | * @param cfg The account config to be initialized. |
| 1364 | */ |
| 1365 | PJ_INLINE(void) pjsua_acc_config_default(pjsua_acc_config *cfg) |
| 1366 | { |
Benny Prijono | ac623b3 | 2006-07-03 15:19:31 +0000 | [diff] [blame] | 1367 | pj_bzero(cfg, sizeof(*cfg)); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1368 | |
| 1369 | cfg->reg_timeout = PJSUA_REG_INTERVAL; |
Benny Prijono | 62c5c5b | 2007-01-13 23:22:40 +0000 | [diff] [blame] | 1370 | cfg->transport_id = PJSUA_INVALID_ID; |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1371 | } |
| 1372 | |
| 1373 | |
| 1374 | |
| 1375 | /** |
| 1376 | * Account info. Application can query account info by calling |
| 1377 | * #pjsua_acc_get_info(). |
| 1378 | */ |
| 1379 | typedef struct pjsua_acc_info |
| 1380 | { |
| 1381 | /** |
| 1382 | * The account ID. |
| 1383 | */ |
| 1384 | pjsua_acc_id id; |
| 1385 | |
| 1386 | /** |
| 1387 | * Flag to indicate whether this is the default account. |
| 1388 | */ |
| 1389 | pj_bool_t is_default; |
| 1390 | |
| 1391 | /** |
| 1392 | * Account URI |
| 1393 | */ |
| 1394 | pj_str_t acc_uri; |
| 1395 | |
| 1396 | /** |
| 1397 | * Flag to tell whether this account has registration setting |
| 1398 | * (reg_uri is not empty). |
| 1399 | */ |
| 1400 | pj_bool_t has_registration; |
| 1401 | |
| 1402 | /** |
| 1403 | * An up to date expiration interval for account registration session. |
| 1404 | */ |
| 1405 | int expires; |
| 1406 | |
| 1407 | /** |
| 1408 | * Last registration status code. If status code is zero, the account |
| 1409 | * is currently not registered. Any other value indicates the SIP |
| 1410 | * status code of the registration. |
| 1411 | */ |
| 1412 | pjsip_status_code status; |
| 1413 | |
| 1414 | /** |
| 1415 | * String describing the registration status. |
| 1416 | */ |
| 1417 | pj_str_t status_text; |
| 1418 | |
| 1419 | /** |
| 1420 | * Presence online status for this account. |
| 1421 | */ |
| 1422 | pj_bool_t online_status; |
| 1423 | |
| 1424 | /** |
| 1425 | * Buffer that is used internally to store the status text. |
| 1426 | */ |
| 1427 | char buf_[PJ_ERR_MSG_SIZE]; |
| 1428 | |
| 1429 | } pjsua_acc_info; |
| 1430 | |
| 1431 | |
| 1432 | |
| 1433 | /** |
| 1434 | * Get number of current accounts. |
| 1435 | * |
| 1436 | * @return Current number of accounts. |
| 1437 | */ |
| 1438 | PJ_DECL(unsigned) pjsua_acc_get_count(void); |
| 1439 | |
| 1440 | |
| 1441 | /** |
| 1442 | * Check if the specified account ID is valid. |
| 1443 | * |
| 1444 | * @param acc_id Account ID to check. |
| 1445 | * |
| 1446 | * @return Non-zero if account ID is valid. |
| 1447 | */ |
| 1448 | PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id); |
| 1449 | |
| 1450 | |
| 1451 | /** |
Benny Prijono | 21b9ad9 | 2006-08-15 13:11:22 +0000 | [diff] [blame] | 1452 | * Set default account to be used when incoming and outgoing |
| 1453 | * requests doesn't match any accounts. |
| 1454 | * |
| 1455 | * @param acc_id The account ID to be used as default. |
| 1456 | * |
| 1457 | * @return PJ_SUCCESS on success. |
| 1458 | */ |
| 1459 | PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id); |
| 1460 | |
| 1461 | |
| 1462 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1463 | * Get default account to be used when receiving incoming requests (calls), |
| 1464 | * when the destination of the incoming call doesn't match any other |
| 1465 | * accounts. |
Benny Prijono | 21b9ad9 | 2006-08-15 13:11:22 +0000 | [diff] [blame] | 1466 | * |
| 1467 | * @return The default account ID, or PJSUA_INVALID_ID if no |
| 1468 | * default account is configured. |
| 1469 | */ |
| 1470 | PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void); |
| 1471 | |
| 1472 | |
| 1473 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1474 | * Add a new account to pjsua. PJSUA must have been initialized (with |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1475 | * #pjsua_init()) before calling this function. If registration is configured |
| 1476 | * for this account, this function would also start the SIP registration |
| 1477 | * session with the SIP registrar server. This SIP registration session |
| 1478 | * will be maintained internally by the library, and application doesn't |
| 1479 | * need to do anything to maintain the registration session. |
| 1480 | * |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1481 | * |
| 1482 | * @param cfg Account configuration. |
| 1483 | * @param is_default If non-zero, this account will be set as the default |
| 1484 | * account. The default account will be used when sending |
| 1485 | * outgoing requests (e.g. making call) when no account is |
| 1486 | * specified, and when receiving incoming requests when the |
| 1487 | * request does not match any accounts. It is recommended |
| 1488 | * that default account is set to local/LAN account. |
| 1489 | * @param p_acc_id Pointer to receive account ID of the new account. |
| 1490 | * |
| 1491 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1492 | */ |
| 1493 | PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *cfg, |
| 1494 | pj_bool_t is_default, |
| 1495 | pjsua_acc_id *p_acc_id); |
| 1496 | |
| 1497 | |
| 1498 | /** |
| 1499 | * Add a local account. A local account is used to identify local endpoint |
| 1500 | * instead of a specific user, and for this reason, a transport ID is needed |
| 1501 | * to obtain the local address information. |
| 1502 | * |
| 1503 | * @param tid Transport ID to generate account address. |
| 1504 | * @param is_default If non-zero, this account will be set as the default |
| 1505 | * account. The default account will be used when sending |
| 1506 | * outgoing requests (e.g. making call) when no account is |
| 1507 | * specified, and when receiving incoming requests when the |
| 1508 | * request does not match any accounts. It is recommended |
| 1509 | * that default account is set to local/LAN account. |
| 1510 | * @param p_acc_id Pointer to receive account ID of the new account. |
| 1511 | * |
| 1512 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1513 | */ |
| 1514 | PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid, |
| 1515 | pj_bool_t is_default, |
| 1516 | pjsua_acc_id *p_acc_id); |
| 1517 | |
| 1518 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1519 | * Delete an account. This will unregister the account from the SIP server, |
| 1520 | * if necessary, and terminate server side presence subscriptions associated |
| 1521 | * with this account. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1522 | * |
| 1523 | * @param acc_id Id of the account to be deleted. |
| 1524 | * |
| 1525 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1526 | */ |
| 1527 | PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id); |
| 1528 | |
| 1529 | |
| 1530 | /** |
| 1531 | * Modify account information. |
| 1532 | * |
| 1533 | * @param acc_id Id of the account to be modified. |
| 1534 | * @param cfg New account configuration. |
| 1535 | * |
| 1536 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1537 | */ |
| 1538 | PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id, |
| 1539 | const pjsua_acc_config *cfg); |
| 1540 | |
| 1541 | |
| 1542 | /** |
| 1543 | * Modify account's presence status to be advertised to remote/presence |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1544 | * subscribers. This would trigger the sending of outgoing NOTIFY request |
| 1545 | * if there are server side presence subscription for this account. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1546 | * |
| 1547 | * @param acc_id The account ID. |
| 1548 | * @param is_online True of false. |
| 1549 | * |
| 1550 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1551 | */ |
| 1552 | PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id, |
| 1553 | pj_bool_t is_online); |
| 1554 | |
| 1555 | |
| 1556 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1557 | * Update registration or perform unregistration. If registration is |
| 1558 | * configured for this account, then initial SIP REGISTER will be sent |
| 1559 | * when the account is added with #pjsua_acc_add(). Application normally |
| 1560 | * only need to call this function if it wants to manually update the |
| 1561 | * registration or to unregister from the server. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1562 | * |
| 1563 | * @param acc_id The account ID. |
| 1564 | * @param renew If renew argument is zero, this will start |
| 1565 | * unregistration process. |
| 1566 | * |
| 1567 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1568 | */ |
| 1569 | PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id, |
| 1570 | pj_bool_t renew); |
| 1571 | |
| 1572 | |
| 1573 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1574 | * Get information about the specified account. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1575 | * |
| 1576 | * @param acc_id Account identification. |
| 1577 | * @param info Pointer to receive account information. |
| 1578 | * |
| 1579 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1580 | */ |
| 1581 | PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id, |
| 1582 | pjsua_acc_info *info); |
| 1583 | |
| 1584 | |
| 1585 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1586 | * Enumerate all account currently active in the library. This will fill |
| 1587 | * the array with the account Ids, and application can then query the |
| 1588 | * account information for each id with #pjsua_acc_get_info(). |
| 1589 | * |
| 1590 | * @see pjsua_acc_enum_info(). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1591 | * |
| 1592 | * @param ids Array of account IDs to be initialized. |
| 1593 | * @param count In input, specifies the maximum number of elements. |
| 1594 | * On return, it contains the actual number of elements. |
| 1595 | * |
| 1596 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1597 | */ |
| 1598 | PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[], |
| 1599 | unsigned *count ); |
| 1600 | |
| 1601 | |
| 1602 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1603 | * Enumerate account informations. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1604 | * |
| 1605 | * @param info Array of account infos to be initialized. |
| 1606 | * @param count In input, specifies the maximum number of elements. |
| 1607 | * On return, it contains the actual number of elements. |
| 1608 | * |
| 1609 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1610 | */ |
| 1611 | PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[], |
| 1612 | unsigned *count ); |
| 1613 | |
| 1614 | |
| 1615 | /** |
| 1616 | * This is an internal function to find the most appropriate account to |
| 1617 | * used to reach to the specified URL. |
| 1618 | * |
| 1619 | * @param url The remote URL to reach. |
| 1620 | * |
| 1621 | * @return Account id. |
| 1622 | */ |
| 1623 | PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url); |
| 1624 | |
| 1625 | |
| 1626 | /** |
| 1627 | * This is an internal function to find the most appropriate account to be |
| 1628 | * used to handle incoming calls. |
| 1629 | * |
| 1630 | * @param rdata The incoming request message. |
| 1631 | * |
| 1632 | * @return Account id. |
| 1633 | */ |
| 1634 | PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata); |
| 1635 | |
| 1636 | |
Benny Prijono | c570f2d | 2006-07-18 00:33:02 +0000 | [diff] [blame] | 1637 | /** |
| 1638 | * Create a suitable URI to be put as Contact based on the specified |
| 1639 | * target URI for the specified account. |
| 1640 | * |
| 1641 | * @param pool Pool to allocate memory for the string. |
| 1642 | * @param contact The string where the Contact URI will be stored. |
| 1643 | * @param acc_id Account ID. |
| 1644 | * @param uri Destination URI of the request. |
| 1645 | * |
| 1646 | * @return PJ_SUCCESS on success, other on error. |
| 1647 | */ |
| 1648 | PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool, |
| 1649 | pj_str_t *contact, |
| 1650 | pjsua_acc_id acc_id, |
| 1651 | const pj_str_t *uri); |
| 1652 | |
| 1653 | |
| 1654 | |
| 1655 | /** |
| 1656 | * Create a suitable URI to be put as Contact based on the information |
| 1657 | * in the incoming request. |
| 1658 | * |
| 1659 | * @param pool Pool to allocate memory for the string. |
| 1660 | * @param contact The string where the Contact URI will be stored. |
| 1661 | * @param acc_id Account ID. |
| 1662 | * @param rdata Incoming request. |
| 1663 | * |
| 1664 | * @return PJ_SUCCESS on success, other on error. |
| 1665 | */ |
| 1666 | PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool, |
| 1667 | pj_str_t *contact, |
| 1668 | pjsua_acc_id acc_id, |
| 1669 | pjsip_rx_data *rdata ); |
| 1670 | |
| 1671 | |
Benny Prijono | 62c5c5b | 2007-01-13 23:22:40 +0000 | [diff] [blame] | 1672 | /** |
| 1673 | * Lock/bind this account to a specific transport/listener. Normally |
| 1674 | * application shouldn't need to do this, as transports will be selected |
| 1675 | * automatically by the stack according to the destination. |
| 1676 | * |
| 1677 | * When account is locked/bound to a specific transport, all outgoing |
| 1678 | * requests from this account will use the specified transport (this |
| 1679 | * includes SIP registration, dialog (call and event subscription), and |
| 1680 | * out-of-dialog requests such as MESSAGE). |
| 1681 | * |
| 1682 | * Note that transport_id may be specified in pjsua_acc_config too. |
| 1683 | * |
| 1684 | * @param acc_id The account ID. |
| 1685 | * @param tp_id The transport ID. |
| 1686 | * |
| 1687 | * @return PJ_SUCCESS on success. |
| 1688 | */ |
| 1689 | PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id, |
| 1690 | pjsua_transport_id tp_id); |
| 1691 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1692 | |
| 1693 | /** |
| 1694 | * @} |
| 1695 | */ |
| 1696 | |
| 1697 | |
| 1698 | /***************************************************************************** |
| 1699 | * CALLS API |
| 1700 | */ |
| 1701 | |
| 1702 | |
| 1703 | /** |
| 1704 | * @defgroup PJSUA_LIB_CALL Calls |
| 1705 | * @ingroup PJSUA_LIB |
| 1706 | * @brief Call manipulation. |
| 1707 | * @{ |
| 1708 | */ |
| 1709 | |
| 1710 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1711 | * Maximum simultaneous calls. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1712 | */ |
| 1713 | #ifndef PJSUA_MAX_CALLS |
| 1714 | # define PJSUA_MAX_CALLS 32 |
| 1715 | #endif |
| 1716 | |
| 1717 | |
| 1718 | |
| 1719 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1720 | * This enumeration specifies the media status of a call, and it's part |
| 1721 | * of pjsua_call_info structure. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1722 | */ |
| 1723 | typedef enum pjsua_call_media_status |
| 1724 | { |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1725 | /** Call currently has no media */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1726 | PJSUA_CALL_MEDIA_NONE, |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1727 | |
| 1728 | /** The media is active */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1729 | PJSUA_CALL_MEDIA_ACTIVE, |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1730 | |
| 1731 | /** The media is currently put on hold by local endpoint */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1732 | PJSUA_CALL_MEDIA_LOCAL_HOLD, |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1733 | |
| 1734 | /** The media is currently put on hold by remote endpoint */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1735 | PJSUA_CALL_MEDIA_REMOTE_HOLD, |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1736 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1737 | } pjsua_call_media_status; |
| 1738 | |
| 1739 | |
| 1740 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1741 | * This structure describes the information and current status of a call. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1742 | */ |
| 1743 | typedef struct pjsua_call_info |
| 1744 | { |
| 1745 | /** Call identification. */ |
| 1746 | pjsua_call_id id; |
| 1747 | |
| 1748 | /** Initial call role (UAC == caller) */ |
| 1749 | pjsip_role_e role; |
| 1750 | |
Benny Prijono | 9031551 | 2006-09-14 16:05:16 +0000 | [diff] [blame] | 1751 | /** The account ID where this call belongs. */ |
| 1752 | pjsua_acc_id acc_id; |
| 1753 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1754 | /** Local URI */ |
| 1755 | pj_str_t local_info; |
| 1756 | |
| 1757 | /** Local Contact */ |
| 1758 | pj_str_t local_contact; |
| 1759 | |
| 1760 | /** Remote URI */ |
| 1761 | pj_str_t remote_info; |
| 1762 | |
| 1763 | /** Remote contact */ |
| 1764 | pj_str_t remote_contact; |
| 1765 | |
| 1766 | /** Dialog Call-ID string. */ |
| 1767 | pj_str_t call_id; |
| 1768 | |
| 1769 | /** Call state */ |
| 1770 | pjsip_inv_state state; |
| 1771 | |
| 1772 | /** Text describing the state */ |
| 1773 | pj_str_t state_text; |
| 1774 | |
| 1775 | /** Last status code heard, which can be used as cause code */ |
| 1776 | pjsip_status_code last_status; |
| 1777 | |
| 1778 | /** The reason phrase describing the status. */ |
| 1779 | pj_str_t last_status_text; |
| 1780 | |
| 1781 | /** Call media status. */ |
| 1782 | pjsua_call_media_status media_status; |
| 1783 | |
| 1784 | /** Media direction */ |
| 1785 | pjmedia_dir media_dir; |
| 1786 | |
| 1787 | /** The conference port number for the call */ |
| 1788 | pjsua_conf_port_id conf_slot; |
| 1789 | |
| 1790 | /** Up-to-date call connected duration (zero when call is not |
| 1791 | * established) |
| 1792 | */ |
| 1793 | pj_time_val connect_duration; |
| 1794 | |
| 1795 | /** Total call duration, including set-up time */ |
| 1796 | pj_time_val total_duration; |
| 1797 | |
| 1798 | /** Internal */ |
| 1799 | struct { |
| 1800 | char local_info[128]; |
| 1801 | char local_contact[128]; |
| 1802 | char remote_info[128]; |
| 1803 | char remote_contact[128]; |
| 1804 | char call_id[128]; |
| 1805 | char last_status_text[128]; |
| 1806 | } buf_; |
| 1807 | |
| 1808 | } pjsua_call_info; |
| 1809 | |
| 1810 | |
| 1811 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 1812 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1813 | * Get maximum number of calls configured in pjsua. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1814 | * |
| 1815 | * @return Maximum number of calls configured. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1816 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 1817 | PJ_DECL(unsigned) pjsua_call_get_max_count(void); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1818 | |
| 1819 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1820 | * Get number of currently active calls. |
| 1821 | * |
| 1822 | * @return Number of currently active calls. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1823 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 1824 | PJ_DECL(unsigned) pjsua_call_get_count(void); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1825 | |
| 1826 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1827 | * Enumerate all active calls. Application may then query the information and |
| 1828 | * state of each call by calling #pjsua_call_get_info(). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1829 | * |
| 1830 | * @param ids Array of account IDs to be initialized. |
| 1831 | * @param count In input, specifies the maximum number of elements. |
| 1832 | * On return, it contains the actual number of elements. |
| 1833 | * |
| 1834 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1835 | */ |
| 1836 | PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[], |
| 1837 | unsigned *count); |
| 1838 | |
| 1839 | |
| 1840 | /** |
| 1841 | * Make outgoing call to the specified URI using the specified account. |
| 1842 | * |
| 1843 | * @param acc_id The account to be used. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1844 | * @param dst_uri URI to be put in the To header (normally is the same |
| 1845 | * as the target URI). |
| 1846 | * @param options Options (must be zero at the moment). |
| 1847 | * @param user_data Arbitrary user data to be attached to the call, and |
| 1848 | * can be retrieved later. |
| 1849 | * @param msg_data Optional headers etc to be added to outgoing INVITE |
| 1850 | * request, or NULL if no custom header is desired. |
| 1851 | * @param p_call_id Pointer to receive call identification. |
| 1852 | * |
| 1853 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1854 | */ |
| 1855 | PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id, |
| 1856 | const pj_str_t *dst_uri, |
| 1857 | unsigned options, |
| 1858 | void *user_data, |
| 1859 | const pjsua_msg_data *msg_data, |
| 1860 | pjsua_call_id *p_call_id); |
| 1861 | |
| 1862 | |
| 1863 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1864 | * Check if the specified call has active INVITE session and the INVITE |
| 1865 | * session has not been disconnected. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1866 | * |
| 1867 | * @param call_id Call identification. |
| 1868 | * |
| 1869 | * @return Non-zero if call is active. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1870 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1871 | 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] | 1872 | |
| 1873 | |
| 1874 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1875 | * Check if call has an active media session. |
| 1876 | * |
| 1877 | * @param call_id Call identification. |
| 1878 | * |
| 1879 | * @return Non-zero if yes. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1880 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1881 | 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] | 1882 | |
| 1883 | |
| 1884 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1885 | * Get the conference port identification associated with the call. |
| 1886 | * |
| 1887 | * @param call_id Call identification. |
| 1888 | * |
| 1889 | * @return Conference port ID, or PJSUA_INVALID_ID when the |
| 1890 | * media has not been established or is not active. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1891 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1892 | PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id); |
| 1893 | |
| 1894 | /** |
| 1895 | * Obtain detail information about the specified call. |
| 1896 | * |
| 1897 | * @param call_id Call identification. |
| 1898 | * @param info Call info to be initialized. |
| 1899 | * |
| 1900 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1901 | */ |
| 1902 | 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] | 1903 | pjsua_call_info *info); |
| 1904 | |
| 1905 | |
| 1906 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1907 | * Attach application specific data to the call. Application can then |
| 1908 | * inspect this data by calling #pjsua_call_get_user_data(). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1909 | * |
| 1910 | * @param call_id Call identification. |
| 1911 | * @param user_data Arbitrary data to be attached to the call. |
| 1912 | * |
| 1913 | * @return The user data. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1914 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1915 | PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id, |
| 1916 | void *user_data); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1917 | |
| 1918 | |
| 1919 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1920 | * Get user data attached to the call, which has been previously set with |
| 1921 | * #pjsua_call_set_user_data(). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1922 | * |
| 1923 | * @param call_id Call identification. |
| 1924 | * |
| 1925 | * @return The user data. |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 1926 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1927 | 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] | 1928 | |
| 1929 | |
| 1930 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1931 | * Send response to incoming INVITE request. Depending on the status |
| 1932 | * code specified as parameter, this function may send provisional |
| 1933 | * response, establish the call, or terminate the call. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1934 | * |
| 1935 | * @param call_id Incoming call identification. |
| 1936 | * @param code Status code, (100-699). |
| 1937 | * @param reason Optional reason phrase. If NULL, default text |
| 1938 | * will be used. |
| 1939 | * @param msg_data Optional list of headers etc to be added to outgoing |
| 1940 | * response message. |
| 1941 | * |
| 1942 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 1943 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1944 | PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id, |
| 1945 | unsigned code, |
| 1946 | const pj_str_t *reason, |
| 1947 | const pjsua_msg_data *msg_data); |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 1948 | |
| 1949 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1950 | * Hangup call by using method that is appropriate according to the |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1951 | * call state. This function is different than answering the call with |
| 1952 | * 3xx-6xx response (with #pjsua_call_answer()), in that this function |
| 1953 | * will hangup the call regardless of the state and role of the call, |
| 1954 | * while #pjsua_call_answer() only works with incoming calls on EARLY |
| 1955 | * state. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1956 | * |
| 1957 | * @param call_id Call identification. |
| 1958 | * @param code Optional status code to be sent when we're rejecting |
| 1959 | * incoming call. If the value is zero, "603/Decline" |
| 1960 | * will be sent. |
| 1961 | * @param reason Optional reason phrase to be sent when we're rejecting |
| 1962 | * incoming call. If NULL, default text will be used. |
| 1963 | * @param msg_data Optional list of headers etc to be added to outgoing |
| 1964 | * request/response message. |
| 1965 | * |
| 1966 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 1967 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1968 | PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id, |
| 1969 | unsigned code, |
| 1970 | const pj_str_t *reason, |
| 1971 | const pjsua_msg_data *msg_data); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 1972 | |
| 1973 | |
| 1974 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1975 | * Put the specified call on hold. This will send re-INVITE with the |
| 1976 | * appropriate SDP to inform remote that the call is being put on hold. |
| 1977 | * The final status of the request itself will be reported on the |
| 1978 | * \a on_call_media_state() callback, which inform the application that |
| 1979 | * the media state of the call has changed. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1980 | * |
| 1981 | * @param call_id Call identification. |
| 1982 | * @param msg_data Optional message components to be sent with |
| 1983 | * the request. |
| 1984 | * |
| 1985 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 1986 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1987 | PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id, |
| 1988 | const pjsua_msg_data *msg_data); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 1989 | |
| 1990 | |
| 1991 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1992 | * Send re-INVITE to release hold. |
| 1993 | * The final status of the request itself will be reported on the |
| 1994 | * \a on_call_media_state() callback, which inform the application that |
| 1995 | * the media state of the call has changed. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1996 | * |
| 1997 | * @param call_id Call identification. |
| 1998 | * @param unhold If this argument is non-zero and the call is locally |
| 1999 | * held, this will release the local hold. |
| 2000 | * @param msg_data Optional message components to be sent with |
| 2001 | * the request. |
| 2002 | * |
| 2003 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 2004 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2005 | PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id, |
| 2006 | pj_bool_t unhold, |
| 2007 | const pjsua_msg_data *msg_data); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 2008 | |
| 2009 | |
| 2010 | /** |
Benny Prijono | 053f522 | 2006-11-11 16:16:04 +0000 | [diff] [blame] | 2011 | * Initiate call transfer to the specified address. This function will send |
| 2012 | * REFER request to instruct remote call party to initiate a new INVITE |
| 2013 | * session to the specified destination/target. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2014 | * |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2015 | * If application is interested to monitor the successfulness and |
| 2016 | * the progress of the transfer request, it can implement |
| 2017 | * \a on_call_transfer_status() callback which will report the progress |
| 2018 | * of the call transfer request. |
| 2019 | * |
Benny Prijono | 053f522 | 2006-11-11 16:16:04 +0000 | [diff] [blame] | 2020 | * @param call_id The call id to be transfered. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2021 | * @param dest Address of new target to be contacted. |
| 2022 | * @param msg_data Optional message components to be sent with |
| 2023 | * the request. |
| 2024 | * |
| 2025 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 2026 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2027 | PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id, |
| 2028 | const pj_str_t *dest, |
| 2029 | const pjsua_msg_data *msg_data); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2030 | |
| 2031 | /** |
Benny Prijono | 053f522 | 2006-11-11 16:16:04 +0000 | [diff] [blame] | 2032 | * Flag to indicate that "Require: replaces" should not be put in the |
| 2033 | * outgoing INVITE request caused by REFER request created by |
| 2034 | * #pjsua_call_xfer_replaces(). |
| 2035 | */ |
| 2036 | #define PJSUA_XFER_NO_REQUIRE_REPLACES 1 |
| 2037 | |
| 2038 | /** |
| 2039 | * Initiate attended call transfer. This function will send REFER request |
| 2040 | * to instruct remote call party to initiate new INVITE session to the URL |
| 2041 | * of \a dest_call_id. The party at \a dest_call_id then should "replace" |
| 2042 | * the call with us with the new call from the REFER recipient. |
| 2043 | * |
| 2044 | * @param call_id The call id to be transfered. |
| 2045 | * @param dest_call_id The call id to be replaced. |
| 2046 | * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES |
| 2047 | * to suppress the inclusion of "Require: replaces" in |
| 2048 | * the outgoing INVITE request created by the REFER |
| 2049 | * request. |
| 2050 | * @param msg_data Optional message components to be sent with |
| 2051 | * the request. |
| 2052 | * |
| 2053 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2054 | */ |
| 2055 | PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id, |
| 2056 | pjsua_call_id dest_call_id, |
| 2057 | unsigned options, |
| 2058 | const pjsua_msg_data *msg_data); |
| 2059 | |
| 2060 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2061 | * Send DTMF digits to remote using RFC 2833 payload formats. |
| 2062 | * |
| 2063 | * @param call_id Call identification. |
| 2064 | * @param digits DTMF digits to be sent. |
| 2065 | * |
| 2066 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2067 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2068 | 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] | 2069 | const pj_str_t *digits); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 2070 | |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 2071 | /** |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 2072 | * Send instant messaging inside INVITE session. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2073 | * |
| 2074 | * @param call_id Call identification. |
| 2075 | * @param mime_type Optional MIME type. If NULL, then "text/plain" is |
| 2076 | * assumed. |
| 2077 | * @param content The message content. |
| 2078 | * @param msg_data Optional list of headers etc to be included in outgoing |
| 2079 | * request. The body descriptor in the msg_data is |
| 2080 | * ignored. |
| 2081 | * @param user_data Optional user data, which will be given back when |
| 2082 | * the IM callback is called. |
| 2083 | * |
| 2084 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 2085 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2086 | PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id, |
| 2087 | const pj_str_t *mime_type, |
| 2088 | const pj_str_t *content, |
| 2089 | const pjsua_msg_data *msg_data, |
| 2090 | void *user_data); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 2091 | |
| 2092 | |
| 2093 | /** |
| 2094 | * Send IM typing indication inside INVITE session. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2095 | * |
| 2096 | * @param call_id Call identification. |
| 2097 | * @param is_typing Non-zero to indicate to remote that local person is |
| 2098 | * currently typing an IM. |
| 2099 | * @param msg_data Optional list of headers etc to be included in outgoing |
| 2100 | * request. |
| 2101 | * |
| 2102 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 2103 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2104 | PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id, |
| 2105 | pj_bool_t is_typing, |
| 2106 | const pjsua_msg_data*msg_data); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 2107 | |
| 2108 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2109 | * Terminate all calls. This will initiate #pjsua_call_hangup() for all |
| 2110 | * currently active calls. |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 2111 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 2112 | PJ_DECL(void) pjsua_call_hangup_all(void); |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 2113 | |
| 2114 | |
Benny Prijono | b9b32ab | 2006-06-01 12:28:44 +0000 | [diff] [blame] | 2115 | /** |
| 2116 | * Dump call and media statistics to string. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2117 | * |
| 2118 | * @param call_id Call identification. |
| 2119 | * @param with_media Non-zero to include media information too. |
| 2120 | * @param buffer Buffer where the statistics are to be written to. |
| 2121 | * @param maxlen Maximum length of buffer. |
| 2122 | * @param indent Spaces for left indentation. |
| 2123 | * |
| 2124 | * @return PJ_SUCCESS on success. |
Benny Prijono | b9b32ab | 2006-06-01 12:28:44 +0000 | [diff] [blame] | 2125 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2126 | PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id, |
| 2127 | pj_bool_t with_media, |
| 2128 | char *buffer, |
| 2129 | unsigned maxlen, |
| 2130 | const char *indent); |
Benny Prijono | b9b32ab | 2006-06-01 12:28:44 +0000 | [diff] [blame] | 2131 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2132 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2133 | * @} |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2134 | */ |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 2135 | |
| 2136 | |
| 2137 | /***************************************************************************** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2138 | * BUDDY API |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 2139 | */ |
| 2140 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2141 | |
| 2142 | /** |
| 2143 | * @defgroup PJSUA_LIB_BUDDY Buddy, Presence, and Instant Messaging |
| 2144 | * @ingroup PJSUA_LIB |
| 2145 | * @brief Buddy management, buddy's presence, and instant messaging. |
| 2146 | * @{ |
| 2147 | */ |
| 2148 | |
| 2149 | /** |
| 2150 | * Max buddies in buddy list. |
| 2151 | */ |
| 2152 | #ifndef PJSUA_MAX_BUDDIES |
| 2153 | # define PJSUA_MAX_BUDDIES 256 |
| 2154 | #endif |
| 2155 | |
| 2156 | |
| 2157 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2158 | * This structure describes buddy configuration when adding a buddy to |
| 2159 | * the buddy list with #pjsua_buddy_add(). Application MUST initialize |
| 2160 | * the structure with #pjsua_buddy_config_default() to initialize this |
| 2161 | * structure with default configuration. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2162 | */ |
| 2163 | typedef struct pjsua_buddy_config |
| 2164 | { |
| 2165 | /** |
| 2166 | * Buddy URL or name address. |
| 2167 | */ |
| 2168 | pj_str_t uri; |
| 2169 | |
| 2170 | /** |
| 2171 | * Specify whether presence subscription should start immediately. |
| 2172 | */ |
| 2173 | pj_bool_t subscribe; |
| 2174 | |
| 2175 | } pjsua_buddy_config; |
| 2176 | |
| 2177 | |
| 2178 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2179 | * This enumeration describes basic buddy's online status. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2180 | */ |
| 2181 | typedef enum pjsua_buddy_status |
| 2182 | { |
| 2183 | /** |
| 2184 | * Online status is unknown (possibly because no presence subscription |
| 2185 | * has been established). |
| 2186 | */ |
| 2187 | PJSUA_BUDDY_STATUS_UNKNOWN, |
| 2188 | |
| 2189 | /** |
| 2190 | * Buddy is known to be offline. |
| 2191 | */ |
| 2192 | PJSUA_BUDDY_STATUS_ONLINE, |
| 2193 | |
| 2194 | /** |
| 2195 | * Buddy is offline. |
| 2196 | */ |
| 2197 | PJSUA_BUDDY_STATUS_OFFLINE, |
| 2198 | |
| 2199 | } pjsua_buddy_status; |
| 2200 | |
| 2201 | |
| 2202 | |
| 2203 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2204 | * This structure describes buddy info, which can be retrieved by calling |
| 2205 | * #pjsua_buddy_get_info(). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2206 | */ |
| 2207 | typedef struct pjsua_buddy_info |
| 2208 | { |
| 2209 | /** |
| 2210 | * The buddy ID. |
| 2211 | */ |
| 2212 | pjsua_buddy_id id; |
| 2213 | |
| 2214 | /** |
| 2215 | * The full URI of the buddy, as specified in the configuration. |
| 2216 | */ |
| 2217 | pj_str_t uri; |
| 2218 | |
| 2219 | /** |
| 2220 | * Buddy's Contact, only available when presence subscription has |
| 2221 | * been established to the buddy. |
| 2222 | */ |
| 2223 | pj_str_t contact; |
| 2224 | |
| 2225 | /** |
| 2226 | * Buddy's online status. |
| 2227 | */ |
| 2228 | pjsua_buddy_status status; |
| 2229 | |
| 2230 | /** |
| 2231 | * Text to describe buddy's online status. |
| 2232 | */ |
| 2233 | pj_str_t status_text; |
| 2234 | |
| 2235 | /** |
| 2236 | * Flag to indicate that we should monitor the presence information for |
| 2237 | * this buddy (normally yes, unless explicitly disabled). |
| 2238 | */ |
| 2239 | pj_bool_t monitor_pres; |
| 2240 | |
| 2241 | /** |
| 2242 | * Internal buffer. |
| 2243 | */ |
| 2244 | char buf_[256]; |
| 2245 | |
| 2246 | } pjsua_buddy_info; |
| 2247 | |
| 2248 | |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 2249 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2250 | * Set default values to the buddy config. |
| 2251 | */ |
| 2252 | PJ_INLINE(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg) |
| 2253 | { |
| 2254 | pj_bzero(cfg, sizeof(*cfg)); |
| 2255 | } |
| 2256 | |
| 2257 | |
| 2258 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2259 | * Get total number of buddies. |
| 2260 | * |
| 2261 | * @return Number of buddies. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2262 | */ |
| 2263 | PJ_DECL(unsigned) pjsua_get_buddy_count(void); |
| 2264 | |
| 2265 | |
| 2266 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2267 | * Check if buddy ID is valid. |
| 2268 | * |
| 2269 | * @param buddy_id Buddy ID to check. |
| 2270 | * |
| 2271 | * @return Non-zero if buddy ID is valid. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2272 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2273 | PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id); |
| 2274 | |
| 2275 | |
| 2276 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2277 | * Enumerate all buddy IDs in the buddy list. Application then can use |
| 2278 | * #pjsua_buddy_get_info() to get the detail information for each buddy |
| 2279 | * id. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2280 | * |
| 2281 | * @param ids Array of ids to be initialized. |
| 2282 | * @param count On input, specifies max elements in the array. |
| 2283 | * On return, it contains actual number of elements |
| 2284 | * that have been initialized. |
| 2285 | * |
| 2286 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2287 | */ |
| 2288 | PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[], |
| 2289 | unsigned *count); |
| 2290 | |
| 2291 | /** |
| 2292 | * Get detailed buddy info. |
| 2293 | * |
| 2294 | * @param buddy_id The buddy identification. |
| 2295 | * @param info Pointer to receive information about buddy. |
| 2296 | * |
| 2297 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2298 | */ |
| 2299 | 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] | 2300 | pjsua_buddy_info *info); |
| 2301 | |
| 2302 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2303 | * Add new buddy to the buddy list. If presence subscription is enabled |
| 2304 | * for this buddy, this function will also start the presence subscription |
| 2305 | * session immediately. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2306 | * |
| 2307 | * @param cfg Buddy configuration. |
| 2308 | * @param p_buddy_id Pointer to receive buddy ID. |
| 2309 | * |
| 2310 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2311 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2312 | PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *cfg, |
| 2313 | pjsua_buddy_id *p_buddy_id); |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 2314 | |
| 2315 | |
| 2316 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2317 | * Delete the specified buddy from the buddy list. Any presence subscription |
| 2318 | * to this buddy will be terminated. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2319 | * |
| 2320 | * @param buddy_id Buddy identification. |
| 2321 | * |
| 2322 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 2323 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2324 | 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] | 2325 | |
| 2326 | |
| 2327 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2328 | * Enable/disable buddy's presence monitoring. Once buddy's presence is |
| 2329 | * subscribed, application will be informed about buddy's presence status |
| 2330 | * changed via \a on_buddy_state() callback. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2331 | * |
| 2332 | * @param buddy_id Buddy identification. |
| 2333 | * @param subscribe Specify non-zero to activate presence subscription to |
| 2334 | * the specified buddy. |
| 2335 | * |
| 2336 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2337 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2338 | PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id, |
| 2339 | pj_bool_t subscribe); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2340 | |
| 2341 | |
| 2342 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2343 | * Dump presence subscriptions to log. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2344 | * |
| 2345 | * @param verbose Yes or no. |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 2346 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2347 | PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose); |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 2348 | |
| 2349 | |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 2350 | /** |
| 2351 | * The MESSAGE method (defined in pjsua_im.c) |
| 2352 | */ |
| 2353 | extern const pjsip_method pjsip_message_method; |
| 2354 | |
| 2355 | |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 2356 | |
| 2357 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2358 | * Send instant messaging outside dialog, using the specified account for |
| 2359 | * route set and authentication. |
| 2360 | * |
| 2361 | * @param acc_id Account ID to be used to send the request. |
| 2362 | * @param to Remote URI. |
| 2363 | * @param mime_type Optional MIME type. If NULL, then "text/plain" is |
| 2364 | * assumed. |
| 2365 | * @param content The message content. |
| 2366 | * @param msg_data Optional list of headers etc to be included in outgoing |
| 2367 | * request. The body descriptor in the msg_data is |
| 2368 | * ignored. |
| 2369 | * @param user_data Optional user data, which will be given back when |
| 2370 | * the IM callback is called. |
| 2371 | * |
| 2372 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 2373 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2374 | PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id, |
| 2375 | const pj_str_t *to, |
| 2376 | const pj_str_t *mime_type, |
| 2377 | const pj_str_t *content, |
| 2378 | const pjsua_msg_data *msg_data, |
| 2379 | void *user_data); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 2380 | |
| 2381 | |
| 2382 | /** |
| 2383 | * Send typing indication outside dialog. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2384 | * |
| 2385 | * @param acc_id Account ID to be used to send the request. |
| 2386 | * @param to Remote URI. |
| 2387 | * @param is_typing If non-zero, it tells remote person that local person |
| 2388 | * is currently composing an IM. |
| 2389 | * @param msg_data Optional list of headers etc to be added to outgoing |
| 2390 | * request. |
| 2391 | * |
| 2392 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 2393 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2394 | PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id, |
| 2395 | const pj_str_t *to, |
| 2396 | pj_bool_t is_typing, |
| 2397 | const pjsua_msg_data *msg_data); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 2398 | |
| 2399 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 2400 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2401 | /** |
| 2402 | * @} |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2403 | */ |
| 2404 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2405 | |
| 2406 | /***************************************************************************** |
| 2407 | * MEDIA API |
| 2408 | */ |
| 2409 | |
| 2410 | |
| 2411 | /** |
| 2412 | * @defgroup PJSUA_LIB_MEDIA Media |
| 2413 | * @ingroup PJSUA_LIB |
| 2414 | * @brief Media manipulation. |
| 2415 | * @{ |
| 2416 | * |
| 2417 | * PJSUA has rather powerful media features, which are built around the |
| 2418 | * PJMEDIA conference bridge. Basically, all media termination (such as |
| 2419 | * calls, file players, file recorders, sound device, tone generators, etc) |
| 2420 | * are terminated in the conference bridge, and application can manipulate |
| 2421 | * the interconnection between these terminations freely. If more than |
| 2422 | * one media terminations are terminated in the same slot, the conference |
| 2423 | * bridge will mix the signal automatically. |
| 2424 | * |
| 2425 | * Application connects one media termination/slot to another by calling |
| 2426 | * #pjsua_conf_connect() function. This will establish <b>unidirectional</b> |
| 2427 | * media flow from the source termination to the sink termination. For |
| 2428 | * example, to stream a WAV file to remote call, application may use |
| 2429 | * the following steps: |
| 2430 | * |
| 2431 | \code |
| 2432 | |
| 2433 | pj_status_t stream_to_call( pjsua_call_id call_id ) |
| 2434 | { |
| 2435 | pjsua_player_id player_id; |
| 2436 | |
| 2437 | status = pjsua_player_create("mysong.wav", 0, NULL, &player_id); |
| 2438 | if (status != PJ_SUCCESS) |
| 2439 | return status; |
| 2440 | |
| 2441 | status = pjsua_conf_connect( pjsua_player_get_conf_port(), |
| 2442 | pjsua_call_get_conf_port() ); |
| 2443 | } |
| 2444 | \endcode |
| 2445 | * |
| 2446 | * |
| 2447 | * Other features of PJSUA media: |
| 2448 | * - efficient N to M interconnections between media terminations. |
| 2449 | * - media termination can be connected to itself to create loopback |
| 2450 | * media. |
| 2451 | * - the media termination may have different clock rates, and resampling |
| 2452 | * will be done automatically by conference bridge. |
| 2453 | * - media terminations may also have different frame time; the |
| 2454 | * conference bridge will perform the necessary bufferring to adjust |
| 2455 | * the difference between terminations. |
| 2456 | * - interconnections are removed automatically when media termination |
| 2457 | * is removed from the bridge. |
| 2458 | * - sound device may be changed even when there are active media |
| 2459 | * interconnections. |
| 2460 | * - correctly report call's media quality (in #pjsua_call_dump()) from |
| 2461 | * RTCP packet exchange. |
| 2462 | */ |
| 2463 | |
| 2464 | /** |
| 2465 | * Max ports in the conference bridge. |
| 2466 | */ |
| 2467 | #ifndef PJSUA_MAX_CONF_PORTS |
Benny Prijono | 12a669c | 2006-11-23 07:32:13 +0000 | [diff] [blame] | 2468 | # define PJSUA_MAX_CONF_PORTS 254 |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2469 | #endif |
| 2470 | |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2471 | /** |
| 2472 | * The default clock rate to be used by the conference bridge. |
| 2473 | */ |
Benny Prijono | 12a669c | 2006-11-23 07:32:13 +0000 | [diff] [blame] | 2474 | #ifndef PJSUA_DEFAULT_CLOCK_RATE |
| 2475 | # define PJSUA_DEFAULT_CLOCK_RATE 16000 |
| 2476 | #endif |
| 2477 | |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2478 | /** |
| 2479 | * Default codec quality settings. |
| 2480 | */ |
Benny Prijono | 12a669c | 2006-11-23 07:32:13 +0000 | [diff] [blame] | 2481 | #ifndef PJSUA_DEFAULT_CODEC_QUALITY |
| 2482 | # define PJSUA_DEFAULT_CODEC_QUALITY 5 |
| 2483 | #endif |
| 2484 | |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2485 | /** |
| 2486 | * Default iLBC mode. |
| 2487 | */ |
Benny Prijono | 12a669c | 2006-11-23 07:32:13 +0000 | [diff] [blame] | 2488 | #ifndef PJSUA_DEFAULT_ILBC_MODE |
| 2489 | # define PJSUA_DEFAULT_ILBC_MODE 20 |
| 2490 | #endif |
| 2491 | |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2492 | /** |
| 2493 | * The default echo canceller tail length. |
| 2494 | */ |
Benny Prijono | 12a669c | 2006-11-23 07:32:13 +0000 | [diff] [blame] | 2495 | #ifndef PJSUA_DEFAULT_EC_TAIL_LEN |
Benny Prijono | d2990b9 | 2006-11-23 10:19:46 +0000 | [diff] [blame] | 2496 | # define PJSUA_DEFAULT_EC_TAIL_LEN 800 |
Benny Prijono | 12a669c | 2006-11-23 07:32:13 +0000 | [diff] [blame] | 2497 | #endif |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2498 | |
| 2499 | |
| 2500 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2501 | * This structure describes media configuration, which will be specified |
| 2502 | * when calling #pjsua_init(). Application MUST initialize this structure |
| 2503 | * by calling #pjsua_media_config_default(). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2504 | */ |
| 2505 | struct pjsua_media_config |
| 2506 | { |
| 2507 | /** |
| 2508 | * Clock rate to be applied to the conference bridge. |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2509 | * If value is zero, default clock rate will be used |
| 2510 | * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2511 | */ |
| 2512 | unsigned clock_rate; |
| 2513 | |
| 2514 | /** |
| 2515 | * Specify maximum number of media ports to be created in the |
| 2516 | * conference bridge. Since all media terminate in the bridge |
| 2517 | * (calls, file player, file recorder, etc), the value must be |
| 2518 | * large enough to support all of them. However, the larger |
| 2519 | * the value, the more computations are performed. |
| 2520 | */ |
| 2521 | unsigned max_media_ports; |
| 2522 | |
| 2523 | /** |
| 2524 | * Specify whether the media manager should manage its own |
| 2525 | * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created |
| 2526 | * and at least one worker thread will be created too. If no, |
| 2527 | * the RTP/RTCP sockets will share the same ioqueue as SIP sockets, |
| 2528 | * and no worker thread is needed. |
| 2529 | * |
| 2530 | * Normally application would say yes here, unless it wants to |
| 2531 | * run everything from a single thread. |
| 2532 | */ |
| 2533 | pj_bool_t has_ioqueue; |
| 2534 | |
| 2535 | /** |
| 2536 | * Specify the number of worker threads to handle incoming RTP |
| 2537 | * packets. A value of one is recommended for most applications. |
| 2538 | */ |
| 2539 | unsigned thread_cnt; |
| 2540 | |
Benny Prijono | 0498d90 | 2006-06-19 14:49:14 +0000 | [diff] [blame] | 2541 | /** |
| 2542 | * Media quality, 0-10, according to this table: |
Benny Prijono | 7ca96da | 2006-08-07 12:11:40 +0000 | [diff] [blame] | 2543 | * 5-10: resampling use large filter, |
| 2544 | * 3-4: resampling use small filter, |
Benny Prijono | 0498d90 | 2006-06-19 14:49:14 +0000 | [diff] [blame] | 2545 | * 1-2: resampling use linear. |
| 2546 | * The media quality also sets speex codec quality/complexity to the |
| 2547 | * number. |
| 2548 | * |
Benny Prijono | 7097299 | 2006-08-05 11:13:58 +0000 | [diff] [blame] | 2549 | * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY). |
Benny Prijono | 0498d90 | 2006-06-19 14:49:14 +0000 | [diff] [blame] | 2550 | */ |
| 2551 | unsigned quality; |
Benny Prijono | 0a12f00 | 2006-07-26 17:05:39 +0000 | [diff] [blame] | 2552 | |
| 2553 | /** |
| 2554 | * Specify default ptime. |
| 2555 | * |
| 2556 | * Default: 0 (codec specific) |
| 2557 | */ |
| 2558 | unsigned ptime; |
| 2559 | |
| 2560 | /** |
| 2561 | * Disable VAD? |
| 2562 | * |
| 2563 | * Default: 0 (no (meaning VAD is enabled)) |
| 2564 | */ |
| 2565 | pj_bool_t no_vad; |
Benny Prijono | 00cae61 | 2006-07-31 15:19:36 +0000 | [diff] [blame] | 2566 | |
| 2567 | /** |
| 2568 | * iLBC mode (20 or 30). |
| 2569 | * |
Benny Prijono | 7097299 | 2006-08-05 11:13:58 +0000 | [diff] [blame] | 2570 | * Default: 20 (PJSUA_DEFAULT_ILBC_MODE) |
Benny Prijono | 00cae61 | 2006-07-31 15:19:36 +0000 | [diff] [blame] | 2571 | */ |
| 2572 | unsigned ilbc_mode; |
| 2573 | |
| 2574 | /** |
| 2575 | * Percentage of RTP packet to drop in TX direction |
| 2576 | * (to simulate packet lost). |
| 2577 | * |
| 2578 | * Default: 0 |
| 2579 | */ |
| 2580 | unsigned tx_drop_pct; |
| 2581 | |
| 2582 | /** |
| 2583 | * Percentage of RTP packet to drop in RX direction |
| 2584 | * (to simulate packet lost). |
| 2585 | * |
| 2586 | * Default: 0 |
| 2587 | */ |
| 2588 | unsigned rx_drop_pct; |
| 2589 | |
Benny Prijono | c8e24a1 | 2006-08-02 18:22:22 +0000 | [diff] [blame] | 2590 | /** |
Benny Prijono | 5da5043 | 2006-08-07 10:24:52 +0000 | [diff] [blame] | 2591 | * Echo canceller options (see #pjmedia_echo_create()) |
| 2592 | * |
| 2593 | * Default: 0. |
| 2594 | */ |
| 2595 | unsigned ec_options; |
| 2596 | |
| 2597 | /** |
Benny Prijono | c8e24a1 | 2006-08-02 18:22:22 +0000 | [diff] [blame] | 2598 | * Echo canceller tail length, in miliseconds. |
| 2599 | * |
Benny Prijono | 669643c | 2006-09-20 20:02:18 +0000 | [diff] [blame] | 2600 | * Default: PJSUA_DEFAULT_EC_TAIL_LEN |
Benny Prijono | c8e24a1 | 2006-08-02 18:22:22 +0000 | [diff] [blame] | 2601 | */ |
| 2602 | unsigned ec_tail_len; |
Benny Prijono | 1d0ca0c | 2006-11-21 09:06:47 +0000 | [diff] [blame] | 2603 | |
| 2604 | /** |
| 2605 | * Jitter buffer initial prefetch delay in msec. The value must be |
| 2606 | * between jb_min_pre and jb_max_pre below. |
| 2607 | * |
| 2608 | * Default: -1 (to use default stream settings, currently 150 msec) |
| 2609 | */ |
| 2610 | int jb_init; |
| 2611 | |
| 2612 | /** |
| 2613 | * Jitter buffer minimum prefetch delay in msec. |
| 2614 | * |
| 2615 | * Default: -1 (to use default stream settings, currently 60 msec) |
| 2616 | */ |
| 2617 | int jb_min_pre; |
| 2618 | |
| 2619 | /** |
| 2620 | * Jitter buffer maximum prefetch delay in msec. |
| 2621 | * |
| 2622 | * Default: -1 (to use default stream settings, currently 240 msec) |
| 2623 | */ |
| 2624 | int jb_max_pre; |
| 2625 | |
| 2626 | /** |
| 2627 | * Set maximum delay that can be accomodated by the jitter buffer msec. |
| 2628 | * |
| 2629 | * Default: -1 (to use default stream settings, currently 360 msec) |
| 2630 | */ |
| 2631 | int jb_max; |
| 2632 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2633 | }; |
| 2634 | |
| 2635 | |
| 2636 | /** |
| 2637 | * Use this function to initialize media config. |
| 2638 | * |
| 2639 | * @param cfg The media config to be initialized. |
| 2640 | */ |
| 2641 | PJ_INLINE(void) pjsua_media_config_default(pjsua_media_config *cfg) |
| 2642 | { |
Benny Prijono | ac623b3 | 2006-07-03 15:19:31 +0000 | [diff] [blame] | 2643 | pj_bzero(cfg, sizeof(*cfg)); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2644 | |
Benny Prijono | 7097299 | 2006-08-05 11:13:58 +0000 | [diff] [blame] | 2645 | cfg->clock_rate = PJSUA_DEFAULT_CLOCK_RATE; |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2646 | cfg->max_media_ports = 32; |
| 2647 | cfg->has_ioqueue = PJ_TRUE; |
| 2648 | cfg->thread_cnt = 1; |
Benny Prijono | 7097299 | 2006-08-05 11:13:58 +0000 | [diff] [blame] | 2649 | cfg->quality = PJSUA_DEFAULT_CODEC_QUALITY; |
| 2650 | cfg->ilbc_mode = PJSUA_DEFAULT_ILBC_MODE; |
| 2651 | cfg->ec_tail_len = PJSUA_DEFAULT_EC_TAIL_LEN; |
Benny Prijono | 1d0ca0c | 2006-11-21 09:06:47 +0000 | [diff] [blame] | 2652 | cfg->jb_init = cfg->jb_min_pre = cfg->jb_max_pre = cfg->jb_max = -1; |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2653 | } |
| 2654 | |
| 2655 | |
| 2656 | |
| 2657 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2658 | * This structure describes codec information, which can be retrieved by |
| 2659 | * calling #pjsua_enum_codecs(). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2660 | */ |
| 2661 | typedef struct pjsua_codec_info |
| 2662 | { |
| 2663 | /** |
| 2664 | * Codec unique identification. |
| 2665 | */ |
| 2666 | pj_str_t codec_id; |
| 2667 | |
| 2668 | /** |
| 2669 | * Codec priority (integer 0-255). |
| 2670 | */ |
| 2671 | pj_uint8_t priority; |
| 2672 | |
| 2673 | /** |
| 2674 | * Internal buffer. |
| 2675 | */ |
| 2676 | char buf_[32]; |
| 2677 | |
| 2678 | } pjsua_codec_info; |
| 2679 | |
| 2680 | |
| 2681 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2682 | * This structure descibes information about a particular media port that |
| 2683 | * has been registered into the conference bridge. Application can query |
| 2684 | * this info by calling #pjsua_conf_get_port_info(). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2685 | */ |
| 2686 | typedef struct pjsua_conf_port_info |
| 2687 | { |
| 2688 | /** Conference port number. */ |
| 2689 | pjsua_conf_port_id slot_id; |
| 2690 | |
| 2691 | /** Port name. */ |
| 2692 | pj_str_t name; |
| 2693 | |
| 2694 | /** Clock rate. */ |
| 2695 | unsigned clock_rate; |
| 2696 | |
| 2697 | /** Number of channels. */ |
| 2698 | unsigned channel_count; |
| 2699 | |
| 2700 | /** Samples per frame */ |
| 2701 | unsigned samples_per_frame; |
| 2702 | |
| 2703 | /** Bits per sample */ |
| 2704 | unsigned bits_per_sample; |
| 2705 | |
| 2706 | /** Number of listeners in the array. */ |
| 2707 | unsigned listener_cnt; |
| 2708 | |
| 2709 | /** Array of listeners (in other words, ports where this port is |
| 2710 | * transmitting to. |
| 2711 | */ |
| 2712 | pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS]; |
| 2713 | |
| 2714 | } pjsua_conf_port_info; |
| 2715 | |
| 2716 | |
| 2717 | /** |
| 2718 | * This structure holds information about custom media transport to |
| 2719 | * be registered to pjsua. |
| 2720 | */ |
| 2721 | typedef struct pjsua_media_transport |
| 2722 | { |
| 2723 | /** |
| 2724 | * Media socket information containing the address information |
| 2725 | * of the RTP and RTCP socket. |
| 2726 | */ |
| 2727 | pjmedia_sock_info skinfo; |
| 2728 | |
| 2729 | /** |
| 2730 | * The media transport instance. |
| 2731 | */ |
| 2732 | pjmedia_transport *transport; |
| 2733 | |
| 2734 | } pjsua_media_transport; |
| 2735 | |
| 2736 | |
| 2737 | |
| 2738 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2739 | /** |
| 2740 | * Get maxinum number of conference ports. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2741 | * |
| 2742 | * @return Maximum number of ports in the conference bridge. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2743 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2744 | PJ_DECL(unsigned) pjsua_conf_get_max_ports(void); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2745 | |
| 2746 | |
| 2747 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2748 | * Get current number of active ports in the bridge. |
| 2749 | * |
| 2750 | * @return The number. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2751 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2752 | PJ_DECL(unsigned) pjsua_conf_get_active_ports(void); |
| 2753 | |
| 2754 | |
| 2755 | /** |
| 2756 | * Enumerate all conference ports. |
| 2757 | * |
| 2758 | * @param id Array of conference port ID to be initialized. |
| 2759 | * @param count On input, specifies max elements in the array. |
| 2760 | * On return, it contains actual number of elements |
| 2761 | * that have been initialized. |
| 2762 | * |
| 2763 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2764 | */ |
| 2765 | PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[], |
| 2766 | unsigned *count); |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 2767 | |
| 2768 | |
| 2769 | /** |
| 2770 | * Get information about the specified conference port |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2771 | * |
| 2772 | * @param id Port identification. |
| 2773 | * @param info Pointer to store the port info. |
| 2774 | * |
| 2775 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 2776 | */ |
| 2777 | PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id id, |
| 2778 | pjsua_conf_port_info *info); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2779 | |
| 2780 | |
| 2781 | /** |
Benny Prijono | e909eac | 2006-07-27 22:04:56 +0000 | [diff] [blame] | 2782 | * Add arbitrary media port to PJSUA's conference bridge. Application |
| 2783 | * can use this function to add the media port that it creates. For |
| 2784 | * media ports that are created by PJSUA-LIB (such as calls, file player, |
| 2785 | * or file recorder), PJSUA-LIB will automatically add the port to |
| 2786 | * the bridge. |
| 2787 | * |
| 2788 | * @param pool Pool to use. |
| 2789 | * @param port Media port to be added to the bridge. |
| 2790 | * @param p_id Optional pointer to receive the conference |
| 2791 | * slot id. |
| 2792 | * |
| 2793 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2794 | */ |
| 2795 | PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool, |
| 2796 | pjmedia_port *port, |
| 2797 | pjsua_conf_port_id *p_id); |
| 2798 | |
| 2799 | |
| 2800 | /** |
| 2801 | * Remove arbitrary slot from the conference bridge. Application should only |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2802 | * call this function if it registered the port manually with previous call |
| 2803 | * to #pjsua_conf_add_port(). |
Benny Prijono | e909eac | 2006-07-27 22:04:56 +0000 | [diff] [blame] | 2804 | * |
| 2805 | * @param id The slot id of the port to be removed. |
| 2806 | * |
| 2807 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2808 | */ |
| 2809 | PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id id); |
| 2810 | |
| 2811 | |
| 2812 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2813 | * Establish unidirectional media flow from souce to sink. One source |
| 2814 | * may transmit to multiple destinations/sink. And if multiple |
| 2815 | * sources are transmitting to the same sink, the media will be mixed |
| 2816 | * together. Source and sink may refer to the same ID, effectively |
| 2817 | * looping the media. |
| 2818 | * |
| 2819 | * If bidirectional media flow is desired, application needs to call |
| 2820 | * this function twice, with the second one having the arguments |
| 2821 | * reversed. |
| 2822 | * |
| 2823 | * @param source Port ID of the source media/transmitter. |
| 2824 | * @param sink Port ID of the destination media/received. |
| 2825 | * |
| 2826 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2827 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2828 | PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source, |
| 2829 | pjsua_conf_port_id sink); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2830 | |
| 2831 | |
| 2832 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2833 | * Disconnect media flow from the source to destination port. |
| 2834 | * |
| 2835 | * @param source Port ID of the source media/transmitter. |
| 2836 | * @param sink Port ID of the destination media/received. |
| 2837 | * |
| 2838 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2839 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2840 | PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source, |
| 2841 | pjsua_conf_port_id sink); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2842 | |
| 2843 | |
Benny Prijono | 6dd967c | 2006-12-26 02:27:14 +0000 | [diff] [blame] | 2844 | /** |
| 2845 | * Adjust the signal level to be transmitted from the bridge to the |
| 2846 | * specified port by making it louder or quieter. |
| 2847 | * |
| 2848 | * @param slot The conference bridge slot number. |
| 2849 | * @param level Signal level adjustment. Value 1.0 means no level |
| 2850 | * adjustment, while value 0 means to mute the port. |
| 2851 | * |
| 2852 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2853 | */ |
| 2854 | PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot, |
| 2855 | float level); |
| 2856 | |
| 2857 | /** |
| 2858 | * Adjust the signal level to be received from the specified port (to |
| 2859 | * the bridge) by making it louder or quieter. |
| 2860 | * |
| 2861 | * @param slot The conference bridge slot number. |
| 2862 | * @param level Signal level adjustment. Value 1.0 means no level |
| 2863 | * adjustment, while value 0 means to mute the port. |
| 2864 | * |
| 2865 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2866 | */ |
| 2867 | PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot, |
| 2868 | float level); |
| 2869 | |
| 2870 | /** |
| 2871 | * Get last signal level transmitted to or received from the specified port. |
| 2872 | * The signal level is an integer value in zero to 255, with zero indicates |
| 2873 | * no signal, and 255 indicates the loudest signal level. |
| 2874 | * |
| 2875 | * @param slot The conference bridge slot number. |
| 2876 | * @param tx_level Optional argument to receive the level of signal |
| 2877 | * transmitted to the specified port (i.e. the direction |
| 2878 | * is from the bridge to the port). |
| 2879 | * @param rx_level Optional argument to receive the level of signal |
| 2880 | * received from the port (i.e. the direction is from the |
| 2881 | * port to the bridge). |
| 2882 | * |
| 2883 | * @return PJ_SUCCESS on success. |
| 2884 | */ |
| 2885 | PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot, |
| 2886 | unsigned *tx_level, |
| 2887 | unsigned *rx_level); |
| 2888 | |
| 2889 | /** |
| 2890 | * |
| 2891 | */ |
| 2892 | |
| 2893 | |
| 2894 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2895 | /***************************************************************************** |
Benny Prijono | a66c331 | 2007-01-21 23:12:40 +0000 | [diff] [blame^] | 2896 | * File player and playlist. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2897 | */ |
| 2898 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2899 | /** |
Benny Prijono | a66c331 | 2007-01-21 23:12:40 +0000 | [diff] [blame^] | 2900 | * Create a file player, and automatically add this player to |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2901 | * the conference bridge. |
| 2902 | * |
| 2903 | * @param filename The filename to be played. Currently only |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2904 | * WAV files are supported, and the WAV file MUST be |
| 2905 | * formatted as 16bit PCM mono/single channel (any |
| 2906 | * clock rate is supported). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2907 | * @param options Options (currently zero). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2908 | * @param p_id Pointer to receive player ID. |
| 2909 | * |
| 2910 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2911 | */ |
| 2912 | 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] | 2913 | unsigned options, |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2914 | pjsua_player_id *p_id); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2915 | |
| 2916 | |
| 2917 | /** |
Benny Prijono | a66c331 | 2007-01-21 23:12:40 +0000 | [diff] [blame^] | 2918 | * Create a file playlist media port, and automatically add the port |
| 2919 | * to the conference bridge. |
| 2920 | * |
| 2921 | * @param file_names Array of file names to be added to the play list. |
| 2922 | * Note that the files must have the same clock rate, |
| 2923 | * number of channels, and number of bits per sample. |
| 2924 | * @param file_count Number of files in the array. |
| 2925 | * @param label Optional label to be set for the media port. |
| 2926 | * @param options Optional option flag. Application may specify |
| 2927 | * PJMEDIA_FILE_NO_LOOP to prevent looping. |
| 2928 | * @param p_id Optional pointer to receive player ID. |
| 2929 | * |
| 2930 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2931 | */ |
| 2932 | PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[], |
| 2933 | unsigned file_count, |
| 2934 | const pj_str_t *label, |
| 2935 | unsigned options, |
| 2936 | pjsua_player_id *p_id); |
| 2937 | |
| 2938 | /** |
| 2939 | * Get conference port ID associated with player or playlist. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2940 | * |
| 2941 | * @param id The file player ID. |
| 2942 | * |
| 2943 | * @return Conference port ID associated with this player. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2944 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 2945 | 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] | 2946 | |
| 2947 | |
| 2948 | /** |
Benny Prijono | a66c331 | 2007-01-21 23:12:40 +0000 | [diff] [blame^] | 2949 | * Get the media port for the player or playlist. |
Benny Prijono | 469b152 | 2006-12-26 03:05:17 +0000 | [diff] [blame] | 2950 | * |
| 2951 | * @param id The player ID. |
| 2952 | * @param p_port The media port associated with the player. |
| 2953 | * |
| 2954 | * @return PJ_SUCCESS on success. |
| 2955 | */ |
| 2956 | PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_recorder_id id, |
| 2957 | pjmedia_port **p_port); |
| 2958 | |
| 2959 | /** |
Benny Prijono | a66c331 | 2007-01-21 23:12:40 +0000 | [diff] [blame^] | 2960 | * Set playback position. This operation is not valid for playlist. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2961 | * |
| 2962 | * @param id The file player ID. |
| 2963 | * @param samples The playback position, in samples. Application can |
| 2964 | * specify zero to re-start the playback. |
| 2965 | * |
| 2966 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2967 | */ |
| 2968 | PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id, |
| 2969 | pj_uint32_t samples); |
| 2970 | |
| 2971 | |
| 2972 | /** |
Benny Prijono | a66c331 | 2007-01-21 23:12:40 +0000 | [diff] [blame^] | 2973 | * Close the file of playlist, remove the player from the bridge, and free |
| 2974 | * resources associated with the file player or playlist. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2975 | * |
| 2976 | * @param id The file player ID. |
| 2977 | * |
| 2978 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2979 | */ |
| 2980 | PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id); |
| 2981 | |
| 2982 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2983 | /***************************************************************************** |
| 2984 | * File recorder. |
| 2985 | */ |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2986 | |
| 2987 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2988 | * Create a file recorder, and automatically connect this recorder to |
Benny Prijono | 8f31052 | 2006-10-20 11:08:49 +0000 | [diff] [blame] | 2989 | * the conference bridge. The recorder currently supports recording WAV file, |
| 2990 | * and on Windows, MP3 file. The type of the recorder to use is determined |
| 2991 | * by the extension of the file (e.g. ".wav" or ".mp3"). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2992 | * |
Benny Prijono | b3cdb2b | 2006-10-19 15:49:47 +0000 | [diff] [blame] | 2993 | * @param filename Output file name. The function will determine the |
| 2994 | * default format to be used based on the file extension. |
| 2995 | * Currently ".wav" is supported on all platforms, and |
| 2996 | * also ".mp3" is support on Windows. |
Benny Prijono | 8f31052 | 2006-10-20 11:08:49 +0000 | [diff] [blame] | 2997 | * @param enc_type Optionally specify the type of encoder to be used to |
| 2998 | * compress the media, if the file can support different |
| 2999 | * encodings. This value must be zero for now. |
| 3000 | * @param enc_param Optionally specify codec specific parameter to be |
| 3001 | * passed to the file writer. For .MP3 recorder, this |
| 3002 | * can point to pjmedia_mp3_encoder_option structure to |
| 3003 | * specify additional settings for the .mp3 recorder. |
| 3004 | * For .WAV recorder, this value must be NULL. |
| 3005 | * @param max_size Maximum file size. Specify zero or -1 to remove size |
| 3006 | * limitation. This value must be zero or -1 for now. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3007 | * @param options Optional options. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3008 | * @param p_id Pointer to receive the recorder instance. |
| 3009 | * |
| 3010 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3011 | */ |
| 3012 | 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] | 3013 | unsigned enc_type, |
| 3014 | void *enc_param, |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3015 | pj_ssize_t max_size, |
| 3016 | unsigned options, |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3017 | pjsua_recorder_id *p_id); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3018 | |
| 3019 | |
| 3020 | /** |
| 3021 | * Get conference port associated with recorder. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3022 | * |
| 3023 | * @param id The recorder ID. |
| 3024 | * |
| 3025 | * @return Conference port ID associated with this recorder. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3026 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 3027 | 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] | 3028 | |
| 3029 | |
| 3030 | /** |
Benny Prijono | 469b152 | 2006-12-26 03:05:17 +0000 | [diff] [blame] | 3031 | * Get the media port for the recorder. |
| 3032 | * |
| 3033 | * @param id The recorder ID. |
| 3034 | * @param p_port The media port associated with the recorder. |
| 3035 | * |
| 3036 | * @return PJ_SUCCESS on success. |
| 3037 | */ |
| 3038 | PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id, |
| 3039 | pjmedia_port **p_port); |
| 3040 | |
| 3041 | |
| 3042 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3043 | * Destroy recorder (this will complete recording). |
| 3044 | * |
| 3045 | * @param id The recorder ID. |
| 3046 | * |
| 3047 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3048 | */ |
| 3049 | PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id); |
| 3050 | |
| 3051 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3052 | /***************************************************************************** |
| 3053 | * Sound devices. |
| 3054 | */ |
| 3055 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3056 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3057 | * Enum all sound devices installed in the system. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3058 | * |
| 3059 | * @param info Array of info to be initialized. |
| 3060 | * @param count On input, specifies max elements in the array. |
| 3061 | * On return, it contains actual number of elements |
| 3062 | * that have been initialized. |
| 3063 | * |
| 3064 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3065 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3066 | PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[], |
| 3067 | unsigned *count); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3068 | |
| 3069 | |
Benny Prijono | a3cbb1c | 2006-08-25 12:41:05 +0000 | [diff] [blame] | 3070 | |
| 3071 | /** |
| 3072 | * Get currently active sound devices. If sound devices has not been created |
| 3073 | * (for example when pjsua_start() is not called), it is possible that |
| 3074 | * the function returns PJ_SUCCESS with -1 as device IDs. |
| 3075 | * |
| 3076 | * @param capture_dev On return it will be filled with device ID of the |
| 3077 | * capture device. |
| 3078 | * @param playback_dev On return it will be filled with device ID of the |
| 3079 | * device ID of the playback device. |
| 3080 | * |
| 3081 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3082 | */ |
| 3083 | PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev, |
| 3084 | int *playback_dev); |
| 3085 | |
| 3086 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3087 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3088 | * Select or change sound device. Application may call this function at |
| 3089 | * any time to replace current sound device. |
| 3090 | * |
| 3091 | * @param capture_dev Device ID of the capture device. |
| 3092 | * @param playback_dev Device ID of the playback device. |
| 3093 | * |
| 3094 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3095 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3096 | PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev, |
| 3097 | int playback_dev); |
| 3098 | |
| 3099 | |
| 3100 | /** |
| 3101 | * Set pjsua to use null sound device. The null sound device only provides |
| 3102 | * the timing needed by the conference bridge, and will not interract with |
| 3103 | * any hardware. |
| 3104 | * |
| 3105 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3106 | */ |
| 3107 | PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void); |
| 3108 | |
| 3109 | |
Benny Prijono | e909eac | 2006-07-27 22:04:56 +0000 | [diff] [blame] | 3110 | /** |
| 3111 | * Disconnect the main conference bridge from any sound devices, and let |
| 3112 | * application connect the bridge to it's own sound device/master port. |
| 3113 | * |
| 3114 | * @return The port interface of the conference bridge, |
| 3115 | * so that application can connect this to it's own |
| 3116 | * sound device or master port. |
| 3117 | */ |
| 3118 | PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void); |
| 3119 | |
| 3120 | |
Benny Prijono | f20687a | 2006-08-04 18:27:19 +0000 | [diff] [blame] | 3121 | /** |
Benny Prijono | 22dfe59 | 2006-08-06 12:07:13 +0000 | [diff] [blame] | 3122 | * Configure the echo canceller tail length of the sound port. |
Benny Prijono | f20687a | 2006-08-04 18:27:19 +0000 | [diff] [blame] | 3123 | * |
| 3124 | * @param tail_ms The tail length, in miliseconds. Set to zero to |
| 3125 | * disable AEC. |
Benny Prijono | 5da5043 | 2006-08-07 10:24:52 +0000 | [diff] [blame] | 3126 | * @param options Options to be passed to #pjmedia_echo_create(). |
| 3127 | * Normally the value should be zero. |
Benny Prijono | f20687a | 2006-08-04 18:27:19 +0000 | [diff] [blame] | 3128 | * |
| 3129 | * @return PJ_SUCCESS on success. |
| 3130 | */ |
Benny Prijono | 5da5043 | 2006-08-07 10:24:52 +0000 | [diff] [blame] | 3131 | 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] | 3132 | |
| 3133 | |
| 3134 | /** |
Benny Prijono | 22dfe59 | 2006-08-06 12:07:13 +0000 | [diff] [blame] | 3135 | * Get current echo canceller tail length. |
Benny Prijono | f20687a | 2006-08-04 18:27:19 +0000 | [diff] [blame] | 3136 | * |
| 3137 | * @param p_tail_ms Pointer to receive the tail length, in miliseconds. |
| 3138 | * If AEC is disabled, the value will be zero. |
| 3139 | * |
| 3140 | * @return PJ_SUCCESS on success. |
| 3141 | */ |
Benny Prijono | 22dfe59 | 2006-08-06 12:07:13 +0000 | [diff] [blame] | 3142 | 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] | 3143 | |
| 3144 | |
| 3145 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3146 | /***************************************************************************** |
| 3147 | * Codecs. |
| 3148 | */ |
| 3149 | |
| 3150 | /** |
| 3151 | * Enum all supported codecs in the system. |
| 3152 | * |
| 3153 | * @param id Array of ID to be initialized. |
| 3154 | * @param count On input, specifies max elements in the array. |
| 3155 | * On return, it contains actual number of elements |
| 3156 | * that have been initialized. |
| 3157 | * |
| 3158 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3159 | */ |
| 3160 | PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[], |
| 3161 | unsigned *count ); |
| 3162 | |
| 3163 | |
| 3164 | /** |
| 3165 | * Change codec priority. |
| 3166 | * |
| 3167 | * @param id Codec ID. |
| 3168 | * @param priority Codec priority, 0-255, where zero means to disable |
| 3169 | * the codec. |
| 3170 | * |
| 3171 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3172 | */ |
| 3173 | PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *id, |
| 3174 | pj_uint8_t priority ); |
| 3175 | |
| 3176 | |
| 3177 | /** |
| 3178 | * Get codec parameters. |
| 3179 | * |
| 3180 | * @param id Codec ID. |
| 3181 | * @param param Structure to receive codec parameters. |
| 3182 | * |
| 3183 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3184 | */ |
| 3185 | PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *id, |
| 3186 | pjmedia_codec_param *param ); |
| 3187 | |
| 3188 | |
| 3189 | /** |
| 3190 | * Set codec parameters. |
| 3191 | * |
| 3192 | * @param id Codec ID. |
| 3193 | * @param param Codec parameter to set. |
| 3194 | * |
| 3195 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3196 | */ |
| 3197 | PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *id, |
| 3198 | const pjmedia_codec_param *param); |
| 3199 | |
| 3200 | |
| 3201 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3202 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3203 | /** |
| 3204 | * Create UDP media transports for all the calls. This function creates |
| 3205 | * one UDP media transport for each call. |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 3206 | * |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3207 | * @param cfg Media transport configuration. The "port" field in the |
| 3208 | * configuration is used as the start port to bind the |
| 3209 | * sockets. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3210 | * |
| 3211 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 3212 | */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3213 | PJ_DECL(pj_status_t) |
| 3214 | pjsua_media_transports_create(const pjsua_transport_config *cfg); |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 3215 | |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 3216 | |
| 3217 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3218 | * Register custom media transports to be used by calls. There must |
| 3219 | * enough media transports for all calls. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3220 | * |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3221 | * @param tp The media transport array. |
| 3222 | * @param count Number of elements in the array. This number MUST |
| 3223 | * match the number of maximum calls configured when |
| 3224 | * pjsua is created. |
| 3225 | * @param auto_delete Flag to indicate whether the transports should be |
| 3226 | * destroyed when pjsua is shutdown. |
| 3227 | * |
| 3228 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 3229 | */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3230 | PJ_DECL(pj_status_t) |
| 3231 | pjsua_media_transports_attach( pjsua_media_transport tp[], |
| 3232 | unsigned count, |
| 3233 | pj_bool_t auto_delete); |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 3234 | |
| 3235 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3236 | /** |
| 3237 | * @} |
| 3238 | */ |
| 3239 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 3240 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 3241 | |
Benny Prijono | 1a01ad3 | 2006-02-07 21:13:28 +0000 | [diff] [blame] | 3242 | PJ_END_DECL |
| 3243 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 3244 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3245 | /** |
| 3246 | * @} |
| 3247 | */ |
| 3248 | |
| 3249 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 3250 | #endif /* __PJSUA_H__ */ |