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