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