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