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