blob: a82141b544cc2d66d7abf8763d8287123b71763b [file] [log] [blame]
Benny Prijono268ca612006-02-07 12:34:11 +00001/* $Id$ */
2/*
Benny Prijonoa771a512007-02-19 01:13:53 +00003 * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org>
Benny Prijono268ca612006-02-07 12:34:11 +00004 *
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 Prijono312aff92006-06-17 04:08:30 +000022/**
23 * @file pjsua.h
24 * @brief PJSUA API.
25 */
26
27
Benny Prijono268ca612006-02-07 12:34:11 +000028/* Include all PJSIP core headers. */
29#include <pjsip.h>
30
31/* Include all PJMEDIA headers. */
32#include <pjmedia.h>
33
Benny Prijono1f9afba2006-02-10 15:57:32 +000034/* Include all PJMEDIA-CODEC headers. */
35#include <pjmedia-codec.h>
36
Benny Prijono268ca612006-02-07 12:34:11 +000037/* Include all PJSIP-UA headers */
38#include <pjsip_ua.h>
39
Benny Prijono834aee32006-02-19 01:38:06 +000040/* Include all PJSIP-SIMPLE headers */
41#include <pjsip_simple.h>
42
Benny Prijono268ca612006-02-07 12:34:11 +000043/* Include all PJLIB-UTIL headers. */
44#include <pjlib-util.h>
45
46/* Include all PJLIB headers. */
47#include <pjlib.h>
48
49
Benny Prijonoe6ead542007-01-31 20:53:31 +000050PJ_BEGIN_DECL
51
52
Benny Prijono312aff92006-06-17 04:08:30 +000053/**
Benny Prijonoe6ead542007-01-31 20:53:31 +000054 * @defgroup PJSUA_LIB PJSUA API - High Level Softphone API for C/C++ and Python
Benny Prijono312aff92006-06-17 04:08:30 +000055 * @ingroup PJSIP
56 * @brief Very high level API for constructing SIP UA applications.
57 * @{
58 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000059 * @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 Prijono312aff92006-06-17 04:08:30 +000063 * 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 Prijonoe6ead542007-01-31 20:53:31 +000069 * @subsection pjsua_for_c_cpp C/C++ Binding
Benny Prijono312aff92006-06-17 04:08:30 +000070 * 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 Prijonoe6ead542007-01-31 20:53:31 +000080 * 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 Prijono312aff92006-06-17 04:08:30 +000084 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000085 * @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 Prijono312aff92006-06-17 04:08:30 +0000116 * @section root_using_pjsua_lib Using PJSUA API
117 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000118 * 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 Prijono312aff92006-06-17 04:08:30 +0000121 */
122
Benny Prijonoa91a0032006-02-26 21:23:45 +0000123
Benny Prijonof3195072006-02-14 21:15:30 +0000124
Benny Prijono312aff92006-06-17 04:08:30 +0000125/*****************************************************************************
126 * BASE API
127 */
128
Benny Prijonof04ffdd2006-02-21 00:11:18 +0000129/**
Benny Prijonoe6ead542007-01-31 20:53:31 +0000130 * @defgroup PJSUA_LIB_BASE PJSUA-API Basic API
Benny Prijono312aff92006-06-17 04:08:30 +0000131 * @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 Prijonoe6ead542007-01-31 20:53:31 +0000142 * Before anything else, application must create PJSUA by calling #pjsua_create()
143 * (or <tt>py_pjsua.create()</tt> from Python).
Benny Prijono312aff92006-06-17 04:08:30 +0000144 * This, among other things, will initialize PJLIB, which is crucial before
Benny Prijonoe6ead542007-01-31 20:53:31 +0000145 * 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 Prijono312aff92006-06-17 04:08:30 +0000150 *
151 * @subsection init_pjsua_lib Initializing PJSUA
152 *
153 * After PJSUA is created, application can initialize PJSUA by calling
Benny Prijonoe6ead542007-01-31 20:53:31 +0000154 * #pjsua_init(). This function takes several optional configuration settings
155 * in the argument, if application wants to set them.
Benny Prijono312aff92006-06-17 04:08:30 +0000156 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000157 * @subsubsection init_pjsua_lib_c_cpp PJSUA-LIB Initialization (in C)
158 * Sample code to initialize PJSUA in C code:
Benny Prijono312aff92006-06-17 04:08:30 +0000159 \code
160
Benny Prijonob5388cf2007-01-04 22:45:08 +0000161 #include <pjsua-lib/pjsua.h>
162
163 #define THIS_FILE __FILE__
164
165 static pj_status_t app_init(void)
166 {
Benny Prijono312aff92006-06-17 04:08:30 +0000167 pjsua_config ua_cfg;
168 pjsua_logging_config log_cfg;
169 pjsua_media_config media_cfg;
Benny Prijonob5388cf2007-01-04 22:45:08 +0000170 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 Prijono312aff92006-06-17 04:08:30 +0000178
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 Prijonob5388cf2007-01-04 22:45:08 +0000200 .
201 ...
202 }
Benny Prijono312aff92006-06-17 04:08:30 +0000203 \endcode
204 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000205 *
206 * @subsubsection init_pjsua_lib_python PJSUA-LIB Initialization (in Python)
207 * Sample code to initialize PJSUA in Python code:
208
209 \code
210
211import py_pjsua
212
213#
214# Initialize pjsua.
215#
216def 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#
252def err_exit(title, rc):
253 py_pjsua.perror(THIS_FILE, title, rc)
254 exit(1)
255
256 \endcode
257
258
Benny Prijono312aff92006-06-17 04:08:30 +0000259 * @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 Prijonoe6ead542007-01-31 20:53:31 +0000264 * - 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 Prijono312aff92006-06-17 04:08:30 +0000267 * @ref PJSUA_LIB_TRANSPORT section for more info.
268 * - create one or more SIP accounts with #pjsua_acc_add() or
Benny Prijonoe6ead542007-01-31 20:53:31 +0000269 * #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 Prijono312aff92006-06-17 04:08:30 +0000271 * - 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 Prijonoe6ead542007-01-31 20:53:31 +0000281 * 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 Prijono312aff92006-06-17 04:08:30 +0000283 *
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 Prijonob5388cf2007-01-04 22:45:08 +0000287 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000288 * @subsubsection starting_pjsua_lib_c C Example for Starting PJSUA
Benny Prijonob5388cf2007-01-04 22:45:08 +0000289 * 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 Prijonoe6ead542007-01-31 20:53:31 +0000313
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
333import thread
334
335C_QUIT = 0
336
337
338def 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#
357def 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 Prijonof04ffdd2006-02-21 00:11:18 +0000371 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000372
Benny Prijono312aff92006-06-17 04:08:30 +0000373/** Constant to identify invalid ID for all sorts of IDs. */
374#define PJSUA_INVALID_ID (-1)
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000375
376/** Call identification */
377typedef int pjsua_call_id;
378
Benny Prijono312aff92006-06-17 04:08:30 +0000379/** Account identification */
380typedef int pjsua_acc_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000381
382/** Buddy identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000383typedef int pjsua_buddy_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000384
385/** File player identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000386typedef int pjsua_player_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000387
388/** File recorder identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000389typedef int pjsua_recorder_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000390
391/** Conference port identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000392typedef int pjsua_conf_port_id;
393
394
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000395
Benny Prijonoa91a0032006-02-26 21:23:45 +0000396/**
Benny Prijono312aff92006-06-17 04:08:30 +0000397 * Maximum proxies in account.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000398 */
Benny Prijono312aff92006-06-17 04:08:30 +0000399#ifndef PJSUA_ACC_MAX_PROXIES
400# define PJSUA_ACC_MAX_PROXIES 8
401#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000402
403
404
405/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000406 * 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 Prijonoe6ead542007-01-31 20:53:31 +0000409 *
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 Prijonoeebe9af2006-06-13 22:57:13 +0000417 */
418typedef 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 Prijonoe6ead542007-01-31 20:53:31 +0000449 *
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 Prijonoeebe9af2006-06-13 22:57:13 +0000459 */
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 Prijonoe6ead542007-01-31 20:53:31 +0000470 *
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 Prijonoeebe9af2006-06-13 22:57:13 +0000476 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000477PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000478
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000479
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 Prijonoe6ead542007-01-31 20:53:31 +0000486 *
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 Prijonoeebe9af2006-06-13 22:57:13 +0000490 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000491PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool,
492 pjsua_logging_config *dst,
493 const pjsua_logging_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000494
Benny Prijonodc39fe82006-05-26 12:17:46 +0000495
496/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000497 * 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 Prijonoe6ead542007-01-31 20:53:31 +0000501 *
502 * \par Python Syntax:
503 * This callback structure is embedded on pjsua_config structure.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000504 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000505typedef struct pjsua_callback
Benny Prijonodc39fe82006-05-26 12:17:46 +0000506{
507 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000508 * Notify application when invite state has changed.
509 * Application may then query the call info to get the
Benny Prijonoe6ead542007-01-31 20:53:31 +0000510 * detail call states by calling pjsua_call_get_info() function.
Benny Prijono0875ae82006-12-26 00:11:48 +0000511 *
512 * @param call_id The call index.
513 * @param e Event which causes the call state to change.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000514 *
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 Prijonodc39fe82006-05-26 12:17:46 +0000523 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000524 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000525
526 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000527 * Notify application on incoming call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000528 *
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 Prijonoe6ead542007-01-31 20:53:31 +0000533 *
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 Prijono8b1889b2006-06-06 18:40:40 +0000543 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000544 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000545 pjsip_rx_data *rdata);
546
547 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000548 * 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 Prijono0875ae82006-12-26 00:11:48 +0000551 *
552 * @param call_id The call index.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000553 *
554 * \par Python Syntax:
555 * \code
556 # call_id: integer
557
558 def on_call_media_state(call_id):
559 return
560 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000561 */
562 void (*on_call_media_state)(pjsua_call_id call_id);
563
564 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000565 * Notify application upon incoming DTMF digits.
566 *
567 * @param call_id The call index.
568 * @param digit DTMF ASCII digit.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000569 *
570 * \par Python Syntax:
571 * \code
572 # call_id: integer
Benny Prijono1f63cc42007-09-10 16:54:22 +0000573 # digit: digit string
Benny Prijonoe6ead542007-01-31 20:53:31 +0000574
575 def on_dtmf_digit(call_id, digit):
576 return
577 * \endcode
Benny Prijono0875ae82006-12-26 00:11:48 +0000578 */
579 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
580
581 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000582 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000583 * 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 Prijono0875ae82006-12-26 00:11:48 +0000587 *
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 Prijonoe6ead542007-01-31 20:53:31 +0000593 *
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 Prijono9fc735d2006-05-28 14:58:12 +0000604 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000605 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 Prijonoe6ead542007-01-31 20:53:31 +0000616 * @param st_code Status progress of the transfer request.
617 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000618 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000619 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000620 * 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 Prijonoe6ead542007-01-31 20:53:31 +0000625 *
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 Prijono4ddad2c2006-10-18 17:16:34 +0000639 */
640 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000641 int st_code,
642 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000643 pj_bool_t final,
644 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000645
646 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000647 * 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 Prijonoe6ead542007-01-31 20:53:31 +0000655 *
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 Prijono053f5222006-11-11 16:16:04 +0000668 */
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 Prijonoe6ead542007-01-31 20:53:31 +0000686 *
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 Prijono053f5222006-11-11 16:16:04 +0000695 */
696 void (*on_call_replaced)(pjsua_call_id old_call_id,
697 pjsua_call_id new_call_id);
698
699
700 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000701 * Notify application when registration status has changed.
702 * Application may then query the account info to get the
703 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000704 *
705 * @param acc_id Account ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000706 *
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 Prijonodc39fe82006-05-26 12:17:46 +0000714 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000715 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000716
717 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000718 * Notify application when the buddy state has changed.
719 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000720 *
721 * @param buddy_id The buddy id.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000722 *
723 * \par Python Syntax:
724 * \code
725 # buddy_id: integer
726
727 def on_buddy_state(buddy_id):
728 return
729 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000730 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000731 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000732
733 /**
734 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000735 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000736 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000737 *
Benny Prijonobbeb3992007-05-21 13:48:35 +0000738 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
739 * passed as one of the argument.
740 *
Benny Prijono0875ae82006-12-26 00:11:48 +0000741 * @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 Prijonoe6ead542007-01-31 20:53:31 +0000749 *
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 Prijonodc39fe82006-05-26 12:17:46 +0000762 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000763 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 Prijonobbeb3992007-05-21 13:48:35 +0000768 * 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 Prijonoeebe9af2006-06-13 22:57:13 +0000787 * Notify application about the delivery status of outgoing pager
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000788 * request. See also on_pager_status2() callback for the version with
789 * \a pjsip_rx_data in the argument list.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000790 *
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 Prijonoe6ead542007-01-31 20:53:31 +0000800 *
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 Prijonoeebe9af2006-06-13 22:57:13 +0000813 */
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 Prijonodc39fe82006-05-26 12:17:46 +0000820
821 /**
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000822 * 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 Prijono0a982002007-06-12 16:22:09 +0000834 * @param tdata The original MESSAGE request.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000835 * @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 Prijono0a982002007-06-12 16:22:09 +0000845 pjsip_tx_data *tdata,
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000846 pjsip_rx_data *rdata);
847
848 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000849 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +0000850 *
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 Prijonoe6ead542007-01-31 20:53:31 +0000859 *
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 Prijonodc39fe82006-05-26 12:17:46 +0000871 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000872 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 Prijonodc39fe82006-05-26 12:17:46 +0000875
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000876} pjsua_callback;
877
878
879
Benny Prijonodc39fe82006-05-26 12:17:46 +0000880
881/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000882 * 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 Prijonoe6ead542007-01-31 20:53:31 +0000886 *
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 Prijonodc39fe82006-05-26 12:17:46 +0000893 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000894typedef struct pjsua_config
895{
896
897 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000898 * 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 Prijonoeebe9af2006-06-13 22:57:13 +0000903 */
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 Prijonofa9e5b12006-10-08 12:39:34 +0000915 * 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 Prijonob5388cf2007-01-04 22:45:08 +0000929 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000930 */
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 Prijonoc97608e2007-03-23 16:34:20 +0000942 /**
Benny Prijonoebbf6892007-03-24 17:37:25 +0000943 * 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 Prijonoc97608e2007-03-23 16:34:20 +0000949 */
Benny Prijonoebbf6892007-03-24 17:37:25 +0000950 pj_str_t stun_domain;
951
952 /**
Benny Prijonoaf09dc32007-04-22 12:48:30 +0000953 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
954 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +0000955 */
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 Prijonoc97608e2007-03-23 16:34:20 +0000962
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000963 /**
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 Prijonob5388cf2007-01-04 22:45:08 +0000970 * 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 Prijonoeebe9af2006-06-13 22:57:13 +0000974 */
975 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
976
977 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000978 * Application callback to receive various event notifications from
979 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000980 */
981 pjsua_callback cb;
982
Benny Prijono56315612006-07-18 14:39:40 +0000983 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000984 * Optional user agent string (default empty). If it's empty, no
985 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +0000986 */
987 pj_str_t user_agent;
988
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000989} pjsua_config;
990
991
992/**
993 * Use this function to initialize pjsua config.
994 *
995 * @param cfg pjsua config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000996 *
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 Prijonoeebe9af2006-06-13 22:57:13 +00001004 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001005PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001006
1007
1008/**
1009 * Duplicate credential.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001010 *
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 Prijonoeebe9af2006-06-13 22:57:13 +00001018 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001019PJ_DECL(void) pjsip_cred_dup( pj_pool_t *pool,
1020 pjsip_cred_info *dst,
1021 const pjsip_cred_info *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001022
1023
1024/**
1025 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001026 *
1027 * @param pool The pool to get memory from.
1028 * @param dst Destination config.
1029 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001030 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001031PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1032 pjsua_config *dst,
1033 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001034
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001035
1036/**
1037 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001038 * 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 Prijonoe6ead542007-01-31 20:53:31 +00001044 *
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 Prijonoeebe9af2006-06-13 22:57:13 +00001051 */
1052typedef struct pjsua_msg_data
1053{
1054 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001055 * 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 Prijonoe6ead542007-01-31 20:53:31 +00001059 *
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 Prijonoeebe9af2006-06-13 22:57:13 +00001067 */
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 Prijonoe6ead542007-01-31 20:53:31 +00001087 *
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 Prijonoeebe9af2006-06-13 22:57:13 +00001093 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001094PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001095
Benny Prijono268ca612006-02-07 12:34:11 +00001096
1097/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001098 * 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 Prijonoe6ead542007-01-31 20:53:31 +00001104 *
1105 * \par Python:
1106 * \code
1107 status = py_pjsua.create()
1108 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001109 */
1110PJ_DECL(pj_status_t) pjsua_create(void);
1111
1112
Benny Prijonoe6ead542007-01-31 20:53:31 +00001113/* Forward declaration */
1114typedef struct pjsua_media_config pjsua_media_config;
1115
1116
Benny Prijonodc39fe82006-05-26 12:17:46 +00001117/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001118 * 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 Prijonoccf95622006-02-07 18:48:01 +00001121 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001122 * Note that #pjsua_create() MUST be called before calling this function.
1123 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001124 * @param ua_cfg User agent configuration.
1125 * @param log_cfg Optional logging configuration.
1126 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001127 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001128 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001129 *
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 Prijono268ca612006-02-07 12:34:11 +00001138 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001139PJ_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 Prijono268ca612006-02-07 12:34:11 +00001142
1143
1144/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001145 * 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 Prijonoccf95622006-02-07 18:48:01 +00001148 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001149 * Application may call this function anytime after #pjsua_init().
1150 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001151 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001152 *
1153 * \par Python:
1154 * The function is similar in Python:
1155 * \code
1156 status = py_pjsua.start()
1157 * \endcode
Benny Prijonoccf95622006-02-07 18:48:01 +00001158 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001159PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001160
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001161
Benny Prijonoccf95622006-02-07 18:48:01 +00001162/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001163 * 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 Prijonoeebe9af2006-06-13 22:57:13 +00001172 *
1173 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001174 *
1175 * \par Python:
1176 * The function is similar in Python:
1177 * \code
1178 status = py_pjsua.destroy()
1179 * \endcode
Benny Prijono268ca612006-02-07 12:34:11 +00001180 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001181PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001182
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001183
Benny Prijono9fc735d2006-05-28 14:58:12 +00001184/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001185 * Poll pjsua for events, and if necessary block the caller thread for
1186 * the specified maximum interval (in miliseconds).
1187 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001188 * 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 Prijonoeebe9af2006-06-13 22:57:13 +00001192 * @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 Prijonoe6ead542007-01-31 20:53:31 +00001196 * 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 Prijonob9b32ab2006-06-01 12:28:44 +00001203 */
1204PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1205
1206
1207/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001208 * 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 Prijonoeebe9af2006-06-13 22:57:13 +00001210 *
1211 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001212 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001213 * @param increment Increment size.
1214 *
1215 * @return The pool, or NULL when there's no memory.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001216 *
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 Prijonoeebe9af2006-06-13 22:57:13 +00001222 */
1223PJ_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 Prijonoe6ead542007-01-31 20:53:31 +00001234 *
1235 * \par Python:
1236 * The function is similar in Python:
1237 * \code
1238 status = py_pjsua.reconfigure_logging(log_cfg)
1239 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001240 */
1241PJ_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 Prijonob5388cf2007-01-04 22:45:08 +00001247 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001248 *
1249 * @return SIP endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001250 *
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 Prijono9fc735d2006-05-28 14:58:12 +00001258 */
1259PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1260
1261/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001262 * Internal function to get media endpoint instance.
1263 * Only valid after #pjsua_init() is called.
1264 *
1265 * @return Media endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001266 *
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 Prijono9fc735d2006-05-28 14:58:12 +00001274 */
1275PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1276
Benny Prijono97b87172006-08-24 14:25:14 +00001277/**
1278 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001279 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001280 *
1281 * @return Pool factory currently used by PJSUA.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001282 *
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 Prijono97b87172006-08-24 14:25:14 +00001290 */
1291PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1292
1293
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001294
1295/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001296 * Utilities.
1297 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001298 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001299
1300/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001301 * 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 Prijono312aff92006-06-17 04:08:30 +00001303 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001304 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001305 *
1306 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001307 *
1308 * \par Python:
1309 * \code
1310 status = py_pjsua.verify_sip_url(url)
1311 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001312 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001313PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001314
1315
1316/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001317 * 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 Prijono312aff92006-06-17 04:08:30 +00001319 *
1320 * @param sender The log sender field.
1321 * @param title Message title for the error.
1322 * @param status Status code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001323 *
1324 * \par Python:
1325 * \code
1326 py_pjsua.perror(sender, title, status)
1327 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001328 */
1329PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1330 pj_status_t status);
1331
1332
Benny Prijonoda9785b2007-04-02 20:43:06 +00001333/**
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 */
1340PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001341
1342/**
1343 * @}
1344 */
1345
1346
1347
1348/*****************************************************************************
1349 * TRANSPORT API
1350 */
1351
1352/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001353 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001354 * @ingroup PJSUA_LIB
1355 * @brief API for managing SIP transports
1356 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001357 *
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 Prijono312aff92006-06-17 04:08:30 +00001361 */
1362
1363
Benny Prijonoe6ead542007-01-31 20:53:31 +00001364/** SIP transport identification.
1365 */
Benny Prijono312aff92006-06-17 04:08:30 +00001366typedef int pjsua_transport_id;
1367
1368
1369/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001370 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001371 * 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 Prijonoe6ead542007-01-31 20:53:31 +00001374 *
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 Prijono312aff92006-06-17 04:08:30 +00001381 */
1382typedef 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 Prijono0a5cad82006-09-26 13:21:02 +00001393 * 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 Prijono312aff92006-06-17 04:08:30 +00001400 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001401 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 Prijono312aff92006-06-17 04:08:30 +00001415
1416 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001417 * 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 Prijono6e0e54b2006-12-08 21:58:31 +00001420 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001421 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001422
Benny Prijono312aff92006-06-17 04:08:30 +00001423} 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 Prijonoe6ead542007-01-31 20:53:31 +00001430 *
1431 * \par Python:
1432 * The corresponding Python function is rather different:
1433 * \code
1434 transport_cfg = py_pjsua.transport_config_default()
1435 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001436 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001437PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001438
1439
1440/**
Benny Prijono312aff92006-06-17 04:08:30 +00001441 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001442 *
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 Prijono312aff92006-06-17 04:08:30 +00001450 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001451PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1452 pjsua_transport_config *dst,
1453 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001454
1455
1456/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001457 * This structure describes transport information returned by
1458 * #pjsua_transport_get_info() function.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001459 *
1460 * \par Python:
1461 * The corresponding data type in Python is <tt>py_pjsua.Transport_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001462 */
1463typedef 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 Prijonob5388cf2007-01-04 22:45:08 +00001515 * Create and start a new SIP transport according to the specified
1516 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001517 *
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 Prijonoe6ead542007-01-31 20:53:31 +00001523 *
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 Prijonoeebe9af2006-06-13 22:57:13 +00001529 */
1530PJ_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 Prijonoe6ead542007-01-31 20:53:31 +00001535 * 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 Prijonoeebe9af2006-06-13 22:57:13 +00001538 *
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 Prijonoe6ead542007-01-31 20:53:31 +00001543 *
1544 * \par Python:
1545 * Not applicable (for now), because one cannot create a custom transport
1546 * from Python script.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001547 */
1548PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1549 pjsua_transport_id *p_id);
1550
1551
1552/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001553 * 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 Prijonoeebe9af2006-06-13 22:57:13 +00001557 *
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 Prijonoe6ead542007-01-31 20:53:31 +00001563 *
1564 * \par Python:
1565 * The function returns list of integers representing transport ids:
1566 * \code
1567 [int] = py_pjsua.enum_transports()
1568 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001569 */
1570PJ_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 Prijonoe6ead542007-01-31 20:53:31 +00001581 *
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 Prijonoeebe9af2006-06-13 22:57:13 +00001587 */
1588PJ_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 Prijonoe6ead542007-01-31 20:53:31 +00001602 *
1603 * \par Python:
1604 * \code
1605 status = py_pjsua.transport_set_enable(id, enabled)
1606 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001607 */
1608PJ_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 Prijonob5388cf2007-01-04 22:45:08 +00001615 * 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 Prijonoeebe9af2006-06-13 22:57:13 +00001619 *
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 Prijonoe6ead542007-01-31 20:53:31 +00001625 *
1626 * \par Python:
1627 * \code
1628 status = py_pjsua.transport_close(id, force)
1629 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001630 */
1631PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1632 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001633
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001634/**
Benny Prijono312aff92006-06-17 04:08:30 +00001635 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001636 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001637
1638
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001639
1640
1641/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001642 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001643 */
1644
Benny Prijono312aff92006-06-17 04:08:30 +00001645
1646/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001647 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001648 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001649 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001650 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001651 *
Benny Prijono312aff92006-06-17 04:08:30 +00001652 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001653 * 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 Prijono312aff92006-06-17 04:08:30 +00001659 *
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 Prijonoe6ead542007-01-31 20:53:31 +00001664 * 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 Prijono312aff92006-06-17 04:08:30 +00001667 *
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 Prijonoe6ead542007-01-31 20:53:31 +00001671 * instead of a particular user, and it correspond with a particular
1672 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00001673 *
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 Prijono3a5e1ab2006-08-15 20:26:34 +00001702 * Default PUBLISH expiration
1703 */
1704#ifndef PJSUA_PUBLISH_EXPIRATION
1705# define PJSUA_PUBLISH_EXPIRATION 600
1706#endif
1707
1708
1709/**
Benny Prijono093d3022006-09-24 00:07:11 +00001710 * Default account priority.
1711 */
1712#ifndef PJSUA_DEFAULT_ACC_PRIORITY
1713# define PJSUA_DEFAULT_ACC_PRIORITY 0
1714#endif
1715
1716
1717/**
Benny Prijono8058a622007-06-08 04:37:05 +00001718 * 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 Prijono66ceef52007-06-08 05:12:58 +00001723# define PJSUA_SECURE_SCHEME "sip"
Benny Prijono8058a622007-06-08 04:37:05 +00001724#endif
1725
1726
1727/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001728 * 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 Prijonoe6ead542007-01-31 20:53:31 +00001731 *
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 Prijono312aff92006-06-17 04:08:30 +00001739 */
1740typedef struct pjsua_acc_config
1741{
Benny Prijono093d3022006-09-24 00:07:11 +00001742 /**
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 Prijono312aff92006-06-17 04:08:30 +00001749 /**
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 Prijono3a5e1ab2006-08-15 20:26:34 +00001766 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001767 * If this flag is set, the presence information of this account will
1768 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001769 */
1770 pj_bool_t publish_enabled;
1771
Benny Prijonofe04fb52007-08-24 08:28:52 +00001772 /**
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 Prijono312aff92006-06-17 04:08:30 +00001778 /**
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 Prijonob4a17c92006-07-10 14:40:21 +00001783 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00001784
1785 /**
1786 * Number of proxies in the proxy array below.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001787 *
1788 * \par Python:
1789 * Not applicable, as \a proxy is implemented as list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001790 */
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 Prijonob5388cf2007-01-04 22:45:08 +00001802 * 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 Prijonoe6ead542007-01-31 20:53:31 +00001805 *
1806 * \par Python:
1807 * This will be list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001808 */
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 Prijonoe6ead542007-01-31 20:53:31 +00001819 *
1820 * \par Python:
1821 * Not applicable, since \a cred_info is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00001822 */
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 Prijonoe6ead542007-01-31 20:53:31 +00001831 *
1832 * \par Python:
1833 * This field is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00001834 */
1835 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1836
Benny Prijono62c5c5b2007-01-13 23:22:40 +00001837 /**
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 Prijono312aff92006-06-17 04:08:30 +00001850} 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 Prijonoe6ead542007-01-31 20:53:31 +00001857 *
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 Prijono312aff92006-06-17 04:08:30 +00001864 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001865PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001866
1867
1868/**
1869 * Account info. Application can query account info by calling
1870 * #pjsua_acc_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00001871 *
1872 * \par Python:
1873 * The data type in Python is <tt>py_pjsua.Acc_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001874 */
1875typedef 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 Prijono4461c7d2007-08-25 13:36:15 +00001921 * 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 Prijono312aff92006-06-17 04:08:30 +00001931 * 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 Prijonoe6ead542007-01-31 20:53:31 +00001943 *
1944 * \par Python:
1945 * \code
1946 count = py_pjsua.acc_get_count()
1947 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001948 */
1949PJ_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 Prijonoe6ead542007-01-31 20:53:31 +00001958 *
1959 * \par Python:
1960 * \code
1961 is_valid = py_pjsua.acc_is_valid(acc_id)
1962 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001963 */
1964PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
1965
1966
1967/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00001968 * 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 Prijonoe6ead542007-01-31 20:53:31 +00001974 *
1975 * \par Python:
1976 * \code
1977 status = py_pjsua.acc_set_default(acc_id)
1978 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00001979 */
1980PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
1981
1982
1983/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001984 * 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 Prijono21b9ad92006-08-15 13:11:22 +00001987 *
1988 * @return The default account ID, or PJSUA_INVALID_ID if no
1989 * default account is configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001990 *
1991 * \par Python:
1992 * \code
1993 acc_id = py_pjsua.acc_get_default()
1994 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00001995 */
1996PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
1997
1998
1999/**
Benny Prijono312aff92006-06-17 04:08:30 +00002000 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002001 * #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 Prijono312aff92006-06-17 04:08:30 +00002007 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002008 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002009 * @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 Prijonoe6ead542007-01-31 20:53:31 +00002018 *
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 Prijono312aff92006-06-17 04:08:30 +00002024 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002025PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002026 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 Prijonoe6ead542007-01-31 20:53:31 +00002045 *
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 Prijono312aff92006-06-17 04:08:30 +00002051 */
2052PJ_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 Prijonob5388cf2007-01-04 22:45:08 +00002057 * 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 Prijono312aff92006-06-17 04:08:30 +00002060 *
2061 * @param acc_id Id of the account to be deleted.
2062 *
2063 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002064 *
2065 * \par Python:
2066 * \code
2067 status = py_pjsua.acc_del(acc_id)
2068 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002069 */
2070PJ_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 Prijonoe6ead542007-01-31 20:53:31 +00002077 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002078 *
2079 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002080 *
2081 * \par Python:
2082 * \code
2083 status = py_pjsua.acc_modify(acc_id, acc_cfg)
2084 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002085 */
2086PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002087 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002088
2089
2090/**
2091 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002092 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002093 * 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 Prijono312aff92006-06-17 04:08:30 +00002097 *
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 Prijonoe6ead542007-01-31 20:53:31 +00002102 *
2103 * \par Python:
2104 * \code
2105 status = py_pjsua.acc_set_online_status(acc_id, is_online)
2106 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002107 */
2108PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2109 pj_bool_t is_online);
2110
Benny Prijono4461c7d2007-08-25 13:36:15 +00002111/**
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 */
2126PJ_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 Prijono312aff92006-06-17 04:08:30 +00002129
2130/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002131 * 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 Prijono312aff92006-06-17 04:08:30 +00002136 *
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 Prijonoe6ead542007-01-31 20:53:31 +00002142 *
2143 * \par Python:
2144 * \code
2145 status = py_pjsua.acc_set_registration(acc_id, renew)
2146 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002147 */
2148PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2149 pj_bool_t renew);
2150
2151
2152/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002153 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002154 *
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 Prijonoe6ead542007-01-31 20:53:31 +00002159 *
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 Prijono312aff92006-06-17 04:08:30 +00002165 */
2166PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2167 pjsua_acc_info *info);
2168
2169
2170/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002171 * 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 Prijono312aff92006-06-17 04:08:30 +00002176 *
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 Prijonoe6ead542007-01-31 20:53:31 +00002182 *
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 Prijono312aff92006-06-17 04:08:30 +00002188 */
2189PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2190 unsigned *count );
2191
2192
2193/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002194 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002195 *
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 Prijonoe6ead542007-01-31 20:53:31 +00002201 *
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 Prijono312aff92006-06-17 04:08:30 +00002207 */
2208PJ_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 Prijonoe6ead542007-01-31 20:53:31 +00002219 *
2220 * \par Python:
2221 * \code
2222 acc_id = py_pjsua.acc_find_for_outgoing(url)
2223 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002224 */
2225PJ_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 Prijonoe6ead542007-01-31 20:53:31 +00002235 *
2236 * \par Python:
2237 * \code
2238 acc_id = py_pjsua.acc_find_for_outgoing(url)
2239 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002240 */
2241PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2242
2243
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002244/**
Benny Prijonofff245c2007-04-02 11:44:47 +00002245 * 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 */
2257PJ_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 Prijonoc570f2d2006-07-18 00:33:02 +00002264 * 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 Prijonoe6ead542007-01-31 20:53:31 +00002273 *
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 Prijonoc570f2d2006-07-18 00:33:02 +00002279 */
2280PJ_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 Prijonoe6ead542007-01-31 20:53:31 +00002297 *
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 Prijonoc570f2d2006-07-18 00:33:02 +00002303 */
2304PJ_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 Prijono62c5c5b2007-01-13 23:22:40 +00002310/**
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 Prijonoe6ead542007-01-31 20:53:31 +00002326 *
2327 * \par Python:
2328 * Not yet implemented.
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002329 */
2330PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
2331 pjsua_transport_id tp_id);
2332
Benny Prijono312aff92006-06-17 04:08:30 +00002333
2334/**
2335 * @}
2336 */
2337
2338
2339/*****************************************************************************
2340 * CALLS API
2341 */
2342
2343
2344/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002345 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00002346 * @ingroup PJSUA_LIB
2347 * @brief Call manipulation.
2348 * @{
2349 */
2350
2351/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002352 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00002353 */
2354#ifndef PJSUA_MAX_CALLS
2355# define PJSUA_MAX_CALLS 32
2356#endif
2357
2358
2359
2360/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002361 * This enumeration specifies the media status of a call, and it's part
2362 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00002363 */
2364typedef enum pjsua_call_media_status
2365{
Benny Prijonob5388cf2007-01-04 22:45:08 +00002366 /** Call currently has no media */
Benny Prijono312aff92006-06-17 04:08:30 +00002367 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002368
2369 /** The media is active */
Benny Prijono312aff92006-06-17 04:08:30 +00002370 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002371
2372 /** The media is currently put on hold by local endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002373 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002374
2375 /** The media is currently put on hold by remote endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002376 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002377
Benny Prijono312aff92006-06-17 04:08:30 +00002378} pjsua_call_media_status;
2379
2380
2381/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002382 * This structure describes the information and current status of a call.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002383 *
2384 * \par Python:
2385 * The type name is <tt>py_pjsua.Call_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002386 */
2387typedef 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 Prijono90315512006-09-14 16:05:16 +00002395 /** The account ID where this call belongs. */
2396 pjsua_acc_id acc_id;
2397
Benny Prijono312aff92006-06-17 04:08:30 +00002398 /** 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 Prijonoa91a0032006-02-26 21:23:45 +00002456/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002457 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002458 *
2459 * @return Maximum number of calls configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002460 *
2461 * \par Python:
2462 * \code
2463 count = py_pjsua.call_get_max_count()
2464 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002465 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002466PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002467
2468/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002469 * Get number of currently active calls.
2470 *
2471 * @return Number of currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002472 *
2473 * \par Python:
2474 * \code
2475 count = py_pjsua.call_get_count()
2476 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002477 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002478PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002479
2480/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002481 * Enumerate all active calls. Application may then query the information and
2482 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002483 *
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 Prijonoe6ead542007-01-31 20:53:31 +00002489 *
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 Prijonoeebe9af2006-06-13 22:57:13 +00002495 */
2496PJ_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 Prijonoeebe9af2006-06-13 22:57:13 +00002504 * @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 Prijonoe6ead542007-01-31 20:53:31 +00002514 *
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 Prijonoeebe9af2006-06-13 22:57:13 +00002523 */
2524PJ_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 Prijono9fc735d2006-05-28 14:58:12 +00002533 * Check if the specified call has active INVITE session and the INVITE
2534 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002535 *
2536 * @param call_id Call identification.
2537 *
2538 * @return Non-zero if call is active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002539 *
2540 * \par Python:
2541 * \code
2542 bool = py_pjsua.call_is_active(call_id)
2543 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002544 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002545PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002546
2547
2548/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002549 * Check if call has an active media session.
2550 *
2551 * @param call_id Call identification.
2552 *
2553 * @return Non-zero if yes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002554 *
2555 * \par Python:
2556 * \code
2557 bool = py_pjsua.call_has_media(call_id)
2558 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002559 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002560PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002561
2562
2563/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002564 * 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 Prijonoe6ead542007-01-31 20:53:31 +00002570 *
2571 * \par Python:
2572 * \code
2573 slot = py_pjsua.call_get_conf_port(call_id)
2574 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002575 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002576PJ_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 Prijonoe6ead542007-01-31 20:53:31 +00002585 *
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 Prijonoeebe9af2006-06-13 22:57:13 +00002591 */
2592PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002593 pjsua_call_info *info);
2594
2595
2596/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002597 * Attach application specific data to the call. Application can then
2598 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002599 *
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 Prijonoe6ead542007-01-31 20:53:31 +00002604 *
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 Prijono9fc735d2006-05-28 14:58:12 +00002610 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002611PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
2612 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002613
2614
2615/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002616 * Get user data attached to the call, which has been previously set with
2617 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002618 *
2619 * @param call_id Call identification.
2620 *
2621 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002622 *
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 Prijono268ca612006-02-07 12:34:11 +00002628 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002629PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00002630
2631
2632/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002633 * 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 Prijonoeebe9af2006-06-13 22:57:13 +00002636 *
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 Prijonoe6ead542007-01-31 20:53:31 +00002645 *
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 Prijonoa91a0032006-02-26 21:23:45 +00002651 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002652PJ_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 Prijonoa91a0032006-02-26 21:23:45 +00002656
2657/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002658 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00002659 * 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 Prijonoeebe9af2006-06-13 22:57:13 +00002664 *
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 Prijonoe6ead542007-01-31 20:53:31 +00002675 *
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 Prijono26ff9062006-02-21 23:47:00 +00002681 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002682PJ_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 Prijono26ff9062006-02-21 23:47:00 +00002686
2687
2688/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002689 * 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 Prijonoeebe9af2006-06-13 22:57:13 +00002694 *
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 Prijonoe6ead542007-01-31 20:53:31 +00002700 *
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 Prijono26ff9062006-02-21 23:47:00 +00002706 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002707PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
2708 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002709
2710
2711/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002712 * 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 Prijonoeebe9af2006-06-13 22:57:13 +00002716 *
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 Prijonoe6ead542007-01-31 20:53:31 +00002724 *
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 Prijono26ff9062006-02-21 23:47:00 +00002730 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002731PJ_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 Prijono26ff9062006-02-21 23:47:00 +00002734
2735
2736/**
Benny Prijono053f5222006-11-11 16:16:04 +00002737 * 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 Prijonoeebe9af2006-06-13 22:57:13 +00002740 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00002741 * 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 Prijono053f5222006-11-11 16:16:04 +00002746 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002747 * @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 Prijonoe6ead542007-01-31 20:53:31 +00002752 *
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 Prijono26ff9062006-02-21 23:47:00 +00002758 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002759PJ_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 Prijono9fc735d2006-05-28 14:58:12 +00002762
2763/**
Benny Prijono053f5222006-11-11 16:16:04 +00002764 * 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 Prijonoe6ead542007-01-31 20:53:31 +00002786 *
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 Prijono053f5222006-11-11 16:16:04 +00002792 */
2793PJ_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 Prijonoeebe9af2006-06-13 22:57:13 +00002799 * Send DTMF digits to remote using RFC 2833 payload formats.
2800 *
2801 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002802 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002803 *
2804 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002805 *
2806 * \par Python:
2807 * \code
2808 status = py_pjsua.call_dial_dtmf(call_id, digits)
2809 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002810 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002811PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002812 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00002813
Benny Prijono26ff9062006-02-21 23:47:00 +00002814/**
Benny Prijonob0808372006-03-02 21:18:58 +00002815 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002816 *
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 Prijonoe6ead542007-01-31 20:53:31 +00002828 *
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 Prijonob0808372006-03-02 21:18:58 +00002834 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002835PJ_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 Prijonob0808372006-03-02 21:18:58 +00002840
2841
2842/**
2843 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002844 *
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 Prijonoe6ead542007-01-31 20:53:31 +00002852 *
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 Prijonob0808372006-03-02 21:18:58 +00002858 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002859PJ_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 Prijonob0808372006-03-02 21:18:58 +00002862
2863/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002864 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
2865 * currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002866 *
2867 * \par Python:
2868 * \code
2869 py_pjsua.call_hangup_all()
2870 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00002871 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00002872PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00002873
2874
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002875/**
2876 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002877 *
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 Prijonoe6ead542007-01-31 20:53:31 +00002885 *
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 Prijonob9b32ab2006-06-01 12:28:44 +00002891 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002892PJ_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 Prijonob9b32ab2006-06-01 12:28:44 +00002897
Benny Prijono9fc735d2006-05-28 14:58:12 +00002898/**
Benny Prijono312aff92006-06-17 04:08:30 +00002899 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00002900 */
Benny Prijono834aee32006-02-19 01:38:06 +00002901
2902
2903/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00002904 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00002905 */
2906
Benny Prijono312aff92006-06-17 04:08:30 +00002907
2908/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002909 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00002910 * @ingroup PJSUA_LIB
2911 * @brief Buddy management, buddy's presence, and instant messaging.
2912 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00002913 *
2914 * This section describes PJSUA-APIs related to buddies management,
2915 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00002916 */
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 Prijonob5388cf2007-01-04 22:45:08 +00002927 * 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 Prijonoe6ead542007-01-31 20:53:31 +00002931 *
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 Prijono312aff92006-06-17 04:08:30 +00002939 */
2940typedef 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 Prijonob5388cf2007-01-04 22:45:08 +00002956 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00002957 */
2958typedef 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 Prijonofc24e692007-01-27 18:31:51 +00002967 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00002968 */
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 Prijonob5388cf2007-01-04 22:45:08 +00002981 * This structure describes buddy info, which can be retrieved by calling
2982 * #pjsua_buddy_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00002983 *
2984 * \par Python:
2985 * This structure in Python is <tt>py_pjsua.Buddy_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002986 */
2987typedef 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 Prijono4461c7d2007-08-25 13:36:15 +00003022 * Extended RPID information about the person.
3023 */
3024 pjrpid_element rpid;
3025
3026 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003027 * Internal buffer.
3028 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003029 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003030
3031} pjsua_buddy_info;
3032
3033
Benny Prijono834aee32006-02-19 01:38:06 +00003034/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003035 * Set default values to the buddy config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003036 *
3037 * \par Python:
3038 * \code
3039 buddy_cfg = py_pjsua.buddy_config_default()
3040 * \endcode
Benny Prijonob5388cf2007-01-04 22:45:08 +00003041 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003042PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003043
3044
3045/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003046 * Get total number of buddies.
3047 *
3048 * @return Number of buddies.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003049 *
3050 * \par Python:
3051 * \code
3052 buddy_count = py_pjsua.get_buddy_count()
3053 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003054 */
3055PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3056
3057
3058/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003059 * 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 Prijonoe6ead542007-01-31 20:53:31 +00003064 *
3065 * \par Python:
3066 * \code
3067 is_valid = py_pjsua.buddy_is_valid(buddy_id)
3068 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003069 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003070PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3071
3072
3073/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003074 * 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 Prijonoeebe9af2006-06-13 22:57:13 +00003077 *
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 Prijonoe6ead542007-01-31 20:53:31 +00003084 *
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 Prijonoeebe9af2006-06-13 22:57:13 +00003090 */
3091PJ_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 Prijonoe6ead542007-01-31 20:53:31 +00003101 *
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 Prijonoeebe9af2006-06-13 22:57:13 +00003107 */
3108PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003109 pjsua_buddy_info *info);
3110
3111/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003112 * 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 Prijonoeebe9af2006-06-13 22:57:13 +00003115 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003116 * @param buddy)cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003117 * @param p_buddy_id Pointer to receive buddy ID.
3118 *
3119 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003120 *
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 Prijono9fc735d2006-05-28 14:58:12 +00003126 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003127PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003128 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003129
3130
3131/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003132 * Delete the specified buddy from the buddy list. Any presence subscription
3133 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003134 *
3135 * @param buddy_id Buddy identification.
3136 *
3137 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003138 *
3139 * \par Python:
3140 * \code
3141 status = py_pjsua.buddy_del(buddy_id)
3142 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +00003143 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003144PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003145
3146
3147/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003148 * 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 Prijonoeebe9af2006-06-13 22:57:13 +00003151 *
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 Prijonoe6ead542007-01-31 20:53:31 +00003157 *
3158 * \par Python:
3159 * \code
3160 status = py_pjsua.buddy_subscribe_pres(buddy_id, subscribe)
3161 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003162 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003163PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3164 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003165
3166
3167/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003168 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003169 *
3170 * @param verbose Yes or no.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003171 *
3172 * \par Python:
3173 * \code
3174 py_pjsua.pres_dump()
3175 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003176 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003177PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003178
3179
Benny Prijonob0808372006-03-02 21:18:58 +00003180/**
3181 * The MESSAGE method (defined in pjsua_im.c)
3182 */
3183extern const pjsip_method pjsip_message_method;
3184
3185
Benny Prijonob0808372006-03-02 21:18:58 +00003186
3187/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003188 * 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 Prijonoe6ead542007-01-31 20:53:31 +00003203 *
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 Prijonob0808372006-03-02 21:18:58 +00003209 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003210PJ_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 Prijonob0808372006-03-02 21:18:58 +00003216
3217
3218/**
3219 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003220 *
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 Prijonoe6ead542007-01-31 20:53:31 +00003229 *
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 Prijonob0808372006-03-02 21:18:58 +00003235 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003236PJ_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 Prijonob0808372006-03-02 21:18:58 +00003240
3241
Benny Prijonof3195072006-02-14 21:15:30 +00003242
Benny Prijono312aff92006-06-17 04:08:30 +00003243/**
3244 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003245 */
3246
Benny Prijono312aff92006-06-17 04:08:30 +00003247
3248/*****************************************************************************
3249 * MEDIA API
3250 */
3251
3252
3253/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003254 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003255 * @ingroup PJSUA_LIB
3256 * @brief Media manipulation.
3257 * @{
3258 *
3259 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003260 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3261 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003262 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003263 * 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 Prijono312aff92006-06-17 04:08:30 +00003271 *
3272 * Application connects one media termination/slot to another by calling
3273 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003274 * 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 Prijono312aff92006-06-17 04:08:30 +00003280 * 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 Prijono12a669c2006-11-23 07:32:13 +00003319# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00003320#endif
3321
Benny Prijonob5388cf2007-01-04 22:45:08 +00003322/**
3323 * The default clock rate to be used by the conference bridge.
3324 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003325#ifndef PJSUA_DEFAULT_CLOCK_RATE
3326# define PJSUA_DEFAULT_CLOCK_RATE 16000
3327#endif
3328
Benny Prijonob5388cf2007-01-04 22:45:08 +00003329/**
3330 * Default codec quality settings.
3331 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003332#ifndef PJSUA_DEFAULT_CODEC_QUALITY
3333# define PJSUA_DEFAULT_CODEC_QUALITY 5
3334#endif
3335
Benny Prijonob5388cf2007-01-04 22:45:08 +00003336/**
3337 * Default iLBC mode.
3338 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003339#ifndef PJSUA_DEFAULT_ILBC_MODE
3340# define PJSUA_DEFAULT_ILBC_MODE 20
3341#endif
3342
Benny Prijonob5388cf2007-01-04 22:45:08 +00003343/**
3344 * The default echo canceller tail length.
3345 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003346#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonod2990b92006-11-23 10:19:46 +00003347# define PJSUA_DEFAULT_EC_TAIL_LEN 800
Benny Prijono12a669c2006-11-23 07:32:13 +00003348#endif
Benny Prijono312aff92006-06-17 04:08:30 +00003349
3350
3351/**
Benny Prijonocba59d92007-02-16 09:22:56 +00003352 * 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 Prijonob5388cf2007-01-04 22:45:08 +00003368 * 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 Prijonoe6ead542007-01-31 20:53:31 +00003371 *
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 Prijono312aff92006-06-17 04:08:30 +00003379 */
3380struct pjsua_media_config
3381{
3382 /**
3383 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003384 * If value is zero, default clock rate will be used
3385 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00003386 */
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 Prijono0498d902006-06-19 14:49:14 +00003416 /**
3417 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00003418 * 5-10: resampling use large filter,
3419 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00003420 * 1-2: resampling use linear.
3421 * The media quality also sets speex codec quality/complexity to the
3422 * number.
3423 *
Benny Prijono70972992006-08-05 11:13:58 +00003424 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00003425 */
3426 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00003427
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 Prijono00cae612006-07-31 15:19:36 +00003441
3442 /**
3443 * iLBC mode (20 or 30).
3444 *
Benny Prijono70972992006-08-05 11:13:58 +00003445 * Default: 20 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00003446 */
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 Prijonoc8e24a12006-08-02 18:22:22 +00003465 /**
Benny Prijono5da50432006-08-07 10:24:52 +00003466 * Echo canceller options (see #pjmedia_echo_create())
3467 *
3468 * Default: 0.
3469 */
3470 unsigned ec_options;
3471
3472 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003473 * Echo canceller tail length, in miliseconds.
3474 *
Benny Prijono669643c2006-09-20 20:02:18 +00003475 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003476 */
3477 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003478
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 Prijonoc97608e2007-03-23 16:34:20 +00003508 /**
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 Prijono312aff92006-06-17 04:08:30 +00003517};
3518
3519
3520/**
3521 * Use this function to initialize media config.
3522 *
3523 * @param cfg The media config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003524 *
3525 * \par Python:
3526 * \code
3527 media_cfg = py_pjsua.media_config_default()
3528 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003529 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003530PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00003531
3532
3533/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003534 * This structure describes codec information, which can be retrieved by
3535 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00003536 */
3537typedef 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 Prijonob5388cf2007-01-04 22:45:08 +00003558 * 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 Prijonoe6ead542007-01-31 20:53:31 +00003561 *
3562 * \par Python:
3563 * In Python, this type is <tt>py_pjsua.Conf_Port_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003564 */
3565typedef 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 Prijonoe6ead542007-01-31 20:53:31 +00003599 *
3600 * \par Python:
3601 * Not applicable.
Benny Prijono312aff92006-06-17 04:08:30 +00003602 */
3603typedef 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 Prijono9fc735d2006-05-28 14:58:12 +00003621/**
3622 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003623 *
3624 * @return Maximum number of ports in the conference bridge.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003625 *
3626 * \par Python:
3627 * \code
3628 port_count = py_pjsua.conf_get_max_ports()
3629 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003630 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003631PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003632
3633
3634/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003635 * Get current number of active ports in the bridge.
3636 *
3637 * @return The number.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003638 *
3639 * \par Python:
3640 * \code
3641 count = py_pjsua.conf_get_active_ports()
3642 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003643 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003644PJ_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 Prijonoe6ead542007-01-31 20:53:31 +00003656 *
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 Prijonoeebe9af2006-06-13 22:57:13 +00003662 */
3663PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
3664 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003665
3666
3667/**
3668 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003669 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003670 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003671 * @param info Pointer to store the port info.
3672 *
3673 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003674 *
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 Prijono8b1889b2006-06-06 18:40:40 +00003680 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003681PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00003682 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003683
3684
3685/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00003686 * 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 Prijonoe6ead542007-01-31 20:53:31 +00003698 *
3699 * \par Python:
3700 * Not applicable (for now)
Benny Prijonoe909eac2006-07-27 22:04:56 +00003701 */
3702PJ_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 Prijonob5388cf2007-01-04 22:45:08 +00003709 * call this function if it registered the port manually with previous call
3710 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00003711 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003712 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00003713 *
3714 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003715 *
3716 * \par Python:
3717 * \code
3718 status = py_pjsua.conf_remove_port(port_id)
3719 * \endcode
Benny Prijonoe909eac2006-07-27 22:04:56 +00003720 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003721PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00003722
3723
3724/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003725 * 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 Prijonoe6ead542007-01-31 20:53:31 +00003739 *
3740 * \par Python:
3741 * \code
3742 status = py_pjsua.conf_connect(source, sink)
3743 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003744 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003745PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
3746 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003747
3748
3749/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003750 * 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 Prijonoe6ead542007-01-31 20:53:31 +00003756 *
3757 * \par Python:
3758 * \code
3759 status = py_pjsua.conf_disconnect(source, sink)
3760 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003761 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003762PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
3763 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003764
3765
Benny Prijono6dd967c2006-12-26 02:27:14 +00003766/**
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 Prijonoe6ead542007-01-31 20:53:31 +00003775 *
3776 * \par Python:
3777 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003778 */
3779PJ_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 Prijonoe6ead542007-01-31 20:53:31 +00003791 *
3792 * \par Python:
3793 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003794 */
3795PJ_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 Prijonoe6ead542007-01-31 20:53:31 +00003812 *
3813 * \par Python:
3814 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003815 */
3816PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
3817 unsigned *tx_level,
3818 unsigned *rx_level);
3819
Benny Prijono6dd967c2006-12-26 02:27:14 +00003820
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003821/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00003822 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003823 */
3824
Benny Prijono9fc735d2006-05-28 14:58:12 +00003825/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003826 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003827 * the conference bridge.
3828 *
3829 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00003830 * 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 Prijonoeebe9af2006-06-13 22:57:13 +00003833 * @param options Options (currently zero).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003834 * @param p_id Pointer to receive player ID.
3835 *
3836 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003837 *
3838 * \par Python:
3839 * The function returns (status, id) tuple:
3840 * \code
3841 status, id = py_pjsua.player_create(filename, options)
3842 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003843 */
3844PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003845 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003846 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003847
3848
3849/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003850 * 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 Prijonoe6ead542007-01-31 20:53:31 +00003863 *
3864 * \par Python:
3865 * Not implemented yet.
Benny Prijonoa66c3312007-01-21 23:12:40 +00003866 */
3867PJ_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 Prijonoeebe9af2006-06-13 22:57:13 +00003875 *
3876 * @param id The file player ID.
3877 *
3878 * @return Conference port ID associated with this player.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003879 *
3880 * \par Python:
3881 * \code
3882 port_id = py_pjsua.player_get_conf_port(id)
3883 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003884 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003885PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003886
3887
3888/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003889 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00003890 *
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 Prijonoe6ead542007-01-31 20:53:31 +00003895 *
3896 * \par Python:
3897 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00003898 */
3899PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_recorder_id id,
3900 pjmedia_port **p_port);
3901
3902/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003903 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003904 *
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 Prijonoe6ead542007-01-31 20:53:31 +00003910 *
3911 * \par Python:
3912 * \code
3913 status = py_pjsua.player_set_pos(id, samples)
3914 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003915 */
3916PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
3917 pj_uint32_t samples);
3918
3919
3920/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003921 * Close the file of playlist, remove the player from the bridge, and free
3922 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003923 *
3924 * @param id The file player ID.
3925 *
3926 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003927 *
3928 * \par Python:
3929 * \code
3930 status = py_pjsua.player_destroy(id)
3931 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003932 */
3933PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
3934
3935
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003936/*****************************************************************************
3937 * File recorder.
3938 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00003939
3940/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003941 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00003942 * 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 Prijonoeebe9af2006-06-13 22:57:13 +00003945 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00003946 * @param filename Output file name. The function will determine the
3947 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00003948 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00003949 * @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 Prijonoc95a0f02007-04-09 07:06:08 +00003953 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00003954 * 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 Prijonoeebe9af2006-06-13 22:57:13 +00003957 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003958 * @param p_id Pointer to receive the recorder instance.
3959 *
3960 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003961 *
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 Prijono9fc735d2006-05-28 14:58:12 +00003967 */
3968PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00003969 unsigned enc_type,
3970 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003971 pj_ssize_t max_size,
3972 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003973 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003974
3975
3976/**
3977 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003978 *
3979 * @param id The recorder ID.
3980 *
3981 * @return Conference port ID associated with this recorder.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003982 *
3983 * \par Python:
3984 * \code
3985 port_id = py_pjsua.recorder_get_conf_port(id)
3986 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003987 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003988PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003989
3990
3991/**
Benny Prijono469b1522006-12-26 03:05:17 +00003992 * 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 Prijonoe6ead542007-01-31 20:53:31 +00003998 *
3999 * \par Python:
4000 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004001 */
4002PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4003 pjmedia_port **p_port);
4004
4005
4006/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004007 * 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 Prijonoe6ead542007-01-31 20:53:31 +00004012 *
4013 * \par Python:
4014 * \code
4015 status = py_pjsua.recorder_destroy(id)
4016 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004017 */
4018PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4019
4020
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004021/*****************************************************************************
4022 * Sound devices.
4023 */
4024
Benny Prijono9fc735d2006-05-28 14:58:12 +00004025/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004026 * Enum all sound devices installed in the system.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004027 *
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 Prijonoe6ead542007-01-31 20:53:31 +00004034 *
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 Prijono9fc735d2006-05-28 14:58:12 +00004042 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004043PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4044 unsigned *count);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004045
4046
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004047
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 Prijonoe6ead542007-01-31 20:53:31 +00004059 *
4060 * \par Python:
Benny Prijonoebdf8772007-02-01 19:25:50 +00004061 * The function takes no argument and return an (integer,integer) tuple:
Benny Prijonoe6ead542007-01-31 20:53:31 +00004062 * \code
4063 capture_dev, playback_dev = py_pjsua.get_snd_dev()
4064 * \endcode
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004065 */
4066PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4067 int *playback_dev);
4068
4069
Benny Prijono9fc735d2006-05-28 14:58:12 +00004070/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004071 * 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 Prijonoe6ead542007-01-31 20:53:31 +00004078 *
4079 * \par Python:
4080 * \code
4081 status = py_pjsua.set_snd_dev(capture_dev, playback_dev)
4082 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004083 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004084PJ_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 Prijonoe6ead542007-01-31 20:53:31 +00004094 *
4095 * \par Python:
4096 * \code
4097 status = py_pjsua.set_null_snd_dev()
4098 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004099 */
4100PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4101
4102
Benny Prijonoe909eac2006-07-27 22:04:56 +00004103/**
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 Prijonoe6ead542007-01-31 20:53:31 +00004110 *
4111 * \par Python:
4112 * Not applicable (for now).
Benny Prijonoe909eac2006-07-27 22:04:56 +00004113 */
4114PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4115
4116
Benny Prijonof20687a2006-08-04 18:27:19 +00004117/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004118 * Configure the echo canceller tail length of the sound port.
Benny Prijonof20687a2006-08-04 18:27:19 +00004119 *
4120 * @param tail_ms The tail length, in miliseconds. Set to zero to
4121 * disable AEC.
Benny Prijono5da50432006-08-07 10:24:52 +00004122 * @param options Options to be passed to #pjmedia_echo_create().
4123 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004124 *
4125 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004126 *
4127 * \par Python:
4128 * \code
4129 status = py_pjsua.set_ec(tail_ms, options)
4130 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004131 */
Benny Prijono5da50432006-08-07 10:24:52 +00004132PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004133
4134
4135/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004136 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004137 *
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 Prijonoe6ead542007-01-31 20:53:31 +00004142 *
4143 * \par Python:
4144 * \code
4145 tail_ms = py_pjsua.get_ec_tail()
4146 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004147 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004148PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004149
4150
4151
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004152/*****************************************************************************
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 Prijonoe6ead542007-01-31 20:53:31 +00004165 *
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 Prijonoeebe9af2006-06-13 22:57:13 +00004171 */
4172PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4173 unsigned *count );
4174
4175
4176/**
4177 * Change codec priority.
4178 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004179 * @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 Prijonoeebe9af2006-06-13 22:57:13 +00004182 * @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 Prijonoe6ead542007-01-31 20:53:31 +00004186 *
4187 * \par Python:
4188 * \code
4189 status = py_pjsua.codec_set_priority(codec_id, priority)
4190 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004191 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004192PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004193 pj_uint8_t priority );
4194
4195
4196/**
4197 * Get codec parameters.
4198 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004199 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004200 * @param param Structure to receive codec parameters.
4201 *
4202 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004203 *
4204 * \par Python:
4205 * The Python function is experimental:
4206 * \code
4207 codec_param = py_pjsua.codec_get_param(codec_id)
4208 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004209 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004210PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004211 pjmedia_codec_param *param );
4212
4213
4214/**
4215 * Set codec parameters.
4216 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004217 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004218 * @param param Codec parameter to set.
4219 *
4220 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004221 *
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 Prijonoeebe9af2006-06-13 22:57:13 +00004228 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004229PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004230 const pjmedia_codec_param *param);
4231
4232
4233
Benny Prijono9fc735d2006-05-28 14:58:12 +00004234
Benny Prijono312aff92006-06-17 04:08:30 +00004235/**
4236 * Create UDP media transports for all the calls. This function creates
4237 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00004238 *
Benny Prijono312aff92006-06-17 04:08:30 +00004239 * @param cfg Media transport configuration. The "port" field in the
4240 * configuration is used as the start port to bind the
4241 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004242 *
4243 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004244 *
4245 * \par Python:
4246 * Not implemented yet.
Benny Prijonof3195072006-02-14 21:15:30 +00004247 */
Benny Prijono312aff92006-06-17 04:08:30 +00004248PJ_DECL(pj_status_t)
4249pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00004250
Benny Prijonodc39fe82006-05-26 12:17:46 +00004251
4252/**
Benny Prijono312aff92006-06-17 04:08:30 +00004253 * Register custom media transports to be used by calls. There must
4254 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004255 *
Benny Prijono312aff92006-06-17 04:08:30 +00004256 * @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 Prijonoe6ead542007-01-31 20:53:31 +00004264 *
4265 * \par Python:
4266 * Note applicable.
Benny Prijonodc39fe82006-05-26 12:17:46 +00004267 */
Benny Prijono312aff92006-06-17 04:08:30 +00004268PJ_DECL(pj_status_t)
4269pjsua_media_transports_attach( pjsua_media_transport tp[],
4270 unsigned count,
4271 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00004272
4273
Benny Prijono312aff92006-06-17 04:08:30 +00004274/**
4275 * @}
4276 */
4277
Benny Prijonof3195072006-02-14 21:15:30 +00004278
Benny Prijono268ca612006-02-07 12:34:11 +00004279
Benny Prijono312aff92006-06-17 04:08:30 +00004280/**
4281 * @}
4282 */
4283
Benny Prijonoe6ead542007-01-31 20:53:31 +00004284PJ_END_DECL
4285
Benny Prijono312aff92006-06-17 04:08:30 +00004286
Benny Prijono268ca612006-02-07 12:34:11 +00004287#endif /* __PJSUA_H__ */