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