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