Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
Benny Prijono | 844653c | 2008-12-23 17:27:53 +0000 | [diff] [blame] | 3 | * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) |
Benny Prijono | 32177c0 | 2008-06-20 22:44:47 +0000 | [diff] [blame] | 4 | * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 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 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 23 | /** |
| 24 | * @file pjsua.h |
| 25 | * @brief PJSUA API. |
| 26 | */ |
| 27 | |
| 28 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 29 | /* Include all PJSIP core headers. */ |
| 30 | #include <pjsip.h> |
| 31 | |
| 32 | /* Include all PJMEDIA headers. */ |
| 33 | #include <pjmedia.h> |
| 34 | |
Benny Prijono | 1f9afba | 2006-02-10 15:57:32 +0000 | [diff] [blame] | 35 | /* Include all PJMEDIA-CODEC headers. */ |
| 36 | #include <pjmedia-codec.h> |
| 37 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 38 | /* Include all PJSIP-UA headers */ |
| 39 | #include <pjsip_ua.h> |
| 40 | |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 41 | /* Include all PJSIP-SIMPLE headers */ |
| 42 | #include <pjsip_simple.h> |
| 43 | |
Benny Prijono | 4ab9fbb | 2007-10-12 12:14:27 +0000 | [diff] [blame] | 44 | /* Include all PJNATH headers */ |
| 45 | #include <pjnath.h> |
| 46 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 47 | /* Include all PJLIB-UTIL headers. */ |
| 48 | #include <pjlib-util.h> |
| 49 | |
| 50 | /* Include all PJLIB headers. */ |
| 51 | #include <pjlib.h> |
| 52 | |
| 53 | |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 54 | PJ_BEGIN_DECL |
| 55 | |
| 56 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 57 | /** |
Benny Prijono | 58163a2 | 2009-06-03 08:40:24 +0000 | [diff] [blame] | 58 | * @defgroup PJSUA_LIB PJSUA API - High Level Softphone API |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 59 | * @brief Very high level API for constructing SIP UA applications. |
| 60 | * @{ |
| 61 | * |
Benny Prijono | 58163a2 | 2009-06-03 08:40:24 +0000 | [diff] [blame] | 62 | * @section pjsua_api_intro A SIP User Agent API for C/C++ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 63 | * |
Benny Prijono | 58163a2 | 2009-06-03 08:40:24 +0000 | [diff] [blame] | 64 | * PJSUA API is very high level API for constructing SIP multimedia user agent |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 65 | * applications. It wraps together the signaling and media functionalities |
| 66 | * into an easy to use call API, provides account management, buddy |
| 67 | * management, presence, instant messaging, along with multimedia |
| 68 | * features such as conferencing, file streaming, local playback, |
| 69 | * voice recording, and so on. |
| 70 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 71 | * @subsection pjsua_for_c_cpp C/C++ Binding |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 72 | * Application must link with <b>pjsua-lib</b> to use this API. In addition, |
| 73 | * this library depends on the following libraries: |
| 74 | * - <b>pjsip-ua</b>, |
| 75 | * - <b>pjsip-simple</b>, |
| 76 | * - <b>pjsip-core</b>, |
| 77 | * - <b>pjmedia</b>, |
| 78 | * - <b>pjmedia-codec</b>, |
| 79 | * - <b>pjlib-util</b>, and |
| 80 | * - <b>pjlib</b>, |
| 81 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 82 | * so application must also link with these libraries as well. For more |
| 83 | * information, please refer to |
| 84 | * <A HREF="http://www.pjsip.org/using.htm">Getting Started with PJSIP</A> |
| 85 | * page. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 86 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 87 | * @section pjsua_samples |
| 88 | * |
Benny Prijono | 58163a2 | 2009-06-03 08:40:24 +0000 | [diff] [blame] | 89 | * Few samples are provided: |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 90 | * |
| 91 | - @ref page_pjsip_sample_simple_pjsuaua_c\n |
| 92 | Very simple SIP User Agent with registration, call, and media, using |
| 93 | PJSUA-API, all in under 200 lines of code. |
| 94 | |
| 95 | - @ref page_pjsip_samples_pjsua\n |
| 96 | This is the reference implementation for PJSIP and PJMEDIA. |
| 97 | PJSUA is a console based application, designed to be simple enough |
| 98 | to be readble, but powerful enough to demonstrate all features |
| 99 | available in PJSIP and PJMEDIA.\n |
| 100 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 101 | * @section root_using_pjsua_lib Using PJSUA API |
| 102 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 103 | * Please refer to @ref PJSUA_LIB_BASE on how to create and initialize the API. |
| 104 | * And then see the Modules on the bottom of this page for more information |
| 105 | * about specific subject. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 106 | */ |
| 107 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 108 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 109 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 110 | /***************************************************************************** |
| 111 | * BASE API |
| 112 | */ |
| 113 | |
Benny Prijono | f04ffdd | 2006-02-21 00:11:18 +0000 | [diff] [blame] | 114 | /** |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 115 | * @defgroup PJSUA_LIB_BASE PJSUA-API Basic API |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 116 | * @ingroup PJSUA_LIB |
| 117 | * @brief Basic application creation/initialization, logging configuration, etc. |
| 118 | * @{ |
| 119 | * |
| 120 | * The base PJSUA API controls PJSUA creation, initialization, and startup, and |
| 121 | * also provides various auxiliary functions. |
| 122 | * |
| 123 | * @section using_pjsua_lib Using PJSUA Library |
| 124 | * |
| 125 | * @subsection creating_pjsua_lib Creating PJSUA |
| 126 | * |
Benny Prijono | 58163a2 | 2009-06-03 08:40:24 +0000 | [diff] [blame] | 127 | * Before anything else, application must create PJSUA by calling |
| 128 | * #pjsua_create(). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 129 | * This, among other things, will initialize PJLIB, which is crucial before |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 130 | * any PJLIB functions can be called, PJLIB-UTIL, and create a SIP endpoint. |
| 131 | * |
| 132 | * After this function is called, application can create a memory pool (with |
| 133 | * #pjsua_pool_create()) and read configurations from command line or file to |
| 134 | * build the settings to initialize PJSUA below. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 135 | * |
| 136 | * @subsection init_pjsua_lib Initializing PJSUA |
| 137 | * |
| 138 | * After PJSUA is created, application can initialize PJSUA by calling |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 139 | * #pjsua_init(). This function takes several optional configuration settings |
| 140 | * in the argument, if application wants to set them. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 141 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 142 | * @subsubsection init_pjsua_lib_c_cpp PJSUA-LIB Initialization (in C) |
| 143 | * Sample code to initialize PJSUA in C code: |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 144 | \code |
| 145 | |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 146 | #include <pjsua-lib/pjsua.h> |
| 147 | |
| 148 | #define THIS_FILE __FILE__ |
| 149 | |
| 150 | static pj_status_t app_init(void) |
| 151 | { |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 152 | pjsua_config ua_cfg; |
| 153 | pjsua_logging_config log_cfg; |
| 154 | pjsua_media_config media_cfg; |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 155 | pj_status_t status; |
| 156 | |
| 157 | // Must create pjsua before anything else! |
| 158 | status = pjsua_create(); |
| 159 | if (status != PJ_SUCCESS) { |
| 160 | pjsua_perror(THIS_FILE, "Error initializing pjsua", status); |
| 161 | return status; |
| 162 | } |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 163 | |
| 164 | // Initialize configs with default settings. |
| 165 | pjsua_config_default(&ua_cfg); |
| 166 | pjsua_logging_config_default(&log_cfg); |
| 167 | pjsua_media_config_default(&media_cfg); |
| 168 | |
| 169 | // At the very least, application would want to override |
| 170 | // the call callbacks in pjsua_config: |
| 171 | ua_cfg.cb.on_incoming_call = ... |
| 172 | ua_cfg.cb.on_call_state = .. |
| 173 | ... |
| 174 | |
| 175 | // Customize other settings (or initialize them from application specific |
| 176 | // configuration file): |
| 177 | ... |
| 178 | |
| 179 | // Initialize pjsua |
| 180 | status = pjsua_init(&ua_cfg, &log_cfg, &media_cfg); |
| 181 | if (status != PJ_SUCCESS) { |
| 182 | pjsua_perror(THIS_FILE, "Error initializing pjsua", status); |
| 183 | return status; |
| 184 | } |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 185 | . |
| 186 | ... |
| 187 | } |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 188 | \endcode |
| 189 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 190 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 191 | |
| 192 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 193 | * @subsection other_init_pjsua_lib Other Initialization |
| 194 | * |
| 195 | * After PJSUA is initialized with #pjsua_init(), application will normally |
| 196 | * need/want to perform the following tasks: |
| 197 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 198 | * - create SIP transport with #pjsua_transport_create(). Application would |
| 199 | * to call #pjsua_transport_create() for each transport types that it |
| 200 | * wants to support (for example, UDP, TCP, and TLS). Please see |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 201 | * @ref PJSUA_LIB_TRANSPORT section for more info. |
| 202 | * - create one or more SIP accounts with #pjsua_acc_add() or |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 203 | * #pjsua_acc_add_local(). The SIP account is used for registering with |
| 204 | * the SIP server, if any. Please see @ref PJSUA_LIB_ACC for more info. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 205 | * - add one or more buddies with #pjsua_buddy_add(). Please see |
| 206 | * @ref PJSUA_LIB_BUDDY section for more info. |
| 207 | * - optionally configure the sound device, codec settings, and other |
| 208 | * media settings. Please see @ref PJSUA_LIB_MEDIA for more info. |
| 209 | * |
| 210 | * |
| 211 | * @subsection starting_pjsua_lib Starting PJSUA |
| 212 | * |
| 213 | * After all initializations have been done, application must call |
| 214 | * #pjsua_start() to start PJSUA. This function will check that all settings |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 215 | * have been properly configured, and apply default settings when they haven't, |
| 216 | * or report error status when it is unable to recover from missing settings. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 217 | * |
| 218 | * Most settings can be changed during run-time. For example, application |
| 219 | * may add, modify, or delete accounts, buddies, or change media settings |
| 220 | * during run-time. |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 221 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 222 | * @subsubsection starting_pjsua_lib_c C Example for Starting PJSUA |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 223 | * Sample code: |
| 224 | \code |
| 225 | static pj_status_t app_run(void) |
| 226 | { |
| 227 | pj_status_t status; |
| 228 | |
| 229 | // Start pjsua |
| 230 | status = pjsua_start(); |
| 231 | if (status != PJ_SUCCESS) { |
| 232 | pjsua_destroy(); |
| 233 | pjsua_perror(THIS_FILE, "Error starting pjsua", status); |
| 234 | return status; |
| 235 | } |
| 236 | |
| 237 | // Run application loop |
| 238 | while (1) { |
| 239 | char choice[10]; |
| 240 | |
| 241 | printf("Select menu: "); |
| 242 | fgets(choice, sizeof(choice), stdin); |
| 243 | ... |
| 244 | } |
| 245 | } |
| 246 | \endcode |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 247 | |
Benny Prijono | f04ffdd | 2006-02-21 00:11:18 +0000 | [diff] [blame] | 248 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 249 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 250 | /** Constant to identify invalid ID for all sorts of IDs. */ |
| 251 | #define PJSUA_INVALID_ID (-1) |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 252 | |
| 253 | /** Call identification */ |
| 254 | typedef int pjsua_call_id; |
| 255 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 256 | /** Account identification */ |
| 257 | typedef int pjsua_acc_id; |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 258 | |
| 259 | /** Buddy identification */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 260 | typedef int pjsua_buddy_id; |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 261 | |
| 262 | /** File player identification */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 263 | typedef int pjsua_player_id; |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 264 | |
| 265 | /** File recorder identification */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 266 | typedef int pjsua_recorder_id; |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 267 | |
| 268 | /** Conference port identification */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 269 | typedef int pjsua_conf_port_id; |
| 270 | |
Benny Prijono | 63fba01 | 2008-07-17 14:19:10 +0000 | [diff] [blame] | 271 | /** Opaque declaration for server side presence subscription */ |
| 272 | typedef struct pjsua_srv_pres pjsua_srv_pres; |
| 273 | |
| 274 | /** Forward declaration for pjsua_msg_data */ |
| 275 | typedef struct pjsua_msg_data pjsua_msg_data; |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 276 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 277 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 278 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 279 | * Maximum proxies in account. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 280 | */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 281 | #ifndef PJSUA_ACC_MAX_PROXIES |
| 282 | # define PJSUA_ACC_MAX_PROXIES 8 |
| 283 | #endif |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 284 | |
Benny Prijono | d817965 | 2008-01-23 20:39:07 +0000 | [diff] [blame] | 285 | #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 286 | |
Benny Prijono | d817965 | 2008-01-23 20:39:07 +0000 | [diff] [blame] | 287 | /** |
| 288 | * Default value of SRTP mode usage. Valid values are PJMEDIA_SRTP_DISABLED, |
| 289 | * PJMEDIA_SRTP_OPTIONAL, and PJMEDIA_SRTP_MANDATORY. |
| 290 | */ |
| 291 | #ifndef PJSUA_DEFAULT_USE_SRTP |
| 292 | #define PJSUA_DEFAULT_USE_SRTP PJMEDIA_SRTP_DISABLED |
| 293 | #endif |
| 294 | |
| 295 | /** |
| 296 | * Default value of secure signaling requirement for SRTP. |
| 297 | * Valid values are: |
| 298 | * 0: SRTP does not require secure signaling |
| 299 | * 1: SRTP requires secure transport such as TLS |
| 300 | * 2: SRTP requires secure end-to-end transport (SIPS) |
| 301 | */ |
| 302 | #ifndef PJSUA_DEFAULT_SRTP_SECURE_SIGNALING |
| 303 | #define PJSUA_DEFAULT_SRTP_SECURE_SIGNALING 1 |
| 304 | #endif |
| 305 | |
| 306 | #endif |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 307 | |
| 308 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 309 | * Logging configuration, which can be (optionally) specified when calling |
| 310 | * #pjsua_init(). Application must call #pjsua_logging_config_default() to |
| 311 | * initialize this structure with the default values. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 312 | */ |
| 313 | typedef struct pjsua_logging_config |
| 314 | { |
| 315 | /** |
| 316 | * Log incoming and outgoing SIP message? Yes! |
| 317 | */ |
| 318 | pj_bool_t msg_logging; |
| 319 | |
| 320 | /** |
| 321 | * Input verbosity level. Value 5 is reasonable. |
| 322 | */ |
| 323 | unsigned level; |
| 324 | |
| 325 | /** |
| 326 | * Verbosity level for console. Value 4 is reasonable. |
| 327 | */ |
| 328 | unsigned console_level; |
| 329 | |
| 330 | /** |
| 331 | * Log decoration. |
| 332 | */ |
| 333 | unsigned decor; |
| 334 | |
| 335 | /** |
| 336 | * Optional log filename. |
| 337 | */ |
| 338 | pj_str_t log_filename; |
| 339 | |
| 340 | /** |
Benny Prijono | dbe3f4b | 2009-05-07 16:56:04 +0000 | [diff] [blame] | 341 | * Additional flags to be given to #pj_file_open() when opening |
| 342 | * the log file. By default, the flag is PJ_O_WRONLY. Application |
| 343 | * may set PJ_O_APPEND here so that logs are appended to existing |
| 344 | * file instead of overwriting it. |
| 345 | * |
| 346 | * Default is 0. |
| 347 | */ |
| 348 | unsigned log_file_flags; |
| 349 | |
| 350 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 351 | * Optional callback function to be called to write log to |
| 352 | * application specific device. This function will be called for |
| 353 | * log messages on input verbosity level. |
| 354 | */ |
Benny Prijono | fe7d87b | 2007-11-29 11:35:44 +0000 | [diff] [blame] | 355 | void (*cb)(int level, const char *data, int len); |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 356 | |
| 357 | |
| 358 | } pjsua_logging_config; |
| 359 | |
| 360 | |
| 361 | /** |
| 362 | * Use this function to initialize logging config. |
| 363 | * |
| 364 | * @param cfg The logging config to be initialized. |
| 365 | */ |
Benny Prijono | 1f61a8f | 2007-08-16 10:11:44 +0000 | [diff] [blame] | 366 | PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg); |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 367 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 368 | |
| 369 | /** |
| 370 | * Use this function to duplicate logging config. |
| 371 | * |
| 372 | * @param pool Pool to use. |
| 373 | * @param dst Destination config. |
| 374 | * @param src Source config. |
| 375 | */ |
Benny Prijono | 1f61a8f | 2007-08-16 10:11:44 +0000 | [diff] [blame] | 376 | PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool, |
| 377 | pjsua_logging_config *dst, |
| 378 | const pjsua_logging_config *src); |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 379 | |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 380 | |
| 381 | /** |
Benny Prijono | 4dd961b | 2009-10-26 11:21:37 +0000 | [diff] [blame] | 382 | * Structure to be passed on MWI callback. |
| 383 | */ |
| 384 | typedef struct pjsua_mwi_info |
| 385 | { |
| 386 | pjsip_evsub *evsub; /**< Event subscription session, for |
| 387 | reference. */ |
| 388 | pjsip_rx_data *rdata; /**< The received NOTIFY request. */ |
| 389 | } pjsua_mwi_info; |
| 390 | |
| 391 | |
| 392 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 393 | * This structure describes application callback to receive various event |
| 394 | * notification from PJSUA-API. All of these callbacks are OPTIONAL, |
| 395 | * although definitely application would want to implement some of |
| 396 | * the important callbacks (such as \a on_incoming_call). |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 397 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 398 | typedef struct pjsua_callback |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 399 | { |
| 400 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 401 | * Notify application when invite state has changed. |
| 402 | * Application may then query the call info to get the |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 403 | * detail call states by calling pjsua_call_get_info() function. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 404 | * |
| 405 | * @param call_id The call index. |
| 406 | * @param e Event which causes the call state to change. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 407 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 408 | void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e); |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 409 | |
| 410 | /** |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 411 | * Notify application on incoming call. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 412 | * |
| 413 | * @param acc_id The account which match the incoming call. |
| 414 | * @param call_id The call id that has just been created for |
| 415 | * the call. |
| 416 | * @param rdata The incoming INVITE request. |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 417 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 418 | void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id, |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 419 | pjsip_rx_data *rdata); |
| 420 | |
| 421 | /** |
Benny Prijono | feb69f4 | 2007-10-05 09:12:26 +0000 | [diff] [blame] | 422 | * This is a general notification callback which is called whenever |
| 423 | * a transaction within the call has changed state. Application can |
| 424 | * implement this callback for example to monitor the state of |
| 425 | * outgoing requests, or to answer unhandled incoming requests |
| 426 | * (such as INFO) with a final response. |
| 427 | * |
| 428 | * @param call_id Call identification. |
| 429 | * @param tsx The transaction which has changed state. |
| 430 | * @param e Transaction event that caused the state change. |
| 431 | */ |
| 432 | void (*on_call_tsx_state)(pjsua_call_id call_id, |
| 433 | pjsip_transaction *tsx, |
| 434 | pjsip_event *e); |
| 435 | |
| 436 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 437 | * Notify application when media state in the call has changed. |
| 438 | * Normal application would need to implement this callback, e.g. |
Benny Prijono | 6ba8c54 | 2007-10-16 01:34:14 +0000 | [diff] [blame] | 439 | * to connect the call's media to sound device. When ICE is used, |
| 440 | * this callback will also be called to report ICE negotiation |
| 441 | * failure. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 442 | * |
| 443 | * @param call_id The call index. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 444 | */ |
| 445 | void (*on_call_media_state)(pjsua_call_id call_id); |
| 446 | |
Benny Prijono | fc13bf6 | 2008-02-20 08:56:15 +0000 | [diff] [blame] | 447 | |
| 448 | /** |
| 449 | * Notify application when media session is created and before it is |
| 450 | * registered to the conference bridge. Application may return different |
| 451 | * media port if it has added media processing port to the stream. This |
| 452 | * media port then will be added to the conference bridge instead. |
| 453 | * |
| 454 | * @param call_id Call identification. |
| 455 | * @param sess Media session for the call. |
| 456 | * @param stream_idx Stream index in the media session. |
| 457 | * @param p_port On input, it specifies the media port of the |
| 458 | * stream. Application may modify this pointer to |
| 459 | * point to different media port to be registered |
| 460 | * to the conference bridge. |
Benny Prijono | fc13bf6 | 2008-02-20 08:56:15 +0000 | [diff] [blame] | 461 | */ |
| 462 | void (*on_stream_created)(pjsua_call_id call_id, |
| 463 | pjmedia_session *sess, |
| 464 | unsigned stream_idx, |
| 465 | pjmedia_port **p_port); |
| 466 | |
| 467 | /** |
| 468 | * Notify application when media session has been unregistered from the |
| 469 | * conference bridge and about to be destroyed. |
| 470 | * |
| 471 | * @param call_id Call identification. |
| 472 | * @param sess Media session for the call. |
| 473 | * @param stream_idx Stream index in the media session. |
Benny Prijono | fc13bf6 | 2008-02-20 08:56:15 +0000 | [diff] [blame] | 474 | */ |
| 475 | void (*on_stream_destroyed)(pjsua_call_id call_id, |
| 476 | pjmedia_session *sess, |
| 477 | unsigned stream_idx); |
| 478 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 479 | /** |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 480 | * Notify application upon incoming DTMF digits. |
| 481 | * |
| 482 | * @param call_id The call index. |
| 483 | * @param digit DTMF ASCII digit. |
| 484 | */ |
| 485 | void (*on_dtmf_digit)(pjsua_call_id call_id, int digit); |
| 486 | |
| 487 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 488 | * Notify application on call being transfered (i.e. REFER is received). |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 489 | * Application can decide to accept/reject transfer request |
Benny Prijono | c54dcb3 | 2008-04-08 23:33:15 +0000 | [diff] [blame] | 490 | * by setting the code (default is 202). When this callback |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 491 | * is not defined, the default behavior is to accept the |
| 492 | * transfer. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 493 | * |
| 494 | * @param call_id The call index. |
| 495 | * @param dst The destination where the call will be |
| 496 | * transfered to. |
| 497 | * @param code Status code to be returned for the call transfer |
| 498 | * request. On input, it contains status code 200. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 499 | */ |
Benny Prijono | 4ddad2c | 2006-10-18 17:16:34 +0000 | [diff] [blame] | 500 | void (*on_call_transfer_request)(pjsua_call_id call_id, |
| 501 | const pj_str_t *dst, |
| 502 | pjsip_status_code *code); |
| 503 | |
| 504 | /** |
| 505 | * Notify application of the status of previously sent call |
| 506 | * transfer request. Application can monitor the status of the |
| 507 | * call transfer request, for example to decide whether to |
| 508 | * terminate existing call. |
| 509 | * |
| 510 | * @param call_id Call ID. |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 511 | * @param st_code Status progress of the transfer request. |
| 512 | * @param st_text Status progress text. |
Benny Prijono | 4ddad2c | 2006-10-18 17:16:34 +0000 | [diff] [blame] | 513 | * @param final If non-zero, no further notification will |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 514 | * be reported. The st_code specified in |
Benny Prijono | 4ddad2c | 2006-10-18 17:16:34 +0000 | [diff] [blame] | 515 | * this callback is the final status. |
| 516 | * @param p_cont Initially will be set to non-zero, application |
| 517 | * can set this to FALSE if it no longer wants |
| 518 | * to receie further notification (for example, |
| 519 | * after it hangs up the call). |
| 520 | */ |
| 521 | void (*on_call_transfer_status)(pjsua_call_id call_id, |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 522 | int st_code, |
| 523 | const pj_str_t *st_text, |
Benny Prijono | 4ddad2c | 2006-10-18 17:16:34 +0000 | [diff] [blame] | 524 | pj_bool_t final, |
| 525 | pj_bool_t *p_cont); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 526 | |
| 527 | /** |
Benny Prijono | 053f522 | 2006-11-11 16:16:04 +0000 | [diff] [blame] | 528 | * Notify application about incoming INVITE with Replaces header. |
| 529 | * Application may reject the request by setting non-2xx code. |
| 530 | * |
| 531 | * @param call_id The call ID to be replaced. |
| 532 | * @param rdata The incoming INVITE request to replace the call. |
| 533 | * @param st_code Status code to be set by application. Application |
| 534 | * should only return a final status (200-699). |
| 535 | * @param st_text Optional status text to be set by application. |
| 536 | */ |
| 537 | void (*on_call_replace_request)(pjsua_call_id call_id, |
| 538 | pjsip_rx_data *rdata, |
| 539 | int *st_code, |
| 540 | pj_str_t *st_text); |
| 541 | |
| 542 | /** |
| 543 | * Notify application that an existing call has been replaced with |
| 544 | * a new call. This happens when PJSUA-API receives incoming INVITE |
| 545 | * request with Replaces header. |
| 546 | * |
| 547 | * After this callback is called, normally PJSUA-API will disconnect |
| 548 | * \a old_call_id and establish \a new_call_id. |
| 549 | * |
| 550 | * @param old_call_id Existing call which to be replaced with the |
| 551 | * new call. |
| 552 | * @param new_call_id The new call. |
| 553 | * @param rdata The incoming INVITE with Replaces request. |
| 554 | */ |
| 555 | void (*on_call_replaced)(pjsua_call_id old_call_id, |
| 556 | pjsua_call_id new_call_id); |
| 557 | |
| 558 | |
| 559 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 560 | * Notify application when registration status has changed. |
| 561 | * Application may then query the account info to get the |
| 562 | * registration details. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 563 | * |
| 564 | * @param acc_id Account ID. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 565 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 566 | void (*on_reg_state)(pjsua_acc_id acc_id); |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 567 | |
| 568 | /** |
Benny Prijono | 63fba01 | 2008-07-17 14:19:10 +0000 | [diff] [blame] | 569 | * Notification when incoming SUBSCRIBE request is received. Application |
| 570 | * may use this callback to authorize the incoming subscribe request |
| 571 | * (e.g. ask user permission if the request should be granted). |
| 572 | * |
| 573 | * If this callback is not implemented, all incoming presence subscription |
| 574 | * requests will be accepted. |
| 575 | * |
| 576 | * If this callback is implemented, application has several choices on |
| 577 | * what to do with the incoming request: |
| 578 | * - it may reject the request immediately by specifying non-200 class |
| 579 | * final response in the \a code argument. |
| 580 | * - it may immediately accept the request by specifying 200 as the |
| 581 | * \a code argument. This is the default value if application doesn't |
| 582 | * set any value to the \a code argument. In this case, the library |
| 583 | * will automatically send NOTIFY request upon returning from this |
| 584 | * callback. |
| 585 | * - it may delay the processing of the request, for example to request |
| 586 | * user permission whether to accept or reject the request. In this |
| 587 | * case, the application MUST set the \a code argument to 202, and |
| 588 | * later calls #pjsua_pres_notify() to accept or reject the |
| 589 | * subscription request. |
| 590 | * |
| 591 | * Any \a code other than 200 and 202 will be treated as 200. |
| 592 | * |
| 593 | * Application MUST return from this callback immediately (e.g. it must |
| 594 | * not block in this callback while waiting for user confirmation). |
| 595 | * |
| 596 | * @param srv_pres Server presence subscription instance. If |
| 597 | * application delays the acceptance of the request, |
| 598 | * it will need to specify this object when calling |
| 599 | * #pjsua_pres_notify(). |
| 600 | * @param acc_id Account ID most appropriate for this request. |
| 601 | * @param buddy_id ID of the buddy matching the sender of the |
| 602 | * request, if any, or PJSUA_INVALID_ID if no |
| 603 | * matching buddy is found. |
| 604 | * @param from The From URI of the request. |
| 605 | * @param rdata The incoming request. |
| 606 | * @param code The status code to respond to the request. The |
| 607 | * default value is 200. Application may set this |
| 608 | * to other final status code to accept or reject |
| 609 | * the request. |
| 610 | * @param reason The reason phrase to respond to the request. |
| 611 | * @param msg_data If the application wants to send additional |
| 612 | * headers in the response, it can put it in this |
| 613 | * parameter. |
| 614 | */ |
| 615 | void (*on_incoming_subscribe)(pjsua_acc_id acc_id, |
| 616 | pjsua_srv_pres *srv_pres, |
| 617 | pjsua_buddy_id buddy_id, |
| 618 | const pj_str_t *from, |
| 619 | pjsip_rx_data *rdata, |
| 620 | pjsip_status_code *code, |
| 621 | pj_str_t *reason, |
| 622 | pjsua_msg_data *msg_data); |
| 623 | |
| 624 | /** |
| 625 | * Notification when server side subscription state has changed. |
| 626 | * This callback is optional as application normally does not need |
| 627 | * to do anything to maintain server side presence subscription. |
| 628 | * |
| 629 | * @param acc_id The account ID. |
| 630 | * @param srv_pres Server presence subscription object. |
| 631 | * @param remote_uri Remote URI string. |
| 632 | * @param state New subscription state. |
| 633 | * @param event PJSIP event that triggers the state change. |
| 634 | */ |
| 635 | void (*on_srv_subscribe_state)(pjsua_acc_id acc_id, |
| 636 | pjsua_srv_pres *srv_pres, |
| 637 | const pj_str_t *remote_uri, |
| 638 | pjsip_evsub_state state, |
| 639 | pjsip_event *event); |
| 640 | |
| 641 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 642 | * Notify application when the buddy state has changed. |
| 643 | * Application may then query the buddy into to get the details. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 644 | * |
| 645 | * @param buddy_id The buddy id. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 646 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 647 | void (*on_buddy_state)(pjsua_buddy_id buddy_id); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 648 | |
| 649 | /** |
| 650 | * Notify application on incoming pager (i.e. MESSAGE request). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 651 | * Argument call_id will be -1 if MESSAGE request is not related to an |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 652 | * existing call. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 653 | * |
Benny Prijono | bbeb399 | 2007-05-21 13:48:35 +0000 | [diff] [blame] | 654 | * See also \a on_pager2() callback for the version with \a pjsip_rx_data |
| 655 | * passed as one of the argument. |
| 656 | * |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 657 | * @param call_id Containts the ID of the call where the IM was |
| 658 | * sent, or PJSUA_INVALID_ID if the IM was sent |
| 659 | * outside call context. |
| 660 | * @param from URI of the sender. |
| 661 | * @param to URI of the destination message. |
| 662 | * @param contact The Contact URI of the sender, if present. |
| 663 | * @param mime_type MIME type of the message. |
| 664 | * @param body The message content. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 665 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 666 | void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from, |
| 667 | const pj_str_t *to, const pj_str_t *contact, |
| 668 | const pj_str_t *mime_type, const pj_str_t *body); |
| 669 | |
| 670 | /** |
Benny Prijono | bbeb399 | 2007-05-21 13:48:35 +0000 | [diff] [blame] | 671 | * This is the alternative version of the \a on_pager() callback with |
| 672 | * \a pjsip_rx_data argument. |
| 673 | * |
| 674 | * @param call_id Containts the ID of the call where the IM was |
| 675 | * sent, or PJSUA_INVALID_ID if the IM was sent |
| 676 | * outside call context. |
| 677 | * @param from URI of the sender. |
| 678 | * @param to URI of the destination message. |
| 679 | * @param contact The Contact URI of the sender, if present. |
| 680 | * @param mime_type MIME type of the message. |
| 681 | * @param body The message content. |
| 682 | * @param rdata The incoming MESSAGE request. |
Benny Prijono | ba736c4 | 2008-07-10 20:45:03 +0000 | [diff] [blame] | 683 | * @param acc_id Account ID most suitable for this message. |
Benny Prijono | bbeb399 | 2007-05-21 13:48:35 +0000 | [diff] [blame] | 684 | */ |
| 685 | void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from, |
| 686 | const pj_str_t *to, const pj_str_t *contact, |
| 687 | const pj_str_t *mime_type, const pj_str_t *body, |
Benny Prijono | ba736c4 | 2008-07-10 20:45:03 +0000 | [diff] [blame] | 688 | pjsip_rx_data *rdata, pjsua_acc_id acc_id); |
Benny Prijono | bbeb399 | 2007-05-21 13:48:35 +0000 | [diff] [blame] | 689 | |
| 690 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 691 | * Notify application about the delivery status of outgoing pager |
Benny Prijono | 4da0b1d | 2007-06-11 18:22:54 +0000 | [diff] [blame] | 692 | * request. See also on_pager_status2() callback for the version with |
| 693 | * \a pjsip_rx_data in the argument list. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 694 | * |
| 695 | * @param call_id Containts the ID of the call where the IM was |
| 696 | * sent, or PJSUA_INVALID_ID if the IM was sent |
| 697 | * outside call context. |
| 698 | * @param to Destination URI. |
| 699 | * @param body Message body. |
| 700 | * @param user_data Arbitrary data that was specified when sending |
| 701 | * IM message. |
| 702 | * @param status Delivery status. |
| 703 | * @param reason Delivery status reason. |
| 704 | */ |
| 705 | void (*on_pager_status)(pjsua_call_id call_id, |
| 706 | const pj_str_t *to, |
| 707 | const pj_str_t *body, |
| 708 | void *user_data, |
| 709 | pjsip_status_code status, |
| 710 | const pj_str_t *reason); |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 711 | |
| 712 | /** |
Benny Prijono | 4da0b1d | 2007-06-11 18:22:54 +0000 | [diff] [blame] | 713 | * Notify application about the delivery status of outgoing pager |
| 714 | * request. |
| 715 | * |
| 716 | * @param call_id Containts the ID of the call where the IM was |
| 717 | * sent, or PJSUA_INVALID_ID if the IM was sent |
| 718 | * outside call context. |
| 719 | * @param to Destination URI. |
| 720 | * @param body Message body. |
| 721 | * @param user_data Arbitrary data that was specified when sending |
| 722 | * IM message. |
| 723 | * @param status Delivery status. |
| 724 | * @param reason Delivery status reason. |
Benny Prijono | 0a98200 | 2007-06-12 16:22:09 +0000 | [diff] [blame] | 725 | * @param tdata The original MESSAGE request. |
Benny Prijono | 4da0b1d | 2007-06-11 18:22:54 +0000 | [diff] [blame] | 726 | * @param rdata The incoming MESSAGE response, or NULL if the |
| 727 | * message transaction fails because of time out |
| 728 | * or transport error. |
Benny Prijono | ba736c4 | 2008-07-10 20:45:03 +0000 | [diff] [blame] | 729 | * @param acc_id Account ID from this the instant message was |
| 730 | * send. |
Benny Prijono | 4da0b1d | 2007-06-11 18:22:54 +0000 | [diff] [blame] | 731 | */ |
| 732 | void (*on_pager_status2)(pjsua_call_id call_id, |
| 733 | const pj_str_t *to, |
| 734 | const pj_str_t *body, |
| 735 | void *user_data, |
| 736 | pjsip_status_code status, |
| 737 | const pj_str_t *reason, |
Benny Prijono | 0a98200 | 2007-06-12 16:22:09 +0000 | [diff] [blame] | 738 | pjsip_tx_data *tdata, |
Benny Prijono | ba736c4 | 2008-07-10 20:45:03 +0000 | [diff] [blame] | 739 | pjsip_rx_data *rdata, |
| 740 | pjsua_acc_id acc_id); |
Benny Prijono | 4da0b1d | 2007-06-11 18:22:54 +0000 | [diff] [blame] | 741 | |
| 742 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 743 | * Notify application about typing indication. |
Benny Prijono | 0875ae8 | 2006-12-26 00:11:48 +0000 | [diff] [blame] | 744 | * |
| 745 | * @param call_id Containts the ID of the call where the IM was |
| 746 | * sent, or PJSUA_INVALID_ID if the IM was sent |
| 747 | * outside call context. |
| 748 | * @param from URI of the sender. |
| 749 | * @param to URI of the destination message. |
| 750 | * @param contact The Contact URI of the sender, if present. |
| 751 | * @param is_typing Non-zero if peer is typing, or zero if peer |
| 752 | * has stopped typing a message. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 753 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 754 | void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from, |
| 755 | const pj_str_t *to, const pj_str_t *contact, |
| 756 | pj_bool_t is_typing); |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 757 | |
Benny Prijono | 6ba8c54 | 2007-10-16 01:34:14 +0000 | [diff] [blame] | 758 | /** |
Benny Prijono | ba736c4 | 2008-07-10 20:45:03 +0000 | [diff] [blame] | 759 | * Notify application about typing indication. |
| 760 | * |
| 761 | * @param call_id Containts the ID of the call where the IM was |
| 762 | * sent, or PJSUA_INVALID_ID if the IM was sent |
| 763 | * outside call context. |
| 764 | * @param from URI of the sender. |
| 765 | * @param to URI of the destination message. |
| 766 | * @param contact The Contact URI of the sender, if present. |
| 767 | * @param is_typing Non-zero if peer is typing, or zero if peer |
| 768 | * has stopped typing a message. |
| 769 | * @param rdata The received request. |
| 770 | * @param acc_id Account ID most suitable for this message. |
| 771 | */ |
| 772 | void (*on_typing2)(pjsua_call_id call_id, const pj_str_t *from, |
| 773 | const pj_str_t *to, const pj_str_t *contact, |
| 774 | pj_bool_t is_typing, pjsip_rx_data *rdata, |
| 775 | pjsua_acc_id acc_id); |
| 776 | |
| 777 | /** |
Benny Prijono | 6ba8c54 | 2007-10-16 01:34:14 +0000 | [diff] [blame] | 778 | * Callback when the library has finished performing NAT type |
| 779 | * detection. |
| 780 | * |
| 781 | * @param res NAT detection result. |
| 782 | */ |
| 783 | void (*on_nat_detect)(const pj_stun_nat_detect_result *res); |
| 784 | |
Benny Prijono | 5e51a4e | 2008-11-27 00:06:46 +0000 | [diff] [blame] | 785 | /** |
| 786 | * This callback is called when the call is about to resend the |
| 787 | * INVITE request to the specified target, following the previously |
| 788 | * received redirection response. |
| 789 | * |
| 790 | * Application may accept the redirection to the specified target |
| 791 | * (the default behavior if this callback is implemented), reject |
| 792 | * this target only and make the session continue to try the next |
| 793 | * target in the list if such target exists, stop the whole |
| 794 | * redirection process altogether and cause the session to be |
| 795 | * disconnected, or defer the decision to ask for user confirmation. |
| 796 | * |
| 797 | * This callback is optional. If this callback is not implemented, |
| 798 | * the default behavior is to NOT follow the redirection response. |
| 799 | * |
| 800 | * @param call_id The call ID. |
| 801 | * @param target The current target to be tried. |
Benny Prijono | 08a48b8 | 2008-11-27 12:42:07 +0000 | [diff] [blame] | 802 | * @param e The event that caused this callback to be called. |
| 803 | * This could be the receipt of 3xx response, or |
| 804 | * 4xx/5xx response received for the INVITE sent to |
| 805 | * subsequent targets, or NULL if this callback is |
| 806 | * called from within #pjsua_call_process_redirect() |
| 807 | * context. |
| 808 | * |
| 809 | * @return Action to be performed for the target. Set this |
Benny Prijono | 5e51a4e | 2008-11-27 00:06:46 +0000 | [diff] [blame] | 810 | * parameter to one of the value below: |
| 811 | * - PJSIP_REDIRECT_ACCEPT: immediately accept the |
| 812 | * redirection (default value). When set, the |
| 813 | * call will immediately resend INVITE request |
| 814 | * to the target. |
| 815 | * - PJSIP_REDIRECT_REJECT: immediately reject this |
| 816 | * target. The call will continue retrying with |
| 817 | * next target if present, or disconnect the call |
| 818 | * if there is no more target to try. |
| 819 | * - PJSIP_REDIRECT_STOP: stop the whole redirection |
| 820 | * process and immediately disconnect the call. The |
| 821 | * on_call_state() callback will be called with |
| 822 | * PJSIP_INV_STATE_DISCONNECTED state immediately |
| 823 | * after this callback returns. |
| 824 | * - PJSIP_REDIRECT_PENDING: set to this value if |
| 825 | * no decision can be made immediately (for example |
| 826 | * to request confirmation from user). Application |
| 827 | * then MUST call #pjsua_call_process_redirect() |
| 828 | * to either accept or reject the redirection upon |
| 829 | * getting user decision. |
Benny Prijono | 5e51a4e | 2008-11-27 00:06:46 +0000 | [diff] [blame] | 830 | */ |
Benny Prijono | 08a48b8 | 2008-11-27 12:42:07 +0000 | [diff] [blame] | 831 | pjsip_redirect_op (*on_call_redirected)(pjsua_call_id call_id, |
| 832 | const pjsip_uri *target, |
| 833 | const pjsip_event *e); |
Benny Prijono | 5e51a4e | 2008-11-27 00:06:46 +0000 | [diff] [blame] | 834 | |
Benny Prijono | 4dd961b | 2009-10-26 11:21:37 +0000 | [diff] [blame] | 835 | /** |
| 836 | * This callback is called when a NOTIFY request for message summary / |
| 837 | * message waiting indication is received. |
| 838 | * |
| 839 | * @param acc_id The account ID. |
| 840 | * @param mwi_info Structure containing details of the event, |
| 841 | * including the received NOTIFY request in the |
| 842 | * \a rdata field. |
| 843 | */ |
| 844 | void (*on_mwi_info)(pjsua_acc_id acc_id, pjsua_mwi_info *mwi_info); |
| 845 | |
Nanang Izzuddin | 2fb937e | 2010-02-24 05:43:34 +0000 | [diff] [blame] | 846 | /** |
| 847 | * This callback is called when transport state is changed. See also |
| 848 | * #pjsip_tp_state_callback. |
Nanang Izzuddin | 2fb937e | 2010-02-24 05:43:34 +0000 | [diff] [blame] | 849 | */ |
Nanang Izzuddin | 5e69da5 | 2010-02-25 11:58:19 +0000 | [diff] [blame] | 850 | pjsip_tp_state_callback on_transport_state; |
Nanang Izzuddin | 2fb937e | 2010-02-24 05:43:34 +0000 | [diff] [blame] | 851 | |
Benny Prijono | 4d6ff4d | 2010-06-19 12:35:33 +0000 | [diff] [blame] | 852 | /** |
| 853 | * This callback is called to report error in ICE media transport. |
| 854 | * Currently it is used to report TURN Refresh error. |
| 855 | * |
| 856 | * @param index Transport index. |
| 857 | * @param op Operation which trigger the failure. |
| 858 | * @param status Error status. |
| 859 | * @param param Additional info about the event. Currently this will |
| 860 | * always be set to NULL. |
| 861 | */ |
| 862 | void (*on_ice_transport_error)(int index, pj_ice_strans_op op, |
| 863 | pj_status_t status, void *param); |
| 864 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 865 | } pjsua_callback; |
| 866 | |
| 867 | |
| 868 | |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 869 | |
| 870 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 871 | * This structure describes the settings to control the API and |
| 872 | * user agent behavior, and can be specified when calling #pjsua_init(). |
| 873 | * Before setting the values, application must call #pjsua_config_default() |
| 874 | * to initialize this structure with the default values. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 875 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 876 | typedef struct pjsua_config |
| 877 | { |
| 878 | |
| 879 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 880 | * Maximum calls to support (default: 4). The value specified here |
| 881 | * must be smaller than the compile time maximum settings |
| 882 | * PJSUA_MAX_CALLS, which by default is 32. To increase this |
| 883 | * limit, the library must be recompiled with new PJSUA_MAX_CALLS |
| 884 | * value. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 885 | */ |
| 886 | unsigned max_calls; |
| 887 | |
| 888 | /** |
| 889 | * Number of worker threads. Normally application will want to have at |
| 890 | * least one worker thread, unless when it wants to poll the library |
| 891 | * periodically, which in this case the worker thread can be set to |
| 892 | * zero. |
| 893 | */ |
| 894 | unsigned thread_cnt; |
| 895 | |
| 896 | /** |
Benny Prijono | fa9e5b1 | 2006-10-08 12:39:34 +0000 | [diff] [blame] | 897 | * Number of nameservers. If no name server is configured, the SIP SRV |
| 898 | * resolution would be disabled, and domain will be resolved with |
| 899 | * standard pj_gethostbyname() function. |
| 900 | */ |
| 901 | unsigned nameserver_count; |
| 902 | |
| 903 | /** |
| 904 | * Array of nameservers to be used by the SIP resolver subsystem. |
| 905 | * The order of the name server specifies the priority (first name |
| 906 | * server will be used first, unless it is not reachable). |
| 907 | */ |
| 908 | pj_str_t nameserver[4]; |
| 909 | |
| 910 | /** |
Benny Prijono | 91d06b6 | 2008-09-20 12:16:56 +0000 | [diff] [blame] | 911 | * Force loose-route to be used in all route/proxy URIs (outbound_proxy |
| 912 | * and account's proxy settings). When this setting is enabled, the |
| 913 | * library will check all the route/proxy URIs specified in the settings |
| 914 | * and append ";lr" parameter to the URI if the parameter is not present. |
| 915 | * |
| 916 | * Default: 1 |
| 917 | */ |
| 918 | pj_bool_t force_lr; |
| 919 | |
| 920 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 921 | * Number of outbound proxies in the \a outbound_proxy array. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 922 | */ |
| 923 | unsigned outbound_proxy_cnt; |
| 924 | |
| 925 | /** |
| 926 | * Specify the URL of outbound proxies to visit for all outgoing requests. |
| 927 | * The outbound proxies will be used for all accounts, and it will |
| 928 | * be used to build the route set for outgoing requests. The final |
| 929 | * route set for outgoing requests will consists of the outbound proxies |
| 930 | * and the proxy configured in the account. |
| 931 | */ |
| 932 | pj_str_t outbound_proxy[4]; |
| 933 | |
Benny Prijono | c97608e | 2007-03-23 16:34:20 +0000 | [diff] [blame] | 934 | /** |
Benny Prijono | bb995fd | 2009-08-12 11:03:23 +0000 | [diff] [blame] | 935 | * Warning: deprecated, please use \a stun_srv field instead. To maintain |
| 936 | * backward compatibility, if \a stun_srv_cnt is zero then the value of |
| 937 | * this field will be copied to \a stun_srv field, if present. |
| 938 | * |
Benny Prijono | ebbf689 | 2007-03-24 17:37:25 +0000 | [diff] [blame] | 939 | * Specify domain name to be resolved with DNS SRV resolution to get the |
Benny Prijono | f76e139 | 2008-06-06 14:51:48 +0000 | [diff] [blame] | 940 | * address of the STUN server. Alternatively application may specify |
| 941 | * \a stun_host instead. |
Benny Prijono | ebbf689 | 2007-03-24 17:37:25 +0000 | [diff] [blame] | 942 | * |
| 943 | * If DNS SRV resolution failed for this domain, then DNS A resolution |
| 944 | * will be performed only if \a stun_host is specified. |
Benny Prijono | c97608e | 2007-03-23 16:34:20 +0000 | [diff] [blame] | 945 | */ |
Benny Prijono | ebbf689 | 2007-03-24 17:37:25 +0000 | [diff] [blame] | 946 | pj_str_t stun_domain; |
| 947 | |
| 948 | /** |
Benny Prijono | bb995fd | 2009-08-12 11:03:23 +0000 | [diff] [blame] | 949 | * Warning: deprecated, please use \a stun_srv field instead. To maintain |
| 950 | * backward compatibility, if \a stun_srv_cnt is zero then the value of |
| 951 | * this field will be copied to \a stun_srv field, if present. |
| 952 | * |
Benny Prijono | af09dc3 | 2007-04-22 12:48:30 +0000 | [diff] [blame] | 953 | * Specify STUN server to be used, in "HOST[:PORT]" format. If port is |
| 954 | * not specified, default port 3478 will be used. |
Benny Prijono | ebbf689 | 2007-03-24 17:37:25 +0000 | [diff] [blame] | 955 | */ |
| 956 | pj_str_t stun_host; |
| 957 | |
| 958 | /** |
Benny Prijono | bb995fd | 2009-08-12 11:03:23 +0000 | [diff] [blame] | 959 | * Number of STUN server entries in \a stun_srv array. |
| 960 | */ |
| 961 | unsigned stun_srv_cnt; |
| 962 | |
| 963 | /** |
| 964 | * Array of STUN servers to try. The library will try to resolve and |
| 965 | * contact each of the STUN server entry until it finds one that is |
| 966 | * usable. Each entry may be a domain name, host name, IP address, and |
| 967 | * it may contain an optional port number. For example: |
| 968 | * - "pjsip.org" (domain name) |
| 969 | * - "sip.pjsip.org" (host name) |
| 970 | * - "pjsip.org:33478" (domain name and a non-standard port number) |
| 971 | * - "10.0.0.1:3478" (IP address and port number) |
| 972 | * |
| 973 | * When nameserver is configured in the \a pjsua_config.nameserver field, |
| 974 | * if entry is not an IP address, it will be resolved with DNS SRV |
| 975 | * resolution first, and it will fallback to use DNS A resolution if this |
| 976 | * fails. Port number may be specified even if the entry is a domain name, |
| 977 | * in case the DNS SRV resolution should fallback to a non-standard port. |
| 978 | * |
| 979 | * When nameserver is not configured, entries will be resolved with |
| 980 | * #pj_gethostbyname() if it's not an IP address. Port number may be |
| 981 | * specified if the server is not listening in standard STUN port. |
| 982 | */ |
| 983 | pj_str_t stun_srv[8]; |
| 984 | |
| 985 | /** |
| 986 | * This specifies if the library startup should ignore failure with the |
| 987 | * STUN servers. If this is set to PJ_FALSE, the library will refuse to |
| 988 | * start if it fails to resolve or contact any of the STUN servers. |
| 989 | * |
| 990 | * Default: PJ_TRUE |
| 991 | */ |
| 992 | pj_bool_t stun_ignore_failure; |
| 993 | |
| 994 | /** |
Benny Prijono | 91a6a17 | 2007-10-31 08:59:29 +0000 | [diff] [blame] | 995 | * Support for adding and parsing NAT type in the SDP to assist |
| 996 | * troubleshooting. The valid values are: |
| 997 | * - 0: no information will be added in SDP, and parsing is disabled. |
Benny Prijono | 6ba8c54 | 2007-10-16 01:34:14 +0000 | [diff] [blame] | 998 | * - 1: only the NAT type number is added. |
| 999 | * - 2: add both NAT type number and name. |
| 1000 | * |
Benny Prijono | 91a6a17 | 2007-10-31 08:59:29 +0000 | [diff] [blame] | 1001 | * Default: 1 |
Benny Prijono | 6ba8c54 | 2007-10-16 01:34:14 +0000 | [diff] [blame] | 1002 | */ |
| 1003 | int nat_type_in_sdp; |
| 1004 | |
| 1005 | /** |
Benny Prijono | dcfc0ba | 2007-09-30 16:50:27 +0000 | [diff] [blame] | 1006 | * Specify whether support for reliable provisional response (100rel and |
| 1007 | * PRACK) should be required by default. Note that this setting can be |
| 1008 | * further customized in account configuration (#pjsua_acc_config). |
| 1009 | * |
| 1010 | * Default: PJ_FALSE |
| 1011 | */ |
| 1012 | pj_bool_t require_100rel; |
| 1013 | |
Nanang Izzuddin | 59dffb1 | 2009-08-11 12:42:38 +0000 | [diff] [blame] | 1014 | /** |
| 1015 | * Specify whether support for Session Timers should be required by |
| 1016 | * default. Note that this setting can be further customized in account |
| 1017 | * configuration (#pjsua_acc_config). |
| 1018 | * |
| 1019 | * Default: PJ_FALSE |
| 1020 | */ |
| 1021 | pj_bool_t require_timer; |
| 1022 | |
| 1023 | /** |
Benny Prijono | fe1bd34 | 2009-11-20 23:33:07 +0000 | [diff] [blame] | 1024 | * Handle unsolicited NOTIFY requests containing message waiting |
| 1025 | * indication (MWI) info. Unsolicited MWI is incoming NOTIFY requests |
| 1026 | * which are not requested by client with SUBSCRIBE request. |
| 1027 | * |
| 1028 | * If this is enabled, the library will respond 200/OK to the NOTIFY |
| 1029 | * request and forward the request to \a on_mwi_info() callback. |
| 1030 | * |
| 1031 | * See also \a mwi_enabled field #on pjsua_acc_config. |
| 1032 | * |
| 1033 | * Default: PJ_TRUE |
| 1034 | * |
| 1035 | */ |
| 1036 | pj_bool_t enable_unsolicited_mwi; |
| 1037 | |
| 1038 | /** |
Nanang Izzuddin | 65add62 | 2009-08-11 16:26:20 +0000 | [diff] [blame] | 1039 | * Specify Session Timer settings, see #pjsip_timer_setting. |
Nanang Izzuddin | 59dffb1 | 2009-08-11 12:42:38 +0000 | [diff] [blame] | 1040 | * Note that this setting can be further customized in account |
| 1041 | * configuration (#pjsua_acc_config). |
Nanang Izzuddin | 59dffb1 | 2009-08-11 12:42:38 +0000 | [diff] [blame] | 1042 | */ |
Nanang Izzuddin | 65add62 | 2009-08-11 16:26:20 +0000 | [diff] [blame] | 1043 | pjsip_timer_setting timer_setting; |
Nanang Izzuddin | 59dffb1 | 2009-08-11 12:42:38 +0000 | [diff] [blame] | 1044 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1045 | /** |
| 1046 | * Number of credentials in the credential array. |
| 1047 | */ |
| 1048 | unsigned cred_count; |
| 1049 | |
| 1050 | /** |
| 1051 | * Array of credentials. These credentials will be used by all accounts, |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1052 | * and can be used to authenticate against outbound proxies. If the |
| 1053 | * credential is specific to the account, then application should set |
| 1054 | * the credential in the pjsua_acc_config rather than the credential |
| 1055 | * here. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1056 | */ |
| 1057 | pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES]; |
| 1058 | |
| 1059 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1060 | * Application callback to receive various event notifications from |
| 1061 | * the library. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1062 | */ |
| 1063 | pjsua_callback cb; |
| 1064 | |
Benny Prijono | 5631561 | 2006-07-18 14:39:40 +0000 | [diff] [blame] | 1065 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1066 | * Optional user agent string (default empty). If it's empty, no |
| 1067 | * User-Agent header will be sent with outgoing requests. |
Benny Prijono | 5631561 | 2006-07-18 14:39:40 +0000 | [diff] [blame] | 1068 | */ |
| 1069 | pj_str_t user_agent; |
| 1070 | |
Benny Prijono | d817965 | 2008-01-23 20:39:07 +0000 | [diff] [blame] | 1071 | #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) |
| 1072 | /** |
| 1073 | * Specify default value of secure media transport usage. |
| 1074 | * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and |
| 1075 | * PJMEDIA_SRTP_MANDATORY. |
| 1076 | * |
| 1077 | * Note that this setting can be further customized in account |
| 1078 | * configuration (#pjsua_acc_config). |
| 1079 | * |
| 1080 | * Default: #PJSUA_DEFAULT_USE_SRTP |
| 1081 | */ |
| 1082 | pjmedia_srtp_use use_srtp; |
| 1083 | |
| 1084 | /** |
| 1085 | * Specify whether SRTP requires secure signaling to be used. This option |
| 1086 | * is only used when \a use_srtp option above is non-zero. |
| 1087 | * |
| 1088 | * Valid values are: |
| 1089 | * 0: SRTP does not require secure signaling |
| 1090 | * 1: SRTP requires secure transport such as TLS |
| 1091 | * 2: SRTP requires secure end-to-end transport (SIPS) |
| 1092 | * |
| 1093 | * Note that this setting can be further customized in account |
| 1094 | * configuration (#pjsua_acc_config). |
| 1095 | * |
| 1096 | * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING |
| 1097 | */ |
| 1098 | int srtp_secure_signaling; |
Nanang Izzuddin | d89cc3a | 2010-05-13 05:22:51 +0000 | [diff] [blame] | 1099 | |
| 1100 | /** |
| 1101 | * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose |
| 1102 | * duplicated media in SDP offer, i.e: unsecured and secured version. |
| 1103 | * Otherwise, the SDP media will be composed as unsecured media but |
| 1104 | * with SDP "crypto" attribute. |
| 1105 | * |
| 1106 | * Default: PJ_FALSE |
| 1107 | */ |
| 1108 | pj_bool_t srtp_optional_dup_offer; |
Benny Prijono | d817965 | 2008-01-23 20:39:07 +0000 | [diff] [blame] | 1109 | #endif |
| 1110 | |
Benny Prijono | 3c5e28b | 2008-09-24 10:10:15 +0000 | [diff] [blame] | 1111 | /** |
| 1112 | * Disconnect other call legs when more than one 2xx responses for |
| 1113 | * outgoing INVITE are received due to forking. Currently the library |
| 1114 | * is not able to handle simultaneous forked media, so disconnecting |
| 1115 | * the other call legs is necessary. |
| 1116 | * |
| 1117 | * With this setting enabled, the library will handle only one of the |
| 1118 | * connected call leg, and the other connected call legs will be |
| 1119 | * disconnected. |
| 1120 | * |
| 1121 | * Default: PJ_TRUE (only disable this setting for testing purposes). |
| 1122 | */ |
| 1123 | pj_bool_t hangup_forked_call; |
| 1124 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1125 | } pjsua_config; |
| 1126 | |
| 1127 | |
| 1128 | /** |
| 1129 | * Use this function to initialize pjsua config. |
| 1130 | * |
| 1131 | * @param cfg pjsua config to be initialized. |
| 1132 | */ |
Benny Prijono | 1f61a8f | 2007-08-16 10:11:44 +0000 | [diff] [blame] | 1133 | PJ_DECL(void) pjsua_config_default(pjsua_config *cfg); |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1134 | |
| 1135 | |
Benny Prijono | a7b376b | 2008-01-25 16:06:33 +0000 | [diff] [blame] | 1136 | /** The implementation has been moved to sip_auth.h */ |
Benny Prijono | 7977f9f | 2007-10-10 11:37:56 +0000 | [diff] [blame] | 1137 | #define pjsip_cred_dup pjsip_cred_info_dup |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1138 | |
| 1139 | |
| 1140 | /** |
| 1141 | * Duplicate pjsua_config. |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1142 | * |
| 1143 | * @param pool The pool to get memory from. |
| 1144 | * @param dst Destination config. |
| 1145 | * @param src Source config. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1146 | */ |
Benny Prijono | 1f61a8f | 2007-08-16 10:11:44 +0000 | [diff] [blame] | 1147 | PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool, |
| 1148 | pjsua_config *dst, |
| 1149 | const pjsua_config *src); |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1150 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1151 | |
| 1152 | /** |
| 1153 | * This structure describes additional information to be sent with |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1154 | * outgoing SIP message. It can (optionally) be specified for example |
| 1155 | * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(), |
| 1156 | * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more. |
| 1157 | * |
| 1158 | * Application MUST call #pjsua_msg_data_init() to initialize this |
| 1159 | * structure before setting its values. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1160 | */ |
Benny Prijono | 63fba01 | 2008-07-17 14:19:10 +0000 | [diff] [blame] | 1161 | struct pjsua_msg_data |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1162 | { |
| 1163 | /** |
Benny Prijono | c92ca5c | 2007-06-11 17:03:41 +0000 | [diff] [blame] | 1164 | * Additional message headers as linked list. Application can add |
| 1165 | * headers to the list by creating the header, either from the heap/pool |
| 1166 | * or from temporary local variable, and add the header using |
| 1167 | * linked list operation. See pjsip_apps.c for some sample codes. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1168 | */ |
| 1169 | pjsip_hdr hdr_list; |
| 1170 | |
| 1171 | /** |
| 1172 | * MIME type of optional message body. |
| 1173 | */ |
| 1174 | pj_str_t content_type; |
| 1175 | |
| 1176 | /** |
| 1177 | * Optional message body. |
| 1178 | */ |
| 1179 | pj_str_t msg_body; |
| 1180 | |
Benny Prijono | 63fba01 | 2008-07-17 14:19:10 +0000 | [diff] [blame] | 1181 | }; |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1182 | |
| 1183 | |
| 1184 | /** |
| 1185 | * Initialize message data. |
| 1186 | * |
| 1187 | * @param msg_data Message data to be initialized. |
| 1188 | */ |
Benny Prijono | 1f61a8f | 2007-08-16 10:11:44 +0000 | [diff] [blame] | 1189 | PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data); |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 1190 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 1191 | |
| 1192 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1193 | * Instantiate pjsua application. Application must call this function before |
| 1194 | * calling any other functions, to make sure that the underlying libraries |
| 1195 | * are properly initialized. Once this function has returned success, |
| 1196 | * application must call pjsua_destroy() before quitting. |
| 1197 | * |
| 1198 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 1199 | */ |
| 1200 | PJ_DECL(pj_status_t) pjsua_create(void); |
| 1201 | |
| 1202 | |
Benny Prijono | a7b376b | 2008-01-25 16:06:33 +0000 | [diff] [blame] | 1203 | /** Forward declaration */ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1204 | typedef struct pjsua_media_config pjsua_media_config; |
| 1205 | |
| 1206 | |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 1207 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1208 | * Initialize pjsua with the specified settings. All the settings are |
| 1209 | * optional, and the default values will be used when the config is not |
| 1210 | * specified. |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 1211 | * |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1212 | * Note that #pjsua_create() MUST be called before calling this function. |
| 1213 | * |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1214 | * @param ua_cfg User agent configuration. |
| 1215 | * @param log_cfg Optional logging configuration. |
| 1216 | * @param media_cfg Optional media configuration. |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 1217 | * |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1218 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 1219 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1220 | PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg, |
| 1221 | const pjsua_logging_config *log_cfg, |
| 1222 | const pjsua_media_config *media_cfg); |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 1223 | |
| 1224 | |
| 1225 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1226 | * Application is recommended to call this function after all initialization |
| 1227 | * is done, so that the library can do additional checking set up |
| 1228 | * additional |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 1229 | * |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1230 | * Application may call this function anytime after #pjsua_init(). |
| 1231 | * |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1232 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 1233 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 1234 | PJ_DECL(pj_status_t) pjsua_start(void); |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 1235 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1236 | |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 1237 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1238 | * Destroy pjsua. Application is recommended to perform graceful shutdown |
| 1239 | * before calling this function (such as unregister the account from the SIP |
| 1240 | * server, terminate presense subscription, and hangup active calls), however, |
| 1241 | * this function will do all of these if it finds there are active sessions |
| 1242 | * that need to be terminated. This function will approximately block for |
| 1243 | * one second to wait for replies from remote. |
| 1244 | * |
| 1245 | * Application.may safely call this function more than once if it doesn't |
| 1246 | * keep track of it's state. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1247 | * |
| 1248 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 1249 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 1250 | PJ_DECL(pj_status_t) pjsua_destroy(void); |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 1251 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1252 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1253 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1254 | * Poll pjsua for events, and if necessary block the caller thread for |
| 1255 | * the specified maximum interval (in miliseconds). |
| 1256 | * |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1257 | * Application doesn't normally need to call this function if it has |
| 1258 | * configured worker thread (\a thread_cnt field) in pjsua_config structure, |
| 1259 | * because polling then will be done by these worker threads instead. |
| 1260 | * |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1261 | * @param msec_timeout Maximum time to wait, in miliseconds. |
| 1262 | * |
| 1263 | * @return The number of events that have been handled during the |
| 1264 | * poll. Negative value indicates error, and application |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1265 | * can retrieve the error as (status = -return_value). |
Benny Prijono | b9b32ab | 2006-06-01 12:28:44 +0000 | [diff] [blame] | 1266 | */ |
| 1267 | PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout); |
| 1268 | |
| 1269 | |
| 1270 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1271 | * Create memory pool to be used by the application. Once application |
| 1272 | * finished using the pool, it must be released with pj_pool_release(). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1273 | * |
| 1274 | * @param name Optional pool name. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1275 | * @param init_size Initial size of the pool. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1276 | * @param increment Increment size. |
| 1277 | * |
| 1278 | * @return The pool, or NULL when there's no memory. |
| 1279 | */ |
| 1280 | PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size, |
| 1281 | pj_size_t increment); |
| 1282 | |
| 1283 | |
| 1284 | /** |
| 1285 | * Application can call this function at any time (after pjsua_create(), of |
| 1286 | * course) to change logging settings. |
| 1287 | * |
| 1288 | * @param c Logging configuration. |
| 1289 | * |
| 1290 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1291 | */ |
| 1292 | PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c); |
| 1293 | |
| 1294 | |
| 1295 | /** |
| 1296 | * Internal function to get SIP endpoint instance of pjsua, which is |
| 1297 | * needed for example to register module, create transports, etc. |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1298 | * Only valid after #pjsua_init() is called. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1299 | * |
| 1300 | * @return SIP endpoint instance. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1301 | */ |
| 1302 | PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void); |
| 1303 | |
| 1304 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1305 | * Internal function to get media endpoint instance. |
| 1306 | * Only valid after #pjsua_init() is called. |
| 1307 | * |
| 1308 | * @return Media endpoint instance. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1309 | */ |
| 1310 | PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void); |
| 1311 | |
Benny Prijono | 97b8717 | 2006-08-24 14:25:14 +0000 | [diff] [blame] | 1312 | /** |
| 1313 | * Internal function to get PJSUA pool factory. |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1314 | * Only valid after #pjsua_create() is called. |
Benny Prijono | 97b8717 | 2006-08-24 14:25:14 +0000 | [diff] [blame] | 1315 | * |
| 1316 | * @return Pool factory currently used by PJSUA. |
| 1317 | */ |
| 1318 | PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void); |
| 1319 | |
| 1320 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1321 | |
| 1322 | /***************************************************************************** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1323 | * Utilities. |
| 1324 | * |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1325 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1326 | |
| 1327 | /** |
Benny Prijono | bb995fd | 2009-08-12 11:03:23 +0000 | [diff] [blame] | 1328 | * This structure is used to represent the result of the STUN server |
| 1329 | * resolution and testing, the #pjsua_resolve_stun_servers() function. |
| 1330 | * This structure will be passed in #pj_stun_resolve_cb callback. |
| 1331 | */ |
| 1332 | typedef struct pj_stun_resolve_result |
| 1333 | { |
| 1334 | /** |
| 1335 | * Arbitrary data that was passed to #pjsua_resolve_stun_servers() |
| 1336 | * function. |
| 1337 | */ |
| 1338 | void *token; |
| 1339 | |
| 1340 | /** |
| 1341 | * This will contain PJ_SUCCESS if at least one usable STUN server |
| 1342 | * is found, otherwise it will contain the last error code during |
| 1343 | * the operation. |
| 1344 | */ |
| 1345 | pj_status_t status; |
| 1346 | |
| 1347 | /** |
| 1348 | * The server name that yields successful result. This will only |
| 1349 | * contain value if status is successful. |
| 1350 | */ |
| 1351 | pj_str_t name; |
| 1352 | |
| 1353 | /** |
| 1354 | * The server IP address. This will only contain value if status |
| 1355 | * is successful. |
| 1356 | */ |
| 1357 | pj_sockaddr addr; |
| 1358 | |
| 1359 | } pj_stun_resolve_result; |
| 1360 | |
| 1361 | |
| 1362 | /** |
| 1363 | * Typedef of callback to be registered to #pjsua_resolve_stun_servers(). |
| 1364 | */ |
| 1365 | typedef void (*pj_stun_resolve_cb)(const pj_stun_resolve_result *result); |
| 1366 | |
| 1367 | /** |
Benny Prijono | 4ab9fbb | 2007-10-12 12:14:27 +0000 | [diff] [blame] | 1368 | * This is a utility function to detect NAT type in front of this |
| 1369 | * endpoint. Once invoked successfully, this function will complete |
Benny Prijono | 6ba8c54 | 2007-10-16 01:34:14 +0000 | [diff] [blame] | 1370 | * asynchronously and report the result in \a on_nat_detect() callback |
| 1371 | * of pjsua_callback. |
Benny Prijono | 4ab9fbb | 2007-10-12 12:14:27 +0000 | [diff] [blame] | 1372 | * |
Benny Prijono | 6ba8c54 | 2007-10-16 01:34:14 +0000 | [diff] [blame] | 1373 | * After NAT has been detected and the callback is called, application can |
| 1374 | * get the detected NAT type by calling #pjsua_get_nat_type(). Application |
| 1375 | * can also perform NAT detection by calling #pjsua_detect_nat_type() |
| 1376 | * again at later time. |
Benny Prijono | 4ab9fbb | 2007-10-12 12:14:27 +0000 | [diff] [blame] | 1377 | * |
Benny Prijono | 6ba8c54 | 2007-10-16 01:34:14 +0000 | [diff] [blame] | 1378 | * Note that STUN must be enabled to run this function successfully. |
| 1379 | * |
| 1380 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 4ab9fbb | 2007-10-12 12:14:27 +0000 | [diff] [blame] | 1381 | */ |
Benny Prijono | 6ba8c54 | 2007-10-16 01:34:14 +0000 | [diff] [blame] | 1382 | PJ_DECL(pj_status_t) pjsua_detect_nat_type(void); |
| 1383 | |
| 1384 | |
| 1385 | /** |
| 1386 | * Get the NAT type as detected by #pjsua_detect_nat_type() function. |
| 1387 | * This function will only return useful NAT type after #pjsua_detect_nat_type() |
| 1388 | * has completed successfully and \a on_nat_detect() callback has been called. |
| 1389 | * |
| 1390 | * @param type NAT type. |
| 1391 | * |
| 1392 | * @return When detection is in progress, this function will |
| 1393 | * return PJ_EPENDING and \a type will be set to |
| 1394 | * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been |
| 1395 | * detected successfully, this function will return |
| 1396 | * PJ_SUCCESS and \a type will be set to the correct |
| 1397 | * value. Other return values indicate error and |
| 1398 | * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN. |
Benny Prijono | 91a6a17 | 2007-10-31 08:59:29 +0000 | [diff] [blame] | 1399 | * |
| 1400 | * @see pjsua_call_get_rem_nat_type() |
Benny Prijono | 6ba8c54 | 2007-10-16 01:34:14 +0000 | [diff] [blame] | 1401 | */ |
| 1402 | PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type); |
Benny Prijono | 4ab9fbb | 2007-10-12 12:14:27 +0000 | [diff] [blame] | 1403 | |
| 1404 | |
| 1405 | /** |
Benny Prijono | bb995fd | 2009-08-12 11:03:23 +0000 | [diff] [blame] | 1406 | * Auxiliary function to resolve and contact each of the STUN server |
| 1407 | * entries (sequentially) to find which is usable. The #pjsua_init() must |
| 1408 | * have been called before calling this function. |
| 1409 | * |
| 1410 | * @param count Number of STUN server entries to try. |
| 1411 | * @param srv Array of STUN server entries to try. Please see |
| 1412 | * the \a stun_srv field in the #pjsua_config |
| 1413 | * documentation about the format of this entry. |
| 1414 | * @param wait Specify non-zero to make the function block until |
| 1415 | * it gets the result. In this case, the function |
| 1416 | * will block while the resolution is being done, |
| 1417 | * and the callback will be called before this function |
| 1418 | * returns. |
| 1419 | * @param token Arbitrary token to be passed back to application |
| 1420 | * in the callback. |
| 1421 | * @param cb Callback to be called to notify the result of |
| 1422 | * the function. |
| 1423 | * |
| 1424 | * @return If \a wait parameter is non-zero, this will return |
| 1425 | * PJ_SUCCESS if one usable STUN server is found. |
| 1426 | * Otherwise it will always return PJ_SUCCESS, and |
| 1427 | * application will be notified about the result in |
| 1428 | * the callback. |
| 1429 | */ |
| 1430 | PJ_DECL(pj_status_t) pjsua_resolve_stun_servers(unsigned count, |
| 1431 | pj_str_t srv[], |
| 1432 | pj_bool_t wait, |
| 1433 | void *token, |
| 1434 | pj_stun_resolve_cb cb); |
| 1435 | |
| 1436 | /** |
| 1437 | * Cancel pending STUN resolution which match the specified token. |
| 1438 | * |
| 1439 | * @param token The token to match. This token was given to |
| 1440 | * #pjsua_resolve_stun_servers() |
| 1441 | * @param notify_cb Boolean to control whether the callback should |
| 1442 | * be called for cancelled resolutions. When the |
| 1443 | * callback is called, the status in the result |
| 1444 | * will be set as PJ_ECANCELLED. |
| 1445 | * |
| 1446 | * @return PJ_SUCCESS if there is at least one pending STUN |
| 1447 | * resolution cancelled, or PJ_ENOTFOUND if there is |
| 1448 | * no matching one, or other error. |
| 1449 | */ |
| 1450 | PJ_DECL(pj_status_t) pjsua_cancel_stun_resolution(void *token, |
| 1451 | pj_bool_t notify_cb); |
| 1452 | |
| 1453 | |
| 1454 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1455 | * This is a utility function to verify that valid SIP url is given. If the |
| 1456 | * URL is valid, PJ_SUCCESS will be returned. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1457 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1458 | * @param url The URL, as NULL terminated string. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1459 | * |
| 1460 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1461 | */ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1462 | PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1463 | |
| 1464 | |
| 1465 | /** |
Benny Prijono | 73bb723 | 2009-10-20 13:56:26 +0000 | [diff] [blame] | 1466 | * Schedule a timer entry. Note that the timer callback may be executed |
| 1467 | * by different thread, depending on whether worker thread is enabled or |
| 1468 | * not. |
| 1469 | * |
| 1470 | * @param entry Timer heap entry. |
| 1471 | * @param delay The interval to expire. |
| 1472 | * |
| 1473 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1474 | * |
| 1475 | * @see pjsip_endpt_schedule_timer() |
| 1476 | */ |
| 1477 | PJ_DECL(pj_status_t) pjsua_schedule_timer(pj_timer_entry *entry, |
| 1478 | const pj_time_val *delay); |
| 1479 | |
| 1480 | |
| 1481 | /** |
| 1482 | * Cancel the previously scheduled timer. |
| 1483 | * |
| 1484 | * @param entry Timer heap entry. |
| 1485 | * |
| 1486 | * @see pjsip_endpt_cancel_timer() |
| 1487 | */ |
| 1488 | PJ_DECL(void) pjsua_cancel_timer(pj_timer_entry *entry); |
| 1489 | |
| 1490 | |
| 1491 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1492 | * This is a utility function to display error message for the specified |
| 1493 | * error code. The error message will be sent to the log. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1494 | * |
| 1495 | * @param sender The log sender field. |
| 1496 | * @param title Message title for the error. |
| 1497 | * @param status Status code. |
| 1498 | */ |
| 1499 | PJ_DECL(void) pjsua_perror(const char *sender, const char *title, |
| 1500 | pj_status_t status); |
| 1501 | |
| 1502 | |
Benny Prijono | da9785b | 2007-04-02 20:43:06 +0000 | [diff] [blame] | 1503 | /** |
| 1504 | * This is a utility function to dump the stack states to log, using |
| 1505 | * verbosity level 3. |
| 1506 | * |
| 1507 | * @param detail Will print detailed output (such as list of |
| 1508 | * SIP transactions) when non-zero. |
| 1509 | */ |
| 1510 | PJ_DECL(void) pjsua_dump(pj_bool_t detail); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1511 | |
| 1512 | /** |
| 1513 | * @} |
| 1514 | */ |
| 1515 | |
| 1516 | |
| 1517 | |
| 1518 | /***************************************************************************** |
| 1519 | * TRANSPORT API |
| 1520 | */ |
| 1521 | |
| 1522 | /** |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1523 | * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1524 | * @ingroup PJSUA_LIB |
| 1525 | * @brief API for managing SIP transports |
| 1526 | * @{ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1527 | * |
| 1528 | * PJSUA-API supports creating multiple transport instances, for example UDP, |
| 1529 | * TCP, and TLS transport. SIP transport must be created before adding an |
| 1530 | * account. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1531 | */ |
| 1532 | |
| 1533 | |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1534 | /** SIP transport identification. |
| 1535 | */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1536 | typedef int pjsua_transport_id; |
| 1537 | |
| 1538 | |
| 1539 | /** |
Benny Prijono | 0a5cad8 | 2006-09-26 13:21:02 +0000 | [diff] [blame] | 1540 | * Transport configuration for creating transports for both SIP |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1541 | * and media. Before setting some values to this structure, application |
| 1542 | * MUST call #pjsua_transport_config_default() to initialize its |
| 1543 | * values with default settings. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1544 | */ |
| 1545 | typedef struct pjsua_transport_config |
| 1546 | { |
| 1547 | /** |
| 1548 | * UDP port number to bind locally. This setting MUST be specified |
| 1549 | * even when default port is desired. If the value is zero, the |
| 1550 | * transport will be bound to any available port, and application |
| 1551 | * can query the port by querying the transport info. |
| 1552 | */ |
| 1553 | unsigned port; |
| 1554 | |
| 1555 | /** |
Benny Prijono | 0a5cad8 | 2006-09-26 13:21:02 +0000 | [diff] [blame] | 1556 | * Optional address to advertise as the address of this transport. |
| 1557 | * Application can specify any address or hostname for this field, |
| 1558 | * for example it can point to one of the interface address in the |
| 1559 | * system, or it can point to the public address of a NAT router |
| 1560 | * where port mappings have been configured for the application. |
| 1561 | * |
| 1562 | * Note: this option can be used for both UDP and TCP as well! |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1563 | */ |
Benny Prijono | 0a5cad8 | 2006-09-26 13:21:02 +0000 | [diff] [blame] | 1564 | pj_str_t public_addr; |
| 1565 | |
| 1566 | /** |
| 1567 | * Optional address where the socket should be bound to. This option |
| 1568 | * SHOULD only be used to selectively bind the socket to particular |
| 1569 | * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the |
| 1570 | * published address of a transport (the public_addr field should be |
| 1571 | * used for that purpose). |
| 1572 | * |
| 1573 | * Note that unlike public_addr field, the address (or hostname) here |
| 1574 | * MUST correspond to the actual interface address in the host, since |
| 1575 | * this address will be specified as bind() argument. |
| 1576 | */ |
| 1577 | pj_str_t bound_addr; |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1578 | |
| 1579 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1580 | * This specifies TLS settings for TLS transport. It is only be used |
| 1581 | * when this transport config is being used to create a SIP TLS |
| 1582 | * transport. |
Benny Prijono | 6e0e54b | 2006-12-08 21:58:31 +0000 | [diff] [blame] | 1583 | */ |
Benny Prijono | f3bbc13 | 2006-12-25 06:43:59 +0000 | [diff] [blame] | 1584 | pjsip_tls_setting tls_setting; |
Benny Prijono | 6e0e54b | 2006-12-08 21:58:31 +0000 | [diff] [blame] | 1585 | |
Benny Prijono | 4d79b0f | 2009-10-25 09:02:07 +0000 | [diff] [blame] | 1586 | /** |
| 1587 | * QoS traffic type to be set on this transport. When application wants |
| 1588 | * to apply QoS tagging to the transport, it's preferable to set this |
| 1589 | * field rather than \a qos_param fields since this is more portable. |
| 1590 | * |
| 1591 | * Default is QoS not set. |
| 1592 | */ |
| 1593 | pj_qos_type qos_type; |
| 1594 | |
| 1595 | /** |
| 1596 | * Set the low level QoS parameters to the transport. This is a lower |
| 1597 | * level operation than setting the \a qos_type field and may not be |
| 1598 | * supported on all platforms. |
| 1599 | * |
| 1600 | * Default is QoS not set. |
| 1601 | */ |
| 1602 | pj_qos_params qos_params; |
| 1603 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1604 | } pjsua_transport_config; |
| 1605 | |
| 1606 | |
| 1607 | /** |
| 1608 | * Call this function to initialize UDP config with default values. |
| 1609 | * |
| 1610 | * @param cfg The UDP config to be initialized. |
| 1611 | */ |
Benny Prijono | 1f61a8f | 2007-08-16 10:11:44 +0000 | [diff] [blame] | 1612 | PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1613 | |
| 1614 | |
| 1615 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1616 | * Duplicate transport config. |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1617 | * |
| 1618 | * @param pool The pool. |
| 1619 | * @param dst The destination config. |
| 1620 | * @param src The source config. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1621 | */ |
Benny Prijono | 1f61a8f | 2007-08-16 10:11:44 +0000 | [diff] [blame] | 1622 | PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool, |
| 1623 | pjsua_transport_config *dst, |
| 1624 | const pjsua_transport_config *src); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1625 | |
| 1626 | |
| 1627 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1628 | * This structure describes transport information returned by |
| 1629 | * #pjsua_transport_get_info() function. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1630 | */ |
| 1631 | typedef struct pjsua_transport_info |
| 1632 | { |
| 1633 | /** |
| 1634 | * PJSUA transport identification. |
| 1635 | */ |
| 1636 | pjsua_transport_id id; |
| 1637 | |
| 1638 | /** |
| 1639 | * Transport type. |
| 1640 | */ |
| 1641 | pjsip_transport_type_e type; |
| 1642 | |
| 1643 | /** |
| 1644 | * Transport type name. |
| 1645 | */ |
| 1646 | pj_str_t type_name; |
| 1647 | |
| 1648 | /** |
| 1649 | * Transport string info/description. |
| 1650 | */ |
| 1651 | pj_str_t info; |
| 1652 | |
| 1653 | /** |
| 1654 | * Transport flag (see ##pjsip_transport_flags_e). |
| 1655 | */ |
| 1656 | unsigned flag; |
| 1657 | |
| 1658 | /** |
| 1659 | * Local address length. |
| 1660 | */ |
| 1661 | unsigned addr_len; |
| 1662 | |
| 1663 | /** |
| 1664 | * Local/bound address. |
| 1665 | */ |
| 1666 | pj_sockaddr local_addr; |
| 1667 | |
| 1668 | /** |
| 1669 | * Published address (or transport address name). |
| 1670 | */ |
| 1671 | pjsip_host_port local_name; |
| 1672 | |
| 1673 | /** |
| 1674 | * Current number of objects currently referencing this transport. |
| 1675 | */ |
| 1676 | unsigned usage_count; |
| 1677 | |
| 1678 | |
| 1679 | } pjsua_transport_info; |
| 1680 | |
| 1681 | |
| 1682 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1683 | * Create and start a new SIP transport according to the specified |
| 1684 | * settings. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1685 | * |
| 1686 | * @param type Transport type. |
| 1687 | * @param cfg Transport configuration. |
| 1688 | * @param p_id Optional pointer to receive transport ID. |
| 1689 | * |
| 1690 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1691 | */ |
| 1692 | PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type, |
| 1693 | const pjsua_transport_config *cfg, |
| 1694 | pjsua_transport_id *p_id); |
| 1695 | |
| 1696 | /** |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1697 | * Register transport that has been created by application. This function |
| 1698 | * is useful if application wants to implement custom SIP transport and use |
| 1699 | * it with pjsua. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1700 | * |
| 1701 | * @param tp Transport instance. |
| 1702 | * @param p_id Optional pointer to receive transport ID. |
| 1703 | * |
| 1704 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1705 | */ |
| 1706 | PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp, |
| 1707 | pjsua_transport_id *p_id); |
| 1708 | |
| 1709 | |
| 1710 | /** |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1711 | * Enumerate all transports currently created in the system. This function |
| 1712 | * will return all transport IDs, and application may then call |
| 1713 | * #pjsua_transport_get_info() function to retrieve detailed information |
| 1714 | * about the transport. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1715 | * |
| 1716 | * @param id Array to receive transport ids. |
| 1717 | * @param count In input, specifies the maximum number of elements. |
| 1718 | * On return, it contains the actual number of elements. |
| 1719 | * |
| 1720 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1721 | */ |
| 1722 | PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[], |
| 1723 | unsigned *count ); |
| 1724 | |
| 1725 | |
| 1726 | /** |
| 1727 | * Get information about transports. |
| 1728 | * |
| 1729 | * @param id Transport ID. |
| 1730 | * @param info Pointer to receive transport info. |
| 1731 | * |
| 1732 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1733 | */ |
| 1734 | PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id, |
| 1735 | pjsua_transport_info *info); |
| 1736 | |
| 1737 | |
| 1738 | /** |
| 1739 | * Disable a transport or re-enable it. By default transport is always |
| 1740 | * enabled after it is created. Disabling a transport does not necessarily |
| 1741 | * close the socket, it will only discard incoming messages and prevent |
| 1742 | * the transport from being used to send outgoing messages. |
| 1743 | * |
| 1744 | * @param id Transport ID. |
| 1745 | * @param enabled Non-zero to enable, zero to disable. |
| 1746 | * |
| 1747 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1748 | */ |
| 1749 | PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id, |
| 1750 | pj_bool_t enabled); |
| 1751 | |
| 1752 | |
| 1753 | /** |
| 1754 | * Close the transport. If transport is forcefully closed, it will be |
| 1755 | * immediately closed, and any pending transactions that are using the |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1756 | * transport may not terminate properly (it may even crash). Otherwise, |
| 1757 | * the system will wait until all transactions are closed while preventing |
| 1758 | * new users from using the transport, and will close the transport when |
| 1759 | * it is safe to do so. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1760 | * |
| 1761 | * @param id Transport ID. |
| 1762 | * @param force Non-zero to immediately close the transport. This |
| 1763 | * is not recommended! |
| 1764 | * |
| 1765 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 1766 | */ |
| 1767 | PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id, |
| 1768 | pj_bool_t force ); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 1769 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1770 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1771 | * @} |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1772 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1773 | |
| 1774 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1775 | |
| 1776 | |
| 1777 | /***************************************************************************** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1778 | * ACCOUNT API |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 1779 | */ |
| 1780 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1781 | |
| 1782 | /** |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1783 | * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1784 | * @ingroup PJSUA_LIB |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1785 | * @brief PJSUA Accounts management |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1786 | * @{ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1787 | * |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1788 | * PJSUA accounts provide identity (or identities) of the user who is currently |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1789 | * using the application. In SIP terms, the identity is used as the <b>From</b> |
| 1790 | * header in outgoing requests. |
| 1791 | * |
| 1792 | * PJSUA-API supports creating and managing multiple accounts. The maximum |
| 1793 | * number of accounts is limited by a compile time constant |
| 1794 | * <tt>PJSUA_MAX_ACC</tt>. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1795 | * |
| 1796 | * Account may or may not have client registration associated with it. |
| 1797 | * An account is also associated with <b>route set</b> and some <b>authentication |
| 1798 | * credentials</b>, which are used when sending SIP request messages using the |
| 1799 | * account. An account also has presence's <b>online status</b>, which |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1800 | * will be reported to remote peer when they subscribe to the account's |
| 1801 | * presence, or which is published to a presence server if presence |
| 1802 | * publication is enabled for the account. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1803 | * |
| 1804 | * At least one account MUST be created in the application. If no user |
| 1805 | * association is required, application can create a userless account by |
| 1806 | * calling #pjsua_acc_add_local(). A userless account identifies local endpoint |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 1807 | * instead of a particular user, and it correspond with a particular |
| 1808 | * transport instance. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1809 | * |
| 1810 | * Also one account must be set as the <b>default account</b>, which is used as |
| 1811 | * the account to use when PJSUA fails to match a request with any other |
| 1812 | * accounts. |
| 1813 | * |
| 1814 | * When sending outgoing SIP requests (such as making calls or sending |
| 1815 | * instant messages), normally PJSUA requires the application to specify |
| 1816 | * which account to use for the request. If no account is specified, |
| 1817 | * PJSUA may be able to select the account by matching the destination |
| 1818 | * domain name, and fall back to default account when no match is found. |
| 1819 | */ |
| 1820 | |
| 1821 | /** |
| 1822 | * Maximum accounts. |
| 1823 | */ |
| 1824 | #ifndef PJSUA_MAX_ACC |
| 1825 | # define PJSUA_MAX_ACC 8 |
| 1826 | #endif |
| 1827 | |
| 1828 | |
| 1829 | /** |
| 1830 | * Default registration interval. |
| 1831 | */ |
| 1832 | #ifndef PJSUA_REG_INTERVAL |
Benny Prijono | bddef2c | 2007-10-31 13:28:08 +0000 | [diff] [blame] | 1833 | # define PJSUA_REG_INTERVAL 300 |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1834 | #endif |
| 1835 | |
| 1836 | |
| 1837 | /** |
Benny Prijono | 384dab4 | 2009-10-14 01:58:04 +0000 | [diff] [blame] | 1838 | * Default maximum time to wait for account unregistration transactions to |
| 1839 | * complete during library shutdown sequence. |
| 1840 | * |
| 1841 | * Default: 4000 (4 seconds) |
| 1842 | */ |
| 1843 | #ifndef PJSUA_UNREG_TIMEOUT |
| 1844 | # define PJSUA_UNREG_TIMEOUT 4000 |
| 1845 | #endif |
| 1846 | |
| 1847 | |
| 1848 | /** |
Benny Prijono | 3a5e1ab | 2006-08-15 20:26:34 +0000 | [diff] [blame] | 1849 | * Default PUBLISH expiration |
| 1850 | */ |
| 1851 | #ifndef PJSUA_PUBLISH_EXPIRATION |
Benny Prijono | 53984d1 | 2009-04-28 22:19:49 +0000 | [diff] [blame] | 1852 | # define PJSUA_PUBLISH_EXPIRATION PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED |
Benny Prijono | 3a5e1ab | 2006-08-15 20:26:34 +0000 | [diff] [blame] | 1853 | #endif |
| 1854 | |
| 1855 | |
| 1856 | /** |
Benny Prijono | 093d302 | 2006-09-24 00:07:11 +0000 | [diff] [blame] | 1857 | * Default account priority. |
| 1858 | */ |
| 1859 | #ifndef PJSUA_DEFAULT_ACC_PRIORITY |
| 1860 | # define PJSUA_DEFAULT_ACC_PRIORITY 0 |
| 1861 | #endif |
| 1862 | |
| 1863 | |
| 1864 | /** |
Benny Prijono | 8058a62 | 2007-06-08 04:37:05 +0000 | [diff] [blame] | 1865 | * This macro specifies the URI scheme to use in Contact header |
| 1866 | * when secure transport such as TLS is used. Application can specify |
| 1867 | * either "sip" or "sips". |
| 1868 | */ |
| 1869 | #ifndef PJSUA_SECURE_SCHEME |
Benny Prijono | 4c82c1e | 2008-10-16 08:14:51 +0000 | [diff] [blame] | 1870 | # define PJSUA_SECURE_SCHEME "sip" |
Benny Prijono | 8058a62 | 2007-06-08 04:37:05 +0000 | [diff] [blame] | 1871 | #endif |
| 1872 | |
| 1873 | |
| 1874 | /** |
Benny Prijono | 534a9ba | 2009-10-13 14:01:59 +0000 | [diff] [blame] | 1875 | * Maximum time to wait for unpublication transaction(s) to complete |
| 1876 | * during shutdown process, before sending unregistration. The library |
| 1877 | * tries to wait for the unpublication (un-PUBLISH) to complete before |
| 1878 | * sending REGISTER request to unregister the account, during library |
| 1879 | * shutdown process. If the value is set too short, it is possible that |
| 1880 | * the unregistration is sent before unpublication completes, causing |
| 1881 | * unpublication request to fail. |
| 1882 | * |
| 1883 | * Default: 2000 (2 seconds) |
| 1884 | */ |
| 1885 | #ifndef PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC |
| 1886 | # define PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC 2000 |
| 1887 | #endif |
| 1888 | |
| 1889 | |
| 1890 | /** |
Nanang Izzuddin | 36dd5b6 | 2010-03-30 11:13:59 +0000 | [diff] [blame] | 1891 | * Default auto retry re-registration interval, in seconds. Set to 0 |
| 1892 | * to disable this. Application can set the timer on per account basis |
| 1893 | * by setting the pjsua_acc_config.reg_retry_interval field instead. |
| 1894 | * |
| 1895 | * Default: 300 (5 minutes) |
| 1896 | */ |
| 1897 | #ifndef PJSUA_REG_RETRY_INTERVAL |
| 1898 | # define PJSUA_REG_RETRY_INTERVAL 300 |
| 1899 | #endif |
| 1900 | |
| 1901 | |
| 1902 | /** |
Benny Prijono | c6d5fdc | 2010-06-20 08:58:26 +0000 | [diff] [blame] | 1903 | * This macro specifies the default value for \a contact_rewrite_method |
| 1904 | * field in pjsua_acc_config. I specifies how Contact update will be |
| 1905 | * done with the registration, if \a allow_contact_rewrite is enabled in |
| 1906 | * the account config. |
| 1907 | * |
| 1908 | * If set to 1, the Contact update will be done by sending unregistration |
| 1909 | * to the currently registered Contact, while simultaneously sending new |
| 1910 | * registration (with different Call-ID) for the updated Contact. |
| 1911 | * |
| 1912 | * If set to 2, the Contact update will be done in a single, current |
| 1913 | * registration session, by removing the current binding (by setting its |
| 1914 | * Contact's expires parameter to zero) and adding a new Contact binding, |
| 1915 | * all done in a single request. |
| 1916 | * |
| 1917 | * Value 1 is the legacy behavior. |
| 1918 | * |
| 1919 | * Default value: 2 |
| 1920 | */ |
| 1921 | #ifndef PJSUA_CONTACT_REWRITE_METHOD |
| 1922 | # define PJSUA_CONTACT_REWRITE_METHOD 2 |
| 1923 | #endif |
| 1924 | |
| 1925 | |
| 1926 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1927 | * This structure describes account configuration to be specified when |
| 1928 | * adding a new account with #pjsua_acc_add(). Application MUST initialize |
| 1929 | * this structure first by calling #pjsua_acc_config_default(). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1930 | */ |
| 1931 | typedef struct pjsua_acc_config |
| 1932 | { |
Benny Prijono | 093d302 | 2006-09-24 00:07:11 +0000 | [diff] [blame] | 1933 | /** |
Benny Prijono | 705e784 | 2008-07-21 18:12:51 +0000 | [diff] [blame] | 1934 | * Arbitrary user data to be associated with the newly created account. |
| 1935 | * Application may set this later with #pjsua_acc_set_user_data() and |
| 1936 | * retrieve it with #pjsua_acc_get_user_data(). |
| 1937 | */ |
| 1938 | void *user_data; |
| 1939 | |
| 1940 | /** |
Benny Prijono | 093d302 | 2006-09-24 00:07:11 +0000 | [diff] [blame] | 1941 | * Account priority, which is used to control the order of matching |
| 1942 | * incoming/outgoing requests. The higher the number means the higher |
| 1943 | * the priority is, and the account will be matched first. |
| 1944 | */ |
| 1945 | int priority; |
| 1946 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 1947 | /** |
| 1948 | * The full SIP URL for the account. The value can take name address or |
| 1949 | * URL format, and will look something like "sip:account@serviceprovider". |
| 1950 | * |
| 1951 | * This field is mandatory. |
| 1952 | */ |
| 1953 | pj_str_t id; |
| 1954 | |
| 1955 | /** |
| 1956 | * This is the URL to be put in the request URI for the registration, |
| 1957 | * and will look something like "sip:serviceprovider". |
| 1958 | * |
| 1959 | * This field should be specified if registration is desired. If the |
| 1960 | * value is empty, no account registration will be performed. |
| 1961 | */ |
| 1962 | pj_str_t reg_uri; |
| 1963 | |
Benny Prijono | 3a5e1ab | 2006-08-15 20:26:34 +0000 | [diff] [blame] | 1964 | /** |
Benny Prijono | fe1bd34 | 2009-11-20 23:33:07 +0000 | [diff] [blame] | 1965 | * Subscribe to message waiting indication events (RFC 3842). |
| 1966 | * |
| 1967 | * See also \a enable_unsolicited_mwi field on #pjsua_config. |
Benny Prijono | 4dd961b | 2009-10-26 11:21:37 +0000 | [diff] [blame] | 1968 | * |
| 1969 | * Default: no |
| 1970 | */ |
| 1971 | pj_bool_t mwi_enabled; |
| 1972 | |
| 1973 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 1974 | * If this flag is set, the presence information of this account will |
| 1975 | * be PUBLISH-ed to the server where the account belongs. |
Benny Prijono | 48ab2b7 | 2007-11-08 09:24:30 +0000 | [diff] [blame] | 1976 | * |
| 1977 | * Default: PJ_FALSE |
Benny Prijono | 3a5e1ab | 2006-08-15 20:26:34 +0000 | [diff] [blame] | 1978 | */ |
| 1979 | pj_bool_t publish_enabled; |
| 1980 | |
Benny Prijono | fe04fb5 | 2007-08-24 08:28:52 +0000 | [diff] [blame] | 1981 | /** |
Benny Prijono | fe50c9e | 2009-10-12 07:44:14 +0000 | [diff] [blame] | 1982 | * Event publication options. |
| 1983 | */ |
| 1984 | pjsip_publishc_opt publish_opt; |
| 1985 | |
| 1986 | /** |
Benny Prijono | 534a9ba | 2009-10-13 14:01:59 +0000 | [diff] [blame] | 1987 | * Maximum time to wait for unpublication transaction(s) to complete |
| 1988 | * during shutdown process, before sending unregistration. The library |
| 1989 | * tries to wait for the unpublication (un-PUBLISH) to complete before |
| 1990 | * sending REGISTER request to unregister the account, during library |
| 1991 | * shutdown process. If the value is set too short, it is possible that |
| 1992 | * the unregistration is sent before unpublication completes, causing |
| 1993 | * unpublication request to fail. |
| 1994 | * |
| 1995 | * Default: PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC |
| 1996 | */ |
| 1997 | unsigned unpublish_max_wait_time_msec; |
| 1998 | |
| 1999 | /** |
Benny Prijono | 48ab2b7 | 2007-11-08 09:24:30 +0000 | [diff] [blame] | 2000 | * Authentication preference. |
| 2001 | */ |
| 2002 | pjsip_auth_clt_pref auth_pref; |
| 2003 | |
| 2004 | /** |
Benny Prijono | fe04fb5 | 2007-08-24 08:28:52 +0000 | [diff] [blame] | 2005 | * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value |
| 2006 | * is not specified, a random string will be used. |
| 2007 | */ |
| 2008 | pj_str_t pidf_tuple_id; |
| 2009 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2010 | /** |
| 2011 | * Optional URI to be put as Contact for this account. It is recommended |
| 2012 | * that this field is left empty, so that the value will be calculated |
| 2013 | * automatically based on the transport address. |
| 2014 | */ |
Benny Prijono | b4a17c9 | 2006-07-10 14:40:21 +0000 | [diff] [blame] | 2015 | pj_str_t force_contact; |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2016 | |
| 2017 | /** |
Nanang Izzuddin | e2c7e85 | 2009-08-04 14:36:17 +0000 | [diff] [blame] | 2018 | * Additional parameters that will be appended in the Contact header |
Benny Prijono | 30fe485 | 2008-12-10 16:54:16 +0000 | [diff] [blame] | 2019 | * for this account. This will affect the Contact header in all SIP |
| 2020 | * messages sent on behalf of this account, including but not limited to |
| 2021 | * REGISTER, INVITE, and SUBCRIBE requests or responses. |
| 2022 | * |
| 2023 | * The parameters should be preceeded by semicolon, and all strings must |
| 2024 | * be properly escaped. Example: |
| 2025 | * ";my-param=X;another-param=Hi%20there" |
| 2026 | */ |
| 2027 | pj_str_t contact_params; |
| 2028 | |
| 2029 | /** |
Nanang Izzuddin | e2c7e85 | 2009-08-04 14:36:17 +0000 | [diff] [blame] | 2030 | * Additional URI parameters that will be appended in the Contact URI |
| 2031 | * for this account. This will affect the Contact URI in all SIP |
| 2032 | * messages sent on behalf of this account, including but not limited to |
| 2033 | * REGISTER, INVITE, and SUBCRIBE requests or responses. |
| 2034 | * |
| 2035 | * The parameters should be preceeded by semicolon, and all strings must |
| 2036 | * be properly escaped. Example: |
| 2037 | * ";my-param=X;another-param=Hi%20there" |
| 2038 | */ |
| 2039 | pj_str_t contact_uri_params; |
| 2040 | |
| 2041 | /** |
Benny Prijono | dcfc0ba | 2007-09-30 16:50:27 +0000 | [diff] [blame] | 2042 | * Specify whether support for reliable provisional response (100rel and |
| 2043 | * PRACK) should be required for all sessions of this account. |
| 2044 | * |
| 2045 | * Default: PJ_FALSE |
| 2046 | */ |
| 2047 | pj_bool_t require_100rel; |
| 2048 | |
| 2049 | /** |
Nanang Izzuddin | 59dffb1 | 2009-08-11 12:42:38 +0000 | [diff] [blame] | 2050 | * Specify whether support for Session Timers should be required for all |
| 2051 | * sessions of this account. |
| 2052 | * |
| 2053 | * Default: PJ_FALSE |
| 2054 | */ |
| 2055 | pj_bool_t require_timer; |
| 2056 | |
| 2057 | /** |
Nanang Izzuddin | 65add62 | 2009-08-11 16:26:20 +0000 | [diff] [blame] | 2058 | * Specify Session Timer settings, see #pjsip_timer_setting. |
Nanang Izzuddin | 59dffb1 | 2009-08-11 12:42:38 +0000 | [diff] [blame] | 2059 | */ |
Nanang Izzuddin | 65add62 | 2009-08-11 16:26:20 +0000 | [diff] [blame] | 2060 | pjsip_timer_setting timer_setting; |
Nanang Izzuddin | 59dffb1 | 2009-08-11 12:42:38 +0000 | [diff] [blame] | 2061 | |
| 2062 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2063 | * Number of proxies in the proxy array below. |
| 2064 | */ |
| 2065 | unsigned proxy_cnt; |
| 2066 | |
| 2067 | /** |
| 2068 | * Optional URI of the proxies to be visited for all outgoing requests |
| 2069 | * that are using this account (REGISTER, INVITE, etc). Application need |
| 2070 | * to specify these proxies if the service provider requires that requests |
| 2071 | * destined towards its network should go through certain proxies first |
| 2072 | * (for example, border controllers). |
| 2073 | * |
| 2074 | * These proxies will be put in the route set for this account, with |
| 2075 | * maintaining the orders (the first proxy in the array will be visited |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2076 | * first). If global outbound proxies are configured in pjsua_config, |
| 2077 | * then these account proxies will be placed after the global outbound |
| 2078 | * proxies in the routeset. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2079 | */ |
| 2080 | pj_str_t proxy[PJSUA_ACC_MAX_PROXIES]; |
| 2081 | |
| 2082 | /** |
| 2083 | * Optional interval for registration, in seconds. If the value is zero, |
Benny Prijono | bddef2c | 2007-10-31 13:28:08 +0000 | [diff] [blame] | 2084 | * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2085 | */ |
| 2086 | unsigned reg_timeout; |
| 2087 | |
Benny Prijono | 384dab4 | 2009-10-14 01:58:04 +0000 | [diff] [blame] | 2088 | /** |
| 2089 | * Specify the maximum time to wait for unregistration requests to |
| 2090 | * complete during library shutdown sequence. |
| 2091 | * |
| 2092 | * Default: PJSUA_UNREG_TIMEOUT |
| 2093 | */ |
| 2094 | unsigned unreg_timeout; |
| 2095 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2096 | /** |
| 2097 | * Number of credentials in the credential array. |
| 2098 | */ |
| 2099 | unsigned cred_count; |
| 2100 | |
| 2101 | /** |
| 2102 | * Array of credentials. If registration is desired, normally there should |
| 2103 | * be at least one credential specified, to successfully authenticate |
| 2104 | * against the service provider. More credentials can be specified, for |
| 2105 | * example when the requests are expected to be challenged by the |
| 2106 | * proxies in the route set. |
| 2107 | */ |
| 2108 | pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES]; |
| 2109 | |
Benny Prijono | 62c5c5b | 2007-01-13 23:22:40 +0000 | [diff] [blame] | 2110 | /** |
| 2111 | * Optionally bind this account to specific transport. This normally is |
| 2112 | * not a good idea, as account should be able to send requests using |
| 2113 | * any available transports according to the destination. But some |
| 2114 | * application may want to have explicit control over the transport to |
| 2115 | * use, so in that case it can set this field. |
| 2116 | * |
| 2117 | * Default: -1 (PJSUA_INVALID_ID) |
| 2118 | * |
| 2119 | * @see pjsua_acc_set_transport() |
| 2120 | */ |
| 2121 | pjsua_transport_id transport_id; |
| 2122 | |
Benny Prijono | 15b0230 | 2007-09-27 14:07:07 +0000 | [diff] [blame] | 2123 | /** |
Benny Prijono | cca2e43 | 2010-02-25 09:33:18 +0000 | [diff] [blame] | 2124 | * This option is used to update the transport address and the Contact |
Benny Prijono | e8554ef | 2008-03-22 09:33:52 +0000 | [diff] [blame] | 2125 | * header of REGISTER request. When this option is enabled, the library |
| 2126 | * will keep track of the public IP address from the response of REGISTER |
| 2127 | * request. Once it detects that the address has changed, it will |
| 2128 | * unregister current Contact, update the Contact with transport address |
| 2129 | * learned from Via header, and register a new Contact to the registrar. |
| 2130 | * This will also update the public name of UDP transport if STUN is |
Benny Prijono | cca2e43 | 2010-02-25 09:33:18 +0000 | [diff] [blame] | 2131 | * configured. |
Benny Prijono | 15b0230 | 2007-09-27 14:07:07 +0000 | [diff] [blame] | 2132 | * |
Benny Prijono | c6d5fdc | 2010-06-20 08:58:26 +0000 | [diff] [blame] | 2133 | * See also contact_rewrite_method field. |
| 2134 | * |
Benny Prijono | 15b0230 | 2007-09-27 14:07:07 +0000 | [diff] [blame] | 2135 | * Default: 1 (yes) |
| 2136 | */ |
Benny Prijono | e8554ef | 2008-03-22 09:33:52 +0000 | [diff] [blame] | 2137 | pj_bool_t allow_contact_rewrite; |
Benny Prijono | 15b0230 | 2007-09-27 14:07:07 +0000 | [diff] [blame] | 2138 | |
Benny Prijono | bddef2c | 2007-10-31 13:28:08 +0000 | [diff] [blame] | 2139 | /** |
Benny Prijono | c6d5fdc | 2010-06-20 08:58:26 +0000 | [diff] [blame] | 2140 | * Specify how Contact update will be done with the registration, if |
| 2141 | * \a allow_contact_rewrite is enabled. |
| 2142 | * |
| 2143 | * If set to 1, the Contact update will be done by sending unregistration |
| 2144 | * to the currently registered Contact, while simultaneously sending new |
| 2145 | * registration (with different Call-ID) for the updated Contact. |
| 2146 | * |
| 2147 | * If set to 2, the Contact update will be done in a single, current |
| 2148 | * registration session, by removing the current binding (by setting its |
| 2149 | * Contact's expires parameter to zero) and adding a new Contact binding, |
| 2150 | * all done in a single request. |
| 2151 | * |
| 2152 | * Value 1 is the legacy behavior. |
| 2153 | * |
| 2154 | * Default value: PJSUA_CONTACT_REWRITE_METHOD (2) |
| 2155 | */ |
| 2156 | int contact_rewrite_method; |
| 2157 | |
| 2158 | /** |
Benny Prijono | bddef2c | 2007-10-31 13:28:08 +0000 | [diff] [blame] | 2159 | * Set the interval for periodic keep-alive transmission for this account. |
| 2160 | * If this value is zero, keep-alive will be disabled for this account. |
| 2161 | * The keep-alive transmission will be sent to the registrar's address, |
| 2162 | * after successful registration. |
| 2163 | * |
Benny Prijono | bddef2c | 2007-10-31 13:28:08 +0000 | [diff] [blame] | 2164 | * Default: 15 (seconds) |
| 2165 | */ |
| 2166 | unsigned ka_interval; |
| 2167 | |
| 2168 | /** |
| 2169 | * Specify the data to be transmitted as keep-alive packets. |
| 2170 | * |
| 2171 | * Default: CR-LF |
| 2172 | */ |
| 2173 | pj_str_t ka_data; |
| 2174 | |
Benny Prijono | d817965 | 2008-01-23 20:39:07 +0000 | [diff] [blame] | 2175 | #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) |
| 2176 | /** |
| 2177 | * Specify whether secure media transport should be used for this account. |
| 2178 | * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and |
| 2179 | * PJMEDIA_SRTP_MANDATORY. |
| 2180 | * |
| 2181 | * Default: #PJSUA_DEFAULT_USE_SRTP |
| 2182 | */ |
| 2183 | pjmedia_srtp_use use_srtp; |
| 2184 | |
| 2185 | /** |
| 2186 | * Specify whether SRTP requires secure signaling to be used. This option |
| 2187 | * is only used when \a use_srtp option above is non-zero. |
| 2188 | * |
| 2189 | * Valid values are: |
| 2190 | * 0: SRTP does not require secure signaling |
| 2191 | * 1: SRTP requires secure transport such as TLS |
| 2192 | * 2: SRTP requires secure end-to-end transport (SIPS) |
| 2193 | * |
| 2194 | * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING |
| 2195 | */ |
| 2196 | int srtp_secure_signaling; |
Nanang Izzuddin | d89cc3a | 2010-05-13 05:22:51 +0000 | [diff] [blame] | 2197 | |
| 2198 | /** |
| 2199 | * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose |
| 2200 | * duplicated media in SDP offer, i.e: unsecured and secured version. |
| 2201 | * Otherwise, the SDP media will be composed as unsecured media but |
| 2202 | * with SDP "crypto" attribute. |
| 2203 | * |
| 2204 | * Default: PJ_FALSE |
| 2205 | */ |
| 2206 | pj_bool_t srtp_optional_dup_offer; |
Benny Prijono | d817965 | 2008-01-23 20:39:07 +0000 | [diff] [blame] | 2207 | #endif |
| 2208 | |
Nanang Izzuddin | 36dd5b6 | 2010-03-30 11:13:59 +0000 | [diff] [blame] | 2209 | /** |
| 2210 | * Specify interval of auto registration retry upon registration failure |
| 2211 | * (including caused by transport problem), in second. Set to 0 to |
| 2212 | * disable auto re-registration. |
| 2213 | * |
| 2214 | * Default: #PJSUA_REG_RETRY_INTERVAL |
| 2215 | */ |
| 2216 | unsigned reg_retry_interval; |
| 2217 | |
| 2218 | /** |
| 2219 | * Specify whether calls of the configured account should be dropped |
| 2220 | * after registration failure and an attempt of re-registration has |
| 2221 | * also failed. |
| 2222 | * |
| 2223 | * Default: PJ_FALSE (disabled) |
| 2224 | */ |
| 2225 | pj_bool_t drop_calls_on_reg_fail; |
| 2226 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2227 | } pjsua_acc_config; |
| 2228 | |
| 2229 | |
| 2230 | /** |
| 2231 | * Call this function to initialize account config with default values. |
| 2232 | * |
| 2233 | * @param cfg The account config to be initialized. |
| 2234 | */ |
Benny Prijono | 1f61a8f | 2007-08-16 10:11:44 +0000 | [diff] [blame] | 2235 | PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2236 | |
| 2237 | |
| 2238 | /** |
Benny Prijono | bddef2c | 2007-10-31 13:28:08 +0000 | [diff] [blame] | 2239 | * Duplicate account config. |
| 2240 | * |
| 2241 | * @param pool Pool to be used for duplicating the config. |
| 2242 | * @param dst Destination configuration. |
| 2243 | * @param src Source configuration. |
| 2244 | */ |
| 2245 | PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool, |
| 2246 | pjsua_acc_config *dst, |
| 2247 | const pjsua_acc_config *src); |
| 2248 | |
| 2249 | |
| 2250 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2251 | * Account info. Application can query account info by calling |
| 2252 | * #pjsua_acc_get_info(). |
| 2253 | */ |
| 2254 | typedef struct pjsua_acc_info |
| 2255 | { |
| 2256 | /** |
| 2257 | * The account ID. |
| 2258 | */ |
| 2259 | pjsua_acc_id id; |
| 2260 | |
| 2261 | /** |
| 2262 | * Flag to indicate whether this is the default account. |
| 2263 | */ |
| 2264 | pj_bool_t is_default; |
| 2265 | |
| 2266 | /** |
| 2267 | * Account URI |
| 2268 | */ |
| 2269 | pj_str_t acc_uri; |
| 2270 | |
| 2271 | /** |
| 2272 | * Flag to tell whether this account has registration setting |
| 2273 | * (reg_uri is not empty). |
| 2274 | */ |
| 2275 | pj_bool_t has_registration; |
| 2276 | |
| 2277 | /** |
| 2278 | * An up to date expiration interval for account registration session. |
| 2279 | */ |
| 2280 | int expires; |
| 2281 | |
| 2282 | /** |
| 2283 | * Last registration status code. If status code is zero, the account |
| 2284 | * is currently not registered. Any other value indicates the SIP |
| 2285 | * status code of the registration. |
| 2286 | */ |
| 2287 | pjsip_status_code status; |
| 2288 | |
| 2289 | /** |
| 2290 | * String describing the registration status. |
| 2291 | */ |
| 2292 | pj_str_t status_text; |
| 2293 | |
| 2294 | /** |
| 2295 | * Presence online status for this account. |
| 2296 | */ |
| 2297 | pj_bool_t online_status; |
| 2298 | |
| 2299 | /** |
Benny Prijono | 4461c7d | 2007-08-25 13:36:15 +0000 | [diff] [blame] | 2300 | * Presence online status text. |
| 2301 | */ |
| 2302 | pj_str_t online_status_text; |
| 2303 | |
| 2304 | /** |
| 2305 | * Extended RPID online status information. |
| 2306 | */ |
| 2307 | pjrpid_element rpid; |
| 2308 | |
| 2309 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2310 | * Buffer that is used internally to store the status text. |
| 2311 | */ |
| 2312 | char buf_[PJ_ERR_MSG_SIZE]; |
| 2313 | |
| 2314 | } pjsua_acc_info; |
| 2315 | |
| 2316 | |
| 2317 | |
| 2318 | /** |
| 2319 | * Get number of current accounts. |
| 2320 | * |
| 2321 | * @return Current number of accounts. |
| 2322 | */ |
| 2323 | PJ_DECL(unsigned) pjsua_acc_get_count(void); |
| 2324 | |
| 2325 | |
| 2326 | /** |
| 2327 | * Check if the specified account ID is valid. |
| 2328 | * |
| 2329 | * @param acc_id Account ID to check. |
| 2330 | * |
| 2331 | * @return Non-zero if account ID is valid. |
| 2332 | */ |
| 2333 | PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id); |
| 2334 | |
| 2335 | |
| 2336 | /** |
Benny Prijono | 21b9ad9 | 2006-08-15 13:11:22 +0000 | [diff] [blame] | 2337 | * Set default account to be used when incoming and outgoing |
| 2338 | * requests doesn't match any accounts. |
| 2339 | * |
| 2340 | * @param acc_id The account ID to be used as default. |
| 2341 | * |
| 2342 | * @return PJ_SUCCESS on success. |
| 2343 | */ |
| 2344 | PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id); |
| 2345 | |
| 2346 | |
| 2347 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2348 | * Get default account to be used when receiving incoming requests (calls), |
| 2349 | * when the destination of the incoming call doesn't match any other |
| 2350 | * accounts. |
Benny Prijono | 21b9ad9 | 2006-08-15 13:11:22 +0000 | [diff] [blame] | 2351 | * |
| 2352 | * @return The default account ID, or PJSUA_INVALID_ID if no |
| 2353 | * default account is configured. |
| 2354 | */ |
| 2355 | PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void); |
| 2356 | |
| 2357 | |
| 2358 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2359 | * Add a new account to pjsua. PJSUA must have been initialized (with |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2360 | * #pjsua_init()) before calling this function. If registration is configured |
| 2361 | * for this account, this function would also start the SIP registration |
| 2362 | * session with the SIP registrar server. This SIP registration session |
| 2363 | * will be maintained internally by the library, and application doesn't |
| 2364 | * need to do anything to maintain the registration session. |
| 2365 | * |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2366 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 2367 | * @param acc_cfg Account configuration. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2368 | * @param is_default If non-zero, this account will be set as the default |
| 2369 | * account. The default account will be used when sending |
| 2370 | * outgoing requests (e.g. making call) when no account is |
| 2371 | * specified, and when receiving incoming requests when the |
| 2372 | * request does not match any accounts. It is recommended |
| 2373 | * that default account is set to local/LAN account. |
| 2374 | * @param p_acc_id Pointer to receive account ID of the new account. |
| 2375 | * |
| 2376 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2377 | */ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 2378 | PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg, |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2379 | pj_bool_t is_default, |
| 2380 | pjsua_acc_id *p_acc_id); |
| 2381 | |
| 2382 | |
| 2383 | /** |
| 2384 | * Add a local account. A local account is used to identify local endpoint |
| 2385 | * instead of a specific user, and for this reason, a transport ID is needed |
| 2386 | * to obtain the local address information. |
| 2387 | * |
| 2388 | * @param tid Transport ID to generate account address. |
| 2389 | * @param is_default If non-zero, this account will be set as the default |
| 2390 | * account. The default account will be used when sending |
| 2391 | * outgoing requests (e.g. making call) when no account is |
| 2392 | * specified, and when receiving incoming requests when the |
| 2393 | * request does not match any accounts. It is recommended |
| 2394 | * that default account is set to local/LAN account. |
| 2395 | * @param p_acc_id Pointer to receive account ID of the new account. |
| 2396 | * |
| 2397 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2398 | */ |
| 2399 | PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid, |
| 2400 | pj_bool_t is_default, |
| 2401 | pjsua_acc_id *p_acc_id); |
| 2402 | |
| 2403 | /** |
Benny Prijono | 705e784 | 2008-07-21 18:12:51 +0000 | [diff] [blame] | 2404 | * Set arbitrary data to be associated with the account. |
| 2405 | * |
| 2406 | * @param acc_id The account ID. |
| 2407 | * @param user_data User/application data. |
| 2408 | * |
| 2409 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2410 | */ |
| 2411 | PJ_DECL(pj_status_t) pjsua_acc_set_user_data(pjsua_acc_id acc_id, |
| 2412 | void *user_data); |
| 2413 | |
| 2414 | |
| 2415 | /** |
| 2416 | * Retrieve arbitrary data associated with the account. |
| 2417 | * |
| 2418 | * @param acc_id The account ID. |
| 2419 | * |
| 2420 | * @return The user data. In the case where the account ID is |
| 2421 | * not valid, NULL is returned. |
| 2422 | */ |
| 2423 | PJ_DECL(void*) pjsua_acc_get_user_data(pjsua_acc_id acc_id); |
| 2424 | |
| 2425 | |
| 2426 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2427 | * Delete an account. This will unregister the account from the SIP server, |
| 2428 | * if necessary, and terminate server side presence subscriptions associated |
| 2429 | * with this account. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2430 | * |
| 2431 | * @param acc_id Id of the account to be deleted. |
| 2432 | * |
| 2433 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2434 | */ |
| 2435 | PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id); |
| 2436 | |
| 2437 | |
| 2438 | /** |
| 2439 | * Modify account information. |
| 2440 | * |
| 2441 | * @param acc_id Id of the account to be modified. |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 2442 | * @param acc_cfg New account configuration. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2443 | * |
| 2444 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2445 | */ |
| 2446 | PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id, |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 2447 | const pjsua_acc_config *acc_cfg); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2448 | |
| 2449 | |
| 2450 | /** |
| 2451 | * Modify account's presence status to be advertised to remote/presence |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2452 | * subscribers. This would trigger the sending of outgoing NOTIFY request |
Benny Prijono | 4461c7d | 2007-08-25 13:36:15 +0000 | [diff] [blame] | 2453 | * if there are server side presence subscription for this account, and/or |
| 2454 | * outgoing PUBLISH if presence publication is enabled for this account. |
| 2455 | * |
| 2456 | * @see pjsua_acc_set_online_status2() |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2457 | * |
| 2458 | * @param acc_id The account ID. |
| 2459 | * @param is_online True of false. |
| 2460 | * |
| 2461 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2462 | */ |
| 2463 | PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id, |
| 2464 | pj_bool_t is_online); |
| 2465 | |
Benny Prijono | 4461c7d | 2007-08-25 13:36:15 +0000 | [diff] [blame] | 2466 | /** |
| 2467 | * Modify account's presence status to be advertised to remote/presence |
| 2468 | * subscribers. This would trigger the sending of outgoing NOTIFY request |
| 2469 | * if there are server side presence subscription for this account, and/or |
| 2470 | * outgoing PUBLISH if presence publication is enabled for this account. |
| 2471 | * |
| 2472 | * @see pjsua_acc_set_online_status() |
| 2473 | * |
| 2474 | * @param acc_id The account ID. |
| 2475 | * @param is_online True of false. |
| 2476 | * @param pr Extended information in subset of RPID format |
| 2477 | * which allows setting custom presence text. |
| 2478 | * |
| 2479 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2480 | */ |
| 2481 | PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id, |
| 2482 | pj_bool_t is_online, |
| 2483 | const pjrpid_element *pr); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2484 | |
| 2485 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2486 | * Update registration or perform unregistration. If registration is |
| 2487 | * configured for this account, then initial SIP REGISTER will be sent |
| 2488 | * when the account is added with #pjsua_acc_add(). Application normally |
| 2489 | * only need to call this function if it wants to manually update the |
| 2490 | * registration or to unregister from the server. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2491 | * |
| 2492 | * @param acc_id The account ID. |
| 2493 | * @param renew If renew argument is zero, this will start |
| 2494 | * unregistration process. |
| 2495 | * |
| 2496 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2497 | */ |
| 2498 | PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id, |
| 2499 | pj_bool_t renew); |
| 2500 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2501 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2502 | * Get information about the specified account. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2503 | * |
| 2504 | * @param acc_id Account identification. |
| 2505 | * @param info Pointer to receive account information. |
| 2506 | * |
| 2507 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2508 | */ |
| 2509 | PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id, |
| 2510 | pjsua_acc_info *info); |
| 2511 | |
| 2512 | |
| 2513 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2514 | * Enumerate all account currently active in the library. This will fill |
| 2515 | * the array with the account Ids, and application can then query the |
| 2516 | * account information for each id with #pjsua_acc_get_info(). |
| 2517 | * |
| 2518 | * @see pjsua_acc_enum_info(). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2519 | * |
| 2520 | * @param ids Array of account IDs to be initialized. |
| 2521 | * @param count In input, specifies the maximum number of elements. |
| 2522 | * On return, it contains the actual number of elements. |
| 2523 | * |
| 2524 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2525 | */ |
| 2526 | PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[], |
| 2527 | unsigned *count ); |
| 2528 | |
| 2529 | |
| 2530 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2531 | * Enumerate account informations. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2532 | * |
| 2533 | * @param info Array of account infos to be initialized. |
| 2534 | * @param count In input, specifies the maximum number of elements. |
| 2535 | * On return, it contains the actual number of elements. |
| 2536 | * |
| 2537 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2538 | */ |
| 2539 | PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[], |
| 2540 | unsigned *count ); |
| 2541 | |
| 2542 | |
| 2543 | /** |
| 2544 | * This is an internal function to find the most appropriate account to |
| 2545 | * used to reach to the specified URL. |
| 2546 | * |
| 2547 | * @param url The remote URL to reach. |
| 2548 | * |
| 2549 | * @return Account id. |
| 2550 | */ |
| 2551 | PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url); |
| 2552 | |
| 2553 | |
| 2554 | /** |
| 2555 | * This is an internal function to find the most appropriate account to be |
| 2556 | * used to handle incoming calls. |
| 2557 | * |
| 2558 | * @param rdata The incoming request message. |
| 2559 | * |
| 2560 | * @return Account id. |
| 2561 | */ |
| 2562 | PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata); |
| 2563 | |
| 2564 | |
Benny Prijono | c570f2d | 2006-07-18 00:33:02 +0000 | [diff] [blame] | 2565 | /** |
Benny Prijono | fff245c | 2007-04-02 11:44:47 +0000 | [diff] [blame] | 2566 | * Create arbitrary requests using the account. Application should only use |
| 2567 | * this function to create auxiliary requests outside dialog, such as |
| 2568 | * OPTIONS, and use the call or presence API to create dialog related |
| 2569 | * requests. |
| 2570 | * |
| 2571 | * @param acc_id The account ID. |
| 2572 | * @param method The SIP method of the request. |
| 2573 | * @param target Target URI. |
| 2574 | * @param p_tdata Pointer to receive the request. |
| 2575 | * |
| 2576 | * @return PJ_SUCCESS or the error code. |
| 2577 | */ |
| 2578 | PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id, |
| 2579 | const pjsip_method *method, |
| 2580 | const pj_str_t *target, |
| 2581 | pjsip_tx_data **p_tdata); |
| 2582 | |
| 2583 | |
| 2584 | /** |
Nanang Izzuddin | 5af37ff | 2009-08-05 18:41:23 +0000 | [diff] [blame] | 2585 | * Create a suitable Contact header value, based on the specified target URI |
| 2586 | * for the specified account. |
Benny Prijono | c570f2d | 2006-07-18 00:33:02 +0000 | [diff] [blame] | 2587 | * |
| 2588 | * @param pool Pool to allocate memory for the string. |
Nanang Izzuddin | 5af37ff | 2009-08-05 18:41:23 +0000 | [diff] [blame] | 2589 | * @param contact The string where the Contact will be stored. |
Benny Prijono | c570f2d | 2006-07-18 00:33:02 +0000 | [diff] [blame] | 2590 | * @param acc_id Account ID. |
| 2591 | * @param uri Destination URI of the request. |
| 2592 | * |
| 2593 | * @return PJ_SUCCESS on success, other on error. |
| 2594 | */ |
| 2595 | PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool, |
| 2596 | pj_str_t *contact, |
| 2597 | pjsua_acc_id acc_id, |
| 2598 | const pj_str_t *uri); |
| 2599 | |
| 2600 | |
| 2601 | |
| 2602 | /** |
Nanang Izzuddin | 5af37ff | 2009-08-05 18:41:23 +0000 | [diff] [blame] | 2603 | * Create a suitable Contact header value, based on the information in the |
| 2604 | * incoming request. |
Benny Prijono | c570f2d | 2006-07-18 00:33:02 +0000 | [diff] [blame] | 2605 | * |
| 2606 | * @param pool Pool to allocate memory for the string. |
Nanang Izzuddin | 5af37ff | 2009-08-05 18:41:23 +0000 | [diff] [blame] | 2607 | * @param contact The string where the Contact will be stored. |
Benny Prijono | c570f2d | 2006-07-18 00:33:02 +0000 | [diff] [blame] | 2608 | * @param acc_id Account ID. |
| 2609 | * @param rdata Incoming request. |
| 2610 | * |
| 2611 | * @return PJ_SUCCESS on success, other on error. |
| 2612 | */ |
| 2613 | PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool, |
| 2614 | pj_str_t *contact, |
| 2615 | pjsua_acc_id acc_id, |
| 2616 | pjsip_rx_data *rdata ); |
| 2617 | |
| 2618 | |
Benny Prijono | 62c5c5b | 2007-01-13 23:22:40 +0000 | [diff] [blame] | 2619 | /** |
| 2620 | * Lock/bind this account to a specific transport/listener. Normally |
| 2621 | * application shouldn't need to do this, as transports will be selected |
| 2622 | * automatically by the stack according to the destination. |
| 2623 | * |
| 2624 | * When account is locked/bound to a specific transport, all outgoing |
| 2625 | * requests from this account will use the specified transport (this |
| 2626 | * includes SIP registration, dialog (call and event subscription), and |
| 2627 | * out-of-dialog requests such as MESSAGE). |
| 2628 | * |
| 2629 | * Note that transport_id may be specified in pjsua_acc_config too. |
| 2630 | * |
| 2631 | * @param acc_id The account ID. |
| 2632 | * @param tp_id The transport ID. |
| 2633 | * |
| 2634 | * @return PJ_SUCCESS on success. |
| 2635 | */ |
| 2636 | PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id, |
| 2637 | pjsua_transport_id tp_id); |
| 2638 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2639 | |
| 2640 | /** |
| 2641 | * @} |
| 2642 | */ |
| 2643 | |
| 2644 | |
| 2645 | /***************************************************************************** |
| 2646 | * CALLS API |
| 2647 | */ |
| 2648 | |
| 2649 | |
| 2650 | /** |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 2651 | * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2652 | * @ingroup PJSUA_LIB |
| 2653 | * @brief Call manipulation. |
| 2654 | * @{ |
| 2655 | */ |
| 2656 | |
| 2657 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2658 | * Maximum simultaneous calls. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2659 | */ |
| 2660 | #ifndef PJSUA_MAX_CALLS |
| 2661 | # define PJSUA_MAX_CALLS 32 |
| 2662 | #endif |
| 2663 | |
| 2664 | |
| 2665 | |
| 2666 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2667 | * This enumeration specifies the media status of a call, and it's part |
| 2668 | * of pjsua_call_info structure. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2669 | */ |
| 2670 | typedef enum pjsua_call_media_status |
| 2671 | { |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2672 | /** Call currently has no media */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2673 | PJSUA_CALL_MEDIA_NONE, |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2674 | |
| 2675 | /** The media is active */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2676 | PJSUA_CALL_MEDIA_ACTIVE, |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2677 | |
| 2678 | /** The media is currently put on hold by local endpoint */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2679 | PJSUA_CALL_MEDIA_LOCAL_HOLD, |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2680 | |
| 2681 | /** The media is currently put on hold by remote endpoint */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2682 | PJSUA_CALL_MEDIA_REMOTE_HOLD, |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2683 | |
Benny Prijono | 096c56c | 2007-09-15 08:30:16 +0000 | [diff] [blame] | 2684 | /** The media has reported error (e.g. ICE negotiation) */ |
| 2685 | PJSUA_CALL_MEDIA_ERROR |
| 2686 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2687 | } pjsua_call_media_status; |
| 2688 | |
| 2689 | |
| 2690 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2691 | * This structure describes the information and current status of a call. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2692 | */ |
| 2693 | typedef struct pjsua_call_info |
| 2694 | { |
| 2695 | /** Call identification. */ |
| 2696 | pjsua_call_id id; |
| 2697 | |
| 2698 | /** Initial call role (UAC == caller) */ |
| 2699 | pjsip_role_e role; |
| 2700 | |
Benny Prijono | 9031551 | 2006-09-14 16:05:16 +0000 | [diff] [blame] | 2701 | /** The account ID where this call belongs. */ |
| 2702 | pjsua_acc_id acc_id; |
| 2703 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 2704 | /** Local URI */ |
| 2705 | pj_str_t local_info; |
| 2706 | |
| 2707 | /** Local Contact */ |
| 2708 | pj_str_t local_contact; |
| 2709 | |
| 2710 | /** Remote URI */ |
| 2711 | pj_str_t remote_info; |
| 2712 | |
| 2713 | /** Remote contact */ |
| 2714 | pj_str_t remote_contact; |
| 2715 | |
| 2716 | /** Dialog Call-ID string. */ |
| 2717 | pj_str_t call_id; |
| 2718 | |
| 2719 | /** Call state */ |
| 2720 | pjsip_inv_state state; |
| 2721 | |
| 2722 | /** Text describing the state */ |
| 2723 | pj_str_t state_text; |
| 2724 | |
| 2725 | /** Last status code heard, which can be used as cause code */ |
| 2726 | pjsip_status_code last_status; |
| 2727 | |
| 2728 | /** The reason phrase describing the status. */ |
| 2729 | pj_str_t last_status_text; |
| 2730 | |
| 2731 | /** Call media status. */ |
| 2732 | pjsua_call_media_status media_status; |
| 2733 | |
| 2734 | /** Media direction */ |
| 2735 | pjmedia_dir media_dir; |
| 2736 | |
| 2737 | /** The conference port number for the call */ |
| 2738 | pjsua_conf_port_id conf_slot; |
| 2739 | |
| 2740 | /** Up-to-date call connected duration (zero when call is not |
| 2741 | * established) |
| 2742 | */ |
| 2743 | pj_time_val connect_duration; |
| 2744 | |
| 2745 | /** Total call duration, including set-up time */ |
| 2746 | pj_time_val total_duration; |
| 2747 | |
| 2748 | /** Internal */ |
| 2749 | struct { |
| 2750 | char local_info[128]; |
| 2751 | char local_contact[128]; |
| 2752 | char remote_info[128]; |
| 2753 | char remote_contact[128]; |
| 2754 | char call_id[128]; |
| 2755 | char last_status_text[128]; |
| 2756 | } buf_; |
| 2757 | |
| 2758 | } pjsua_call_info; |
| 2759 | |
| 2760 | |
| 2761 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 2762 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2763 | * Get maximum number of calls configured in pjsua. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2764 | * |
| 2765 | * @return Maximum number of calls configured. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2766 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 2767 | PJ_DECL(unsigned) pjsua_call_get_max_count(void); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2768 | |
| 2769 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2770 | * Get number of currently active calls. |
| 2771 | * |
| 2772 | * @return Number of currently active calls. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2773 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 2774 | PJ_DECL(unsigned) pjsua_call_get_count(void); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2775 | |
| 2776 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2777 | * Enumerate all active calls. Application may then query the information and |
| 2778 | * state of each call by calling #pjsua_call_get_info(). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2779 | * |
| 2780 | * @param ids Array of account IDs to be initialized. |
| 2781 | * @param count In input, specifies the maximum number of elements. |
| 2782 | * On return, it contains the actual number of elements. |
| 2783 | * |
| 2784 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2785 | */ |
| 2786 | PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[], |
| 2787 | unsigned *count); |
| 2788 | |
| 2789 | |
| 2790 | /** |
| 2791 | * Make outgoing call to the specified URI using the specified account. |
| 2792 | * |
| 2793 | * @param acc_id The account to be used. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2794 | * @param dst_uri URI to be put in the To header (normally is the same |
| 2795 | * as the target URI). |
| 2796 | * @param options Options (must be zero at the moment). |
| 2797 | * @param user_data Arbitrary user data to be attached to the call, and |
| 2798 | * can be retrieved later. |
| 2799 | * @param msg_data Optional headers etc to be added to outgoing INVITE |
| 2800 | * request, or NULL if no custom header is desired. |
| 2801 | * @param p_call_id Pointer to receive call identification. |
| 2802 | * |
| 2803 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2804 | */ |
| 2805 | PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id, |
| 2806 | const pj_str_t *dst_uri, |
| 2807 | unsigned options, |
| 2808 | void *user_data, |
| 2809 | const pjsua_msg_data *msg_data, |
| 2810 | pjsua_call_id *p_call_id); |
| 2811 | |
| 2812 | |
| 2813 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2814 | * Check if the specified call has active INVITE session and the INVITE |
| 2815 | * session has not been disconnected. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2816 | * |
| 2817 | * @param call_id Call identification. |
| 2818 | * |
| 2819 | * @return Non-zero if call is active. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2820 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2821 | PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2822 | |
| 2823 | |
| 2824 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2825 | * Check if call has an active media session. |
| 2826 | * |
| 2827 | * @param call_id Call identification. |
| 2828 | * |
| 2829 | * @return Non-zero if yes. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2830 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2831 | PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2832 | |
| 2833 | |
| 2834 | /** |
Benny Prijono | cf986c4 | 2008-09-02 11:25:07 +0000 | [diff] [blame] | 2835 | * Retrieve the media session associated with this call. Note that the media |
| 2836 | * session may not be available depending on the current call's media status |
| 2837 | * (the pjsua_call_media_status information in pjsua_call_info). Application |
| 2838 | * may use the media session to retrieve more detailed information about the |
| 2839 | * call's media. |
| 2840 | * |
| 2841 | * @param call_id Call identification. |
| 2842 | * |
| 2843 | * @return Call media session. |
| 2844 | */ |
| 2845 | PJ_DECL(pjmedia_session*) pjsua_call_get_media_session(pjsua_call_id call_id); |
| 2846 | |
| 2847 | |
| 2848 | /** |
| 2849 | * Retrieve the media transport instance that is used for this call. |
| 2850 | * Application may use the media transport to query more detailed information |
| 2851 | * about the media transport. |
| 2852 | * |
| 2853 | * @param cid Call identification (the call_id). |
| 2854 | * |
| 2855 | * @return Call media transport. |
| 2856 | */ |
| 2857 | PJ_DECL(pjmedia_transport*) pjsua_call_get_media_transport(pjsua_call_id cid); |
| 2858 | |
| 2859 | |
| 2860 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2861 | * Get the conference port identification associated with the call. |
| 2862 | * |
| 2863 | * @param call_id Call identification. |
| 2864 | * |
| 2865 | * @return Conference port ID, or PJSUA_INVALID_ID when the |
| 2866 | * media has not been established or is not active. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2867 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2868 | PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id); |
| 2869 | |
| 2870 | /** |
| 2871 | * Obtain detail information about the specified call. |
| 2872 | * |
| 2873 | * @param call_id Call identification. |
| 2874 | * @param info Call info to be initialized. |
| 2875 | * |
| 2876 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 2877 | */ |
| 2878 | PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id, |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2879 | pjsua_call_info *info); |
| 2880 | |
Nanang Izzuddin | 2a1b9ee | 2010-06-03 10:41:32 +0000 | [diff] [blame] | 2881 | /** |
| 2882 | * Check if remote peer support the specified capability. |
| 2883 | * |
| 2884 | * @param call_id Call identification. |
| 2885 | * @param htype The header type to be checked, which value may be: |
| 2886 | * - PJSIP_H_ACCEPT |
| 2887 | * - PJSIP_H_ALLOW |
| 2888 | * - PJSIP_H_SUPPORTED |
| 2889 | * @param hname If htype specifies PJSIP_H_OTHER, then the header |
| 2890 | * name must be supplied in this argument. Otherwise the |
| 2891 | * value must be set to NULL. |
| 2892 | * @param token The capability token to check. For example, if \a |
| 2893 | * htype is PJSIP_H_ALLOW, then \a token specifies the |
| 2894 | * method names; if \a htype is PJSIP_H_SUPPORTED, then |
| 2895 | * \a token specifies the extension names such as |
| 2896 | * "100rel". |
| 2897 | * |
| 2898 | * @return PJSIP_DIALOG_CAP_SUPPORTED if the specified capability |
| 2899 | * is explicitly supported, see @pjsip_dialog_cap_status |
| 2900 | * for more info. |
| 2901 | */ |
| 2902 | PJ_DECL(pjsip_dialog_cap_status) pjsua_call_remote_has_cap( |
| 2903 | pjsua_call_id call_id, |
| 2904 | int htype, |
| 2905 | const pj_str_t *hname, |
| 2906 | const pj_str_t *token); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2907 | |
| 2908 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2909 | * Attach application specific data to the call. Application can then |
| 2910 | * inspect this data by calling #pjsua_call_get_user_data(). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2911 | * |
| 2912 | * @param call_id Call identification. |
| 2913 | * @param user_data Arbitrary data to be attached to the call. |
| 2914 | * |
| 2915 | * @return The user data. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2916 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2917 | PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id, |
| 2918 | void *user_data); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 2919 | |
| 2920 | |
| 2921 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2922 | * Get user data attached to the call, which has been previously set with |
| 2923 | * #pjsua_call_set_user_data(). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2924 | * |
| 2925 | * @param call_id Call identification. |
| 2926 | * |
| 2927 | * @return The user data. |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 2928 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2929 | PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id); |
Benny Prijono | 84126ab | 2006-02-09 09:30:09 +0000 | [diff] [blame] | 2930 | |
| 2931 | |
| 2932 | /** |
Benny Prijono | 91a6a17 | 2007-10-31 08:59:29 +0000 | [diff] [blame] | 2933 | * Get the NAT type of remote's endpoint. This is a proprietary feature |
| 2934 | * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp |
| 2935 | * is set in #pjsua_config. |
| 2936 | * |
| 2937 | * This function can only be called after SDP has been received from remote, |
| 2938 | * which means for incoming call, this function can be called as soon as |
| 2939 | * call is received as long as incoming call contains SDP, and for outgoing |
| 2940 | * call, this function can be called only after SDP is received (normally in |
| 2941 | * 200/OK response to INVITE). As a general case, application should call |
| 2942 | * this function after or in \a on_call_media_state() callback. |
| 2943 | * |
| 2944 | * @param call_id Call identification. |
| 2945 | * @param p_type Pointer to store the NAT type. Application can then |
| 2946 | * retrieve the string description of the NAT type |
| 2947 | * by calling pj_stun_get_nat_name(). |
| 2948 | * |
| 2949 | * @return PJ_SUCCESS on success. |
| 2950 | * |
| 2951 | * @see pjsua_get_nat_type(), nat_type_in_sdp |
| 2952 | */ |
| 2953 | PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id, |
| 2954 | pj_stun_nat_type *p_type); |
| 2955 | |
| 2956 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2957 | * Send response to incoming INVITE request. Depending on the status |
| 2958 | * code specified as parameter, this function may send provisional |
| 2959 | * response, establish the call, or terminate the call. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2960 | * |
| 2961 | * @param call_id Incoming call identification. |
| 2962 | * @param code Status code, (100-699). |
| 2963 | * @param reason Optional reason phrase. If NULL, default text |
| 2964 | * will be used. |
| 2965 | * @param msg_data Optional list of headers etc to be added to outgoing |
| 2966 | * response message. |
| 2967 | * |
| 2968 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 2969 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2970 | PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id, |
| 2971 | unsigned code, |
| 2972 | const pj_str_t *reason, |
| 2973 | const pjsua_msg_data *msg_data); |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 2974 | |
| 2975 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2976 | * Hangup call by using method that is appropriate according to the |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 2977 | * call state. This function is different than answering the call with |
| 2978 | * 3xx-6xx response (with #pjsua_call_answer()), in that this function |
| 2979 | * will hangup the call regardless of the state and role of the call, |
| 2980 | * while #pjsua_call_answer() only works with incoming calls on EARLY |
| 2981 | * state. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2982 | * |
| 2983 | * @param call_id Call identification. |
| 2984 | * @param code Optional status code to be sent when we're rejecting |
| 2985 | * incoming call. If the value is zero, "603/Decline" |
| 2986 | * will be sent. |
| 2987 | * @param reason Optional reason phrase to be sent when we're rejecting |
| 2988 | * incoming call. If NULL, default text will be used. |
| 2989 | * @param msg_data Optional list of headers etc to be added to outgoing |
| 2990 | * request/response message. |
| 2991 | * |
| 2992 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 2993 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 2994 | PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id, |
| 2995 | unsigned code, |
| 2996 | const pj_str_t *reason, |
| 2997 | const pjsua_msg_data *msg_data); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 2998 | |
Benny Prijono | 5e51a4e | 2008-11-27 00:06:46 +0000 | [diff] [blame] | 2999 | /** |
| 3000 | * Accept or reject redirection response. Application MUST call this function |
| 3001 | * after it signaled PJSIP_REDIRECT_PENDING in the \a on_call_redirected() |
| 3002 | * callback, to notify the call whether to accept or reject the redirection |
| 3003 | * to the current target. Application can use the combination of |
| 3004 | * PJSIP_REDIRECT_PENDING command in \a on_call_redirected() callback and |
| 3005 | * this function to ask for user permission before redirecting the call. |
| 3006 | * |
| 3007 | * Note that if the application chooses to reject or stop redirection (by |
| 3008 | * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the |
| 3009 | * call disconnection callback will be called before this function returns. |
| 3010 | * And if the application rejects the target, the \a on_call_redirected() |
| 3011 | * callback may also be called before this function returns if there is |
| 3012 | * another target to try. |
| 3013 | * |
| 3014 | * @param call_id The call ID. |
| 3015 | * @param cmd Redirection operation to be applied to the current |
| 3016 | * target. The semantic of this argument is similar |
| 3017 | * to the description in the \a on_call_redirected() |
| 3018 | * callback, except that the PJSIP_REDIRECT_PENDING is |
| 3019 | * not accepted here. |
| 3020 | * |
| 3021 | * @return PJ_SUCCESS on successful operation. |
| 3022 | */ |
| 3023 | PJ_DECL(pj_status_t) pjsua_call_process_redirect(pjsua_call_id call_id, |
| 3024 | pjsip_redirect_op cmd); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 3025 | |
| 3026 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3027 | * Put the specified call on hold. This will send re-INVITE with the |
| 3028 | * appropriate SDP to inform remote that the call is being put on hold. |
| 3029 | * The final status of the request itself will be reported on the |
| 3030 | * \a on_call_media_state() callback, which inform the application that |
| 3031 | * the media state of the call has changed. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3032 | * |
| 3033 | * @param call_id Call identification. |
| 3034 | * @param msg_data Optional message components to be sent with |
| 3035 | * the request. |
| 3036 | * |
| 3037 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 3038 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3039 | PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id, |
| 3040 | const pjsua_msg_data *msg_data); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 3041 | |
| 3042 | |
| 3043 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3044 | * Send re-INVITE to release hold. |
| 3045 | * The final status of the request itself will be reported on the |
| 3046 | * \a on_call_media_state() callback, which inform the application that |
| 3047 | * the media state of the call has changed. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3048 | * |
| 3049 | * @param call_id Call identification. |
| 3050 | * @param unhold If this argument is non-zero and the call is locally |
| 3051 | * held, this will release the local hold. |
| 3052 | * @param msg_data Optional message components to be sent with |
| 3053 | * the request. |
| 3054 | * |
| 3055 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 3056 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3057 | PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id, |
| 3058 | pj_bool_t unhold, |
| 3059 | const pjsua_msg_data *msg_data); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 3060 | |
Benny Prijono | c08682e | 2007-10-04 06:17:58 +0000 | [diff] [blame] | 3061 | /** |
| 3062 | * Send UPDATE request. |
| 3063 | * |
| 3064 | * @param call_id Call identification. |
| 3065 | * @param options Must be zero for now. |
| 3066 | * @param msg_data Optional message components to be sent with |
| 3067 | * the request. |
| 3068 | * |
| 3069 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3070 | */ |
| 3071 | PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id, |
| 3072 | unsigned options, |
| 3073 | const pjsua_msg_data *msg_data); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 3074 | |
| 3075 | /** |
Benny Prijono | 053f522 | 2006-11-11 16:16:04 +0000 | [diff] [blame] | 3076 | * Initiate call transfer to the specified address. This function will send |
| 3077 | * REFER request to instruct remote call party to initiate a new INVITE |
| 3078 | * session to the specified destination/target. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3079 | * |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3080 | * If application is interested to monitor the successfulness and |
| 3081 | * the progress of the transfer request, it can implement |
| 3082 | * \a on_call_transfer_status() callback which will report the progress |
| 3083 | * of the call transfer request. |
| 3084 | * |
Benny Prijono | 053f522 | 2006-11-11 16:16:04 +0000 | [diff] [blame] | 3085 | * @param call_id The call id to be transfered. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3086 | * @param dest Address of new target to be contacted. |
| 3087 | * @param msg_data Optional message components to be sent with |
| 3088 | * the request. |
| 3089 | * |
| 3090 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 3091 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3092 | PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id, |
| 3093 | const pj_str_t *dest, |
| 3094 | const pjsua_msg_data *msg_data); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3095 | |
| 3096 | /** |
Benny Prijono | 053f522 | 2006-11-11 16:16:04 +0000 | [diff] [blame] | 3097 | * Flag to indicate that "Require: replaces" should not be put in the |
| 3098 | * outgoing INVITE request caused by REFER request created by |
| 3099 | * #pjsua_call_xfer_replaces(). |
| 3100 | */ |
| 3101 | #define PJSUA_XFER_NO_REQUIRE_REPLACES 1 |
| 3102 | |
| 3103 | /** |
| 3104 | * Initiate attended call transfer. This function will send REFER request |
| 3105 | * to instruct remote call party to initiate new INVITE session to the URL |
| 3106 | * of \a dest_call_id. The party at \a dest_call_id then should "replace" |
| 3107 | * the call with us with the new call from the REFER recipient. |
| 3108 | * |
| 3109 | * @param call_id The call id to be transfered. |
| 3110 | * @param dest_call_id The call id to be replaced. |
| 3111 | * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES |
| 3112 | * to suppress the inclusion of "Require: replaces" in |
| 3113 | * the outgoing INVITE request created by the REFER |
| 3114 | * request. |
| 3115 | * @param msg_data Optional message components to be sent with |
| 3116 | * the request. |
| 3117 | * |
| 3118 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3119 | */ |
| 3120 | PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id, |
| 3121 | pjsua_call_id dest_call_id, |
| 3122 | unsigned options, |
| 3123 | const pjsua_msg_data *msg_data); |
| 3124 | |
| 3125 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3126 | * Send DTMF digits to remote using RFC 2833 payload formats. |
| 3127 | * |
| 3128 | * @param call_id Call identification. |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 3129 | * @param digits DTMF string digits to be sent. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3130 | * |
| 3131 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3132 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3133 | PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id, |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3134 | const pj_str_t *digits); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 3135 | |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 3136 | /** |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 3137 | * Send instant messaging inside INVITE session. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3138 | * |
| 3139 | * @param call_id Call identification. |
| 3140 | * @param mime_type Optional MIME type. If NULL, then "text/plain" is |
| 3141 | * assumed. |
| 3142 | * @param content The message content. |
| 3143 | * @param msg_data Optional list of headers etc to be included in outgoing |
| 3144 | * request. The body descriptor in the msg_data is |
| 3145 | * ignored. |
| 3146 | * @param user_data Optional user data, which will be given back when |
| 3147 | * the IM callback is called. |
| 3148 | * |
| 3149 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 3150 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3151 | PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id, |
| 3152 | const pj_str_t *mime_type, |
| 3153 | const pj_str_t *content, |
| 3154 | const pjsua_msg_data *msg_data, |
| 3155 | void *user_data); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 3156 | |
| 3157 | |
| 3158 | /** |
| 3159 | * Send IM typing indication inside INVITE session. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3160 | * |
| 3161 | * @param call_id Call identification. |
| 3162 | * @param is_typing Non-zero to indicate to remote that local person is |
| 3163 | * currently typing an IM. |
| 3164 | * @param msg_data Optional list of headers etc to be included in outgoing |
| 3165 | * request. |
| 3166 | * |
| 3167 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 3168 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3169 | PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id, |
| 3170 | pj_bool_t is_typing, |
| 3171 | const pjsua_msg_data*msg_data); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 3172 | |
| 3173 | /** |
Benny Prijono | feb69f4 | 2007-10-05 09:12:26 +0000 | [diff] [blame] | 3174 | * Send arbitrary request with the call. This is useful for example to send |
| 3175 | * INFO request. Note that application should not use this function to send |
| 3176 | * requests which would change the invite session's state, such as re-INVITE, |
| 3177 | * UPDATE, PRACK, and BYE. |
| 3178 | * |
| 3179 | * @param call_id Call identification. |
| 3180 | * @param method SIP method of the request. |
| 3181 | * @param msg_data Optional message body and/or list of headers to be |
| 3182 | * included in outgoing request. |
| 3183 | * |
| 3184 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3185 | */ |
| 3186 | PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id, |
| 3187 | const pj_str_t *method, |
| 3188 | const pjsua_msg_data *msg_data); |
| 3189 | |
| 3190 | |
| 3191 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3192 | * Terminate all calls. This will initiate #pjsua_call_hangup() for all |
| 3193 | * currently active calls. |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 3194 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 3195 | PJ_DECL(void) pjsua_call_hangup_all(void); |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 3196 | |
| 3197 | |
Benny Prijono | b9b32ab | 2006-06-01 12:28:44 +0000 | [diff] [blame] | 3198 | /** |
| 3199 | * Dump call and media statistics to string. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3200 | * |
| 3201 | * @param call_id Call identification. |
| 3202 | * @param with_media Non-zero to include media information too. |
| 3203 | * @param buffer Buffer where the statistics are to be written to. |
| 3204 | * @param maxlen Maximum length of buffer. |
| 3205 | * @param indent Spaces for left indentation. |
| 3206 | * |
| 3207 | * @return PJ_SUCCESS on success. |
Benny Prijono | b9b32ab | 2006-06-01 12:28:44 +0000 | [diff] [blame] | 3208 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3209 | PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id, |
| 3210 | pj_bool_t with_media, |
| 3211 | char *buffer, |
| 3212 | unsigned maxlen, |
| 3213 | const char *indent); |
Benny Prijono | b9b32ab | 2006-06-01 12:28:44 +0000 | [diff] [blame] | 3214 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3215 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3216 | * @} |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3217 | */ |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 3218 | |
| 3219 | |
| 3220 | /***************************************************************************** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3221 | * BUDDY API |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 3222 | */ |
| 3223 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3224 | |
| 3225 | /** |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 3226 | * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3227 | * @ingroup PJSUA_LIB |
| 3228 | * @brief Buddy management, buddy's presence, and instant messaging. |
| 3229 | * @{ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 3230 | * |
| 3231 | * This section describes PJSUA-APIs related to buddies management, |
| 3232 | * presence management, and instant messaging. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3233 | */ |
| 3234 | |
| 3235 | /** |
| 3236 | * Max buddies in buddy list. |
| 3237 | */ |
| 3238 | #ifndef PJSUA_MAX_BUDDIES |
| 3239 | # define PJSUA_MAX_BUDDIES 256 |
| 3240 | #endif |
| 3241 | |
| 3242 | |
| 3243 | /** |
Benny Prijono | 6ab0532 | 2009-10-21 03:03:06 +0000 | [diff] [blame] | 3244 | * This specifies how long the library should wait before retrying failed |
| 3245 | * SUBSCRIBE request, and there is no rule to automatically resubscribe |
| 3246 | * (for example, no "retry-after" parameter in Subscription-State header). |
| 3247 | * |
| 3248 | * This also controls the duration before failed PUBLISH request will be |
| 3249 | * retried. |
Benny Prijono | a17496a | 2007-10-31 10:20:31 +0000 | [diff] [blame] | 3250 | * |
| 3251 | * Default: 300 seconds |
| 3252 | */ |
| 3253 | #ifndef PJSUA_PRES_TIMER |
| 3254 | # define PJSUA_PRES_TIMER 300 |
| 3255 | #endif |
| 3256 | |
| 3257 | |
| 3258 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3259 | * This structure describes buddy configuration when adding a buddy to |
| 3260 | * the buddy list with #pjsua_buddy_add(). Application MUST initialize |
| 3261 | * the structure with #pjsua_buddy_config_default() to initialize this |
| 3262 | * structure with default configuration. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3263 | */ |
| 3264 | typedef struct pjsua_buddy_config |
| 3265 | { |
| 3266 | /** |
| 3267 | * Buddy URL or name address. |
| 3268 | */ |
| 3269 | pj_str_t uri; |
| 3270 | |
| 3271 | /** |
| 3272 | * Specify whether presence subscription should start immediately. |
| 3273 | */ |
| 3274 | pj_bool_t subscribe; |
| 3275 | |
Benny Prijono | 705e784 | 2008-07-21 18:12:51 +0000 | [diff] [blame] | 3276 | /** |
| 3277 | * Specify arbitrary application data to be associated with with |
| 3278 | * the buddy object. |
| 3279 | */ |
| 3280 | void *user_data; |
| 3281 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3282 | } pjsua_buddy_config; |
| 3283 | |
| 3284 | |
| 3285 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3286 | * This enumeration describes basic buddy's online status. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3287 | */ |
| 3288 | typedef enum pjsua_buddy_status |
| 3289 | { |
| 3290 | /** |
| 3291 | * Online status is unknown (possibly because no presence subscription |
| 3292 | * has been established). |
| 3293 | */ |
| 3294 | PJSUA_BUDDY_STATUS_UNKNOWN, |
| 3295 | |
| 3296 | /** |
Benny Prijono | fc24e69 | 2007-01-27 18:31:51 +0000 | [diff] [blame] | 3297 | * Buddy is known to be online. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3298 | */ |
| 3299 | PJSUA_BUDDY_STATUS_ONLINE, |
| 3300 | |
| 3301 | /** |
| 3302 | * Buddy is offline. |
| 3303 | */ |
| 3304 | PJSUA_BUDDY_STATUS_OFFLINE, |
| 3305 | |
| 3306 | } pjsua_buddy_status; |
| 3307 | |
| 3308 | |
| 3309 | |
| 3310 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3311 | * This structure describes buddy info, which can be retrieved by calling |
| 3312 | * #pjsua_buddy_get_info(). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3313 | */ |
| 3314 | typedef struct pjsua_buddy_info |
| 3315 | { |
| 3316 | /** |
| 3317 | * The buddy ID. |
| 3318 | */ |
| 3319 | pjsua_buddy_id id; |
| 3320 | |
| 3321 | /** |
| 3322 | * The full URI of the buddy, as specified in the configuration. |
| 3323 | */ |
| 3324 | pj_str_t uri; |
| 3325 | |
| 3326 | /** |
| 3327 | * Buddy's Contact, only available when presence subscription has |
| 3328 | * been established to the buddy. |
| 3329 | */ |
| 3330 | pj_str_t contact; |
| 3331 | |
| 3332 | /** |
| 3333 | * Buddy's online status. |
| 3334 | */ |
| 3335 | pjsua_buddy_status status; |
| 3336 | |
| 3337 | /** |
| 3338 | * Text to describe buddy's online status. |
| 3339 | */ |
| 3340 | pj_str_t status_text; |
| 3341 | |
| 3342 | /** |
| 3343 | * Flag to indicate that we should monitor the presence information for |
| 3344 | * this buddy (normally yes, unless explicitly disabled). |
| 3345 | */ |
| 3346 | pj_bool_t monitor_pres; |
| 3347 | |
| 3348 | /** |
Benny Prijono | 63fba01 | 2008-07-17 14:19:10 +0000 | [diff] [blame] | 3349 | * If \a monitor_pres is enabled, this specifies the last state of the |
| 3350 | * presence subscription. If presence subscription session is currently |
| 3351 | * active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence |
| 3352 | * subscription request has been rejected, the value will be |
| 3353 | * PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be |
| 3354 | * specified in \a sub_term_reason. |
| 3355 | */ |
| 3356 | pjsip_evsub_state sub_state; |
| 3357 | |
| 3358 | /** |
Benny Prijono | d06d8c5 | 2009-06-30 13:53:47 +0000 | [diff] [blame] | 3359 | * String representation of subscription state. |
| 3360 | */ |
| 3361 | const char *sub_state_name; |
| 3362 | |
| 3363 | /** |
Benny Prijono | 73bb723 | 2009-10-20 13:56:26 +0000 | [diff] [blame] | 3364 | * Specifies the last presence subscription termination code. This would |
| 3365 | * return the last status of the SUBSCRIBE request. If the subscription |
| 3366 | * is terminated with NOTIFY by the server, this value will be set to |
| 3367 | * 200, and subscription termination reason will be given in the |
| 3368 | * \a sub_term_reason field. |
| 3369 | */ |
| 3370 | unsigned sub_term_code; |
| 3371 | |
| 3372 | /** |
| 3373 | * Specifies the last presence subscription termination reason. If |
Benny Prijono | 63fba01 | 2008-07-17 14:19:10 +0000 | [diff] [blame] | 3374 | * presence subscription is currently active, the value will be empty. |
| 3375 | */ |
| 3376 | pj_str_t sub_term_reason; |
| 3377 | |
| 3378 | /** |
Benny Prijono | 4461c7d | 2007-08-25 13:36:15 +0000 | [diff] [blame] | 3379 | * Extended RPID information about the person. |
| 3380 | */ |
| 3381 | pjrpid_element rpid; |
| 3382 | |
| 3383 | /** |
Benny Prijono | 28add7e | 2009-06-15 16:03:40 +0000 | [diff] [blame] | 3384 | * Extended presence info. |
| 3385 | */ |
| 3386 | pjsip_pres_status pres_status; |
| 3387 | |
| 3388 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3389 | * Internal buffer. |
| 3390 | */ |
Benny Prijono | 4461c7d | 2007-08-25 13:36:15 +0000 | [diff] [blame] | 3391 | char buf_[512]; |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3392 | |
| 3393 | } pjsua_buddy_info; |
| 3394 | |
| 3395 | |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 3396 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3397 | * Set default values to the buddy config. |
| 3398 | */ |
Benny Prijono | 1f61a8f | 2007-08-16 10:11:44 +0000 | [diff] [blame] | 3399 | PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg); |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3400 | |
| 3401 | |
| 3402 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3403 | * Get total number of buddies. |
| 3404 | * |
| 3405 | * @return Number of buddies. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3406 | */ |
| 3407 | PJ_DECL(unsigned) pjsua_get_buddy_count(void); |
| 3408 | |
| 3409 | |
| 3410 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3411 | * Check if buddy ID is valid. |
| 3412 | * |
| 3413 | * @param buddy_id Buddy ID to check. |
| 3414 | * |
| 3415 | * @return Non-zero if buddy ID is valid. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3416 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3417 | PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id); |
| 3418 | |
| 3419 | |
| 3420 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3421 | * Enumerate all buddy IDs in the buddy list. Application then can use |
| 3422 | * #pjsua_buddy_get_info() to get the detail information for each buddy |
| 3423 | * id. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3424 | * |
| 3425 | * @param ids Array of ids to be initialized. |
| 3426 | * @param count On input, specifies max elements in the array. |
| 3427 | * On return, it contains actual number of elements |
| 3428 | * that have been initialized. |
| 3429 | * |
| 3430 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3431 | */ |
| 3432 | PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[], |
| 3433 | unsigned *count); |
| 3434 | |
| 3435 | /** |
Benny Prijono | 705e784 | 2008-07-21 18:12:51 +0000 | [diff] [blame] | 3436 | * Find the buddy ID with the specified URI. |
| 3437 | * |
| 3438 | * @param uri The buddy URI. |
| 3439 | * |
| 3440 | * @return The buddy ID, or PJSUA_INVALID_ID if not found. |
| 3441 | */ |
| 3442 | PJ_DECL(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri); |
| 3443 | |
| 3444 | |
| 3445 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3446 | * Get detailed buddy info. |
| 3447 | * |
| 3448 | * @param buddy_id The buddy identification. |
| 3449 | * @param info Pointer to receive information about buddy. |
| 3450 | * |
| 3451 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3452 | */ |
| 3453 | PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id, |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3454 | pjsua_buddy_info *info); |
| 3455 | |
| 3456 | /** |
Benny Prijono | 705e784 | 2008-07-21 18:12:51 +0000 | [diff] [blame] | 3457 | * Set the user data associated with the buddy object. |
| 3458 | * |
| 3459 | * @param buddy_id The buddy identification. |
| 3460 | * @param user_data Arbitrary application data to be associated with |
| 3461 | * the buddy object. |
| 3462 | * |
| 3463 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3464 | */ |
| 3465 | PJ_DECL(pj_status_t) pjsua_buddy_set_user_data(pjsua_buddy_id buddy_id, |
| 3466 | void *user_data); |
| 3467 | |
| 3468 | |
| 3469 | /** |
| 3470 | * Get the user data associated with the budy object. |
| 3471 | * |
| 3472 | * @param buddy_id The buddy identification. |
| 3473 | * |
| 3474 | * @return The application data. |
| 3475 | */ |
| 3476 | PJ_DECL(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id); |
| 3477 | |
| 3478 | |
| 3479 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3480 | * Add new buddy to the buddy list. If presence subscription is enabled |
| 3481 | * for this buddy, this function will also start the presence subscription |
| 3482 | * session immediately. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3483 | * |
Benny Prijono | a7b376b | 2008-01-25 16:06:33 +0000 | [diff] [blame] | 3484 | * @param buddy_cfg Buddy configuration. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3485 | * @param p_buddy_id Pointer to receive buddy ID. |
| 3486 | * |
| 3487 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3488 | */ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 3489 | PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg, |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3490 | pjsua_buddy_id *p_buddy_id); |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 3491 | |
| 3492 | |
| 3493 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3494 | * Delete the specified buddy from the buddy list. Any presence subscription |
| 3495 | * to this buddy will be terminated. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3496 | * |
| 3497 | * @param buddy_id Buddy identification. |
| 3498 | * |
| 3499 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 3500 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3501 | PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3502 | |
| 3503 | |
| 3504 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3505 | * Enable/disable buddy's presence monitoring. Once buddy's presence is |
| 3506 | * subscribed, application will be informed about buddy's presence status |
| 3507 | * changed via \a on_buddy_state() callback. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3508 | * |
| 3509 | * @param buddy_id Buddy identification. |
| 3510 | * @param subscribe Specify non-zero to activate presence subscription to |
| 3511 | * the specified buddy. |
| 3512 | * |
| 3513 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3514 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3515 | PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id, |
| 3516 | pj_bool_t subscribe); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3517 | |
| 3518 | |
| 3519 | /** |
Benny Prijono | 1086143 | 2007-10-31 10:54:53 +0000 | [diff] [blame] | 3520 | * Update the presence information for the buddy. Although the library |
| 3521 | * periodically refreshes the presence subscription for all buddies, some |
| 3522 | * application may want to refresh the buddy's presence subscription |
| 3523 | * immediately, and in this case it can use this function to accomplish |
| 3524 | * this. |
| 3525 | * |
| 3526 | * Note that the buddy's presence subscription will only be initiated |
| 3527 | * if presence monitoring is enabled for the buddy. See |
| 3528 | * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription |
| 3529 | * for the buddy is already active, this function will not do anything. |
| 3530 | * |
| 3531 | * Once the presence subscription is activated successfully for the buddy, |
| 3532 | * application will be notified about the buddy's presence status in the |
| 3533 | * on_buddy_state() callback. |
| 3534 | * |
| 3535 | * @param buddy_id Buddy identification. |
| 3536 | * |
| 3537 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 3538 | */ |
| 3539 | PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id); |
| 3540 | |
| 3541 | |
| 3542 | /** |
Benny Prijono | 63fba01 | 2008-07-17 14:19:10 +0000 | [diff] [blame] | 3543 | * Send NOTIFY to inform account presence status or to terminate server |
| 3544 | * side presence subscription. If application wants to reject the incoming |
| 3545 | * request, it should set the \a state to PJSIP_EVSUB_STATE_TERMINATED. |
| 3546 | * |
| 3547 | * @param acc_id Account ID. |
| 3548 | * @param srv_pres Server presence subscription instance. |
| 3549 | * @param state New state to set. |
| 3550 | * @param state_str Optionally specify the state string name, if state |
| 3551 | * is not "active", "pending", or "terminated". |
| 3552 | * @param reason If the new state is PJSIP_EVSUB_STATE_TERMINATED, |
| 3553 | * optionally specify the termination reason. |
| 3554 | * @param with_body If the new state is PJSIP_EVSUB_STATE_TERMINATED, |
| 3555 | * this specifies whether the NOTIFY request should |
| 3556 | * contain message body containing account's presence |
| 3557 | * information. |
| 3558 | * @param msg_data Optional list of headers to be sent with the NOTIFY |
| 3559 | * request. |
| 3560 | * |
| 3561 | * @return PJ_SUCCESS on success. |
| 3562 | */ |
| 3563 | PJ_DECL(pj_status_t) pjsua_pres_notify(pjsua_acc_id acc_id, |
| 3564 | pjsua_srv_pres *srv_pres, |
| 3565 | pjsip_evsub_state state, |
| 3566 | const pj_str_t *state_str, |
| 3567 | const pj_str_t *reason, |
| 3568 | pj_bool_t with_body, |
| 3569 | const pjsua_msg_data *msg_data); |
| 3570 | |
| 3571 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3572 | * Dump presence subscriptions to log. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3573 | * |
| 3574 | * @param verbose Yes or no. |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 3575 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3576 | PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose); |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 3577 | |
| 3578 | |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 3579 | /** |
| 3580 | * The MESSAGE method (defined in pjsua_im.c) |
| 3581 | */ |
| 3582 | extern const pjsip_method pjsip_message_method; |
| 3583 | |
| 3584 | |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 3585 | |
| 3586 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3587 | * Send instant messaging outside dialog, using the specified account for |
| 3588 | * route set and authentication. |
| 3589 | * |
| 3590 | * @param acc_id Account ID to be used to send the request. |
| 3591 | * @param to Remote URI. |
| 3592 | * @param mime_type Optional MIME type. If NULL, then "text/plain" is |
| 3593 | * assumed. |
| 3594 | * @param content The message content. |
| 3595 | * @param msg_data Optional list of headers etc to be included in outgoing |
| 3596 | * request. The body descriptor in the msg_data is |
| 3597 | * ignored. |
| 3598 | * @param user_data Optional user data, which will be given back when |
| 3599 | * the IM callback is called. |
| 3600 | * |
| 3601 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 3602 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3603 | PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id, |
| 3604 | const pj_str_t *to, |
| 3605 | const pj_str_t *mime_type, |
| 3606 | const pj_str_t *content, |
| 3607 | const pjsua_msg_data *msg_data, |
| 3608 | void *user_data); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 3609 | |
| 3610 | |
| 3611 | /** |
| 3612 | * Send typing indication outside dialog. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3613 | * |
| 3614 | * @param acc_id Account ID to be used to send the request. |
| 3615 | * @param to Remote URI. |
| 3616 | * @param is_typing If non-zero, it tells remote person that local person |
| 3617 | * is currently composing an IM. |
| 3618 | * @param msg_data Optional list of headers etc to be added to outgoing |
| 3619 | * request. |
| 3620 | * |
| 3621 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 3622 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 3623 | PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id, |
| 3624 | const pj_str_t *to, |
| 3625 | pj_bool_t is_typing, |
| 3626 | const pjsua_msg_data *msg_data); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 3627 | |
| 3628 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 3629 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3630 | /** |
| 3631 | * @} |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 3632 | */ |
| 3633 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3634 | |
| 3635 | /***************************************************************************** |
| 3636 | * MEDIA API |
| 3637 | */ |
| 3638 | |
| 3639 | |
| 3640 | /** |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 3641 | * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3642 | * @ingroup PJSUA_LIB |
| 3643 | * @brief Media manipulation. |
| 3644 | * @{ |
| 3645 | * |
| 3646 | * PJSUA has rather powerful media features, which are built around the |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 3647 | * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV |
| 3648 | * players, WAV playlist, file recorders, sound device, tone generators, etc) |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3649 | * are terminated in the conference bridge, and application can manipulate |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 3650 | * the interconnection between these terminations freely. |
| 3651 | * |
| 3652 | * The conference bridge provides powerful switching and mixing functionality |
| 3653 | * for application. With the conference bridge, each conference slot (e.g. |
| 3654 | * a call) can transmit to multiple destinations, and one destination can |
| 3655 | * receive from multiple sources. If more than one media terminations are |
| 3656 | * terminated in the same slot, the conference bridge will mix the signal |
| 3657 | * automatically. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3658 | * |
| 3659 | * Application connects one media termination/slot to another by calling |
| 3660 | * #pjsua_conf_connect() function. This will establish <b>unidirectional</b> |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 3661 | * media flow from the source termination to the sink termination. To |
| 3662 | * establish bidirectional media flow, application wound need to make another |
| 3663 | * call to #pjsua_conf_connect(), this time inverting the source and |
| 3664 | * destination slots in the parameter. |
| 3665 | * |
| 3666 | * For example, to stream a WAV file to remote call, application may use |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3667 | * the following steps: |
| 3668 | * |
| 3669 | \code |
| 3670 | |
| 3671 | pj_status_t stream_to_call( pjsua_call_id call_id ) |
| 3672 | { |
| 3673 | pjsua_player_id player_id; |
| 3674 | |
| 3675 | status = pjsua_player_create("mysong.wav", 0, NULL, &player_id); |
| 3676 | if (status != PJ_SUCCESS) |
| 3677 | return status; |
| 3678 | |
| 3679 | status = pjsua_conf_connect( pjsua_player_get_conf_port(), |
| 3680 | pjsua_call_get_conf_port() ); |
| 3681 | } |
| 3682 | \endcode |
| 3683 | * |
| 3684 | * |
| 3685 | * Other features of PJSUA media: |
| 3686 | * - efficient N to M interconnections between media terminations. |
| 3687 | * - media termination can be connected to itself to create loopback |
| 3688 | * media. |
| 3689 | * - the media termination may have different clock rates, and resampling |
| 3690 | * will be done automatically by conference bridge. |
| 3691 | * - media terminations may also have different frame time; the |
| 3692 | * conference bridge will perform the necessary bufferring to adjust |
| 3693 | * the difference between terminations. |
| 3694 | * - interconnections are removed automatically when media termination |
| 3695 | * is removed from the bridge. |
| 3696 | * - sound device may be changed even when there are active media |
| 3697 | * interconnections. |
| 3698 | * - correctly report call's media quality (in #pjsua_call_dump()) from |
| 3699 | * RTCP packet exchange. |
| 3700 | */ |
| 3701 | |
| 3702 | /** |
Benny Prijono | 37c710b | 2008-01-10 12:09:26 +0000 | [diff] [blame] | 3703 | * Max ports in the conference bridge. This setting is the default value |
| 3704 | * for pjsua_media_config.max_media_ports. |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3705 | */ |
| 3706 | #ifndef PJSUA_MAX_CONF_PORTS |
Benny Prijono | 12a669c | 2006-11-23 07:32:13 +0000 | [diff] [blame] | 3707 | # define PJSUA_MAX_CONF_PORTS 254 |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3708 | #endif |
| 3709 | |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3710 | /** |
Benny Prijono | 37c710b | 2008-01-10 12:09:26 +0000 | [diff] [blame] | 3711 | * The default clock rate to be used by the conference bridge. This setting |
| 3712 | * is the default value for pjsua_media_config.clock_rate. |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3713 | */ |
Benny Prijono | 12a669c | 2006-11-23 07:32:13 +0000 | [diff] [blame] | 3714 | #ifndef PJSUA_DEFAULT_CLOCK_RATE |
| 3715 | # define PJSUA_DEFAULT_CLOCK_RATE 16000 |
| 3716 | #endif |
| 3717 | |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3718 | /** |
Benny Prijono | 37c710b | 2008-01-10 12:09:26 +0000 | [diff] [blame] | 3719 | * Default frame length in the conference bridge. This setting |
| 3720 | * is the default value for pjsua_media_config.audio_frame_ptime. |
| 3721 | */ |
| 3722 | #ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME |
Nanang Izzuddin | af97484 | 2008-05-08 09:51:16 +0000 | [diff] [blame] | 3723 | # define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20 |
Benny Prijono | 37c710b | 2008-01-10 12:09:26 +0000 | [diff] [blame] | 3724 | #endif |
| 3725 | |
| 3726 | |
| 3727 | /** |
| 3728 | * Default codec quality settings. This setting is the default value |
| 3729 | * for pjsua_media_config.quality. |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3730 | */ |
Benny Prijono | 12a669c | 2006-11-23 07:32:13 +0000 | [diff] [blame] | 3731 | #ifndef PJSUA_DEFAULT_CODEC_QUALITY |
Nanang Izzuddin | 9dbad15 | 2008-06-10 18:56:10 +0000 | [diff] [blame] | 3732 | # define PJSUA_DEFAULT_CODEC_QUALITY 8 |
Benny Prijono | 12a669c | 2006-11-23 07:32:13 +0000 | [diff] [blame] | 3733 | #endif |
| 3734 | |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3735 | /** |
Benny Prijono | 37c710b | 2008-01-10 12:09:26 +0000 | [diff] [blame] | 3736 | * Default iLBC mode. This setting is the default value for |
| 3737 | * pjsua_media_config.ilbc_mode. |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3738 | */ |
Benny Prijono | 12a669c | 2006-11-23 07:32:13 +0000 | [diff] [blame] | 3739 | #ifndef PJSUA_DEFAULT_ILBC_MODE |
Benny Prijono | 37c710b | 2008-01-10 12:09:26 +0000 | [diff] [blame] | 3740 | # define PJSUA_DEFAULT_ILBC_MODE 30 |
Benny Prijono | 12a669c | 2006-11-23 07:32:13 +0000 | [diff] [blame] | 3741 | #endif |
| 3742 | |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3743 | /** |
Benny Prijono | 37c710b | 2008-01-10 12:09:26 +0000 | [diff] [blame] | 3744 | * The default echo canceller tail length. This setting |
| 3745 | * is the default value for pjsua_media_config.ec_tail_len. |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3746 | */ |
Benny Prijono | 12a669c | 2006-11-23 07:32:13 +0000 | [diff] [blame] | 3747 | #ifndef PJSUA_DEFAULT_EC_TAIL_LEN |
Benny Prijono | 427439c | 2007-10-21 09:41:24 +0000 | [diff] [blame] | 3748 | # define PJSUA_DEFAULT_EC_TAIL_LEN 200 |
Benny Prijono | 12a669c | 2006-11-23 07:32:13 +0000 | [diff] [blame] | 3749 | #endif |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3750 | |
| 3751 | |
| 3752 | /** |
Benny Prijono | cba59d9 | 2007-02-16 09:22:56 +0000 | [diff] [blame] | 3753 | * The maximum file player. |
| 3754 | */ |
| 3755 | #ifndef PJSUA_MAX_PLAYERS |
| 3756 | # define PJSUA_MAX_PLAYERS 32 |
| 3757 | #endif |
| 3758 | |
| 3759 | |
| 3760 | /** |
| 3761 | * The maximum file player. |
| 3762 | */ |
| 3763 | #ifndef PJSUA_MAX_RECORDERS |
| 3764 | # define PJSUA_MAX_RECORDERS 32 |
| 3765 | #endif |
| 3766 | |
| 3767 | |
| 3768 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3769 | * This structure describes media configuration, which will be specified |
| 3770 | * when calling #pjsua_init(). Application MUST initialize this structure |
| 3771 | * by calling #pjsua_media_config_default(). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3772 | */ |
| 3773 | struct pjsua_media_config |
| 3774 | { |
| 3775 | /** |
| 3776 | * Clock rate to be applied to the conference bridge. |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 3777 | * If value is zero, default clock rate will be used |
| 3778 | * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3779 | */ |
| 3780 | unsigned clock_rate; |
| 3781 | |
| 3782 | /** |
Benny Prijono | f3758ee | 2008-02-26 15:32:16 +0000 | [diff] [blame] | 3783 | * Clock rate to be applied when opening the sound device. |
| 3784 | * If value is zero, conference bridge clock rate will be used. |
| 3785 | */ |
| 3786 | unsigned snd_clock_rate; |
| 3787 | |
| 3788 | /** |
Benny Prijono | 7d60d05 | 2008-03-29 12:24:20 +0000 | [diff] [blame] | 3789 | * Channel count be applied when opening the sound device and |
| 3790 | * conference bridge. |
| 3791 | */ |
| 3792 | unsigned channel_count; |
| 3793 | |
| 3794 | /** |
Benny Prijono | cf0b4b2 | 2007-10-06 17:31:09 +0000 | [diff] [blame] | 3795 | * Specify audio frame ptime. The value here will affect the |
| 3796 | * samples per frame of both the sound device and the conference |
| 3797 | * bridge. Specifying lower ptime will normally reduce the |
| 3798 | * latency. |
| 3799 | * |
Benny Prijono | 37c710b | 2008-01-10 12:09:26 +0000 | [diff] [blame] | 3800 | * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME |
Benny Prijono | cf0b4b2 | 2007-10-06 17:31:09 +0000 | [diff] [blame] | 3801 | */ |
| 3802 | unsigned audio_frame_ptime; |
| 3803 | |
| 3804 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3805 | * Specify maximum number of media ports to be created in the |
| 3806 | * conference bridge. Since all media terminate in the bridge |
| 3807 | * (calls, file player, file recorder, etc), the value must be |
| 3808 | * large enough to support all of them. However, the larger |
| 3809 | * the value, the more computations are performed. |
Benny Prijono | 37c710b | 2008-01-10 12:09:26 +0000 | [diff] [blame] | 3810 | * |
| 3811 | * Default value: PJSUA_MAX_CONF_PORTS |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3812 | */ |
| 3813 | unsigned max_media_ports; |
| 3814 | |
| 3815 | /** |
| 3816 | * Specify whether the media manager should manage its own |
| 3817 | * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created |
| 3818 | * and at least one worker thread will be created too. If no, |
| 3819 | * the RTP/RTCP sockets will share the same ioqueue as SIP sockets, |
| 3820 | * and no worker thread is needed. |
| 3821 | * |
| 3822 | * Normally application would say yes here, unless it wants to |
| 3823 | * run everything from a single thread. |
| 3824 | */ |
| 3825 | pj_bool_t has_ioqueue; |
| 3826 | |
| 3827 | /** |
| 3828 | * Specify the number of worker threads to handle incoming RTP |
| 3829 | * packets. A value of one is recommended for most applications. |
| 3830 | */ |
| 3831 | unsigned thread_cnt; |
| 3832 | |
Benny Prijono | 0498d90 | 2006-06-19 14:49:14 +0000 | [diff] [blame] | 3833 | /** |
| 3834 | * Media quality, 0-10, according to this table: |
Benny Prijono | 7ca96da | 2006-08-07 12:11:40 +0000 | [diff] [blame] | 3835 | * 5-10: resampling use large filter, |
| 3836 | * 3-4: resampling use small filter, |
Benny Prijono | 0498d90 | 2006-06-19 14:49:14 +0000 | [diff] [blame] | 3837 | * 1-2: resampling use linear. |
| 3838 | * The media quality also sets speex codec quality/complexity to the |
| 3839 | * number. |
| 3840 | * |
Benny Prijono | 7097299 | 2006-08-05 11:13:58 +0000 | [diff] [blame] | 3841 | * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY). |
Benny Prijono | 0498d90 | 2006-06-19 14:49:14 +0000 | [diff] [blame] | 3842 | */ |
| 3843 | unsigned quality; |
Benny Prijono | 0a12f00 | 2006-07-26 17:05:39 +0000 | [diff] [blame] | 3844 | |
| 3845 | /** |
Benny Prijono | cf0b4b2 | 2007-10-06 17:31:09 +0000 | [diff] [blame] | 3846 | * Specify default codec ptime. |
Benny Prijono | 0a12f00 | 2006-07-26 17:05:39 +0000 | [diff] [blame] | 3847 | * |
| 3848 | * Default: 0 (codec specific) |
| 3849 | */ |
| 3850 | unsigned ptime; |
| 3851 | |
| 3852 | /** |
| 3853 | * Disable VAD? |
| 3854 | * |
| 3855 | * Default: 0 (no (meaning VAD is enabled)) |
| 3856 | */ |
| 3857 | pj_bool_t no_vad; |
Benny Prijono | 00cae61 | 2006-07-31 15:19:36 +0000 | [diff] [blame] | 3858 | |
| 3859 | /** |
| 3860 | * iLBC mode (20 or 30). |
| 3861 | * |
Benny Prijono | 37c710b | 2008-01-10 12:09:26 +0000 | [diff] [blame] | 3862 | * Default: 30 (PJSUA_DEFAULT_ILBC_MODE) |
Benny Prijono | 00cae61 | 2006-07-31 15:19:36 +0000 | [diff] [blame] | 3863 | */ |
| 3864 | unsigned ilbc_mode; |
| 3865 | |
| 3866 | /** |
| 3867 | * Percentage of RTP packet to drop in TX direction |
| 3868 | * (to simulate packet lost). |
| 3869 | * |
| 3870 | * Default: 0 |
| 3871 | */ |
| 3872 | unsigned tx_drop_pct; |
| 3873 | |
| 3874 | /** |
| 3875 | * Percentage of RTP packet to drop in RX direction |
| 3876 | * (to simulate packet lost). |
| 3877 | * |
| 3878 | * Default: 0 |
| 3879 | */ |
| 3880 | unsigned rx_drop_pct; |
| 3881 | |
Benny Prijono | c8e24a1 | 2006-08-02 18:22:22 +0000 | [diff] [blame] | 3882 | /** |
Benny Prijono | 5da5043 | 2006-08-07 10:24:52 +0000 | [diff] [blame] | 3883 | * Echo canceller options (see #pjmedia_echo_create()) |
| 3884 | * |
| 3885 | * Default: 0. |
| 3886 | */ |
| 3887 | unsigned ec_options; |
| 3888 | |
| 3889 | /** |
Benny Prijono | c8e24a1 | 2006-08-02 18:22:22 +0000 | [diff] [blame] | 3890 | * Echo canceller tail length, in miliseconds. |
| 3891 | * |
Benny Prijono | 669643c | 2006-09-20 20:02:18 +0000 | [diff] [blame] | 3892 | * Default: PJSUA_DEFAULT_EC_TAIL_LEN |
Benny Prijono | c8e24a1 | 2006-08-02 18:22:22 +0000 | [diff] [blame] | 3893 | */ |
| 3894 | unsigned ec_tail_len; |
Benny Prijono | 1d0ca0c | 2006-11-21 09:06:47 +0000 | [diff] [blame] | 3895 | |
Benny Prijono | 10454dc | 2009-02-21 14:21:59 +0000 | [diff] [blame] | 3896 | /** |
| 3897 | * Audio capture buffer length, in milliseconds. |
| 3898 | * |
| 3899 | * Default: PJMEDIA_SND_DEFAULT_REC_LATENCY |
| 3900 | */ |
| 3901 | unsigned snd_rec_latency; |
| 3902 | |
| 3903 | /** |
| 3904 | * Audio playback buffer length, in milliseconds. |
| 3905 | * |
| 3906 | * Default: PJMEDIA_SND_DEFAULT_PLAY_LATENCY |
| 3907 | */ |
| 3908 | unsigned snd_play_latency; |
| 3909 | |
Benny Prijono | 1d0ca0c | 2006-11-21 09:06:47 +0000 | [diff] [blame] | 3910 | /** |
| 3911 | * Jitter buffer initial prefetch delay in msec. The value must be |
| 3912 | * between jb_min_pre and jb_max_pre below. |
| 3913 | * |
| 3914 | * Default: -1 (to use default stream settings, currently 150 msec) |
| 3915 | */ |
| 3916 | int jb_init; |
| 3917 | |
| 3918 | /** |
| 3919 | * Jitter buffer minimum prefetch delay in msec. |
| 3920 | * |
| 3921 | * Default: -1 (to use default stream settings, currently 60 msec) |
| 3922 | */ |
| 3923 | int jb_min_pre; |
| 3924 | |
| 3925 | /** |
| 3926 | * Jitter buffer maximum prefetch delay in msec. |
| 3927 | * |
| 3928 | * Default: -1 (to use default stream settings, currently 240 msec) |
| 3929 | */ |
| 3930 | int jb_max_pre; |
| 3931 | |
| 3932 | /** |
| 3933 | * Set maximum delay that can be accomodated by the jitter buffer msec. |
| 3934 | * |
| 3935 | * Default: -1 (to use default stream settings, currently 360 msec) |
| 3936 | */ |
| 3937 | int jb_max; |
| 3938 | |
Benny Prijono | c97608e | 2007-03-23 16:34:20 +0000 | [diff] [blame] | 3939 | /** |
| 3940 | * Enable ICE |
| 3941 | */ |
| 3942 | pj_bool_t enable_ice; |
| 3943 | |
| 3944 | /** |
Benny Prijono | 329d638 | 2009-05-29 13:04:03 +0000 | [diff] [blame] | 3945 | * Set the maximum number of host candidates. |
| 3946 | * |
| 3947 | * Default: -1 (maximum not set) |
Benny Prijono | c97608e | 2007-03-23 16:34:20 +0000 | [diff] [blame] | 3948 | */ |
Benny Prijono | 329d638 | 2009-05-29 13:04:03 +0000 | [diff] [blame] | 3949 | int ice_max_host_cands; |
| 3950 | |
| 3951 | /** |
| 3952 | * ICE session options. |
| 3953 | */ |
| 3954 | pj_ice_sess_options ice_opt; |
Benny Prijono | f76e139 | 2008-06-06 14:51:48 +0000 | [diff] [blame] | 3955 | |
| 3956 | /** |
Benny Prijono | 551af42 | 2008-08-07 09:55:52 +0000 | [diff] [blame] | 3957 | * Disable RTCP component. |
| 3958 | * |
| 3959 | * Default: no |
| 3960 | */ |
| 3961 | pj_bool_t ice_no_rtcp; |
| 3962 | |
| 3963 | /** |
Benny Prijono | f76e139 | 2008-06-06 14:51:48 +0000 | [diff] [blame] | 3964 | * Enable TURN relay candidate in ICE. |
| 3965 | */ |
| 3966 | pj_bool_t enable_turn; |
| 3967 | |
| 3968 | /** |
| 3969 | * Specify TURN domain name or host name, in in "DOMAIN:PORT" or |
| 3970 | * "HOST:PORT" format. |
| 3971 | */ |
| 3972 | pj_str_t turn_server; |
| 3973 | |
| 3974 | /** |
| 3975 | * Specify the connection type to be used to the TURN server. Valid |
| 3976 | * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP. |
| 3977 | * |
| 3978 | * Default: PJ_TURN_TP_UDP |
| 3979 | */ |
| 3980 | pj_turn_tp_type turn_conn_type; |
| 3981 | |
| 3982 | /** |
| 3983 | * Specify the credential to authenticate with the TURN server. |
| 3984 | */ |
| 3985 | pj_stun_auth_cred turn_auth_cred; |
Nanang Izzuddin | 68559c3 | 2008-06-13 17:01:46 +0000 | [diff] [blame] | 3986 | |
| 3987 | /** |
| 3988 | * Specify idle time of sound device before it is automatically closed, |
Benny Prijono | f798e50 | 2009-03-09 13:08:16 +0000 | [diff] [blame] | 3989 | * in seconds. Use value -1 to disable the auto-close feature of sound |
| 3990 | * device |
Nanang Izzuddin | 68559c3 | 2008-06-13 17:01:46 +0000 | [diff] [blame] | 3991 | * |
Benny Prijono | f798e50 | 2009-03-09 13:08:16 +0000 | [diff] [blame] | 3992 | * Default : 1 |
Nanang Izzuddin | 68559c3 | 2008-06-13 17:01:46 +0000 | [diff] [blame] | 3993 | */ |
| 3994 | int snd_auto_close_time; |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 3995 | }; |
| 3996 | |
| 3997 | |
| 3998 | /** |
| 3999 | * Use this function to initialize media config. |
| 4000 | * |
| 4001 | * @param cfg The media config to be initialized. |
| 4002 | */ |
Benny Prijono | 1f61a8f | 2007-08-16 10:11:44 +0000 | [diff] [blame] | 4003 | PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg); |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4004 | |
| 4005 | |
| 4006 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 4007 | * This structure describes codec information, which can be retrieved by |
| 4008 | * calling #pjsua_enum_codecs(). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4009 | */ |
| 4010 | typedef struct pjsua_codec_info |
| 4011 | { |
| 4012 | /** |
| 4013 | * Codec unique identification. |
| 4014 | */ |
| 4015 | pj_str_t codec_id; |
| 4016 | |
| 4017 | /** |
| 4018 | * Codec priority (integer 0-255). |
| 4019 | */ |
| 4020 | pj_uint8_t priority; |
| 4021 | |
| 4022 | /** |
| 4023 | * Internal buffer. |
| 4024 | */ |
| 4025 | char buf_[32]; |
| 4026 | |
| 4027 | } pjsua_codec_info; |
| 4028 | |
| 4029 | |
| 4030 | /** |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 4031 | * This structure descibes information about a particular media port that |
| 4032 | * has been registered into the conference bridge. Application can query |
| 4033 | * this info by calling #pjsua_conf_get_port_info(). |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4034 | */ |
| 4035 | typedef struct pjsua_conf_port_info |
| 4036 | { |
| 4037 | /** Conference port number. */ |
| 4038 | pjsua_conf_port_id slot_id; |
| 4039 | |
| 4040 | /** Port name. */ |
| 4041 | pj_str_t name; |
| 4042 | |
| 4043 | /** Clock rate. */ |
| 4044 | unsigned clock_rate; |
| 4045 | |
| 4046 | /** Number of channels. */ |
| 4047 | unsigned channel_count; |
| 4048 | |
| 4049 | /** Samples per frame */ |
| 4050 | unsigned samples_per_frame; |
| 4051 | |
| 4052 | /** Bits per sample */ |
| 4053 | unsigned bits_per_sample; |
| 4054 | |
| 4055 | /** Number of listeners in the array. */ |
| 4056 | unsigned listener_cnt; |
| 4057 | |
| 4058 | /** Array of listeners (in other words, ports where this port is |
| 4059 | * transmitting to. |
| 4060 | */ |
| 4061 | pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS]; |
| 4062 | |
| 4063 | } pjsua_conf_port_info; |
| 4064 | |
| 4065 | |
| 4066 | /** |
| 4067 | * This structure holds information about custom media transport to |
| 4068 | * be registered to pjsua. |
| 4069 | */ |
| 4070 | typedef struct pjsua_media_transport |
| 4071 | { |
| 4072 | /** |
| 4073 | * Media socket information containing the address information |
| 4074 | * of the RTP and RTCP socket. |
| 4075 | */ |
| 4076 | pjmedia_sock_info skinfo; |
| 4077 | |
| 4078 | /** |
| 4079 | * The media transport instance. |
| 4080 | */ |
| 4081 | pjmedia_transport *transport; |
| 4082 | |
| 4083 | } pjsua_media_transport; |
| 4084 | |
| 4085 | |
| 4086 | |
| 4087 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4088 | /** |
| 4089 | * Get maxinum number of conference ports. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4090 | * |
| 4091 | * @return Maximum number of ports in the conference bridge. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4092 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4093 | PJ_DECL(unsigned) pjsua_conf_get_max_ports(void); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4094 | |
| 4095 | |
| 4096 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4097 | * Get current number of active ports in the bridge. |
| 4098 | * |
| 4099 | * @return The number. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4100 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4101 | PJ_DECL(unsigned) pjsua_conf_get_active_ports(void); |
| 4102 | |
| 4103 | |
| 4104 | /** |
| 4105 | * Enumerate all conference ports. |
| 4106 | * |
| 4107 | * @param id Array of conference port ID to be initialized. |
| 4108 | * @param count On input, specifies max elements in the array. |
| 4109 | * On return, it contains actual number of elements |
| 4110 | * that have been initialized. |
| 4111 | * |
| 4112 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4113 | */ |
| 4114 | PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[], |
| 4115 | unsigned *count); |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 4116 | |
| 4117 | |
| 4118 | /** |
| 4119 | * Get information about the specified conference port |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4120 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4121 | * @param port_id Port identification. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4122 | * @param info Pointer to store the port info. |
| 4123 | * |
| 4124 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 4125 | */ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4126 | PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id, |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 4127 | pjsua_conf_port_info *info); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4128 | |
| 4129 | |
| 4130 | /** |
Benny Prijono | e909eac | 2006-07-27 22:04:56 +0000 | [diff] [blame] | 4131 | * Add arbitrary media port to PJSUA's conference bridge. Application |
| 4132 | * can use this function to add the media port that it creates. For |
| 4133 | * media ports that are created by PJSUA-LIB (such as calls, file player, |
| 4134 | * or file recorder), PJSUA-LIB will automatically add the port to |
| 4135 | * the bridge. |
| 4136 | * |
| 4137 | * @param pool Pool to use. |
| 4138 | * @param port Media port to be added to the bridge. |
| 4139 | * @param p_id Optional pointer to receive the conference |
| 4140 | * slot id. |
| 4141 | * |
| 4142 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4143 | */ |
| 4144 | PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool, |
| 4145 | pjmedia_port *port, |
| 4146 | pjsua_conf_port_id *p_id); |
| 4147 | |
| 4148 | |
| 4149 | /** |
| 4150 | * Remove arbitrary slot from the conference bridge. Application should only |
Benny Prijono | b5388cf | 2007-01-04 22:45:08 +0000 | [diff] [blame] | 4151 | * call this function if it registered the port manually with previous call |
| 4152 | * to #pjsua_conf_add_port(). |
Benny Prijono | e909eac | 2006-07-27 22:04:56 +0000 | [diff] [blame] | 4153 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4154 | * @param port_id The slot id of the port to be removed. |
Benny Prijono | e909eac | 2006-07-27 22:04:56 +0000 | [diff] [blame] | 4155 | * |
| 4156 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4157 | */ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4158 | PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id); |
Benny Prijono | e909eac | 2006-07-27 22:04:56 +0000 | [diff] [blame] | 4159 | |
| 4160 | |
| 4161 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4162 | * Establish unidirectional media flow from souce to sink. One source |
| 4163 | * may transmit to multiple destinations/sink. And if multiple |
| 4164 | * sources are transmitting to the same sink, the media will be mixed |
| 4165 | * together. Source and sink may refer to the same ID, effectively |
| 4166 | * looping the media. |
| 4167 | * |
| 4168 | * If bidirectional media flow is desired, application needs to call |
| 4169 | * this function twice, with the second one having the arguments |
| 4170 | * reversed. |
| 4171 | * |
| 4172 | * @param source Port ID of the source media/transmitter. |
| 4173 | * @param sink Port ID of the destination media/received. |
| 4174 | * |
| 4175 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4176 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4177 | PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source, |
| 4178 | pjsua_conf_port_id sink); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4179 | |
| 4180 | |
| 4181 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4182 | * Disconnect media flow from the source to destination port. |
| 4183 | * |
| 4184 | * @param source Port ID of the source media/transmitter. |
| 4185 | * @param sink Port ID of the destination media/received. |
| 4186 | * |
| 4187 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4188 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4189 | PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source, |
| 4190 | pjsua_conf_port_id sink); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4191 | |
| 4192 | |
Benny Prijono | 6dd967c | 2006-12-26 02:27:14 +0000 | [diff] [blame] | 4193 | /** |
| 4194 | * Adjust the signal level to be transmitted from the bridge to the |
| 4195 | * specified port by making it louder or quieter. |
| 4196 | * |
| 4197 | * @param slot The conference bridge slot number. |
| 4198 | * @param level Signal level adjustment. Value 1.0 means no level |
| 4199 | * adjustment, while value 0 means to mute the port. |
| 4200 | * |
| 4201 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4202 | */ |
| 4203 | PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot, |
| 4204 | float level); |
| 4205 | |
| 4206 | /** |
| 4207 | * Adjust the signal level to be received from the specified port (to |
| 4208 | * the bridge) by making it louder or quieter. |
| 4209 | * |
| 4210 | * @param slot The conference bridge slot number. |
| 4211 | * @param level Signal level adjustment. Value 1.0 means no level |
| 4212 | * adjustment, while value 0 means to mute the port. |
| 4213 | * |
| 4214 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4215 | */ |
| 4216 | PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot, |
| 4217 | float level); |
| 4218 | |
| 4219 | /** |
| 4220 | * Get last signal level transmitted to or received from the specified port. |
| 4221 | * The signal level is an integer value in zero to 255, with zero indicates |
| 4222 | * no signal, and 255 indicates the loudest signal level. |
| 4223 | * |
| 4224 | * @param slot The conference bridge slot number. |
| 4225 | * @param tx_level Optional argument to receive the level of signal |
| 4226 | * transmitted to the specified port (i.e. the direction |
| 4227 | * is from the bridge to the port). |
| 4228 | * @param rx_level Optional argument to receive the level of signal |
| 4229 | * received from the port (i.e. the direction is from the |
| 4230 | * port to the bridge). |
| 4231 | * |
| 4232 | * @return PJ_SUCCESS on success. |
| 4233 | */ |
| 4234 | PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot, |
| 4235 | unsigned *tx_level, |
| 4236 | unsigned *rx_level); |
| 4237 | |
Benny Prijono | 6dd967c | 2006-12-26 02:27:14 +0000 | [diff] [blame] | 4238 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4239 | /***************************************************************************** |
Benny Prijono | a66c331 | 2007-01-21 23:12:40 +0000 | [diff] [blame] | 4240 | * File player and playlist. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4241 | */ |
| 4242 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4243 | /** |
Benny Prijono | a66c331 | 2007-01-21 23:12:40 +0000 | [diff] [blame] | 4244 | * Create a file player, and automatically add this player to |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4245 | * the conference bridge. |
| 4246 | * |
| 4247 | * @param filename The filename to be played. Currently only |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4248 | * WAV files are supported, and the WAV file MUST be |
| 4249 | * formatted as 16bit PCM mono/single channel (any |
| 4250 | * clock rate is supported). |
Benny Prijono | 58add7c | 2008-01-18 13:24:07 +0000 | [diff] [blame] | 4251 | * @param options Optional option flag. Application may specify |
| 4252 | * PJMEDIA_FILE_NO_LOOP to prevent playback loop. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4253 | * @param p_id Pointer to receive player ID. |
| 4254 | * |
| 4255 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4256 | */ |
| 4257 | PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename, |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4258 | unsigned options, |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4259 | pjsua_player_id *p_id); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4260 | |
| 4261 | |
| 4262 | /** |
Benny Prijono | a66c331 | 2007-01-21 23:12:40 +0000 | [diff] [blame] | 4263 | * Create a file playlist media port, and automatically add the port |
| 4264 | * to the conference bridge. |
| 4265 | * |
| 4266 | * @param file_names Array of file names to be added to the play list. |
| 4267 | * Note that the files must have the same clock rate, |
| 4268 | * number of channels, and number of bits per sample. |
| 4269 | * @param file_count Number of files in the array. |
| 4270 | * @param label Optional label to be set for the media port. |
| 4271 | * @param options Optional option flag. Application may specify |
| 4272 | * PJMEDIA_FILE_NO_LOOP to prevent looping. |
| 4273 | * @param p_id Optional pointer to receive player ID. |
| 4274 | * |
| 4275 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4276 | */ |
| 4277 | PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[], |
| 4278 | unsigned file_count, |
| 4279 | const pj_str_t *label, |
| 4280 | unsigned options, |
| 4281 | pjsua_player_id *p_id); |
| 4282 | |
| 4283 | /** |
| 4284 | * Get conference port ID associated with player or playlist. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4285 | * |
| 4286 | * @param id The file player ID. |
| 4287 | * |
| 4288 | * @return Conference port ID associated with this player. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4289 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 4290 | PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4291 | |
| 4292 | |
| 4293 | /** |
Benny Prijono | a66c331 | 2007-01-21 23:12:40 +0000 | [diff] [blame] | 4294 | * Get the media port for the player or playlist. |
Benny Prijono | 469b152 | 2006-12-26 03:05:17 +0000 | [diff] [blame] | 4295 | * |
| 4296 | * @param id The player ID. |
| 4297 | * @param p_port The media port associated with the player. |
| 4298 | * |
| 4299 | * @return PJ_SUCCESS on success. |
| 4300 | */ |
Benny Prijono | 58add7c | 2008-01-18 13:24:07 +0000 | [diff] [blame] | 4301 | PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id, |
Benny Prijono | 469b152 | 2006-12-26 03:05:17 +0000 | [diff] [blame] | 4302 | pjmedia_port **p_port); |
| 4303 | |
| 4304 | /** |
Benny Prijono | a66c331 | 2007-01-21 23:12:40 +0000 | [diff] [blame] | 4305 | * Set playback position. This operation is not valid for playlist. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4306 | * |
| 4307 | * @param id The file player ID. |
| 4308 | * @param samples The playback position, in samples. Application can |
| 4309 | * specify zero to re-start the playback. |
| 4310 | * |
| 4311 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4312 | */ |
| 4313 | PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id, |
| 4314 | pj_uint32_t samples); |
| 4315 | |
| 4316 | |
| 4317 | /** |
Benny Prijono | a66c331 | 2007-01-21 23:12:40 +0000 | [diff] [blame] | 4318 | * Close the file of playlist, remove the player from the bridge, and free |
| 4319 | * resources associated with the file player or playlist. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4320 | * |
| 4321 | * @param id The file player ID. |
| 4322 | * |
| 4323 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4324 | */ |
| 4325 | PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id); |
| 4326 | |
| 4327 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4328 | /***************************************************************************** |
| 4329 | * File recorder. |
| 4330 | */ |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4331 | |
| 4332 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4333 | * Create a file recorder, and automatically connect this recorder to |
Benny Prijono | c95a0f0 | 2007-04-09 07:06:08 +0000 | [diff] [blame] | 4334 | * the conference bridge. The recorder currently supports recording WAV file. |
| 4335 | * The type of the recorder to use is determined by the extension of the file |
| 4336 | * (e.g. ".wav"). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4337 | * |
Benny Prijono | b3cdb2b | 2006-10-19 15:49:47 +0000 | [diff] [blame] | 4338 | * @param filename Output file name. The function will determine the |
| 4339 | * default format to be used based on the file extension. |
Benny Prijono | c95a0f0 | 2007-04-09 07:06:08 +0000 | [diff] [blame] | 4340 | * Currently ".wav" is supported on all platforms. |
Benny Prijono | 8f31052 | 2006-10-20 11:08:49 +0000 | [diff] [blame] | 4341 | * @param enc_type Optionally specify the type of encoder to be used to |
| 4342 | * compress the media, if the file can support different |
| 4343 | * encodings. This value must be zero for now. |
| 4344 | * @param enc_param Optionally specify codec specific parameter to be |
Benny Prijono | c95a0f0 | 2007-04-09 07:06:08 +0000 | [diff] [blame] | 4345 | * passed to the file writer. |
Benny Prijono | 8f31052 | 2006-10-20 11:08:49 +0000 | [diff] [blame] | 4346 | * For .WAV recorder, this value must be NULL. |
| 4347 | * @param max_size Maximum file size. Specify zero or -1 to remove size |
| 4348 | * limitation. This value must be zero or -1 for now. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4349 | * @param options Optional options. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4350 | * @param p_id Pointer to receive the recorder instance. |
| 4351 | * |
| 4352 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4353 | */ |
| 4354 | PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename, |
Benny Prijono | 8f31052 | 2006-10-20 11:08:49 +0000 | [diff] [blame] | 4355 | unsigned enc_type, |
| 4356 | void *enc_param, |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4357 | pj_ssize_t max_size, |
| 4358 | unsigned options, |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4359 | pjsua_recorder_id *p_id); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4360 | |
| 4361 | |
| 4362 | /** |
| 4363 | * Get conference port associated with recorder. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4364 | * |
| 4365 | * @param id The recorder ID. |
| 4366 | * |
| 4367 | * @return Conference port ID associated with this recorder. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4368 | */ |
Benny Prijono | 8b1889b | 2006-06-06 18:40:40 +0000 | [diff] [blame] | 4369 | PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id); |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4370 | |
| 4371 | |
| 4372 | /** |
Benny Prijono | 469b152 | 2006-12-26 03:05:17 +0000 | [diff] [blame] | 4373 | * Get the media port for the recorder. |
| 4374 | * |
| 4375 | * @param id The recorder ID. |
| 4376 | * @param p_port The media port associated with the recorder. |
| 4377 | * |
| 4378 | * @return PJ_SUCCESS on success. |
| 4379 | */ |
| 4380 | PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id, |
| 4381 | pjmedia_port **p_port); |
| 4382 | |
| 4383 | |
| 4384 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4385 | * Destroy recorder (this will complete recording). |
| 4386 | * |
| 4387 | * @param id The recorder ID. |
| 4388 | * |
| 4389 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4390 | */ |
| 4391 | PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id); |
| 4392 | |
| 4393 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4394 | /***************************************************************************** |
| 4395 | * Sound devices. |
| 4396 | */ |
| 4397 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4398 | /** |
Benny Prijono | f798e50 | 2009-03-09 13:08:16 +0000 | [diff] [blame] | 4399 | * Enum all audio devices installed in the system. |
| 4400 | * |
| 4401 | * @param info Array of info to be initialized. |
| 4402 | * @param count On input, specifies max elements in the array. |
| 4403 | * On return, it contains actual number of elements |
| 4404 | * that have been initialized. |
| 4405 | * |
| 4406 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4407 | */ |
| 4408 | PJ_DECL(pj_status_t) pjsua_enum_aud_devs(pjmedia_aud_dev_info info[], |
| 4409 | unsigned *count); |
| 4410 | |
| 4411 | /** |
| 4412 | * Enum all sound devices installed in the system (old API). |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4413 | * |
| 4414 | * @param info Array of info to be initialized. |
| 4415 | * @param count On input, specifies max elements in the array. |
| 4416 | * On return, it contains actual number of elements |
| 4417 | * that have been initialized. |
| 4418 | * |
| 4419 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4420 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4421 | PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[], |
| 4422 | unsigned *count); |
Benny Prijono | a3cbb1c | 2006-08-25 12:41:05 +0000 | [diff] [blame] | 4423 | |
| 4424 | /** |
| 4425 | * Get currently active sound devices. If sound devices has not been created |
| 4426 | * (for example when pjsua_start() is not called), it is possible that |
| 4427 | * the function returns PJ_SUCCESS with -1 as device IDs. |
| 4428 | * |
| 4429 | * @param capture_dev On return it will be filled with device ID of the |
| 4430 | * capture device. |
| 4431 | * @param playback_dev On return it will be filled with device ID of the |
| 4432 | * device ID of the playback device. |
| 4433 | * |
| 4434 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4435 | */ |
| 4436 | PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev, |
| 4437 | int *playback_dev); |
| 4438 | |
| 4439 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4440 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4441 | * Select or change sound device. Application may call this function at |
| 4442 | * any time to replace current sound device. |
| 4443 | * |
| 4444 | * @param capture_dev Device ID of the capture device. |
| 4445 | * @param playback_dev Device ID of the playback device. |
| 4446 | * |
| 4447 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4448 | */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4449 | PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev, |
| 4450 | int playback_dev); |
| 4451 | |
| 4452 | |
| 4453 | /** |
| 4454 | * Set pjsua to use null sound device. The null sound device only provides |
| 4455 | * the timing needed by the conference bridge, and will not interract with |
| 4456 | * any hardware. |
| 4457 | * |
| 4458 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4459 | */ |
| 4460 | PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void); |
| 4461 | |
| 4462 | |
Benny Prijono | e909eac | 2006-07-27 22:04:56 +0000 | [diff] [blame] | 4463 | /** |
| 4464 | * Disconnect the main conference bridge from any sound devices, and let |
| 4465 | * application connect the bridge to it's own sound device/master port. |
| 4466 | * |
| 4467 | * @return The port interface of the conference bridge, |
| 4468 | * so that application can connect this to it's own |
| 4469 | * sound device or master port. |
| 4470 | */ |
| 4471 | PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void); |
| 4472 | |
| 4473 | |
Benny Prijono | f20687a | 2006-08-04 18:27:19 +0000 | [diff] [blame] | 4474 | /** |
Benny Prijono | e506c8c | 2009-03-10 13:28:43 +0000 | [diff] [blame] | 4475 | * Change the echo cancellation settings. |
Benny Prijono | f798e50 | 2009-03-09 13:08:16 +0000 | [diff] [blame] | 4476 | * |
| 4477 | * The behavior of this function depends on whether the sound device is |
| 4478 | * currently active, and if it is, whether device or software AEC is |
| 4479 | * being used. |
Benny Prijono | 10454dc | 2009-02-21 14:21:59 +0000 | [diff] [blame] | 4480 | * |
| 4481 | * If the sound device is currently active, and if the device supports AEC, |
| 4482 | * this function will forward the change request to the device and it will |
| 4483 | * be up to the device on whether support the request. If software AEC is |
| 4484 | * being used (the software EC will be used if the device does not support |
| 4485 | * AEC), this function will change the software EC settings. In all cases, |
| 4486 | * the setting will be saved for future opening of the sound device. |
| 4487 | * |
| 4488 | * If the sound device is not currently active, this will only change the |
| 4489 | * default AEC settings and the setting will be applied next time the |
| 4490 | * sound device is opened. |
Benny Prijono | f20687a | 2006-08-04 18:27:19 +0000 | [diff] [blame] | 4491 | * |
| 4492 | * @param tail_ms The tail length, in miliseconds. Set to zero to |
| 4493 | * disable AEC. |
Benny Prijono | a7b376b | 2008-01-25 16:06:33 +0000 | [diff] [blame] | 4494 | * @param options Options to be passed to pjmedia_echo_create(). |
Benny Prijono | 5da5043 | 2006-08-07 10:24:52 +0000 | [diff] [blame] | 4495 | * Normally the value should be zero. |
Benny Prijono | f20687a | 2006-08-04 18:27:19 +0000 | [diff] [blame] | 4496 | * |
| 4497 | * @return PJ_SUCCESS on success. |
| 4498 | */ |
Benny Prijono | 5da5043 | 2006-08-07 10:24:52 +0000 | [diff] [blame] | 4499 | PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options); |
Benny Prijono | f20687a | 2006-08-04 18:27:19 +0000 | [diff] [blame] | 4500 | |
| 4501 | |
| 4502 | /** |
Benny Prijono | e506c8c | 2009-03-10 13:28:43 +0000 | [diff] [blame] | 4503 | * Get current echo canceller tail length. |
Benny Prijono | f20687a | 2006-08-04 18:27:19 +0000 | [diff] [blame] | 4504 | * |
| 4505 | * @param p_tail_ms Pointer to receive the tail length, in miliseconds. |
| 4506 | * If AEC is disabled, the value will be zero. |
| 4507 | * |
| 4508 | * @return PJ_SUCCESS on success. |
| 4509 | */ |
Benny Prijono | 22dfe59 | 2006-08-06 12:07:13 +0000 | [diff] [blame] | 4510 | PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms); |
Benny Prijono | f20687a | 2006-08-04 18:27:19 +0000 | [diff] [blame] | 4511 | |
| 4512 | |
Nanang Izzuddin | 0cb3b02 | 2009-02-27 17:37:35 +0000 | [diff] [blame] | 4513 | /** |
Benny Prijono | f798e50 | 2009-03-09 13:08:16 +0000 | [diff] [blame] | 4514 | * Check whether the sound device is currently active. The sound device |
| 4515 | * may be inactive if the application has set the auto close feature to |
| 4516 | * non-zero (the snd_auto_close_time setting in #pjsua_media_config), or |
| 4517 | * if null sound device or no sound device has been configured via the |
| 4518 | * #pjsua_set_no_snd_dev() function. |
Nanang Izzuddin | 0cb3b02 | 2009-02-27 17:37:35 +0000 | [diff] [blame] | 4519 | */ |
Benny Prijono | f798e50 | 2009-03-09 13:08:16 +0000 | [diff] [blame] | 4520 | PJ_DECL(pj_bool_t) pjsua_snd_is_active(void); |
| 4521 | |
| 4522 | |
| 4523 | /** |
| 4524 | * Configure sound device setting to the sound device being used. If sound |
| 4525 | * device is currently active, the function will forward the setting to the |
| 4526 | * sound device instance to be applied immediately, if it supports it. |
| 4527 | * |
| 4528 | * The setting will be saved for future opening of the sound device, if the |
| 4529 | * "keep" argument is set to non-zero. If the sound device is currently |
| 4530 | * inactive, and the "keep" argument is false, this function will return |
| 4531 | * error. |
| 4532 | * |
| 4533 | * Note that in case the setting is kept for future use, it will be applied |
| 4534 | * to any devices, even when application has changed the sound device to be |
| 4535 | * used. |
| 4536 | * |
Benny Prijono | e506c8c | 2009-03-10 13:28:43 +0000 | [diff] [blame] | 4537 | * Note also that the echo cancellation setting should be set with |
| 4538 | * #pjsua_set_ec() API instead. |
| 4539 | * |
Benny Prijono | f798e50 | 2009-03-09 13:08:16 +0000 | [diff] [blame] | 4540 | * See also #pjmedia_aud_stream_set_cap() for more information about setting |
| 4541 | * an audio device capability. |
| 4542 | * |
| 4543 | * @param cap The sound device setting to change. |
| 4544 | * @param pval Pointer to value. Please see #pjmedia_aud_dev_cap |
| 4545 | * documentation about the type of value to be |
| 4546 | * supplied for each setting. |
| 4547 | * @param keep Specify whether the setting is to be kept for future |
| 4548 | * use. |
| 4549 | * |
| 4550 | * @return PJ_SUCCESS on success or the appropriate error code. |
| 4551 | */ |
| 4552 | PJ_DECL(pj_status_t) pjsua_snd_set_setting(pjmedia_aud_dev_cap cap, |
| 4553 | const void *pval, |
| 4554 | pj_bool_t keep); |
| 4555 | |
| 4556 | /** |
| 4557 | * Retrieve a sound device setting. If sound device is currently active, |
| 4558 | * the function will forward the request to the sound device. If sound device |
| 4559 | * is currently inactive, and if application had previously set the setting |
| 4560 | * and mark the setting as kept, then that setting will be returned. |
| 4561 | * Otherwise, this function will return error. |
| 4562 | * |
Benny Prijono | e506c8c | 2009-03-10 13:28:43 +0000 | [diff] [blame] | 4563 | * Note that echo cancellation settings should be retrieved with |
| 4564 | * #pjsua_get_ec_tail() API instead. |
| 4565 | * |
Benny Prijono | f798e50 | 2009-03-09 13:08:16 +0000 | [diff] [blame] | 4566 | * @param cap The sound device setting to retrieve. |
| 4567 | * @param pval Pointer to receive the value. |
| 4568 | * Please see #pjmedia_aud_dev_cap documentation about |
| 4569 | * the type of value to be supplied for each setting. |
| 4570 | * |
| 4571 | * @return PJ_SUCCESS on success or the appropriate error code. |
| 4572 | */ |
| 4573 | PJ_DECL(pj_status_t) pjsua_snd_get_setting(pjmedia_aud_dev_cap cap, |
| 4574 | void *pval); |
Nanang Izzuddin | 0cb3b02 | 2009-02-27 17:37:35 +0000 | [diff] [blame] | 4575 | |
| 4576 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4577 | /***************************************************************************** |
| 4578 | * Codecs. |
| 4579 | */ |
| 4580 | |
| 4581 | /** |
| 4582 | * Enum all supported codecs in the system. |
| 4583 | * |
| 4584 | * @param id Array of ID to be initialized. |
| 4585 | * @param count On input, specifies max elements in the array. |
| 4586 | * On return, it contains actual number of elements |
| 4587 | * that have been initialized. |
| 4588 | * |
| 4589 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4590 | */ |
| 4591 | PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[], |
| 4592 | unsigned *count ); |
| 4593 | |
| 4594 | |
| 4595 | /** |
| 4596 | * Change codec priority. |
| 4597 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4598 | * @param codec_id Codec ID, which is a string that uniquely identify |
| 4599 | * the codec (such as "speex/8000"). Please see pjsua |
| 4600 | * manual or pjmedia codec reference for details. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4601 | * @param priority Codec priority, 0-255, where zero means to disable |
| 4602 | * the codec. |
| 4603 | * |
| 4604 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4605 | */ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4606 | PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id, |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4607 | pj_uint8_t priority ); |
| 4608 | |
| 4609 | |
| 4610 | /** |
| 4611 | * Get codec parameters. |
| 4612 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4613 | * @param codec_id Codec ID. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4614 | * @param param Structure to receive codec parameters. |
| 4615 | * |
| 4616 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4617 | */ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4618 | PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id, |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4619 | pjmedia_codec_param *param ); |
| 4620 | |
| 4621 | |
| 4622 | /** |
| 4623 | * Set codec parameters. |
| 4624 | * |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4625 | * @param codec_id Codec ID. |
Nanang Izzuddin | 06839e7 | 2010-01-27 11:48:31 +0000 | [diff] [blame] | 4626 | * @param param Codec parameter to set. Set to NULL to reset |
| 4627 | * codec parameter to library default settings. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4628 | * |
| 4629 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 4630 | */ |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4631 | PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id, |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4632 | const pjmedia_codec_param *param); |
| 4633 | |
| 4634 | |
| 4635 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame] | 4636 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4637 | /** |
| 4638 | * Create UDP media transports for all the calls. This function creates |
| 4639 | * one UDP media transport for each call. |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 4640 | * |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4641 | * @param cfg Media transport configuration. The "port" field in the |
| 4642 | * configuration is used as the start port to bind the |
| 4643 | * sockets. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4644 | * |
| 4645 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 4646 | */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4647 | PJ_DECL(pj_status_t) |
| 4648 | pjsua_media_transports_create(const pjsua_transport_config *cfg); |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 4649 | |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 4650 | |
| 4651 | /** |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4652 | * Register custom media transports to be used by calls. There must |
| 4653 | * enough media transports for all calls. |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 4654 | * |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4655 | * @param tp The media transport array. |
| 4656 | * @param count Number of elements in the array. This number MUST |
| 4657 | * match the number of maximum calls configured when |
| 4658 | * pjsua is created. |
| 4659 | * @param auto_delete Flag to indicate whether the transports should be |
| 4660 | * destroyed when pjsua is shutdown. |
| 4661 | * |
| 4662 | * @return PJ_SUCCESS on success, or the appropriate error code. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 4663 | */ |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4664 | PJ_DECL(pj_status_t) |
| 4665 | pjsua_media_transports_attach( pjsua_media_transport tp[], |
| 4666 | unsigned count, |
| 4667 | pj_bool_t auto_delete); |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 4668 | |
| 4669 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4670 | /** |
| 4671 | * @} |
| 4672 | */ |
| 4673 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 4674 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 4675 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4676 | /** |
| 4677 | * @} |
| 4678 | */ |
| 4679 | |
Benny Prijono | e6ead54 | 2007-01-31 20:53:31 +0000 | [diff] [blame] | 4680 | PJ_END_DECL |
| 4681 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 4682 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 4683 | #endif /* __PJSUA_H__ */ |