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