blob: b560fca18d7655a9497978377f7efab0369c482c [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 */
477PJ_INLINE(void) pjsua_logging_config_default(pjsua_logging_config *cfg)
478{
Benny Prijonoac623b32006-07-03 15:19:31 +0000479 pj_bzero(cfg, sizeof(*cfg));
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000480
481 cfg->msg_logging = PJ_TRUE;
482 cfg->level = 5;
483 cfg->console_level = 4;
484 cfg->decor = PJ_LOG_HAS_SENDER | PJ_LOG_HAS_TIME |
485 PJ_LOG_HAS_MICRO_SEC | PJ_LOG_HAS_NEWLINE;
486}
487
488/**
489 * Use this function to duplicate logging config.
490 *
491 * @param pool Pool to use.
492 * @param dst Destination config.
493 * @param src Source config.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000494 *
495 * \par Python Syntax:
496 * Not available (for now). Ideally we should be able to just assign
497 * one config to another, but this has not been tested.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000498 */
499PJ_INLINE(void) pjsua_logging_config_dup(pj_pool_t *pool,
500 pjsua_logging_config *dst,
501 const pjsua_logging_config *src)
502{
503 pj_memcpy(dst, src, sizeof(*src));
504 pj_strdup_with_null(pool, &dst->log_filename, &src->log_filename);
505}
506
507
Benny Prijonodc39fe82006-05-26 12:17:46 +0000508
509/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000510 * This structure describes application callback to receive various event
511 * notification from PJSUA-API. All of these callbacks are OPTIONAL,
512 * although definitely application would want to implement some of
513 * the important callbacks (such as \a on_incoming_call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000514 *
515 * \par Python Syntax:
516 * This callback structure is embedded on pjsua_config structure.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000517 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000518typedef struct pjsua_callback
Benny Prijonodc39fe82006-05-26 12:17:46 +0000519{
520 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000521 * Notify application when invite state has changed.
522 * Application may then query the call info to get the
Benny Prijonoe6ead542007-01-31 20:53:31 +0000523 * detail call states by calling pjsua_call_get_info() function.
Benny Prijono0875ae82006-12-26 00:11:48 +0000524 *
525 * @param call_id The call index.
526 * @param e Event which causes the call state to change.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000527 *
528 * \par Python Syntax:
529 * \code
530 # call_id: integer
531 # e: an opaque object
532
533 def on_call_state(call_id, e):
534 return
535 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000536 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000537 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000538
539 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000540 * Notify application on incoming call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000541 *
542 * @param acc_id The account which match the incoming call.
543 * @param call_id The call id that has just been created for
544 * the call.
545 * @param rdata The incoming INVITE request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000546 *
547 * \par Python Syntax:
548 * \code
549 # acc_id: integer
550 # call_id: integer
551 # rdata: an opaque object
552
553 def on_incoming_call(acc_id, call_id, rdata):
554 return
555 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +0000556 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000557 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000558 pjsip_rx_data *rdata);
559
560 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000561 * Notify application when media state in the call has changed.
562 * Normal application would need to implement this callback, e.g.
563 * to connect the call's media to sound device.
Benny Prijono0875ae82006-12-26 00:11:48 +0000564 *
565 * @param call_id The call index.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000566 *
567 * \par Python Syntax:
568 * \code
569 # call_id: integer
570
571 def on_call_media_state(call_id):
572 return
573 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000574 */
575 void (*on_call_media_state)(pjsua_call_id call_id);
576
577 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000578 * Notify application upon incoming DTMF digits.
579 *
580 * @param call_id The call index.
581 * @param digit DTMF ASCII digit.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000582 *
583 * \par Python Syntax:
584 * \code
585 # call_id: integer
586 # digit: integer
587
588 def on_dtmf_digit(call_id, digit):
589 return
590 * \endcode
Benny Prijono0875ae82006-12-26 00:11:48 +0000591 */
592 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
593
594 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000595 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000596 * Application can decide to accept/reject transfer request
597 * by setting the code (default is 200). When this callback
598 * is not defined, the default behavior is to accept the
599 * transfer.
Benny Prijono0875ae82006-12-26 00:11:48 +0000600 *
601 * @param call_id The call index.
602 * @param dst The destination where the call will be
603 * transfered to.
604 * @param code Status code to be returned for the call transfer
605 * request. On input, it contains status code 200.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000606 *
607 * \par Python Syntax:
608 * \code
609 # call_id: integer
610 # dst: string
611 # code: integer
612
613 def on_call_transfer_request(call_id, dst, code):
614 return code
615
616 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000617 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000618 void (*on_call_transfer_request)(pjsua_call_id call_id,
619 const pj_str_t *dst,
620 pjsip_status_code *code);
621
622 /**
623 * Notify application of the status of previously sent call
624 * transfer request. Application can monitor the status of the
625 * call transfer request, for example to decide whether to
626 * terminate existing call.
627 *
628 * @param call_id Call ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000629 * @param st_code Status progress of the transfer request.
630 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000631 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000632 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000633 * this callback is the final status.
634 * @param p_cont Initially will be set to non-zero, application
635 * can set this to FALSE if it no longer wants
636 * to receie further notification (for example,
637 * after it hangs up the call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000638 *
639 * \par Python Syntax:
640 * \code
641 # call_id: integer
642 # st_code: integer
643 # st_text: string
644 # final: integer
645 # cont: integer
646
647 # return: cont
648
649 def on_call_transfer_status(call_id, st_code, st_text, final, cont):
650 return cont
651 * \endcode
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000652 */
653 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000654 int st_code,
655 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000656 pj_bool_t final,
657 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000658
659 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000660 * Notify application about incoming INVITE with Replaces header.
661 * Application may reject the request by setting non-2xx code.
662 *
663 * @param call_id The call ID to be replaced.
664 * @param rdata The incoming INVITE request to replace the call.
665 * @param st_code Status code to be set by application. Application
666 * should only return a final status (200-699).
667 * @param st_text Optional status text to be set by application.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000668 *
669 * \par Python Syntax:
670 * \code
671 # call_id: integer
672 # rdata: an opaque object
673 # st_code: integer
674 # st_text: string
675
676 # return: (st_code, st_text) tuple
677
678 def on_call_replace_request(call_id, rdata, st_code, st_text):
679 return st_code, st_text
680 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000681 */
682 void (*on_call_replace_request)(pjsua_call_id call_id,
683 pjsip_rx_data *rdata,
684 int *st_code,
685 pj_str_t *st_text);
686
687 /**
688 * Notify application that an existing call has been replaced with
689 * a new call. This happens when PJSUA-API receives incoming INVITE
690 * request with Replaces header.
691 *
692 * After this callback is called, normally PJSUA-API will disconnect
693 * \a old_call_id and establish \a new_call_id.
694 *
695 * @param old_call_id Existing call which to be replaced with the
696 * new call.
697 * @param new_call_id The new call.
698 * @param rdata The incoming INVITE with Replaces request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000699 *
700 * \par Python Syntax:
701 * \code
702 # old_call_id: integer
703 # new_call_id: integer
704
705 def on_call_replaced(old_call_id, new_call_id):
706 return
707 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000708 */
709 void (*on_call_replaced)(pjsua_call_id old_call_id,
710 pjsua_call_id new_call_id);
711
712
713 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000714 * Notify application when registration status has changed.
715 * Application may then query the account info to get the
716 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000717 *
718 * @param acc_id Account ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000719 *
720 * \par Python Syntax:
721 * \code
722 # acc_id: account ID (integer)
723
724 def on_reg_state(acc_id):
725 return
726 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000727 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000728 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000729
730 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000731 * Notify application when the buddy state has changed.
732 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000733 *
734 * @param buddy_id The buddy id.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000735 *
736 * \par Python Syntax:
737 * \code
738 # buddy_id: integer
739
740 def on_buddy_state(buddy_id):
741 return
742 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000743 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000744 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000745
746 /**
747 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000748 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000749 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000750 *
Benny Prijonobbeb3992007-05-21 13:48:35 +0000751 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
752 * passed as one of the argument.
753 *
Benny Prijono0875ae82006-12-26 00:11:48 +0000754 * @param call_id Containts the ID of the call where the IM was
755 * sent, or PJSUA_INVALID_ID if the IM was sent
756 * outside call context.
757 * @param from URI of the sender.
758 * @param to URI of the destination message.
759 * @param contact The Contact URI of the sender, if present.
760 * @param mime_type MIME type of the message.
761 * @param body The message content.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000762 *
763 * \par Python Syntax:
764 * \code
765 # call_id: integer
766 # from: string
767 # to: string
768 # contact: string
769 # mime_type: string
770 # body: string
771
772 def on_pager(call_id, from, to, contact, mime_type, body):
773 return
774 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000775 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000776 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
777 const pj_str_t *to, const pj_str_t *contact,
778 const pj_str_t *mime_type, const pj_str_t *body);
779
780 /**
Benny Prijonobbeb3992007-05-21 13:48:35 +0000781 * This is the alternative version of the \a on_pager() callback with
782 * \a pjsip_rx_data argument.
783 *
784 * @param call_id Containts the ID of the call where the IM was
785 * sent, or PJSUA_INVALID_ID if the IM was sent
786 * outside call context.
787 * @param from URI of the sender.
788 * @param to URI of the destination message.
789 * @param contact The Contact URI of the sender, if present.
790 * @param mime_type MIME type of the message.
791 * @param body The message content.
792 * @param rdata The incoming MESSAGE request.
793 */
794 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
795 const pj_str_t *to, const pj_str_t *contact,
796 const pj_str_t *mime_type, const pj_str_t *body,
797 pjsip_rx_data *rdata);
798
799 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000800 * Notify application about the delivery status of outgoing pager
801 * request.
802 *
803 * @param call_id Containts the ID of the call where the IM was
804 * sent, or PJSUA_INVALID_ID if the IM was sent
805 * outside call context.
806 * @param to Destination URI.
807 * @param body Message body.
808 * @param user_data Arbitrary data that was specified when sending
809 * IM message.
810 * @param status Delivery status.
811 * @param reason Delivery status reason.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000812 *
813 * \par Python Syntax
814 * \code
815 # call_id: integer
816 # to: string
817 # body: string
818 # user_data: string
819 # status: integer
820 # reason: string
821
822 def on_pager_status(call_id, to, body, user_data, status, reason):
823 return
824 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000825 */
826 void (*on_pager_status)(pjsua_call_id call_id,
827 const pj_str_t *to,
828 const pj_str_t *body,
829 void *user_data,
830 pjsip_status_code status,
831 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000832
833 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000834 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +0000835 *
836 * @param call_id Containts the ID of the call where the IM was
837 * sent, or PJSUA_INVALID_ID if the IM was sent
838 * outside call context.
839 * @param from URI of the sender.
840 * @param to URI of the destination message.
841 * @param contact The Contact URI of the sender, if present.
842 * @param is_typing Non-zero if peer is typing, or zero if peer
843 * has stopped typing a message.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000844 *
845 * \par Python Syntax
846 * \code
847 # call_id: string
848 # from: string
849 # to: string
850 # contact: string
851 # is_typing: integer
852
853 def on_typing(call_id, from, to, contact, is_typing):
854 return
855 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000856 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000857 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
858 const pj_str_t *to, const pj_str_t *contact,
859 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000860
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000861} pjsua_callback;
862
863
864
Benny Prijonodc39fe82006-05-26 12:17:46 +0000865
866/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000867 * This structure describes the settings to control the API and
868 * user agent behavior, and can be specified when calling #pjsua_init().
869 * Before setting the values, application must call #pjsua_config_default()
870 * to initialize this structure with the default values.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000871 *
872 * \par Python Sample Syntax:
873 * The pjsua_config type in Python is <tt>py_pjsua.Config</tt>. Application
874 * creates the instance by calling <tt>py_pjsua.config_default()</tt>:
875 * \code
876 cfg = py_pjsua.config_default()
877 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000878 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000879typedef struct pjsua_config
880{
881
882 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000883 * Maximum calls to support (default: 4). The value specified here
884 * must be smaller than the compile time maximum settings
885 * PJSUA_MAX_CALLS, which by default is 32. To increase this
886 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
887 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000888 */
889 unsigned max_calls;
890
891 /**
892 * Number of worker threads. Normally application will want to have at
893 * least one worker thread, unless when it wants to poll the library
894 * periodically, which in this case the worker thread can be set to
895 * zero.
896 */
897 unsigned thread_cnt;
898
899 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +0000900 * Number of nameservers. If no name server is configured, the SIP SRV
901 * resolution would be disabled, and domain will be resolved with
902 * standard pj_gethostbyname() function.
903 */
904 unsigned nameserver_count;
905
906 /**
907 * Array of nameservers to be used by the SIP resolver subsystem.
908 * The order of the name server specifies the priority (first name
909 * server will be used first, unless it is not reachable).
910 */
911 pj_str_t nameserver[4];
912
913 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000914 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000915 */
916 unsigned outbound_proxy_cnt;
917
918 /**
919 * Specify the URL of outbound proxies to visit for all outgoing requests.
920 * The outbound proxies will be used for all accounts, and it will
921 * be used to build the route set for outgoing requests. The final
922 * route set for outgoing requests will consists of the outbound proxies
923 * and the proxy configured in the account.
924 */
925 pj_str_t outbound_proxy[4];
926
Benny Prijonoc97608e2007-03-23 16:34:20 +0000927 /**
Benny Prijonoebbf6892007-03-24 17:37:25 +0000928 * Specify domain name to be resolved with DNS SRV resolution to get the
929 * address of the STUN servers. Alternatively application may specify
930 * \a stun_host and \a stun_relay_host instead.
931 *
932 * If DNS SRV resolution failed for this domain, then DNS A resolution
933 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +0000934 */
Benny Prijonoebbf6892007-03-24 17:37:25 +0000935 pj_str_t stun_domain;
936
937 /**
Benny Prijonoaf09dc32007-04-22 12:48:30 +0000938 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
939 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +0000940 */
941 pj_str_t stun_host;
942
943 /**
944 * Specify STUN relay server to be used.
945 */
946 pj_str_t stun_relay_host;
Benny Prijonoc97608e2007-03-23 16:34:20 +0000947
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000948 /**
949 * Number of credentials in the credential array.
950 */
951 unsigned cred_count;
952
953 /**
954 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +0000955 * and can be used to authenticate against outbound proxies. If the
956 * credential is specific to the account, then application should set
957 * the credential in the pjsua_acc_config rather than the credential
958 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000959 */
960 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
961
962 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000963 * Application callback to receive various event notifications from
964 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000965 */
966 pjsua_callback cb;
967
Benny Prijono56315612006-07-18 14:39:40 +0000968 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000969 * Optional user agent string (default empty). If it's empty, no
970 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +0000971 */
972 pj_str_t user_agent;
973
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000974} pjsua_config;
975
976
977/**
978 * Use this function to initialize pjsua config.
979 *
980 * @param cfg pjsua config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000981 *
982 * \par Python Sample Syntax:
983 * The corresponding Python function creates an instance of the config and
984 * initializes it to the default settings:
985 * \code
986 cfg = py_pjsua.config_default()
987 * \endcode
988
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000989 */
990PJ_INLINE(void) pjsua_config_default(pjsua_config *cfg)
991{
Benny Prijonoac623b32006-07-03 15:19:31 +0000992 pj_bzero(cfg, sizeof(*cfg));
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000993
994 cfg->max_calls = 4;
995 cfg->thread_cnt = 1;
996}
997
998
999/**
1000 * Duplicate credential.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001001 *
1002 * @param pool The memory pool.
1003 * @param dst Destination credential.
1004 * @param src Source credential.
1005 *
1006 * \par Python:
1007 * Not applicable (for now). Probably we could just assign one credential
1008 * variable to another, but this has not been tested.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001009 */
1010PJ_INLINE(void) pjsip_cred_dup( pj_pool_t *pool,
1011 pjsip_cred_info *dst,
1012 const pjsip_cred_info *src)
1013{
1014 pj_strdup_with_null(pool, &dst->realm, &src->realm);
1015 pj_strdup_with_null(pool, &dst->scheme, &src->scheme);
1016 pj_strdup_with_null(pool, &dst->username, &src->username);
1017 pj_strdup_with_null(pool, &dst->data, &src->data);
1018
1019}
1020
1021
1022/**
1023 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001024 *
1025 * @param pool The pool to get memory from.
1026 * @param dst Destination config.
1027 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001028 */
1029PJ_INLINE(void) pjsua_config_dup(pj_pool_t *pool,
1030 pjsua_config *dst,
1031 const pjsua_config *src)
1032{
1033 unsigned i;
1034
1035 pj_memcpy(dst, src, sizeof(*src));
1036
1037 for (i=0; i<src->outbound_proxy_cnt; ++i) {
1038 pj_strdup_with_null(pool, &dst->outbound_proxy[i],
1039 &src->outbound_proxy[i]);
1040 }
1041
1042 for (i=0; i<src->cred_count; ++i) {
1043 pjsip_cred_dup(pool, &dst->cred_info[i], &src->cred_info[i]);
1044 }
Benny Prijono56315612006-07-18 14:39:40 +00001045
1046 pj_strdup_with_null(pool, &dst->user_agent, &src->user_agent);
Benny Prijonoebbf6892007-03-24 17:37:25 +00001047 pj_strdup_with_null(pool, &dst->stun_domain, &src->stun_domain);
1048 pj_strdup_with_null(pool, &dst->stun_host, &src->stun_host);
1049 pj_strdup_with_null(pool, &dst->stun_relay_host, &src->stun_relay_host);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001050}
1051
1052
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001053
1054/**
1055 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001056 * outgoing SIP message. It can (optionally) be specified for example
1057 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1058 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1059 *
1060 * Application MUST call #pjsua_msg_data_init() to initialize this
1061 * structure before setting its values.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001062 *
1063 * \par Python Syntax
1064 * The data type in Python is <tt>py_pjsua.Msg_Data</tt>. Application is
1065 * recommended to instantiate the structure by using this construct:
1066 * \code
1067 msg_data = py_pjsua.msg_data_init()
1068 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001069 */
1070typedef struct pjsua_msg_data
1071{
1072 /**
1073 * Additional message headers as linked list.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001074 *
1075 * \par Python:
1076 * This field is implemented as string linked-list in Python, where each
1077 * string describes the header. For example:
1078 \code
1079 msg_data = py_pjsua.Msg_Data()
1080 msg_data.hdr_list = ["Subject: Hello py_pjsua!", "Priority: very low"]
1081 \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001082 */
1083 pjsip_hdr hdr_list;
1084
1085 /**
1086 * MIME type of optional message body.
1087 */
1088 pj_str_t content_type;
1089
1090 /**
1091 * Optional message body.
1092 */
1093 pj_str_t msg_body;
1094
1095} pjsua_msg_data;
1096
1097
1098/**
1099 * Initialize message data.
1100 *
1101 * @param msg_data Message data to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001102 *
1103 * \par Python
1104 * The corresponding Python function creates and initializes the structure:
1105 * \code
1106 msg_data = py_pjsua.msg_data_init()
1107 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001108 */
1109PJ_INLINE(void) pjsua_msg_data_init(pjsua_msg_data *msg_data)
1110{
Benny Prijonoac623b32006-07-03 15:19:31 +00001111 pj_bzero(msg_data, sizeof(*msg_data));
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001112 pj_list_init(&msg_data->hdr_list);
1113}
Benny Prijono8b1889b2006-06-06 18:40:40 +00001114
Benny Prijono268ca612006-02-07 12:34:11 +00001115
Benny Prijono268ca612006-02-07 12:34:11 +00001116
1117/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001118 * Instantiate pjsua application. Application must call this function before
1119 * calling any other functions, to make sure that the underlying libraries
1120 * are properly initialized. Once this function has returned success,
1121 * application must call pjsua_destroy() before quitting.
1122 *
1123 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001124 *
1125 * \par Python:
1126 * \code
1127 status = py_pjsua.create()
1128 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001129 */
1130PJ_DECL(pj_status_t) pjsua_create(void);
1131
1132
Benny Prijonoe6ead542007-01-31 20:53:31 +00001133/* Forward declaration */
1134typedef struct pjsua_media_config pjsua_media_config;
1135
1136
Benny Prijonodc39fe82006-05-26 12:17:46 +00001137/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001138 * Initialize pjsua with the specified settings. All the settings are
1139 * optional, and the default values will be used when the config is not
1140 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001141 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001142 * Note that #pjsua_create() MUST be called before calling this function.
1143 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001144 * @param ua_cfg User agent configuration.
1145 * @param log_cfg Optional logging configuration.
1146 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001147 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001148 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001149 *
1150 * \par Python:
1151 * The function is similar in Python:
1152 * \code
1153 status = py_pjsua.init(ua_cfg, log_cfg, media_cfg)
1154 * \endcode
1155 * Note that \a ua_cfg, \a log_cfg, and \a media_cfg are optional, and
1156 * the Python script may pass None if it doesn't want to configure the
1157 * setting.
Benny Prijono268ca612006-02-07 12:34:11 +00001158 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001159PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1160 const pjsua_logging_config *log_cfg,
1161 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001162
1163
1164/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001165 * Application is recommended to call this function after all initialization
1166 * is done, so that the library can do additional checking set up
1167 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001168 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001169 * Application may call this function anytime after #pjsua_init().
1170 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001171 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001172 *
1173 * \par Python:
1174 * The function is similar in Python:
1175 * \code
1176 status = py_pjsua.start()
1177 * \endcode
Benny Prijonoccf95622006-02-07 18:48:01 +00001178 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001179PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001180
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001181
Benny Prijonoccf95622006-02-07 18:48:01 +00001182/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001183 * Destroy pjsua. Application is recommended to perform graceful shutdown
1184 * before calling this function (such as unregister the account from the SIP
1185 * server, terminate presense subscription, and hangup active calls), however,
1186 * this function will do all of these if it finds there are active sessions
1187 * that need to be terminated. This function will approximately block for
1188 * one second to wait for replies from remote.
1189 *
1190 * Application.may safely call this function more than once if it doesn't
1191 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001192 *
1193 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001194 *
1195 * \par Python:
1196 * The function is similar in Python:
1197 * \code
1198 status = py_pjsua.destroy()
1199 * \endcode
Benny Prijono268ca612006-02-07 12:34:11 +00001200 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001201PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001202
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001203
Benny Prijono9fc735d2006-05-28 14:58:12 +00001204/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001205 * Poll pjsua for events, and if necessary block the caller thread for
1206 * the specified maximum interval (in miliseconds).
1207 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001208 * Application doesn't normally need to call this function if it has
1209 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1210 * because polling then will be done by these worker threads instead.
1211 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001212 * @param msec_timeout Maximum time to wait, in miliseconds.
1213 *
1214 * @return The number of events that have been handled during the
1215 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001216 * can retrieve the error as (status = -return_value).
1217 *
1218 * \par Python:
1219 * The function is similar in Python:
1220 * \code
1221 n = py_pjsua.handle_events(msec_timeout)
1222 * \endcode
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001223 */
1224PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1225
1226
1227/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001228 * Create memory pool to be used by the application. Once application
1229 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001230 *
1231 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001232 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001233 * @param increment Increment size.
1234 *
1235 * @return The pool, or NULL when there's no memory.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001236 *
1237 * \par Python:
1238 * Python script may also create a pool object from the script:
1239 * \code
1240 pool = py_pjsua.pool_create(name, init_size, increment)
1241 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001242 */
1243PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1244 pj_size_t increment);
1245
1246
1247/**
1248 * Application can call this function at any time (after pjsua_create(), of
1249 * course) to change logging settings.
1250 *
1251 * @param c Logging configuration.
1252 *
1253 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001254 *
1255 * \par Python:
1256 * The function is similar in Python:
1257 * \code
1258 status = py_pjsua.reconfigure_logging(log_cfg)
1259 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001260 */
1261PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1262
1263
1264/**
1265 * Internal function to get SIP endpoint instance of pjsua, which is
1266 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001267 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001268 *
1269 * @return SIP endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001270 *
1271 * \par Python:
1272 * Application may retrieve the SIP endpoint instance:
1273 * \code
1274 endpt = py_pjsua.get_pjsip_endpt()
1275 * \endcode
1276 * However currently the object is just an opaque object and does not have
1277 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001278 */
1279PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1280
1281/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001282 * Internal function to get media endpoint instance.
1283 * Only valid after #pjsua_init() is called.
1284 *
1285 * @return Media endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001286 *
1287 * \par Python:
1288 * Application may retrieve the media endpoint instance:
1289 * \code
1290 endpt = py_pjsua.get_pjmedia_endpt()
1291 * \endcode
1292 * However currently the object is just an opaque object and does not have
1293 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001294 */
1295PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1296
Benny Prijono97b87172006-08-24 14:25:14 +00001297/**
1298 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001299 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001300 *
1301 * @return Pool factory currently used by PJSUA.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001302 *
1303 * \par Python:
1304 * Application may retrieve the pool factory instance:
1305 * \code
1306 endpt = py_pjsua.get_pool_factory()
1307 * \endcode
1308 * However currently the object is just an opaque object and does not have
1309 * any use for Python scripts.
Benny Prijono97b87172006-08-24 14:25:14 +00001310 */
1311PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1312
1313
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001314
1315/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001316 * Utilities.
1317 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001318 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001319
1320/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001321 * This is a utility function to verify that valid SIP url is given. If the
1322 * URL is valid, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001323 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001324 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001325 *
1326 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001327 *
1328 * \par Python:
1329 * \code
1330 status = py_pjsua.verify_sip_url(url)
1331 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001332 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001333PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001334
1335
1336/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001337 * This is a utility function to display error message for the specified
1338 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001339 *
1340 * @param sender The log sender field.
1341 * @param title Message title for the error.
1342 * @param status Status code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001343 *
1344 * \par Python:
1345 * \code
1346 py_pjsua.perror(sender, title, status)
1347 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001348 */
1349PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1350 pj_status_t status);
1351
1352
Benny Prijonoda9785b2007-04-02 20:43:06 +00001353/**
1354 * This is a utility function to dump the stack states to log, using
1355 * verbosity level 3.
1356 *
1357 * @param detail Will print detailed output (such as list of
1358 * SIP transactions) when non-zero.
1359 */
1360PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001361
1362/**
1363 * @}
1364 */
1365
1366
1367
1368/*****************************************************************************
1369 * TRANSPORT API
1370 */
1371
1372/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001373 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001374 * @ingroup PJSUA_LIB
1375 * @brief API for managing SIP transports
1376 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001377 *
1378 * PJSUA-API supports creating multiple transport instances, for example UDP,
1379 * TCP, and TLS transport. SIP transport must be created before adding an
1380 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001381 */
1382
1383
Benny Prijonoe6ead542007-01-31 20:53:31 +00001384/** SIP transport identification.
1385 */
Benny Prijono312aff92006-06-17 04:08:30 +00001386typedef int pjsua_transport_id;
1387
1388
1389/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001390 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001391 * and media. Before setting some values to this structure, application
1392 * MUST call #pjsua_transport_config_default() to initialize its
1393 * values with default settings.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001394 *
1395 * \par Python:
1396 * The data type in Python is <tt>py_pjsua.Transport_Config</tt>,
1397 * although application can just do this to create the instance:
1398 * \code
1399 transport_cfg = py_pjsua.transport_config_default()
1400 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001401 */
1402typedef struct pjsua_transport_config
1403{
1404 /**
1405 * UDP port number to bind locally. This setting MUST be specified
1406 * even when default port is desired. If the value is zero, the
1407 * transport will be bound to any available port, and application
1408 * can query the port by querying the transport info.
1409 */
1410 unsigned port;
1411
1412 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001413 * Optional address to advertise as the address of this transport.
1414 * Application can specify any address or hostname for this field,
1415 * for example it can point to one of the interface address in the
1416 * system, or it can point to the public address of a NAT router
1417 * where port mappings have been configured for the application.
1418 *
1419 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001420 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001421 pj_str_t public_addr;
1422
1423 /**
1424 * Optional address where the socket should be bound to. This option
1425 * SHOULD only be used to selectively bind the socket to particular
1426 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1427 * published address of a transport (the public_addr field should be
1428 * used for that purpose).
1429 *
1430 * Note that unlike public_addr field, the address (or hostname) here
1431 * MUST correspond to the actual interface address in the host, since
1432 * this address will be specified as bind() argument.
1433 */
1434 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001435
1436 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001437 * This specifies TLS settings for TLS transport. It is only be used
1438 * when this transport config is being used to create a SIP TLS
1439 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001440 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001441 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001442
Benny Prijono312aff92006-06-17 04:08:30 +00001443} pjsua_transport_config;
1444
1445
1446/**
1447 * Call this function to initialize UDP config with default values.
1448 *
1449 * @param cfg The UDP config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001450 *
1451 * \par Python:
1452 * The corresponding Python function is rather different:
1453 * \code
1454 transport_cfg = py_pjsua.transport_config_default()
1455 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001456 */
1457PJ_INLINE(void) pjsua_transport_config_default(pjsua_transport_config *cfg)
1458{
Benny Prijonoac623b32006-07-03 15:19:31 +00001459 pj_bzero(cfg, sizeof(*cfg));
Benny Prijonof3bbc132006-12-25 06:43:59 +00001460 pjsip_tls_setting_default(&cfg->tls_setting);
Benny Prijono312aff92006-06-17 04:08:30 +00001461}
1462
1463
1464/**
Benny Prijono312aff92006-06-17 04:08:30 +00001465 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001466 *
1467 * @param pool The pool.
1468 * @param dst The destination config.
1469 * @param src The source config.
1470 *
1471 * \par Python:
1472 * Not applicable. One should be able to just copy one variable instance
1473 * to another in Python.
Benny Prijono312aff92006-06-17 04:08:30 +00001474 */
1475PJ_INLINE(void) pjsua_transport_config_dup(pj_pool_t *pool,
1476 pjsua_transport_config *dst,
1477 const pjsua_transport_config *src)
1478{
Benny Prijonoc97608e2007-03-23 16:34:20 +00001479 PJ_UNUSED_ARG(pool);
Benny Prijono312aff92006-06-17 04:08:30 +00001480 pj_memcpy(dst, src, sizeof(*src));
Benny Prijono312aff92006-06-17 04:08:30 +00001481}
1482
1483
1484
1485/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001486 * This structure describes transport information returned by
1487 * #pjsua_transport_get_info() function.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001488 *
1489 * \par Python:
1490 * The corresponding data type in Python is <tt>py_pjsua.Transport_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001491 */
1492typedef struct pjsua_transport_info
1493{
1494 /**
1495 * PJSUA transport identification.
1496 */
1497 pjsua_transport_id id;
1498
1499 /**
1500 * Transport type.
1501 */
1502 pjsip_transport_type_e type;
1503
1504 /**
1505 * Transport type name.
1506 */
1507 pj_str_t type_name;
1508
1509 /**
1510 * Transport string info/description.
1511 */
1512 pj_str_t info;
1513
1514 /**
1515 * Transport flag (see ##pjsip_transport_flags_e).
1516 */
1517 unsigned flag;
1518
1519 /**
1520 * Local address length.
1521 */
1522 unsigned addr_len;
1523
1524 /**
1525 * Local/bound address.
1526 */
1527 pj_sockaddr local_addr;
1528
1529 /**
1530 * Published address (or transport address name).
1531 */
1532 pjsip_host_port local_name;
1533
1534 /**
1535 * Current number of objects currently referencing this transport.
1536 */
1537 unsigned usage_count;
1538
1539
1540} pjsua_transport_info;
1541
1542
1543/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001544 * Create and start a new SIP transport according to the specified
1545 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001546 *
1547 * @param type Transport type.
1548 * @param cfg Transport configuration.
1549 * @param p_id Optional pointer to receive transport ID.
1550 *
1551 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001552 *
1553 * \par Python:
1554 * The corresponding Python function returns (status,id) tuple:
1555 * \code
1556 status, transport_id = py_pjsua.transport_create(type, cfg)
1557 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001558 */
1559PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1560 const pjsua_transport_config *cfg,
1561 pjsua_transport_id *p_id);
1562
1563/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001564 * Register transport that has been created by application. This function
1565 * is useful if application wants to implement custom SIP transport and use
1566 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001567 *
1568 * @param tp Transport instance.
1569 * @param p_id Optional pointer to receive transport ID.
1570 *
1571 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001572 *
1573 * \par Python:
1574 * Not applicable (for now), because one cannot create a custom transport
1575 * from Python script.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001576 */
1577PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1578 pjsua_transport_id *p_id);
1579
1580
1581/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001582 * Enumerate all transports currently created in the system. This function
1583 * will return all transport IDs, and application may then call
1584 * #pjsua_transport_get_info() function to retrieve detailed information
1585 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001586 *
1587 * @param id Array to receive transport ids.
1588 * @param count In input, specifies the maximum number of elements.
1589 * On return, it contains the actual number of elements.
1590 *
1591 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001592 *
1593 * \par Python:
1594 * The function returns list of integers representing transport ids:
1595 * \code
1596 [int] = py_pjsua.enum_transports()
1597 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001598 */
1599PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1600 unsigned *count );
1601
1602
1603/**
1604 * Get information about transports.
1605 *
1606 * @param id Transport ID.
1607 * @param info Pointer to receive transport info.
1608 *
1609 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001610 *
1611 * \par Python:
1612 * \code
1613 transport_info = py_pjsua.transport_get_info(id)
1614 * \endcode
1615 * The Python function returns None on error.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001616 */
1617PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1618 pjsua_transport_info *info);
1619
1620
1621/**
1622 * Disable a transport or re-enable it. By default transport is always
1623 * enabled after it is created. Disabling a transport does not necessarily
1624 * close the socket, it will only discard incoming messages and prevent
1625 * the transport from being used to send outgoing messages.
1626 *
1627 * @param id Transport ID.
1628 * @param enabled Non-zero to enable, zero to disable.
1629 *
1630 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001631 *
1632 * \par Python:
1633 * \code
1634 status = py_pjsua.transport_set_enable(id, enabled)
1635 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001636 */
1637PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1638 pj_bool_t enabled);
1639
1640
1641/**
1642 * Close the transport. If transport is forcefully closed, it will be
1643 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00001644 * transport may not terminate properly (it may even crash). Otherwise,
1645 * the system will wait until all transactions are closed while preventing
1646 * new users from using the transport, and will close the transport when
1647 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001648 *
1649 * @param id Transport ID.
1650 * @param force Non-zero to immediately close the transport. This
1651 * is not recommended!
1652 *
1653 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001654 *
1655 * \par Python:
1656 * \code
1657 status = py_pjsua.transport_close(id, force)
1658 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001659 */
1660PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1661 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001662
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001663/**
Benny Prijono312aff92006-06-17 04:08:30 +00001664 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001665 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001666
1667
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001668
1669
1670/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001671 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001672 */
1673
Benny Prijono312aff92006-06-17 04:08:30 +00001674
1675/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001676 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001677 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001678 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001679 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001680 *
Benny Prijono312aff92006-06-17 04:08:30 +00001681 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001682 * using the application. In SIP terms, the identity is used as the <b>From</b>
1683 * header in outgoing requests.
1684 *
1685 * PJSUA-API supports creating and managing multiple accounts. The maximum
1686 * number of accounts is limited by a compile time constant
1687 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001688 *
1689 * Account may or may not have client registration associated with it.
1690 * An account is also associated with <b>route set</b> and some <b>authentication
1691 * credentials</b>, which are used when sending SIP request messages using the
1692 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00001693 * will be reported to remote peer when they subscribe to the account's
1694 * presence, or which is published to a presence server if presence
1695 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00001696 *
1697 * At least one account MUST be created in the application. If no user
1698 * association is required, application can create a userless account by
1699 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00001700 * instead of a particular user, and it correspond with a particular
1701 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00001702 *
1703 * Also one account must be set as the <b>default account</b>, which is used as
1704 * the account to use when PJSUA fails to match a request with any other
1705 * accounts.
1706 *
1707 * When sending outgoing SIP requests (such as making calls or sending
1708 * instant messages), normally PJSUA requires the application to specify
1709 * which account to use for the request. If no account is specified,
1710 * PJSUA may be able to select the account by matching the destination
1711 * domain name, and fall back to default account when no match is found.
1712 */
1713
1714/**
1715 * Maximum accounts.
1716 */
1717#ifndef PJSUA_MAX_ACC
1718# define PJSUA_MAX_ACC 8
1719#endif
1720
1721
1722/**
1723 * Default registration interval.
1724 */
1725#ifndef PJSUA_REG_INTERVAL
1726# define PJSUA_REG_INTERVAL 55
1727#endif
1728
1729
1730/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001731 * Default PUBLISH expiration
1732 */
1733#ifndef PJSUA_PUBLISH_EXPIRATION
1734# define PJSUA_PUBLISH_EXPIRATION 600
1735#endif
1736
1737
1738/**
Benny Prijono093d3022006-09-24 00:07:11 +00001739 * Default account priority.
1740 */
1741#ifndef PJSUA_DEFAULT_ACC_PRIORITY
1742# define PJSUA_DEFAULT_ACC_PRIORITY 0
1743#endif
1744
1745
1746/**
Benny Prijono8058a622007-06-08 04:37:05 +00001747 * This macro specifies the URI scheme to use in Contact header
1748 * when secure transport such as TLS is used. Application can specify
1749 * either "sip" or "sips".
1750 */
1751#ifndef PJSUA_SECURE_SCHEME
1752# define PJSUA_SECURE_SCHEME "sips"
1753#endif
1754
1755
1756/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001757 * This structure describes account configuration to be specified when
1758 * adding a new account with #pjsua_acc_add(). Application MUST initialize
1759 * this structure first by calling #pjsua_acc_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00001760 *
1761 * \par Python:
1762 * The data type in Python is <tt>py_pjsua.Acc_Config</tt>, but normally
1763 * application can just use the snippet below to create and initialize
1764 * the account config:
1765 * \code
1766 acc_cfg = py_pjsua.acc_config_default()
1767 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001768 */
1769typedef struct pjsua_acc_config
1770{
Benny Prijono093d3022006-09-24 00:07:11 +00001771 /**
1772 * Account priority, which is used to control the order of matching
1773 * incoming/outgoing requests. The higher the number means the higher
1774 * the priority is, and the account will be matched first.
1775 */
1776 int priority;
1777
Benny Prijono312aff92006-06-17 04:08:30 +00001778 /**
1779 * The full SIP URL for the account. The value can take name address or
1780 * URL format, and will look something like "sip:account@serviceprovider".
1781 *
1782 * This field is mandatory.
1783 */
1784 pj_str_t id;
1785
1786 /**
1787 * This is the URL to be put in the request URI for the registration,
1788 * and will look something like "sip:serviceprovider".
1789 *
1790 * This field should be specified if registration is desired. If the
1791 * value is empty, no account registration will be performed.
1792 */
1793 pj_str_t reg_uri;
1794
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001795 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001796 * If this flag is set, the presence information of this account will
1797 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001798 */
1799 pj_bool_t publish_enabled;
1800
Benny Prijono312aff92006-06-17 04:08:30 +00001801 /**
1802 * Optional URI to be put as Contact for this account. It is recommended
1803 * that this field is left empty, so that the value will be calculated
1804 * automatically based on the transport address.
1805 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00001806 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00001807
1808 /**
1809 * Number of proxies in the proxy array below.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001810 *
1811 * \par Python:
1812 * Not applicable, as \a proxy is implemented as list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001813 */
1814 unsigned proxy_cnt;
1815
1816 /**
1817 * Optional URI of the proxies to be visited for all outgoing requests
1818 * that are using this account (REGISTER, INVITE, etc). Application need
1819 * to specify these proxies if the service provider requires that requests
1820 * destined towards its network should go through certain proxies first
1821 * (for example, border controllers).
1822 *
1823 * These proxies will be put in the route set for this account, with
1824 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00001825 * first). If global outbound proxies are configured in pjsua_config,
1826 * then these account proxies will be placed after the global outbound
1827 * proxies in the routeset.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001828 *
1829 * \par Python:
1830 * This will be list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001831 */
1832 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
1833
1834 /**
1835 * Optional interval for registration, in seconds. If the value is zero,
1836 * default interval will be used (PJSUA_REG_INTERVAL, 55 seconds).
1837 */
1838 unsigned reg_timeout;
1839
1840 /**
1841 * Number of credentials in the credential array.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001842 *
1843 * \par Python:
1844 * Not applicable, since \a cred_info is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00001845 */
1846 unsigned cred_count;
1847
1848 /**
1849 * Array of credentials. If registration is desired, normally there should
1850 * be at least one credential specified, to successfully authenticate
1851 * against the service provider. More credentials can be specified, for
1852 * example when the requests are expected to be challenged by the
1853 * proxies in the route set.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001854 *
1855 * \par Python:
1856 * This field is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00001857 */
1858 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1859
Benny Prijono62c5c5b2007-01-13 23:22:40 +00001860 /**
1861 * Optionally bind this account to specific transport. This normally is
1862 * not a good idea, as account should be able to send requests using
1863 * any available transports according to the destination. But some
1864 * application may want to have explicit control over the transport to
1865 * use, so in that case it can set this field.
1866 *
1867 * Default: -1 (PJSUA_INVALID_ID)
1868 *
1869 * @see pjsua_acc_set_transport()
1870 */
1871 pjsua_transport_id transport_id;
1872
Benny Prijono312aff92006-06-17 04:08:30 +00001873} pjsua_acc_config;
1874
1875
1876/**
1877 * Call this function to initialize account config with default values.
1878 *
1879 * @param cfg The account config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001880 *
1881 * \par Python:
1882 * In Python, this function both creates and initializes the account
1883 * config:
1884 * \code
1885 acc_cfg = py_pjsua.acc_config_default()
1886 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001887 */
1888PJ_INLINE(void) pjsua_acc_config_default(pjsua_acc_config *cfg)
1889{
Benny Prijonoac623b32006-07-03 15:19:31 +00001890 pj_bzero(cfg, sizeof(*cfg));
Benny Prijono312aff92006-06-17 04:08:30 +00001891
1892 cfg->reg_timeout = PJSUA_REG_INTERVAL;
Benny Prijono62c5c5b2007-01-13 23:22:40 +00001893 cfg->transport_id = PJSUA_INVALID_ID;
Benny Prijono312aff92006-06-17 04:08:30 +00001894}
1895
1896
1897
1898/**
1899 * Account info. Application can query account info by calling
1900 * #pjsua_acc_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00001901 *
1902 * \par Python:
1903 * The data type in Python is <tt>py_pjsua.Acc_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001904 */
1905typedef struct pjsua_acc_info
1906{
1907 /**
1908 * The account ID.
1909 */
1910 pjsua_acc_id id;
1911
1912 /**
1913 * Flag to indicate whether this is the default account.
1914 */
1915 pj_bool_t is_default;
1916
1917 /**
1918 * Account URI
1919 */
1920 pj_str_t acc_uri;
1921
1922 /**
1923 * Flag to tell whether this account has registration setting
1924 * (reg_uri is not empty).
1925 */
1926 pj_bool_t has_registration;
1927
1928 /**
1929 * An up to date expiration interval for account registration session.
1930 */
1931 int expires;
1932
1933 /**
1934 * Last registration status code. If status code is zero, the account
1935 * is currently not registered. Any other value indicates the SIP
1936 * status code of the registration.
1937 */
1938 pjsip_status_code status;
1939
1940 /**
1941 * String describing the registration status.
1942 */
1943 pj_str_t status_text;
1944
1945 /**
1946 * Presence online status for this account.
1947 */
1948 pj_bool_t online_status;
1949
1950 /**
1951 * Buffer that is used internally to store the status text.
1952 */
1953 char buf_[PJ_ERR_MSG_SIZE];
1954
1955} pjsua_acc_info;
1956
1957
1958
1959/**
1960 * Get number of current accounts.
1961 *
1962 * @return Current number of accounts.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001963 *
1964 * \par Python:
1965 * \code
1966 count = py_pjsua.acc_get_count()
1967 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001968 */
1969PJ_DECL(unsigned) pjsua_acc_get_count(void);
1970
1971
1972/**
1973 * Check if the specified account ID is valid.
1974 *
1975 * @param acc_id Account ID to check.
1976 *
1977 * @return Non-zero if account ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001978 *
1979 * \par Python:
1980 * \code
1981 is_valid = py_pjsua.acc_is_valid(acc_id)
1982 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001983 */
1984PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
1985
1986
1987/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00001988 * Set default account to be used when incoming and outgoing
1989 * requests doesn't match any accounts.
1990 *
1991 * @param acc_id The account ID to be used as default.
1992 *
1993 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001994 *
1995 * \par Python:
1996 * \code
1997 status = py_pjsua.acc_set_default(acc_id)
1998 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00001999 */
2000PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2001
2002
2003/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002004 * Get default account to be used when receiving incoming requests (calls),
2005 * when the destination of the incoming call doesn't match any other
2006 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002007 *
2008 * @return The default account ID, or PJSUA_INVALID_ID if no
2009 * default account is configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002010 *
2011 * \par Python:
2012 * \code
2013 acc_id = py_pjsua.acc_get_default()
2014 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002015 */
2016PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2017
2018
2019/**
Benny Prijono312aff92006-06-17 04:08:30 +00002020 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002021 * #pjsua_init()) before calling this function. If registration is configured
2022 * for this account, this function would also start the SIP registration
2023 * session with the SIP registrar server. This SIP registration session
2024 * will be maintained internally by the library, and application doesn't
2025 * need to do anything to maintain the registration session.
2026 *
Benny Prijono312aff92006-06-17 04:08:30 +00002027 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002028 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002029 * @param is_default If non-zero, this account will be set as the default
2030 * account. The default account will be used when sending
2031 * outgoing requests (e.g. making call) when no account is
2032 * specified, and when receiving incoming requests when the
2033 * request does not match any accounts. It is recommended
2034 * that default account is set to local/LAN account.
2035 * @param p_acc_id Pointer to receive account ID of the new account.
2036 *
2037 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002038 *
2039 * \par Python:
2040 * The function returns (status, account_id) tuple:
2041 * \code
2042 status, account_id = py_pjsua.acc_add(acc_cfg, is_default)
2043 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002044 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002045PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002046 pj_bool_t is_default,
2047 pjsua_acc_id *p_acc_id);
2048
2049
2050/**
2051 * Add a local account. A local account is used to identify local endpoint
2052 * instead of a specific user, and for this reason, a transport ID is needed
2053 * to obtain the local address information.
2054 *
2055 * @param tid Transport ID to generate account address.
2056 * @param is_default If non-zero, this account will be set as the default
2057 * account. The default account will be used when sending
2058 * outgoing requests (e.g. making call) when no account is
2059 * specified, and when receiving incoming requests when the
2060 * request does not match any accounts. It is recommended
2061 * that default account is set to local/LAN account.
2062 * @param p_acc_id Pointer to receive account ID of the new account.
2063 *
2064 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002065 *
2066 * \par Python:
2067 * The function returns (status, account_id) tuple:
2068 * \code
2069 status, account_id = py_pjsua.acc_add_local(tid, is_default)
2070 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002071 */
2072PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2073 pj_bool_t is_default,
2074 pjsua_acc_id *p_acc_id);
2075
2076/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002077 * Delete an account. This will unregister the account from the SIP server,
2078 * if necessary, and terminate server side presence subscriptions associated
2079 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002080 *
2081 * @param acc_id Id of the account to be deleted.
2082 *
2083 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002084 *
2085 * \par Python:
2086 * \code
2087 status = py_pjsua.acc_del(acc_id)
2088 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002089 */
2090PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2091
2092
2093/**
2094 * Modify account information.
2095 *
2096 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002097 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002098 *
2099 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002100 *
2101 * \par Python:
2102 * \code
2103 status = py_pjsua.acc_modify(acc_id, acc_cfg)
2104 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002105 */
2106PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002107 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002108
2109
2110/**
2111 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002112 * subscribers. This would trigger the sending of outgoing NOTIFY request
2113 * if there are server side presence subscription for this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002114 *
2115 * @param acc_id The account ID.
2116 * @param is_online True of false.
2117 *
2118 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002119 *
2120 * \par Python:
2121 * \code
2122 status = py_pjsua.acc_set_online_status(acc_id, is_online)
2123 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002124 */
2125PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2126 pj_bool_t is_online);
2127
2128
2129/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002130 * Update registration or perform unregistration. If registration is
2131 * configured for this account, then initial SIP REGISTER will be sent
2132 * when the account is added with #pjsua_acc_add(). Application normally
2133 * only need to call this function if it wants to manually update the
2134 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002135 *
2136 * @param acc_id The account ID.
2137 * @param renew If renew argument is zero, this will start
2138 * unregistration process.
2139 *
2140 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002141 *
2142 * \par Python:
2143 * \code
2144 status = py_pjsua.acc_set_registration(acc_id, renew)
2145 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002146 */
2147PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2148 pj_bool_t renew);
2149
2150
2151/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002152 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002153 *
2154 * @param acc_id Account identification.
2155 * @param info Pointer to receive account information.
2156 *
2157 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002158 *
2159 * \par Python:
2160 * \code
2161 acc_info = py_pjsua.acc_get_info(acc_id)
2162 * \endcode
2163 * The function returns None if account ID is not valid.
Benny Prijono312aff92006-06-17 04:08:30 +00002164 */
2165PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2166 pjsua_acc_info *info);
2167
2168
2169/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002170 * Enumerate all account currently active in the library. This will fill
2171 * the array with the account Ids, and application can then query the
2172 * account information for each id with #pjsua_acc_get_info().
2173 *
2174 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002175 *
2176 * @param ids Array of account IDs to be initialized.
2177 * @param count In input, specifies the maximum number of elements.
2178 * On return, it contains the actual number of elements.
2179 *
2180 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002181 *
2182 * \par Python:
2183 * The function takes no argument and returns list of account Ids:
2184 * \code
2185 [acc_ids] = py_pjsua.enum_accs()
2186 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002187 */
2188PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2189 unsigned *count );
2190
2191
2192/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002193 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002194 *
2195 * @param info Array of account infos to be initialized.
2196 * @param count In input, specifies the maximum number of elements.
2197 * On return, it contains the actual number of elements.
2198 *
2199 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002200 *
2201 * \par Python:
2202 * The function takes no argument and returns list of account infos:
2203 * \code
2204 [acc_info] = py_pjsua.acc_enum_info()
2205 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002206 */
2207PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2208 unsigned *count );
2209
2210
2211/**
2212 * This is an internal function to find the most appropriate account to
2213 * used to reach to the specified URL.
2214 *
2215 * @param url The remote URL to reach.
2216 *
2217 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002218 *
2219 * \par Python:
2220 * \code
2221 acc_id = py_pjsua.acc_find_for_outgoing(url)
2222 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002223 */
2224PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2225
2226
2227/**
2228 * This is an internal function to find the most appropriate account to be
2229 * used to handle incoming calls.
2230 *
2231 * @param rdata The incoming request message.
2232 *
2233 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002234 *
2235 * \par Python:
2236 * \code
2237 acc_id = py_pjsua.acc_find_for_outgoing(url)
2238 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002239 */
2240PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2241
2242
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002243/**
Benny Prijonofff245c2007-04-02 11:44:47 +00002244 * Create arbitrary requests using the account. Application should only use
2245 * this function to create auxiliary requests outside dialog, such as
2246 * OPTIONS, and use the call or presence API to create dialog related
2247 * requests.
2248 *
2249 * @param acc_id The account ID.
2250 * @param method The SIP method of the request.
2251 * @param target Target URI.
2252 * @param p_tdata Pointer to receive the request.
2253 *
2254 * @return PJ_SUCCESS or the error code.
2255 */
2256PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
2257 const pjsip_method *method,
2258 const pj_str_t *target,
2259 pjsip_tx_data **p_tdata);
2260
2261
2262/**
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002263 * Create a suitable URI to be put as Contact based on the specified
2264 * target URI for the specified account.
2265 *
2266 * @param pool Pool to allocate memory for the string.
2267 * @param contact The string where the Contact URI will be stored.
2268 * @param acc_id Account ID.
2269 * @param uri Destination URI of the request.
2270 *
2271 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002272 *
2273 * \par Python:
2274 * This function is still experimental in Python:
2275 * \code
2276 uri = py_pjsua.acc_create_uac_contact(pool, acc_id, uri)
2277 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002278 */
2279PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
2280 pj_str_t *contact,
2281 pjsua_acc_id acc_id,
2282 const pj_str_t *uri);
2283
2284
2285
2286/**
2287 * Create a suitable URI to be put as Contact based on the information
2288 * in the incoming request.
2289 *
2290 * @param pool Pool to allocate memory for the string.
2291 * @param contact The string where the Contact URI will be stored.
2292 * @param acc_id Account ID.
2293 * @param rdata Incoming request.
2294 *
2295 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002296 *
2297 * \par Python:
2298 * This function is still experimental in Python:
2299 * \code
2300 uri = py_pjsua.acc_create_uas_contact(pool, acc_id, rdata)
2301 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002302 */
2303PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
2304 pj_str_t *contact,
2305 pjsua_acc_id acc_id,
2306 pjsip_rx_data *rdata );
2307
2308
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002309/**
2310 * Lock/bind this account to a specific transport/listener. Normally
2311 * application shouldn't need to do this, as transports will be selected
2312 * automatically by the stack according to the destination.
2313 *
2314 * When account is locked/bound to a specific transport, all outgoing
2315 * requests from this account will use the specified transport (this
2316 * includes SIP registration, dialog (call and event subscription), and
2317 * out-of-dialog requests such as MESSAGE).
2318 *
2319 * Note that transport_id may be specified in pjsua_acc_config too.
2320 *
2321 * @param acc_id The account ID.
2322 * @param tp_id The transport ID.
2323 *
2324 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002325 *
2326 * \par Python:
2327 * Not yet implemented.
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002328 */
2329PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
2330 pjsua_transport_id tp_id);
2331
Benny Prijono312aff92006-06-17 04:08:30 +00002332
2333/**
2334 * @}
2335 */
2336
2337
2338/*****************************************************************************
2339 * CALLS API
2340 */
2341
2342
2343/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002344 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00002345 * @ingroup PJSUA_LIB
2346 * @brief Call manipulation.
2347 * @{
2348 */
2349
2350/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002351 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00002352 */
2353#ifndef PJSUA_MAX_CALLS
2354# define PJSUA_MAX_CALLS 32
2355#endif
2356
2357
2358
2359/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002360 * This enumeration specifies the media status of a call, and it's part
2361 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00002362 */
2363typedef enum pjsua_call_media_status
2364{
Benny Prijonob5388cf2007-01-04 22:45:08 +00002365 /** Call currently has no media */
Benny Prijono312aff92006-06-17 04:08:30 +00002366 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002367
2368 /** The media is active */
Benny Prijono312aff92006-06-17 04:08:30 +00002369 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002370
2371 /** The media is currently put on hold by local endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002372 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002373
2374 /** The media is currently put on hold by remote endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002375 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002376
Benny Prijono312aff92006-06-17 04:08:30 +00002377} pjsua_call_media_status;
2378
2379
2380/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002381 * This structure describes the information and current status of a call.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002382 *
2383 * \par Python:
2384 * The type name is <tt>py_pjsua.Call_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002385 */
2386typedef struct pjsua_call_info
2387{
2388 /** Call identification. */
2389 pjsua_call_id id;
2390
2391 /** Initial call role (UAC == caller) */
2392 pjsip_role_e role;
2393
Benny Prijono90315512006-09-14 16:05:16 +00002394 /** The account ID where this call belongs. */
2395 pjsua_acc_id acc_id;
2396
Benny Prijono312aff92006-06-17 04:08:30 +00002397 /** Local URI */
2398 pj_str_t local_info;
2399
2400 /** Local Contact */
2401 pj_str_t local_contact;
2402
2403 /** Remote URI */
2404 pj_str_t remote_info;
2405
2406 /** Remote contact */
2407 pj_str_t remote_contact;
2408
2409 /** Dialog Call-ID string. */
2410 pj_str_t call_id;
2411
2412 /** Call state */
2413 pjsip_inv_state state;
2414
2415 /** Text describing the state */
2416 pj_str_t state_text;
2417
2418 /** Last status code heard, which can be used as cause code */
2419 pjsip_status_code last_status;
2420
2421 /** The reason phrase describing the status. */
2422 pj_str_t last_status_text;
2423
2424 /** Call media status. */
2425 pjsua_call_media_status media_status;
2426
2427 /** Media direction */
2428 pjmedia_dir media_dir;
2429
2430 /** The conference port number for the call */
2431 pjsua_conf_port_id conf_slot;
2432
2433 /** Up-to-date call connected duration (zero when call is not
2434 * established)
2435 */
2436 pj_time_val connect_duration;
2437
2438 /** Total call duration, including set-up time */
2439 pj_time_val total_duration;
2440
2441 /** Internal */
2442 struct {
2443 char local_info[128];
2444 char local_contact[128];
2445 char remote_info[128];
2446 char remote_contact[128];
2447 char call_id[128];
2448 char last_status_text[128];
2449 } buf_;
2450
2451} pjsua_call_info;
2452
2453
2454
Benny Prijonoa91a0032006-02-26 21:23:45 +00002455/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002456 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002457 *
2458 * @return Maximum number of calls configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002459 *
2460 * \par Python:
2461 * \code
2462 count = py_pjsua.call_get_max_count()
2463 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002464 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002465PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002466
2467/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002468 * Get number of currently active calls.
2469 *
2470 * @return Number of currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002471 *
2472 * \par Python:
2473 * \code
2474 count = py_pjsua.call_get_count()
2475 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002476 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002477PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002478
2479/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002480 * Enumerate all active calls. Application may then query the information and
2481 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002482 *
2483 * @param ids Array of account IDs to be initialized.
2484 * @param count In input, specifies the maximum number of elements.
2485 * On return, it contains the actual number of elements.
2486 *
2487 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002488 *
2489 * \par Python:
2490 * This function takes no argument and return list of call Ids.
2491 * \code
2492 [call_ids] = py_pjsua.enum_calls()
2493 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002494 */
2495PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
2496 unsigned *count);
2497
2498
2499/**
2500 * Make outgoing call to the specified URI using the specified account.
2501 *
2502 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002503 * @param dst_uri URI to be put in the To header (normally is the same
2504 * as the target URI).
2505 * @param options Options (must be zero at the moment).
2506 * @param user_data Arbitrary user data to be attached to the call, and
2507 * can be retrieved later.
2508 * @param msg_data Optional headers etc to be added to outgoing INVITE
2509 * request, or NULL if no custom header is desired.
2510 * @param p_call_id Pointer to receive call identification.
2511 *
2512 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002513 *
2514 * \par Python:
2515 * The Python function returns (status, call_id) tuple:
2516 * \code
2517 status, call_id = py_pjsua.call_make_call(acc_id, dst_uri, options,
2518 user_data, msg_data)
2519 * \endcode
2520 * Note: the \a user_data in Python function is an integer, and the
2521 * \a msg_data can be set to None if not required.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002522 */
2523PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
2524 const pj_str_t *dst_uri,
2525 unsigned options,
2526 void *user_data,
2527 const pjsua_msg_data *msg_data,
2528 pjsua_call_id *p_call_id);
2529
2530
2531/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002532 * Check if the specified call has active INVITE session and the INVITE
2533 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002534 *
2535 * @param call_id Call identification.
2536 *
2537 * @return Non-zero if call is active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002538 *
2539 * \par Python:
2540 * \code
2541 bool = py_pjsua.call_is_active(call_id)
2542 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002543 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002544PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002545
2546
2547/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002548 * Check if call has an active media session.
2549 *
2550 * @param call_id Call identification.
2551 *
2552 * @return Non-zero if yes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002553 *
2554 * \par Python:
2555 * \code
2556 bool = py_pjsua.call_has_media(call_id)
2557 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002558 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002559PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002560
2561
2562/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002563 * Get the conference port identification associated with the call.
2564 *
2565 * @param call_id Call identification.
2566 *
2567 * @return Conference port ID, or PJSUA_INVALID_ID when the
2568 * media has not been established or is not active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002569 *
2570 * \par Python:
2571 * \code
2572 slot = py_pjsua.call_get_conf_port(call_id)
2573 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002574 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002575PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
2576
2577/**
2578 * Obtain detail information about the specified call.
2579 *
2580 * @param call_id Call identification.
2581 * @param info Call info to be initialized.
2582 *
2583 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002584 *
2585 * \par Python:
2586 * \code
2587 call_info = py_pjsua.call_get_info(call_id)
2588 * \endcode
2589 * \a call_info return value will be set to None if call_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002590 */
2591PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002592 pjsua_call_info *info);
2593
2594
2595/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002596 * Attach application specific data to the call. Application can then
2597 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002598 *
2599 * @param call_id Call identification.
2600 * @param user_data Arbitrary data to be attached to the call.
2601 *
2602 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002603 *
2604 * \par Python:
2605 * \code
2606 status = py_pjsua.call_set_user_data(call_id, user_data)
2607 * \endcode
2608 * The \a user_data is an integer in the Python function.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002609 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002610PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
2611 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002612
2613
2614/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002615 * Get user data attached to the call, which has been previously set with
2616 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002617 *
2618 * @param call_id Call identification.
2619 *
2620 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002621 *
2622 * \par Python:
2623 * \code
2624 user_data = py_pjsua.call_get_user_data(call_id)
2625 * \endcode
2626 * The \a user_data is an integer.
Benny Prijono268ca612006-02-07 12:34:11 +00002627 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002628PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00002629
2630
2631/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002632 * Send response to incoming INVITE request. Depending on the status
2633 * code specified as parameter, this function may send provisional
2634 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002635 *
2636 * @param call_id Incoming call identification.
2637 * @param code Status code, (100-699).
2638 * @param reason Optional reason phrase. If NULL, default text
2639 * will be used.
2640 * @param msg_data Optional list of headers etc to be added to outgoing
2641 * response message.
2642 *
2643 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002644 *
2645 * \par Python:
2646 * \code
2647 status = py_pjsua.call_answer(call_id, code, reason, msg_data)
2648 * \endcode
2649 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijonoa91a0032006-02-26 21:23:45 +00002650 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002651PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
2652 unsigned code,
2653 const pj_str_t *reason,
2654 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00002655
2656/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002657 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00002658 * call state. This function is different than answering the call with
2659 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
2660 * will hangup the call regardless of the state and role of the call,
2661 * while #pjsua_call_answer() only works with incoming calls on EARLY
2662 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002663 *
2664 * @param call_id Call identification.
2665 * @param code Optional status code to be sent when we're rejecting
2666 * incoming call. If the value is zero, "603/Decline"
2667 * will be sent.
2668 * @param reason Optional reason phrase to be sent when we're rejecting
2669 * incoming call. If NULL, default text will be used.
2670 * @param msg_data Optional list of headers etc to be added to outgoing
2671 * request/response message.
2672 *
2673 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002674 *
2675 * \par Python:
2676 * \code
2677 status = py_pjsua.call_hangup(call_id, code, reason, msg_data)
2678 * \endcode
2679 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002680 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002681PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
2682 unsigned code,
2683 const pj_str_t *reason,
2684 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002685
2686
2687/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002688 * Put the specified call on hold. This will send re-INVITE with the
2689 * appropriate SDP to inform remote that the call is being put on hold.
2690 * The final status of the request itself will be reported on the
2691 * \a on_call_media_state() callback, which inform the application that
2692 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002693 *
2694 * @param call_id Call identification.
2695 * @param msg_data Optional message components to be sent with
2696 * the request.
2697 *
2698 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002699 *
2700 * \par Python:
2701 * \code
2702 status = py_pjsua.call_set_hold(call_id, msg_data)
2703 * \endcode
2704 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002705 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002706PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
2707 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002708
2709
2710/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002711 * Send re-INVITE to release hold.
2712 * The final status of the request itself will be reported on the
2713 * \a on_call_media_state() callback, which inform the application that
2714 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002715 *
2716 * @param call_id Call identification.
2717 * @param unhold If this argument is non-zero and the call is locally
2718 * held, this will release the local hold.
2719 * @param msg_data Optional message components to be sent with
2720 * the request.
2721 *
2722 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002723 *
2724 * \par Python:
2725 * \code
2726 status = py_pjsua.call_reinvite(call_id, unhold, msg_data)
2727 * \endcode
2728 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002729 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002730PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
2731 pj_bool_t unhold,
2732 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002733
2734
2735/**
Benny Prijono053f5222006-11-11 16:16:04 +00002736 * Initiate call transfer to the specified address. This function will send
2737 * REFER request to instruct remote call party to initiate a new INVITE
2738 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002739 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00002740 * If application is interested to monitor the successfulness and
2741 * the progress of the transfer request, it can implement
2742 * \a on_call_transfer_status() callback which will report the progress
2743 * of the call transfer request.
2744 *
Benny Prijono053f5222006-11-11 16:16:04 +00002745 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002746 * @param dest Address of new target to be contacted.
2747 * @param msg_data Optional message components to be sent with
2748 * the request.
2749 *
2750 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002751 *
2752 * \par Python:
2753 * \code
2754 status = py_pjsua.call_xfer(call_id, dest, msg_data)
2755 * \endcode
2756 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002757 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002758PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
2759 const pj_str_t *dest,
2760 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002761
2762/**
Benny Prijono053f5222006-11-11 16:16:04 +00002763 * Flag to indicate that "Require: replaces" should not be put in the
2764 * outgoing INVITE request caused by REFER request created by
2765 * #pjsua_call_xfer_replaces().
2766 */
2767#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
2768
2769/**
2770 * Initiate attended call transfer. This function will send REFER request
2771 * to instruct remote call party to initiate new INVITE session to the URL
2772 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
2773 * the call with us with the new call from the REFER recipient.
2774 *
2775 * @param call_id The call id to be transfered.
2776 * @param dest_call_id The call id to be replaced.
2777 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
2778 * to suppress the inclusion of "Require: replaces" in
2779 * the outgoing INVITE request created by the REFER
2780 * request.
2781 * @param msg_data Optional message components to be sent with
2782 * the request.
2783 *
2784 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002785 *
2786 * \par Python:
2787 * \code
2788 status = py_pjsua.call_xfer_replaces(call_id, dest_call_id, options, msg_data)
2789 * \endcode
2790 * Argument \a msg_data may be set to None if not required.
Benny Prijono053f5222006-11-11 16:16:04 +00002791 */
2792PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
2793 pjsua_call_id dest_call_id,
2794 unsigned options,
2795 const pjsua_msg_data *msg_data);
2796
2797/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002798 * Send DTMF digits to remote using RFC 2833 payload formats.
2799 *
2800 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002801 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002802 *
2803 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002804 *
2805 * \par Python:
2806 * \code
2807 status = py_pjsua.call_dial_dtmf(call_id, digits)
2808 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002809 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002810PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002811 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00002812
Benny Prijono26ff9062006-02-21 23:47:00 +00002813/**
Benny Prijonob0808372006-03-02 21:18:58 +00002814 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002815 *
2816 * @param call_id Call identification.
2817 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
2818 * assumed.
2819 * @param content The message content.
2820 * @param msg_data Optional list of headers etc to be included in outgoing
2821 * request. The body descriptor in the msg_data is
2822 * ignored.
2823 * @param user_data Optional user data, which will be given back when
2824 * the IM callback is called.
2825 *
2826 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002827 *
2828 * \par Python:
2829 * \code
2830 status = py_pjsua.call_send_im(call_id, mime_type, content, msg_data, user_data)
2831 * \endcode
2832 * Note that the \a user_data argument is an integer in Python.
Benny Prijonob0808372006-03-02 21:18:58 +00002833 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002834PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
2835 const pj_str_t *mime_type,
2836 const pj_str_t *content,
2837 const pjsua_msg_data *msg_data,
2838 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00002839
2840
2841/**
2842 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002843 *
2844 * @param call_id Call identification.
2845 * @param is_typing Non-zero to indicate to remote that local person is
2846 * currently typing an IM.
2847 * @param msg_data Optional list of headers etc to be included in outgoing
2848 * request.
2849 *
2850 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002851 *
2852 * \par Python:
2853 * \code
2854 status = py_pjsua.call_send_typing_ind(call_id, is_typing, msg_data)
2855 * \endcode
2856 * Argument \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00002857 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002858PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
2859 pj_bool_t is_typing,
2860 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00002861
2862/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002863 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
2864 * currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002865 *
2866 * \par Python:
2867 * \code
2868 py_pjsua.call_hangup_all()
2869 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00002870 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00002871PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00002872
2873
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002874/**
2875 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002876 *
2877 * @param call_id Call identification.
2878 * @param with_media Non-zero to include media information too.
2879 * @param buffer Buffer where the statistics are to be written to.
2880 * @param maxlen Maximum length of buffer.
2881 * @param indent Spaces for left indentation.
2882 *
2883 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002884 *
2885 * \par Python:
2886 * \code
2887 string = py_pjsua.call_dump(call_id, with_media, max_len, indent)
2888 * \endcode
2889 * The \a max_len argument is the desired maximum length to be allocated.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002890 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002891PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
2892 pj_bool_t with_media,
2893 char *buffer,
2894 unsigned maxlen,
2895 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002896
Benny Prijono9fc735d2006-05-28 14:58:12 +00002897/**
Benny Prijono312aff92006-06-17 04:08:30 +00002898 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00002899 */
Benny Prijono834aee32006-02-19 01:38:06 +00002900
2901
2902/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00002903 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00002904 */
2905
Benny Prijono312aff92006-06-17 04:08:30 +00002906
2907/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002908 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00002909 * @ingroup PJSUA_LIB
2910 * @brief Buddy management, buddy's presence, and instant messaging.
2911 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00002912 *
2913 * This section describes PJSUA-APIs related to buddies management,
2914 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00002915 */
2916
2917/**
2918 * Max buddies in buddy list.
2919 */
2920#ifndef PJSUA_MAX_BUDDIES
2921# define PJSUA_MAX_BUDDIES 256
2922#endif
2923
2924
2925/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002926 * This structure describes buddy configuration when adding a buddy to
2927 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
2928 * the structure with #pjsua_buddy_config_default() to initialize this
2929 * structure with default configuration.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002930 *
2931 * \par Python:
2932 * In Python this structure is <tt>py_pjsua.Buddy_Config</tt>. However
2933 * it is recommended that application instantiates the buddy config
2934 * by calling:
2935 * \code
2936 buddy_cfg = py_pjsua.buddy_config_default()
2937 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002938 */
2939typedef struct pjsua_buddy_config
2940{
2941 /**
2942 * Buddy URL or name address.
2943 */
2944 pj_str_t uri;
2945
2946 /**
2947 * Specify whether presence subscription should start immediately.
2948 */
2949 pj_bool_t subscribe;
2950
2951} pjsua_buddy_config;
2952
2953
2954/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002955 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00002956 */
2957typedef enum pjsua_buddy_status
2958{
2959 /**
2960 * Online status is unknown (possibly because no presence subscription
2961 * has been established).
2962 */
2963 PJSUA_BUDDY_STATUS_UNKNOWN,
2964
2965 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00002966 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00002967 */
2968 PJSUA_BUDDY_STATUS_ONLINE,
2969
2970 /**
2971 * Buddy is offline.
2972 */
2973 PJSUA_BUDDY_STATUS_OFFLINE,
2974
2975} pjsua_buddy_status;
2976
2977
2978
2979/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002980 * This structure describes buddy info, which can be retrieved by calling
2981 * #pjsua_buddy_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00002982 *
2983 * \par Python:
2984 * This structure in Python is <tt>py_pjsua.Buddy_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002985 */
2986typedef struct pjsua_buddy_info
2987{
2988 /**
2989 * The buddy ID.
2990 */
2991 pjsua_buddy_id id;
2992
2993 /**
2994 * The full URI of the buddy, as specified in the configuration.
2995 */
2996 pj_str_t uri;
2997
2998 /**
2999 * Buddy's Contact, only available when presence subscription has
3000 * been established to the buddy.
3001 */
3002 pj_str_t contact;
3003
3004 /**
3005 * Buddy's online status.
3006 */
3007 pjsua_buddy_status status;
3008
3009 /**
3010 * Text to describe buddy's online status.
3011 */
3012 pj_str_t status_text;
3013
3014 /**
3015 * Flag to indicate that we should monitor the presence information for
3016 * this buddy (normally yes, unless explicitly disabled).
3017 */
3018 pj_bool_t monitor_pres;
3019
3020 /**
3021 * Internal buffer.
3022 */
3023 char buf_[256];
3024
3025} pjsua_buddy_info;
3026
3027
Benny Prijono834aee32006-02-19 01:38:06 +00003028/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003029 * Set default values to the buddy config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003030 *
3031 * \par Python:
3032 * \code
3033 buddy_cfg = py_pjsua.buddy_config_default()
3034 * \endcode
Benny Prijonob5388cf2007-01-04 22:45:08 +00003035 */
3036PJ_INLINE(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg)
3037{
3038 pj_bzero(cfg, sizeof(*cfg));
3039}
3040
3041
3042/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003043 * Get total number of buddies.
3044 *
3045 * @return Number of buddies.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003046 *
3047 * \par Python:
3048 * \code
3049 buddy_count = py_pjsua.get_buddy_count()
3050 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003051 */
3052PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3053
3054
3055/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003056 * Check if buddy ID is valid.
3057 *
3058 * @param buddy_id Buddy ID to check.
3059 *
3060 * @return Non-zero if buddy ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003061 *
3062 * \par Python:
3063 * \code
3064 is_valid = py_pjsua.buddy_is_valid(buddy_id)
3065 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003066 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003067PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3068
3069
3070/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003071 * Enumerate all buddy IDs in the buddy list. Application then can use
3072 * #pjsua_buddy_get_info() to get the detail information for each buddy
3073 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003074 *
3075 * @param ids Array of ids to be initialized.
3076 * @param count On input, specifies max elements in the array.
3077 * On return, it contains actual number of elements
3078 * that have been initialized.
3079 *
3080 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003081 *
3082 * \par Python:
3083 * The Python function takes no argument and returns list of buddy IDs:
3084 * \code
3085 [buddy_ids] = py_pjsua.enum_buddies()
3086 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003087 */
3088PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3089 unsigned *count);
3090
3091/**
3092 * Get detailed buddy info.
3093 *
3094 * @param buddy_id The buddy identification.
3095 * @param info Pointer to receive information about buddy.
3096 *
3097 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003098 *
3099 * \par Python:
3100 * \code
3101 buddy_info = py_pjsua.buddy_get_info(buddy_id)
3102 * \endcode
3103 * The function returns None if buddy_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003104 */
3105PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003106 pjsua_buddy_info *info);
3107
3108/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003109 * Add new buddy to the buddy list. If presence subscription is enabled
3110 * for this buddy, this function will also start the presence subscription
3111 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003112 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003113 * @param buddy)cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003114 * @param p_buddy_id Pointer to receive buddy ID.
3115 *
3116 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003117 *
3118 * \par Python:
3119 * The function returns (status, buddy_id) tuple:
3120 * \code
3121 status, buddy_id = py_pjsua.buddy_add(buddy_cfg)
3122 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003123 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003124PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003125 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003126
3127
3128/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003129 * Delete the specified buddy from the buddy list. Any presence subscription
3130 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003131 *
3132 * @param buddy_id Buddy identification.
3133 *
3134 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003135 *
3136 * \par Python:
3137 * \code
3138 status = py_pjsua.buddy_del(buddy_id)
3139 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +00003140 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003141PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003142
3143
3144/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003145 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3146 * subscribed, application will be informed about buddy's presence status
3147 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003148 *
3149 * @param buddy_id Buddy identification.
3150 * @param subscribe Specify non-zero to activate presence subscription to
3151 * the specified buddy.
3152 *
3153 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003154 *
3155 * \par Python:
3156 * \code
3157 status = py_pjsua.buddy_subscribe_pres(buddy_id, subscribe)
3158 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003159 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003160PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3161 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003162
3163
3164/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003165 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003166 *
3167 * @param verbose Yes or no.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003168 *
3169 * \par Python:
3170 * \code
3171 py_pjsua.pres_dump()
3172 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003173 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003174PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003175
3176
Benny Prijonob0808372006-03-02 21:18:58 +00003177/**
3178 * The MESSAGE method (defined in pjsua_im.c)
3179 */
3180extern const pjsip_method pjsip_message_method;
3181
3182
Benny Prijonob0808372006-03-02 21:18:58 +00003183
3184/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003185 * Send instant messaging outside dialog, using the specified account for
3186 * route set and authentication.
3187 *
3188 * @param acc_id Account ID to be used to send the request.
3189 * @param to Remote URI.
3190 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3191 * assumed.
3192 * @param content The message content.
3193 * @param msg_data Optional list of headers etc to be included in outgoing
3194 * request. The body descriptor in the msg_data is
3195 * ignored.
3196 * @param user_data Optional user data, which will be given back when
3197 * the IM callback is called.
3198 *
3199 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003200 *
3201 * \par Python:
3202 * \code
3203 status = py_pjsua.im_send(acc_id, to, mime_type, content, msg_data, user_data)
3204 * \endcode
3205 * Arguments \a mime_type and \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003206 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003207PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3208 const pj_str_t *to,
3209 const pj_str_t *mime_type,
3210 const pj_str_t *content,
3211 const pjsua_msg_data *msg_data,
3212 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003213
3214
3215/**
3216 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003217 *
3218 * @param acc_id Account ID to be used to send the request.
3219 * @param to Remote URI.
3220 * @param is_typing If non-zero, it tells remote person that local person
3221 * is currently composing an IM.
3222 * @param msg_data Optional list of headers etc to be added to outgoing
3223 * request.
3224 *
3225 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003226 *
3227 * \par Python:
3228 * \code
3229 status = py_pjsua.im_typing(acc_id, to, is_typing, msg_data)
3230 * \endcode
3231 * Argument \a msg_data may be set to None if not requried.
Benny Prijonob0808372006-03-02 21:18:58 +00003232 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003233PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3234 const pj_str_t *to,
3235 pj_bool_t is_typing,
3236 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003237
3238
Benny Prijonof3195072006-02-14 21:15:30 +00003239
Benny Prijono312aff92006-06-17 04:08:30 +00003240/**
3241 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003242 */
3243
Benny Prijono312aff92006-06-17 04:08:30 +00003244
3245/*****************************************************************************
3246 * MEDIA API
3247 */
3248
3249
3250/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003251 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003252 * @ingroup PJSUA_LIB
3253 * @brief Media manipulation.
3254 * @{
3255 *
3256 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003257 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3258 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003259 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003260 * the interconnection between these terminations freely.
3261 *
3262 * The conference bridge provides powerful switching and mixing functionality
3263 * for application. With the conference bridge, each conference slot (e.g.
3264 * a call) can transmit to multiple destinations, and one destination can
3265 * receive from multiple sources. If more than one media terminations are
3266 * terminated in the same slot, the conference bridge will mix the signal
3267 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00003268 *
3269 * Application connects one media termination/slot to another by calling
3270 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003271 * media flow from the source termination to the sink termination. To
3272 * establish bidirectional media flow, application wound need to make another
3273 * call to #pjsua_conf_connect(), this time inverting the source and
3274 * destination slots in the parameter.
3275 *
3276 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00003277 * the following steps:
3278 *
3279 \code
3280
3281 pj_status_t stream_to_call( pjsua_call_id call_id )
3282 {
3283 pjsua_player_id player_id;
3284
3285 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
3286 if (status != PJ_SUCCESS)
3287 return status;
3288
3289 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
3290 pjsua_call_get_conf_port() );
3291 }
3292 \endcode
3293 *
3294 *
3295 * Other features of PJSUA media:
3296 * - efficient N to M interconnections between media terminations.
3297 * - media termination can be connected to itself to create loopback
3298 * media.
3299 * - the media termination may have different clock rates, and resampling
3300 * will be done automatically by conference bridge.
3301 * - media terminations may also have different frame time; the
3302 * conference bridge will perform the necessary bufferring to adjust
3303 * the difference between terminations.
3304 * - interconnections are removed automatically when media termination
3305 * is removed from the bridge.
3306 * - sound device may be changed even when there are active media
3307 * interconnections.
3308 * - correctly report call's media quality (in #pjsua_call_dump()) from
3309 * RTCP packet exchange.
3310 */
3311
3312/**
3313 * Max ports in the conference bridge.
3314 */
3315#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00003316# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00003317#endif
3318
Benny Prijonob5388cf2007-01-04 22:45:08 +00003319/**
3320 * The default clock rate to be used by the conference bridge.
3321 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003322#ifndef PJSUA_DEFAULT_CLOCK_RATE
3323# define PJSUA_DEFAULT_CLOCK_RATE 16000
3324#endif
3325
Benny Prijonob5388cf2007-01-04 22:45:08 +00003326/**
3327 * Default codec quality settings.
3328 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003329#ifndef PJSUA_DEFAULT_CODEC_QUALITY
3330# define PJSUA_DEFAULT_CODEC_QUALITY 5
3331#endif
3332
Benny Prijonob5388cf2007-01-04 22:45:08 +00003333/**
3334 * Default iLBC mode.
3335 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003336#ifndef PJSUA_DEFAULT_ILBC_MODE
3337# define PJSUA_DEFAULT_ILBC_MODE 20
3338#endif
3339
Benny Prijonob5388cf2007-01-04 22:45:08 +00003340/**
3341 * The default echo canceller tail length.
3342 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003343#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonod2990b92006-11-23 10:19:46 +00003344# define PJSUA_DEFAULT_EC_TAIL_LEN 800
Benny Prijono12a669c2006-11-23 07:32:13 +00003345#endif
Benny Prijono312aff92006-06-17 04:08:30 +00003346
3347
3348/**
Benny Prijonocba59d92007-02-16 09:22:56 +00003349 * The maximum file player.
3350 */
3351#ifndef PJSUA_MAX_PLAYERS
3352# define PJSUA_MAX_PLAYERS 32
3353#endif
3354
3355
3356/**
3357 * The maximum file player.
3358 */
3359#ifndef PJSUA_MAX_RECORDERS
3360# define PJSUA_MAX_RECORDERS 32
3361#endif
3362
3363
3364/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003365 * This structure describes media configuration, which will be specified
3366 * when calling #pjsua_init(). Application MUST initialize this structure
3367 * by calling #pjsua_media_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003368 *
3369 * \par Python:
3370 * This data type in Python is <tt>py_pjsua.Media_Config</tt>. To create
3371 * an object of this type, it is recommended to call
3372 * <tt>py_pjsua.media_config_default()</tt> function instead:
3373 * \code
3374 media_cfg = py_pjsua.media_config_default()
3375 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003376 */
3377struct pjsua_media_config
3378{
3379 /**
3380 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003381 * If value is zero, default clock rate will be used
3382 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00003383 */
3384 unsigned clock_rate;
3385
3386 /**
3387 * Specify maximum number of media ports to be created in the
3388 * conference bridge. Since all media terminate in the bridge
3389 * (calls, file player, file recorder, etc), the value must be
3390 * large enough to support all of them. However, the larger
3391 * the value, the more computations are performed.
3392 */
3393 unsigned max_media_ports;
3394
3395 /**
3396 * Specify whether the media manager should manage its own
3397 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
3398 * and at least one worker thread will be created too. If no,
3399 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
3400 * and no worker thread is needed.
3401 *
3402 * Normally application would say yes here, unless it wants to
3403 * run everything from a single thread.
3404 */
3405 pj_bool_t has_ioqueue;
3406
3407 /**
3408 * Specify the number of worker threads to handle incoming RTP
3409 * packets. A value of one is recommended for most applications.
3410 */
3411 unsigned thread_cnt;
3412
Benny Prijono0498d902006-06-19 14:49:14 +00003413 /**
3414 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00003415 * 5-10: resampling use large filter,
3416 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00003417 * 1-2: resampling use linear.
3418 * The media quality also sets speex codec quality/complexity to the
3419 * number.
3420 *
Benny Prijono70972992006-08-05 11:13:58 +00003421 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00003422 */
3423 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00003424
3425 /**
3426 * Specify default ptime.
3427 *
3428 * Default: 0 (codec specific)
3429 */
3430 unsigned ptime;
3431
3432 /**
3433 * Disable VAD?
3434 *
3435 * Default: 0 (no (meaning VAD is enabled))
3436 */
3437 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00003438
3439 /**
3440 * iLBC mode (20 or 30).
3441 *
Benny Prijono70972992006-08-05 11:13:58 +00003442 * Default: 20 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00003443 */
3444 unsigned ilbc_mode;
3445
3446 /**
3447 * Percentage of RTP packet to drop in TX direction
3448 * (to simulate packet lost).
3449 *
3450 * Default: 0
3451 */
3452 unsigned tx_drop_pct;
3453
3454 /**
3455 * Percentage of RTP packet to drop in RX direction
3456 * (to simulate packet lost).
3457 *
3458 * Default: 0
3459 */
3460 unsigned rx_drop_pct;
3461
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003462 /**
Benny Prijono5da50432006-08-07 10:24:52 +00003463 * Echo canceller options (see #pjmedia_echo_create())
3464 *
3465 * Default: 0.
3466 */
3467 unsigned ec_options;
3468
3469 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003470 * Echo canceller tail length, in miliseconds.
3471 *
Benny Prijono669643c2006-09-20 20:02:18 +00003472 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003473 */
3474 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003475
3476 /**
3477 * Jitter buffer initial prefetch delay in msec. The value must be
3478 * between jb_min_pre and jb_max_pre below.
3479 *
3480 * Default: -1 (to use default stream settings, currently 150 msec)
3481 */
3482 int jb_init;
3483
3484 /**
3485 * Jitter buffer minimum prefetch delay in msec.
3486 *
3487 * Default: -1 (to use default stream settings, currently 60 msec)
3488 */
3489 int jb_min_pre;
3490
3491 /**
3492 * Jitter buffer maximum prefetch delay in msec.
3493 *
3494 * Default: -1 (to use default stream settings, currently 240 msec)
3495 */
3496 int jb_max_pre;
3497
3498 /**
3499 * Set maximum delay that can be accomodated by the jitter buffer msec.
3500 *
3501 * Default: -1 (to use default stream settings, currently 360 msec)
3502 */
3503 int jb_max;
3504
Benny Prijonoc97608e2007-03-23 16:34:20 +00003505 /**
3506 * Enable ICE
3507 */
3508 pj_bool_t enable_ice;
3509
3510 /**
3511 * Enable ICE media relay.
3512 */
3513 pj_bool_t enable_relay;
Benny Prijono312aff92006-06-17 04:08:30 +00003514};
3515
3516
3517/**
3518 * Use this function to initialize media config.
3519 *
3520 * @param cfg The media config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003521 *
3522 * \par Python:
3523 * \code
3524 media_cfg = py_pjsua.media_config_default()
3525 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003526 */
3527PJ_INLINE(void) pjsua_media_config_default(pjsua_media_config *cfg)
3528{
Benny Prijonoac623b32006-07-03 15:19:31 +00003529 pj_bzero(cfg, sizeof(*cfg));
Benny Prijono312aff92006-06-17 04:08:30 +00003530
Benny Prijono70972992006-08-05 11:13:58 +00003531 cfg->clock_rate = PJSUA_DEFAULT_CLOCK_RATE;
Benny Prijono312aff92006-06-17 04:08:30 +00003532 cfg->max_media_ports = 32;
3533 cfg->has_ioqueue = PJ_TRUE;
3534 cfg->thread_cnt = 1;
Benny Prijono70972992006-08-05 11:13:58 +00003535 cfg->quality = PJSUA_DEFAULT_CODEC_QUALITY;
3536 cfg->ilbc_mode = PJSUA_DEFAULT_ILBC_MODE;
3537 cfg->ec_tail_len = PJSUA_DEFAULT_EC_TAIL_LEN;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003538 cfg->jb_init = cfg->jb_min_pre = cfg->jb_max_pre = cfg->jb_max = -1;
Benny Prijono312aff92006-06-17 04:08:30 +00003539}
3540
3541
3542
3543/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003544 * This structure describes codec information, which can be retrieved by
3545 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00003546 */
3547typedef struct pjsua_codec_info
3548{
3549 /**
3550 * Codec unique identification.
3551 */
3552 pj_str_t codec_id;
3553
3554 /**
3555 * Codec priority (integer 0-255).
3556 */
3557 pj_uint8_t priority;
3558
3559 /**
3560 * Internal buffer.
3561 */
3562 char buf_[32];
3563
3564} pjsua_codec_info;
3565
3566
3567/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003568 * This structure descibes information about a particular media port that
3569 * has been registered into the conference bridge. Application can query
3570 * this info by calling #pjsua_conf_get_port_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003571 *
3572 * \par Python:
3573 * In Python, this type is <tt>py_pjsua.Conf_Port_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003574 */
3575typedef struct pjsua_conf_port_info
3576{
3577 /** Conference port number. */
3578 pjsua_conf_port_id slot_id;
3579
3580 /** Port name. */
3581 pj_str_t name;
3582
3583 /** Clock rate. */
3584 unsigned clock_rate;
3585
3586 /** Number of channels. */
3587 unsigned channel_count;
3588
3589 /** Samples per frame */
3590 unsigned samples_per_frame;
3591
3592 /** Bits per sample */
3593 unsigned bits_per_sample;
3594
3595 /** Number of listeners in the array. */
3596 unsigned listener_cnt;
3597
3598 /** Array of listeners (in other words, ports where this port is
3599 * transmitting to.
3600 */
3601 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
3602
3603} pjsua_conf_port_info;
3604
3605
3606/**
3607 * This structure holds information about custom media transport to
3608 * be registered to pjsua.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003609 *
3610 * \par Python:
3611 * Not applicable.
Benny Prijono312aff92006-06-17 04:08:30 +00003612 */
3613typedef struct pjsua_media_transport
3614{
3615 /**
3616 * Media socket information containing the address information
3617 * of the RTP and RTCP socket.
3618 */
3619 pjmedia_sock_info skinfo;
3620
3621 /**
3622 * The media transport instance.
3623 */
3624 pjmedia_transport *transport;
3625
3626} pjsua_media_transport;
3627
3628
3629
3630
Benny Prijono9fc735d2006-05-28 14:58:12 +00003631/**
3632 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003633 *
3634 * @return Maximum number of ports in the conference bridge.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003635 *
3636 * \par Python:
3637 * \code
3638 port_count = py_pjsua.conf_get_max_ports()
3639 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003640 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003641PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003642
3643
3644/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003645 * Get current number of active ports in the bridge.
3646 *
3647 * @return The number.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003648 *
3649 * \par Python:
3650 * \code
3651 count = py_pjsua.conf_get_active_ports()
3652 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003653 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003654PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
3655
3656
3657/**
3658 * Enumerate all conference ports.
3659 *
3660 * @param id Array of conference port ID to be initialized.
3661 * @param count On input, specifies max elements in the array.
3662 * On return, it contains actual number of elements
3663 * that have been initialized.
3664 *
3665 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003666 *
3667 * \par Python:
3668 * The Python functions returns list of conference port Ids:
3669 * \code
3670 [port_ids] = py_pjsua.enum_conf_ports()
3671 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003672 */
3673PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
3674 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003675
3676
3677/**
3678 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003679 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003680 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003681 * @param info Pointer to store the port info.
3682 *
3683 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003684 *
3685 * \par Python:
3686 * \code
3687 port_info = py_pjsua.conf_get_port_info(port_id)
3688 * \endcode
3689 * The function will return None if \a port_id is not valid.
Benny Prijono8b1889b2006-06-06 18:40:40 +00003690 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003691PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00003692 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003693
3694
3695/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00003696 * Add arbitrary media port to PJSUA's conference bridge. Application
3697 * can use this function to add the media port that it creates. For
3698 * media ports that are created by PJSUA-LIB (such as calls, file player,
3699 * or file recorder), PJSUA-LIB will automatically add the port to
3700 * the bridge.
3701 *
3702 * @param pool Pool to use.
3703 * @param port Media port to be added to the bridge.
3704 * @param p_id Optional pointer to receive the conference
3705 * slot id.
3706 *
3707 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003708 *
3709 * \par Python:
3710 * Not applicable (for now)
Benny Prijonoe909eac2006-07-27 22:04:56 +00003711 */
3712PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
3713 pjmedia_port *port,
3714 pjsua_conf_port_id *p_id);
3715
3716
3717/**
3718 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00003719 * call this function if it registered the port manually with previous call
3720 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00003721 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003722 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00003723 *
3724 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003725 *
3726 * \par Python:
3727 * \code
3728 status = py_pjsua.conf_remove_port(port_id)
3729 * \endcode
Benny Prijonoe909eac2006-07-27 22:04:56 +00003730 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003731PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00003732
3733
3734/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003735 * Establish unidirectional media flow from souce to sink. One source
3736 * may transmit to multiple destinations/sink. And if multiple
3737 * sources are transmitting to the same sink, the media will be mixed
3738 * together. Source and sink may refer to the same ID, effectively
3739 * looping the media.
3740 *
3741 * If bidirectional media flow is desired, application needs to call
3742 * this function twice, with the second one having the arguments
3743 * reversed.
3744 *
3745 * @param source Port ID of the source media/transmitter.
3746 * @param sink Port ID of the destination media/received.
3747 *
3748 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003749 *
3750 * \par Python:
3751 * \code
3752 status = py_pjsua.conf_connect(source, sink)
3753 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003754 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003755PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
3756 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003757
3758
3759/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003760 * Disconnect media flow from the source to destination port.
3761 *
3762 * @param source Port ID of the source media/transmitter.
3763 * @param sink Port ID of the destination media/received.
3764 *
3765 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003766 *
3767 * \par Python:
3768 * \code
3769 status = py_pjsua.conf_disconnect(source, sink)
3770 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003771 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003772PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
3773 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003774
3775
Benny Prijono6dd967c2006-12-26 02:27:14 +00003776/**
3777 * Adjust the signal level to be transmitted from the bridge to the
3778 * specified port by making it louder or quieter.
3779 *
3780 * @param slot The conference bridge slot number.
3781 * @param level Signal level adjustment. Value 1.0 means no level
3782 * adjustment, while value 0 means to mute the port.
3783 *
3784 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003785 *
3786 * \par Python:
3787 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003788 */
3789PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
3790 float level);
3791
3792/**
3793 * Adjust the signal level to be received from the specified port (to
3794 * the bridge) by making it louder or quieter.
3795 *
3796 * @param slot The conference bridge slot number.
3797 * @param level Signal level adjustment. Value 1.0 means no level
3798 * adjustment, while value 0 means to mute the port.
3799 *
3800 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003801 *
3802 * \par Python:
3803 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003804 */
3805PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
3806 float level);
3807
3808/**
3809 * Get last signal level transmitted to or received from the specified port.
3810 * The signal level is an integer value in zero to 255, with zero indicates
3811 * no signal, and 255 indicates the loudest signal level.
3812 *
3813 * @param slot The conference bridge slot number.
3814 * @param tx_level Optional argument to receive the level of signal
3815 * transmitted to the specified port (i.e. the direction
3816 * is from the bridge to the port).
3817 * @param rx_level Optional argument to receive the level of signal
3818 * received from the port (i.e. the direction is from the
3819 * port to the bridge).
3820 *
3821 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003822 *
3823 * \par Python:
3824 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003825 */
3826PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
3827 unsigned *tx_level,
3828 unsigned *rx_level);
3829
Benny Prijono6dd967c2006-12-26 02:27:14 +00003830
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003831/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00003832 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003833 */
3834
Benny Prijono9fc735d2006-05-28 14:58:12 +00003835/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003836 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003837 * the conference bridge.
3838 *
3839 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00003840 * WAV files are supported, and the WAV file MUST be
3841 * formatted as 16bit PCM mono/single channel (any
3842 * clock rate is supported).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003843 * @param options Options (currently zero).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003844 * @param p_id Pointer to receive player ID.
3845 *
3846 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003847 *
3848 * \par Python:
3849 * The function returns (status, id) tuple:
3850 * \code
3851 status, id = py_pjsua.player_create(filename, options)
3852 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003853 */
3854PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003855 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003856 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003857
3858
3859/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003860 * Create a file playlist media port, and automatically add the port
3861 * to the conference bridge.
3862 *
3863 * @param file_names Array of file names to be added to the play list.
3864 * Note that the files must have the same clock rate,
3865 * number of channels, and number of bits per sample.
3866 * @param file_count Number of files in the array.
3867 * @param label Optional label to be set for the media port.
3868 * @param options Optional option flag. Application may specify
3869 * PJMEDIA_FILE_NO_LOOP to prevent looping.
3870 * @param p_id Optional pointer to receive player ID.
3871 *
3872 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003873 *
3874 * \par Python:
3875 * Not implemented yet.
Benny Prijonoa66c3312007-01-21 23:12:40 +00003876 */
3877PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
3878 unsigned file_count,
3879 const pj_str_t *label,
3880 unsigned options,
3881 pjsua_player_id *p_id);
3882
3883/**
3884 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003885 *
3886 * @param id The file player ID.
3887 *
3888 * @return Conference port ID associated with this player.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003889 *
3890 * \par Python:
3891 * \code
3892 port_id = py_pjsua.player_get_conf_port(id)
3893 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003894 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003895PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003896
3897
3898/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003899 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00003900 *
3901 * @param id The player ID.
3902 * @param p_port The media port associated with the player.
3903 *
3904 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003905 *
3906 * \par Python:
3907 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00003908 */
3909PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_recorder_id id,
3910 pjmedia_port **p_port);
3911
3912/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003913 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003914 *
3915 * @param id The file player ID.
3916 * @param samples The playback position, in samples. Application can
3917 * specify zero to re-start the playback.
3918 *
3919 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003920 *
3921 * \par Python:
3922 * \code
3923 status = py_pjsua.player_set_pos(id, samples)
3924 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003925 */
3926PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
3927 pj_uint32_t samples);
3928
3929
3930/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003931 * Close the file of playlist, remove the player from the bridge, and free
3932 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003933 *
3934 * @param id The file player ID.
3935 *
3936 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003937 *
3938 * \par Python:
3939 * \code
3940 status = py_pjsua.player_destroy(id)
3941 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003942 */
3943PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
3944
3945
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003946/*****************************************************************************
3947 * File recorder.
3948 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00003949
3950/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003951 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00003952 * the conference bridge. The recorder currently supports recording WAV file.
3953 * The type of the recorder to use is determined by the extension of the file
3954 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003955 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00003956 * @param filename Output file name. The function will determine the
3957 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00003958 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00003959 * @param enc_type Optionally specify the type of encoder to be used to
3960 * compress the media, if the file can support different
3961 * encodings. This value must be zero for now.
3962 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00003963 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00003964 * For .WAV recorder, this value must be NULL.
3965 * @param max_size Maximum file size. Specify zero or -1 to remove size
3966 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003967 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003968 * @param p_id Pointer to receive the recorder instance.
3969 *
3970 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003971 *
3972 * \par Python:
3973 * \code
3974 status, id = py_pjsua.recorder_create(filename, enc_type, enc_param, max_size, options)
3975 * \endcode
3976 * The \a enc_param is a string in Python.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003977 */
3978PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00003979 unsigned enc_type,
3980 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003981 pj_ssize_t max_size,
3982 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003983 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003984
3985
3986/**
3987 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003988 *
3989 * @param id The recorder ID.
3990 *
3991 * @return Conference port ID associated with this recorder.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003992 *
3993 * \par Python:
3994 * \code
3995 port_id = py_pjsua.recorder_get_conf_port(id)
3996 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003997 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003998PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003999
4000
4001/**
Benny Prijono469b1522006-12-26 03:05:17 +00004002 * Get the media port for the recorder.
4003 *
4004 * @param id The recorder ID.
4005 * @param p_port The media port associated with the recorder.
4006 *
4007 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004008 *
4009 * \par Python:
4010 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004011 */
4012PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4013 pjmedia_port **p_port);
4014
4015
4016/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004017 * Destroy recorder (this will complete recording).
4018 *
4019 * @param id The recorder ID.
4020 *
4021 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004022 *
4023 * \par Python:
4024 * \code
4025 status = py_pjsua.recorder_destroy(id)
4026 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004027 */
4028PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4029
4030
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004031/*****************************************************************************
4032 * Sound devices.
4033 */
4034
Benny Prijono9fc735d2006-05-28 14:58:12 +00004035/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004036 * Enum all sound devices installed in the system.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004037 *
4038 * @param info Array of info to be initialized.
4039 * @param count On input, specifies max elements in the array.
4040 * On return, it contains actual number of elements
4041 * that have been initialized.
4042 *
4043 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004044 *
4045 *
4046 * \par Python:
4047 * The function returns list of sound device info:
4048 * \code
4049 [dev_infos] = py_pjsua.enum_snd_devs()
4050 * \endcode
4051 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00004052 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004053PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4054 unsigned *count);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004055
4056
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004057
4058/**
4059 * Get currently active sound devices. If sound devices has not been created
4060 * (for example when pjsua_start() is not called), it is possible that
4061 * the function returns PJ_SUCCESS with -1 as device IDs.
4062 *
4063 * @param capture_dev On return it will be filled with device ID of the
4064 * capture device.
4065 * @param playback_dev On return it will be filled with device ID of the
4066 * device ID of the playback device.
4067 *
4068 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004069 *
4070 * \par Python:
Benny Prijonoebdf8772007-02-01 19:25:50 +00004071 * The function takes no argument and return an (integer,integer) tuple:
Benny Prijonoe6ead542007-01-31 20:53:31 +00004072 * \code
4073 capture_dev, playback_dev = py_pjsua.get_snd_dev()
4074 * \endcode
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004075 */
4076PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4077 int *playback_dev);
4078
4079
Benny Prijono9fc735d2006-05-28 14:58:12 +00004080/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004081 * Select or change sound device. Application may call this function at
4082 * any time to replace current sound device.
4083 *
4084 * @param capture_dev Device ID of the capture device.
4085 * @param playback_dev Device ID of the playback device.
4086 *
4087 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004088 *
4089 * \par Python:
4090 * \code
4091 status = py_pjsua.set_snd_dev(capture_dev, playback_dev)
4092 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004093 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004094PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4095 int playback_dev);
4096
4097
4098/**
4099 * Set pjsua to use null sound device. The null sound device only provides
4100 * the timing needed by the conference bridge, and will not interract with
4101 * any hardware.
4102 *
4103 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004104 *
4105 * \par Python:
4106 * \code
4107 status = py_pjsua.set_null_snd_dev()
4108 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004109 */
4110PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4111
4112
Benny Prijonoe909eac2006-07-27 22:04:56 +00004113/**
4114 * Disconnect the main conference bridge from any sound devices, and let
4115 * application connect the bridge to it's own sound device/master port.
4116 *
4117 * @return The port interface of the conference bridge,
4118 * so that application can connect this to it's own
4119 * sound device or master port.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004120 *
4121 * \par Python:
4122 * Not applicable (for now).
Benny Prijonoe909eac2006-07-27 22:04:56 +00004123 */
4124PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4125
4126
Benny Prijonof20687a2006-08-04 18:27:19 +00004127/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004128 * Configure the echo canceller tail length of the sound port.
Benny Prijonof20687a2006-08-04 18:27:19 +00004129 *
4130 * @param tail_ms The tail length, in miliseconds. Set to zero to
4131 * disable AEC.
Benny Prijono5da50432006-08-07 10:24:52 +00004132 * @param options Options to be passed to #pjmedia_echo_create().
4133 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004134 *
4135 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004136 *
4137 * \par Python:
4138 * \code
4139 status = py_pjsua.set_ec(tail_ms, options)
4140 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004141 */
Benny Prijono5da50432006-08-07 10:24:52 +00004142PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004143
4144
4145/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004146 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004147 *
4148 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4149 * If AEC is disabled, the value will be zero.
4150 *
4151 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004152 *
4153 * \par Python:
4154 * \code
4155 tail_ms = py_pjsua.get_ec_tail()
4156 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004157 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004158PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004159
4160
4161
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004162/*****************************************************************************
4163 * Codecs.
4164 */
4165
4166/**
4167 * Enum all supported codecs in the system.
4168 *
4169 * @param id Array of ID to be initialized.
4170 * @param count On input, specifies max elements in the array.
4171 * On return, it contains actual number of elements
4172 * that have been initialized.
4173 *
4174 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004175 *
4176 * \par Python:
4177 * This function takes no argument and returns list of codec infos:
4178 * \code
4179 [codec_info] = py_pjsua.enum_codecs()
4180 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004181 */
4182PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4183 unsigned *count );
4184
4185
4186/**
4187 * Change codec priority.
4188 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004189 * @param codec_id Codec ID, which is a string that uniquely identify
4190 * the codec (such as "speex/8000"). Please see pjsua
4191 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004192 * @param priority Codec priority, 0-255, where zero means to disable
4193 * the codec.
4194 *
4195 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004196 *
4197 * \par Python:
4198 * \code
4199 status = py_pjsua.codec_set_priority(codec_id, priority)
4200 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004201 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004202PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004203 pj_uint8_t priority );
4204
4205
4206/**
4207 * Get codec parameters.
4208 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004209 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004210 * @param param Structure to receive codec parameters.
4211 *
4212 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004213 *
4214 * \par Python:
4215 * The Python function is experimental:
4216 * \code
4217 codec_param = py_pjsua.codec_get_param(codec_id)
4218 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004219 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004220PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004221 pjmedia_codec_param *param );
4222
4223
4224/**
4225 * Set codec parameters.
4226 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004227 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004228 * @param param Codec parameter to set.
4229 *
4230 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004231 *
4232 * \par Python:
4233 * The Python function is experimental:
4234 * \code
4235 status = py_pjsua.codec_set_param(codec_id, param)
4236 * \endcode
4237
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004238 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004239PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004240 const pjmedia_codec_param *param);
4241
4242
4243
Benny Prijono9fc735d2006-05-28 14:58:12 +00004244
Benny Prijono312aff92006-06-17 04:08:30 +00004245/**
4246 * Create UDP media transports for all the calls. This function creates
4247 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00004248 *
Benny Prijono312aff92006-06-17 04:08:30 +00004249 * @param cfg Media transport configuration. The "port" field in the
4250 * configuration is used as the start port to bind the
4251 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004252 *
4253 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004254 *
4255 * \par Python:
4256 * Not implemented yet.
Benny Prijonof3195072006-02-14 21:15:30 +00004257 */
Benny Prijono312aff92006-06-17 04:08:30 +00004258PJ_DECL(pj_status_t)
4259pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00004260
Benny Prijonodc39fe82006-05-26 12:17:46 +00004261
4262/**
Benny Prijono312aff92006-06-17 04:08:30 +00004263 * Register custom media transports to be used by calls. There must
4264 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004265 *
Benny Prijono312aff92006-06-17 04:08:30 +00004266 * @param tp The media transport array.
4267 * @param count Number of elements in the array. This number MUST
4268 * match the number of maximum calls configured when
4269 * pjsua is created.
4270 * @param auto_delete Flag to indicate whether the transports should be
4271 * destroyed when pjsua is shutdown.
4272 *
4273 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004274 *
4275 * \par Python:
4276 * Note applicable.
Benny Prijonodc39fe82006-05-26 12:17:46 +00004277 */
Benny Prijono312aff92006-06-17 04:08:30 +00004278PJ_DECL(pj_status_t)
4279pjsua_media_transports_attach( pjsua_media_transport tp[],
4280 unsigned count,
4281 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00004282
4283
Benny Prijono312aff92006-06-17 04:08:30 +00004284/**
4285 * @}
4286 */
4287
Benny Prijonof3195072006-02-14 21:15:30 +00004288
Benny Prijono268ca612006-02-07 12:34:11 +00004289
Benny Prijono312aff92006-06-17 04:08:30 +00004290/**
4291 * @}
4292 */
4293
Benny Prijonoe6ead542007-01-31 20:53:31 +00004294PJ_END_DECL
4295
Benny Prijono312aff92006-06-17 04:08:30 +00004296
Benny Prijono268ca612006-02-07 12:34:11 +00004297#endif /* __PJSUA_H__ */