blob: d78eeb78ae7441614442e4029441cbd73dda96b4 [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 Prijono4ab9fbb2007-10-12 12:14:27 +000043/* Include all PJNATH headers */
44#include <pjnath.h>
45
Benny Prijono268ca612006-02-07 12:34:11 +000046/* Include all PJLIB-UTIL headers. */
47#include <pjlib-util.h>
48
49/* Include all PJLIB headers. */
50#include <pjlib.h>
51
52
Benny Prijonoe6ead542007-01-31 20:53:31 +000053PJ_BEGIN_DECL
54
55
Benny Prijono312aff92006-06-17 04:08:30 +000056/**
Benny Prijonoe6ead542007-01-31 20:53:31 +000057 * @defgroup PJSUA_LIB PJSUA API - High Level Softphone API for C/C++ and Python
Benny Prijono312aff92006-06-17 04:08:30 +000058 * @ingroup PJSIP
59 * @brief Very high level API for constructing SIP UA applications.
60 * @{
61 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000062 * @section pjsua_api_intro A SIP User Agent API for C/C++ and Python
63 *
64 * PJSUA API is very high level API, available for C/C++ and Python language,
65 * for constructing SIP multimedia user agent
Benny Prijono312aff92006-06-17 04:08:30 +000066 * applications. It wraps together the signaling and media functionalities
67 * into an easy to use call API, provides account management, buddy
68 * management, presence, instant messaging, along with multimedia
69 * features such as conferencing, file streaming, local playback,
70 * voice recording, and so on.
71 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000072 * @subsection pjsua_for_c_cpp C/C++ Binding
Benny Prijono312aff92006-06-17 04:08:30 +000073 * Application must link with <b>pjsua-lib</b> to use this API. In addition,
74 * this library depends on the following libraries:
75 * - <b>pjsip-ua</b>,
76 * - <b>pjsip-simple</b>,
77 * - <b>pjsip-core</b>,
78 * - <b>pjmedia</b>,
79 * - <b>pjmedia-codec</b>,
80 * - <b>pjlib-util</b>, and
81 * - <b>pjlib</b>,
82 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000083 * so application must also link with these libraries as well. For more
84 * information, please refer to
85 * <A HREF="http://www.pjsip.org/using.htm">Getting Started with PJSIP</A>
86 * page.
Benny Prijono312aff92006-06-17 04:08:30 +000087 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000088 * @subsection pjsua_for_python Python Binding
89 *
90 * The Python binding for PJSUA-API is implemented by <b>py_pjsua</b>
91 * module, in <tt>pjsip-apps/py_pjsua</tt> directory. This module is
92 * built by building <tt>py_pjsua</tt> project in <tt>pjsip_apps</tt>
93 * Visual Studio workspace, or by invoking the usual <tt>setup.py</tt>
94 * Python installer script.
95 *
96 * The Python script then can import the PJSUA-API Python module by
97 * using <b>import py_pjsua</b> construct as usual.
98 *
99 *
100 * @section pjsua_samples
101 *
102 * Few samples are provided both in C and Python.
103 *
104 - @ref page_pjsip_sample_simple_pjsuaua_c\n
105 Very simple SIP User Agent with registration, call, and media, using
106 PJSUA-API, all in under 200 lines of code.
107
108 - @ref page_pjsip_samples_pjsua\n
109 This is the reference implementation for PJSIP and PJMEDIA.
110 PJSUA is a console based application, designed to be simple enough
111 to be readble, but powerful enough to demonstrate all features
112 available in PJSIP and PJMEDIA.\n
113
114 - Python sample\n
115 For a real simple Python sample application, have a look at
116 <A HREF="http://www.pjsip.org/trac/browser/pjproject/trunk/pjsip-apps/src/py_pjsua/pjsua_app.py">
117 <tt>pjsip-apps/src/py_pjsua/pjsua_app.py</tt></A> file.
118
Benny Prijono312aff92006-06-17 04:08:30 +0000119 * @section root_using_pjsua_lib Using PJSUA API
120 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000121 * Please refer to @ref PJSUA_LIB_BASE on how to create and initialize the API.
122 * And then see the Modules on the bottom of this page for more information
123 * about specific subject.
Benny Prijono312aff92006-06-17 04:08:30 +0000124 */
125
Benny Prijonoa91a0032006-02-26 21:23:45 +0000126
Benny Prijonof3195072006-02-14 21:15:30 +0000127
Benny Prijono312aff92006-06-17 04:08:30 +0000128/*****************************************************************************
129 * BASE API
130 */
131
Benny Prijonof04ffdd2006-02-21 00:11:18 +0000132/**
Benny Prijonoe6ead542007-01-31 20:53:31 +0000133 * @defgroup PJSUA_LIB_BASE PJSUA-API Basic API
Benny Prijono312aff92006-06-17 04:08:30 +0000134 * @ingroup PJSUA_LIB
135 * @brief Basic application creation/initialization, logging configuration, etc.
136 * @{
137 *
138 * The base PJSUA API controls PJSUA creation, initialization, and startup, and
139 * also provides various auxiliary functions.
140 *
141 * @section using_pjsua_lib Using PJSUA Library
142 *
143 * @subsection creating_pjsua_lib Creating PJSUA
144 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000145 * Before anything else, application must create PJSUA by calling #pjsua_create()
146 * (or <tt>py_pjsua.create()</tt> from Python).
Benny Prijono312aff92006-06-17 04:08:30 +0000147 * This, among other things, will initialize PJLIB, which is crucial before
Benny Prijonoe6ead542007-01-31 20:53:31 +0000148 * any PJLIB functions can be called, PJLIB-UTIL, and create a SIP endpoint.
149 *
150 * After this function is called, application can create a memory pool (with
151 * #pjsua_pool_create()) and read configurations from command line or file to
152 * build the settings to initialize PJSUA below.
Benny Prijono312aff92006-06-17 04:08:30 +0000153 *
154 * @subsection init_pjsua_lib Initializing PJSUA
155 *
156 * After PJSUA is created, application can initialize PJSUA by calling
Benny Prijonoe6ead542007-01-31 20:53:31 +0000157 * #pjsua_init(). This function takes several optional configuration settings
158 * in the argument, if application wants to set them.
Benny Prijono312aff92006-06-17 04:08:30 +0000159 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000160 * @subsubsection init_pjsua_lib_c_cpp PJSUA-LIB Initialization (in C)
161 * Sample code to initialize PJSUA in C code:
Benny Prijono312aff92006-06-17 04:08:30 +0000162 \code
163
Benny Prijonob5388cf2007-01-04 22:45:08 +0000164 #include <pjsua-lib/pjsua.h>
165
166 #define THIS_FILE __FILE__
167
168 static pj_status_t app_init(void)
169 {
Benny Prijono312aff92006-06-17 04:08:30 +0000170 pjsua_config ua_cfg;
171 pjsua_logging_config log_cfg;
172 pjsua_media_config media_cfg;
Benny Prijonob5388cf2007-01-04 22:45:08 +0000173 pj_status_t status;
174
175 // Must create pjsua before anything else!
176 status = pjsua_create();
177 if (status != PJ_SUCCESS) {
178 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
179 return status;
180 }
Benny Prijono312aff92006-06-17 04:08:30 +0000181
182 // Initialize configs with default settings.
183 pjsua_config_default(&ua_cfg);
184 pjsua_logging_config_default(&log_cfg);
185 pjsua_media_config_default(&media_cfg);
186
187 // At the very least, application would want to override
188 // the call callbacks in pjsua_config:
189 ua_cfg.cb.on_incoming_call = ...
190 ua_cfg.cb.on_call_state = ..
191 ...
192
193 // Customize other settings (or initialize them from application specific
194 // configuration file):
195 ...
196
197 // Initialize pjsua
198 status = pjsua_init(&ua_cfg, &log_cfg, &media_cfg);
199 if (status != PJ_SUCCESS) {
200 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
201 return status;
202 }
Benny Prijonob5388cf2007-01-04 22:45:08 +0000203 .
204 ...
205 }
Benny Prijono312aff92006-06-17 04:08:30 +0000206 \endcode
207 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000208 *
209 * @subsubsection init_pjsua_lib_python PJSUA-LIB Initialization (in Python)
210 * Sample code to initialize PJSUA in Python code:
211
212 \code
213
214import py_pjsua
215
216#
217# Initialize pjsua.
218#
219def app_init():
220 # Create pjsua before anything else
221 status = py_pjsua.create()
222 if status != 0:
223 err_exit("pjsua create() error", status)
224
225 # We use default logging config for this sample
226 log_cfg = py_pjsua.logging_config_default()
227
228 # Create and initialize pjsua config
229 # Note: for this Python module, thread_cnt must be 0 since Python
230 # doesn't like to be called from alien thread (pjsua's thread
231 # in this case)
232 ua_cfg = py_pjsua.config_default()
233 ua_cfg.thread_cnt = 0
234 ua_cfg.user_agent = "PJSUA/Python 0.1"
235
236 # Override callbacks. At the very least application would want to
237 # override the call callbacks in pjsua_config
238 ua_cfg.cb.on_incoming_call = ...
239 ua_cfg.cb.on_call_state = ...
240
241 # Use default media config for this cample
242 med_cfg = py_pjsua.media_config_default()
243
244 #
245 # Initialize pjsua!!
246 #
247 status = py_pjsua.init(ua_cfg, log_cfg, med_cfg)
248 if status != 0:
249 err_exit("pjsua init() error", status)
250
251
252
253# Utility: display PJ error and exit
254#
255def err_exit(title, rc):
256 py_pjsua.perror(THIS_FILE, title, rc)
257 exit(1)
258
259 \endcode
260
261
Benny Prijono312aff92006-06-17 04:08:30 +0000262 * @subsection other_init_pjsua_lib Other Initialization
263 *
264 * After PJSUA is initialized with #pjsua_init(), application will normally
265 * need/want to perform the following tasks:
266 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000267 * - create SIP transport with #pjsua_transport_create(). Application would
268 * to call #pjsua_transport_create() for each transport types that it
269 * wants to support (for example, UDP, TCP, and TLS). Please see
Benny Prijono312aff92006-06-17 04:08:30 +0000270 * @ref PJSUA_LIB_TRANSPORT section for more info.
271 * - create one or more SIP accounts with #pjsua_acc_add() or
Benny Prijonoe6ead542007-01-31 20:53:31 +0000272 * #pjsua_acc_add_local(). The SIP account is used for registering with
273 * the SIP server, if any. Please see @ref PJSUA_LIB_ACC for more info.
Benny Prijono312aff92006-06-17 04:08:30 +0000274 * - add one or more buddies with #pjsua_buddy_add(). Please see
275 * @ref PJSUA_LIB_BUDDY section for more info.
276 * - optionally configure the sound device, codec settings, and other
277 * media settings. Please see @ref PJSUA_LIB_MEDIA for more info.
278 *
279 *
280 * @subsection starting_pjsua_lib Starting PJSUA
281 *
282 * After all initializations have been done, application must call
283 * #pjsua_start() to start PJSUA. This function will check that all settings
Benny Prijonoe6ead542007-01-31 20:53:31 +0000284 * have been properly configured, and apply default settings when they haven't,
285 * or report error status when it is unable to recover from missing settings.
Benny Prijono312aff92006-06-17 04:08:30 +0000286 *
287 * Most settings can be changed during run-time. For example, application
288 * may add, modify, or delete accounts, buddies, or change media settings
289 * during run-time.
Benny Prijonob5388cf2007-01-04 22:45:08 +0000290 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000291 * @subsubsection starting_pjsua_lib_c C Example for Starting PJSUA
Benny Prijonob5388cf2007-01-04 22:45:08 +0000292 * Sample code:
293 \code
294 static pj_status_t app_run(void)
295 {
296 pj_status_t status;
297
298 // Start pjsua
299 status = pjsua_start();
300 if (status != PJ_SUCCESS) {
301 pjsua_destroy();
302 pjsua_perror(THIS_FILE, "Error starting pjsua", status);
303 return status;
304 }
305
306 // Run application loop
307 while (1) {
308 char choice[10];
309
310 printf("Select menu: ");
311 fgets(choice, sizeof(choice), stdin);
312 ...
313 }
314 }
315 \endcode
Benny Prijonoe6ead542007-01-31 20:53:31 +0000316
317 * @subsubsection starting_pjsua_lib_python Python Example for starting PJSUA
318 * For Python, starting PJSUA-LIB takes one more step, that is to initialize
319 * Python worker thread to poll PJSUA-LIB. This step is necessary because
320 * Python doesn't like it when it is called by an "alien" thread (that is,
321 * thread that is not created using Python API).
322 *
323 * Because of this, we cannot use a worker thread in PJSUA-LIB, because then
324 * the Python callback will be called by an "alien" thread and this would
325 * crash Python (or raise assert() probably).
326 *
327 * So because worker thread is disabled, we need to create a worker thread
328 * in Python. Note that this may not be necessary if we're creating a
329 * GUI application, because then we can attach, for example, a GUI timer
330 * object to poll the PJSUA-LIB. But because we're creating a console
331 * application which will block at <tt>sys.stdin.readline()</tt>, we need
332 * to have a worker thread to poll PJSUA-LIB.
333
334 \code
335
336import thread
337
338C_QUIT = 0
339
340
341def app_start():
342 # Done with initialization, start pjsua!!
343 #
344 status = py_pjsua.start()
345 if status != 0:
346 py_pjsua.destroy()
347 err_exit("Error starting pjsua!", status)
348
349 # Start worker thread
350 thr = thread.start_new(worker_thread_main, (0,))
351
352 print "PJSUA Started!!"
353
354#
355# Worker thread function.
356# Python doesn't like it when it's called from an alien thread
357# (pjsua's worker thread, in this case), so for Python we must
358# disable worker thread in pjsua and poll pjsua from Python instead.
359#
360def worker_thread_main(arg):
361 global C_QUIT
362 thread_desc = 0
363 status = py_pjsua.thread_register("python worker", thread_desc)
364 if status != 0:
365 py_pjsua.perror(THIS_FILE, "Error registering thread", status)
366 else:
367 while C_QUIT == 0:
368 py_pjsua.handle_events(50)
369 print "Worker thread quitting.."
370 C_QUIT = 2
371
372
373 \endcode
Benny Prijonof04ffdd2006-02-21 00:11:18 +0000374 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000375
Benny Prijono312aff92006-06-17 04:08:30 +0000376/** Constant to identify invalid ID for all sorts of IDs. */
377#define PJSUA_INVALID_ID (-1)
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000378
379/** Call identification */
380typedef int pjsua_call_id;
381
Benny Prijono312aff92006-06-17 04:08:30 +0000382/** Account identification */
383typedef int pjsua_acc_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000384
385/** Buddy identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000386typedef int pjsua_buddy_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000387
388/** File player identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000389typedef int pjsua_player_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000390
391/** File recorder identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000392typedef int pjsua_recorder_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000393
394/** Conference port identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000395typedef int pjsua_conf_port_id;
396
397
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000398
Benny Prijonoa91a0032006-02-26 21:23:45 +0000399/**
Benny Prijono312aff92006-06-17 04:08:30 +0000400 * Maximum proxies in account.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000401 */
Benny Prijono312aff92006-06-17 04:08:30 +0000402#ifndef PJSUA_ACC_MAX_PROXIES
403# define PJSUA_ACC_MAX_PROXIES 8
404#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000405
Benny Prijonod8179652008-01-23 20:39:07 +0000406#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000407
Benny Prijonod8179652008-01-23 20:39:07 +0000408/**
409 * Default value of SRTP mode usage. Valid values are PJMEDIA_SRTP_DISABLED,
410 * PJMEDIA_SRTP_OPTIONAL, and PJMEDIA_SRTP_MANDATORY.
411 */
412#ifndef PJSUA_DEFAULT_USE_SRTP
413 #define PJSUA_DEFAULT_USE_SRTP PJMEDIA_SRTP_DISABLED
414#endif
415
416/**
417 * Default value of secure signaling requirement for SRTP.
418 * Valid values are:
419 * 0: SRTP does not require secure signaling
420 * 1: SRTP requires secure transport such as TLS
421 * 2: SRTP requires secure end-to-end transport (SIPS)
422 */
423#ifndef PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
424 #define PJSUA_DEFAULT_SRTP_SECURE_SIGNALING 1
425#endif
426
427#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000428
429/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000430 * Logging configuration, which can be (optionally) specified when calling
431 * #pjsua_init(). Application must call #pjsua_logging_config_default() to
432 * initialize this structure with the default values.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000433 *
434 * \par Sample Python Syntax:
435 * \code
436 # Python type: py_pjsua.Logging_Config
437
438 log_cfg = py_pjsua.logging_config_default()
439 log_cfg.level = 4
440 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000441 */
442typedef struct pjsua_logging_config
443{
444 /**
445 * Log incoming and outgoing SIP message? Yes!
446 */
447 pj_bool_t msg_logging;
448
449 /**
450 * Input verbosity level. Value 5 is reasonable.
451 */
452 unsigned level;
453
454 /**
455 * Verbosity level for console. Value 4 is reasonable.
456 */
457 unsigned console_level;
458
459 /**
460 * Log decoration.
461 */
462 unsigned decor;
463
464 /**
465 * Optional log filename.
466 */
467 pj_str_t log_filename;
468
469 /**
470 * Optional callback function to be called to write log to
471 * application specific device. This function will be called for
472 * log messages on input verbosity level.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000473 *
474 * \par Sample Python Syntax:
475 * \code
476 # level: integer
477 # data: string
478 # len: integer
479
480 def cb(level, data, len):
481 print data,
482 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000483 */
Benny Prijonofe7d87b2007-11-29 11:35:44 +0000484 void (*cb)(int level, const char *data, int len);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000485
486
487} pjsua_logging_config;
488
489
490/**
491 * Use this function to initialize logging config.
492 *
493 * @param cfg The logging config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000494 *
495 * \par Python Syntax:
496 * The Python function instantiates and initialize the logging config:
497 * \code
498 logging_cfg = py_pjsua.logging_config_default()
499 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000500 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000501PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000502
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000503
504/**
505 * Use this function to duplicate logging config.
506 *
507 * @param pool Pool to use.
508 * @param dst Destination config.
509 * @param src Source config.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000510 *
511 * \par Python Syntax:
512 * Not available (for now). Ideally we should be able to just assign
513 * one config to another, but this has not been tested.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000514 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000515PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool,
516 pjsua_logging_config *dst,
517 const pjsua_logging_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000518
Benny Prijonodc39fe82006-05-26 12:17:46 +0000519
520/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000521 * This structure describes application callback to receive various event
522 * notification from PJSUA-API. All of these callbacks are OPTIONAL,
523 * although definitely application would want to implement some of
524 * the important callbacks (such as \a on_incoming_call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000525 *
526 * \par Python Syntax:
527 * This callback structure is embedded on pjsua_config structure.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000528 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000529typedef struct pjsua_callback
Benny Prijonodc39fe82006-05-26 12:17:46 +0000530{
531 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000532 * Notify application when invite state has changed.
533 * Application may then query the call info to get the
Benny Prijonoe6ead542007-01-31 20:53:31 +0000534 * detail call states by calling pjsua_call_get_info() function.
Benny Prijono0875ae82006-12-26 00:11:48 +0000535 *
536 * @param call_id The call index.
537 * @param e Event which causes the call state to change.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000538 *
539 * \par Python Syntax:
540 * \code
541 # call_id: integer
542 # e: an opaque object
543
544 def on_call_state(call_id, e):
545 return
546 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000547 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000548 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000549
550 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000551 * Notify application on incoming call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000552 *
553 * @param acc_id The account which match the incoming call.
554 * @param call_id The call id that has just been created for
555 * the call.
556 * @param rdata The incoming INVITE request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000557 *
558 * \par Python Syntax:
559 * \code
560 # acc_id: integer
561 # call_id: integer
562 # rdata: an opaque object
563
564 def on_incoming_call(acc_id, call_id, rdata):
565 return
566 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +0000567 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000568 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000569 pjsip_rx_data *rdata);
570
571 /**
Benny Prijonofeb69f42007-10-05 09:12:26 +0000572 * This is a general notification callback which is called whenever
573 * a transaction within the call has changed state. Application can
574 * implement this callback for example to monitor the state of
575 * outgoing requests, or to answer unhandled incoming requests
576 * (such as INFO) with a final response.
577 *
578 * @param call_id Call identification.
579 * @param tsx The transaction which has changed state.
580 * @param e Transaction event that caused the state change.
581 */
582 void (*on_call_tsx_state)(pjsua_call_id call_id,
583 pjsip_transaction *tsx,
584 pjsip_event *e);
585
586 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000587 * Notify application when media state in the call has changed.
588 * Normal application would need to implement this callback, e.g.
Benny Prijono6ba8c542007-10-16 01:34:14 +0000589 * to connect the call's media to sound device. When ICE is used,
590 * this callback will also be called to report ICE negotiation
591 * failure.
Benny Prijono0875ae82006-12-26 00:11:48 +0000592 *
593 * @param call_id The call index.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000594 *
595 * \par Python Syntax:
596 * \code
597 # call_id: integer
598
599 def on_call_media_state(call_id):
600 return
601 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000602 */
603 void (*on_call_media_state)(pjsua_call_id call_id);
604
605 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000606 * Notify application upon incoming DTMF digits.
607 *
608 * @param call_id The call index.
609 * @param digit DTMF ASCII digit.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000610 *
611 * \par Python Syntax:
612 * \code
613 # call_id: integer
Benny Prijono1f63cc42007-09-10 16:54:22 +0000614 # digit: digit string
Benny Prijonoe6ead542007-01-31 20:53:31 +0000615
616 def on_dtmf_digit(call_id, digit):
617 return
618 * \endcode
Benny Prijono0875ae82006-12-26 00:11:48 +0000619 */
620 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
621
622 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000623 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000624 * Application can decide to accept/reject transfer request
625 * by setting the code (default is 200). When this callback
626 * is not defined, the default behavior is to accept the
627 * transfer.
Benny Prijono0875ae82006-12-26 00:11:48 +0000628 *
629 * @param call_id The call index.
630 * @param dst The destination where the call will be
631 * transfered to.
632 * @param code Status code to be returned for the call transfer
633 * request. On input, it contains status code 200.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000634 *
635 * \par Python Syntax:
636 * \code
637 # call_id: integer
638 # dst: string
639 # code: integer
640
641 def on_call_transfer_request(call_id, dst, code):
642 return code
643
644 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000645 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000646 void (*on_call_transfer_request)(pjsua_call_id call_id,
647 const pj_str_t *dst,
648 pjsip_status_code *code);
649
650 /**
651 * Notify application of the status of previously sent call
652 * transfer request. Application can monitor the status of the
653 * call transfer request, for example to decide whether to
654 * terminate existing call.
655 *
656 * @param call_id Call ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000657 * @param st_code Status progress of the transfer request.
658 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000659 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000660 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000661 * this callback is the final status.
662 * @param p_cont Initially will be set to non-zero, application
663 * can set this to FALSE if it no longer wants
664 * to receie further notification (for example,
665 * after it hangs up the call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000666 *
667 * \par Python Syntax:
668 * \code
669 # call_id: integer
670 # st_code: integer
671 # st_text: string
672 # final: integer
673 # cont: integer
674
675 # return: cont
676
677 def on_call_transfer_status(call_id, st_code, st_text, final, cont):
678 return cont
679 * \endcode
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000680 */
681 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000682 int st_code,
683 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000684 pj_bool_t final,
685 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000686
687 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000688 * Notify application about incoming INVITE with Replaces header.
689 * Application may reject the request by setting non-2xx code.
690 *
691 * @param call_id The call ID to be replaced.
692 * @param rdata The incoming INVITE request to replace the call.
693 * @param st_code Status code to be set by application. Application
694 * should only return a final status (200-699).
695 * @param st_text Optional status text to be set by application.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000696 *
697 * \par Python Syntax:
698 * \code
699 # call_id: integer
700 # rdata: an opaque object
701 # st_code: integer
702 # st_text: string
703
704 # return: (st_code, st_text) tuple
705
706 def on_call_replace_request(call_id, rdata, st_code, st_text):
707 return st_code, st_text
708 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000709 */
710 void (*on_call_replace_request)(pjsua_call_id call_id,
711 pjsip_rx_data *rdata,
712 int *st_code,
713 pj_str_t *st_text);
714
715 /**
716 * Notify application that an existing call has been replaced with
717 * a new call. This happens when PJSUA-API receives incoming INVITE
718 * request with Replaces header.
719 *
720 * After this callback is called, normally PJSUA-API will disconnect
721 * \a old_call_id and establish \a new_call_id.
722 *
723 * @param old_call_id Existing call which to be replaced with the
724 * new call.
725 * @param new_call_id The new call.
726 * @param rdata The incoming INVITE with Replaces request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000727 *
728 * \par Python Syntax:
729 * \code
730 # old_call_id: integer
731 # new_call_id: integer
732
733 def on_call_replaced(old_call_id, new_call_id):
734 return
735 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000736 */
737 void (*on_call_replaced)(pjsua_call_id old_call_id,
738 pjsua_call_id new_call_id);
739
740
741 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000742 * Notify application when registration status has changed.
743 * Application may then query the account info to get the
744 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000745 *
746 * @param acc_id Account ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000747 *
748 * \par Python Syntax:
749 * \code
750 # acc_id: account ID (integer)
751
752 def on_reg_state(acc_id):
753 return
754 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000755 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000756 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000757
758 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000759 * Notify application when the buddy state has changed.
760 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000761 *
762 * @param buddy_id The buddy id.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000763 *
764 * \par Python Syntax:
765 * \code
766 # buddy_id: integer
767
768 def on_buddy_state(buddy_id):
769 return
770 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000771 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000772 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000773
774 /**
775 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000776 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000777 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000778 *
Benny Prijonobbeb3992007-05-21 13:48:35 +0000779 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
780 * passed as one of the argument.
781 *
Benny Prijono0875ae82006-12-26 00:11:48 +0000782 * @param call_id Containts the ID of the call where the IM was
783 * sent, or PJSUA_INVALID_ID if the IM was sent
784 * outside call context.
785 * @param from URI of the sender.
786 * @param to URI of the destination message.
787 * @param contact The Contact URI of the sender, if present.
788 * @param mime_type MIME type of the message.
789 * @param body The message content.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000790 *
791 * \par Python Syntax:
792 * \code
793 # call_id: integer
794 # from: string
795 # to: string
796 # contact: string
797 # mime_type: string
798 # body: string
799
800 def on_pager(call_id, from, to, contact, mime_type, body):
801 return
802 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000803 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000804 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
805 const pj_str_t *to, const pj_str_t *contact,
806 const pj_str_t *mime_type, const pj_str_t *body);
807
808 /**
Benny Prijonobbeb3992007-05-21 13:48:35 +0000809 * This is the alternative version of the \a on_pager() callback with
810 * \a pjsip_rx_data argument.
811 *
812 * @param call_id Containts the ID of the call where the IM was
813 * sent, or PJSUA_INVALID_ID if the IM was sent
814 * outside call context.
815 * @param from URI of the sender.
816 * @param to URI of the destination message.
817 * @param contact The Contact URI of the sender, if present.
818 * @param mime_type MIME type of the message.
819 * @param body The message content.
820 * @param rdata The incoming MESSAGE request.
821 */
822 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
823 const pj_str_t *to, const pj_str_t *contact,
824 const pj_str_t *mime_type, const pj_str_t *body,
825 pjsip_rx_data *rdata);
826
827 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000828 * Notify application about the delivery status of outgoing pager
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000829 * request. See also on_pager_status2() callback for the version with
830 * \a pjsip_rx_data in the argument list.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000831 *
832 * @param call_id Containts the ID of the call where the IM was
833 * sent, or PJSUA_INVALID_ID if the IM was sent
834 * outside call context.
835 * @param to Destination URI.
836 * @param body Message body.
837 * @param user_data Arbitrary data that was specified when sending
838 * IM message.
839 * @param status Delivery status.
840 * @param reason Delivery status reason.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000841 *
842 * \par Python Syntax
843 * \code
844 # call_id: integer
845 # to: string
846 # body: string
847 # user_data: string
848 # status: integer
849 # reason: string
850
851 def on_pager_status(call_id, to, body, user_data, status, reason):
852 return
853 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000854 */
855 void (*on_pager_status)(pjsua_call_id call_id,
856 const pj_str_t *to,
857 const pj_str_t *body,
858 void *user_data,
859 pjsip_status_code status,
860 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000861
862 /**
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000863 * Notify application about the delivery status of outgoing pager
864 * request.
865 *
866 * @param call_id Containts the ID of the call where the IM was
867 * sent, or PJSUA_INVALID_ID if the IM was sent
868 * outside call context.
869 * @param to Destination URI.
870 * @param body Message body.
871 * @param user_data Arbitrary data that was specified when sending
872 * IM message.
873 * @param status Delivery status.
874 * @param reason Delivery status reason.
Benny Prijono0a982002007-06-12 16:22:09 +0000875 * @param tdata The original MESSAGE request.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000876 * @param rdata The incoming MESSAGE response, or NULL if the
877 * message transaction fails because of time out
878 * or transport error.
879 */
880 void (*on_pager_status2)(pjsua_call_id call_id,
881 const pj_str_t *to,
882 const pj_str_t *body,
883 void *user_data,
884 pjsip_status_code status,
885 const pj_str_t *reason,
Benny Prijono0a982002007-06-12 16:22:09 +0000886 pjsip_tx_data *tdata,
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000887 pjsip_rx_data *rdata);
888
889 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000890 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +0000891 *
892 * @param call_id Containts the ID of the call where the IM was
893 * sent, or PJSUA_INVALID_ID if the IM was sent
894 * outside call context.
895 * @param from URI of the sender.
896 * @param to URI of the destination message.
897 * @param contact The Contact URI of the sender, if present.
898 * @param is_typing Non-zero if peer is typing, or zero if peer
899 * has stopped typing a message.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000900 *
901 * \par Python Syntax
902 * \code
903 # call_id: string
904 # from: string
905 # to: string
906 # contact: string
907 # is_typing: integer
908
909 def on_typing(call_id, from, to, contact, is_typing):
910 return
911 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000912 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000913 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
914 const pj_str_t *to, const pj_str_t *contact,
915 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000916
Benny Prijono6ba8c542007-10-16 01:34:14 +0000917 /**
918 * Callback when the library has finished performing NAT type
919 * detection.
920 *
921 * @param res NAT detection result.
922 */
923 void (*on_nat_detect)(const pj_stun_nat_detect_result *res);
924
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000925} pjsua_callback;
926
927
928
Benny Prijonodc39fe82006-05-26 12:17:46 +0000929
930/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000931 * This structure describes the settings to control the API and
932 * user agent behavior, and can be specified when calling #pjsua_init().
933 * Before setting the values, application must call #pjsua_config_default()
934 * to initialize this structure with the default values.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000935 *
936 * \par Python Sample Syntax:
937 * The pjsua_config type in Python is <tt>py_pjsua.Config</tt>. Application
938 * creates the instance by calling <tt>py_pjsua.config_default()</tt>:
939 * \code
940 cfg = py_pjsua.config_default()
941 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000942 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000943typedef struct pjsua_config
944{
945
946 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000947 * Maximum calls to support (default: 4). The value specified here
948 * must be smaller than the compile time maximum settings
949 * PJSUA_MAX_CALLS, which by default is 32. To increase this
950 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
951 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000952 */
953 unsigned max_calls;
954
955 /**
956 * Number of worker threads. Normally application will want to have at
957 * least one worker thread, unless when it wants to poll the library
958 * periodically, which in this case the worker thread can be set to
959 * zero.
960 */
961 unsigned thread_cnt;
962
963 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +0000964 * Number of nameservers. If no name server is configured, the SIP SRV
965 * resolution would be disabled, and domain will be resolved with
966 * standard pj_gethostbyname() function.
967 */
968 unsigned nameserver_count;
969
970 /**
971 * Array of nameservers to be used by the SIP resolver subsystem.
972 * The order of the name server specifies the priority (first name
973 * server will be used first, unless it is not reachable).
974 */
975 pj_str_t nameserver[4];
976
977 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000978 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000979 */
980 unsigned outbound_proxy_cnt;
981
982 /**
983 * Specify the URL of outbound proxies to visit for all outgoing requests.
984 * The outbound proxies will be used for all accounts, and it will
985 * be used to build the route set for outgoing requests. The final
986 * route set for outgoing requests will consists of the outbound proxies
987 * and the proxy configured in the account.
988 */
989 pj_str_t outbound_proxy[4];
990
Benny Prijonoc97608e2007-03-23 16:34:20 +0000991 /**
Benny Prijonoebbf6892007-03-24 17:37:25 +0000992 * Specify domain name to be resolved with DNS SRV resolution to get the
993 * address of the STUN servers. Alternatively application may specify
994 * \a stun_host and \a stun_relay_host instead.
995 *
996 * If DNS SRV resolution failed for this domain, then DNS A resolution
997 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +0000998 */
Benny Prijonoebbf6892007-03-24 17:37:25 +0000999 pj_str_t stun_domain;
1000
1001 /**
Benny Prijonoaf09dc32007-04-22 12:48:30 +00001002 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
1003 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001004 */
1005 pj_str_t stun_host;
1006
1007 /**
1008 * Specify STUN relay server to be used.
1009 */
1010 pj_str_t stun_relay_host;
Benny Prijonoc97608e2007-03-23 16:34:20 +00001011
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001012 /**
Benny Prijono91a6a172007-10-31 08:59:29 +00001013 * Support for adding and parsing NAT type in the SDP to assist
1014 * troubleshooting. The valid values are:
1015 * - 0: no information will be added in SDP, and parsing is disabled.
Benny Prijono6ba8c542007-10-16 01:34:14 +00001016 * - 1: only the NAT type number is added.
1017 * - 2: add both NAT type number and name.
1018 *
Benny Prijono91a6a172007-10-31 08:59:29 +00001019 * Default: 1
Benny Prijono6ba8c542007-10-16 01:34:14 +00001020 */
1021 int nat_type_in_sdp;
1022
1023 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001024 * Specify whether support for reliable provisional response (100rel and
1025 * PRACK) should be required by default. Note that this setting can be
1026 * further customized in account configuration (#pjsua_acc_config).
1027 *
1028 * Default: PJ_FALSE
1029 */
1030 pj_bool_t require_100rel;
1031
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001032 /**
1033 * Number of credentials in the credential array.
1034 */
1035 unsigned cred_count;
1036
1037 /**
1038 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +00001039 * and can be used to authenticate against outbound proxies. If the
1040 * credential is specific to the account, then application should set
1041 * the credential in the pjsua_acc_config rather than the credential
1042 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001043 */
1044 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1045
1046 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001047 * Application callback to receive various event notifications from
1048 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001049 */
1050 pjsua_callback cb;
1051
Benny Prijono56315612006-07-18 14:39:40 +00001052 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001053 * Optional user agent string (default empty). If it's empty, no
1054 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +00001055 */
1056 pj_str_t user_agent;
1057
Benny Prijonod8179652008-01-23 20:39:07 +00001058#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
1059 /**
1060 * Specify default value of secure media transport usage.
1061 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
1062 * PJMEDIA_SRTP_MANDATORY.
1063 *
1064 * Note that this setting can be further customized in account
1065 * configuration (#pjsua_acc_config).
1066 *
1067 * Default: #PJSUA_DEFAULT_USE_SRTP
1068 */
1069 pjmedia_srtp_use use_srtp;
1070
1071 /**
1072 * Specify whether SRTP requires secure signaling to be used. This option
1073 * is only used when \a use_srtp option above is non-zero.
1074 *
1075 * Valid values are:
1076 * 0: SRTP does not require secure signaling
1077 * 1: SRTP requires secure transport such as TLS
1078 * 2: SRTP requires secure end-to-end transport (SIPS)
1079 *
1080 * Note that this setting can be further customized in account
1081 * configuration (#pjsua_acc_config).
1082 *
1083 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
1084 */
1085 int srtp_secure_signaling;
1086#endif
1087
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001088} pjsua_config;
1089
1090
1091/**
1092 * Use this function to initialize pjsua config.
1093 *
1094 * @param cfg pjsua config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001095 *
1096 * \par Python Sample Syntax:
1097 * The corresponding Python function creates an instance of the config and
1098 * initializes it to the default settings:
1099 * \code
1100 cfg = py_pjsua.config_default()
1101 * \endcode
1102
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001103 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001104PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001105
1106
Benny Prijono7977f9f2007-10-10 11:37:56 +00001107/* The implementation has been moved to sip_auth.h */
1108#define pjsip_cred_dup pjsip_cred_info_dup
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001109
1110
1111/**
1112 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001113 *
1114 * @param pool The pool to get memory from.
1115 * @param dst Destination config.
1116 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001117 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001118PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1119 pjsua_config *dst,
1120 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001121
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001122
1123/**
1124 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001125 * outgoing SIP message. It can (optionally) be specified for example
1126 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1127 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1128 *
1129 * Application MUST call #pjsua_msg_data_init() to initialize this
1130 * structure before setting its values.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001131 *
1132 * \par Python Syntax
1133 * The data type in Python is <tt>py_pjsua.Msg_Data</tt>. Application is
1134 * recommended to instantiate the structure by using this construct:
1135 * \code
1136 msg_data = py_pjsua.msg_data_init()
1137 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001138 */
1139typedef struct pjsua_msg_data
1140{
1141 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001142 * Additional message headers as linked list. Application can add
1143 * headers to the list by creating the header, either from the heap/pool
1144 * or from temporary local variable, and add the header using
1145 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001146 *
1147 * \par Python:
1148 * This field is implemented as string linked-list in Python, where each
1149 * string describes the header. For example:
1150 \code
1151 msg_data = py_pjsua.Msg_Data()
1152 msg_data.hdr_list = ["Subject: Hello py_pjsua!", "Priority: very low"]
1153 \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001154 */
1155 pjsip_hdr hdr_list;
1156
1157 /**
1158 * MIME type of optional message body.
1159 */
1160 pj_str_t content_type;
1161
1162 /**
1163 * Optional message body.
1164 */
1165 pj_str_t msg_body;
1166
1167} pjsua_msg_data;
1168
1169
1170/**
1171 * Initialize message data.
1172 *
1173 * @param msg_data Message data to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001174 *
1175 * \par Python
1176 * The corresponding Python function creates and initializes the structure:
1177 * \code
1178 msg_data = py_pjsua.msg_data_init()
1179 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001180 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001181PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001182
Benny Prijono268ca612006-02-07 12:34:11 +00001183
1184/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001185 * Instantiate pjsua application. Application must call this function before
1186 * calling any other functions, to make sure that the underlying libraries
1187 * are properly initialized. Once this function has returned success,
1188 * application must call pjsua_destroy() before quitting.
1189 *
1190 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001191 *
1192 * \par Python:
1193 * \code
1194 status = py_pjsua.create()
1195 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001196 */
1197PJ_DECL(pj_status_t) pjsua_create(void);
1198
1199
Benny Prijonoe6ead542007-01-31 20:53:31 +00001200/* Forward declaration */
1201typedef struct pjsua_media_config pjsua_media_config;
1202
1203
Benny Prijonodc39fe82006-05-26 12:17:46 +00001204/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001205 * Initialize pjsua with the specified settings. All the settings are
1206 * optional, and the default values will be used when the config is not
1207 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001208 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001209 * Note that #pjsua_create() MUST be called before calling this function.
1210 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001211 * @param ua_cfg User agent configuration.
1212 * @param log_cfg Optional logging configuration.
1213 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001214 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001215 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001216 *
1217 * \par Python:
1218 * The function is similar in Python:
1219 * \code
1220 status = py_pjsua.init(ua_cfg, log_cfg, media_cfg)
1221 * \endcode
1222 * Note that \a ua_cfg, \a log_cfg, and \a media_cfg are optional, and
1223 * the Python script may pass None if it doesn't want to configure the
1224 * setting.
Benny Prijono268ca612006-02-07 12:34:11 +00001225 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001226PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1227 const pjsua_logging_config *log_cfg,
1228 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001229
1230
1231/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001232 * Application is recommended to call this function after all initialization
1233 * is done, so that the library can do additional checking set up
1234 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001235 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001236 * Application may call this function anytime after #pjsua_init().
1237 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001238 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001239 *
1240 * \par Python:
1241 * The function is similar in Python:
1242 * \code
1243 status = py_pjsua.start()
1244 * \endcode
Benny Prijonoccf95622006-02-07 18:48:01 +00001245 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001246PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001247
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001248
Benny Prijonoccf95622006-02-07 18:48:01 +00001249/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001250 * Destroy pjsua. Application is recommended to perform graceful shutdown
1251 * before calling this function (such as unregister the account from the SIP
1252 * server, terminate presense subscription, and hangup active calls), however,
1253 * this function will do all of these if it finds there are active sessions
1254 * that need to be terminated. This function will approximately block for
1255 * one second to wait for replies from remote.
1256 *
1257 * Application.may safely call this function more than once if it doesn't
1258 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001259 *
1260 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001261 *
1262 * \par Python:
1263 * The function is similar in Python:
1264 * \code
1265 status = py_pjsua.destroy()
1266 * \endcode
Benny Prijono268ca612006-02-07 12:34:11 +00001267 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001268PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001269
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001270
Benny Prijono9fc735d2006-05-28 14:58:12 +00001271/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001272 * Poll pjsua for events, and if necessary block the caller thread for
1273 * the specified maximum interval (in miliseconds).
1274 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001275 * Application doesn't normally need to call this function if it has
1276 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1277 * because polling then will be done by these worker threads instead.
1278 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001279 * @param msec_timeout Maximum time to wait, in miliseconds.
1280 *
1281 * @return The number of events that have been handled during the
1282 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001283 * can retrieve the error as (status = -return_value).
1284 *
1285 * \par Python:
1286 * The function is similar in Python:
1287 * \code
1288 n = py_pjsua.handle_events(msec_timeout)
1289 * \endcode
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001290 */
1291PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1292
1293
1294/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001295 * Create memory pool to be used by the application. Once application
1296 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001297 *
1298 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001299 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001300 * @param increment Increment size.
1301 *
1302 * @return The pool, or NULL when there's no memory.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001303 *
1304 * \par Python:
1305 * Python script may also create a pool object from the script:
1306 * \code
1307 pool = py_pjsua.pool_create(name, init_size, increment)
1308 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001309 */
1310PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1311 pj_size_t increment);
1312
1313
1314/**
1315 * Application can call this function at any time (after pjsua_create(), of
1316 * course) to change logging settings.
1317 *
1318 * @param c Logging configuration.
1319 *
1320 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001321 *
1322 * \par Python:
1323 * The function is similar in Python:
1324 * \code
1325 status = py_pjsua.reconfigure_logging(log_cfg)
1326 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001327 */
1328PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1329
1330
1331/**
1332 * Internal function to get SIP endpoint instance of pjsua, which is
1333 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001334 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001335 *
1336 * @return SIP endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001337 *
1338 * \par Python:
1339 * Application may retrieve the SIP endpoint instance:
1340 * \code
1341 endpt = py_pjsua.get_pjsip_endpt()
1342 * \endcode
1343 * However currently the object is just an opaque object and does not have
1344 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001345 */
1346PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1347
1348/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001349 * Internal function to get media endpoint instance.
1350 * Only valid after #pjsua_init() is called.
1351 *
1352 * @return Media endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001353 *
1354 * \par Python:
1355 * Application may retrieve the media endpoint instance:
1356 * \code
1357 endpt = py_pjsua.get_pjmedia_endpt()
1358 * \endcode
1359 * However currently the object is just an opaque object and does not have
1360 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001361 */
1362PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1363
Benny Prijono97b87172006-08-24 14:25:14 +00001364/**
1365 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001366 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001367 *
1368 * @return Pool factory currently used by PJSUA.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001369 *
1370 * \par Python:
1371 * Application may retrieve the pool factory instance:
1372 * \code
1373 endpt = py_pjsua.get_pool_factory()
1374 * \endcode
1375 * However currently the object is just an opaque object and does not have
1376 * any use for Python scripts.
Benny Prijono97b87172006-08-24 14:25:14 +00001377 */
1378PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1379
1380
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001381
1382/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001383 * Utilities.
1384 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001385 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001386
1387/**
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001388 * This is a utility function to detect NAT type in front of this
1389 * endpoint. Once invoked successfully, this function will complete
Benny Prijono6ba8c542007-10-16 01:34:14 +00001390 * asynchronously and report the result in \a on_nat_detect() callback
1391 * of pjsua_callback.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001392 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001393 * After NAT has been detected and the callback is called, application can
1394 * get the detected NAT type by calling #pjsua_get_nat_type(). Application
1395 * can also perform NAT detection by calling #pjsua_detect_nat_type()
1396 * again at later time.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001397 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001398 * Note that STUN must be enabled to run this function successfully.
1399 *
1400 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001401 */
Benny Prijono6ba8c542007-10-16 01:34:14 +00001402PJ_DECL(pj_status_t) pjsua_detect_nat_type(void);
1403
1404
1405/**
1406 * Get the NAT type as detected by #pjsua_detect_nat_type() function.
1407 * This function will only return useful NAT type after #pjsua_detect_nat_type()
1408 * has completed successfully and \a on_nat_detect() callback has been called.
1409 *
1410 * @param type NAT type.
1411 *
1412 * @return When detection is in progress, this function will
1413 * return PJ_EPENDING and \a type will be set to
1414 * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been
1415 * detected successfully, this function will return
1416 * PJ_SUCCESS and \a type will be set to the correct
1417 * value. Other return values indicate error and
1418 * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN.
Benny Prijono91a6a172007-10-31 08:59:29 +00001419 *
1420 * @see pjsua_call_get_rem_nat_type()
Benny Prijono6ba8c542007-10-16 01:34:14 +00001421 */
1422PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type);
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001423
1424
1425/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001426 * This is a utility function to verify that valid SIP url is given. If the
1427 * URL is valid, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001428 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001429 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001430 *
1431 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001432 *
1433 * \par Python:
1434 * \code
1435 status = py_pjsua.verify_sip_url(url)
1436 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001437 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001438PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001439
1440
1441/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001442 * This is a utility function to display error message for the specified
1443 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001444 *
1445 * @param sender The log sender field.
1446 * @param title Message title for the error.
1447 * @param status Status code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001448 *
1449 * \par Python:
1450 * \code
1451 py_pjsua.perror(sender, title, status)
1452 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001453 */
1454PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1455 pj_status_t status);
1456
1457
Benny Prijonoda9785b2007-04-02 20:43:06 +00001458/**
1459 * This is a utility function to dump the stack states to log, using
1460 * verbosity level 3.
1461 *
1462 * @param detail Will print detailed output (such as list of
1463 * SIP transactions) when non-zero.
1464 */
1465PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001466
1467/**
1468 * @}
1469 */
1470
1471
1472
1473/*****************************************************************************
1474 * TRANSPORT API
1475 */
1476
1477/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001478 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001479 * @ingroup PJSUA_LIB
1480 * @brief API for managing SIP transports
1481 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001482 *
1483 * PJSUA-API supports creating multiple transport instances, for example UDP,
1484 * TCP, and TLS transport. SIP transport must be created before adding an
1485 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001486 */
1487
1488
Benny Prijonoe6ead542007-01-31 20:53:31 +00001489/** SIP transport identification.
1490 */
Benny Prijono312aff92006-06-17 04:08:30 +00001491typedef int pjsua_transport_id;
1492
1493
1494/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001495 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001496 * and media. Before setting some values to this structure, application
1497 * MUST call #pjsua_transport_config_default() to initialize its
1498 * values with default settings.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001499 *
1500 * \par Python:
1501 * The data type in Python is <tt>py_pjsua.Transport_Config</tt>,
1502 * although application can just do this to create the instance:
1503 * \code
1504 transport_cfg = py_pjsua.transport_config_default()
1505 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001506 */
1507typedef struct pjsua_transport_config
1508{
1509 /**
1510 * UDP port number to bind locally. This setting MUST be specified
1511 * even when default port is desired. If the value is zero, the
1512 * transport will be bound to any available port, and application
1513 * can query the port by querying the transport info.
1514 */
1515 unsigned port;
1516
1517 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001518 * Optional address to advertise as the address of this transport.
1519 * Application can specify any address or hostname for this field,
1520 * for example it can point to one of the interface address in the
1521 * system, or it can point to the public address of a NAT router
1522 * where port mappings have been configured for the application.
1523 *
1524 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001525 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001526 pj_str_t public_addr;
1527
1528 /**
1529 * Optional address where the socket should be bound to. This option
1530 * SHOULD only be used to selectively bind the socket to particular
1531 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1532 * published address of a transport (the public_addr field should be
1533 * used for that purpose).
1534 *
1535 * Note that unlike public_addr field, the address (or hostname) here
1536 * MUST correspond to the actual interface address in the host, since
1537 * this address will be specified as bind() argument.
1538 */
1539 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001540
1541 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001542 * This specifies TLS settings for TLS transport. It is only be used
1543 * when this transport config is being used to create a SIP TLS
1544 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001545 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001546 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001547
Benny Prijono312aff92006-06-17 04:08:30 +00001548} pjsua_transport_config;
1549
1550
1551/**
1552 * Call this function to initialize UDP config with default values.
1553 *
1554 * @param cfg The UDP config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001555 *
1556 * \par Python:
1557 * The corresponding Python function is rather different:
1558 * \code
1559 transport_cfg = py_pjsua.transport_config_default()
1560 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001561 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001562PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001563
1564
1565/**
Benny Prijono312aff92006-06-17 04:08:30 +00001566 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001567 *
1568 * @param pool The pool.
1569 * @param dst The destination config.
1570 * @param src The source config.
1571 *
1572 * \par Python:
1573 * Not applicable. One should be able to just copy one variable instance
1574 * to another in Python.
Benny Prijono312aff92006-06-17 04:08:30 +00001575 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001576PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1577 pjsua_transport_config *dst,
1578 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001579
1580
1581/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001582 * This structure describes transport information returned by
1583 * #pjsua_transport_get_info() function.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001584 *
1585 * \par Python:
1586 * The corresponding data type in Python is <tt>py_pjsua.Transport_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001587 */
1588typedef struct pjsua_transport_info
1589{
1590 /**
1591 * PJSUA transport identification.
1592 */
1593 pjsua_transport_id id;
1594
1595 /**
1596 * Transport type.
1597 */
1598 pjsip_transport_type_e type;
1599
1600 /**
1601 * Transport type name.
1602 */
1603 pj_str_t type_name;
1604
1605 /**
1606 * Transport string info/description.
1607 */
1608 pj_str_t info;
1609
1610 /**
1611 * Transport flag (see ##pjsip_transport_flags_e).
1612 */
1613 unsigned flag;
1614
1615 /**
1616 * Local address length.
1617 */
1618 unsigned addr_len;
1619
1620 /**
1621 * Local/bound address.
1622 */
1623 pj_sockaddr local_addr;
1624
1625 /**
1626 * Published address (or transport address name).
1627 */
1628 pjsip_host_port local_name;
1629
1630 /**
1631 * Current number of objects currently referencing this transport.
1632 */
1633 unsigned usage_count;
1634
1635
1636} pjsua_transport_info;
1637
1638
1639/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001640 * Create and start a new SIP transport according to the specified
1641 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001642 *
1643 * @param type Transport type.
1644 * @param cfg Transport configuration.
1645 * @param p_id Optional pointer to receive transport ID.
1646 *
1647 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001648 *
1649 * \par Python:
1650 * The corresponding Python function returns (status,id) tuple:
1651 * \code
1652 status, transport_id = py_pjsua.transport_create(type, cfg)
1653 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001654 */
1655PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1656 const pjsua_transport_config *cfg,
1657 pjsua_transport_id *p_id);
1658
1659/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001660 * Register transport that has been created by application. This function
1661 * is useful if application wants to implement custom SIP transport and use
1662 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001663 *
1664 * @param tp Transport instance.
1665 * @param p_id Optional pointer to receive transport ID.
1666 *
1667 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001668 *
1669 * \par Python:
1670 * Not applicable (for now), because one cannot create a custom transport
1671 * from Python script.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001672 */
1673PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1674 pjsua_transport_id *p_id);
1675
1676
1677/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001678 * Enumerate all transports currently created in the system. This function
1679 * will return all transport IDs, and application may then call
1680 * #pjsua_transport_get_info() function to retrieve detailed information
1681 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001682 *
1683 * @param id Array to receive transport ids.
1684 * @param count In input, specifies the maximum number of elements.
1685 * On return, it contains the actual number of elements.
1686 *
1687 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001688 *
1689 * \par Python:
1690 * The function returns list of integers representing transport ids:
1691 * \code
1692 [int] = py_pjsua.enum_transports()
1693 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001694 */
1695PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1696 unsigned *count );
1697
1698
1699/**
1700 * Get information about transports.
1701 *
1702 * @param id Transport ID.
1703 * @param info Pointer to receive transport info.
1704 *
1705 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001706 *
1707 * \par Python:
1708 * \code
1709 transport_info = py_pjsua.transport_get_info(id)
1710 * \endcode
1711 * The Python function returns None on error.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001712 */
1713PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1714 pjsua_transport_info *info);
1715
1716
1717/**
1718 * Disable a transport or re-enable it. By default transport is always
1719 * enabled after it is created. Disabling a transport does not necessarily
1720 * close the socket, it will only discard incoming messages and prevent
1721 * the transport from being used to send outgoing messages.
1722 *
1723 * @param id Transport ID.
1724 * @param enabled Non-zero to enable, zero to disable.
1725 *
1726 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001727 *
1728 * \par Python:
1729 * \code
1730 status = py_pjsua.transport_set_enable(id, enabled)
1731 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001732 */
1733PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1734 pj_bool_t enabled);
1735
1736
1737/**
1738 * Close the transport. If transport is forcefully closed, it will be
1739 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00001740 * transport may not terminate properly (it may even crash). Otherwise,
1741 * the system will wait until all transactions are closed while preventing
1742 * new users from using the transport, and will close the transport when
1743 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001744 *
1745 * @param id Transport ID.
1746 * @param force Non-zero to immediately close the transport. This
1747 * is not recommended!
1748 *
1749 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001750 *
1751 * \par Python:
1752 * \code
1753 status = py_pjsua.transport_close(id, force)
1754 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001755 */
1756PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1757 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001758
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001759/**
Benny Prijono312aff92006-06-17 04:08:30 +00001760 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001761 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001762
1763
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001764
1765
1766/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001767 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001768 */
1769
Benny Prijono312aff92006-06-17 04:08:30 +00001770
1771/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001772 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001773 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001774 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001775 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001776 *
Benny Prijono312aff92006-06-17 04:08:30 +00001777 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001778 * using the application. In SIP terms, the identity is used as the <b>From</b>
1779 * header in outgoing requests.
1780 *
1781 * PJSUA-API supports creating and managing multiple accounts. The maximum
1782 * number of accounts is limited by a compile time constant
1783 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001784 *
1785 * Account may or may not have client registration associated with it.
1786 * An account is also associated with <b>route set</b> and some <b>authentication
1787 * credentials</b>, which are used when sending SIP request messages using the
1788 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00001789 * will be reported to remote peer when they subscribe to the account's
1790 * presence, or which is published to a presence server if presence
1791 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00001792 *
1793 * At least one account MUST be created in the application. If no user
1794 * association is required, application can create a userless account by
1795 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00001796 * instead of a particular user, and it correspond with a particular
1797 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00001798 *
1799 * Also one account must be set as the <b>default account</b>, which is used as
1800 * the account to use when PJSUA fails to match a request with any other
1801 * accounts.
1802 *
1803 * When sending outgoing SIP requests (such as making calls or sending
1804 * instant messages), normally PJSUA requires the application to specify
1805 * which account to use for the request. If no account is specified,
1806 * PJSUA may be able to select the account by matching the destination
1807 * domain name, and fall back to default account when no match is found.
1808 */
1809
1810/**
1811 * Maximum accounts.
1812 */
1813#ifndef PJSUA_MAX_ACC
1814# define PJSUA_MAX_ACC 8
1815#endif
1816
1817
1818/**
1819 * Default registration interval.
1820 */
1821#ifndef PJSUA_REG_INTERVAL
Benny Prijonobddef2c2007-10-31 13:28:08 +00001822# define PJSUA_REG_INTERVAL 300
Benny Prijono312aff92006-06-17 04:08:30 +00001823#endif
1824
1825
1826/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001827 * Default PUBLISH expiration
1828 */
1829#ifndef PJSUA_PUBLISH_EXPIRATION
1830# define PJSUA_PUBLISH_EXPIRATION 600
1831#endif
1832
1833
1834/**
Benny Prijono093d3022006-09-24 00:07:11 +00001835 * Default account priority.
1836 */
1837#ifndef PJSUA_DEFAULT_ACC_PRIORITY
1838# define PJSUA_DEFAULT_ACC_PRIORITY 0
1839#endif
1840
1841
1842/**
Benny Prijono8058a622007-06-08 04:37:05 +00001843 * This macro specifies the URI scheme to use in Contact header
1844 * when secure transport such as TLS is used. Application can specify
1845 * either "sip" or "sips".
1846 */
1847#ifndef PJSUA_SECURE_SCHEME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00001848# define PJSUA_SECURE_SCHEME "sips"
Benny Prijono8058a622007-06-08 04:37:05 +00001849#endif
1850
1851
1852/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001853 * This structure describes account configuration to be specified when
1854 * adding a new account with #pjsua_acc_add(). Application MUST initialize
1855 * this structure first by calling #pjsua_acc_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00001856 *
1857 * \par Python:
1858 * The data type in Python is <tt>py_pjsua.Acc_Config</tt>, but normally
1859 * application can just use the snippet below to create and initialize
1860 * the account config:
1861 * \code
1862 acc_cfg = py_pjsua.acc_config_default()
1863 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001864 */
1865typedef struct pjsua_acc_config
1866{
Benny Prijono093d3022006-09-24 00:07:11 +00001867 /**
1868 * Account priority, which is used to control the order of matching
1869 * incoming/outgoing requests. The higher the number means the higher
1870 * the priority is, and the account will be matched first.
1871 */
1872 int priority;
1873
Benny Prijono312aff92006-06-17 04:08:30 +00001874 /**
1875 * The full SIP URL for the account. The value can take name address or
1876 * URL format, and will look something like "sip:account@serviceprovider".
1877 *
1878 * This field is mandatory.
1879 */
1880 pj_str_t id;
1881
1882 /**
1883 * This is the URL to be put in the request URI for the registration,
1884 * and will look something like "sip:serviceprovider".
1885 *
1886 * This field should be specified if registration is desired. If the
1887 * value is empty, no account registration will be performed.
1888 */
1889 pj_str_t reg_uri;
1890
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001891 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001892 * If this flag is set, the presence information of this account will
1893 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono48ab2b72007-11-08 09:24:30 +00001894 *
1895 * Default: PJ_FALSE
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001896 */
1897 pj_bool_t publish_enabled;
1898
Benny Prijonofe04fb52007-08-24 08:28:52 +00001899 /**
Benny Prijono48ab2b72007-11-08 09:24:30 +00001900 * Authentication preference.
1901 */
1902 pjsip_auth_clt_pref auth_pref;
1903
1904 /**
Benny Prijonofe04fb52007-08-24 08:28:52 +00001905 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
1906 * is not specified, a random string will be used.
1907 */
1908 pj_str_t pidf_tuple_id;
1909
Benny Prijono312aff92006-06-17 04:08:30 +00001910 /**
1911 * Optional URI to be put as Contact for this account. It is recommended
1912 * that this field is left empty, so that the value will be calculated
1913 * automatically based on the transport address.
1914 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00001915 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00001916
1917 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001918 * Specify whether support for reliable provisional response (100rel and
1919 * PRACK) should be required for all sessions of this account.
1920 *
1921 * Default: PJ_FALSE
1922 */
1923 pj_bool_t require_100rel;
1924
1925 /**
Benny Prijono312aff92006-06-17 04:08:30 +00001926 * Number of proxies in the proxy array below.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001927 *
1928 * \par Python:
1929 * Not applicable, as \a proxy is implemented as list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001930 */
1931 unsigned proxy_cnt;
1932
1933 /**
1934 * Optional URI of the proxies to be visited for all outgoing requests
1935 * that are using this account (REGISTER, INVITE, etc). Application need
1936 * to specify these proxies if the service provider requires that requests
1937 * destined towards its network should go through certain proxies first
1938 * (for example, border controllers).
1939 *
1940 * These proxies will be put in the route set for this account, with
1941 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00001942 * first). If global outbound proxies are configured in pjsua_config,
1943 * then these account proxies will be placed after the global outbound
1944 * proxies in the routeset.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001945 *
1946 * \par Python:
1947 * This will be list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001948 */
1949 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
1950
1951 /**
1952 * Optional interval for registration, in seconds. If the value is zero,
Benny Prijonobddef2c2007-10-31 13:28:08 +00001953 * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
Benny Prijono312aff92006-06-17 04:08:30 +00001954 */
1955 unsigned reg_timeout;
1956
1957 /**
1958 * Number of credentials in the credential array.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001959 *
1960 * \par Python:
1961 * Not applicable, since \a cred_info is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00001962 */
1963 unsigned cred_count;
1964
1965 /**
1966 * Array of credentials. If registration is desired, normally there should
1967 * be at least one credential specified, to successfully authenticate
1968 * against the service provider. More credentials can be specified, for
1969 * example when the requests are expected to be challenged by the
1970 * proxies in the route set.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001971 *
1972 * \par Python:
1973 * This field is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00001974 */
1975 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1976
Benny Prijono62c5c5b2007-01-13 23:22:40 +00001977 /**
1978 * Optionally bind this account to specific transport. This normally is
1979 * not a good idea, as account should be able to send requests using
1980 * any available transports according to the destination. But some
1981 * application may want to have explicit control over the transport to
1982 * use, so in that case it can set this field.
1983 *
1984 * Default: -1 (PJSUA_INVALID_ID)
1985 *
1986 * @see pjsua_acc_set_transport()
1987 */
1988 pjsua_transport_id transport_id;
1989
Benny Prijono15b02302007-09-27 14:07:07 +00001990 /**
1991 * This option is useful for keeping the UDP transport address up to
1992 * date with the NAT public mapped address. When this option is
1993 * enabled and STUN is configured, the library will keep track of
1994 * the public IP address from the response of REGISTER request. Once
1995 * it detects that the address has changed, it will unregister current
1996 * Contact, update the UDP transport address, and register a new
1997 * Contact to the registrar.
1998 *
1999 * Default: 1 (yes)
2000 */
2001 pj_bool_t auto_update_nat;
2002
Benny Prijonobddef2c2007-10-31 13:28:08 +00002003 /**
2004 * Set the interval for periodic keep-alive transmission for this account.
2005 * If this value is zero, keep-alive will be disabled for this account.
2006 * The keep-alive transmission will be sent to the registrar's address,
2007 * after successful registration.
2008 *
2009 * Even if this setting is enabled, keep-alive transmission is only done
2010 * when STUN is enabled in the global #pjsua_config, and the transport
2011 * used for registration is UDP. For TCP and TLS transports, keep-alive
2012 * is done by the transport themselves.
2013 *
2014 * Default: 15 (seconds)
2015 */
2016 unsigned ka_interval;
2017
2018 /**
2019 * Specify the data to be transmitted as keep-alive packets.
2020 *
2021 * Default: CR-LF
2022 */
2023 pj_str_t ka_data;
2024
Benny Prijonod8179652008-01-23 20:39:07 +00002025#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
2026 /**
2027 * Specify whether secure media transport should be used for this account.
2028 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
2029 * PJMEDIA_SRTP_MANDATORY.
2030 *
2031 * Default: #PJSUA_DEFAULT_USE_SRTP
2032 */
2033 pjmedia_srtp_use use_srtp;
2034
2035 /**
2036 * Specify whether SRTP requires secure signaling to be used. This option
2037 * is only used when \a use_srtp option above is non-zero.
2038 *
2039 * Valid values are:
2040 * 0: SRTP does not require secure signaling
2041 * 1: SRTP requires secure transport such as TLS
2042 * 2: SRTP requires secure end-to-end transport (SIPS)
2043 *
2044 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
2045 */
2046 int srtp_secure_signaling;
2047#endif
2048
Benny Prijono312aff92006-06-17 04:08:30 +00002049} pjsua_acc_config;
2050
2051
2052/**
2053 * Call this function to initialize account config with default values.
2054 *
2055 * @param cfg The account config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002056 *
2057 * \par Python:
2058 * In Python, this function both creates and initializes the account
2059 * config:
2060 * \code
2061 acc_cfg = py_pjsua.acc_config_default()
2062 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002063 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00002064PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002065
2066
2067/**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002068 * Duplicate account config.
2069 *
2070 * @param pool Pool to be used for duplicating the config.
2071 * @param dst Destination configuration.
2072 * @param src Source configuration.
2073 */
2074PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
2075 pjsua_acc_config *dst,
2076 const pjsua_acc_config *src);
2077
2078
2079/**
Benny Prijono312aff92006-06-17 04:08:30 +00002080 * Account info. Application can query account info by calling
2081 * #pjsua_acc_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00002082 *
2083 * \par Python:
2084 * The data type in Python is <tt>py_pjsua.Acc_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002085 */
2086typedef struct pjsua_acc_info
2087{
2088 /**
2089 * The account ID.
2090 */
2091 pjsua_acc_id id;
2092
2093 /**
2094 * Flag to indicate whether this is the default account.
2095 */
2096 pj_bool_t is_default;
2097
2098 /**
2099 * Account URI
2100 */
2101 pj_str_t acc_uri;
2102
2103 /**
2104 * Flag to tell whether this account has registration setting
2105 * (reg_uri is not empty).
2106 */
2107 pj_bool_t has_registration;
2108
2109 /**
2110 * An up to date expiration interval for account registration session.
2111 */
2112 int expires;
2113
2114 /**
2115 * Last registration status code. If status code is zero, the account
2116 * is currently not registered. Any other value indicates the SIP
2117 * status code of the registration.
2118 */
2119 pjsip_status_code status;
2120
2121 /**
2122 * String describing the registration status.
2123 */
2124 pj_str_t status_text;
2125
2126 /**
2127 * Presence online status for this account.
2128 */
2129 pj_bool_t online_status;
2130
2131 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00002132 * Presence online status text.
2133 */
2134 pj_str_t online_status_text;
2135
2136 /**
2137 * Extended RPID online status information.
2138 */
2139 pjrpid_element rpid;
2140
2141 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002142 * Buffer that is used internally to store the status text.
2143 */
2144 char buf_[PJ_ERR_MSG_SIZE];
2145
2146} pjsua_acc_info;
2147
2148
2149
2150/**
2151 * Get number of current accounts.
2152 *
2153 * @return Current number of accounts.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002154 *
2155 * \par Python:
2156 * \code
2157 count = py_pjsua.acc_get_count()
2158 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002159 */
2160PJ_DECL(unsigned) pjsua_acc_get_count(void);
2161
2162
2163/**
2164 * Check if the specified account ID is valid.
2165 *
2166 * @param acc_id Account ID to check.
2167 *
2168 * @return Non-zero if account ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002169 *
2170 * \par Python:
2171 * \code
2172 is_valid = py_pjsua.acc_is_valid(acc_id)
2173 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002174 */
2175PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
2176
2177
2178/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00002179 * Set default account to be used when incoming and outgoing
2180 * requests doesn't match any accounts.
2181 *
2182 * @param acc_id The account ID to be used as default.
2183 *
2184 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002185 *
2186 * \par Python:
2187 * \code
2188 status = py_pjsua.acc_set_default(acc_id)
2189 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002190 */
2191PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2192
2193
2194/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002195 * Get default account to be used when receiving incoming requests (calls),
2196 * when the destination of the incoming call doesn't match any other
2197 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002198 *
2199 * @return The default account ID, or PJSUA_INVALID_ID if no
2200 * default account is configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002201 *
2202 * \par Python:
2203 * \code
2204 acc_id = py_pjsua.acc_get_default()
2205 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002206 */
2207PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2208
2209
2210/**
Benny Prijono312aff92006-06-17 04:08:30 +00002211 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002212 * #pjsua_init()) before calling this function. If registration is configured
2213 * for this account, this function would also start the SIP registration
2214 * session with the SIP registrar server. This SIP registration session
2215 * will be maintained internally by the library, and application doesn't
2216 * need to do anything to maintain the registration session.
2217 *
Benny Prijono312aff92006-06-17 04:08:30 +00002218 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002219 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002220 * @param is_default If non-zero, this account will be set as the default
2221 * account. The default account will be used when sending
2222 * outgoing requests (e.g. making call) when no account is
2223 * specified, and when receiving incoming requests when the
2224 * request does not match any accounts. It is recommended
2225 * that default account is set to local/LAN account.
2226 * @param p_acc_id Pointer to receive account ID of the new account.
2227 *
2228 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002229 *
2230 * \par Python:
2231 * The function returns (status, account_id) tuple:
2232 * \code
2233 status, account_id = py_pjsua.acc_add(acc_cfg, is_default)
2234 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002235 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002236PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002237 pj_bool_t is_default,
2238 pjsua_acc_id *p_acc_id);
2239
2240
2241/**
2242 * Add a local account. A local account is used to identify local endpoint
2243 * instead of a specific user, and for this reason, a transport ID is needed
2244 * to obtain the local address information.
2245 *
2246 * @param tid Transport ID to generate account address.
2247 * @param is_default If non-zero, this account will be set as the default
2248 * account. The default account will be used when sending
2249 * outgoing requests (e.g. making call) when no account is
2250 * specified, and when receiving incoming requests when the
2251 * request does not match any accounts. It is recommended
2252 * that default account is set to local/LAN account.
2253 * @param p_acc_id Pointer to receive account ID of the new account.
2254 *
2255 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002256 *
2257 * \par Python:
2258 * The function returns (status, account_id) tuple:
2259 * \code
2260 status, account_id = py_pjsua.acc_add_local(tid, is_default)
2261 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002262 */
2263PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2264 pj_bool_t is_default,
2265 pjsua_acc_id *p_acc_id);
2266
2267/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002268 * Delete an account. This will unregister the account from the SIP server,
2269 * if necessary, and terminate server side presence subscriptions associated
2270 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002271 *
2272 * @param acc_id Id of the account to be deleted.
2273 *
2274 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002275 *
2276 * \par Python:
2277 * \code
2278 status = py_pjsua.acc_del(acc_id)
2279 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002280 */
2281PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2282
2283
2284/**
2285 * Modify account information.
2286 *
2287 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002288 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002289 *
2290 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002291 *
2292 * \par Python:
2293 * \code
2294 status = py_pjsua.acc_modify(acc_id, acc_cfg)
2295 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002296 */
2297PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002298 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002299
2300
2301/**
2302 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002303 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002304 * if there are server side presence subscription for this account, and/or
2305 * outgoing PUBLISH if presence publication is enabled for this account.
2306 *
2307 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002308 *
2309 * @param acc_id The account ID.
2310 * @param is_online True of false.
2311 *
2312 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002313 *
2314 * \par Python:
2315 * \code
2316 status = py_pjsua.acc_set_online_status(acc_id, is_online)
2317 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002318 */
2319PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2320 pj_bool_t is_online);
2321
Benny Prijono4461c7d2007-08-25 13:36:15 +00002322/**
2323 * Modify account's presence status to be advertised to remote/presence
2324 * subscribers. This would trigger the sending of outgoing NOTIFY request
2325 * if there are server side presence subscription for this account, and/or
2326 * outgoing PUBLISH if presence publication is enabled for this account.
2327 *
2328 * @see pjsua_acc_set_online_status()
2329 *
2330 * @param acc_id The account ID.
2331 * @param is_online True of false.
2332 * @param pr Extended information in subset of RPID format
2333 * which allows setting custom presence text.
2334 *
2335 * @return PJ_SUCCESS on success, or the appropriate error code.
2336 */
2337PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2338 pj_bool_t is_online,
2339 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002340
2341/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002342 * Update registration or perform unregistration. If registration is
2343 * configured for this account, then initial SIP REGISTER will be sent
2344 * when the account is added with #pjsua_acc_add(). Application normally
2345 * only need to call this function if it wants to manually update the
2346 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002347 *
2348 * @param acc_id The account ID.
2349 * @param renew If renew argument is zero, this will start
2350 * unregistration process.
2351 *
2352 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002353 *
2354 * \par Python:
2355 * \code
2356 status = py_pjsua.acc_set_registration(acc_id, renew)
2357 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002358 */
2359PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2360 pj_bool_t renew);
2361
2362
2363/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002364 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002365 *
2366 * @param acc_id Account identification.
2367 * @param info Pointer to receive account information.
2368 *
2369 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002370 *
2371 * \par Python:
2372 * \code
2373 acc_info = py_pjsua.acc_get_info(acc_id)
2374 * \endcode
2375 * The function returns None if account ID is not valid.
Benny Prijono312aff92006-06-17 04:08:30 +00002376 */
2377PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2378 pjsua_acc_info *info);
2379
2380
2381/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002382 * Enumerate all account currently active in the library. This will fill
2383 * the array with the account Ids, and application can then query the
2384 * account information for each id with #pjsua_acc_get_info().
2385 *
2386 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002387 *
2388 * @param ids Array of account IDs to be initialized.
2389 * @param count In input, specifies the maximum number of elements.
2390 * On return, it contains the actual number of elements.
2391 *
2392 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002393 *
2394 * \par Python:
2395 * The function takes no argument and returns list of account Ids:
2396 * \code
2397 [acc_ids] = py_pjsua.enum_accs()
2398 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002399 */
2400PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2401 unsigned *count );
2402
2403
2404/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002405 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002406 *
2407 * @param info Array of account infos to be initialized.
2408 * @param count In input, specifies the maximum number of elements.
2409 * On return, it contains the actual number of elements.
2410 *
2411 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002412 *
2413 * \par Python:
2414 * The function takes no argument and returns list of account infos:
2415 * \code
2416 [acc_info] = py_pjsua.acc_enum_info()
2417 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002418 */
2419PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2420 unsigned *count );
2421
2422
2423/**
2424 * This is an internal function to find the most appropriate account to
2425 * used to reach to the specified URL.
2426 *
2427 * @param url The remote URL to reach.
2428 *
2429 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002430 *
2431 * \par Python:
2432 * \code
2433 acc_id = py_pjsua.acc_find_for_outgoing(url)
2434 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002435 */
2436PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2437
2438
2439/**
2440 * This is an internal function to find the most appropriate account to be
2441 * used to handle incoming calls.
2442 *
2443 * @param rdata The incoming request message.
2444 *
2445 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002446 *
2447 * \par Python:
2448 * \code
2449 acc_id = py_pjsua.acc_find_for_outgoing(url)
2450 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002451 */
2452PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2453
2454
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002455/**
Benny Prijonofff245c2007-04-02 11:44:47 +00002456 * Create arbitrary requests using the account. Application should only use
2457 * this function to create auxiliary requests outside dialog, such as
2458 * OPTIONS, and use the call or presence API to create dialog related
2459 * requests.
2460 *
2461 * @param acc_id The account ID.
2462 * @param method The SIP method of the request.
2463 * @param target Target URI.
2464 * @param p_tdata Pointer to receive the request.
2465 *
2466 * @return PJ_SUCCESS or the error code.
2467 */
2468PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
2469 const pjsip_method *method,
2470 const pj_str_t *target,
2471 pjsip_tx_data **p_tdata);
2472
2473
2474/**
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002475 * Create a suitable URI to be put as Contact based on the specified
2476 * target URI for the specified account.
2477 *
2478 * @param pool Pool to allocate memory for the string.
2479 * @param contact The string where the Contact URI will be stored.
2480 * @param acc_id Account ID.
2481 * @param uri Destination URI of the request.
2482 *
2483 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002484 *
2485 * \par Python:
2486 * This function is still experimental in Python:
2487 * \code
2488 uri = py_pjsua.acc_create_uac_contact(pool, acc_id, uri)
2489 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002490 */
2491PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
2492 pj_str_t *contact,
2493 pjsua_acc_id acc_id,
2494 const pj_str_t *uri);
2495
2496
2497
2498/**
2499 * Create a suitable URI to be put as Contact based on the information
2500 * in the incoming request.
2501 *
2502 * @param pool Pool to allocate memory for the string.
2503 * @param contact The string where the Contact URI will be stored.
2504 * @param acc_id Account ID.
2505 * @param rdata Incoming request.
2506 *
2507 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002508 *
2509 * \par Python:
2510 * This function is still experimental in Python:
2511 * \code
2512 uri = py_pjsua.acc_create_uas_contact(pool, acc_id, rdata)
2513 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002514 */
2515PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
2516 pj_str_t *contact,
2517 pjsua_acc_id acc_id,
2518 pjsip_rx_data *rdata );
2519
2520
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002521/**
2522 * Lock/bind this account to a specific transport/listener. Normally
2523 * application shouldn't need to do this, as transports will be selected
2524 * automatically by the stack according to the destination.
2525 *
2526 * When account is locked/bound to a specific transport, all outgoing
2527 * requests from this account will use the specified transport (this
2528 * includes SIP registration, dialog (call and event subscription), and
2529 * out-of-dialog requests such as MESSAGE).
2530 *
2531 * Note that transport_id may be specified in pjsua_acc_config too.
2532 *
2533 * @param acc_id The account ID.
2534 * @param tp_id The transport ID.
2535 *
2536 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002537 *
2538 * \par Python:
2539 * Not yet implemented.
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002540 */
2541PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
2542 pjsua_transport_id tp_id);
2543
Benny Prijono312aff92006-06-17 04:08:30 +00002544
2545/**
2546 * @}
2547 */
2548
2549
2550/*****************************************************************************
2551 * CALLS API
2552 */
2553
2554
2555/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002556 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00002557 * @ingroup PJSUA_LIB
2558 * @brief Call manipulation.
2559 * @{
2560 */
2561
2562/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002563 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00002564 */
2565#ifndef PJSUA_MAX_CALLS
2566# define PJSUA_MAX_CALLS 32
2567#endif
2568
2569
2570
2571/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002572 * This enumeration specifies the media status of a call, and it's part
2573 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00002574 */
2575typedef enum pjsua_call_media_status
2576{
Benny Prijonob5388cf2007-01-04 22:45:08 +00002577 /** Call currently has no media */
Benny Prijono312aff92006-06-17 04:08:30 +00002578 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002579
2580 /** The media is active */
Benny Prijono312aff92006-06-17 04:08:30 +00002581 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002582
2583 /** The media is currently put on hold by local endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002584 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002585
2586 /** The media is currently put on hold by remote endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002587 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002588
Benny Prijono096c56c2007-09-15 08:30:16 +00002589 /** The media has reported error (e.g. ICE negotiation) */
2590 PJSUA_CALL_MEDIA_ERROR
2591
Benny Prijono312aff92006-06-17 04:08:30 +00002592} pjsua_call_media_status;
2593
2594
2595/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002596 * This structure describes the information and current status of a call.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002597 *
2598 * \par Python:
2599 * The type name is <tt>py_pjsua.Call_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002600 */
2601typedef struct pjsua_call_info
2602{
2603 /** Call identification. */
2604 pjsua_call_id id;
2605
2606 /** Initial call role (UAC == caller) */
2607 pjsip_role_e role;
2608
Benny Prijono90315512006-09-14 16:05:16 +00002609 /** The account ID where this call belongs. */
2610 pjsua_acc_id acc_id;
2611
Benny Prijono312aff92006-06-17 04:08:30 +00002612 /** Local URI */
2613 pj_str_t local_info;
2614
2615 /** Local Contact */
2616 pj_str_t local_contact;
2617
2618 /** Remote URI */
2619 pj_str_t remote_info;
2620
2621 /** Remote contact */
2622 pj_str_t remote_contact;
2623
2624 /** Dialog Call-ID string. */
2625 pj_str_t call_id;
2626
2627 /** Call state */
2628 pjsip_inv_state state;
2629
2630 /** Text describing the state */
2631 pj_str_t state_text;
2632
2633 /** Last status code heard, which can be used as cause code */
2634 pjsip_status_code last_status;
2635
2636 /** The reason phrase describing the status. */
2637 pj_str_t last_status_text;
2638
2639 /** Call media status. */
2640 pjsua_call_media_status media_status;
2641
2642 /** Media direction */
2643 pjmedia_dir media_dir;
2644
2645 /** The conference port number for the call */
2646 pjsua_conf_port_id conf_slot;
2647
2648 /** Up-to-date call connected duration (zero when call is not
2649 * established)
2650 */
2651 pj_time_val connect_duration;
2652
2653 /** Total call duration, including set-up time */
2654 pj_time_val total_duration;
2655
2656 /** Internal */
2657 struct {
2658 char local_info[128];
2659 char local_contact[128];
2660 char remote_info[128];
2661 char remote_contact[128];
2662 char call_id[128];
2663 char last_status_text[128];
2664 } buf_;
2665
2666} pjsua_call_info;
2667
2668
2669
Benny Prijonoa91a0032006-02-26 21:23:45 +00002670/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002671 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002672 *
2673 * @return Maximum number of calls configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002674 *
2675 * \par Python:
2676 * \code
2677 count = py_pjsua.call_get_max_count()
2678 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002679 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002680PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002681
2682/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002683 * Get number of currently active calls.
2684 *
2685 * @return Number of currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002686 *
2687 * \par Python:
2688 * \code
2689 count = py_pjsua.call_get_count()
2690 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002691 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002692PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002693
2694/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002695 * Enumerate all active calls. Application may then query the information and
2696 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002697 *
2698 * @param ids Array of account IDs to be initialized.
2699 * @param count In input, specifies the maximum number of elements.
2700 * On return, it contains the actual number of elements.
2701 *
2702 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002703 *
2704 * \par Python:
2705 * This function takes no argument and return list of call Ids.
2706 * \code
2707 [call_ids] = py_pjsua.enum_calls()
2708 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002709 */
2710PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
2711 unsigned *count);
2712
2713
2714/**
2715 * Make outgoing call to the specified URI using the specified account.
2716 *
2717 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002718 * @param dst_uri URI to be put in the To header (normally is the same
2719 * as the target URI).
2720 * @param options Options (must be zero at the moment).
2721 * @param user_data Arbitrary user data to be attached to the call, and
2722 * can be retrieved later.
2723 * @param msg_data Optional headers etc to be added to outgoing INVITE
2724 * request, or NULL if no custom header is desired.
2725 * @param p_call_id Pointer to receive call identification.
2726 *
2727 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002728 *
2729 * \par Python:
2730 * The Python function returns (status, call_id) tuple:
2731 * \code
2732 status, call_id = py_pjsua.call_make_call(acc_id, dst_uri, options,
2733 user_data, msg_data)
2734 * \endcode
2735 * Note: the \a user_data in Python function is an integer, and the
2736 * \a msg_data can be set to None if not required.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002737 */
2738PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
2739 const pj_str_t *dst_uri,
2740 unsigned options,
2741 void *user_data,
2742 const pjsua_msg_data *msg_data,
2743 pjsua_call_id *p_call_id);
2744
2745
2746/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002747 * Check if the specified call has active INVITE session and the INVITE
2748 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002749 *
2750 * @param call_id Call identification.
2751 *
2752 * @return Non-zero if call is active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002753 *
2754 * \par Python:
2755 * \code
2756 bool = py_pjsua.call_is_active(call_id)
2757 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002758 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002759PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002760
2761
2762/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002763 * Check if call has an active media session.
2764 *
2765 * @param call_id Call identification.
2766 *
2767 * @return Non-zero if yes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002768 *
2769 * \par Python:
2770 * \code
2771 bool = py_pjsua.call_has_media(call_id)
2772 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002773 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002774PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002775
2776
2777/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002778 * Get the conference port identification associated with the call.
2779 *
2780 * @param call_id Call identification.
2781 *
2782 * @return Conference port ID, or PJSUA_INVALID_ID when the
2783 * media has not been established or is not active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002784 *
2785 * \par Python:
2786 * \code
2787 slot = py_pjsua.call_get_conf_port(call_id)
2788 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002789 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002790PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
2791
2792/**
2793 * Obtain detail information about the specified call.
2794 *
2795 * @param call_id Call identification.
2796 * @param info Call info to be initialized.
2797 *
2798 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002799 *
2800 * \par Python:
2801 * \code
2802 call_info = py_pjsua.call_get_info(call_id)
2803 * \endcode
2804 * \a call_info return value will be set to None if call_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002805 */
2806PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002807 pjsua_call_info *info);
2808
2809
2810/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002811 * Attach application specific data to the call. Application can then
2812 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002813 *
2814 * @param call_id Call identification.
2815 * @param user_data Arbitrary data to be attached to the call.
2816 *
2817 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002818 *
2819 * \par Python:
2820 * \code
2821 status = py_pjsua.call_set_user_data(call_id, user_data)
2822 * \endcode
2823 * The \a user_data is an integer in the Python function.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002824 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002825PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
2826 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002827
2828
2829/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002830 * Get user data attached to the call, which has been previously set with
2831 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002832 *
2833 * @param call_id Call identification.
2834 *
2835 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002836 *
2837 * \par Python:
2838 * \code
2839 user_data = py_pjsua.call_get_user_data(call_id)
2840 * \endcode
2841 * The \a user_data is an integer.
Benny Prijono268ca612006-02-07 12:34:11 +00002842 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002843PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00002844
2845
2846/**
Benny Prijono91a6a172007-10-31 08:59:29 +00002847 * Get the NAT type of remote's endpoint. This is a proprietary feature
2848 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
2849 * is set in #pjsua_config.
2850 *
2851 * This function can only be called after SDP has been received from remote,
2852 * which means for incoming call, this function can be called as soon as
2853 * call is received as long as incoming call contains SDP, and for outgoing
2854 * call, this function can be called only after SDP is received (normally in
2855 * 200/OK response to INVITE). As a general case, application should call
2856 * this function after or in \a on_call_media_state() callback.
2857 *
2858 * @param call_id Call identification.
2859 * @param p_type Pointer to store the NAT type. Application can then
2860 * retrieve the string description of the NAT type
2861 * by calling pj_stun_get_nat_name().
2862 *
2863 * @return PJ_SUCCESS on success.
2864 *
2865 * @see pjsua_get_nat_type(), nat_type_in_sdp
2866 */
2867PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
2868 pj_stun_nat_type *p_type);
2869
2870/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002871 * Send response to incoming INVITE request. Depending on the status
2872 * code specified as parameter, this function may send provisional
2873 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002874 *
2875 * @param call_id Incoming call identification.
2876 * @param code Status code, (100-699).
2877 * @param reason Optional reason phrase. If NULL, default text
2878 * will be used.
2879 * @param msg_data Optional list of headers etc to be added to outgoing
2880 * response message.
2881 *
2882 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002883 *
2884 * \par Python:
2885 * \code
2886 status = py_pjsua.call_answer(call_id, code, reason, msg_data)
2887 * \endcode
2888 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijonoa91a0032006-02-26 21:23:45 +00002889 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002890PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
2891 unsigned code,
2892 const pj_str_t *reason,
2893 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00002894
2895/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002896 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00002897 * call state. This function is different than answering the call with
2898 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
2899 * will hangup the call regardless of the state and role of the call,
2900 * while #pjsua_call_answer() only works with incoming calls on EARLY
2901 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002902 *
2903 * @param call_id Call identification.
2904 * @param code Optional status code to be sent when we're rejecting
2905 * incoming call. If the value is zero, "603/Decline"
2906 * will be sent.
2907 * @param reason Optional reason phrase to be sent when we're rejecting
2908 * incoming call. If NULL, default text will be used.
2909 * @param msg_data Optional list of headers etc to be added to outgoing
2910 * request/response message.
2911 *
2912 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002913 *
2914 * \par Python:
2915 * \code
2916 status = py_pjsua.call_hangup(call_id, code, reason, msg_data)
2917 * \endcode
2918 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002919 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002920PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
2921 unsigned code,
2922 const pj_str_t *reason,
2923 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002924
2925
2926/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002927 * Put the specified call on hold. This will send re-INVITE with the
2928 * appropriate SDP to inform remote that the call is being put on hold.
2929 * The final status of the request itself will be reported on the
2930 * \a on_call_media_state() callback, which inform the application that
2931 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002932 *
2933 * @param call_id Call identification.
2934 * @param msg_data Optional message components to be sent with
2935 * the request.
2936 *
2937 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002938 *
2939 * \par Python:
2940 * \code
2941 status = py_pjsua.call_set_hold(call_id, msg_data)
2942 * \endcode
2943 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002944 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002945PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
2946 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002947
2948
2949/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002950 * Send re-INVITE to release hold.
2951 * The final status of the request itself will be reported on the
2952 * \a on_call_media_state() callback, which inform the application that
2953 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002954 *
2955 * @param call_id Call identification.
2956 * @param unhold If this argument is non-zero and the call is locally
2957 * held, this will release the local hold.
2958 * @param msg_data Optional message components to be sent with
2959 * the request.
2960 *
2961 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002962 *
2963 * \par Python:
2964 * \code
2965 status = py_pjsua.call_reinvite(call_id, unhold, msg_data)
2966 * \endcode
2967 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002968 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002969PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
2970 pj_bool_t unhold,
2971 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002972
Benny Prijonoc08682e2007-10-04 06:17:58 +00002973/**
2974 * Send UPDATE request.
2975 *
2976 * @param call_id Call identification.
2977 * @param options Must be zero for now.
2978 * @param msg_data Optional message components to be sent with
2979 * the request.
2980 *
2981 * @return PJ_SUCCESS on success, or the appropriate error code.
2982 */
2983PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
2984 unsigned options,
2985 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002986
2987/**
Benny Prijono053f5222006-11-11 16:16:04 +00002988 * Initiate call transfer to the specified address. This function will send
2989 * REFER request to instruct remote call party to initiate a new INVITE
2990 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002991 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00002992 * If application is interested to monitor the successfulness and
2993 * the progress of the transfer request, it can implement
2994 * \a on_call_transfer_status() callback which will report the progress
2995 * of the call transfer request.
2996 *
Benny Prijono053f5222006-11-11 16:16:04 +00002997 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002998 * @param dest Address of new target to be contacted.
2999 * @param msg_data Optional message components to be sent with
3000 * the request.
3001 *
3002 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003003 *
3004 * \par Python:
3005 * \code
3006 status = py_pjsua.call_xfer(call_id, dest, msg_data)
3007 * \endcode
3008 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003009 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003010PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
3011 const pj_str_t *dest,
3012 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003013
3014/**
Benny Prijono053f5222006-11-11 16:16:04 +00003015 * Flag to indicate that "Require: replaces" should not be put in the
3016 * outgoing INVITE request caused by REFER request created by
3017 * #pjsua_call_xfer_replaces().
3018 */
3019#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
3020
3021/**
3022 * Initiate attended call transfer. This function will send REFER request
3023 * to instruct remote call party to initiate new INVITE session to the URL
3024 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
3025 * the call with us with the new call from the REFER recipient.
3026 *
3027 * @param call_id The call id to be transfered.
3028 * @param dest_call_id The call id to be replaced.
3029 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
3030 * to suppress the inclusion of "Require: replaces" in
3031 * the outgoing INVITE request created by the REFER
3032 * request.
3033 * @param msg_data Optional message components to be sent with
3034 * the request.
3035 *
3036 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003037 *
3038 * \par Python:
3039 * \code
3040 status = py_pjsua.call_xfer_replaces(call_id, dest_call_id, options, msg_data)
3041 * \endcode
3042 * Argument \a msg_data may be set to None if not required.
Benny Prijono053f5222006-11-11 16:16:04 +00003043 */
3044PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
3045 pjsua_call_id dest_call_id,
3046 unsigned options,
3047 const pjsua_msg_data *msg_data);
3048
3049/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003050 * Send DTMF digits to remote using RFC 2833 payload formats.
3051 *
3052 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003053 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003054 *
3055 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003056 *
3057 * \par Python:
3058 * \code
3059 status = py_pjsua.call_dial_dtmf(call_id, digits)
3060 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003061 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003062PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003063 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00003064
Benny Prijono26ff9062006-02-21 23:47:00 +00003065/**
Benny Prijonob0808372006-03-02 21:18:58 +00003066 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003067 *
3068 * @param call_id Call identification.
3069 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3070 * assumed.
3071 * @param content The message content.
3072 * @param msg_data Optional list of headers etc to be included in outgoing
3073 * request. The body descriptor in the msg_data is
3074 * ignored.
3075 * @param user_data Optional user data, which will be given back when
3076 * the IM callback is called.
3077 *
3078 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003079 *
3080 * \par Python:
3081 * \code
3082 status = py_pjsua.call_send_im(call_id, mime_type, content, msg_data, user_data)
3083 * \endcode
3084 * Note that the \a user_data argument is an integer in Python.
Benny Prijonob0808372006-03-02 21:18:58 +00003085 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003086PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
3087 const pj_str_t *mime_type,
3088 const pj_str_t *content,
3089 const pjsua_msg_data *msg_data,
3090 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003091
3092
3093/**
3094 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003095 *
3096 * @param call_id Call identification.
3097 * @param is_typing Non-zero to indicate to remote that local person is
3098 * currently typing an IM.
3099 * @param msg_data Optional list of headers etc to be included in outgoing
3100 * request.
3101 *
3102 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003103 *
3104 * \par Python:
3105 * \code
3106 status = py_pjsua.call_send_typing_ind(call_id, is_typing, msg_data)
3107 * \endcode
3108 * Argument \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003109 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003110PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
3111 pj_bool_t is_typing,
3112 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003113
3114/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00003115 * Send arbitrary request with the call. This is useful for example to send
3116 * INFO request. Note that application should not use this function to send
3117 * requests which would change the invite session's state, such as re-INVITE,
3118 * UPDATE, PRACK, and BYE.
3119 *
3120 * @param call_id Call identification.
3121 * @param method SIP method of the request.
3122 * @param msg_data Optional message body and/or list of headers to be
3123 * included in outgoing request.
3124 *
3125 * @return PJ_SUCCESS on success, or the appropriate error code.
3126 */
3127PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
3128 const pj_str_t *method,
3129 const pjsua_msg_data *msg_data);
3130
3131
3132/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003133 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
3134 * currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003135 *
3136 * \par Python:
3137 * \code
3138 py_pjsua.call_hangup_all()
3139 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003140 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00003141PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00003142
3143
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003144/**
3145 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003146 *
3147 * @param call_id Call identification.
3148 * @param with_media Non-zero to include media information too.
3149 * @param buffer Buffer where the statistics are to be written to.
3150 * @param maxlen Maximum length of buffer.
3151 * @param indent Spaces for left indentation.
3152 *
3153 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003154 *
3155 * \par Python:
3156 * \code
3157 string = py_pjsua.call_dump(call_id, with_media, max_len, indent)
3158 * \endcode
3159 * The \a max_len argument is the desired maximum length to be allocated.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003160 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003161PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
3162 pj_bool_t with_media,
3163 char *buffer,
3164 unsigned maxlen,
3165 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003166
Benny Prijono9fc735d2006-05-28 14:58:12 +00003167/**
Benny Prijono312aff92006-06-17 04:08:30 +00003168 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003169 */
Benny Prijono834aee32006-02-19 01:38:06 +00003170
3171
3172/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00003173 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00003174 */
3175
Benny Prijono312aff92006-06-17 04:08:30 +00003176
3177/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003178 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00003179 * @ingroup PJSUA_LIB
3180 * @brief Buddy management, buddy's presence, and instant messaging.
3181 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00003182 *
3183 * This section describes PJSUA-APIs related to buddies management,
3184 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00003185 */
3186
3187/**
3188 * Max buddies in buddy list.
3189 */
3190#ifndef PJSUA_MAX_BUDDIES
3191# define PJSUA_MAX_BUDDIES 256
3192#endif
3193
3194
3195/**
Benny Prijonoa17496a2007-10-31 10:20:31 +00003196 * This specifies how long the library should retry resending SUBSCRIBE
3197 * if the previous SUBSCRIBE failed.
3198 *
3199 * Default: 300 seconds
3200 */
3201#ifndef PJSUA_PRES_TIMER
3202# define PJSUA_PRES_TIMER 300
3203#endif
3204
3205
3206/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003207 * This structure describes buddy configuration when adding a buddy to
3208 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
3209 * the structure with #pjsua_buddy_config_default() to initialize this
3210 * structure with default configuration.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003211 *
3212 * \par Python:
3213 * In Python this structure is <tt>py_pjsua.Buddy_Config</tt>. However
3214 * it is recommended that application instantiates the buddy config
3215 * by calling:
3216 * \code
3217 buddy_cfg = py_pjsua.buddy_config_default()
3218 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003219 */
3220typedef struct pjsua_buddy_config
3221{
3222 /**
3223 * Buddy URL or name address.
3224 */
3225 pj_str_t uri;
3226
3227 /**
3228 * Specify whether presence subscription should start immediately.
3229 */
3230 pj_bool_t subscribe;
3231
3232} pjsua_buddy_config;
3233
3234
3235/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003236 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003237 */
3238typedef enum pjsua_buddy_status
3239{
3240 /**
3241 * Online status is unknown (possibly because no presence subscription
3242 * has been established).
3243 */
3244 PJSUA_BUDDY_STATUS_UNKNOWN,
3245
3246 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003247 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003248 */
3249 PJSUA_BUDDY_STATUS_ONLINE,
3250
3251 /**
3252 * Buddy is offline.
3253 */
3254 PJSUA_BUDDY_STATUS_OFFLINE,
3255
3256} pjsua_buddy_status;
3257
3258
3259
3260/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003261 * This structure describes buddy info, which can be retrieved by calling
3262 * #pjsua_buddy_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003263 *
3264 * \par Python:
3265 * This structure in Python is <tt>py_pjsua.Buddy_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003266 */
3267typedef struct pjsua_buddy_info
3268{
3269 /**
3270 * The buddy ID.
3271 */
3272 pjsua_buddy_id id;
3273
3274 /**
3275 * The full URI of the buddy, as specified in the configuration.
3276 */
3277 pj_str_t uri;
3278
3279 /**
3280 * Buddy's Contact, only available when presence subscription has
3281 * been established to the buddy.
3282 */
3283 pj_str_t contact;
3284
3285 /**
3286 * Buddy's online status.
3287 */
3288 pjsua_buddy_status status;
3289
3290 /**
3291 * Text to describe buddy's online status.
3292 */
3293 pj_str_t status_text;
3294
3295 /**
3296 * Flag to indicate that we should monitor the presence information for
3297 * this buddy (normally yes, unless explicitly disabled).
3298 */
3299 pj_bool_t monitor_pres;
3300
3301 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003302 * Extended RPID information about the person.
3303 */
3304 pjrpid_element rpid;
3305
3306 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003307 * Internal buffer.
3308 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003309 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003310
3311} pjsua_buddy_info;
3312
3313
Benny Prijono834aee32006-02-19 01:38:06 +00003314/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003315 * Set default values to the buddy config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003316 *
3317 * \par Python:
3318 * \code
3319 buddy_cfg = py_pjsua.buddy_config_default()
3320 * \endcode
Benny Prijonob5388cf2007-01-04 22:45:08 +00003321 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003322PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003323
3324
3325/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003326 * Get total number of buddies.
3327 *
3328 * @return Number of buddies.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003329 *
3330 * \par Python:
3331 * \code
3332 buddy_count = py_pjsua.get_buddy_count()
3333 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003334 */
3335PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3336
3337
3338/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003339 * Check if buddy ID is valid.
3340 *
3341 * @param buddy_id Buddy ID to check.
3342 *
3343 * @return Non-zero if buddy ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003344 *
3345 * \par Python:
3346 * \code
3347 is_valid = py_pjsua.buddy_is_valid(buddy_id)
3348 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003349 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003350PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3351
3352
3353/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003354 * Enumerate all buddy IDs in the buddy list. Application then can use
3355 * #pjsua_buddy_get_info() to get the detail information for each buddy
3356 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003357 *
3358 * @param ids Array of ids to be initialized.
3359 * @param count On input, specifies max elements in the array.
3360 * On return, it contains actual number of elements
3361 * that have been initialized.
3362 *
3363 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003364 *
3365 * \par Python:
3366 * The Python function takes no argument and returns list of buddy IDs:
3367 * \code
3368 [buddy_ids] = py_pjsua.enum_buddies()
3369 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003370 */
3371PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3372 unsigned *count);
3373
3374/**
3375 * Get detailed buddy info.
3376 *
3377 * @param buddy_id The buddy identification.
3378 * @param info Pointer to receive information about buddy.
3379 *
3380 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003381 *
3382 * \par Python:
3383 * \code
3384 buddy_info = py_pjsua.buddy_get_info(buddy_id)
3385 * \endcode
3386 * The function returns None if buddy_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003387 */
3388PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003389 pjsua_buddy_info *info);
3390
3391/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003392 * Add new buddy to the buddy list. If presence subscription is enabled
3393 * for this buddy, this function will also start the presence subscription
3394 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003395 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003396 * @param buddy)cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003397 * @param p_buddy_id Pointer to receive buddy ID.
3398 *
3399 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003400 *
3401 * \par Python:
3402 * The function returns (status, buddy_id) tuple:
3403 * \code
3404 status, buddy_id = py_pjsua.buddy_add(buddy_cfg)
3405 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003406 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003407PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003408 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003409
3410
3411/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003412 * Delete the specified buddy from the buddy list. Any presence subscription
3413 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003414 *
3415 * @param buddy_id Buddy identification.
3416 *
3417 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003418 *
3419 * \par Python:
3420 * \code
3421 status = py_pjsua.buddy_del(buddy_id)
3422 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +00003423 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003424PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003425
3426
3427/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003428 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3429 * subscribed, application will be informed about buddy's presence status
3430 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003431 *
3432 * @param buddy_id Buddy identification.
3433 * @param subscribe Specify non-zero to activate presence subscription to
3434 * the specified buddy.
3435 *
3436 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003437 *
3438 * \par Python:
3439 * \code
3440 status = py_pjsua.buddy_subscribe_pres(buddy_id, subscribe)
3441 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003442 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003443PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3444 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003445
3446
3447/**
Benny Prijono10861432007-10-31 10:54:53 +00003448 * Update the presence information for the buddy. Although the library
3449 * periodically refreshes the presence subscription for all buddies, some
3450 * application may want to refresh the buddy's presence subscription
3451 * immediately, and in this case it can use this function to accomplish
3452 * this.
3453 *
3454 * Note that the buddy's presence subscription will only be initiated
3455 * if presence monitoring is enabled for the buddy. See
3456 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
3457 * for the buddy is already active, this function will not do anything.
3458 *
3459 * Once the presence subscription is activated successfully for the buddy,
3460 * application will be notified about the buddy's presence status in the
3461 * on_buddy_state() callback.
3462 *
3463 * @param buddy_id Buddy identification.
3464 *
3465 * @return PJ_SUCCESS on success, or the appropriate error code.
3466 */
3467PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
3468
3469
3470/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003471 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003472 *
3473 * @param verbose Yes or no.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003474 *
3475 * \par Python:
3476 * \code
3477 py_pjsua.pres_dump()
3478 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003479 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003480PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003481
3482
Benny Prijonob0808372006-03-02 21:18:58 +00003483/**
3484 * The MESSAGE method (defined in pjsua_im.c)
3485 */
3486extern const pjsip_method pjsip_message_method;
3487
3488
Benny Prijonob0808372006-03-02 21:18:58 +00003489
3490/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003491 * Send instant messaging outside dialog, using the specified account for
3492 * route set and authentication.
3493 *
3494 * @param acc_id Account ID to be used to send the request.
3495 * @param to Remote URI.
3496 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3497 * assumed.
3498 * @param content The message content.
3499 * @param msg_data Optional list of headers etc to be included in outgoing
3500 * request. The body descriptor in the msg_data is
3501 * ignored.
3502 * @param user_data Optional user data, which will be given back when
3503 * the IM callback is called.
3504 *
3505 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003506 *
3507 * \par Python:
3508 * \code
3509 status = py_pjsua.im_send(acc_id, to, mime_type, content, msg_data, user_data)
3510 * \endcode
3511 * Arguments \a mime_type and \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003512 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003513PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3514 const pj_str_t *to,
3515 const pj_str_t *mime_type,
3516 const pj_str_t *content,
3517 const pjsua_msg_data *msg_data,
3518 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003519
3520
3521/**
3522 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003523 *
3524 * @param acc_id Account ID to be used to send the request.
3525 * @param to Remote URI.
3526 * @param is_typing If non-zero, it tells remote person that local person
3527 * is currently composing an IM.
3528 * @param msg_data Optional list of headers etc to be added to outgoing
3529 * request.
3530 *
3531 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003532 *
3533 * \par Python:
3534 * \code
3535 status = py_pjsua.im_typing(acc_id, to, is_typing, msg_data)
3536 * \endcode
3537 * Argument \a msg_data may be set to None if not requried.
Benny Prijonob0808372006-03-02 21:18:58 +00003538 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003539PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3540 const pj_str_t *to,
3541 pj_bool_t is_typing,
3542 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003543
3544
Benny Prijonof3195072006-02-14 21:15:30 +00003545
Benny Prijono312aff92006-06-17 04:08:30 +00003546/**
3547 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003548 */
3549
Benny Prijono312aff92006-06-17 04:08:30 +00003550
3551/*****************************************************************************
3552 * MEDIA API
3553 */
3554
3555
3556/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003557 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003558 * @ingroup PJSUA_LIB
3559 * @brief Media manipulation.
3560 * @{
3561 *
3562 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003563 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3564 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003565 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003566 * the interconnection between these terminations freely.
3567 *
3568 * The conference bridge provides powerful switching and mixing functionality
3569 * for application. With the conference bridge, each conference slot (e.g.
3570 * a call) can transmit to multiple destinations, and one destination can
3571 * receive from multiple sources. If more than one media terminations are
3572 * terminated in the same slot, the conference bridge will mix the signal
3573 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00003574 *
3575 * Application connects one media termination/slot to another by calling
3576 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003577 * media flow from the source termination to the sink termination. To
3578 * establish bidirectional media flow, application wound need to make another
3579 * call to #pjsua_conf_connect(), this time inverting the source and
3580 * destination slots in the parameter.
3581 *
3582 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00003583 * the following steps:
3584 *
3585 \code
3586
3587 pj_status_t stream_to_call( pjsua_call_id call_id )
3588 {
3589 pjsua_player_id player_id;
3590
3591 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
3592 if (status != PJ_SUCCESS)
3593 return status;
3594
3595 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
3596 pjsua_call_get_conf_port() );
3597 }
3598 \endcode
3599 *
3600 *
3601 * Other features of PJSUA media:
3602 * - efficient N to M interconnections between media terminations.
3603 * - media termination can be connected to itself to create loopback
3604 * media.
3605 * - the media termination may have different clock rates, and resampling
3606 * will be done automatically by conference bridge.
3607 * - media terminations may also have different frame time; the
3608 * conference bridge will perform the necessary bufferring to adjust
3609 * the difference between terminations.
3610 * - interconnections are removed automatically when media termination
3611 * is removed from the bridge.
3612 * - sound device may be changed even when there are active media
3613 * interconnections.
3614 * - correctly report call's media quality (in #pjsua_call_dump()) from
3615 * RTCP packet exchange.
3616 */
3617
3618/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003619 * Max ports in the conference bridge. This setting is the default value
3620 * for pjsua_media_config.max_media_ports.
Benny Prijono312aff92006-06-17 04:08:30 +00003621 */
3622#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00003623# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00003624#endif
3625
Benny Prijonob5388cf2007-01-04 22:45:08 +00003626/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003627 * The default clock rate to be used by the conference bridge. This setting
3628 * is the default value for pjsua_media_config.clock_rate.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003629 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003630#ifndef PJSUA_DEFAULT_CLOCK_RATE
3631# define PJSUA_DEFAULT_CLOCK_RATE 16000
3632#endif
3633
Benny Prijonob5388cf2007-01-04 22:45:08 +00003634/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003635 * Default frame length in the conference bridge. This setting
3636 * is the default value for pjsua_media_config.audio_frame_ptime.
3637 */
3638#ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
3639# define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 10
3640#endif
3641
3642
3643/**
3644 * Default codec quality settings. This setting is the default value
3645 * for pjsua_media_config.quality.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003646 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003647#ifndef PJSUA_DEFAULT_CODEC_QUALITY
3648# define PJSUA_DEFAULT_CODEC_QUALITY 5
3649#endif
3650
Benny Prijonob5388cf2007-01-04 22:45:08 +00003651/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003652 * Default iLBC mode. This setting is the default value for
3653 * pjsua_media_config.ilbc_mode.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003654 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003655#ifndef PJSUA_DEFAULT_ILBC_MODE
Benny Prijono37c710b2008-01-10 12:09:26 +00003656# define PJSUA_DEFAULT_ILBC_MODE 30
Benny Prijono12a669c2006-11-23 07:32:13 +00003657#endif
3658
Benny Prijonob5388cf2007-01-04 22:45:08 +00003659/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003660 * The default echo canceller tail length. This setting
3661 * is the default value for pjsua_media_config.ec_tail_len.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003662 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003663#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijono427439c2007-10-21 09:41:24 +00003664# define PJSUA_DEFAULT_EC_TAIL_LEN 200
Benny Prijono12a669c2006-11-23 07:32:13 +00003665#endif
Benny Prijono312aff92006-06-17 04:08:30 +00003666
3667
3668/**
Benny Prijonocba59d92007-02-16 09:22:56 +00003669 * The maximum file player.
3670 */
3671#ifndef PJSUA_MAX_PLAYERS
3672# define PJSUA_MAX_PLAYERS 32
3673#endif
3674
3675
3676/**
3677 * The maximum file player.
3678 */
3679#ifndef PJSUA_MAX_RECORDERS
3680# define PJSUA_MAX_RECORDERS 32
3681#endif
3682
3683
3684/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003685 * This structure describes media configuration, which will be specified
3686 * when calling #pjsua_init(). Application MUST initialize this structure
3687 * by calling #pjsua_media_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003688 *
3689 * \par Python:
3690 * This data type in Python is <tt>py_pjsua.Media_Config</tt>. To create
3691 * an object of this type, it is recommended to call
3692 * <tt>py_pjsua.media_config_default()</tt> function instead:
3693 * \code
3694 media_cfg = py_pjsua.media_config_default()
3695 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003696 */
3697struct pjsua_media_config
3698{
3699 /**
3700 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003701 * If value is zero, default clock rate will be used
3702 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00003703 */
3704 unsigned clock_rate;
3705
3706 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003707 * Specify audio frame ptime. The value here will affect the
3708 * samples per frame of both the sound device and the conference
3709 * bridge. Specifying lower ptime will normally reduce the
3710 * latency.
3711 *
Benny Prijono37c710b2008-01-10 12:09:26 +00003712 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003713 */
3714 unsigned audio_frame_ptime;
3715
3716 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003717 * Specify maximum number of media ports to be created in the
3718 * conference bridge. Since all media terminate in the bridge
3719 * (calls, file player, file recorder, etc), the value must be
3720 * large enough to support all of them. However, the larger
3721 * the value, the more computations are performed.
Benny Prijono37c710b2008-01-10 12:09:26 +00003722 *
3723 * Default value: PJSUA_MAX_CONF_PORTS
Benny Prijono312aff92006-06-17 04:08:30 +00003724 */
3725 unsigned max_media_ports;
3726
3727 /**
3728 * Specify whether the media manager should manage its own
3729 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
3730 * and at least one worker thread will be created too. If no,
3731 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
3732 * and no worker thread is needed.
3733 *
3734 * Normally application would say yes here, unless it wants to
3735 * run everything from a single thread.
3736 */
3737 pj_bool_t has_ioqueue;
3738
3739 /**
3740 * Specify the number of worker threads to handle incoming RTP
3741 * packets. A value of one is recommended for most applications.
3742 */
3743 unsigned thread_cnt;
3744
Benny Prijono0498d902006-06-19 14:49:14 +00003745 /**
3746 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00003747 * 5-10: resampling use large filter,
3748 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00003749 * 1-2: resampling use linear.
3750 * The media quality also sets speex codec quality/complexity to the
3751 * number.
3752 *
Benny Prijono70972992006-08-05 11:13:58 +00003753 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00003754 */
3755 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00003756
3757 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003758 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00003759 *
3760 * Default: 0 (codec specific)
3761 */
3762 unsigned ptime;
3763
3764 /**
3765 * Disable VAD?
3766 *
3767 * Default: 0 (no (meaning VAD is enabled))
3768 */
3769 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00003770
3771 /**
3772 * iLBC mode (20 or 30).
3773 *
Benny Prijono37c710b2008-01-10 12:09:26 +00003774 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00003775 */
3776 unsigned ilbc_mode;
3777
3778 /**
3779 * Percentage of RTP packet to drop in TX direction
3780 * (to simulate packet lost).
3781 *
3782 * Default: 0
3783 */
3784 unsigned tx_drop_pct;
3785
3786 /**
3787 * Percentage of RTP packet to drop in RX direction
3788 * (to simulate packet lost).
3789 *
3790 * Default: 0
3791 */
3792 unsigned rx_drop_pct;
3793
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003794 /**
Benny Prijono5da50432006-08-07 10:24:52 +00003795 * Echo canceller options (see #pjmedia_echo_create())
3796 *
3797 * Default: 0.
3798 */
3799 unsigned ec_options;
3800
3801 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003802 * Echo canceller tail length, in miliseconds.
3803 *
Benny Prijono669643c2006-09-20 20:02:18 +00003804 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003805 */
3806 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003807
3808 /**
3809 * Jitter buffer initial prefetch delay in msec. The value must be
3810 * between jb_min_pre and jb_max_pre below.
3811 *
3812 * Default: -1 (to use default stream settings, currently 150 msec)
3813 */
3814 int jb_init;
3815
3816 /**
3817 * Jitter buffer minimum prefetch delay in msec.
3818 *
3819 * Default: -1 (to use default stream settings, currently 60 msec)
3820 */
3821 int jb_min_pre;
3822
3823 /**
3824 * Jitter buffer maximum prefetch delay in msec.
3825 *
3826 * Default: -1 (to use default stream settings, currently 240 msec)
3827 */
3828 int jb_max_pre;
3829
3830 /**
3831 * Set maximum delay that can be accomodated by the jitter buffer msec.
3832 *
3833 * Default: -1 (to use default stream settings, currently 360 msec)
3834 */
3835 int jb_max;
3836
Benny Prijonoc97608e2007-03-23 16:34:20 +00003837 /**
3838 * Enable ICE
3839 */
3840 pj_bool_t enable_ice;
3841
3842 /**
3843 * Enable ICE media relay.
3844 */
3845 pj_bool_t enable_relay;
Benny Prijono312aff92006-06-17 04:08:30 +00003846};
3847
3848
3849/**
3850 * Use this function to initialize media config.
3851 *
3852 * @param cfg The media config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003853 *
3854 * \par Python:
3855 * \code
3856 media_cfg = py_pjsua.media_config_default()
3857 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003858 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003859PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00003860
3861
3862/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003863 * This structure describes codec information, which can be retrieved by
3864 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00003865 */
3866typedef struct pjsua_codec_info
3867{
3868 /**
3869 * Codec unique identification.
3870 */
3871 pj_str_t codec_id;
3872
3873 /**
3874 * Codec priority (integer 0-255).
3875 */
3876 pj_uint8_t priority;
3877
3878 /**
3879 * Internal buffer.
3880 */
3881 char buf_[32];
3882
3883} pjsua_codec_info;
3884
3885
3886/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003887 * This structure descibes information about a particular media port that
3888 * has been registered into the conference bridge. Application can query
3889 * this info by calling #pjsua_conf_get_port_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003890 *
3891 * \par Python:
3892 * In Python, this type is <tt>py_pjsua.Conf_Port_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003893 */
3894typedef struct pjsua_conf_port_info
3895{
3896 /** Conference port number. */
3897 pjsua_conf_port_id slot_id;
3898
3899 /** Port name. */
3900 pj_str_t name;
3901
3902 /** Clock rate. */
3903 unsigned clock_rate;
3904
3905 /** Number of channels. */
3906 unsigned channel_count;
3907
3908 /** Samples per frame */
3909 unsigned samples_per_frame;
3910
3911 /** Bits per sample */
3912 unsigned bits_per_sample;
3913
3914 /** Number of listeners in the array. */
3915 unsigned listener_cnt;
3916
3917 /** Array of listeners (in other words, ports where this port is
3918 * transmitting to.
3919 */
3920 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
3921
3922} pjsua_conf_port_info;
3923
3924
3925/**
3926 * This structure holds information about custom media transport to
3927 * be registered to pjsua.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003928 *
3929 * \par Python:
3930 * Not applicable.
Benny Prijono312aff92006-06-17 04:08:30 +00003931 */
3932typedef struct pjsua_media_transport
3933{
3934 /**
3935 * Media socket information containing the address information
3936 * of the RTP and RTCP socket.
3937 */
3938 pjmedia_sock_info skinfo;
3939
3940 /**
3941 * The media transport instance.
3942 */
3943 pjmedia_transport *transport;
3944
3945} pjsua_media_transport;
3946
3947
3948
3949
Benny Prijono9fc735d2006-05-28 14:58:12 +00003950/**
3951 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003952 *
3953 * @return Maximum number of ports in the conference bridge.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003954 *
3955 * \par Python:
3956 * \code
3957 port_count = py_pjsua.conf_get_max_ports()
3958 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003959 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003960PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003961
3962
3963/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003964 * Get current number of active ports in the bridge.
3965 *
3966 * @return The number.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003967 *
3968 * \par Python:
3969 * \code
3970 count = py_pjsua.conf_get_active_ports()
3971 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003972 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003973PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
3974
3975
3976/**
3977 * Enumerate all conference ports.
3978 *
3979 * @param id Array of conference port ID to be initialized.
3980 * @param count On input, specifies max elements in the array.
3981 * On return, it contains actual number of elements
3982 * that have been initialized.
3983 *
3984 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003985 *
3986 * \par Python:
3987 * The Python functions returns list of conference port Ids:
3988 * \code
3989 [port_ids] = py_pjsua.enum_conf_ports()
3990 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003991 */
3992PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
3993 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003994
3995
3996/**
3997 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003998 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003999 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004000 * @param info Pointer to store the port info.
4001 *
4002 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004003 *
4004 * \par Python:
4005 * \code
4006 port_info = py_pjsua.conf_get_port_info(port_id)
4007 * \endcode
4008 * The function will return None if \a port_id is not valid.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004009 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004010PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00004011 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004012
4013
4014/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00004015 * Add arbitrary media port to PJSUA's conference bridge. Application
4016 * can use this function to add the media port that it creates. For
4017 * media ports that are created by PJSUA-LIB (such as calls, file player,
4018 * or file recorder), PJSUA-LIB will automatically add the port to
4019 * the bridge.
4020 *
4021 * @param pool Pool to use.
4022 * @param port Media port to be added to the bridge.
4023 * @param p_id Optional pointer to receive the conference
4024 * slot id.
4025 *
4026 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004027 *
4028 * \par Python:
4029 * Not applicable (for now)
Benny Prijonoe909eac2006-07-27 22:04:56 +00004030 */
4031PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
4032 pjmedia_port *port,
4033 pjsua_conf_port_id *p_id);
4034
4035
4036/**
4037 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00004038 * call this function if it registered the port manually with previous call
4039 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00004040 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004041 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00004042 *
4043 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004044 *
4045 * \par Python:
4046 * \code
4047 status = py_pjsua.conf_remove_port(port_id)
4048 * \endcode
Benny Prijonoe909eac2006-07-27 22:04:56 +00004049 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004050PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00004051
4052
4053/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004054 * Establish unidirectional media flow from souce to sink. One source
4055 * may transmit to multiple destinations/sink. And if multiple
4056 * sources are transmitting to the same sink, the media will be mixed
4057 * together. Source and sink may refer to the same ID, effectively
4058 * looping the media.
4059 *
4060 * If bidirectional media flow is desired, application needs to call
4061 * this function twice, with the second one having the arguments
4062 * reversed.
4063 *
4064 * @param source Port ID of the source media/transmitter.
4065 * @param sink Port ID of the destination media/received.
4066 *
4067 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004068 *
4069 * \par Python:
4070 * \code
4071 status = py_pjsua.conf_connect(source, sink)
4072 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004073 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004074PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
4075 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004076
4077
4078/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004079 * Disconnect media flow from the source to destination port.
4080 *
4081 * @param source Port ID of the source media/transmitter.
4082 * @param sink Port ID of the destination media/received.
4083 *
4084 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004085 *
4086 * \par Python:
4087 * \code
4088 status = py_pjsua.conf_disconnect(source, sink)
4089 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004090 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004091PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
4092 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004093
4094
Benny Prijono6dd967c2006-12-26 02:27:14 +00004095/**
4096 * Adjust the signal level to be transmitted from the bridge to the
4097 * specified port by making it louder or quieter.
4098 *
4099 * @param slot The conference bridge slot number.
4100 * @param level Signal level adjustment. Value 1.0 means no level
4101 * adjustment, while value 0 means to mute the port.
4102 *
4103 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004104 *
4105 * \par Python:
4106 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004107 */
4108PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
4109 float level);
4110
4111/**
4112 * Adjust the signal level to be received from the specified port (to
4113 * the bridge) by making it louder or quieter.
4114 *
4115 * @param slot The conference bridge slot number.
4116 * @param level Signal level adjustment. Value 1.0 means no level
4117 * adjustment, while value 0 means to mute the port.
4118 *
4119 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004120 *
4121 * \par Python:
4122 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004123 */
4124PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
4125 float level);
4126
4127/**
4128 * Get last signal level transmitted to or received from the specified port.
4129 * The signal level is an integer value in zero to 255, with zero indicates
4130 * no signal, and 255 indicates the loudest signal level.
4131 *
4132 * @param slot The conference bridge slot number.
4133 * @param tx_level Optional argument to receive the level of signal
4134 * transmitted to the specified port (i.e. the direction
4135 * is from the bridge to the port).
4136 * @param rx_level Optional argument to receive the level of signal
4137 * received from the port (i.e. the direction is from the
4138 * port to the bridge).
4139 *
4140 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004141 *
4142 * \par Python:
4143 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004144 */
4145PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
4146 unsigned *tx_level,
4147 unsigned *rx_level);
4148
Benny Prijono6dd967c2006-12-26 02:27:14 +00004149
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004150/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00004151 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004152 */
4153
Benny Prijono9fc735d2006-05-28 14:58:12 +00004154/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004155 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004156 * the conference bridge.
4157 *
4158 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00004159 * WAV files are supported, and the WAV file MUST be
4160 * formatted as 16bit PCM mono/single channel (any
4161 * clock rate is supported).
Benny Prijono58add7c2008-01-18 13:24:07 +00004162 * @param options Optional option flag. Application may specify
4163 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004164 * @param p_id Pointer to receive player ID.
4165 *
4166 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004167 *
4168 * \par Python:
4169 * The function returns (status, id) tuple:
4170 * \code
4171 status, id = py_pjsua.player_create(filename, options)
4172 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004173 */
4174PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004175 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004176 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004177
4178
4179/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004180 * Create a file playlist media port, and automatically add the port
4181 * to the conference bridge.
4182 *
4183 * @param file_names Array of file names to be added to the play list.
4184 * Note that the files must have the same clock rate,
4185 * number of channels, and number of bits per sample.
4186 * @param file_count Number of files in the array.
4187 * @param label Optional label to be set for the media port.
4188 * @param options Optional option flag. Application may specify
4189 * PJMEDIA_FILE_NO_LOOP to prevent looping.
4190 * @param p_id Optional pointer to receive player ID.
4191 *
4192 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004193 *
4194 * \par Python:
4195 * Not implemented yet.
Benny Prijonoa66c3312007-01-21 23:12:40 +00004196 */
4197PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
4198 unsigned file_count,
4199 const pj_str_t *label,
4200 unsigned options,
4201 pjsua_player_id *p_id);
4202
4203/**
4204 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004205 *
4206 * @param id The file player ID.
4207 *
4208 * @return Conference port ID associated with this player.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004209 *
4210 * \par Python:
4211 * \code
4212 port_id = py_pjsua.player_get_conf_port(id)
4213 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004214 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004215PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004216
4217
4218/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004219 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00004220 *
4221 * @param id The player ID.
4222 * @param p_port The media port associated with the player.
4223 *
4224 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004225 *
4226 * \par Python:
4227 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004228 */
Benny Prijono58add7c2008-01-18 13:24:07 +00004229PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
Benny Prijono469b1522006-12-26 03:05:17 +00004230 pjmedia_port **p_port);
4231
4232/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004233 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004234 *
4235 * @param id The file player ID.
4236 * @param samples The playback position, in samples. Application can
4237 * specify zero to re-start the playback.
4238 *
4239 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004240 *
4241 * \par Python:
4242 * \code
4243 status = py_pjsua.player_set_pos(id, samples)
4244 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004245 */
4246PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
4247 pj_uint32_t samples);
4248
4249
4250/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004251 * Close the file of playlist, remove the player from the bridge, and free
4252 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004253 *
4254 * @param id The file player ID.
4255 *
4256 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004257 *
4258 * \par Python:
4259 * \code
4260 status = py_pjsua.player_destroy(id)
4261 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004262 */
4263PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
4264
4265
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004266/*****************************************************************************
4267 * File recorder.
4268 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00004269
4270/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004271 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004272 * the conference bridge. The recorder currently supports recording WAV file.
4273 * The type of the recorder to use is determined by the extension of the file
4274 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004275 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00004276 * @param filename Output file name. The function will determine the
4277 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004278 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00004279 * @param enc_type Optionally specify the type of encoder to be used to
4280 * compress the media, if the file can support different
4281 * encodings. This value must be zero for now.
4282 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004283 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00004284 * For .WAV recorder, this value must be NULL.
4285 * @param max_size Maximum file size. Specify zero or -1 to remove size
4286 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004287 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004288 * @param p_id Pointer to receive the recorder instance.
4289 *
4290 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004291 *
4292 * \par Python:
4293 * \code
4294 status, id = py_pjsua.recorder_create(filename, enc_type, enc_param, max_size, options)
4295 * \endcode
4296 * The \a enc_param is a string in Python.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004297 */
4298PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004299 unsigned enc_type,
4300 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004301 pj_ssize_t max_size,
4302 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004303 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004304
4305
4306/**
4307 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004308 *
4309 * @param id The recorder ID.
4310 *
4311 * @return Conference port ID associated with this recorder.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004312 *
4313 * \par Python:
4314 * \code
4315 port_id = py_pjsua.recorder_get_conf_port(id)
4316 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004317 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004318PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004319
4320
4321/**
Benny Prijono469b1522006-12-26 03:05:17 +00004322 * Get the media port for the recorder.
4323 *
4324 * @param id The recorder ID.
4325 * @param p_port The media port associated with the recorder.
4326 *
4327 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004328 *
4329 * \par Python:
4330 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004331 */
4332PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4333 pjmedia_port **p_port);
4334
4335
4336/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004337 * Destroy recorder (this will complete recording).
4338 *
4339 * @param id The recorder ID.
4340 *
4341 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004342 *
4343 * \par Python:
4344 * \code
4345 status = py_pjsua.recorder_destroy(id)
4346 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004347 */
4348PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4349
4350
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004351/*****************************************************************************
4352 * Sound devices.
4353 */
4354
Benny Prijono9fc735d2006-05-28 14:58:12 +00004355/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004356 * Enum all sound devices installed in the system.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004357 *
4358 * @param info Array of info to be initialized.
4359 * @param count On input, specifies max elements in the array.
4360 * On return, it contains actual number of elements
4361 * that have been initialized.
4362 *
4363 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004364 *
4365 *
4366 * \par Python:
4367 * The function returns list of sound device info:
4368 * \code
4369 [dev_infos] = py_pjsua.enum_snd_devs()
4370 * \endcode
4371 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00004372 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004373PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4374 unsigned *count);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004375
4376
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004377
4378/**
4379 * Get currently active sound devices. If sound devices has not been created
4380 * (for example when pjsua_start() is not called), it is possible that
4381 * the function returns PJ_SUCCESS with -1 as device IDs.
4382 *
4383 * @param capture_dev On return it will be filled with device ID of the
4384 * capture device.
4385 * @param playback_dev On return it will be filled with device ID of the
4386 * device ID of the playback device.
4387 *
4388 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004389 *
4390 * \par Python:
Benny Prijonoebdf8772007-02-01 19:25:50 +00004391 * The function takes no argument and return an (integer,integer) tuple:
Benny Prijonoe6ead542007-01-31 20:53:31 +00004392 * \code
4393 capture_dev, playback_dev = py_pjsua.get_snd_dev()
4394 * \endcode
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004395 */
4396PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4397 int *playback_dev);
4398
4399
Benny Prijono9fc735d2006-05-28 14:58:12 +00004400/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004401 * Select or change sound device. Application may call this function at
4402 * any time to replace current sound device.
4403 *
4404 * @param capture_dev Device ID of the capture device.
4405 * @param playback_dev Device ID of the playback device.
4406 *
4407 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004408 *
4409 * \par Python:
4410 * \code
4411 status = py_pjsua.set_snd_dev(capture_dev, playback_dev)
4412 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004413 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004414PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4415 int playback_dev);
4416
4417
4418/**
4419 * Set pjsua to use null sound device. The null sound device only provides
4420 * the timing needed by the conference bridge, and will not interract with
4421 * any hardware.
4422 *
4423 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004424 *
4425 * \par Python:
4426 * \code
4427 status = py_pjsua.set_null_snd_dev()
4428 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004429 */
4430PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4431
4432
Benny Prijonoe909eac2006-07-27 22:04:56 +00004433/**
4434 * Disconnect the main conference bridge from any sound devices, and let
4435 * application connect the bridge to it's own sound device/master port.
4436 *
4437 * @return The port interface of the conference bridge,
4438 * so that application can connect this to it's own
4439 * sound device or master port.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004440 *
4441 * \par Python:
4442 * Not applicable (for now).
Benny Prijonoe909eac2006-07-27 22:04:56 +00004443 */
4444PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4445
4446
Benny Prijonof20687a2006-08-04 18:27:19 +00004447/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004448 * Configure the echo canceller tail length of the sound port.
Benny Prijonof20687a2006-08-04 18:27:19 +00004449 *
4450 * @param tail_ms The tail length, in miliseconds. Set to zero to
4451 * disable AEC.
Benny Prijono5da50432006-08-07 10:24:52 +00004452 * @param options Options to be passed to #pjmedia_echo_create().
4453 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004454 *
4455 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004456 *
4457 * \par Python:
4458 * \code
4459 status = py_pjsua.set_ec(tail_ms, options)
4460 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004461 */
Benny Prijono5da50432006-08-07 10:24:52 +00004462PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004463
4464
4465/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004466 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004467 *
4468 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4469 * If AEC is disabled, the value will be zero.
4470 *
4471 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004472 *
4473 * \par Python:
4474 * \code
4475 tail_ms = py_pjsua.get_ec_tail()
4476 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004477 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004478PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004479
4480
4481
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004482/*****************************************************************************
4483 * Codecs.
4484 */
4485
4486/**
4487 * Enum all supported codecs in the system.
4488 *
4489 * @param id Array of ID to be initialized.
4490 * @param count On input, specifies max elements in the array.
4491 * On return, it contains actual number of elements
4492 * that have been initialized.
4493 *
4494 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004495 *
4496 * \par Python:
4497 * This function takes no argument and returns list of codec infos:
4498 * \code
4499 [codec_info] = py_pjsua.enum_codecs()
4500 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004501 */
4502PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4503 unsigned *count );
4504
4505
4506/**
4507 * Change codec priority.
4508 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004509 * @param codec_id Codec ID, which is a string that uniquely identify
4510 * the codec (such as "speex/8000"). Please see pjsua
4511 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004512 * @param priority Codec priority, 0-255, where zero means to disable
4513 * the codec.
4514 *
4515 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004516 *
4517 * \par Python:
4518 * \code
4519 status = py_pjsua.codec_set_priority(codec_id, priority)
4520 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004521 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004522PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004523 pj_uint8_t priority );
4524
4525
4526/**
4527 * Get codec parameters.
4528 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004529 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004530 * @param param Structure to receive codec parameters.
4531 *
4532 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004533 *
4534 * \par Python:
4535 * The Python function is experimental:
4536 * \code
4537 codec_param = py_pjsua.codec_get_param(codec_id)
4538 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004539 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004540PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004541 pjmedia_codec_param *param );
4542
4543
4544/**
4545 * Set codec parameters.
4546 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004547 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004548 * @param param Codec parameter to set.
4549 *
4550 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004551 *
4552 * \par Python:
4553 * The Python function is experimental:
4554 * \code
4555 status = py_pjsua.codec_set_param(codec_id, param)
4556 * \endcode
4557
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004558 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004559PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004560 const pjmedia_codec_param *param);
4561
4562
4563
Benny Prijono9fc735d2006-05-28 14:58:12 +00004564
Benny Prijono312aff92006-06-17 04:08:30 +00004565/**
4566 * Create UDP media transports for all the calls. This function creates
4567 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00004568 *
Benny Prijono312aff92006-06-17 04:08:30 +00004569 * @param cfg Media transport configuration. The "port" field in the
4570 * configuration is used as the start port to bind the
4571 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004572 *
4573 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004574 *
4575 * \par Python:
4576 * Not implemented yet.
Benny Prijonof3195072006-02-14 21:15:30 +00004577 */
Benny Prijono312aff92006-06-17 04:08:30 +00004578PJ_DECL(pj_status_t)
4579pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00004580
Benny Prijonodc39fe82006-05-26 12:17:46 +00004581
4582/**
Benny Prijono312aff92006-06-17 04:08:30 +00004583 * Register custom media transports to be used by calls. There must
4584 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004585 *
Benny Prijono312aff92006-06-17 04:08:30 +00004586 * @param tp The media transport array.
4587 * @param count Number of elements in the array. This number MUST
4588 * match the number of maximum calls configured when
4589 * pjsua is created.
4590 * @param auto_delete Flag to indicate whether the transports should be
4591 * destroyed when pjsua is shutdown.
4592 *
4593 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004594 *
4595 * \par Python:
4596 * Note applicable.
Benny Prijonodc39fe82006-05-26 12:17:46 +00004597 */
Benny Prijono312aff92006-06-17 04:08:30 +00004598PJ_DECL(pj_status_t)
4599pjsua_media_transports_attach( pjsua_media_transport tp[],
4600 unsigned count,
4601 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00004602
4603
Benny Prijono312aff92006-06-17 04:08:30 +00004604/**
4605 * @}
4606 */
4607
Benny Prijonof3195072006-02-14 21:15:30 +00004608
Benny Prijono268ca612006-02-07 12:34:11 +00004609
Benny Prijono312aff92006-06-17 04:08:30 +00004610/**
4611 * @}
4612 */
4613
Benny Prijonoe6ead542007-01-31 20:53:31 +00004614PJ_END_DECL
4615
Benny Prijono312aff92006-06-17 04:08:30 +00004616
Benny Prijono268ca612006-02-07 12:34:11 +00004617#endif /* __PJSUA_H__ */