blob: cb21ea071d71a4712a7ed52e2dce4bf97932922b [file] [log] [blame]
Benny Prijono268ca612006-02-07 12:34:11 +00001/* $Id$ */
2/*
Benny Prijono844653c2008-12-23 17:27:53 +00003 * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
Benny Prijono32177c02008-06-20 22:44:47 +00004 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
Benny Prijono268ca612006-02-07 12:34:11 +00005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#ifndef __PJSUA_H__
21#define __PJSUA_H__
22
Benny Prijono312aff92006-06-17 04:08:30 +000023/**
24 * @file pjsua.h
25 * @brief PJSUA API.
26 */
27
28
Benny Prijono268ca612006-02-07 12:34:11 +000029/* Include all PJSIP core headers. */
30#include <pjsip.h>
31
32/* Include all PJMEDIA headers. */
33#include <pjmedia.h>
34
Benny Prijono1f9afba2006-02-10 15:57:32 +000035/* Include all PJMEDIA-CODEC headers. */
36#include <pjmedia-codec.h>
37
Benny Prijono268ca612006-02-07 12:34:11 +000038/* Include all PJSIP-UA headers */
39#include <pjsip_ua.h>
40
Benny Prijono834aee32006-02-19 01:38:06 +000041/* Include all PJSIP-SIMPLE headers */
42#include <pjsip_simple.h>
43
Benny Prijono4ab9fbb2007-10-12 12:14:27 +000044/* Include all PJNATH headers */
45#include <pjnath.h>
46
Benny Prijono268ca612006-02-07 12:34:11 +000047/* Include all PJLIB-UTIL headers. */
48#include <pjlib-util.h>
49
50/* Include all PJLIB headers. */
51#include <pjlib.h>
52
53
Benny Prijonoe6ead542007-01-31 20:53:31 +000054PJ_BEGIN_DECL
55
56
Benny Prijono312aff92006-06-17 04:08:30 +000057/**
Benny Prijonoe6ead542007-01-31 20:53:31 +000058 * @defgroup PJSUA_LIB PJSUA API - High Level Softphone API for C/C++ and Python
Benny Prijono312aff92006-06-17 04:08:30 +000059 * @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
Benny Prijono63fba012008-07-17 14:19:10 +0000397/** Opaque declaration for server side presence subscription */
398typedef struct pjsua_srv_pres pjsua_srv_pres;
399
400/** Forward declaration for pjsua_msg_data */
401typedef struct pjsua_msg_data pjsua_msg_data;
Benny Prijono8b1889b2006-06-06 18:40:40 +0000402
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000403
Benny Prijonoa91a0032006-02-26 21:23:45 +0000404/**
Benny Prijono312aff92006-06-17 04:08:30 +0000405 * Maximum proxies in account.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000406 */
Benny Prijono312aff92006-06-17 04:08:30 +0000407#ifndef PJSUA_ACC_MAX_PROXIES
408# define PJSUA_ACC_MAX_PROXIES 8
409#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000410
Benny Prijonod8179652008-01-23 20:39:07 +0000411#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000412
Benny Prijonod8179652008-01-23 20:39:07 +0000413/**
414 * Default value of SRTP mode usage. Valid values are PJMEDIA_SRTP_DISABLED,
415 * PJMEDIA_SRTP_OPTIONAL, and PJMEDIA_SRTP_MANDATORY.
416 */
417#ifndef PJSUA_DEFAULT_USE_SRTP
418 #define PJSUA_DEFAULT_USE_SRTP PJMEDIA_SRTP_DISABLED
419#endif
420
421/**
422 * Default value of secure signaling requirement for SRTP.
423 * Valid values are:
424 * 0: SRTP does not require secure signaling
425 * 1: SRTP requires secure transport such as TLS
426 * 2: SRTP requires secure end-to-end transport (SIPS)
427 */
428#ifndef PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
429 #define PJSUA_DEFAULT_SRTP_SECURE_SIGNALING 1
430#endif
431
432#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000433
434/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000435 * Logging configuration, which can be (optionally) specified when calling
436 * #pjsua_init(). Application must call #pjsua_logging_config_default() to
437 * initialize this structure with the default values.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000438 *
439 * \par Sample Python Syntax:
440 * \code
441 # Python type: py_pjsua.Logging_Config
442
443 log_cfg = py_pjsua.logging_config_default()
444 log_cfg.level = 4
445 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000446 */
447typedef struct pjsua_logging_config
448{
449 /**
450 * Log incoming and outgoing SIP message? Yes!
451 */
452 pj_bool_t msg_logging;
453
454 /**
455 * Input verbosity level. Value 5 is reasonable.
456 */
457 unsigned level;
458
459 /**
460 * Verbosity level for console. Value 4 is reasonable.
461 */
462 unsigned console_level;
463
464 /**
465 * Log decoration.
466 */
467 unsigned decor;
468
469 /**
470 * Optional log filename.
471 */
472 pj_str_t log_filename;
473
474 /**
Benny Prijonodbe3f4b2009-05-07 16:56:04 +0000475 * Additional flags to be given to #pj_file_open() when opening
476 * the log file. By default, the flag is PJ_O_WRONLY. Application
477 * may set PJ_O_APPEND here so that logs are appended to existing
478 * file instead of overwriting it.
479 *
480 * Default is 0.
481 */
482 unsigned log_file_flags;
483
484 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000485 * Optional callback function to be called to write log to
486 * application specific device. This function will be called for
487 * log messages on input verbosity level.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000488 *
489 * \par Sample Python Syntax:
490 * \code
491 # level: integer
492 # data: string
493 # len: integer
494
495 def cb(level, data, len):
496 print data,
497 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000498 */
Benny Prijonofe7d87b2007-11-29 11:35:44 +0000499 void (*cb)(int level, const char *data, int len);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000500
501
502} pjsua_logging_config;
503
504
505/**
506 * Use this function to initialize logging config.
507 *
508 * @param cfg The logging config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000509 *
510 * \par Python Syntax:
511 * The Python function instantiates and initialize the logging config:
512 * \code
513 logging_cfg = py_pjsua.logging_config_default()
514 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000515 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000516PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000517
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000518
519/**
520 * Use this function to duplicate logging config.
521 *
522 * @param pool Pool to use.
523 * @param dst Destination config.
524 * @param src Source config.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000525 *
526 * \par Python Syntax:
527 * Not available (for now). Ideally we should be able to just assign
528 * one config to another, but this has not been tested.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000529 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000530PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool,
531 pjsua_logging_config *dst,
532 const pjsua_logging_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000533
Benny Prijonodc39fe82006-05-26 12:17:46 +0000534
535/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000536 * This structure describes application callback to receive various event
537 * notification from PJSUA-API. All of these callbacks are OPTIONAL,
538 * although definitely application would want to implement some of
539 * the important callbacks (such as \a on_incoming_call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000540 *
541 * \par Python Syntax:
542 * This callback structure is embedded on pjsua_config structure.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000543 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000544typedef struct pjsua_callback
Benny Prijonodc39fe82006-05-26 12:17:46 +0000545{
546 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000547 * Notify application when invite state has changed.
548 * Application may then query the call info to get the
Benny Prijonoe6ead542007-01-31 20:53:31 +0000549 * detail call states by calling pjsua_call_get_info() function.
Benny Prijono0875ae82006-12-26 00:11:48 +0000550 *
551 * @param call_id The call index.
552 * @param e Event which causes the call state to change.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000553 *
554 * \par Python Syntax:
555 * \code
556 # call_id: integer
557 # e: an opaque object
558
559 def on_call_state(call_id, e):
560 return
561 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000562 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000563 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000564
565 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000566 * Notify application on incoming call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000567 *
568 * @param acc_id The account which match the incoming call.
569 * @param call_id The call id that has just been created for
570 * the call.
571 * @param rdata The incoming INVITE request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000572 *
573 * \par Python Syntax:
574 * \code
575 # acc_id: integer
576 # call_id: integer
577 # rdata: an opaque object
578
579 def on_incoming_call(acc_id, call_id, rdata):
580 return
581 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +0000582 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000583 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000584 pjsip_rx_data *rdata);
585
586 /**
Benny Prijonofeb69f42007-10-05 09:12:26 +0000587 * This is a general notification callback which is called whenever
588 * a transaction within the call has changed state. Application can
589 * implement this callback for example to monitor the state of
590 * outgoing requests, or to answer unhandled incoming requests
591 * (such as INFO) with a final response.
592 *
593 * @param call_id Call identification.
594 * @param tsx The transaction which has changed state.
595 * @param e Transaction event that caused the state change.
596 */
597 void (*on_call_tsx_state)(pjsua_call_id call_id,
598 pjsip_transaction *tsx,
599 pjsip_event *e);
600
601 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000602 * Notify application when media state in the call has changed.
603 * Normal application would need to implement this callback, e.g.
Benny Prijono6ba8c542007-10-16 01:34:14 +0000604 * to connect the call's media to sound device. When ICE is used,
605 * this callback will also be called to report ICE negotiation
606 * failure.
Benny Prijono0875ae82006-12-26 00:11:48 +0000607 *
608 * @param call_id The call index.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000609 *
610 * \par Python Syntax:
611 * \code
612 # call_id: integer
613
614 def on_call_media_state(call_id):
615 return
616 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000617 */
618 void (*on_call_media_state)(pjsua_call_id call_id);
619
Benny Prijonofc13bf62008-02-20 08:56:15 +0000620
621 /**
622 * Notify application when media session is created and before it is
623 * registered to the conference bridge. Application may return different
624 * media port if it has added media processing port to the stream. This
625 * media port then will be added to the conference bridge instead.
626 *
627 * @param call_id Call identification.
628 * @param sess Media session for the call.
629 * @param stream_idx Stream index in the media session.
630 * @param p_port On input, it specifies the media port of the
631 * stream. Application may modify this pointer to
632 * point to different media port to be registered
633 * to the conference bridge.
634 *
635 * \par Python:
636 * Not applicable.
637 */
638 void (*on_stream_created)(pjsua_call_id call_id,
639 pjmedia_session *sess,
640 unsigned stream_idx,
641 pjmedia_port **p_port);
642
643 /**
644 * Notify application when media session has been unregistered from the
645 * conference bridge and about to be destroyed.
646 *
647 * @param call_id Call identification.
648 * @param sess Media session for the call.
649 * @param stream_idx Stream index in the media session.
650 *
651 * \par Python:
652 * Not applicable.
653 */
654 void (*on_stream_destroyed)(pjsua_call_id call_id,
655 pjmedia_session *sess,
656 unsigned stream_idx);
657
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000658 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000659 * Notify application upon incoming DTMF digits.
660 *
661 * @param call_id The call index.
662 * @param digit DTMF ASCII digit.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000663 *
664 * \par Python Syntax:
665 * \code
666 # call_id: integer
Benny Prijono1f63cc42007-09-10 16:54:22 +0000667 # digit: digit string
Benny Prijonoe6ead542007-01-31 20:53:31 +0000668
669 def on_dtmf_digit(call_id, digit):
670 return
671 * \endcode
Benny Prijono0875ae82006-12-26 00:11:48 +0000672 */
673 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
674
675 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000676 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000677 * Application can decide to accept/reject transfer request
Benny Prijonoc54dcb32008-04-08 23:33:15 +0000678 * by setting the code (default is 202). When this callback
Benny Prijono9fc735d2006-05-28 14:58:12 +0000679 * is not defined, the default behavior is to accept the
680 * transfer.
Benny Prijono0875ae82006-12-26 00:11:48 +0000681 *
682 * @param call_id The call index.
683 * @param dst The destination where the call will be
684 * transfered to.
685 * @param code Status code to be returned for the call transfer
686 * request. On input, it contains status code 200.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000687 *
688 * \par Python Syntax:
689 * \code
690 # call_id: integer
691 # dst: string
692 # code: integer
693
694 def on_call_transfer_request(call_id, dst, code):
695 return code
696
697 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000698 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000699 void (*on_call_transfer_request)(pjsua_call_id call_id,
700 const pj_str_t *dst,
701 pjsip_status_code *code);
702
703 /**
704 * Notify application of the status of previously sent call
705 * transfer request. Application can monitor the status of the
706 * call transfer request, for example to decide whether to
707 * terminate existing call.
708 *
709 * @param call_id Call ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000710 * @param st_code Status progress of the transfer request.
711 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000712 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000713 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000714 * this callback is the final status.
715 * @param p_cont Initially will be set to non-zero, application
716 * can set this to FALSE if it no longer wants
717 * to receie further notification (for example,
718 * after it hangs up the call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000719 *
720 * \par Python Syntax:
721 * \code
722 # call_id: integer
723 # st_code: integer
724 # st_text: string
725 # final: integer
726 # cont: integer
727
728 # return: cont
729
730 def on_call_transfer_status(call_id, st_code, st_text, final, cont):
731 return cont
732 * \endcode
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000733 */
734 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000735 int st_code,
736 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000737 pj_bool_t final,
738 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000739
740 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000741 * Notify application about incoming INVITE with Replaces header.
742 * Application may reject the request by setting non-2xx code.
743 *
744 * @param call_id The call ID to be replaced.
745 * @param rdata The incoming INVITE request to replace the call.
746 * @param st_code Status code to be set by application. Application
747 * should only return a final status (200-699).
748 * @param st_text Optional status text to be set by application.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000749 *
750 * \par Python Syntax:
751 * \code
752 # call_id: integer
753 # rdata: an opaque object
754 # st_code: integer
755 # st_text: string
756
757 # return: (st_code, st_text) tuple
758
759 def on_call_replace_request(call_id, rdata, st_code, st_text):
760 return st_code, st_text
761 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000762 */
763 void (*on_call_replace_request)(pjsua_call_id call_id,
764 pjsip_rx_data *rdata,
765 int *st_code,
766 pj_str_t *st_text);
767
768 /**
769 * Notify application that an existing call has been replaced with
770 * a new call. This happens when PJSUA-API receives incoming INVITE
771 * request with Replaces header.
772 *
773 * After this callback is called, normally PJSUA-API will disconnect
774 * \a old_call_id and establish \a new_call_id.
775 *
776 * @param old_call_id Existing call which to be replaced with the
777 * new call.
778 * @param new_call_id The new call.
779 * @param rdata The incoming INVITE with Replaces request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000780 *
781 * \par Python Syntax:
782 * \code
783 # old_call_id: integer
784 # new_call_id: integer
785
786 def on_call_replaced(old_call_id, new_call_id):
787 return
788 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000789 */
790 void (*on_call_replaced)(pjsua_call_id old_call_id,
791 pjsua_call_id new_call_id);
792
793
794 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000795 * Notify application when registration status has changed.
796 * Application may then query the account info to get the
797 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000798 *
799 * @param acc_id Account ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000800 *
801 * \par Python Syntax:
802 * \code
803 # acc_id: account ID (integer)
804
805 def on_reg_state(acc_id):
806 return
807 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000808 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000809 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000810
811 /**
Benny Prijono63fba012008-07-17 14:19:10 +0000812 * Notification when incoming SUBSCRIBE request is received. Application
813 * may use this callback to authorize the incoming subscribe request
814 * (e.g. ask user permission if the request should be granted).
815 *
816 * If this callback is not implemented, all incoming presence subscription
817 * requests will be accepted.
818 *
819 * If this callback is implemented, application has several choices on
820 * what to do with the incoming request:
821 * - it may reject the request immediately by specifying non-200 class
822 * final response in the \a code argument.
823 * - it may immediately accept the request by specifying 200 as the
824 * \a code argument. This is the default value if application doesn't
825 * set any value to the \a code argument. In this case, the library
826 * will automatically send NOTIFY request upon returning from this
827 * callback.
828 * - it may delay the processing of the request, for example to request
829 * user permission whether to accept or reject the request. In this
830 * case, the application MUST set the \a code argument to 202, and
831 * later calls #pjsua_pres_notify() to accept or reject the
832 * subscription request.
833 *
834 * Any \a code other than 200 and 202 will be treated as 200.
835 *
836 * Application MUST return from this callback immediately (e.g. it must
837 * not block in this callback while waiting for user confirmation).
838 *
839 * @param srv_pres Server presence subscription instance. If
840 * application delays the acceptance of the request,
841 * it will need to specify this object when calling
842 * #pjsua_pres_notify().
843 * @param acc_id Account ID most appropriate for this request.
844 * @param buddy_id ID of the buddy matching the sender of the
845 * request, if any, or PJSUA_INVALID_ID if no
846 * matching buddy is found.
847 * @param from The From URI of the request.
848 * @param rdata The incoming request.
849 * @param code The status code to respond to the request. The
850 * default value is 200. Application may set this
851 * to other final status code to accept or reject
852 * the request.
853 * @param reason The reason phrase to respond to the request.
854 * @param msg_data If the application wants to send additional
855 * headers in the response, it can put it in this
856 * parameter.
857 */
858 void (*on_incoming_subscribe)(pjsua_acc_id acc_id,
859 pjsua_srv_pres *srv_pres,
860 pjsua_buddy_id buddy_id,
861 const pj_str_t *from,
862 pjsip_rx_data *rdata,
863 pjsip_status_code *code,
864 pj_str_t *reason,
865 pjsua_msg_data *msg_data);
866
867 /**
868 * Notification when server side subscription state has changed.
869 * This callback is optional as application normally does not need
870 * to do anything to maintain server side presence subscription.
871 *
872 * @param acc_id The account ID.
873 * @param srv_pres Server presence subscription object.
874 * @param remote_uri Remote URI string.
875 * @param state New subscription state.
876 * @param event PJSIP event that triggers the state change.
877 */
878 void (*on_srv_subscribe_state)(pjsua_acc_id acc_id,
879 pjsua_srv_pres *srv_pres,
880 const pj_str_t *remote_uri,
881 pjsip_evsub_state state,
882 pjsip_event *event);
883
884 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000885 * Notify application when the buddy state has changed.
886 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000887 *
888 * @param buddy_id The buddy id.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000889 *
890 * \par Python Syntax:
891 * \code
892 # buddy_id: integer
893
894 def on_buddy_state(buddy_id):
895 return
896 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000897 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000898 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000899
900 /**
901 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000902 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000903 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000904 *
Benny Prijonobbeb3992007-05-21 13:48:35 +0000905 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
906 * passed as one of the argument.
907 *
Benny Prijono0875ae82006-12-26 00:11:48 +0000908 * @param call_id Containts the ID of the call where the IM was
909 * sent, or PJSUA_INVALID_ID if the IM was sent
910 * outside call context.
911 * @param from URI of the sender.
912 * @param to URI of the destination message.
913 * @param contact The Contact URI of the sender, if present.
914 * @param mime_type MIME type of the message.
915 * @param body The message content.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000916 *
917 * \par Python Syntax:
918 * \code
919 # call_id: integer
920 # from: string
921 # to: string
922 # contact: string
923 # mime_type: string
924 # body: string
Benny Prijonoba736c42008-07-10 20:45:03 +0000925 # acc_id: integer
Benny Prijonoe6ead542007-01-31 20:53:31 +0000926
927 def on_pager(call_id, from, to, contact, mime_type, body):
928 return
929 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000930 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000931 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
932 const pj_str_t *to, const pj_str_t *contact,
933 const pj_str_t *mime_type, const pj_str_t *body);
934
935 /**
Benny Prijonobbeb3992007-05-21 13:48:35 +0000936 * This is the alternative version of the \a on_pager() callback with
937 * \a pjsip_rx_data argument.
938 *
939 * @param call_id Containts the ID of the call where the IM was
940 * sent, or PJSUA_INVALID_ID if the IM was sent
941 * outside call context.
942 * @param from URI of the sender.
943 * @param to URI of the destination message.
944 * @param contact The Contact URI of the sender, if present.
945 * @param mime_type MIME type of the message.
946 * @param body The message content.
947 * @param rdata The incoming MESSAGE request.
Benny Prijonoba736c42008-07-10 20:45:03 +0000948 * @param acc_id Account ID most suitable for this message.
Benny Prijonobbeb3992007-05-21 13:48:35 +0000949 */
950 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
951 const pj_str_t *to, const pj_str_t *contact,
952 const pj_str_t *mime_type, const pj_str_t *body,
Benny Prijonoba736c42008-07-10 20:45:03 +0000953 pjsip_rx_data *rdata, pjsua_acc_id acc_id);
Benny Prijonobbeb3992007-05-21 13:48:35 +0000954
955 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000956 * Notify application about the delivery status of outgoing pager
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000957 * request. See also on_pager_status2() callback for the version with
958 * \a pjsip_rx_data in the argument list.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000959 *
960 * @param call_id Containts the ID of the call where the IM was
961 * sent, or PJSUA_INVALID_ID if the IM was sent
962 * outside call context.
963 * @param to Destination URI.
964 * @param body Message body.
965 * @param user_data Arbitrary data that was specified when sending
966 * IM message.
967 * @param status Delivery status.
968 * @param reason Delivery status reason.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000969 *
970 * \par Python Syntax
971 * \code
972 # call_id: integer
973 # to: string
974 # body: string
975 # user_data: string
976 # status: integer
977 # reason: string
Benny Prijonoba736c42008-07-10 20:45:03 +0000978 # acc_id: integer
Benny Prijonoe6ead542007-01-31 20:53:31 +0000979
980 def on_pager_status(call_id, to, body, user_data, status, reason):
981 return
982 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000983 */
984 void (*on_pager_status)(pjsua_call_id call_id,
985 const pj_str_t *to,
986 const pj_str_t *body,
987 void *user_data,
988 pjsip_status_code status,
989 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000990
991 /**
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000992 * Notify application about the delivery status of outgoing pager
993 * request.
994 *
995 * @param call_id Containts the ID of the call where the IM was
996 * sent, or PJSUA_INVALID_ID if the IM was sent
997 * outside call context.
998 * @param to Destination URI.
999 * @param body Message body.
1000 * @param user_data Arbitrary data that was specified when sending
1001 * IM message.
1002 * @param status Delivery status.
1003 * @param reason Delivery status reason.
Benny Prijono0a982002007-06-12 16:22:09 +00001004 * @param tdata The original MESSAGE request.
Benny Prijono4da0b1d2007-06-11 18:22:54 +00001005 * @param rdata The incoming MESSAGE response, or NULL if the
1006 * message transaction fails because of time out
1007 * or transport error.
Benny Prijonoba736c42008-07-10 20:45:03 +00001008 * @param acc_id Account ID from this the instant message was
1009 * send.
Benny Prijono4da0b1d2007-06-11 18:22:54 +00001010 */
1011 void (*on_pager_status2)(pjsua_call_id call_id,
1012 const pj_str_t *to,
1013 const pj_str_t *body,
1014 void *user_data,
1015 pjsip_status_code status,
1016 const pj_str_t *reason,
Benny Prijono0a982002007-06-12 16:22:09 +00001017 pjsip_tx_data *tdata,
Benny Prijonoba736c42008-07-10 20:45:03 +00001018 pjsip_rx_data *rdata,
1019 pjsua_acc_id acc_id);
Benny Prijono4da0b1d2007-06-11 18:22:54 +00001020
1021 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +00001022 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +00001023 *
1024 * @param call_id Containts the ID of the call where the IM was
1025 * sent, or PJSUA_INVALID_ID if the IM was sent
1026 * outside call context.
1027 * @param from URI of the sender.
1028 * @param to URI of the destination message.
1029 * @param contact The Contact URI of the sender, if present.
1030 * @param is_typing Non-zero if peer is typing, or zero if peer
1031 * has stopped typing a message.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001032 *
1033 * \par Python Syntax
1034 * \code
1035 # call_id: string
1036 # from: string
1037 # to: string
1038 # contact: string
1039 # is_typing: integer
1040
1041 def on_typing(call_id, from, to, contact, is_typing):
1042 return
1043 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001044 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001045 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
1046 const pj_str_t *to, const pj_str_t *contact,
1047 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +00001048
Benny Prijono6ba8c542007-10-16 01:34:14 +00001049 /**
Benny Prijonoba736c42008-07-10 20:45:03 +00001050 * Notify application about typing indication.
1051 *
1052 * @param call_id Containts the ID of the call where the IM was
1053 * sent, or PJSUA_INVALID_ID if the IM was sent
1054 * outside call context.
1055 * @param from URI of the sender.
1056 * @param to URI of the destination message.
1057 * @param contact The Contact URI of the sender, if present.
1058 * @param is_typing Non-zero if peer is typing, or zero if peer
1059 * has stopped typing a message.
1060 * @param rdata The received request.
1061 * @param acc_id Account ID most suitable for this message.
1062 */
1063 void (*on_typing2)(pjsua_call_id call_id, const pj_str_t *from,
1064 const pj_str_t *to, const pj_str_t *contact,
1065 pj_bool_t is_typing, pjsip_rx_data *rdata,
1066 pjsua_acc_id acc_id);
1067
1068 /**
Benny Prijono6ba8c542007-10-16 01:34:14 +00001069 * Callback when the library has finished performing NAT type
1070 * detection.
1071 *
1072 * @param res NAT detection result.
1073 */
1074 void (*on_nat_detect)(const pj_stun_nat_detect_result *res);
1075
Benny Prijono5e51a4e2008-11-27 00:06:46 +00001076 /**
1077 * This callback is called when the call is about to resend the
1078 * INVITE request to the specified target, following the previously
1079 * received redirection response.
1080 *
1081 * Application may accept the redirection to the specified target
1082 * (the default behavior if this callback is implemented), reject
1083 * this target only and make the session continue to try the next
1084 * target in the list if such target exists, stop the whole
1085 * redirection process altogether and cause the session to be
1086 * disconnected, or defer the decision to ask for user confirmation.
1087 *
1088 * This callback is optional. If this callback is not implemented,
1089 * the default behavior is to NOT follow the redirection response.
1090 *
1091 * @param call_id The call ID.
1092 * @param target The current target to be tried.
Benny Prijono08a48b82008-11-27 12:42:07 +00001093 * @param e The event that caused this callback to be called.
1094 * This could be the receipt of 3xx response, or
1095 * 4xx/5xx response received for the INVITE sent to
1096 * subsequent targets, or NULL if this callback is
1097 * called from within #pjsua_call_process_redirect()
1098 * context.
1099 *
1100 * @return Action to be performed for the target. Set this
Benny Prijono5e51a4e2008-11-27 00:06:46 +00001101 * parameter to one of the value below:
1102 * - PJSIP_REDIRECT_ACCEPT: immediately accept the
1103 * redirection (default value). When set, the
1104 * call will immediately resend INVITE request
1105 * to the target.
1106 * - PJSIP_REDIRECT_REJECT: immediately reject this
1107 * target. The call will continue retrying with
1108 * next target if present, or disconnect the call
1109 * if there is no more target to try.
1110 * - PJSIP_REDIRECT_STOP: stop the whole redirection
1111 * process and immediately disconnect the call. The
1112 * on_call_state() callback will be called with
1113 * PJSIP_INV_STATE_DISCONNECTED state immediately
1114 * after this callback returns.
1115 * - PJSIP_REDIRECT_PENDING: set to this value if
1116 * no decision can be made immediately (for example
1117 * to request confirmation from user). Application
1118 * then MUST call #pjsua_call_process_redirect()
1119 * to either accept or reject the redirection upon
1120 * getting user decision.
Benny Prijono5e51a4e2008-11-27 00:06:46 +00001121 */
Benny Prijono08a48b82008-11-27 12:42:07 +00001122 pjsip_redirect_op (*on_call_redirected)(pjsua_call_id call_id,
1123 const pjsip_uri *target,
1124 const pjsip_event *e);
Benny Prijono5e51a4e2008-11-27 00:06:46 +00001125
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001126} pjsua_callback;
1127
1128
1129
Benny Prijonodc39fe82006-05-26 12:17:46 +00001130
1131/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001132 * This structure describes the settings to control the API and
1133 * user agent behavior, and can be specified when calling #pjsua_init().
1134 * Before setting the values, application must call #pjsua_config_default()
1135 * to initialize this structure with the default values.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001136 *
1137 * \par Python Sample Syntax:
1138 * The pjsua_config type in Python is <tt>py_pjsua.Config</tt>. Application
1139 * creates the instance by calling <tt>py_pjsua.config_default()</tt>:
1140 * \code
1141 cfg = py_pjsua.config_default()
1142 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001143 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001144typedef struct pjsua_config
1145{
1146
1147 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001148 * Maximum calls to support (default: 4). The value specified here
1149 * must be smaller than the compile time maximum settings
1150 * PJSUA_MAX_CALLS, which by default is 32. To increase this
1151 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
1152 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001153 */
1154 unsigned max_calls;
1155
1156 /**
1157 * Number of worker threads. Normally application will want to have at
1158 * least one worker thread, unless when it wants to poll the library
1159 * periodically, which in this case the worker thread can be set to
1160 * zero.
1161 */
1162 unsigned thread_cnt;
1163
1164 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +00001165 * Number of nameservers. If no name server is configured, the SIP SRV
1166 * resolution would be disabled, and domain will be resolved with
1167 * standard pj_gethostbyname() function.
1168 */
1169 unsigned nameserver_count;
1170
1171 /**
1172 * Array of nameservers to be used by the SIP resolver subsystem.
1173 * The order of the name server specifies the priority (first name
1174 * server will be used first, unless it is not reachable).
1175 */
1176 pj_str_t nameserver[4];
1177
1178 /**
Benny Prijono91d06b62008-09-20 12:16:56 +00001179 * Force loose-route to be used in all route/proxy URIs (outbound_proxy
1180 * and account's proxy settings). When this setting is enabled, the
1181 * library will check all the route/proxy URIs specified in the settings
1182 * and append ";lr" parameter to the URI if the parameter is not present.
1183 *
1184 * Default: 1
1185 */
1186 pj_bool_t force_lr;
1187
1188 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001189 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001190 */
1191 unsigned outbound_proxy_cnt;
1192
1193 /**
1194 * Specify the URL of outbound proxies to visit for all outgoing requests.
1195 * The outbound proxies will be used for all accounts, and it will
1196 * be used to build the route set for outgoing requests. The final
1197 * route set for outgoing requests will consists of the outbound proxies
1198 * and the proxy configured in the account.
1199 */
1200 pj_str_t outbound_proxy[4];
1201
Benny Prijonoc97608e2007-03-23 16:34:20 +00001202 /**
Benny Prijonoebbf6892007-03-24 17:37:25 +00001203 * Specify domain name to be resolved with DNS SRV resolution to get the
Benny Prijonof76e1392008-06-06 14:51:48 +00001204 * address of the STUN server. Alternatively application may specify
1205 * \a stun_host instead.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001206 *
1207 * If DNS SRV resolution failed for this domain, then DNS A resolution
1208 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +00001209 */
Benny Prijonoebbf6892007-03-24 17:37:25 +00001210 pj_str_t stun_domain;
1211
1212 /**
Benny Prijonoaf09dc32007-04-22 12:48:30 +00001213 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
1214 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001215 */
1216 pj_str_t stun_host;
1217
1218 /**
Benny Prijono91a6a172007-10-31 08:59:29 +00001219 * Support for adding and parsing NAT type in the SDP to assist
1220 * troubleshooting. The valid values are:
1221 * - 0: no information will be added in SDP, and parsing is disabled.
Benny Prijono6ba8c542007-10-16 01:34:14 +00001222 * - 1: only the NAT type number is added.
1223 * - 2: add both NAT type number and name.
1224 *
Benny Prijono91a6a172007-10-31 08:59:29 +00001225 * Default: 1
Benny Prijono6ba8c542007-10-16 01:34:14 +00001226 */
1227 int nat_type_in_sdp;
1228
1229 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001230 * Specify whether support for reliable provisional response (100rel and
1231 * PRACK) should be required by default. Note that this setting can be
1232 * further customized in account configuration (#pjsua_acc_config).
1233 *
1234 * Default: PJ_FALSE
1235 */
1236 pj_bool_t require_100rel;
1237
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001238 /**
1239 * Number of credentials in the credential array.
1240 */
1241 unsigned cred_count;
1242
1243 /**
1244 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +00001245 * and can be used to authenticate against outbound proxies. If the
1246 * credential is specific to the account, then application should set
1247 * the credential in the pjsua_acc_config rather than the credential
1248 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001249 */
1250 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1251
1252 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001253 * Application callback to receive various event notifications from
1254 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001255 */
1256 pjsua_callback cb;
1257
Benny Prijono56315612006-07-18 14:39:40 +00001258 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001259 * Optional user agent string (default empty). If it's empty, no
1260 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +00001261 */
1262 pj_str_t user_agent;
1263
Benny Prijonod8179652008-01-23 20:39:07 +00001264#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
1265 /**
1266 * Specify default value of secure media transport usage.
1267 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
1268 * PJMEDIA_SRTP_MANDATORY.
1269 *
1270 * Note that this setting can be further customized in account
1271 * configuration (#pjsua_acc_config).
1272 *
1273 * Default: #PJSUA_DEFAULT_USE_SRTP
1274 */
1275 pjmedia_srtp_use use_srtp;
1276
1277 /**
1278 * Specify whether SRTP requires secure signaling to be used. This option
1279 * is only used when \a use_srtp option above is non-zero.
1280 *
1281 * Valid values are:
1282 * 0: SRTP does not require secure signaling
1283 * 1: SRTP requires secure transport such as TLS
1284 * 2: SRTP requires secure end-to-end transport (SIPS)
1285 *
1286 * Note that this setting can be further customized in account
1287 * configuration (#pjsua_acc_config).
1288 *
1289 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
1290 */
1291 int srtp_secure_signaling;
1292#endif
1293
Benny Prijono3c5e28b2008-09-24 10:10:15 +00001294 /**
1295 * Disconnect other call legs when more than one 2xx responses for
1296 * outgoing INVITE are received due to forking. Currently the library
1297 * is not able to handle simultaneous forked media, so disconnecting
1298 * the other call legs is necessary.
1299 *
1300 * With this setting enabled, the library will handle only one of the
1301 * connected call leg, and the other connected call legs will be
1302 * disconnected.
1303 *
1304 * Default: PJ_TRUE (only disable this setting for testing purposes).
1305 */
1306 pj_bool_t hangup_forked_call;
1307
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001308} pjsua_config;
1309
1310
1311/**
1312 * Use this function to initialize pjsua config.
1313 *
1314 * @param cfg pjsua config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001315 *
1316 * \par Python Sample Syntax:
1317 * The corresponding Python function creates an instance of the config and
1318 * initializes it to the default settings:
1319 * \code
1320 cfg = py_pjsua.config_default()
1321 * \endcode
1322
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001323 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001324PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001325
1326
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001327/** The implementation has been moved to sip_auth.h */
Benny Prijono7977f9f2007-10-10 11:37:56 +00001328#define pjsip_cred_dup pjsip_cred_info_dup
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001329
1330
1331/**
1332 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001333 *
1334 * @param pool The pool to get memory from.
1335 * @param dst Destination config.
1336 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001337 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001338PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1339 pjsua_config *dst,
1340 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001341
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001342
1343/**
1344 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001345 * outgoing SIP message. It can (optionally) be specified for example
1346 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1347 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1348 *
1349 * Application MUST call #pjsua_msg_data_init() to initialize this
1350 * structure before setting its values.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001351 *
1352 * \par Python Syntax
1353 * The data type in Python is <tt>py_pjsua.Msg_Data</tt>. Application is
1354 * recommended to instantiate the structure by using this construct:
1355 * \code
1356 msg_data = py_pjsua.msg_data_init()
1357 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001358 */
Benny Prijono63fba012008-07-17 14:19:10 +00001359struct pjsua_msg_data
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001360{
1361 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001362 * Additional message headers as linked list. Application can add
1363 * headers to the list by creating the header, either from the heap/pool
1364 * or from temporary local variable, and add the header using
1365 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001366 *
1367 * \par Python:
1368 * This field is implemented as string linked-list in Python, where each
1369 * string describes the header. For example:
1370 \code
1371 msg_data = py_pjsua.Msg_Data()
1372 msg_data.hdr_list = ["Subject: Hello py_pjsua!", "Priority: very low"]
1373 \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001374 */
1375 pjsip_hdr hdr_list;
1376
1377 /**
1378 * MIME type of optional message body.
1379 */
1380 pj_str_t content_type;
1381
1382 /**
1383 * Optional message body.
1384 */
1385 pj_str_t msg_body;
1386
Benny Prijono63fba012008-07-17 14:19:10 +00001387};
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001388
1389
1390/**
1391 * Initialize message data.
1392 *
1393 * @param msg_data Message data to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001394 *
1395 * \par Python
1396 * The corresponding Python function creates and initializes the structure:
1397 * \code
1398 msg_data = py_pjsua.msg_data_init()
1399 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001400 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001401PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001402
Benny Prijono268ca612006-02-07 12:34:11 +00001403
1404/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001405 * Instantiate pjsua application. Application must call this function before
1406 * calling any other functions, to make sure that the underlying libraries
1407 * are properly initialized. Once this function has returned success,
1408 * application must call pjsua_destroy() before quitting.
1409 *
1410 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001411 *
1412 * \par Python:
1413 * \code
1414 status = py_pjsua.create()
1415 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001416 */
1417PJ_DECL(pj_status_t) pjsua_create(void);
1418
1419
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001420/** Forward declaration */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001421typedef struct pjsua_media_config pjsua_media_config;
1422
1423
Benny Prijonodc39fe82006-05-26 12:17:46 +00001424/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001425 * Initialize pjsua with the specified settings. All the settings are
1426 * optional, and the default values will be used when the config is not
1427 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001428 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001429 * Note that #pjsua_create() MUST be called before calling this function.
1430 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001431 * @param ua_cfg User agent configuration.
1432 * @param log_cfg Optional logging configuration.
1433 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001434 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001435 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001436 *
1437 * \par Python:
1438 * The function is similar in Python:
1439 * \code
1440 status = py_pjsua.init(ua_cfg, log_cfg, media_cfg)
1441 * \endcode
1442 * Note that \a ua_cfg, \a log_cfg, and \a media_cfg are optional, and
1443 * the Python script may pass None if it doesn't want to configure the
1444 * setting.
Benny Prijono268ca612006-02-07 12:34:11 +00001445 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001446PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1447 const pjsua_logging_config *log_cfg,
1448 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001449
1450
1451/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001452 * Application is recommended to call this function after all initialization
1453 * is done, so that the library can do additional checking set up
1454 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001455 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001456 * Application may call this function anytime after #pjsua_init().
1457 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001458 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001459 *
1460 * \par Python:
1461 * The function is similar in Python:
1462 * \code
1463 status = py_pjsua.start()
1464 * \endcode
Benny Prijonoccf95622006-02-07 18:48:01 +00001465 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001466PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001467
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001468
Benny Prijonoccf95622006-02-07 18:48:01 +00001469/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001470 * Destroy pjsua. Application is recommended to perform graceful shutdown
1471 * before calling this function (such as unregister the account from the SIP
1472 * server, terminate presense subscription, and hangup active calls), however,
1473 * this function will do all of these if it finds there are active sessions
1474 * that need to be terminated. This function will approximately block for
1475 * one second to wait for replies from remote.
1476 *
1477 * Application.may safely call this function more than once if it doesn't
1478 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001479 *
1480 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001481 *
1482 * \par Python:
1483 * The function is similar in Python:
1484 * \code
1485 status = py_pjsua.destroy()
1486 * \endcode
Benny Prijono268ca612006-02-07 12:34:11 +00001487 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001488PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001489
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001490
Benny Prijono9fc735d2006-05-28 14:58:12 +00001491/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001492 * Poll pjsua for events, and if necessary block the caller thread for
1493 * the specified maximum interval (in miliseconds).
1494 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001495 * Application doesn't normally need to call this function if it has
1496 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1497 * because polling then will be done by these worker threads instead.
1498 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001499 * @param msec_timeout Maximum time to wait, in miliseconds.
1500 *
1501 * @return The number of events that have been handled during the
1502 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001503 * can retrieve the error as (status = -return_value).
1504 *
1505 * \par Python:
1506 * The function is similar in Python:
1507 * \code
1508 n = py_pjsua.handle_events(msec_timeout)
1509 * \endcode
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001510 */
1511PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1512
1513
1514/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001515 * Create memory pool to be used by the application. Once application
1516 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001517 *
1518 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001519 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001520 * @param increment Increment size.
1521 *
1522 * @return The pool, or NULL when there's no memory.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001523 *
1524 * \par Python:
1525 * Python script may also create a pool object from the script:
1526 * \code
1527 pool = py_pjsua.pool_create(name, init_size, increment)
1528 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001529 */
1530PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1531 pj_size_t increment);
1532
1533
1534/**
1535 * Application can call this function at any time (after pjsua_create(), of
1536 * course) to change logging settings.
1537 *
1538 * @param c Logging configuration.
1539 *
1540 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001541 *
1542 * \par Python:
1543 * The function is similar in Python:
1544 * \code
1545 status = py_pjsua.reconfigure_logging(log_cfg)
1546 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001547 */
1548PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1549
1550
1551/**
1552 * Internal function to get SIP endpoint instance of pjsua, which is
1553 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001554 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001555 *
1556 * @return SIP endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001557 *
1558 * \par Python:
1559 * Application may retrieve the SIP endpoint instance:
1560 * \code
1561 endpt = py_pjsua.get_pjsip_endpt()
1562 * \endcode
1563 * However currently the object is just an opaque object and does not have
1564 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001565 */
1566PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1567
1568/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001569 * Internal function to get media endpoint instance.
1570 * Only valid after #pjsua_init() is called.
1571 *
1572 * @return Media endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001573 *
1574 * \par Python:
1575 * Application may retrieve the media endpoint instance:
1576 * \code
1577 endpt = py_pjsua.get_pjmedia_endpt()
1578 * \endcode
1579 * However currently the object is just an opaque object and does not have
1580 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001581 */
1582PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1583
Benny Prijono97b87172006-08-24 14:25:14 +00001584/**
1585 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001586 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001587 *
1588 * @return Pool factory currently used by PJSUA.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001589 *
1590 * \par Python:
1591 * Application may retrieve the pool factory instance:
1592 * \code
1593 endpt = py_pjsua.get_pool_factory()
1594 * \endcode
1595 * However currently the object is just an opaque object and does not have
1596 * any use for Python scripts.
Benny Prijono97b87172006-08-24 14:25:14 +00001597 */
1598PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1599
1600
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001601
1602/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001603 * Utilities.
1604 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001605 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001606
1607/**
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001608 * This is a utility function to detect NAT type in front of this
1609 * endpoint. Once invoked successfully, this function will complete
Benny Prijono6ba8c542007-10-16 01:34:14 +00001610 * asynchronously and report the result in \a on_nat_detect() callback
1611 * of pjsua_callback.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001612 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001613 * After NAT has been detected and the callback is called, application can
1614 * get the detected NAT type by calling #pjsua_get_nat_type(). Application
1615 * can also perform NAT detection by calling #pjsua_detect_nat_type()
1616 * again at later time.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001617 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001618 * Note that STUN must be enabled to run this function successfully.
1619 *
1620 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001621 */
Benny Prijono6ba8c542007-10-16 01:34:14 +00001622PJ_DECL(pj_status_t) pjsua_detect_nat_type(void);
1623
1624
1625/**
1626 * Get the NAT type as detected by #pjsua_detect_nat_type() function.
1627 * This function will only return useful NAT type after #pjsua_detect_nat_type()
1628 * has completed successfully and \a on_nat_detect() callback has been called.
1629 *
1630 * @param type NAT type.
1631 *
1632 * @return When detection is in progress, this function will
1633 * return PJ_EPENDING and \a type will be set to
1634 * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been
1635 * detected successfully, this function will return
1636 * PJ_SUCCESS and \a type will be set to the correct
1637 * value. Other return values indicate error and
1638 * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN.
Benny Prijono91a6a172007-10-31 08:59:29 +00001639 *
1640 * @see pjsua_call_get_rem_nat_type()
Benny Prijono6ba8c542007-10-16 01:34:14 +00001641 */
1642PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type);
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001643
1644
1645/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001646 * This is a utility function to verify that valid SIP url is given. If the
1647 * URL is valid, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001648 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001649 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001650 *
1651 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001652 *
1653 * \par Python:
1654 * \code
1655 status = py_pjsua.verify_sip_url(url)
1656 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001657 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001658PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001659
1660
1661/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001662 * This is a utility function to display error message for the specified
1663 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001664 *
1665 * @param sender The log sender field.
1666 * @param title Message title for the error.
1667 * @param status Status code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001668 *
1669 * \par Python:
1670 * \code
1671 py_pjsua.perror(sender, title, status)
1672 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001673 */
1674PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1675 pj_status_t status);
1676
1677
Benny Prijonoda9785b2007-04-02 20:43:06 +00001678/**
1679 * This is a utility function to dump the stack states to log, using
1680 * verbosity level 3.
1681 *
1682 * @param detail Will print detailed output (such as list of
1683 * SIP transactions) when non-zero.
1684 */
1685PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001686
1687/**
1688 * @}
1689 */
1690
1691
1692
1693/*****************************************************************************
1694 * TRANSPORT API
1695 */
1696
1697/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001698 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001699 * @ingroup PJSUA_LIB
1700 * @brief API for managing SIP transports
1701 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001702 *
1703 * PJSUA-API supports creating multiple transport instances, for example UDP,
1704 * TCP, and TLS transport. SIP transport must be created before adding an
1705 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001706 */
1707
1708
Benny Prijonoe6ead542007-01-31 20:53:31 +00001709/** SIP transport identification.
1710 */
Benny Prijono312aff92006-06-17 04:08:30 +00001711typedef int pjsua_transport_id;
1712
1713
1714/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001715 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001716 * and media. Before setting some values to this structure, application
1717 * MUST call #pjsua_transport_config_default() to initialize its
1718 * values with default settings.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001719 *
1720 * \par Python:
1721 * The data type in Python is <tt>py_pjsua.Transport_Config</tt>,
1722 * although application can just do this to create the instance:
1723 * \code
1724 transport_cfg = py_pjsua.transport_config_default()
1725 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001726 */
1727typedef struct pjsua_transport_config
1728{
1729 /**
1730 * UDP port number to bind locally. This setting MUST be specified
1731 * even when default port is desired. If the value is zero, the
1732 * transport will be bound to any available port, and application
1733 * can query the port by querying the transport info.
1734 */
1735 unsigned port;
1736
1737 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001738 * Optional address to advertise as the address of this transport.
1739 * Application can specify any address or hostname for this field,
1740 * for example it can point to one of the interface address in the
1741 * system, or it can point to the public address of a NAT router
1742 * where port mappings have been configured for the application.
1743 *
1744 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001745 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001746 pj_str_t public_addr;
1747
1748 /**
1749 * Optional address where the socket should be bound to. This option
1750 * SHOULD only be used to selectively bind the socket to particular
1751 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1752 * published address of a transport (the public_addr field should be
1753 * used for that purpose).
1754 *
1755 * Note that unlike public_addr field, the address (or hostname) here
1756 * MUST correspond to the actual interface address in the host, since
1757 * this address will be specified as bind() argument.
1758 */
1759 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001760
1761 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001762 * This specifies TLS settings for TLS transport. It is only be used
1763 * when this transport config is being used to create a SIP TLS
1764 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001765 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001766 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001767
Benny Prijono312aff92006-06-17 04:08:30 +00001768} pjsua_transport_config;
1769
1770
1771/**
1772 * Call this function to initialize UDP config with default values.
1773 *
1774 * @param cfg The UDP config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001775 *
1776 * \par Python:
1777 * The corresponding Python function is rather different:
1778 * \code
1779 transport_cfg = py_pjsua.transport_config_default()
1780 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001781 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001782PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001783
1784
1785/**
Benny Prijono312aff92006-06-17 04:08:30 +00001786 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001787 *
1788 * @param pool The pool.
1789 * @param dst The destination config.
1790 * @param src The source config.
1791 *
1792 * \par Python:
1793 * Not applicable. One should be able to just copy one variable instance
1794 * to another in Python.
Benny Prijono312aff92006-06-17 04:08:30 +00001795 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001796PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1797 pjsua_transport_config *dst,
1798 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001799
1800
1801/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001802 * This structure describes transport information returned by
1803 * #pjsua_transport_get_info() function.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001804 *
1805 * \par Python:
1806 * The corresponding data type in Python is <tt>py_pjsua.Transport_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001807 */
1808typedef struct pjsua_transport_info
1809{
1810 /**
1811 * PJSUA transport identification.
1812 */
1813 pjsua_transport_id id;
1814
1815 /**
1816 * Transport type.
1817 */
1818 pjsip_transport_type_e type;
1819
1820 /**
1821 * Transport type name.
1822 */
1823 pj_str_t type_name;
1824
1825 /**
1826 * Transport string info/description.
1827 */
1828 pj_str_t info;
1829
1830 /**
1831 * Transport flag (see ##pjsip_transport_flags_e).
1832 */
1833 unsigned flag;
1834
1835 /**
1836 * Local address length.
1837 */
1838 unsigned addr_len;
1839
1840 /**
1841 * Local/bound address.
1842 */
1843 pj_sockaddr local_addr;
1844
1845 /**
1846 * Published address (or transport address name).
1847 */
1848 pjsip_host_port local_name;
1849
1850 /**
1851 * Current number of objects currently referencing this transport.
1852 */
1853 unsigned usage_count;
1854
1855
1856} pjsua_transport_info;
1857
1858
1859/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001860 * Create and start a new SIP transport according to the specified
1861 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001862 *
1863 * @param type Transport type.
1864 * @param cfg Transport configuration.
1865 * @param p_id Optional pointer to receive transport ID.
1866 *
1867 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001868 *
1869 * \par Python:
1870 * The corresponding Python function returns (status,id) tuple:
1871 * \code
1872 status, transport_id = py_pjsua.transport_create(type, cfg)
1873 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001874 */
1875PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1876 const pjsua_transport_config *cfg,
1877 pjsua_transport_id *p_id);
1878
1879/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001880 * Register transport that has been created by application. This function
1881 * is useful if application wants to implement custom SIP transport and use
1882 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001883 *
1884 * @param tp Transport instance.
1885 * @param p_id Optional pointer to receive transport ID.
1886 *
1887 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001888 *
1889 * \par Python:
1890 * Not applicable (for now), because one cannot create a custom transport
1891 * from Python script.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001892 */
1893PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1894 pjsua_transport_id *p_id);
1895
1896
1897/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001898 * Enumerate all transports currently created in the system. This function
1899 * will return all transport IDs, and application may then call
1900 * #pjsua_transport_get_info() function to retrieve detailed information
1901 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001902 *
1903 * @param id Array to receive transport ids.
1904 * @param count In input, specifies the maximum number of elements.
1905 * On return, it contains the actual number of elements.
1906 *
1907 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001908 *
1909 * \par Python:
1910 * The function returns list of integers representing transport ids:
1911 * \code
1912 [int] = py_pjsua.enum_transports()
1913 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001914 */
1915PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1916 unsigned *count );
1917
1918
1919/**
1920 * Get information about transports.
1921 *
1922 * @param id Transport ID.
1923 * @param info Pointer to receive transport info.
1924 *
1925 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001926 *
1927 * \par Python:
1928 * \code
1929 transport_info = py_pjsua.transport_get_info(id)
1930 * \endcode
1931 * The Python function returns None on error.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001932 */
1933PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1934 pjsua_transport_info *info);
1935
1936
1937/**
1938 * Disable a transport or re-enable it. By default transport is always
1939 * enabled after it is created. Disabling a transport does not necessarily
1940 * close the socket, it will only discard incoming messages and prevent
1941 * the transport from being used to send outgoing messages.
1942 *
1943 * @param id Transport ID.
1944 * @param enabled Non-zero to enable, zero to disable.
1945 *
1946 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001947 *
1948 * \par Python:
1949 * \code
1950 status = py_pjsua.transport_set_enable(id, enabled)
1951 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001952 */
1953PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1954 pj_bool_t enabled);
1955
1956
1957/**
1958 * Close the transport. If transport is forcefully closed, it will be
1959 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00001960 * transport may not terminate properly (it may even crash). Otherwise,
1961 * the system will wait until all transactions are closed while preventing
1962 * new users from using the transport, and will close the transport when
1963 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001964 *
1965 * @param id Transport ID.
1966 * @param force Non-zero to immediately close the transport. This
1967 * is not recommended!
1968 *
1969 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001970 *
1971 * \par Python:
1972 * \code
1973 status = py_pjsua.transport_close(id, force)
1974 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001975 */
1976PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1977 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001978
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001979/**
Benny Prijono312aff92006-06-17 04:08:30 +00001980 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001981 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001982
1983
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001984
1985
1986/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001987 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001988 */
1989
Benny Prijono312aff92006-06-17 04:08:30 +00001990
1991/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001992 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001993 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001994 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001995 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001996 *
Benny Prijono312aff92006-06-17 04:08:30 +00001997 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001998 * using the application. In SIP terms, the identity is used as the <b>From</b>
1999 * header in outgoing requests.
2000 *
2001 * PJSUA-API supports creating and managing multiple accounts. The maximum
2002 * number of accounts is limited by a compile time constant
2003 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002004 *
2005 * Account may or may not have client registration associated with it.
2006 * An account is also associated with <b>route set</b> and some <b>authentication
2007 * credentials</b>, which are used when sending SIP request messages using the
2008 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00002009 * will be reported to remote peer when they subscribe to the account's
2010 * presence, or which is published to a presence server if presence
2011 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00002012 *
2013 * At least one account MUST be created in the application. If no user
2014 * association is required, application can create a userless account by
2015 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00002016 * instead of a particular user, and it correspond with a particular
2017 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00002018 *
2019 * Also one account must be set as the <b>default account</b>, which is used as
2020 * the account to use when PJSUA fails to match a request with any other
2021 * accounts.
2022 *
2023 * When sending outgoing SIP requests (such as making calls or sending
2024 * instant messages), normally PJSUA requires the application to specify
2025 * which account to use for the request. If no account is specified,
2026 * PJSUA may be able to select the account by matching the destination
2027 * domain name, and fall back to default account when no match is found.
2028 */
2029
2030/**
2031 * Maximum accounts.
2032 */
2033#ifndef PJSUA_MAX_ACC
2034# define PJSUA_MAX_ACC 8
2035#endif
2036
2037
2038/**
2039 * Default registration interval.
2040 */
2041#ifndef PJSUA_REG_INTERVAL
Benny Prijonobddef2c2007-10-31 13:28:08 +00002042# define PJSUA_REG_INTERVAL 300
Benny Prijono312aff92006-06-17 04:08:30 +00002043#endif
2044
2045
2046/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002047 * Default PUBLISH expiration
2048 */
2049#ifndef PJSUA_PUBLISH_EXPIRATION
Benny Prijono53984d12009-04-28 22:19:49 +00002050# define PJSUA_PUBLISH_EXPIRATION PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002051#endif
2052
2053
2054/**
Benny Prijono093d3022006-09-24 00:07:11 +00002055 * Default account priority.
2056 */
2057#ifndef PJSUA_DEFAULT_ACC_PRIORITY
2058# define PJSUA_DEFAULT_ACC_PRIORITY 0
2059#endif
2060
2061
2062/**
Benny Prijono8058a622007-06-08 04:37:05 +00002063 * This macro specifies the URI scheme to use in Contact header
2064 * when secure transport such as TLS is used. Application can specify
2065 * either "sip" or "sips".
2066 */
2067#ifndef PJSUA_SECURE_SCHEME
Benny Prijono4c82c1e2008-10-16 08:14:51 +00002068# define PJSUA_SECURE_SCHEME "sip"
Benny Prijono8058a622007-06-08 04:37:05 +00002069#endif
2070
2071
2072/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002073 * This structure describes account configuration to be specified when
2074 * adding a new account with #pjsua_acc_add(). Application MUST initialize
2075 * this structure first by calling #pjsua_acc_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00002076 *
2077 * \par Python:
2078 * The data type in Python is <tt>py_pjsua.Acc_Config</tt>, but normally
2079 * application can just use the snippet below to create and initialize
2080 * the account config:
2081 * \code
2082 acc_cfg = py_pjsua.acc_config_default()
2083 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002084 */
2085typedef struct pjsua_acc_config
2086{
Benny Prijono093d3022006-09-24 00:07:11 +00002087 /**
Benny Prijono705e7842008-07-21 18:12:51 +00002088 * Arbitrary user data to be associated with the newly created account.
2089 * Application may set this later with #pjsua_acc_set_user_data() and
2090 * retrieve it with #pjsua_acc_get_user_data().
2091 */
2092 void *user_data;
2093
2094 /**
Benny Prijono093d3022006-09-24 00:07:11 +00002095 * Account priority, which is used to control the order of matching
2096 * incoming/outgoing requests. The higher the number means the higher
2097 * the priority is, and the account will be matched first.
2098 */
2099 int priority;
2100
Benny Prijono312aff92006-06-17 04:08:30 +00002101 /**
2102 * The full SIP URL for the account. The value can take name address or
2103 * URL format, and will look something like "sip:account@serviceprovider".
2104 *
2105 * This field is mandatory.
2106 */
2107 pj_str_t id;
2108
2109 /**
2110 * This is the URL to be put in the request URI for the registration,
2111 * and will look something like "sip:serviceprovider".
2112 *
2113 * This field should be specified if registration is desired. If the
2114 * value is empty, no account registration will be performed.
2115 */
2116 pj_str_t reg_uri;
2117
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002118 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002119 * If this flag is set, the presence information of this account will
2120 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono48ab2b72007-11-08 09:24:30 +00002121 *
2122 * Default: PJ_FALSE
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002123 */
2124 pj_bool_t publish_enabled;
2125
Benny Prijonofe04fb52007-08-24 08:28:52 +00002126 /**
Benny Prijono48ab2b72007-11-08 09:24:30 +00002127 * Authentication preference.
2128 */
2129 pjsip_auth_clt_pref auth_pref;
2130
2131 /**
Benny Prijonofe04fb52007-08-24 08:28:52 +00002132 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
2133 * is not specified, a random string will be used.
2134 */
2135 pj_str_t pidf_tuple_id;
2136
Benny Prijono312aff92006-06-17 04:08:30 +00002137 /**
2138 * Optional URI to be put as Contact for this account. It is recommended
2139 * that this field is left empty, so that the value will be calculated
2140 * automatically based on the transport address.
2141 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00002142 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00002143
2144 /**
Benny Prijono30fe4852008-12-10 16:54:16 +00002145 * Additional URI parameters that will be appended in the Contact header
2146 * for this account. This will affect the Contact header in all SIP
2147 * messages sent on behalf of this account, including but not limited to
2148 * REGISTER, INVITE, and SUBCRIBE requests or responses.
2149 *
2150 * The parameters should be preceeded by semicolon, and all strings must
2151 * be properly escaped. Example:
2152 * ";my-param=X;another-param=Hi%20there"
2153 */
2154 pj_str_t contact_params;
2155
2156 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00002157 * Specify whether support for reliable provisional response (100rel and
2158 * PRACK) should be required for all sessions of this account.
2159 *
2160 * Default: PJ_FALSE
2161 */
2162 pj_bool_t require_100rel;
2163
2164 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002165 * Number of proxies in the proxy array below.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002166 *
2167 * \par Python:
2168 * Not applicable, as \a proxy is implemented as list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00002169 */
2170 unsigned proxy_cnt;
2171
2172 /**
2173 * Optional URI of the proxies to be visited for all outgoing requests
2174 * that are using this account (REGISTER, INVITE, etc). Application need
2175 * to specify these proxies if the service provider requires that requests
2176 * destined towards its network should go through certain proxies first
2177 * (for example, border controllers).
2178 *
2179 * These proxies will be put in the route set for this account, with
2180 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00002181 * first). If global outbound proxies are configured in pjsua_config,
2182 * then these account proxies will be placed after the global outbound
2183 * proxies in the routeset.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002184 *
2185 * \par Python:
2186 * This will be list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00002187 */
2188 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
2189
2190 /**
2191 * Optional interval for registration, in seconds. If the value is zero,
Benny Prijonobddef2c2007-10-31 13:28:08 +00002192 * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
Benny Prijono312aff92006-06-17 04:08:30 +00002193 */
2194 unsigned reg_timeout;
2195
2196 /**
2197 * Number of credentials in the credential array.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002198 *
2199 * \par Python:
2200 * Not applicable, since \a cred_info is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00002201 */
2202 unsigned cred_count;
2203
2204 /**
2205 * Array of credentials. If registration is desired, normally there should
2206 * be at least one credential specified, to successfully authenticate
2207 * against the service provider. More credentials can be specified, for
2208 * example when the requests are expected to be challenged by the
2209 * proxies in the route set.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002210 *
2211 * \par Python:
2212 * This field is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00002213 */
2214 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
2215
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002216 /**
2217 * Optionally bind this account to specific transport. This normally is
2218 * not a good idea, as account should be able to send requests using
2219 * any available transports according to the destination. But some
2220 * application may want to have explicit control over the transport to
2221 * use, so in that case it can set this field.
2222 *
2223 * Default: -1 (PJSUA_INVALID_ID)
2224 *
2225 * @see pjsua_acc_set_transport()
2226 */
2227 pjsua_transport_id transport_id;
2228
Benny Prijono15b02302007-09-27 14:07:07 +00002229 /**
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002230 * This option is used to update the UDP transport address and the Contact
2231 * header of REGISTER request. When this option is enabled, the library
2232 * will keep track of the public IP address from the response of REGISTER
2233 * request. Once it detects that the address has changed, it will
2234 * unregister current Contact, update the Contact with transport address
2235 * learned from Via header, and register a new Contact to the registrar.
2236 * This will also update the public name of UDP transport if STUN is
2237 * configured.
Benny Prijono15b02302007-09-27 14:07:07 +00002238 *
2239 * Default: 1 (yes)
2240 */
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002241 pj_bool_t allow_contact_rewrite;
Benny Prijono15b02302007-09-27 14:07:07 +00002242
Benny Prijonobddef2c2007-10-31 13:28:08 +00002243 /**
2244 * Set the interval for periodic keep-alive transmission for this account.
2245 * If this value is zero, keep-alive will be disabled for this account.
2246 * The keep-alive transmission will be sent to the registrar's address,
2247 * after successful registration.
2248 *
Benny Prijonobddef2c2007-10-31 13:28:08 +00002249 * Default: 15 (seconds)
2250 */
2251 unsigned ka_interval;
2252
2253 /**
2254 * Specify the data to be transmitted as keep-alive packets.
2255 *
2256 * Default: CR-LF
2257 */
2258 pj_str_t ka_data;
2259
Benny Prijonod8179652008-01-23 20:39:07 +00002260#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
2261 /**
2262 * Specify whether secure media transport should be used for this account.
2263 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
2264 * PJMEDIA_SRTP_MANDATORY.
2265 *
2266 * Default: #PJSUA_DEFAULT_USE_SRTP
2267 */
2268 pjmedia_srtp_use use_srtp;
2269
2270 /**
2271 * Specify whether SRTP requires secure signaling to be used. This option
2272 * is only used when \a use_srtp option above is non-zero.
2273 *
2274 * Valid values are:
2275 * 0: SRTP does not require secure signaling
2276 * 1: SRTP requires secure transport such as TLS
2277 * 2: SRTP requires secure end-to-end transport (SIPS)
2278 *
2279 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
2280 */
2281 int srtp_secure_signaling;
2282#endif
2283
Benny Prijono312aff92006-06-17 04:08:30 +00002284} pjsua_acc_config;
2285
2286
2287/**
2288 * Call this function to initialize account config with default values.
2289 *
2290 * @param cfg The account config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002291 *
2292 * \par Python:
2293 * In Python, this function both creates and initializes the account
2294 * config:
2295 * \code
2296 acc_cfg = py_pjsua.acc_config_default()
2297 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002298 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00002299PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002300
2301
2302/**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002303 * Duplicate account config.
2304 *
2305 * @param pool Pool to be used for duplicating the config.
2306 * @param dst Destination configuration.
2307 * @param src Source configuration.
2308 */
2309PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
2310 pjsua_acc_config *dst,
2311 const pjsua_acc_config *src);
2312
2313
2314/**
Benny Prijono312aff92006-06-17 04:08:30 +00002315 * Account info. Application can query account info by calling
2316 * #pjsua_acc_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00002317 *
2318 * \par Python:
2319 * The data type in Python is <tt>py_pjsua.Acc_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002320 */
2321typedef struct pjsua_acc_info
2322{
2323 /**
2324 * The account ID.
2325 */
2326 pjsua_acc_id id;
2327
2328 /**
2329 * Flag to indicate whether this is the default account.
2330 */
2331 pj_bool_t is_default;
2332
2333 /**
2334 * Account URI
2335 */
2336 pj_str_t acc_uri;
2337
2338 /**
2339 * Flag to tell whether this account has registration setting
2340 * (reg_uri is not empty).
2341 */
2342 pj_bool_t has_registration;
2343
2344 /**
2345 * An up to date expiration interval for account registration session.
2346 */
2347 int expires;
2348
2349 /**
2350 * Last registration status code. If status code is zero, the account
2351 * is currently not registered. Any other value indicates the SIP
2352 * status code of the registration.
2353 */
2354 pjsip_status_code status;
2355
2356 /**
2357 * String describing the registration status.
2358 */
2359 pj_str_t status_text;
2360
2361 /**
2362 * Presence online status for this account.
2363 */
2364 pj_bool_t online_status;
2365
2366 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00002367 * Presence online status text.
2368 */
2369 pj_str_t online_status_text;
2370
2371 /**
2372 * Extended RPID online status information.
2373 */
2374 pjrpid_element rpid;
2375
2376 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002377 * Buffer that is used internally to store the status text.
2378 */
2379 char buf_[PJ_ERR_MSG_SIZE];
2380
2381} pjsua_acc_info;
2382
2383
2384
2385/**
2386 * Get number of current accounts.
2387 *
2388 * @return Current number of accounts.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002389 *
2390 * \par Python:
2391 * \code
2392 count = py_pjsua.acc_get_count()
2393 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002394 */
2395PJ_DECL(unsigned) pjsua_acc_get_count(void);
2396
2397
2398/**
2399 * Check if the specified account ID is valid.
2400 *
2401 * @param acc_id Account ID to check.
2402 *
2403 * @return Non-zero if account ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002404 *
2405 * \par Python:
2406 * \code
2407 is_valid = py_pjsua.acc_is_valid(acc_id)
2408 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002409 */
2410PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
2411
2412
2413/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00002414 * Set default account to be used when incoming and outgoing
2415 * requests doesn't match any accounts.
2416 *
2417 * @param acc_id The account ID to be used as default.
2418 *
2419 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002420 *
2421 * \par Python:
2422 * \code
2423 status = py_pjsua.acc_set_default(acc_id)
2424 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002425 */
2426PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2427
2428
2429/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002430 * Get default account to be used when receiving incoming requests (calls),
2431 * when the destination of the incoming call doesn't match any other
2432 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002433 *
2434 * @return The default account ID, or PJSUA_INVALID_ID if no
2435 * default account is configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002436 *
2437 * \par Python:
2438 * \code
2439 acc_id = py_pjsua.acc_get_default()
2440 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002441 */
2442PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2443
2444
2445/**
Benny Prijono312aff92006-06-17 04:08:30 +00002446 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002447 * #pjsua_init()) before calling this function. If registration is configured
2448 * for this account, this function would also start the SIP registration
2449 * session with the SIP registrar server. This SIP registration session
2450 * will be maintained internally by the library, and application doesn't
2451 * need to do anything to maintain the registration session.
2452 *
Benny Prijono312aff92006-06-17 04:08:30 +00002453 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002454 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002455 * @param is_default If non-zero, this account will be set as the default
2456 * account. The default account will be used when sending
2457 * outgoing requests (e.g. making call) when no account is
2458 * specified, and when receiving incoming requests when the
2459 * request does not match any accounts. It is recommended
2460 * that default account is set to local/LAN account.
2461 * @param p_acc_id Pointer to receive account ID of the new account.
2462 *
2463 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002464 *
2465 * \par Python:
2466 * The function returns (status, account_id) tuple:
2467 * \code
2468 status, account_id = py_pjsua.acc_add(acc_cfg, is_default)
2469 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002470 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002471PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002472 pj_bool_t is_default,
2473 pjsua_acc_id *p_acc_id);
2474
2475
2476/**
2477 * Add a local account. A local account is used to identify local endpoint
2478 * instead of a specific user, and for this reason, a transport ID is needed
2479 * to obtain the local address information.
2480 *
2481 * @param tid Transport ID to generate account address.
2482 * @param is_default If non-zero, this account will be set as the default
2483 * account. The default account will be used when sending
2484 * outgoing requests (e.g. making call) when no account is
2485 * specified, and when receiving incoming requests when the
2486 * request does not match any accounts. It is recommended
2487 * that default account is set to local/LAN account.
2488 * @param p_acc_id Pointer to receive account ID of the new account.
2489 *
2490 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002491 *
2492 * \par Python:
2493 * The function returns (status, account_id) tuple:
2494 * \code
2495 status, account_id = py_pjsua.acc_add_local(tid, is_default)
2496 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002497 */
2498PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2499 pj_bool_t is_default,
2500 pjsua_acc_id *p_acc_id);
2501
2502/**
Benny Prijono705e7842008-07-21 18:12:51 +00002503 * Set arbitrary data to be associated with the account.
2504 *
2505 * @param acc_id The account ID.
2506 * @param user_data User/application data.
2507 *
2508 * @return PJ_SUCCESS on success, or the appropriate error code.
2509 */
2510PJ_DECL(pj_status_t) pjsua_acc_set_user_data(pjsua_acc_id acc_id,
2511 void *user_data);
2512
2513
2514/**
2515 * Retrieve arbitrary data associated with the account.
2516 *
2517 * @param acc_id The account ID.
2518 *
2519 * @return The user data. In the case where the account ID is
2520 * not valid, NULL is returned.
2521 */
2522PJ_DECL(void*) pjsua_acc_get_user_data(pjsua_acc_id acc_id);
2523
2524
2525/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002526 * Delete an account. This will unregister the account from the SIP server,
2527 * if necessary, and terminate server side presence subscriptions associated
2528 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002529 *
2530 * @param acc_id Id of the account to be deleted.
2531 *
2532 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002533 *
2534 * \par Python:
2535 * \code
2536 status = py_pjsua.acc_del(acc_id)
2537 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002538 */
2539PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2540
2541
2542/**
2543 * Modify account information.
2544 *
2545 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002546 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002547 *
2548 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002549 *
2550 * \par Python:
2551 * \code
2552 status = py_pjsua.acc_modify(acc_id, acc_cfg)
2553 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002554 */
2555PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002556 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002557
2558
2559/**
2560 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002561 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002562 * if there are server side presence subscription for this account, and/or
2563 * outgoing PUBLISH if presence publication is enabled for this account.
2564 *
2565 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002566 *
2567 * @param acc_id The account ID.
2568 * @param is_online True of false.
2569 *
2570 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002571 *
2572 * \par Python:
2573 * \code
2574 status = py_pjsua.acc_set_online_status(acc_id, is_online)
2575 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002576 */
2577PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2578 pj_bool_t is_online);
2579
Benny Prijono4461c7d2007-08-25 13:36:15 +00002580/**
2581 * Modify account's presence status to be advertised to remote/presence
2582 * subscribers. This would trigger the sending of outgoing NOTIFY request
2583 * if there are server side presence subscription for this account, and/or
2584 * outgoing PUBLISH if presence publication is enabled for this account.
2585 *
2586 * @see pjsua_acc_set_online_status()
2587 *
2588 * @param acc_id The account ID.
2589 * @param is_online True of false.
2590 * @param pr Extended information in subset of RPID format
2591 * which allows setting custom presence text.
2592 *
2593 * @return PJ_SUCCESS on success, or the appropriate error code.
2594 */
2595PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2596 pj_bool_t is_online,
2597 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002598
2599/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002600 * Update registration or perform unregistration. If registration is
2601 * configured for this account, then initial SIP REGISTER will be sent
2602 * when the account is added with #pjsua_acc_add(). Application normally
2603 * only need to call this function if it wants to manually update the
2604 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002605 *
2606 * @param acc_id The account ID.
2607 * @param renew If renew argument is zero, this will start
2608 * unregistration process.
2609 *
2610 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002611 *
2612 * \par Python:
2613 * \code
2614 status = py_pjsua.acc_set_registration(acc_id, renew)
2615 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002616 */
2617PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2618 pj_bool_t renew);
2619
Benny Prijono312aff92006-06-17 04:08:30 +00002620/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002621 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002622 *
2623 * @param acc_id Account identification.
2624 * @param info Pointer to receive account information.
2625 *
2626 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002627 *
2628 * \par Python:
2629 * \code
2630 acc_info = py_pjsua.acc_get_info(acc_id)
2631 * \endcode
2632 * The function returns None if account ID is not valid.
Benny Prijono312aff92006-06-17 04:08:30 +00002633 */
2634PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2635 pjsua_acc_info *info);
2636
2637
2638/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002639 * Enumerate all account currently active in the library. This will fill
2640 * the array with the account Ids, and application can then query the
2641 * account information for each id with #pjsua_acc_get_info().
2642 *
2643 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002644 *
2645 * @param ids Array of account IDs to be initialized.
2646 * @param count In input, specifies the maximum number of elements.
2647 * On return, it contains the actual number of elements.
2648 *
2649 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002650 *
2651 * \par Python:
2652 * The function takes no argument and returns list of account Ids:
2653 * \code
2654 [acc_ids] = py_pjsua.enum_accs()
2655 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002656 */
2657PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2658 unsigned *count );
2659
2660
2661/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002662 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002663 *
2664 * @param info Array of account infos to be initialized.
2665 * @param count In input, specifies the maximum number of elements.
2666 * On return, it contains the actual number of elements.
2667 *
2668 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002669 *
2670 * \par Python:
2671 * The function takes no argument and returns list of account infos:
2672 * \code
2673 [acc_info] = py_pjsua.acc_enum_info()
2674 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002675 */
2676PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2677 unsigned *count );
2678
2679
2680/**
2681 * This is an internal function to find the most appropriate account to
2682 * used to reach to the specified URL.
2683 *
2684 * @param url The remote URL to reach.
2685 *
2686 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002687 *
2688 * \par Python:
2689 * \code
2690 acc_id = py_pjsua.acc_find_for_outgoing(url)
2691 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002692 */
2693PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2694
2695
2696/**
2697 * This is an internal function to find the most appropriate account to be
2698 * used to handle incoming calls.
2699 *
2700 * @param rdata The incoming request message.
2701 *
2702 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002703 *
2704 * \par Python:
2705 * \code
2706 acc_id = py_pjsua.acc_find_for_outgoing(url)
2707 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002708 */
2709PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2710
2711
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002712/**
Benny Prijonofff245c2007-04-02 11:44:47 +00002713 * Create arbitrary requests using the account. Application should only use
2714 * this function to create auxiliary requests outside dialog, such as
2715 * OPTIONS, and use the call or presence API to create dialog related
2716 * requests.
2717 *
2718 * @param acc_id The account ID.
2719 * @param method The SIP method of the request.
2720 * @param target Target URI.
2721 * @param p_tdata Pointer to receive the request.
2722 *
2723 * @return PJ_SUCCESS or the error code.
2724 */
2725PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
2726 const pjsip_method *method,
2727 const pj_str_t *target,
2728 pjsip_tx_data **p_tdata);
2729
2730
2731/**
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002732 * Create a suitable URI to be put as Contact based on the specified
2733 * target URI for the specified account.
2734 *
2735 * @param pool Pool to allocate memory for the string.
2736 * @param contact The string where the Contact URI will be stored.
2737 * @param acc_id Account ID.
2738 * @param uri Destination URI of the request.
2739 *
2740 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002741 *
2742 * \par Python:
2743 * This function is still experimental in Python:
2744 * \code
2745 uri = py_pjsua.acc_create_uac_contact(pool, acc_id, uri)
2746 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002747 */
2748PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
2749 pj_str_t *contact,
2750 pjsua_acc_id acc_id,
2751 const pj_str_t *uri);
2752
2753
2754
2755/**
2756 * Create a suitable URI to be put as Contact based on the information
2757 * in the incoming request.
2758 *
2759 * @param pool Pool to allocate memory for the string.
2760 * @param contact The string where the Contact URI will be stored.
2761 * @param acc_id Account ID.
2762 * @param rdata Incoming request.
2763 *
2764 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002765 *
2766 * \par Python:
2767 * This function is still experimental in Python:
2768 * \code
2769 uri = py_pjsua.acc_create_uas_contact(pool, acc_id, rdata)
2770 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002771 */
2772PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
2773 pj_str_t *contact,
2774 pjsua_acc_id acc_id,
2775 pjsip_rx_data *rdata );
2776
2777
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002778/**
2779 * Lock/bind this account to a specific transport/listener. Normally
2780 * application shouldn't need to do this, as transports will be selected
2781 * automatically by the stack according to the destination.
2782 *
2783 * When account is locked/bound to a specific transport, all outgoing
2784 * requests from this account will use the specified transport (this
2785 * includes SIP registration, dialog (call and event subscription), and
2786 * out-of-dialog requests such as MESSAGE).
2787 *
2788 * Note that transport_id may be specified in pjsua_acc_config too.
2789 *
2790 * @param acc_id The account ID.
2791 * @param tp_id The transport ID.
2792 *
2793 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002794 *
2795 * \par Python:
2796 * Not yet implemented.
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002797 */
2798PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
2799 pjsua_transport_id tp_id);
2800
Benny Prijono312aff92006-06-17 04:08:30 +00002801
2802/**
2803 * @}
2804 */
2805
2806
2807/*****************************************************************************
2808 * CALLS API
2809 */
2810
2811
2812/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002813 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00002814 * @ingroup PJSUA_LIB
2815 * @brief Call manipulation.
2816 * @{
2817 */
2818
2819/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002820 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00002821 */
2822#ifndef PJSUA_MAX_CALLS
2823# define PJSUA_MAX_CALLS 32
2824#endif
2825
2826
2827
2828/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002829 * This enumeration specifies the media status of a call, and it's part
2830 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00002831 */
2832typedef enum pjsua_call_media_status
2833{
Benny Prijonob5388cf2007-01-04 22:45:08 +00002834 /** Call currently has no media */
Benny Prijono312aff92006-06-17 04:08:30 +00002835 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002836
2837 /** The media is active */
Benny Prijono312aff92006-06-17 04:08:30 +00002838 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002839
2840 /** The media is currently put on hold by local endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002841 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002842
2843 /** The media is currently put on hold by remote endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002844 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002845
Benny Prijono096c56c2007-09-15 08:30:16 +00002846 /** The media has reported error (e.g. ICE negotiation) */
2847 PJSUA_CALL_MEDIA_ERROR
2848
Benny Prijono312aff92006-06-17 04:08:30 +00002849} pjsua_call_media_status;
2850
2851
2852/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002853 * This structure describes the information and current status of a call.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002854 *
2855 * \par Python:
2856 * The type name is <tt>py_pjsua.Call_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002857 */
2858typedef struct pjsua_call_info
2859{
2860 /** Call identification. */
2861 pjsua_call_id id;
2862
2863 /** Initial call role (UAC == caller) */
2864 pjsip_role_e role;
2865
Benny Prijono90315512006-09-14 16:05:16 +00002866 /** The account ID where this call belongs. */
2867 pjsua_acc_id acc_id;
2868
Benny Prijono312aff92006-06-17 04:08:30 +00002869 /** Local URI */
2870 pj_str_t local_info;
2871
2872 /** Local Contact */
2873 pj_str_t local_contact;
2874
2875 /** Remote URI */
2876 pj_str_t remote_info;
2877
2878 /** Remote contact */
2879 pj_str_t remote_contact;
2880
2881 /** Dialog Call-ID string. */
2882 pj_str_t call_id;
2883
2884 /** Call state */
2885 pjsip_inv_state state;
2886
2887 /** Text describing the state */
2888 pj_str_t state_text;
2889
2890 /** Last status code heard, which can be used as cause code */
2891 pjsip_status_code last_status;
2892
2893 /** The reason phrase describing the status. */
2894 pj_str_t last_status_text;
2895
2896 /** Call media status. */
2897 pjsua_call_media_status media_status;
2898
2899 /** Media direction */
2900 pjmedia_dir media_dir;
2901
2902 /** The conference port number for the call */
2903 pjsua_conf_port_id conf_slot;
2904
2905 /** Up-to-date call connected duration (zero when call is not
2906 * established)
2907 */
2908 pj_time_val connect_duration;
2909
2910 /** Total call duration, including set-up time */
2911 pj_time_val total_duration;
2912
2913 /** Internal */
2914 struct {
2915 char local_info[128];
2916 char local_contact[128];
2917 char remote_info[128];
2918 char remote_contact[128];
2919 char call_id[128];
2920 char last_status_text[128];
2921 } buf_;
2922
2923} pjsua_call_info;
2924
2925
2926
Benny Prijonoa91a0032006-02-26 21:23:45 +00002927/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002928 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002929 *
2930 * @return Maximum number of calls configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002931 *
2932 * \par Python:
2933 * \code
2934 count = py_pjsua.call_get_max_count()
2935 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002936 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002937PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002938
2939/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002940 * Get number of currently active calls.
2941 *
2942 * @return Number of currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002943 *
2944 * \par Python:
2945 * \code
2946 count = py_pjsua.call_get_count()
2947 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002948 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002949PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002950
2951/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002952 * Enumerate all active calls. Application may then query the information and
2953 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002954 *
2955 * @param ids Array of account IDs to be initialized.
2956 * @param count In input, specifies the maximum number of elements.
2957 * On return, it contains the actual number of elements.
2958 *
2959 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002960 *
2961 * \par Python:
2962 * This function takes no argument and return list of call Ids.
2963 * \code
2964 [call_ids] = py_pjsua.enum_calls()
2965 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002966 */
2967PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
2968 unsigned *count);
2969
2970
2971/**
2972 * Make outgoing call to the specified URI using the specified account.
2973 *
2974 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002975 * @param dst_uri URI to be put in the To header (normally is the same
2976 * as the target URI).
2977 * @param options Options (must be zero at the moment).
2978 * @param user_data Arbitrary user data to be attached to the call, and
2979 * can be retrieved later.
2980 * @param msg_data Optional headers etc to be added to outgoing INVITE
2981 * request, or NULL if no custom header is desired.
2982 * @param p_call_id Pointer to receive call identification.
2983 *
2984 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002985 *
2986 * \par Python:
2987 * The Python function returns (status, call_id) tuple:
2988 * \code
2989 status, call_id = py_pjsua.call_make_call(acc_id, dst_uri, options,
2990 user_data, msg_data)
2991 * \endcode
2992 * Note: the \a user_data in Python function is an integer, and the
2993 * \a msg_data can be set to None if not required.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002994 */
2995PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
2996 const pj_str_t *dst_uri,
2997 unsigned options,
2998 void *user_data,
2999 const pjsua_msg_data *msg_data,
3000 pjsua_call_id *p_call_id);
3001
3002
3003/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00003004 * Check if the specified call has active INVITE session and the INVITE
3005 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003006 *
3007 * @param call_id Call identification.
3008 *
3009 * @return Non-zero if call is active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003010 *
3011 * \par Python:
3012 * \code
3013 bool = py_pjsua.call_is_active(call_id)
3014 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003015 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003016PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003017
3018
3019/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003020 * Check if call has an active media session.
3021 *
3022 * @param call_id Call identification.
3023 *
3024 * @return Non-zero if yes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003025 *
3026 * \par Python:
3027 * \code
3028 bool = py_pjsua.call_has_media(call_id)
3029 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003030 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003031PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003032
3033
3034/**
Benny Prijonocf986c42008-09-02 11:25:07 +00003035 * Retrieve the media session associated with this call. Note that the media
3036 * session may not be available depending on the current call's media status
3037 * (the pjsua_call_media_status information in pjsua_call_info). Application
3038 * may use the media session to retrieve more detailed information about the
3039 * call's media.
3040 *
3041 * @param call_id Call identification.
3042 *
3043 * @return Call media session.
3044 */
3045PJ_DECL(pjmedia_session*) pjsua_call_get_media_session(pjsua_call_id call_id);
3046
3047
3048/**
3049 * Retrieve the media transport instance that is used for this call.
3050 * Application may use the media transport to query more detailed information
3051 * about the media transport.
3052 *
3053 * @param cid Call identification (the call_id).
3054 *
3055 * @return Call media transport.
3056 */
3057PJ_DECL(pjmedia_transport*) pjsua_call_get_media_transport(pjsua_call_id cid);
3058
3059
3060/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003061 * Get the conference port identification associated with the call.
3062 *
3063 * @param call_id Call identification.
3064 *
3065 * @return Conference port ID, or PJSUA_INVALID_ID when the
3066 * media has not been established or is not active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003067 *
3068 * \par Python:
3069 * \code
3070 slot = py_pjsua.call_get_conf_port(call_id)
3071 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003072 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003073PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
3074
3075/**
3076 * Obtain detail information about the specified call.
3077 *
3078 * @param call_id Call identification.
3079 * @param info Call info to be initialized.
3080 *
3081 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003082 *
3083 * \par Python:
3084 * \code
3085 call_info = py_pjsua.call_get_info(call_id)
3086 * \endcode
3087 * \a call_info return value will be set to None if call_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003088 */
3089PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003090 pjsua_call_info *info);
3091
3092
3093/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003094 * Attach application specific data to the call. Application can then
3095 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003096 *
3097 * @param call_id Call identification.
3098 * @param user_data Arbitrary data to be attached to the call.
3099 *
3100 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003101 *
3102 * \par Python:
3103 * \code
3104 status = py_pjsua.call_set_user_data(call_id, user_data)
3105 * \endcode
3106 * The \a user_data is an integer in the Python function.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003107 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003108PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
3109 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003110
3111
3112/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003113 * Get user data attached to the call, which has been previously set with
3114 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003115 *
3116 * @param call_id Call identification.
3117 *
3118 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003119 *
3120 * \par Python:
3121 * \code
3122 user_data = py_pjsua.call_get_user_data(call_id)
3123 * \endcode
3124 * The \a user_data is an integer.
Benny Prijono268ca612006-02-07 12:34:11 +00003125 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003126PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00003127
3128
3129/**
Benny Prijono91a6a172007-10-31 08:59:29 +00003130 * Get the NAT type of remote's endpoint. This is a proprietary feature
3131 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
3132 * is set in #pjsua_config.
3133 *
3134 * This function can only be called after SDP has been received from remote,
3135 * which means for incoming call, this function can be called as soon as
3136 * call is received as long as incoming call contains SDP, and for outgoing
3137 * call, this function can be called only after SDP is received (normally in
3138 * 200/OK response to INVITE). As a general case, application should call
3139 * this function after or in \a on_call_media_state() callback.
3140 *
3141 * @param call_id Call identification.
3142 * @param p_type Pointer to store the NAT type. Application can then
3143 * retrieve the string description of the NAT type
3144 * by calling pj_stun_get_nat_name().
3145 *
3146 * @return PJ_SUCCESS on success.
3147 *
3148 * @see pjsua_get_nat_type(), nat_type_in_sdp
3149 */
3150PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
3151 pj_stun_nat_type *p_type);
3152
3153/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003154 * Send response to incoming INVITE request. Depending on the status
3155 * code specified as parameter, this function may send provisional
3156 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003157 *
3158 * @param call_id Incoming call identification.
3159 * @param code Status code, (100-699).
3160 * @param reason Optional reason phrase. If NULL, default text
3161 * will be used.
3162 * @param msg_data Optional list of headers etc to be added to outgoing
3163 * response message.
3164 *
3165 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003166 *
3167 * \par Python:
3168 * \code
3169 status = py_pjsua.call_answer(call_id, code, reason, msg_data)
3170 * \endcode
3171 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijonoa91a0032006-02-26 21:23:45 +00003172 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003173PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
3174 unsigned code,
3175 const pj_str_t *reason,
3176 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00003177
3178/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003179 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00003180 * call state. This function is different than answering the call with
3181 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
3182 * will hangup the call regardless of the state and role of the call,
3183 * while #pjsua_call_answer() only works with incoming calls on EARLY
3184 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003185 *
3186 * @param call_id Call identification.
3187 * @param code Optional status code to be sent when we're rejecting
3188 * incoming call. If the value is zero, "603/Decline"
3189 * will be sent.
3190 * @param reason Optional reason phrase to be sent when we're rejecting
3191 * incoming call. If NULL, default text will be used.
3192 * @param msg_data Optional list of headers etc to be added to outgoing
3193 * request/response message.
3194 *
3195 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003196 *
3197 * \par Python:
3198 * \code
3199 status = py_pjsua.call_hangup(call_id, code, reason, msg_data)
3200 * \endcode
3201 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003202 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003203PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
3204 unsigned code,
3205 const pj_str_t *reason,
3206 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003207
Benny Prijono5e51a4e2008-11-27 00:06:46 +00003208/**
3209 * Accept or reject redirection response. Application MUST call this function
3210 * after it signaled PJSIP_REDIRECT_PENDING in the \a on_call_redirected()
3211 * callback, to notify the call whether to accept or reject the redirection
3212 * to the current target. Application can use the combination of
3213 * PJSIP_REDIRECT_PENDING command in \a on_call_redirected() callback and
3214 * this function to ask for user permission before redirecting the call.
3215 *
3216 * Note that if the application chooses to reject or stop redirection (by
3217 * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the
3218 * call disconnection callback will be called before this function returns.
3219 * And if the application rejects the target, the \a on_call_redirected()
3220 * callback may also be called before this function returns if there is
3221 * another target to try.
3222 *
3223 * @param call_id The call ID.
3224 * @param cmd Redirection operation to be applied to the current
3225 * target. The semantic of this argument is similar
3226 * to the description in the \a on_call_redirected()
3227 * callback, except that the PJSIP_REDIRECT_PENDING is
3228 * not accepted here.
3229 *
3230 * @return PJ_SUCCESS on successful operation.
3231 */
3232PJ_DECL(pj_status_t) pjsua_call_process_redirect(pjsua_call_id call_id,
3233 pjsip_redirect_op cmd);
Benny Prijono26ff9062006-02-21 23:47:00 +00003234
3235/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003236 * Put the specified call on hold. This will send re-INVITE with the
3237 * appropriate SDP to inform remote that the call is being put on hold.
3238 * The final status of the request itself will be reported on the
3239 * \a on_call_media_state() callback, which inform the application that
3240 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003241 *
3242 * @param call_id Call identification.
3243 * @param msg_data Optional message components to be sent with
3244 * the request.
3245 *
3246 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003247 *
3248 * \par Python:
3249 * \code
3250 status = py_pjsua.call_set_hold(call_id, msg_data)
3251 * \endcode
3252 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003253 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003254PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
3255 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003256
3257
3258/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003259 * Send re-INVITE to release hold.
3260 * The final status of the request itself will be reported on the
3261 * \a on_call_media_state() callback, which inform the application that
3262 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003263 *
3264 * @param call_id Call identification.
3265 * @param unhold If this argument is non-zero and the call is locally
3266 * held, this will release the local hold.
3267 * @param msg_data Optional message components to be sent with
3268 * the request.
3269 *
3270 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003271 *
3272 * \par Python:
3273 * \code
3274 status = py_pjsua.call_reinvite(call_id, unhold, msg_data)
3275 * \endcode
3276 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003277 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003278PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
3279 pj_bool_t unhold,
3280 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003281
Benny Prijonoc08682e2007-10-04 06:17:58 +00003282/**
3283 * Send UPDATE request.
3284 *
3285 * @param call_id Call identification.
3286 * @param options Must be zero for now.
3287 * @param msg_data Optional message components to be sent with
3288 * the request.
3289 *
3290 * @return PJ_SUCCESS on success, or the appropriate error code.
3291 */
3292PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
3293 unsigned options,
3294 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003295
3296/**
Benny Prijono053f5222006-11-11 16:16:04 +00003297 * Initiate call transfer to the specified address. This function will send
3298 * REFER request to instruct remote call party to initiate a new INVITE
3299 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003300 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00003301 * If application is interested to monitor the successfulness and
3302 * the progress of the transfer request, it can implement
3303 * \a on_call_transfer_status() callback which will report the progress
3304 * of the call transfer request.
3305 *
Benny Prijono053f5222006-11-11 16:16:04 +00003306 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003307 * @param dest Address of new target to be contacted.
3308 * @param msg_data Optional message components to be sent with
3309 * the request.
3310 *
3311 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003312 *
3313 * \par Python:
3314 * \code
3315 status = py_pjsua.call_xfer(call_id, dest, msg_data)
3316 * \endcode
3317 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003318 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003319PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
3320 const pj_str_t *dest,
3321 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003322
3323/**
Benny Prijono053f5222006-11-11 16:16:04 +00003324 * Flag to indicate that "Require: replaces" should not be put in the
3325 * outgoing INVITE request caused by REFER request created by
3326 * #pjsua_call_xfer_replaces().
3327 */
3328#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
3329
3330/**
3331 * Initiate attended call transfer. This function will send REFER request
3332 * to instruct remote call party to initiate new INVITE session to the URL
3333 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
3334 * the call with us with the new call from the REFER recipient.
3335 *
3336 * @param call_id The call id to be transfered.
3337 * @param dest_call_id The call id to be replaced.
3338 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
3339 * to suppress the inclusion of "Require: replaces" in
3340 * the outgoing INVITE request created by the REFER
3341 * request.
3342 * @param msg_data Optional message components to be sent with
3343 * the request.
3344 *
3345 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003346 *
3347 * \par Python:
3348 * \code
3349 status = py_pjsua.call_xfer_replaces(call_id, dest_call_id, options, msg_data)
3350 * \endcode
3351 * Argument \a msg_data may be set to None if not required.
Benny Prijono053f5222006-11-11 16:16:04 +00003352 */
3353PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
3354 pjsua_call_id dest_call_id,
3355 unsigned options,
3356 const pjsua_msg_data *msg_data);
3357
3358/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003359 * Send DTMF digits to remote using RFC 2833 payload formats.
3360 *
3361 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003362 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003363 *
3364 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003365 *
3366 * \par Python:
3367 * \code
3368 status = py_pjsua.call_dial_dtmf(call_id, digits)
3369 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003370 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003371PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003372 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00003373
Benny Prijono26ff9062006-02-21 23:47:00 +00003374/**
Benny Prijonob0808372006-03-02 21:18:58 +00003375 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003376 *
3377 * @param call_id Call identification.
3378 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3379 * assumed.
3380 * @param content The message content.
3381 * @param msg_data Optional list of headers etc to be included in outgoing
3382 * request. The body descriptor in the msg_data is
3383 * ignored.
3384 * @param user_data Optional user data, which will be given back when
3385 * the IM callback is called.
3386 *
3387 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003388 *
3389 * \par Python:
3390 * \code
3391 status = py_pjsua.call_send_im(call_id, mime_type, content, msg_data, user_data)
3392 * \endcode
3393 * Note that the \a user_data argument is an integer in Python.
Benny Prijonob0808372006-03-02 21:18:58 +00003394 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003395PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
3396 const pj_str_t *mime_type,
3397 const pj_str_t *content,
3398 const pjsua_msg_data *msg_data,
3399 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003400
3401
3402/**
3403 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003404 *
3405 * @param call_id Call identification.
3406 * @param is_typing Non-zero to indicate to remote that local person is
3407 * currently typing an IM.
3408 * @param msg_data Optional list of headers etc to be included in outgoing
3409 * request.
3410 *
3411 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003412 *
3413 * \par Python:
3414 * \code
3415 status = py_pjsua.call_send_typing_ind(call_id, is_typing, msg_data)
3416 * \endcode
3417 * Argument \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003418 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003419PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
3420 pj_bool_t is_typing,
3421 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003422
3423/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00003424 * Send arbitrary request with the call. This is useful for example to send
3425 * INFO request. Note that application should not use this function to send
3426 * requests which would change the invite session's state, such as re-INVITE,
3427 * UPDATE, PRACK, and BYE.
3428 *
3429 * @param call_id Call identification.
3430 * @param method SIP method of the request.
3431 * @param msg_data Optional message body and/or list of headers to be
3432 * included in outgoing request.
3433 *
3434 * @return PJ_SUCCESS on success, or the appropriate error code.
3435 */
3436PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
3437 const pj_str_t *method,
3438 const pjsua_msg_data *msg_data);
3439
3440
3441/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003442 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
3443 * currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003444 *
3445 * \par Python:
3446 * \code
3447 py_pjsua.call_hangup_all()
3448 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003449 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00003450PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00003451
3452
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003453/**
3454 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003455 *
3456 * @param call_id Call identification.
3457 * @param with_media Non-zero to include media information too.
3458 * @param buffer Buffer where the statistics are to be written to.
3459 * @param maxlen Maximum length of buffer.
3460 * @param indent Spaces for left indentation.
3461 *
3462 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003463 *
3464 * \par Python:
3465 * \code
3466 string = py_pjsua.call_dump(call_id, with_media, max_len, indent)
3467 * \endcode
3468 * The \a max_len argument is the desired maximum length to be allocated.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003469 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003470PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
3471 pj_bool_t with_media,
3472 char *buffer,
3473 unsigned maxlen,
3474 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003475
Benny Prijono9fc735d2006-05-28 14:58:12 +00003476/**
Benny Prijono312aff92006-06-17 04:08:30 +00003477 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003478 */
Benny Prijono834aee32006-02-19 01:38:06 +00003479
3480
3481/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00003482 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00003483 */
3484
Benny Prijono312aff92006-06-17 04:08:30 +00003485
3486/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003487 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00003488 * @ingroup PJSUA_LIB
3489 * @brief Buddy management, buddy's presence, and instant messaging.
3490 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00003491 *
3492 * This section describes PJSUA-APIs related to buddies management,
3493 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00003494 */
3495
3496/**
3497 * Max buddies in buddy list.
3498 */
3499#ifndef PJSUA_MAX_BUDDIES
3500# define PJSUA_MAX_BUDDIES 256
3501#endif
3502
3503
3504/**
Benny Prijonoa17496a2007-10-31 10:20:31 +00003505 * This specifies how long the library should retry resending SUBSCRIBE
Benny Prijono53984d12009-04-28 22:19:49 +00003506 * if the previous SUBSCRIBE failed. This also controls the duration
3507 * before failed PUBLISH request will be retried.
Benny Prijonoa17496a2007-10-31 10:20:31 +00003508 *
3509 * Default: 300 seconds
3510 */
3511#ifndef PJSUA_PRES_TIMER
3512# define PJSUA_PRES_TIMER 300
3513#endif
3514
3515
3516/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003517 * This structure describes buddy configuration when adding a buddy to
3518 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
3519 * the structure with #pjsua_buddy_config_default() to initialize this
3520 * structure with default configuration.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003521 *
3522 * \par Python:
3523 * In Python this structure is <tt>py_pjsua.Buddy_Config</tt>. However
3524 * it is recommended that application instantiates the buddy config
3525 * by calling:
3526 * \code
3527 buddy_cfg = py_pjsua.buddy_config_default()
3528 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003529 */
3530typedef struct pjsua_buddy_config
3531{
3532 /**
3533 * Buddy URL or name address.
3534 */
3535 pj_str_t uri;
3536
3537 /**
3538 * Specify whether presence subscription should start immediately.
3539 */
3540 pj_bool_t subscribe;
3541
Benny Prijono705e7842008-07-21 18:12:51 +00003542 /**
3543 * Specify arbitrary application data to be associated with with
3544 * the buddy object.
3545 */
3546 void *user_data;
3547
Benny Prijono312aff92006-06-17 04:08:30 +00003548} pjsua_buddy_config;
3549
3550
3551/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003552 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003553 */
3554typedef enum pjsua_buddy_status
3555{
3556 /**
3557 * Online status is unknown (possibly because no presence subscription
3558 * has been established).
3559 */
3560 PJSUA_BUDDY_STATUS_UNKNOWN,
3561
3562 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003563 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003564 */
3565 PJSUA_BUDDY_STATUS_ONLINE,
3566
3567 /**
3568 * Buddy is offline.
3569 */
3570 PJSUA_BUDDY_STATUS_OFFLINE,
3571
3572} pjsua_buddy_status;
3573
3574
3575
3576/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003577 * This structure describes buddy info, which can be retrieved by calling
3578 * #pjsua_buddy_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003579 *
3580 * \par Python:
3581 * This structure in Python is <tt>py_pjsua.Buddy_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003582 */
3583typedef struct pjsua_buddy_info
3584{
3585 /**
3586 * The buddy ID.
3587 */
3588 pjsua_buddy_id id;
3589
3590 /**
3591 * The full URI of the buddy, as specified in the configuration.
3592 */
3593 pj_str_t uri;
3594
3595 /**
3596 * Buddy's Contact, only available when presence subscription has
3597 * been established to the buddy.
3598 */
3599 pj_str_t contact;
3600
3601 /**
3602 * Buddy's online status.
3603 */
3604 pjsua_buddy_status status;
3605
3606 /**
3607 * Text to describe buddy's online status.
3608 */
3609 pj_str_t status_text;
3610
3611 /**
3612 * Flag to indicate that we should monitor the presence information for
3613 * this buddy (normally yes, unless explicitly disabled).
3614 */
3615 pj_bool_t monitor_pres;
3616
3617 /**
Benny Prijono63fba012008-07-17 14:19:10 +00003618 * If \a monitor_pres is enabled, this specifies the last state of the
3619 * presence subscription. If presence subscription session is currently
3620 * active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence
3621 * subscription request has been rejected, the value will be
3622 * PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be
3623 * specified in \a sub_term_reason.
3624 */
3625 pjsip_evsub_state sub_state;
3626
3627 /**
3628 * Specifies the last presence subscription terminatino reason. If
3629 * presence subscription is currently active, the value will be empty.
3630 */
3631 pj_str_t sub_term_reason;
3632
3633 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003634 * Extended RPID information about the person.
3635 */
3636 pjrpid_element rpid;
3637
3638 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003639 * Internal buffer.
3640 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003641 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003642
3643} pjsua_buddy_info;
3644
3645
Benny Prijono834aee32006-02-19 01:38:06 +00003646/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003647 * Set default values to the buddy config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003648 *
3649 * \par Python:
3650 * \code
3651 buddy_cfg = py_pjsua.buddy_config_default()
3652 * \endcode
Benny Prijonob5388cf2007-01-04 22:45:08 +00003653 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003654PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003655
3656
3657/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003658 * Get total number of buddies.
3659 *
3660 * @return Number of buddies.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003661 *
3662 * \par Python:
3663 * \code
3664 buddy_count = py_pjsua.get_buddy_count()
3665 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003666 */
3667PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3668
3669
3670/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003671 * Check if buddy ID is valid.
3672 *
3673 * @param buddy_id Buddy ID to check.
3674 *
3675 * @return Non-zero if buddy ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003676 *
3677 * \par Python:
3678 * \code
3679 is_valid = py_pjsua.buddy_is_valid(buddy_id)
3680 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003681 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003682PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3683
3684
3685/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003686 * Enumerate all buddy IDs in the buddy list. Application then can use
3687 * #pjsua_buddy_get_info() to get the detail information for each buddy
3688 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003689 *
3690 * @param ids Array of ids to be initialized.
3691 * @param count On input, specifies max elements in the array.
3692 * On return, it contains actual number of elements
3693 * that have been initialized.
3694 *
3695 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003696 *
3697 * \par Python:
3698 * The Python function takes no argument and returns list of buddy IDs:
3699 * \code
3700 [buddy_ids] = py_pjsua.enum_buddies()
3701 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003702 */
3703PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3704 unsigned *count);
3705
3706/**
Benny Prijono705e7842008-07-21 18:12:51 +00003707 * Find the buddy ID with the specified URI.
3708 *
3709 * @param uri The buddy URI.
3710 *
3711 * @return The buddy ID, or PJSUA_INVALID_ID if not found.
3712 */
3713PJ_DECL(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri);
3714
3715
3716/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003717 * Get detailed buddy info.
3718 *
3719 * @param buddy_id The buddy identification.
3720 * @param info Pointer to receive information about buddy.
3721 *
3722 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003723 *
3724 * \par Python:
3725 * \code
3726 buddy_info = py_pjsua.buddy_get_info(buddy_id)
3727 * \endcode
3728 * The function returns None if buddy_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003729 */
3730PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003731 pjsua_buddy_info *info);
3732
3733/**
Benny Prijono705e7842008-07-21 18:12:51 +00003734 * Set the user data associated with the buddy object.
3735 *
3736 * @param buddy_id The buddy identification.
3737 * @param user_data Arbitrary application data to be associated with
3738 * the buddy object.
3739 *
3740 * @return PJ_SUCCESS on success, or the appropriate error code.
3741 */
3742PJ_DECL(pj_status_t) pjsua_buddy_set_user_data(pjsua_buddy_id buddy_id,
3743 void *user_data);
3744
3745
3746/**
3747 * Get the user data associated with the budy object.
3748 *
3749 * @param buddy_id The buddy identification.
3750 *
3751 * @return The application data.
3752 */
3753PJ_DECL(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id);
3754
3755
3756/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003757 * Add new buddy to the buddy list. If presence subscription is enabled
3758 * for this buddy, this function will also start the presence subscription
3759 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003760 *
Benny Prijonoa7b376b2008-01-25 16:06:33 +00003761 * @param buddy_cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003762 * @param p_buddy_id Pointer to receive buddy ID.
3763 *
3764 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003765 *
3766 * \par Python:
3767 * The function returns (status, buddy_id) tuple:
3768 * \code
3769 status, buddy_id = py_pjsua.buddy_add(buddy_cfg)
3770 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003771 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003772PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003773 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003774
3775
3776/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003777 * Delete the specified buddy from the buddy list. Any presence subscription
3778 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003779 *
3780 * @param buddy_id Buddy identification.
3781 *
3782 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003783 *
3784 * \par Python:
3785 * \code
3786 status = py_pjsua.buddy_del(buddy_id)
3787 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +00003788 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003789PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003790
3791
3792/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003793 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3794 * subscribed, application will be informed about buddy's presence status
3795 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003796 *
3797 * @param buddy_id Buddy identification.
3798 * @param subscribe Specify non-zero to activate presence subscription to
3799 * the specified buddy.
3800 *
3801 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003802 *
3803 * \par Python:
3804 * \code
3805 status = py_pjsua.buddy_subscribe_pres(buddy_id, subscribe)
3806 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003807 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003808PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3809 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003810
3811
3812/**
Benny Prijono10861432007-10-31 10:54:53 +00003813 * Update the presence information for the buddy. Although the library
3814 * periodically refreshes the presence subscription for all buddies, some
3815 * application may want to refresh the buddy's presence subscription
3816 * immediately, and in this case it can use this function to accomplish
3817 * this.
3818 *
3819 * Note that the buddy's presence subscription will only be initiated
3820 * if presence monitoring is enabled for the buddy. See
3821 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
3822 * for the buddy is already active, this function will not do anything.
3823 *
3824 * Once the presence subscription is activated successfully for the buddy,
3825 * application will be notified about the buddy's presence status in the
3826 * on_buddy_state() callback.
3827 *
3828 * @param buddy_id Buddy identification.
3829 *
3830 * @return PJ_SUCCESS on success, or the appropriate error code.
3831 */
3832PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
3833
3834
3835/**
Benny Prijono63fba012008-07-17 14:19:10 +00003836 * Send NOTIFY to inform account presence status or to terminate server
3837 * side presence subscription. If application wants to reject the incoming
3838 * request, it should set the \a state to PJSIP_EVSUB_STATE_TERMINATED.
3839 *
3840 * @param acc_id Account ID.
3841 * @param srv_pres Server presence subscription instance.
3842 * @param state New state to set.
3843 * @param state_str Optionally specify the state string name, if state
3844 * is not "active", "pending", or "terminated".
3845 * @param reason If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3846 * optionally specify the termination reason.
3847 * @param with_body If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3848 * this specifies whether the NOTIFY request should
3849 * contain message body containing account's presence
3850 * information.
3851 * @param msg_data Optional list of headers to be sent with the NOTIFY
3852 * request.
3853 *
3854 * @return PJ_SUCCESS on success.
3855 */
3856PJ_DECL(pj_status_t) pjsua_pres_notify(pjsua_acc_id acc_id,
3857 pjsua_srv_pres *srv_pres,
3858 pjsip_evsub_state state,
3859 const pj_str_t *state_str,
3860 const pj_str_t *reason,
3861 pj_bool_t with_body,
3862 const pjsua_msg_data *msg_data);
3863
3864/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003865 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003866 *
3867 * @param verbose Yes or no.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003868 *
3869 * \par Python:
3870 * \code
3871 py_pjsua.pres_dump()
3872 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003873 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003874PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003875
3876
Benny Prijonob0808372006-03-02 21:18:58 +00003877/**
3878 * The MESSAGE method (defined in pjsua_im.c)
3879 */
3880extern const pjsip_method pjsip_message_method;
3881
3882
Benny Prijonob0808372006-03-02 21:18:58 +00003883
3884/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003885 * Send instant messaging outside dialog, using the specified account for
3886 * route set and authentication.
3887 *
3888 * @param acc_id Account ID to be used to send the request.
3889 * @param to Remote URI.
3890 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3891 * assumed.
3892 * @param content The message content.
3893 * @param msg_data Optional list of headers etc to be included in outgoing
3894 * request. The body descriptor in the msg_data is
3895 * ignored.
3896 * @param user_data Optional user data, which will be given back when
3897 * the IM callback is called.
3898 *
3899 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003900 *
3901 * \par Python:
3902 * \code
3903 status = py_pjsua.im_send(acc_id, to, mime_type, content, msg_data, user_data)
3904 * \endcode
3905 * Arguments \a mime_type and \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003906 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003907PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3908 const pj_str_t *to,
3909 const pj_str_t *mime_type,
3910 const pj_str_t *content,
3911 const pjsua_msg_data *msg_data,
3912 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003913
3914
3915/**
3916 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003917 *
3918 * @param acc_id Account ID to be used to send the request.
3919 * @param to Remote URI.
3920 * @param is_typing If non-zero, it tells remote person that local person
3921 * is currently composing an IM.
3922 * @param msg_data Optional list of headers etc to be added to outgoing
3923 * request.
3924 *
3925 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003926 *
3927 * \par Python:
3928 * \code
3929 status = py_pjsua.im_typing(acc_id, to, is_typing, msg_data)
3930 * \endcode
3931 * Argument \a msg_data may be set to None if not requried.
Benny Prijonob0808372006-03-02 21:18:58 +00003932 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003933PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3934 const pj_str_t *to,
3935 pj_bool_t is_typing,
3936 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003937
3938
Benny Prijonof3195072006-02-14 21:15:30 +00003939
Benny Prijono312aff92006-06-17 04:08:30 +00003940/**
3941 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003942 */
3943
Benny Prijono312aff92006-06-17 04:08:30 +00003944
3945/*****************************************************************************
3946 * MEDIA API
3947 */
3948
3949
3950/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003951 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003952 * @ingroup PJSUA_LIB
3953 * @brief Media manipulation.
3954 * @{
3955 *
3956 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003957 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3958 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003959 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003960 * the interconnection between these terminations freely.
3961 *
3962 * The conference bridge provides powerful switching and mixing functionality
3963 * for application. With the conference bridge, each conference slot (e.g.
3964 * a call) can transmit to multiple destinations, and one destination can
3965 * receive from multiple sources. If more than one media terminations are
3966 * terminated in the same slot, the conference bridge will mix the signal
3967 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00003968 *
3969 * Application connects one media termination/slot to another by calling
3970 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003971 * media flow from the source termination to the sink termination. To
3972 * establish bidirectional media flow, application wound need to make another
3973 * call to #pjsua_conf_connect(), this time inverting the source and
3974 * destination slots in the parameter.
3975 *
3976 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00003977 * the following steps:
3978 *
3979 \code
3980
3981 pj_status_t stream_to_call( pjsua_call_id call_id )
3982 {
3983 pjsua_player_id player_id;
3984
3985 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
3986 if (status != PJ_SUCCESS)
3987 return status;
3988
3989 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
3990 pjsua_call_get_conf_port() );
3991 }
3992 \endcode
3993 *
3994 *
3995 * Other features of PJSUA media:
3996 * - efficient N to M interconnections between media terminations.
3997 * - media termination can be connected to itself to create loopback
3998 * media.
3999 * - the media termination may have different clock rates, and resampling
4000 * will be done automatically by conference bridge.
4001 * - media terminations may also have different frame time; the
4002 * conference bridge will perform the necessary bufferring to adjust
4003 * the difference between terminations.
4004 * - interconnections are removed automatically when media termination
4005 * is removed from the bridge.
4006 * - sound device may be changed even when there are active media
4007 * interconnections.
4008 * - correctly report call's media quality (in #pjsua_call_dump()) from
4009 * RTCP packet exchange.
4010 */
4011
4012/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004013 * Max ports in the conference bridge. This setting is the default value
4014 * for pjsua_media_config.max_media_ports.
Benny Prijono312aff92006-06-17 04:08:30 +00004015 */
4016#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00004017# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00004018#endif
4019
Benny Prijonob5388cf2007-01-04 22:45:08 +00004020/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004021 * The default clock rate to be used by the conference bridge. This setting
4022 * is the default value for pjsua_media_config.clock_rate.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004023 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004024#ifndef PJSUA_DEFAULT_CLOCK_RATE
4025# define PJSUA_DEFAULT_CLOCK_RATE 16000
4026#endif
4027
Benny Prijonob5388cf2007-01-04 22:45:08 +00004028/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004029 * Default frame length in the conference bridge. This setting
4030 * is the default value for pjsua_media_config.audio_frame_ptime.
4031 */
4032#ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Nanang Izzuddinaf974842008-05-08 09:51:16 +00004033# define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
Benny Prijono37c710b2008-01-10 12:09:26 +00004034#endif
4035
4036
4037/**
4038 * Default codec quality settings. This setting is the default value
4039 * for pjsua_media_config.quality.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004040 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004041#ifndef PJSUA_DEFAULT_CODEC_QUALITY
Nanang Izzuddin9dbad152008-06-10 18:56:10 +00004042# define PJSUA_DEFAULT_CODEC_QUALITY 8
Benny Prijono12a669c2006-11-23 07:32:13 +00004043#endif
4044
Benny Prijonob5388cf2007-01-04 22:45:08 +00004045/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004046 * Default iLBC mode. This setting is the default value for
4047 * pjsua_media_config.ilbc_mode.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004048 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004049#ifndef PJSUA_DEFAULT_ILBC_MODE
Benny Prijono37c710b2008-01-10 12:09:26 +00004050# define PJSUA_DEFAULT_ILBC_MODE 30
Benny Prijono12a669c2006-11-23 07:32:13 +00004051#endif
4052
Benny Prijonob5388cf2007-01-04 22:45:08 +00004053/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004054 * The default echo canceller tail length. This setting
4055 * is the default value for pjsua_media_config.ec_tail_len.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004056 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004057#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijono427439c2007-10-21 09:41:24 +00004058# define PJSUA_DEFAULT_EC_TAIL_LEN 200
Benny Prijono12a669c2006-11-23 07:32:13 +00004059#endif
Benny Prijono312aff92006-06-17 04:08:30 +00004060
4061
4062/**
Benny Prijonocba59d92007-02-16 09:22:56 +00004063 * The maximum file player.
4064 */
4065#ifndef PJSUA_MAX_PLAYERS
4066# define PJSUA_MAX_PLAYERS 32
4067#endif
4068
4069
4070/**
4071 * The maximum file player.
4072 */
4073#ifndef PJSUA_MAX_RECORDERS
4074# define PJSUA_MAX_RECORDERS 32
4075#endif
4076
4077
4078/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004079 * This structure describes media configuration, which will be specified
4080 * when calling #pjsua_init(). Application MUST initialize this structure
4081 * by calling #pjsua_media_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00004082 *
4083 * \par Python:
4084 * This data type in Python is <tt>py_pjsua.Media_Config</tt>. To create
4085 * an object of this type, it is recommended to call
4086 * <tt>py_pjsua.media_config_default()</tt> function instead:
4087 * \code
4088 media_cfg = py_pjsua.media_config_default()
4089 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00004090 */
4091struct pjsua_media_config
4092{
4093 /**
4094 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004095 * If value is zero, default clock rate will be used
4096 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00004097 */
4098 unsigned clock_rate;
4099
4100 /**
Benny Prijonof3758ee2008-02-26 15:32:16 +00004101 * Clock rate to be applied when opening the sound device.
4102 * If value is zero, conference bridge clock rate will be used.
4103 */
4104 unsigned snd_clock_rate;
4105
4106 /**
Benny Prijono7d60d052008-03-29 12:24:20 +00004107 * Channel count be applied when opening the sound device and
4108 * conference bridge.
4109 */
4110 unsigned channel_count;
4111
4112 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004113 * Specify audio frame ptime. The value here will affect the
4114 * samples per frame of both the sound device and the conference
4115 * bridge. Specifying lower ptime will normally reduce the
4116 * latency.
4117 *
Benny Prijono37c710b2008-01-10 12:09:26 +00004118 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004119 */
4120 unsigned audio_frame_ptime;
4121
4122 /**
Benny Prijono312aff92006-06-17 04:08:30 +00004123 * Specify maximum number of media ports to be created in the
4124 * conference bridge. Since all media terminate in the bridge
4125 * (calls, file player, file recorder, etc), the value must be
4126 * large enough to support all of them. However, the larger
4127 * the value, the more computations are performed.
Benny Prijono37c710b2008-01-10 12:09:26 +00004128 *
4129 * Default value: PJSUA_MAX_CONF_PORTS
Benny Prijono312aff92006-06-17 04:08:30 +00004130 */
4131 unsigned max_media_ports;
4132
4133 /**
4134 * Specify whether the media manager should manage its own
4135 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
4136 * and at least one worker thread will be created too. If no,
4137 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
4138 * and no worker thread is needed.
4139 *
4140 * Normally application would say yes here, unless it wants to
4141 * run everything from a single thread.
4142 */
4143 pj_bool_t has_ioqueue;
4144
4145 /**
4146 * Specify the number of worker threads to handle incoming RTP
4147 * packets. A value of one is recommended for most applications.
4148 */
4149 unsigned thread_cnt;
4150
Benny Prijono0498d902006-06-19 14:49:14 +00004151 /**
4152 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00004153 * 5-10: resampling use large filter,
4154 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00004155 * 1-2: resampling use linear.
4156 * The media quality also sets speex codec quality/complexity to the
4157 * number.
4158 *
Benny Prijono70972992006-08-05 11:13:58 +00004159 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00004160 */
4161 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00004162
4163 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004164 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00004165 *
4166 * Default: 0 (codec specific)
4167 */
4168 unsigned ptime;
4169
4170 /**
4171 * Disable VAD?
4172 *
4173 * Default: 0 (no (meaning VAD is enabled))
4174 */
4175 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00004176
4177 /**
4178 * iLBC mode (20 or 30).
4179 *
Benny Prijono37c710b2008-01-10 12:09:26 +00004180 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00004181 */
4182 unsigned ilbc_mode;
4183
4184 /**
4185 * Percentage of RTP packet to drop in TX direction
4186 * (to simulate packet lost).
4187 *
4188 * Default: 0
4189 */
4190 unsigned tx_drop_pct;
4191
4192 /**
4193 * Percentage of RTP packet to drop in RX direction
4194 * (to simulate packet lost).
4195 *
4196 * Default: 0
4197 */
4198 unsigned rx_drop_pct;
4199
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004200 /**
Benny Prijono5da50432006-08-07 10:24:52 +00004201 * Echo canceller options (see #pjmedia_echo_create())
4202 *
4203 * Default: 0.
4204 */
4205 unsigned ec_options;
4206
4207 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004208 * Echo canceller tail length, in miliseconds.
4209 *
Benny Prijono669643c2006-09-20 20:02:18 +00004210 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004211 */
4212 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004213
Benny Prijono10454dc2009-02-21 14:21:59 +00004214 /**
4215 * Audio capture buffer length, in milliseconds.
4216 *
4217 * Default: PJMEDIA_SND_DEFAULT_REC_LATENCY
4218 */
4219 unsigned snd_rec_latency;
4220
4221 /**
4222 * Audio playback buffer length, in milliseconds.
4223 *
4224 * Default: PJMEDIA_SND_DEFAULT_PLAY_LATENCY
4225 */
4226 unsigned snd_play_latency;
4227
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004228 /**
4229 * Jitter buffer initial prefetch delay in msec. The value must be
4230 * between jb_min_pre and jb_max_pre below.
4231 *
4232 * Default: -1 (to use default stream settings, currently 150 msec)
4233 */
4234 int jb_init;
4235
4236 /**
4237 * Jitter buffer minimum prefetch delay in msec.
4238 *
4239 * Default: -1 (to use default stream settings, currently 60 msec)
4240 */
4241 int jb_min_pre;
4242
4243 /**
4244 * Jitter buffer maximum prefetch delay in msec.
4245 *
4246 * Default: -1 (to use default stream settings, currently 240 msec)
4247 */
4248 int jb_max_pre;
4249
4250 /**
4251 * Set maximum delay that can be accomodated by the jitter buffer msec.
4252 *
4253 * Default: -1 (to use default stream settings, currently 360 msec)
4254 */
4255 int jb_max;
4256
Benny Prijonoc97608e2007-03-23 16:34:20 +00004257 /**
4258 * Enable ICE
4259 */
4260 pj_bool_t enable_ice;
4261
4262 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00004263 * Disable ICE host candidates.
Benny Prijonoc97608e2007-03-23 16:34:20 +00004264 */
Benny Prijonof76e1392008-06-06 14:51:48 +00004265 pj_bool_t ice_no_host_cands;
4266
4267 /**
Benny Prijono551af422008-08-07 09:55:52 +00004268 * Disable RTCP component.
4269 *
4270 * Default: no
4271 */
4272 pj_bool_t ice_no_rtcp;
4273
4274 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00004275 * Enable TURN relay candidate in ICE.
4276 */
4277 pj_bool_t enable_turn;
4278
4279 /**
4280 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
4281 * "HOST:PORT" format.
4282 */
4283 pj_str_t turn_server;
4284
4285 /**
4286 * Specify the connection type to be used to the TURN server. Valid
4287 * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP.
4288 *
4289 * Default: PJ_TURN_TP_UDP
4290 */
4291 pj_turn_tp_type turn_conn_type;
4292
4293 /**
4294 * Specify the credential to authenticate with the TURN server.
4295 */
4296 pj_stun_auth_cred turn_auth_cred;
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004297
4298 /**
4299 * Specify idle time of sound device before it is automatically closed,
Benny Prijonof798e502009-03-09 13:08:16 +00004300 * in seconds. Use value -1 to disable the auto-close feature of sound
4301 * device
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004302 *
Benny Prijonof798e502009-03-09 13:08:16 +00004303 * Default : 1
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004304 */
4305 int snd_auto_close_time;
Benny Prijono312aff92006-06-17 04:08:30 +00004306};
4307
4308
4309/**
4310 * Use this function to initialize media config.
4311 *
4312 * @param cfg The media config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004313 *
4314 * \par Python:
4315 * \code
4316 media_cfg = py_pjsua.media_config_default()
4317 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00004318 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00004319PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00004320
4321
4322/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004323 * This structure describes codec information, which can be retrieved by
4324 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00004325 */
4326typedef struct pjsua_codec_info
4327{
4328 /**
4329 * Codec unique identification.
4330 */
4331 pj_str_t codec_id;
4332
4333 /**
4334 * Codec priority (integer 0-255).
4335 */
4336 pj_uint8_t priority;
4337
4338 /**
4339 * Internal buffer.
4340 */
4341 char buf_[32];
4342
4343} pjsua_codec_info;
4344
4345
4346/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004347 * This structure descibes information about a particular media port that
4348 * has been registered into the conference bridge. Application can query
4349 * this info by calling #pjsua_conf_get_port_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00004350 *
4351 * \par Python:
4352 * In Python, this type is <tt>py_pjsua.Conf_Port_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00004353 */
4354typedef struct pjsua_conf_port_info
4355{
4356 /** Conference port number. */
4357 pjsua_conf_port_id slot_id;
4358
4359 /** Port name. */
4360 pj_str_t name;
4361
4362 /** Clock rate. */
4363 unsigned clock_rate;
4364
4365 /** Number of channels. */
4366 unsigned channel_count;
4367
4368 /** Samples per frame */
4369 unsigned samples_per_frame;
4370
4371 /** Bits per sample */
4372 unsigned bits_per_sample;
4373
4374 /** Number of listeners in the array. */
4375 unsigned listener_cnt;
4376
4377 /** Array of listeners (in other words, ports where this port is
4378 * transmitting to.
4379 */
4380 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
4381
4382} pjsua_conf_port_info;
4383
4384
4385/**
4386 * This structure holds information about custom media transport to
4387 * be registered to pjsua.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004388 *
4389 * \par Python:
4390 * Not applicable.
Benny Prijono312aff92006-06-17 04:08:30 +00004391 */
4392typedef struct pjsua_media_transport
4393{
4394 /**
4395 * Media socket information containing the address information
4396 * of the RTP and RTCP socket.
4397 */
4398 pjmedia_sock_info skinfo;
4399
4400 /**
4401 * The media transport instance.
4402 */
4403 pjmedia_transport *transport;
4404
4405} pjsua_media_transport;
4406
4407
4408
4409
Benny Prijono9fc735d2006-05-28 14:58:12 +00004410/**
4411 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004412 *
4413 * @return Maximum number of ports in the conference bridge.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004414 *
4415 * \par Python:
4416 * \code
4417 port_count = py_pjsua.conf_get_max_ports()
4418 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004419 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004420PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004421
4422
4423/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004424 * Get current number of active ports in the bridge.
4425 *
4426 * @return The number.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004427 *
4428 * \par Python:
4429 * \code
4430 count = py_pjsua.conf_get_active_ports()
4431 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004432 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004433PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
4434
4435
4436/**
4437 * Enumerate all conference ports.
4438 *
4439 * @param id Array of conference port ID to be initialized.
4440 * @param count On input, specifies max elements in the array.
4441 * On return, it contains actual number of elements
4442 * that have been initialized.
4443 *
4444 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004445 *
4446 * \par Python:
4447 * The Python functions returns list of conference port Ids:
4448 * \code
4449 [port_ids] = py_pjsua.enum_conf_ports()
4450 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004451 */
4452PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
4453 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004454
4455
4456/**
4457 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004458 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004459 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004460 * @param info Pointer to store the port info.
4461 *
4462 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004463 *
4464 * \par Python:
4465 * \code
4466 port_info = py_pjsua.conf_get_port_info(port_id)
4467 * \endcode
4468 * The function will return None if \a port_id is not valid.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004469 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004470PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00004471 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004472
4473
4474/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00004475 * Add arbitrary media port to PJSUA's conference bridge. Application
4476 * can use this function to add the media port that it creates. For
4477 * media ports that are created by PJSUA-LIB (such as calls, file player,
4478 * or file recorder), PJSUA-LIB will automatically add the port to
4479 * the bridge.
4480 *
4481 * @param pool Pool to use.
4482 * @param port Media port to be added to the bridge.
4483 * @param p_id Optional pointer to receive the conference
4484 * slot id.
4485 *
4486 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004487 *
4488 * \par Python:
4489 * Not applicable (for now)
Benny Prijonoe909eac2006-07-27 22:04:56 +00004490 */
4491PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
4492 pjmedia_port *port,
4493 pjsua_conf_port_id *p_id);
4494
4495
4496/**
4497 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00004498 * call this function if it registered the port manually with previous call
4499 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00004500 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004501 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00004502 *
4503 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004504 *
4505 * \par Python:
4506 * \code
4507 status = py_pjsua.conf_remove_port(port_id)
4508 * \endcode
Benny Prijonoe909eac2006-07-27 22:04:56 +00004509 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004510PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00004511
4512
4513/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004514 * Establish unidirectional media flow from souce to sink. One source
4515 * may transmit to multiple destinations/sink. And if multiple
4516 * sources are transmitting to the same sink, the media will be mixed
4517 * together. Source and sink may refer to the same ID, effectively
4518 * looping the media.
4519 *
4520 * If bidirectional media flow is desired, application needs to call
4521 * this function twice, with the second one having the arguments
4522 * reversed.
4523 *
4524 * @param source Port ID of the source media/transmitter.
4525 * @param sink Port ID of the destination media/received.
4526 *
4527 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004528 *
4529 * \par Python:
4530 * \code
4531 status = py_pjsua.conf_connect(source, sink)
4532 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004533 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004534PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
4535 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004536
4537
4538/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004539 * Disconnect media flow from the source to destination port.
4540 *
4541 * @param source Port ID of the source media/transmitter.
4542 * @param sink Port ID of the destination media/received.
4543 *
4544 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004545 *
4546 * \par Python:
4547 * \code
4548 status = py_pjsua.conf_disconnect(source, sink)
4549 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004550 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004551PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
4552 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004553
4554
Benny Prijono6dd967c2006-12-26 02:27:14 +00004555/**
4556 * Adjust the signal level to be transmitted from the bridge to the
4557 * specified port by making it louder or quieter.
4558 *
4559 * @param slot The conference bridge slot number.
4560 * @param level Signal level adjustment. Value 1.0 means no level
4561 * adjustment, while value 0 means to mute the port.
4562 *
4563 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004564 *
4565 * \par Python:
4566 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004567 */
4568PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
4569 float level);
4570
4571/**
4572 * Adjust the signal level to be received from the specified port (to
4573 * the bridge) by making it louder or quieter.
4574 *
4575 * @param slot The conference bridge slot number.
4576 * @param level Signal level adjustment. Value 1.0 means no level
4577 * adjustment, while value 0 means to mute the port.
4578 *
4579 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004580 *
4581 * \par Python:
4582 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004583 */
4584PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
4585 float level);
4586
4587/**
4588 * Get last signal level transmitted to or received from the specified port.
4589 * The signal level is an integer value in zero to 255, with zero indicates
4590 * no signal, and 255 indicates the loudest signal level.
4591 *
4592 * @param slot The conference bridge slot number.
4593 * @param tx_level Optional argument to receive the level of signal
4594 * transmitted to the specified port (i.e. the direction
4595 * is from the bridge to the port).
4596 * @param rx_level Optional argument to receive the level of signal
4597 * received from the port (i.e. the direction is from the
4598 * port to the bridge).
4599 *
4600 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004601 *
4602 * \par Python:
4603 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004604 */
4605PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
4606 unsigned *tx_level,
4607 unsigned *rx_level);
4608
Benny Prijono6dd967c2006-12-26 02:27:14 +00004609
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004610/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00004611 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004612 */
4613
Benny Prijono9fc735d2006-05-28 14:58:12 +00004614/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004615 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004616 * the conference bridge.
4617 *
4618 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00004619 * WAV files are supported, and the WAV file MUST be
4620 * formatted as 16bit PCM mono/single channel (any
4621 * clock rate is supported).
Benny Prijono58add7c2008-01-18 13:24:07 +00004622 * @param options Optional option flag. Application may specify
4623 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004624 * @param p_id Pointer to receive player ID.
4625 *
4626 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004627 *
4628 * \par Python:
4629 * The function returns (status, id) tuple:
4630 * \code
4631 status, id = py_pjsua.player_create(filename, options)
4632 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004633 */
4634PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004635 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004636 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004637
4638
4639/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004640 * Create a file playlist media port, and automatically add the port
4641 * to the conference bridge.
4642 *
4643 * @param file_names Array of file names to be added to the play list.
4644 * Note that the files must have the same clock rate,
4645 * number of channels, and number of bits per sample.
4646 * @param file_count Number of files in the array.
4647 * @param label Optional label to be set for the media port.
4648 * @param options Optional option flag. Application may specify
4649 * PJMEDIA_FILE_NO_LOOP to prevent looping.
4650 * @param p_id Optional pointer to receive player ID.
4651 *
4652 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004653 *
4654 * \par Python:
4655 * Not implemented yet.
Benny Prijonoa66c3312007-01-21 23:12:40 +00004656 */
4657PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
4658 unsigned file_count,
4659 const pj_str_t *label,
4660 unsigned options,
4661 pjsua_player_id *p_id);
4662
4663/**
4664 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004665 *
4666 * @param id The file player ID.
4667 *
4668 * @return Conference port ID associated with this player.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004669 *
4670 * \par Python:
4671 * \code
4672 port_id = py_pjsua.player_get_conf_port(id)
4673 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004674 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004675PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004676
4677
4678/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004679 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00004680 *
4681 * @param id The player ID.
4682 * @param p_port The media port associated with the player.
4683 *
4684 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004685 *
4686 * \par Python:
4687 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004688 */
Benny Prijono58add7c2008-01-18 13:24:07 +00004689PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
Benny Prijono469b1522006-12-26 03:05:17 +00004690 pjmedia_port **p_port);
4691
4692/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004693 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004694 *
4695 * @param id The file player ID.
4696 * @param samples The playback position, in samples. Application can
4697 * specify zero to re-start the playback.
4698 *
4699 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004700 *
4701 * \par Python:
4702 * \code
4703 status = py_pjsua.player_set_pos(id, samples)
4704 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004705 */
4706PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
4707 pj_uint32_t samples);
4708
4709
4710/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004711 * Close the file of playlist, remove the player from the bridge, and free
4712 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004713 *
4714 * @param id The file player ID.
4715 *
4716 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004717 *
4718 * \par Python:
4719 * \code
4720 status = py_pjsua.player_destroy(id)
4721 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004722 */
4723PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
4724
4725
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004726/*****************************************************************************
4727 * File recorder.
4728 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00004729
4730/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004731 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004732 * the conference bridge. The recorder currently supports recording WAV file.
4733 * The type of the recorder to use is determined by the extension of the file
4734 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004735 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00004736 * @param filename Output file name. The function will determine the
4737 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004738 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00004739 * @param enc_type Optionally specify the type of encoder to be used to
4740 * compress the media, if the file can support different
4741 * encodings. This value must be zero for now.
4742 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004743 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00004744 * For .WAV recorder, this value must be NULL.
4745 * @param max_size Maximum file size. Specify zero or -1 to remove size
4746 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004747 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004748 * @param p_id Pointer to receive the recorder instance.
4749 *
4750 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004751 *
4752 * \par Python:
4753 * \code
4754 status, id = py_pjsua.recorder_create(filename, enc_type, enc_param, max_size, options)
4755 * \endcode
4756 * The \a enc_param is a string in Python.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004757 */
4758PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004759 unsigned enc_type,
4760 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004761 pj_ssize_t max_size,
4762 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004763 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004764
4765
4766/**
4767 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004768 *
4769 * @param id The recorder ID.
4770 *
4771 * @return Conference port ID associated with this recorder.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004772 *
4773 * \par Python:
4774 * \code
4775 port_id = py_pjsua.recorder_get_conf_port(id)
4776 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004777 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004778PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004779
4780
4781/**
Benny Prijono469b1522006-12-26 03:05:17 +00004782 * Get the media port for the recorder.
4783 *
4784 * @param id The recorder ID.
4785 * @param p_port The media port associated with the recorder.
4786 *
4787 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004788 *
4789 * \par Python:
4790 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004791 */
4792PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4793 pjmedia_port **p_port);
4794
4795
4796/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004797 * Destroy recorder (this will complete recording).
4798 *
4799 * @param id The recorder ID.
4800 *
4801 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004802 *
4803 * \par Python:
4804 * \code
4805 status = py_pjsua.recorder_destroy(id)
4806 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004807 */
4808PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4809
4810
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004811/*****************************************************************************
4812 * Sound devices.
4813 */
4814
Benny Prijono9fc735d2006-05-28 14:58:12 +00004815/**
Benny Prijonof798e502009-03-09 13:08:16 +00004816 * Enum all audio devices installed in the system.
4817 *
4818 * @param info Array of info to be initialized.
4819 * @param count On input, specifies max elements in the array.
4820 * On return, it contains actual number of elements
4821 * that have been initialized.
4822 *
4823 * @return PJ_SUCCESS on success, or the appropriate error code.
4824 */
4825PJ_DECL(pj_status_t) pjsua_enum_aud_devs(pjmedia_aud_dev_info info[],
4826 unsigned *count);
4827
4828/**
4829 * Enum all sound devices installed in the system (old API).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004830 *
4831 * @param info Array of info to be initialized.
4832 * @param count On input, specifies max elements in the array.
4833 * On return, it contains actual number of elements
4834 * that have been initialized.
4835 *
4836 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004837 *
4838 *
4839 * \par Python:
4840 * The function returns list of sound device info:
4841 * \code
4842 [dev_infos] = py_pjsua.enum_snd_devs()
4843 * \endcode
4844 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00004845 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004846PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4847 unsigned *count);
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004848
4849/**
4850 * Get currently active sound devices. If sound devices has not been created
4851 * (for example when pjsua_start() is not called), it is possible that
4852 * the function returns PJ_SUCCESS with -1 as device IDs.
4853 *
4854 * @param capture_dev On return it will be filled with device ID of the
4855 * capture device.
4856 * @param playback_dev On return it will be filled with device ID of the
4857 * device ID of the playback device.
4858 *
4859 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004860 *
4861 * \par Python:
Benny Prijonoebdf8772007-02-01 19:25:50 +00004862 * The function takes no argument and return an (integer,integer) tuple:
Benny Prijonoe6ead542007-01-31 20:53:31 +00004863 * \code
4864 capture_dev, playback_dev = py_pjsua.get_snd_dev()
4865 * \endcode
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004866 */
4867PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4868 int *playback_dev);
4869
4870
Benny Prijono9fc735d2006-05-28 14:58:12 +00004871/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004872 * Select or change sound device. Application may call this function at
4873 * any time to replace current sound device.
4874 *
4875 * @param capture_dev Device ID of the capture device.
4876 * @param playback_dev Device ID of the playback device.
4877 *
4878 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004879 *
4880 * \par Python:
4881 * \code
4882 status = py_pjsua.set_snd_dev(capture_dev, playback_dev)
4883 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004884 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004885PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4886 int playback_dev);
4887
4888
4889/**
4890 * Set pjsua to use null sound device. The null sound device only provides
4891 * the timing needed by the conference bridge, and will not interract with
4892 * any hardware.
4893 *
4894 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004895 *
4896 * \par Python:
4897 * \code
4898 status = py_pjsua.set_null_snd_dev()
4899 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004900 */
4901PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4902
4903
Benny Prijonoe909eac2006-07-27 22:04:56 +00004904/**
4905 * Disconnect the main conference bridge from any sound devices, and let
4906 * application connect the bridge to it's own sound device/master port.
4907 *
4908 * @return The port interface of the conference bridge,
4909 * so that application can connect this to it's own
4910 * sound device or master port.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004911 *
4912 * \par Python:
4913 * Not applicable (for now).
Benny Prijonoe909eac2006-07-27 22:04:56 +00004914 */
4915PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4916
4917
Benny Prijonof20687a2006-08-04 18:27:19 +00004918/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004919 * Change the echo cancellation settings.
Benny Prijonof798e502009-03-09 13:08:16 +00004920 *
4921 * The behavior of this function depends on whether the sound device is
4922 * currently active, and if it is, whether device or software AEC is
4923 * being used.
Benny Prijono10454dc2009-02-21 14:21:59 +00004924 *
4925 * If the sound device is currently active, and if the device supports AEC,
4926 * this function will forward the change request to the device and it will
4927 * be up to the device on whether support the request. If software AEC is
4928 * being used (the software EC will be used if the device does not support
4929 * AEC), this function will change the software EC settings. In all cases,
4930 * the setting will be saved for future opening of the sound device.
4931 *
4932 * If the sound device is not currently active, this will only change the
4933 * default AEC settings and the setting will be applied next time the
4934 * sound device is opened.
Benny Prijonof20687a2006-08-04 18:27:19 +00004935 *
4936 * @param tail_ms The tail length, in miliseconds. Set to zero to
4937 * disable AEC.
Benny Prijonoa7b376b2008-01-25 16:06:33 +00004938 * @param options Options to be passed to pjmedia_echo_create().
Benny Prijono5da50432006-08-07 10:24:52 +00004939 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004940 *
4941 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004942 *
4943 * \par Python:
4944 * \code
4945 status = py_pjsua.set_ec(tail_ms, options)
4946 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004947 */
Benny Prijono5da50432006-08-07 10:24:52 +00004948PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004949
4950
4951/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004952 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004953 *
4954 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4955 * If AEC is disabled, the value will be zero.
4956 *
4957 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004958 *
4959 * \par Python:
4960 * \code
4961 tail_ms = py_pjsua.get_ec_tail()
4962 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004963 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004964PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004965
4966
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004967/**
Benny Prijonof798e502009-03-09 13:08:16 +00004968 * Check whether the sound device is currently active. The sound device
4969 * may be inactive if the application has set the auto close feature to
4970 * non-zero (the snd_auto_close_time setting in #pjsua_media_config), or
4971 * if null sound device or no sound device has been configured via the
4972 * #pjsua_set_no_snd_dev() function.
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004973 */
Benny Prijonof798e502009-03-09 13:08:16 +00004974PJ_DECL(pj_bool_t) pjsua_snd_is_active(void);
4975
4976
4977/**
4978 * Configure sound device setting to the sound device being used. If sound
4979 * device is currently active, the function will forward the setting to the
4980 * sound device instance to be applied immediately, if it supports it.
4981 *
4982 * The setting will be saved for future opening of the sound device, if the
4983 * "keep" argument is set to non-zero. If the sound device is currently
4984 * inactive, and the "keep" argument is false, this function will return
4985 * error.
4986 *
4987 * Note that in case the setting is kept for future use, it will be applied
4988 * to any devices, even when application has changed the sound device to be
4989 * used.
4990 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004991 * Note also that the echo cancellation setting should be set with
4992 * #pjsua_set_ec() API instead.
4993 *
Benny Prijonof798e502009-03-09 13:08:16 +00004994 * See also #pjmedia_aud_stream_set_cap() for more information about setting
4995 * an audio device capability.
4996 *
4997 * @param cap The sound device setting to change.
4998 * @param pval Pointer to value. Please see #pjmedia_aud_dev_cap
4999 * documentation about the type of value to be
5000 * supplied for each setting.
5001 * @param keep Specify whether the setting is to be kept for future
5002 * use.
5003 *
5004 * @return PJ_SUCCESS on success or the appropriate error code.
5005 */
5006PJ_DECL(pj_status_t) pjsua_snd_set_setting(pjmedia_aud_dev_cap cap,
5007 const void *pval,
5008 pj_bool_t keep);
5009
5010/**
5011 * Retrieve a sound device setting. If sound device is currently active,
5012 * the function will forward the request to the sound device. If sound device
5013 * is currently inactive, and if application had previously set the setting
5014 * and mark the setting as kept, then that setting will be returned.
5015 * Otherwise, this function will return error.
5016 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00005017 * Note that echo cancellation settings should be retrieved with
5018 * #pjsua_get_ec_tail() API instead.
5019 *
Benny Prijonof798e502009-03-09 13:08:16 +00005020 * @param cap The sound device setting to retrieve.
5021 * @param pval Pointer to receive the value.
5022 * Please see #pjmedia_aud_dev_cap documentation about
5023 * the type of value to be supplied for each setting.
5024 *
5025 * @return PJ_SUCCESS on success or the appropriate error code.
5026 */
5027PJ_DECL(pj_status_t) pjsua_snd_get_setting(pjmedia_aud_dev_cap cap,
5028 void *pval);
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00005029
5030
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005031/*****************************************************************************
5032 * Codecs.
5033 */
5034
5035/**
5036 * Enum all supported codecs in the system.
5037 *
5038 * @param id Array of ID to be initialized.
5039 * @param count On input, specifies max elements in the array.
5040 * On return, it contains actual number of elements
5041 * that have been initialized.
5042 *
5043 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00005044 *
5045 * \par Python:
5046 * This function takes no argument and returns list of codec infos:
5047 * \code
5048 [codec_info] = py_pjsua.enum_codecs()
5049 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005050 */
5051PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
5052 unsigned *count );
5053
5054
5055/**
5056 * Change codec priority.
5057 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00005058 * @param codec_id Codec ID, which is a string that uniquely identify
5059 * the codec (such as "speex/8000"). Please see pjsua
5060 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005061 * @param priority Codec priority, 0-255, where zero means to disable
5062 * the codec.
5063 *
5064 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00005065 *
5066 * \par Python:
5067 * \code
5068 status = py_pjsua.codec_set_priority(codec_id, priority)
5069 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005070 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00005071PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005072 pj_uint8_t priority );
5073
5074
5075/**
5076 * Get codec parameters.
5077 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00005078 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005079 * @param param Structure to receive codec parameters.
5080 *
5081 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00005082 *
5083 * \par Python:
5084 * The Python function is experimental:
5085 * \code
5086 codec_param = py_pjsua.codec_get_param(codec_id)
5087 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005088 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00005089PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005090 pjmedia_codec_param *param );
5091
5092
5093/**
5094 * Set codec parameters.
5095 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00005096 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005097 * @param param Codec parameter to set.
5098 *
5099 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00005100 *
5101 * \par Python:
5102 * The Python function is experimental:
5103 * \code
5104 status = py_pjsua.codec_set_param(codec_id, param)
5105 * \endcode
5106
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005107 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00005108PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005109 const pjmedia_codec_param *param);
5110
5111
5112
Benny Prijono9fc735d2006-05-28 14:58:12 +00005113
Benny Prijono312aff92006-06-17 04:08:30 +00005114/**
5115 * Create UDP media transports for all the calls. This function creates
5116 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00005117 *
Benny Prijono312aff92006-06-17 04:08:30 +00005118 * @param cfg Media transport configuration. The "port" field in the
5119 * configuration is used as the start port to bind the
5120 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005121 *
5122 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00005123 *
5124 * \par Python:
5125 * Not implemented yet.
Benny Prijonof3195072006-02-14 21:15:30 +00005126 */
Benny Prijono312aff92006-06-17 04:08:30 +00005127PJ_DECL(pj_status_t)
5128pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00005129
Benny Prijonodc39fe82006-05-26 12:17:46 +00005130
5131/**
Benny Prijono312aff92006-06-17 04:08:30 +00005132 * Register custom media transports to be used by calls. There must
5133 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005134 *
Benny Prijono312aff92006-06-17 04:08:30 +00005135 * @param tp The media transport array.
5136 * @param count Number of elements in the array. This number MUST
5137 * match the number of maximum calls configured when
5138 * pjsua is created.
5139 * @param auto_delete Flag to indicate whether the transports should be
5140 * destroyed when pjsua is shutdown.
5141 *
5142 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00005143 *
5144 * \par Python:
5145 * Note applicable.
Benny Prijonodc39fe82006-05-26 12:17:46 +00005146 */
Benny Prijono312aff92006-06-17 04:08:30 +00005147PJ_DECL(pj_status_t)
5148pjsua_media_transports_attach( pjsua_media_transport tp[],
5149 unsigned count,
5150 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00005151
5152
Benny Prijono312aff92006-06-17 04:08:30 +00005153/**
5154 * @}
5155 */
5156
Benny Prijonof3195072006-02-14 21:15:30 +00005157
Benny Prijono268ca612006-02-07 12:34:11 +00005158
Benny Prijono312aff92006-06-17 04:08:30 +00005159/**
5160 * @}
5161 */
5162
Benny Prijonoe6ead542007-01-31 20:53:31 +00005163PJ_END_DECL
5164
Benny Prijono312aff92006-06-17 04:08:30 +00005165
Benny Prijono268ca612006-02-07 12:34:11 +00005166#endif /* __PJSUA_H__ */