blob: e6f6e2de722102ac02437bc487005548d24570a0 [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
Benny Prijonofc13bf62008-02-20 08:56:15 +0000605
606 /**
607 * Notify application when media session is created and before it is
608 * registered to the conference bridge. Application may return different
609 * media port if it has added media processing port to the stream. This
610 * media port then will be added to the conference bridge instead.
611 *
612 * @param call_id Call identification.
613 * @param sess Media session for the call.
614 * @param stream_idx Stream index in the media session.
615 * @param p_port On input, it specifies the media port of the
616 * stream. Application may modify this pointer to
617 * point to different media port to be registered
618 * to the conference bridge.
619 *
620 * \par Python:
621 * Not applicable.
622 */
623 void (*on_stream_created)(pjsua_call_id call_id,
624 pjmedia_session *sess,
625 unsigned stream_idx,
626 pjmedia_port **p_port);
627
628 /**
629 * Notify application when media session has been unregistered from the
630 * conference bridge and about to be destroyed.
631 *
632 * @param call_id Call identification.
633 * @param sess Media session for the call.
634 * @param stream_idx Stream index in the media session.
635 *
636 * \par Python:
637 * Not applicable.
638 */
639 void (*on_stream_destroyed)(pjsua_call_id call_id,
640 pjmedia_session *sess,
641 unsigned stream_idx);
642
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000643 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000644 * Notify application upon incoming DTMF digits.
645 *
646 * @param call_id The call index.
647 * @param digit DTMF ASCII digit.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000648 *
649 * \par Python Syntax:
650 * \code
651 # call_id: integer
Benny Prijono1f63cc42007-09-10 16:54:22 +0000652 # digit: digit string
Benny Prijonoe6ead542007-01-31 20:53:31 +0000653
654 def on_dtmf_digit(call_id, digit):
655 return
656 * \endcode
Benny Prijono0875ae82006-12-26 00:11:48 +0000657 */
658 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
659
660 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000661 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000662 * Application can decide to accept/reject transfer request
663 * by setting the code (default is 200). When this callback
664 * is not defined, the default behavior is to accept the
665 * transfer.
Benny Prijono0875ae82006-12-26 00:11:48 +0000666 *
667 * @param call_id The call index.
668 * @param dst The destination where the call will be
669 * transfered to.
670 * @param code Status code to be returned for the call transfer
671 * request. On input, it contains status code 200.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000672 *
673 * \par Python Syntax:
674 * \code
675 # call_id: integer
676 # dst: string
677 # code: integer
678
679 def on_call_transfer_request(call_id, dst, code):
680 return code
681
682 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000683 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000684 void (*on_call_transfer_request)(pjsua_call_id call_id,
685 const pj_str_t *dst,
686 pjsip_status_code *code);
687
688 /**
689 * Notify application of the status of previously sent call
690 * transfer request. Application can monitor the status of the
691 * call transfer request, for example to decide whether to
692 * terminate existing call.
693 *
694 * @param call_id Call ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000695 * @param st_code Status progress of the transfer request.
696 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000697 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000698 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000699 * this callback is the final status.
700 * @param p_cont Initially will be set to non-zero, application
701 * can set this to FALSE if it no longer wants
702 * to receie further notification (for example,
703 * after it hangs up the call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000704 *
705 * \par Python Syntax:
706 * \code
707 # call_id: integer
708 # st_code: integer
709 # st_text: string
710 # final: integer
711 # cont: integer
712
713 # return: cont
714
715 def on_call_transfer_status(call_id, st_code, st_text, final, cont):
716 return cont
717 * \endcode
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000718 */
719 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000720 int st_code,
721 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000722 pj_bool_t final,
723 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000724
725 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000726 * Notify application about incoming INVITE with Replaces header.
727 * Application may reject the request by setting non-2xx code.
728 *
729 * @param call_id The call ID to be replaced.
730 * @param rdata The incoming INVITE request to replace the call.
731 * @param st_code Status code to be set by application. Application
732 * should only return a final status (200-699).
733 * @param st_text Optional status text to be set by application.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000734 *
735 * \par Python Syntax:
736 * \code
737 # call_id: integer
738 # rdata: an opaque object
739 # st_code: integer
740 # st_text: string
741
742 # return: (st_code, st_text) tuple
743
744 def on_call_replace_request(call_id, rdata, st_code, st_text):
745 return st_code, st_text
746 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000747 */
748 void (*on_call_replace_request)(pjsua_call_id call_id,
749 pjsip_rx_data *rdata,
750 int *st_code,
751 pj_str_t *st_text);
752
753 /**
754 * Notify application that an existing call has been replaced with
755 * a new call. This happens when PJSUA-API receives incoming INVITE
756 * request with Replaces header.
757 *
758 * After this callback is called, normally PJSUA-API will disconnect
759 * \a old_call_id and establish \a new_call_id.
760 *
761 * @param old_call_id Existing call which to be replaced with the
762 * new call.
763 * @param new_call_id The new call.
764 * @param rdata The incoming INVITE with Replaces request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000765 *
766 * \par Python Syntax:
767 * \code
768 # old_call_id: integer
769 # new_call_id: integer
770
771 def on_call_replaced(old_call_id, new_call_id):
772 return
773 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000774 */
775 void (*on_call_replaced)(pjsua_call_id old_call_id,
776 pjsua_call_id new_call_id);
777
778
779 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000780 * Notify application when registration status has changed.
781 * Application may then query the account info to get the
782 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000783 *
784 * @param acc_id Account ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000785 *
786 * \par Python Syntax:
787 * \code
788 # acc_id: account ID (integer)
789
790 def on_reg_state(acc_id):
791 return
792 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000793 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000794 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000795
796 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000797 * Notify application when the buddy state has changed.
798 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000799 *
800 * @param buddy_id The buddy id.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000801 *
802 * \par Python Syntax:
803 * \code
804 # buddy_id: integer
805
806 def on_buddy_state(buddy_id):
807 return
808 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000809 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000810 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000811
812 /**
813 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000814 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000815 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000816 *
Benny Prijonobbeb3992007-05-21 13:48:35 +0000817 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
818 * passed as one of the argument.
819 *
Benny Prijono0875ae82006-12-26 00:11:48 +0000820 * @param call_id Containts the ID of the call where the IM was
821 * sent, or PJSUA_INVALID_ID if the IM was sent
822 * outside call context.
823 * @param from URI of the sender.
824 * @param to URI of the destination message.
825 * @param contact The Contact URI of the sender, if present.
826 * @param mime_type MIME type of the message.
827 * @param body The message content.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000828 *
829 * \par Python Syntax:
830 * \code
831 # call_id: integer
832 # from: string
833 # to: string
834 # contact: string
835 # mime_type: string
836 # body: string
837
838 def on_pager(call_id, from, to, contact, mime_type, body):
839 return
840 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000841 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000842 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
843 const pj_str_t *to, const pj_str_t *contact,
844 const pj_str_t *mime_type, const pj_str_t *body);
845
846 /**
Benny Prijonobbeb3992007-05-21 13:48:35 +0000847 * This is the alternative version of the \a on_pager() callback with
848 * \a pjsip_rx_data argument.
849 *
850 * @param call_id Containts the ID of the call where the IM was
851 * sent, or PJSUA_INVALID_ID if the IM was sent
852 * outside call context.
853 * @param from URI of the sender.
854 * @param to URI of the destination message.
855 * @param contact The Contact URI of the sender, if present.
856 * @param mime_type MIME type of the message.
857 * @param body The message content.
858 * @param rdata The incoming MESSAGE request.
859 */
860 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
861 const pj_str_t *to, const pj_str_t *contact,
862 const pj_str_t *mime_type, const pj_str_t *body,
863 pjsip_rx_data *rdata);
864
865 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000866 * Notify application about the delivery status of outgoing pager
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000867 * request. See also on_pager_status2() callback for the version with
868 * \a pjsip_rx_data in the argument list.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000869 *
870 * @param call_id Containts the ID of the call where the IM was
871 * sent, or PJSUA_INVALID_ID if the IM was sent
872 * outside call context.
873 * @param to Destination URI.
874 * @param body Message body.
875 * @param user_data Arbitrary data that was specified when sending
876 * IM message.
877 * @param status Delivery status.
878 * @param reason Delivery status reason.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000879 *
880 * \par Python Syntax
881 * \code
882 # call_id: integer
883 # to: string
884 # body: string
885 # user_data: string
886 # status: integer
887 # reason: string
888
889 def on_pager_status(call_id, to, body, user_data, status, reason):
890 return
891 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000892 */
893 void (*on_pager_status)(pjsua_call_id call_id,
894 const pj_str_t *to,
895 const pj_str_t *body,
896 void *user_data,
897 pjsip_status_code status,
898 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000899
900 /**
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000901 * Notify application about the delivery status of outgoing pager
902 * request.
903 *
904 * @param call_id Containts the ID of the call where the IM was
905 * sent, or PJSUA_INVALID_ID if the IM was sent
906 * outside call context.
907 * @param to Destination URI.
908 * @param body Message body.
909 * @param user_data Arbitrary data that was specified when sending
910 * IM message.
911 * @param status Delivery status.
912 * @param reason Delivery status reason.
Benny Prijono0a982002007-06-12 16:22:09 +0000913 * @param tdata The original MESSAGE request.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000914 * @param rdata The incoming MESSAGE response, or NULL if the
915 * message transaction fails because of time out
916 * or transport error.
917 */
918 void (*on_pager_status2)(pjsua_call_id call_id,
919 const pj_str_t *to,
920 const pj_str_t *body,
921 void *user_data,
922 pjsip_status_code status,
923 const pj_str_t *reason,
Benny Prijono0a982002007-06-12 16:22:09 +0000924 pjsip_tx_data *tdata,
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000925 pjsip_rx_data *rdata);
926
927 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000928 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +0000929 *
930 * @param call_id Containts the ID of the call where the IM was
931 * sent, or PJSUA_INVALID_ID if the IM was sent
932 * outside call context.
933 * @param from URI of the sender.
934 * @param to URI of the destination message.
935 * @param contact The Contact URI of the sender, if present.
936 * @param is_typing Non-zero if peer is typing, or zero if peer
937 * has stopped typing a message.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000938 *
939 * \par Python Syntax
940 * \code
941 # call_id: string
942 # from: string
943 # to: string
944 # contact: string
945 # is_typing: integer
946
947 def on_typing(call_id, from, to, contact, is_typing):
948 return
949 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000950 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000951 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
952 const pj_str_t *to, const pj_str_t *contact,
953 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000954
Benny Prijono6ba8c542007-10-16 01:34:14 +0000955 /**
956 * Callback when the library has finished performing NAT type
957 * detection.
958 *
959 * @param res NAT detection result.
960 */
961 void (*on_nat_detect)(const pj_stun_nat_detect_result *res);
962
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000963} pjsua_callback;
964
965
966
Benny Prijonodc39fe82006-05-26 12:17:46 +0000967
968/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000969 * This structure describes the settings to control the API and
970 * user agent behavior, and can be specified when calling #pjsua_init().
971 * Before setting the values, application must call #pjsua_config_default()
972 * to initialize this structure with the default values.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000973 *
974 * \par Python Sample Syntax:
975 * The pjsua_config type in Python is <tt>py_pjsua.Config</tt>. Application
976 * creates the instance by calling <tt>py_pjsua.config_default()</tt>:
977 * \code
978 cfg = py_pjsua.config_default()
979 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000980 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000981typedef struct pjsua_config
982{
983
984 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000985 * Maximum calls to support (default: 4). The value specified here
986 * must be smaller than the compile time maximum settings
987 * PJSUA_MAX_CALLS, which by default is 32. To increase this
988 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
989 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000990 */
991 unsigned max_calls;
992
993 /**
994 * Number of worker threads. Normally application will want to have at
995 * least one worker thread, unless when it wants to poll the library
996 * periodically, which in this case the worker thread can be set to
997 * zero.
998 */
999 unsigned thread_cnt;
1000
1001 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +00001002 * Number of nameservers. If no name server is configured, the SIP SRV
1003 * resolution would be disabled, and domain will be resolved with
1004 * standard pj_gethostbyname() function.
1005 */
1006 unsigned nameserver_count;
1007
1008 /**
1009 * Array of nameservers to be used by the SIP resolver subsystem.
1010 * The order of the name server specifies the priority (first name
1011 * server will be used first, unless it is not reachable).
1012 */
1013 pj_str_t nameserver[4];
1014
1015 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001016 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001017 */
1018 unsigned outbound_proxy_cnt;
1019
1020 /**
1021 * Specify the URL of outbound proxies to visit for all outgoing requests.
1022 * The outbound proxies will be used for all accounts, and it will
1023 * be used to build the route set for outgoing requests. The final
1024 * route set for outgoing requests will consists of the outbound proxies
1025 * and the proxy configured in the account.
1026 */
1027 pj_str_t outbound_proxy[4];
1028
Benny Prijonoc97608e2007-03-23 16:34:20 +00001029 /**
Benny Prijonoebbf6892007-03-24 17:37:25 +00001030 * Specify domain name to be resolved with DNS SRV resolution to get the
1031 * address of the STUN servers. Alternatively application may specify
1032 * \a stun_host and \a stun_relay_host instead.
1033 *
1034 * If DNS SRV resolution failed for this domain, then DNS A resolution
1035 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +00001036 */
Benny Prijonoebbf6892007-03-24 17:37:25 +00001037 pj_str_t stun_domain;
1038
1039 /**
Benny Prijonoaf09dc32007-04-22 12:48:30 +00001040 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
1041 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001042 */
1043 pj_str_t stun_host;
1044
1045 /**
1046 * Specify STUN relay server to be used.
1047 */
1048 pj_str_t stun_relay_host;
Benny Prijonoc97608e2007-03-23 16:34:20 +00001049
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001050 /**
Benny Prijono91a6a172007-10-31 08:59:29 +00001051 * Support for adding and parsing NAT type in the SDP to assist
1052 * troubleshooting. The valid values are:
1053 * - 0: no information will be added in SDP, and parsing is disabled.
Benny Prijono6ba8c542007-10-16 01:34:14 +00001054 * - 1: only the NAT type number is added.
1055 * - 2: add both NAT type number and name.
1056 *
Benny Prijono91a6a172007-10-31 08:59:29 +00001057 * Default: 1
Benny Prijono6ba8c542007-10-16 01:34:14 +00001058 */
1059 int nat_type_in_sdp;
1060
1061 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001062 * Specify whether support for reliable provisional response (100rel and
1063 * PRACK) should be required by default. Note that this setting can be
1064 * further customized in account configuration (#pjsua_acc_config).
1065 *
1066 * Default: PJ_FALSE
1067 */
1068 pj_bool_t require_100rel;
1069
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001070 /**
1071 * Number of credentials in the credential array.
1072 */
1073 unsigned cred_count;
1074
1075 /**
1076 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +00001077 * and can be used to authenticate against outbound proxies. If the
1078 * credential is specific to the account, then application should set
1079 * the credential in the pjsua_acc_config rather than the credential
1080 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001081 */
1082 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1083
1084 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001085 * Application callback to receive various event notifications from
1086 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001087 */
1088 pjsua_callback cb;
1089
Benny Prijono56315612006-07-18 14:39:40 +00001090 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001091 * Optional user agent string (default empty). If it's empty, no
1092 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +00001093 */
1094 pj_str_t user_agent;
1095
Benny Prijonod8179652008-01-23 20:39:07 +00001096#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
1097 /**
1098 * Specify default value of secure media transport usage.
1099 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
1100 * PJMEDIA_SRTP_MANDATORY.
1101 *
1102 * Note that this setting can be further customized in account
1103 * configuration (#pjsua_acc_config).
1104 *
1105 * Default: #PJSUA_DEFAULT_USE_SRTP
1106 */
1107 pjmedia_srtp_use use_srtp;
1108
1109 /**
1110 * Specify whether SRTP requires secure signaling to be used. This option
1111 * is only used when \a use_srtp option above is non-zero.
1112 *
1113 * Valid values are:
1114 * 0: SRTP does not require secure signaling
1115 * 1: SRTP requires secure transport such as TLS
1116 * 2: SRTP requires secure end-to-end transport (SIPS)
1117 *
1118 * Note that this setting can be further customized in account
1119 * configuration (#pjsua_acc_config).
1120 *
1121 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
1122 */
1123 int srtp_secure_signaling;
1124#endif
1125
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001126} pjsua_config;
1127
1128
1129/**
1130 * Use this function to initialize pjsua config.
1131 *
1132 * @param cfg pjsua config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001133 *
1134 * \par Python Sample Syntax:
1135 * The corresponding Python function creates an instance of the config and
1136 * initializes it to the default settings:
1137 * \code
1138 cfg = py_pjsua.config_default()
1139 * \endcode
1140
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001141 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001142PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001143
1144
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001145/** The implementation has been moved to sip_auth.h */
Benny Prijono7977f9f2007-10-10 11:37:56 +00001146#define pjsip_cred_dup pjsip_cred_info_dup
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001147
1148
1149/**
1150 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001151 *
1152 * @param pool The pool to get memory from.
1153 * @param dst Destination config.
1154 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001155 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001156PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1157 pjsua_config *dst,
1158 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001159
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001160
1161/**
1162 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001163 * outgoing SIP message. It can (optionally) be specified for example
1164 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1165 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1166 *
1167 * Application MUST call #pjsua_msg_data_init() to initialize this
1168 * structure before setting its values.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001169 *
1170 * \par Python Syntax
1171 * The data type in Python is <tt>py_pjsua.Msg_Data</tt>. Application is
1172 * recommended to instantiate the structure by using this construct:
1173 * \code
1174 msg_data = py_pjsua.msg_data_init()
1175 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001176 */
1177typedef struct pjsua_msg_data
1178{
1179 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001180 * Additional message headers as linked list. Application can add
1181 * headers to the list by creating the header, either from the heap/pool
1182 * or from temporary local variable, and add the header using
1183 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001184 *
1185 * \par Python:
1186 * This field is implemented as string linked-list in Python, where each
1187 * string describes the header. For example:
1188 \code
1189 msg_data = py_pjsua.Msg_Data()
1190 msg_data.hdr_list = ["Subject: Hello py_pjsua!", "Priority: very low"]
1191 \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001192 */
1193 pjsip_hdr hdr_list;
1194
1195 /**
1196 * MIME type of optional message body.
1197 */
1198 pj_str_t content_type;
1199
1200 /**
1201 * Optional message body.
1202 */
1203 pj_str_t msg_body;
1204
1205} pjsua_msg_data;
1206
1207
1208/**
1209 * Initialize message data.
1210 *
1211 * @param msg_data Message data to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001212 *
1213 * \par Python
1214 * The corresponding Python function creates and initializes the structure:
1215 * \code
1216 msg_data = py_pjsua.msg_data_init()
1217 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001218 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001219PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001220
Benny Prijono268ca612006-02-07 12:34:11 +00001221
1222/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001223 * Instantiate pjsua application. Application must call this function before
1224 * calling any other functions, to make sure that the underlying libraries
1225 * are properly initialized. Once this function has returned success,
1226 * application must call pjsua_destroy() before quitting.
1227 *
1228 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001229 *
1230 * \par Python:
1231 * \code
1232 status = py_pjsua.create()
1233 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001234 */
1235PJ_DECL(pj_status_t) pjsua_create(void);
1236
1237
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001238/** Forward declaration */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001239typedef struct pjsua_media_config pjsua_media_config;
1240
1241
Benny Prijonodc39fe82006-05-26 12:17:46 +00001242/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001243 * Initialize pjsua with the specified settings. All the settings are
1244 * optional, and the default values will be used when the config is not
1245 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001246 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001247 * Note that #pjsua_create() MUST be called before calling this function.
1248 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001249 * @param ua_cfg User agent configuration.
1250 * @param log_cfg Optional logging configuration.
1251 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001252 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001253 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001254 *
1255 * \par Python:
1256 * The function is similar in Python:
1257 * \code
1258 status = py_pjsua.init(ua_cfg, log_cfg, media_cfg)
1259 * \endcode
1260 * Note that \a ua_cfg, \a log_cfg, and \a media_cfg are optional, and
1261 * the Python script may pass None if it doesn't want to configure the
1262 * setting.
Benny Prijono268ca612006-02-07 12:34:11 +00001263 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001264PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1265 const pjsua_logging_config *log_cfg,
1266 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001267
1268
1269/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001270 * Application is recommended to call this function after all initialization
1271 * is done, so that the library can do additional checking set up
1272 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001273 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001274 * Application may call this function anytime after #pjsua_init().
1275 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001276 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001277 *
1278 * \par Python:
1279 * The function is similar in Python:
1280 * \code
1281 status = py_pjsua.start()
1282 * \endcode
Benny Prijonoccf95622006-02-07 18:48:01 +00001283 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001284PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001285
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001286
Benny Prijonoccf95622006-02-07 18:48:01 +00001287/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001288 * Destroy pjsua. Application is recommended to perform graceful shutdown
1289 * before calling this function (such as unregister the account from the SIP
1290 * server, terminate presense subscription, and hangup active calls), however,
1291 * this function will do all of these if it finds there are active sessions
1292 * that need to be terminated. This function will approximately block for
1293 * one second to wait for replies from remote.
1294 *
1295 * Application.may safely call this function more than once if it doesn't
1296 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001297 *
1298 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001299 *
1300 * \par Python:
1301 * The function is similar in Python:
1302 * \code
1303 status = py_pjsua.destroy()
1304 * \endcode
Benny Prijono268ca612006-02-07 12:34:11 +00001305 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001306PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001307
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001308
Benny Prijono9fc735d2006-05-28 14:58:12 +00001309/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001310 * Poll pjsua for events, and if necessary block the caller thread for
1311 * the specified maximum interval (in miliseconds).
1312 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001313 * Application doesn't normally need to call this function if it has
1314 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1315 * because polling then will be done by these worker threads instead.
1316 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001317 * @param msec_timeout Maximum time to wait, in miliseconds.
1318 *
1319 * @return The number of events that have been handled during the
1320 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001321 * can retrieve the error as (status = -return_value).
1322 *
1323 * \par Python:
1324 * The function is similar in Python:
1325 * \code
1326 n = py_pjsua.handle_events(msec_timeout)
1327 * \endcode
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001328 */
1329PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1330
1331
1332/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001333 * Create memory pool to be used by the application. Once application
1334 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001335 *
1336 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001337 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001338 * @param increment Increment size.
1339 *
1340 * @return The pool, or NULL when there's no memory.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001341 *
1342 * \par Python:
1343 * Python script may also create a pool object from the script:
1344 * \code
1345 pool = py_pjsua.pool_create(name, init_size, increment)
1346 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001347 */
1348PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1349 pj_size_t increment);
1350
1351
1352/**
1353 * Application can call this function at any time (after pjsua_create(), of
1354 * course) to change logging settings.
1355 *
1356 * @param c Logging configuration.
1357 *
1358 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001359 *
1360 * \par Python:
1361 * The function is similar in Python:
1362 * \code
1363 status = py_pjsua.reconfigure_logging(log_cfg)
1364 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001365 */
1366PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1367
1368
1369/**
1370 * Internal function to get SIP endpoint instance of pjsua, which is
1371 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001372 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001373 *
1374 * @return SIP endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001375 *
1376 * \par Python:
1377 * Application may retrieve the SIP endpoint instance:
1378 * \code
1379 endpt = py_pjsua.get_pjsip_endpt()
1380 * \endcode
1381 * However currently the object is just an opaque object and does not have
1382 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001383 */
1384PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1385
1386/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001387 * Internal function to get media endpoint instance.
1388 * Only valid after #pjsua_init() is called.
1389 *
1390 * @return Media endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001391 *
1392 * \par Python:
1393 * Application may retrieve the media endpoint instance:
1394 * \code
1395 endpt = py_pjsua.get_pjmedia_endpt()
1396 * \endcode
1397 * However currently the object is just an opaque object and does not have
1398 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001399 */
1400PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1401
Benny Prijono97b87172006-08-24 14:25:14 +00001402/**
1403 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001404 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001405 *
1406 * @return Pool factory currently used by PJSUA.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001407 *
1408 * \par Python:
1409 * Application may retrieve the pool factory instance:
1410 * \code
1411 endpt = py_pjsua.get_pool_factory()
1412 * \endcode
1413 * However currently the object is just an opaque object and does not have
1414 * any use for Python scripts.
Benny Prijono97b87172006-08-24 14:25:14 +00001415 */
1416PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1417
1418
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001419
1420/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001421 * Utilities.
1422 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001423 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001424
1425/**
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001426 * This is a utility function to detect NAT type in front of this
1427 * endpoint. Once invoked successfully, this function will complete
Benny Prijono6ba8c542007-10-16 01:34:14 +00001428 * asynchronously and report the result in \a on_nat_detect() callback
1429 * of pjsua_callback.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001430 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001431 * After NAT has been detected and the callback is called, application can
1432 * get the detected NAT type by calling #pjsua_get_nat_type(). Application
1433 * can also perform NAT detection by calling #pjsua_detect_nat_type()
1434 * again at later time.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001435 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001436 * Note that STUN must be enabled to run this function successfully.
1437 *
1438 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001439 */
Benny Prijono6ba8c542007-10-16 01:34:14 +00001440PJ_DECL(pj_status_t) pjsua_detect_nat_type(void);
1441
1442
1443/**
1444 * Get the NAT type as detected by #pjsua_detect_nat_type() function.
1445 * This function will only return useful NAT type after #pjsua_detect_nat_type()
1446 * has completed successfully and \a on_nat_detect() callback has been called.
1447 *
1448 * @param type NAT type.
1449 *
1450 * @return When detection is in progress, this function will
1451 * return PJ_EPENDING and \a type will be set to
1452 * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been
1453 * detected successfully, this function will return
1454 * PJ_SUCCESS and \a type will be set to the correct
1455 * value. Other return values indicate error and
1456 * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN.
Benny Prijono91a6a172007-10-31 08:59:29 +00001457 *
1458 * @see pjsua_call_get_rem_nat_type()
Benny Prijono6ba8c542007-10-16 01:34:14 +00001459 */
1460PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type);
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001461
1462
1463/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001464 * This is a utility function to verify that valid SIP url is given. If the
1465 * URL is valid, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001466 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001467 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001468 *
1469 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001470 *
1471 * \par Python:
1472 * \code
1473 status = py_pjsua.verify_sip_url(url)
1474 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001475 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001476PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001477
1478
1479/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001480 * This is a utility function to display error message for the specified
1481 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001482 *
1483 * @param sender The log sender field.
1484 * @param title Message title for the error.
1485 * @param status Status code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001486 *
1487 * \par Python:
1488 * \code
1489 py_pjsua.perror(sender, title, status)
1490 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001491 */
1492PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1493 pj_status_t status);
1494
1495
Benny Prijonoda9785b2007-04-02 20:43:06 +00001496/**
1497 * This is a utility function to dump the stack states to log, using
1498 * verbosity level 3.
1499 *
1500 * @param detail Will print detailed output (such as list of
1501 * SIP transactions) when non-zero.
1502 */
1503PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001504
1505/**
1506 * @}
1507 */
1508
1509
1510
1511/*****************************************************************************
1512 * TRANSPORT API
1513 */
1514
1515/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001516 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001517 * @ingroup PJSUA_LIB
1518 * @brief API for managing SIP transports
1519 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001520 *
1521 * PJSUA-API supports creating multiple transport instances, for example UDP,
1522 * TCP, and TLS transport. SIP transport must be created before adding an
1523 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001524 */
1525
1526
Benny Prijonoe6ead542007-01-31 20:53:31 +00001527/** SIP transport identification.
1528 */
Benny Prijono312aff92006-06-17 04:08:30 +00001529typedef int pjsua_transport_id;
1530
1531
1532/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001533 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001534 * and media. Before setting some values to this structure, application
1535 * MUST call #pjsua_transport_config_default() to initialize its
1536 * values with default settings.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001537 *
1538 * \par Python:
1539 * The data type in Python is <tt>py_pjsua.Transport_Config</tt>,
1540 * although application can just do this to create the instance:
1541 * \code
1542 transport_cfg = py_pjsua.transport_config_default()
1543 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001544 */
1545typedef struct pjsua_transport_config
1546{
1547 /**
1548 * UDP port number to bind locally. This setting MUST be specified
1549 * even when default port is desired. If the value is zero, the
1550 * transport will be bound to any available port, and application
1551 * can query the port by querying the transport info.
1552 */
1553 unsigned port;
1554
1555 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001556 * Optional address to advertise as the address of this transport.
1557 * Application can specify any address or hostname for this field,
1558 * for example it can point to one of the interface address in the
1559 * system, or it can point to the public address of a NAT router
1560 * where port mappings have been configured for the application.
1561 *
1562 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001563 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001564 pj_str_t public_addr;
1565
1566 /**
1567 * Optional address where the socket should be bound to. This option
1568 * SHOULD only be used to selectively bind the socket to particular
1569 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1570 * published address of a transport (the public_addr field should be
1571 * used for that purpose).
1572 *
1573 * Note that unlike public_addr field, the address (or hostname) here
1574 * MUST correspond to the actual interface address in the host, since
1575 * this address will be specified as bind() argument.
1576 */
1577 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001578
1579 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001580 * This specifies TLS settings for TLS transport. It is only be used
1581 * when this transport config is being used to create a SIP TLS
1582 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001583 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001584 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001585
Benny Prijono312aff92006-06-17 04:08:30 +00001586} pjsua_transport_config;
1587
1588
1589/**
1590 * Call this function to initialize UDP config with default values.
1591 *
1592 * @param cfg The UDP config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001593 *
1594 * \par Python:
1595 * The corresponding Python function is rather different:
1596 * \code
1597 transport_cfg = py_pjsua.transport_config_default()
1598 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001599 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001600PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001601
1602
1603/**
Benny Prijono312aff92006-06-17 04:08:30 +00001604 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001605 *
1606 * @param pool The pool.
1607 * @param dst The destination config.
1608 * @param src The source config.
1609 *
1610 * \par Python:
1611 * Not applicable. One should be able to just copy one variable instance
1612 * to another in Python.
Benny Prijono312aff92006-06-17 04:08:30 +00001613 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001614PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1615 pjsua_transport_config *dst,
1616 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001617
1618
1619/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001620 * This structure describes transport information returned by
1621 * #pjsua_transport_get_info() function.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001622 *
1623 * \par Python:
1624 * The corresponding data type in Python is <tt>py_pjsua.Transport_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001625 */
1626typedef struct pjsua_transport_info
1627{
1628 /**
1629 * PJSUA transport identification.
1630 */
1631 pjsua_transport_id id;
1632
1633 /**
1634 * Transport type.
1635 */
1636 pjsip_transport_type_e type;
1637
1638 /**
1639 * Transport type name.
1640 */
1641 pj_str_t type_name;
1642
1643 /**
1644 * Transport string info/description.
1645 */
1646 pj_str_t info;
1647
1648 /**
1649 * Transport flag (see ##pjsip_transport_flags_e).
1650 */
1651 unsigned flag;
1652
1653 /**
1654 * Local address length.
1655 */
1656 unsigned addr_len;
1657
1658 /**
1659 * Local/bound address.
1660 */
1661 pj_sockaddr local_addr;
1662
1663 /**
1664 * Published address (or transport address name).
1665 */
1666 pjsip_host_port local_name;
1667
1668 /**
1669 * Current number of objects currently referencing this transport.
1670 */
1671 unsigned usage_count;
1672
1673
1674} pjsua_transport_info;
1675
1676
1677/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001678 * Create and start a new SIP transport according to the specified
1679 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001680 *
1681 * @param type Transport type.
1682 * @param cfg Transport configuration.
1683 * @param p_id Optional pointer to receive transport ID.
1684 *
1685 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001686 *
1687 * \par Python:
1688 * The corresponding Python function returns (status,id) tuple:
1689 * \code
1690 status, transport_id = py_pjsua.transport_create(type, cfg)
1691 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001692 */
1693PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1694 const pjsua_transport_config *cfg,
1695 pjsua_transport_id *p_id);
1696
1697/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001698 * Register transport that has been created by application. This function
1699 * is useful if application wants to implement custom SIP transport and use
1700 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001701 *
1702 * @param tp Transport instance.
1703 * @param p_id Optional pointer to receive transport ID.
1704 *
1705 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001706 *
1707 * \par Python:
1708 * Not applicable (for now), because one cannot create a custom transport
1709 * from Python script.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001710 */
1711PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1712 pjsua_transport_id *p_id);
1713
1714
1715/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001716 * Enumerate all transports currently created in the system. This function
1717 * will return all transport IDs, and application may then call
1718 * #pjsua_transport_get_info() function to retrieve detailed information
1719 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001720 *
1721 * @param id Array to receive transport ids.
1722 * @param count In input, specifies the maximum number of elements.
1723 * On return, it contains the actual number of elements.
1724 *
1725 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001726 *
1727 * \par Python:
1728 * The function returns list of integers representing transport ids:
1729 * \code
1730 [int] = py_pjsua.enum_transports()
1731 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001732 */
1733PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1734 unsigned *count );
1735
1736
1737/**
1738 * Get information about transports.
1739 *
1740 * @param id Transport ID.
1741 * @param info Pointer to receive transport info.
1742 *
1743 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001744 *
1745 * \par Python:
1746 * \code
1747 transport_info = py_pjsua.transport_get_info(id)
1748 * \endcode
1749 * The Python function returns None on error.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001750 */
1751PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1752 pjsua_transport_info *info);
1753
1754
1755/**
1756 * Disable a transport or re-enable it. By default transport is always
1757 * enabled after it is created. Disabling a transport does not necessarily
1758 * close the socket, it will only discard incoming messages and prevent
1759 * the transport from being used to send outgoing messages.
1760 *
1761 * @param id Transport ID.
1762 * @param enabled Non-zero to enable, zero to disable.
1763 *
1764 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001765 *
1766 * \par Python:
1767 * \code
1768 status = py_pjsua.transport_set_enable(id, enabled)
1769 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001770 */
1771PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1772 pj_bool_t enabled);
1773
1774
1775/**
1776 * Close the transport. If transport is forcefully closed, it will be
1777 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00001778 * transport may not terminate properly (it may even crash). Otherwise,
1779 * the system will wait until all transactions are closed while preventing
1780 * new users from using the transport, and will close the transport when
1781 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001782 *
1783 * @param id Transport ID.
1784 * @param force Non-zero to immediately close the transport. This
1785 * is not recommended!
1786 *
1787 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001788 *
1789 * \par Python:
1790 * \code
1791 status = py_pjsua.transport_close(id, force)
1792 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001793 */
1794PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1795 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001796
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001797/**
Benny Prijono312aff92006-06-17 04:08:30 +00001798 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001799 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001800
1801
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001802
1803
1804/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001805 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001806 */
1807
Benny Prijono312aff92006-06-17 04:08:30 +00001808
1809/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001810 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001811 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001812 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001813 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001814 *
Benny Prijono312aff92006-06-17 04:08:30 +00001815 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001816 * using the application. In SIP terms, the identity is used as the <b>From</b>
1817 * header in outgoing requests.
1818 *
1819 * PJSUA-API supports creating and managing multiple accounts. The maximum
1820 * number of accounts is limited by a compile time constant
1821 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001822 *
1823 * Account may or may not have client registration associated with it.
1824 * An account is also associated with <b>route set</b> and some <b>authentication
1825 * credentials</b>, which are used when sending SIP request messages using the
1826 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00001827 * will be reported to remote peer when they subscribe to the account's
1828 * presence, or which is published to a presence server if presence
1829 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00001830 *
1831 * At least one account MUST be created in the application. If no user
1832 * association is required, application can create a userless account by
1833 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00001834 * instead of a particular user, and it correspond with a particular
1835 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00001836 *
1837 * Also one account must be set as the <b>default account</b>, which is used as
1838 * the account to use when PJSUA fails to match a request with any other
1839 * accounts.
1840 *
1841 * When sending outgoing SIP requests (such as making calls or sending
1842 * instant messages), normally PJSUA requires the application to specify
1843 * which account to use for the request. If no account is specified,
1844 * PJSUA may be able to select the account by matching the destination
1845 * domain name, and fall back to default account when no match is found.
1846 */
1847
1848/**
1849 * Maximum accounts.
1850 */
1851#ifndef PJSUA_MAX_ACC
1852# define PJSUA_MAX_ACC 8
1853#endif
1854
1855
1856/**
1857 * Default registration interval.
1858 */
1859#ifndef PJSUA_REG_INTERVAL
Benny Prijonobddef2c2007-10-31 13:28:08 +00001860# define PJSUA_REG_INTERVAL 300
Benny Prijono312aff92006-06-17 04:08:30 +00001861#endif
1862
1863
1864/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001865 * Default PUBLISH expiration
1866 */
1867#ifndef PJSUA_PUBLISH_EXPIRATION
1868# define PJSUA_PUBLISH_EXPIRATION 600
1869#endif
1870
1871
1872/**
Benny Prijono093d3022006-09-24 00:07:11 +00001873 * Default account priority.
1874 */
1875#ifndef PJSUA_DEFAULT_ACC_PRIORITY
1876# define PJSUA_DEFAULT_ACC_PRIORITY 0
1877#endif
1878
1879
1880/**
Benny Prijono8058a622007-06-08 04:37:05 +00001881 * This macro specifies the URI scheme to use in Contact header
1882 * when secure transport such as TLS is used. Application can specify
1883 * either "sip" or "sips".
1884 */
1885#ifndef PJSUA_SECURE_SCHEME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00001886# define PJSUA_SECURE_SCHEME "sips"
Benny Prijono8058a622007-06-08 04:37:05 +00001887#endif
1888
1889
1890/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001891 * This structure describes account configuration to be specified when
1892 * adding a new account with #pjsua_acc_add(). Application MUST initialize
1893 * this structure first by calling #pjsua_acc_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00001894 *
1895 * \par Python:
1896 * The data type in Python is <tt>py_pjsua.Acc_Config</tt>, but normally
1897 * application can just use the snippet below to create and initialize
1898 * the account config:
1899 * \code
1900 acc_cfg = py_pjsua.acc_config_default()
1901 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001902 */
1903typedef struct pjsua_acc_config
1904{
Benny Prijono093d3022006-09-24 00:07:11 +00001905 /**
1906 * Account priority, which is used to control the order of matching
1907 * incoming/outgoing requests. The higher the number means the higher
1908 * the priority is, and the account will be matched first.
1909 */
1910 int priority;
1911
Benny Prijono312aff92006-06-17 04:08:30 +00001912 /**
1913 * The full SIP URL for the account. The value can take name address or
1914 * URL format, and will look something like "sip:account@serviceprovider".
1915 *
1916 * This field is mandatory.
1917 */
1918 pj_str_t id;
1919
1920 /**
1921 * This is the URL to be put in the request URI for the registration,
1922 * and will look something like "sip:serviceprovider".
1923 *
1924 * This field should be specified if registration is desired. If the
1925 * value is empty, no account registration will be performed.
1926 */
1927 pj_str_t reg_uri;
1928
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001929 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001930 * If this flag is set, the presence information of this account will
1931 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono48ab2b72007-11-08 09:24:30 +00001932 *
1933 * Default: PJ_FALSE
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001934 */
1935 pj_bool_t publish_enabled;
1936
Benny Prijonofe04fb52007-08-24 08:28:52 +00001937 /**
Benny Prijono48ab2b72007-11-08 09:24:30 +00001938 * Authentication preference.
1939 */
1940 pjsip_auth_clt_pref auth_pref;
1941
1942 /**
Benny Prijonofe04fb52007-08-24 08:28:52 +00001943 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
1944 * is not specified, a random string will be used.
1945 */
1946 pj_str_t pidf_tuple_id;
1947
Benny Prijono312aff92006-06-17 04:08:30 +00001948 /**
1949 * Optional URI to be put as Contact for this account. It is recommended
1950 * that this field is left empty, so that the value will be calculated
1951 * automatically based on the transport address.
1952 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00001953 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00001954
1955 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001956 * Specify whether support for reliable provisional response (100rel and
1957 * PRACK) should be required for all sessions of this account.
1958 *
1959 * Default: PJ_FALSE
1960 */
1961 pj_bool_t require_100rel;
1962
1963 /**
Benny Prijono312aff92006-06-17 04:08:30 +00001964 * Number of proxies in the proxy array below.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001965 *
1966 * \par Python:
1967 * Not applicable, as \a proxy is implemented as list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001968 */
1969 unsigned proxy_cnt;
1970
1971 /**
1972 * Optional URI of the proxies to be visited for all outgoing requests
1973 * that are using this account (REGISTER, INVITE, etc). Application need
1974 * to specify these proxies if the service provider requires that requests
1975 * destined towards its network should go through certain proxies first
1976 * (for example, border controllers).
1977 *
1978 * These proxies will be put in the route set for this account, with
1979 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00001980 * first). If global outbound proxies are configured in pjsua_config,
1981 * then these account proxies will be placed after the global outbound
1982 * proxies in the routeset.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001983 *
1984 * \par Python:
1985 * This will be list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001986 */
1987 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
1988
1989 /**
1990 * Optional interval for registration, in seconds. If the value is zero,
Benny Prijonobddef2c2007-10-31 13:28:08 +00001991 * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
Benny Prijono312aff92006-06-17 04:08:30 +00001992 */
1993 unsigned reg_timeout;
1994
1995 /**
1996 * Number of credentials in the credential array.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001997 *
1998 * \par Python:
1999 * Not applicable, since \a cred_info is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00002000 */
2001 unsigned cred_count;
2002
2003 /**
2004 * Array of credentials. If registration is desired, normally there should
2005 * be at least one credential specified, to successfully authenticate
2006 * against the service provider. More credentials can be specified, for
2007 * example when the requests are expected to be challenged by the
2008 * proxies in the route set.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002009 *
2010 * \par Python:
2011 * This field is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00002012 */
2013 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
2014
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002015 /**
2016 * Optionally bind this account to specific transport. This normally is
2017 * not a good idea, as account should be able to send requests using
2018 * any available transports according to the destination. But some
2019 * application may want to have explicit control over the transport to
2020 * use, so in that case it can set this field.
2021 *
2022 * Default: -1 (PJSUA_INVALID_ID)
2023 *
2024 * @see pjsua_acc_set_transport()
2025 */
2026 pjsua_transport_id transport_id;
2027
Benny Prijono15b02302007-09-27 14:07:07 +00002028 /**
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002029 * This option is used to update the UDP transport address and the Contact
2030 * header of REGISTER request. When this option is enabled, the library
2031 * will keep track of the public IP address from the response of REGISTER
2032 * request. Once it detects that the address has changed, it will
2033 * unregister current Contact, update the Contact with transport address
2034 * learned from Via header, and register a new Contact to the registrar.
2035 * This will also update the public name of UDP transport if STUN is
2036 * configured.
Benny Prijono15b02302007-09-27 14:07:07 +00002037 *
2038 * Default: 1 (yes)
2039 */
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002040 pj_bool_t allow_contact_rewrite;
Benny Prijono15b02302007-09-27 14:07:07 +00002041
Benny Prijonobddef2c2007-10-31 13:28:08 +00002042 /**
2043 * Set the interval for periodic keep-alive transmission for this account.
2044 * If this value is zero, keep-alive will be disabled for this account.
2045 * The keep-alive transmission will be sent to the registrar's address,
2046 * after successful registration.
2047 *
2048 * Even if this setting is enabled, keep-alive transmission is only done
2049 * when STUN is enabled in the global #pjsua_config, and the transport
2050 * used for registration is UDP. For TCP and TLS transports, keep-alive
2051 * is done by the transport themselves.
2052 *
2053 * Default: 15 (seconds)
2054 */
2055 unsigned ka_interval;
2056
2057 /**
2058 * Specify the data to be transmitted as keep-alive packets.
2059 *
2060 * Default: CR-LF
2061 */
2062 pj_str_t ka_data;
2063
Benny Prijonod8179652008-01-23 20:39:07 +00002064#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
2065 /**
2066 * Specify whether secure media transport should be used for this account.
2067 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
2068 * PJMEDIA_SRTP_MANDATORY.
2069 *
2070 * Default: #PJSUA_DEFAULT_USE_SRTP
2071 */
2072 pjmedia_srtp_use use_srtp;
2073
2074 /**
2075 * Specify whether SRTP requires secure signaling to be used. This option
2076 * is only used when \a use_srtp option above is non-zero.
2077 *
2078 * Valid values are:
2079 * 0: SRTP does not require secure signaling
2080 * 1: SRTP requires secure transport such as TLS
2081 * 2: SRTP requires secure end-to-end transport (SIPS)
2082 *
2083 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
2084 */
2085 int srtp_secure_signaling;
2086#endif
2087
Benny Prijono312aff92006-06-17 04:08:30 +00002088} pjsua_acc_config;
2089
2090
2091/**
2092 * Call this function to initialize account config with default values.
2093 *
2094 * @param cfg The account config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002095 *
2096 * \par Python:
2097 * In Python, this function both creates and initializes the account
2098 * config:
2099 * \code
2100 acc_cfg = py_pjsua.acc_config_default()
2101 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002102 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00002103PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002104
2105
2106/**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002107 * Duplicate account config.
2108 *
2109 * @param pool Pool to be used for duplicating the config.
2110 * @param dst Destination configuration.
2111 * @param src Source configuration.
2112 */
2113PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
2114 pjsua_acc_config *dst,
2115 const pjsua_acc_config *src);
2116
2117
2118/**
Benny Prijono312aff92006-06-17 04:08:30 +00002119 * Account info. Application can query account info by calling
2120 * #pjsua_acc_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00002121 *
2122 * \par Python:
2123 * The data type in Python is <tt>py_pjsua.Acc_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002124 */
2125typedef struct pjsua_acc_info
2126{
2127 /**
2128 * The account ID.
2129 */
2130 pjsua_acc_id id;
2131
2132 /**
2133 * Flag to indicate whether this is the default account.
2134 */
2135 pj_bool_t is_default;
2136
2137 /**
2138 * Account URI
2139 */
2140 pj_str_t acc_uri;
2141
2142 /**
2143 * Flag to tell whether this account has registration setting
2144 * (reg_uri is not empty).
2145 */
2146 pj_bool_t has_registration;
2147
2148 /**
2149 * An up to date expiration interval for account registration session.
2150 */
2151 int expires;
2152
2153 /**
2154 * Last registration status code. If status code is zero, the account
2155 * is currently not registered. Any other value indicates the SIP
2156 * status code of the registration.
2157 */
2158 pjsip_status_code status;
2159
2160 /**
2161 * String describing the registration status.
2162 */
2163 pj_str_t status_text;
2164
2165 /**
2166 * Presence online status for this account.
2167 */
2168 pj_bool_t online_status;
2169
2170 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00002171 * Presence online status text.
2172 */
2173 pj_str_t online_status_text;
2174
2175 /**
2176 * Extended RPID online status information.
2177 */
2178 pjrpid_element rpid;
2179
2180 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002181 * Buffer that is used internally to store the status text.
2182 */
2183 char buf_[PJ_ERR_MSG_SIZE];
2184
2185} pjsua_acc_info;
2186
2187
2188
2189/**
2190 * Get number of current accounts.
2191 *
2192 * @return Current number of accounts.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002193 *
2194 * \par Python:
2195 * \code
2196 count = py_pjsua.acc_get_count()
2197 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002198 */
2199PJ_DECL(unsigned) pjsua_acc_get_count(void);
2200
2201
2202/**
2203 * Check if the specified account ID is valid.
2204 *
2205 * @param acc_id Account ID to check.
2206 *
2207 * @return Non-zero if account ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002208 *
2209 * \par Python:
2210 * \code
2211 is_valid = py_pjsua.acc_is_valid(acc_id)
2212 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002213 */
2214PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
2215
2216
2217/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00002218 * Set default account to be used when incoming and outgoing
2219 * requests doesn't match any accounts.
2220 *
2221 * @param acc_id The account ID to be used as default.
2222 *
2223 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002224 *
2225 * \par Python:
2226 * \code
2227 status = py_pjsua.acc_set_default(acc_id)
2228 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002229 */
2230PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2231
2232
2233/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002234 * Get default account to be used when receiving incoming requests (calls),
2235 * when the destination of the incoming call doesn't match any other
2236 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002237 *
2238 * @return The default account ID, or PJSUA_INVALID_ID if no
2239 * default account is configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002240 *
2241 * \par Python:
2242 * \code
2243 acc_id = py_pjsua.acc_get_default()
2244 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002245 */
2246PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2247
2248
2249/**
Benny Prijono312aff92006-06-17 04:08:30 +00002250 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002251 * #pjsua_init()) before calling this function. If registration is configured
2252 * for this account, this function would also start the SIP registration
2253 * session with the SIP registrar server. This SIP registration session
2254 * will be maintained internally by the library, and application doesn't
2255 * need to do anything to maintain the registration session.
2256 *
Benny Prijono312aff92006-06-17 04:08:30 +00002257 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002258 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002259 * @param is_default If non-zero, this account will be set as the default
2260 * account. The default account will be used when sending
2261 * outgoing requests (e.g. making call) when no account is
2262 * specified, and when receiving incoming requests when the
2263 * request does not match any accounts. It is recommended
2264 * that default account is set to local/LAN account.
2265 * @param p_acc_id Pointer to receive account ID of the new account.
2266 *
2267 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002268 *
2269 * \par Python:
2270 * The function returns (status, account_id) tuple:
2271 * \code
2272 status, account_id = py_pjsua.acc_add(acc_cfg, is_default)
2273 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002274 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002275PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002276 pj_bool_t is_default,
2277 pjsua_acc_id *p_acc_id);
2278
2279
2280/**
2281 * Add a local account. A local account is used to identify local endpoint
2282 * instead of a specific user, and for this reason, a transport ID is needed
2283 * to obtain the local address information.
2284 *
2285 * @param tid Transport ID to generate account address.
2286 * @param is_default If non-zero, this account will be set as the default
2287 * account. The default account will be used when sending
2288 * outgoing requests (e.g. making call) when no account is
2289 * specified, and when receiving incoming requests when the
2290 * request does not match any accounts. It is recommended
2291 * that default account is set to local/LAN account.
2292 * @param p_acc_id Pointer to receive account ID of the new account.
2293 *
2294 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002295 *
2296 * \par Python:
2297 * The function returns (status, account_id) tuple:
2298 * \code
2299 status, account_id = py_pjsua.acc_add_local(tid, is_default)
2300 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002301 */
2302PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2303 pj_bool_t is_default,
2304 pjsua_acc_id *p_acc_id);
2305
2306/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002307 * Delete an account. This will unregister the account from the SIP server,
2308 * if necessary, and terminate server side presence subscriptions associated
2309 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002310 *
2311 * @param acc_id Id of the account to be deleted.
2312 *
2313 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002314 *
2315 * \par Python:
2316 * \code
2317 status = py_pjsua.acc_del(acc_id)
2318 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002319 */
2320PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2321
2322
2323/**
2324 * Modify account information.
2325 *
2326 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002327 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002328 *
2329 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002330 *
2331 * \par Python:
2332 * \code
2333 status = py_pjsua.acc_modify(acc_id, acc_cfg)
2334 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002335 */
2336PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002337 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002338
2339
2340/**
2341 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002342 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002343 * if there are server side presence subscription for this account, and/or
2344 * outgoing PUBLISH if presence publication is enabled for this account.
2345 *
2346 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002347 *
2348 * @param acc_id The account ID.
2349 * @param is_online True of false.
2350 *
2351 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002352 *
2353 * \par Python:
2354 * \code
2355 status = py_pjsua.acc_set_online_status(acc_id, is_online)
2356 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002357 */
2358PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2359 pj_bool_t is_online);
2360
Benny Prijono4461c7d2007-08-25 13:36:15 +00002361/**
2362 * Modify account's presence status to be advertised to remote/presence
2363 * subscribers. This would trigger the sending of outgoing NOTIFY request
2364 * if there are server side presence subscription for this account, and/or
2365 * outgoing PUBLISH if presence publication is enabled for this account.
2366 *
2367 * @see pjsua_acc_set_online_status()
2368 *
2369 * @param acc_id The account ID.
2370 * @param is_online True of false.
2371 * @param pr Extended information in subset of RPID format
2372 * which allows setting custom presence text.
2373 *
2374 * @return PJ_SUCCESS on success, or the appropriate error code.
2375 */
2376PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2377 pj_bool_t is_online,
2378 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002379
2380/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002381 * Update registration or perform unregistration. If registration is
2382 * configured for this account, then initial SIP REGISTER will be sent
2383 * when the account is added with #pjsua_acc_add(). Application normally
2384 * only need to call this function if it wants to manually update the
2385 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002386 *
2387 * @param acc_id The account ID.
2388 * @param renew If renew argument is zero, this will start
2389 * unregistration process.
2390 *
2391 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002392 *
2393 * \par Python:
2394 * \code
2395 status = py_pjsua.acc_set_registration(acc_id, renew)
2396 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002397 */
2398PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2399 pj_bool_t renew);
2400
2401
2402/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002403 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002404 *
2405 * @param acc_id Account identification.
2406 * @param info Pointer to receive account information.
2407 *
2408 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002409 *
2410 * \par Python:
2411 * \code
2412 acc_info = py_pjsua.acc_get_info(acc_id)
2413 * \endcode
2414 * The function returns None if account ID is not valid.
Benny Prijono312aff92006-06-17 04:08:30 +00002415 */
2416PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2417 pjsua_acc_info *info);
2418
2419
2420/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002421 * Enumerate all account currently active in the library. This will fill
2422 * the array with the account Ids, and application can then query the
2423 * account information for each id with #pjsua_acc_get_info().
2424 *
2425 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002426 *
2427 * @param ids Array of account IDs to be initialized.
2428 * @param count In input, specifies the maximum number of elements.
2429 * On return, it contains the actual number of elements.
2430 *
2431 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002432 *
2433 * \par Python:
2434 * The function takes no argument and returns list of account Ids:
2435 * \code
2436 [acc_ids] = py_pjsua.enum_accs()
2437 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002438 */
2439PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2440 unsigned *count );
2441
2442
2443/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002444 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002445 *
2446 * @param info Array of account infos to be initialized.
2447 * @param count In input, specifies the maximum number of elements.
2448 * On return, it contains the actual number of elements.
2449 *
2450 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002451 *
2452 * \par Python:
2453 * The function takes no argument and returns list of account infos:
2454 * \code
2455 [acc_info] = py_pjsua.acc_enum_info()
2456 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002457 */
2458PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2459 unsigned *count );
2460
2461
2462/**
2463 * This is an internal function to find the most appropriate account to
2464 * used to reach to the specified URL.
2465 *
2466 * @param url The remote URL to reach.
2467 *
2468 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002469 *
2470 * \par Python:
2471 * \code
2472 acc_id = py_pjsua.acc_find_for_outgoing(url)
2473 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002474 */
2475PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2476
2477
2478/**
2479 * This is an internal function to find the most appropriate account to be
2480 * used to handle incoming calls.
2481 *
2482 * @param rdata The incoming request message.
2483 *
2484 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002485 *
2486 * \par Python:
2487 * \code
2488 acc_id = py_pjsua.acc_find_for_outgoing(url)
2489 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002490 */
2491PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2492
2493
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002494/**
Benny Prijonofff245c2007-04-02 11:44:47 +00002495 * Create arbitrary requests using the account. Application should only use
2496 * this function to create auxiliary requests outside dialog, such as
2497 * OPTIONS, and use the call or presence API to create dialog related
2498 * requests.
2499 *
2500 * @param acc_id The account ID.
2501 * @param method The SIP method of the request.
2502 * @param target Target URI.
2503 * @param p_tdata Pointer to receive the request.
2504 *
2505 * @return PJ_SUCCESS or the error code.
2506 */
2507PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
2508 const pjsip_method *method,
2509 const pj_str_t *target,
2510 pjsip_tx_data **p_tdata);
2511
2512
2513/**
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002514 * Create a suitable URI to be put as Contact based on the specified
2515 * target URI for the specified account.
2516 *
2517 * @param pool Pool to allocate memory for the string.
2518 * @param contact The string where the Contact URI will be stored.
2519 * @param acc_id Account ID.
2520 * @param uri Destination URI of the request.
2521 *
2522 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002523 *
2524 * \par Python:
2525 * This function is still experimental in Python:
2526 * \code
2527 uri = py_pjsua.acc_create_uac_contact(pool, acc_id, uri)
2528 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002529 */
2530PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
2531 pj_str_t *contact,
2532 pjsua_acc_id acc_id,
2533 const pj_str_t *uri);
2534
2535
2536
2537/**
2538 * Create a suitable URI to be put as Contact based on the information
2539 * in the incoming request.
2540 *
2541 * @param pool Pool to allocate memory for the string.
2542 * @param contact The string where the Contact URI will be stored.
2543 * @param acc_id Account ID.
2544 * @param rdata Incoming request.
2545 *
2546 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002547 *
2548 * \par Python:
2549 * This function is still experimental in Python:
2550 * \code
2551 uri = py_pjsua.acc_create_uas_contact(pool, acc_id, rdata)
2552 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002553 */
2554PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
2555 pj_str_t *contact,
2556 pjsua_acc_id acc_id,
2557 pjsip_rx_data *rdata );
2558
2559
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002560/**
2561 * Lock/bind this account to a specific transport/listener. Normally
2562 * application shouldn't need to do this, as transports will be selected
2563 * automatically by the stack according to the destination.
2564 *
2565 * When account is locked/bound to a specific transport, all outgoing
2566 * requests from this account will use the specified transport (this
2567 * includes SIP registration, dialog (call and event subscription), and
2568 * out-of-dialog requests such as MESSAGE).
2569 *
2570 * Note that transport_id may be specified in pjsua_acc_config too.
2571 *
2572 * @param acc_id The account ID.
2573 * @param tp_id The transport ID.
2574 *
2575 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002576 *
2577 * \par Python:
2578 * Not yet implemented.
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002579 */
2580PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
2581 pjsua_transport_id tp_id);
2582
Benny Prijono312aff92006-06-17 04:08:30 +00002583
2584/**
2585 * @}
2586 */
2587
2588
2589/*****************************************************************************
2590 * CALLS API
2591 */
2592
2593
2594/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002595 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00002596 * @ingroup PJSUA_LIB
2597 * @brief Call manipulation.
2598 * @{
2599 */
2600
2601/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002602 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00002603 */
2604#ifndef PJSUA_MAX_CALLS
2605# define PJSUA_MAX_CALLS 32
2606#endif
2607
2608
2609
2610/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002611 * This enumeration specifies the media status of a call, and it's part
2612 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00002613 */
2614typedef enum pjsua_call_media_status
2615{
Benny Prijonob5388cf2007-01-04 22:45:08 +00002616 /** Call currently has no media */
Benny Prijono312aff92006-06-17 04:08:30 +00002617 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002618
2619 /** The media is active */
Benny Prijono312aff92006-06-17 04:08:30 +00002620 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002621
2622 /** The media is currently put on hold by local endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002623 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002624
2625 /** The media is currently put on hold by remote endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002626 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002627
Benny Prijono096c56c2007-09-15 08:30:16 +00002628 /** The media has reported error (e.g. ICE negotiation) */
2629 PJSUA_CALL_MEDIA_ERROR
2630
Benny Prijono312aff92006-06-17 04:08:30 +00002631} pjsua_call_media_status;
2632
2633
2634/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002635 * This structure describes the information and current status of a call.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002636 *
2637 * \par Python:
2638 * The type name is <tt>py_pjsua.Call_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002639 */
2640typedef struct pjsua_call_info
2641{
2642 /** Call identification. */
2643 pjsua_call_id id;
2644
2645 /** Initial call role (UAC == caller) */
2646 pjsip_role_e role;
2647
Benny Prijono90315512006-09-14 16:05:16 +00002648 /** The account ID where this call belongs. */
2649 pjsua_acc_id acc_id;
2650
Benny Prijono312aff92006-06-17 04:08:30 +00002651 /** Local URI */
2652 pj_str_t local_info;
2653
2654 /** Local Contact */
2655 pj_str_t local_contact;
2656
2657 /** Remote URI */
2658 pj_str_t remote_info;
2659
2660 /** Remote contact */
2661 pj_str_t remote_contact;
2662
2663 /** Dialog Call-ID string. */
2664 pj_str_t call_id;
2665
2666 /** Call state */
2667 pjsip_inv_state state;
2668
2669 /** Text describing the state */
2670 pj_str_t state_text;
2671
2672 /** Last status code heard, which can be used as cause code */
2673 pjsip_status_code last_status;
2674
2675 /** The reason phrase describing the status. */
2676 pj_str_t last_status_text;
2677
2678 /** Call media status. */
2679 pjsua_call_media_status media_status;
2680
2681 /** Media direction */
2682 pjmedia_dir media_dir;
2683
2684 /** The conference port number for the call */
2685 pjsua_conf_port_id conf_slot;
2686
2687 /** Up-to-date call connected duration (zero when call is not
2688 * established)
2689 */
2690 pj_time_val connect_duration;
2691
2692 /** Total call duration, including set-up time */
2693 pj_time_val total_duration;
2694
2695 /** Internal */
2696 struct {
2697 char local_info[128];
2698 char local_contact[128];
2699 char remote_info[128];
2700 char remote_contact[128];
2701 char call_id[128];
2702 char last_status_text[128];
2703 } buf_;
2704
2705} pjsua_call_info;
2706
2707
2708
Benny Prijonoa91a0032006-02-26 21:23:45 +00002709/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002710 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002711 *
2712 * @return Maximum number of calls configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002713 *
2714 * \par Python:
2715 * \code
2716 count = py_pjsua.call_get_max_count()
2717 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002718 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002719PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002720
2721/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002722 * Get number of currently active calls.
2723 *
2724 * @return Number of currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002725 *
2726 * \par Python:
2727 * \code
2728 count = py_pjsua.call_get_count()
2729 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002730 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002731PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002732
2733/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002734 * Enumerate all active calls. Application may then query the information and
2735 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002736 *
2737 * @param ids Array of account IDs to be initialized.
2738 * @param count In input, specifies the maximum number of elements.
2739 * On return, it contains the actual number of elements.
2740 *
2741 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002742 *
2743 * \par Python:
2744 * This function takes no argument and return list of call Ids.
2745 * \code
2746 [call_ids] = py_pjsua.enum_calls()
2747 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002748 */
2749PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
2750 unsigned *count);
2751
2752
2753/**
2754 * Make outgoing call to the specified URI using the specified account.
2755 *
2756 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002757 * @param dst_uri URI to be put in the To header (normally is the same
2758 * as the target URI).
2759 * @param options Options (must be zero at the moment).
2760 * @param user_data Arbitrary user data to be attached to the call, and
2761 * can be retrieved later.
2762 * @param msg_data Optional headers etc to be added to outgoing INVITE
2763 * request, or NULL if no custom header is desired.
2764 * @param p_call_id Pointer to receive call identification.
2765 *
2766 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002767 *
2768 * \par Python:
2769 * The Python function returns (status, call_id) tuple:
2770 * \code
2771 status, call_id = py_pjsua.call_make_call(acc_id, dst_uri, options,
2772 user_data, msg_data)
2773 * \endcode
2774 * Note: the \a user_data in Python function is an integer, and the
2775 * \a msg_data can be set to None if not required.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002776 */
2777PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
2778 const pj_str_t *dst_uri,
2779 unsigned options,
2780 void *user_data,
2781 const pjsua_msg_data *msg_data,
2782 pjsua_call_id *p_call_id);
2783
2784
2785/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002786 * Check if the specified call has active INVITE session and the INVITE
2787 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002788 *
2789 * @param call_id Call identification.
2790 *
2791 * @return Non-zero if call is active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002792 *
2793 * \par Python:
2794 * \code
2795 bool = py_pjsua.call_is_active(call_id)
2796 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002797 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002798PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002799
2800
2801/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002802 * Check if call has an active media session.
2803 *
2804 * @param call_id Call identification.
2805 *
2806 * @return Non-zero if yes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002807 *
2808 * \par Python:
2809 * \code
2810 bool = py_pjsua.call_has_media(call_id)
2811 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002812 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002813PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002814
2815
2816/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002817 * Get the conference port identification associated with the call.
2818 *
2819 * @param call_id Call identification.
2820 *
2821 * @return Conference port ID, or PJSUA_INVALID_ID when the
2822 * media has not been established or is not active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002823 *
2824 * \par Python:
2825 * \code
2826 slot = py_pjsua.call_get_conf_port(call_id)
2827 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002828 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002829PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
2830
2831/**
2832 * Obtain detail information about the specified call.
2833 *
2834 * @param call_id Call identification.
2835 * @param info Call info to be initialized.
2836 *
2837 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002838 *
2839 * \par Python:
2840 * \code
2841 call_info = py_pjsua.call_get_info(call_id)
2842 * \endcode
2843 * \a call_info return value will be set to None if call_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002844 */
2845PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002846 pjsua_call_info *info);
2847
2848
2849/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002850 * Attach application specific data to the call. Application can then
2851 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002852 *
2853 * @param call_id Call identification.
2854 * @param user_data Arbitrary data to be attached to the call.
2855 *
2856 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002857 *
2858 * \par Python:
2859 * \code
2860 status = py_pjsua.call_set_user_data(call_id, user_data)
2861 * \endcode
2862 * The \a user_data is an integer in the Python function.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002863 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002864PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
2865 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002866
2867
2868/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002869 * Get user data attached to the call, which has been previously set with
2870 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002871 *
2872 * @param call_id Call identification.
2873 *
2874 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002875 *
2876 * \par Python:
2877 * \code
2878 user_data = py_pjsua.call_get_user_data(call_id)
2879 * \endcode
2880 * The \a user_data is an integer.
Benny Prijono268ca612006-02-07 12:34:11 +00002881 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002882PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00002883
2884
2885/**
Benny Prijono91a6a172007-10-31 08:59:29 +00002886 * Get the NAT type of remote's endpoint. This is a proprietary feature
2887 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
2888 * is set in #pjsua_config.
2889 *
2890 * This function can only be called after SDP has been received from remote,
2891 * which means for incoming call, this function can be called as soon as
2892 * call is received as long as incoming call contains SDP, and for outgoing
2893 * call, this function can be called only after SDP is received (normally in
2894 * 200/OK response to INVITE). As a general case, application should call
2895 * this function after or in \a on_call_media_state() callback.
2896 *
2897 * @param call_id Call identification.
2898 * @param p_type Pointer to store the NAT type. Application can then
2899 * retrieve the string description of the NAT type
2900 * by calling pj_stun_get_nat_name().
2901 *
2902 * @return PJ_SUCCESS on success.
2903 *
2904 * @see pjsua_get_nat_type(), nat_type_in_sdp
2905 */
2906PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
2907 pj_stun_nat_type *p_type);
2908
2909/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002910 * Send response to incoming INVITE request. Depending on the status
2911 * code specified as parameter, this function may send provisional
2912 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002913 *
2914 * @param call_id Incoming call identification.
2915 * @param code Status code, (100-699).
2916 * @param reason Optional reason phrase. If NULL, default text
2917 * will be used.
2918 * @param msg_data Optional list of headers etc to be added to outgoing
2919 * response message.
2920 *
2921 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002922 *
2923 * \par Python:
2924 * \code
2925 status = py_pjsua.call_answer(call_id, code, reason, msg_data)
2926 * \endcode
2927 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijonoa91a0032006-02-26 21:23:45 +00002928 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002929PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
2930 unsigned code,
2931 const pj_str_t *reason,
2932 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00002933
2934/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002935 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00002936 * call state. This function is different than answering the call with
2937 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
2938 * will hangup the call regardless of the state and role of the call,
2939 * while #pjsua_call_answer() only works with incoming calls on EARLY
2940 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002941 *
2942 * @param call_id Call identification.
2943 * @param code Optional status code to be sent when we're rejecting
2944 * incoming call. If the value is zero, "603/Decline"
2945 * will be sent.
2946 * @param reason Optional reason phrase to be sent when we're rejecting
2947 * incoming call. If NULL, default text will be used.
2948 * @param msg_data Optional list of headers etc to be added to outgoing
2949 * request/response message.
2950 *
2951 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002952 *
2953 * \par Python:
2954 * \code
2955 status = py_pjsua.call_hangup(call_id, code, reason, msg_data)
2956 * \endcode
2957 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002958 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002959PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
2960 unsigned code,
2961 const pj_str_t *reason,
2962 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002963
2964
2965/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002966 * Put the specified call on hold. This will send re-INVITE with the
2967 * appropriate SDP to inform remote that the call is being put on hold.
2968 * The final status of the request itself will be reported on the
2969 * \a on_call_media_state() callback, which inform the application that
2970 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002971 *
2972 * @param call_id Call identification.
2973 * @param msg_data Optional message components to be sent with
2974 * the request.
2975 *
2976 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002977 *
2978 * \par Python:
2979 * \code
2980 status = py_pjsua.call_set_hold(call_id, msg_data)
2981 * \endcode
2982 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002983 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002984PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
2985 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002986
2987
2988/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002989 * Send re-INVITE to release hold.
2990 * The final status of the request itself will be reported on the
2991 * \a on_call_media_state() callback, which inform the application that
2992 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002993 *
2994 * @param call_id Call identification.
2995 * @param unhold If this argument is non-zero and the call is locally
2996 * held, this will release the local hold.
2997 * @param msg_data Optional message components to be sent with
2998 * the request.
2999 *
3000 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003001 *
3002 * \par Python:
3003 * \code
3004 status = py_pjsua.call_reinvite(call_id, unhold, msg_data)
3005 * \endcode
3006 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003007 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003008PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
3009 pj_bool_t unhold,
3010 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003011
Benny Prijonoc08682e2007-10-04 06:17:58 +00003012/**
3013 * Send UPDATE request.
3014 *
3015 * @param call_id Call identification.
3016 * @param options Must be zero for now.
3017 * @param msg_data Optional message components to be sent with
3018 * the request.
3019 *
3020 * @return PJ_SUCCESS on success, or the appropriate error code.
3021 */
3022PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
3023 unsigned options,
3024 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003025
3026/**
Benny Prijono053f5222006-11-11 16:16:04 +00003027 * Initiate call transfer to the specified address. This function will send
3028 * REFER request to instruct remote call party to initiate a new INVITE
3029 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003030 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00003031 * If application is interested to monitor the successfulness and
3032 * the progress of the transfer request, it can implement
3033 * \a on_call_transfer_status() callback which will report the progress
3034 * of the call transfer request.
3035 *
Benny Prijono053f5222006-11-11 16:16:04 +00003036 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003037 * @param dest Address of new target to be contacted.
3038 * @param msg_data Optional message components to be sent with
3039 * the request.
3040 *
3041 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003042 *
3043 * \par Python:
3044 * \code
3045 status = py_pjsua.call_xfer(call_id, dest, msg_data)
3046 * \endcode
3047 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003048 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003049PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
3050 const pj_str_t *dest,
3051 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003052
3053/**
Benny Prijono053f5222006-11-11 16:16:04 +00003054 * Flag to indicate that "Require: replaces" should not be put in the
3055 * outgoing INVITE request caused by REFER request created by
3056 * #pjsua_call_xfer_replaces().
3057 */
3058#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
3059
3060/**
3061 * Initiate attended call transfer. This function will send REFER request
3062 * to instruct remote call party to initiate new INVITE session to the URL
3063 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
3064 * the call with us with the new call from the REFER recipient.
3065 *
3066 * @param call_id The call id to be transfered.
3067 * @param dest_call_id The call id to be replaced.
3068 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
3069 * to suppress the inclusion of "Require: replaces" in
3070 * the outgoing INVITE request created by the REFER
3071 * request.
3072 * @param msg_data Optional message components to be sent with
3073 * the request.
3074 *
3075 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003076 *
3077 * \par Python:
3078 * \code
3079 status = py_pjsua.call_xfer_replaces(call_id, dest_call_id, options, msg_data)
3080 * \endcode
3081 * Argument \a msg_data may be set to None if not required.
Benny Prijono053f5222006-11-11 16:16:04 +00003082 */
3083PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
3084 pjsua_call_id dest_call_id,
3085 unsigned options,
3086 const pjsua_msg_data *msg_data);
3087
3088/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003089 * Send DTMF digits to remote using RFC 2833 payload formats.
3090 *
3091 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003092 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003093 *
3094 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003095 *
3096 * \par Python:
3097 * \code
3098 status = py_pjsua.call_dial_dtmf(call_id, digits)
3099 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003100 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003101PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003102 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00003103
Benny Prijono26ff9062006-02-21 23:47:00 +00003104/**
Benny Prijonob0808372006-03-02 21:18:58 +00003105 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003106 *
3107 * @param call_id Call identification.
3108 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3109 * assumed.
3110 * @param content The message content.
3111 * @param msg_data Optional list of headers etc to be included in outgoing
3112 * request. The body descriptor in the msg_data is
3113 * ignored.
3114 * @param user_data Optional user data, which will be given back when
3115 * the IM callback is called.
3116 *
3117 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003118 *
3119 * \par Python:
3120 * \code
3121 status = py_pjsua.call_send_im(call_id, mime_type, content, msg_data, user_data)
3122 * \endcode
3123 * Note that the \a user_data argument is an integer in Python.
Benny Prijonob0808372006-03-02 21:18:58 +00003124 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003125PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
3126 const pj_str_t *mime_type,
3127 const pj_str_t *content,
3128 const pjsua_msg_data *msg_data,
3129 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003130
3131
3132/**
3133 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003134 *
3135 * @param call_id Call identification.
3136 * @param is_typing Non-zero to indicate to remote that local person is
3137 * currently typing an IM.
3138 * @param msg_data Optional list of headers etc to be included in outgoing
3139 * request.
3140 *
3141 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003142 *
3143 * \par Python:
3144 * \code
3145 status = py_pjsua.call_send_typing_ind(call_id, is_typing, msg_data)
3146 * \endcode
3147 * Argument \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003148 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003149PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
3150 pj_bool_t is_typing,
3151 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003152
3153/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00003154 * Send arbitrary request with the call. This is useful for example to send
3155 * INFO request. Note that application should not use this function to send
3156 * requests which would change the invite session's state, such as re-INVITE,
3157 * UPDATE, PRACK, and BYE.
3158 *
3159 * @param call_id Call identification.
3160 * @param method SIP method of the request.
3161 * @param msg_data Optional message body and/or list of headers to be
3162 * included in outgoing request.
3163 *
3164 * @return PJ_SUCCESS on success, or the appropriate error code.
3165 */
3166PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
3167 const pj_str_t *method,
3168 const pjsua_msg_data *msg_data);
3169
3170
3171/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003172 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
3173 * currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003174 *
3175 * \par Python:
3176 * \code
3177 py_pjsua.call_hangup_all()
3178 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003179 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00003180PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00003181
3182
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003183/**
3184 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003185 *
3186 * @param call_id Call identification.
3187 * @param with_media Non-zero to include media information too.
3188 * @param buffer Buffer where the statistics are to be written to.
3189 * @param maxlen Maximum length of buffer.
3190 * @param indent Spaces for left indentation.
3191 *
3192 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003193 *
3194 * \par Python:
3195 * \code
3196 string = py_pjsua.call_dump(call_id, with_media, max_len, indent)
3197 * \endcode
3198 * The \a max_len argument is the desired maximum length to be allocated.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003199 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003200PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
3201 pj_bool_t with_media,
3202 char *buffer,
3203 unsigned maxlen,
3204 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003205
Benny Prijono9fc735d2006-05-28 14:58:12 +00003206/**
Benny Prijono312aff92006-06-17 04:08:30 +00003207 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003208 */
Benny Prijono834aee32006-02-19 01:38:06 +00003209
3210
3211/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00003212 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00003213 */
3214
Benny Prijono312aff92006-06-17 04:08:30 +00003215
3216/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003217 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00003218 * @ingroup PJSUA_LIB
3219 * @brief Buddy management, buddy's presence, and instant messaging.
3220 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00003221 *
3222 * This section describes PJSUA-APIs related to buddies management,
3223 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00003224 */
3225
3226/**
3227 * Max buddies in buddy list.
3228 */
3229#ifndef PJSUA_MAX_BUDDIES
3230# define PJSUA_MAX_BUDDIES 256
3231#endif
3232
3233
3234/**
Benny Prijonoa17496a2007-10-31 10:20:31 +00003235 * This specifies how long the library should retry resending SUBSCRIBE
3236 * if the previous SUBSCRIBE failed.
3237 *
3238 * Default: 300 seconds
3239 */
3240#ifndef PJSUA_PRES_TIMER
3241# define PJSUA_PRES_TIMER 300
3242#endif
3243
3244
3245/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003246 * This structure describes buddy configuration when adding a buddy to
3247 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
3248 * the structure with #pjsua_buddy_config_default() to initialize this
3249 * structure with default configuration.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003250 *
3251 * \par Python:
3252 * In Python this structure is <tt>py_pjsua.Buddy_Config</tt>. However
3253 * it is recommended that application instantiates the buddy config
3254 * by calling:
3255 * \code
3256 buddy_cfg = py_pjsua.buddy_config_default()
3257 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003258 */
3259typedef struct pjsua_buddy_config
3260{
3261 /**
3262 * Buddy URL or name address.
3263 */
3264 pj_str_t uri;
3265
3266 /**
3267 * Specify whether presence subscription should start immediately.
3268 */
3269 pj_bool_t subscribe;
3270
3271} pjsua_buddy_config;
3272
3273
3274/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003275 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003276 */
3277typedef enum pjsua_buddy_status
3278{
3279 /**
3280 * Online status is unknown (possibly because no presence subscription
3281 * has been established).
3282 */
3283 PJSUA_BUDDY_STATUS_UNKNOWN,
3284
3285 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003286 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003287 */
3288 PJSUA_BUDDY_STATUS_ONLINE,
3289
3290 /**
3291 * Buddy is offline.
3292 */
3293 PJSUA_BUDDY_STATUS_OFFLINE,
3294
3295} pjsua_buddy_status;
3296
3297
3298
3299/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003300 * This structure describes buddy info, which can be retrieved by calling
3301 * #pjsua_buddy_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003302 *
3303 * \par Python:
3304 * This structure in Python is <tt>py_pjsua.Buddy_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003305 */
3306typedef struct pjsua_buddy_info
3307{
3308 /**
3309 * The buddy ID.
3310 */
3311 pjsua_buddy_id id;
3312
3313 /**
3314 * The full URI of the buddy, as specified in the configuration.
3315 */
3316 pj_str_t uri;
3317
3318 /**
3319 * Buddy's Contact, only available when presence subscription has
3320 * been established to the buddy.
3321 */
3322 pj_str_t contact;
3323
3324 /**
3325 * Buddy's online status.
3326 */
3327 pjsua_buddy_status status;
3328
3329 /**
3330 * Text to describe buddy's online status.
3331 */
3332 pj_str_t status_text;
3333
3334 /**
3335 * Flag to indicate that we should monitor the presence information for
3336 * this buddy (normally yes, unless explicitly disabled).
3337 */
3338 pj_bool_t monitor_pres;
3339
3340 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003341 * Extended RPID information about the person.
3342 */
3343 pjrpid_element rpid;
3344
3345 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003346 * Internal buffer.
3347 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003348 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003349
3350} pjsua_buddy_info;
3351
3352
Benny Prijono834aee32006-02-19 01:38:06 +00003353/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003354 * Set default values to the buddy config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003355 *
3356 * \par Python:
3357 * \code
3358 buddy_cfg = py_pjsua.buddy_config_default()
3359 * \endcode
Benny Prijonob5388cf2007-01-04 22:45:08 +00003360 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003361PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003362
3363
3364/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003365 * Get total number of buddies.
3366 *
3367 * @return Number of buddies.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003368 *
3369 * \par Python:
3370 * \code
3371 buddy_count = py_pjsua.get_buddy_count()
3372 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003373 */
3374PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3375
3376
3377/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003378 * Check if buddy ID is valid.
3379 *
3380 * @param buddy_id Buddy ID to check.
3381 *
3382 * @return Non-zero if buddy ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003383 *
3384 * \par Python:
3385 * \code
3386 is_valid = py_pjsua.buddy_is_valid(buddy_id)
3387 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003388 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003389PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3390
3391
3392/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003393 * Enumerate all buddy IDs in the buddy list. Application then can use
3394 * #pjsua_buddy_get_info() to get the detail information for each buddy
3395 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003396 *
3397 * @param ids Array of ids to be initialized.
3398 * @param count On input, specifies max elements in the array.
3399 * On return, it contains actual number of elements
3400 * that have been initialized.
3401 *
3402 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003403 *
3404 * \par Python:
3405 * The Python function takes no argument and returns list of buddy IDs:
3406 * \code
3407 [buddy_ids] = py_pjsua.enum_buddies()
3408 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003409 */
3410PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3411 unsigned *count);
3412
3413/**
3414 * Get detailed buddy info.
3415 *
3416 * @param buddy_id The buddy identification.
3417 * @param info Pointer to receive information about buddy.
3418 *
3419 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003420 *
3421 * \par Python:
3422 * \code
3423 buddy_info = py_pjsua.buddy_get_info(buddy_id)
3424 * \endcode
3425 * The function returns None if buddy_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003426 */
3427PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003428 pjsua_buddy_info *info);
3429
3430/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003431 * Add new buddy to the buddy list. If presence subscription is enabled
3432 * for this buddy, this function will also start the presence subscription
3433 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003434 *
Benny Prijonoa7b376b2008-01-25 16:06:33 +00003435 * @param buddy_cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003436 * @param p_buddy_id Pointer to receive buddy ID.
3437 *
3438 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003439 *
3440 * \par Python:
3441 * The function returns (status, buddy_id) tuple:
3442 * \code
3443 status, buddy_id = py_pjsua.buddy_add(buddy_cfg)
3444 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003445 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003446PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003447 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003448
3449
3450/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003451 * Delete the specified buddy from the buddy list. Any presence subscription
3452 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003453 *
3454 * @param buddy_id Buddy identification.
3455 *
3456 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003457 *
3458 * \par Python:
3459 * \code
3460 status = py_pjsua.buddy_del(buddy_id)
3461 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +00003462 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003463PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003464
3465
3466/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003467 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3468 * subscribed, application will be informed about buddy's presence status
3469 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003470 *
3471 * @param buddy_id Buddy identification.
3472 * @param subscribe Specify non-zero to activate presence subscription to
3473 * the specified buddy.
3474 *
3475 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003476 *
3477 * \par Python:
3478 * \code
3479 status = py_pjsua.buddy_subscribe_pres(buddy_id, subscribe)
3480 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003481 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003482PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3483 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003484
3485
3486/**
Benny Prijono10861432007-10-31 10:54:53 +00003487 * Update the presence information for the buddy. Although the library
3488 * periodically refreshes the presence subscription for all buddies, some
3489 * application may want to refresh the buddy's presence subscription
3490 * immediately, and in this case it can use this function to accomplish
3491 * this.
3492 *
3493 * Note that the buddy's presence subscription will only be initiated
3494 * if presence monitoring is enabled for the buddy. See
3495 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
3496 * for the buddy is already active, this function will not do anything.
3497 *
3498 * Once the presence subscription is activated successfully for the buddy,
3499 * application will be notified about the buddy's presence status in the
3500 * on_buddy_state() callback.
3501 *
3502 * @param buddy_id Buddy identification.
3503 *
3504 * @return PJ_SUCCESS on success, or the appropriate error code.
3505 */
3506PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
3507
3508
3509/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003510 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003511 *
3512 * @param verbose Yes or no.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003513 *
3514 * \par Python:
3515 * \code
3516 py_pjsua.pres_dump()
3517 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003518 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003519PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003520
3521
Benny Prijonob0808372006-03-02 21:18:58 +00003522/**
3523 * The MESSAGE method (defined in pjsua_im.c)
3524 */
3525extern const pjsip_method pjsip_message_method;
3526
3527
Benny Prijonob0808372006-03-02 21:18:58 +00003528
3529/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003530 * Send instant messaging outside dialog, using the specified account for
3531 * route set and authentication.
3532 *
3533 * @param acc_id Account ID to be used to send the request.
3534 * @param to Remote URI.
3535 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3536 * assumed.
3537 * @param content The message content.
3538 * @param msg_data Optional list of headers etc to be included in outgoing
3539 * request. The body descriptor in the msg_data is
3540 * ignored.
3541 * @param user_data Optional user data, which will be given back when
3542 * the IM callback is called.
3543 *
3544 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003545 *
3546 * \par Python:
3547 * \code
3548 status = py_pjsua.im_send(acc_id, to, mime_type, content, msg_data, user_data)
3549 * \endcode
3550 * Arguments \a mime_type and \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003551 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003552PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3553 const pj_str_t *to,
3554 const pj_str_t *mime_type,
3555 const pj_str_t *content,
3556 const pjsua_msg_data *msg_data,
3557 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003558
3559
3560/**
3561 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003562 *
3563 * @param acc_id Account ID to be used to send the request.
3564 * @param to Remote URI.
3565 * @param is_typing If non-zero, it tells remote person that local person
3566 * is currently composing an IM.
3567 * @param msg_data Optional list of headers etc to be added to outgoing
3568 * request.
3569 *
3570 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003571 *
3572 * \par Python:
3573 * \code
3574 status = py_pjsua.im_typing(acc_id, to, is_typing, msg_data)
3575 * \endcode
3576 * Argument \a msg_data may be set to None if not requried.
Benny Prijonob0808372006-03-02 21:18:58 +00003577 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003578PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3579 const pj_str_t *to,
3580 pj_bool_t is_typing,
3581 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003582
3583
Benny Prijonof3195072006-02-14 21:15:30 +00003584
Benny Prijono312aff92006-06-17 04:08:30 +00003585/**
3586 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003587 */
3588
Benny Prijono312aff92006-06-17 04:08:30 +00003589
3590/*****************************************************************************
3591 * MEDIA API
3592 */
3593
3594
3595/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003596 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003597 * @ingroup PJSUA_LIB
3598 * @brief Media manipulation.
3599 * @{
3600 *
3601 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003602 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3603 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003604 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003605 * the interconnection between these terminations freely.
3606 *
3607 * The conference bridge provides powerful switching and mixing functionality
3608 * for application. With the conference bridge, each conference slot (e.g.
3609 * a call) can transmit to multiple destinations, and one destination can
3610 * receive from multiple sources. If more than one media terminations are
3611 * terminated in the same slot, the conference bridge will mix the signal
3612 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00003613 *
3614 * Application connects one media termination/slot to another by calling
3615 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003616 * media flow from the source termination to the sink termination. To
3617 * establish bidirectional media flow, application wound need to make another
3618 * call to #pjsua_conf_connect(), this time inverting the source and
3619 * destination slots in the parameter.
3620 *
3621 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00003622 * the following steps:
3623 *
3624 \code
3625
3626 pj_status_t stream_to_call( pjsua_call_id call_id )
3627 {
3628 pjsua_player_id player_id;
3629
3630 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
3631 if (status != PJ_SUCCESS)
3632 return status;
3633
3634 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
3635 pjsua_call_get_conf_port() );
3636 }
3637 \endcode
3638 *
3639 *
3640 * Other features of PJSUA media:
3641 * - efficient N to M interconnections between media terminations.
3642 * - media termination can be connected to itself to create loopback
3643 * media.
3644 * - the media termination may have different clock rates, and resampling
3645 * will be done automatically by conference bridge.
3646 * - media terminations may also have different frame time; the
3647 * conference bridge will perform the necessary bufferring to adjust
3648 * the difference between terminations.
3649 * - interconnections are removed automatically when media termination
3650 * is removed from the bridge.
3651 * - sound device may be changed even when there are active media
3652 * interconnections.
3653 * - correctly report call's media quality (in #pjsua_call_dump()) from
3654 * RTCP packet exchange.
3655 */
3656
3657/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003658 * Max ports in the conference bridge. This setting is the default value
3659 * for pjsua_media_config.max_media_ports.
Benny Prijono312aff92006-06-17 04:08:30 +00003660 */
3661#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00003662# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00003663#endif
3664
Benny Prijonob5388cf2007-01-04 22:45:08 +00003665/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003666 * The default clock rate to be used by the conference bridge. This setting
3667 * is the default value for pjsua_media_config.clock_rate.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003668 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003669#ifndef PJSUA_DEFAULT_CLOCK_RATE
3670# define PJSUA_DEFAULT_CLOCK_RATE 16000
3671#endif
3672
Benny Prijonob5388cf2007-01-04 22:45:08 +00003673/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003674 * Default frame length in the conference bridge. This setting
3675 * is the default value for pjsua_media_config.audio_frame_ptime.
3676 */
3677#ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
3678# define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 10
3679#endif
3680
3681
3682/**
3683 * Default codec quality settings. This setting is the default value
3684 * for pjsua_media_config.quality.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003685 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003686#ifndef PJSUA_DEFAULT_CODEC_QUALITY
3687# define PJSUA_DEFAULT_CODEC_QUALITY 5
3688#endif
3689
Benny Prijonob5388cf2007-01-04 22:45:08 +00003690/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003691 * Default iLBC mode. This setting is the default value for
3692 * pjsua_media_config.ilbc_mode.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003693 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003694#ifndef PJSUA_DEFAULT_ILBC_MODE
Benny Prijono37c710b2008-01-10 12:09:26 +00003695# define PJSUA_DEFAULT_ILBC_MODE 30
Benny Prijono12a669c2006-11-23 07:32:13 +00003696#endif
3697
Benny Prijonob5388cf2007-01-04 22:45:08 +00003698/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003699 * The default echo canceller tail length. This setting
3700 * is the default value for pjsua_media_config.ec_tail_len.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003701 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003702#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijono427439c2007-10-21 09:41:24 +00003703# define PJSUA_DEFAULT_EC_TAIL_LEN 200
Benny Prijono12a669c2006-11-23 07:32:13 +00003704#endif
Benny Prijono312aff92006-06-17 04:08:30 +00003705
3706
3707/**
Benny Prijonocba59d92007-02-16 09:22:56 +00003708 * The maximum file player.
3709 */
3710#ifndef PJSUA_MAX_PLAYERS
3711# define PJSUA_MAX_PLAYERS 32
3712#endif
3713
3714
3715/**
3716 * The maximum file player.
3717 */
3718#ifndef PJSUA_MAX_RECORDERS
3719# define PJSUA_MAX_RECORDERS 32
3720#endif
3721
3722
3723/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003724 * This structure describes media configuration, which will be specified
3725 * when calling #pjsua_init(). Application MUST initialize this structure
3726 * by calling #pjsua_media_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003727 *
3728 * \par Python:
3729 * This data type in Python is <tt>py_pjsua.Media_Config</tt>. To create
3730 * an object of this type, it is recommended to call
3731 * <tt>py_pjsua.media_config_default()</tt> function instead:
3732 * \code
3733 media_cfg = py_pjsua.media_config_default()
3734 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003735 */
3736struct pjsua_media_config
3737{
3738 /**
3739 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003740 * If value is zero, default clock rate will be used
3741 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00003742 */
3743 unsigned clock_rate;
3744
3745 /**
Benny Prijonof3758ee2008-02-26 15:32:16 +00003746 * Clock rate to be applied when opening the sound device.
3747 * If value is zero, conference bridge clock rate will be used.
3748 */
3749 unsigned snd_clock_rate;
3750
3751 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003752 * Specify audio frame ptime. The value here will affect the
3753 * samples per frame of both the sound device and the conference
3754 * bridge. Specifying lower ptime will normally reduce the
3755 * latency.
3756 *
Benny Prijono37c710b2008-01-10 12:09:26 +00003757 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003758 */
3759 unsigned audio_frame_ptime;
3760
3761 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003762 * Specify maximum number of media ports to be created in the
3763 * conference bridge. Since all media terminate in the bridge
3764 * (calls, file player, file recorder, etc), the value must be
3765 * large enough to support all of them. However, the larger
3766 * the value, the more computations are performed.
Benny Prijono37c710b2008-01-10 12:09:26 +00003767 *
3768 * Default value: PJSUA_MAX_CONF_PORTS
Benny Prijono312aff92006-06-17 04:08:30 +00003769 */
3770 unsigned max_media_ports;
3771
3772 /**
3773 * Specify whether the media manager should manage its own
3774 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
3775 * and at least one worker thread will be created too. If no,
3776 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
3777 * and no worker thread is needed.
3778 *
3779 * Normally application would say yes here, unless it wants to
3780 * run everything from a single thread.
3781 */
3782 pj_bool_t has_ioqueue;
3783
3784 /**
3785 * Specify the number of worker threads to handle incoming RTP
3786 * packets. A value of one is recommended for most applications.
3787 */
3788 unsigned thread_cnt;
3789
Benny Prijono0498d902006-06-19 14:49:14 +00003790 /**
3791 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00003792 * 5-10: resampling use large filter,
3793 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00003794 * 1-2: resampling use linear.
3795 * The media quality also sets speex codec quality/complexity to the
3796 * number.
3797 *
Benny Prijono70972992006-08-05 11:13:58 +00003798 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00003799 */
3800 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00003801
3802 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003803 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00003804 *
3805 * Default: 0 (codec specific)
3806 */
3807 unsigned ptime;
3808
3809 /**
3810 * Disable VAD?
3811 *
3812 * Default: 0 (no (meaning VAD is enabled))
3813 */
3814 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00003815
3816 /**
3817 * iLBC mode (20 or 30).
3818 *
Benny Prijono37c710b2008-01-10 12:09:26 +00003819 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00003820 */
3821 unsigned ilbc_mode;
3822
3823 /**
3824 * Percentage of RTP packet to drop in TX direction
3825 * (to simulate packet lost).
3826 *
3827 * Default: 0
3828 */
3829 unsigned tx_drop_pct;
3830
3831 /**
3832 * Percentage of RTP packet to drop in RX direction
3833 * (to simulate packet lost).
3834 *
3835 * Default: 0
3836 */
3837 unsigned rx_drop_pct;
3838
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003839 /**
Benny Prijono5da50432006-08-07 10:24:52 +00003840 * Echo canceller options (see #pjmedia_echo_create())
3841 *
3842 * Default: 0.
3843 */
3844 unsigned ec_options;
3845
3846 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003847 * Echo canceller tail length, in miliseconds.
3848 *
Benny Prijono669643c2006-09-20 20:02:18 +00003849 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003850 */
3851 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003852
3853 /**
3854 * Jitter buffer initial prefetch delay in msec. The value must be
3855 * between jb_min_pre and jb_max_pre below.
3856 *
3857 * Default: -1 (to use default stream settings, currently 150 msec)
3858 */
3859 int jb_init;
3860
3861 /**
3862 * Jitter buffer minimum prefetch delay in msec.
3863 *
3864 * Default: -1 (to use default stream settings, currently 60 msec)
3865 */
3866 int jb_min_pre;
3867
3868 /**
3869 * Jitter buffer maximum prefetch delay in msec.
3870 *
3871 * Default: -1 (to use default stream settings, currently 240 msec)
3872 */
3873 int jb_max_pre;
3874
3875 /**
3876 * Set maximum delay that can be accomodated by the jitter buffer msec.
3877 *
3878 * Default: -1 (to use default stream settings, currently 360 msec)
3879 */
3880 int jb_max;
3881
Benny Prijonoc97608e2007-03-23 16:34:20 +00003882 /**
3883 * Enable ICE
3884 */
3885 pj_bool_t enable_ice;
3886
3887 /**
3888 * Enable ICE media relay.
3889 */
3890 pj_bool_t enable_relay;
Benny Prijono312aff92006-06-17 04:08:30 +00003891};
3892
3893
3894/**
3895 * Use this function to initialize media config.
3896 *
3897 * @param cfg The media config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003898 *
3899 * \par Python:
3900 * \code
3901 media_cfg = py_pjsua.media_config_default()
3902 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003903 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003904PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00003905
3906
3907/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003908 * This structure describes codec information, which can be retrieved by
3909 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00003910 */
3911typedef struct pjsua_codec_info
3912{
3913 /**
3914 * Codec unique identification.
3915 */
3916 pj_str_t codec_id;
3917
3918 /**
3919 * Codec priority (integer 0-255).
3920 */
3921 pj_uint8_t priority;
3922
3923 /**
3924 * Internal buffer.
3925 */
3926 char buf_[32];
3927
3928} pjsua_codec_info;
3929
3930
3931/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003932 * This structure descibes information about a particular media port that
3933 * has been registered into the conference bridge. Application can query
3934 * this info by calling #pjsua_conf_get_port_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003935 *
3936 * \par Python:
3937 * In Python, this type is <tt>py_pjsua.Conf_Port_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003938 */
3939typedef struct pjsua_conf_port_info
3940{
3941 /** Conference port number. */
3942 pjsua_conf_port_id slot_id;
3943
3944 /** Port name. */
3945 pj_str_t name;
3946
3947 /** Clock rate. */
3948 unsigned clock_rate;
3949
3950 /** Number of channels. */
3951 unsigned channel_count;
3952
3953 /** Samples per frame */
3954 unsigned samples_per_frame;
3955
3956 /** Bits per sample */
3957 unsigned bits_per_sample;
3958
3959 /** Number of listeners in the array. */
3960 unsigned listener_cnt;
3961
3962 /** Array of listeners (in other words, ports where this port is
3963 * transmitting to.
3964 */
3965 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
3966
3967} pjsua_conf_port_info;
3968
3969
3970/**
3971 * This structure holds information about custom media transport to
3972 * be registered to pjsua.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003973 *
3974 * \par Python:
3975 * Not applicable.
Benny Prijono312aff92006-06-17 04:08:30 +00003976 */
3977typedef struct pjsua_media_transport
3978{
3979 /**
3980 * Media socket information containing the address information
3981 * of the RTP and RTCP socket.
3982 */
3983 pjmedia_sock_info skinfo;
3984
3985 /**
3986 * The media transport instance.
3987 */
3988 pjmedia_transport *transport;
3989
3990} pjsua_media_transport;
3991
3992
3993
3994
Benny Prijono9fc735d2006-05-28 14:58:12 +00003995/**
3996 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003997 *
3998 * @return Maximum number of ports in the conference bridge.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003999 *
4000 * \par Python:
4001 * \code
4002 port_count = py_pjsua.conf_get_max_ports()
4003 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004004 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004005PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004006
4007
4008/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004009 * Get current number of active ports in the bridge.
4010 *
4011 * @return The number.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004012 *
4013 * \par Python:
4014 * \code
4015 count = py_pjsua.conf_get_active_ports()
4016 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004017 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004018PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
4019
4020
4021/**
4022 * Enumerate all conference ports.
4023 *
4024 * @param id Array of conference port ID to be initialized.
4025 * @param count On input, specifies max elements in the array.
4026 * On return, it contains actual number of elements
4027 * that have been initialized.
4028 *
4029 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004030 *
4031 * \par Python:
4032 * The Python functions returns list of conference port Ids:
4033 * \code
4034 [port_ids] = py_pjsua.enum_conf_ports()
4035 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004036 */
4037PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
4038 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004039
4040
4041/**
4042 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004043 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004044 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004045 * @param info Pointer to store the port info.
4046 *
4047 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004048 *
4049 * \par Python:
4050 * \code
4051 port_info = py_pjsua.conf_get_port_info(port_id)
4052 * \endcode
4053 * The function will return None if \a port_id is not valid.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004054 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004055PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00004056 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004057
4058
4059/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00004060 * Add arbitrary media port to PJSUA's conference bridge. Application
4061 * can use this function to add the media port that it creates. For
4062 * media ports that are created by PJSUA-LIB (such as calls, file player,
4063 * or file recorder), PJSUA-LIB will automatically add the port to
4064 * the bridge.
4065 *
4066 * @param pool Pool to use.
4067 * @param port Media port to be added to the bridge.
4068 * @param p_id Optional pointer to receive the conference
4069 * slot id.
4070 *
4071 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004072 *
4073 * \par Python:
4074 * Not applicable (for now)
Benny Prijonoe909eac2006-07-27 22:04:56 +00004075 */
4076PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
4077 pjmedia_port *port,
4078 pjsua_conf_port_id *p_id);
4079
4080
4081/**
4082 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00004083 * call this function if it registered the port manually with previous call
4084 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00004085 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004086 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00004087 *
4088 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004089 *
4090 * \par Python:
4091 * \code
4092 status = py_pjsua.conf_remove_port(port_id)
4093 * \endcode
Benny Prijonoe909eac2006-07-27 22:04:56 +00004094 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004095PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00004096
4097
4098/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004099 * Establish unidirectional media flow from souce to sink. One source
4100 * may transmit to multiple destinations/sink. And if multiple
4101 * sources are transmitting to the same sink, the media will be mixed
4102 * together. Source and sink may refer to the same ID, effectively
4103 * looping the media.
4104 *
4105 * If bidirectional media flow is desired, application needs to call
4106 * this function twice, with the second one having the arguments
4107 * reversed.
4108 *
4109 * @param source Port ID of the source media/transmitter.
4110 * @param sink Port ID of the destination media/received.
4111 *
4112 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004113 *
4114 * \par Python:
4115 * \code
4116 status = py_pjsua.conf_connect(source, sink)
4117 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004118 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004119PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
4120 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004121
4122
4123/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004124 * Disconnect media flow from the source to destination port.
4125 *
4126 * @param source Port ID of the source media/transmitter.
4127 * @param sink Port ID of the destination media/received.
4128 *
4129 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004130 *
4131 * \par Python:
4132 * \code
4133 status = py_pjsua.conf_disconnect(source, sink)
4134 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004135 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004136PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
4137 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004138
4139
Benny Prijono6dd967c2006-12-26 02:27:14 +00004140/**
4141 * Adjust the signal level to be transmitted from the bridge to the
4142 * specified port by making it louder or quieter.
4143 *
4144 * @param slot The conference bridge slot number.
4145 * @param level Signal level adjustment. Value 1.0 means no level
4146 * adjustment, while value 0 means to mute the port.
4147 *
4148 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004149 *
4150 * \par Python:
4151 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004152 */
4153PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
4154 float level);
4155
4156/**
4157 * Adjust the signal level to be received from the specified port (to
4158 * the bridge) by making it louder or quieter.
4159 *
4160 * @param slot The conference bridge slot number.
4161 * @param level Signal level adjustment. Value 1.0 means no level
4162 * adjustment, while value 0 means to mute the port.
4163 *
4164 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004165 *
4166 * \par Python:
4167 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004168 */
4169PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
4170 float level);
4171
4172/**
4173 * Get last signal level transmitted to or received from the specified port.
4174 * The signal level is an integer value in zero to 255, with zero indicates
4175 * no signal, and 255 indicates the loudest signal level.
4176 *
4177 * @param slot The conference bridge slot number.
4178 * @param tx_level Optional argument to receive the level of signal
4179 * transmitted to the specified port (i.e. the direction
4180 * is from the bridge to the port).
4181 * @param rx_level Optional argument to receive the level of signal
4182 * received from the port (i.e. the direction is from the
4183 * port to the bridge).
4184 *
4185 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004186 *
4187 * \par Python:
4188 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004189 */
4190PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
4191 unsigned *tx_level,
4192 unsigned *rx_level);
4193
Benny Prijono6dd967c2006-12-26 02:27:14 +00004194
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004195/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00004196 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004197 */
4198
Benny Prijono9fc735d2006-05-28 14:58:12 +00004199/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004200 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004201 * the conference bridge.
4202 *
4203 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00004204 * WAV files are supported, and the WAV file MUST be
4205 * formatted as 16bit PCM mono/single channel (any
4206 * clock rate is supported).
Benny Prijono58add7c2008-01-18 13:24:07 +00004207 * @param options Optional option flag. Application may specify
4208 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004209 * @param p_id Pointer to receive player ID.
4210 *
4211 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004212 *
4213 * \par Python:
4214 * The function returns (status, id) tuple:
4215 * \code
4216 status, id = py_pjsua.player_create(filename, options)
4217 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004218 */
4219PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004220 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004221 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004222
4223
4224/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004225 * Create a file playlist media port, and automatically add the port
4226 * to the conference bridge.
4227 *
4228 * @param file_names Array of file names to be added to the play list.
4229 * Note that the files must have the same clock rate,
4230 * number of channels, and number of bits per sample.
4231 * @param file_count Number of files in the array.
4232 * @param label Optional label to be set for the media port.
4233 * @param options Optional option flag. Application may specify
4234 * PJMEDIA_FILE_NO_LOOP to prevent looping.
4235 * @param p_id Optional pointer to receive player ID.
4236 *
4237 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004238 *
4239 * \par Python:
4240 * Not implemented yet.
Benny Prijonoa66c3312007-01-21 23:12:40 +00004241 */
4242PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
4243 unsigned file_count,
4244 const pj_str_t *label,
4245 unsigned options,
4246 pjsua_player_id *p_id);
4247
4248/**
4249 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004250 *
4251 * @param id The file player ID.
4252 *
4253 * @return Conference port ID associated with this player.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004254 *
4255 * \par Python:
4256 * \code
4257 port_id = py_pjsua.player_get_conf_port(id)
4258 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004259 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004260PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004261
4262
4263/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004264 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00004265 *
4266 * @param id The player ID.
4267 * @param p_port The media port associated with the player.
4268 *
4269 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004270 *
4271 * \par Python:
4272 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004273 */
Benny Prijono58add7c2008-01-18 13:24:07 +00004274PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
Benny Prijono469b1522006-12-26 03:05:17 +00004275 pjmedia_port **p_port);
4276
4277/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004278 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004279 *
4280 * @param id The file player ID.
4281 * @param samples The playback position, in samples. Application can
4282 * specify zero to re-start the playback.
4283 *
4284 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004285 *
4286 * \par Python:
4287 * \code
4288 status = py_pjsua.player_set_pos(id, samples)
4289 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004290 */
4291PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
4292 pj_uint32_t samples);
4293
4294
4295/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004296 * Close the file of playlist, remove the player from the bridge, and free
4297 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004298 *
4299 * @param id The file player ID.
4300 *
4301 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004302 *
4303 * \par Python:
4304 * \code
4305 status = py_pjsua.player_destroy(id)
4306 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004307 */
4308PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
4309
4310
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004311/*****************************************************************************
4312 * File recorder.
4313 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00004314
4315/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004316 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004317 * the conference bridge. The recorder currently supports recording WAV file.
4318 * The type of the recorder to use is determined by the extension of the file
4319 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004320 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00004321 * @param filename Output file name. The function will determine the
4322 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004323 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00004324 * @param enc_type Optionally specify the type of encoder to be used to
4325 * compress the media, if the file can support different
4326 * encodings. This value must be zero for now.
4327 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004328 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00004329 * For .WAV recorder, this value must be NULL.
4330 * @param max_size Maximum file size. Specify zero or -1 to remove size
4331 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004332 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004333 * @param p_id Pointer to receive the recorder instance.
4334 *
4335 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004336 *
4337 * \par Python:
4338 * \code
4339 status, id = py_pjsua.recorder_create(filename, enc_type, enc_param, max_size, options)
4340 * \endcode
4341 * The \a enc_param is a string in Python.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004342 */
4343PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004344 unsigned enc_type,
4345 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004346 pj_ssize_t max_size,
4347 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004348 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004349
4350
4351/**
4352 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004353 *
4354 * @param id The recorder ID.
4355 *
4356 * @return Conference port ID associated with this recorder.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004357 *
4358 * \par Python:
4359 * \code
4360 port_id = py_pjsua.recorder_get_conf_port(id)
4361 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004362 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004363PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004364
4365
4366/**
Benny Prijono469b1522006-12-26 03:05:17 +00004367 * Get the media port for the recorder.
4368 *
4369 * @param id The recorder ID.
4370 * @param p_port The media port associated with the recorder.
4371 *
4372 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004373 *
4374 * \par Python:
4375 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004376 */
4377PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4378 pjmedia_port **p_port);
4379
4380
4381/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004382 * Destroy recorder (this will complete recording).
4383 *
4384 * @param id The recorder ID.
4385 *
4386 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004387 *
4388 * \par Python:
4389 * \code
4390 status = py_pjsua.recorder_destroy(id)
4391 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004392 */
4393PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4394
4395
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004396/*****************************************************************************
4397 * Sound devices.
4398 */
4399
Benny Prijono9fc735d2006-05-28 14:58:12 +00004400/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004401 * Enum all sound devices installed in the system.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004402 *
4403 * @param info Array of info to be initialized.
4404 * @param count On input, specifies max elements in the array.
4405 * On return, it contains actual number of elements
4406 * that have been initialized.
4407 *
4408 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004409 *
4410 *
4411 * \par Python:
4412 * The function returns list of sound device info:
4413 * \code
4414 [dev_infos] = py_pjsua.enum_snd_devs()
4415 * \endcode
4416 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00004417 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004418PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4419 unsigned *count);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004420
4421
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004422
4423/**
4424 * Get currently active sound devices. If sound devices has not been created
4425 * (for example when pjsua_start() is not called), it is possible that
4426 * the function returns PJ_SUCCESS with -1 as device IDs.
4427 *
4428 * @param capture_dev On return it will be filled with device ID of the
4429 * capture device.
4430 * @param playback_dev On return it will be filled with device ID of the
4431 * device ID of the playback device.
4432 *
4433 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004434 *
4435 * \par Python:
Benny Prijonoebdf8772007-02-01 19:25:50 +00004436 * The function takes no argument and return an (integer,integer) tuple:
Benny Prijonoe6ead542007-01-31 20:53:31 +00004437 * \code
4438 capture_dev, playback_dev = py_pjsua.get_snd_dev()
4439 * \endcode
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004440 */
4441PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4442 int *playback_dev);
4443
4444
Benny Prijono9fc735d2006-05-28 14:58:12 +00004445/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004446 * Select or change sound device. Application may call this function at
4447 * any time to replace current sound device.
4448 *
4449 * @param capture_dev Device ID of the capture device.
4450 * @param playback_dev Device ID of the playback device.
4451 *
4452 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004453 *
4454 * \par Python:
4455 * \code
4456 status = py_pjsua.set_snd_dev(capture_dev, playback_dev)
4457 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004458 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004459PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4460 int playback_dev);
4461
4462
4463/**
4464 * Set pjsua to use null sound device. The null sound device only provides
4465 * the timing needed by the conference bridge, and will not interract with
4466 * any hardware.
4467 *
4468 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004469 *
4470 * \par Python:
4471 * \code
4472 status = py_pjsua.set_null_snd_dev()
4473 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004474 */
4475PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4476
4477
Benny Prijonoe909eac2006-07-27 22:04:56 +00004478/**
4479 * Disconnect the main conference bridge from any sound devices, and let
4480 * application connect the bridge to it's own sound device/master port.
4481 *
4482 * @return The port interface of the conference bridge,
4483 * so that application can connect this to it's own
4484 * sound device or master port.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004485 *
4486 * \par Python:
4487 * Not applicable (for now).
Benny Prijonoe909eac2006-07-27 22:04:56 +00004488 */
4489PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4490
4491
Benny Prijonof20687a2006-08-04 18:27:19 +00004492/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004493 * Configure the echo canceller tail length of the sound port.
Benny Prijonof20687a2006-08-04 18:27:19 +00004494 *
4495 * @param tail_ms The tail length, in miliseconds. Set to zero to
4496 * disable AEC.
Benny Prijonoa7b376b2008-01-25 16:06:33 +00004497 * @param options Options to be passed to pjmedia_echo_create().
Benny Prijono5da50432006-08-07 10:24:52 +00004498 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004499 *
4500 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004501 *
4502 * \par Python:
4503 * \code
4504 status = py_pjsua.set_ec(tail_ms, options)
4505 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004506 */
Benny Prijono5da50432006-08-07 10:24:52 +00004507PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004508
4509
4510/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004511 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004512 *
4513 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4514 * If AEC is disabled, the value will be zero.
4515 *
4516 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004517 *
4518 * \par Python:
4519 * \code
4520 tail_ms = py_pjsua.get_ec_tail()
4521 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004522 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004523PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004524
4525
4526
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004527/*****************************************************************************
4528 * Codecs.
4529 */
4530
4531/**
4532 * Enum all supported codecs in the system.
4533 *
4534 * @param id Array of ID to be initialized.
4535 * @param count On input, specifies max elements in the array.
4536 * On return, it contains actual number of elements
4537 * that have been initialized.
4538 *
4539 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004540 *
4541 * \par Python:
4542 * This function takes no argument and returns list of codec infos:
4543 * \code
4544 [codec_info] = py_pjsua.enum_codecs()
4545 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004546 */
4547PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4548 unsigned *count );
4549
4550
4551/**
4552 * Change codec priority.
4553 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004554 * @param codec_id Codec ID, which is a string that uniquely identify
4555 * the codec (such as "speex/8000"). Please see pjsua
4556 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004557 * @param priority Codec priority, 0-255, where zero means to disable
4558 * the codec.
4559 *
4560 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004561 *
4562 * \par Python:
4563 * \code
4564 status = py_pjsua.codec_set_priority(codec_id, priority)
4565 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004566 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004567PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004568 pj_uint8_t priority );
4569
4570
4571/**
4572 * Get codec parameters.
4573 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004574 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004575 * @param param Structure to receive codec parameters.
4576 *
4577 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004578 *
4579 * \par Python:
4580 * The Python function is experimental:
4581 * \code
4582 codec_param = py_pjsua.codec_get_param(codec_id)
4583 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004584 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004585PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004586 pjmedia_codec_param *param );
4587
4588
4589/**
4590 * Set codec parameters.
4591 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004592 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004593 * @param param Codec parameter to set.
4594 *
4595 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004596 *
4597 * \par Python:
4598 * The Python function is experimental:
4599 * \code
4600 status = py_pjsua.codec_set_param(codec_id, param)
4601 * \endcode
4602
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004603 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004604PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004605 const pjmedia_codec_param *param);
4606
4607
4608
Benny Prijono9fc735d2006-05-28 14:58:12 +00004609
Benny Prijono312aff92006-06-17 04:08:30 +00004610/**
4611 * Create UDP media transports for all the calls. This function creates
4612 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00004613 *
Benny Prijono312aff92006-06-17 04:08:30 +00004614 * @param cfg Media transport configuration. The "port" field in the
4615 * configuration is used as the start port to bind the
4616 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004617 *
4618 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004619 *
4620 * \par Python:
4621 * Not implemented yet.
Benny Prijonof3195072006-02-14 21:15:30 +00004622 */
Benny Prijono312aff92006-06-17 04:08:30 +00004623PJ_DECL(pj_status_t)
4624pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00004625
Benny Prijonodc39fe82006-05-26 12:17:46 +00004626
4627/**
Benny Prijono312aff92006-06-17 04:08:30 +00004628 * Register custom media transports to be used by calls. There must
4629 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004630 *
Benny Prijono312aff92006-06-17 04:08:30 +00004631 * @param tp The media transport array.
4632 * @param count Number of elements in the array. This number MUST
4633 * match the number of maximum calls configured when
4634 * pjsua is created.
4635 * @param auto_delete Flag to indicate whether the transports should be
4636 * destroyed when pjsua is shutdown.
4637 *
4638 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004639 *
4640 * \par Python:
4641 * Note applicable.
Benny Prijonodc39fe82006-05-26 12:17:46 +00004642 */
Benny Prijono312aff92006-06-17 04:08:30 +00004643PJ_DECL(pj_status_t)
4644pjsua_media_transports_attach( pjsua_media_transport tp[],
4645 unsigned count,
4646 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00004647
4648
Benny Prijono312aff92006-06-17 04:08:30 +00004649/**
4650 * @}
4651 */
4652
Benny Prijonof3195072006-02-14 21:15:30 +00004653
Benny Prijono268ca612006-02-07 12:34:11 +00004654
Benny Prijono312aff92006-06-17 04:08:30 +00004655/**
4656 * @}
4657 */
4658
Benny Prijonoe6ead542007-01-31 20:53:31 +00004659PJ_END_DECL
4660
Benny Prijono312aff92006-06-17 04:08:30 +00004661
Benny Prijono268ca612006-02-07 12:34:11 +00004662#endif /* __PJSUA_H__ */