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 | |
| 118 | pjsua_config ua_cfg; |
| 119 | pjsua_logging_config log_cfg; |
| 120 | pjsua_media_config media_cfg; |
| 121 | |
| 122 | // Initialize configs with default settings. |
| 123 | pjsua_config_default(&ua_cfg); |
| 124 | pjsua_logging_config_default(&log_cfg); |
| 125 | pjsua_media_config_default(&media_cfg); |
| 126 | |
| 127 | // At the very least, application would want to override |
| 128 | // the call callbacks in pjsua_config: |
| 129 | ua_cfg.cb.on_incoming_call = ... |
| 130 | ua_cfg.cb.on_call_state = .. |
| 131 | ... |
| 132 | |
| 133 | // Customize other settings (or initialize them from application specific |
| 134 | // configuration file): |
| 135 | ... |
| 136 | |
| 137 | // Initialize pjsua |
| 138 | status = pjsua_init(&ua_cfg, &log_cfg, &media_cfg); |
| 139 | if (status != PJ_SUCCESS) { |
| 140 | pjsua_perror(THIS_FILE, "Error initializing pjsua", status); |
| 141 | return status; |
| 142 | } |
| 143 | .. |
| 144 | |
| 145 | \endcode |
| 146 | * |
| 147 | * @subsection other_init_pjsua_lib Other Initialization |
| 148 | * |
| 149 | * After PJSUA is initialized with #pjsua_init(), application will normally |
| 150 | * need/want to perform the following tasks: |
| 151 | * |
| 152 | * - create SIP transport with #pjsua_transport_create(). Please see |
| 153 | * @ref PJSUA_LIB_TRANSPORT section for more info. |
| 154 | * - create one or more SIP accounts with #pjsua_acc_add() or |
| 155 | * #pjsua_acc_add_local(). Please see @ref PJSUA_LIB_ACC for more info. |
| 156 | * - add one or more buddies with #pjsua_buddy_add(). Please see |
| 157 | * @ref PJSUA_LIB_BUDDY section for more info. |
| 158 | * - optionally configure the sound device, codec settings, and other |
| 159 | * media settings. Please see @ref PJSUA_LIB_MEDIA for more info. |
| 160 | * |
| 161 | * |
| 162 | * @subsection starting_pjsua_lib Starting PJSUA |
| 163 | * |
| 164 | * After all initializations have been done, application must call |
| 165 | * #pjsua_start() to start PJSUA. This function will check that all settings |
| 166 | * are properly configured, and apply default settings when it's not, or |
| 167 | * report error status when it is unable to recover from missing setting. |
| 168 | * |
| 169 | * Most settings can be changed during run-time. For example, application |
| 170 | * may add, modify, or delete accounts, buddies, or change media settings |
| 171 | * during run-time. |
Benny Prijono | f04ffdd | 2006-02-21 00:11:18 +0000 | [diff] [blame] | 172 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 173 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 174 | /** Constant to identify invalid ID for all sorts of IDs. */ |
| 175 | #define PJSUA_INVALID_ID (-1) |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 176 | |
| 177 | /** Call identification */ |
| 178 | typedef int pjsua_call_id; |
| 179 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 180 | /** Account identification */ |
| 181 | typedef int pjsua_acc_id; |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 182 | |
| 183 | /** Buddy identification */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 184 | typedef int pjsua_buddy_id; |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 185 | |
| 186 | /** File player identification */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 187 | typedef int pjsua_player_id; |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 188 | |
| 189 | /** File recorder identification */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 190 | typedef int pjsua_recorder_id; |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 191 | |
| 192 | /** Conference port identification */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 193 | typedef int pjsua_conf_port_id; |
| 194 | |
| 195 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 196 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 197 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 198 | * Maximum proxies in account. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 199 | */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 200 | #ifndef PJSUA_ACC_MAX_PROXIES |
| 201 | # define PJSUA_ACC_MAX_PROXIES 8 |
| 202 | #endif |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 203 | |
| 204 | |
| 205 | |
| 206 | /** |
| 207 | * Logging configuration. |
| 208 | */ |
| 209 | typedef struct pjsua_logging_config |
| 210 | { |
| 211 | /** |
| 212 | * Log incoming and outgoing SIP message? Yes! |
| 213 | */ |
| 214 | pj_bool_t msg_logging; |
| 215 | |
| 216 | /** |
| 217 | * Input verbosity level. Value 5 is reasonable. |
| 218 | */ |
| 219 | unsigned level; |
| 220 | |
| 221 | /** |
| 222 | * Verbosity level for console. Value 4 is reasonable. |
| 223 | */ |
| 224 | unsigned console_level; |
| 225 | |
| 226 | /** |
| 227 | * Log decoration. |
| 228 | */ |
| 229 | unsigned decor; |
| 230 | |
| 231 | /** |
| 232 | * Optional log filename. |
| 233 | */ |
| 234 | pj_str_t log_filename; |
| 235 | |
| 236 | /** |
| 237 | * Optional callback function to be called to write log to |
| 238 | * application specific device. This function will be called for |
| 239 | * log messages on input verbosity level. |
| 240 | */ |
| 241 | void (*cb)(int level, const char *data, pj_size_t len); |
| 242 | |
| 243 | |
| 244 | } pjsua_logging_config; |
| 245 | |
| 246 | |
| 247 | /** |
| 248 | * Use this function to initialize logging config. |
| 249 | * |
| 250 | * @param cfg The logging config to be initialized. |
| 251 | */ |
| 252 | PJ_INLINE(void) pjsua_logging_config_default(pjsua_logging_config *cfg) |
| 253 | { |
Benny Prijono | ac623b3 | 2006-07-03 15:19:31 +0000 | [diff] [blame] | 254 | pj_bzero(cfg, sizeof(*cfg)); |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 255 | |
| 256 | cfg->msg_logging = PJ_TRUE; |
| 257 | cfg->level = 5; |
| 258 | cfg->console_level = 4; |
| 259 | cfg->decor = PJ_LOG_HAS_SENDER | PJ_LOG_HAS_TIME | |
| 260 | PJ_LOG_HAS_MICRO_SEC | PJ_LOG_HAS_NEWLINE; |
| 261 | } |
| 262 | |
| 263 | /** |
| 264 | * Use this function to duplicate logging config. |
| 265 | * |
| 266 | * @param pool Pool to use. |
| 267 | * @param dst Destination config. |
| 268 | * @param src Source config. |
| 269 | */ |
| 270 | PJ_INLINE(void) pjsua_logging_config_dup(pj_pool_t *pool, |
| 271 | pjsua_logging_config *dst, |
| 272 | const pjsua_logging_config *src) |
| 273 | { |
| 274 | pj_memcpy(dst, src, sizeof(*src)); |
| 275 | pj_strdup_with_null(pool, &dst->log_filename, &src->log_filename); |
| 276 | } |
| 277 | |
| 278 | |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 279 | |
| 280 | /** |
| 281 | * Application callbacks. |
| 282 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 283 | typedef struct pjsua_callback |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 284 | { |
| 285 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 286 | * Notify application when invite state has changed. |
| 287 | * Application may then query the call info to get the |
| 288 | * detail call states. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 289 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 290 | void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e); |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 291 | |
| 292 | /** |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 293 | * Notify application on incoming call. |
| 294 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 295 | 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] | 296 | pjsip_rx_data *rdata); |
| 297 | |
| 298 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 299 | * Notify application when media state in the call has changed. |
| 300 | * Normal application would need to implement this callback, e.g. |
| 301 | * to connect the call's media to sound device. |
| 302 | */ |
| 303 | void (*on_call_media_state)(pjsua_call_id call_id); |
| 304 | |
| 305 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 306 | * Notify application on call being transfered. |
| 307 | * Application can decide to accept/reject transfer request |
| 308 | * by setting the code (default is 200). When this callback |
| 309 | * is not defined, the default behavior is to accept the |
| 310 | * transfer. |
| 311 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 312 | void (*on_call_transfered)(pjsua_call_id call_id, |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 313 | const pj_str_t *dst, |
| 314 | pjsip_status_code *code); |
| 315 | |
| 316 | /** |
| 317 | * Notify application when registration status has changed. |
| 318 | * Application may then query the account info to get the |
| 319 | * registration details. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 320 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 321 | void (*on_reg_state)(pjsua_acc_id acc_id); |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 322 | |
| 323 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 324 | * Notify application when the buddy state has changed. |
| 325 | * Application may then query the buddy into to get the details. |
| 326 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 327 | void (*on_buddy_state)(pjsua_buddy_id buddy_id); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 328 | |
| 329 | /** |
| 330 | * Notify application on incoming pager (i.e. MESSAGE request). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 331 | * 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] | 332 | * existing call. |
| 333 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 334 | void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from, |
| 335 | const pj_str_t *to, const pj_str_t *contact, |
| 336 | const pj_str_t *mime_type, const pj_str_t *body); |
| 337 | |
| 338 | /** |
| 339 | * Notify application about the delivery status of outgoing pager |
| 340 | * request. |
| 341 | * |
| 342 | * @param call_id Containts the ID of the call where the IM was |
| 343 | * sent, or PJSUA_INVALID_ID if the IM was sent |
| 344 | * outside call context. |
| 345 | * @param to Destination URI. |
| 346 | * @param body Message body. |
| 347 | * @param user_data Arbitrary data that was specified when sending |
| 348 | * IM message. |
| 349 | * @param status Delivery status. |
| 350 | * @param reason Delivery status reason. |
| 351 | */ |
| 352 | void (*on_pager_status)(pjsua_call_id call_id, |
| 353 | const pj_str_t *to, |
| 354 | const pj_str_t *body, |
| 355 | void *user_data, |
| 356 | pjsip_status_code status, |
| 357 | const pj_str_t *reason); |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 358 | |
| 359 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 360 | * Notify application about typing indication. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 361 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 362 | void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from, |
| 363 | const pj_str_t *to, const pj_str_t *contact, |
| 364 | pj_bool_t is_typing); |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 365 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 366 | } pjsua_callback; |
| 367 | |
| 368 | |
| 369 | |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 370 | |
| 371 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 372 | * PJSUA settings. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 373 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 374 | typedef struct pjsua_config |
| 375 | { |
| 376 | |
| 377 | /** |
| 378 | * Maximum calls to support (default: 4) |
| 379 | */ |
| 380 | unsigned max_calls; |
| 381 | |
| 382 | /** |
| 383 | * Number of worker threads. Normally application will want to have at |
| 384 | * least one worker thread, unless when it wants to poll the library |
| 385 | * periodically, which in this case the worker thread can be set to |
| 386 | * zero. |
| 387 | */ |
| 388 | unsigned thread_cnt; |
| 389 | |
| 390 | /** |
| 391 | * Number of outbound proxies in the array. |
| 392 | */ |
| 393 | unsigned outbound_proxy_cnt; |
| 394 | |
| 395 | /** |
| 396 | * Specify the URL of outbound proxies to visit for all outgoing requests. |
| 397 | * The outbound proxies will be used for all accounts, and it will |
| 398 | * be used to build the route set for outgoing requests. The final |
| 399 | * route set for outgoing requests will consists of the outbound proxies |
| 400 | * and the proxy configured in the account. |
| 401 | */ |
| 402 | pj_str_t outbound_proxy[4]; |
| 403 | |
| 404 | /** |
| 405 | * Number of credentials in the credential array. |
| 406 | */ |
| 407 | unsigned cred_count; |
| 408 | |
| 409 | /** |
| 410 | * Array of credentials. These credentials will be used by all accounts, |
| 411 | * and can be used to authenticate against outbound proxies. |
| 412 | */ |
| 413 | pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES]; |
| 414 | |
| 415 | /** |
| 416 | * Application callback. |
| 417 | */ |
| 418 | pjsua_callback cb; |
| 419 | |
Benny Prijono | 5631561 | 2006-07-18 14:39:40 +0000 | [diff] [blame] | 420 | /** |
| 421 | * User agent string (default empty) |
| 422 | */ |
| 423 | pj_str_t user_agent; |
| 424 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 425 | } pjsua_config; |
| 426 | |
| 427 | |
| 428 | /** |
| 429 | * Use this function to initialize pjsua config. |
| 430 | * |
| 431 | * @param cfg pjsua config to be initialized. |
| 432 | */ |
| 433 | PJ_INLINE(void) pjsua_config_default(pjsua_config *cfg) |
| 434 | { |
Benny Prijono | ac623b3 | 2006-07-03 15:19:31 +0000 | [diff] [blame] | 435 | pj_bzero(cfg, sizeof(*cfg)); |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 436 | |
| 437 | cfg->max_calls = 4; |
| 438 | cfg->thread_cnt = 1; |
| 439 | } |
| 440 | |
| 441 | |
| 442 | /** |
| 443 | * Duplicate credential. |
| 444 | */ |
| 445 | PJ_INLINE(void) pjsip_cred_dup( pj_pool_t *pool, |
| 446 | pjsip_cred_info *dst, |
| 447 | const pjsip_cred_info *src) |
| 448 | { |
| 449 | pj_strdup_with_null(pool, &dst->realm, &src->realm); |
| 450 | pj_strdup_with_null(pool, &dst->scheme, &src->scheme); |
| 451 | pj_strdup_with_null(pool, &dst->username, &src->username); |
| 452 | pj_strdup_with_null(pool, &dst->data, &src->data); |
| 453 | |
| 454 | } |
| 455 | |
| 456 | |
| 457 | /** |
| 458 | * Duplicate pjsua_config. |
| 459 | */ |
| 460 | PJ_INLINE(void) pjsua_config_dup(pj_pool_t *pool, |
| 461 | pjsua_config *dst, |
| 462 | const pjsua_config *src) |
| 463 | { |
| 464 | unsigned i; |
| 465 | |
| 466 | pj_memcpy(dst, src, sizeof(*src)); |
| 467 | |
| 468 | for (i=0; i<src->outbound_proxy_cnt; ++i) { |
| 469 | pj_strdup_with_null(pool, &dst->outbound_proxy[i], |
| 470 | &src->outbound_proxy[i]); |
| 471 | } |
| 472 | |
| 473 | for (i=0; i<src->cred_count; ++i) { |
| 474 | pjsip_cred_dup(pool, &dst->cred_info[i], &src->cred_info[i]); |
| 475 | } |
Benny Prijono | 5631561 | 2006-07-18 14:39:40 +0000 | [diff] [blame] | 476 | |
| 477 | pj_strdup_with_null(pool, &dst->user_agent, &src->user_agent); |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 478 | } |
| 479 | |
| 480 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 481 | |
| 482 | /** |
| 483 | * This structure describes additional information to be sent with |
| 484 | * outgoing SIP message. |
| 485 | */ |
| 486 | typedef struct pjsua_msg_data |
| 487 | { |
| 488 | /** |
| 489 | * Additional message headers as linked list. |
| 490 | */ |
| 491 | pjsip_hdr hdr_list; |
| 492 | |
| 493 | /** |
| 494 | * MIME type of optional message body. |
| 495 | */ |
| 496 | pj_str_t content_type; |
| 497 | |
| 498 | /** |
| 499 | * Optional message body. |
| 500 | */ |
| 501 | pj_str_t msg_body; |
| 502 | |
| 503 | } pjsua_msg_data; |
| 504 | |
| 505 | |
| 506 | /** |
| 507 | * Initialize message data. |
| 508 | * |
| 509 | * @param msg_data Message data to be initialized. |
| 510 | */ |
| 511 | PJ_INLINE(void) pjsua_msg_data_init(pjsua_msg_data *msg_data) |
| 512 | { |
Benny Prijono | ac623b3 | 2006-07-03 15:19:31 +0000 | [diff] [blame] | 513 | pj_bzero(msg_data, sizeof(*msg_data)); |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 514 | pj_list_init(&msg_data->hdr_list); |
| 515 | } |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 516 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 517 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 518 | |
| 519 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 520 | * Instantiate pjsua application. Application must call this function before |
| 521 | * calling any other functions, to make sure that the underlying libraries |
| 522 | * are properly initialized. Once this function has returned success, |
| 523 | * application must call pjsua_destroy() before quitting. |
| 524 | * |
| 525 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 526 | */ |
| 527 | PJ_DECL(pj_status_t) pjsua_create(void); |
| 528 | |
| 529 | |
| 530 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 531 | * Initialize pjsua with the specified settings. All the settings are |
| 532 | * optional, and the default values will be used when the config is not |
| 533 | * specified. |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 534 | * |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 535 | * @param ua_cfg User agent configuration. |
| 536 | * @param log_cfg Optional logging configuration. |
| 537 | * @param media_cfg Optional media configuration. |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 538 | * |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 539 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 540 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 541 | PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg, |
| 542 | const pjsua_logging_config *log_cfg, |
| 543 | const pjsua_media_config *media_cfg); |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 544 | |
| 545 | |
| 546 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 547 | * Application is recommended to call this function after all initialization |
| 548 | * is done, so that the library can do additional checking set up |
| 549 | * additional |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 550 | * |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 551 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 552 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 553 | PJ_DECL(pj_status_t) pjsua_start(void); |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 554 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 555 | |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 556 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 557 | * Destroy pjsua. This function must be called once PJSUA is created. To |
| 558 | * make it easier for application, application may call this function |
| 559 | * several times with no danger. |
| 560 | * |
| 561 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 562 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 563 | PJ_DECL(pj_status_t) pjsua_destroy(void); |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 564 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 565 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 566 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 567 | * Poll pjsua for events, and if necessary block the caller thread for |
| 568 | * the specified maximum interval (in miliseconds). |
| 569 | * |
| 570 | * @param msec_timeout Maximum time to wait, in miliseconds. |
| 571 | * |
| 572 | * @return The number of events that have been handled during the |
| 573 | * poll. Negative value indicates error, and application |
| 574 | * can retrieve the error as (err = -return_value). |
Benny Prijono | b9b32ab | 2006-06-01 12:28:44 +0000 | [diff] [blame] | 575 | */ |
| 576 | PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout); |
| 577 | |
| 578 | |
| 579 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 580 | * Create memory pool. |
| 581 | * |
| 582 | * @param name Optional pool name. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 583 | * @param init_size Initial size of the pool. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 584 | * @param increment Increment size. |
| 585 | * |
| 586 | * @return The pool, or NULL when there's no memory. |
| 587 | */ |
| 588 | PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size, |
| 589 | pj_size_t increment); |
| 590 | |
| 591 | |
| 592 | /** |
| 593 | * Application can call this function at any time (after pjsua_create(), of |
| 594 | * course) to change logging settings. |
| 595 | * |
| 596 | * @param c Logging configuration. |
| 597 | * |
| 598 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 599 | */ |
| 600 | PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c); |
| 601 | |
| 602 | |
| 603 | /** |
| 604 | * Internal function to get SIP endpoint instance of pjsua, which is |
| 605 | * needed for example to register module, create transports, etc. |
| 606 | * Probably is only valid after #pjsua_init() is called. |
| 607 | * |
| 608 | * @return SIP endpoint instance. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 609 | */ |
| 610 | PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void); |
| 611 | |
| 612 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 613 | * Internal function to get media endpoint instance. |
| 614 | * Only valid after #pjsua_init() is called. |
| 615 | * |
| 616 | * @return Media endpoint instance. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 617 | */ |
| 618 | PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void); |
| 619 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 620 | |
| 621 | /***************************************************************************** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 622 | * Utilities. |
| 623 | * |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 624 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 625 | |
| 626 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 627 | * Verify that valid SIP url is given. |
| 628 | * |
| 629 | * @param c_url The URL, as NULL terminated string. |
| 630 | * |
| 631 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 632 | */ |
| 633 | PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *c_url); |
| 634 | |
| 635 | |
| 636 | /** |
| 637 | * Display error message for the specified error code. |
| 638 | * |
| 639 | * @param sender The log sender field. |
| 640 | * @param title Message title for the error. |
| 641 | * @param status Status code. |
| 642 | */ |
| 643 | PJ_DECL(void) pjsua_perror(const char *sender, const char *title, |
| 644 | pj_status_t status); |
| 645 | |
| 646 | |
| 647 | |
| 648 | |
| 649 | /** |
| 650 | * @} |
| 651 | */ |
| 652 | |
| 653 | |
| 654 | |
| 655 | /***************************************************************************** |
| 656 | * TRANSPORT API |
| 657 | */ |
| 658 | |
| 659 | /** |
| 660 | * @defgroup PJSUA_LIB_TRANSPORT Signaling Transport |
| 661 | * @ingroup PJSUA_LIB |
| 662 | * @brief API for managing SIP transports |
| 663 | * @{ |
| 664 | * SIP transport must be created before adding an account. SIP transport is |
| 665 | * created by calling #pjsua_transport_create() function. |
| 666 | */ |
| 667 | |
| 668 | |
| 669 | /** SIP transport identification */ |
| 670 | typedef int pjsua_transport_id; |
| 671 | |
| 672 | |
| 673 | /** |
| 674 | * STUN configuration. |
| 675 | */ |
| 676 | typedef struct pjsua_stun_config |
| 677 | { |
| 678 | /** |
| 679 | * The first STUN server IP address or hostname. |
| 680 | */ |
| 681 | pj_str_t stun_srv1; |
| 682 | |
| 683 | /** |
| 684 | * Port number of the first STUN server. |
| 685 | * If zero, default STUN port will be used. |
| 686 | */ |
| 687 | unsigned stun_port1; |
| 688 | |
| 689 | /** |
| 690 | * Optional second STUN server IP address or hostname, for which the |
| 691 | * result of the mapping request will be compared to. If the value |
| 692 | * is empty, only one STUN server will be used. |
| 693 | */ |
| 694 | pj_str_t stun_srv2; |
| 695 | |
| 696 | /** |
| 697 | * Port number of the second STUN server. |
| 698 | * If zero, default STUN port will be used. |
| 699 | */ |
| 700 | unsigned stun_port2; |
| 701 | |
| 702 | } pjsua_stun_config; |
| 703 | |
| 704 | |
| 705 | |
| 706 | /** |
| 707 | * Call this function to initialize STUN config with default values. |
| 708 | * |
| 709 | * @param cfg The STUN config to be initialized. |
| 710 | */ |
| 711 | PJ_INLINE(void) pjsua_stun_config_default(pjsua_stun_config *cfg) |
| 712 | { |
Benny Prijono | ac623b3 | 2006-07-03 15:19:31 +0000 | [diff] [blame] | 713 | pj_bzero(cfg, sizeof(*cfg)); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 714 | } |
| 715 | |
| 716 | |
| 717 | /** |
| 718 | * Transport configuration for creating UDP transports for both SIP |
| 719 | * and media. |
| 720 | */ |
| 721 | typedef struct pjsua_transport_config |
| 722 | { |
| 723 | /** |
| 724 | * UDP port number to bind locally. This setting MUST be specified |
| 725 | * even when default port is desired. If the value is zero, the |
| 726 | * transport will be bound to any available port, and application |
| 727 | * can query the port by querying the transport info. |
| 728 | */ |
| 729 | unsigned port; |
| 730 | |
| 731 | /** |
| 732 | * Optional address where the socket should be bound. |
| 733 | */ |
| 734 | pj_in_addr ip_addr; |
| 735 | |
| 736 | /** |
| 737 | * Flag to indicate whether STUN should be used. |
| 738 | */ |
| 739 | pj_bool_t use_stun; |
| 740 | |
| 741 | /** |
| 742 | * STUN configuration, must be specified when STUN is used. |
| 743 | */ |
| 744 | pjsua_stun_config stun_config; |
| 745 | |
| 746 | } pjsua_transport_config; |
| 747 | |
| 748 | |
| 749 | /** |
| 750 | * Call this function to initialize UDP config with default values. |
| 751 | * |
| 752 | * @param cfg The UDP config to be initialized. |
| 753 | */ |
| 754 | PJ_INLINE(void) pjsua_transport_config_default(pjsua_transport_config *cfg) |
| 755 | { |
Benny Prijono | ac623b3 | 2006-07-03 15:19:31 +0000 | [diff] [blame] | 756 | pj_bzero(cfg, sizeof(*cfg)); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 757 | } |
| 758 | |
| 759 | |
| 760 | /** |
| 761 | * Normalize STUN config. |
| 762 | */ |
| 763 | PJ_INLINE(void) pjsua_normalize_stun_config( pjsua_stun_config *cfg ) |
| 764 | { |
| 765 | if (cfg->stun_srv1.slen) { |
| 766 | |
| 767 | if (cfg->stun_port1 == 0) |
| 768 | cfg->stun_port1 = 3478; |
| 769 | |
| 770 | if (cfg->stun_srv2.slen == 0) { |
| 771 | cfg->stun_srv2 = cfg->stun_srv1; |
| 772 | cfg->stun_port2 = cfg->stun_port1; |
| 773 | } else { |
| 774 | if (cfg->stun_port2 == 0) |
| 775 | cfg->stun_port2 = 3478; |
| 776 | } |
| 777 | |
| 778 | } else { |
| 779 | cfg->stun_port1 = 0; |
| 780 | cfg->stun_srv2.slen = 0; |
| 781 | cfg->stun_port2 = 0; |
| 782 | } |
| 783 | } |
| 784 | |
| 785 | |
| 786 | /** |
| 787 | * Duplicate transport config. |
| 788 | */ |
| 789 | PJ_INLINE(void) pjsua_transport_config_dup(pj_pool_t *pool, |
| 790 | pjsua_transport_config *dst, |
| 791 | const pjsua_transport_config *src) |
| 792 | { |
| 793 | pj_memcpy(dst, src, sizeof(*src)); |
| 794 | |
| 795 | if (src->stun_config.stun_srv1.slen) { |
| 796 | pj_strdup_with_null(pool, &dst->stun_config.stun_srv1, |
| 797 | &src->stun_config.stun_srv1); |
| 798 | } |
| 799 | |
| 800 | if (src->stun_config.stun_srv2.slen) { |
| 801 | pj_strdup_with_null(pool, &dst->stun_config.stun_srv2, |
| 802 | &src->stun_config.stun_srv2); |
| 803 | } |
| 804 | |
| 805 | pjsua_normalize_stun_config(&dst->stun_config); |
| 806 | } |
| 807 | |
| 808 | |
| 809 | |
| 810 | /** |
| 811 | * Transport info. |
| 812 | */ |
| 813 | typedef struct pjsua_transport_info |
| 814 | { |
| 815 | /** |
| 816 | * PJSUA transport identification. |
| 817 | */ |
| 818 | pjsua_transport_id id; |
| 819 | |
| 820 | /** |
| 821 | * Transport type. |
| 822 | */ |
| 823 | pjsip_transport_type_e type; |
| 824 | |
| 825 | /** |
| 826 | * Transport type name. |
| 827 | */ |
| 828 | pj_str_t type_name; |
| 829 | |
| 830 | /** |
| 831 | * Transport string info/description. |
| 832 | */ |
| 833 | pj_str_t info; |
| 834 | |
| 835 | /** |
| 836 | * Transport flag (see ##pjsip_transport_flags_e). |
| 837 | */ |
| 838 | unsigned flag; |
| 839 | |
| 840 | /** |
| 841 | * Local address length. |
| 842 | */ |
| 843 | unsigned addr_len; |
| 844 | |
| 845 | /** |
| 846 | * Local/bound address. |
| 847 | */ |
| 848 | pj_sockaddr local_addr; |
| 849 | |
| 850 | /** |
| 851 | * Published address (or transport address name). |
| 852 | */ |
| 853 | pjsip_host_port local_name; |
| 854 | |
| 855 | /** |
| 856 | * Current number of objects currently referencing this transport. |
| 857 | */ |
| 858 | unsigned usage_count; |
| 859 | |
| 860 | |
| 861 | } pjsua_transport_info; |
| 862 | |
| 863 | |
| 864 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 865 | * Create SIP transport. |
| 866 | * |
| 867 | * @param type Transport type. |
| 868 | * @param cfg Transport configuration. |
| 869 | * @param p_id Optional pointer to receive transport ID. |
| 870 | * |
| 871 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 872 | */ |
| 873 | PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type, |
| 874 | const pjsua_transport_config *cfg, |
| 875 | pjsua_transport_id *p_id); |
| 876 | |
| 877 | /** |
| 878 | * Register transport that has been created by application. |
| 879 | * |
| 880 | * @param tp Transport instance. |
| 881 | * @param p_id Optional pointer to receive transport ID. |
| 882 | * |
| 883 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 884 | */ |
| 885 | PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp, |
| 886 | pjsua_transport_id *p_id); |
| 887 | |
| 888 | |
| 889 | /** |
| 890 | * Enumerate all transports currently created in the system. |
| 891 | * |
| 892 | * @param id Array to receive transport ids. |
| 893 | * @param count In input, specifies the maximum number of elements. |
| 894 | * On return, it contains the actual number of elements. |
| 895 | * |
| 896 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 897 | */ |
| 898 | PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[], |
| 899 | unsigned *count ); |
| 900 | |
| 901 | |
| 902 | /** |
| 903 | * Get information about transports. |
| 904 | * |
| 905 | * @param id Transport ID. |
| 906 | * @param info Pointer to receive transport info. |
| 907 | * |
| 908 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 909 | */ |
| 910 | PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id, |
| 911 | pjsua_transport_info *info); |
| 912 | |
| 913 | |
| 914 | /** |
| 915 | * Disable a transport or re-enable it. By default transport is always |
| 916 | * enabled after it is created. Disabling a transport does not necessarily |
| 917 | * close the socket, it will only discard incoming messages and prevent |
| 918 | * the transport from being used to send outgoing messages. |
| 919 | * |
| 920 | * @param id Transport ID. |
| 921 | * @param enabled Non-zero to enable, zero to disable. |
| 922 | * |
| 923 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 924 | */ |
| 925 | PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id, |
| 926 | pj_bool_t enabled); |
| 927 | |
| 928 | |
| 929 | /** |
| 930 | * Close the transport. If transport is forcefully closed, it will be |
| 931 | * immediately closed, and any pending transactions that are using the |
| 932 | * transport may not terminate properly. Otherwise, the system will wait |
| 933 | * until all transactions are closed while preventing new users from |
| 934 | * using the transport, and will close the transport when it is safe to |
| 935 | * do so. |
| 936 | * |
| 937 | * @param id Transport ID. |
| 938 | * @param force Non-zero to immediately close the transport. This |
| 939 | * is not recommended! |
| 940 | * |
| 941 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 942 | */ |
| 943 | PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id, |
| 944 | pj_bool_t force ); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 945 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 946 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 947 | * @} |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 948 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 949 | |
| 950 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 951 | |
| 952 | |
| 953 | /***************************************************************************** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 954 | * ACCOUNT API |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 955 | */ |
| 956 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 957 | |
| 958 | /** |
| 959 | * @defgroup PJSUA_LIB_ACC Account Management |
| 960 | * @ingroup PJSUA_LIB |
| 961 | * @brief PJSUA supports multiple accounts.. |
| 962 | * @{ |
| 963 | * PJSUA accounts provide identity (or identities) of the user who is currently |
| 964 | * using the application. More than one account maybe created with PJSUA. |
| 965 | * |
| 966 | * Account may or may not have client registration associated with it. |
| 967 | * An account is also associated with <b>route set</b> and some <b>authentication |
| 968 | * credentials</b>, which are used when sending SIP request messages using the |
| 969 | * account. An account also has presence's <b>online status</b>, which |
| 970 | * will be reported to remote peer when the subscribe to the account's |
| 971 | * presence. |
| 972 | * |
| 973 | * At least one account MUST be created in the application. If no user |
| 974 | * association is required, application can create a userless account by |
| 975 | * calling #pjsua_acc_add_local(). A userless account identifies local endpoint |
| 976 | * instead of a particular user. |
| 977 | * |
| 978 | * Also one account must be set as the <b>default account</b>, which is used as |
| 979 | * the account to use when PJSUA fails to match a request with any other |
| 980 | * accounts. |
| 981 | * |
| 982 | * When sending outgoing SIP requests (such as making calls or sending |
| 983 | * instant messages), normally PJSUA requires the application to specify |
| 984 | * which account to use for the request. If no account is specified, |
| 985 | * PJSUA may be able to select the account by matching the destination |
| 986 | * domain name, and fall back to default account when no match is found. |
| 987 | */ |
| 988 | |
| 989 | /** |
| 990 | * Maximum accounts. |
| 991 | */ |
| 992 | #ifndef PJSUA_MAX_ACC |
| 993 | # define PJSUA_MAX_ACC 8 |
| 994 | #endif |
| 995 | |
| 996 | |
| 997 | /** |
| 998 | * Default registration interval. |
| 999 | */ |
| 1000 | #ifndef PJSUA_REG_INTERVAL |
| 1001 | # define PJSUA_REG_INTERVAL 55 |
| 1002 | #endif |
| 1003 | |
| 1004 | |
| 1005 | /** |
| 1006 | * Account configuration. |
| 1007 | */ |
| 1008 | typedef struct pjsua_acc_config |
| 1009 | { |
| 1010 | /** |
| 1011 | * The full SIP URL for the account. The value can take name address or |
| 1012 | * URL format, and will look something like "sip:account@serviceprovider". |
| 1013 | * |
| 1014 | * This field is mandatory. |
| 1015 | */ |
| 1016 | pj_str_t id; |
| 1017 | |
| 1018 | /** |
| 1019 | * This is the URL to be put in the request URI for the registration, |
| 1020 | * and will look something like "sip:serviceprovider". |
| 1021 | * |
| 1022 | * This field should be specified if registration is desired. If the |
| 1023 | * value is empty, no account registration will be performed. |
| 1024 | */ |
| 1025 | pj_str_t reg_uri; |
| 1026 | |
| 1027 | /** |
| 1028 | * Optional URI to be put as Contact for this account. It is recommended |
| 1029 | * that this field is left empty, so that the value will be calculated |
| 1030 | * automatically based on the transport address. |
| 1031 | */ |
Benny Prijono | b4a17c9 | 2006-07-10 14:40:21 +0000 | [diff] [blame] | 1032 | pj_str_t force_contact; |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1033 | |
| 1034 | /** |
| 1035 | * Number of proxies in the proxy array below. |
| 1036 | */ |
| 1037 | unsigned proxy_cnt; |
| 1038 | |
| 1039 | /** |
| 1040 | * Optional URI of the proxies to be visited for all outgoing requests |
| 1041 | * that are using this account (REGISTER, INVITE, etc). Application need |
| 1042 | * to specify these proxies if the service provider requires that requests |
| 1043 | * destined towards its network should go through certain proxies first |
| 1044 | * (for example, border controllers). |
| 1045 | * |
| 1046 | * These proxies will be put in the route set for this account, with |
| 1047 | * maintaining the orders (the first proxy in the array will be visited |
| 1048 | * first). |
| 1049 | */ |
| 1050 | pj_str_t proxy[PJSUA_ACC_MAX_PROXIES]; |
| 1051 | |
| 1052 | /** |
| 1053 | * Optional interval for registration, in seconds. If the value is zero, |
| 1054 | * default interval will be used (PJSUA_REG_INTERVAL, 55 seconds). |
| 1055 | */ |
| 1056 | unsigned reg_timeout; |
| 1057 | |
| 1058 | /** |
| 1059 | * Number of credentials in the credential array. |
| 1060 | */ |
| 1061 | unsigned cred_count; |
| 1062 | |
| 1063 | /** |
| 1064 | * Array of credentials. If registration is desired, normally there should |
| 1065 | * be at least one credential specified, to successfully authenticate |
| 1066 | * against the service provider. More credentials can be specified, for |
| 1067 | * example when the requests are expected to be challenged by the |
| 1068 | * proxies in the route set. |
| 1069 | */ |
| 1070 | pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES]; |
| 1071 | |
| 1072 | } pjsua_acc_config; |
| 1073 | |
| 1074 | |
| 1075 | /** |
| 1076 | * Call this function to initialize account config with default values. |
| 1077 | * |
| 1078 | * @param cfg The account config to be initialized. |
| 1079 | */ |
| 1080 | PJ_INLINE(void) pjsua_acc_config_default(pjsua_acc_config *cfg) |
| 1081 | { |
Benny Prijono | ac623b3 | 2006-07-03 15:19:31 +0000 | [diff] [blame] | 1082 | pj_bzero(cfg, sizeof(*cfg)); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1083 | |
| 1084 | cfg->reg_timeout = PJSUA_REG_INTERVAL; |
| 1085 | } |
| 1086 | |
| 1087 | |
| 1088 | |
| 1089 | /** |
| 1090 | * Account info. Application can query account info by calling |
| 1091 | * #pjsua_acc_get_info(). |
| 1092 | */ |
| 1093 | typedef struct pjsua_acc_info |
| 1094 | { |
| 1095 | /** |
| 1096 | * The account ID. |
| 1097 | */ |
| 1098 | pjsua_acc_id id; |
| 1099 | |
| 1100 | /** |
| 1101 | * Flag to indicate whether this is the default account. |
| 1102 | */ |
| 1103 | pj_bool_t is_default; |
| 1104 | |
| 1105 | /** |
| 1106 | * Account URI |
| 1107 | */ |
| 1108 | pj_str_t acc_uri; |
| 1109 | |
| 1110 | /** |
| 1111 | * Flag to tell whether this account has registration setting |
| 1112 | * (reg_uri is not empty). |
| 1113 | */ |
| 1114 | pj_bool_t has_registration; |
| 1115 | |
| 1116 | /** |
| 1117 | * An up to date expiration interval for account registration session. |
| 1118 | */ |
| 1119 | int expires; |
| 1120 | |
| 1121 | /** |
| 1122 | * Last registration status code. If status code is zero, the account |
| 1123 | * is currently not registered. Any other value indicates the SIP |
| 1124 | * status code of the registration. |
| 1125 | */ |
| 1126 | pjsip_status_code status; |
| 1127 | |
| 1128 | /** |
| 1129 | * String describing the registration status. |
| 1130 | */ |
| 1131 | pj_str_t status_text; |
| 1132 | |
| 1133 | /** |
| 1134 | * Presence online status for this account. |
| 1135 | */ |
| 1136 | pj_bool_t online_status; |
| 1137 | |
| 1138 | /** |
| 1139 | * Buffer that is used internally to store the status text. |
| 1140 | */ |
| 1141 | char buf_[PJ_ERR_MSG_SIZE]; |
| 1142 | |
| 1143 | } pjsua_acc_info; |
| 1144 | |
| 1145 | |
| 1146 | |
| 1147 | /** |
| 1148 | * Get number of current accounts. |
| 1149 | * |
| 1150 | * @return Current number of accounts. |
| 1151 | */ |
| 1152 | PJ_DECL(unsigned) pjsua_acc_get_count(void); |
| 1153 | |
| 1154 | |
| 1155 | /** |
| 1156 | * Check if the specified account ID is valid. |
| 1157 | * |
| 1158 | * @param acc_id Account ID to check. |
| 1159 | * |
| 1160 | * @return Non-zero if account ID is valid. |
| 1161 | */ |
| 1162 | PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id); |
| 1163 | |
| 1164 | |
| 1165 | /** |
| 1166 | * Add a new account to pjsua. PJSUA must have been initialized (with |
| 1167 | * #pjsua_init()) before calling this function. |
| 1168 | * |
| 1169 | * @param cfg Account configuration. |
| 1170 | * @param is_default If non-zero, this account will be set as the default |
| 1171 | * account. The default account will be used when sending |
| 1172 | * outgoing requests (e.g. making call) when no account is |
| 1173 | * specified, and when receiving incoming requests when the |
| 1174 | * request does not match any accounts. It is recommended |
| 1175 | * that default account is set to local/LAN account. |
| 1176 | * @param p_acc_id Pointer to receive account ID of the new account. |
| 1177 | * |
| 1178 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1179 | */ |
| 1180 | PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *cfg, |
| 1181 | pj_bool_t is_default, |
| 1182 | pjsua_acc_id *p_acc_id); |
| 1183 | |
| 1184 | |
| 1185 | /** |
| 1186 | * Add a local account. A local account is used to identify local endpoint |
| 1187 | * instead of a specific user, and for this reason, a transport ID is needed |
| 1188 | * to obtain the local address information. |
| 1189 | * |
| 1190 | * @param tid Transport ID to generate account address. |
| 1191 | * @param is_default If non-zero, this account will be set as the default |
| 1192 | * account. The default account will be used when sending |
| 1193 | * outgoing requests (e.g. making call) when no account is |
| 1194 | * specified, and when receiving incoming requests when the |
| 1195 | * request does not match any accounts. It is recommended |
| 1196 | * that default account is set to local/LAN account. |
| 1197 | * @param p_acc_id Pointer to receive account ID of the new account. |
| 1198 | * |
| 1199 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1200 | */ |
| 1201 | PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid, |
| 1202 | pj_bool_t is_default, |
| 1203 | pjsua_acc_id *p_acc_id); |
| 1204 | |
| 1205 | /** |
| 1206 | * Delete account. |
| 1207 | * |
| 1208 | * @param acc_id Id of the account to be deleted. |
| 1209 | * |
| 1210 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1211 | */ |
| 1212 | PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id); |
| 1213 | |
| 1214 | |
| 1215 | /** |
| 1216 | * Modify account information. |
| 1217 | * |
| 1218 | * @param acc_id Id of the account to be modified. |
| 1219 | * @param cfg New account configuration. |
| 1220 | * |
| 1221 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1222 | */ |
| 1223 | PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id, |
| 1224 | const pjsua_acc_config *cfg); |
| 1225 | |
| 1226 | |
| 1227 | /** |
| 1228 | * Modify account's presence status to be advertised to remote/presence |
| 1229 | * subscribers. |
| 1230 | * |
| 1231 | * @param acc_id The account ID. |
| 1232 | * @param is_online True of false. |
| 1233 | * |
| 1234 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1235 | */ |
| 1236 | PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id, |
| 1237 | pj_bool_t is_online); |
| 1238 | |
| 1239 | |
| 1240 | /** |
| 1241 | * Update registration or perform unregistration. |
| 1242 | * |
| 1243 | * @param acc_id The account ID. |
| 1244 | * @param renew If renew argument is zero, this will start |
| 1245 | * unregistration process. |
| 1246 | * |
| 1247 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1248 | */ |
| 1249 | PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id, |
| 1250 | pj_bool_t renew); |
| 1251 | |
| 1252 | |
| 1253 | /** |
| 1254 | * Get account information. |
| 1255 | * |
| 1256 | * @param acc_id Account identification. |
| 1257 | * @param info Pointer to receive account information. |
| 1258 | * |
| 1259 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1260 | */ |
| 1261 | PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id, |
| 1262 | pjsua_acc_info *info); |
| 1263 | |
| 1264 | |
| 1265 | /** |
| 1266 | * Enum accounts all account ids. |
| 1267 | * |
| 1268 | * @param ids Array of account IDs to be initialized. |
| 1269 | * @param count In input, specifies the maximum number of elements. |
| 1270 | * On return, it contains the actual number of elements. |
| 1271 | * |
| 1272 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1273 | */ |
| 1274 | PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[], |
| 1275 | unsigned *count ); |
| 1276 | |
| 1277 | |
| 1278 | /** |
| 1279 | * Enum accounts info. |
| 1280 | * |
| 1281 | * @param info Array of account infos to be initialized. |
| 1282 | * @param count In input, specifies the maximum number of elements. |
| 1283 | * On return, it contains the actual number of elements. |
| 1284 | * |
| 1285 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1286 | */ |
| 1287 | PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[], |
| 1288 | unsigned *count ); |
| 1289 | |
| 1290 | |
| 1291 | /** |
| 1292 | * This is an internal function to find the most appropriate account to |
| 1293 | * used to reach to the specified URL. |
| 1294 | * |
| 1295 | * @param url The remote URL to reach. |
| 1296 | * |
| 1297 | * @return Account id. |
| 1298 | */ |
| 1299 | PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url); |
| 1300 | |
| 1301 | |
| 1302 | /** |
| 1303 | * This is an internal function to find the most appropriate account to be |
| 1304 | * used to handle incoming calls. |
| 1305 | * |
| 1306 | * @param rdata The incoming request message. |
| 1307 | * |
| 1308 | * @return Account id. |
| 1309 | */ |
| 1310 | PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata); |
| 1311 | |
| 1312 | |
Benny Prijono | c570f2d | 2006-07-18 00:33:02 +0000 | [diff] [blame] | 1313 | /** |
| 1314 | * Create a suitable URI to be put as Contact based on the specified |
| 1315 | * target URI for the specified account. |
| 1316 | * |
| 1317 | * @param pool Pool to allocate memory for the string. |
| 1318 | * @param contact The string where the Contact URI will be stored. |
| 1319 | * @param acc_id Account ID. |
| 1320 | * @param uri Destination URI of the request. |
| 1321 | * |
| 1322 | * @return PJ_SUCCESS on success, other on error. |
| 1323 | */ |
| 1324 | PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool, |
| 1325 | pj_str_t *contact, |
| 1326 | pjsua_acc_id acc_id, |
| 1327 | const pj_str_t *uri); |
| 1328 | |
| 1329 | |
| 1330 | |
| 1331 | /** |
| 1332 | * Create a suitable URI to be put as Contact based on the information |
| 1333 | * in the incoming request. |
| 1334 | * |
| 1335 | * @param pool Pool to allocate memory for the string. |
| 1336 | * @param contact The string where the Contact URI will be stored. |
| 1337 | * @param acc_id Account ID. |
| 1338 | * @param rdata Incoming request. |
| 1339 | * |
| 1340 | * @return PJ_SUCCESS on success, other on error. |
| 1341 | */ |
| 1342 | PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool, |
| 1343 | pj_str_t *contact, |
| 1344 | pjsua_acc_id acc_id, |
| 1345 | pjsip_rx_data *rdata ); |
| 1346 | |
| 1347 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1348 | |
| 1349 | /** |
| 1350 | * @} |
| 1351 | */ |
| 1352 | |
| 1353 | |
| 1354 | /***************************************************************************** |
| 1355 | * CALLS API |
| 1356 | */ |
| 1357 | |
| 1358 | |
| 1359 | /** |
| 1360 | * @defgroup PJSUA_LIB_CALL Calls |
| 1361 | * @ingroup PJSUA_LIB |
| 1362 | * @brief Call manipulation. |
| 1363 | * @{ |
| 1364 | */ |
| 1365 | |
| 1366 | /** |
| 1367 | * Max simultaneous calls. |
| 1368 | */ |
| 1369 | #ifndef PJSUA_MAX_CALLS |
| 1370 | # define PJSUA_MAX_CALLS 32 |
| 1371 | #endif |
| 1372 | |
| 1373 | |
| 1374 | |
| 1375 | /** |
| 1376 | * Call media status. |
| 1377 | */ |
| 1378 | typedef enum pjsua_call_media_status |
| 1379 | { |
| 1380 | PJSUA_CALL_MEDIA_NONE, |
| 1381 | PJSUA_CALL_MEDIA_ACTIVE, |
| 1382 | PJSUA_CALL_MEDIA_LOCAL_HOLD, |
| 1383 | PJSUA_CALL_MEDIA_REMOTE_HOLD, |
| 1384 | } pjsua_call_media_status; |
| 1385 | |
| 1386 | |
| 1387 | /** |
| 1388 | * Call info. |
| 1389 | */ |
| 1390 | typedef struct pjsua_call_info |
| 1391 | { |
| 1392 | /** Call identification. */ |
| 1393 | pjsua_call_id id; |
| 1394 | |
| 1395 | /** Initial call role (UAC == caller) */ |
| 1396 | pjsip_role_e role; |
| 1397 | |
| 1398 | /** Local URI */ |
| 1399 | pj_str_t local_info; |
| 1400 | |
| 1401 | /** Local Contact */ |
| 1402 | pj_str_t local_contact; |
| 1403 | |
| 1404 | /** Remote URI */ |
| 1405 | pj_str_t remote_info; |
| 1406 | |
| 1407 | /** Remote contact */ |
| 1408 | pj_str_t remote_contact; |
| 1409 | |
| 1410 | /** Dialog Call-ID string. */ |
| 1411 | pj_str_t call_id; |
| 1412 | |
| 1413 | /** Call state */ |
| 1414 | pjsip_inv_state state; |
| 1415 | |
| 1416 | /** Text describing the state */ |
| 1417 | pj_str_t state_text; |
| 1418 | |
| 1419 | /** Last status code heard, which can be used as cause code */ |
| 1420 | pjsip_status_code last_status; |
| 1421 | |
| 1422 | /** The reason phrase describing the status. */ |
| 1423 | pj_str_t last_status_text; |
| 1424 | |
| 1425 | /** Call media status. */ |
| 1426 | pjsua_call_media_status media_status; |
| 1427 | |
| 1428 | /** Media direction */ |
| 1429 | pjmedia_dir media_dir; |
| 1430 | |
| 1431 | /** The conference port number for the call */ |
| 1432 | pjsua_conf_port_id conf_slot; |
| 1433 | |
| 1434 | /** Up-to-date call connected duration (zero when call is not |
| 1435 | * established) |
| 1436 | */ |
| 1437 | pj_time_val connect_duration; |
| 1438 | |
| 1439 | /** Total call duration, including set-up time */ |
| 1440 | pj_time_val total_duration; |
| 1441 | |
| 1442 | /** Internal */ |
| 1443 | struct { |
| 1444 | char local_info[128]; |
| 1445 | char local_contact[128]; |
| 1446 | char remote_info[128]; |
| 1447 | char remote_contact[128]; |
| 1448 | char call_id[128]; |
| 1449 | char last_status_text[128]; |
| 1450 | } buf_; |
| 1451 | |
| 1452 | } pjsua_call_info; |
| 1453 | |
| 1454 | |
| 1455 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 1456 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1457 | * Get maximum number of calls configured in pjsua. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1458 | * |
| 1459 | * @return Maximum number of calls configured. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1460 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 1461 | PJ_DECL(unsigned) pjsua_call_get_max_count(void); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1462 | |
| 1463 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1464 | * Get number of currently active calls. |
| 1465 | * |
| 1466 | * @return Number of currently active calls. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1467 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 1468 | PJ_DECL(unsigned) pjsua_call_get_count(void); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1469 | |
| 1470 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1471 | * Enumerate all active calls. |
| 1472 | * |
| 1473 | * @param ids Array of account IDs to be initialized. |
| 1474 | * @param count In input, specifies the maximum number of elements. |
| 1475 | * On return, it contains the actual number of elements. |
| 1476 | * |
| 1477 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1478 | */ |
| 1479 | PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[], |
| 1480 | unsigned *count); |
| 1481 | |
| 1482 | |
| 1483 | /** |
| 1484 | * Make outgoing call to the specified URI using the specified account. |
| 1485 | * |
| 1486 | * @param acc_id The account to be used. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1487 | * @param dst_uri URI to be put in the To header (normally is the same |
| 1488 | * as the target URI). |
| 1489 | * @param options Options (must be zero at the moment). |
| 1490 | * @param user_data Arbitrary user data to be attached to the call, and |
| 1491 | * can be retrieved later. |
| 1492 | * @param msg_data Optional headers etc to be added to outgoing INVITE |
| 1493 | * request, or NULL if no custom header is desired. |
| 1494 | * @param p_call_id Pointer to receive call identification. |
| 1495 | * |
| 1496 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1497 | */ |
| 1498 | PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id, |
| 1499 | const pj_str_t *dst_uri, |
| 1500 | unsigned options, |
| 1501 | void *user_data, |
| 1502 | const pjsua_msg_data *msg_data, |
| 1503 | pjsua_call_id *p_call_id); |
| 1504 | |
| 1505 | |
| 1506 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1507 | * Check if the specified call has active INVITE session and the INVITE |
| 1508 | * session has not been disconnected. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1509 | * |
| 1510 | * @param call_id Call identification. |
| 1511 | * |
| 1512 | * @return Non-zero if call is active. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1513 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1514 | 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] | 1515 | |
| 1516 | |
| 1517 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1518 | * Check if call has an active media session. |
| 1519 | * |
| 1520 | * @param call_id Call identification. |
| 1521 | * |
| 1522 | * @return Non-zero if yes. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1523 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1524 | 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] | 1525 | |
| 1526 | |
| 1527 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1528 | * Get the conference port identification associated with the call. |
| 1529 | * |
| 1530 | * @param call_id Call identification. |
| 1531 | * |
| 1532 | * @return Conference port ID, or PJSUA_INVALID_ID when the |
| 1533 | * media has not been established or is not active. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1534 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1535 | PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id); |
| 1536 | |
| 1537 | /** |
| 1538 | * Obtain detail information about the specified call. |
| 1539 | * |
| 1540 | * @param call_id Call identification. |
| 1541 | * @param info Call info to be initialized. |
| 1542 | * |
| 1543 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1544 | */ |
| 1545 | 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] | 1546 | pjsua_call_info *info); |
| 1547 | |
| 1548 | |
| 1549 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1550 | * Attach application specific data to the call. |
| 1551 | * |
| 1552 | * @param call_id Call identification. |
| 1553 | * @param user_data Arbitrary data to be attached to the call. |
| 1554 | * |
| 1555 | * @return The user data. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1556 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1557 | PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id, |
| 1558 | void *user_data); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1559 | |
| 1560 | |
| 1561 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1562 | * Get user data attached to the call. |
| 1563 | * |
| 1564 | * @param call_id Call identification. |
| 1565 | * |
| 1566 | * @return The user data. |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 1567 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1568 | 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] | 1569 | |
| 1570 | |
| 1571 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1572 | * Send response to incoming INVITE request. |
| 1573 | * |
| 1574 | * @param call_id Incoming call identification. |
| 1575 | * @param code Status code, (100-699). |
| 1576 | * @param reason Optional reason phrase. If NULL, default text |
| 1577 | * will be used. |
| 1578 | * @param msg_data Optional list of headers etc to be added to outgoing |
| 1579 | * response message. |
| 1580 | * |
| 1581 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 1582 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1583 | PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id, |
| 1584 | unsigned code, |
| 1585 | const pj_str_t *reason, |
| 1586 | const pjsua_msg_data *msg_data); |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 1587 | |
| 1588 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1589 | * Hangup call by using method that is appropriate according to the |
| 1590 | * call state. |
| 1591 | * |
| 1592 | * @param call_id Call identification. |
| 1593 | * @param code Optional status code to be sent when we're rejecting |
| 1594 | * incoming call. If the value is zero, "603/Decline" |
| 1595 | * will be sent. |
| 1596 | * @param reason Optional reason phrase to be sent when we're rejecting |
| 1597 | * incoming call. If NULL, default text will be used. |
| 1598 | * @param msg_data Optional list of headers etc to be added to outgoing |
| 1599 | * request/response message. |
| 1600 | * |
| 1601 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 1602 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1603 | PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id, |
| 1604 | unsigned code, |
| 1605 | const pj_str_t *reason, |
| 1606 | const pjsua_msg_data *msg_data); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 1607 | |
| 1608 | |
| 1609 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1610 | * Put the specified call on hold. |
| 1611 | * |
| 1612 | * @param call_id Call identification. |
| 1613 | * @param msg_data Optional message components to be sent with |
| 1614 | * the request. |
| 1615 | * |
| 1616 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 1617 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1618 | PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id, |
| 1619 | const pjsua_msg_data *msg_data); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 1620 | |
| 1621 | |
| 1622 | /** |
| 1623 | * Send re-INVITE (to release hold). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1624 | * |
| 1625 | * @param call_id Call identification. |
| 1626 | * @param unhold If this argument is non-zero and the call is locally |
| 1627 | * held, this will release the local hold. |
| 1628 | * @param msg_data Optional message components to be sent with |
| 1629 | * the request. |
| 1630 | * |
| 1631 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 1632 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1633 | PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id, |
| 1634 | pj_bool_t unhold, |
| 1635 | const pjsua_msg_data *msg_data); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 1636 | |
| 1637 | |
| 1638 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1639 | * Initiate call transfer to the specified address. |
| 1640 | * |
| 1641 | * @param call_id Call identification. |
| 1642 | * @param dest Address of new target to be contacted. |
| 1643 | * @param msg_data Optional message components to be sent with |
| 1644 | * the request. |
| 1645 | * |
| 1646 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 1647 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1648 | PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id, |
| 1649 | const pj_str_t *dest, |
| 1650 | const pjsua_msg_data *msg_data); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1651 | |
| 1652 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1653 | * Send DTMF digits to remote using RFC 2833 payload formats. |
| 1654 | * |
| 1655 | * @param call_id Call identification. |
| 1656 | * @param digits DTMF digits to be sent. |
| 1657 | * |
| 1658 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1659 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1660 | 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] | 1661 | const pj_str_t *digits); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 1662 | |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 1663 | /** |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 1664 | * Send instant messaging inside INVITE session. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1665 | * |
| 1666 | * @param call_id Call identification. |
| 1667 | * @param mime_type Optional MIME type. If NULL, then "text/plain" is |
| 1668 | * assumed. |
| 1669 | * @param content The message content. |
| 1670 | * @param msg_data Optional list of headers etc to be included in outgoing |
| 1671 | * request. The body descriptor in the msg_data is |
| 1672 | * ignored. |
| 1673 | * @param user_data Optional user data, which will be given back when |
| 1674 | * the IM callback is called. |
| 1675 | * |
| 1676 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 1677 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1678 | PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id, |
| 1679 | const pj_str_t *mime_type, |
| 1680 | const pj_str_t *content, |
| 1681 | const pjsua_msg_data *msg_data, |
| 1682 | void *user_data); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 1683 | |
| 1684 | |
| 1685 | /** |
| 1686 | * Send IM typing indication inside INVITE session. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1687 | * |
| 1688 | * @param call_id Call identification. |
| 1689 | * @param is_typing Non-zero to indicate to remote that local person is |
| 1690 | * currently typing an IM. |
| 1691 | * @param msg_data Optional list of headers etc to be included in outgoing |
| 1692 | * request. |
| 1693 | * |
| 1694 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 1695 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1696 | PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id, |
| 1697 | pj_bool_t is_typing, |
| 1698 | const pjsua_msg_data*msg_data); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 1699 | |
| 1700 | /** |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 1701 | * Terminate all calls. |
| 1702 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 1703 | PJ_DECL(void) pjsua_call_hangup_all(void); |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 1704 | |
| 1705 | |
Benny Prijono | b9b32ab | 2006-06-01 12:28:44 +0000 | [diff] [blame] | 1706 | /** |
| 1707 | * Dump call and media statistics to string. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1708 | * |
| 1709 | * @param call_id Call identification. |
| 1710 | * @param with_media Non-zero to include media information too. |
| 1711 | * @param buffer Buffer where the statistics are to be written to. |
| 1712 | * @param maxlen Maximum length of buffer. |
| 1713 | * @param indent Spaces for left indentation. |
| 1714 | * |
| 1715 | * @return PJ_SUCCESS on success. |
Benny Prijono | b9b32ab | 2006-06-01 12:28:44 +0000 | [diff] [blame] | 1716 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1717 | PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id, |
| 1718 | pj_bool_t with_media, |
| 1719 | char *buffer, |
| 1720 | unsigned maxlen, |
| 1721 | const char *indent); |
Benny Prijono | b9b32ab | 2006-06-01 12:28:44 +0000 | [diff] [blame] | 1722 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1723 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1724 | * @} |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1725 | */ |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 1726 | |
| 1727 | |
| 1728 | /***************************************************************************** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1729 | * BUDDY API |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 1730 | */ |
| 1731 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1732 | |
| 1733 | /** |
| 1734 | * @defgroup PJSUA_LIB_BUDDY Buddy, Presence, and Instant Messaging |
| 1735 | * @ingroup PJSUA_LIB |
| 1736 | * @brief Buddy management, buddy's presence, and instant messaging. |
| 1737 | * @{ |
| 1738 | */ |
| 1739 | |
| 1740 | /** |
| 1741 | * Max buddies in buddy list. |
| 1742 | */ |
| 1743 | #ifndef PJSUA_MAX_BUDDIES |
| 1744 | # define PJSUA_MAX_BUDDIES 256 |
| 1745 | #endif |
| 1746 | |
| 1747 | |
| 1748 | /** |
| 1749 | * Buddy configuration. |
| 1750 | */ |
| 1751 | typedef struct pjsua_buddy_config |
| 1752 | { |
| 1753 | /** |
| 1754 | * Buddy URL or name address. |
| 1755 | */ |
| 1756 | pj_str_t uri; |
| 1757 | |
| 1758 | /** |
| 1759 | * Specify whether presence subscription should start immediately. |
| 1760 | */ |
| 1761 | pj_bool_t subscribe; |
| 1762 | |
| 1763 | } pjsua_buddy_config; |
| 1764 | |
| 1765 | |
| 1766 | /** |
| 1767 | * Buddy's online status. |
| 1768 | */ |
| 1769 | typedef enum pjsua_buddy_status |
| 1770 | { |
| 1771 | /** |
| 1772 | * Online status is unknown (possibly because no presence subscription |
| 1773 | * has been established). |
| 1774 | */ |
| 1775 | PJSUA_BUDDY_STATUS_UNKNOWN, |
| 1776 | |
| 1777 | /** |
| 1778 | * Buddy is known to be offline. |
| 1779 | */ |
| 1780 | PJSUA_BUDDY_STATUS_ONLINE, |
| 1781 | |
| 1782 | /** |
| 1783 | * Buddy is offline. |
| 1784 | */ |
| 1785 | PJSUA_BUDDY_STATUS_OFFLINE, |
| 1786 | |
| 1787 | } pjsua_buddy_status; |
| 1788 | |
| 1789 | |
| 1790 | |
| 1791 | /** |
| 1792 | * Buddy info. |
| 1793 | */ |
| 1794 | typedef struct pjsua_buddy_info |
| 1795 | { |
| 1796 | /** |
| 1797 | * The buddy ID. |
| 1798 | */ |
| 1799 | pjsua_buddy_id id; |
| 1800 | |
| 1801 | /** |
| 1802 | * The full URI of the buddy, as specified in the configuration. |
| 1803 | */ |
| 1804 | pj_str_t uri; |
| 1805 | |
| 1806 | /** |
| 1807 | * Buddy's Contact, only available when presence subscription has |
| 1808 | * been established to the buddy. |
| 1809 | */ |
| 1810 | pj_str_t contact; |
| 1811 | |
| 1812 | /** |
| 1813 | * Buddy's online status. |
| 1814 | */ |
| 1815 | pjsua_buddy_status status; |
| 1816 | |
| 1817 | /** |
| 1818 | * Text to describe buddy's online status. |
| 1819 | */ |
| 1820 | pj_str_t status_text; |
| 1821 | |
| 1822 | /** |
| 1823 | * Flag to indicate that we should monitor the presence information for |
| 1824 | * this buddy (normally yes, unless explicitly disabled). |
| 1825 | */ |
| 1826 | pj_bool_t monitor_pres; |
| 1827 | |
| 1828 | /** |
| 1829 | * Internal buffer. |
| 1830 | */ |
| 1831 | char buf_[256]; |
| 1832 | |
| 1833 | } pjsua_buddy_info; |
| 1834 | |
| 1835 | |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 1836 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1837 | * Get total number of buddies. |
| 1838 | * |
| 1839 | * @return Number of buddies. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1840 | */ |
| 1841 | PJ_DECL(unsigned) pjsua_get_buddy_count(void); |
| 1842 | |
| 1843 | |
| 1844 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1845 | * Check if buddy ID is valid. |
| 1846 | * |
| 1847 | * @param buddy_id Buddy ID to check. |
| 1848 | * |
| 1849 | * @return Non-zero if buddy ID is valid. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1850 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1851 | PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id); |
| 1852 | |
| 1853 | |
| 1854 | /** |
| 1855 | * Enum buddy IDs. |
| 1856 | * |
| 1857 | * @param ids Array of ids to be initialized. |
| 1858 | * @param count On input, specifies max elements in the array. |
| 1859 | * On return, it contains actual number of elements |
| 1860 | * that have been initialized. |
| 1861 | * |
| 1862 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1863 | */ |
| 1864 | PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[], |
| 1865 | unsigned *count); |
| 1866 | |
| 1867 | /** |
| 1868 | * Get detailed buddy info. |
| 1869 | * |
| 1870 | * @param buddy_id The buddy identification. |
| 1871 | * @param info Pointer to receive information about buddy. |
| 1872 | * |
| 1873 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1874 | */ |
| 1875 | 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] | 1876 | pjsua_buddy_info *info); |
| 1877 | |
| 1878 | /** |
| 1879 | * Add new buddy. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1880 | * |
| 1881 | * @param cfg Buddy configuration. |
| 1882 | * @param p_buddy_id Pointer to receive buddy ID. |
| 1883 | * |
| 1884 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1885 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1886 | PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *cfg, |
| 1887 | pjsua_buddy_id *p_buddy_id); |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 1888 | |
| 1889 | |
| 1890 | /** |
| 1891 | * Delete buddy. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1892 | * |
| 1893 | * @param buddy_id Buddy identification. |
| 1894 | * |
| 1895 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 1896 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1897 | 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] | 1898 | |
| 1899 | |
| 1900 | /** |
| 1901 | * Enable/disable buddy's presence monitoring. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1902 | * |
| 1903 | * @param buddy_id Buddy identification. |
| 1904 | * @param subscribe Specify non-zero to activate presence subscription to |
| 1905 | * the specified buddy. |
| 1906 | * |
| 1907 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1908 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1909 | PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id, |
| 1910 | pj_bool_t subscribe); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1911 | |
| 1912 | |
| 1913 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1914 | * Dump presence subscriptions to log file. |
| 1915 | * |
| 1916 | * @param verbose Yes or no. |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 1917 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1918 | PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose); |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 1919 | |
| 1920 | |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 1921 | /** |
| 1922 | * The MESSAGE method (defined in pjsua_im.c) |
| 1923 | */ |
| 1924 | extern const pjsip_method pjsip_message_method; |
| 1925 | |
| 1926 | |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 1927 | |
| 1928 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1929 | * Send instant messaging outside dialog, using the specified account for |
| 1930 | * route set and authentication. |
| 1931 | * |
| 1932 | * @param acc_id Account ID to be used to send the request. |
| 1933 | * @param to Remote URI. |
| 1934 | * @param mime_type Optional MIME type. If NULL, then "text/plain" is |
| 1935 | * assumed. |
| 1936 | * @param content The message content. |
| 1937 | * @param msg_data Optional list of headers etc to be included in outgoing |
| 1938 | * request. The body descriptor in the msg_data is |
| 1939 | * ignored. |
| 1940 | * @param user_data Optional user data, which will be given back when |
| 1941 | * the IM callback is called. |
| 1942 | * |
| 1943 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 1944 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1945 | PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id, |
| 1946 | const pj_str_t *to, |
| 1947 | const pj_str_t *mime_type, |
| 1948 | const pj_str_t *content, |
| 1949 | const pjsua_msg_data *msg_data, |
| 1950 | void *user_data); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 1951 | |
| 1952 | |
| 1953 | /** |
| 1954 | * Send typing indication outside dialog. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1955 | * |
| 1956 | * @param acc_id Account ID to be used to send the request. |
| 1957 | * @param to Remote URI. |
| 1958 | * @param is_typing If non-zero, it tells remote person that local person |
| 1959 | * is currently composing an IM. |
| 1960 | * @param msg_data Optional list of headers etc to be added to outgoing |
| 1961 | * request. |
| 1962 | * |
| 1963 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 1964 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1965 | PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id, |
| 1966 | const pj_str_t *to, |
| 1967 | pj_bool_t is_typing, |
| 1968 | const pjsua_msg_data *msg_data); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 1969 | |
| 1970 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 1971 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1972 | /** |
| 1973 | * @} |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1974 | */ |
| 1975 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1976 | |
| 1977 | /***************************************************************************** |
| 1978 | * MEDIA API |
| 1979 | */ |
| 1980 | |
| 1981 | |
| 1982 | /** |
| 1983 | * @defgroup PJSUA_LIB_MEDIA Media |
| 1984 | * @ingroup PJSUA_LIB |
| 1985 | * @brief Media manipulation. |
| 1986 | * @{ |
| 1987 | * |
| 1988 | * PJSUA has rather powerful media features, which are built around the |
| 1989 | * PJMEDIA conference bridge. Basically, all media termination (such as |
| 1990 | * calls, file players, file recorders, sound device, tone generators, etc) |
| 1991 | * are terminated in the conference bridge, and application can manipulate |
| 1992 | * the interconnection between these terminations freely. If more than |
| 1993 | * one media terminations are terminated in the same slot, the conference |
| 1994 | * bridge will mix the signal automatically. |
| 1995 | * |
| 1996 | * Application connects one media termination/slot to another by calling |
| 1997 | * #pjsua_conf_connect() function. This will establish <b>unidirectional</b> |
| 1998 | * media flow from the source termination to the sink termination. For |
| 1999 | * example, to stream a WAV file to remote call, application may use |
| 2000 | * the following steps: |
| 2001 | * |
| 2002 | \code |
| 2003 | |
| 2004 | pj_status_t stream_to_call( pjsua_call_id call_id ) |
| 2005 | { |
| 2006 | pjsua_player_id player_id; |
| 2007 | |
| 2008 | status = pjsua_player_create("mysong.wav", 0, NULL, &player_id); |
| 2009 | if (status != PJ_SUCCESS) |
| 2010 | return status; |
| 2011 | |
| 2012 | status = pjsua_conf_connect( pjsua_player_get_conf_port(), |
| 2013 | pjsua_call_get_conf_port() ); |
| 2014 | } |
| 2015 | \endcode |
| 2016 | * |
| 2017 | * |
| 2018 | * Other features of PJSUA media: |
| 2019 | * - efficient N to M interconnections between media terminations. |
| 2020 | * - media termination can be connected to itself to create loopback |
| 2021 | * media. |
| 2022 | * - the media termination may have different clock rates, and resampling |
| 2023 | * will be done automatically by conference bridge. |
| 2024 | * - media terminations may also have different frame time; the |
| 2025 | * conference bridge will perform the necessary bufferring to adjust |
| 2026 | * the difference between terminations. |
| 2027 | * - interconnections are removed automatically when media termination |
| 2028 | * is removed from the bridge. |
| 2029 | * - sound device may be changed even when there are active media |
| 2030 | * interconnections. |
| 2031 | * - correctly report call's media quality (in #pjsua_call_dump()) from |
| 2032 | * RTCP packet exchange. |
| 2033 | */ |
| 2034 | |
| 2035 | /** |
| 2036 | * Max ports in the conference bridge. |
| 2037 | */ |
| 2038 | #ifndef PJSUA_MAX_CONF_PORTS |
| 2039 | # define PJSUA_MAX_CONF_PORTS 254 |
| 2040 | #endif |
| 2041 | |
Benny Prijono | 7097299 | 2006-08-05 11:13:58 +0000 | [diff] [blame^] | 2042 | #define PJSUA_DEFAULT_CLOCK_RATE 16000 |
| 2043 | #define PJSUA_DEFAULT_CODEC_QUALITY 5 |
| 2044 | #define PJSUA_DEFAULT_ILBC_MODE 20 |
| 2045 | #define PJSUA_DEFAULT_EC_TAIL_LEN 256 |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2046 | |
| 2047 | |
| 2048 | /** |
| 2049 | * Media configuration. |
| 2050 | */ |
| 2051 | struct pjsua_media_config |
| 2052 | { |
| 2053 | /** |
| 2054 | * Clock rate to be applied to the conference bridge. |
| 2055 | * If value is zero, default clock rate will be used (16KHz). |
| 2056 | */ |
| 2057 | unsigned clock_rate; |
| 2058 | |
| 2059 | /** |
| 2060 | * Specify maximum number of media ports to be created in the |
| 2061 | * conference bridge. Since all media terminate in the bridge |
| 2062 | * (calls, file player, file recorder, etc), the value must be |
| 2063 | * large enough to support all of them. However, the larger |
| 2064 | * the value, the more computations are performed. |
| 2065 | */ |
| 2066 | unsigned max_media_ports; |
| 2067 | |
| 2068 | /** |
| 2069 | * Specify whether the media manager should manage its own |
| 2070 | * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created |
| 2071 | * and at least one worker thread will be created too. If no, |
| 2072 | * the RTP/RTCP sockets will share the same ioqueue as SIP sockets, |
| 2073 | * and no worker thread is needed. |
| 2074 | * |
| 2075 | * Normally application would say yes here, unless it wants to |
| 2076 | * run everything from a single thread. |
| 2077 | */ |
| 2078 | pj_bool_t has_ioqueue; |
| 2079 | |
| 2080 | /** |
| 2081 | * Specify the number of worker threads to handle incoming RTP |
| 2082 | * packets. A value of one is recommended for most applications. |
| 2083 | */ |
| 2084 | unsigned thread_cnt; |
| 2085 | |
Benny Prijono | 0498d90 | 2006-06-19 14:49:14 +0000 | [diff] [blame] | 2086 | /** |
| 2087 | * Media quality, 0-10, according to this table: |
| 2088 | * 8-10: resampling use large filter, |
| 2089 | * 3-7: resampling use small filter, |
| 2090 | * 1-2: resampling use linear. |
| 2091 | * The media quality also sets speex codec quality/complexity to the |
| 2092 | * number. |
| 2093 | * |
Benny Prijono | 7097299 | 2006-08-05 11:13:58 +0000 | [diff] [blame^] | 2094 | * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY). |
Benny Prijono | 0498d90 | 2006-06-19 14:49:14 +0000 | [diff] [blame] | 2095 | */ |
| 2096 | unsigned quality; |
Benny Prijono | 0a12f00 | 2006-07-26 17:05:39 +0000 | [diff] [blame] | 2097 | |
| 2098 | /** |
| 2099 | * Specify default ptime. |
| 2100 | * |
| 2101 | * Default: 0 (codec specific) |
| 2102 | */ |
| 2103 | unsigned ptime; |
| 2104 | |
| 2105 | /** |
| 2106 | * Disable VAD? |
| 2107 | * |
| 2108 | * Default: 0 (no (meaning VAD is enabled)) |
| 2109 | */ |
| 2110 | pj_bool_t no_vad; |
Benny Prijono | 00cae61 | 2006-07-31 15:19:36 +0000 | [diff] [blame] | 2111 | |
| 2112 | /** |
| 2113 | * iLBC mode (20 or 30). |
| 2114 | * |
Benny Prijono | 7097299 | 2006-08-05 11:13:58 +0000 | [diff] [blame^] | 2115 | * Default: 20 (PJSUA_DEFAULT_ILBC_MODE) |
Benny Prijono | 00cae61 | 2006-07-31 15:19:36 +0000 | [diff] [blame] | 2116 | */ |
| 2117 | unsigned ilbc_mode; |
| 2118 | |
| 2119 | /** |
| 2120 | * Percentage of RTP packet to drop in TX direction |
| 2121 | * (to simulate packet lost). |
| 2122 | * |
| 2123 | * Default: 0 |
| 2124 | */ |
| 2125 | unsigned tx_drop_pct; |
| 2126 | |
| 2127 | /** |
| 2128 | * Percentage of RTP packet to drop in RX direction |
| 2129 | * (to simulate packet lost). |
| 2130 | * |
| 2131 | * Default: 0 |
| 2132 | */ |
| 2133 | unsigned rx_drop_pct; |
| 2134 | |
Benny Prijono | c8e24a1 | 2006-08-02 18:22:22 +0000 | [diff] [blame] | 2135 | /** |
| 2136 | * Echo canceller tail length, in miliseconds. |
| 2137 | * |
Benny Prijono | 7097299 | 2006-08-05 11:13:58 +0000 | [diff] [blame^] | 2138 | * Default: 128 (PJSUA_DEFAULT_EC_TAIL_LEN) |
Benny Prijono | c8e24a1 | 2006-08-02 18:22:22 +0000 | [diff] [blame] | 2139 | */ |
| 2140 | unsigned ec_tail_len; |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2141 | }; |
| 2142 | |
| 2143 | |
| 2144 | /** |
| 2145 | * Use this function to initialize media config. |
| 2146 | * |
| 2147 | * @param cfg The media config to be initialized. |
| 2148 | */ |
| 2149 | PJ_INLINE(void) pjsua_media_config_default(pjsua_media_config *cfg) |
| 2150 | { |
Benny Prijono | ac623b3 | 2006-07-03 15:19:31 +0000 | [diff] [blame] | 2151 | pj_bzero(cfg, sizeof(*cfg)); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2152 | |
Benny Prijono | 7097299 | 2006-08-05 11:13:58 +0000 | [diff] [blame^] | 2153 | cfg->clock_rate = PJSUA_DEFAULT_CLOCK_RATE; |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2154 | cfg->max_media_ports = 32; |
| 2155 | cfg->has_ioqueue = PJ_TRUE; |
| 2156 | cfg->thread_cnt = 1; |
Benny Prijono | 7097299 | 2006-08-05 11:13:58 +0000 | [diff] [blame^] | 2157 | cfg->quality = PJSUA_DEFAULT_CODEC_QUALITY; |
| 2158 | cfg->ilbc_mode = PJSUA_DEFAULT_ILBC_MODE; |
| 2159 | cfg->ec_tail_len = PJSUA_DEFAULT_EC_TAIL_LEN; |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2160 | } |
| 2161 | |
| 2162 | |
| 2163 | |
| 2164 | /** |
| 2165 | * Codec config. |
| 2166 | */ |
| 2167 | typedef struct pjsua_codec_info |
| 2168 | { |
| 2169 | /** |
| 2170 | * Codec unique identification. |
| 2171 | */ |
| 2172 | pj_str_t codec_id; |
| 2173 | |
| 2174 | /** |
| 2175 | * Codec priority (integer 0-255). |
| 2176 | */ |
| 2177 | pj_uint8_t priority; |
| 2178 | |
| 2179 | /** |
| 2180 | * Internal buffer. |
| 2181 | */ |
| 2182 | char buf_[32]; |
| 2183 | |
| 2184 | } pjsua_codec_info; |
| 2185 | |
| 2186 | |
| 2187 | /** |
| 2188 | * Conference port info. |
| 2189 | */ |
| 2190 | typedef struct pjsua_conf_port_info |
| 2191 | { |
| 2192 | /** Conference port number. */ |
| 2193 | pjsua_conf_port_id slot_id; |
| 2194 | |
| 2195 | /** Port name. */ |
| 2196 | pj_str_t name; |
| 2197 | |
| 2198 | /** Clock rate. */ |
| 2199 | unsigned clock_rate; |
| 2200 | |
| 2201 | /** Number of channels. */ |
| 2202 | unsigned channel_count; |
| 2203 | |
| 2204 | /** Samples per frame */ |
| 2205 | unsigned samples_per_frame; |
| 2206 | |
| 2207 | /** Bits per sample */ |
| 2208 | unsigned bits_per_sample; |
| 2209 | |
| 2210 | /** Number of listeners in the array. */ |
| 2211 | unsigned listener_cnt; |
| 2212 | |
| 2213 | /** Array of listeners (in other words, ports where this port is |
| 2214 | * transmitting to. |
| 2215 | */ |
| 2216 | pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS]; |
| 2217 | |
| 2218 | } pjsua_conf_port_info; |
| 2219 | |
| 2220 | |
| 2221 | /** |
| 2222 | * This structure holds information about custom media transport to |
| 2223 | * be registered to pjsua. |
| 2224 | */ |
| 2225 | typedef struct pjsua_media_transport |
| 2226 | { |
| 2227 | /** |
| 2228 | * Media socket information containing the address information |
| 2229 | * of the RTP and RTCP socket. |
| 2230 | */ |
| 2231 | pjmedia_sock_info skinfo; |
| 2232 | |
| 2233 | /** |
| 2234 | * The media transport instance. |
| 2235 | */ |
| 2236 | pjmedia_transport *transport; |
| 2237 | |
| 2238 | } pjsua_media_transport; |
| 2239 | |
| 2240 | |
| 2241 | |
| 2242 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2243 | /** |
| 2244 | * Get maxinum number of conference ports. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2245 | * |
| 2246 | * @return Maximum number of ports in the conference bridge. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2247 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2248 | PJ_DECL(unsigned) pjsua_conf_get_max_ports(void); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2249 | |
| 2250 | |
| 2251 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2252 | * Get current number of active ports in the bridge. |
| 2253 | * |
| 2254 | * @return The number. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2255 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2256 | PJ_DECL(unsigned) pjsua_conf_get_active_ports(void); |
| 2257 | |
| 2258 | |
| 2259 | /** |
| 2260 | * Enumerate all conference ports. |
| 2261 | * |
| 2262 | * @param id Array of conference port ID to be initialized. |
| 2263 | * @param count On input, specifies max elements in the array. |
| 2264 | * On return, it contains actual number of elements |
| 2265 | * that have been initialized. |
| 2266 | * |
| 2267 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2268 | */ |
| 2269 | PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[], |
| 2270 | unsigned *count); |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 2271 | |
| 2272 | |
| 2273 | /** |
| 2274 | * Get information about the specified conference port |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2275 | * |
| 2276 | * @param id Port identification. |
| 2277 | * @param info Pointer to store the port info. |
| 2278 | * |
| 2279 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 2280 | */ |
| 2281 | PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id id, |
| 2282 | pjsua_conf_port_info *info); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2283 | |
| 2284 | |
| 2285 | /** |
Benny Prijono | e909eac | 2006-07-27 22:04:56 +0000 | [diff] [blame] | 2286 | * Add arbitrary media port to PJSUA's conference bridge. Application |
| 2287 | * can use this function to add the media port that it creates. For |
| 2288 | * media ports that are created by PJSUA-LIB (such as calls, file player, |
| 2289 | * or file recorder), PJSUA-LIB will automatically add the port to |
| 2290 | * the bridge. |
| 2291 | * |
| 2292 | * @param pool Pool to use. |
| 2293 | * @param port Media port to be added to the bridge. |
| 2294 | * @param p_id Optional pointer to receive the conference |
| 2295 | * slot id. |
| 2296 | * |
| 2297 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2298 | */ |
| 2299 | PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool, |
| 2300 | pjmedia_port *port, |
| 2301 | pjsua_conf_port_id *p_id); |
| 2302 | |
| 2303 | |
| 2304 | /** |
| 2305 | * Remove arbitrary slot from the conference bridge. Application should only |
| 2306 | * call this function if it registered the port manually. |
| 2307 | * |
| 2308 | * @param id The slot id of the port to be removed. |
| 2309 | * |
| 2310 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2311 | */ |
| 2312 | PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id id); |
| 2313 | |
| 2314 | |
| 2315 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2316 | * Establish unidirectional media flow from souce to sink. One source |
| 2317 | * may transmit to multiple destinations/sink. And if multiple |
| 2318 | * sources are transmitting to the same sink, the media will be mixed |
| 2319 | * together. Source and sink may refer to the same ID, effectively |
| 2320 | * looping the media. |
| 2321 | * |
| 2322 | * If bidirectional media flow is desired, application needs to call |
| 2323 | * this function twice, with the second one having the arguments |
| 2324 | * reversed. |
| 2325 | * |
| 2326 | * @param source Port ID of the source media/transmitter. |
| 2327 | * @param sink Port ID of the destination media/received. |
| 2328 | * |
| 2329 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2330 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2331 | PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source, |
| 2332 | pjsua_conf_port_id sink); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2333 | |
| 2334 | |
| 2335 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2336 | * Disconnect media flow from the source to destination port. |
| 2337 | * |
| 2338 | * @param source Port ID of the source media/transmitter. |
| 2339 | * @param sink Port ID of the destination media/received. |
| 2340 | * |
| 2341 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2342 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2343 | PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source, |
| 2344 | pjsua_conf_port_id sink); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2345 | |
| 2346 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2347 | /***************************************************************************** |
| 2348 | * File player. |
| 2349 | */ |
| 2350 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2351 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2352 | * Create a file player, and automatically connect this player to |
| 2353 | * the conference bridge. |
| 2354 | * |
| 2355 | * @param filename The filename to be played. Currently only |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2356 | * WAV files are supported, and the WAV file MUST be |
| 2357 | * formatted as 16bit PCM mono/single channel (any |
| 2358 | * clock rate is supported). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2359 | * @param options Options (currently zero). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2360 | * @param p_id Pointer to receive player ID. |
| 2361 | * |
| 2362 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2363 | */ |
| 2364 | 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] | 2365 | unsigned options, |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2366 | pjsua_player_id *p_id); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2367 | |
| 2368 | |
| 2369 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2370 | * Get conference port ID associated with player. |
| 2371 | * |
| 2372 | * @param id The file player ID. |
| 2373 | * |
| 2374 | * @return Conference port ID associated with this player. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2375 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 2376 | 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] | 2377 | |
| 2378 | |
| 2379 | /** |
| 2380 | * Set playback position. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2381 | * |
| 2382 | * @param id The file player ID. |
| 2383 | * @param samples The playback position, in samples. Application can |
| 2384 | * specify zero to re-start the playback. |
| 2385 | * |
| 2386 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2387 | */ |
| 2388 | PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id, |
| 2389 | pj_uint32_t samples); |
| 2390 | |
| 2391 | |
| 2392 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2393 | * Close the file, remove the player from the bridge, and free |
| 2394 | * resources associated with the file player. |
| 2395 | * |
| 2396 | * @param id The file player ID. |
| 2397 | * |
| 2398 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2399 | */ |
| 2400 | PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id); |
| 2401 | |
| 2402 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2403 | /***************************************************************************** |
| 2404 | * File recorder. |
| 2405 | */ |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2406 | |
| 2407 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2408 | * Create a file recorder, and automatically connect this recorder to |
| 2409 | * the conference bridge. |
| 2410 | * |
| 2411 | * @param filename Output file name. |
| 2412 | * @param file_format Specify the file format (currently only WAV is |
| 2413 | * supported, so the value MUST be zero). |
| 2414 | * @param encoding Specify the encoding to be applied to the file. |
| 2415 | * Currently only 16bit raw PCM is supported, so |
| 2416 | * the value must be NULL. |
| 2417 | * @param max_size Maximum file size. Specify -1 to remove size |
| 2418 | * limitation. |
| 2419 | * @param options Optional options. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2420 | * @param p_id Pointer to receive the recorder instance. |
| 2421 | * |
| 2422 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2423 | */ |
| 2424 | PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename, |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2425 | unsigned file_format, |
| 2426 | const pj_str_t *encoding, |
| 2427 | pj_ssize_t max_size, |
| 2428 | unsigned options, |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2429 | pjsua_recorder_id *p_id); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2430 | |
| 2431 | |
| 2432 | /** |
| 2433 | * Get conference port associated with recorder. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2434 | * |
| 2435 | * @param id The recorder ID. |
| 2436 | * |
| 2437 | * @return Conference port ID associated with this recorder. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2438 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 2439 | 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] | 2440 | |
| 2441 | |
| 2442 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2443 | * Destroy recorder (this will complete recording). |
| 2444 | * |
| 2445 | * @param id The recorder ID. |
| 2446 | * |
| 2447 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2448 | */ |
| 2449 | PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id); |
| 2450 | |
| 2451 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2452 | /***************************************************************************** |
| 2453 | * Sound devices. |
| 2454 | */ |
| 2455 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2456 | /** |
| 2457 | * Enum sound devices. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2458 | * |
| 2459 | * @param info Array of info to be initialized. |
| 2460 | * @param count On input, specifies max elements in the array. |
| 2461 | * On return, it contains actual number of elements |
| 2462 | * that have been initialized. |
| 2463 | * |
| 2464 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2465 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2466 | PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[], |
| 2467 | unsigned *count); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2468 | |
| 2469 | |
| 2470 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2471 | * Select or change sound device. Application may call this function at |
| 2472 | * any time to replace current sound device. |
| 2473 | * |
| 2474 | * @param capture_dev Device ID of the capture device. |
| 2475 | * @param playback_dev Device ID of the playback device. |
| 2476 | * |
| 2477 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2478 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2479 | PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev, |
| 2480 | int playback_dev); |
| 2481 | |
| 2482 | |
| 2483 | /** |
| 2484 | * Set pjsua to use null sound device. The null sound device only provides |
| 2485 | * the timing needed by the conference bridge, and will not interract with |
| 2486 | * any hardware. |
| 2487 | * |
| 2488 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2489 | */ |
| 2490 | PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void); |
| 2491 | |
| 2492 | |
Benny Prijono | e909eac | 2006-07-27 22:04:56 +0000 | [diff] [blame] | 2493 | /** |
| 2494 | * Disconnect the main conference bridge from any sound devices, and let |
| 2495 | * application connect the bridge to it's own sound device/master port. |
| 2496 | * |
| 2497 | * @return The port interface of the conference bridge, |
| 2498 | * so that application can connect this to it's own |
| 2499 | * sound device or master port. |
| 2500 | */ |
| 2501 | PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void); |
| 2502 | |
| 2503 | |
Benny Prijono | f20687a | 2006-08-04 18:27:19 +0000 | [diff] [blame] | 2504 | /** |
| 2505 | * Configure the AEC settings of the sound port. |
| 2506 | * |
| 2507 | * @param tail_ms The tail length, in miliseconds. Set to zero to |
| 2508 | * disable AEC. |
| 2509 | * |
| 2510 | * @return PJ_SUCCESS on success. |
| 2511 | */ |
| 2512 | PJ_DECL(pj_status_t) pjsua_set_aec(unsigned tail_ms); |
| 2513 | |
| 2514 | |
| 2515 | /** |
| 2516 | * Get current AEC tail length. |
| 2517 | * |
| 2518 | * @param p_tail_ms Pointer to receive the tail length, in miliseconds. |
| 2519 | * If AEC is disabled, the value will be zero. |
| 2520 | * |
| 2521 | * @return PJ_SUCCESS on success. |
| 2522 | */ |
| 2523 | PJ_DECL(pj_status_t) pjsua_get_aec(unsigned *p_tail_ms); |
| 2524 | |
| 2525 | |
| 2526 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2527 | /***************************************************************************** |
| 2528 | * Codecs. |
| 2529 | */ |
| 2530 | |
| 2531 | /** |
| 2532 | * Enum all supported codecs in the system. |
| 2533 | * |
| 2534 | * @param id Array of ID to be initialized. |
| 2535 | * @param count On input, specifies max elements in the array. |
| 2536 | * On return, it contains actual number of elements |
| 2537 | * that have been initialized. |
| 2538 | * |
| 2539 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2540 | */ |
| 2541 | PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[], |
| 2542 | unsigned *count ); |
| 2543 | |
| 2544 | |
| 2545 | /** |
| 2546 | * Change codec priority. |
| 2547 | * |
| 2548 | * @param id Codec ID. |
| 2549 | * @param priority Codec priority, 0-255, where zero means to disable |
| 2550 | * the codec. |
| 2551 | * |
| 2552 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2553 | */ |
| 2554 | PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *id, |
| 2555 | pj_uint8_t priority ); |
| 2556 | |
| 2557 | |
| 2558 | /** |
| 2559 | * Get codec parameters. |
| 2560 | * |
| 2561 | * @param id Codec ID. |
| 2562 | * @param param Structure to receive codec parameters. |
| 2563 | * |
| 2564 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2565 | */ |
| 2566 | PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *id, |
| 2567 | pjmedia_codec_param *param ); |
| 2568 | |
| 2569 | |
| 2570 | /** |
| 2571 | * Set codec parameters. |
| 2572 | * |
| 2573 | * @param id Codec ID. |
| 2574 | * @param param Codec parameter to set. |
| 2575 | * |
| 2576 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2577 | */ |
| 2578 | PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *id, |
| 2579 | const pjmedia_codec_param *param); |
| 2580 | |
| 2581 | |
| 2582 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2583 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2584 | /** |
| 2585 | * Create UDP media transports for all the calls. This function creates |
| 2586 | * one UDP media transport for each call. |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 2587 | * |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2588 | * @param cfg Media transport configuration. The "port" field in the |
| 2589 | * configuration is used as the start port to bind the |
| 2590 | * sockets. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2591 | * |
| 2592 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 2593 | */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2594 | PJ_DECL(pj_status_t) |
| 2595 | pjsua_media_transports_create(const pjsua_transport_config *cfg); |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 2596 | |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 2597 | |
| 2598 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2599 | * Register custom media transports to be used by calls. There must |
| 2600 | * enough media transports for all calls. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2601 | * |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2602 | * @param tp The media transport array. |
| 2603 | * @param count Number of elements in the array. This number MUST |
| 2604 | * match the number of maximum calls configured when |
| 2605 | * pjsua is created. |
| 2606 | * @param auto_delete Flag to indicate whether the transports should be |
| 2607 | * destroyed when pjsua is shutdown. |
| 2608 | * |
| 2609 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 2610 | */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2611 | PJ_DECL(pj_status_t) |
| 2612 | pjsua_media_transports_attach( pjsua_media_transport tp[], |
| 2613 | unsigned count, |
| 2614 | pj_bool_t auto_delete); |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 2615 | |
| 2616 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2617 | /** |
| 2618 | * @} |
| 2619 | */ |
| 2620 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 2621 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 2622 | |
Benny Prijono | 1a01ad3 | 2006-02-07 21:13:28 +0000 | [diff] [blame] | 2623 | PJ_END_DECL |
| 2624 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 2625 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2626 | /** |
| 2627 | * @} |
| 2628 | */ |
| 2629 | |
| 2630 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 2631 | #endif /* __PJSUA_H__ */ |