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