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