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