blob: 21d8ffb16a402851e264196bdc39a075de87b93c [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
Benny Prijonoc54dcb32008-04-08 23:33:15 +0000663 * by setting the code (default is 202). When this callback
Benny Prijono9fc735d2006-05-28 14:58:12 +0000664 * 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
Benny Prijonof76e1392008-06-06 14:51:48 +00001031 * address of the STUN server. Alternatively application may specify
1032 * \a stun_host instead.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001033 *
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 /**
Benny Prijono91a6a172007-10-31 08:59:29 +00001046 * Support for adding and parsing NAT type in the SDP to assist
1047 * troubleshooting. The valid values are:
1048 * - 0: no information will be added in SDP, and parsing is disabled.
Benny Prijono6ba8c542007-10-16 01:34:14 +00001049 * - 1: only the NAT type number is added.
1050 * - 2: add both NAT type number and name.
1051 *
Benny Prijono91a6a172007-10-31 08:59:29 +00001052 * Default: 1
Benny Prijono6ba8c542007-10-16 01:34:14 +00001053 */
1054 int nat_type_in_sdp;
1055
1056 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001057 * Specify whether support for reliable provisional response (100rel and
1058 * PRACK) should be required by default. Note that this setting can be
1059 * further customized in account configuration (#pjsua_acc_config).
1060 *
1061 * Default: PJ_FALSE
1062 */
1063 pj_bool_t require_100rel;
1064
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001065 /**
1066 * Number of credentials in the credential array.
1067 */
1068 unsigned cred_count;
1069
1070 /**
1071 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +00001072 * and can be used to authenticate against outbound proxies. If the
1073 * credential is specific to the account, then application should set
1074 * the credential in the pjsua_acc_config rather than the credential
1075 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001076 */
1077 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1078
1079 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001080 * Application callback to receive various event notifications from
1081 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001082 */
1083 pjsua_callback cb;
1084
Benny Prijono56315612006-07-18 14:39:40 +00001085 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001086 * Optional user agent string (default empty). If it's empty, no
1087 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +00001088 */
1089 pj_str_t user_agent;
1090
Benny Prijonod8179652008-01-23 20:39:07 +00001091#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
1092 /**
1093 * Specify default value of secure media transport usage.
1094 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
1095 * PJMEDIA_SRTP_MANDATORY.
1096 *
1097 * Note that this setting can be further customized in account
1098 * configuration (#pjsua_acc_config).
1099 *
1100 * Default: #PJSUA_DEFAULT_USE_SRTP
1101 */
1102 pjmedia_srtp_use use_srtp;
1103
1104 /**
1105 * Specify whether SRTP requires secure signaling to be used. This option
1106 * is only used when \a use_srtp option above is non-zero.
1107 *
1108 * Valid values are:
1109 * 0: SRTP does not require secure signaling
1110 * 1: SRTP requires secure transport such as TLS
1111 * 2: SRTP requires secure end-to-end transport (SIPS)
1112 *
1113 * Note that this setting can be further customized in account
1114 * configuration (#pjsua_acc_config).
1115 *
1116 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
1117 */
1118 int srtp_secure_signaling;
1119#endif
1120
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001121} pjsua_config;
1122
1123
1124/**
1125 * Use this function to initialize pjsua config.
1126 *
1127 * @param cfg pjsua config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001128 *
1129 * \par Python Sample Syntax:
1130 * The corresponding Python function creates an instance of the config and
1131 * initializes it to the default settings:
1132 * \code
1133 cfg = py_pjsua.config_default()
1134 * \endcode
1135
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001136 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001137PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001138
1139
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001140/** The implementation has been moved to sip_auth.h */
Benny Prijono7977f9f2007-10-10 11:37:56 +00001141#define pjsip_cred_dup pjsip_cred_info_dup
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001142
1143
1144/**
1145 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001146 *
1147 * @param pool The pool to get memory from.
1148 * @param dst Destination config.
1149 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001150 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001151PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1152 pjsua_config *dst,
1153 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001154
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001155
1156/**
1157 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001158 * outgoing SIP message. It can (optionally) be specified for example
1159 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1160 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1161 *
1162 * Application MUST call #pjsua_msg_data_init() to initialize this
1163 * structure before setting its values.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001164 *
1165 * \par Python Syntax
1166 * The data type in Python is <tt>py_pjsua.Msg_Data</tt>. Application is
1167 * recommended to instantiate the structure by using this construct:
1168 * \code
1169 msg_data = py_pjsua.msg_data_init()
1170 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001171 */
1172typedef struct pjsua_msg_data
1173{
1174 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001175 * Additional message headers as linked list. Application can add
1176 * headers to the list by creating the header, either from the heap/pool
1177 * or from temporary local variable, and add the header using
1178 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001179 *
1180 * \par Python:
1181 * This field is implemented as string linked-list in Python, where each
1182 * string describes the header. For example:
1183 \code
1184 msg_data = py_pjsua.Msg_Data()
1185 msg_data.hdr_list = ["Subject: Hello py_pjsua!", "Priority: very low"]
1186 \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001187 */
1188 pjsip_hdr hdr_list;
1189
1190 /**
1191 * MIME type of optional message body.
1192 */
1193 pj_str_t content_type;
1194
1195 /**
1196 * Optional message body.
1197 */
1198 pj_str_t msg_body;
1199
1200} pjsua_msg_data;
1201
1202
1203/**
1204 * Initialize message data.
1205 *
1206 * @param msg_data Message data to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001207 *
1208 * \par Python
1209 * The corresponding Python function creates and initializes the structure:
1210 * \code
1211 msg_data = py_pjsua.msg_data_init()
1212 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001213 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001214PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001215
Benny Prijono268ca612006-02-07 12:34:11 +00001216
1217/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001218 * Instantiate pjsua application. Application must call this function before
1219 * calling any other functions, to make sure that the underlying libraries
1220 * are properly initialized. Once this function has returned success,
1221 * application must call pjsua_destroy() before quitting.
1222 *
1223 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001224 *
1225 * \par Python:
1226 * \code
1227 status = py_pjsua.create()
1228 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001229 */
1230PJ_DECL(pj_status_t) pjsua_create(void);
1231
1232
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001233/** Forward declaration */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001234typedef struct pjsua_media_config pjsua_media_config;
1235
1236
Benny Prijonodc39fe82006-05-26 12:17:46 +00001237/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001238 * Initialize pjsua with the specified settings. All the settings are
1239 * optional, and the default values will be used when the config is not
1240 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001241 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001242 * Note that #pjsua_create() MUST be called before calling this function.
1243 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001244 * @param ua_cfg User agent configuration.
1245 * @param log_cfg Optional logging configuration.
1246 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001247 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001248 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001249 *
1250 * \par Python:
1251 * The function is similar in Python:
1252 * \code
1253 status = py_pjsua.init(ua_cfg, log_cfg, media_cfg)
1254 * \endcode
1255 * Note that \a ua_cfg, \a log_cfg, and \a media_cfg are optional, and
1256 * the Python script may pass None if it doesn't want to configure the
1257 * setting.
Benny Prijono268ca612006-02-07 12:34:11 +00001258 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001259PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1260 const pjsua_logging_config *log_cfg,
1261 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001262
1263
1264/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001265 * Application is recommended to call this function after all initialization
1266 * is done, so that the library can do additional checking set up
1267 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001268 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001269 * Application may call this function anytime after #pjsua_init().
1270 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001271 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001272 *
1273 * \par Python:
1274 * The function is similar in Python:
1275 * \code
1276 status = py_pjsua.start()
1277 * \endcode
Benny Prijonoccf95622006-02-07 18:48:01 +00001278 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001279PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001280
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001281
Benny Prijonoccf95622006-02-07 18:48:01 +00001282/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001283 * Destroy pjsua. Application is recommended to perform graceful shutdown
1284 * before calling this function (such as unregister the account from the SIP
1285 * server, terminate presense subscription, and hangup active calls), however,
1286 * this function will do all of these if it finds there are active sessions
1287 * that need to be terminated. This function will approximately block for
1288 * one second to wait for replies from remote.
1289 *
1290 * Application.may safely call this function more than once if it doesn't
1291 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001292 *
1293 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001294 *
1295 * \par Python:
1296 * The function is similar in Python:
1297 * \code
1298 status = py_pjsua.destroy()
1299 * \endcode
Benny Prijono268ca612006-02-07 12:34:11 +00001300 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001301PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001302
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001303
Benny Prijono9fc735d2006-05-28 14:58:12 +00001304/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001305 * Poll pjsua for events, and if necessary block the caller thread for
1306 * the specified maximum interval (in miliseconds).
1307 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001308 * Application doesn't normally need to call this function if it has
1309 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1310 * because polling then will be done by these worker threads instead.
1311 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001312 * @param msec_timeout Maximum time to wait, in miliseconds.
1313 *
1314 * @return The number of events that have been handled during the
1315 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001316 * can retrieve the error as (status = -return_value).
1317 *
1318 * \par Python:
1319 * The function is similar in Python:
1320 * \code
1321 n = py_pjsua.handle_events(msec_timeout)
1322 * \endcode
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001323 */
1324PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1325
1326
1327/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001328 * Create memory pool to be used by the application. Once application
1329 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001330 *
1331 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001332 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001333 * @param increment Increment size.
1334 *
1335 * @return The pool, or NULL when there's no memory.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001336 *
1337 * \par Python:
1338 * Python script may also create a pool object from the script:
1339 * \code
1340 pool = py_pjsua.pool_create(name, init_size, increment)
1341 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001342 */
1343PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1344 pj_size_t increment);
1345
1346
1347/**
1348 * Application can call this function at any time (after pjsua_create(), of
1349 * course) to change logging settings.
1350 *
1351 * @param c Logging configuration.
1352 *
1353 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001354 *
1355 * \par Python:
1356 * The function is similar in Python:
1357 * \code
1358 status = py_pjsua.reconfigure_logging(log_cfg)
1359 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001360 */
1361PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1362
1363
1364/**
1365 * Internal function to get SIP endpoint instance of pjsua, which is
1366 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001367 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001368 *
1369 * @return SIP endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001370 *
1371 * \par Python:
1372 * Application may retrieve the SIP endpoint instance:
1373 * \code
1374 endpt = py_pjsua.get_pjsip_endpt()
1375 * \endcode
1376 * However currently the object is just an opaque object and does not have
1377 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001378 */
1379PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1380
1381/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001382 * Internal function to get media endpoint instance.
1383 * Only valid after #pjsua_init() is called.
1384 *
1385 * @return Media endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001386 *
1387 * \par Python:
1388 * Application may retrieve the media endpoint instance:
1389 * \code
1390 endpt = py_pjsua.get_pjmedia_endpt()
1391 * \endcode
1392 * However currently the object is just an opaque object and does not have
1393 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001394 */
1395PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1396
Benny Prijono97b87172006-08-24 14:25:14 +00001397/**
1398 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001399 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001400 *
1401 * @return Pool factory currently used by PJSUA.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001402 *
1403 * \par Python:
1404 * Application may retrieve the pool factory instance:
1405 * \code
1406 endpt = py_pjsua.get_pool_factory()
1407 * \endcode
1408 * However currently the object is just an opaque object and does not have
1409 * any use for Python scripts.
Benny Prijono97b87172006-08-24 14:25:14 +00001410 */
1411PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1412
1413
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001414
1415/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001416 * Utilities.
1417 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001418 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001419
1420/**
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001421 * This is a utility function to detect NAT type in front of this
1422 * endpoint. Once invoked successfully, this function will complete
Benny Prijono6ba8c542007-10-16 01:34:14 +00001423 * asynchronously and report the result in \a on_nat_detect() callback
1424 * of pjsua_callback.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001425 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001426 * After NAT has been detected and the callback is called, application can
1427 * get the detected NAT type by calling #pjsua_get_nat_type(). Application
1428 * can also perform NAT detection by calling #pjsua_detect_nat_type()
1429 * again at later time.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001430 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001431 * Note that STUN must be enabled to run this function successfully.
1432 *
1433 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001434 */
Benny Prijono6ba8c542007-10-16 01:34:14 +00001435PJ_DECL(pj_status_t) pjsua_detect_nat_type(void);
1436
1437
1438/**
1439 * Get the NAT type as detected by #pjsua_detect_nat_type() function.
1440 * This function will only return useful NAT type after #pjsua_detect_nat_type()
1441 * has completed successfully and \a on_nat_detect() callback has been called.
1442 *
1443 * @param type NAT type.
1444 *
1445 * @return When detection is in progress, this function will
1446 * return PJ_EPENDING and \a type will be set to
1447 * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been
1448 * detected successfully, this function will return
1449 * PJ_SUCCESS and \a type will be set to the correct
1450 * value. Other return values indicate error and
1451 * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN.
Benny Prijono91a6a172007-10-31 08:59:29 +00001452 *
1453 * @see pjsua_call_get_rem_nat_type()
Benny Prijono6ba8c542007-10-16 01:34:14 +00001454 */
1455PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type);
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001456
1457
1458/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001459 * This is a utility function to verify that valid SIP url is given. If the
1460 * URL is valid, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001461 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001462 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001463 *
1464 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001465 *
1466 * \par Python:
1467 * \code
1468 status = py_pjsua.verify_sip_url(url)
1469 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001470 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001471PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001472
1473
1474/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001475 * This is a utility function to display error message for the specified
1476 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001477 *
1478 * @param sender The log sender field.
1479 * @param title Message title for the error.
1480 * @param status Status code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001481 *
1482 * \par Python:
1483 * \code
1484 py_pjsua.perror(sender, title, status)
1485 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001486 */
1487PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1488 pj_status_t status);
1489
1490
Benny Prijonoda9785b2007-04-02 20:43:06 +00001491/**
1492 * This is a utility function to dump the stack states to log, using
1493 * verbosity level 3.
1494 *
1495 * @param detail Will print detailed output (such as list of
1496 * SIP transactions) when non-zero.
1497 */
1498PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001499
1500/**
1501 * @}
1502 */
1503
1504
1505
1506/*****************************************************************************
1507 * TRANSPORT API
1508 */
1509
1510/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001511 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001512 * @ingroup PJSUA_LIB
1513 * @brief API for managing SIP transports
1514 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001515 *
1516 * PJSUA-API supports creating multiple transport instances, for example UDP,
1517 * TCP, and TLS transport. SIP transport must be created before adding an
1518 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001519 */
1520
1521
Benny Prijonoe6ead542007-01-31 20:53:31 +00001522/** SIP transport identification.
1523 */
Benny Prijono312aff92006-06-17 04:08:30 +00001524typedef int pjsua_transport_id;
1525
1526
1527/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001528 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001529 * and media. Before setting some values to this structure, application
1530 * MUST call #pjsua_transport_config_default() to initialize its
1531 * values with default settings.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001532 *
1533 * \par Python:
1534 * The data type in Python is <tt>py_pjsua.Transport_Config</tt>,
1535 * although application can just do this to create the instance:
1536 * \code
1537 transport_cfg = py_pjsua.transport_config_default()
1538 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001539 */
1540typedef struct pjsua_transport_config
1541{
1542 /**
1543 * UDP port number to bind locally. This setting MUST be specified
1544 * even when default port is desired. If the value is zero, the
1545 * transport will be bound to any available port, and application
1546 * can query the port by querying the transport info.
1547 */
1548 unsigned port;
1549
1550 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001551 * Optional address to advertise as the address of this transport.
1552 * Application can specify any address or hostname for this field,
1553 * for example it can point to one of the interface address in the
1554 * system, or it can point to the public address of a NAT router
1555 * where port mappings have been configured for the application.
1556 *
1557 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001558 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001559 pj_str_t public_addr;
1560
1561 /**
1562 * Optional address where the socket should be bound to. This option
1563 * SHOULD only be used to selectively bind the socket to particular
1564 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1565 * published address of a transport (the public_addr field should be
1566 * used for that purpose).
1567 *
1568 * Note that unlike public_addr field, the address (or hostname) here
1569 * MUST correspond to the actual interface address in the host, since
1570 * this address will be specified as bind() argument.
1571 */
1572 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001573
1574 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001575 * This specifies TLS settings for TLS transport. It is only be used
1576 * when this transport config is being used to create a SIP TLS
1577 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001578 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001579 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001580
Benny Prijono312aff92006-06-17 04:08:30 +00001581} pjsua_transport_config;
1582
1583
1584/**
1585 * Call this function to initialize UDP config with default values.
1586 *
1587 * @param cfg The UDP config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001588 *
1589 * \par Python:
1590 * The corresponding Python function is rather different:
1591 * \code
1592 transport_cfg = py_pjsua.transport_config_default()
1593 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001594 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001595PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001596
1597
1598/**
Benny Prijono312aff92006-06-17 04:08:30 +00001599 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001600 *
1601 * @param pool The pool.
1602 * @param dst The destination config.
1603 * @param src The source config.
1604 *
1605 * \par Python:
1606 * Not applicable. One should be able to just copy one variable instance
1607 * to another in Python.
Benny Prijono312aff92006-06-17 04:08:30 +00001608 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001609PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1610 pjsua_transport_config *dst,
1611 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001612
1613
1614/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001615 * This structure describes transport information returned by
1616 * #pjsua_transport_get_info() function.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001617 *
1618 * \par Python:
1619 * The corresponding data type in Python is <tt>py_pjsua.Transport_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001620 */
1621typedef struct pjsua_transport_info
1622{
1623 /**
1624 * PJSUA transport identification.
1625 */
1626 pjsua_transport_id id;
1627
1628 /**
1629 * Transport type.
1630 */
1631 pjsip_transport_type_e type;
1632
1633 /**
1634 * Transport type name.
1635 */
1636 pj_str_t type_name;
1637
1638 /**
1639 * Transport string info/description.
1640 */
1641 pj_str_t info;
1642
1643 /**
1644 * Transport flag (see ##pjsip_transport_flags_e).
1645 */
1646 unsigned flag;
1647
1648 /**
1649 * Local address length.
1650 */
1651 unsigned addr_len;
1652
1653 /**
1654 * Local/bound address.
1655 */
1656 pj_sockaddr local_addr;
1657
1658 /**
1659 * Published address (or transport address name).
1660 */
1661 pjsip_host_port local_name;
1662
1663 /**
1664 * Current number of objects currently referencing this transport.
1665 */
1666 unsigned usage_count;
1667
1668
1669} pjsua_transport_info;
1670
1671
1672/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001673 * Create and start a new SIP transport according to the specified
1674 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001675 *
1676 * @param type Transport type.
1677 * @param cfg Transport configuration.
1678 * @param p_id Optional pointer to receive transport ID.
1679 *
1680 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001681 *
1682 * \par Python:
1683 * The corresponding Python function returns (status,id) tuple:
1684 * \code
1685 status, transport_id = py_pjsua.transport_create(type, cfg)
1686 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001687 */
1688PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1689 const pjsua_transport_config *cfg,
1690 pjsua_transport_id *p_id);
1691
1692/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001693 * Register transport that has been created by application. This function
1694 * is useful if application wants to implement custom SIP transport and use
1695 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001696 *
1697 * @param tp Transport instance.
1698 * @param p_id Optional pointer to receive transport ID.
1699 *
1700 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001701 *
1702 * \par Python:
1703 * Not applicable (for now), because one cannot create a custom transport
1704 * from Python script.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001705 */
1706PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1707 pjsua_transport_id *p_id);
1708
1709
1710/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001711 * Enumerate all transports currently created in the system. This function
1712 * will return all transport IDs, and application may then call
1713 * #pjsua_transport_get_info() function to retrieve detailed information
1714 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001715 *
1716 * @param id Array to receive transport ids.
1717 * @param count In input, specifies the maximum number of elements.
1718 * On return, it contains the actual number of elements.
1719 *
1720 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001721 *
1722 * \par Python:
1723 * The function returns list of integers representing transport ids:
1724 * \code
1725 [int] = py_pjsua.enum_transports()
1726 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001727 */
1728PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1729 unsigned *count );
1730
1731
1732/**
1733 * Get information about transports.
1734 *
1735 * @param id Transport ID.
1736 * @param info Pointer to receive transport info.
1737 *
1738 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001739 *
1740 * \par Python:
1741 * \code
1742 transport_info = py_pjsua.transport_get_info(id)
1743 * \endcode
1744 * The Python function returns None on error.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001745 */
1746PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1747 pjsua_transport_info *info);
1748
1749
1750/**
1751 * Disable a transport or re-enable it. By default transport is always
1752 * enabled after it is created. Disabling a transport does not necessarily
1753 * close the socket, it will only discard incoming messages and prevent
1754 * the transport from being used to send outgoing messages.
1755 *
1756 * @param id Transport ID.
1757 * @param enabled Non-zero to enable, zero to disable.
1758 *
1759 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001760 *
1761 * \par Python:
1762 * \code
1763 status = py_pjsua.transport_set_enable(id, enabled)
1764 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001765 */
1766PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1767 pj_bool_t enabled);
1768
1769
1770/**
1771 * Close the transport. If transport is forcefully closed, it will be
1772 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00001773 * transport may not terminate properly (it may even crash). Otherwise,
1774 * the system will wait until all transactions are closed while preventing
1775 * new users from using the transport, and will close the transport when
1776 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001777 *
1778 * @param id Transport ID.
1779 * @param force Non-zero to immediately close the transport. This
1780 * is not recommended!
1781 *
1782 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001783 *
1784 * \par Python:
1785 * \code
1786 status = py_pjsua.transport_close(id, force)
1787 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001788 */
1789PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1790 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001791
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001792/**
Benny Prijono312aff92006-06-17 04:08:30 +00001793 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001794 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001795
1796
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001797
1798
1799/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001800 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001801 */
1802
Benny Prijono312aff92006-06-17 04:08:30 +00001803
1804/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001805 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001806 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001807 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001808 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001809 *
Benny Prijono312aff92006-06-17 04:08:30 +00001810 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001811 * using the application. In SIP terms, the identity is used as the <b>From</b>
1812 * header in outgoing requests.
1813 *
1814 * PJSUA-API supports creating and managing multiple accounts. The maximum
1815 * number of accounts is limited by a compile time constant
1816 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001817 *
1818 * Account may or may not have client registration associated with it.
1819 * An account is also associated with <b>route set</b> and some <b>authentication
1820 * credentials</b>, which are used when sending SIP request messages using the
1821 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00001822 * will be reported to remote peer when they subscribe to the account's
1823 * presence, or which is published to a presence server if presence
1824 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00001825 *
1826 * At least one account MUST be created in the application. If no user
1827 * association is required, application can create a userless account by
1828 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00001829 * instead of a particular user, and it correspond with a particular
1830 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00001831 *
1832 * Also one account must be set as the <b>default account</b>, which is used as
1833 * the account to use when PJSUA fails to match a request with any other
1834 * accounts.
1835 *
1836 * When sending outgoing SIP requests (such as making calls or sending
1837 * instant messages), normally PJSUA requires the application to specify
1838 * which account to use for the request. If no account is specified,
1839 * PJSUA may be able to select the account by matching the destination
1840 * domain name, and fall back to default account when no match is found.
1841 */
1842
1843/**
1844 * Maximum accounts.
1845 */
1846#ifndef PJSUA_MAX_ACC
1847# define PJSUA_MAX_ACC 8
1848#endif
1849
1850
1851/**
1852 * Default registration interval.
1853 */
1854#ifndef PJSUA_REG_INTERVAL
Benny Prijonobddef2c2007-10-31 13:28:08 +00001855# define PJSUA_REG_INTERVAL 300
Benny Prijono312aff92006-06-17 04:08:30 +00001856#endif
1857
1858
1859/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001860 * Default PUBLISH expiration
1861 */
1862#ifndef PJSUA_PUBLISH_EXPIRATION
1863# define PJSUA_PUBLISH_EXPIRATION 600
1864#endif
1865
1866
1867/**
Benny Prijono093d3022006-09-24 00:07:11 +00001868 * Default account priority.
1869 */
1870#ifndef PJSUA_DEFAULT_ACC_PRIORITY
1871# define PJSUA_DEFAULT_ACC_PRIORITY 0
1872#endif
1873
1874
1875/**
Benny Prijono8058a622007-06-08 04:37:05 +00001876 * This macro specifies the URI scheme to use in Contact header
1877 * when secure transport such as TLS is used. Application can specify
1878 * either "sip" or "sips".
1879 */
1880#ifndef PJSUA_SECURE_SCHEME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00001881# define PJSUA_SECURE_SCHEME "sips"
Benny Prijono8058a622007-06-08 04:37:05 +00001882#endif
1883
1884
1885/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001886 * This structure describes account configuration to be specified when
1887 * adding a new account with #pjsua_acc_add(). Application MUST initialize
1888 * this structure first by calling #pjsua_acc_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00001889 *
1890 * \par Python:
1891 * The data type in Python is <tt>py_pjsua.Acc_Config</tt>, but normally
1892 * application can just use the snippet below to create and initialize
1893 * the account config:
1894 * \code
1895 acc_cfg = py_pjsua.acc_config_default()
1896 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001897 */
1898typedef struct pjsua_acc_config
1899{
Benny Prijono093d3022006-09-24 00:07:11 +00001900 /**
1901 * Account priority, which is used to control the order of matching
1902 * incoming/outgoing requests. The higher the number means the higher
1903 * the priority is, and the account will be matched first.
1904 */
1905 int priority;
1906
Benny Prijono312aff92006-06-17 04:08:30 +00001907 /**
1908 * The full SIP URL for the account. The value can take name address or
1909 * URL format, and will look something like "sip:account@serviceprovider".
1910 *
1911 * This field is mandatory.
1912 */
1913 pj_str_t id;
1914
1915 /**
1916 * This is the URL to be put in the request URI for the registration,
1917 * and will look something like "sip:serviceprovider".
1918 *
1919 * This field should be specified if registration is desired. If the
1920 * value is empty, no account registration will be performed.
1921 */
1922 pj_str_t reg_uri;
1923
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001924 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001925 * If this flag is set, the presence information of this account will
1926 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono48ab2b72007-11-08 09:24:30 +00001927 *
1928 * Default: PJ_FALSE
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001929 */
1930 pj_bool_t publish_enabled;
1931
Benny Prijonofe04fb52007-08-24 08:28:52 +00001932 /**
Benny Prijono48ab2b72007-11-08 09:24:30 +00001933 * Authentication preference.
1934 */
1935 pjsip_auth_clt_pref auth_pref;
1936
1937 /**
Benny Prijonofe04fb52007-08-24 08:28:52 +00001938 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
1939 * is not specified, a random string will be used.
1940 */
1941 pj_str_t pidf_tuple_id;
1942
Benny Prijono312aff92006-06-17 04:08:30 +00001943 /**
1944 * Optional URI to be put as Contact for this account. It is recommended
1945 * that this field is left empty, so that the value will be calculated
1946 * automatically based on the transport address.
1947 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00001948 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00001949
1950 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001951 * Specify whether support for reliable provisional response (100rel and
1952 * PRACK) should be required for all sessions of this account.
1953 *
1954 * Default: PJ_FALSE
1955 */
1956 pj_bool_t require_100rel;
1957
1958 /**
Benny Prijono312aff92006-06-17 04:08:30 +00001959 * Number of proxies in the proxy array below.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001960 *
1961 * \par Python:
1962 * Not applicable, as \a proxy is implemented as list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001963 */
1964 unsigned proxy_cnt;
1965
1966 /**
1967 * Optional URI of the proxies to be visited for all outgoing requests
1968 * that are using this account (REGISTER, INVITE, etc). Application need
1969 * to specify these proxies if the service provider requires that requests
1970 * destined towards its network should go through certain proxies first
1971 * (for example, border controllers).
1972 *
1973 * These proxies will be put in the route set for this account, with
1974 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00001975 * first). If global outbound proxies are configured in pjsua_config,
1976 * then these account proxies will be placed after the global outbound
1977 * proxies in the routeset.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001978 *
1979 * \par Python:
1980 * This will be list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001981 */
1982 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
1983
1984 /**
1985 * Optional interval for registration, in seconds. If the value is zero,
Benny Prijonobddef2c2007-10-31 13:28:08 +00001986 * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
Benny Prijono312aff92006-06-17 04:08:30 +00001987 */
1988 unsigned reg_timeout;
1989
1990 /**
1991 * Number of credentials in the credential array.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001992 *
1993 * \par Python:
1994 * Not applicable, since \a cred_info is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00001995 */
1996 unsigned cred_count;
1997
1998 /**
1999 * Array of credentials. If registration is desired, normally there should
2000 * be at least one credential specified, to successfully authenticate
2001 * against the service provider. More credentials can be specified, for
2002 * example when the requests are expected to be challenged by the
2003 * proxies in the route set.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002004 *
2005 * \par Python:
2006 * This field is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00002007 */
2008 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
2009
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002010 /**
2011 * Optionally bind this account to specific transport. This normally is
2012 * not a good idea, as account should be able to send requests using
2013 * any available transports according to the destination. But some
2014 * application may want to have explicit control over the transport to
2015 * use, so in that case it can set this field.
2016 *
2017 * Default: -1 (PJSUA_INVALID_ID)
2018 *
2019 * @see pjsua_acc_set_transport()
2020 */
2021 pjsua_transport_id transport_id;
2022
Benny Prijono15b02302007-09-27 14:07:07 +00002023 /**
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002024 * This option is used to update the UDP transport address and the Contact
2025 * header of REGISTER request. When this option is enabled, the library
2026 * will keep track of the public IP address from the response of REGISTER
2027 * request. Once it detects that the address has changed, it will
2028 * unregister current Contact, update the Contact with transport address
2029 * learned from Via header, and register a new Contact to the registrar.
2030 * This will also update the public name of UDP transport if STUN is
2031 * configured.
Benny Prijono15b02302007-09-27 14:07:07 +00002032 *
2033 * Default: 1 (yes)
2034 */
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002035 pj_bool_t allow_contact_rewrite;
Benny Prijono15b02302007-09-27 14:07:07 +00002036
Benny Prijonobddef2c2007-10-31 13:28:08 +00002037 /**
2038 * Set the interval for periodic keep-alive transmission for this account.
2039 * If this value is zero, keep-alive will be disabled for this account.
2040 * The keep-alive transmission will be sent to the registrar's address,
2041 * after successful registration.
2042 *
Benny Prijonobddef2c2007-10-31 13:28:08 +00002043 * Default: 15 (seconds)
2044 */
2045 unsigned ka_interval;
2046
2047 /**
2048 * Specify the data to be transmitted as keep-alive packets.
2049 *
2050 * Default: CR-LF
2051 */
2052 pj_str_t ka_data;
2053
Benny Prijonod8179652008-01-23 20:39:07 +00002054#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
2055 /**
2056 * Specify whether secure media transport should be used for this account.
2057 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
2058 * PJMEDIA_SRTP_MANDATORY.
2059 *
2060 * Default: #PJSUA_DEFAULT_USE_SRTP
2061 */
2062 pjmedia_srtp_use use_srtp;
2063
2064 /**
2065 * Specify whether SRTP requires secure signaling to be used. This option
2066 * is only used when \a use_srtp option above is non-zero.
2067 *
2068 * Valid values are:
2069 * 0: SRTP does not require secure signaling
2070 * 1: SRTP requires secure transport such as TLS
2071 * 2: SRTP requires secure end-to-end transport (SIPS)
2072 *
2073 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
2074 */
2075 int srtp_secure_signaling;
2076#endif
2077
Benny Prijono312aff92006-06-17 04:08:30 +00002078} pjsua_acc_config;
2079
2080
2081/**
2082 * Call this function to initialize account config with default values.
2083 *
2084 * @param cfg The account config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002085 *
2086 * \par Python:
2087 * In Python, this function both creates and initializes the account
2088 * config:
2089 * \code
2090 acc_cfg = py_pjsua.acc_config_default()
2091 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002092 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00002093PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002094
2095
2096/**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002097 * Duplicate account config.
2098 *
2099 * @param pool Pool to be used for duplicating the config.
2100 * @param dst Destination configuration.
2101 * @param src Source configuration.
2102 */
2103PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
2104 pjsua_acc_config *dst,
2105 const pjsua_acc_config *src);
2106
2107
2108/**
Benny Prijono312aff92006-06-17 04:08:30 +00002109 * Account info. Application can query account info by calling
2110 * #pjsua_acc_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00002111 *
2112 * \par Python:
2113 * The data type in Python is <tt>py_pjsua.Acc_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002114 */
2115typedef struct pjsua_acc_info
2116{
2117 /**
2118 * The account ID.
2119 */
2120 pjsua_acc_id id;
2121
2122 /**
2123 * Flag to indicate whether this is the default account.
2124 */
2125 pj_bool_t is_default;
2126
2127 /**
2128 * Account URI
2129 */
2130 pj_str_t acc_uri;
2131
2132 /**
2133 * Flag to tell whether this account has registration setting
2134 * (reg_uri is not empty).
2135 */
2136 pj_bool_t has_registration;
2137
2138 /**
2139 * An up to date expiration interval for account registration session.
2140 */
2141 int expires;
2142
2143 /**
2144 * Last registration status code. If status code is zero, the account
2145 * is currently not registered. Any other value indicates the SIP
2146 * status code of the registration.
2147 */
2148 pjsip_status_code status;
2149
2150 /**
2151 * String describing the registration status.
2152 */
2153 pj_str_t status_text;
2154
2155 /**
2156 * Presence online status for this account.
2157 */
2158 pj_bool_t online_status;
2159
2160 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00002161 * Presence online status text.
2162 */
2163 pj_str_t online_status_text;
2164
2165 /**
2166 * Extended RPID online status information.
2167 */
2168 pjrpid_element rpid;
2169
2170 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002171 * Buffer that is used internally to store the status text.
2172 */
2173 char buf_[PJ_ERR_MSG_SIZE];
2174
2175} pjsua_acc_info;
2176
2177
2178
2179/**
2180 * Get number of current accounts.
2181 *
2182 * @return Current number of accounts.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002183 *
2184 * \par Python:
2185 * \code
2186 count = py_pjsua.acc_get_count()
2187 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002188 */
2189PJ_DECL(unsigned) pjsua_acc_get_count(void);
2190
2191
2192/**
2193 * Check if the specified account ID is valid.
2194 *
2195 * @param acc_id Account ID to check.
2196 *
2197 * @return Non-zero if account ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002198 *
2199 * \par Python:
2200 * \code
2201 is_valid = py_pjsua.acc_is_valid(acc_id)
2202 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002203 */
2204PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
2205
2206
2207/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00002208 * Set default account to be used when incoming and outgoing
2209 * requests doesn't match any accounts.
2210 *
2211 * @param acc_id The account ID to be used as default.
2212 *
2213 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002214 *
2215 * \par Python:
2216 * \code
2217 status = py_pjsua.acc_set_default(acc_id)
2218 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002219 */
2220PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2221
2222
2223/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002224 * Get default account to be used when receiving incoming requests (calls),
2225 * when the destination of the incoming call doesn't match any other
2226 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002227 *
2228 * @return The default account ID, or PJSUA_INVALID_ID if no
2229 * default account is configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002230 *
2231 * \par Python:
2232 * \code
2233 acc_id = py_pjsua.acc_get_default()
2234 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002235 */
2236PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2237
2238
2239/**
Benny Prijono312aff92006-06-17 04:08:30 +00002240 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002241 * #pjsua_init()) before calling this function. If registration is configured
2242 * for this account, this function would also start the SIP registration
2243 * session with the SIP registrar server. This SIP registration session
2244 * will be maintained internally by the library, and application doesn't
2245 * need to do anything to maintain the registration session.
2246 *
Benny Prijono312aff92006-06-17 04:08:30 +00002247 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002248 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002249 * @param is_default If non-zero, this account will be set as the default
2250 * account. The default account will be used when sending
2251 * outgoing requests (e.g. making call) when no account is
2252 * specified, and when receiving incoming requests when the
2253 * request does not match any accounts. It is recommended
2254 * that default account is set to local/LAN account.
2255 * @param p_acc_id Pointer to receive account ID of the new account.
2256 *
2257 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002258 *
2259 * \par Python:
2260 * The function returns (status, account_id) tuple:
2261 * \code
2262 status, account_id = py_pjsua.acc_add(acc_cfg, is_default)
2263 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002264 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002265PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002266 pj_bool_t is_default,
2267 pjsua_acc_id *p_acc_id);
2268
2269
2270/**
2271 * Add a local account. A local account is used to identify local endpoint
2272 * instead of a specific user, and for this reason, a transport ID is needed
2273 * to obtain the local address information.
2274 *
2275 * @param tid Transport ID to generate account address.
2276 * @param is_default If non-zero, this account will be set as the default
2277 * account. The default account will be used when sending
2278 * outgoing requests (e.g. making call) when no account is
2279 * specified, and when receiving incoming requests when the
2280 * request does not match any accounts. It is recommended
2281 * that default account is set to local/LAN account.
2282 * @param p_acc_id Pointer to receive account ID of the new account.
2283 *
2284 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002285 *
2286 * \par Python:
2287 * The function returns (status, account_id) tuple:
2288 * \code
2289 status, account_id = py_pjsua.acc_add_local(tid, is_default)
2290 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002291 */
2292PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2293 pj_bool_t is_default,
2294 pjsua_acc_id *p_acc_id);
2295
2296/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002297 * Delete an account. This will unregister the account from the SIP server,
2298 * if necessary, and terminate server side presence subscriptions associated
2299 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002300 *
2301 * @param acc_id Id of the account to be deleted.
2302 *
2303 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002304 *
2305 * \par Python:
2306 * \code
2307 status = py_pjsua.acc_del(acc_id)
2308 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002309 */
2310PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2311
2312
2313/**
2314 * Modify account information.
2315 *
2316 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002317 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002318 *
2319 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002320 *
2321 * \par Python:
2322 * \code
2323 status = py_pjsua.acc_modify(acc_id, acc_cfg)
2324 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002325 */
2326PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002327 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002328
2329
2330/**
2331 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002332 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002333 * if there are server side presence subscription for this account, and/or
2334 * outgoing PUBLISH if presence publication is enabled for this account.
2335 *
2336 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002337 *
2338 * @param acc_id The account ID.
2339 * @param is_online True of false.
2340 *
2341 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002342 *
2343 * \par Python:
2344 * \code
2345 status = py_pjsua.acc_set_online_status(acc_id, is_online)
2346 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002347 */
2348PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2349 pj_bool_t is_online);
2350
Benny Prijono4461c7d2007-08-25 13:36:15 +00002351/**
2352 * Modify account's presence status to be advertised to remote/presence
2353 * subscribers. This would trigger the sending of outgoing NOTIFY request
2354 * if there are server side presence subscription for this account, and/or
2355 * outgoing PUBLISH if presence publication is enabled for this account.
2356 *
2357 * @see pjsua_acc_set_online_status()
2358 *
2359 * @param acc_id The account ID.
2360 * @param is_online True of false.
2361 * @param pr Extended information in subset of RPID format
2362 * which allows setting custom presence text.
2363 *
2364 * @return PJ_SUCCESS on success, or the appropriate error code.
2365 */
2366PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2367 pj_bool_t is_online,
2368 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002369
2370/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002371 * Update registration or perform unregistration. If registration is
2372 * configured for this account, then initial SIP REGISTER will be sent
2373 * when the account is added with #pjsua_acc_add(). Application normally
2374 * only need to call this function if it wants to manually update the
2375 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002376 *
2377 * @param acc_id The account ID.
2378 * @param renew If renew argument is zero, this will start
2379 * unregistration process.
2380 *
2381 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002382 *
2383 * \par Python:
2384 * \code
2385 status = py_pjsua.acc_set_registration(acc_id, renew)
2386 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002387 */
2388PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2389 pj_bool_t renew);
2390
2391
2392/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002393 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002394 *
2395 * @param acc_id Account identification.
2396 * @param info Pointer to receive account information.
2397 *
2398 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002399 *
2400 * \par Python:
2401 * \code
2402 acc_info = py_pjsua.acc_get_info(acc_id)
2403 * \endcode
2404 * The function returns None if account ID is not valid.
Benny Prijono312aff92006-06-17 04:08:30 +00002405 */
2406PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2407 pjsua_acc_info *info);
2408
2409
2410/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002411 * Enumerate all account currently active in the library. This will fill
2412 * the array with the account Ids, and application can then query the
2413 * account information for each id with #pjsua_acc_get_info().
2414 *
2415 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002416 *
2417 * @param ids Array of account IDs to be initialized.
2418 * @param count In input, specifies the maximum number of elements.
2419 * On return, it contains the actual number of elements.
2420 *
2421 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002422 *
2423 * \par Python:
2424 * The function takes no argument and returns list of account Ids:
2425 * \code
2426 [acc_ids] = py_pjsua.enum_accs()
2427 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002428 */
2429PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2430 unsigned *count );
2431
2432
2433/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002434 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002435 *
2436 * @param info Array of account infos to be initialized.
2437 * @param count In input, specifies the maximum number of elements.
2438 * On return, it contains the actual number of elements.
2439 *
2440 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002441 *
2442 * \par Python:
2443 * The function takes no argument and returns list of account infos:
2444 * \code
2445 [acc_info] = py_pjsua.acc_enum_info()
2446 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002447 */
2448PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2449 unsigned *count );
2450
2451
2452/**
2453 * This is an internal function to find the most appropriate account to
2454 * used to reach to the specified URL.
2455 *
2456 * @param url The remote URL to reach.
2457 *
2458 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002459 *
2460 * \par Python:
2461 * \code
2462 acc_id = py_pjsua.acc_find_for_outgoing(url)
2463 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002464 */
2465PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2466
2467
2468/**
2469 * This is an internal function to find the most appropriate account to be
2470 * used to handle incoming calls.
2471 *
2472 * @param rdata The incoming request message.
2473 *
2474 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002475 *
2476 * \par Python:
2477 * \code
2478 acc_id = py_pjsua.acc_find_for_outgoing(url)
2479 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002480 */
2481PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2482
2483
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002484/**
Benny Prijonofff245c2007-04-02 11:44:47 +00002485 * Create arbitrary requests using the account. Application should only use
2486 * this function to create auxiliary requests outside dialog, such as
2487 * OPTIONS, and use the call or presence API to create dialog related
2488 * requests.
2489 *
2490 * @param acc_id The account ID.
2491 * @param method The SIP method of the request.
2492 * @param target Target URI.
2493 * @param p_tdata Pointer to receive the request.
2494 *
2495 * @return PJ_SUCCESS or the error code.
2496 */
2497PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
2498 const pjsip_method *method,
2499 const pj_str_t *target,
2500 pjsip_tx_data **p_tdata);
2501
2502
2503/**
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002504 * Create a suitable URI to be put as Contact based on the specified
2505 * target URI for the specified account.
2506 *
2507 * @param pool Pool to allocate memory for the string.
2508 * @param contact The string where the Contact URI will be stored.
2509 * @param acc_id Account ID.
2510 * @param uri Destination URI of the request.
2511 *
2512 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002513 *
2514 * \par Python:
2515 * This function is still experimental in Python:
2516 * \code
2517 uri = py_pjsua.acc_create_uac_contact(pool, acc_id, uri)
2518 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002519 */
2520PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
2521 pj_str_t *contact,
2522 pjsua_acc_id acc_id,
2523 const pj_str_t *uri);
2524
2525
2526
2527/**
2528 * Create a suitable URI to be put as Contact based on the information
2529 * in the incoming request.
2530 *
2531 * @param pool Pool to allocate memory for the string.
2532 * @param contact The string where the Contact URI will be stored.
2533 * @param acc_id Account ID.
2534 * @param rdata Incoming request.
2535 *
2536 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002537 *
2538 * \par Python:
2539 * This function is still experimental in Python:
2540 * \code
2541 uri = py_pjsua.acc_create_uas_contact(pool, acc_id, rdata)
2542 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002543 */
2544PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
2545 pj_str_t *contact,
2546 pjsua_acc_id acc_id,
2547 pjsip_rx_data *rdata );
2548
2549
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002550/**
2551 * Lock/bind this account to a specific transport/listener. Normally
2552 * application shouldn't need to do this, as transports will be selected
2553 * automatically by the stack according to the destination.
2554 *
2555 * When account is locked/bound to a specific transport, all outgoing
2556 * requests from this account will use the specified transport (this
2557 * includes SIP registration, dialog (call and event subscription), and
2558 * out-of-dialog requests such as MESSAGE).
2559 *
2560 * Note that transport_id may be specified in pjsua_acc_config too.
2561 *
2562 * @param acc_id The account ID.
2563 * @param tp_id The transport ID.
2564 *
2565 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002566 *
2567 * \par Python:
2568 * Not yet implemented.
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002569 */
2570PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
2571 pjsua_transport_id tp_id);
2572
Benny Prijono312aff92006-06-17 04:08:30 +00002573
2574/**
2575 * @}
2576 */
2577
2578
2579/*****************************************************************************
2580 * CALLS API
2581 */
2582
2583
2584/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002585 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00002586 * @ingroup PJSUA_LIB
2587 * @brief Call manipulation.
2588 * @{
2589 */
2590
2591/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002592 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00002593 */
2594#ifndef PJSUA_MAX_CALLS
2595# define PJSUA_MAX_CALLS 32
2596#endif
2597
2598
2599
2600/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002601 * This enumeration specifies the media status of a call, and it's part
2602 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00002603 */
2604typedef enum pjsua_call_media_status
2605{
Benny Prijonob5388cf2007-01-04 22:45:08 +00002606 /** Call currently has no media */
Benny Prijono312aff92006-06-17 04:08:30 +00002607 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002608
2609 /** The media is active */
Benny Prijono312aff92006-06-17 04:08:30 +00002610 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002611
2612 /** The media is currently put on hold by local endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002613 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002614
2615 /** The media is currently put on hold by remote endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002616 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002617
Benny Prijono096c56c2007-09-15 08:30:16 +00002618 /** The media has reported error (e.g. ICE negotiation) */
2619 PJSUA_CALL_MEDIA_ERROR
2620
Benny Prijono312aff92006-06-17 04:08:30 +00002621} pjsua_call_media_status;
2622
2623
2624/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002625 * This structure describes the information and current status of a call.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002626 *
2627 * \par Python:
2628 * The type name is <tt>py_pjsua.Call_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002629 */
2630typedef struct pjsua_call_info
2631{
2632 /** Call identification. */
2633 pjsua_call_id id;
2634
2635 /** Initial call role (UAC == caller) */
2636 pjsip_role_e role;
2637
Benny Prijono90315512006-09-14 16:05:16 +00002638 /** The account ID where this call belongs. */
2639 pjsua_acc_id acc_id;
2640
Benny Prijono312aff92006-06-17 04:08:30 +00002641 /** Local URI */
2642 pj_str_t local_info;
2643
2644 /** Local Contact */
2645 pj_str_t local_contact;
2646
2647 /** Remote URI */
2648 pj_str_t remote_info;
2649
2650 /** Remote contact */
2651 pj_str_t remote_contact;
2652
2653 /** Dialog Call-ID string. */
2654 pj_str_t call_id;
2655
2656 /** Call state */
2657 pjsip_inv_state state;
2658
2659 /** Text describing the state */
2660 pj_str_t state_text;
2661
2662 /** Last status code heard, which can be used as cause code */
2663 pjsip_status_code last_status;
2664
2665 /** The reason phrase describing the status. */
2666 pj_str_t last_status_text;
2667
2668 /** Call media status. */
2669 pjsua_call_media_status media_status;
2670
2671 /** Media direction */
2672 pjmedia_dir media_dir;
2673
2674 /** The conference port number for the call */
2675 pjsua_conf_port_id conf_slot;
2676
2677 /** Up-to-date call connected duration (zero when call is not
2678 * established)
2679 */
2680 pj_time_val connect_duration;
2681
2682 /** Total call duration, including set-up time */
2683 pj_time_val total_duration;
2684
2685 /** Internal */
2686 struct {
2687 char local_info[128];
2688 char local_contact[128];
2689 char remote_info[128];
2690 char remote_contact[128];
2691 char call_id[128];
2692 char last_status_text[128];
2693 } buf_;
2694
2695} pjsua_call_info;
2696
2697
2698
Benny Prijonoa91a0032006-02-26 21:23:45 +00002699/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002700 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002701 *
2702 * @return Maximum number of calls configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002703 *
2704 * \par Python:
2705 * \code
2706 count = py_pjsua.call_get_max_count()
2707 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002708 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002709PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002710
2711/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002712 * Get number of currently active calls.
2713 *
2714 * @return Number of currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002715 *
2716 * \par Python:
2717 * \code
2718 count = py_pjsua.call_get_count()
2719 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002720 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002721PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002722
2723/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002724 * Enumerate all active calls. Application may then query the information and
2725 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002726 *
2727 * @param ids Array of account IDs to be initialized.
2728 * @param count In input, specifies the maximum number of elements.
2729 * On return, it contains the actual number of elements.
2730 *
2731 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002732 *
2733 * \par Python:
2734 * This function takes no argument and return list of call Ids.
2735 * \code
2736 [call_ids] = py_pjsua.enum_calls()
2737 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002738 */
2739PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
2740 unsigned *count);
2741
2742
2743/**
2744 * Make outgoing call to the specified URI using the specified account.
2745 *
2746 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002747 * @param dst_uri URI to be put in the To header (normally is the same
2748 * as the target URI).
2749 * @param options Options (must be zero at the moment).
2750 * @param user_data Arbitrary user data to be attached to the call, and
2751 * can be retrieved later.
2752 * @param msg_data Optional headers etc to be added to outgoing INVITE
2753 * request, or NULL if no custom header is desired.
2754 * @param p_call_id Pointer to receive call identification.
2755 *
2756 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002757 *
2758 * \par Python:
2759 * The Python function returns (status, call_id) tuple:
2760 * \code
2761 status, call_id = py_pjsua.call_make_call(acc_id, dst_uri, options,
2762 user_data, msg_data)
2763 * \endcode
2764 * Note: the \a user_data in Python function is an integer, and the
2765 * \a msg_data can be set to None if not required.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002766 */
2767PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
2768 const pj_str_t *dst_uri,
2769 unsigned options,
2770 void *user_data,
2771 const pjsua_msg_data *msg_data,
2772 pjsua_call_id *p_call_id);
2773
2774
2775/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002776 * Check if the specified call has active INVITE session and the INVITE
2777 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002778 *
2779 * @param call_id Call identification.
2780 *
2781 * @return Non-zero if call is active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002782 *
2783 * \par Python:
2784 * \code
2785 bool = py_pjsua.call_is_active(call_id)
2786 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002787 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002788PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002789
2790
2791/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002792 * Check if call has an active media session.
2793 *
2794 * @param call_id Call identification.
2795 *
2796 * @return Non-zero if yes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002797 *
2798 * \par Python:
2799 * \code
2800 bool = py_pjsua.call_has_media(call_id)
2801 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002802 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002803PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002804
2805
2806/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002807 * Get the conference port identification associated with the call.
2808 *
2809 * @param call_id Call identification.
2810 *
2811 * @return Conference port ID, or PJSUA_INVALID_ID when the
2812 * media has not been established or is not active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002813 *
2814 * \par Python:
2815 * \code
2816 slot = py_pjsua.call_get_conf_port(call_id)
2817 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002818 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002819PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
2820
2821/**
2822 * Obtain detail information about the specified call.
2823 *
2824 * @param call_id Call identification.
2825 * @param info Call info to be initialized.
2826 *
2827 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002828 *
2829 * \par Python:
2830 * \code
2831 call_info = py_pjsua.call_get_info(call_id)
2832 * \endcode
2833 * \a call_info return value will be set to None if call_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002834 */
2835PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002836 pjsua_call_info *info);
2837
2838
2839/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002840 * Attach application specific data to the call. Application can then
2841 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002842 *
2843 * @param call_id Call identification.
2844 * @param user_data Arbitrary data to be attached to the call.
2845 *
2846 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002847 *
2848 * \par Python:
2849 * \code
2850 status = py_pjsua.call_set_user_data(call_id, user_data)
2851 * \endcode
2852 * The \a user_data is an integer in the Python function.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002853 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002854PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
2855 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002856
2857
2858/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002859 * Get user data attached to the call, which has been previously set with
2860 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002861 *
2862 * @param call_id Call identification.
2863 *
2864 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002865 *
2866 * \par Python:
2867 * \code
2868 user_data = py_pjsua.call_get_user_data(call_id)
2869 * \endcode
2870 * The \a user_data is an integer.
Benny Prijono268ca612006-02-07 12:34:11 +00002871 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002872PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00002873
2874
2875/**
Benny Prijono91a6a172007-10-31 08:59:29 +00002876 * Get the NAT type of remote's endpoint. This is a proprietary feature
2877 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
2878 * is set in #pjsua_config.
2879 *
2880 * This function can only be called after SDP has been received from remote,
2881 * which means for incoming call, this function can be called as soon as
2882 * call is received as long as incoming call contains SDP, and for outgoing
2883 * call, this function can be called only after SDP is received (normally in
2884 * 200/OK response to INVITE). As a general case, application should call
2885 * this function after or in \a on_call_media_state() callback.
2886 *
2887 * @param call_id Call identification.
2888 * @param p_type Pointer to store the NAT type. Application can then
2889 * retrieve the string description of the NAT type
2890 * by calling pj_stun_get_nat_name().
2891 *
2892 * @return PJ_SUCCESS on success.
2893 *
2894 * @see pjsua_get_nat_type(), nat_type_in_sdp
2895 */
2896PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
2897 pj_stun_nat_type *p_type);
2898
2899/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002900 * Send response to incoming INVITE request. Depending on the status
2901 * code specified as parameter, this function may send provisional
2902 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002903 *
2904 * @param call_id Incoming call identification.
2905 * @param code Status code, (100-699).
2906 * @param reason Optional reason phrase. If NULL, default text
2907 * will be used.
2908 * @param msg_data Optional list of headers etc to be added to outgoing
2909 * response message.
2910 *
2911 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002912 *
2913 * \par Python:
2914 * \code
2915 status = py_pjsua.call_answer(call_id, code, reason, msg_data)
2916 * \endcode
2917 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijonoa91a0032006-02-26 21:23:45 +00002918 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002919PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
2920 unsigned code,
2921 const pj_str_t *reason,
2922 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00002923
2924/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002925 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00002926 * call state. This function is different than answering the call with
2927 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
2928 * will hangup the call regardless of the state and role of the call,
2929 * while #pjsua_call_answer() only works with incoming calls on EARLY
2930 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002931 *
2932 * @param call_id Call identification.
2933 * @param code Optional status code to be sent when we're rejecting
2934 * incoming call. If the value is zero, "603/Decline"
2935 * will be sent.
2936 * @param reason Optional reason phrase to be sent when we're rejecting
2937 * incoming call. If NULL, default text will be used.
2938 * @param msg_data Optional list of headers etc to be added to outgoing
2939 * request/response message.
2940 *
2941 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002942 *
2943 * \par Python:
2944 * \code
2945 status = py_pjsua.call_hangup(call_id, code, reason, msg_data)
2946 * \endcode
2947 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002948 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002949PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
2950 unsigned code,
2951 const pj_str_t *reason,
2952 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002953
2954
2955/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002956 * Put the specified call on hold. This will send re-INVITE with the
2957 * appropriate SDP to inform remote that the call is being put on hold.
2958 * The final status of the request itself will be reported on the
2959 * \a on_call_media_state() callback, which inform the application that
2960 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002961 *
2962 * @param call_id Call identification.
2963 * @param msg_data Optional message components to be sent with
2964 * the request.
2965 *
2966 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002967 *
2968 * \par Python:
2969 * \code
2970 status = py_pjsua.call_set_hold(call_id, msg_data)
2971 * \endcode
2972 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002973 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002974PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
2975 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002976
2977
2978/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002979 * Send re-INVITE to release hold.
2980 * The final status of the request itself will be reported on the
2981 * \a on_call_media_state() callback, which inform the application that
2982 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002983 *
2984 * @param call_id Call identification.
2985 * @param unhold If this argument is non-zero and the call is locally
2986 * held, this will release the local hold.
2987 * @param msg_data Optional message components to be sent with
2988 * the request.
2989 *
2990 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002991 *
2992 * \par Python:
2993 * \code
2994 status = py_pjsua.call_reinvite(call_id, unhold, msg_data)
2995 * \endcode
2996 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002997 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002998PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
2999 pj_bool_t unhold,
3000 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003001
Benny Prijonoc08682e2007-10-04 06:17:58 +00003002/**
3003 * Send UPDATE request.
3004 *
3005 * @param call_id Call identification.
3006 * @param options Must be zero for now.
3007 * @param msg_data Optional message components to be sent with
3008 * the request.
3009 *
3010 * @return PJ_SUCCESS on success, or the appropriate error code.
3011 */
3012PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
3013 unsigned options,
3014 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003015
3016/**
Benny Prijono053f5222006-11-11 16:16:04 +00003017 * Initiate call transfer to the specified address. This function will send
3018 * REFER request to instruct remote call party to initiate a new INVITE
3019 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003020 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00003021 * If application is interested to monitor the successfulness and
3022 * the progress of the transfer request, it can implement
3023 * \a on_call_transfer_status() callback which will report the progress
3024 * of the call transfer request.
3025 *
Benny Prijono053f5222006-11-11 16:16:04 +00003026 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003027 * @param dest Address of new target to be contacted.
3028 * @param msg_data Optional message components to be sent with
3029 * the request.
3030 *
3031 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003032 *
3033 * \par Python:
3034 * \code
3035 status = py_pjsua.call_xfer(call_id, dest, msg_data)
3036 * \endcode
3037 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003038 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003039PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
3040 const pj_str_t *dest,
3041 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003042
3043/**
Benny Prijono053f5222006-11-11 16:16:04 +00003044 * Flag to indicate that "Require: replaces" should not be put in the
3045 * outgoing INVITE request caused by REFER request created by
3046 * #pjsua_call_xfer_replaces().
3047 */
3048#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
3049
3050/**
3051 * Initiate attended call transfer. This function will send REFER request
3052 * to instruct remote call party to initiate new INVITE session to the URL
3053 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
3054 * the call with us with the new call from the REFER recipient.
3055 *
3056 * @param call_id The call id to be transfered.
3057 * @param dest_call_id The call id to be replaced.
3058 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
3059 * to suppress the inclusion of "Require: replaces" in
3060 * the outgoing INVITE request created by the REFER
3061 * request.
3062 * @param msg_data Optional message components to be sent with
3063 * the request.
3064 *
3065 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003066 *
3067 * \par Python:
3068 * \code
3069 status = py_pjsua.call_xfer_replaces(call_id, dest_call_id, options, msg_data)
3070 * \endcode
3071 * Argument \a msg_data may be set to None if not required.
Benny Prijono053f5222006-11-11 16:16:04 +00003072 */
3073PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
3074 pjsua_call_id dest_call_id,
3075 unsigned options,
3076 const pjsua_msg_data *msg_data);
3077
3078/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003079 * Send DTMF digits to remote using RFC 2833 payload formats.
3080 *
3081 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003082 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003083 *
3084 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003085 *
3086 * \par Python:
3087 * \code
3088 status = py_pjsua.call_dial_dtmf(call_id, digits)
3089 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003090 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003091PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003092 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00003093
Benny Prijono26ff9062006-02-21 23:47:00 +00003094/**
Benny Prijonob0808372006-03-02 21:18:58 +00003095 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003096 *
3097 * @param call_id Call identification.
3098 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3099 * assumed.
3100 * @param content The message content.
3101 * @param msg_data Optional list of headers etc to be included in outgoing
3102 * request. The body descriptor in the msg_data is
3103 * ignored.
3104 * @param user_data Optional user data, which will be given back when
3105 * the IM callback is called.
3106 *
3107 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003108 *
3109 * \par Python:
3110 * \code
3111 status = py_pjsua.call_send_im(call_id, mime_type, content, msg_data, user_data)
3112 * \endcode
3113 * Note that the \a user_data argument is an integer in Python.
Benny Prijonob0808372006-03-02 21:18:58 +00003114 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003115PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
3116 const pj_str_t *mime_type,
3117 const pj_str_t *content,
3118 const pjsua_msg_data *msg_data,
3119 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003120
3121
3122/**
3123 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003124 *
3125 * @param call_id Call identification.
3126 * @param is_typing Non-zero to indicate to remote that local person is
3127 * currently typing an IM.
3128 * @param msg_data Optional list of headers etc to be included in outgoing
3129 * request.
3130 *
3131 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003132 *
3133 * \par Python:
3134 * \code
3135 status = py_pjsua.call_send_typing_ind(call_id, is_typing, msg_data)
3136 * \endcode
3137 * Argument \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003138 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003139PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
3140 pj_bool_t is_typing,
3141 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003142
3143/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00003144 * Send arbitrary request with the call. This is useful for example to send
3145 * INFO request. Note that application should not use this function to send
3146 * requests which would change the invite session's state, such as re-INVITE,
3147 * UPDATE, PRACK, and BYE.
3148 *
3149 * @param call_id Call identification.
3150 * @param method SIP method of the request.
3151 * @param msg_data Optional message body and/or list of headers to be
3152 * included in outgoing request.
3153 *
3154 * @return PJ_SUCCESS on success, or the appropriate error code.
3155 */
3156PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
3157 const pj_str_t *method,
3158 const pjsua_msg_data *msg_data);
3159
3160
3161/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003162 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
3163 * currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003164 *
3165 * \par Python:
3166 * \code
3167 py_pjsua.call_hangup_all()
3168 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003169 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00003170PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00003171
3172
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003173/**
3174 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003175 *
3176 * @param call_id Call identification.
3177 * @param with_media Non-zero to include media information too.
3178 * @param buffer Buffer where the statistics are to be written to.
3179 * @param maxlen Maximum length of buffer.
3180 * @param indent Spaces for left indentation.
3181 *
3182 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003183 *
3184 * \par Python:
3185 * \code
3186 string = py_pjsua.call_dump(call_id, with_media, max_len, indent)
3187 * \endcode
3188 * The \a max_len argument is the desired maximum length to be allocated.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003189 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003190PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
3191 pj_bool_t with_media,
3192 char *buffer,
3193 unsigned maxlen,
3194 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003195
Benny Prijono9fc735d2006-05-28 14:58:12 +00003196/**
Benny Prijono312aff92006-06-17 04:08:30 +00003197 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003198 */
Benny Prijono834aee32006-02-19 01:38:06 +00003199
3200
3201/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00003202 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00003203 */
3204
Benny Prijono312aff92006-06-17 04:08:30 +00003205
3206/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003207 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00003208 * @ingroup PJSUA_LIB
3209 * @brief Buddy management, buddy's presence, and instant messaging.
3210 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00003211 *
3212 * This section describes PJSUA-APIs related to buddies management,
3213 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00003214 */
3215
3216/**
3217 * Max buddies in buddy list.
3218 */
3219#ifndef PJSUA_MAX_BUDDIES
3220# define PJSUA_MAX_BUDDIES 256
3221#endif
3222
3223
3224/**
Benny Prijonoa17496a2007-10-31 10:20:31 +00003225 * This specifies how long the library should retry resending SUBSCRIBE
3226 * if the previous SUBSCRIBE failed.
3227 *
3228 * Default: 300 seconds
3229 */
3230#ifndef PJSUA_PRES_TIMER
3231# define PJSUA_PRES_TIMER 300
3232#endif
3233
3234
3235/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003236 * This structure describes buddy configuration when adding a buddy to
3237 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
3238 * the structure with #pjsua_buddy_config_default() to initialize this
3239 * structure with default configuration.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003240 *
3241 * \par Python:
3242 * In Python this structure is <tt>py_pjsua.Buddy_Config</tt>. However
3243 * it is recommended that application instantiates the buddy config
3244 * by calling:
3245 * \code
3246 buddy_cfg = py_pjsua.buddy_config_default()
3247 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003248 */
3249typedef struct pjsua_buddy_config
3250{
3251 /**
3252 * Buddy URL or name address.
3253 */
3254 pj_str_t uri;
3255
3256 /**
3257 * Specify whether presence subscription should start immediately.
3258 */
3259 pj_bool_t subscribe;
3260
3261} pjsua_buddy_config;
3262
3263
3264/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003265 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003266 */
3267typedef enum pjsua_buddy_status
3268{
3269 /**
3270 * Online status is unknown (possibly because no presence subscription
3271 * has been established).
3272 */
3273 PJSUA_BUDDY_STATUS_UNKNOWN,
3274
3275 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003276 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003277 */
3278 PJSUA_BUDDY_STATUS_ONLINE,
3279
3280 /**
3281 * Buddy is offline.
3282 */
3283 PJSUA_BUDDY_STATUS_OFFLINE,
3284
3285} pjsua_buddy_status;
3286
3287
3288
3289/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003290 * This structure describes buddy info, which can be retrieved by calling
3291 * #pjsua_buddy_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003292 *
3293 * \par Python:
3294 * This structure in Python is <tt>py_pjsua.Buddy_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003295 */
3296typedef struct pjsua_buddy_info
3297{
3298 /**
3299 * The buddy ID.
3300 */
3301 pjsua_buddy_id id;
3302
3303 /**
3304 * The full URI of the buddy, as specified in the configuration.
3305 */
3306 pj_str_t uri;
3307
3308 /**
3309 * Buddy's Contact, only available when presence subscription has
3310 * been established to the buddy.
3311 */
3312 pj_str_t contact;
3313
3314 /**
3315 * Buddy's online status.
3316 */
3317 pjsua_buddy_status status;
3318
3319 /**
3320 * Text to describe buddy's online status.
3321 */
3322 pj_str_t status_text;
3323
3324 /**
3325 * Flag to indicate that we should monitor the presence information for
3326 * this buddy (normally yes, unless explicitly disabled).
3327 */
3328 pj_bool_t monitor_pres;
3329
3330 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003331 * Extended RPID information about the person.
3332 */
3333 pjrpid_element rpid;
3334
3335 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003336 * Internal buffer.
3337 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003338 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003339
3340} pjsua_buddy_info;
3341
3342
Benny Prijono834aee32006-02-19 01:38:06 +00003343/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003344 * Set default values to the buddy config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003345 *
3346 * \par Python:
3347 * \code
3348 buddy_cfg = py_pjsua.buddy_config_default()
3349 * \endcode
Benny Prijonob5388cf2007-01-04 22:45:08 +00003350 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003351PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003352
3353
3354/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003355 * Get total number of buddies.
3356 *
3357 * @return Number of buddies.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003358 *
3359 * \par Python:
3360 * \code
3361 buddy_count = py_pjsua.get_buddy_count()
3362 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003363 */
3364PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3365
3366
3367/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003368 * Check if buddy ID is valid.
3369 *
3370 * @param buddy_id Buddy ID to check.
3371 *
3372 * @return Non-zero if buddy ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003373 *
3374 * \par Python:
3375 * \code
3376 is_valid = py_pjsua.buddy_is_valid(buddy_id)
3377 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003378 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003379PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3380
3381
3382/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003383 * Enumerate all buddy IDs in the buddy list. Application then can use
3384 * #pjsua_buddy_get_info() to get the detail information for each buddy
3385 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003386 *
3387 * @param ids Array of ids to be initialized.
3388 * @param count On input, specifies max elements in the array.
3389 * On return, it contains actual number of elements
3390 * that have been initialized.
3391 *
3392 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003393 *
3394 * \par Python:
3395 * The Python function takes no argument and returns list of buddy IDs:
3396 * \code
3397 [buddy_ids] = py_pjsua.enum_buddies()
3398 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003399 */
3400PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3401 unsigned *count);
3402
3403/**
3404 * Get detailed buddy info.
3405 *
3406 * @param buddy_id The buddy identification.
3407 * @param info Pointer to receive information about buddy.
3408 *
3409 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003410 *
3411 * \par Python:
3412 * \code
3413 buddy_info = py_pjsua.buddy_get_info(buddy_id)
3414 * \endcode
3415 * The function returns None if buddy_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003416 */
3417PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003418 pjsua_buddy_info *info);
3419
3420/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003421 * Add new buddy to the buddy list. If presence subscription is enabled
3422 * for this buddy, this function will also start the presence subscription
3423 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003424 *
Benny Prijonoa7b376b2008-01-25 16:06:33 +00003425 * @param buddy_cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003426 * @param p_buddy_id Pointer to receive buddy ID.
3427 *
3428 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003429 *
3430 * \par Python:
3431 * The function returns (status, buddy_id) tuple:
3432 * \code
3433 status, buddy_id = py_pjsua.buddy_add(buddy_cfg)
3434 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003435 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003436PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003437 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003438
3439
3440/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003441 * Delete the specified buddy from the buddy list. Any presence subscription
3442 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003443 *
3444 * @param buddy_id Buddy identification.
3445 *
3446 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003447 *
3448 * \par Python:
3449 * \code
3450 status = py_pjsua.buddy_del(buddy_id)
3451 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +00003452 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003453PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003454
3455
3456/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003457 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3458 * subscribed, application will be informed about buddy's presence status
3459 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003460 *
3461 * @param buddy_id Buddy identification.
3462 * @param subscribe Specify non-zero to activate presence subscription to
3463 * the specified buddy.
3464 *
3465 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003466 *
3467 * \par Python:
3468 * \code
3469 status = py_pjsua.buddy_subscribe_pres(buddy_id, subscribe)
3470 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003471 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003472PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3473 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003474
3475
3476/**
Benny Prijono10861432007-10-31 10:54:53 +00003477 * Update the presence information for the buddy. Although the library
3478 * periodically refreshes the presence subscription for all buddies, some
3479 * application may want to refresh the buddy's presence subscription
3480 * immediately, and in this case it can use this function to accomplish
3481 * this.
3482 *
3483 * Note that the buddy's presence subscription will only be initiated
3484 * if presence monitoring is enabled for the buddy. See
3485 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
3486 * for the buddy is already active, this function will not do anything.
3487 *
3488 * Once the presence subscription is activated successfully for the buddy,
3489 * application will be notified about the buddy's presence status in the
3490 * on_buddy_state() callback.
3491 *
3492 * @param buddy_id Buddy identification.
3493 *
3494 * @return PJ_SUCCESS on success, or the appropriate error code.
3495 */
3496PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
3497
3498
3499/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003500 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003501 *
3502 * @param verbose Yes or no.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003503 *
3504 * \par Python:
3505 * \code
3506 py_pjsua.pres_dump()
3507 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003508 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003509PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003510
3511
Benny Prijonob0808372006-03-02 21:18:58 +00003512/**
3513 * The MESSAGE method (defined in pjsua_im.c)
3514 */
3515extern const pjsip_method pjsip_message_method;
3516
3517
Benny Prijonob0808372006-03-02 21:18:58 +00003518
3519/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003520 * Send instant messaging outside dialog, using the specified account for
3521 * route set and authentication.
3522 *
3523 * @param acc_id Account ID to be used to send the request.
3524 * @param to Remote URI.
3525 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3526 * assumed.
3527 * @param content The message content.
3528 * @param msg_data Optional list of headers etc to be included in outgoing
3529 * request. The body descriptor in the msg_data is
3530 * ignored.
3531 * @param user_data Optional user data, which will be given back when
3532 * the IM callback is called.
3533 *
3534 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003535 *
3536 * \par Python:
3537 * \code
3538 status = py_pjsua.im_send(acc_id, to, mime_type, content, msg_data, user_data)
3539 * \endcode
3540 * Arguments \a mime_type and \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003541 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003542PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3543 const pj_str_t *to,
3544 const pj_str_t *mime_type,
3545 const pj_str_t *content,
3546 const pjsua_msg_data *msg_data,
3547 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003548
3549
3550/**
3551 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003552 *
3553 * @param acc_id Account ID to be used to send the request.
3554 * @param to Remote URI.
3555 * @param is_typing If non-zero, it tells remote person that local person
3556 * is currently composing an IM.
3557 * @param msg_data Optional list of headers etc to be added to outgoing
3558 * request.
3559 *
3560 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003561 *
3562 * \par Python:
3563 * \code
3564 status = py_pjsua.im_typing(acc_id, to, is_typing, msg_data)
3565 * \endcode
3566 * Argument \a msg_data may be set to None if not requried.
Benny Prijonob0808372006-03-02 21:18:58 +00003567 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003568PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3569 const pj_str_t *to,
3570 pj_bool_t is_typing,
3571 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003572
3573
Benny Prijonof3195072006-02-14 21:15:30 +00003574
Benny Prijono312aff92006-06-17 04:08:30 +00003575/**
3576 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003577 */
3578
Benny Prijono312aff92006-06-17 04:08:30 +00003579
3580/*****************************************************************************
3581 * MEDIA API
3582 */
3583
3584
3585/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003586 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003587 * @ingroup PJSUA_LIB
3588 * @brief Media manipulation.
3589 * @{
3590 *
3591 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003592 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3593 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003594 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003595 * the interconnection between these terminations freely.
3596 *
3597 * The conference bridge provides powerful switching and mixing functionality
3598 * for application. With the conference bridge, each conference slot (e.g.
3599 * a call) can transmit to multiple destinations, and one destination can
3600 * receive from multiple sources. If more than one media terminations are
3601 * terminated in the same slot, the conference bridge will mix the signal
3602 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00003603 *
3604 * Application connects one media termination/slot to another by calling
3605 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003606 * media flow from the source termination to the sink termination. To
3607 * establish bidirectional media flow, application wound need to make another
3608 * call to #pjsua_conf_connect(), this time inverting the source and
3609 * destination slots in the parameter.
3610 *
3611 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00003612 * the following steps:
3613 *
3614 \code
3615
3616 pj_status_t stream_to_call( pjsua_call_id call_id )
3617 {
3618 pjsua_player_id player_id;
3619
3620 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
3621 if (status != PJ_SUCCESS)
3622 return status;
3623
3624 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
3625 pjsua_call_get_conf_port() );
3626 }
3627 \endcode
3628 *
3629 *
3630 * Other features of PJSUA media:
3631 * - efficient N to M interconnections between media terminations.
3632 * - media termination can be connected to itself to create loopback
3633 * media.
3634 * - the media termination may have different clock rates, and resampling
3635 * will be done automatically by conference bridge.
3636 * - media terminations may also have different frame time; the
3637 * conference bridge will perform the necessary bufferring to adjust
3638 * the difference between terminations.
3639 * - interconnections are removed automatically when media termination
3640 * is removed from the bridge.
3641 * - sound device may be changed even when there are active media
3642 * interconnections.
3643 * - correctly report call's media quality (in #pjsua_call_dump()) from
3644 * RTCP packet exchange.
3645 */
3646
3647/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003648 * Max ports in the conference bridge. This setting is the default value
3649 * for pjsua_media_config.max_media_ports.
Benny Prijono312aff92006-06-17 04:08:30 +00003650 */
3651#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00003652# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00003653#endif
3654
Benny Prijonob5388cf2007-01-04 22:45:08 +00003655/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003656 * The default clock rate to be used by the conference bridge. This setting
3657 * is the default value for pjsua_media_config.clock_rate.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003658 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003659#ifndef PJSUA_DEFAULT_CLOCK_RATE
3660# define PJSUA_DEFAULT_CLOCK_RATE 16000
3661#endif
3662
Benny Prijonob5388cf2007-01-04 22:45:08 +00003663/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003664 * Default frame length in the conference bridge. This setting
3665 * is the default value for pjsua_media_config.audio_frame_ptime.
3666 */
3667#ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Nanang Izzuddinaf974842008-05-08 09:51:16 +00003668# define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
Benny Prijono37c710b2008-01-10 12:09:26 +00003669#endif
3670
3671
3672/**
3673 * Default codec quality settings. This setting is the default value
3674 * for pjsua_media_config.quality.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003675 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003676#ifndef PJSUA_DEFAULT_CODEC_QUALITY
Nanang Izzuddin9dbad152008-06-10 18:56:10 +00003677# define PJSUA_DEFAULT_CODEC_QUALITY 8
Benny Prijono12a669c2006-11-23 07:32:13 +00003678#endif
3679
Benny Prijonob5388cf2007-01-04 22:45:08 +00003680/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003681 * Default iLBC mode. This setting is the default value for
3682 * pjsua_media_config.ilbc_mode.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003683 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003684#ifndef PJSUA_DEFAULT_ILBC_MODE
Benny Prijono37c710b2008-01-10 12:09:26 +00003685# define PJSUA_DEFAULT_ILBC_MODE 30
Benny Prijono12a669c2006-11-23 07:32:13 +00003686#endif
3687
Benny Prijonob5388cf2007-01-04 22:45:08 +00003688/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003689 * The default echo canceller tail length. This setting
3690 * is the default value for pjsua_media_config.ec_tail_len.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003691 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003692#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijono427439c2007-10-21 09:41:24 +00003693# define PJSUA_DEFAULT_EC_TAIL_LEN 200
Benny Prijono12a669c2006-11-23 07:32:13 +00003694#endif
Benny Prijono312aff92006-06-17 04:08:30 +00003695
3696
3697/**
Benny Prijonocba59d92007-02-16 09:22:56 +00003698 * The maximum file player.
3699 */
3700#ifndef PJSUA_MAX_PLAYERS
3701# define PJSUA_MAX_PLAYERS 32
3702#endif
3703
3704
3705/**
3706 * The maximum file player.
3707 */
3708#ifndef PJSUA_MAX_RECORDERS
3709# define PJSUA_MAX_RECORDERS 32
3710#endif
3711
3712
3713/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003714 * This structure describes media configuration, which will be specified
3715 * when calling #pjsua_init(). Application MUST initialize this structure
3716 * by calling #pjsua_media_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003717 *
3718 * \par Python:
3719 * This data type in Python is <tt>py_pjsua.Media_Config</tt>. To create
3720 * an object of this type, it is recommended to call
3721 * <tt>py_pjsua.media_config_default()</tt> function instead:
3722 * \code
3723 media_cfg = py_pjsua.media_config_default()
3724 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003725 */
3726struct pjsua_media_config
3727{
3728 /**
3729 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003730 * If value is zero, default clock rate will be used
3731 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00003732 */
3733 unsigned clock_rate;
3734
3735 /**
Benny Prijonof3758ee2008-02-26 15:32:16 +00003736 * Clock rate to be applied when opening the sound device.
3737 * If value is zero, conference bridge clock rate will be used.
3738 */
3739 unsigned snd_clock_rate;
3740
3741 /**
Benny Prijono7d60d052008-03-29 12:24:20 +00003742 * Channel count be applied when opening the sound device and
3743 * conference bridge.
3744 */
3745 unsigned channel_count;
3746
3747 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003748 * Specify audio frame ptime. The value here will affect the
3749 * samples per frame of both the sound device and the conference
3750 * bridge. Specifying lower ptime will normally reduce the
3751 * latency.
3752 *
Benny Prijono37c710b2008-01-10 12:09:26 +00003753 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003754 */
3755 unsigned audio_frame_ptime;
3756
3757 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003758 * Specify maximum number of media ports to be created in the
3759 * conference bridge. Since all media terminate in the bridge
3760 * (calls, file player, file recorder, etc), the value must be
3761 * large enough to support all of them. However, the larger
3762 * the value, the more computations are performed.
Benny Prijono37c710b2008-01-10 12:09:26 +00003763 *
3764 * Default value: PJSUA_MAX_CONF_PORTS
Benny Prijono312aff92006-06-17 04:08:30 +00003765 */
3766 unsigned max_media_ports;
3767
3768 /**
3769 * Specify whether the media manager should manage its own
3770 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
3771 * and at least one worker thread will be created too. If no,
3772 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
3773 * and no worker thread is needed.
3774 *
3775 * Normally application would say yes here, unless it wants to
3776 * run everything from a single thread.
3777 */
3778 pj_bool_t has_ioqueue;
3779
3780 /**
3781 * Specify the number of worker threads to handle incoming RTP
3782 * packets. A value of one is recommended for most applications.
3783 */
3784 unsigned thread_cnt;
3785
Benny Prijono0498d902006-06-19 14:49:14 +00003786 /**
3787 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00003788 * 5-10: resampling use large filter,
3789 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00003790 * 1-2: resampling use linear.
3791 * The media quality also sets speex codec quality/complexity to the
3792 * number.
3793 *
Benny Prijono70972992006-08-05 11:13:58 +00003794 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00003795 */
3796 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00003797
3798 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003799 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00003800 *
3801 * Default: 0 (codec specific)
3802 */
3803 unsigned ptime;
3804
3805 /**
3806 * Disable VAD?
3807 *
3808 * Default: 0 (no (meaning VAD is enabled))
3809 */
3810 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00003811
3812 /**
3813 * iLBC mode (20 or 30).
3814 *
Benny Prijono37c710b2008-01-10 12:09:26 +00003815 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00003816 */
3817 unsigned ilbc_mode;
3818
3819 /**
3820 * Percentage of RTP packet to drop in TX direction
3821 * (to simulate packet lost).
3822 *
3823 * Default: 0
3824 */
3825 unsigned tx_drop_pct;
3826
3827 /**
3828 * Percentage of RTP packet to drop in RX direction
3829 * (to simulate packet lost).
3830 *
3831 * Default: 0
3832 */
3833 unsigned rx_drop_pct;
3834
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003835 /**
Benny Prijono5da50432006-08-07 10:24:52 +00003836 * Echo canceller options (see #pjmedia_echo_create())
3837 *
3838 * Default: 0.
3839 */
3840 unsigned ec_options;
3841
3842 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003843 * Echo canceller tail length, in miliseconds.
3844 *
Benny Prijono669643c2006-09-20 20:02:18 +00003845 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003846 */
3847 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003848
3849 /**
3850 * Jitter buffer initial prefetch delay in msec. The value must be
3851 * between jb_min_pre and jb_max_pre below.
3852 *
3853 * Default: -1 (to use default stream settings, currently 150 msec)
3854 */
3855 int jb_init;
3856
3857 /**
3858 * Jitter buffer minimum prefetch delay in msec.
3859 *
3860 * Default: -1 (to use default stream settings, currently 60 msec)
3861 */
3862 int jb_min_pre;
3863
3864 /**
3865 * Jitter buffer maximum prefetch delay in msec.
3866 *
3867 * Default: -1 (to use default stream settings, currently 240 msec)
3868 */
3869 int jb_max_pre;
3870
3871 /**
3872 * Set maximum delay that can be accomodated by the jitter buffer msec.
3873 *
3874 * Default: -1 (to use default stream settings, currently 360 msec)
3875 */
3876 int jb_max;
3877
Benny Prijonoc97608e2007-03-23 16:34:20 +00003878 /**
3879 * Enable ICE
3880 */
3881 pj_bool_t enable_ice;
3882
3883 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00003884 * Disable ICE host candidates.
Benny Prijonoc97608e2007-03-23 16:34:20 +00003885 */
Benny Prijonof76e1392008-06-06 14:51:48 +00003886 pj_bool_t ice_no_host_cands;
3887
3888 /**
3889 * Enable TURN relay candidate in ICE.
3890 */
3891 pj_bool_t enable_turn;
3892
3893 /**
3894 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
3895 * "HOST:PORT" format.
3896 */
3897 pj_str_t turn_server;
3898
3899 /**
3900 * Specify the connection type to be used to the TURN server. Valid
3901 * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP.
3902 *
3903 * Default: PJ_TURN_TP_UDP
3904 */
3905 pj_turn_tp_type turn_conn_type;
3906
3907 /**
3908 * Specify the credential to authenticate with the TURN server.
3909 */
3910 pj_stun_auth_cred turn_auth_cred;
Benny Prijono312aff92006-06-17 04:08:30 +00003911};
3912
3913
3914/**
3915 * Use this function to initialize media config.
3916 *
3917 * @param cfg The media config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003918 *
3919 * \par Python:
3920 * \code
3921 media_cfg = py_pjsua.media_config_default()
3922 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003923 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003924PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00003925
3926
3927/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003928 * This structure describes codec information, which can be retrieved by
3929 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00003930 */
3931typedef struct pjsua_codec_info
3932{
3933 /**
3934 * Codec unique identification.
3935 */
3936 pj_str_t codec_id;
3937
3938 /**
3939 * Codec priority (integer 0-255).
3940 */
3941 pj_uint8_t priority;
3942
3943 /**
3944 * Internal buffer.
3945 */
3946 char buf_[32];
3947
3948} pjsua_codec_info;
3949
3950
3951/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003952 * This structure descibes information about a particular media port that
3953 * has been registered into the conference bridge. Application can query
3954 * this info by calling #pjsua_conf_get_port_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003955 *
3956 * \par Python:
3957 * In Python, this type is <tt>py_pjsua.Conf_Port_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003958 */
3959typedef struct pjsua_conf_port_info
3960{
3961 /** Conference port number. */
3962 pjsua_conf_port_id slot_id;
3963
3964 /** Port name. */
3965 pj_str_t name;
3966
3967 /** Clock rate. */
3968 unsigned clock_rate;
3969
3970 /** Number of channels. */
3971 unsigned channel_count;
3972
3973 /** Samples per frame */
3974 unsigned samples_per_frame;
3975
3976 /** Bits per sample */
3977 unsigned bits_per_sample;
3978
3979 /** Number of listeners in the array. */
3980 unsigned listener_cnt;
3981
3982 /** Array of listeners (in other words, ports where this port is
3983 * transmitting to.
3984 */
3985 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
3986
3987} pjsua_conf_port_info;
3988
3989
3990/**
3991 * This structure holds information about custom media transport to
3992 * be registered to pjsua.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003993 *
3994 * \par Python:
3995 * Not applicable.
Benny Prijono312aff92006-06-17 04:08:30 +00003996 */
3997typedef struct pjsua_media_transport
3998{
3999 /**
4000 * Media socket information containing the address information
4001 * of the RTP and RTCP socket.
4002 */
4003 pjmedia_sock_info skinfo;
4004
4005 /**
4006 * The media transport instance.
4007 */
4008 pjmedia_transport *transport;
4009
4010} pjsua_media_transport;
4011
4012
4013
4014
Benny Prijono9fc735d2006-05-28 14:58:12 +00004015/**
4016 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004017 *
4018 * @return Maximum number of ports in the conference bridge.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004019 *
4020 * \par Python:
4021 * \code
4022 port_count = py_pjsua.conf_get_max_ports()
4023 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004024 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004025PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004026
4027
4028/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004029 * Get current number of active ports in the bridge.
4030 *
4031 * @return The number.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004032 *
4033 * \par Python:
4034 * \code
4035 count = py_pjsua.conf_get_active_ports()
4036 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004037 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004038PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
4039
4040
4041/**
4042 * Enumerate all conference ports.
4043 *
4044 * @param id Array of conference port ID to be initialized.
4045 * @param count On input, specifies max elements in the array.
4046 * On return, it contains actual number of elements
4047 * that have been initialized.
4048 *
4049 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004050 *
4051 * \par Python:
4052 * The Python functions returns list of conference port Ids:
4053 * \code
4054 [port_ids] = py_pjsua.enum_conf_ports()
4055 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004056 */
4057PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
4058 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004059
4060
4061/**
4062 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004063 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004064 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004065 * @param info Pointer to store the port info.
4066 *
4067 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004068 *
4069 * \par Python:
4070 * \code
4071 port_info = py_pjsua.conf_get_port_info(port_id)
4072 * \endcode
4073 * The function will return None if \a port_id is not valid.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004074 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004075PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00004076 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004077
4078
4079/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00004080 * Add arbitrary media port to PJSUA's conference bridge. Application
4081 * can use this function to add the media port that it creates. For
4082 * media ports that are created by PJSUA-LIB (such as calls, file player,
4083 * or file recorder), PJSUA-LIB will automatically add the port to
4084 * the bridge.
4085 *
4086 * @param pool Pool to use.
4087 * @param port Media port to be added to the bridge.
4088 * @param p_id Optional pointer to receive the conference
4089 * slot id.
4090 *
4091 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004092 *
4093 * \par Python:
4094 * Not applicable (for now)
Benny Prijonoe909eac2006-07-27 22:04:56 +00004095 */
4096PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
4097 pjmedia_port *port,
4098 pjsua_conf_port_id *p_id);
4099
4100
4101/**
4102 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00004103 * call this function if it registered the port manually with previous call
4104 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00004105 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004106 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00004107 *
4108 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004109 *
4110 * \par Python:
4111 * \code
4112 status = py_pjsua.conf_remove_port(port_id)
4113 * \endcode
Benny Prijonoe909eac2006-07-27 22:04:56 +00004114 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004115PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00004116
4117
4118/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004119 * Establish unidirectional media flow from souce to sink. One source
4120 * may transmit to multiple destinations/sink. And if multiple
4121 * sources are transmitting to the same sink, the media will be mixed
4122 * together. Source and sink may refer to the same ID, effectively
4123 * looping the media.
4124 *
4125 * If bidirectional media flow is desired, application needs to call
4126 * this function twice, with the second one having the arguments
4127 * reversed.
4128 *
4129 * @param source Port ID of the source media/transmitter.
4130 * @param sink Port ID of the destination media/received.
4131 *
4132 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004133 *
4134 * \par Python:
4135 * \code
4136 status = py_pjsua.conf_connect(source, sink)
4137 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004138 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004139PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
4140 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004141
4142
4143/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004144 * Disconnect media flow from the source to destination port.
4145 *
4146 * @param source Port ID of the source media/transmitter.
4147 * @param sink Port ID of the destination media/received.
4148 *
4149 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004150 *
4151 * \par Python:
4152 * \code
4153 status = py_pjsua.conf_disconnect(source, sink)
4154 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004155 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004156PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
4157 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004158
4159
Benny Prijono6dd967c2006-12-26 02:27:14 +00004160/**
4161 * Adjust the signal level to be transmitted from the bridge to the
4162 * specified port by making it louder or quieter.
4163 *
4164 * @param slot The conference bridge slot number.
4165 * @param level Signal level adjustment. Value 1.0 means no level
4166 * adjustment, while value 0 means to mute the port.
4167 *
4168 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004169 *
4170 * \par Python:
4171 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004172 */
4173PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
4174 float level);
4175
4176/**
4177 * Adjust the signal level to be received from the specified port (to
4178 * the bridge) by making it louder or quieter.
4179 *
4180 * @param slot The conference bridge slot number.
4181 * @param level Signal level adjustment. Value 1.0 means no level
4182 * adjustment, while value 0 means to mute the port.
4183 *
4184 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004185 *
4186 * \par Python:
4187 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004188 */
4189PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
4190 float level);
4191
4192/**
4193 * Get last signal level transmitted to or received from the specified port.
4194 * The signal level is an integer value in zero to 255, with zero indicates
4195 * no signal, and 255 indicates the loudest signal level.
4196 *
4197 * @param slot The conference bridge slot number.
4198 * @param tx_level Optional argument to receive the level of signal
4199 * transmitted to the specified port (i.e. the direction
4200 * is from the bridge to the port).
4201 * @param rx_level Optional argument to receive the level of signal
4202 * received from the port (i.e. the direction is from the
4203 * port to the bridge).
4204 *
4205 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004206 *
4207 * \par Python:
4208 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004209 */
4210PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
4211 unsigned *tx_level,
4212 unsigned *rx_level);
4213
Benny Prijono6dd967c2006-12-26 02:27:14 +00004214
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004215/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00004216 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004217 */
4218
Benny Prijono9fc735d2006-05-28 14:58:12 +00004219/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004220 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004221 * the conference bridge.
4222 *
4223 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00004224 * WAV files are supported, and the WAV file MUST be
4225 * formatted as 16bit PCM mono/single channel (any
4226 * clock rate is supported).
Benny Prijono58add7c2008-01-18 13:24:07 +00004227 * @param options Optional option flag. Application may specify
4228 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004229 * @param p_id Pointer to receive player ID.
4230 *
4231 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004232 *
4233 * \par Python:
4234 * The function returns (status, id) tuple:
4235 * \code
4236 status, id = py_pjsua.player_create(filename, options)
4237 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004238 */
4239PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004240 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004241 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004242
4243
4244/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004245 * Create a file playlist media port, and automatically add the port
4246 * to the conference bridge.
4247 *
4248 * @param file_names Array of file names to be added to the play list.
4249 * Note that the files must have the same clock rate,
4250 * number of channels, and number of bits per sample.
4251 * @param file_count Number of files in the array.
4252 * @param label Optional label to be set for the media port.
4253 * @param options Optional option flag. Application may specify
4254 * PJMEDIA_FILE_NO_LOOP to prevent looping.
4255 * @param p_id Optional pointer to receive player ID.
4256 *
4257 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004258 *
4259 * \par Python:
4260 * Not implemented yet.
Benny Prijonoa66c3312007-01-21 23:12:40 +00004261 */
4262PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
4263 unsigned file_count,
4264 const pj_str_t *label,
4265 unsigned options,
4266 pjsua_player_id *p_id);
4267
4268/**
4269 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004270 *
4271 * @param id The file player ID.
4272 *
4273 * @return Conference port ID associated with this player.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004274 *
4275 * \par Python:
4276 * \code
4277 port_id = py_pjsua.player_get_conf_port(id)
4278 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004279 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004280PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004281
4282
4283/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004284 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00004285 *
4286 * @param id The player ID.
4287 * @param p_port The media port associated with the player.
4288 *
4289 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004290 *
4291 * \par Python:
4292 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004293 */
Benny Prijono58add7c2008-01-18 13:24:07 +00004294PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
Benny Prijono469b1522006-12-26 03:05:17 +00004295 pjmedia_port **p_port);
4296
4297/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004298 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004299 *
4300 * @param id The file player ID.
4301 * @param samples The playback position, in samples. Application can
4302 * specify zero to re-start the playback.
4303 *
4304 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004305 *
4306 * \par Python:
4307 * \code
4308 status = py_pjsua.player_set_pos(id, samples)
4309 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004310 */
4311PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
4312 pj_uint32_t samples);
4313
4314
4315/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004316 * Close the file of playlist, remove the player from the bridge, and free
4317 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004318 *
4319 * @param id The file player ID.
4320 *
4321 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004322 *
4323 * \par Python:
4324 * \code
4325 status = py_pjsua.player_destroy(id)
4326 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004327 */
4328PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
4329
4330
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004331/*****************************************************************************
4332 * File recorder.
4333 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00004334
4335/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004336 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004337 * the conference bridge. The recorder currently supports recording WAV file.
4338 * The type of the recorder to use is determined by the extension of the file
4339 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004340 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00004341 * @param filename Output file name. The function will determine the
4342 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004343 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00004344 * @param enc_type Optionally specify the type of encoder to be used to
4345 * compress the media, if the file can support different
4346 * encodings. This value must be zero for now.
4347 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004348 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00004349 * For .WAV recorder, this value must be NULL.
4350 * @param max_size Maximum file size. Specify zero or -1 to remove size
4351 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004352 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004353 * @param p_id Pointer to receive the recorder instance.
4354 *
4355 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004356 *
4357 * \par Python:
4358 * \code
4359 status, id = py_pjsua.recorder_create(filename, enc_type, enc_param, max_size, options)
4360 * \endcode
4361 * The \a enc_param is a string in Python.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004362 */
4363PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004364 unsigned enc_type,
4365 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004366 pj_ssize_t max_size,
4367 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004368 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004369
4370
4371/**
4372 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004373 *
4374 * @param id The recorder ID.
4375 *
4376 * @return Conference port ID associated with this recorder.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004377 *
4378 * \par Python:
4379 * \code
4380 port_id = py_pjsua.recorder_get_conf_port(id)
4381 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004382 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004383PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004384
4385
4386/**
Benny Prijono469b1522006-12-26 03:05:17 +00004387 * Get the media port for the recorder.
4388 *
4389 * @param id The recorder ID.
4390 * @param p_port The media port associated with the recorder.
4391 *
4392 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004393 *
4394 * \par Python:
4395 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004396 */
4397PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4398 pjmedia_port **p_port);
4399
4400
4401/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004402 * Destroy recorder (this will complete recording).
4403 *
4404 * @param id The recorder ID.
4405 *
4406 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004407 *
4408 * \par Python:
4409 * \code
4410 status = py_pjsua.recorder_destroy(id)
4411 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004412 */
4413PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4414
4415
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004416/*****************************************************************************
4417 * Sound devices.
4418 */
4419
Benny Prijono9fc735d2006-05-28 14:58:12 +00004420/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004421 * Enum all sound devices installed in the system.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004422 *
4423 * @param info Array of info to be initialized.
4424 * @param count On input, specifies max elements in the array.
4425 * On return, it contains actual number of elements
4426 * that have been initialized.
4427 *
4428 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004429 *
4430 *
4431 * \par Python:
4432 * The function returns list of sound device info:
4433 * \code
4434 [dev_infos] = py_pjsua.enum_snd_devs()
4435 * \endcode
4436 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00004437 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004438PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4439 unsigned *count);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004440
4441
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004442
4443/**
4444 * Get currently active sound devices. If sound devices has not been created
4445 * (for example when pjsua_start() is not called), it is possible that
4446 * the function returns PJ_SUCCESS with -1 as device IDs.
4447 *
4448 * @param capture_dev On return it will be filled with device ID of the
4449 * capture device.
4450 * @param playback_dev On return it will be filled with device ID of the
4451 * device ID of the playback device.
4452 *
4453 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004454 *
4455 * \par Python:
Benny Prijonoebdf8772007-02-01 19:25:50 +00004456 * The function takes no argument and return an (integer,integer) tuple:
Benny Prijonoe6ead542007-01-31 20:53:31 +00004457 * \code
4458 capture_dev, playback_dev = py_pjsua.get_snd_dev()
4459 * \endcode
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004460 */
4461PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4462 int *playback_dev);
4463
4464
Benny Prijono9fc735d2006-05-28 14:58:12 +00004465/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004466 * Select or change sound device. Application may call this function at
4467 * any time to replace current sound device.
4468 *
4469 * @param capture_dev Device ID of the capture device.
4470 * @param playback_dev Device ID of the playback device.
4471 *
4472 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004473 *
4474 * \par Python:
4475 * \code
4476 status = py_pjsua.set_snd_dev(capture_dev, playback_dev)
4477 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004478 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004479PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4480 int playback_dev);
4481
4482
4483/**
4484 * Set pjsua to use null sound device. The null sound device only provides
4485 * the timing needed by the conference bridge, and will not interract with
4486 * any hardware.
4487 *
4488 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004489 *
4490 * \par Python:
4491 * \code
4492 status = py_pjsua.set_null_snd_dev()
4493 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004494 */
4495PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4496
4497
Benny Prijonoe909eac2006-07-27 22:04:56 +00004498/**
4499 * Disconnect the main conference bridge from any sound devices, and let
4500 * application connect the bridge to it's own sound device/master port.
4501 *
4502 * @return The port interface of the conference bridge,
4503 * so that application can connect this to it's own
4504 * sound device or master port.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004505 *
4506 * \par Python:
4507 * Not applicable (for now).
Benny Prijonoe909eac2006-07-27 22:04:56 +00004508 */
4509PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4510
4511
Benny Prijonof20687a2006-08-04 18:27:19 +00004512/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004513 * Configure the echo canceller tail length of the sound port.
Benny Prijonof20687a2006-08-04 18:27:19 +00004514 *
4515 * @param tail_ms The tail length, in miliseconds. Set to zero to
4516 * disable AEC.
Benny Prijonoa7b376b2008-01-25 16:06:33 +00004517 * @param options Options to be passed to pjmedia_echo_create().
Benny Prijono5da50432006-08-07 10:24:52 +00004518 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004519 *
4520 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004521 *
4522 * \par Python:
4523 * \code
4524 status = py_pjsua.set_ec(tail_ms, options)
4525 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004526 */
Benny Prijono5da50432006-08-07 10:24:52 +00004527PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004528
4529
4530/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004531 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004532 *
4533 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4534 * If AEC is disabled, the value will be zero.
4535 *
4536 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004537 *
4538 * \par Python:
4539 * \code
4540 tail_ms = py_pjsua.get_ec_tail()
4541 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004542 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004543PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004544
4545
4546
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004547/*****************************************************************************
4548 * Codecs.
4549 */
4550
4551/**
4552 * Enum all supported codecs in the system.
4553 *
4554 * @param id Array of ID to be initialized.
4555 * @param count On input, specifies max elements in the array.
4556 * On return, it contains actual number of elements
4557 * that have been initialized.
4558 *
4559 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004560 *
4561 * \par Python:
4562 * This function takes no argument and returns list of codec infos:
4563 * \code
4564 [codec_info] = py_pjsua.enum_codecs()
4565 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004566 */
4567PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4568 unsigned *count );
4569
4570
4571/**
4572 * Change codec priority.
4573 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004574 * @param codec_id Codec ID, which is a string that uniquely identify
4575 * the codec (such as "speex/8000"). Please see pjsua
4576 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004577 * @param priority Codec priority, 0-255, where zero means to disable
4578 * the codec.
4579 *
4580 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004581 *
4582 * \par Python:
4583 * \code
4584 status = py_pjsua.codec_set_priority(codec_id, priority)
4585 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004586 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004587PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004588 pj_uint8_t priority );
4589
4590
4591/**
4592 * Get codec parameters.
4593 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004594 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004595 * @param param Structure to receive codec parameters.
4596 *
4597 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004598 *
4599 * \par Python:
4600 * The Python function is experimental:
4601 * \code
4602 codec_param = py_pjsua.codec_get_param(codec_id)
4603 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004604 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004605PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004606 pjmedia_codec_param *param );
4607
4608
4609/**
4610 * Set codec parameters.
4611 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004612 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004613 * @param param Codec parameter to set.
4614 *
4615 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004616 *
4617 * \par Python:
4618 * The Python function is experimental:
4619 * \code
4620 status = py_pjsua.codec_set_param(codec_id, param)
4621 * \endcode
4622
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004623 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004624PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004625 const pjmedia_codec_param *param);
4626
4627
4628
Benny Prijono9fc735d2006-05-28 14:58:12 +00004629
Benny Prijono312aff92006-06-17 04:08:30 +00004630/**
4631 * Create UDP media transports for all the calls. This function creates
4632 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00004633 *
Benny Prijono312aff92006-06-17 04:08:30 +00004634 * @param cfg Media transport configuration. The "port" field in the
4635 * configuration is used as the start port to bind the
4636 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004637 *
4638 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004639 *
4640 * \par Python:
4641 * Not implemented yet.
Benny Prijonof3195072006-02-14 21:15:30 +00004642 */
Benny Prijono312aff92006-06-17 04:08:30 +00004643PJ_DECL(pj_status_t)
4644pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00004645
Benny Prijonodc39fe82006-05-26 12:17:46 +00004646
4647/**
Benny Prijono312aff92006-06-17 04:08:30 +00004648 * Register custom media transports to be used by calls. There must
4649 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004650 *
Benny Prijono312aff92006-06-17 04:08:30 +00004651 * @param tp The media transport array.
4652 * @param count Number of elements in the array. This number MUST
4653 * match the number of maximum calls configured when
4654 * pjsua is created.
4655 * @param auto_delete Flag to indicate whether the transports should be
4656 * destroyed when pjsua is shutdown.
4657 *
4658 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004659 *
4660 * \par Python:
4661 * Note applicable.
Benny Prijonodc39fe82006-05-26 12:17:46 +00004662 */
Benny Prijono312aff92006-06-17 04:08:30 +00004663PJ_DECL(pj_status_t)
4664pjsua_media_transports_attach( pjsua_media_transport tp[],
4665 unsigned count,
4666 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00004667
4668
Benny Prijono312aff92006-06-17 04:08:30 +00004669/**
4670 * @}
4671 */
4672
Benny Prijonof3195072006-02-14 21:15:30 +00004673
Benny Prijono268ca612006-02-07 12:34:11 +00004674
Benny Prijono312aff92006-06-17 04:08:30 +00004675/**
4676 * @}
4677 */
4678
Benny Prijonoe6ead542007-01-31 20:53:31 +00004679PJ_END_DECL
4680
Benny Prijono312aff92006-06-17 04:08:30 +00004681
Benny Prijono268ca612006-02-07 12:34:11 +00004682#endif /* __PJSUA_H__ */