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