Alexandre Lision | 8af73cb | 2013-12-10 14:11:20 -0500 | [diff] [blame] | 1 | /* $Id: pjsua.h 4667 2013-12-03 05:22:10Z bennylp $ */ |
Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) |
| 4 | * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | #ifndef __PJSUA_H__ |
| 21 | #define __PJSUA_H__ |
| 22 | |
| 23 | /** |
| 24 | * @file pjsua.h |
| 25 | * @brief PJSUA API. |
| 26 | */ |
| 27 | |
| 28 | |
| 29 | /* Include all PJSIP core headers. */ |
| 30 | #include <pjsip.h> |
| 31 | |
| 32 | /* Include all PJMEDIA headers. */ |
| 33 | #include <pjmedia.h> |
| 34 | |
| 35 | /* Include all PJMEDIA-CODEC headers. */ |
| 36 | #include <pjmedia-codec.h> |
| 37 | |
| 38 | /* Videodev too */ |
| 39 | #include <pjmedia_videodev.h> |
| 40 | |
| 41 | /* Include all PJSIP-UA headers */ |
| 42 | #include <pjsip_ua.h> |
| 43 | |
| 44 | /* Include all PJSIP-SIMPLE headers */ |
| 45 | #include <pjsip_simple.h> |
| 46 | |
| 47 | /* Include all PJNATH headers */ |
| 48 | #include <pjnath.h> |
| 49 | |
| 50 | /* Include all PJLIB-UTIL headers. */ |
| 51 | #include <pjlib-util.h> |
| 52 | |
| 53 | /* Include all PJLIB headers. */ |
| 54 | #include <pjlib.h> |
| 55 | |
| 56 | |
| 57 | PJ_BEGIN_DECL |
| 58 | |
| 59 | |
| 60 | /** |
| 61 | * @defgroup PJSUA_LIB PJSUA API - High Level Softphone API |
| 62 | * @brief Very high level API for constructing SIP UA applications. |
| 63 | * @{ |
| 64 | * |
| 65 | * @section pjsua_api_intro A SIP User Agent API for C/C++ |
| 66 | * |
| 67 | * PJSUA API is very high level API for constructing SIP multimedia user agent |
| 68 | * applications. It wraps together the signaling and media functionalities |
| 69 | * into an easy to use call API, provides account management, buddy |
| 70 | * management, presence, instant messaging, along with multimedia |
| 71 | * features such as conferencing, file streaming, local playback, |
| 72 | * voice recording, and so on. |
| 73 | * |
| 74 | * @subsection pjsua_for_c_cpp C/C++ Binding |
| 75 | * Application must link with <b>pjsua-lib</b> to use this API. In addition, |
| 76 | * this library depends on the following libraries: |
| 77 | * - <b>pjsip-ua</b>, |
| 78 | * - <b>pjsip-simple</b>, |
| 79 | * - <b>pjsip-core</b>, |
| 80 | * - <b>pjmedia</b>, |
| 81 | * - <b>pjmedia-codec</b>, |
| 82 | * - <b>pjlib-util</b>, and |
| 83 | * - <b>pjlib</b>, |
| 84 | * |
| 85 | * so application must also link with these libraries as well. For more |
| 86 | * information, please refer to |
| 87 | * <A HREF="http://www.pjsip.org/using.htm">Getting Started with PJSIP</A> |
| 88 | * page. |
| 89 | * |
| 90 | * @section pjsua_samples |
| 91 | * |
| 92 | * Few samples are provided: |
| 93 | * |
| 94 | - @ref page_pjsip_sample_simple_pjsuaua_c\n |
| 95 | Very simple SIP User Agent with registration, call, and media, using |
| 96 | PJSUA-API, all in under 200 lines of code. |
| 97 | |
| 98 | - @ref page_pjsip_samples_pjsua\n |
| 99 | This is the reference implementation for PJSIP and PJMEDIA. |
| 100 | PJSUA is a console based application, designed to be simple enough |
| 101 | to be readble, but powerful enough to demonstrate all features |
| 102 | available in PJSIP and PJMEDIA.\n |
| 103 | |
| 104 | * @section root_using_pjsua_lib Using PJSUA API |
| 105 | * |
| 106 | * Please refer to @ref PJSUA_LIB_BASE on how to create and initialize the API. |
| 107 | * And then see the Modules on the bottom of this page for more information |
| 108 | * about specific subject. |
| 109 | */ |
| 110 | |
| 111 | |
| 112 | |
| 113 | /***************************************************************************** |
| 114 | * BASE API |
| 115 | */ |
| 116 | |
| 117 | /** |
| 118 | * @defgroup PJSUA_LIB_BASE PJSUA-API Basic API |
| 119 | * @ingroup PJSUA_LIB |
| 120 | * @brief Basic application creation/initialization, logging configuration, etc. |
| 121 | * @{ |
| 122 | * |
| 123 | * The base PJSUA API controls PJSUA creation, initialization, and startup, and |
| 124 | * also provides various auxiliary functions. |
| 125 | * |
| 126 | * @section using_pjsua_lib Using PJSUA Library |
| 127 | * |
| 128 | * @subsection creating_pjsua_lib Creating PJSUA |
| 129 | * |
| 130 | * Before anything else, application must create PJSUA by calling |
| 131 | * #pjsua_create(). |
| 132 | * This, among other things, will initialize PJLIB, which is crucial before |
| 133 | * any PJLIB functions can be called, PJLIB-UTIL, and create a SIP endpoint. |
| 134 | * |
| 135 | * After this function is called, application can create a memory pool (with |
| 136 | * #pjsua_pool_create()) and read configurations from command line or file to |
| 137 | * build the settings to initialize PJSUA below. |
| 138 | * |
| 139 | * @subsection init_pjsua_lib Initializing PJSUA |
| 140 | * |
| 141 | * After PJSUA is created, application can initialize PJSUA by calling |
| 142 | * #pjsua_init(). This function takes several optional configuration settings |
| 143 | * in the argument, if application wants to set them. |
| 144 | * |
| 145 | * @subsubsection init_pjsua_lib_c_cpp PJSUA-LIB Initialization (in C) |
| 146 | * Sample code to initialize PJSUA in C code: |
| 147 | \code |
| 148 | |
| 149 | #include <pjsua-lib/pjsua.h> |
| 150 | |
| 151 | #define THIS_FILE __FILE__ |
| 152 | |
| 153 | static pj_status_t app_init(void) |
| 154 | { |
| 155 | pjsua_config ua_cfg; |
| 156 | pjsua_logging_config log_cfg; |
| 157 | pjsua_media_config media_cfg; |
| 158 | pj_status_t status; |
| 159 | |
| 160 | // Must create pjsua before anything else! |
| 161 | status = pjsua_create(); |
| 162 | if (status != PJ_SUCCESS) { |
| 163 | pjsua_perror(THIS_FILE, "Error initializing pjsua", status); |
| 164 | return status; |
| 165 | } |
| 166 | |
| 167 | // Initialize configs with default settings. |
| 168 | pjsua_config_default(&ua_cfg); |
| 169 | pjsua_logging_config_default(&log_cfg); |
| 170 | pjsua_media_config_default(&media_cfg); |
| 171 | |
| 172 | // At the very least, application would want to override |
| 173 | // the call callbacks in pjsua_config: |
| 174 | ua_cfg.cb.on_incoming_call = ... |
| 175 | ua_cfg.cb.on_call_state = .. |
| 176 | ... |
| 177 | |
| 178 | // Customize other settings (or initialize them from application specific |
| 179 | // configuration file): |
| 180 | ... |
| 181 | |
| 182 | // Initialize pjsua |
| 183 | status = pjsua_init(&ua_cfg, &log_cfg, &media_cfg); |
| 184 | if (status != PJ_SUCCESS) { |
| 185 | pjsua_perror(THIS_FILE, "Error initializing pjsua", status); |
| 186 | return status; |
| 187 | } |
| 188 | . |
| 189 | ... |
| 190 | } |
| 191 | \endcode |
| 192 | * |
| 193 | * |
| 194 | |
| 195 | |
| 196 | * @subsection other_init_pjsua_lib Other Initialization |
| 197 | * |
| 198 | * After PJSUA is initialized with #pjsua_init(), application will normally |
| 199 | * need/want to perform the following tasks: |
| 200 | * |
| 201 | * - create SIP transport with #pjsua_transport_create(). Application would |
| 202 | * to call #pjsua_transport_create() for each transport types that it |
| 203 | * wants to support (for example, UDP, TCP, and TLS). Please see |
| 204 | * @ref PJSUA_LIB_TRANSPORT section for more info. |
| 205 | * - create one or more SIP accounts with #pjsua_acc_add() or |
| 206 | * #pjsua_acc_add_local(). The SIP account is used for registering with |
| 207 | * the SIP server, if any. Please see @ref PJSUA_LIB_ACC for more info. |
| 208 | * - add one or more buddies with #pjsua_buddy_add(). Please see |
| 209 | * @ref PJSUA_LIB_BUDDY section for more info. |
| 210 | * - optionally configure the sound device, codec settings, and other |
| 211 | * media settings. Please see @ref PJSUA_LIB_MEDIA for more info. |
| 212 | * |
| 213 | * |
| 214 | * @subsection starting_pjsua_lib Starting PJSUA |
| 215 | * |
| 216 | * After all initializations have been done, application must call |
| 217 | * #pjsua_start() to start PJSUA. This function will check that all settings |
| 218 | * have been properly configured, and apply default settings when they haven't, |
| 219 | * or report error status when it is unable to recover from missing settings. |
| 220 | * |
| 221 | * Most settings can be changed during run-time. For example, application |
| 222 | * may add, modify, or delete accounts, buddies, or change media settings |
| 223 | * during run-time. |
| 224 | * |
| 225 | * @subsubsection starting_pjsua_lib_c C Example for Starting PJSUA |
| 226 | * Sample code: |
| 227 | \code |
| 228 | static pj_status_t app_run(void) |
| 229 | { |
| 230 | pj_status_t status; |
| 231 | |
| 232 | // Start pjsua |
| 233 | status = pjsua_start(); |
| 234 | if (status != PJ_SUCCESS) { |
| 235 | pjsua_destroy(); |
| 236 | pjsua_perror(THIS_FILE, "Error starting pjsua", status); |
| 237 | return status; |
| 238 | } |
| 239 | |
| 240 | // Run application loop |
| 241 | while (1) { |
| 242 | char choice[10]; |
| 243 | |
| 244 | printf("Select menu: "); |
| 245 | fgets(choice, sizeof(choice), stdin); |
| 246 | ... |
| 247 | } |
| 248 | } |
| 249 | \endcode |
| 250 | |
| 251 | */ |
| 252 | |
| 253 | /** Constant to identify invalid ID for all sorts of IDs. */ |
| 254 | #define PJSUA_INVALID_ID (-1) |
| 255 | |
| 256 | /** Disabled features temporarily for media reorganization */ |
| 257 | #define DISABLED_FOR_TICKET_1185 0 |
| 258 | |
| 259 | /** Call identification */ |
| 260 | typedef int pjsua_call_id; |
| 261 | |
| 262 | /** Account identification */ |
| 263 | typedef int pjsua_acc_id; |
| 264 | |
| 265 | /** Buddy identification */ |
| 266 | typedef int pjsua_buddy_id; |
| 267 | |
| 268 | /** File player identification */ |
| 269 | typedef int pjsua_player_id; |
| 270 | |
| 271 | /** File recorder identification */ |
| 272 | typedef int pjsua_recorder_id; |
| 273 | |
| 274 | /** Conference port identification */ |
| 275 | typedef int pjsua_conf_port_id; |
| 276 | |
| 277 | /** Opaque declaration for server side presence subscription */ |
| 278 | typedef struct pjsua_srv_pres pjsua_srv_pres; |
| 279 | |
| 280 | /** Forward declaration for pjsua_msg_data */ |
| 281 | typedef struct pjsua_msg_data pjsua_msg_data; |
| 282 | |
| 283 | |
| 284 | /** |
| 285 | * Maximum proxies in account. |
| 286 | */ |
| 287 | #ifndef PJSUA_ACC_MAX_PROXIES |
| 288 | # define PJSUA_ACC_MAX_PROXIES 8 |
| 289 | #endif |
| 290 | |
| 291 | /** |
| 292 | * Default value of SRTP mode usage. Valid values are PJMEDIA_SRTP_DISABLED, |
| 293 | * PJMEDIA_SRTP_OPTIONAL, and PJMEDIA_SRTP_MANDATORY. |
| 294 | */ |
| 295 | #ifndef PJSUA_DEFAULT_USE_SRTP |
| 296 | #define PJSUA_DEFAULT_USE_SRTP PJMEDIA_SRTP_DISABLED |
| 297 | #endif |
| 298 | |
| 299 | /** |
| 300 | * Default value of secure signaling requirement for SRTP. |
| 301 | * Valid values are: |
| 302 | * 0: SRTP does not require secure signaling |
| 303 | * 1: SRTP requires secure transport such as TLS |
| 304 | * 2: SRTP requires secure end-to-end transport (SIPS) |
| 305 | */ |
| 306 | #ifndef PJSUA_DEFAULT_SRTP_SECURE_SIGNALING |
| 307 | #define PJSUA_DEFAULT_SRTP_SECURE_SIGNALING 1 |
| 308 | #endif |
| 309 | |
| 310 | /** |
| 311 | * Controls whether PJSUA-LIB should add ICE media feature tag |
| 312 | * parameter (the ";+sip.ice" parameter) to Contact header if ICE |
| 313 | * is enabled in the config. |
| 314 | * |
| 315 | * Default: 1 |
| 316 | */ |
| 317 | #ifndef PJSUA_ADD_ICE_TAGS |
| 318 | # define PJSUA_ADD_ICE_TAGS 1 |
| 319 | #endif |
| 320 | |
| 321 | /** |
| 322 | * Timeout value used to acquire mutex lock on a particular call. |
| 323 | * |
| 324 | * Default: 2000 ms |
| 325 | */ |
| 326 | #ifndef PJSUA_ACQUIRE_CALL_TIMEOUT |
| 327 | # define PJSUA_ACQUIRE_CALL_TIMEOUT 2000 |
| 328 | #endif |
| 329 | |
| 330 | /** |
| 331 | * Is video enabled. |
| 332 | */ |
| 333 | #ifndef PJSUA_HAS_VIDEO |
| 334 | # define PJSUA_HAS_VIDEO PJMEDIA_HAS_VIDEO |
| 335 | #endif |
| 336 | |
| 337 | |
| 338 | /** |
| 339 | * Interval between two keyframe requests, in milliseconds. |
| 340 | * |
| 341 | * Default: 3000 ms |
| 342 | */ |
| 343 | #ifndef PJSUA_VID_REQ_KEYFRAME_INTERVAL |
| 344 | # define PJSUA_VID_REQ_KEYFRAME_INTERVAL 3000 |
| 345 | #endif |
| 346 | |
| 347 | |
| 348 | /** |
| 349 | * This enumeration represents pjsua state. |
| 350 | */ |
| 351 | typedef enum pjsua_state |
| 352 | { |
| 353 | /** |
| 354 | * The library has not been initialized. |
| 355 | */ |
| 356 | PJSUA_STATE_NULL, |
| 357 | |
| 358 | /** |
| 359 | * After pjsua_create() is called but before pjsua_init() is called. |
| 360 | */ |
| 361 | PJSUA_STATE_CREATED, |
| 362 | |
| 363 | /** |
| 364 | * After pjsua_init() is called but before pjsua_start() is called. |
| 365 | */ |
| 366 | PJSUA_STATE_INIT, |
| 367 | |
| 368 | /** |
| 369 | * After pjsua_start() is called but before everything is running. |
| 370 | */ |
| 371 | PJSUA_STATE_STARTING, |
| 372 | |
| 373 | /** |
| 374 | * After pjsua_start() is called and before pjsua_destroy() is called. |
| 375 | */ |
| 376 | PJSUA_STATE_RUNNING, |
| 377 | |
| 378 | /** |
| 379 | * After pjsua_destroy() is called but before the function returns. |
| 380 | */ |
| 381 | PJSUA_STATE_CLOSING |
| 382 | |
| 383 | } pjsua_state; |
| 384 | |
| 385 | |
| 386 | /** |
| 387 | * Logging configuration, which can be (optionally) specified when calling |
| 388 | * #pjsua_init(). Application must call #pjsua_logging_config_default() to |
| 389 | * initialize this structure with the default values. |
| 390 | */ |
| 391 | typedef struct pjsua_logging_config |
| 392 | { |
| 393 | /** |
| 394 | * Log incoming and outgoing SIP message? Yes! |
| 395 | */ |
| 396 | pj_bool_t msg_logging; |
| 397 | |
| 398 | /** |
| 399 | * Input verbosity level. Value 5 is reasonable. |
| 400 | */ |
| 401 | unsigned level; |
| 402 | |
| 403 | /** |
| 404 | * Verbosity level for console. Value 4 is reasonable. |
| 405 | */ |
| 406 | unsigned console_level; |
| 407 | |
| 408 | /** |
| 409 | * Log decoration. |
| 410 | */ |
| 411 | unsigned decor; |
| 412 | |
| 413 | /** |
| 414 | * Optional log filename. |
| 415 | */ |
| 416 | pj_str_t log_filename; |
| 417 | |
| 418 | /** |
| 419 | * Additional flags to be given to #pj_file_open() when opening |
| 420 | * the log file. By default, the flag is PJ_O_WRONLY. Application |
| 421 | * may set PJ_O_APPEND here so that logs are appended to existing |
| 422 | * file instead of overwriting it. |
| 423 | * |
| 424 | * Default is 0. |
| 425 | */ |
| 426 | unsigned log_file_flags; |
| 427 | |
| 428 | /** |
| 429 | * Optional callback function to be called to write log to |
| 430 | * application specific device. This function will be called for |
| 431 | * log messages on input verbosity level. |
| 432 | */ |
| 433 | void (*cb)(int level, const char *data, int len); |
| 434 | |
| 435 | |
| 436 | } pjsua_logging_config; |
| 437 | |
| 438 | |
| 439 | /** |
| 440 | * Use this function to initialize logging config. |
| 441 | * |
| 442 | * @param cfg The logging config to be initialized. |
| 443 | */ |
| 444 | PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg); |
| 445 | |
| 446 | |
| 447 | /** |
| 448 | * Use this function to duplicate logging config. |
| 449 | * |
| 450 | * @param pool Pool to use. |
| 451 | * @param dst Destination config. |
| 452 | * @param src Source config. |
| 453 | */ |
| 454 | PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool, |
| 455 | pjsua_logging_config *dst, |
| 456 | const pjsua_logging_config *src); |
| 457 | |
| 458 | |
| 459 | /** |
| 460 | * Structure to be passed on MWI callback. |
| 461 | */ |
| 462 | typedef struct pjsua_mwi_info |
| 463 | { |
| 464 | pjsip_evsub *evsub; /**< Event subscription session, for |
| 465 | reference. */ |
| 466 | pjsip_rx_data *rdata; /**< The received NOTIFY request. */ |
| 467 | } pjsua_mwi_info; |
| 468 | |
| 469 | |
| 470 | /** |
| 471 | * Structure to be passed on registration callback. |
| 472 | */ |
| 473 | typedef struct pjsua_reg_info |
| 474 | { |
| 475 | struct pjsip_regc_cbparam *cbparam; /**< Parameters returned by |
| 476 | registration callback. */ |
| 477 | } pjsua_reg_info; |
| 478 | |
| 479 | |
| 480 | /** |
| 481 | * Enumeration of media transport state types. |
| 482 | */ |
| 483 | typedef enum pjsua_med_tp_st |
| 484 | { |
| 485 | /** Null, this is the state before media transport is created. */ |
| 486 | PJSUA_MED_TP_NULL, |
| 487 | |
| 488 | /** |
| 489 | * Just before media transport is created, which can finish |
| 490 | * asynchronously later. |
| 491 | */ |
| 492 | PJSUA_MED_TP_CREATING, |
| 493 | |
| 494 | /** Media transport creation is completed, but not initialized yet. */ |
| 495 | PJSUA_MED_TP_IDLE, |
| 496 | |
| 497 | /** Initialized (media_create() has been called). */ |
| 498 | PJSUA_MED_TP_INIT, |
| 499 | |
| 500 | /** Running (media_start() has been called). */ |
| 501 | PJSUA_MED_TP_RUNNING, |
| 502 | |
| 503 | /** Disabled (transport is initialized, but media is being disabled). */ |
| 504 | PJSUA_MED_TP_DISABLED |
| 505 | |
| 506 | } pjsua_med_tp_st; |
| 507 | |
| 508 | |
| 509 | /** |
| 510 | * Structure to be passed on media transport state callback. |
| 511 | */ |
| 512 | typedef struct pjsua_med_tp_state_info |
| 513 | { |
| 514 | /** |
| 515 | * The media index. |
| 516 | */ |
| 517 | unsigned med_idx; |
| 518 | |
| 519 | /** |
| 520 | * The media transport state |
| 521 | */ |
| 522 | pjsua_med_tp_st state; |
| 523 | |
| 524 | /** |
| 525 | * The last error code related to the media transport state. |
| 526 | */ |
| 527 | pj_status_t status; |
| 528 | |
| 529 | /** |
| 530 | * Optional SIP error code. |
| 531 | */ |
| 532 | int sip_err_code; |
| 533 | |
| 534 | /** |
| 535 | * Optional extended info, the content is specific for each transport type. |
| 536 | */ |
| 537 | void *ext_info; |
| 538 | |
| 539 | } pjsua_med_tp_state_info; |
| 540 | |
| 541 | |
| 542 | /** |
| 543 | * Type of callback to be called when media transport state is changed. |
| 544 | * |
| 545 | * @param call_id The call ID. |
| 546 | * @param info The media transport state info. |
| 547 | * |
| 548 | * @return The callback must return PJ_SUCCESS at the moment. |
| 549 | */ |
| 550 | typedef pj_status_t |
| 551 | (*pjsua_med_tp_state_cb)(pjsua_call_id call_id, |
| 552 | const pjsua_med_tp_state_info *info); |
| 553 | |
| 554 | |
| 555 | /** |
| 556 | * This enumeration specifies the options for custom media transport creation. |
| 557 | */ |
| 558 | typedef enum pjsua_create_media_transport_flag |
| 559 | { |
| 560 | /** |
| 561 | * This flag indicates that the media transport must also close its |
| 562 | * "member" or "child" transport when pjmedia_transport_close() is |
| 563 | * called. If this flag is not specified, then the media transport |
| 564 | * must not call pjmedia_transport_close() of its member transport. |
| 565 | */ |
| 566 | PJSUA_MED_TP_CLOSE_MEMBER = 1 |
| 567 | |
| 568 | } pjsua_create_media_transport_flag; |
| 569 | |
| 570 | |
| 571 | /** |
Alexandre Lision | 94f06ba | 2013-12-09 16:28:33 -0500 | [diff] [blame] | 572 | * This enumeration specifies the contact rewrite method. |
| 573 | */ |
| 574 | typedef enum pjsua_contact_rewrite_method |
| 575 | { |
| 576 | /** |
| 577 | * The Contact update will be done by sending unregistration |
| 578 | * to the currently registered Contact, while simultaneously sending new |
| 579 | * registration (with different Call-ID) for the updated Contact. |
| 580 | */ |
| 581 | PJSUA_CONTACT_REWRITE_UNREGISTER = 1, |
| 582 | |
| 583 | /** |
| 584 | * The Contact update will be done in a single, current |
| 585 | * registration session, by removing the current binding (by setting its |
| 586 | * Contact's expires parameter to zero) and adding a new Contact binding, |
| 587 | * all done in a single request. |
| 588 | */ |
| 589 | PJSUA_CONTACT_REWRITE_NO_UNREG = 2, |
| 590 | |
| 591 | /** |
| 592 | * The Contact update will be done when receiving any registration final |
| 593 | * response. If this flag is not specified, contact update will only be |
| 594 | * done upon receiving 2xx response. This flag MUST be used with |
| 595 | * PJSUA_CONTACT_REWRITE_UNREGISTER or PJSUA_CONTACT_REWRITE_NO_UNREG |
| 596 | * above to specify how the Contact update should be performed when |
| 597 | * receiving 2xx response. |
| 598 | */ |
| 599 | PJSUA_CONTACT_REWRITE_ALWAYS_UPDATE = 4 |
| 600 | |
| 601 | } pjsua_contact_rewrite_method; |
| 602 | |
| 603 | |
| 604 | /** |
Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 605 | * Call settings. |
| 606 | */ |
| 607 | typedef struct pjsua_call_setting |
| 608 | { |
| 609 | /** |
| 610 | * Bitmask of #pjsua_call_flag constants. |
| 611 | * |
| 612 | * Default: 0 |
| 613 | */ |
| 614 | unsigned flag; |
| 615 | |
| 616 | /** |
| 617 | * This flag controls what methods to request keyframe are allowed on |
| 618 | * the call. Value is bitmask of #pjsua_vid_req_keyframe_method. |
| 619 | */ |
| 620 | unsigned req_keyframe_method; |
| 621 | |
| 622 | /** |
| 623 | * Number of simultaneous active audio streams for this call. Setting |
| 624 | * this to zero will disable audio in this call. |
| 625 | * |
| 626 | * Default: 1 |
| 627 | */ |
| 628 | unsigned aud_cnt; |
| 629 | |
| 630 | /** |
| 631 | * Number of simultaneous active video streams for this call. Setting |
| 632 | * this to zero will disable video in this call. |
| 633 | * |
| 634 | * Default: 1 (if video feature is enabled, otherwise it is zero) |
| 635 | */ |
| 636 | unsigned vid_cnt; |
| 637 | |
| 638 | } pjsua_call_setting; |
| 639 | |
| 640 | |
| 641 | /** |
| 642 | * This structure describes application callback to receive various event |
| 643 | * notification from PJSUA-API. All of these callbacks are OPTIONAL, |
| 644 | * although definitely application would want to implement some of |
| 645 | * the important callbacks (such as \a on_incoming_call). |
| 646 | */ |
| 647 | typedef struct pjsua_callback |
| 648 | { |
| 649 | /** |
| 650 | * Notify application when call state has changed. |
| 651 | * Application may then query the call info to get the |
| 652 | * detail call states by calling pjsua_call_get_info() function. |
| 653 | * |
| 654 | * @param call_id The call index. |
| 655 | * @param e Event which causes the call state to change. |
| 656 | */ |
| 657 | void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e); |
| 658 | |
| 659 | /** |
| 660 | * Notify application on incoming call. |
| 661 | * |
| 662 | * @param acc_id The account which match the incoming call. |
| 663 | * @param call_id The call id that has just been created for |
| 664 | * the call. |
| 665 | * @param rdata The incoming INVITE request. |
| 666 | */ |
| 667 | void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id, |
| 668 | pjsip_rx_data *rdata); |
| 669 | |
| 670 | /** |
| 671 | * This is a general notification callback which is called whenever |
| 672 | * a transaction within the call has changed state. Application can |
| 673 | * implement this callback for example to monitor the state of |
| 674 | * outgoing requests, or to answer unhandled incoming requests |
| 675 | * (such as INFO) with a final response. |
| 676 | * |
| 677 | * @param call_id Call identification. |
| 678 | * @param tsx The transaction which has changed state. |
| 679 | * @param e Transaction event that caused the state change. |
| 680 | */ |
| 681 | void (*on_call_tsx_state)(pjsua_call_id call_id, |
| 682 | pjsip_transaction *tsx, |
| 683 | pjsip_event *e); |
| 684 | |
| 685 | /** |
| 686 | * Notify application when media state in the call has changed. |
| 687 | * Normal application would need to implement this callback, e.g. |
| 688 | * to connect the call's media to sound device. When ICE is used, |
| 689 | * this callback will also be called to report ICE negotiation |
| 690 | * failure. |
| 691 | * |
| 692 | * @param call_id The call index. |
| 693 | */ |
| 694 | void (*on_call_media_state)(pjsua_call_id call_id); |
| 695 | |
| 696 | |
| 697 | /** |
| 698 | * Notify application when a call has just created a local SDP (for |
| 699 | * initial or subsequent SDP offer/answer). Application can implement |
| 700 | * this callback to modify the SDP, before it is being sent and/or |
| 701 | * negotiated with remote SDP, for example to apply per account/call |
| 702 | * basis codecs priority or to add custom/proprietary SDP attributes. |
| 703 | * |
| 704 | * @param call_id The call index. |
| 705 | * @param sdp The SDP has just been created. |
| 706 | * @param pool The pool instance, application should use this pool |
| 707 | * to modify the SDP. |
| 708 | * @param rem_sdp The remote SDP, will be NULL if local is SDP offerer. |
| 709 | */ |
| 710 | void (*on_call_sdp_created)(pjsua_call_id call_id, |
| 711 | pjmedia_sdp_session *sdp, |
| 712 | pj_pool_t *pool, |
| 713 | const pjmedia_sdp_session *rem_sdp); |
| 714 | |
| 715 | |
| 716 | /** |
| 717 | * Notify application when media session is created and before it is |
| 718 | * registered to the conference bridge. Application may return different |
| 719 | * media port if it has added media processing port to the stream. This |
| 720 | * media port then will be added to the conference bridge instead. |
| 721 | * |
| 722 | * @param call_id Call identification. |
| 723 | * @param strm Media stream. |
| 724 | * @param stream_idx Stream index in the media session. |
| 725 | * @param p_port On input, it specifies the media port of the |
| 726 | * stream. Application may modify this pointer to |
| 727 | * point to different media port to be registered |
| 728 | * to the conference bridge. |
| 729 | */ |
| 730 | void (*on_stream_created)(pjsua_call_id call_id, |
| 731 | pjmedia_stream *strm, |
| 732 | unsigned stream_idx, |
| 733 | pjmedia_port **p_port); |
| 734 | |
| 735 | /** |
| 736 | * Notify application when media session has been unregistered from the |
| 737 | * conference bridge and about to be destroyed. |
| 738 | * |
| 739 | * @param call_id Call identification. |
| 740 | * @param strm Media stream. |
| 741 | * @param stream_idx Stream index in the media session. |
| 742 | */ |
| 743 | void (*on_stream_destroyed)(pjsua_call_id call_id, |
| 744 | pjmedia_stream *strm, |
| 745 | unsigned stream_idx); |
| 746 | |
| 747 | /** |
| 748 | * Notify application upon incoming DTMF digits. |
| 749 | * |
| 750 | * @param call_id The call index. |
| 751 | * @param digit DTMF ASCII digit. |
| 752 | */ |
| 753 | void (*on_dtmf_digit)(pjsua_call_id call_id, int digit); |
| 754 | |
| 755 | /** |
| 756 | * Notify application on call being transfered (i.e. REFER is received). |
| 757 | * Application can decide to accept/reject transfer request |
| 758 | * by setting the code (default is 202). When this callback |
| 759 | * is not defined, the default behavior is to accept the |
| 760 | * transfer. See also on_call_transfer_request2() callback for |
| 761 | * the version with \a pjsua_call_setting in the argument list. |
| 762 | * |
| 763 | * @param call_id The call index. |
| 764 | * @param dst The destination where the call will be |
| 765 | * transfered to. |
| 766 | * @param code Status code to be returned for the call transfer |
| 767 | * request. On input, it contains status code 200. |
| 768 | */ |
| 769 | void (*on_call_transfer_request)(pjsua_call_id call_id, |
| 770 | const pj_str_t *dst, |
| 771 | pjsip_status_code *code); |
| 772 | |
| 773 | /** |
| 774 | * Notify application on call being transfered (i.e. REFER is received). |
| 775 | * Application can decide to accept/reject transfer request |
| 776 | * by setting the code (default is 202). When this callback |
| 777 | * is not defined, the default behavior is to accept the |
| 778 | * transfer. |
| 779 | * |
| 780 | * @param call_id The call index. |
| 781 | * @param dst The destination where the call will be |
| 782 | * transfered to. |
| 783 | * @param code Status code to be returned for the call transfer |
| 784 | * request. On input, it contains status code 200. |
| 785 | * @param opt The current call setting, application can update |
| 786 | * this setting for the call being transfered. |
| 787 | */ |
| 788 | void (*on_call_transfer_request2)(pjsua_call_id call_id, |
| 789 | const pj_str_t *dst, |
| 790 | pjsip_status_code *code, |
| 791 | pjsua_call_setting *opt); |
| 792 | |
| 793 | /** |
| 794 | * Notify application of the status of previously sent call |
| 795 | * transfer request. Application can monitor the status of the |
| 796 | * call transfer request, for example to decide whether to |
| 797 | * terminate existing call. |
| 798 | * |
| 799 | * @param call_id Call ID. |
| 800 | * @param st_code Status progress of the transfer request. |
| 801 | * @param st_text Status progress text. |
| 802 | * @param final If non-zero, no further notification will |
| 803 | * be reported. The st_code specified in |
| 804 | * this callback is the final status. |
| 805 | * @param p_cont Initially will be set to non-zero, application |
| 806 | * can set this to FALSE if it no longer wants |
| 807 | * to receie further notification (for example, |
| 808 | * after it hangs up the call). |
| 809 | */ |
| 810 | void (*on_call_transfer_status)(pjsua_call_id call_id, |
| 811 | int st_code, |
| 812 | const pj_str_t *st_text, |
| 813 | pj_bool_t final, |
| 814 | pj_bool_t *p_cont); |
| 815 | |
| 816 | /** |
| 817 | * Notify application about incoming INVITE with Replaces header. |
| 818 | * Application may reject the request by setting non-2xx code. |
| 819 | * See also on_call_replace_request2() callback for the version |
| 820 | * with \a pjsua_call_setting in the argument list. |
| 821 | * |
| 822 | * @param call_id The call ID to be replaced. |
| 823 | * @param rdata The incoming INVITE request to replace the call. |
| 824 | * @param st_code Status code to be set by application. Application |
| 825 | * should only return a final status (200-699). |
| 826 | * @param st_text Optional status text to be set by application. |
| 827 | */ |
| 828 | void (*on_call_replace_request)(pjsua_call_id call_id, |
| 829 | pjsip_rx_data *rdata, |
| 830 | int *st_code, |
| 831 | pj_str_t *st_text); |
| 832 | |
| 833 | /** |
| 834 | * Notify application about incoming INVITE with Replaces header. |
| 835 | * Application may reject the request by setting non-2xx code. |
| 836 | * |
| 837 | * @param call_id The call ID to be replaced. |
| 838 | * @param rdata The incoming INVITE request to replace the call. |
| 839 | * @param st_code Status code to be set by application. Application |
| 840 | * should only return a final status (200-699). |
| 841 | * @param st_text Optional status text to be set by application. |
| 842 | * @param opt The current call setting, application can update |
| 843 | * this setting for the call being replaced. |
| 844 | */ |
| 845 | void (*on_call_replace_request2)(pjsua_call_id call_id, |
| 846 | pjsip_rx_data *rdata, |
| 847 | int *st_code, |
| 848 | pj_str_t *st_text, |
| 849 | pjsua_call_setting *opt); |
| 850 | |
| 851 | /** |
| 852 | * Notify application that an existing call has been replaced with |
| 853 | * a new call. This happens when PJSUA-API receives incoming INVITE |
| 854 | * request with Replaces header. |
| 855 | * |
| 856 | * After this callback is called, normally PJSUA-API will disconnect |
| 857 | * \a old_call_id and establish \a new_call_id. |
| 858 | * |
| 859 | * @param old_call_id Existing call which to be replaced with the |
| 860 | * new call. |
| 861 | * @param new_call_id The new call. |
| 862 | * @param rdata The incoming INVITE with Replaces request. |
| 863 | */ |
| 864 | void (*on_call_replaced)(pjsua_call_id old_call_id, |
| 865 | pjsua_call_id new_call_id); |
| 866 | |
| 867 | |
| 868 | /** |
| 869 | * Notify application when call has received new offer from remote |
| 870 | * (i.e. re-INVITE/UPDATE with SDP is received). Application can |
| 871 | * decide to accept/reject the offer by setting the code (default |
| 872 | * is 200). If the offer is accepted, application can update the |
| 873 | * call setting to be applied in the answer. When this callback is |
| 874 | * not defined, the default behavior is to accept the offer using |
| 875 | * current call setting. |
| 876 | * |
| 877 | * @param call_id The call index. |
| 878 | * @param offer The new offer received. |
| 879 | * @param reserved Reserved param, currently not used. |
| 880 | * @param code Status code to be returned for answering the |
| 881 | * offer. On input, it contains status code 200. |
| 882 | * Currently, valid values are only 200 and 488. |
| 883 | * @param opt The current call setting, application can update |
| 884 | * this setting for answering the offer. |
| 885 | */ |
| 886 | void (*on_call_rx_offer)(pjsua_call_id call_id, |
| 887 | const pjmedia_sdp_session *offer, |
| 888 | void *reserved, |
| 889 | pjsip_status_code *code, |
| 890 | pjsua_call_setting *opt); |
| 891 | |
| 892 | /** |
| 893 | * Notify application when registration or unregistration has been |
| 894 | * initiated. Note that this only notifies the initial registration |
| 895 | * and unregistration. Once registration session is active, subsequent |
| 896 | * refresh will not cause this callback to be called. |
| 897 | * |
| 898 | * @param acc_id The account ID. |
| 899 | * @param renew Non-zero for registration and zero for |
| 900 | * unregistration. |
| 901 | */ |
| 902 | void (*on_reg_started)(pjsua_acc_id acc_id, pj_bool_t renew); |
| 903 | |
| 904 | /** |
| 905 | * Notify application when registration status has changed. |
| 906 | * Application may then query the account info to get the |
| 907 | * registration details. |
| 908 | * |
| 909 | * @param acc_id The account ID. |
| 910 | */ |
| 911 | void (*on_reg_state)(pjsua_acc_id acc_id); |
| 912 | |
| 913 | /** |
| 914 | * Notify application when registration status has changed. |
| 915 | * Application may inspect the registration info to get the |
| 916 | * registration status details. |
| 917 | * |
| 918 | * @param acc_id The account ID. |
| 919 | * @param info The registration info. |
| 920 | */ |
| 921 | void (*on_reg_state2)(pjsua_acc_id acc_id, pjsua_reg_info *info); |
| 922 | |
| 923 | /** |
| 924 | * Notification when incoming SUBSCRIBE request is received. Application |
| 925 | * may use this callback to authorize the incoming subscribe request |
| 926 | * (e.g. ask user permission if the request should be granted). |
| 927 | * |
| 928 | * If this callback is not implemented, all incoming presence subscription |
| 929 | * requests will be accepted. |
| 930 | * |
| 931 | * If this callback is implemented, application has several choices on |
| 932 | * what to do with the incoming request: |
| 933 | * - it may reject the request immediately by specifying non-200 class |
| 934 | * final response in the \a code argument. |
| 935 | * - it may immediately accept the request by specifying 200 as the |
| 936 | * \a code argument. This is the default value if application doesn't |
| 937 | * set any value to the \a code argument. In this case, the library |
| 938 | * will automatically send NOTIFY request upon returning from this |
| 939 | * callback. |
| 940 | * - it may delay the processing of the request, for example to request |
| 941 | * user permission whether to accept or reject the request. In this |
| 942 | * case, the application MUST set the \a code argument to 202, then |
| 943 | * IMMEDIATELY calls #pjsua_pres_notify() with state |
| 944 | * PJSIP_EVSUB_STATE_PENDING and later calls #pjsua_pres_notify() |
| 945 | * again to accept or reject the subscription request. |
| 946 | * |
| 947 | * Any \a code other than 200 and 202 will be treated as 200. |
| 948 | * |
| 949 | * Application MUST return from this callback immediately (e.g. it must |
| 950 | * not block in this callback while waiting for user confirmation). |
| 951 | * |
| 952 | * @param srv_pres Server presence subscription instance. If |
| 953 | * application delays the acceptance of the request, |
| 954 | * it will need to specify this object when calling |
| 955 | * #pjsua_pres_notify(). |
| 956 | * @param acc_id Account ID most appropriate for this request. |
| 957 | * @param buddy_id ID of the buddy matching the sender of the |
| 958 | * request, if any, or PJSUA_INVALID_ID if no |
| 959 | * matching buddy is found. |
| 960 | * @param from The From URI of the request. |
| 961 | * @param rdata The incoming request. |
| 962 | * @param code The status code to respond to the request. The |
| 963 | * default value is 200. Application may set this |
| 964 | * to other final status code to accept or reject |
| 965 | * the request. |
| 966 | * @param reason The reason phrase to respond to the request. |
| 967 | * @param msg_data If the application wants to send additional |
| 968 | * headers in the response, it can put it in this |
| 969 | * parameter. |
| 970 | */ |
| 971 | void (*on_incoming_subscribe)(pjsua_acc_id acc_id, |
| 972 | pjsua_srv_pres *srv_pres, |
| 973 | pjsua_buddy_id buddy_id, |
| 974 | const pj_str_t *from, |
| 975 | pjsip_rx_data *rdata, |
| 976 | pjsip_status_code *code, |
| 977 | pj_str_t *reason, |
| 978 | pjsua_msg_data *msg_data); |
| 979 | |
| 980 | /** |
| 981 | * Notification when server side subscription state has changed. |
| 982 | * This callback is optional as application normally does not need |
| 983 | * to do anything to maintain server side presence subscription. |
| 984 | * |
| 985 | * @param acc_id The account ID. |
| 986 | * @param srv_pres Server presence subscription object. |
| 987 | * @param remote_uri Remote URI string. |
| 988 | * @param state New subscription state. |
| 989 | * @param event PJSIP event that triggers the state change. |
| 990 | */ |
| 991 | void (*on_srv_subscribe_state)(pjsua_acc_id acc_id, |
| 992 | pjsua_srv_pres *srv_pres, |
| 993 | const pj_str_t *remote_uri, |
| 994 | pjsip_evsub_state state, |
| 995 | pjsip_event *event); |
| 996 | |
| 997 | /** |
| 998 | * Notify application when the buddy state has changed. |
| 999 | * Application may then query the buddy into to get the details. |
| 1000 | * |
| 1001 | * @param buddy_id The buddy id. |
| 1002 | */ |
| 1003 | void (*on_buddy_state)(pjsua_buddy_id buddy_id); |
| 1004 | |
| 1005 | |
| 1006 | /** |
| 1007 | * Notify application when the state of client subscription session |
| 1008 | * associated with a buddy has changed. Application may use this |
| 1009 | * callback to retrieve more detailed information about the state |
| 1010 | * changed event. |
| 1011 | * |
| 1012 | * @param buddy_id The buddy id. |
| 1013 | * @param sub Event subscription session. |
| 1014 | * @param event The event which triggers state change event. |
| 1015 | */ |
| 1016 | void (*on_buddy_evsub_state)(pjsua_buddy_id buddy_id, |
| 1017 | pjsip_evsub *sub, |
| 1018 | pjsip_event *event); |
| 1019 | |
| 1020 | /** |
| 1021 | * Notify application on incoming pager (i.e. MESSAGE request). |
| 1022 | * Argument call_id will be -1 if MESSAGE request is not related to an |
| 1023 | * existing call. |
| 1024 | * |
| 1025 | * See also \a on_pager2() callback for the version with \a pjsip_rx_data |
| 1026 | * passed as one of the argument. |
| 1027 | * |
| 1028 | * @param call_id Containts the ID of the call where the IM was |
| 1029 | * sent, or PJSUA_INVALID_ID if the IM was sent |
| 1030 | * outside call context. |
| 1031 | * @param from URI of the sender. |
| 1032 | * @param to URI of the destination message. |
| 1033 | * @param contact The Contact URI of the sender, if present. |
| 1034 | * @param mime_type MIME type of the message. |
| 1035 | * @param body The message content. |
| 1036 | */ |
| 1037 | void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from, |
| 1038 | const pj_str_t *to, const pj_str_t *contact, |
| 1039 | const pj_str_t *mime_type, const pj_str_t *body); |
| 1040 | |
| 1041 | /** |
| 1042 | * This is the alternative version of the \a on_pager() callback with |
| 1043 | * \a pjsip_rx_data argument. |
| 1044 | * |
| 1045 | * @param call_id Containts the ID of the call where the IM was |
| 1046 | * sent, or PJSUA_INVALID_ID if the IM was sent |
| 1047 | * outside call context. |
| 1048 | * @param from URI of the sender. |
| 1049 | * @param to URI of the destination message. |
| 1050 | * @param contact The Contact URI of the sender, if present. |
| 1051 | * @param mime_type MIME type of the message. |
| 1052 | * @param body The message content. |
| 1053 | * @param rdata The incoming MESSAGE request. |
| 1054 | * @param acc_id Account ID most suitable for this message. |
| 1055 | */ |
| 1056 | void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from, |
| 1057 | const pj_str_t *to, const pj_str_t *contact, |
| 1058 | const pj_str_t *mime_type, const pj_str_t *body, |
| 1059 | pjsip_rx_data *rdata, pjsua_acc_id acc_id); |
| 1060 | |
| 1061 | /** |
| 1062 | * Notify application about the delivery status of outgoing pager |
| 1063 | * request. See also on_pager_status2() callback for the version with |
| 1064 | * \a pjsip_rx_data in the argument list. |
| 1065 | * |
| 1066 | * @param call_id Containts the ID of the call where the IM was |
| 1067 | * sent, or PJSUA_INVALID_ID if the IM was sent |
| 1068 | * outside call context. |
| 1069 | * @param to Destination URI. |
| 1070 | * @param body Message body. |
| 1071 | * @param user_data Arbitrary data that was specified when sending |
| 1072 | * IM message. |
| 1073 | * @param status Delivery status. |
| 1074 | * @param reason Delivery status reason. |
| 1075 | */ |
| 1076 | void (*on_pager_status)(pjsua_call_id call_id, |
| 1077 | const pj_str_t *to, |
| 1078 | const pj_str_t *body, |
| 1079 | void *user_data, |
| 1080 | pjsip_status_code status, |
| 1081 | const pj_str_t *reason); |
| 1082 | |
| 1083 | /** |
| 1084 | * Notify application about the delivery status of outgoing pager |
| 1085 | * request. |
| 1086 | * |
| 1087 | * @param call_id Containts the ID of the call where the IM was |
| 1088 | * sent, or PJSUA_INVALID_ID if the IM was sent |
| 1089 | * outside call context. |
| 1090 | * @param to Destination URI. |
| 1091 | * @param body Message body. |
| 1092 | * @param user_data Arbitrary data that was specified when sending |
| 1093 | * IM message. |
| 1094 | * @param status Delivery status. |
| 1095 | * @param reason Delivery status reason. |
| 1096 | * @param tdata The original MESSAGE request. |
| 1097 | * @param rdata The incoming MESSAGE response, or NULL if the |
| 1098 | * message transaction fails because of time out |
| 1099 | * or transport error. |
| 1100 | * @param acc_id Account ID from this the instant message was |
| 1101 | * send. |
| 1102 | */ |
| 1103 | void (*on_pager_status2)(pjsua_call_id call_id, |
| 1104 | const pj_str_t *to, |
| 1105 | const pj_str_t *body, |
| 1106 | void *user_data, |
| 1107 | pjsip_status_code status, |
| 1108 | const pj_str_t *reason, |
| 1109 | pjsip_tx_data *tdata, |
| 1110 | pjsip_rx_data *rdata, |
| 1111 | pjsua_acc_id acc_id); |
| 1112 | |
| 1113 | /** |
| 1114 | * Notify application about typing indication. |
| 1115 | * |
| 1116 | * @param call_id Containts the ID of the call where the IM was |
| 1117 | * sent, or PJSUA_INVALID_ID if the IM was sent |
| 1118 | * outside call context. |
| 1119 | * @param from URI of the sender. |
| 1120 | * @param to URI of the destination message. |
| 1121 | * @param contact The Contact URI of the sender, if present. |
| 1122 | * @param is_typing Non-zero if peer is typing, or zero if peer |
| 1123 | * has stopped typing a message. |
| 1124 | */ |
| 1125 | void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from, |
| 1126 | const pj_str_t *to, const pj_str_t *contact, |
| 1127 | pj_bool_t is_typing); |
| 1128 | |
| 1129 | /** |
| 1130 | * Notify application about typing indication. |
| 1131 | * |
| 1132 | * @param call_id Containts the ID of the call where the IM was |
| 1133 | * sent, or PJSUA_INVALID_ID if the IM was sent |
| 1134 | * outside call context. |
| 1135 | * @param from URI of the sender. |
| 1136 | * @param to URI of the destination message. |
| 1137 | * @param contact The Contact URI of the sender, if present. |
| 1138 | * @param is_typing Non-zero if peer is typing, or zero if peer |
| 1139 | * has stopped typing a message. |
| 1140 | * @param rdata The received request. |
| 1141 | * @param acc_id Account ID most suitable for this message. |
| 1142 | */ |
| 1143 | void (*on_typing2)(pjsua_call_id call_id, const pj_str_t *from, |
| 1144 | const pj_str_t *to, const pj_str_t *contact, |
| 1145 | pj_bool_t is_typing, pjsip_rx_data *rdata, |
| 1146 | pjsua_acc_id acc_id); |
| 1147 | |
| 1148 | /** |
| 1149 | * Callback when the library has finished performing NAT type |
| 1150 | * detection. |
| 1151 | * |
| 1152 | * @param res NAT detection result. |
| 1153 | */ |
| 1154 | void (*on_nat_detect)(const pj_stun_nat_detect_result *res); |
| 1155 | |
| 1156 | /** |
| 1157 | * This callback is called when the call is about to resend the |
| 1158 | * INVITE request to the specified target, following the previously |
| 1159 | * received redirection response. |
| 1160 | * |
| 1161 | * Application may accept the redirection to the specified target, |
| 1162 | * reject this target only and make the session continue to try the next |
| 1163 | * target in the list if such target exists, stop the whole |
| 1164 | * redirection process altogether and cause the session to be |
| 1165 | * disconnected, or defer the decision to ask for user confirmation. |
| 1166 | * |
| 1167 | * This callback is optional. If this callback is not implemented, |
| 1168 | * the default behavior is to NOT follow the redirection response. |
| 1169 | * |
| 1170 | * @param call_id The call ID. |
| 1171 | * @param target The current target to be tried. |
| 1172 | * @param e The event that caused this callback to be called. |
| 1173 | * This could be the receipt of 3xx response, or |
| 1174 | * 4xx/5xx response received for the INVITE sent to |
| 1175 | * subsequent targets, or NULL if this callback is |
| 1176 | * called from within #pjsua_call_process_redirect() |
| 1177 | * context. |
| 1178 | * |
| 1179 | * @return Action to be performed for the target. Set this |
| 1180 | * parameter to one of the value below: |
| 1181 | * - PJSIP_REDIRECT_ACCEPT: immediately accept the |
| 1182 | * redirection. When set, the call will immediately |
| 1183 | * resend INVITE request to the target. |
| 1184 | * - PJSIP_REDIRECT_ACCEPT_REPLACE: immediately accept |
| 1185 | * the redirection and replace the To header with the |
| 1186 | * current target. When set, the call will immediately |
| 1187 | * resend INVITE request to the target. |
| 1188 | * - PJSIP_REDIRECT_REJECT: immediately reject this |
| 1189 | * target. The call will continue retrying with |
| 1190 | * next target if present, or disconnect the call |
| 1191 | * if there is no more target to try. |
| 1192 | * - PJSIP_REDIRECT_STOP: stop the whole redirection |
| 1193 | * process and immediately disconnect the call. The |
| 1194 | * on_call_state() callback will be called with |
| 1195 | * PJSIP_INV_STATE_DISCONNECTED state immediately |
| 1196 | * after this callback returns. |
| 1197 | * - PJSIP_REDIRECT_PENDING: set to this value if |
| 1198 | * no decision can be made immediately (for example |
| 1199 | * to request confirmation from user). Application |
| 1200 | * then MUST call #pjsua_call_process_redirect() |
| 1201 | * to either accept or reject the redirection upon |
| 1202 | * getting user decision. |
| 1203 | */ |
| 1204 | pjsip_redirect_op (*on_call_redirected)(pjsua_call_id call_id, |
| 1205 | const pjsip_uri *target, |
| 1206 | const pjsip_event *e); |
| 1207 | |
| 1208 | /** |
| 1209 | * This callback is called when message waiting indication subscription |
| 1210 | * state has changed. Application can then query the subscription state |
| 1211 | * by calling #pjsip_evsub_get_state(). |
| 1212 | * |
| 1213 | * @param acc_id The account ID. |
| 1214 | * @param evsub The subscription instance. |
| 1215 | */ |
| 1216 | void (*on_mwi_state)(pjsua_acc_id acc_id, pjsip_evsub *evsub); |
| 1217 | |
| 1218 | /** |
| 1219 | * This callback is called when a NOTIFY request for message summary / |
| 1220 | * message waiting indication is received. |
| 1221 | * |
| 1222 | * @param acc_id The account ID. |
| 1223 | * @param mwi_info Structure containing details of the event, |
| 1224 | * including the received NOTIFY request in the |
| 1225 | * \a rdata field. |
| 1226 | */ |
| 1227 | void (*on_mwi_info)(pjsua_acc_id acc_id, pjsua_mwi_info *mwi_info); |
| 1228 | |
| 1229 | /** |
| 1230 | * This callback is called when transport state is changed. See also |
| 1231 | * #pjsip_tp_state_callback. |
| 1232 | */ |
| 1233 | pjsip_tp_state_callback on_transport_state; |
| 1234 | |
| 1235 | /** |
| 1236 | * This callback is called when media transport state is changed. See |
| 1237 | * also #pjsua_med_tp_state_cb. |
| 1238 | */ |
| 1239 | pjsua_med_tp_state_cb on_call_media_transport_state; |
| 1240 | |
| 1241 | /** |
| 1242 | * This callback is called to report error in ICE media transport. |
| 1243 | * Currently it is used to report TURN Refresh error. |
| 1244 | * |
| 1245 | * @param index Transport index. |
| 1246 | * @param op Operation which trigger the failure. |
| 1247 | * @param status Error status. |
| 1248 | * @param param Additional info about the event. Currently this will |
| 1249 | * always be set to NULL. |
| 1250 | */ |
| 1251 | void (*on_ice_transport_error)(int index, pj_ice_strans_op op, |
| 1252 | pj_status_t status, void *param); |
| 1253 | |
| 1254 | /** |
| 1255 | * Callback when the sound device is about to be opened or closed. |
| 1256 | * This callback will be called even when null sound device or no |
| 1257 | * sound device is configured by the application (i.e. the |
| 1258 | * #pjsua_set_null_snd_dev() and #pjsua_set_no_snd_dev() APIs). |
| 1259 | * This API is mostly useful when the application wants to manage |
| 1260 | * the sound device by itself (i.e. with #pjsua_set_no_snd_dev()), |
| 1261 | * to get notified when it should open or close the sound device. |
| 1262 | * |
| 1263 | * @param operation The value will be set to 0 to signal that sound |
| 1264 | * device is about to be closed, and 1 to be opened. |
| 1265 | * |
| 1266 | * @return The callback must return PJ_SUCCESS at the moment. |
| 1267 | */ |
| 1268 | pj_status_t (*on_snd_dev_operation)(int operation); |
| 1269 | |
| 1270 | /** |
| 1271 | * Notification about media events such as video notifications. This |
| 1272 | * callback will most likely be called from media threads, thus |
| 1273 | * application must not perform heavy processing in this callback. |
| 1274 | * Especially, application must not destroy the call or media in this |
| 1275 | * callback. If application needs to perform more complex tasks to |
| 1276 | * handle the event, it should post the task to another thread. |
| 1277 | * |
| 1278 | * @param call_id The call id. |
| 1279 | * @param med_idx The media stream index. |
| 1280 | * @param event The media event. |
| 1281 | */ |
| 1282 | void (*on_call_media_event)(pjsua_call_id call_id, |
| 1283 | unsigned med_idx, |
| 1284 | pjmedia_event *event); |
| 1285 | |
| 1286 | /** |
| 1287 | * This callback can be used by application to implement custom media |
| 1288 | * transport adapter for the call, or to replace the media transport |
| 1289 | * with something completely new altogether. |
| 1290 | * |
| 1291 | * This callback is called when a new call is created. The library has |
| 1292 | * created a media transport for the call, and it is provided as the |
| 1293 | * \a base_tp argument of this callback. Upon returning, the callback |
| 1294 | * must return an instance of media transport to be used by the call. |
| 1295 | * |
| 1296 | * @param call_id Call ID |
| 1297 | * @param media_idx The media index in the SDP for which this media |
| 1298 | * transport will be used. |
| 1299 | * @param base_tp The media transport which otherwise will be |
| 1300 | * used by the call has this callback not been |
| 1301 | * implemented. |
| 1302 | * @param flags Bitmask from pjsua_create_media_transport_flag. |
| 1303 | * |
| 1304 | * @return The callback must return an instance of media |
| 1305 | * transport to be used by the call. |
| 1306 | */ |
| 1307 | pjmedia_transport* (*on_create_media_transport)(pjsua_call_id call_id, |
| 1308 | unsigned media_idx, |
| 1309 | pjmedia_transport *base_tp, |
| 1310 | unsigned flags); |
| 1311 | |
| 1312 | /** |
| 1313 | * This callback can be used by application to override the account |
| 1314 | * to be used to handle an incoming message. Initially, the account to |
| 1315 | * be used will be calculated automatically by the library. This initial |
| 1316 | * account will be used if application does not implement this callback, |
| 1317 | * or application sets an invalid account upon returning from this |
| 1318 | * callback. |
| 1319 | * |
| 1320 | * Note that currently the incoming messages requiring account assignment |
| 1321 | * are INVITE, MESSAGE, SUBSCRIBE, and unsolicited NOTIFY. This callback |
| 1322 | * may be called before the callback of the SIP event itself, i.e: |
| 1323 | * incoming call, pager, subscription, or unsolicited-event. |
| 1324 | * |
| 1325 | * @param rdata The incoming message. |
| 1326 | * @param acc_id On input, initial account ID calculated automatically |
| 1327 | * by the library. On output, the account ID prefered |
| 1328 | * by application to handle the incoming message. |
| 1329 | */ |
| 1330 | void (*on_acc_find_for_incoming)(const pjsip_rx_data *rdata, |
| 1331 | pjsua_acc_id* acc_id); |
| 1332 | |
| 1333 | } pjsua_callback; |
| 1334 | |
| 1335 | |
| 1336 | /** |
| 1337 | * This enumeration specifies the usage of SIP Session Timers extension. |
| 1338 | */ |
| 1339 | typedef enum pjsua_sip_timer_use |
| 1340 | { |
| 1341 | /** |
| 1342 | * When this flag is specified, Session Timers will not be used in any |
| 1343 | * session, except it is explicitly required in the remote request. |
| 1344 | */ |
| 1345 | PJSUA_SIP_TIMER_INACTIVE, |
| 1346 | |
| 1347 | /** |
| 1348 | * When this flag is specified, Session Timers will be used in all |
| 1349 | * sessions whenever remote supports and uses it. |
| 1350 | */ |
| 1351 | PJSUA_SIP_TIMER_OPTIONAL, |
| 1352 | |
| 1353 | /** |
| 1354 | * When this flag is specified, Session Timers support will be |
| 1355 | * a requirement for the remote to be able to establish a session. |
| 1356 | */ |
| 1357 | PJSUA_SIP_TIMER_REQUIRED, |
| 1358 | |
| 1359 | /** |
| 1360 | * When this flag is specified, Session Timers will always be used |
| 1361 | * in all sessions, regardless whether remote supports/uses it or not. |
| 1362 | */ |
| 1363 | PJSUA_SIP_TIMER_ALWAYS |
| 1364 | |
| 1365 | } pjsua_sip_timer_use; |
| 1366 | |
| 1367 | |
| 1368 | /** |
| 1369 | * This constants controls the use of 100rel extension. |
| 1370 | */ |
| 1371 | typedef enum pjsua_100rel_use |
| 1372 | { |
| 1373 | /** |
| 1374 | * Not used. For UAC, support for 100rel will be indicated in Supported |
| 1375 | * header so that peer can opt to use it if it wants to. As UAS, this |
| 1376 | * option will NOT cause 100rel to be used even if UAC indicates that |
| 1377 | * it supports this feature. |
| 1378 | */ |
| 1379 | PJSUA_100REL_NOT_USED, |
| 1380 | |
| 1381 | /** |
| 1382 | * Mandatory. UAC will place 100rel in Require header, and UAS will |
| 1383 | * reject incoming calls unless it has 100rel in Supported header. |
| 1384 | */ |
| 1385 | PJSUA_100REL_MANDATORY, |
| 1386 | |
| 1387 | /** |
| 1388 | * Optional. Similar to PJSUA_100REL_NOT_USED, except that as UAS, this |
| 1389 | * option will cause 100rel to be used if UAC indicates that it supports it. |
| 1390 | */ |
| 1391 | PJSUA_100REL_OPTIONAL |
| 1392 | |
| 1393 | } pjsua_100rel_use; |
| 1394 | |
| 1395 | |
| 1396 | /** |
| 1397 | * This structure describes the settings to control the API and |
| 1398 | * user agent behavior, and can be specified when calling #pjsua_init(). |
| 1399 | * Before setting the values, application must call #pjsua_config_default() |
| 1400 | * to initialize this structure with the default values. |
| 1401 | */ |
| 1402 | typedef struct pjsua_config |
| 1403 | { |
| 1404 | |
| 1405 | /** |
| 1406 | * Maximum calls to support (default: 4). The value specified here |
| 1407 | * must be smaller than the compile time maximum settings |
| 1408 | * PJSUA_MAX_CALLS, which by default is 32. To increase this |
| 1409 | * limit, the library must be recompiled with new PJSUA_MAX_CALLS |
| 1410 | * value. |
| 1411 | */ |
| 1412 | unsigned max_calls; |
| 1413 | |
| 1414 | /** |
| 1415 | * Number of worker threads. Normally application will want to have at |
| 1416 | * least one worker thread, unless when it wants to poll the library |
| 1417 | * periodically, which in this case the worker thread can be set to |
| 1418 | * zero. |
| 1419 | */ |
| 1420 | unsigned thread_cnt; |
| 1421 | |
| 1422 | /** |
| 1423 | * Number of nameservers. If no name server is configured, the SIP SRV |
| 1424 | * resolution would be disabled, and domain will be resolved with |
| 1425 | * standard pj_gethostbyname() function. |
| 1426 | */ |
| 1427 | unsigned nameserver_count; |
| 1428 | |
| 1429 | /** |
| 1430 | * Array of nameservers to be used by the SIP resolver subsystem. |
| 1431 | * The order of the name server specifies the priority (first name |
| 1432 | * server will be used first, unless it is not reachable). |
| 1433 | */ |
| 1434 | pj_str_t nameserver[4]; |
| 1435 | |
| 1436 | /** |
| 1437 | * Force loose-route to be used in all route/proxy URIs (outbound_proxy |
| 1438 | * and account's proxy settings). When this setting is enabled, the |
| 1439 | * library will check all the route/proxy URIs specified in the settings |
| 1440 | * and append ";lr" parameter to the URI if the parameter is not present. |
| 1441 | * |
| 1442 | * Default: 1 |
| 1443 | */ |
| 1444 | pj_bool_t force_lr; |
| 1445 | |
| 1446 | /** |
| 1447 | * Number of outbound proxies in the \a outbound_proxy array. |
| 1448 | */ |
| 1449 | unsigned outbound_proxy_cnt; |
| 1450 | |
| 1451 | /** |
| 1452 | * Specify the URL of outbound proxies to visit for all outgoing requests. |
| 1453 | * The outbound proxies will be used for all accounts, and it will |
| 1454 | * be used to build the route set for outgoing requests. The final |
| 1455 | * route set for outgoing requests will consists of the outbound proxies |
| 1456 | * and the proxy configured in the account. |
| 1457 | */ |
| 1458 | pj_str_t outbound_proxy[4]; |
| 1459 | |
| 1460 | /** |
| 1461 | * Warning: deprecated, please use \a stun_srv field instead. To maintain |
| 1462 | * backward compatibility, if \a stun_srv_cnt is zero then the value of |
| 1463 | * this field will be copied to \a stun_srv field, if present. |
| 1464 | * |
| 1465 | * Specify domain name to be resolved with DNS SRV resolution to get the |
| 1466 | * address of the STUN server. Alternatively application may specify |
| 1467 | * \a stun_host instead. |
| 1468 | * |
| 1469 | * If DNS SRV resolution failed for this domain, then DNS A resolution |
| 1470 | * will be performed only if \a stun_host is specified. |
| 1471 | */ |
| 1472 | pj_str_t stun_domain; |
| 1473 | |
| 1474 | /** |
| 1475 | * Warning: deprecated, please use \a stun_srv field instead. To maintain |
| 1476 | * backward compatibility, if \a stun_srv_cnt is zero then the value of |
| 1477 | * this field will be copied to \a stun_srv field, if present. |
| 1478 | * |
| 1479 | * Specify STUN server to be used, in "HOST[:PORT]" format. If port is |
| 1480 | * not specified, default port 3478 will be used. |
| 1481 | */ |
| 1482 | pj_str_t stun_host; |
| 1483 | |
| 1484 | /** |
| 1485 | * Number of STUN server entries in \a stun_srv array. |
| 1486 | */ |
| 1487 | unsigned stun_srv_cnt; |
| 1488 | |
| 1489 | /** |
| 1490 | * Array of STUN servers to try. The library will try to resolve and |
| 1491 | * contact each of the STUN server entry until it finds one that is |
| 1492 | * usable. Each entry may be a domain name, host name, IP address, and |
| 1493 | * it may contain an optional port number. For example: |
| 1494 | * - "pjsip.org" (domain name) |
| 1495 | * - "sip.pjsip.org" (host name) |
| 1496 | * - "pjsip.org:33478" (domain name and a non-standard port number) |
| 1497 | * - "10.0.0.1:3478" (IP address and port number) |
| 1498 | * |
| 1499 | * When nameserver is configured in the \a pjsua_config.nameserver field, |
| 1500 | * if entry is not an IP address, it will be resolved with DNS SRV |
| 1501 | * resolution first, and it will fallback to use DNS A resolution if this |
| 1502 | * fails. Port number may be specified even if the entry is a domain name, |
| 1503 | * in case the DNS SRV resolution should fallback to a non-standard port. |
| 1504 | * |
| 1505 | * When nameserver is not configured, entries will be resolved with |
| 1506 | * #pj_gethostbyname() if it's not an IP address. Port number may be |
| 1507 | * specified if the server is not listening in standard STUN port. |
| 1508 | */ |
| 1509 | pj_str_t stun_srv[8]; |
| 1510 | |
| 1511 | /** |
| 1512 | * This specifies if the library startup should ignore failure with the |
| 1513 | * STUN servers. If this is set to PJ_FALSE, the library will refuse to |
| 1514 | * start if it fails to resolve or contact any of the STUN servers. |
| 1515 | * |
| 1516 | * Default: PJ_TRUE |
| 1517 | */ |
| 1518 | pj_bool_t stun_ignore_failure; |
| 1519 | |
| 1520 | /** |
| 1521 | * This specifies whether STUN requests for resolving socket mapped |
| 1522 | * address should use the new format, i.e: having STUN magic cookie |
| 1523 | * in its transaction ID. |
| 1524 | * |
| 1525 | * Default: PJ_FALSE |
| 1526 | */ |
| 1527 | pj_bool_t stun_map_use_stun2; |
| 1528 | |
| 1529 | /** |
| 1530 | * Support for adding and parsing NAT type in the SDP to assist |
| 1531 | * troubleshooting. The valid values are: |
| 1532 | * - 0: no information will be added in SDP, and parsing is disabled. |
| 1533 | * - 1: only the NAT type number is added. |
| 1534 | * - 2: add both NAT type number and name. |
| 1535 | * |
| 1536 | * Default: 1 |
| 1537 | */ |
| 1538 | int nat_type_in_sdp; |
| 1539 | |
| 1540 | /** |
| 1541 | * Specify how the support for reliable provisional response (100rel/ |
| 1542 | * PRACK) should be used by default. Note that this setting can be |
| 1543 | * further customized in account configuration (#pjsua_acc_config). |
| 1544 | * |
| 1545 | * Default: PJSUA_100REL_NOT_USED |
| 1546 | */ |
| 1547 | pjsua_100rel_use require_100rel; |
| 1548 | |
| 1549 | /** |
| 1550 | * Specify the usage of Session Timers for all sessions. See the |
| 1551 | * #pjsua_sip_timer_use for possible values. Note that this setting can be |
| 1552 | * further customized in account configuration (#pjsua_acc_config). |
| 1553 | * |
| 1554 | * Default: PJSUA_SIP_TIMER_OPTIONAL |
| 1555 | */ |
| 1556 | pjsua_sip_timer_use use_timer; |
| 1557 | |
| 1558 | /** |
| 1559 | * Handle unsolicited NOTIFY requests containing message waiting |
| 1560 | * indication (MWI) info. Unsolicited MWI is incoming NOTIFY requests |
| 1561 | * which are not requested by client with SUBSCRIBE request. |
| 1562 | * |
| 1563 | * If this is enabled, the library will respond 200/OK to the NOTIFY |
| 1564 | * request and forward the request to \a on_mwi_info() callback. |
| 1565 | * |
| 1566 | * See also \a mwi_enabled field #on pjsua_acc_config. |
| 1567 | * |
| 1568 | * Default: PJ_TRUE |
| 1569 | * |
| 1570 | */ |
| 1571 | pj_bool_t enable_unsolicited_mwi; |
| 1572 | |
| 1573 | /** |
| 1574 | * Specify Session Timer settings, see #pjsip_timer_setting. |
| 1575 | * Note that this setting can be further customized in account |
| 1576 | * configuration (#pjsua_acc_config). |
| 1577 | */ |
| 1578 | pjsip_timer_setting timer_setting; |
| 1579 | |
| 1580 | /** |
| 1581 | * Number of credentials in the credential array. |
| 1582 | */ |
| 1583 | unsigned cred_count; |
| 1584 | |
| 1585 | /** |
| 1586 | * Array of credentials. These credentials will be used by all accounts, |
| 1587 | * and can be used to authenticate against outbound proxies. If the |
| 1588 | * credential is specific to the account, then application should set |
| 1589 | * the credential in the pjsua_acc_config rather than the credential |
| 1590 | * here. |
| 1591 | */ |
| 1592 | pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES]; |
| 1593 | |
| 1594 | /** |
| 1595 | * Application callback to receive various event notifications from |
| 1596 | * the library. |
| 1597 | */ |
| 1598 | pjsua_callback cb; |
| 1599 | |
| 1600 | /** |
| 1601 | * Optional user agent string (default empty). If it's empty, no |
| 1602 | * User-Agent header will be sent with outgoing requests. |
| 1603 | */ |
| 1604 | pj_str_t user_agent; |
| 1605 | |
| 1606 | /** |
| 1607 | * Specify default value of secure media transport usage. |
| 1608 | * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and |
| 1609 | * PJMEDIA_SRTP_MANDATORY. |
| 1610 | * |
| 1611 | * Note that this setting can be further customized in account |
| 1612 | * configuration (#pjsua_acc_config). |
| 1613 | * |
| 1614 | * Default: #PJSUA_DEFAULT_USE_SRTP |
| 1615 | */ |
| 1616 | pjmedia_srtp_use use_srtp; |
| 1617 | |
| 1618 | /** |
| 1619 | * Specify whether SRTP requires secure signaling to be used. This option |
| 1620 | * is only used when \a use_srtp option above is non-zero. |
| 1621 | * |
| 1622 | * Valid values are: |
| 1623 | * 0: SRTP does not require secure signaling |
| 1624 | * 1: SRTP requires secure transport such as TLS |
| 1625 | * 2: SRTP requires secure end-to-end transport (SIPS) |
| 1626 | * |
| 1627 | * Note that this setting can be further customized in account |
| 1628 | * configuration (#pjsua_acc_config). |
| 1629 | * |
| 1630 | * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING |
| 1631 | */ |
| 1632 | int srtp_secure_signaling; |
| 1633 | |
| 1634 | /** |
| 1635 | * This setting has been deprecated and will be ignored. |
| 1636 | */ |
| 1637 | pj_bool_t srtp_optional_dup_offer; |
| 1638 | |
| 1639 | /** |
| 1640 | * Disconnect other call legs when more than one 2xx responses for |
| 1641 | * outgoing INVITE are received due to forking. Currently the library |
| 1642 | * is not able to handle simultaneous forked media, so disconnecting |
| 1643 | * the other call legs is necessary. |
| 1644 | * |
| 1645 | * With this setting enabled, the library will handle only one of the |
| 1646 | * connected call leg, and the other connected call legs will be |
| 1647 | * disconnected. |
| 1648 | * |
| 1649 | * Default: PJ_TRUE (only disable this setting for testing purposes). |
| 1650 | */ |
| 1651 | pj_bool_t hangup_forked_call; |
| 1652 | |
| 1653 | } pjsua_config; |
| 1654 | |
| 1655 | |
| 1656 | /** |
| 1657 | * Flags to be given to pjsua_destroy2() |
| 1658 | */ |
| 1659 | typedef enum pjsua_destroy_flag |
| 1660 | { |
| 1661 | /** |
| 1662 | * Allow sending outgoing messages (such as unregistration, event |
| 1663 | * unpublication, BYEs, unsubscription, etc.), but do not wait for |
| 1664 | * responses. This is useful to perform "best effort" clean up |
| 1665 | * without delaying the shutdown process waiting for responses. |
| 1666 | */ |
| 1667 | PJSUA_DESTROY_NO_RX_MSG = 1, |
| 1668 | |
| 1669 | /** |
| 1670 | * If this flag is set, do not send any outgoing messages at all. |
| 1671 | * This flag is useful if application knows that the network which |
| 1672 | * the messages are to be sent on is currently down. |
| 1673 | */ |
| 1674 | PJSUA_DESTROY_NO_TX_MSG = 2, |
| 1675 | |
| 1676 | /** |
| 1677 | * Do not send or receive messages during destroy. This flag is |
| 1678 | * shorthand for PJSUA_DESTROY_NO_RX_MSG + PJSUA_DESTROY_NO_TX_MSG. |
| 1679 | */ |
| 1680 | PJSUA_DESTROY_NO_NETWORK = PJSUA_DESTROY_NO_RX_MSG | |
| 1681 | PJSUA_DESTROY_NO_TX_MSG |
| 1682 | |
| 1683 | } pjsua_destroy_flag; |
| 1684 | |
| 1685 | /** |
| 1686 | * Use this function to initialize pjsua config. |
| 1687 | * |
| 1688 | * @param cfg pjsua config to be initialized. |
| 1689 | */ |
| 1690 | PJ_DECL(void) pjsua_config_default(pjsua_config *cfg); |
| 1691 | |
| 1692 | |
| 1693 | /** The implementation has been moved to sip_auth.h */ |
| 1694 | #define pjsip_cred_dup pjsip_cred_info_dup |
| 1695 | |
| 1696 | |
| 1697 | /** |
| 1698 | * Duplicate pjsua_config. |
| 1699 | * |
| 1700 | * @param pool The pool to get memory from. |
| 1701 | * @param dst Destination config. |
| 1702 | * @param src Source config. |
| 1703 | */ |
| 1704 | PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool, |
| 1705 | pjsua_config *dst, |
| 1706 | const pjsua_config *src); |
| 1707 | |
| 1708 | |
| 1709 | /** |
| 1710 | * This structure describes additional information to be sent with |
| 1711 | * outgoing SIP message. It can (optionally) be specified for example |
| 1712 | * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(), |
| 1713 | * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more. |
| 1714 | * |
| 1715 | * Application MUST call #pjsua_msg_data_init() to initialize this |
| 1716 | * structure before setting its values. |
| 1717 | */ |
| 1718 | struct pjsua_msg_data |
| 1719 | { |
| 1720 | /** |
| 1721 | * Optional remote target URI (i.e. Target header). If NULL, the target |
| 1722 | * will be set to the remote URI (To header). At the moment this field |
| 1723 | * is only used by #pjsua_call_make_call() and #pjsua_im_send(). |
| 1724 | */ |
| 1725 | pj_str_t target_uri; |
| 1726 | |
| 1727 | /** |
| 1728 | * Additional message headers as linked list. Application can add |
| 1729 | * headers to the list by creating the header, either from the heap/pool |
| 1730 | * or from temporary local variable, and add the header using |
| 1731 | * linked list operation. See pjsua_app.c for some sample codes. |
| 1732 | */ |
| 1733 | pjsip_hdr hdr_list; |
| 1734 | |
| 1735 | /** |
| 1736 | * MIME type of optional message body. |
| 1737 | */ |
| 1738 | pj_str_t content_type; |
| 1739 | |
| 1740 | /** |
| 1741 | * Optional message body to be added to the message, only when the |
| 1742 | * message doesn't have a body. |
| 1743 | */ |
| 1744 | pj_str_t msg_body; |
| 1745 | |
| 1746 | /** |
| 1747 | * Content type of the multipart body. If application wants to send |
| 1748 | * multipart message bodies, it puts the parts in \a parts and set |
| 1749 | * the content type in \a multipart_ctype. If the message already |
| 1750 | * contains a body, the body will be added to the multipart bodies. |
| 1751 | */ |
| 1752 | pjsip_media_type multipart_ctype; |
| 1753 | |
| 1754 | /** |
| 1755 | * List of multipart parts. If application wants to send multipart |
| 1756 | * message bodies, it puts the parts in \a parts and set the content |
| 1757 | * type in \a multipart_ctype. If the message already contains a body, |
| 1758 | * the body will be added to the multipart bodies. |
| 1759 | */ |
| 1760 | pjsip_multipart_part multipart_parts; |
| 1761 | }; |
| 1762 | |
| 1763 | |
| 1764 | /** |
| 1765 | * Initialize message data. |
| 1766 | * |
| 1767 | * @param msg_data Message data to be initialized. |
| 1768 | */ |
| 1769 | PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data); |
| 1770 | |
| 1771 | |
| 1772 | /** |
| 1773 | * Clone message data. |
| 1774 | * |
| 1775 | * @param pool Pool to allocate memory for the new message data. |
| 1776 | * @param rhs Message data to be cloned. |
| 1777 | * |
| 1778 | * @return The new message data. |
| 1779 | */ |
| 1780 | PJ_DECL(pjsua_msg_data*) pjsua_msg_data_clone(pj_pool_t *pool, |
| 1781 | const pjsua_msg_data *rhs); |
| 1782 | |
| 1783 | |
| 1784 | /** |
| 1785 | * Instantiate pjsua application. Application must call this function before |
| 1786 | * calling any other functions, to make sure that the underlying libraries |
| 1787 | * are properly initialized. Once this function has returned success, |
| 1788 | * application must call pjsua_destroy() before quitting. |
| 1789 | * |
| 1790 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1791 | */ |
| 1792 | PJ_DECL(pj_status_t) pjsua_create(void); |
| 1793 | |
| 1794 | |
| 1795 | /** Forward declaration */ |
| 1796 | typedef struct pjsua_media_config pjsua_media_config; |
| 1797 | |
| 1798 | |
| 1799 | /** |
| 1800 | * Initialize pjsua with the specified settings. All the settings are |
| 1801 | * optional, and the default values will be used when the config is not |
| 1802 | * specified. |
| 1803 | * |
| 1804 | * Note that #pjsua_create() MUST be called before calling this function. |
| 1805 | * |
| 1806 | * @param ua_cfg User agent configuration. |
| 1807 | * @param log_cfg Optional logging configuration. |
| 1808 | * @param media_cfg Optional media configuration. |
| 1809 | * |
| 1810 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1811 | */ |
| 1812 | PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg, |
| 1813 | const pjsua_logging_config *log_cfg, |
| 1814 | const pjsua_media_config *media_cfg); |
| 1815 | |
| 1816 | |
| 1817 | /** |
| 1818 | * Application is recommended to call this function after all initialization |
| 1819 | * is done, so that the library can do additional checking set up |
| 1820 | * additional |
| 1821 | * |
| 1822 | * Application may call this function anytime after #pjsua_init(). |
| 1823 | * |
| 1824 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1825 | */ |
| 1826 | PJ_DECL(pj_status_t) pjsua_start(void); |
| 1827 | |
| 1828 | |
| 1829 | /** |
| 1830 | * Destroy pjsua. Application is recommended to perform graceful shutdown |
| 1831 | * before calling this function (such as unregister the account from the SIP |
| 1832 | * server, terminate presense subscription, and hangup active calls), however, |
| 1833 | * this function will do all of these if it finds there are active sessions |
| 1834 | * that need to be terminated. This function will approximately block for |
| 1835 | * one second to wait for replies from remote. |
| 1836 | * |
| 1837 | * Application.may safely call this function more than once if it doesn't |
| 1838 | * keep track of it's state. |
| 1839 | * |
| 1840 | * @see pjsua_destroy2() |
| 1841 | * |
| 1842 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1843 | */ |
| 1844 | PJ_DECL(pj_status_t) pjsua_destroy(void); |
| 1845 | |
| 1846 | |
| 1847 | /** |
| 1848 | * Retrieve pjsua state. |
| 1849 | * |
| 1850 | * @return pjsua state. |
| 1851 | */ |
| 1852 | PJ_DECL(pjsua_state) pjsua_get_state(void); |
| 1853 | |
| 1854 | |
| 1855 | /** |
| 1856 | * Variant of destroy with additional flags. |
| 1857 | * |
| 1858 | * @param flags Combination of pjsua_destroy_flag enumeration. |
| 1859 | * |
| 1860 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1861 | */ |
| 1862 | PJ_DECL(pj_status_t) pjsua_destroy2(unsigned flags); |
| 1863 | |
| 1864 | |
| 1865 | /** |
| 1866 | * Poll pjsua for events, and if necessary block the caller thread for |
| 1867 | * the specified maximum interval (in miliseconds). |
| 1868 | * |
| 1869 | * Application doesn't normally need to call this function if it has |
| 1870 | * configured worker thread (\a thread_cnt field) in pjsua_config structure, |
| 1871 | * because polling then will be done by these worker threads instead. |
| 1872 | * |
| 1873 | * @param msec_timeout Maximum time to wait, in miliseconds. |
| 1874 | * |
| 1875 | * @return The number of events that have been handled during the |
| 1876 | * poll. Negative value indicates error, and application |
| 1877 | * can retrieve the error as (status = -return_value). |
| 1878 | */ |
| 1879 | PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout); |
| 1880 | |
| 1881 | |
| 1882 | /** |
| 1883 | * Create memory pool to be used by the application. Once application |
| 1884 | * finished using the pool, it must be released with pj_pool_release(). |
| 1885 | * |
| 1886 | * @param name Optional pool name. |
| 1887 | * @param init_size Initial size of the pool. |
| 1888 | * @param increment Increment size. |
| 1889 | * |
| 1890 | * @return The pool, or NULL when there's no memory. |
| 1891 | */ |
| 1892 | PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size, |
| 1893 | pj_size_t increment); |
| 1894 | |
| 1895 | |
| 1896 | /** |
| 1897 | * Application can call this function at any time (after pjsua_create(), of |
| 1898 | * course) to change logging settings. |
| 1899 | * |
| 1900 | * @param c Logging configuration. |
| 1901 | * |
| 1902 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1903 | */ |
| 1904 | PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c); |
| 1905 | |
| 1906 | |
| 1907 | /** |
| 1908 | * Internal function to get SIP endpoint instance of pjsua, which is |
| 1909 | * needed for example to register module, create transports, etc. |
| 1910 | * Only valid after #pjsua_init() is called. |
| 1911 | * |
| 1912 | * @return SIP endpoint instance. |
| 1913 | */ |
| 1914 | PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void); |
| 1915 | |
| 1916 | /** |
| 1917 | * Internal function to get media endpoint instance. |
| 1918 | * Only valid after #pjsua_init() is called. |
| 1919 | * |
| 1920 | * @return Media endpoint instance. |
| 1921 | */ |
| 1922 | PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void); |
| 1923 | |
| 1924 | /** |
| 1925 | * Internal function to get PJSUA pool factory. |
| 1926 | * Only valid after #pjsua_create() is called. |
| 1927 | * |
| 1928 | * @return Pool factory currently used by PJSUA. |
| 1929 | */ |
| 1930 | PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void); |
| 1931 | |
| 1932 | |
| 1933 | |
| 1934 | /***************************************************************************** |
| 1935 | * Utilities. |
| 1936 | * |
| 1937 | */ |
| 1938 | |
| 1939 | /** |
| 1940 | * This structure is used to represent the result of the STUN server |
| 1941 | * resolution and testing, the #pjsua_resolve_stun_servers() function. |
| 1942 | * This structure will be passed in #pj_stun_resolve_cb callback. |
| 1943 | */ |
| 1944 | typedef struct pj_stun_resolve_result |
| 1945 | { |
| 1946 | /** |
| 1947 | * Arbitrary data that was passed to #pjsua_resolve_stun_servers() |
| 1948 | * function. |
| 1949 | */ |
| 1950 | void *token; |
| 1951 | |
| 1952 | /** |
| 1953 | * This will contain PJ_SUCCESS if at least one usable STUN server |
| 1954 | * is found, otherwise it will contain the last error code during |
| 1955 | * the operation. |
| 1956 | */ |
| 1957 | pj_status_t status; |
| 1958 | |
| 1959 | /** |
| 1960 | * The server name that yields successful result. This will only |
| 1961 | * contain value if status is successful. |
| 1962 | */ |
| 1963 | pj_str_t name; |
| 1964 | |
| 1965 | /** |
| 1966 | * The server IP address. This will only contain value if status |
| 1967 | * is successful. |
| 1968 | */ |
| 1969 | pj_sockaddr addr; |
| 1970 | |
| 1971 | } pj_stun_resolve_result; |
| 1972 | |
| 1973 | |
| 1974 | /** |
| 1975 | * Typedef of callback to be registered to #pjsua_resolve_stun_servers(). |
| 1976 | */ |
| 1977 | typedef void (*pj_stun_resolve_cb)(const pj_stun_resolve_result *result); |
| 1978 | |
| 1979 | /** |
| 1980 | * This is a utility function to detect NAT type in front of this |
| 1981 | * endpoint. Once invoked successfully, this function will complete |
| 1982 | * asynchronously and report the result in \a on_nat_detect() callback |
| 1983 | * of pjsua_callback. |
| 1984 | * |
| 1985 | * After NAT has been detected and the callback is called, application can |
| 1986 | * get the detected NAT type by calling #pjsua_get_nat_type(). Application |
| 1987 | * can also perform NAT detection by calling #pjsua_detect_nat_type() |
| 1988 | * again at later time. |
| 1989 | * |
| 1990 | * Note that STUN must be enabled to run this function successfully. |
| 1991 | * |
| 1992 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1993 | */ |
| 1994 | PJ_DECL(pj_status_t) pjsua_detect_nat_type(void); |
| 1995 | |
| 1996 | |
| 1997 | /** |
| 1998 | * Get the NAT type as detected by #pjsua_detect_nat_type() function. |
| 1999 | * This function will only return useful NAT type after #pjsua_detect_nat_type() |
| 2000 | * has completed successfully and \a on_nat_detect() callback has been called. |
| 2001 | * |
| 2002 | * @param type NAT type. |
| 2003 | * |
| 2004 | * @return When detection is in progress, this function will |
| 2005 | * return PJ_EPENDING and \a type will be set to |
| 2006 | * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been |
| 2007 | * detected successfully, this function will return |
| 2008 | * PJ_SUCCESS and \a type will be set to the correct |
| 2009 | * value. Other return values indicate error and |
| 2010 | * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN. |
| 2011 | * |
| 2012 | * @see pjsua_call_get_rem_nat_type() |
| 2013 | */ |
| 2014 | PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type); |
| 2015 | |
| 2016 | |
| 2017 | /** |
| 2018 | * Auxiliary function to resolve and contact each of the STUN server |
| 2019 | * entries (sequentially) to find which is usable. The #pjsua_init() must |
| 2020 | * have been called before calling this function. |
| 2021 | * |
| 2022 | * @param count Number of STUN server entries to try. |
| 2023 | * @param srv Array of STUN server entries to try. Please see |
| 2024 | * the \a stun_srv field in the #pjsua_config |
| 2025 | * documentation about the format of this entry. |
| 2026 | * @param wait Specify non-zero to make the function block until |
| 2027 | * it gets the result. In this case, the function |
| 2028 | * will block while the resolution is being done, |
| 2029 | * and the callback will be called before this function |
| 2030 | * returns. |
| 2031 | * @param token Arbitrary token to be passed back to application |
| 2032 | * in the callback. |
| 2033 | * @param cb Callback to be called to notify the result of |
| 2034 | * the function. |
| 2035 | * |
| 2036 | * @return If \a wait parameter is non-zero, this will return |
| 2037 | * PJ_SUCCESS if one usable STUN server is found. |
| 2038 | * Otherwise it will always return PJ_SUCCESS, and |
| 2039 | * application will be notified about the result in |
| 2040 | * the callback. |
| 2041 | */ |
| 2042 | PJ_DECL(pj_status_t) pjsua_resolve_stun_servers(unsigned count, |
| 2043 | pj_str_t srv[], |
| 2044 | pj_bool_t wait, |
| 2045 | void *token, |
| 2046 | pj_stun_resolve_cb cb); |
| 2047 | |
| 2048 | /** |
| 2049 | * Cancel pending STUN resolution which match the specified token. |
| 2050 | * |
| 2051 | * @param token The token to match. This token was given to |
| 2052 | * #pjsua_resolve_stun_servers() |
| 2053 | * @param notify_cb Boolean to control whether the callback should |
| 2054 | * be called for cancelled resolutions. When the |
| 2055 | * callback is called, the status in the result |
| 2056 | * will be set as PJ_ECANCELLED. |
| 2057 | * |
| 2058 | * @return PJ_SUCCESS if there is at least one pending STUN |
| 2059 | * resolution cancelled, or PJ_ENOTFOUND if there is |
| 2060 | * no matching one, or other error. |
| 2061 | */ |
| 2062 | PJ_DECL(pj_status_t) pjsua_cancel_stun_resolution(void *token, |
| 2063 | pj_bool_t notify_cb); |
| 2064 | |
| 2065 | |
| 2066 | /** |
| 2067 | * This is a utility function to verify that valid SIP url is given. If the |
| 2068 | * URL is a valid SIP/SIPS scheme, PJ_SUCCESS will be returned. |
| 2069 | * |
| 2070 | * @param url The URL, as NULL terminated string. |
| 2071 | * |
| 2072 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2073 | * |
| 2074 | * @see pjsua_verify_url() |
| 2075 | */ |
| 2076 | PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url); |
| 2077 | |
| 2078 | |
| 2079 | /** |
| 2080 | * This is a utility function to verify that valid URI is given. Unlike |
| 2081 | * pjsua_verify_sip_url(), this function will return PJ_SUCCESS if tel: URI |
| 2082 | * is given. |
| 2083 | * |
| 2084 | * @param url The URL, as NULL terminated string. |
| 2085 | * |
| 2086 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2087 | * |
| 2088 | * @see pjsua_verify_sip_url() |
| 2089 | */ |
| 2090 | PJ_DECL(pj_status_t) pjsua_verify_url(const char *url); |
| 2091 | |
| 2092 | |
| 2093 | /** |
| 2094 | * Schedule a timer entry. Note that the timer callback may be executed |
| 2095 | * by different thread, depending on whether worker thread is enabled or |
| 2096 | * not. |
| 2097 | * |
| 2098 | * @param entry Timer heap entry. |
| 2099 | * @param delay The interval to expire. |
| 2100 | * |
| 2101 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2102 | * |
| 2103 | * @see pjsip_endpt_schedule_timer() |
| 2104 | */ |
| 2105 | #if PJ_TIMER_DEBUG |
| 2106 | #define pjsua_schedule_timer(e,d) pjsua_schedule_timer_dbg(e,d,\ |
| 2107 | __FILE__,__LINE__) |
| 2108 | |
| 2109 | PJ_DECL(pj_status_t) pjsua_schedule_timer_dbg(pj_timer_entry *entry, |
| 2110 | const pj_time_val *delay, |
| 2111 | const char *src_file, |
| 2112 | int src_line); |
| 2113 | #else |
| 2114 | PJ_DECL(pj_status_t) pjsua_schedule_timer(pj_timer_entry *entry, |
| 2115 | const pj_time_val *delay); |
| 2116 | #endif |
| 2117 | |
| 2118 | /** |
| 2119 | * Schedule a callback function to be called after a specified time interval. |
| 2120 | * Note that the callback may be executed by different thread, depending on |
| 2121 | * whether worker thread is enabled or not. |
| 2122 | * |
| 2123 | * @param cb The callback function. |
| 2124 | * @param user_data The user data. |
| 2125 | * @param msec_delay The time interval in msec. |
| 2126 | * |
| 2127 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2128 | */ |
| 2129 | #if PJ_TIMER_DEBUG |
| 2130 | #define pjsua_schedule_timer2(cb,u,d) \ |
| 2131 | pjsua_schedule_timer2_dbg(cb,u,d,__FILE__,__LINE__) |
| 2132 | |
| 2133 | PJ_DECL(pj_status_t) pjsua_schedule_timer2_dbg(void (*cb)(void *user_data), |
| 2134 | void *user_data, |
| 2135 | unsigned msec_delay, |
| 2136 | const char *src_file, |
| 2137 | int src_line); |
| 2138 | #else |
| 2139 | PJ_DECL(pj_status_t) pjsua_schedule_timer2(void (*cb)(void *user_data), |
| 2140 | void *user_data, |
| 2141 | unsigned msec_delay); |
| 2142 | #endif |
| 2143 | |
| 2144 | /** |
| 2145 | * Cancel the previously scheduled timer. |
| 2146 | * |
| 2147 | * @param entry Timer heap entry. |
| 2148 | * |
| 2149 | * @see pjsip_endpt_cancel_timer() |
| 2150 | */ |
| 2151 | PJ_DECL(void) pjsua_cancel_timer(pj_timer_entry *entry); |
| 2152 | |
| 2153 | |
| 2154 | /** |
| 2155 | * This is a utility function to display error message for the specified |
| 2156 | * error code. The error message will be sent to the log. |
| 2157 | * |
| 2158 | * @param sender The log sender field. |
| 2159 | * @param title Message title for the error. |
| 2160 | * @param status Status code. |
| 2161 | */ |
| 2162 | PJ_DECL(void) pjsua_perror(const char *sender, const char *title, |
| 2163 | pj_status_t status); |
| 2164 | |
| 2165 | |
| 2166 | /** |
| 2167 | * This is a utility function to dump the stack states to log, using |
| 2168 | * verbosity level 3. |
| 2169 | * |
| 2170 | * @param detail Will print detailed output (such as list of |
| 2171 | * SIP transactions) when non-zero. |
| 2172 | */ |
| 2173 | PJ_DECL(void) pjsua_dump(pj_bool_t detail); |
| 2174 | |
| 2175 | /** |
| 2176 | * @} |
| 2177 | */ |
| 2178 | |
| 2179 | |
| 2180 | |
| 2181 | /***************************************************************************** |
| 2182 | * TRANSPORT API |
| 2183 | */ |
| 2184 | |
| 2185 | /** |
| 2186 | * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport |
| 2187 | * @ingroup PJSUA_LIB |
| 2188 | * @brief API for managing SIP transports |
| 2189 | * @{ |
| 2190 | * |
| 2191 | * PJSUA-API supports creating multiple transport instances, for example UDP, |
| 2192 | * TCP, and TLS transport. SIP transport must be created before adding an |
| 2193 | * account. |
| 2194 | */ |
| 2195 | |
| 2196 | |
| 2197 | /** SIP transport identification. |
| 2198 | */ |
| 2199 | typedef int pjsua_transport_id; |
| 2200 | |
| 2201 | |
| 2202 | /** |
| 2203 | * Transport configuration for creating transports for both SIP |
| 2204 | * and media. Before setting some values to this structure, application |
| 2205 | * MUST call #pjsua_transport_config_default() to initialize its |
| 2206 | * values with default settings. |
| 2207 | */ |
| 2208 | typedef struct pjsua_transport_config |
| 2209 | { |
| 2210 | /** |
| 2211 | * UDP port number to bind locally. This setting MUST be specified |
| 2212 | * even when default port is desired. If the value is zero, the |
| 2213 | * transport will be bound to any available port, and application |
| 2214 | * can query the port by querying the transport info. |
| 2215 | */ |
| 2216 | unsigned port; |
| 2217 | |
| 2218 | /** |
| 2219 | * Specify the port range for socket binding, relative to the start |
| 2220 | * port number specified in \a port. Note that this setting is only |
| 2221 | * applicable when the start port number is non zero. |
| 2222 | * |
| 2223 | * Default value is zero. |
| 2224 | */ |
| 2225 | unsigned port_range; |
| 2226 | |
| 2227 | /** |
| 2228 | * Optional address to advertise as the address of this transport. |
| 2229 | * Application can specify any address or hostname for this field, |
| 2230 | * for example it can point to one of the interface address in the |
| 2231 | * system, or it can point to the public address of a NAT router |
| 2232 | * where port mappings have been configured for the application. |
| 2233 | * |
| 2234 | * Note: this option can be used for both UDP and TCP as well! |
| 2235 | */ |
| 2236 | pj_str_t public_addr; |
| 2237 | |
| 2238 | /** |
| 2239 | * Optional address where the socket should be bound to. This option |
| 2240 | * SHOULD only be used to selectively bind the socket to particular |
| 2241 | * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the |
| 2242 | * published address of a transport (the public_addr field should be |
| 2243 | * used for that purpose). |
| 2244 | * |
| 2245 | * Note that unlike public_addr field, the address (or hostname) here |
| 2246 | * MUST correspond to the actual interface address in the host, since |
| 2247 | * this address will be specified as bind() argument. |
| 2248 | */ |
| 2249 | pj_str_t bound_addr; |
| 2250 | |
| 2251 | /** |
| 2252 | * This specifies TLS settings for TLS transport. It is only be used |
| 2253 | * when this transport config is being used to create a SIP TLS |
| 2254 | * transport. |
| 2255 | */ |
| 2256 | pjsip_tls_setting tls_setting; |
| 2257 | |
| 2258 | /** |
| 2259 | * QoS traffic type to be set on this transport. When application wants |
| 2260 | * to apply QoS tagging to the transport, it's preferable to set this |
| 2261 | * field rather than \a qos_param fields since this is more portable. |
| 2262 | * |
| 2263 | * Default is QoS not set. |
| 2264 | */ |
| 2265 | pj_qos_type qos_type; |
| 2266 | |
| 2267 | /** |
| 2268 | * Set the low level QoS parameters to the transport. This is a lower |
| 2269 | * level operation than setting the \a qos_type field and may not be |
| 2270 | * supported on all platforms. |
| 2271 | * |
| 2272 | * Default is QoS not set. |
| 2273 | */ |
| 2274 | pj_qos_params qos_params; |
| 2275 | |
| 2276 | } pjsua_transport_config; |
| 2277 | |
| 2278 | |
| 2279 | /** |
| 2280 | * Call this function to initialize UDP config with default values. |
| 2281 | * |
| 2282 | * @param cfg The UDP config to be initialized. |
| 2283 | */ |
| 2284 | PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg); |
| 2285 | |
| 2286 | |
| 2287 | /** |
| 2288 | * Duplicate transport config. |
| 2289 | * |
| 2290 | * @param pool The pool. |
| 2291 | * @param dst The destination config. |
| 2292 | * @param src The source config. |
| 2293 | */ |
| 2294 | PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool, |
| 2295 | pjsua_transport_config *dst, |
| 2296 | const pjsua_transport_config *src); |
| 2297 | |
| 2298 | |
| 2299 | /** |
| 2300 | * This structure describes transport information returned by |
| 2301 | * #pjsua_transport_get_info() function. |
| 2302 | */ |
| 2303 | typedef struct pjsua_transport_info |
| 2304 | { |
| 2305 | /** |
| 2306 | * PJSUA transport identification. |
| 2307 | */ |
| 2308 | pjsua_transport_id id; |
| 2309 | |
| 2310 | /** |
| 2311 | * Transport type. |
| 2312 | */ |
| 2313 | pjsip_transport_type_e type; |
| 2314 | |
| 2315 | /** |
| 2316 | * Transport type name. |
| 2317 | */ |
| 2318 | pj_str_t type_name; |
| 2319 | |
| 2320 | /** |
| 2321 | * Transport string info/description. |
| 2322 | */ |
| 2323 | pj_str_t info; |
| 2324 | |
| 2325 | /** |
| 2326 | * Transport flag (see ##pjsip_transport_flags_e). |
| 2327 | */ |
| 2328 | unsigned flag; |
| 2329 | |
| 2330 | /** |
| 2331 | * Local address length. |
| 2332 | */ |
| 2333 | unsigned addr_len; |
| 2334 | |
| 2335 | /** |
| 2336 | * Local/bound address. |
| 2337 | */ |
| 2338 | pj_sockaddr local_addr; |
| 2339 | |
| 2340 | /** |
| 2341 | * Published address (or transport address name). |
| 2342 | */ |
| 2343 | pjsip_host_port local_name; |
| 2344 | |
| 2345 | /** |
| 2346 | * Current number of objects currently referencing this transport. |
| 2347 | */ |
| 2348 | unsigned usage_count; |
| 2349 | |
| 2350 | |
| 2351 | } pjsua_transport_info; |
| 2352 | |
| 2353 | |
| 2354 | /** |
| 2355 | * Create and start a new SIP transport according to the specified |
| 2356 | * settings. |
| 2357 | * |
| 2358 | * @param type Transport type. |
| 2359 | * @param cfg Transport configuration. |
| 2360 | * @param p_id Optional pointer to receive transport ID. |
| 2361 | * |
| 2362 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2363 | */ |
| 2364 | PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type, |
| 2365 | const pjsua_transport_config *cfg, |
| 2366 | pjsua_transport_id *p_id); |
| 2367 | |
| 2368 | /** |
| 2369 | * Register transport that has been created by application. This function |
| 2370 | * is useful if application wants to implement custom SIP transport and use |
| 2371 | * it with pjsua. |
| 2372 | * |
| 2373 | * @param tp Transport instance. |
| 2374 | * @param p_id Optional pointer to receive transport ID. |
| 2375 | * |
| 2376 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2377 | */ |
| 2378 | PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp, |
| 2379 | pjsua_transport_id *p_id); |
| 2380 | |
| 2381 | |
| 2382 | /** |
| 2383 | * Enumerate all transports currently created in the system. This function |
| 2384 | * will return all transport IDs, and application may then call |
| 2385 | * #pjsua_transport_get_info() function to retrieve detailed information |
| 2386 | * about the transport. |
| 2387 | * |
| 2388 | * @param id Array to receive transport ids. |
| 2389 | * @param count In input, specifies the maximum number of elements. |
| 2390 | * On return, it contains the actual number of elements. |
| 2391 | * |
| 2392 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2393 | */ |
| 2394 | PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[], |
| 2395 | unsigned *count ); |
| 2396 | |
| 2397 | |
| 2398 | /** |
| 2399 | * Get information about transports. |
| 2400 | * |
| 2401 | * @param id Transport ID. |
| 2402 | * @param info Pointer to receive transport info. |
| 2403 | * |
| 2404 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2405 | */ |
| 2406 | PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id, |
| 2407 | pjsua_transport_info *info); |
| 2408 | |
| 2409 | |
| 2410 | /** |
| 2411 | * Disable a transport or re-enable it. By default transport is always |
| 2412 | * enabled after it is created. Disabling a transport does not necessarily |
| 2413 | * close the socket, it will only discard incoming messages and prevent |
| 2414 | * the transport from being used to send outgoing messages. |
| 2415 | * |
| 2416 | * @param id Transport ID. |
| 2417 | * @param enabled Non-zero to enable, zero to disable. |
| 2418 | * |
| 2419 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2420 | */ |
| 2421 | PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id, |
| 2422 | pj_bool_t enabled); |
| 2423 | |
| 2424 | |
| 2425 | /** |
| 2426 | * Close the transport. If transport is forcefully closed, it will be |
| 2427 | * immediately closed, and any pending transactions that are using the |
| 2428 | * transport may not terminate properly (it may even crash). Otherwise, |
| 2429 | * the system will wait until all transactions are closed while preventing |
| 2430 | * new users from using the transport, and will close the transport when |
| 2431 | * it is safe to do so. |
| 2432 | * |
| 2433 | * @param id Transport ID. |
| 2434 | * @param force Non-zero to immediately close the transport. This |
| 2435 | * is not recommended! |
| 2436 | * |
| 2437 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2438 | */ |
| 2439 | PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id, |
| 2440 | pj_bool_t force ); |
| 2441 | |
| 2442 | /** |
| 2443 | * @} |
| 2444 | */ |
| 2445 | |
| 2446 | |
| 2447 | |
| 2448 | |
| 2449 | /***************************************************************************** |
| 2450 | * ACCOUNT API |
| 2451 | */ |
| 2452 | |
| 2453 | |
| 2454 | /** |
| 2455 | * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management |
| 2456 | * @ingroup PJSUA_LIB |
| 2457 | * @brief PJSUA Accounts management |
| 2458 | * @{ |
| 2459 | * |
| 2460 | * PJSUA accounts provide identity (or identities) of the user who is currently |
| 2461 | * using the application. In SIP terms, the identity is used as the <b>From</b> |
| 2462 | * header in outgoing requests. |
| 2463 | * |
| 2464 | * PJSUA-API supports creating and managing multiple accounts. The maximum |
| 2465 | * number of accounts is limited by a compile time constant |
| 2466 | * <tt>PJSUA_MAX_ACC</tt>. |
| 2467 | * |
| 2468 | * Account may or may not have client registration associated with it. |
| 2469 | * An account is also associated with <b>route set</b> and some <b>authentication |
| 2470 | * credentials</b>, which are used when sending SIP request messages using the |
| 2471 | * account. An account also has presence's <b>online status</b>, which |
| 2472 | * will be reported to remote peer when they subscribe to the account's |
| 2473 | * presence, or which is published to a presence server if presence |
| 2474 | * publication is enabled for the account. |
| 2475 | * |
| 2476 | * At least one account MUST be created in the application. If no user |
| 2477 | * association is required, application can create a userless account by |
| 2478 | * calling #pjsua_acc_add_local(). A userless account identifies local endpoint |
| 2479 | * instead of a particular user, and it correspond with a particular |
| 2480 | * transport instance. |
| 2481 | * |
| 2482 | * Also one account must be set as the <b>default account</b>, which is used as |
| 2483 | * the account to use when PJSUA fails to match a request with any other |
| 2484 | * accounts. |
| 2485 | * |
| 2486 | * When sending outgoing SIP requests (such as making calls or sending |
| 2487 | * instant messages), normally PJSUA requires the application to specify |
| 2488 | * which account to use for the request. If no account is specified, |
| 2489 | * PJSUA may be able to select the account by matching the destination |
| 2490 | * domain name, and fall back to default account when no match is found. |
| 2491 | */ |
| 2492 | |
| 2493 | /** |
| 2494 | * Maximum accounts. |
| 2495 | */ |
| 2496 | #ifndef PJSUA_MAX_ACC |
| 2497 | # define PJSUA_MAX_ACC 8 |
| 2498 | #endif |
| 2499 | |
| 2500 | |
| 2501 | /** |
| 2502 | * Default registration interval. |
| 2503 | */ |
| 2504 | #ifndef PJSUA_REG_INTERVAL |
| 2505 | # define PJSUA_REG_INTERVAL 300 |
| 2506 | #endif |
| 2507 | |
| 2508 | |
| 2509 | /** |
| 2510 | * Default maximum time to wait for account unregistration transactions to |
| 2511 | * complete during library shutdown sequence. |
| 2512 | * |
| 2513 | * Default: 4000 (4 seconds) |
| 2514 | */ |
| 2515 | #ifndef PJSUA_UNREG_TIMEOUT |
| 2516 | # define PJSUA_UNREG_TIMEOUT 4000 |
| 2517 | #endif |
| 2518 | |
| 2519 | |
| 2520 | /** |
| 2521 | * Default PUBLISH expiration |
| 2522 | */ |
| 2523 | #ifndef PJSUA_PUBLISH_EXPIRATION |
| 2524 | # define PJSUA_PUBLISH_EXPIRATION PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED |
| 2525 | #endif |
| 2526 | |
| 2527 | |
| 2528 | /** |
| 2529 | * Default account priority. |
| 2530 | */ |
| 2531 | #ifndef PJSUA_DEFAULT_ACC_PRIORITY |
| 2532 | # define PJSUA_DEFAULT_ACC_PRIORITY 0 |
| 2533 | #endif |
| 2534 | |
| 2535 | |
| 2536 | /** |
Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 2537 | * Maximum time to wait for unpublication transaction(s) to complete |
| 2538 | * during shutdown process, before sending unregistration. The library |
| 2539 | * tries to wait for the unpublication (un-PUBLISH) to complete before |
| 2540 | * sending REGISTER request to unregister the account, during library |
| 2541 | * shutdown process. If the value is set too short, it is possible that |
| 2542 | * the unregistration is sent before unpublication completes, causing |
| 2543 | * unpublication request to fail. |
| 2544 | * |
| 2545 | * Default: 2000 (2 seconds) |
| 2546 | */ |
| 2547 | #ifndef PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC |
| 2548 | # define PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC 2000 |
| 2549 | #endif |
| 2550 | |
| 2551 | |
| 2552 | /** |
| 2553 | * Default auto retry re-registration interval, in seconds. Set to 0 |
| 2554 | * to disable this. Application can set the timer on per account basis |
| 2555 | * by setting the pjsua_acc_config.reg_retry_interval field instead. |
| 2556 | * |
| 2557 | * Default: 300 (5 minutes) |
| 2558 | */ |
| 2559 | #ifndef PJSUA_REG_RETRY_INTERVAL |
| 2560 | # define PJSUA_REG_RETRY_INTERVAL 300 |
| 2561 | #endif |
| 2562 | |
| 2563 | |
| 2564 | /** |
| 2565 | * This macro specifies the default value for \a contact_rewrite_method |
Alexandre Lision | 94f06ba | 2013-12-09 16:28:33 -0500 | [diff] [blame] | 2566 | * field in pjsua_acc_config. It specifies how Contact update will be |
Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 2567 | * done with the registration, if \a allow_contact_rewrite is enabled in |
Alexandre Lision | 94f06ba | 2013-12-09 16:28:33 -0500 | [diff] [blame] | 2568 | * the account config. See \a pjsua_contact_rewrite_method for the options. |
Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 2569 | * |
Alexandre Lision | 94f06ba | 2013-12-09 16:28:33 -0500 | [diff] [blame] | 2570 | * Value PJSUA_CONTACT_REWRITE_UNREGISTER(1) is the legacy behavior. |
Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 2571 | * |
Alexandre Lision | 94f06ba | 2013-12-09 16:28:33 -0500 | [diff] [blame] | 2572 | * Default value: PJSUA_CONTACT_REWRITE_NO_UNREG(2) | |
| 2573 | * PJSUA_CONTACT_REWRITE_ALWAYS_UPDATE(4) |
Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 2574 | */ |
| 2575 | #ifndef PJSUA_CONTACT_REWRITE_METHOD |
Alexandre Lision | 94f06ba | 2013-12-09 16:28:33 -0500 | [diff] [blame] | 2576 | # define PJSUA_CONTACT_REWRITE_METHOD (PJSUA_CONTACT_REWRITE_NO_UNREG | \ |
| 2577 | PJSUA_CONTACT_REWRITE_ALWAYS_UPDATE) |
Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 2578 | #endif |
| 2579 | |
| 2580 | |
| 2581 | /** |
| 2582 | * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that |
| 2583 | * the global outbound proxy list should be added to the REGISTER request. |
| 2584 | */ |
| 2585 | #define PJSUA_REG_USE_OUTBOUND_PROXY 1 |
| 2586 | |
| 2587 | |
| 2588 | /** |
| 2589 | * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that |
| 2590 | * the account proxy list should be added to the REGISTER request. |
| 2591 | */ |
| 2592 | #define PJSUA_REG_USE_ACC_PROXY 2 |
| 2593 | |
| 2594 | |
| 2595 | /** |
| 2596 | * This enumeration specifies how we should offer call hold request to |
| 2597 | * remote peer. The default value is set by compile time constant |
| 2598 | * PJSUA_CALL_HOLD_TYPE_DEFAULT, and application may control the setting |
| 2599 | * on per-account basis by manipulating \a call_hold_type field in |
| 2600 | * #pjsua_acc_config. |
| 2601 | */ |
| 2602 | typedef enum pjsua_call_hold_type |
| 2603 | { |
| 2604 | /** |
| 2605 | * This will follow RFC 3264 recommendation to use a=sendonly, |
| 2606 | * a=recvonly, and a=inactive attribute as means to signal call |
| 2607 | * hold status. This is the correct value to use. |
| 2608 | */ |
| 2609 | PJSUA_CALL_HOLD_TYPE_RFC3264, |
| 2610 | |
| 2611 | /** |
| 2612 | * This will use the old and deprecated method as specified in RFC 2543, |
| 2613 | * and will offer c=0.0.0.0 in the SDP instead. Using this has many |
| 2614 | * drawbacks such as inability to keep the media transport alive while |
| 2615 | * the call is being put on hold, and should only be used if remote |
| 2616 | * does not understand RFC 3264 style call hold offer. |
| 2617 | */ |
| 2618 | PJSUA_CALL_HOLD_TYPE_RFC2543 |
| 2619 | |
| 2620 | } pjsua_call_hold_type; |
| 2621 | |
| 2622 | |
| 2623 | /** |
| 2624 | * Specify the default call hold type to be used in #pjsua_acc_config. |
| 2625 | * |
| 2626 | * Default is PJSUA_CALL_HOLD_TYPE_RFC3264, and there's no reason to change |
| 2627 | * this except if you're communicating with an old/non-standard peer. |
| 2628 | */ |
| 2629 | #ifndef PJSUA_CALL_HOLD_TYPE_DEFAULT |
| 2630 | # define PJSUA_CALL_HOLD_TYPE_DEFAULT PJSUA_CALL_HOLD_TYPE_RFC3264 |
| 2631 | #endif |
| 2632 | |
| 2633 | /** |
| 2634 | * This enumeration controls the use of STUN in the account. |
| 2635 | */ |
| 2636 | typedef enum pjsua_stun_use |
| 2637 | { |
| 2638 | /** |
| 2639 | * Follow the default setting in the global \a pjsua_config. |
| 2640 | */ |
| 2641 | PJSUA_STUN_USE_DEFAULT, |
| 2642 | |
| 2643 | /** |
| 2644 | * Disable STUN. If STUN is not enabled in the global \a pjsua_config, |
| 2645 | * this setting has no effect. |
| 2646 | */ |
| 2647 | PJSUA_STUN_USE_DISABLED |
| 2648 | |
| 2649 | } pjsua_stun_use; |
| 2650 | |
| 2651 | /** |
| 2652 | * This enumeration controls the use of ICE settings in the account. |
| 2653 | */ |
| 2654 | typedef enum pjsua_ice_config_use |
| 2655 | { |
| 2656 | /** |
| 2657 | * Use the default settings in the global \a pjsua_media_config. |
| 2658 | */ |
| 2659 | PJSUA_ICE_CONFIG_USE_DEFAULT, |
| 2660 | |
| 2661 | /** |
| 2662 | * Use the custom \a pjsua_ice_config setting in the account. |
| 2663 | */ |
| 2664 | PJSUA_ICE_CONFIG_USE_CUSTOM |
| 2665 | |
| 2666 | } pjsua_ice_config_use; |
| 2667 | |
| 2668 | /** |
| 2669 | * This enumeration controls the use of TURN settings in the account. |
| 2670 | */ |
| 2671 | typedef enum pjsua_turn_config_use |
| 2672 | { |
| 2673 | /** |
| 2674 | * Use the default setting in the global \a pjsua_media_config. |
| 2675 | */ |
| 2676 | PJSUA_TURN_CONFIG_USE_DEFAULT, |
| 2677 | |
| 2678 | /** |
| 2679 | * Use the custom \a pjsua_turn_config setting in the account. |
| 2680 | */ |
| 2681 | PJSUA_TURN_CONFIG_USE_CUSTOM |
| 2682 | |
| 2683 | } pjsua_turn_config_use; |
| 2684 | |
| 2685 | /** |
| 2686 | * ICE setting. This setting is used in the pjsua_acc_config. |
| 2687 | */ |
| 2688 | typedef struct pjsua_ice_config |
| 2689 | { |
| 2690 | /** |
| 2691 | * Enable ICE. |
| 2692 | */ |
| 2693 | pj_bool_t enable_ice; |
| 2694 | |
| 2695 | /** |
| 2696 | * Set the maximum number of host candidates. |
| 2697 | * |
| 2698 | * Default: -1 (maximum not set) |
| 2699 | */ |
| 2700 | int ice_max_host_cands; |
| 2701 | |
| 2702 | /** |
| 2703 | * ICE session options. |
| 2704 | */ |
| 2705 | pj_ice_sess_options ice_opt; |
| 2706 | |
| 2707 | /** |
| 2708 | * Disable RTCP component. |
| 2709 | * |
| 2710 | * Default: no |
| 2711 | */ |
| 2712 | pj_bool_t ice_no_rtcp; |
| 2713 | |
| 2714 | /** |
| 2715 | * Send re-INVITE/UPDATE every after ICE connectivity check regardless |
| 2716 | * the default ICE transport address is changed or not. When this is set |
| 2717 | * to PJ_FALSE, re-INVITE/UPDATE will be sent only when the default ICE |
| 2718 | * transport address is changed. |
| 2719 | * |
| 2720 | * Default: yes |
| 2721 | */ |
| 2722 | pj_bool_t ice_always_update; |
| 2723 | |
| 2724 | } pjsua_ice_config; |
| 2725 | |
| 2726 | /** |
| 2727 | * TURN setting. This setting is used in the pjsua_acc_config. |
| 2728 | */ |
| 2729 | typedef struct pjsua_turn_config |
| 2730 | { |
| 2731 | /** |
| 2732 | * Enable TURN candidate in ICE. |
| 2733 | */ |
| 2734 | pj_bool_t enable_turn; |
| 2735 | |
| 2736 | /** |
| 2737 | * Specify TURN domain name or host name, in in "DOMAIN:PORT" or |
| 2738 | * "HOST:PORT" format. |
| 2739 | */ |
| 2740 | pj_str_t turn_server; |
| 2741 | |
| 2742 | /** |
| 2743 | * Specify the connection type to be used to the TURN server. Valid |
| 2744 | * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP. |
| 2745 | * |
| 2746 | * Default: PJ_TURN_TP_UDP |
| 2747 | */ |
| 2748 | pj_turn_tp_type turn_conn_type; |
| 2749 | |
| 2750 | /** |
| 2751 | * Specify the credential to authenticate with the TURN server. |
| 2752 | */ |
| 2753 | pj_stun_auth_cred turn_auth_cred; |
| 2754 | |
| 2755 | } pjsua_turn_config; |
| 2756 | |
| 2757 | /** |
| 2758 | * Specify how IPv6 transport should be used in account config. |
| 2759 | */ |
| 2760 | typedef enum pjsua_ipv6_use |
| 2761 | { |
| 2762 | /** |
| 2763 | * IPv6 is not used. |
| 2764 | */ |
| 2765 | PJSUA_IPV6_DISABLED, |
| 2766 | |
| 2767 | /** |
| 2768 | * IPv6 is enabled. |
| 2769 | */ |
| 2770 | PJSUA_IPV6_ENABLED |
| 2771 | |
| 2772 | } pjsua_ipv6_use; |
| 2773 | |
| 2774 | /** |
| 2775 | * This structure describes account configuration to be specified when |
| 2776 | * adding a new account with #pjsua_acc_add(). Application MUST initialize |
| 2777 | * this structure first by calling #pjsua_acc_config_default(). |
| 2778 | */ |
| 2779 | typedef struct pjsua_acc_config |
| 2780 | { |
| 2781 | /** |
| 2782 | * Arbitrary user data to be associated with the newly created account. |
| 2783 | * Application may set this later with #pjsua_acc_set_user_data() and |
| 2784 | * retrieve it with #pjsua_acc_get_user_data(). |
| 2785 | */ |
| 2786 | void *user_data; |
| 2787 | |
| 2788 | /** |
| 2789 | * Account priority, which is used to control the order of matching |
| 2790 | * incoming/outgoing requests. The higher the number means the higher |
| 2791 | * the priority is, and the account will be matched first. |
| 2792 | */ |
| 2793 | int priority; |
| 2794 | |
| 2795 | /** |
| 2796 | * The full SIP URL for the account. The value can take name address or |
| 2797 | * URL format, and will look something like "sip:account@serviceprovider" |
| 2798 | * or "\"Display Name\" <sip:account@provider>". |
| 2799 | * |
| 2800 | * This field is mandatory. |
| 2801 | */ |
| 2802 | pj_str_t id; |
| 2803 | |
| 2804 | /** |
| 2805 | * This is the URL to be put in the request URI for the registration, |
| 2806 | * and will look something like "sip:serviceprovider". |
| 2807 | * |
| 2808 | * This field should be specified if registration is desired. If the |
| 2809 | * value is empty, no account registration will be performed. |
| 2810 | */ |
| 2811 | pj_str_t reg_uri; |
| 2812 | |
| 2813 | /** |
| 2814 | * The optional custom SIP headers to be put in the registration |
| 2815 | * request. |
| 2816 | */ |
| 2817 | pjsip_hdr reg_hdr_list; |
| 2818 | |
| 2819 | /** |
| 2820 | * The optional custom SIP headers to be put in the presence |
| 2821 | * subscription request. |
| 2822 | */ |
| 2823 | pjsip_hdr sub_hdr_list; |
| 2824 | |
| 2825 | /** |
| 2826 | * Subscribe to message waiting indication events (RFC 3842). |
| 2827 | * |
| 2828 | * See also \a enable_unsolicited_mwi field on #pjsua_config. |
| 2829 | * |
| 2830 | * Default: no |
| 2831 | */ |
| 2832 | pj_bool_t mwi_enabled; |
| 2833 | |
| 2834 | /** |
| 2835 | * Specify the default expiration time for Message Waiting Indication |
| 2836 | * (RFC 3842) event subscription. This must not be zero. |
| 2837 | * |
| 2838 | * Default: PJSIP_MWI_DEFAULT_EXPIRES |
| 2839 | */ |
| 2840 | unsigned mwi_expires; |
| 2841 | |
| 2842 | /** |
| 2843 | * If this flag is set, the presence information of this account will |
| 2844 | * be PUBLISH-ed to the server where the account belongs. |
| 2845 | * |
| 2846 | * Default: PJ_FALSE |
| 2847 | */ |
| 2848 | pj_bool_t publish_enabled; |
| 2849 | |
| 2850 | /** |
| 2851 | * Event publication options. |
| 2852 | */ |
| 2853 | pjsip_publishc_opt publish_opt; |
| 2854 | |
| 2855 | /** |
| 2856 | * Maximum time to wait for unpublication transaction(s) to complete |
| 2857 | * during shutdown process, before sending unregistration. The library |
| 2858 | * tries to wait for the unpublication (un-PUBLISH) to complete before |
| 2859 | * sending REGISTER request to unregister the account, during library |
| 2860 | * shutdown process. If the value is set too short, it is possible that |
| 2861 | * the unregistration is sent before unpublication completes, causing |
| 2862 | * unpublication request to fail. |
| 2863 | * |
| 2864 | * Default: PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC |
| 2865 | */ |
| 2866 | unsigned unpublish_max_wait_time_msec; |
| 2867 | |
| 2868 | /** |
| 2869 | * Authentication preference. |
| 2870 | */ |
| 2871 | pjsip_auth_clt_pref auth_pref; |
| 2872 | |
| 2873 | /** |
| 2874 | * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value |
| 2875 | * is not specified, a random string will be used. |
| 2876 | */ |
| 2877 | pj_str_t pidf_tuple_id; |
| 2878 | |
| 2879 | /** |
| 2880 | * Optional URI to be put as Contact for this account. It is recommended |
| 2881 | * that this field is left empty, so that the value will be calculated |
| 2882 | * automatically based on the transport address. |
| 2883 | */ |
| 2884 | pj_str_t force_contact; |
| 2885 | |
| 2886 | /** |
| 2887 | * Additional parameters that will be appended in the Contact header |
| 2888 | * for this account. This will affect the Contact header in all SIP |
| 2889 | * messages sent on behalf of this account, including but not limited to |
| 2890 | * REGISTER, INVITE, and SUBCRIBE requests or responses. |
| 2891 | * |
| 2892 | * The parameters should be preceeded by semicolon, and all strings must |
| 2893 | * be properly escaped. Example: |
| 2894 | * ";my-param=X;another-param=Hi%20there" |
| 2895 | */ |
| 2896 | pj_str_t contact_params; |
| 2897 | |
| 2898 | /** |
| 2899 | * Additional URI parameters that will be appended in the Contact URI |
| 2900 | * for this account. This will affect the Contact URI in all SIP |
| 2901 | * messages sent on behalf of this account, including but not limited to |
| 2902 | * REGISTER, INVITE, and SUBCRIBE requests or responses. |
| 2903 | * |
| 2904 | * The parameters should be preceeded by semicolon, and all strings must |
| 2905 | * be properly escaped. Example: |
| 2906 | * ";my-param=X;another-param=Hi%20there" |
| 2907 | */ |
| 2908 | pj_str_t contact_uri_params; |
| 2909 | |
| 2910 | /** |
| 2911 | * Specify how support for reliable provisional response (100rel/ |
| 2912 | * PRACK) should be used for all sessions in this account. See the |
| 2913 | * documentation of pjsua_100rel_use enumeration for more info. |
| 2914 | * |
| 2915 | * Default: The default value is taken from the value of |
| 2916 | * require_100rel in pjsua_config. |
| 2917 | */ |
| 2918 | pjsua_100rel_use require_100rel; |
| 2919 | |
| 2920 | /** |
| 2921 | * Specify the usage of Session Timers for all sessions. See the |
| 2922 | * #pjsua_sip_timer_use for possible values. |
| 2923 | * |
| 2924 | * Default: PJSUA_SIP_TIMER_OPTIONAL |
| 2925 | */ |
| 2926 | pjsua_sip_timer_use use_timer; |
| 2927 | |
| 2928 | /** |
| 2929 | * Specify Session Timer settings, see #pjsip_timer_setting. |
| 2930 | */ |
| 2931 | pjsip_timer_setting timer_setting; |
| 2932 | |
| 2933 | /** |
| 2934 | * Number of proxies in the proxy array below. |
| 2935 | */ |
| 2936 | unsigned proxy_cnt; |
| 2937 | |
| 2938 | /** |
| 2939 | * Optional URI of the proxies to be visited for all outgoing requests |
| 2940 | * that are using this account (REGISTER, INVITE, etc). Application need |
| 2941 | * to specify these proxies if the service provider requires that requests |
| 2942 | * destined towards its network should go through certain proxies first |
| 2943 | * (for example, border controllers). |
| 2944 | * |
| 2945 | * These proxies will be put in the route set for this account, with |
| 2946 | * maintaining the orders (the first proxy in the array will be visited |
| 2947 | * first). If global outbound proxies are configured in pjsua_config, |
| 2948 | * then these account proxies will be placed after the global outbound |
| 2949 | * proxies in the routeset. |
| 2950 | */ |
| 2951 | pj_str_t proxy[PJSUA_ACC_MAX_PROXIES]; |
| 2952 | |
| 2953 | /** |
| 2954 | * If remote sends SDP answer containing more than one format or codec in |
| 2955 | * the media line, send re-INVITE or UPDATE with just one codec to lock |
| 2956 | * which codec to use. |
| 2957 | * |
| 2958 | * Default: 1 (Yes). Set to zero to disable. |
| 2959 | */ |
| 2960 | unsigned lock_codec; |
| 2961 | |
| 2962 | /** |
| 2963 | * Optional interval for registration, in seconds. If the value is zero, |
| 2964 | * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds). |
| 2965 | */ |
| 2966 | unsigned reg_timeout; |
| 2967 | |
| 2968 | /** |
| 2969 | * Specify the number of seconds to refresh the client registration |
| 2970 | * before the registration expires. |
| 2971 | * |
| 2972 | * Default: PJSIP_REGISTER_CLIENT_DELAY_BEFORE_REFRESH, 5 seconds |
| 2973 | */ |
| 2974 | unsigned reg_delay_before_refresh; |
| 2975 | |
| 2976 | /** |
| 2977 | * Specify the maximum time to wait for unregistration requests to |
| 2978 | * complete during library shutdown sequence. |
| 2979 | * |
| 2980 | * Default: PJSUA_UNREG_TIMEOUT |
| 2981 | */ |
| 2982 | unsigned unreg_timeout; |
| 2983 | |
| 2984 | /** |
| 2985 | * Number of credentials in the credential array. |
| 2986 | */ |
| 2987 | unsigned cred_count; |
| 2988 | |
| 2989 | /** |
| 2990 | * Array of credentials. If registration is desired, normally there should |
| 2991 | * be at least one credential specified, to successfully authenticate |
| 2992 | * against the service provider. More credentials can be specified, for |
| 2993 | * example when the requests are expected to be challenged by the |
| 2994 | * proxies in the route set. |
| 2995 | */ |
| 2996 | pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES]; |
| 2997 | |
| 2998 | /** |
| 2999 | * Optionally bind this account to specific transport. This normally is |
| 3000 | * not a good idea, as account should be able to send requests using |
| 3001 | * any available transports according to the destination. But some |
| 3002 | * application may want to have explicit control over the transport to |
| 3003 | * use, so in that case it can set this field. |
| 3004 | * |
| 3005 | * Default: -1 (PJSUA_INVALID_ID) |
| 3006 | * |
| 3007 | * @see pjsua_acc_set_transport() |
| 3008 | */ |
| 3009 | pjsua_transport_id transport_id; |
| 3010 | |
| 3011 | /** |
| 3012 | * This option is used to update the transport address and the Contact |
| 3013 | * header of REGISTER request. When this option is enabled, the library |
| 3014 | * will keep track of the public IP address from the response of REGISTER |
| 3015 | * request. Once it detects that the address has changed, it will |
| 3016 | * unregister current Contact, update the Contact with transport address |
| 3017 | * learned from Via header, and register a new Contact to the registrar. |
| 3018 | * This will also update the public name of UDP transport if STUN is |
| 3019 | * configured. |
| 3020 | * |
| 3021 | * See also contact_rewrite_method field. |
| 3022 | * |
| 3023 | * Default: 1 (yes) |
| 3024 | */ |
| 3025 | pj_bool_t allow_contact_rewrite; |
| 3026 | |
| 3027 | /** |
| 3028 | * Specify how Contact update will be done with the registration, if |
Alexandre Lision | 94f06ba | 2013-12-09 16:28:33 -0500 | [diff] [blame] | 3029 | * \a allow_contact_rewrite is enabled. The value is bitmask combination of |
| 3030 | * \a pjsua_contact_rewrite_method. See also pjsua_contact_rewrite_method. |
Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 3031 | * |
Alexandre Lision | 94f06ba | 2013-12-09 16:28:33 -0500 | [diff] [blame] | 3032 | * Value PJSUA_CONTACT_REWRITE_UNREGISTER(1) is the legacy behavior. |
Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 3033 | * |
Alexandre Lision | 94f06ba | 2013-12-09 16:28:33 -0500 | [diff] [blame] | 3034 | * Default value: PJSUA_CONTACT_REWRITE_METHOD |
| 3035 | * (PJSUA_CONTACT_REWRITE_NO_UNREG | PJSUA_CONTACT_REWRITE_ALWAYS_UPDATE) |
Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 3036 | */ |
| 3037 | int contact_rewrite_method; |
| 3038 | |
| 3039 | /** |
| 3040 | * This option is used to overwrite the "sent-by" field of the Via header |
| 3041 | * for outgoing messages with the same interface address as the one in |
| 3042 | * the REGISTER request, as long as the request uses the same transport |
| 3043 | * instance as the previous REGISTER request. |
| 3044 | * |
| 3045 | * Default: 1 (yes) |
| 3046 | */ |
| 3047 | pj_bool_t allow_via_rewrite; |
| 3048 | |
| 3049 | /** |
| 3050 | * This option controls whether the IP address in SDP should be replaced |
| 3051 | * with the IP address found in Via header of the REGISTER response, ONLY |
| 3052 | * when STUN and ICE are not used. If the value is FALSE (the original |
| 3053 | * behavior), then the local IP address will be used. If TRUE, and when |
| 3054 | * STUN and ICE are disabled, then the IP address found in registration |
| 3055 | * response will be used. |
| 3056 | * |
| 3057 | * Default: PJ_FALSE (no) |
| 3058 | */ |
| 3059 | pj_bool_t allow_sdp_nat_rewrite; |
| 3060 | |
| 3061 | /** |
| 3062 | * Control the use of SIP outbound feature. SIP outbound is described in |
| 3063 | * RFC 5626 to enable proxies or registrar to send inbound requests back |
| 3064 | * to UA using the same connection initiated by the UA for its |
| 3065 | * registration. This feature is highly useful in NAT-ed deployemtns, |
| 3066 | * hence it is enabled by default. |
| 3067 | * |
| 3068 | * Note: currently SIP outbound can only be used with TCP and TLS |
| 3069 | * transports. If UDP is used for the registration, the SIP outbound |
| 3070 | * feature will be silently ignored for the account. |
| 3071 | * |
| 3072 | * Default: PJ_TRUE |
| 3073 | */ |
| 3074 | unsigned use_rfc5626; |
| 3075 | |
| 3076 | /** |
| 3077 | * Specify SIP outbound (RFC 5626) instance ID to be used by this |
| 3078 | * application. If empty, an instance ID will be generated based on |
| 3079 | * the hostname of this agent. If application specifies this parameter, the |
| 3080 | * value will look like "<urn:uuid:00000000-0000-1000-8000-AABBCCDDEEFF>" |
| 3081 | * without the doublequote. |
| 3082 | * |
| 3083 | * Default: empty |
| 3084 | */ |
| 3085 | pj_str_t rfc5626_instance_id; |
| 3086 | |
| 3087 | /** |
| 3088 | * Specify SIP outbound (RFC 5626) registration ID. The default value |
| 3089 | * is empty, which would cause the library to automatically generate |
| 3090 | * a suitable value. |
| 3091 | * |
| 3092 | * Default: empty |
| 3093 | */ |
| 3094 | pj_str_t rfc5626_reg_id; |
| 3095 | |
| 3096 | /** |
| 3097 | * Set the interval for periodic keep-alive transmission for this account. |
| 3098 | * If this value is zero, keep-alive will be disabled for this account. |
| 3099 | * The keep-alive transmission will be sent to the registrar's address, |
| 3100 | * after successful registration. |
| 3101 | * |
| 3102 | * Default: 15 (seconds) |
| 3103 | */ |
| 3104 | unsigned ka_interval; |
| 3105 | |
| 3106 | /** |
| 3107 | * Specify the data to be transmitted as keep-alive packets. |
| 3108 | * |
| 3109 | * Default: CR-LF |
| 3110 | */ |
| 3111 | pj_str_t ka_data; |
| 3112 | |
| 3113 | /** |
| 3114 | * Specify whether incoming video should be shown to screen by default. |
| 3115 | * This applies to incoming call (INVITE), incoming re-INVITE, and |
| 3116 | * incoming UPDATE requests. |
| 3117 | * |
| 3118 | * Regardless of this setting, application can detect incoming video |
| 3119 | * by implementing \a on_call_media_state() callback and enumerating |
| 3120 | * the media stream(s) with #pjsua_call_get_info(). Once incoming |
| 3121 | * video is recognised, application may retrieve the window associated |
| 3122 | * with the incoming video and show or hide it with |
| 3123 | * #pjsua_vid_win_set_show(). |
| 3124 | * |
| 3125 | * Default: PJ_FALSE |
| 3126 | */ |
| 3127 | pj_bool_t vid_in_auto_show; |
| 3128 | |
| 3129 | /** |
| 3130 | * Specify whether outgoing video should be activated by default when |
| 3131 | * making outgoing calls and/or when incoming video is detected. This |
| 3132 | * applies to incoming and outgoing calls, incoming re-INVITE, and |
| 3133 | * incoming UPDATE. If the setting is non-zero, outgoing video |
| 3134 | * transmission will be started as soon as response to these requests |
| 3135 | * is sent (or received). |
| 3136 | * |
| 3137 | * Regardless of the value of this setting, application can start and |
| 3138 | * stop outgoing video transmission with #pjsua_call_set_vid_strm(). |
| 3139 | * |
| 3140 | * Default: PJ_FALSE |
| 3141 | */ |
| 3142 | pj_bool_t vid_out_auto_transmit; |
| 3143 | |
| 3144 | /** |
| 3145 | * Specify video window's flags. The value is a bitmask combination of |
| 3146 | * #pjmedia_vid_dev_wnd_flag. |
| 3147 | * |
| 3148 | * Default: 0 |
| 3149 | */ |
| 3150 | unsigned vid_wnd_flags; |
| 3151 | |
| 3152 | /** |
| 3153 | * Specify the default capture device to be used by this account. If |
| 3154 | * \a vid_out_auto_transmit is enabled, this device will be used for |
| 3155 | * capturing video. |
| 3156 | * |
| 3157 | * Default: PJMEDIA_VID_DEFAULT_CAPTURE_DEV |
| 3158 | */ |
| 3159 | pjmedia_vid_dev_index vid_cap_dev; |
| 3160 | |
| 3161 | /** |
| 3162 | * Specify the default rendering device to be used by this account. |
| 3163 | * |
| 3164 | * Default: PJMEDIA_VID_DEFAULT_RENDER_DEV |
| 3165 | */ |
| 3166 | pjmedia_vid_dev_index vid_rend_dev; |
| 3167 | |
| 3168 | /** |
| 3169 | * Specify the send rate control for video stream. |
| 3170 | * |
| 3171 | * Default: see #pjmedia_vid_stream_rc_config |
| 3172 | */ |
| 3173 | pjmedia_vid_stream_rc_config vid_stream_rc_cfg; |
| 3174 | |
| 3175 | /** |
| 3176 | * Media transport config. |
| 3177 | */ |
| 3178 | pjsua_transport_config rtp_cfg; |
| 3179 | |
| 3180 | /** |
| 3181 | * Specify whether IPv6 should be used on media. |
| 3182 | */ |
| 3183 | pjsua_ipv6_use ipv6_media_use; |
| 3184 | |
| 3185 | /** |
| 3186 | * Control the use of STUN for the SIP signaling. |
| 3187 | * |
| 3188 | * Default: PJSUA_STUN_USE_DEFAULT |
| 3189 | */ |
| 3190 | pjsua_stun_use sip_stun_use; |
| 3191 | |
| 3192 | /** |
| 3193 | * Control the use of STUN for the media transports. |
| 3194 | * |
| 3195 | * Default: PJSUA_STUN_USE_DEFAULT |
| 3196 | */ |
| 3197 | pjsua_stun_use media_stun_use; |
| 3198 | |
| 3199 | /** |
| 3200 | * Control the use of ICE in the account. By default, the settings in the |
| 3201 | * \a pjsua_media_config will be used. |
| 3202 | * |
| 3203 | * Default: PJSUA_ICE_CONFIG_USE_DEFAULT |
| 3204 | */ |
| 3205 | pjsua_ice_config_use ice_cfg_use; |
| 3206 | |
| 3207 | /** |
| 3208 | * The custom ICE setting for this account. This setting will only be |
| 3209 | * used if \a ice_cfg_use is set to PJSUA_ICE_CONFIG_USE_CUSTOM |
| 3210 | */ |
| 3211 | pjsua_ice_config ice_cfg; |
| 3212 | |
| 3213 | /** |
| 3214 | * Control the use of TURN in the account. By default, the settings in the |
| 3215 | * \a pjsua_media_config will be used |
| 3216 | * |
| 3217 | * Default: PJSUA_TURN_CONFIG_USE_DEFAULT |
| 3218 | */ |
| 3219 | pjsua_turn_config_use turn_cfg_use; |
| 3220 | |
| 3221 | /** |
| 3222 | * The custom TURN setting for this account. This setting will only be |
| 3223 | * used if \a turn_cfg_use is set to PJSUA_TURN_CONFIG_USE_CUSTOM |
| 3224 | */ |
| 3225 | pjsua_turn_config turn_cfg; |
| 3226 | |
| 3227 | /** |
| 3228 | * Specify whether secure media transport should be used for this account. |
| 3229 | * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and |
| 3230 | * PJMEDIA_SRTP_MANDATORY. |
| 3231 | * |
| 3232 | * Default: #PJSUA_DEFAULT_USE_SRTP |
| 3233 | */ |
| 3234 | pjmedia_srtp_use use_srtp; |
| 3235 | |
| 3236 | /** |
| 3237 | * Specify whether SRTP requires secure signaling to be used. This option |
| 3238 | * is only used when \a use_srtp option above is non-zero. |
| 3239 | * |
| 3240 | * Valid values are: |
| 3241 | * 0: SRTP does not require secure signaling |
| 3242 | * 1: SRTP requires secure transport such as TLS |
| 3243 | * 2: SRTP requires secure end-to-end transport (SIPS) |
| 3244 | * |
| 3245 | * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING |
| 3246 | */ |
| 3247 | int srtp_secure_signaling; |
| 3248 | |
| 3249 | /** |
| 3250 | * This setting has been deprecated and will be ignored. |
| 3251 | */ |
| 3252 | pj_bool_t srtp_optional_dup_offer; |
| 3253 | |
| 3254 | /** |
| 3255 | * Specify interval of auto registration retry upon registration failure |
| 3256 | * (including caused by transport problem), in second. Set to 0 to |
| 3257 | * disable auto re-registration. Note that if the registration retry |
| 3258 | * occurs because of transport failure, the first retry will be done |
| 3259 | * after \a reg_first_retry_interval seconds instead. Also note that |
| 3260 | * the interval will be randomized slightly by approximately +/- ten |
| 3261 | * seconds to avoid all clients re-registering at the same time. |
| 3262 | * |
| 3263 | * See also \a reg_first_retry_interval setting. |
| 3264 | * |
| 3265 | * Default: #PJSUA_REG_RETRY_INTERVAL |
| 3266 | */ |
| 3267 | unsigned reg_retry_interval; |
| 3268 | |
| 3269 | /** |
| 3270 | * This specifies the interval for the first registration retry. The |
| 3271 | * registration retry is explained in \a reg_retry_interval. Note that |
| 3272 | * the value here will also be randomized by +/- ten seconds. |
| 3273 | * |
| 3274 | * Default: 0 |
| 3275 | */ |
| 3276 | unsigned reg_first_retry_interval; |
| 3277 | |
| 3278 | /** |
| 3279 | * Specify whether calls of the configured account should be dropped |
| 3280 | * after registration failure and an attempt of re-registration has |
| 3281 | * also failed. |
| 3282 | * |
| 3283 | * Default: PJ_FALSE (disabled) |
| 3284 | */ |
| 3285 | pj_bool_t drop_calls_on_reg_fail; |
| 3286 | |
| 3287 | /** |
| 3288 | * Specify how the registration uses the outbound and account proxy |
| 3289 | * settings. This controls if and what Route headers will appear in |
| 3290 | * the REGISTER request of this account. The value is bitmask combination |
| 3291 | * of PJSUA_REG_USE_OUTBOUND_PROXY and PJSUA_REG_USE_ACC_PROXY bits. |
| 3292 | * If the value is set to 0, the REGISTER request will not use any proxy |
| 3293 | * (i.e. it will not have any Route headers). |
| 3294 | * |
| 3295 | * Default: 3 (PJSUA_REG_USE_OUTBOUND_PROXY | PJSUA_REG_USE_ACC_PROXY) |
| 3296 | */ |
| 3297 | unsigned reg_use_proxy; |
| 3298 | |
| 3299 | #if defined(PJMEDIA_STREAM_ENABLE_KA) && (PJMEDIA_STREAM_ENABLE_KA != 0) |
| 3300 | /** |
| 3301 | * Specify whether stream keep-alive and NAT hole punching with |
| 3302 | * non-codec-VAD mechanism (see @ref PJMEDIA_STREAM_ENABLE_KA) is enabled |
| 3303 | * for this account. |
| 3304 | * |
| 3305 | * Default: PJ_FALSE (disabled) |
| 3306 | */ |
| 3307 | pj_bool_t use_stream_ka; |
| 3308 | #endif |
| 3309 | |
| 3310 | /** |
| 3311 | * Specify how to offer call hold to remote peer. Please see the |
| 3312 | * documentation on #pjsua_call_hold_type for more info. |
| 3313 | * |
| 3314 | * Default: PJSUA_CALL_HOLD_TYPE_DEFAULT |
| 3315 | */ |
| 3316 | pjsua_call_hold_type call_hold_type; |
| 3317 | |
| 3318 | |
| 3319 | /** |
| 3320 | * Specify whether the account should register as soon as it is |
| 3321 | * added to the UA. Application can set this to PJ_FALSE and control |
| 3322 | * the registration manually with pjsua_acc_set_registration(). |
| 3323 | * |
| 3324 | * Default: PJ_TRUE |
| 3325 | */ |
| 3326 | pj_bool_t register_on_acc_add; |
| 3327 | |
| 3328 | } pjsua_acc_config; |
| 3329 | |
| 3330 | |
| 3331 | /** |
| 3332 | * Initialize ICE config from a media config. If the \a pool argument |
| 3333 | * is NULL, a simple memcpy() will be used. |
| 3334 | * |
| 3335 | * @param pool Memory to duplicate strings. |
| 3336 | * @param dst Destination config. |
| 3337 | * @param src Source config. |
| 3338 | */ |
| 3339 | PJ_DECL(void) pjsua_ice_config_from_media_config(pj_pool_t *pool, |
| 3340 | pjsua_ice_config *dst, |
| 3341 | const pjsua_media_config *src); |
| 3342 | |
| 3343 | /** |
| 3344 | * Clone. If the \a pool argument is NULL, a simple memcpy() will be used. |
| 3345 | * |
| 3346 | * @param pool Memory to duplicate strings. |
| 3347 | * @param dst Destination config. |
| 3348 | * @param src Source config. |
| 3349 | */ |
| 3350 | PJ_DECL(void) pjsua_ice_config_dup( pj_pool_t *pool, |
| 3351 | pjsua_ice_config *dst, |
| 3352 | const pjsua_ice_config *src); |
| 3353 | |
| 3354 | /** |
| 3355 | * Initialize TURN config from a media config. If the \a pool argument |
| 3356 | * is NULL, a simple memcpy() will be used. |
| 3357 | * |
| 3358 | * @param pool Memory to duplicate strings. |
| 3359 | * @param dst Destination config. |
| 3360 | * @param src Source config. |
| 3361 | */ |
| 3362 | PJ_DECL(void) pjsua_turn_config_from_media_config(pj_pool_t *pool, |
| 3363 | pjsua_turn_config *dst, |
| 3364 | const pjsua_media_config *src); |
| 3365 | |
| 3366 | /** |
| 3367 | * Clone. If the \a pool argument is NULL, a simple memcpy() will be used. |
| 3368 | * |
| 3369 | * @param pool Memory to duplicate strings. |
| 3370 | * @param dst Destination config. |
| 3371 | * @param src Source config. |
| 3372 | */ |
| 3373 | PJ_DECL(void) pjsua_turn_config_dup(pj_pool_t *pool, |
| 3374 | pjsua_turn_config *dst, |
| 3375 | const pjsua_turn_config *src); |
| 3376 | |
| 3377 | /** |
| 3378 | * Call this function to initialize account config with default values. |
| 3379 | * |
| 3380 | * @param cfg The account config to be initialized. |
| 3381 | */ |
| 3382 | PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg); |
| 3383 | |
| 3384 | |
| 3385 | /** |
| 3386 | * Duplicate account config. |
| 3387 | * |
| 3388 | * @param pool Pool to be used for duplicating the config. |
| 3389 | * @param dst Destination configuration. |
| 3390 | * @param src Source configuration. |
| 3391 | */ |
| 3392 | PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool, |
| 3393 | pjsua_acc_config *dst, |
| 3394 | const pjsua_acc_config *src); |
| 3395 | |
| 3396 | |
| 3397 | /** |
| 3398 | * Account info. Application can query account info by calling |
| 3399 | * #pjsua_acc_get_info(). |
| 3400 | */ |
| 3401 | typedef struct pjsua_acc_info |
| 3402 | { |
| 3403 | /** |
| 3404 | * The account ID. |
| 3405 | */ |
| 3406 | pjsua_acc_id id; |
| 3407 | |
| 3408 | /** |
| 3409 | * Flag to indicate whether this is the default account. |
| 3410 | */ |
| 3411 | pj_bool_t is_default; |
| 3412 | |
| 3413 | /** |
| 3414 | * Account URI |
| 3415 | */ |
| 3416 | pj_str_t acc_uri; |
| 3417 | |
| 3418 | /** |
| 3419 | * Flag to tell whether this account has registration setting |
| 3420 | * (reg_uri is not empty). |
| 3421 | */ |
| 3422 | pj_bool_t has_registration; |
| 3423 | |
| 3424 | /** |
| 3425 | * An up to date expiration interval for account registration session. |
| 3426 | */ |
| 3427 | int expires; |
| 3428 | |
| 3429 | /** |
| 3430 | * Last registration status code. If status code is zero, the account |
| 3431 | * is currently not registered. Any other value indicates the SIP |
| 3432 | * status code of the registration. |
| 3433 | */ |
| 3434 | pjsip_status_code status; |
| 3435 | |
| 3436 | /** |
| 3437 | * Last registration error code. When the status field contains a SIP |
| 3438 | * status code that indicates a registration failure, last registration |
| 3439 | * error code contains the error code that causes the failure. In any |
| 3440 | * other case, its value is zero. |
| 3441 | */ |
| 3442 | pj_status_t reg_last_err; |
| 3443 | |
| 3444 | /** |
| 3445 | * String describing the registration status. |
| 3446 | */ |
| 3447 | pj_str_t status_text; |
| 3448 | |
| 3449 | /** |
| 3450 | * Presence online status for this account. |
| 3451 | */ |
| 3452 | pj_bool_t online_status; |
| 3453 | |
| 3454 | /** |
| 3455 | * Presence online status text. |
| 3456 | */ |
| 3457 | pj_str_t online_status_text; |
| 3458 | |
| 3459 | /** |
| 3460 | * Extended RPID online status information. |
| 3461 | */ |
| 3462 | pjrpid_element rpid; |
| 3463 | |
| 3464 | /** |
| 3465 | * Buffer that is used internally to store the status text. |
| 3466 | */ |
| 3467 | char buf_[PJ_ERR_MSG_SIZE]; |
| 3468 | |
| 3469 | } pjsua_acc_info; |
| 3470 | |
| 3471 | |
| 3472 | |
| 3473 | /** |
| 3474 | * Get number of current accounts. |
| 3475 | * |
| 3476 | * @return Current number of accounts. |
| 3477 | */ |
| 3478 | PJ_DECL(unsigned) pjsua_acc_get_count(void); |
| 3479 | |
| 3480 | |
| 3481 | /** |
| 3482 | * Check if the specified account ID is valid. |
| 3483 | * |
| 3484 | * @param acc_id Account ID to check. |
| 3485 | * |
| 3486 | * @return Non-zero if account ID is valid. |
| 3487 | */ |
| 3488 | PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id); |
| 3489 | |
| 3490 | |
| 3491 | /** |
| 3492 | * Set default account to be used when incoming and outgoing |
| 3493 | * requests doesn't match any accounts. |
| 3494 | * |
| 3495 | * @param acc_id The account ID to be used as default. |
| 3496 | * |
| 3497 | * @return PJ_SUCCESS on success. |
| 3498 | */ |
| 3499 | PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id); |
| 3500 | |
| 3501 | |
| 3502 | /** |
| 3503 | * Get default account to be used when receiving incoming requests (calls), |
| 3504 | * when the destination of the incoming call doesn't match any other |
| 3505 | * accounts. |
| 3506 | * |
| 3507 | * @return The default account ID, or PJSUA_INVALID_ID if no |
| 3508 | * default account is configured. |
| 3509 | */ |
| 3510 | PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void); |
| 3511 | |
| 3512 | |
| 3513 | /** |
| 3514 | * Add a new account to pjsua. PJSUA must have been initialized (with |
| 3515 | * #pjsua_init()) before calling this function. If registration is configured |
| 3516 | * for this account, this function would also start the SIP registration |
| 3517 | * session with the SIP registrar server. This SIP registration session |
| 3518 | * will be maintained internally by the library, and application doesn't |
| 3519 | * need to do anything to maintain the registration session. |
| 3520 | * |
| 3521 | * |
| 3522 | * @param acc_cfg Account configuration. |
| 3523 | * @param is_default If non-zero, this account will be set as the default |
| 3524 | * account. The default account will be used when sending |
| 3525 | * outgoing requests (e.g. making call) when no account is |
| 3526 | * specified, and when receiving incoming requests when the |
| 3527 | * request does not match any accounts. It is recommended |
| 3528 | * that default account is set to local/LAN account. |
| 3529 | * @param p_acc_id Pointer to receive account ID of the new account. |
| 3530 | * |
| 3531 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3532 | */ |
| 3533 | PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg, |
| 3534 | pj_bool_t is_default, |
| 3535 | pjsua_acc_id *p_acc_id); |
| 3536 | |
| 3537 | |
| 3538 | /** |
| 3539 | * Add a local account. A local account is used to identify local endpoint |
| 3540 | * instead of a specific user, and for this reason, a transport ID is needed |
| 3541 | * to obtain the local address information. |
| 3542 | * |
| 3543 | * @param tid Transport ID to generate account address. |
| 3544 | * @param is_default If non-zero, this account will be set as the default |
| 3545 | * account. The default account will be used when sending |
| 3546 | * outgoing requests (e.g. making call) when no account is |
| 3547 | * specified, and when receiving incoming requests when the |
| 3548 | * request does not match any accounts. It is recommended |
| 3549 | * that default account is set to local/LAN account. |
| 3550 | * @param p_acc_id Pointer to receive account ID of the new account. |
| 3551 | * |
| 3552 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3553 | */ |
| 3554 | PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid, |
| 3555 | pj_bool_t is_default, |
| 3556 | pjsua_acc_id *p_acc_id); |
| 3557 | |
| 3558 | /** |
| 3559 | * Set arbitrary data to be associated with the account. |
| 3560 | * |
| 3561 | * @param acc_id The account ID. |
| 3562 | * @param user_data User/application data. |
| 3563 | * |
| 3564 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3565 | */ |
| 3566 | PJ_DECL(pj_status_t) pjsua_acc_set_user_data(pjsua_acc_id acc_id, |
| 3567 | void *user_data); |
| 3568 | |
| 3569 | |
| 3570 | /** |
| 3571 | * Retrieve arbitrary data associated with the account. |
| 3572 | * |
| 3573 | * @param acc_id The account ID. |
| 3574 | * |
| 3575 | * @return The user data. In the case where the account ID is |
| 3576 | * not valid, NULL is returned. |
| 3577 | */ |
| 3578 | PJ_DECL(void*) pjsua_acc_get_user_data(pjsua_acc_id acc_id); |
| 3579 | |
| 3580 | |
| 3581 | /** |
| 3582 | * Delete an account. This will unregister the account from the SIP server, |
| 3583 | * if necessary, and terminate server side presence subscriptions associated |
| 3584 | * with this account. |
| 3585 | * |
| 3586 | * @param acc_id Id of the account to be deleted. |
| 3587 | * |
| 3588 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3589 | */ |
| 3590 | PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id); |
| 3591 | |
| 3592 | |
| 3593 | /** |
| 3594 | * Get current config for the account. This will copy current account setting |
| 3595 | * to the specified parameter. Note that all pointers in the settings will |
| 3596 | * point to the original settings in the account and application must not |
| 3597 | * modify the values in any way. Application must also take care that these |
| 3598 | * data is only valid until the account is destroyed. |
| 3599 | * |
| 3600 | * @param acc_id The account ID. |
Alexandre Lision | 94f06ba | 2013-12-09 16:28:33 -0500 | [diff] [blame] | 3601 | * @param pool Pool to duplicate the config. |
Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 3602 | * @param acc_cfg Structure to receive the settings. |
| 3603 | * |
| 3604 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3605 | */ |
| 3606 | PJ_DECL(pj_status_t) pjsua_acc_get_config(pjsua_acc_id acc_id, |
Alexandre Lision | 94f06ba | 2013-12-09 16:28:33 -0500 | [diff] [blame] | 3607 | pj_pool_t *pool, |
Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 3608 | pjsua_acc_config *acc_cfg); |
| 3609 | |
| 3610 | |
| 3611 | /** |
| 3612 | * Modify account information. |
| 3613 | * |
| 3614 | * @param acc_id Id of the account to be modified. |
| 3615 | * @param acc_cfg New account configuration. |
| 3616 | * |
| 3617 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3618 | */ |
| 3619 | PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id, |
| 3620 | const pjsua_acc_config *acc_cfg); |
| 3621 | |
| 3622 | |
| 3623 | /** |
| 3624 | * Modify account's presence status to be advertised to remote/presence |
| 3625 | * subscribers. This would trigger the sending of outgoing NOTIFY request |
| 3626 | * if there are server side presence subscription for this account, and/or |
| 3627 | * outgoing PUBLISH if presence publication is enabled for this account. |
| 3628 | * |
| 3629 | * @see pjsua_acc_set_online_status2() |
| 3630 | * |
| 3631 | * @param acc_id The account ID. |
| 3632 | * @param is_online True of false. |
| 3633 | * |
| 3634 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3635 | */ |
| 3636 | PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id, |
| 3637 | pj_bool_t is_online); |
| 3638 | |
| 3639 | /** |
| 3640 | * Modify account's presence status to be advertised to remote/presence |
| 3641 | * subscribers. This would trigger the sending of outgoing NOTIFY request |
| 3642 | * if there are server side presence subscription for this account, and/or |
| 3643 | * outgoing PUBLISH if presence publication is enabled for this account. |
| 3644 | * |
| 3645 | * @see pjsua_acc_set_online_status() |
| 3646 | * |
| 3647 | * @param acc_id The account ID. |
| 3648 | * @param is_online True of false. |
| 3649 | * @param pr Extended information in subset of RPID format |
| 3650 | * which allows setting custom presence text. |
| 3651 | * |
| 3652 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3653 | */ |
| 3654 | PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id, |
| 3655 | pj_bool_t is_online, |
| 3656 | const pjrpid_element *pr); |
| 3657 | |
| 3658 | /** |
| 3659 | * Update registration or perform unregistration. If registration is |
| 3660 | * configured for this account, then initial SIP REGISTER will be sent |
| 3661 | * when the account is added with #pjsua_acc_add(). Application normally |
| 3662 | * only need to call this function if it wants to manually update the |
| 3663 | * registration or to unregister from the server. |
| 3664 | * |
| 3665 | * @param acc_id The account ID. |
| 3666 | * @param renew If renew argument is zero, this will start |
| 3667 | * unregistration process. |
| 3668 | * |
| 3669 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3670 | */ |
| 3671 | PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id, |
| 3672 | pj_bool_t renew); |
| 3673 | |
| 3674 | /** |
| 3675 | * Get information about the specified account. |
| 3676 | * |
| 3677 | * @param acc_id Account identification. |
| 3678 | * @param info Pointer to receive account information. |
| 3679 | * |
| 3680 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3681 | */ |
| 3682 | PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id, |
| 3683 | pjsua_acc_info *info); |
| 3684 | |
| 3685 | |
| 3686 | /** |
| 3687 | * Enumerate all account currently active in the library. This will fill |
| 3688 | * the array with the account Ids, and application can then query the |
| 3689 | * account information for each id with #pjsua_acc_get_info(). |
| 3690 | * |
| 3691 | * @see pjsua_acc_enum_info(). |
| 3692 | * |
| 3693 | * @param ids Array of account IDs to be initialized. |
| 3694 | * @param count In input, specifies the maximum number of elements. |
| 3695 | * On return, it contains the actual number of elements. |
| 3696 | * |
| 3697 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3698 | */ |
| 3699 | PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[], |
| 3700 | unsigned *count ); |
| 3701 | |
| 3702 | |
| 3703 | /** |
| 3704 | * Enumerate account informations. |
| 3705 | * |
| 3706 | * @param info Array of account infos to be initialized. |
| 3707 | * @param count In input, specifies the maximum number of elements. |
| 3708 | * On return, it contains the actual number of elements. |
| 3709 | * |
| 3710 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3711 | */ |
| 3712 | PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[], |
| 3713 | unsigned *count ); |
| 3714 | |
| 3715 | |
| 3716 | /** |
| 3717 | * This is an internal function to find the most appropriate account to |
| 3718 | * used to reach to the specified URL. |
| 3719 | * |
| 3720 | * @param url The remote URL to reach. |
| 3721 | * |
| 3722 | * @return Account id. |
| 3723 | */ |
| 3724 | PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url); |
| 3725 | |
| 3726 | |
| 3727 | /** |
| 3728 | * This is an internal function to find the most appropriate account to be |
| 3729 | * used to handle incoming calls. |
| 3730 | * |
| 3731 | * @param rdata The incoming request message. |
| 3732 | * |
| 3733 | * @return Account id. |
| 3734 | */ |
| 3735 | PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata); |
| 3736 | |
| 3737 | |
| 3738 | /** |
| 3739 | * Create arbitrary requests using the account. Application should only use |
| 3740 | * this function to create auxiliary requests outside dialog, such as |
| 3741 | * OPTIONS, and use the call or presence API to create dialog related |
| 3742 | * requests. |
| 3743 | * |
| 3744 | * @param acc_id The account ID. |
| 3745 | * @param method The SIP method of the request. |
| 3746 | * @param target Target URI. |
| 3747 | * @param p_tdata Pointer to receive the request. |
| 3748 | * |
| 3749 | * @return PJ_SUCCESS or the error code. |
| 3750 | */ |
| 3751 | PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id, |
| 3752 | const pjsip_method *method, |
| 3753 | const pj_str_t *target, |
| 3754 | pjsip_tx_data **p_tdata); |
| 3755 | |
| 3756 | |
| 3757 | /** |
| 3758 | * Create a suitable Contact header value, based on the specified target URI |
| 3759 | * for the specified account. |
| 3760 | * |
| 3761 | * @param pool Pool to allocate memory for the string. |
| 3762 | * @param contact The string where the Contact will be stored. |
| 3763 | * @param acc_id Account ID. |
| 3764 | * @param uri Destination URI of the request. |
| 3765 | * |
| 3766 | * @return PJ_SUCCESS on success, other on error. |
| 3767 | */ |
| 3768 | PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool, |
| 3769 | pj_str_t *contact, |
| 3770 | pjsua_acc_id acc_id, |
| 3771 | const pj_str_t *uri); |
| 3772 | |
| 3773 | |
| 3774 | |
| 3775 | /** |
| 3776 | * Create a suitable Contact header value, based on the information in the |
| 3777 | * incoming request. |
| 3778 | * |
| 3779 | * @param pool Pool to allocate memory for the string. |
| 3780 | * @param contact The string where the Contact will be stored. |
| 3781 | * @param acc_id Account ID. |
| 3782 | * @param rdata Incoming request. |
| 3783 | * |
| 3784 | * @return PJ_SUCCESS on success, other on error. |
| 3785 | */ |
| 3786 | PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool, |
| 3787 | pj_str_t *contact, |
| 3788 | pjsua_acc_id acc_id, |
| 3789 | pjsip_rx_data *rdata ); |
| 3790 | |
| 3791 | |
| 3792 | /** |
| 3793 | * Lock/bind this account to a specific transport/listener. Normally |
| 3794 | * application shouldn't need to do this, as transports will be selected |
| 3795 | * automatically by the stack according to the destination. |
| 3796 | * |
| 3797 | * When account is locked/bound to a specific transport, all outgoing |
| 3798 | * requests from this account will use the specified transport (this |
| 3799 | * includes SIP registration, dialog (call and event subscription), and |
| 3800 | * out-of-dialog requests such as MESSAGE). |
| 3801 | * |
| 3802 | * Note that transport_id may be specified in pjsua_acc_config too. |
| 3803 | * |
| 3804 | * @param acc_id The account ID. |
| 3805 | * @param tp_id The transport ID. |
| 3806 | * |
| 3807 | * @return PJ_SUCCESS on success. |
| 3808 | */ |
| 3809 | PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id, |
| 3810 | pjsua_transport_id tp_id); |
| 3811 | |
| 3812 | |
| 3813 | /** |
| 3814 | * @} |
| 3815 | */ |
| 3816 | |
| 3817 | |
| 3818 | /***************************************************************************** |
| 3819 | * CALLS API |
| 3820 | */ |
| 3821 | |
| 3822 | |
| 3823 | /** |
| 3824 | * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management |
| 3825 | * @ingroup PJSUA_LIB |
| 3826 | * @brief Call manipulation. |
| 3827 | * @{ |
| 3828 | */ |
| 3829 | |
| 3830 | /** |
| 3831 | * Maximum simultaneous calls. |
| 3832 | */ |
| 3833 | #ifndef PJSUA_MAX_CALLS |
| 3834 | # define PJSUA_MAX_CALLS 32 |
| 3835 | #endif |
| 3836 | |
| 3837 | /** |
| 3838 | * Maximum active video windows |
| 3839 | */ |
| 3840 | #ifndef PJSUA_MAX_VID_WINS |
| 3841 | # define PJSUA_MAX_VID_WINS 16 |
| 3842 | #endif |
| 3843 | |
| 3844 | /** |
| 3845 | * Video window ID. |
| 3846 | */ |
| 3847 | typedef int pjsua_vid_win_id; |
| 3848 | |
| 3849 | |
| 3850 | /** |
| 3851 | * This enumeration specifies the media status of a call, and it's part |
| 3852 | * of pjsua_call_info structure. |
| 3853 | */ |
| 3854 | typedef enum pjsua_call_media_status |
| 3855 | { |
| 3856 | /** |
| 3857 | * Call currently has no media, or the media is not used. |
| 3858 | */ |
| 3859 | PJSUA_CALL_MEDIA_NONE, |
| 3860 | |
| 3861 | /** |
| 3862 | * The media is active |
| 3863 | */ |
| 3864 | PJSUA_CALL_MEDIA_ACTIVE, |
| 3865 | |
| 3866 | /** |
| 3867 | * The media is currently put on hold by local endpoint |
| 3868 | */ |
| 3869 | PJSUA_CALL_MEDIA_LOCAL_HOLD, |
| 3870 | |
| 3871 | /** |
| 3872 | * The media is currently put on hold by remote endpoint |
| 3873 | */ |
| 3874 | PJSUA_CALL_MEDIA_REMOTE_HOLD, |
| 3875 | |
| 3876 | /** |
| 3877 | * The media has reported error (e.g. ICE negotiation) |
| 3878 | */ |
| 3879 | PJSUA_CALL_MEDIA_ERROR |
| 3880 | |
| 3881 | } pjsua_call_media_status; |
| 3882 | |
| 3883 | |
| 3884 | /** |
| 3885 | * Enumeration of video keyframe request methods. Keyframe request is |
| 3886 | * triggered by decoder, usually when the incoming video stream cannot |
| 3887 | * be decoded properly due to missing video keyframe. |
| 3888 | */ |
| 3889 | typedef enum pjsua_vid_req_keyframe_method |
| 3890 | { |
| 3891 | /** |
| 3892 | * Requesting keyframe via SIP INFO message. Note that incoming keyframe |
| 3893 | * request via SIP INFO will always be handled even if this flag is unset. |
| 3894 | */ |
| 3895 | PJSUA_VID_REQ_KEYFRAME_SIP_INFO = 1, |
| 3896 | |
| 3897 | /** |
| 3898 | * Requesting keyframe via Picture Loss Indication of RTCP feedback. |
| 3899 | * This is currently not supported. |
| 3900 | */ |
| 3901 | PJSUA_VID_REQ_KEYFRAME_RTCP_PLI = 2 |
| 3902 | |
| 3903 | } pjsua_vid_req_keyframe_method; |
| 3904 | |
| 3905 | |
| 3906 | /** |
| 3907 | * Call media information. |
| 3908 | */ |
| 3909 | typedef struct pjsua_call_media_info |
| 3910 | { |
| 3911 | /** Media index in SDP. */ |
| 3912 | unsigned index; |
| 3913 | |
| 3914 | /** Media type. */ |
| 3915 | pjmedia_type type; |
| 3916 | |
| 3917 | /** Media direction. */ |
| 3918 | pjmedia_dir dir; |
| 3919 | |
| 3920 | /** Call media status. */ |
| 3921 | pjsua_call_media_status status; |
| 3922 | |
| 3923 | /** The specific media stream info. */ |
| 3924 | union { |
| 3925 | /** Audio stream */ |
| 3926 | struct { |
| 3927 | /** The conference port number for the call. */ |
| 3928 | pjsua_conf_port_id conf_slot; |
| 3929 | } aud; |
| 3930 | |
| 3931 | /** Video stream */ |
| 3932 | struct { |
| 3933 | /** |
| 3934 | * The window id for incoming video, if any, or |
| 3935 | * PJSUA_INVALID_ID. |
| 3936 | */ |
| 3937 | pjsua_vid_win_id win_in; |
| 3938 | |
| 3939 | /** The video capture device for outgoing transmission, |
| 3940 | * if any, or PJMEDIA_VID_INVALID_DEV |
| 3941 | */ |
| 3942 | pjmedia_vid_dev_index cap_dev; |
| 3943 | |
| 3944 | } vid; |
| 3945 | } stream; |
| 3946 | |
| 3947 | } pjsua_call_media_info; |
| 3948 | |
| 3949 | |
| 3950 | /** |
| 3951 | * This structure describes the information and current status of a call. |
| 3952 | */ |
| 3953 | typedef struct pjsua_call_info |
| 3954 | { |
| 3955 | /** Call identification. */ |
| 3956 | pjsua_call_id id; |
| 3957 | |
| 3958 | /** Initial call role (UAC == caller) */ |
| 3959 | pjsip_role_e role; |
| 3960 | |
| 3961 | /** The account ID where this call belongs. */ |
| 3962 | pjsua_acc_id acc_id; |
| 3963 | |
| 3964 | /** Local URI */ |
| 3965 | pj_str_t local_info; |
| 3966 | |
| 3967 | /** Local Contact */ |
| 3968 | pj_str_t local_contact; |
| 3969 | |
| 3970 | /** Remote URI */ |
| 3971 | pj_str_t remote_info; |
| 3972 | |
| 3973 | /** Remote contact */ |
| 3974 | pj_str_t remote_contact; |
| 3975 | |
| 3976 | /** Dialog Call-ID string. */ |
| 3977 | pj_str_t call_id; |
| 3978 | |
| 3979 | /** Call setting */ |
| 3980 | pjsua_call_setting setting; |
| 3981 | |
| 3982 | /** Call state */ |
| 3983 | pjsip_inv_state state; |
| 3984 | |
| 3985 | /** Text describing the state */ |
| 3986 | pj_str_t state_text; |
| 3987 | |
| 3988 | /** Last status code heard, which can be used as cause code */ |
| 3989 | pjsip_status_code last_status; |
| 3990 | |
| 3991 | /** The reason phrase describing the status. */ |
| 3992 | pj_str_t last_status_text; |
| 3993 | |
| 3994 | /** Media status of the first audio stream. */ |
| 3995 | pjsua_call_media_status media_status; |
| 3996 | |
| 3997 | /** Media direction of the first audio stream. */ |
| 3998 | pjmedia_dir media_dir; |
| 3999 | |
| 4000 | /** The conference port number for the first audio stream. */ |
| 4001 | pjsua_conf_port_id conf_slot; |
| 4002 | |
| 4003 | /** Number of active media info in this call. */ |
| 4004 | unsigned media_cnt; |
| 4005 | |
| 4006 | /** Array of active media information. */ |
| 4007 | pjsua_call_media_info media[PJMEDIA_MAX_SDP_MEDIA]; |
| 4008 | |
| 4009 | /** Number of provisional media info in this call. */ |
| 4010 | unsigned prov_media_cnt; |
| 4011 | |
| 4012 | /** Array of provisional media information. This contains the media info |
| 4013 | * in the provisioning state, that is when the media session is being |
| 4014 | * created/updated (SDP offer/answer is on progress). |
| 4015 | */ |
| 4016 | pjsua_call_media_info prov_media[PJMEDIA_MAX_SDP_MEDIA]; |
| 4017 | |
| 4018 | /** Up-to-date call connected duration (zero when call is not |
| 4019 | * established) |
| 4020 | */ |
| 4021 | pj_time_val connect_duration; |
| 4022 | |
| 4023 | /** Total call duration, including set-up time */ |
| 4024 | pj_time_val total_duration; |
| 4025 | |
| 4026 | /** Flag if remote was SDP offerer */ |
| 4027 | pj_bool_t rem_offerer; |
| 4028 | |
| 4029 | /** Number of audio streams offered by remote */ |
| 4030 | unsigned rem_aud_cnt; |
| 4031 | |
| 4032 | /** Number of video streams offered by remote */ |
| 4033 | unsigned rem_vid_cnt; |
| 4034 | |
| 4035 | /** Internal */ |
| 4036 | struct { |
| 4037 | char local_info[128]; |
| 4038 | char local_contact[128]; |
| 4039 | char remote_info[128]; |
| 4040 | char remote_contact[128]; |
| 4041 | char call_id[128]; |
| 4042 | char last_status_text[128]; |
| 4043 | } buf_; |
| 4044 | |
| 4045 | } pjsua_call_info; |
| 4046 | |
| 4047 | /** |
| 4048 | * Flags to be given to various call APIs. More than one flags may be |
| 4049 | * specified by bitmasking them. |
| 4050 | */ |
| 4051 | typedef enum pjsua_call_flag |
| 4052 | { |
| 4053 | /** |
| 4054 | * When the call is being put on hold, specify this flag to unhold it. |
| 4055 | * This flag is only valid for #pjsua_call_reinvite(). Note: for |
| 4056 | * compatibility reason, this flag must have value of 1 because |
| 4057 | * previously the unhold option is specified as boolean value. |
| 4058 | */ |
| 4059 | PJSUA_CALL_UNHOLD = 1, |
| 4060 | |
| 4061 | /** |
| 4062 | * Update the local invite session's contact with the contact URI from |
| 4063 | * the account. This flag is only valid for #pjsua_call_set_hold2(), |
| 4064 | * #pjsua_call_reinvite() and #pjsua_call_update(). This flag is useful |
| 4065 | * in IP address change situation, after the local account's Contact has |
| 4066 | * been updated (typically with re-registration) use this flag to update |
| 4067 | * the invite session with the new Contact and to inform this new Contact |
| 4068 | * to the remote peer with the outgoing re-INVITE or UPDATE. |
| 4069 | */ |
| 4070 | PJSUA_CALL_UPDATE_CONTACT = 2, |
| 4071 | |
| 4072 | /** |
| 4073 | * Include SDP "m=" line with port set to zero for each disabled media |
| 4074 | * (i.e when aud_cnt or vid_cnt is set to zero). This flag is only valid |
| 4075 | * for #pjsua_call_make_call(). |
| 4076 | */ |
| 4077 | PJSUA_CALL_INCLUDE_DISABLED_MEDIA = 4 |
| 4078 | |
| 4079 | } pjsua_call_flag; |
| 4080 | |
| 4081 | |
| 4082 | /** |
| 4083 | * Media stream info. |
| 4084 | */ |
| 4085 | typedef struct pjsua_stream_info |
| 4086 | { |
| 4087 | /** Media type of this stream. */ |
| 4088 | pjmedia_type type; |
| 4089 | |
| 4090 | /** Stream info (union). */ |
| 4091 | union { |
| 4092 | /** Audio stream info */ |
| 4093 | pjmedia_stream_info aud; |
| 4094 | |
| 4095 | /** Video stream info */ |
| 4096 | pjmedia_vid_stream_info vid; |
| 4097 | } info; |
| 4098 | |
| 4099 | } pjsua_stream_info; |
| 4100 | |
| 4101 | |
| 4102 | /** |
| 4103 | * Media stream statistic. |
| 4104 | */ |
| 4105 | typedef struct pjsua_stream_stat |
| 4106 | { |
| 4107 | /** RTCP statistic. */ |
| 4108 | pjmedia_rtcp_stat rtcp; |
| 4109 | |
| 4110 | /** Jitter buffer statistic. */ |
| 4111 | pjmedia_jb_state jbuf; |
| 4112 | |
| 4113 | } pjsua_stream_stat; |
| 4114 | |
| 4115 | /** |
| 4116 | * This enumeration represents video stream operation on a call. |
| 4117 | * See also #pjsua_call_vid_strm_op_param for further info. |
| 4118 | */ |
| 4119 | typedef enum pjsua_call_vid_strm_op |
| 4120 | { |
| 4121 | /** |
| 4122 | * No operation |
| 4123 | */ |
| 4124 | PJSUA_CALL_VID_STRM_NO_OP, |
| 4125 | |
| 4126 | /** |
| 4127 | * Add a new video stream. This will add a new m=video line to |
| 4128 | * the media, regardless of whether existing video is/are present |
| 4129 | * or not. This will cause re-INVITE or UPDATE to be sent to remote |
| 4130 | * party. |
| 4131 | */ |
| 4132 | PJSUA_CALL_VID_STRM_ADD, |
| 4133 | |
| 4134 | /** |
| 4135 | * Remove/disable an existing video stream. This will |
| 4136 | * cause re-INVITE or UPDATE to be sent to remote party. |
| 4137 | */ |
| 4138 | PJSUA_CALL_VID_STRM_REMOVE, |
| 4139 | |
| 4140 | /** |
| 4141 | * Change direction of a video stream. This operation can be used |
| 4142 | * to activate or deactivate an existing video media. This will |
| 4143 | * cause re-INVITE or UPDATE to be sent to remote party. |
| 4144 | */ |
| 4145 | PJSUA_CALL_VID_STRM_CHANGE_DIR, |
| 4146 | |
| 4147 | /** |
| 4148 | * Change capture device of a video stream. This will not send |
| 4149 | * re-INVITE or UPDATE to remote party. |
| 4150 | */ |
| 4151 | PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV, |
| 4152 | |
| 4153 | /** |
| 4154 | * Start transmitting video stream. This will cause previously |
| 4155 | * stopped stream to start transmitting again. Note that no |
| 4156 | * re-INVITE/UPDATE is to be transmitted to remote since this |
| 4157 | * operation only operates on local stream. |
| 4158 | */ |
| 4159 | PJSUA_CALL_VID_STRM_START_TRANSMIT, |
| 4160 | |
| 4161 | /** |
| 4162 | * Stop transmitting video stream. This will cause the stream to |
| 4163 | * be paused in TX direction, causing it to stop sending any video |
| 4164 | * packets. No re-INVITE/UPDATE is to be transmitted to remote |
| 4165 | * with this operation. |
| 4166 | */ |
| 4167 | PJSUA_CALL_VID_STRM_STOP_TRANSMIT, |
| 4168 | |
| 4169 | /** |
| 4170 | * Send keyframe in the video stream. This will force the stream to |
| 4171 | * generate and send video keyframe as soon as possible. No |
| 4172 | * re-INVITE/UPDATE is to be transmitted to remote with this operation. |
| 4173 | */ |
| 4174 | PJSUA_CALL_VID_STRM_SEND_KEYFRAME |
| 4175 | |
| 4176 | } pjsua_call_vid_strm_op; |
| 4177 | |
| 4178 | |
| 4179 | /** |
| 4180 | * Parameters for video stream operation on a call. Application should |
| 4181 | * use #pjsua_call_vid_strm_op_param_default() to initialize this structure |
| 4182 | * with its default values. |
| 4183 | */ |
| 4184 | typedef struct pjsua_call_vid_strm_op_param |
| 4185 | { |
| 4186 | /** |
| 4187 | * Specify the media stream index. This can be set to -1 to denote |
| 4188 | * the default video stream in the call, which is the first active |
| 4189 | * video stream or any first video stream if none is active. |
| 4190 | * |
| 4191 | * This field is valid for all video stream operations, except |
| 4192 | * PJSUA_CALL_VID_STRM_ADD. |
| 4193 | * |
| 4194 | * Default: -1 (first active video stream, or any first video stream |
| 4195 | * if none is active) |
| 4196 | */ |
| 4197 | int med_idx; |
| 4198 | |
| 4199 | /** |
| 4200 | * Specify the media stream direction. |
| 4201 | * |
| 4202 | * This field is valid for the following video stream operations: |
| 4203 | * PJSUA_CALL_VID_STRM_ADD and PJSUA_CALL_VID_STRM_CHANGE_DIR. |
| 4204 | * |
| 4205 | * Default: PJMEDIA_DIR_ENCODING_DECODING |
| 4206 | */ |
| 4207 | pjmedia_dir dir; |
| 4208 | |
| 4209 | /** |
| 4210 | * Specify the video capture device ID. This can be set to |
| 4211 | * PJMEDIA_VID_DEFAULT_CAPTURE_DEV to specify the default capture |
| 4212 | * device as configured in the account. |
| 4213 | * |
| 4214 | * This field is valid for the following video stream operations: |
| 4215 | * PJSUA_CALL_VID_STRM_ADD and PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV. |
| 4216 | * |
| 4217 | * Default: PJMEDIA_VID_DEFAULT_CAPTURE_DEV. |
| 4218 | */ |
| 4219 | pjmedia_vid_dev_index cap_dev; |
| 4220 | |
| 4221 | } pjsua_call_vid_strm_op_param; |
| 4222 | |
| 4223 | |
| 4224 | /** |
| 4225 | * Initialize call settings. |
| 4226 | * |
| 4227 | * @param opt The call setting to be initialized. |
| 4228 | */ |
| 4229 | PJ_DECL(void) pjsua_call_setting_default(pjsua_call_setting *opt); |
| 4230 | |
| 4231 | |
| 4232 | /** |
| 4233 | * Initialize video stream operation param with default values. |
| 4234 | * |
| 4235 | * @param param The video stream operation param to be initialized. |
| 4236 | */ |
| 4237 | PJ_DECL(void) |
| 4238 | pjsua_call_vid_strm_op_param_default(pjsua_call_vid_strm_op_param *param); |
| 4239 | |
| 4240 | |
| 4241 | /** |
| 4242 | * Get maximum number of calls configured in pjsua. |
| 4243 | * |
| 4244 | * @return Maximum number of calls configured. |
| 4245 | */ |
| 4246 | PJ_DECL(unsigned) pjsua_call_get_max_count(void); |
| 4247 | |
| 4248 | /** |
| 4249 | * Get number of currently active calls. |
| 4250 | * |
| 4251 | * @return Number of currently active calls. |
| 4252 | */ |
| 4253 | PJ_DECL(unsigned) pjsua_call_get_count(void); |
| 4254 | |
| 4255 | /** |
| 4256 | * Enumerate all active calls. Application may then query the information and |
| 4257 | * state of each call by calling #pjsua_call_get_info(). |
| 4258 | * |
| 4259 | * @param ids Array of account IDs to be initialized. |
| 4260 | * @param count In input, specifies the maximum number of elements. |
| 4261 | * On return, it contains the actual number of elements. |
| 4262 | * |
| 4263 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4264 | */ |
| 4265 | PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[], |
| 4266 | unsigned *count); |
| 4267 | |
| 4268 | |
| 4269 | /** |
| 4270 | * Make outgoing call to the specified URI using the specified account. |
| 4271 | * |
| 4272 | * @param acc_id The account to be used. |
| 4273 | * @param dst_uri URI to be put in the To header (normally is the same |
| 4274 | * as the target URI). |
| 4275 | * @param opt Optional call setting. This should be initialized |
| 4276 | * using #pjsua_call_setting_default(). |
| 4277 | * @param user_data Arbitrary user data to be attached to the call, and |
| 4278 | * can be retrieved later. |
| 4279 | * @param msg_data Optional headers etc to be added to outgoing INVITE |
| 4280 | * request, or NULL if no custom header is desired. |
| 4281 | * @param p_call_id Pointer to receive call identification. |
| 4282 | * |
| 4283 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4284 | */ |
| 4285 | PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id, |
| 4286 | const pj_str_t *dst_uri, |
| 4287 | const pjsua_call_setting *opt, |
| 4288 | void *user_data, |
| 4289 | const pjsua_msg_data *msg_data, |
| 4290 | pjsua_call_id *p_call_id); |
| 4291 | |
| 4292 | |
| 4293 | /** |
| 4294 | * Check if the specified call has active INVITE session and the INVITE |
| 4295 | * session has not been disconnected. |
| 4296 | * |
| 4297 | * @param call_id Call identification. |
| 4298 | * |
| 4299 | * @return Non-zero if call is active. |
| 4300 | */ |
| 4301 | PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id); |
| 4302 | |
| 4303 | |
| 4304 | /** |
| 4305 | * Check if call has an active media session. |
| 4306 | * |
| 4307 | * @param call_id Call identification. |
| 4308 | * |
| 4309 | * @return Non-zero if yes. |
| 4310 | */ |
| 4311 | PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id); |
| 4312 | |
| 4313 | |
| 4314 | /** |
| 4315 | * Get the conference port identification associated with the call. |
| 4316 | * |
| 4317 | * @param call_id Call identification. |
| 4318 | * |
| 4319 | * @return Conference port ID, or PJSUA_INVALID_ID when the |
| 4320 | * media has not been established or is not active. |
| 4321 | */ |
| 4322 | PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id); |
| 4323 | |
| 4324 | /** |
| 4325 | * Obtain detail information about the specified call. |
| 4326 | * |
| 4327 | * @param call_id Call identification. |
| 4328 | * @param info Call info to be initialized. |
| 4329 | * |
| 4330 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4331 | */ |
| 4332 | PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id, |
| 4333 | pjsua_call_info *info); |
| 4334 | |
| 4335 | /** |
| 4336 | * Check if remote peer support the specified capability. |
| 4337 | * |
| 4338 | * @param call_id Call identification. |
| 4339 | * @param htype The header type to be checked, which value may be: |
| 4340 | * - PJSIP_H_ACCEPT |
| 4341 | * - PJSIP_H_ALLOW |
| 4342 | * - PJSIP_H_SUPPORTED |
| 4343 | * @param hname If htype specifies PJSIP_H_OTHER, then the header |
| 4344 | * name must be supplied in this argument. Otherwise the |
| 4345 | * value must be set to NULL. |
| 4346 | * @param token The capability token to check. For example, if \a |
| 4347 | * htype is PJSIP_H_ALLOW, then \a token specifies the |
| 4348 | * method names; if \a htype is PJSIP_H_SUPPORTED, then |
| 4349 | * \a token specifies the extension names such as |
| 4350 | * "100rel". |
| 4351 | * |
| 4352 | * @return PJSIP_DIALOG_CAP_SUPPORTED if the specified capability |
| 4353 | * is explicitly supported, see @pjsip_dialog_cap_status |
| 4354 | * for more info. |
| 4355 | */ |
| 4356 | PJ_DECL(pjsip_dialog_cap_status) pjsua_call_remote_has_cap( |
| 4357 | pjsua_call_id call_id, |
| 4358 | int htype, |
| 4359 | const pj_str_t *hname, |
| 4360 | const pj_str_t *token); |
| 4361 | |
| 4362 | /** |
| 4363 | * Attach application specific data to the call. Application can then |
| 4364 | * inspect this data by calling #pjsua_call_get_user_data(). |
| 4365 | * |
| 4366 | * @param call_id Call identification. |
| 4367 | * @param user_data Arbitrary data to be attached to the call. |
| 4368 | * |
| 4369 | * @return The user data. |
| 4370 | */ |
| 4371 | PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id, |
| 4372 | void *user_data); |
| 4373 | |
| 4374 | |
| 4375 | /** |
| 4376 | * Get user data attached to the call, which has been previously set with |
| 4377 | * #pjsua_call_set_user_data(). |
| 4378 | * |
| 4379 | * @param call_id Call identification. |
| 4380 | * |
| 4381 | * @return The user data. |
| 4382 | */ |
| 4383 | PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id); |
| 4384 | |
| 4385 | |
| 4386 | /** |
| 4387 | * Get the NAT type of remote's endpoint. This is a proprietary feature |
| 4388 | * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp |
| 4389 | * is set in #pjsua_config. |
| 4390 | * |
| 4391 | * This function can only be called after SDP has been received from remote, |
| 4392 | * which means for incoming call, this function can be called as soon as |
| 4393 | * call is received as long as incoming call contains SDP, and for outgoing |
| 4394 | * call, this function can be called only after SDP is received (normally in |
| 4395 | * 200/OK response to INVITE). As a general case, application should call |
| 4396 | * this function after or in \a on_call_media_state() callback. |
| 4397 | * |
| 4398 | * @param call_id Call identification. |
| 4399 | * @param p_type Pointer to store the NAT type. Application can then |
| 4400 | * retrieve the string description of the NAT type |
| 4401 | * by calling pj_stun_get_nat_name(). |
| 4402 | * |
| 4403 | * @return PJ_SUCCESS on success. |
| 4404 | * |
| 4405 | * @see pjsua_get_nat_type(), nat_type_in_sdp |
| 4406 | */ |
| 4407 | PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id, |
| 4408 | pj_stun_nat_type *p_type); |
| 4409 | |
| 4410 | /** |
| 4411 | * Send response to incoming INVITE request. Depending on the status |
| 4412 | * code specified as parameter, this function may send provisional |
| 4413 | * response, establish the call, or terminate the call. See also |
| 4414 | * #pjsua_call_answer2(). |
| 4415 | * |
| 4416 | * @param call_id Incoming call identification. |
| 4417 | * @param code Status code, (100-699). |
| 4418 | * @param reason Optional reason phrase. If NULL, default text |
| 4419 | * will be used. |
| 4420 | * @param msg_data Optional list of headers etc to be added to outgoing |
| 4421 | * response message. Note that this message data will |
| 4422 | * be persistent in all next answers/responses for this |
| 4423 | * INVITE request. |
| 4424 | * |
| 4425 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4426 | */ |
| 4427 | PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id, |
| 4428 | unsigned code, |
| 4429 | const pj_str_t *reason, |
| 4430 | const pjsua_msg_data *msg_data); |
| 4431 | |
| 4432 | |
| 4433 | /** |
| 4434 | * Send response to incoming INVITE request with call setting param. |
| 4435 | * Depending on the status code specified as parameter, this function may |
| 4436 | * send provisional response, establish the call, or terminate the call. |
| 4437 | * Notes about call setting: |
| 4438 | * - if call setting is changed in the subsequent call to this function, |
| 4439 | * only the first call setting supplied will applied. So normally |
| 4440 | * application will not supply call setting before getting confirmation |
| 4441 | * from the user. |
| 4442 | * - if no call setting is supplied when SDP has to be sent, i.e: answer |
| 4443 | * with status code 183 or 2xx, the default call setting will be used, |
| 4444 | * check #pjsua_call_setting for its default values. |
| 4445 | * |
| 4446 | * @param call_id Incoming call identification. |
| 4447 | * @param opt Optional call setting. |
| 4448 | * @param code Status code, (100-699). |
| 4449 | * @param reason Optional reason phrase. If NULL, default text |
| 4450 | * will be used. |
| 4451 | * @param msg_data Optional list of headers etc to be added to outgoing |
| 4452 | * response message. Note that this message data will |
| 4453 | * be persistent in all next answers/responses for this |
| 4454 | * INVITE request. |
| 4455 | * |
| 4456 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4457 | */ |
| 4458 | PJ_DECL(pj_status_t) pjsua_call_answer2(pjsua_call_id call_id, |
| 4459 | const pjsua_call_setting *opt, |
| 4460 | unsigned code, |
| 4461 | const pj_str_t *reason, |
| 4462 | const pjsua_msg_data *msg_data); |
| 4463 | |
| 4464 | |
| 4465 | /** |
| 4466 | * Hangup call by using method that is appropriate according to the |
| 4467 | * call state. This function is different than answering the call with |
| 4468 | * 3xx-6xx response (with #pjsua_call_answer()), in that this function |
| 4469 | * will hangup the call regardless of the state and role of the call, |
| 4470 | * while #pjsua_call_answer() only works with incoming calls on EARLY |
| 4471 | * state. |
| 4472 | * |
| 4473 | * @param call_id Call identification. |
| 4474 | * @param code Optional status code to be sent when we're rejecting |
| 4475 | * incoming call. If the value is zero, "603/Decline" |
| 4476 | * will be sent. |
| 4477 | * @param reason Optional reason phrase to be sent when we're rejecting |
| 4478 | * incoming call. If NULL, default text will be used. |
| 4479 | * @param msg_data Optional list of headers etc to be added to outgoing |
| 4480 | * request/response message. |
| 4481 | * |
| 4482 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4483 | */ |
| 4484 | PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id, |
| 4485 | unsigned code, |
| 4486 | const pj_str_t *reason, |
| 4487 | const pjsua_msg_data *msg_data); |
| 4488 | |
| 4489 | /** |
| 4490 | * Accept or reject redirection response. Application MUST call this function |
| 4491 | * after it signaled PJSIP_REDIRECT_PENDING in the \a on_call_redirected() |
| 4492 | * callback, to notify the call whether to accept or reject the redirection |
| 4493 | * to the current target. Application can use the combination of |
| 4494 | * PJSIP_REDIRECT_PENDING command in \a on_call_redirected() callback and |
| 4495 | * this function to ask for user permission before redirecting the call. |
| 4496 | * |
| 4497 | * Note that if the application chooses to reject or stop redirection (by |
| 4498 | * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the |
| 4499 | * call disconnection callback will be called before this function returns. |
| 4500 | * And if the application rejects the target, the \a on_call_redirected() |
| 4501 | * callback may also be called before this function returns if there is |
| 4502 | * another target to try. |
| 4503 | * |
| 4504 | * @param call_id The call ID. |
| 4505 | * @param cmd Redirection operation to be applied to the current |
| 4506 | * target. The semantic of this argument is similar |
| 4507 | * to the description in the \a on_call_redirected() |
| 4508 | * callback, except that the PJSIP_REDIRECT_PENDING is |
| 4509 | * not accepted here. |
| 4510 | * |
| 4511 | * @return PJ_SUCCESS on successful operation. |
| 4512 | */ |
| 4513 | PJ_DECL(pj_status_t) pjsua_call_process_redirect(pjsua_call_id call_id, |
| 4514 | pjsip_redirect_op cmd); |
| 4515 | |
| 4516 | /** |
| 4517 | * Put the specified call on hold. This will send re-INVITE with the |
| 4518 | * appropriate SDP to inform remote that the call is being put on hold. |
| 4519 | * The final status of the request itself will be reported on the |
| 4520 | * \a on_call_media_state() callback, which inform the application that |
| 4521 | * the media state of the call has changed. |
| 4522 | * |
| 4523 | * @param call_id Call identification. |
| 4524 | * @param msg_data Optional message components to be sent with |
| 4525 | * the request. |
| 4526 | * |
| 4527 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4528 | */ |
| 4529 | PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id, |
| 4530 | const pjsua_msg_data *msg_data); |
| 4531 | |
| 4532 | /** |
| 4533 | * Put the specified call on hold. This will send re-INVITE with the |
| 4534 | * appropriate SDP to inform remote that the call is being put on hold. |
| 4535 | * The final status of the request itself will be reported on the |
| 4536 | * \a on_call_media_state() callback, which inform the application that |
| 4537 | * the media state of the call has changed. |
| 4538 | * |
| 4539 | * @param call_id Call identification. |
| 4540 | * @param options Bitmask of pjsua_call_flag constants. Currently, only |
| 4541 | * the flag PJSUA_CALL_UPDATE_CONTACT can be used. |
| 4542 | * @param msg_data Optional message components to be sent with |
| 4543 | * the request. |
| 4544 | * |
| 4545 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4546 | */ |
| 4547 | PJ_DECL(pj_status_t) pjsua_call_set_hold2(pjsua_call_id call_id, |
| 4548 | unsigned options, |
| 4549 | const pjsua_msg_data *msg_data); |
| 4550 | |
| 4551 | /** |
| 4552 | * Send re-INVITE to release hold. |
| 4553 | * The final status of the request itself will be reported on the |
| 4554 | * \a on_call_media_state() callback, which inform the application that |
| 4555 | * the media state of the call has changed. |
| 4556 | * |
| 4557 | * @param call_id Call identification. |
| 4558 | * @param options Bitmask of pjsua_call_flag constants. Note that |
| 4559 | * for compatibility, specifying PJ_TRUE here is |
| 4560 | * equal to specifying PJSUA_CALL_UNHOLD flag. |
| 4561 | * @param msg_data Optional message components to be sent with |
| 4562 | * the request. |
| 4563 | * |
| 4564 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4565 | */ |
| 4566 | PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id, |
| 4567 | unsigned options, |
| 4568 | const pjsua_msg_data *msg_data); |
| 4569 | |
| 4570 | |
| 4571 | /** |
| 4572 | * Send re-INVITE to release hold. |
| 4573 | * The final status of the request itself will be reported on the |
| 4574 | * \a on_call_media_state() callback, which inform the application that |
| 4575 | * the media state of the call has changed. |
| 4576 | * |
| 4577 | * @param call_id Call identification. |
| 4578 | * @param opt Optional call setting, if NULL, the current call |
| 4579 | * setting will remain unchanged. |
| 4580 | * @param msg_data Optional message components to be sent with |
| 4581 | * the request. |
| 4582 | * |
| 4583 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4584 | */ |
| 4585 | PJ_DECL(pj_status_t) pjsua_call_reinvite2(pjsua_call_id call_id, |
| 4586 | const pjsua_call_setting *opt, |
| 4587 | const pjsua_msg_data *msg_data); |
| 4588 | |
| 4589 | |
| 4590 | /** |
| 4591 | * Send UPDATE request. |
| 4592 | * |
| 4593 | * @param call_id Call identification. |
| 4594 | * @param options Bitmask of pjsua_call_flag constants. |
| 4595 | * @param msg_data Optional message components to be sent with |
| 4596 | * the request. |
| 4597 | * |
| 4598 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4599 | */ |
| 4600 | PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id, |
| 4601 | unsigned options, |
| 4602 | const pjsua_msg_data *msg_data); |
| 4603 | |
| 4604 | |
| 4605 | /** |
| 4606 | * Send UPDATE request. |
| 4607 | * |
| 4608 | * @param call_id Call identification. |
| 4609 | * @param opt Optional call setting, if NULL, the current call |
| 4610 | * setting will remain unchanged. |
| 4611 | * @param msg_data Optional message components to be sent with |
| 4612 | * the request. |
| 4613 | * |
| 4614 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4615 | */ |
| 4616 | PJ_DECL(pj_status_t) pjsua_call_update2(pjsua_call_id call_id, |
| 4617 | const pjsua_call_setting *opt, |
| 4618 | const pjsua_msg_data *msg_data); |
| 4619 | |
| 4620 | |
| 4621 | /** |
| 4622 | * Initiate call transfer to the specified address. This function will send |
| 4623 | * REFER request to instruct remote call party to initiate a new INVITE |
| 4624 | * session to the specified destination/target. |
| 4625 | * |
| 4626 | * If application is interested to monitor the successfulness and |
| 4627 | * the progress of the transfer request, it can implement |
| 4628 | * \a on_call_transfer_status() callback which will report the progress |
| 4629 | * of the call transfer request. |
| 4630 | * |
| 4631 | * @param call_id The call id to be transfered. |
| 4632 | * @param dest URI of new target to be contacted. The URI may be |
| 4633 | * in name address or addr-spec format. |
| 4634 | * @param msg_data Optional message components to be sent with |
| 4635 | * the request. |
| 4636 | * |
| 4637 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4638 | */ |
| 4639 | PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id, |
| 4640 | const pj_str_t *dest, |
| 4641 | const pjsua_msg_data *msg_data); |
| 4642 | |
| 4643 | /** |
| 4644 | * Flag to indicate that "Require: replaces" should not be put in the |
| 4645 | * outgoing INVITE request caused by REFER request created by |
| 4646 | * #pjsua_call_xfer_replaces(). |
| 4647 | */ |
| 4648 | #define PJSUA_XFER_NO_REQUIRE_REPLACES 1 |
| 4649 | |
| 4650 | /** |
| 4651 | * Initiate attended call transfer. This function will send REFER request |
| 4652 | * to instruct remote call party to initiate new INVITE session to the URL |
| 4653 | * of \a dest_call_id. The party at \a dest_call_id then should "replace" |
| 4654 | * the call with us with the new call from the REFER recipient. |
| 4655 | * |
| 4656 | * @param call_id The call id to be transfered. |
| 4657 | * @param dest_call_id The call id to be replaced. |
| 4658 | * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES |
| 4659 | * to suppress the inclusion of "Require: replaces" in |
| 4660 | * the outgoing INVITE request created by the REFER |
| 4661 | * request. |
| 4662 | * @param msg_data Optional message components to be sent with |
| 4663 | * the request. |
| 4664 | * |
| 4665 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4666 | */ |
| 4667 | PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id, |
| 4668 | pjsua_call_id dest_call_id, |
| 4669 | unsigned options, |
| 4670 | const pjsua_msg_data *msg_data); |
| 4671 | |
| 4672 | /** |
| 4673 | * Send DTMF digits to remote using RFC 2833 payload formats. |
| 4674 | * |
| 4675 | * @param call_id Call identification. |
| 4676 | * @param digits DTMF string digits to be sent. |
| 4677 | * |
| 4678 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4679 | */ |
| 4680 | PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id, |
| 4681 | const pj_str_t *digits); |
| 4682 | |
| 4683 | /** |
| 4684 | * Send instant messaging inside INVITE session. |
| 4685 | * |
| 4686 | * @param call_id Call identification. |
| 4687 | * @param mime_type Optional MIME type. If NULL, then "text/plain" is |
| 4688 | * assumed. |
| 4689 | * @param content The message content. |
| 4690 | * @param msg_data Optional list of headers etc to be included in outgoing |
| 4691 | * request. The body descriptor in the msg_data is |
| 4692 | * ignored. |
| 4693 | * @param user_data Optional user data, which will be given back when |
| 4694 | * the IM callback is called. |
| 4695 | * |
| 4696 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4697 | */ |
| 4698 | PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id, |
| 4699 | const pj_str_t *mime_type, |
| 4700 | const pj_str_t *content, |
| 4701 | const pjsua_msg_data *msg_data, |
| 4702 | void *user_data); |
| 4703 | |
| 4704 | |
| 4705 | /** |
| 4706 | * Send IM typing indication inside INVITE session. |
| 4707 | * |
| 4708 | * @param call_id Call identification. |
| 4709 | * @param is_typing Non-zero to indicate to remote that local person is |
| 4710 | * currently typing an IM. |
| 4711 | * @param msg_data Optional list of headers etc to be included in outgoing |
| 4712 | * request. |
| 4713 | * |
| 4714 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4715 | */ |
| 4716 | PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id, |
| 4717 | pj_bool_t is_typing, |
| 4718 | const pjsua_msg_data*msg_data); |
| 4719 | |
| 4720 | /** |
| 4721 | * Send arbitrary request with the call. This is useful for example to send |
| 4722 | * INFO request. Note that application should not use this function to send |
| 4723 | * requests which would change the invite session's state, such as re-INVITE, |
| 4724 | * UPDATE, PRACK, and BYE. |
| 4725 | * |
| 4726 | * @param call_id Call identification. |
| 4727 | * @param method SIP method of the request. |
| 4728 | * @param msg_data Optional message body and/or list of headers to be |
| 4729 | * included in outgoing request. |
| 4730 | * |
| 4731 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4732 | */ |
| 4733 | PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id, |
| 4734 | const pj_str_t *method, |
| 4735 | const pjsua_msg_data *msg_data); |
| 4736 | |
| 4737 | |
| 4738 | /** |
| 4739 | * Terminate all calls. This will initiate #pjsua_call_hangup() for all |
| 4740 | * currently active calls. |
| 4741 | */ |
| 4742 | PJ_DECL(void) pjsua_call_hangup_all(void); |
| 4743 | |
| 4744 | |
| 4745 | /** |
| 4746 | * Dump call and media statistics to string. |
| 4747 | * |
| 4748 | * @param call_id Call identification. |
| 4749 | * @param with_media Non-zero to include media information too. |
| 4750 | * @param buffer Buffer where the statistics are to be written to. |
| 4751 | * @param maxlen Maximum length of buffer. |
| 4752 | * @param indent Spaces for left indentation. |
| 4753 | * |
| 4754 | * @return PJ_SUCCESS on success. |
| 4755 | */ |
| 4756 | PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id, |
| 4757 | pj_bool_t with_media, |
| 4758 | char *buffer, |
| 4759 | unsigned maxlen, |
| 4760 | const char *indent); |
| 4761 | |
| 4762 | /** |
| 4763 | * Get the media stream index of the default video stream in the call. |
| 4764 | * Typically this will just retrieve the stream index of the first |
| 4765 | * activated video stream in the call. If none is active, it will return |
| 4766 | * the first inactive video stream. |
| 4767 | * |
| 4768 | * @param call_id Call identification. |
| 4769 | * |
| 4770 | * @return The media stream index or -1 if no video stream |
| 4771 | * is present in the call. |
| 4772 | */ |
| 4773 | PJ_DECL(int) pjsua_call_get_vid_stream_idx(pjsua_call_id call_id); |
| 4774 | |
| 4775 | |
| 4776 | /** |
| 4777 | * Determine if video stream for the specified call is currently running |
| 4778 | * (i.e. has been created, started, and not being paused) for the specified |
| 4779 | * direction. |
| 4780 | * |
| 4781 | * @param call_id Call identification. |
| 4782 | * @param med_idx Media stream index, or -1 to specify default video |
| 4783 | * media. |
| 4784 | * @param dir The direction to be checked. |
| 4785 | * |
| 4786 | * @return PJ_TRUE if stream is currently running for the |
| 4787 | * specified direction. |
| 4788 | */ |
| 4789 | PJ_DECL(pj_bool_t) pjsua_call_vid_stream_is_running(pjsua_call_id call_id, |
| 4790 | int med_idx, |
| 4791 | pjmedia_dir dir); |
| 4792 | |
| 4793 | /** |
| 4794 | * Add, remove, modify, and/or manipulate video media stream for the |
| 4795 | * specified call. This may trigger a re-INVITE or UPDATE to be sent |
| 4796 | * for the call. |
| 4797 | * |
| 4798 | * @param call_id Call identification. |
| 4799 | * @param op The video stream operation to be performed, |
| 4800 | * possible values are #pjsua_call_vid_strm_op. |
| 4801 | * @param param The parameters for the video stream operation, |
| 4802 | * or NULL for the default parameter values |
| 4803 | * (see #pjsua_call_vid_strm_op_param). |
| 4804 | * |
| 4805 | * @return PJ_SUCCESS on success or the appropriate error. |
| 4806 | */ |
| 4807 | PJ_DECL(pj_status_t) pjsua_call_set_vid_strm ( |
| 4808 | pjsua_call_id call_id, |
| 4809 | pjsua_call_vid_strm_op op, |
| 4810 | const pjsua_call_vid_strm_op_param *param); |
| 4811 | |
| 4812 | |
| 4813 | /** |
| 4814 | * Get media stream info for the specified media index. |
| 4815 | * |
| 4816 | * @param call_id The call identification. |
| 4817 | * @param med_idx Media stream index. |
| 4818 | * @param psi To be filled with the stream info. |
| 4819 | * |
| 4820 | * @return PJ_SUCCESS on success or the appropriate error. |
| 4821 | */ |
| 4822 | PJ_DECL(pj_status_t) pjsua_call_get_stream_info(pjsua_call_id call_id, |
| 4823 | unsigned med_idx, |
| 4824 | pjsua_stream_info *psi); |
| 4825 | |
| 4826 | /** |
| 4827 | * Get media stream statistic for the specified media index. |
| 4828 | * |
| 4829 | * @param call_id The call identification. |
| 4830 | * @param med_idx Media stream index. |
| 4831 | * @param psi To be filled with the stream statistic. |
| 4832 | * |
| 4833 | * @return PJ_SUCCESS on success or the appropriate error. |
| 4834 | */ |
| 4835 | PJ_DECL(pj_status_t) pjsua_call_get_stream_stat(pjsua_call_id call_id, |
| 4836 | unsigned med_idx, |
| 4837 | pjsua_stream_stat *stat); |
| 4838 | |
| 4839 | /** |
| 4840 | * Get media transport info for the specified media index. |
| 4841 | * |
| 4842 | * @param call_id The call identification. |
| 4843 | * @param med_idx Media stream index. |
| 4844 | * @param t To be filled with the transport info. |
| 4845 | * |
| 4846 | * @return PJ_SUCCESS on success or the appropriate error. |
| 4847 | */ |
| 4848 | PJ_DECL(pj_status_t) |
| 4849 | pjsua_call_get_med_transport_info(pjsua_call_id call_id, |
| 4850 | unsigned med_idx, |
| 4851 | pjmedia_transport_info *t); |
| 4852 | |
| 4853 | |
| 4854 | |
| 4855 | /** |
| 4856 | * @} |
| 4857 | */ |
| 4858 | |
| 4859 | |
| 4860 | /***************************************************************************** |
| 4861 | * BUDDY API |
| 4862 | */ |
| 4863 | |
| 4864 | |
| 4865 | /** |
| 4866 | * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging |
| 4867 | * @ingroup PJSUA_LIB |
| 4868 | * @brief Buddy management, buddy's presence, and instant messaging. |
| 4869 | * @{ |
| 4870 | * |
| 4871 | * This section describes PJSUA-APIs related to buddies management, |
| 4872 | * presence management, and instant messaging. |
| 4873 | */ |
| 4874 | |
| 4875 | /** |
| 4876 | * Max buddies in buddy list. |
| 4877 | */ |
| 4878 | #ifndef PJSUA_MAX_BUDDIES |
| 4879 | # define PJSUA_MAX_BUDDIES 256 |
| 4880 | #endif |
| 4881 | |
| 4882 | |
| 4883 | /** |
| 4884 | * This specifies how long the library should wait before retrying failed |
| 4885 | * SUBSCRIBE request, and there is no rule to automatically resubscribe |
| 4886 | * (for example, no "retry-after" parameter in Subscription-State header). |
| 4887 | * |
| 4888 | * This also controls the duration before failed PUBLISH request will be |
| 4889 | * retried. |
| 4890 | * |
| 4891 | * Default: 300 seconds |
| 4892 | */ |
| 4893 | #ifndef PJSUA_PRES_TIMER |
| 4894 | # define PJSUA_PRES_TIMER 300 |
| 4895 | #endif |
| 4896 | |
| 4897 | |
| 4898 | /** |
| 4899 | * This structure describes buddy configuration when adding a buddy to |
| 4900 | * the buddy list with #pjsua_buddy_add(). Application MUST initialize |
| 4901 | * the structure with #pjsua_buddy_config_default() to initialize this |
| 4902 | * structure with default configuration. |
| 4903 | */ |
| 4904 | typedef struct pjsua_buddy_config |
| 4905 | { |
| 4906 | /** |
| 4907 | * Buddy URL or name address. |
| 4908 | */ |
| 4909 | pj_str_t uri; |
| 4910 | |
| 4911 | /** |
| 4912 | * Specify whether presence subscription should start immediately. |
| 4913 | */ |
| 4914 | pj_bool_t subscribe; |
| 4915 | |
| 4916 | /** |
| 4917 | * Specify arbitrary application data to be associated with with |
| 4918 | * the buddy object. |
| 4919 | */ |
| 4920 | void *user_data; |
| 4921 | |
| 4922 | } pjsua_buddy_config; |
| 4923 | |
| 4924 | |
| 4925 | /** |
| 4926 | * This enumeration describes basic buddy's online status. |
| 4927 | */ |
| 4928 | typedef enum pjsua_buddy_status |
| 4929 | { |
| 4930 | /** |
| 4931 | * Online status is unknown (possibly because no presence subscription |
| 4932 | * has been established). |
| 4933 | */ |
| 4934 | PJSUA_BUDDY_STATUS_UNKNOWN, |
| 4935 | |
| 4936 | /** |
| 4937 | * Buddy is known to be online. |
| 4938 | */ |
| 4939 | PJSUA_BUDDY_STATUS_ONLINE, |
| 4940 | |
| 4941 | /** |
| 4942 | * Buddy is offline. |
| 4943 | */ |
| 4944 | PJSUA_BUDDY_STATUS_OFFLINE, |
| 4945 | |
| 4946 | } pjsua_buddy_status; |
| 4947 | |
| 4948 | |
| 4949 | |
| 4950 | /** |
| 4951 | * This structure describes buddy info, which can be retrieved by calling |
| 4952 | * #pjsua_buddy_get_info(). |
| 4953 | */ |
| 4954 | typedef struct pjsua_buddy_info |
| 4955 | { |
| 4956 | /** |
| 4957 | * The buddy ID. |
| 4958 | */ |
| 4959 | pjsua_buddy_id id; |
| 4960 | |
| 4961 | /** |
| 4962 | * The full URI of the buddy, as specified in the configuration. |
| 4963 | */ |
| 4964 | pj_str_t uri; |
| 4965 | |
| 4966 | /** |
| 4967 | * Buddy's Contact, only available when presence subscription has |
| 4968 | * been established to the buddy. |
| 4969 | */ |
| 4970 | pj_str_t contact; |
| 4971 | |
| 4972 | /** |
| 4973 | * Buddy's online status. |
| 4974 | */ |
| 4975 | pjsua_buddy_status status; |
| 4976 | |
| 4977 | /** |
| 4978 | * Text to describe buddy's online status. |
| 4979 | */ |
| 4980 | pj_str_t status_text; |
| 4981 | |
| 4982 | /** |
| 4983 | * Flag to indicate that we should monitor the presence information for |
| 4984 | * this buddy (normally yes, unless explicitly disabled). |
| 4985 | */ |
| 4986 | pj_bool_t monitor_pres; |
| 4987 | |
| 4988 | /** |
| 4989 | * If \a monitor_pres is enabled, this specifies the last state of the |
| 4990 | * presence subscription. If presence subscription session is currently |
| 4991 | * active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence |
| 4992 | * subscription request has been rejected, the value will be |
| 4993 | * PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be |
| 4994 | * specified in \a sub_term_reason. |
| 4995 | */ |
| 4996 | pjsip_evsub_state sub_state; |
| 4997 | |
| 4998 | /** |
| 4999 | * String representation of subscription state. |
| 5000 | */ |
| 5001 | const char *sub_state_name; |
| 5002 | |
| 5003 | /** |
| 5004 | * Specifies the last presence subscription termination code. This would |
| 5005 | * return the last status of the SUBSCRIBE request. If the subscription |
| 5006 | * is terminated with NOTIFY by the server, this value will be set to |
| 5007 | * 200, and subscription termination reason will be given in the |
| 5008 | * \a sub_term_reason field. |
| 5009 | */ |
| 5010 | unsigned sub_term_code; |
| 5011 | |
| 5012 | /** |
| 5013 | * Specifies the last presence subscription termination reason. If |
| 5014 | * presence subscription is currently active, the value will be empty. |
| 5015 | */ |
| 5016 | pj_str_t sub_term_reason; |
| 5017 | |
| 5018 | /** |
| 5019 | * Extended RPID information about the person. |
| 5020 | */ |
| 5021 | pjrpid_element rpid; |
| 5022 | |
| 5023 | /** |
| 5024 | * Extended presence info. |
| 5025 | */ |
| 5026 | pjsip_pres_status pres_status; |
| 5027 | |
| 5028 | /** |
| 5029 | * Internal buffer. |
| 5030 | */ |
| 5031 | char buf_[512]; |
| 5032 | |
| 5033 | } pjsua_buddy_info; |
| 5034 | |
| 5035 | |
| 5036 | /** |
| 5037 | * Set default values to the buddy config. |
| 5038 | */ |
| 5039 | PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg); |
| 5040 | |
| 5041 | |
| 5042 | /** |
| 5043 | * Get total number of buddies. |
| 5044 | * |
| 5045 | * @return Number of buddies. |
| 5046 | */ |
| 5047 | PJ_DECL(unsigned) pjsua_get_buddy_count(void); |
| 5048 | |
| 5049 | |
| 5050 | /** |
| 5051 | * Check if buddy ID is valid. |
| 5052 | * |
| 5053 | * @param buddy_id Buddy ID to check. |
| 5054 | * |
| 5055 | * @return Non-zero if buddy ID is valid. |
| 5056 | */ |
| 5057 | PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id); |
| 5058 | |
| 5059 | |
| 5060 | /** |
| 5061 | * Enumerate all buddy IDs in the buddy list. Application then can use |
| 5062 | * #pjsua_buddy_get_info() to get the detail information for each buddy |
| 5063 | * id. |
| 5064 | * |
| 5065 | * @param ids Array of ids to be initialized. |
| 5066 | * @param count On input, specifies max elements in the array. |
| 5067 | * On return, it contains actual number of elements |
| 5068 | * that have been initialized. |
| 5069 | * |
| 5070 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 5071 | */ |
| 5072 | PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[], |
| 5073 | unsigned *count); |
| 5074 | |
| 5075 | /** |
| 5076 | * Find the buddy ID with the specified URI. |
| 5077 | * |
| 5078 | * @param uri The buddy URI. |
| 5079 | * |
| 5080 | * @return The buddy ID, or PJSUA_INVALID_ID if not found. |
| 5081 | */ |
| 5082 | PJ_DECL(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri); |
| 5083 | |
| 5084 | |
| 5085 | /** |
| 5086 | * Get detailed buddy info. |
| 5087 | * |
| 5088 | * @param buddy_id The buddy identification. |
| 5089 | * @param info Pointer to receive information about buddy. |
| 5090 | * |
| 5091 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 5092 | */ |
| 5093 | PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id, |
| 5094 | pjsua_buddy_info *info); |
| 5095 | |
| 5096 | /** |
| 5097 | * Set the user data associated with the buddy object. |
| 5098 | * |
| 5099 | * @param buddy_id The buddy identification. |
| 5100 | * @param user_data Arbitrary application data to be associated with |
| 5101 | * the buddy object. |
| 5102 | * |
| 5103 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 5104 | */ |
| 5105 | PJ_DECL(pj_status_t) pjsua_buddy_set_user_data(pjsua_buddy_id buddy_id, |
| 5106 | void *user_data); |
| 5107 | |
| 5108 | |
| 5109 | /** |
| 5110 | * Get the user data associated with the budy object. |
| 5111 | * |
| 5112 | * @param buddy_id The buddy identification. |
| 5113 | * |
| 5114 | * @return The application data. |
| 5115 | */ |
| 5116 | PJ_DECL(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id); |
| 5117 | |
| 5118 | |
| 5119 | /** |
| 5120 | * Add new buddy to the buddy list. If presence subscription is enabled |
| 5121 | * for this buddy, this function will also start the presence subscription |
| 5122 | * session immediately. |
| 5123 | * |
| 5124 | * @param buddy_cfg Buddy configuration. |
| 5125 | * @param p_buddy_id Pointer to receive buddy ID. |
| 5126 | * |
| 5127 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 5128 | */ |
| 5129 | PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg, |
| 5130 | pjsua_buddy_id *p_buddy_id); |
| 5131 | |
| 5132 | |
| 5133 | /** |
| 5134 | * Delete the specified buddy from the buddy list. Any presence subscription |
| 5135 | * to this buddy will be terminated. |
| 5136 | * |
| 5137 | * @param buddy_id Buddy identification. |
| 5138 | * |
| 5139 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 5140 | */ |
| 5141 | PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id); |
| 5142 | |
| 5143 | |
| 5144 | /** |
| 5145 | * Enable/disable buddy's presence monitoring. Once buddy's presence is |
| 5146 | * subscribed, application will be informed about buddy's presence status |
| 5147 | * changed via \a on_buddy_state() callback. |
| 5148 | * |
| 5149 | * @param buddy_id Buddy identification. |
| 5150 | * @param subscribe Specify non-zero to activate presence subscription to |
| 5151 | * the specified buddy. |
| 5152 | * |
| 5153 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 5154 | */ |
| 5155 | PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id, |
| 5156 | pj_bool_t subscribe); |
| 5157 | |
| 5158 | |
| 5159 | /** |
| 5160 | * Update the presence information for the buddy. Although the library |
| 5161 | * periodically refreshes the presence subscription for all buddies, some |
| 5162 | * application may want to refresh the buddy's presence subscription |
| 5163 | * immediately, and in this case it can use this function to accomplish |
| 5164 | * this. |
| 5165 | * |
| 5166 | * Note that the buddy's presence subscription will only be initiated |
| 5167 | * if presence monitoring is enabled for the buddy. See |
| 5168 | * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription |
| 5169 | * for the buddy is already active, this function will not do anything. |
| 5170 | * |
| 5171 | * Once the presence subscription is activated successfully for the buddy, |
| 5172 | * application will be notified about the buddy's presence status in the |
| 5173 | * on_buddy_state() callback. |
| 5174 | * |
| 5175 | * @param buddy_id Buddy identification. |
| 5176 | * |
| 5177 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 5178 | */ |
| 5179 | PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id); |
| 5180 | |
| 5181 | |
| 5182 | /** |
| 5183 | * Send NOTIFY to inform account presence status or to terminate server |
| 5184 | * side presence subscription. If application wants to reject the incoming |
| 5185 | * request, it should set the \a state to PJSIP_EVSUB_STATE_TERMINATED. |
| 5186 | * |
| 5187 | * @param acc_id Account ID. |
| 5188 | * @param srv_pres Server presence subscription instance. |
| 5189 | * @param state New state to set. |
| 5190 | * @param state_str Optionally specify the state string name, if state |
| 5191 | * is not "active", "pending", or "terminated". |
| 5192 | * @param reason If the new state is PJSIP_EVSUB_STATE_TERMINATED, |
| 5193 | * optionally specify the termination reason. |
| 5194 | * @param with_body If the new state is PJSIP_EVSUB_STATE_TERMINATED, |
| 5195 | * this specifies whether the NOTIFY request should |
| 5196 | * contain message body containing account's presence |
| 5197 | * information. |
| 5198 | * @param msg_data Optional list of headers to be sent with the NOTIFY |
| 5199 | * request. |
| 5200 | * |
| 5201 | * @return PJ_SUCCESS on success. |
| 5202 | */ |
| 5203 | PJ_DECL(pj_status_t) pjsua_pres_notify(pjsua_acc_id acc_id, |
| 5204 | pjsua_srv_pres *srv_pres, |
| 5205 | pjsip_evsub_state state, |
| 5206 | const pj_str_t *state_str, |
| 5207 | const pj_str_t *reason, |
| 5208 | pj_bool_t with_body, |
| 5209 | const pjsua_msg_data *msg_data); |
| 5210 | |
| 5211 | /** |
| 5212 | * Dump presence subscriptions to log. |
| 5213 | * |
| 5214 | * @param verbose Yes or no. |
| 5215 | */ |
| 5216 | PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose); |
| 5217 | |
| 5218 | |
| 5219 | /** |
| 5220 | * The MESSAGE method (defined in pjsua_im.c) |
| 5221 | */ |
| 5222 | extern const pjsip_method pjsip_message_method; |
| 5223 | |
| 5224 | |
| 5225 | /** |
| 5226 | * The INFO method (defined in pjsua_call.c) |
| 5227 | */ |
| 5228 | extern const pjsip_method pjsip_info_method; |
| 5229 | |
| 5230 | |
| 5231 | /** |
| 5232 | * Send instant messaging outside dialog, using the specified account for |
| 5233 | * route set and authentication. |
| 5234 | * |
| 5235 | * @param acc_id Account ID to be used to send the request. |
| 5236 | * @param to Remote URI. |
| 5237 | * @param mime_type Optional MIME type. If NULL, then "text/plain" is |
| 5238 | * assumed. |
| 5239 | * @param content The message content. |
| 5240 | * @param msg_data Optional list of headers etc to be included in outgoing |
| 5241 | * request. The body descriptor in the msg_data is |
| 5242 | * ignored. |
| 5243 | * @param user_data Optional user data, which will be given back when |
| 5244 | * the IM callback is called. |
| 5245 | * |
| 5246 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 5247 | */ |
| 5248 | PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id, |
| 5249 | const pj_str_t *to, |
| 5250 | const pj_str_t *mime_type, |
| 5251 | const pj_str_t *content, |
| 5252 | const pjsua_msg_data *msg_data, |
| 5253 | void *user_data); |
| 5254 | |
| 5255 | |
| 5256 | /** |
| 5257 | * Send typing indication outside dialog. |
| 5258 | * |
| 5259 | * @param acc_id Account ID to be used to send the request. |
| 5260 | * @param to Remote URI. |
| 5261 | * @param is_typing If non-zero, it tells remote person that local person |
| 5262 | * is currently composing an IM. |
| 5263 | * @param msg_data Optional list of headers etc to be added to outgoing |
| 5264 | * request. |
| 5265 | * |
| 5266 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 5267 | */ |
| 5268 | PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id, |
| 5269 | const pj_str_t *to, |
| 5270 | pj_bool_t is_typing, |
| 5271 | const pjsua_msg_data *msg_data); |
| 5272 | |
| 5273 | |
| 5274 | |
| 5275 | /** |
| 5276 | * @} |
| 5277 | */ |
| 5278 | |
| 5279 | |
| 5280 | /***************************************************************************** |
| 5281 | * MEDIA API |
| 5282 | */ |
| 5283 | |
| 5284 | |
| 5285 | /** |
| 5286 | * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation |
| 5287 | * @ingroup PJSUA_LIB |
| 5288 | * @brief Media manipulation. |
| 5289 | * @{ |
| 5290 | * |
| 5291 | * PJSUA has rather powerful media features, which are built around the |
| 5292 | * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV |
| 5293 | * players, WAV playlist, file recorders, sound device, tone generators, etc) |
| 5294 | * are terminated in the conference bridge, and application can manipulate |
| 5295 | * the interconnection between these terminations freely. |
| 5296 | * |
| 5297 | * The conference bridge provides powerful switching and mixing functionality |
| 5298 | * for application. With the conference bridge, each conference slot (e.g. |
| 5299 | * a call) can transmit to multiple destinations, and one destination can |
| 5300 | * receive from multiple sources. If more than one media terminations are |
| 5301 | * terminated in the same slot, the conference bridge will mix the signal |
| 5302 | * automatically. |
| 5303 | * |
| 5304 | * Application connects one media termination/slot to another by calling |
| 5305 | * #pjsua_conf_connect() function. This will establish <b>unidirectional</b> |
| 5306 | * media flow from the source termination to the sink termination. To |
| 5307 | * establish bidirectional media flow, application wound need to make another |
| 5308 | * call to #pjsua_conf_connect(), this time inverting the source and |
| 5309 | * destination slots in the parameter. |
| 5310 | * |
| 5311 | * For example, to stream a WAV file to remote call, application may use |
| 5312 | * the following steps: |
| 5313 | * |
| 5314 | \code |
| 5315 | |
| 5316 | pj_status_t stream_to_call( pjsua_call_id call_id ) |
| 5317 | { |
| 5318 | pjsua_player_id player_id; |
| 5319 | |
| 5320 | status = pjsua_player_create("mysong.wav", 0, &player_id); |
| 5321 | if (status != PJ_SUCCESS) |
| 5322 | return status; |
| 5323 | |
| 5324 | status = pjsua_conf_connect( pjsua_player_get_conf_port(), |
| 5325 | pjsua_call_get_conf_port() ); |
| 5326 | } |
| 5327 | \endcode |
| 5328 | * |
| 5329 | * |
| 5330 | * Other features of PJSUA media: |
| 5331 | * - efficient N to M interconnections between media terminations. |
| 5332 | * - media termination can be connected to itself to create loopback |
| 5333 | * media. |
| 5334 | * - the media termination may have different clock rates, and resampling |
| 5335 | * will be done automatically by conference bridge. |
| 5336 | * - media terminations may also have different frame time; the |
| 5337 | * conference bridge will perform the necessary bufferring to adjust |
| 5338 | * the difference between terminations. |
| 5339 | * - interconnections are removed automatically when media termination |
| 5340 | * is removed from the bridge. |
| 5341 | * - sound device may be changed even when there are active media |
| 5342 | * interconnections. |
| 5343 | * - correctly report call's media quality (in #pjsua_call_dump()) from |
| 5344 | * RTCP packet exchange. |
| 5345 | */ |
| 5346 | |
| 5347 | /** |
| 5348 | * Use PJMEDIA for media? Set this to zero when using third party media |
| 5349 | * stack. |
| 5350 | */ |
| 5351 | #ifndef PJSUA_MEDIA_HAS_PJMEDIA |
| 5352 | # define PJSUA_MEDIA_HAS_PJMEDIA 1 |
| 5353 | #endif /* PJSUA_MEDIA_HAS_PJMEDIA */ |
| 5354 | |
| 5355 | |
| 5356 | /** |
| 5357 | * Specify whether the third party stream has the capability of retrieving |
| 5358 | * the stream info, i.e: pjmedia_stream_get_info() and |
| 5359 | * pjmedia_vid_stream_get_info(). Currently this capability is required |
| 5360 | * by smart media update and call dump. |
| 5361 | */ |
| 5362 | #ifndef PJSUA_THIRD_PARTY_STREAM_HAS_GET_INFO |
| 5363 | # define PJSUA_THIRD_PARTY_STREAM_HAS_GET_INFO 0 |
| 5364 | #endif |
| 5365 | |
| 5366 | |
| 5367 | /** |
| 5368 | * Specify whether the third party stream has the capability of retrieving |
| 5369 | * the stream statistics, i.e: pjmedia_stream_get_stat() and |
| 5370 | * pjmedia_vid_stream_get_stat(). Currently this capability is required |
| 5371 | * by call dump. |
| 5372 | */ |
| 5373 | #ifndef PJSUA_THIRD_PARTY_STREAM_HAS_GET_STAT |
| 5374 | # define PJSUA_THIRD_PARTY_STREAM_HAS_GET_STAT 0 |
| 5375 | #endif |
| 5376 | |
| 5377 | |
| 5378 | /** |
| 5379 | * Max ports in the conference bridge. This setting is the default value |
| 5380 | * for pjsua_media_config.max_media_ports. |
| 5381 | */ |
| 5382 | #ifndef PJSUA_MAX_CONF_PORTS |
| 5383 | # define PJSUA_MAX_CONF_PORTS 254 |
| 5384 | #endif |
| 5385 | |
| 5386 | /** |
| 5387 | * The default clock rate to be used by the conference bridge. This setting |
| 5388 | * is the default value for pjsua_media_config.clock_rate. |
| 5389 | */ |
| 5390 | #ifndef PJSUA_DEFAULT_CLOCK_RATE |
| 5391 | # define PJSUA_DEFAULT_CLOCK_RATE 16000 |
| 5392 | #endif |
| 5393 | |
| 5394 | /** |
| 5395 | * Default frame length in the conference bridge. This setting |
| 5396 | * is the default value for pjsua_media_config.audio_frame_ptime. |
| 5397 | */ |
| 5398 | #ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME |
| 5399 | # define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20 |
| 5400 | #endif |
| 5401 | |
| 5402 | |
| 5403 | /** |
| 5404 | * Default codec quality settings. This setting is the default value |
| 5405 | * for pjsua_media_config.quality. |
| 5406 | */ |
| 5407 | #ifndef PJSUA_DEFAULT_CODEC_QUALITY |
| 5408 | # define PJSUA_DEFAULT_CODEC_QUALITY 8 |
| 5409 | #endif |
| 5410 | |
| 5411 | /** |
| 5412 | * Default iLBC mode. This setting is the default value for |
| 5413 | * pjsua_media_config.ilbc_mode. |
| 5414 | */ |
| 5415 | #ifndef PJSUA_DEFAULT_ILBC_MODE |
| 5416 | # define PJSUA_DEFAULT_ILBC_MODE 30 |
| 5417 | #endif |
| 5418 | |
| 5419 | /** |
| 5420 | * The default echo canceller tail length. This setting |
| 5421 | * is the default value for pjsua_media_config.ec_tail_len. |
| 5422 | */ |
| 5423 | #ifndef PJSUA_DEFAULT_EC_TAIL_LEN |
| 5424 | # define PJSUA_DEFAULT_EC_TAIL_LEN 200 |
| 5425 | #endif |
| 5426 | |
| 5427 | |
| 5428 | /** |
| 5429 | * The maximum file player. |
| 5430 | */ |
| 5431 | #ifndef PJSUA_MAX_PLAYERS |
| 5432 | # define PJSUA_MAX_PLAYERS 32 |
| 5433 | #endif |
| 5434 | |
| 5435 | |
| 5436 | /** |
| 5437 | * The maximum file player. |
| 5438 | */ |
| 5439 | #ifndef PJSUA_MAX_RECORDERS |
| 5440 | # define PJSUA_MAX_RECORDERS 32 |
| 5441 | #endif |
| 5442 | |
| 5443 | |
| 5444 | /** |
| 5445 | * Enable/disable "c=" line in SDP session level. Set to zero to disable it. |
| 5446 | */ |
| 5447 | #ifndef PJSUA_SDP_SESS_HAS_CONN |
| 5448 | # define PJSUA_SDP_SESS_HAS_CONN 0 |
| 5449 | #endif |
| 5450 | |
| 5451 | |
| 5452 | /** |
| 5453 | * This structure describes media configuration, which will be specified |
| 5454 | * when calling #pjsua_init(). Application MUST initialize this structure |
| 5455 | * by calling #pjsua_media_config_default(). |
| 5456 | */ |
| 5457 | struct pjsua_media_config |
| 5458 | { |
| 5459 | /** |
| 5460 | * Clock rate to be applied to the conference bridge. |
| 5461 | * If value is zero, default clock rate will be used |
| 5462 | * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz). |
| 5463 | */ |
| 5464 | unsigned clock_rate; |
| 5465 | |
| 5466 | /** |
| 5467 | * Clock rate to be applied when opening the sound device. |
| 5468 | * If value is zero, conference bridge clock rate will be used. |
| 5469 | */ |
| 5470 | unsigned snd_clock_rate; |
| 5471 | |
| 5472 | /** |
| 5473 | * Channel count be applied when opening the sound device and |
| 5474 | * conference bridge. |
| 5475 | */ |
| 5476 | unsigned channel_count; |
| 5477 | |
| 5478 | /** |
| 5479 | * Specify audio frame ptime. The value here will affect the |
| 5480 | * samples per frame of both the sound device and the conference |
| 5481 | * bridge. Specifying lower ptime will normally reduce the |
| 5482 | * latency. |
| 5483 | * |
| 5484 | * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME |
| 5485 | */ |
| 5486 | unsigned audio_frame_ptime; |
| 5487 | |
| 5488 | /** |
| 5489 | * Specify maximum number of media ports to be created in the |
| 5490 | * conference bridge. Since all media terminate in the bridge |
| 5491 | * (calls, file player, file recorder, etc), the value must be |
| 5492 | * large enough to support all of them. However, the larger |
| 5493 | * the value, the more computations are performed. |
| 5494 | * |
| 5495 | * Default value: PJSUA_MAX_CONF_PORTS |
| 5496 | */ |
| 5497 | unsigned max_media_ports; |
| 5498 | |
| 5499 | /** |
| 5500 | * Specify whether the media manager should manage its own |
| 5501 | * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created |
| 5502 | * and at least one worker thread will be created too. If no, |
| 5503 | * the RTP/RTCP sockets will share the same ioqueue as SIP sockets, |
| 5504 | * and no worker thread is needed. |
| 5505 | * |
| 5506 | * Normally application would say yes here, unless it wants to |
| 5507 | * run everything from a single thread. |
| 5508 | */ |
| 5509 | pj_bool_t has_ioqueue; |
| 5510 | |
| 5511 | /** |
| 5512 | * Specify the number of worker threads to handle incoming RTP |
| 5513 | * packets. A value of one is recommended for most applications. |
| 5514 | */ |
| 5515 | unsigned thread_cnt; |
| 5516 | |
| 5517 | /** |
| 5518 | * Media quality, 0-10, according to this table: |
| 5519 | * 5-10: resampling use large filter, |
| 5520 | * 3-4: resampling use small filter, |
| 5521 | * 1-2: resampling use linear. |
| 5522 | * The media quality also sets speex codec quality/complexity to the |
| 5523 | * number. |
| 5524 | * |
| 5525 | * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY). |
| 5526 | */ |
| 5527 | unsigned quality; |
| 5528 | |
| 5529 | /** |
| 5530 | * Specify default codec ptime. |
| 5531 | * |
| 5532 | * Default: 0 (codec specific) |
| 5533 | */ |
| 5534 | unsigned ptime; |
| 5535 | |
| 5536 | /** |
| 5537 | * Disable VAD? |
| 5538 | * |
| 5539 | * Default: 0 (no (meaning VAD is enabled)) |
| 5540 | */ |
| 5541 | pj_bool_t no_vad; |
| 5542 | |
| 5543 | /** |
| 5544 | * iLBC mode (20 or 30). |
| 5545 | * |
| 5546 | * Default: 30 (PJSUA_DEFAULT_ILBC_MODE) |
| 5547 | */ |
| 5548 | unsigned ilbc_mode; |
| 5549 | |
| 5550 | /** |
| 5551 | * Percentage of RTP packet to drop in TX direction |
| 5552 | * (to simulate packet lost). |
| 5553 | * |
| 5554 | * Default: 0 |
| 5555 | */ |
| 5556 | unsigned tx_drop_pct; |
| 5557 | |
| 5558 | /** |
| 5559 | * Percentage of RTP packet to drop in RX direction |
| 5560 | * (to simulate packet lost). |
| 5561 | * |
| 5562 | * Default: 0 |
| 5563 | */ |
| 5564 | unsigned rx_drop_pct; |
| 5565 | |
| 5566 | /** |
| 5567 | * Echo canceller options (see #pjmedia_echo_create()) |
| 5568 | * |
| 5569 | * Default: 0. |
| 5570 | */ |
| 5571 | unsigned ec_options; |
| 5572 | |
| 5573 | /** |
| 5574 | * Echo canceller tail length, in miliseconds. |
| 5575 | * |
| 5576 | * Default: PJSUA_DEFAULT_EC_TAIL_LEN |
| 5577 | */ |
| 5578 | unsigned ec_tail_len; |
| 5579 | |
| 5580 | /** |
| 5581 | * Audio capture buffer length, in milliseconds. |
| 5582 | * |
| 5583 | * Default: PJMEDIA_SND_DEFAULT_REC_LATENCY |
| 5584 | */ |
| 5585 | unsigned snd_rec_latency; |
| 5586 | |
| 5587 | /** |
| 5588 | * Audio playback buffer length, in milliseconds. |
| 5589 | * |
| 5590 | * Default: PJMEDIA_SND_DEFAULT_PLAY_LATENCY |
| 5591 | */ |
| 5592 | unsigned snd_play_latency; |
| 5593 | |
| 5594 | /** |
| 5595 | * Jitter buffer initial prefetch delay in msec. The value must be |
Alexandre Lision | 8af73cb | 2013-12-10 14:11:20 -0500 | [diff] [blame] | 5596 | * between jb_min_pre and jb_max_pre below. If the value is 0, |
| 5597 | * prefetching will be disabled. |
Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 5598 | * |
Alexandre Lision | 8af73cb | 2013-12-10 14:11:20 -0500 | [diff] [blame] | 5599 | * Default: -1 (to use default stream settings, currently 0) |
Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 5600 | */ |
| 5601 | int jb_init; |
| 5602 | |
| 5603 | /** |
| 5604 | * Jitter buffer minimum prefetch delay in msec. |
| 5605 | * |
| 5606 | * Default: -1 (to use default stream settings, currently 60 msec) |
| 5607 | */ |
| 5608 | int jb_min_pre; |
| 5609 | |
| 5610 | /** |
| 5611 | * Jitter buffer maximum prefetch delay in msec. |
| 5612 | * |
| 5613 | * Default: -1 (to use default stream settings, currently 240 msec) |
| 5614 | */ |
| 5615 | int jb_max_pre; |
| 5616 | |
| 5617 | /** |
| 5618 | * Set maximum delay that can be accomodated by the jitter buffer msec. |
| 5619 | * |
| 5620 | * Default: -1 (to use default stream settings, currently 360 msec) |
| 5621 | */ |
| 5622 | int jb_max; |
| 5623 | |
| 5624 | /** |
| 5625 | * Enable ICE |
| 5626 | */ |
| 5627 | pj_bool_t enable_ice; |
| 5628 | |
| 5629 | /** |
| 5630 | * Set the maximum number of host candidates. |
| 5631 | * |
| 5632 | * Default: -1 (maximum not set) |
| 5633 | */ |
| 5634 | int ice_max_host_cands; |
| 5635 | |
| 5636 | /** |
| 5637 | * ICE session options. |
| 5638 | */ |
| 5639 | pj_ice_sess_options ice_opt; |
| 5640 | |
| 5641 | /** |
| 5642 | * Disable RTCP component. |
| 5643 | * |
| 5644 | * Default: no |
| 5645 | */ |
| 5646 | pj_bool_t ice_no_rtcp; |
| 5647 | |
| 5648 | /** |
| 5649 | * Send re-INVITE/UPDATE every after ICE connectivity check regardless |
| 5650 | * the default ICE transport address is changed or not. When this is set |
| 5651 | * to PJ_FALSE, re-INVITE/UPDATE will be sent only when the default ICE |
| 5652 | * transport address is changed. |
| 5653 | * |
| 5654 | * Default: yes |
| 5655 | */ |
| 5656 | pj_bool_t ice_always_update; |
| 5657 | |
| 5658 | /** |
| 5659 | * Enable TURN relay candidate in ICE. |
| 5660 | */ |
| 5661 | pj_bool_t enable_turn; |
| 5662 | |
| 5663 | /** |
| 5664 | * Specify TURN domain name or host name, in in "DOMAIN:PORT" or |
| 5665 | * "HOST:PORT" format. |
| 5666 | */ |
| 5667 | pj_str_t turn_server; |
| 5668 | |
| 5669 | /** |
| 5670 | * Specify the connection type to be used to the TURN server. Valid |
| 5671 | * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP. |
| 5672 | * |
| 5673 | * Default: PJ_TURN_TP_UDP |
| 5674 | */ |
| 5675 | pj_turn_tp_type turn_conn_type; |
| 5676 | |
| 5677 | /** |
| 5678 | * Specify the credential to authenticate with the TURN server. |
| 5679 | */ |
| 5680 | pj_stun_auth_cred turn_auth_cred; |
| 5681 | |
| 5682 | /** |
| 5683 | * Specify idle time of sound device before it is automatically closed, |
| 5684 | * in seconds. Use value -1 to disable the auto-close feature of sound |
| 5685 | * device |
| 5686 | * |
| 5687 | * Default : 1 |
| 5688 | */ |
| 5689 | int snd_auto_close_time; |
| 5690 | |
| 5691 | /** |
| 5692 | * Specify whether built-in/native preview should be used if available. |
| 5693 | * In some systems, video input devices have built-in capability to show |
| 5694 | * preview window of the device. Using this built-in preview is preferable |
| 5695 | * as it consumes less CPU power. If built-in preview is not available, |
| 5696 | * the library will perform software rendering of the input. If this |
| 5697 | * field is set to PJ_FALSE, software preview will always be used. |
| 5698 | * |
| 5699 | * Default: PJ_TRUE |
| 5700 | */ |
| 5701 | pj_bool_t vid_preview_enable_native; |
| 5702 | |
| 5703 | /** |
| 5704 | * Disable smart media update (ticket #1568). The smart media update |
| 5705 | * will check for any changes in the media properties after a successful |
| 5706 | * SDP negotiation and the media will only be reinitialized when any |
| 5707 | * change is found. When it is disabled, media streams will always be |
| 5708 | * reinitialized after a successful SDP negotiation. |
| 5709 | * |
| 5710 | * Note for third party media, the smart media update requires stream info |
| 5711 | * retrieval capability, see #PJSUA_THIRD_PARTY_STREAM_HAS_GET_INFO. |
| 5712 | * |
| 5713 | * Default: PJ_FALSE |
| 5714 | */ |
| 5715 | pj_bool_t no_smart_media_update; |
| 5716 | |
| 5717 | /** |
| 5718 | * Omit RTCP SDES and BYE in outgoing RTCP packet, this setting will be |
| 5719 | * applied for both audio and video streams. Note that, when RTCP SDES |
| 5720 | * and BYE are set to be omitted, RTCP SDES will still be sent once when |
| 5721 | * the stream starts/stops and RTCP BYE will be sent once when the stream |
| 5722 | * stops. |
| 5723 | * |
| 5724 | * Default: PJ_FALSE |
| 5725 | */ |
| 5726 | pj_bool_t no_rtcp_sdes_bye; |
| 5727 | }; |
| 5728 | |
| 5729 | |
| 5730 | /** |
| 5731 | * Use this function to initialize media config. |
| 5732 | * |
| 5733 | * @param cfg The media config to be initialized. |
| 5734 | */ |
| 5735 | PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg); |
| 5736 | |
| 5737 | |
| 5738 | /** |
| 5739 | * This structure describes codec information, which can be retrieved by |
| 5740 | * calling #pjsua_enum_codecs(). |
| 5741 | */ |
| 5742 | typedef struct pjsua_codec_info |
| 5743 | { |
| 5744 | /** |
| 5745 | * Codec unique identification. |
| 5746 | */ |
| 5747 | pj_str_t codec_id; |
| 5748 | |
| 5749 | /** |
| 5750 | * Codec priority (integer 0-255). |
| 5751 | */ |
| 5752 | pj_uint8_t priority; |
| 5753 | |
| 5754 | /** |
| 5755 | * Codec description. |
| 5756 | */ |
| 5757 | pj_str_t desc; |
| 5758 | |
| 5759 | /** |
| 5760 | * Internal buffer. |
| 5761 | */ |
| 5762 | char buf_[64]; |
| 5763 | |
| 5764 | } pjsua_codec_info; |
| 5765 | |
| 5766 | |
| 5767 | /** |
| 5768 | * This structure descibes information about a particular media port that |
| 5769 | * has been registered into the conference bridge. Application can query |
| 5770 | * this info by calling #pjsua_conf_get_port_info(). |
| 5771 | */ |
| 5772 | typedef struct pjsua_conf_port_info |
| 5773 | { |
| 5774 | /** Conference port number. */ |
| 5775 | pjsua_conf_port_id slot_id; |
| 5776 | |
| 5777 | /** Port name. */ |
| 5778 | pj_str_t name; |
| 5779 | |
| 5780 | /** Clock rate. */ |
| 5781 | unsigned clock_rate; |
| 5782 | |
| 5783 | /** Number of channels. */ |
| 5784 | unsigned channel_count; |
| 5785 | |
| 5786 | /** Samples per frame */ |
| 5787 | unsigned samples_per_frame; |
| 5788 | |
| 5789 | /** Bits per sample */ |
| 5790 | unsigned bits_per_sample; |
| 5791 | |
| 5792 | /** Number of listeners in the array. */ |
| 5793 | unsigned listener_cnt; |
| 5794 | |
| 5795 | /** Array of listeners (in other words, ports where this port is |
| 5796 | * transmitting to. |
| 5797 | */ |
| 5798 | pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS]; |
| 5799 | |
| 5800 | } pjsua_conf_port_info; |
| 5801 | |
| 5802 | |
| 5803 | /** |
| 5804 | * This structure holds information about custom media transport to |
| 5805 | * be registered to pjsua. |
| 5806 | */ |
| 5807 | typedef struct pjsua_media_transport |
| 5808 | { |
| 5809 | /** |
| 5810 | * Media socket information containing the address information |
| 5811 | * of the RTP and RTCP socket. |
| 5812 | */ |
| 5813 | pjmedia_sock_info skinfo; |
| 5814 | |
| 5815 | /** |
| 5816 | * The media transport instance. |
| 5817 | */ |
| 5818 | pjmedia_transport *transport; |
| 5819 | |
| 5820 | } pjsua_media_transport; |
| 5821 | |
| 5822 | |
| 5823 | /** |
| 5824 | * Get maxinum number of conference ports. |
| 5825 | * |
| 5826 | * @return Maximum number of ports in the conference bridge. |
| 5827 | */ |
| 5828 | PJ_DECL(unsigned) pjsua_conf_get_max_ports(void); |
| 5829 | |
| 5830 | |
| 5831 | /** |
| 5832 | * Get current number of active ports in the bridge. |
| 5833 | * |
| 5834 | * @return The number. |
| 5835 | */ |
| 5836 | PJ_DECL(unsigned) pjsua_conf_get_active_ports(void); |
| 5837 | |
| 5838 | |
| 5839 | /** |
| 5840 | * Enumerate all conference ports. |
| 5841 | * |
| 5842 | * @param id Array of conference port ID to be initialized. |
| 5843 | * @param count On input, specifies max elements in the array. |
| 5844 | * On return, it contains actual number of elements |
| 5845 | * that have been initialized. |
| 5846 | * |
| 5847 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 5848 | */ |
| 5849 | PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[], |
| 5850 | unsigned *count); |
| 5851 | |
| 5852 | |
| 5853 | /** |
| 5854 | * Get information about the specified conference port |
| 5855 | * |
| 5856 | * @param port_id Port identification. |
| 5857 | * @param info Pointer to store the port info. |
| 5858 | * |
| 5859 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 5860 | */ |
| 5861 | PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id, |
| 5862 | pjsua_conf_port_info *info); |
| 5863 | |
| 5864 | |
| 5865 | /** |
| 5866 | * Add arbitrary media port to PJSUA's conference bridge. Application |
| 5867 | * can use this function to add the media port that it creates. For |
| 5868 | * media ports that are created by PJSUA-LIB (such as calls, file player, |
| 5869 | * or file recorder), PJSUA-LIB will automatically add the port to |
| 5870 | * the bridge. |
| 5871 | * |
| 5872 | * @param pool Pool to use. |
| 5873 | * @param port Media port to be added to the bridge. |
| 5874 | * @param p_id Optional pointer to receive the conference |
| 5875 | * slot id. |
| 5876 | * |
| 5877 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 5878 | */ |
| 5879 | PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool, |
| 5880 | pjmedia_port *port, |
| 5881 | pjsua_conf_port_id *p_id); |
| 5882 | |
| 5883 | |
| 5884 | /** |
| 5885 | * Remove arbitrary slot from the conference bridge. Application should only |
| 5886 | * call this function if it registered the port manually with previous call |
| 5887 | * to #pjsua_conf_add_port(). |
| 5888 | * |
| 5889 | * @param port_id The slot id of the port to be removed. |
| 5890 | * |
| 5891 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 5892 | */ |
| 5893 | PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id); |
| 5894 | |
| 5895 | |
| 5896 | /** |
| 5897 | * Establish unidirectional media flow from souce to sink. One source |
| 5898 | * may transmit to multiple destinations/sink. And if multiple |
| 5899 | * sources are transmitting to the same sink, the media will be mixed |
| 5900 | * together. Source and sink may refer to the same ID, effectively |
| 5901 | * looping the media. |
| 5902 | * |
| 5903 | * If bidirectional media flow is desired, application needs to call |
| 5904 | * this function twice, with the second one having the arguments |
| 5905 | * reversed. |
| 5906 | * |
| 5907 | * @param source Port ID of the source media/transmitter. |
| 5908 | * @param sink Port ID of the destination media/received. |
| 5909 | * |
| 5910 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 5911 | */ |
| 5912 | PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source, |
| 5913 | pjsua_conf_port_id sink); |
| 5914 | |
| 5915 | |
| 5916 | /** |
| 5917 | * Disconnect media flow from the source to destination port. |
| 5918 | * |
| 5919 | * @param source Port ID of the source media/transmitter. |
| 5920 | * @param sink Port ID of the destination media/received. |
| 5921 | * |
| 5922 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 5923 | */ |
| 5924 | PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source, |
| 5925 | pjsua_conf_port_id sink); |
| 5926 | |
| 5927 | |
| 5928 | /** |
| 5929 | * Adjust the signal level to be transmitted from the bridge to the |
| 5930 | * specified port by making it louder or quieter. |
| 5931 | * |
| 5932 | * @param slot The conference bridge slot number. |
| 5933 | * @param level Signal level adjustment. Value 1.0 means no level |
| 5934 | * adjustment, while value 0 means to mute the port. |
| 5935 | * |
| 5936 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 5937 | */ |
| 5938 | PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot, |
| 5939 | float level); |
| 5940 | |
| 5941 | /** |
| 5942 | * Adjust the signal level to be received from the specified port (to |
| 5943 | * the bridge) by making it louder or quieter. |
| 5944 | * |
| 5945 | * @param slot The conference bridge slot number. |
| 5946 | * @param level Signal level adjustment. Value 1.0 means no level |
| 5947 | * adjustment, while value 0 means to mute the port. |
| 5948 | * |
| 5949 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 5950 | */ |
| 5951 | PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot, |
| 5952 | float level); |
| 5953 | |
| 5954 | /** |
| 5955 | * Get last signal level transmitted to or received from the specified port. |
| 5956 | * The signal level is an integer value in zero to 255, with zero indicates |
| 5957 | * no signal, and 255 indicates the loudest signal level. |
| 5958 | * |
| 5959 | * @param slot The conference bridge slot number. |
| 5960 | * @param tx_level Optional argument to receive the level of signal |
| 5961 | * transmitted to the specified port (i.e. the direction |
| 5962 | * is from the bridge to the port). |
| 5963 | * @param rx_level Optional argument to receive the level of signal |
| 5964 | * received from the port (i.e. the direction is from the |
| 5965 | * port to the bridge). |
| 5966 | * |
| 5967 | * @return PJ_SUCCESS on success. |
| 5968 | */ |
| 5969 | PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot, |
| 5970 | unsigned *tx_level, |
| 5971 | unsigned *rx_level); |
| 5972 | |
| 5973 | |
| 5974 | /***************************************************************************** |
| 5975 | * File player and playlist. |
| 5976 | */ |
| 5977 | |
| 5978 | /** |
| 5979 | * Create a file player, and automatically add this player to |
| 5980 | * the conference bridge. |
| 5981 | * |
| 5982 | * @param filename The filename to be played. Currently only |
| 5983 | * WAV files are supported, and the WAV file MUST be |
| 5984 | * formatted as 16bit PCM mono/single channel (any |
| 5985 | * clock rate is supported). |
| 5986 | * @param options Optional option flag. Application may specify |
| 5987 | * PJMEDIA_FILE_NO_LOOP to prevent playback loop. |
| 5988 | * @param p_id Pointer to receive player ID. |
| 5989 | * |
| 5990 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 5991 | */ |
| 5992 | PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename, |
| 5993 | unsigned options, |
| 5994 | pjsua_player_id *p_id); |
| 5995 | |
| 5996 | |
| 5997 | /** |
| 5998 | * Create a file playlist media port, and automatically add the port |
| 5999 | * to the conference bridge. |
| 6000 | * |
| 6001 | * @param file_names Array of file names to be added to the play list. |
| 6002 | * Note that the files must have the same clock rate, |
| 6003 | * number of channels, and number of bits per sample. |
| 6004 | * @param file_count Number of files in the array. |
| 6005 | * @param label Optional label to be set for the media port. |
| 6006 | * @param options Optional option flag. Application may specify |
| 6007 | * PJMEDIA_FILE_NO_LOOP to prevent looping. |
| 6008 | * @param p_id Optional pointer to receive player ID. |
| 6009 | * |
| 6010 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6011 | */ |
| 6012 | PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[], |
| 6013 | unsigned file_count, |
| 6014 | const pj_str_t *label, |
| 6015 | unsigned options, |
| 6016 | pjsua_player_id *p_id); |
| 6017 | |
| 6018 | /** |
| 6019 | * Get conference port ID associated with player or playlist. |
| 6020 | * |
| 6021 | * @param id The file player ID. |
| 6022 | * |
| 6023 | * @return Conference port ID associated with this player. |
| 6024 | */ |
| 6025 | PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id); |
| 6026 | |
| 6027 | |
| 6028 | /** |
| 6029 | * Get the media port for the player or playlist. |
| 6030 | * |
| 6031 | * @param id The player ID. |
| 6032 | * @param p_port The media port associated with the player. |
| 6033 | * |
| 6034 | * @return PJ_SUCCESS on success. |
| 6035 | */ |
| 6036 | PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id, |
| 6037 | pjmedia_port **p_port); |
| 6038 | |
| 6039 | /** |
| 6040 | * Set playback position. This operation is not valid for playlist. |
| 6041 | * |
| 6042 | * @param id The file player ID. |
| 6043 | * @param samples The playback position, in samples. Application can |
| 6044 | * specify zero to re-start the playback. |
| 6045 | * |
| 6046 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6047 | */ |
| 6048 | PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id, |
| 6049 | pj_uint32_t samples); |
| 6050 | |
| 6051 | |
| 6052 | /** |
| 6053 | * Close the file of playlist, remove the player from the bridge, and free |
| 6054 | * resources associated with the file player or playlist. |
| 6055 | * |
| 6056 | * @param id The file player ID. |
| 6057 | * |
| 6058 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6059 | */ |
| 6060 | PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id); |
| 6061 | |
| 6062 | |
| 6063 | /***************************************************************************** |
| 6064 | * File recorder. |
| 6065 | */ |
| 6066 | |
| 6067 | /** |
| 6068 | * Create a file recorder, and automatically connect this recorder to |
| 6069 | * the conference bridge. The recorder currently supports recording WAV file. |
| 6070 | * The type of the recorder to use is determined by the extension of the file |
| 6071 | * (e.g. ".wav"). |
| 6072 | * |
| 6073 | * @param filename Output file name. The function will determine the |
| 6074 | * default format to be used based on the file extension. |
| 6075 | * Currently ".wav" is supported on all platforms. |
| 6076 | * @param enc_type Optionally specify the type of encoder to be used to |
| 6077 | * compress the media, if the file can support different |
| 6078 | * encodings. This value must be zero for now. |
| 6079 | * @param enc_param Optionally specify codec specific parameter to be |
| 6080 | * passed to the file writer. |
| 6081 | * For .WAV recorder, this value must be NULL. |
| 6082 | * @param max_size Maximum file size. Specify zero or -1 to remove size |
| 6083 | * limitation. This value must be zero or -1 for now. |
| 6084 | * @param options Optional options. |
| 6085 | * @param p_id Pointer to receive the recorder instance. |
| 6086 | * |
| 6087 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6088 | */ |
| 6089 | PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename, |
| 6090 | unsigned enc_type, |
| 6091 | void *enc_param, |
| 6092 | pj_ssize_t max_size, |
| 6093 | unsigned options, |
| 6094 | pjsua_recorder_id *p_id); |
| 6095 | |
| 6096 | |
| 6097 | /** |
| 6098 | * Get conference port associated with recorder. |
| 6099 | * |
| 6100 | * @param id The recorder ID. |
| 6101 | * |
| 6102 | * @return Conference port ID associated with this recorder. |
| 6103 | */ |
| 6104 | PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id); |
| 6105 | |
| 6106 | |
| 6107 | /** |
| 6108 | * Get the media port for the recorder. |
| 6109 | * |
| 6110 | * @param id The recorder ID. |
| 6111 | * @param p_port The media port associated with the recorder. |
| 6112 | * |
| 6113 | * @return PJ_SUCCESS on success. |
| 6114 | */ |
| 6115 | PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id, |
| 6116 | pjmedia_port **p_port); |
| 6117 | |
| 6118 | |
| 6119 | /** |
| 6120 | * Destroy recorder (this will complete recording). |
| 6121 | * |
| 6122 | * @param id The recorder ID. |
| 6123 | * |
| 6124 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6125 | */ |
| 6126 | PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id); |
| 6127 | |
| 6128 | |
| 6129 | /***************************************************************************** |
| 6130 | * Sound devices. |
| 6131 | */ |
| 6132 | |
| 6133 | /** |
| 6134 | * Enum all audio devices installed in the system. |
| 6135 | * |
| 6136 | * @param info Array of info to be initialized. |
| 6137 | * @param count On input, specifies max elements in the array. |
| 6138 | * On return, it contains actual number of elements |
| 6139 | * that have been initialized. |
| 6140 | * |
| 6141 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6142 | */ |
| 6143 | PJ_DECL(pj_status_t) pjsua_enum_aud_devs(pjmedia_aud_dev_info info[], |
| 6144 | unsigned *count); |
| 6145 | |
| 6146 | /** |
| 6147 | * Enum all sound devices installed in the system (old API). |
| 6148 | * |
| 6149 | * @param info Array of info to be initialized. |
| 6150 | * @param count On input, specifies max elements in the array. |
| 6151 | * On return, it contains actual number of elements |
| 6152 | * that have been initialized. |
| 6153 | * |
| 6154 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6155 | */ |
| 6156 | PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[], |
| 6157 | unsigned *count); |
| 6158 | |
| 6159 | /** |
| 6160 | * Get currently active sound devices. If sound devices has not been created |
| 6161 | * (for example when pjsua_start() is not called), it is possible that |
| 6162 | * the function returns PJ_SUCCESS with -1 as device IDs. |
| 6163 | * |
| 6164 | * @param capture_dev On return it will be filled with device ID of the |
| 6165 | * capture device. |
| 6166 | * @param playback_dev On return it will be filled with device ID of the |
| 6167 | * device ID of the playback device. |
| 6168 | * |
| 6169 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6170 | */ |
| 6171 | PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev, |
| 6172 | int *playback_dev); |
| 6173 | |
| 6174 | |
| 6175 | /** |
| 6176 | * Select or change sound device. Application may call this function at |
| 6177 | * any time to replace current sound device. |
| 6178 | * |
| 6179 | * @param capture_dev Device ID of the capture device. |
| 6180 | * @param playback_dev Device ID of the playback device. |
| 6181 | * |
| 6182 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6183 | */ |
| 6184 | PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev, |
| 6185 | int playback_dev); |
| 6186 | |
| 6187 | |
| 6188 | /** |
| 6189 | * Set pjsua to use null sound device. The null sound device only provides |
| 6190 | * the timing needed by the conference bridge, and will not interract with |
| 6191 | * any hardware. |
| 6192 | * |
| 6193 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6194 | */ |
| 6195 | PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void); |
| 6196 | |
| 6197 | |
| 6198 | /** |
| 6199 | * Disconnect the main conference bridge from any sound devices, and let |
| 6200 | * application connect the bridge to it's own sound device/master port. |
| 6201 | * |
| 6202 | * @return The port interface of the conference bridge, |
| 6203 | * so that application can connect this to it's own |
| 6204 | * sound device or master port. |
| 6205 | */ |
| 6206 | PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void); |
| 6207 | |
| 6208 | |
| 6209 | /** |
| 6210 | * Change the echo cancellation settings. |
| 6211 | * |
| 6212 | * The behavior of this function depends on whether the sound device is |
| 6213 | * currently active, and if it is, whether device or software AEC is |
| 6214 | * being used. |
| 6215 | * |
| 6216 | * If the sound device is currently active, and if the device supports AEC, |
| 6217 | * this function will forward the change request to the device and it will |
| 6218 | * be up to the device on whether support the request. If software AEC is |
| 6219 | * being used (the software EC will be used if the device does not support |
| 6220 | * AEC), this function will change the software EC settings. In all cases, |
| 6221 | * the setting will be saved for future opening of the sound device. |
| 6222 | * |
| 6223 | * If the sound device is not currently active, this will only change the |
| 6224 | * default AEC settings and the setting will be applied next time the |
| 6225 | * sound device is opened. |
| 6226 | * |
| 6227 | * @param tail_ms The tail length, in miliseconds. Set to zero to |
| 6228 | * disable AEC. |
| 6229 | * @param options Options to be passed to pjmedia_echo_create(). |
| 6230 | * Normally the value should be zero. |
| 6231 | * |
| 6232 | * @return PJ_SUCCESS on success. |
| 6233 | */ |
| 6234 | PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options); |
| 6235 | |
| 6236 | |
| 6237 | /** |
| 6238 | * Get current echo canceller tail length. |
| 6239 | * |
| 6240 | * @param p_tail_ms Pointer to receive the tail length, in miliseconds. |
| 6241 | * If AEC is disabled, the value will be zero. |
| 6242 | * |
| 6243 | * @return PJ_SUCCESS on success. |
| 6244 | */ |
| 6245 | PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms); |
| 6246 | |
| 6247 | |
| 6248 | /** |
| 6249 | * Check whether the sound device is currently active. The sound device |
| 6250 | * may be inactive if the application has set the auto close feature to |
| 6251 | * non-zero (the snd_auto_close_time setting in #pjsua_media_config), or |
| 6252 | * if null sound device or no sound device has been configured via the |
| 6253 | * #pjsua_set_no_snd_dev() function. |
| 6254 | */ |
| 6255 | PJ_DECL(pj_bool_t) pjsua_snd_is_active(void); |
| 6256 | |
| 6257 | |
| 6258 | /** |
| 6259 | * Configure sound device setting to the sound device being used. If sound |
| 6260 | * device is currently active, the function will forward the setting to the |
| 6261 | * sound device instance to be applied immediately, if it supports it. |
| 6262 | * |
| 6263 | * The setting will be saved for future opening of the sound device, if the |
| 6264 | * "keep" argument is set to non-zero. If the sound device is currently |
| 6265 | * inactive, and the "keep" argument is false, this function will return |
| 6266 | * error. |
| 6267 | * |
| 6268 | * Note that in case the setting is kept for future use, it will be applied |
| 6269 | * to any devices, even when application has changed the sound device to be |
| 6270 | * used. |
| 6271 | * |
| 6272 | * Note also that the echo cancellation setting should be set with |
| 6273 | * #pjsua_set_ec() API instead. |
| 6274 | * |
| 6275 | * See also #pjmedia_aud_stream_set_cap() for more information about setting |
| 6276 | * an audio device capability. |
| 6277 | * |
| 6278 | * @param cap The sound device setting to change. |
| 6279 | * @param pval Pointer to value. Please see #pjmedia_aud_dev_cap |
| 6280 | * documentation about the type of value to be |
| 6281 | * supplied for each setting. |
| 6282 | * @param keep Specify whether the setting is to be kept for future |
| 6283 | * use. |
| 6284 | * |
| 6285 | * @return PJ_SUCCESS on success or the appropriate error code. |
| 6286 | */ |
| 6287 | PJ_DECL(pj_status_t) pjsua_snd_set_setting(pjmedia_aud_dev_cap cap, |
| 6288 | const void *pval, |
| 6289 | pj_bool_t keep); |
| 6290 | |
| 6291 | /** |
| 6292 | * Retrieve a sound device setting. If sound device is currently active, |
| 6293 | * the function will forward the request to the sound device. If sound device |
| 6294 | * is currently inactive, and if application had previously set the setting |
| 6295 | * and mark the setting as kept, then that setting will be returned. |
| 6296 | * Otherwise, this function will return error. |
| 6297 | * |
| 6298 | * Note that echo cancellation settings should be retrieved with |
| 6299 | * #pjsua_get_ec_tail() API instead. |
| 6300 | * |
| 6301 | * @param cap The sound device setting to retrieve. |
| 6302 | * @param pval Pointer to receive the value. |
| 6303 | * Please see #pjmedia_aud_dev_cap documentation about |
| 6304 | * the type of value to be supplied for each setting. |
| 6305 | * |
| 6306 | * @return PJ_SUCCESS on success or the appropriate error code. |
| 6307 | */ |
| 6308 | PJ_DECL(pj_status_t) pjsua_snd_get_setting(pjmedia_aud_dev_cap cap, |
| 6309 | void *pval); |
| 6310 | |
| 6311 | |
| 6312 | /***************************************************************************** |
| 6313 | * Codecs. |
| 6314 | */ |
| 6315 | |
| 6316 | /** |
| 6317 | * Enum all supported codecs in the system. |
| 6318 | * |
| 6319 | * @param id Array of ID to be initialized. |
| 6320 | * @param count On input, specifies max elements in the array. |
| 6321 | * On return, it contains actual number of elements |
| 6322 | * that have been initialized. |
| 6323 | * |
| 6324 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6325 | */ |
| 6326 | PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[], |
| 6327 | unsigned *count ); |
| 6328 | |
| 6329 | |
| 6330 | /** |
| 6331 | * Change codec priority. |
| 6332 | * |
| 6333 | * @param codec_id Codec ID, which is a string that uniquely identify |
| 6334 | * the codec (such as "speex/8000"). Please see pjsua |
| 6335 | * manual or pjmedia codec reference for details. |
| 6336 | * @param priority Codec priority, 0-255, where zero means to disable |
| 6337 | * the codec. |
| 6338 | * |
| 6339 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6340 | */ |
| 6341 | PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id, |
| 6342 | pj_uint8_t priority ); |
| 6343 | |
| 6344 | |
| 6345 | /** |
| 6346 | * Get codec parameters. |
| 6347 | * |
| 6348 | * @param codec_id Codec ID. |
| 6349 | * @param param Structure to receive codec parameters. |
| 6350 | * |
| 6351 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6352 | */ |
| 6353 | PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id, |
| 6354 | pjmedia_codec_param *param ); |
| 6355 | |
| 6356 | |
| 6357 | /** |
| 6358 | * Set codec parameters. |
| 6359 | * |
| 6360 | * @param codec_id Codec ID. |
| 6361 | * @param param Codec parameter to set. Set to NULL to reset |
| 6362 | * codec parameter to library default settings. |
| 6363 | * |
| 6364 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6365 | */ |
| 6366 | PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id, |
| 6367 | const pjmedia_codec_param *param); |
| 6368 | |
| 6369 | |
| 6370 | #if DISABLED_FOR_TICKET_1185 |
| 6371 | /** |
| 6372 | * Create UDP media transports for all the calls. This function creates |
| 6373 | * one UDP media transport for each call. |
| 6374 | * |
| 6375 | * @param cfg Media transport configuration. The "port" field in the |
| 6376 | * configuration is used as the start port to bind the |
| 6377 | * sockets. |
| 6378 | * |
| 6379 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6380 | */ |
| 6381 | PJ_DECL(pj_status_t) |
| 6382 | pjsua_media_transports_create(const pjsua_transport_config *cfg); |
| 6383 | |
| 6384 | |
| 6385 | /** |
| 6386 | * Register custom media transports to be used by calls. There must |
| 6387 | * enough media transports for all calls. |
| 6388 | * |
| 6389 | * @param tp The media transport array. |
| 6390 | * @param count Number of elements in the array. This number MUST |
| 6391 | * match the number of maximum calls configured when |
| 6392 | * pjsua is created. |
| 6393 | * @param auto_delete Flag to indicate whether the transports should be |
| 6394 | * destroyed when pjsua is shutdown. |
| 6395 | * |
| 6396 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6397 | */ |
| 6398 | PJ_DECL(pj_status_t) |
| 6399 | pjsua_media_transports_attach( pjsua_media_transport tp[], |
| 6400 | unsigned count, |
| 6401 | pj_bool_t auto_delete); |
| 6402 | #endif |
| 6403 | |
| 6404 | |
| 6405 | /* end of MEDIA API */ |
| 6406 | /** |
| 6407 | * @} |
| 6408 | */ |
| 6409 | |
| 6410 | |
| 6411 | /***************************************************************************** |
| 6412 | * VIDEO API |
| 6413 | */ |
| 6414 | |
| 6415 | |
| 6416 | /** |
| 6417 | * @defgroup PJSUA_LIB_VIDEO PJSUA-API Video |
| 6418 | * @ingroup PJSUA_LIB |
| 6419 | * @brief Video support |
| 6420 | * @{ |
| 6421 | */ |
| 6422 | |
| 6423 | /* |
| 6424 | * Video devices API |
| 6425 | */ |
| 6426 | |
| 6427 | /** |
| 6428 | * Get the number of video devices installed in the system. |
| 6429 | * |
| 6430 | * @return The number of devices. |
| 6431 | */ |
| 6432 | PJ_DECL(unsigned) pjsua_vid_dev_count(void); |
| 6433 | |
| 6434 | /** |
| 6435 | * Retrieve the video device info for the specified device index. |
| 6436 | * |
| 6437 | * @param id The device index. |
| 6438 | * @param vdi Device info to be initialized. |
| 6439 | * |
| 6440 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6441 | */ |
| 6442 | PJ_DECL(pj_status_t) pjsua_vid_dev_get_info(pjmedia_vid_dev_index id, |
| 6443 | pjmedia_vid_dev_info *vdi); |
| 6444 | |
| 6445 | /** |
| 6446 | * Enum all video devices installed in the system. |
| 6447 | * |
| 6448 | * @param info Array of info to be initialized. |
| 6449 | * @param count On input, specifies max elements in the array. |
| 6450 | * On return, it contains actual number of elements |
| 6451 | * that have been initialized. |
| 6452 | * |
| 6453 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6454 | */ |
| 6455 | PJ_DECL(pj_status_t) pjsua_vid_enum_devs(pjmedia_vid_dev_info info[], |
| 6456 | unsigned *count); |
| 6457 | |
| 6458 | |
| 6459 | /* |
| 6460 | * Video preview API |
| 6461 | */ |
| 6462 | |
| 6463 | /** |
| 6464 | * Parameters for starting video preview with pjsua_vid_preview_start(). |
| 6465 | * Application should initialize this structure with |
| 6466 | * pjsua_vid_preview_param_default(). |
| 6467 | */ |
| 6468 | typedef struct pjsua_vid_preview_param |
| 6469 | { |
| 6470 | /** |
| 6471 | * Device ID for the video renderer to be used for rendering the |
| 6472 | * capture stream for preview. This parameter is ignored if native |
| 6473 | * preview is being used. |
| 6474 | * |
| 6475 | * Default: PJMEDIA_VID_DEFAULT_RENDER_DEV |
| 6476 | */ |
| 6477 | pjmedia_vid_dev_index rend_id; |
| 6478 | |
| 6479 | /** |
| 6480 | * Show window initially. |
| 6481 | * |
| 6482 | * Default: PJ_TRUE. |
| 6483 | */ |
| 6484 | pj_bool_t show; |
| 6485 | |
| 6486 | /** |
| 6487 | * Window flags. The value is a bitmask combination of |
| 6488 | * #pjmedia_vid_dev_wnd_flag. |
| 6489 | * |
| 6490 | * Default: 0. |
| 6491 | */ |
| 6492 | unsigned wnd_flags; |
| 6493 | |
| 6494 | } pjsua_vid_preview_param; |
| 6495 | |
| 6496 | |
| 6497 | /** |
| 6498 | * Initialize pjsua_vid_preview_param |
| 6499 | * |
| 6500 | * @param p The parameter to be initialized. |
| 6501 | */ |
| 6502 | PJ_DECL(void) pjsua_vid_preview_param_default(pjsua_vid_preview_param *p); |
| 6503 | |
| 6504 | /** |
| 6505 | * Determine if the specified video input device has built-in native |
| 6506 | * preview capability. This is a convenience function that is equal to |
| 6507 | * querying device's capability for PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW |
| 6508 | * capability. |
| 6509 | * |
| 6510 | * @param id The capture device ID. |
| 6511 | * |
| 6512 | * @return PJ_TRUE if it has. |
| 6513 | */ |
| 6514 | PJ_DECL(pj_bool_t) pjsua_vid_preview_has_native(pjmedia_vid_dev_index id); |
| 6515 | |
| 6516 | /** |
| 6517 | * Start video preview window for the specified capture device. |
| 6518 | * |
| 6519 | * @param id The capture device ID where its preview will be |
| 6520 | * started. |
| 6521 | * @param p Optional video preview parameters. Specify NULL |
| 6522 | * to use default values. |
| 6523 | * |
| 6524 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6525 | */ |
| 6526 | PJ_DECL(pj_status_t) pjsua_vid_preview_start(pjmedia_vid_dev_index id, |
| 6527 | const pjsua_vid_preview_param *p); |
| 6528 | |
| 6529 | /** |
| 6530 | * Get the preview window handle associated with the capture device, if any. |
| 6531 | * |
| 6532 | * @param id The capture device ID. |
| 6533 | * |
| 6534 | * @return The window ID of the preview window for the |
| 6535 | * specified capture device ID, or PJSUA_INVALID_ID if |
| 6536 | * preview has not been started for the device. |
| 6537 | */ |
| 6538 | PJ_DECL(pjsua_vid_win_id) pjsua_vid_preview_get_win(pjmedia_vid_dev_index id); |
| 6539 | |
| 6540 | /** |
| 6541 | * Stop video preview. |
| 6542 | * |
| 6543 | * @param id The capture device ID. |
| 6544 | * |
| 6545 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6546 | */ |
| 6547 | PJ_DECL(pj_status_t) pjsua_vid_preview_stop(pjmedia_vid_dev_index id); |
| 6548 | |
| 6549 | |
| 6550 | /* |
| 6551 | * Video window manipulation API. |
| 6552 | */ |
| 6553 | |
| 6554 | /** |
| 6555 | * This structure describes video window info. |
| 6556 | */ |
| 6557 | typedef struct pjsua_vid_win_info |
| 6558 | { |
| 6559 | /** |
| 6560 | * Flag to indicate whether this window is a native window, |
| 6561 | * such as created by built-in preview device. If this field is |
| 6562 | * PJ_TRUE, only the native window handle field of this |
| 6563 | * structure is valid. |
| 6564 | */ |
| 6565 | pj_bool_t is_native; |
| 6566 | |
| 6567 | /** |
| 6568 | * Native window handle. |
| 6569 | */ |
| 6570 | pjmedia_vid_dev_hwnd hwnd; |
| 6571 | |
| 6572 | /** |
| 6573 | * Renderer device ID. |
| 6574 | */ |
| 6575 | pjmedia_vid_dev_index rdr_dev; |
| 6576 | |
| 6577 | /** |
| 6578 | * Window show status. The window is hidden if false. |
| 6579 | */ |
| 6580 | pj_bool_t show; |
| 6581 | |
| 6582 | /** |
| 6583 | * Window position. |
| 6584 | */ |
| 6585 | pjmedia_coord pos; |
| 6586 | |
| 6587 | /** |
| 6588 | * Window size. |
| 6589 | */ |
| 6590 | pjmedia_rect_size size; |
| 6591 | |
| 6592 | } pjsua_vid_win_info; |
| 6593 | |
| 6594 | |
| 6595 | /** |
| 6596 | * Enumerates all video windows. |
| 6597 | * |
| 6598 | * @param id Array of window ID to be initialized. |
| 6599 | * @param count On input, specifies max elements in the array. |
| 6600 | * On return, it contains actual number of elements |
| 6601 | * that have been initialized. |
| 6602 | * |
| 6603 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6604 | */ |
| 6605 | PJ_DECL(pj_status_t) pjsua_vid_enum_wins(pjsua_vid_win_id wids[], |
| 6606 | unsigned *count); |
| 6607 | |
| 6608 | |
| 6609 | /** |
| 6610 | * Get window info. |
| 6611 | * |
| 6612 | * @param wid The video window ID. |
| 6613 | * @param wi The video window info to be initialized. |
| 6614 | * |
| 6615 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6616 | */ |
| 6617 | PJ_DECL(pj_status_t) pjsua_vid_win_get_info(pjsua_vid_win_id wid, |
| 6618 | pjsua_vid_win_info *wi); |
| 6619 | |
| 6620 | /** |
| 6621 | * Show or hide window. This operation is not valid for native windows |
| 6622 | * (pjsua_vid_win_info.is_native=PJ_TRUE), on which native windowing API |
| 6623 | * must be used instead. |
| 6624 | * |
| 6625 | * @param wid The video window ID. |
| 6626 | * @param show Set to PJ_TRUE to show the window, PJ_FALSE to |
| 6627 | * hide the window. |
| 6628 | * |
| 6629 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6630 | */ |
| 6631 | PJ_DECL(pj_status_t) pjsua_vid_win_set_show(pjsua_vid_win_id wid, |
| 6632 | pj_bool_t show); |
| 6633 | |
| 6634 | /** |
| 6635 | * Set video window position. This operation is not valid for native windows |
| 6636 | * (pjsua_vid_win_info.is_native=PJ_TRUE), on which native windowing API |
| 6637 | * must be used instead. |
| 6638 | * |
| 6639 | * @param wid The video window ID. |
| 6640 | * @param pos The window position. |
| 6641 | * |
| 6642 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6643 | */ |
| 6644 | PJ_DECL(pj_status_t) pjsua_vid_win_set_pos(pjsua_vid_win_id wid, |
| 6645 | const pjmedia_coord *pos); |
| 6646 | |
| 6647 | /** |
| 6648 | * Resize window. This operation is not valid for native windows |
| 6649 | * (pjsua_vid_win_info.is_native=PJ_TRUE), on which native windowing API |
| 6650 | * must be used instead. |
| 6651 | * |
| 6652 | * @param wid The video window ID. |
| 6653 | * @param size The new window size. |
| 6654 | * |
| 6655 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6656 | */ |
| 6657 | PJ_DECL(pj_status_t) pjsua_vid_win_set_size(pjsua_vid_win_id wid, |
| 6658 | const pjmedia_rect_size *size); |
| 6659 | |
| 6660 | /** |
| 6661 | * Rotate the video window. This function will change the video orientation |
| 6662 | * and also possibly the video window size (width and height get swapped). |
| 6663 | * This operation is not valid for native windows (pjsua_vid_win_info.is_native |
| 6664 | * =PJ_TRUE), on which native windowing API must be used instead. |
| 6665 | * |
| 6666 | * @param wid The video window ID. |
| 6667 | * @param angle The rotation angle in degrees, must be multiple of 90. |
| 6668 | * Specify positive value for clockwise rotation or |
| 6669 | * negative value for counter-clockwise rotation. |
| 6670 | * |
| 6671 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6672 | */ |
| 6673 | PJ_DECL(pj_status_t) pjsua_vid_win_rotate(pjsua_vid_win_id wid, |
| 6674 | int angle); |
| 6675 | |
| 6676 | |
| 6677 | /* |
| 6678 | * Video codecs API |
| 6679 | */ |
| 6680 | |
| 6681 | /** |
| 6682 | * Enum all supported video codecs in the system. |
| 6683 | * |
| 6684 | * @param id Array of ID to be initialized. |
| 6685 | * @param count On input, specifies max elements in the array. |
| 6686 | * On return, it contains actual number of elements |
| 6687 | * that have been initialized. |
| 6688 | * |
| 6689 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6690 | */ |
| 6691 | PJ_DECL(pj_status_t) pjsua_vid_enum_codecs( pjsua_codec_info id[], |
| 6692 | unsigned *count ); |
| 6693 | |
| 6694 | |
| 6695 | /** |
| 6696 | * Change video codec priority. |
| 6697 | * |
| 6698 | * @param codec_id Codec ID, which is a string that uniquely identify |
| 6699 | * the codec (such as "H263/90000"). Please see pjsua |
| 6700 | * manual or pjmedia codec reference for details. |
| 6701 | * @param priority Codec priority, 0-255, where zero means to disable |
| 6702 | * the codec. |
| 6703 | * |
| 6704 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6705 | */ |
| 6706 | PJ_DECL(pj_status_t) pjsua_vid_codec_set_priority( const pj_str_t *codec_id, |
| 6707 | pj_uint8_t priority ); |
| 6708 | |
| 6709 | |
| 6710 | /** |
| 6711 | * Get video codec parameters. |
| 6712 | * |
| 6713 | * @param codec_id Codec ID. |
| 6714 | * @param param Structure to receive video codec parameters. |
| 6715 | * |
| 6716 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6717 | */ |
| 6718 | PJ_DECL(pj_status_t) pjsua_vid_codec_get_param( |
| 6719 | const pj_str_t *codec_id, |
| 6720 | pjmedia_vid_codec_param *param); |
| 6721 | |
| 6722 | |
| 6723 | /** |
| 6724 | * Set video codec parameters. |
| 6725 | * |
| 6726 | * @param codec_id Codec ID. |
| 6727 | * @param param Codec parameter to set. Set to NULL to reset |
| 6728 | * codec parameter to library default settings. |
| 6729 | * |
| 6730 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 6731 | */ |
| 6732 | PJ_DECL(pj_status_t) pjsua_vid_codec_set_param( |
| 6733 | const pj_str_t *codec_id, |
| 6734 | const pjmedia_vid_codec_param *param); |
| 6735 | |
| 6736 | |
| 6737 | |
| 6738 | /* end of VIDEO API */ |
| 6739 | /** |
| 6740 | * @} |
| 6741 | */ |
| 6742 | |
| 6743 | |
| 6744 | /** |
| 6745 | * @} |
| 6746 | */ |
| 6747 | |
| 6748 | PJ_END_DECL |
| 6749 | |
| 6750 | |
| 6751 | #endif /* __PJSUA_H__ */ |