blob: ca00bb184dd9672ee2de0efd0efaca998f2b8079 [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 /**
475 * Optional callback function to be called to write log to
476 * application specific device. This function will be called for
477 * log messages on input verbosity level.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000478 *
479 * \par Sample Python Syntax:
480 * \code
481 # level: integer
482 # data: string
483 # len: integer
484
485 def cb(level, data, len):
486 print data,
487 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000488 */
Benny Prijonofe7d87b2007-11-29 11:35:44 +0000489 void (*cb)(int level, const char *data, int len);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000490
491
492} pjsua_logging_config;
493
494
495/**
496 * Use this function to initialize logging config.
497 *
498 * @param cfg The logging config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000499 *
500 * \par Python Syntax:
501 * The Python function instantiates and initialize the logging config:
502 * \code
503 logging_cfg = py_pjsua.logging_config_default()
504 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000505 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000506PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000507
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000508
509/**
510 * Use this function to duplicate logging config.
511 *
512 * @param pool Pool to use.
513 * @param dst Destination config.
514 * @param src Source config.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000515 *
516 * \par Python Syntax:
517 * Not available (for now). Ideally we should be able to just assign
518 * one config to another, but this has not been tested.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000519 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000520PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool,
521 pjsua_logging_config *dst,
522 const pjsua_logging_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000523
Benny Prijonodc39fe82006-05-26 12:17:46 +0000524
525/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000526 * This structure describes application callback to receive various event
527 * notification from PJSUA-API. All of these callbacks are OPTIONAL,
528 * although definitely application would want to implement some of
529 * the important callbacks (such as \a on_incoming_call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000530 *
531 * \par Python Syntax:
532 * This callback structure is embedded on pjsua_config structure.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000533 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000534typedef struct pjsua_callback
Benny Prijonodc39fe82006-05-26 12:17:46 +0000535{
536 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000537 * Notify application when invite state has changed.
538 * Application may then query the call info to get the
Benny Prijonoe6ead542007-01-31 20:53:31 +0000539 * detail call states by calling pjsua_call_get_info() function.
Benny Prijono0875ae82006-12-26 00:11:48 +0000540 *
541 * @param call_id The call index.
542 * @param e Event which causes the call state to change.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000543 *
544 * \par Python Syntax:
545 * \code
546 # call_id: integer
547 # e: an opaque object
548
549 def on_call_state(call_id, e):
550 return
551 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000552 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000553 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000554
555 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000556 * Notify application on incoming call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000557 *
558 * @param acc_id The account which match the incoming call.
559 * @param call_id The call id that has just been created for
560 * the call.
561 * @param rdata The incoming INVITE request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000562 *
563 * \par Python Syntax:
564 * \code
565 # acc_id: integer
566 # call_id: integer
567 # rdata: an opaque object
568
569 def on_incoming_call(acc_id, call_id, rdata):
570 return
571 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +0000572 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000573 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000574 pjsip_rx_data *rdata);
575
576 /**
Benny Prijonofeb69f42007-10-05 09:12:26 +0000577 * This is a general notification callback which is called whenever
578 * a transaction within the call has changed state. Application can
579 * implement this callback for example to monitor the state of
580 * outgoing requests, or to answer unhandled incoming requests
581 * (such as INFO) with a final response.
582 *
583 * @param call_id Call identification.
584 * @param tsx The transaction which has changed state.
585 * @param e Transaction event that caused the state change.
586 */
587 void (*on_call_tsx_state)(pjsua_call_id call_id,
588 pjsip_transaction *tsx,
589 pjsip_event *e);
590
591 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000592 * Notify application when media state in the call has changed.
593 * Normal application would need to implement this callback, e.g.
Benny Prijono6ba8c542007-10-16 01:34:14 +0000594 * to connect the call's media to sound device. When ICE is used,
595 * this callback will also be called to report ICE negotiation
596 * failure.
Benny Prijono0875ae82006-12-26 00:11:48 +0000597 *
598 * @param call_id The call index.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000599 *
600 * \par Python Syntax:
601 * \code
602 # call_id: integer
603
604 def on_call_media_state(call_id):
605 return
606 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000607 */
608 void (*on_call_media_state)(pjsua_call_id call_id);
609
Benny Prijonofc13bf62008-02-20 08:56:15 +0000610
611 /**
612 * Notify application when media session is created and before it is
613 * registered to the conference bridge. Application may return different
614 * media port if it has added media processing port to the stream. This
615 * media port then will be added to the conference bridge instead.
616 *
617 * @param call_id Call identification.
618 * @param sess Media session for the call.
619 * @param stream_idx Stream index in the media session.
620 * @param p_port On input, it specifies the media port of the
621 * stream. Application may modify this pointer to
622 * point to different media port to be registered
623 * to the conference bridge.
624 *
625 * \par Python:
626 * Not applicable.
627 */
628 void (*on_stream_created)(pjsua_call_id call_id,
629 pjmedia_session *sess,
630 unsigned stream_idx,
631 pjmedia_port **p_port);
632
633 /**
634 * Notify application when media session has been unregistered from the
635 * conference bridge and about to be destroyed.
636 *
637 * @param call_id Call identification.
638 * @param sess Media session for the call.
639 * @param stream_idx Stream index in the media session.
640 *
641 * \par Python:
642 * Not applicable.
643 */
644 void (*on_stream_destroyed)(pjsua_call_id call_id,
645 pjmedia_session *sess,
646 unsigned stream_idx);
647
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000648 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000649 * Notify application upon incoming DTMF digits.
650 *
651 * @param call_id The call index.
652 * @param digit DTMF ASCII digit.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000653 *
654 * \par Python Syntax:
655 * \code
656 # call_id: integer
Benny Prijono1f63cc42007-09-10 16:54:22 +0000657 # digit: digit string
Benny Prijonoe6ead542007-01-31 20:53:31 +0000658
659 def on_dtmf_digit(call_id, digit):
660 return
661 * \endcode
Benny Prijono0875ae82006-12-26 00:11:48 +0000662 */
663 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
664
665 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000666 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000667 * Application can decide to accept/reject transfer request
Benny Prijonoc54dcb32008-04-08 23:33:15 +0000668 * by setting the code (default is 202). When this callback
Benny Prijono9fc735d2006-05-28 14:58:12 +0000669 * is not defined, the default behavior is to accept the
670 * transfer.
Benny Prijono0875ae82006-12-26 00:11:48 +0000671 *
672 * @param call_id The call index.
673 * @param dst The destination where the call will be
674 * transfered to.
675 * @param code Status code to be returned for the call transfer
676 * request. On input, it contains status code 200.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000677 *
678 * \par Python Syntax:
679 * \code
680 # call_id: integer
681 # dst: string
682 # code: integer
683
684 def on_call_transfer_request(call_id, dst, code):
685 return code
686
687 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000688 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000689 void (*on_call_transfer_request)(pjsua_call_id call_id,
690 const pj_str_t *dst,
691 pjsip_status_code *code);
692
693 /**
694 * Notify application of the status of previously sent call
695 * transfer request. Application can monitor the status of the
696 * call transfer request, for example to decide whether to
697 * terminate existing call.
698 *
699 * @param call_id Call ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000700 * @param st_code Status progress of the transfer request.
701 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000702 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000703 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000704 * this callback is the final status.
705 * @param p_cont Initially will be set to non-zero, application
706 * can set this to FALSE if it no longer wants
707 * to receie further notification (for example,
708 * after it hangs up the call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000709 *
710 * \par Python Syntax:
711 * \code
712 # call_id: integer
713 # st_code: integer
714 # st_text: string
715 # final: integer
716 # cont: integer
717
718 # return: cont
719
720 def on_call_transfer_status(call_id, st_code, st_text, final, cont):
721 return cont
722 * \endcode
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000723 */
724 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000725 int st_code,
726 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000727 pj_bool_t final,
728 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000729
730 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000731 * Notify application about incoming INVITE with Replaces header.
732 * Application may reject the request by setting non-2xx code.
733 *
734 * @param call_id The call ID to be replaced.
735 * @param rdata The incoming INVITE request to replace the call.
736 * @param st_code Status code to be set by application. Application
737 * should only return a final status (200-699).
738 * @param st_text Optional status text to be set by application.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000739 *
740 * \par Python Syntax:
741 * \code
742 # call_id: integer
743 # rdata: an opaque object
744 # st_code: integer
745 # st_text: string
746
747 # return: (st_code, st_text) tuple
748
749 def on_call_replace_request(call_id, rdata, st_code, st_text):
750 return st_code, st_text
751 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000752 */
753 void (*on_call_replace_request)(pjsua_call_id call_id,
754 pjsip_rx_data *rdata,
755 int *st_code,
756 pj_str_t *st_text);
757
758 /**
759 * Notify application that an existing call has been replaced with
760 * a new call. This happens when PJSUA-API receives incoming INVITE
761 * request with Replaces header.
762 *
763 * After this callback is called, normally PJSUA-API will disconnect
764 * \a old_call_id and establish \a new_call_id.
765 *
766 * @param old_call_id Existing call which to be replaced with the
767 * new call.
768 * @param new_call_id The new call.
769 * @param rdata The incoming INVITE with Replaces request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000770 *
771 * \par Python Syntax:
772 * \code
773 # old_call_id: integer
774 # new_call_id: integer
775
776 def on_call_replaced(old_call_id, new_call_id):
777 return
778 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000779 */
780 void (*on_call_replaced)(pjsua_call_id old_call_id,
781 pjsua_call_id new_call_id);
782
783
784 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000785 * Notify application when registration status has changed.
786 * Application may then query the account info to get the
787 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000788 *
789 * @param acc_id Account ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000790 *
791 * \par Python Syntax:
792 * \code
793 # acc_id: account ID (integer)
794
795 def on_reg_state(acc_id):
796 return
797 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000798 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000799 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000800
801 /**
Benny Prijono63fba012008-07-17 14:19:10 +0000802 * Notification when incoming SUBSCRIBE request is received. Application
803 * may use this callback to authorize the incoming subscribe request
804 * (e.g. ask user permission if the request should be granted).
805 *
806 * If this callback is not implemented, all incoming presence subscription
807 * requests will be accepted.
808 *
809 * If this callback is implemented, application has several choices on
810 * what to do with the incoming request:
811 * - it may reject the request immediately by specifying non-200 class
812 * final response in the \a code argument.
813 * - it may immediately accept the request by specifying 200 as the
814 * \a code argument. This is the default value if application doesn't
815 * set any value to the \a code argument. In this case, the library
816 * will automatically send NOTIFY request upon returning from this
817 * callback.
818 * - it may delay the processing of the request, for example to request
819 * user permission whether to accept or reject the request. In this
820 * case, the application MUST set the \a code argument to 202, and
821 * later calls #pjsua_pres_notify() to accept or reject the
822 * subscription request.
823 *
824 * Any \a code other than 200 and 202 will be treated as 200.
825 *
826 * Application MUST return from this callback immediately (e.g. it must
827 * not block in this callback while waiting for user confirmation).
828 *
829 * @param srv_pres Server presence subscription instance. If
830 * application delays the acceptance of the request,
831 * it will need to specify this object when calling
832 * #pjsua_pres_notify().
833 * @param acc_id Account ID most appropriate for this request.
834 * @param buddy_id ID of the buddy matching the sender of the
835 * request, if any, or PJSUA_INVALID_ID if no
836 * matching buddy is found.
837 * @param from The From URI of the request.
838 * @param rdata The incoming request.
839 * @param code The status code to respond to the request. The
840 * default value is 200. Application may set this
841 * to other final status code to accept or reject
842 * the request.
843 * @param reason The reason phrase to respond to the request.
844 * @param msg_data If the application wants to send additional
845 * headers in the response, it can put it in this
846 * parameter.
847 */
848 void (*on_incoming_subscribe)(pjsua_acc_id acc_id,
849 pjsua_srv_pres *srv_pres,
850 pjsua_buddy_id buddy_id,
851 const pj_str_t *from,
852 pjsip_rx_data *rdata,
853 pjsip_status_code *code,
854 pj_str_t *reason,
855 pjsua_msg_data *msg_data);
856
857 /**
858 * Notification when server side subscription state has changed.
859 * This callback is optional as application normally does not need
860 * to do anything to maintain server side presence subscription.
861 *
862 * @param acc_id The account ID.
863 * @param srv_pres Server presence subscription object.
864 * @param remote_uri Remote URI string.
865 * @param state New subscription state.
866 * @param event PJSIP event that triggers the state change.
867 */
868 void (*on_srv_subscribe_state)(pjsua_acc_id acc_id,
869 pjsua_srv_pres *srv_pres,
870 const pj_str_t *remote_uri,
871 pjsip_evsub_state state,
872 pjsip_event *event);
873
874 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000875 * Notify application when the buddy state has changed.
876 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000877 *
878 * @param buddy_id The buddy id.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000879 *
880 * \par Python Syntax:
881 * \code
882 # buddy_id: integer
883
884 def on_buddy_state(buddy_id):
885 return
886 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000887 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000888 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000889
890 /**
891 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000892 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000893 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000894 *
Benny Prijonobbeb3992007-05-21 13:48:35 +0000895 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
896 * passed as one of the argument.
897 *
Benny Prijono0875ae82006-12-26 00:11:48 +0000898 * @param call_id Containts the ID of the call where the IM was
899 * sent, or PJSUA_INVALID_ID if the IM was sent
900 * outside call context.
901 * @param from URI of the sender.
902 * @param to URI of the destination message.
903 * @param contact The Contact URI of the sender, if present.
904 * @param mime_type MIME type of the message.
905 * @param body The message content.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000906 *
907 * \par Python Syntax:
908 * \code
909 # call_id: integer
910 # from: string
911 # to: string
912 # contact: string
913 # mime_type: string
914 # body: string
Benny Prijonoba736c42008-07-10 20:45:03 +0000915 # acc_id: integer
Benny Prijonoe6ead542007-01-31 20:53:31 +0000916
917 def on_pager(call_id, from, to, contact, mime_type, body):
918 return
919 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000920 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000921 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
922 const pj_str_t *to, const pj_str_t *contact,
923 const pj_str_t *mime_type, const pj_str_t *body);
924
925 /**
Benny Prijonobbeb3992007-05-21 13:48:35 +0000926 * This is the alternative version of the \a on_pager() callback with
927 * \a pjsip_rx_data argument.
928 *
929 * @param call_id Containts the ID of the call where the IM was
930 * sent, or PJSUA_INVALID_ID if the IM was sent
931 * outside call context.
932 * @param from URI of the sender.
933 * @param to URI of the destination message.
934 * @param contact The Contact URI of the sender, if present.
935 * @param mime_type MIME type of the message.
936 * @param body The message content.
937 * @param rdata The incoming MESSAGE request.
Benny Prijonoba736c42008-07-10 20:45:03 +0000938 * @param acc_id Account ID most suitable for this message.
Benny Prijonobbeb3992007-05-21 13:48:35 +0000939 */
940 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
941 const pj_str_t *to, const pj_str_t *contact,
942 const pj_str_t *mime_type, const pj_str_t *body,
Benny Prijonoba736c42008-07-10 20:45:03 +0000943 pjsip_rx_data *rdata, pjsua_acc_id acc_id);
Benny Prijonobbeb3992007-05-21 13:48:35 +0000944
945 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000946 * Notify application about the delivery status of outgoing pager
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000947 * request. See also on_pager_status2() callback for the version with
948 * \a pjsip_rx_data in the argument list.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000949 *
950 * @param call_id Containts the ID of the call where the IM was
951 * sent, or PJSUA_INVALID_ID if the IM was sent
952 * outside call context.
953 * @param to Destination URI.
954 * @param body Message body.
955 * @param user_data Arbitrary data that was specified when sending
956 * IM message.
957 * @param status Delivery status.
958 * @param reason Delivery status reason.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000959 *
960 * \par Python Syntax
961 * \code
962 # call_id: integer
963 # to: string
964 # body: string
965 # user_data: string
966 # status: integer
967 # reason: string
Benny Prijonoba736c42008-07-10 20:45:03 +0000968 # acc_id: integer
Benny Prijonoe6ead542007-01-31 20:53:31 +0000969
970 def on_pager_status(call_id, to, body, user_data, status, reason):
971 return
972 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000973 */
974 void (*on_pager_status)(pjsua_call_id call_id,
975 const pj_str_t *to,
976 const pj_str_t *body,
977 void *user_data,
978 pjsip_status_code status,
979 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000980
981 /**
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000982 * Notify application about the delivery status of outgoing pager
983 * request.
984 *
985 * @param call_id Containts the ID of the call where the IM was
986 * sent, or PJSUA_INVALID_ID if the IM was sent
987 * outside call context.
988 * @param to Destination URI.
989 * @param body Message body.
990 * @param user_data Arbitrary data that was specified when sending
991 * IM message.
992 * @param status Delivery status.
993 * @param reason Delivery status reason.
Benny Prijono0a982002007-06-12 16:22:09 +0000994 * @param tdata The original MESSAGE request.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000995 * @param rdata The incoming MESSAGE response, or NULL if the
996 * message transaction fails because of time out
997 * or transport error.
Benny Prijonoba736c42008-07-10 20:45:03 +0000998 * @param acc_id Account ID from this the instant message was
999 * send.
Benny Prijono4da0b1d2007-06-11 18:22:54 +00001000 */
1001 void (*on_pager_status2)(pjsua_call_id call_id,
1002 const pj_str_t *to,
1003 const pj_str_t *body,
1004 void *user_data,
1005 pjsip_status_code status,
1006 const pj_str_t *reason,
Benny Prijono0a982002007-06-12 16:22:09 +00001007 pjsip_tx_data *tdata,
Benny Prijonoba736c42008-07-10 20:45:03 +00001008 pjsip_rx_data *rdata,
1009 pjsua_acc_id acc_id);
Benny Prijono4da0b1d2007-06-11 18:22:54 +00001010
1011 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +00001012 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +00001013 *
1014 * @param call_id Containts the ID of the call where the IM was
1015 * sent, or PJSUA_INVALID_ID if the IM was sent
1016 * outside call context.
1017 * @param from URI of the sender.
1018 * @param to URI of the destination message.
1019 * @param contact The Contact URI of the sender, if present.
1020 * @param is_typing Non-zero if peer is typing, or zero if peer
1021 * has stopped typing a message.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001022 *
1023 * \par Python Syntax
1024 * \code
1025 # call_id: string
1026 # from: string
1027 # to: string
1028 # contact: string
1029 # is_typing: integer
1030
1031 def on_typing(call_id, from, to, contact, is_typing):
1032 return
1033 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001034 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001035 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
1036 const pj_str_t *to, const pj_str_t *contact,
1037 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +00001038
Benny Prijono6ba8c542007-10-16 01:34:14 +00001039 /**
Benny Prijonoba736c42008-07-10 20:45:03 +00001040 * Notify application about typing indication.
1041 *
1042 * @param call_id Containts the ID of the call where the IM was
1043 * sent, or PJSUA_INVALID_ID if the IM was sent
1044 * outside call context.
1045 * @param from URI of the sender.
1046 * @param to URI of the destination message.
1047 * @param contact The Contact URI of the sender, if present.
1048 * @param is_typing Non-zero if peer is typing, or zero if peer
1049 * has stopped typing a message.
1050 * @param rdata The received request.
1051 * @param acc_id Account ID most suitable for this message.
1052 */
1053 void (*on_typing2)(pjsua_call_id call_id, const pj_str_t *from,
1054 const pj_str_t *to, const pj_str_t *contact,
1055 pj_bool_t is_typing, pjsip_rx_data *rdata,
1056 pjsua_acc_id acc_id);
1057
1058 /**
Benny Prijono6ba8c542007-10-16 01:34:14 +00001059 * Callback when the library has finished performing NAT type
1060 * detection.
1061 *
1062 * @param res NAT detection result.
1063 */
1064 void (*on_nat_detect)(const pj_stun_nat_detect_result *res);
1065
Benny Prijono5e51a4e2008-11-27 00:06:46 +00001066 /**
1067 * This callback is called when the call is about to resend the
1068 * INVITE request to the specified target, following the previously
1069 * received redirection response.
1070 *
1071 * Application may accept the redirection to the specified target
1072 * (the default behavior if this callback is implemented), reject
1073 * this target only and make the session continue to try the next
1074 * target in the list if such target exists, stop the whole
1075 * redirection process altogether and cause the session to be
1076 * disconnected, or defer the decision to ask for user confirmation.
1077 *
1078 * This callback is optional. If this callback is not implemented,
1079 * the default behavior is to NOT follow the redirection response.
1080 *
1081 * @param call_id The call ID.
1082 * @param target The current target to be tried.
Benny Prijono08a48b82008-11-27 12:42:07 +00001083 * @param e The event that caused this callback to be called.
1084 * This could be the receipt of 3xx response, or
1085 * 4xx/5xx response received for the INVITE sent to
1086 * subsequent targets, or NULL if this callback is
1087 * called from within #pjsua_call_process_redirect()
1088 * context.
1089 *
1090 * @return Action to be performed for the target. Set this
Benny Prijono5e51a4e2008-11-27 00:06:46 +00001091 * parameter to one of the value below:
1092 * - PJSIP_REDIRECT_ACCEPT: immediately accept the
1093 * redirection (default value). When set, the
1094 * call will immediately resend INVITE request
1095 * to the target.
1096 * - PJSIP_REDIRECT_REJECT: immediately reject this
1097 * target. The call will continue retrying with
1098 * next target if present, or disconnect the call
1099 * if there is no more target to try.
1100 * - PJSIP_REDIRECT_STOP: stop the whole redirection
1101 * process and immediately disconnect the call. The
1102 * on_call_state() callback will be called with
1103 * PJSIP_INV_STATE_DISCONNECTED state immediately
1104 * after this callback returns.
1105 * - PJSIP_REDIRECT_PENDING: set to this value if
1106 * no decision can be made immediately (for example
1107 * to request confirmation from user). Application
1108 * then MUST call #pjsua_call_process_redirect()
1109 * to either accept or reject the redirection upon
1110 * getting user decision.
Benny Prijono5e51a4e2008-11-27 00:06:46 +00001111 */
Benny Prijono08a48b82008-11-27 12:42:07 +00001112 pjsip_redirect_op (*on_call_redirected)(pjsua_call_id call_id,
1113 const pjsip_uri *target,
1114 const pjsip_event *e);
Benny Prijono5e51a4e2008-11-27 00:06:46 +00001115
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001116} pjsua_callback;
1117
1118
1119
Benny Prijonodc39fe82006-05-26 12:17:46 +00001120
1121/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001122 * This structure describes the settings to control the API and
1123 * user agent behavior, and can be specified when calling #pjsua_init().
1124 * Before setting the values, application must call #pjsua_config_default()
1125 * to initialize this structure with the default values.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001126 *
1127 * \par Python Sample Syntax:
1128 * The pjsua_config type in Python is <tt>py_pjsua.Config</tt>. Application
1129 * creates the instance by calling <tt>py_pjsua.config_default()</tt>:
1130 * \code
1131 cfg = py_pjsua.config_default()
1132 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001133 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001134typedef struct pjsua_config
1135{
1136
1137 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001138 * Maximum calls to support (default: 4). The value specified here
1139 * must be smaller than the compile time maximum settings
1140 * PJSUA_MAX_CALLS, which by default is 32. To increase this
1141 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
1142 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001143 */
1144 unsigned max_calls;
1145
1146 /**
1147 * Number of worker threads. Normally application will want to have at
1148 * least one worker thread, unless when it wants to poll the library
1149 * periodically, which in this case the worker thread can be set to
1150 * zero.
1151 */
1152 unsigned thread_cnt;
1153
1154 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +00001155 * Number of nameservers. If no name server is configured, the SIP SRV
1156 * resolution would be disabled, and domain will be resolved with
1157 * standard pj_gethostbyname() function.
1158 */
1159 unsigned nameserver_count;
1160
1161 /**
1162 * Array of nameservers to be used by the SIP resolver subsystem.
1163 * The order of the name server specifies the priority (first name
1164 * server will be used first, unless it is not reachable).
1165 */
1166 pj_str_t nameserver[4];
1167
1168 /**
Benny Prijono91d06b62008-09-20 12:16:56 +00001169 * Force loose-route to be used in all route/proxy URIs (outbound_proxy
1170 * and account's proxy settings). When this setting is enabled, the
1171 * library will check all the route/proxy URIs specified in the settings
1172 * and append ";lr" parameter to the URI if the parameter is not present.
1173 *
1174 * Default: 1
1175 */
1176 pj_bool_t force_lr;
1177
1178 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001179 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001180 */
1181 unsigned outbound_proxy_cnt;
1182
1183 /**
1184 * Specify the URL of outbound proxies to visit for all outgoing requests.
1185 * The outbound proxies will be used for all accounts, and it will
1186 * be used to build the route set for outgoing requests. The final
1187 * route set for outgoing requests will consists of the outbound proxies
1188 * and the proxy configured in the account.
1189 */
1190 pj_str_t outbound_proxy[4];
1191
Benny Prijonoc97608e2007-03-23 16:34:20 +00001192 /**
Benny Prijonoebbf6892007-03-24 17:37:25 +00001193 * Specify domain name to be resolved with DNS SRV resolution to get the
Benny Prijonof76e1392008-06-06 14:51:48 +00001194 * address of the STUN server. Alternatively application may specify
1195 * \a stun_host instead.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001196 *
1197 * If DNS SRV resolution failed for this domain, then DNS A resolution
1198 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +00001199 */
Benny Prijonoebbf6892007-03-24 17:37:25 +00001200 pj_str_t stun_domain;
1201
1202 /**
Benny Prijonoaf09dc32007-04-22 12:48:30 +00001203 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
1204 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001205 */
1206 pj_str_t stun_host;
1207
1208 /**
Benny Prijono91a6a172007-10-31 08:59:29 +00001209 * Support for adding and parsing NAT type in the SDP to assist
1210 * troubleshooting. The valid values are:
1211 * - 0: no information will be added in SDP, and parsing is disabled.
Benny Prijono6ba8c542007-10-16 01:34:14 +00001212 * - 1: only the NAT type number is added.
1213 * - 2: add both NAT type number and name.
1214 *
Benny Prijono91a6a172007-10-31 08:59:29 +00001215 * Default: 1
Benny Prijono6ba8c542007-10-16 01:34:14 +00001216 */
1217 int nat_type_in_sdp;
1218
1219 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001220 * Specify whether support for reliable provisional response (100rel and
1221 * PRACK) should be required by default. Note that this setting can be
1222 * further customized in account configuration (#pjsua_acc_config).
1223 *
1224 * Default: PJ_FALSE
1225 */
1226 pj_bool_t require_100rel;
1227
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001228 /**
1229 * Number of credentials in the credential array.
1230 */
1231 unsigned cred_count;
1232
1233 /**
1234 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +00001235 * and can be used to authenticate against outbound proxies. If the
1236 * credential is specific to the account, then application should set
1237 * the credential in the pjsua_acc_config rather than the credential
1238 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001239 */
1240 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1241
1242 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001243 * Application callback to receive various event notifications from
1244 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001245 */
1246 pjsua_callback cb;
1247
Benny Prijono56315612006-07-18 14:39:40 +00001248 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001249 * Optional user agent string (default empty). If it's empty, no
1250 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +00001251 */
1252 pj_str_t user_agent;
1253
Benny Prijonod8179652008-01-23 20:39:07 +00001254#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
1255 /**
1256 * Specify default value of secure media transport usage.
1257 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
1258 * PJMEDIA_SRTP_MANDATORY.
1259 *
1260 * Note that this setting can be further customized in account
1261 * configuration (#pjsua_acc_config).
1262 *
1263 * Default: #PJSUA_DEFAULT_USE_SRTP
1264 */
1265 pjmedia_srtp_use use_srtp;
1266
1267 /**
1268 * Specify whether SRTP requires secure signaling to be used. This option
1269 * is only used when \a use_srtp option above is non-zero.
1270 *
1271 * Valid values are:
1272 * 0: SRTP does not require secure signaling
1273 * 1: SRTP requires secure transport such as TLS
1274 * 2: SRTP requires secure end-to-end transport (SIPS)
1275 *
1276 * Note that this setting can be further customized in account
1277 * configuration (#pjsua_acc_config).
1278 *
1279 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
1280 */
1281 int srtp_secure_signaling;
1282#endif
1283
Benny Prijono3c5e28b2008-09-24 10:10:15 +00001284 /**
1285 * Disconnect other call legs when more than one 2xx responses for
1286 * outgoing INVITE are received due to forking. Currently the library
1287 * is not able to handle simultaneous forked media, so disconnecting
1288 * the other call legs is necessary.
1289 *
1290 * With this setting enabled, the library will handle only one of the
1291 * connected call leg, and the other connected call legs will be
1292 * disconnected.
1293 *
1294 * Default: PJ_TRUE (only disable this setting for testing purposes).
1295 */
1296 pj_bool_t hangup_forked_call;
1297
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001298} pjsua_config;
1299
1300
1301/**
1302 * Use this function to initialize pjsua config.
1303 *
1304 * @param cfg pjsua config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001305 *
1306 * \par Python Sample Syntax:
1307 * The corresponding Python function creates an instance of the config and
1308 * initializes it to the default settings:
1309 * \code
1310 cfg = py_pjsua.config_default()
1311 * \endcode
1312
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001313 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001314PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001315
1316
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001317/** The implementation has been moved to sip_auth.h */
Benny Prijono7977f9f2007-10-10 11:37:56 +00001318#define pjsip_cred_dup pjsip_cred_info_dup
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001319
1320
1321/**
1322 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001323 *
1324 * @param pool The pool to get memory from.
1325 * @param dst Destination config.
1326 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001327 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001328PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1329 pjsua_config *dst,
1330 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001331
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001332
1333/**
1334 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001335 * outgoing SIP message. It can (optionally) be specified for example
1336 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1337 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1338 *
1339 * Application MUST call #pjsua_msg_data_init() to initialize this
1340 * structure before setting its values.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001341 *
1342 * \par Python Syntax
1343 * The data type in Python is <tt>py_pjsua.Msg_Data</tt>. Application is
1344 * recommended to instantiate the structure by using this construct:
1345 * \code
1346 msg_data = py_pjsua.msg_data_init()
1347 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001348 */
Benny Prijono63fba012008-07-17 14:19:10 +00001349struct pjsua_msg_data
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001350{
1351 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001352 * Additional message headers as linked list. Application can add
1353 * headers to the list by creating the header, either from the heap/pool
1354 * or from temporary local variable, and add the header using
1355 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001356 *
1357 * \par Python:
1358 * This field is implemented as string linked-list in Python, where each
1359 * string describes the header. For example:
1360 \code
1361 msg_data = py_pjsua.Msg_Data()
1362 msg_data.hdr_list = ["Subject: Hello py_pjsua!", "Priority: very low"]
1363 \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001364 */
1365 pjsip_hdr hdr_list;
1366
1367 /**
1368 * MIME type of optional message body.
1369 */
1370 pj_str_t content_type;
1371
1372 /**
1373 * Optional message body.
1374 */
1375 pj_str_t msg_body;
1376
Benny Prijono63fba012008-07-17 14:19:10 +00001377};
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001378
1379
1380/**
1381 * Initialize message data.
1382 *
1383 * @param msg_data Message data to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001384 *
1385 * \par Python
1386 * The corresponding Python function creates and initializes the structure:
1387 * \code
1388 msg_data = py_pjsua.msg_data_init()
1389 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001390 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001391PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001392
Benny Prijono268ca612006-02-07 12:34:11 +00001393
1394/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001395 * Instantiate pjsua application. Application must call this function before
1396 * calling any other functions, to make sure that the underlying libraries
1397 * are properly initialized. Once this function has returned success,
1398 * application must call pjsua_destroy() before quitting.
1399 *
1400 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001401 *
1402 * \par Python:
1403 * \code
1404 status = py_pjsua.create()
1405 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001406 */
1407PJ_DECL(pj_status_t) pjsua_create(void);
1408
1409
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001410/** Forward declaration */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001411typedef struct pjsua_media_config pjsua_media_config;
1412
1413
Benny Prijonodc39fe82006-05-26 12:17:46 +00001414/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001415 * Initialize pjsua with the specified settings. All the settings are
1416 * optional, and the default values will be used when the config is not
1417 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001418 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001419 * Note that #pjsua_create() MUST be called before calling this function.
1420 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001421 * @param ua_cfg User agent configuration.
1422 * @param log_cfg Optional logging configuration.
1423 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001424 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001425 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001426 *
1427 * \par Python:
1428 * The function is similar in Python:
1429 * \code
1430 status = py_pjsua.init(ua_cfg, log_cfg, media_cfg)
1431 * \endcode
1432 * Note that \a ua_cfg, \a log_cfg, and \a media_cfg are optional, and
1433 * the Python script may pass None if it doesn't want to configure the
1434 * setting.
Benny Prijono268ca612006-02-07 12:34:11 +00001435 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001436PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1437 const pjsua_logging_config *log_cfg,
1438 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001439
1440
1441/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001442 * Application is recommended to call this function after all initialization
1443 * is done, so that the library can do additional checking set up
1444 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001445 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001446 * Application may call this function anytime after #pjsua_init().
1447 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001448 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001449 *
1450 * \par Python:
1451 * The function is similar in Python:
1452 * \code
1453 status = py_pjsua.start()
1454 * \endcode
Benny Prijonoccf95622006-02-07 18:48:01 +00001455 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001456PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001457
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001458
Benny Prijonoccf95622006-02-07 18:48:01 +00001459/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001460 * Destroy pjsua. Application is recommended to perform graceful shutdown
1461 * before calling this function (such as unregister the account from the SIP
1462 * server, terminate presense subscription, and hangup active calls), however,
1463 * this function will do all of these if it finds there are active sessions
1464 * that need to be terminated. This function will approximately block for
1465 * one second to wait for replies from remote.
1466 *
1467 * Application.may safely call this function more than once if it doesn't
1468 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001469 *
1470 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001471 *
1472 * \par Python:
1473 * The function is similar in Python:
1474 * \code
1475 status = py_pjsua.destroy()
1476 * \endcode
Benny Prijono268ca612006-02-07 12:34:11 +00001477 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001478PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001479
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001480
Benny Prijono9fc735d2006-05-28 14:58:12 +00001481/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001482 * Poll pjsua for events, and if necessary block the caller thread for
1483 * the specified maximum interval (in miliseconds).
1484 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001485 * Application doesn't normally need to call this function if it has
1486 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1487 * because polling then will be done by these worker threads instead.
1488 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001489 * @param msec_timeout Maximum time to wait, in miliseconds.
1490 *
1491 * @return The number of events that have been handled during the
1492 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001493 * can retrieve the error as (status = -return_value).
1494 *
1495 * \par Python:
1496 * The function is similar in Python:
1497 * \code
1498 n = py_pjsua.handle_events(msec_timeout)
1499 * \endcode
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001500 */
1501PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1502
1503
1504/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001505 * Create memory pool to be used by the application. Once application
1506 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001507 *
1508 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001509 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001510 * @param increment Increment size.
1511 *
1512 * @return The pool, or NULL when there's no memory.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001513 *
1514 * \par Python:
1515 * Python script may also create a pool object from the script:
1516 * \code
1517 pool = py_pjsua.pool_create(name, init_size, increment)
1518 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001519 */
1520PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1521 pj_size_t increment);
1522
1523
1524/**
1525 * Application can call this function at any time (after pjsua_create(), of
1526 * course) to change logging settings.
1527 *
1528 * @param c Logging configuration.
1529 *
1530 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001531 *
1532 * \par Python:
1533 * The function is similar in Python:
1534 * \code
1535 status = py_pjsua.reconfigure_logging(log_cfg)
1536 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001537 */
1538PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1539
1540
1541/**
1542 * Internal function to get SIP endpoint instance of pjsua, which is
1543 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001544 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001545 *
1546 * @return SIP endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001547 *
1548 * \par Python:
1549 * Application may retrieve the SIP endpoint instance:
1550 * \code
1551 endpt = py_pjsua.get_pjsip_endpt()
1552 * \endcode
1553 * However currently the object is just an opaque object and does not have
1554 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001555 */
1556PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1557
1558/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001559 * Internal function to get media endpoint instance.
1560 * Only valid after #pjsua_init() is called.
1561 *
1562 * @return Media endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001563 *
1564 * \par Python:
1565 * Application may retrieve the media endpoint instance:
1566 * \code
1567 endpt = py_pjsua.get_pjmedia_endpt()
1568 * \endcode
1569 * However currently the object is just an opaque object and does not have
1570 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001571 */
1572PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1573
Benny Prijono97b87172006-08-24 14:25:14 +00001574/**
1575 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001576 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001577 *
1578 * @return Pool factory currently used by PJSUA.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001579 *
1580 * \par Python:
1581 * Application may retrieve the pool factory instance:
1582 * \code
1583 endpt = py_pjsua.get_pool_factory()
1584 * \endcode
1585 * However currently the object is just an opaque object and does not have
1586 * any use for Python scripts.
Benny Prijono97b87172006-08-24 14:25:14 +00001587 */
1588PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1589
1590
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001591
1592/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001593 * Utilities.
1594 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001595 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001596
1597/**
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001598 * This is a utility function to detect NAT type in front of this
1599 * endpoint. Once invoked successfully, this function will complete
Benny Prijono6ba8c542007-10-16 01:34:14 +00001600 * asynchronously and report the result in \a on_nat_detect() callback
1601 * of pjsua_callback.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001602 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001603 * After NAT has been detected and the callback is called, application can
1604 * get the detected NAT type by calling #pjsua_get_nat_type(). Application
1605 * can also perform NAT detection by calling #pjsua_detect_nat_type()
1606 * again at later time.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001607 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001608 * Note that STUN must be enabled to run this function successfully.
1609 *
1610 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001611 */
Benny Prijono6ba8c542007-10-16 01:34:14 +00001612PJ_DECL(pj_status_t) pjsua_detect_nat_type(void);
1613
1614
1615/**
1616 * Get the NAT type as detected by #pjsua_detect_nat_type() function.
1617 * This function will only return useful NAT type after #pjsua_detect_nat_type()
1618 * has completed successfully and \a on_nat_detect() callback has been called.
1619 *
1620 * @param type NAT type.
1621 *
1622 * @return When detection is in progress, this function will
1623 * return PJ_EPENDING and \a type will be set to
1624 * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been
1625 * detected successfully, this function will return
1626 * PJ_SUCCESS and \a type will be set to the correct
1627 * value. Other return values indicate error and
1628 * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN.
Benny Prijono91a6a172007-10-31 08:59:29 +00001629 *
1630 * @see pjsua_call_get_rem_nat_type()
Benny Prijono6ba8c542007-10-16 01:34:14 +00001631 */
1632PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type);
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001633
1634
1635/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001636 * This is a utility function to verify that valid SIP url is given. If the
1637 * URL is valid, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001638 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001639 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001640 *
1641 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001642 *
1643 * \par Python:
1644 * \code
1645 status = py_pjsua.verify_sip_url(url)
1646 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001647 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001648PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001649
1650
1651/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001652 * This is a utility function to display error message for the specified
1653 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001654 *
1655 * @param sender The log sender field.
1656 * @param title Message title for the error.
1657 * @param status Status code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001658 *
1659 * \par Python:
1660 * \code
1661 py_pjsua.perror(sender, title, status)
1662 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001663 */
1664PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1665 pj_status_t status);
1666
1667
Benny Prijonoda9785b2007-04-02 20:43:06 +00001668/**
1669 * This is a utility function to dump the stack states to log, using
1670 * verbosity level 3.
1671 *
1672 * @param detail Will print detailed output (such as list of
1673 * SIP transactions) when non-zero.
1674 */
1675PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001676
1677/**
1678 * @}
1679 */
1680
1681
1682
1683/*****************************************************************************
1684 * TRANSPORT API
1685 */
1686
1687/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001688 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001689 * @ingroup PJSUA_LIB
1690 * @brief API for managing SIP transports
1691 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001692 *
1693 * PJSUA-API supports creating multiple transport instances, for example UDP,
1694 * TCP, and TLS transport. SIP transport must be created before adding an
1695 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001696 */
1697
1698
Benny Prijonoe6ead542007-01-31 20:53:31 +00001699/** SIP transport identification.
1700 */
Benny Prijono312aff92006-06-17 04:08:30 +00001701typedef int pjsua_transport_id;
1702
1703
1704/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001705 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001706 * and media. Before setting some values to this structure, application
1707 * MUST call #pjsua_transport_config_default() to initialize its
1708 * values with default settings.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001709 *
1710 * \par Python:
1711 * The data type in Python is <tt>py_pjsua.Transport_Config</tt>,
1712 * although application can just do this to create the instance:
1713 * \code
1714 transport_cfg = py_pjsua.transport_config_default()
1715 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001716 */
1717typedef struct pjsua_transport_config
1718{
1719 /**
1720 * UDP port number to bind locally. This setting MUST be specified
1721 * even when default port is desired. If the value is zero, the
1722 * transport will be bound to any available port, and application
1723 * can query the port by querying the transport info.
1724 */
1725 unsigned port;
1726
1727 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001728 * Optional address to advertise as the address of this transport.
1729 * Application can specify any address or hostname for this field,
1730 * for example it can point to one of the interface address in the
1731 * system, or it can point to the public address of a NAT router
1732 * where port mappings have been configured for the application.
1733 *
1734 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001735 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001736 pj_str_t public_addr;
1737
1738 /**
1739 * Optional address where the socket should be bound to. This option
1740 * SHOULD only be used to selectively bind the socket to particular
1741 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1742 * published address of a transport (the public_addr field should be
1743 * used for that purpose).
1744 *
1745 * Note that unlike public_addr field, the address (or hostname) here
1746 * MUST correspond to the actual interface address in the host, since
1747 * this address will be specified as bind() argument.
1748 */
1749 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001750
1751 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001752 * This specifies TLS settings for TLS transport. It is only be used
1753 * when this transport config is being used to create a SIP TLS
1754 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001755 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001756 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001757
Benny Prijono312aff92006-06-17 04:08:30 +00001758} pjsua_transport_config;
1759
1760
1761/**
1762 * Call this function to initialize UDP config with default values.
1763 *
1764 * @param cfg The UDP config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001765 *
1766 * \par Python:
1767 * The corresponding Python function is rather different:
1768 * \code
1769 transport_cfg = py_pjsua.transport_config_default()
1770 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001771 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001772PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001773
1774
1775/**
Benny Prijono312aff92006-06-17 04:08:30 +00001776 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001777 *
1778 * @param pool The pool.
1779 * @param dst The destination config.
1780 * @param src The source config.
1781 *
1782 * \par Python:
1783 * Not applicable. One should be able to just copy one variable instance
1784 * to another in Python.
Benny Prijono312aff92006-06-17 04:08:30 +00001785 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001786PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1787 pjsua_transport_config *dst,
1788 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001789
1790
1791/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001792 * This structure describes transport information returned by
1793 * #pjsua_transport_get_info() function.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001794 *
1795 * \par Python:
1796 * The corresponding data type in Python is <tt>py_pjsua.Transport_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001797 */
1798typedef struct pjsua_transport_info
1799{
1800 /**
1801 * PJSUA transport identification.
1802 */
1803 pjsua_transport_id id;
1804
1805 /**
1806 * Transport type.
1807 */
1808 pjsip_transport_type_e type;
1809
1810 /**
1811 * Transport type name.
1812 */
1813 pj_str_t type_name;
1814
1815 /**
1816 * Transport string info/description.
1817 */
1818 pj_str_t info;
1819
1820 /**
1821 * Transport flag (see ##pjsip_transport_flags_e).
1822 */
1823 unsigned flag;
1824
1825 /**
1826 * Local address length.
1827 */
1828 unsigned addr_len;
1829
1830 /**
1831 * Local/bound address.
1832 */
1833 pj_sockaddr local_addr;
1834
1835 /**
1836 * Published address (or transport address name).
1837 */
1838 pjsip_host_port local_name;
1839
1840 /**
1841 * Current number of objects currently referencing this transport.
1842 */
1843 unsigned usage_count;
1844
1845
1846} pjsua_transport_info;
1847
1848
1849/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001850 * Create and start a new SIP transport according to the specified
1851 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001852 *
1853 * @param type Transport type.
1854 * @param cfg Transport configuration.
1855 * @param p_id Optional pointer to receive transport ID.
1856 *
1857 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001858 *
1859 * \par Python:
1860 * The corresponding Python function returns (status,id) tuple:
1861 * \code
1862 status, transport_id = py_pjsua.transport_create(type, cfg)
1863 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001864 */
1865PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1866 const pjsua_transport_config *cfg,
1867 pjsua_transport_id *p_id);
1868
1869/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001870 * Register transport that has been created by application. This function
1871 * is useful if application wants to implement custom SIP transport and use
1872 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001873 *
1874 * @param tp Transport instance.
1875 * @param p_id Optional pointer to receive transport ID.
1876 *
1877 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001878 *
1879 * \par Python:
1880 * Not applicable (for now), because one cannot create a custom transport
1881 * from Python script.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001882 */
1883PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1884 pjsua_transport_id *p_id);
1885
1886
1887/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001888 * Enumerate all transports currently created in the system. This function
1889 * will return all transport IDs, and application may then call
1890 * #pjsua_transport_get_info() function to retrieve detailed information
1891 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001892 *
1893 * @param id Array to receive transport ids.
1894 * @param count In input, specifies the maximum number of elements.
1895 * On return, it contains the actual number of elements.
1896 *
1897 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001898 *
1899 * \par Python:
1900 * The function returns list of integers representing transport ids:
1901 * \code
1902 [int] = py_pjsua.enum_transports()
1903 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001904 */
1905PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1906 unsigned *count );
1907
1908
1909/**
1910 * Get information about transports.
1911 *
1912 * @param id Transport ID.
1913 * @param info Pointer to receive transport info.
1914 *
1915 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001916 *
1917 * \par Python:
1918 * \code
1919 transport_info = py_pjsua.transport_get_info(id)
1920 * \endcode
1921 * The Python function returns None on error.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001922 */
1923PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1924 pjsua_transport_info *info);
1925
1926
1927/**
1928 * Disable a transport or re-enable it. By default transport is always
1929 * enabled after it is created. Disabling a transport does not necessarily
1930 * close the socket, it will only discard incoming messages and prevent
1931 * the transport from being used to send outgoing messages.
1932 *
1933 * @param id Transport ID.
1934 * @param enabled Non-zero to enable, zero to disable.
1935 *
1936 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001937 *
1938 * \par Python:
1939 * \code
1940 status = py_pjsua.transport_set_enable(id, enabled)
1941 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001942 */
1943PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1944 pj_bool_t enabled);
1945
1946
1947/**
1948 * Close the transport. If transport is forcefully closed, it will be
1949 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00001950 * transport may not terminate properly (it may even crash). Otherwise,
1951 * the system will wait until all transactions are closed while preventing
1952 * new users from using the transport, and will close the transport when
1953 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001954 *
1955 * @param id Transport ID.
1956 * @param force Non-zero to immediately close the transport. This
1957 * is not recommended!
1958 *
1959 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001960 *
1961 * \par Python:
1962 * \code
1963 status = py_pjsua.transport_close(id, force)
1964 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001965 */
1966PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1967 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001968
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001969/**
Benny Prijono312aff92006-06-17 04:08:30 +00001970 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001971 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001972
1973
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001974
1975
1976/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001977 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001978 */
1979
Benny Prijono312aff92006-06-17 04:08:30 +00001980
1981/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001982 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001983 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001984 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001985 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001986 *
Benny Prijono312aff92006-06-17 04:08:30 +00001987 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001988 * using the application. In SIP terms, the identity is used as the <b>From</b>
1989 * header in outgoing requests.
1990 *
1991 * PJSUA-API supports creating and managing multiple accounts. The maximum
1992 * number of accounts is limited by a compile time constant
1993 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001994 *
1995 * Account may or may not have client registration associated with it.
1996 * An account is also associated with <b>route set</b> and some <b>authentication
1997 * credentials</b>, which are used when sending SIP request messages using the
1998 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00001999 * will be reported to remote peer when they subscribe to the account's
2000 * presence, or which is published to a presence server if presence
2001 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00002002 *
2003 * At least one account MUST be created in the application. If no user
2004 * association is required, application can create a userless account by
2005 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00002006 * instead of a particular user, and it correspond with a particular
2007 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00002008 *
2009 * Also one account must be set as the <b>default account</b>, which is used as
2010 * the account to use when PJSUA fails to match a request with any other
2011 * accounts.
2012 *
2013 * When sending outgoing SIP requests (such as making calls or sending
2014 * instant messages), normally PJSUA requires the application to specify
2015 * which account to use for the request. If no account is specified,
2016 * PJSUA may be able to select the account by matching the destination
2017 * domain name, and fall back to default account when no match is found.
2018 */
2019
2020/**
2021 * Maximum accounts.
2022 */
2023#ifndef PJSUA_MAX_ACC
2024# define PJSUA_MAX_ACC 8
2025#endif
2026
2027
2028/**
2029 * Default registration interval.
2030 */
2031#ifndef PJSUA_REG_INTERVAL
Benny Prijonobddef2c2007-10-31 13:28:08 +00002032# define PJSUA_REG_INTERVAL 300
Benny Prijono312aff92006-06-17 04:08:30 +00002033#endif
2034
2035
2036/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002037 * Default PUBLISH expiration
2038 */
2039#ifndef PJSUA_PUBLISH_EXPIRATION
2040# define PJSUA_PUBLISH_EXPIRATION 600
2041#endif
2042
2043
2044/**
Benny Prijono093d3022006-09-24 00:07:11 +00002045 * Default account priority.
2046 */
2047#ifndef PJSUA_DEFAULT_ACC_PRIORITY
2048# define PJSUA_DEFAULT_ACC_PRIORITY 0
2049#endif
2050
2051
2052/**
Benny Prijono8058a622007-06-08 04:37:05 +00002053 * This macro specifies the URI scheme to use in Contact header
2054 * when secure transport such as TLS is used. Application can specify
2055 * either "sip" or "sips".
2056 */
2057#ifndef PJSUA_SECURE_SCHEME
Benny Prijono4c82c1e2008-10-16 08:14:51 +00002058# define PJSUA_SECURE_SCHEME "sip"
Benny Prijono8058a622007-06-08 04:37:05 +00002059#endif
2060
2061
2062/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002063 * This structure describes account configuration to be specified when
2064 * adding a new account with #pjsua_acc_add(). Application MUST initialize
2065 * this structure first by calling #pjsua_acc_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00002066 *
2067 * \par Python:
2068 * The data type in Python is <tt>py_pjsua.Acc_Config</tt>, but normally
2069 * application can just use the snippet below to create and initialize
2070 * the account config:
2071 * \code
2072 acc_cfg = py_pjsua.acc_config_default()
2073 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002074 */
2075typedef struct pjsua_acc_config
2076{
Benny Prijono093d3022006-09-24 00:07:11 +00002077 /**
Benny Prijono705e7842008-07-21 18:12:51 +00002078 * Arbitrary user data to be associated with the newly created account.
2079 * Application may set this later with #pjsua_acc_set_user_data() and
2080 * retrieve it with #pjsua_acc_get_user_data().
2081 */
2082 void *user_data;
2083
2084 /**
Benny Prijono093d3022006-09-24 00:07:11 +00002085 * Account priority, which is used to control the order of matching
2086 * incoming/outgoing requests. The higher the number means the higher
2087 * the priority is, and the account will be matched first.
2088 */
2089 int priority;
2090
Benny Prijono312aff92006-06-17 04:08:30 +00002091 /**
2092 * The full SIP URL for the account. The value can take name address or
2093 * URL format, and will look something like "sip:account@serviceprovider".
2094 *
2095 * This field is mandatory.
2096 */
2097 pj_str_t id;
2098
2099 /**
2100 * This is the URL to be put in the request URI for the registration,
2101 * and will look something like "sip:serviceprovider".
2102 *
2103 * This field should be specified if registration is desired. If the
2104 * value is empty, no account registration will be performed.
2105 */
2106 pj_str_t reg_uri;
2107
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002108 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002109 * If this flag is set, the presence information of this account will
2110 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono48ab2b72007-11-08 09:24:30 +00002111 *
2112 * Default: PJ_FALSE
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002113 */
2114 pj_bool_t publish_enabled;
2115
Benny Prijonofe04fb52007-08-24 08:28:52 +00002116 /**
Benny Prijono48ab2b72007-11-08 09:24:30 +00002117 * Authentication preference.
2118 */
2119 pjsip_auth_clt_pref auth_pref;
2120
2121 /**
Benny Prijonofe04fb52007-08-24 08:28:52 +00002122 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
2123 * is not specified, a random string will be used.
2124 */
2125 pj_str_t pidf_tuple_id;
2126
Benny Prijono312aff92006-06-17 04:08:30 +00002127 /**
2128 * Optional URI to be put as Contact for this account. It is recommended
2129 * that this field is left empty, so that the value will be calculated
2130 * automatically based on the transport address.
2131 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00002132 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00002133
2134 /**
Benny Prijono30fe4852008-12-10 16:54:16 +00002135 * Additional URI parameters that will be appended in the Contact header
2136 * for this account. This will affect the Contact header in all SIP
2137 * messages sent on behalf of this account, including but not limited to
2138 * REGISTER, INVITE, and SUBCRIBE requests or responses.
2139 *
2140 * The parameters should be preceeded by semicolon, and all strings must
2141 * be properly escaped. Example:
2142 * ";my-param=X;another-param=Hi%20there"
2143 */
2144 pj_str_t contact_params;
2145
2146 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00002147 * Specify whether support for reliable provisional response (100rel and
2148 * PRACK) should be required for all sessions of this account.
2149 *
2150 * Default: PJ_FALSE
2151 */
2152 pj_bool_t require_100rel;
2153
2154 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002155 * Number of proxies in the proxy array below.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002156 *
2157 * \par Python:
2158 * Not applicable, as \a proxy is implemented as list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00002159 */
2160 unsigned proxy_cnt;
2161
2162 /**
2163 * Optional URI of the proxies to be visited for all outgoing requests
2164 * that are using this account (REGISTER, INVITE, etc). Application need
2165 * to specify these proxies if the service provider requires that requests
2166 * destined towards its network should go through certain proxies first
2167 * (for example, border controllers).
2168 *
2169 * These proxies will be put in the route set for this account, with
2170 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00002171 * first). If global outbound proxies are configured in pjsua_config,
2172 * then these account proxies will be placed after the global outbound
2173 * proxies in the routeset.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002174 *
2175 * \par Python:
2176 * This will be list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00002177 */
2178 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
2179
2180 /**
2181 * Optional interval for registration, in seconds. If the value is zero,
Benny Prijonobddef2c2007-10-31 13:28:08 +00002182 * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
Benny Prijono312aff92006-06-17 04:08:30 +00002183 */
2184 unsigned reg_timeout;
2185
2186 /**
2187 * Number of credentials in the credential array.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002188 *
2189 * \par Python:
2190 * Not applicable, since \a cred_info is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00002191 */
2192 unsigned cred_count;
2193
2194 /**
2195 * Array of credentials. If registration is desired, normally there should
2196 * be at least one credential specified, to successfully authenticate
2197 * against the service provider. More credentials can be specified, for
2198 * example when the requests are expected to be challenged by the
2199 * proxies in the route set.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002200 *
2201 * \par Python:
2202 * This field is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00002203 */
2204 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
2205
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002206 /**
2207 * Optionally bind this account to specific transport. This normally is
2208 * not a good idea, as account should be able to send requests using
2209 * any available transports according to the destination. But some
2210 * application may want to have explicit control over the transport to
2211 * use, so in that case it can set this field.
2212 *
2213 * Default: -1 (PJSUA_INVALID_ID)
2214 *
2215 * @see pjsua_acc_set_transport()
2216 */
2217 pjsua_transport_id transport_id;
2218
Benny Prijono15b02302007-09-27 14:07:07 +00002219 /**
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002220 * This option is used to update the UDP transport address and the Contact
2221 * header of REGISTER request. When this option is enabled, the library
2222 * will keep track of the public IP address from the response of REGISTER
2223 * request. Once it detects that the address has changed, it will
2224 * unregister current Contact, update the Contact with transport address
2225 * learned from Via header, and register a new Contact to the registrar.
2226 * This will also update the public name of UDP transport if STUN is
2227 * configured.
Benny Prijono15b02302007-09-27 14:07:07 +00002228 *
2229 * Default: 1 (yes)
2230 */
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002231 pj_bool_t allow_contact_rewrite;
Benny Prijono15b02302007-09-27 14:07:07 +00002232
Benny Prijonobddef2c2007-10-31 13:28:08 +00002233 /**
2234 * Set the interval for periodic keep-alive transmission for this account.
2235 * If this value is zero, keep-alive will be disabled for this account.
2236 * The keep-alive transmission will be sent to the registrar's address,
2237 * after successful registration.
2238 *
Benny Prijonobddef2c2007-10-31 13:28:08 +00002239 * Default: 15 (seconds)
2240 */
2241 unsigned ka_interval;
2242
2243 /**
2244 * Specify the data to be transmitted as keep-alive packets.
2245 *
2246 * Default: CR-LF
2247 */
2248 pj_str_t ka_data;
2249
Benny Prijonod8179652008-01-23 20:39:07 +00002250#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
2251 /**
2252 * Specify whether secure media transport should be used for this account.
2253 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
2254 * PJMEDIA_SRTP_MANDATORY.
2255 *
2256 * Default: #PJSUA_DEFAULT_USE_SRTP
2257 */
2258 pjmedia_srtp_use use_srtp;
2259
2260 /**
2261 * Specify whether SRTP requires secure signaling to be used. This option
2262 * is only used when \a use_srtp option above is non-zero.
2263 *
2264 * Valid values are:
2265 * 0: SRTP does not require secure signaling
2266 * 1: SRTP requires secure transport such as TLS
2267 * 2: SRTP requires secure end-to-end transport (SIPS)
2268 *
2269 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
2270 */
2271 int srtp_secure_signaling;
2272#endif
2273
Benny Prijono312aff92006-06-17 04:08:30 +00002274} pjsua_acc_config;
2275
2276
2277/**
2278 * Call this function to initialize account config with default values.
2279 *
2280 * @param cfg The account config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002281 *
2282 * \par Python:
2283 * In Python, this function both creates and initializes the account
2284 * config:
2285 * \code
2286 acc_cfg = py_pjsua.acc_config_default()
2287 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002288 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00002289PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002290
2291
2292/**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002293 * Duplicate account config.
2294 *
2295 * @param pool Pool to be used for duplicating the config.
2296 * @param dst Destination configuration.
2297 * @param src Source configuration.
2298 */
2299PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
2300 pjsua_acc_config *dst,
2301 const pjsua_acc_config *src);
2302
2303
2304/**
Benny Prijono312aff92006-06-17 04:08:30 +00002305 * Account info. Application can query account info by calling
2306 * #pjsua_acc_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00002307 *
2308 * \par Python:
2309 * The data type in Python is <tt>py_pjsua.Acc_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002310 */
2311typedef struct pjsua_acc_info
2312{
2313 /**
2314 * The account ID.
2315 */
2316 pjsua_acc_id id;
2317
2318 /**
2319 * Flag to indicate whether this is the default account.
2320 */
2321 pj_bool_t is_default;
2322
2323 /**
2324 * Account URI
2325 */
2326 pj_str_t acc_uri;
2327
2328 /**
2329 * Flag to tell whether this account has registration setting
2330 * (reg_uri is not empty).
2331 */
2332 pj_bool_t has_registration;
2333
2334 /**
2335 * An up to date expiration interval for account registration session.
2336 */
2337 int expires;
2338
2339 /**
2340 * Last registration status code. If status code is zero, the account
2341 * is currently not registered. Any other value indicates the SIP
2342 * status code of the registration.
2343 */
2344 pjsip_status_code status;
2345
2346 /**
2347 * String describing the registration status.
2348 */
2349 pj_str_t status_text;
2350
2351 /**
2352 * Presence online status for this account.
2353 */
2354 pj_bool_t online_status;
2355
2356 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00002357 * Presence online status text.
2358 */
2359 pj_str_t online_status_text;
2360
2361 /**
2362 * Extended RPID online status information.
2363 */
2364 pjrpid_element rpid;
2365
2366 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002367 * Buffer that is used internally to store the status text.
2368 */
2369 char buf_[PJ_ERR_MSG_SIZE];
2370
2371} pjsua_acc_info;
2372
2373
2374
2375/**
2376 * Get number of current accounts.
2377 *
2378 * @return Current number of accounts.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002379 *
2380 * \par Python:
2381 * \code
2382 count = py_pjsua.acc_get_count()
2383 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002384 */
2385PJ_DECL(unsigned) pjsua_acc_get_count(void);
2386
2387
2388/**
2389 * Check if the specified account ID is valid.
2390 *
2391 * @param acc_id Account ID to check.
2392 *
2393 * @return Non-zero if account ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002394 *
2395 * \par Python:
2396 * \code
2397 is_valid = py_pjsua.acc_is_valid(acc_id)
2398 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002399 */
2400PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
2401
2402
2403/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00002404 * Set default account to be used when incoming and outgoing
2405 * requests doesn't match any accounts.
2406 *
2407 * @param acc_id The account ID to be used as default.
2408 *
2409 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002410 *
2411 * \par Python:
2412 * \code
2413 status = py_pjsua.acc_set_default(acc_id)
2414 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002415 */
2416PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2417
2418
2419/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002420 * Get default account to be used when receiving incoming requests (calls),
2421 * when the destination of the incoming call doesn't match any other
2422 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002423 *
2424 * @return The default account ID, or PJSUA_INVALID_ID if no
2425 * default account is configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002426 *
2427 * \par Python:
2428 * \code
2429 acc_id = py_pjsua.acc_get_default()
2430 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002431 */
2432PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2433
2434
2435/**
Benny Prijono312aff92006-06-17 04:08:30 +00002436 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002437 * #pjsua_init()) before calling this function. If registration is configured
2438 * for this account, this function would also start the SIP registration
2439 * session with the SIP registrar server. This SIP registration session
2440 * will be maintained internally by the library, and application doesn't
2441 * need to do anything to maintain the registration session.
2442 *
Benny Prijono312aff92006-06-17 04:08:30 +00002443 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002444 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002445 * @param is_default If non-zero, this account will be set as the default
2446 * account. The default account will be used when sending
2447 * outgoing requests (e.g. making call) when no account is
2448 * specified, and when receiving incoming requests when the
2449 * request does not match any accounts. It is recommended
2450 * that default account is set to local/LAN account.
2451 * @param p_acc_id Pointer to receive account ID of the new account.
2452 *
2453 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002454 *
2455 * \par Python:
2456 * The function returns (status, account_id) tuple:
2457 * \code
2458 status, account_id = py_pjsua.acc_add(acc_cfg, is_default)
2459 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002460 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002461PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002462 pj_bool_t is_default,
2463 pjsua_acc_id *p_acc_id);
2464
2465
2466/**
2467 * Add a local account. A local account is used to identify local endpoint
2468 * instead of a specific user, and for this reason, a transport ID is needed
2469 * to obtain the local address information.
2470 *
2471 * @param tid Transport ID to generate account address.
2472 * @param is_default If non-zero, this account will be set as the default
2473 * account. The default account will be used when sending
2474 * outgoing requests (e.g. making call) when no account is
2475 * specified, and when receiving incoming requests when the
2476 * request does not match any accounts. It is recommended
2477 * that default account is set to local/LAN account.
2478 * @param p_acc_id Pointer to receive account ID of the new account.
2479 *
2480 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002481 *
2482 * \par Python:
2483 * The function returns (status, account_id) tuple:
2484 * \code
2485 status, account_id = py_pjsua.acc_add_local(tid, is_default)
2486 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002487 */
2488PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2489 pj_bool_t is_default,
2490 pjsua_acc_id *p_acc_id);
2491
2492/**
Benny Prijono705e7842008-07-21 18:12:51 +00002493 * Set arbitrary data to be associated with the account.
2494 *
2495 * @param acc_id The account ID.
2496 * @param user_data User/application data.
2497 *
2498 * @return PJ_SUCCESS on success, or the appropriate error code.
2499 */
2500PJ_DECL(pj_status_t) pjsua_acc_set_user_data(pjsua_acc_id acc_id,
2501 void *user_data);
2502
2503
2504/**
2505 * Retrieve arbitrary data associated with the account.
2506 *
2507 * @param acc_id The account ID.
2508 *
2509 * @return The user data. In the case where the account ID is
2510 * not valid, NULL is returned.
2511 */
2512PJ_DECL(void*) pjsua_acc_get_user_data(pjsua_acc_id acc_id);
2513
2514
2515/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002516 * Delete an account. This will unregister the account from the SIP server,
2517 * if necessary, and terminate server side presence subscriptions associated
2518 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002519 *
2520 * @param acc_id Id of the account to be deleted.
2521 *
2522 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002523 *
2524 * \par Python:
2525 * \code
2526 status = py_pjsua.acc_del(acc_id)
2527 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002528 */
2529PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2530
2531
2532/**
2533 * Modify account information.
2534 *
2535 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002536 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002537 *
2538 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002539 *
2540 * \par Python:
2541 * \code
2542 status = py_pjsua.acc_modify(acc_id, acc_cfg)
2543 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002544 */
2545PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002546 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002547
2548
2549/**
2550 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002551 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002552 * if there are server side presence subscription for this account, and/or
2553 * outgoing PUBLISH if presence publication is enabled for this account.
2554 *
2555 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002556 *
2557 * @param acc_id The account ID.
2558 * @param is_online True of false.
2559 *
2560 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002561 *
2562 * \par Python:
2563 * \code
2564 status = py_pjsua.acc_set_online_status(acc_id, is_online)
2565 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002566 */
2567PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2568 pj_bool_t is_online);
2569
Benny Prijono4461c7d2007-08-25 13:36:15 +00002570/**
2571 * Modify account's presence status to be advertised to remote/presence
2572 * subscribers. This would trigger the sending of outgoing NOTIFY request
2573 * if there are server side presence subscription for this account, and/or
2574 * outgoing PUBLISH if presence publication is enabled for this account.
2575 *
2576 * @see pjsua_acc_set_online_status()
2577 *
2578 * @param acc_id The account ID.
2579 * @param is_online True of false.
2580 * @param pr Extended information in subset of RPID format
2581 * which allows setting custom presence text.
2582 *
2583 * @return PJ_SUCCESS on success, or the appropriate error code.
2584 */
2585PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2586 pj_bool_t is_online,
2587 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002588
2589/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002590 * Update registration or perform unregistration. If registration is
2591 * configured for this account, then initial SIP REGISTER will be sent
2592 * when the account is added with #pjsua_acc_add(). Application normally
2593 * only need to call this function if it wants to manually update the
2594 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002595 *
2596 * @param acc_id The account ID.
2597 * @param renew If renew argument is zero, this will start
2598 * unregistration process.
2599 *
2600 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002601 *
2602 * \par Python:
2603 * \code
2604 status = py_pjsua.acc_set_registration(acc_id, renew)
2605 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002606 */
2607PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2608 pj_bool_t renew);
2609
Benny Prijono312aff92006-06-17 04:08:30 +00002610/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002611 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002612 *
2613 * @param acc_id Account identification.
2614 * @param info Pointer to receive account information.
2615 *
2616 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002617 *
2618 * \par Python:
2619 * \code
2620 acc_info = py_pjsua.acc_get_info(acc_id)
2621 * \endcode
2622 * The function returns None if account ID is not valid.
Benny Prijono312aff92006-06-17 04:08:30 +00002623 */
2624PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2625 pjsua_acc_info *info);
2626
2627
2628/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002629 * Enumerate all account currently active in the library. This will fill
2630 * the array with the account Ids, and application can then query the
2631 * account information for each id with #pjsua_acc_get_info().
2632 *
2633 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002634 *
2635 * @param ids Array of account IDs to be initialized.
2636 * @param count In input, specifies the maximum number of elements.
2637 * On return, it contains the actual number of elements.
2638 *
2639 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002640 *
2641 * \par Python:
2642 * The function takes no argument and returns list of account Ids:
2643 * \code
2644 [acc_ids] = py_pjsua.enum_accs()
2645 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002646 */
2647PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2648 unsigned *count );
2649
2650
2651/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002652 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002653 *
2654 * @param info Array of account infos to be initialized.
2655 * @param count In input, specifies the maximum number of elements.
2656 * On return, it contains the actual number of elements.
2657 *
2658 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002659 *
2660 * \par Python:
2661 * The function takes no argument and returns list of account infos:
2662 * \code
2663 [acc_info] = py_pjsua.acc_enum_info()
2664 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002665 */
2666PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2667 unsigned *count );
2668
2669
2670/**
2671 * This is an internal function to find the most appropriate account to
2672 * used to reach to the specified URL.
2673 *
2674 * @param url The remote URL to reach.
2675 *
2676 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002677 *
2678 * \par Python:
2679 * \code
2680 acc_id = py_pjsua.acc_find_for_outgoing(url)
2681 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002682 */
2683PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2684
2685
2686/**
2687 * This is an internal function to find the most appropriate account to be
2688 * used to handle incoming calls.
2689 *
2690 * @param rdata The incoming request message.
2691 *
2692 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002693 *
2694 * \par Python:
2695 * \code
2696 acc_id = py_pjsua.acc_find_for_outgoing(url)
2697 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002698 */
2699PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2700
2701
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002702/**
Benny Prijonofff245c2007-04-02 11:44:47 +00002703 * Create arbitrary requests using the account. Application should only use
2704 * this function to create auxiliary requests outside dialog, such as
2705 * OPTIONS, and use the call or presence API to create dialog related
2706 * requests.
2707 *
2708 * @param acc_id The account ID.
2709 * @param method The SIP method of the request.
2710 * @param target Target URI.
2711 * @param p_tdata Pointer to receive the request.
2712 *
2713 * @return PJ_SUCCESS or the error code.
2714 */
2715PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
2716 const pjsip_method *method,
2717 const pj_str_t *target,
2718 pjsip_tx_data **p_tdata);
2719
2720
2721/**
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002722 * Create a suitable URI to be put as Contact based on the specified
2723 * target URI for the specified account.
2724 *
2725 * @param pool Pool to allocate memory for the string.
2726 * @param contact The string where the Contact URI will be stored.
2727 * @param acc_id Account ID.
2728 * @param uri Destination URI of the request.
2729 *
2730 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002731 *
2732 * \par Python:
2733 * This function is still experimental in Python:
2734 * \code
2735 uri = py_pjsua.acc_create_uac_contact(pool, acc_id, uri)
2736 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002737 */
2738PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
2739 pj_str_t *contact,
2740 pjsua_acc_id acc_id,
2741 const pj_str_t *uri);
2742
2743
2744
2745/**
2746 * Create a suitable URI to be put as Contact based on the information
2747 * in the incoming request.
2748 *
2749 * @param pool Pool to allocate memory for the string.
2750 * @param contact The string where the Contact URI will be stored.
2751 * @param acc_id Account ID.
2752 * @param rdata Incoming request.
2753 *
2754 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002755 *
2756 * \par Python:
2757 * This function is still experimental in Python:
2758 * \code
2759 uri = py_pjsua.acc_create_uas_contact(pool, acc_id, rdata)
2760 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002761 */
2762PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
2763 pj_str_t *contact,
2764 pjsua_acc_id acc_id,
2765 pjsip_rx_data *rdata );
2766
2767
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002768/**
2769 * Lock/bind this account to a specific transport/listener. Normally
2770 * application shouldn't need to do this, as transports will be selected
2771 * automatically by the stack according to the destination.
2772 *
2773 * When account is locked/bound to a specific transport, all outgoing
2774 * requests from this account will use the specified transport (this
2775 * includes SIP registration, dialog (call and event subscription), and
2776 * out-of-dialog requests such as MESSAGE).
2777 *
2778 * Note that transport_id may be specified in pjsua_acc_config too.
2779 *
2780 * @param acc_id The account ID.
2781 * @param tp_id The transport ID.
2782 *
2783 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002784 *
2785 * \par Python:
2786 * Not yet implemented.
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002787 */
2788PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
2789 pjsua_transport_id tp_id);
2790
Benny Prijono312aff92006-06-17 04:08:30 +00002791
2792/**
2793 * @}
2794 */
2795
2796
2797/*****************************************************************************
2798 * CALLS API
2799 */
2800
2801
2802/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002803 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00002804 * @ingroup PJSUA_LIB
2805 * @brief Call manipulation.
2806 * @{
2807 */
2808
2809/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002810 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00002811 */
2812#ifndef PJSUA_MAX_CALLS
2813# define PJSUA_MAX_CALLS 32
2814#endif
2815
2816
2817
2818/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002819 * This enumeration specifies the media status of a call, and it's part
2820 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00002821 */
2822typedef enum pjsua_call_media_status
2823{
Benny Prijonob5388cf2007-01-04 22:45:08 +00002824 /** Call currently has no media */
Benny Prijono312aff92006-06-17 04:08:30 +00002825 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002826
2827 /** The media is active */
Benny Prijono312aff92006-06-17 04:08:30 +00002828 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002829
2830 /** The media is currently put on hold by local endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002831 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002832
2833 /** The media is currently put on hold by remote endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002834 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002835
Benny Prijono096c56c2007-09-15 08:30:16 +00002836 /** The media has reported error (e.g. ICE negotiation) */
2837 PJSUA_CALL_MEDIA_ERROR
2838
Benny Prijono312aff92006-06-17 04:08:30 +00002839} pjsua_call_media_status;
2840
2841
2842/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002843 * This structure describes the information and current status of a call.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002844 *
2845 * \par Python:
2846 * The type name is <tt>py_pjsua.Call_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002847 */
2848typedef struct pjsua_call_info
2849{
2850 /** Call identification. */
2851 pjsua_call_id id;
2852
2853 /** Initial call role (UAC == caller) */
2854 pjsip_role_e role;
2855
Benny Prijono90315512006-09-14 16:05:16 +00002856 /** The account ID where this call belongs. */
2857 pjsua_acc_id acc_id;
2858
Benny Prijono312aff92006-06-17 04:08:30 +00002859 /** Local URI */
2860 pj_str_t local_info;
2861
2862 /** Local Contact */
2863 pj_str_t local_contact;
2864
2865 /** Remote URI */
2866 pj_str_t remote_info;
2867
2868 /** Remote contact */
2869 pj_str_t remote_contact;
2870
2871 /** Dialog Call-ID string. */
2872 pj_str_t call_id;
2873
2874 /** Call state */
2875 pjsip_inv_state state;
2876
2877 /** Text describing the state */
2878 pj_str_t state_text;
2879
2880 /** Last status code heard, which can be used as cause code */
2881 pjsip_status_code last_status;
2882
2883 /** The reason phrase describing the status. */
2884 pj_str_t last_status_text;
2885
2886 /** Call media status. */
2887 pjsua_call_media_status media_status;
2888
2889 /** Media direction */
2890 pjmedia_dir media_dir;
2891
2892 /** The conference port number for the call */
2893 pjsua_conf_port_id conf_slot;
2894
2895 /** Up-to-date call connected duration (zero when call is not
2896 * established)
2897 */
2898 pj_time_val connect_duration;
2899
2900 /** Total call duration, including set-up time */
2901 pj_time_val total_duration;
2902
2903 /** Internal */
2904 struct {
2905 char local_info[128];
2906 char local_contact[128];
2907 char remote_info[128];
2908 char remote_contact[128];
2909 char call_id[128];
2910 char last_status_text[128];
2911 } buf_;
2912
2913} pjsua_call_info;
2914
2915
2916
Benny Prijonoa91a0032006-02-26 21:23:45 +00002917/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002918 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002919 *
2920 * @return Maximum number of calls configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002921 *
2922 * \par Python:
2923 * \code
2924 count = py_pjsua.call_get_max_count()
2925 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002926 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002927PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002928
2929/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002930 * Get number of currently active calls.
2931 *
2932 * @return Number of currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002933 *
2934 * \par Python:
2935 * \code
2936 count = py_pjsua.call_get_count()
2937 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002938 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002939PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002940
2941/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002942 * Enumerate all active calls. Application may then query the information and
2943 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002944 *
2945 * @param ids Array of account IDs to be initialized.
2946 * @param count In input, specifies the maximum number of elements.
2947 * On return, it contains the actual number of elements.
2948 *
2949 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002950 *
2951 * \par Python:
2952 * This function takes no argument and return list of call Ids.
2953 * \code
2954 [call_ids] = py_pjsua.enum_calls()
2955 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002956 */
2957PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
2958 unsigned *count);
2959
2960
2961/**
2962 * Make outgoing call to the specified URI using the specified account.
2963 *
2964 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002965 * @param dst_uri URI to be put in the To header (normally is the same
2966 * as the target URI).
2967 * @param options Options (must be zero at the moment).
2968 * @param user_data Arbitrary user data to be attached to the call, and
2969 * can be retrieved later.
2970 * @param msg_data Optional headers etc to be added to outgoing INVITE
2971 * request, or NULL if no custom header is desired.
2972 * @param p_call_id Pointer to receive call identification.
2973 *
2974 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002975 *
2976 * \par Python:
2977 * The Python function returns (status, call_id) tuple:
2978 * \code
2979 status, call_id = py_pjsua.call_make_call(acc_id, dst_uri, options,
2980 user_data, msg_data)
2981 * \endcode
2982 * Note: the \a user_data in Python function is an integer, and the
2983 * \a msg_data can be set to None if not required.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002984 */
2985PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
2986 const pj_str_t *dst_uri,
2987 unsigned options,
2988 void *user_data,
2989 const pjsua_msg_data *msg_data,
2990 pjsua_call_id *p_call_id);
2991
2992
2993/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002994 * Check if the specified call has active INVITE session and the INVITE
2995 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002996 *
2997 * @param call_id Call identification.
2998 *
2999 * @return Non-zero if call is active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003000 *
3001 * \par Python:
3002 * \code
3003 bool = py_pjsua.call_is_active(call_id)
3004 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003005 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003006PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003007
3008
3009/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003010 * Check if call has an active media session.
3011 *
3012 * @param call_id Call identification.
3013 *
3014 * @return Non-zero if yes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003015 *
3016 * \par Python:
3017 * \code
3018 bool = py_pjsua.call_has_media(call_id)
3019 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003020 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003021PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003022
3023
3024/**
Benny Prijonocf986c42008-09-02 11:25:07 +00003025 * Retrieve the media session associated with this call. Note that the media
3026 * session may not be available depending on the current call's media status
3027 * (the pjsua_call_media_status information in pjsua_call_info). Application
3028 * may use the media session to retrieve more detailed information about the
3029 * call's media.
3030 *
3031 * @param call_id Call identification.
3032 *
3033 * @return Call media session.
3034 */
3035PJ_DECL(pjmedia_session*) pjsua_call_get_media_session(pjsua_call_id call_id);
3036
3037
3038/**
3039 * Retrieve the media transport instance that is used for this call.
3040 * Application may use the media transport to query more detailed information
3041 * about the media transport.
3042 *
3043 * @param cid Call identification (the call_id).
3044 *
3045 * @return Call media transport.
3046 */
3047PJ_DECL(pjmedia_transport*) pjsua_call_get_media_transport(pjsua_call_id cid);
3048
3049
3050/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003051 * Get the conference port identification associated with the call.
3052 *
3053 * @param call_id Call identification.
3054 *
3055 * @return Conference port ID, or PJSUA_INVALID_ID when the
3056 * media has not been established or is not active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003057 *
3058 * \par Python:
3059 * \code
3060 slot = py_pjsua.call_get_conf_port(call_id)
3061 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003062 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003063PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
3064
3065/**
3066 * Obtain detail information about the specified call.
3067 *
3068 * @param call_id Call identification.
3069 * @param info Call info to be initialized.
3070 *
3071 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003072 *
3073 * \par Python:
3074 * \code
3075 call_info = py_pjsua.call_get_info(call_id)
3076 * \endcode
3077 * \a call_info return value will be set to None if call_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003078 */
3079PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003080 pjsua_call_info *info);
3081
3082
3083/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003084 * Attach application specific data to the call. Application can then
3085 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003086 *
3087 * @param call_id Call identification.
3088 * @param user_data Arbitrary data to be attached to the call.
3089 *
3090 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003091 *
3092 * \par Python:
3093 * \code
3094 status = py_pjsua.call_set_user_data(call_id, user_data)
3095 * \endcode
3096 * The \a user_data is an integer in the Python function.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003097 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003098PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
3099 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003100
3101
3102/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003103 * Get user data attached to the call, which has been previously set with
3104 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003105 *
3106 * @param call_id Call identification.
3107 *
3108 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003109 *
3110 * \par Python:
3111 * \code
3112 user_data = py_pjsua.call_get_user_data(call_id)
3113 * \endcode
3114 * The \a user_data is an integer.
Benny Prijono268ca612006-02-07 12:34:11 +00003115 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003116PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00003117
3118
3119/**
Benny Prijono91a6a172007-10-31 08:59:29 +00003120 * Get the NAT type of remote's endpoint. This is a proprietary feature
3121 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
3122 * is set in #pjsua_config.
3123 *
3124 * This function can only be called after SDP has been received from remote,
3125 * which means for incoming call, this function can be called as soon as
3126 * call is received as long as incoming call contains SDP, and for outgoing
3127 * call, this function can be called only after SDP is received (normally in
3128 * 200/OK response to INVITE). As a general case, application should call
3129 * this function after or in \a on_call_media_state() callback.
3130 *
3131 * @param call_id Call identification.
3132 * @param p_type Pointer to store the NAT type. Application can then
3133 * retrieve the string description of the NAT type
3134 * by calling pj_stun_get_nat_name().
3135 *
3136 * @return PJ_SUCCESS on success.
3137 *
3138 * @see pjsua_get_nat_type(), nat_type_in_sdp
3139 */
3140PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
3141 pj_stun_nat_type *p_type);
3142
3143/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003144 * Send response to incoming INVITE request. Depending on the status
3145 * code specified as parameter, this function may send provisional
3146 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003147 *
3148 * @param call_id Incoming call identification.
3149 * @param code Status code, (100-699).
3150 * @param reason Optional reason phrase. If NULL, default text
3151 * will be used.
3152 * @param msg_data Optional list of headers etc to be added to outgoing
3153 * response message.
3154 *
3155 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003156 *
3157 * \par Python:
3158 * \code
3159 status = py_pjsua.call_answer(call_id, code, reason, msg_data)
3160 * \endcode
3161 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijonoa91a0032006-02-26 21:23:45 +00003162 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003163PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
3164 unsigned code,
3165 const pj_str_t *reason,
3166 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00003167
3168/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003169 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00003170 * call state. This function is different than answering the call with
3171 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
3172 * will hangup the call regardless of the state and role of the call,
3173 * while #pjsua_call_answer() only works with incoming calls on EARLY
3174 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003175 *
3176 * @param call_id Call identification.
3177 * @param code Optional status code to be sent when we're rejecting
3178 * incoming call. If the value is zero, "603/Decline"
3179 * will be sent.
3180 * @param reason Optional reason phrase to be sent when we're rejecting
3181 * incoming call. If NULL, default text will be used.
3182 * @param msg_data Optional list of headers etc to be added to outgoing
3183 * request/response message.
3184 *
3185 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003186 *
3187 * \par Python:
3188 * \code
3189 status = py_pjsua.call_hangup(call_id, code, reason, msg_data)
3190 * \endcode
3191 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003192 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003193PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
3194 unsigned code,
3195 const pj_str_t *reason,
3196 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003197
Benny Prijono5e51a4e2008-11-27 00:06:46 +00003198/**
3199 * Accept or reject redirection response. Application MUST call this function
3200 * after it signaled PJSIP_REDIRECT_PENDING in the \a on_call_redirected()
3201 * callback, to notify the call whether to accept or reject the redirection
3202 * to the current target. Application can use the combination of
3203 * PJSIP_REDIRECT_PENDING command in \a on_call_redirected() callback and
3204 * this function to ask for user permission before redirecting the call.
3205 *
3206 * Note that if the application chooses to reject or stop redirection (by
3207 * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the
3208 * call disconnection callback will be called before this function returns.
3209 * And if the application rejects the target, the \a on_call_redirected()
3210 * callback may also be called before this function returns if there is
3211 * another target to try.
3212 *
3213 * @param call_id The call ID.
3214 * @param cmd Redirection operation to be applied to the current
3215 * target. The semantic of this argument is similar
3216 * to the description in the \a on_call_redirected()
3217 * callback, except that the PJSIP_REDIRECT_PENDING is
3218 * not accepted here.
3219 *
3220 * @return PJ_SUCCESS on successful operation.
3221 */
3222PJ_DECL(pj_status_t) pjsua_call_process_redirect(pjsua_call_id call_id,
3223 pjsip_redirect_op cmd);
Benny Prijono26ff9062006-02-21 23:47:00 +00003224
3225/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003226 * Put the specified call on hold. This will send re-INVITE with the
3227 * appropriate SDP to inform remote that the call is being put on hold.
3228 * The final status of the request itself will be reported on the
3229 * \a on_call_media_state() callback, which inform the application that
3230 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003231 *
3232 * @param call_id Call identification.
3233 * @param msg_data Optional message components to be sent with
3234 * the request.
3235 *
3236 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003237 *
3238 * \par Python:
3239 * \code
3240 status = py_pjsua.call_set_hold(call_id, msg_data)
3241 * \endcode
3242 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003243 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003244PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
3245 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003246
3247
3248/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003249 * Send re-INVITE to release hold.
3250 * The final status of the request itself will be reported on the
3251 * \a on_call_media_state() callback, which inform the application that
3252 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003253 *
3254 * @param call_id Call identification.
3255 * @param unhold If this argument is non-zero and the call is locally
3256 * held, this will release the local hold.
3257 * @param msg_data Optional message components to be sent with
3258 * the request.
3259 *
3260 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003261 *
3262 * \par Python:
3263 * \code
3264 status = py_pjsua.call_reinvite(call_id, unhold, msg_data)
3265 * \endcode
3266 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003267 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003268PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
3269 pj_bool_t unhold,
3270 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003271
Benny Prijonoc08682e2007-10-04 06:17:58 +00003272/**
3273 * Send UPDATE request.
3274 *
3275 * @param call_id Call identification.
3276 * @param options Must be zero for now.
3277 * @param msg_data Optional message components to be sent with
3278 * the request.
3279 *
3280 * @return PJ_SUCCESS on success, or the appropriate error code.
3281 */
3282PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
3283 unsigned options,
3284 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003285
3286/**
Benny Prijono053f5222006-11-11 16:16:04 +00003287 * Initiate call transfer to the specified address. This function will send
3288 * REFER request to instruct remote call party to initiate a new INVITE
3289 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003290 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00003291 * If application is interested to monitor the successfulness and
3292 * the progress of the transfer request, it can implement
3293 * \a on_call_transfer_status() callback which will report the progress
3294 * of the call transfer request.
3295 *
Benny Prijono053f5222006-11-11 16:16:04 +00003296 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003297 * @param dest Address of new target to be contacted.
3298 * @param msg_data Optional message components to be sent with
3299 * the request.
3300 *
3301 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003302 *
3303 * \par Python:
3304 * \code
3305 status = py_pjsua.call_xfer(call_id, dest, msg_data)
3306 * \endcode
3307 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003308 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003309PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
3310 const pj_str_t *dest,
3311 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003312
3313/**
Benny Prijono053f5222006-11-11 16:16:04 +00003314 * Flag to indicate that "Require: replaces" should not be put in the
3315 * outgoing INVITE request caused by REFER request created by
3316 * #pjsua_call_xfer_replaces().
3317 */
3318#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
3319
3320/**
3321 * Initiate attended call transfer. This function will send REFER request
3322 * to instruct remote call party to initiate new INVITE session to the URL
3323 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
3324 * the call with us with the new call from the REFER recipient.
3325 *
3326 * @param call_id The call id to be transfered.
3327 * @param dest_call_id The call id to be replaced.
3328 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
3329 * to suppress the inclusion of "Require: replaces" in
3330 * the outgoing INVITE request created by the REFER
3331 * request.
3332 * @param msg_data Optional message components to be sent with
3333 * the request.
3334 *
3335 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003336 *
3337 * \par Python:
3338 * \code
3339 status = py_pjsua.call_xfer_replaces(call_id, dest_call_id, options, msg_data)
3340 * \endcode
3341 * Argument \a msg_data may be set to None if not required.
Benny Prijono053f5222006-11-11 16:16:04 +00003342 */
3343PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
3344 pjsua_call_id dest_call_id,
3345 unsigned options,
3346 const pjsua_msg_data *msg_data);
3347
3348/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003349 * Send DTMF digits to remote using RFC 2833 payload formats.
3350 *
3351 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003352 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003353 *
3354 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003355 *
3356 * \par Python:
3357 * \code
3358 status = py_pjsua.call_dial_dtmf(call_id, digits)
3359 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003360 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003361PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003362 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00003363
Benny Prijono26ff9062006-02-21 23:47:00 +00003364/**
Benny Prijonob0808372006-03-02 21:18:58 +00003365 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003366 *
3367 * @param call_id Call identification.
3368 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3369 * assumed.
3370 * @param content The message content.
3371 * @param msg_data Optional list of headers etc to be included in outgoing
3372 * request. The body descriptor in the msg_data is
3373 * ignored.
3374 * @param user_data Optional user data, which will be given back when
3375 * the IM callback is called.
3376 *
3377 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003378 *
3379 * \par Python:
3380 * \code
3381 status = py_pjsua.call_send_im(call_id, mime_type, content, msg_data, user_data)
3382 * \endcode
3383 * Note that the \a user_data argument is an integer in Python.
Benny Prijonob0808372006-03-02 21:18:58 +00003384 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003385PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
3386 const pj_str_t *mime_type,
3387 const pj_str_t *content,
3388 const pjsua_msg_data *msg_data,
3389 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003390
3391
3392/**
3393 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003394 *
3395 * @param call_id Call identification.
3396 * @param is_typing Non-zero to indicate to remote that local person is
3397 * currently typing an IM.
3398 * @param msg_data Optional list of headers etc to be included in outgoing
3399 * request.
3400 *
3401 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003402 *
3403 * \par Python:
3404 * \code
3405 status = py_pjsua.call_send_typing_ind(call_id, is_typing, msg_data)
3406 * \endcode
3407 * Argument \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003408 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003409PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
3410 pj_bool_t is_typing,
3411 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003412
3413/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00003414 * Send arbitrary request with the call. This is useful for example to send
3415 * INFO request. Note that application should not use this function to send
3416 * requests which would change the invite session's state, such as re-INVITE,
3417 * UPDATE, PRACK, and BYE.
3418 *
3419 * @param call_id Call identification.
3420 * @param method SIP method of the request.
3421 * @param msg_data Optional message body and/or list of headers to be
3422 * included in outgoing request.
3423 *
3424 * @return PJ_SUCCESS on success, or the appropriate error code.
3425 */
3426PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
3427 const pj_str_t *method,
3428 const pjsua_msg_data *msg_data);
3429
3430
3431/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003432 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
3433 * currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003434 *
3435 * \par Python:
3436 * \code
3437 py_pjsua.call_hangup_all()
3438 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003439 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00003440PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00003441
3442
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003443/**
3444 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003445 *
3446 * @param call_id Call identification.
3447 * @param with_media Non-zero to include media information too.
3448 * @param buffer Buffer where the statistics are to be written to.
3449 * @param maxlen Maximum length of buffer.
3450 * @param indent Spaces for left indentation.
3451 *
3452 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003453 *
3454 * \par Python:
3455 * \code
3456 string = py_pjsua.call_dump(call_id, with_media, max_len, indent)
3457 * \endcode
3458 * The \a max_len argument is the desired maximum length to be allocated.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003459 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003460PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
3461 pj_bool_t with_media,
3462 char *buffer,
3463 unsigned maxlen,
3464 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003465
Benny Prijono9fc735d2006-05-28 14:58:12 +00003466/**
Benny Prijono312aff92006-06-17 04:08:30 +00003467 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003468 */
Benny Prijono834aee32006-02-19 01:38:06 +00003469
3470
3471/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00003472 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00003473 */
3474
Benny Prijono312aff92006-06-17 04:08:30 +00003475
3476/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003477 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00003478 * @ingroup PJSUA_LIB
3479 * @brief Buddy management, buddy's presence, and instant messaging.
3480 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00003481 *
3482 * This section describes PJSUA-APIs related to buddies management,
3483 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00003484 */
3485
3486/**
3487 * Max buddies in buddy list.
3488 */
3489#ifndef PJSUA_MAX_BUDDIES
3490# define PJSUA_MAX_BUDDIES 256
3491#endif
3492
3493
3494/**
Benny Prijonoa17496a2007-10-31 10:20:31 +00003495 * This specifies how long the library should retry resending SUBSCRIBE
3496 * if the previous SUBSCRIBE failed.
3497 *
3498 * Default: 300 seconds
3499 */
3500#ifndef PJSUA_PRES_TIMER
3501# define PJSUA_PRES_TIMER 300
3502#endif
3503
3504
3505/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003506 * This structure describes buddy configuration when adding a buddy to
3507 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
3508 * the structure with #pjsua_buddy_config_default() to initialize this
3509 * structure with default configuration.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003510 *
3511 * \par Python:
3512 * In Python this structure is <tt>py_pjsua.Buddy_Config</tt>. However
3513 * it is recommended that application instantiates the buddy config
3514 * by calling:
3515 * \code
3516 buddy_cfg = py_pjsua.buddy_config_default()
3517 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003518 */
3519typedef struct pjsua_buddy_config
3520{
3521 /**
3522 * Buddy URL or name address.
3523 */
3524 pj_str_t uri;
3525
3526 /**
3527 * Specify whether presence subscription should start immediately.
3528 */
3529 pj_bool_t subscribe;
3530
Benny Prijono705e7842008-07-21 18:12:51 +00003531 /**
3532 * Specify arbitrary application data to be associated with with
3533 * the buddy object.
3534 */
3535 void *user_data;
3536
Benny Prijono312aff92006-06-17 04:08:30 +00003537} pjsua_buddy_config;
3538
3539
3540/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003541 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003542 */
3543typedef enum pjsua_buddy_status
3544{
3545 /**
3546 * Online status is unknown (possibly because no presence subscription
3547 * has been established).
3548 */
3549 PJSUA_BUDDY_STATUS_UNKNOWN,
3550
3551 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003552 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003553 */
3554 PJSUA_BUDDY_STATUS_ONLINE,
3555
3556 /**
3557 * Buddy is offline.
3558 */
3559 PJSUA_BUDDY_STATUS_OFFLINE,
3560
3561} pjsua_buddy_status;
3562
3563
3564
3565/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003566 * This structure describes buddy info, which can be retrieved by calling
3567 * #pjsua_buddy_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003568 *
3569 * \par Python:
3570 * This structure in Python is <tt>py_pjsua.Buddy_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003571 */
3572typedef struct pjsua_buddy_info
3573{
3574 /**
3575 * The buddy ID.
3576 */
3577 pjsua_buddy_id id;
3578
3579 /**
3580 * The full URI of the buddy, as specified in the configuration.
3581 */
3582 pj_str_t uri;
3583
3584 /**
3585 * Buddy's Contact, only available when presence subscription has
3586 * been established to the buddy.
3587 */
3588 pj_str_t contact;
3589
3590 /**
3591 * Buddy's online status.
3592 */
3593 pjsua_buddy_status status;
3594
3595 /**
3596 * Text to describe buddy's online status.
3597 */
3598 pj_str_t status_text;
3599
3600 /**
3601 * Flag to indicate that we should monitor the presence information for
3602 * this buddy (normally yes, unless explicitly disabled).
3603 */
3604 pj_bool_t monitor_pres;
3605
3606 /**
Benny Prijono63fba012008-07-17 14:19:10 +00003607 * If \a monitor_pres is enabled, this specifies the last state of the
3608 * presence subscription. If presence subscription session is currently
3609 * active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence
3610 * subscription request has been rejected, the value will be
3611 * PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be
3612 * specified in \a sub_term_reason.
3613 */
3614 pjsip_evsub_state sub_state;
3615
3616 /**
3617 * Specifies the last presence subscription terminatino reason. If
3618 * presence subscription is currently active, the value will be empty.
3619 */
3620 pj_str_t sub_term_reason;
3621
3622 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003623 * Extended RPID information about the person.
3624 */
3625 pjrpid_element rpid;
3626
3627 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003628 * Internal buffer.
3629 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003630 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003631
3632} pjsua_buddy_info;
3633
3634
Benny Prijono834aee32006-02-19 01:38:06 +00003635/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003636 * Set default values to the buddy config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003637 *
3638 * \par Python:
3639 * \code
3640 buddy_cfg = py_pjsua.buddy_config_default()
3641 * \endcode
Benny Prijonob5388cf2007-01-04 22:45:08 +00003642 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003643PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003644
3645
3646/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003647 * Get total number of buddies.
3648 *
3649 * @return Number of buddies.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003650 *
3651 * \par Python:
3652 * \code
3653 buddy_count = py_pjsua.get_buddy_count()
3654 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003655 */
3656PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3657
3658
3659/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003660 * Check if buddy ID is valid.
3661 *
3662 * @param buddy_id Buddy ID to check.
3663 *
3664 * @return Non-zero if buddy ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003665 *
3666 * \par Python:
3667 * \code
3668 is_valid = py_pjsua.buddy_is_valid(buddy_id)
3669 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003670 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003671PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3672
3673
3674/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003675 * Enumerate all buddy IDs in the buddy list. Application then can use
3676 * #pjsua_buddy_get_info() to get the detail information for each buddy
3677 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003678 *
3679 * @param ids Array of ids to be initialized.
3680 * @param count On input, specifies max elements in the array.
3681 * On return, it contains actual number of elements
3682 * that have been initialized.
3683 *
3684 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003685 *
3686 * \par Python:
3687 * The Python function takes no argument and returns list of buddy IDs:
3688 * \code
3689 [buddy_ids] = py_pjsua.enum_buddies()
3690 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003691 */
3692PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3693 unsigned *count);
3694
3695/**
Benny Prijono705e7842008-07-21 18:12:51 +00003696 * Find the buddy ID with the specified URI.
3697 *
3698 * @param uri The buddy URI.
3699 *
3700 * @return The buddy ID, or PJSUA_INVALID_ID if not found.
3701 */
3702PJ_DECL(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri);
3703
3704
3705/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003706 * Get detailed buddy info.
3707 *
3708 * @param buddy_id The buddy identification.
3709 * @param info Pointer to receive information about buddy.
3710 *
3711 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003712 *
3713 * \par Python:
3714 * \code
3715 buddy_info = py_pjsua.buddy_get_info(buddy_id)
3716 * \endcode
3717 * The function returns None if buddy_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003718 */
3719PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003720 pjsua_buddy_info *info);
3721
3722/**
Benny Prijono705e7842008-07-21 18:12:51 +00003723 * Set the user data associated with the buddy object.
3724 *
3725 * @param buddy_id The buddy identification.
3726 * @param user_data Arbitrary application data to be associated with
3727 * the buddy object.
3728 *
3729 * @return PJ_SUCCESS on success, or the appropriate error code.
3730 */
3731PJ_DECL(pj_status_t) pjsua_buddy_set_user_data(pjsua_buddy_id buddy_id,
3732 void *user_data);
3733
3734
3735/**
3736 * Get the user data associated with the budy object.
3737 *
3738 * @param buddy_id The buddy identification.
3739 *
3740 * @return The application data.
3741 */
3742PJ_DECL(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id);
3743
3744
3745/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003746 * Add new buddy to the buddy list. If presence subscription is enabled
3747 * for this buddy, this function will also start the presence subscription
3748 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003749 *
Benny Prijonoa7b376b2008-01-25 16:06:33 +00003750 * @param buddy_cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003751 * @param p_buddy_id Pointer to receive buddy ID.
3752 *
3753 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003754 *
3755 * \par Python:
3756 * The function returns (status, buddy_id) tuple:
3757 * \code
3758 status, buddy_id = py_pjsua.buddy_add(buddy_cfg)
3759 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003760 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003761PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003762 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003763
3764
3765/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003766 * Delete the specified buddy from the buddy list. Any presence subscription
3767 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003768 *
3769 * @param buddy_id Buddy identification.
3770 *
3771 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003772 *
3773 * \par Python:
3774 * \code
3775 status = py_pjsua.buddy_del(buddy_id)
3776 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +00003777 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003778PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003779
3780
3781/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003782 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3783 * subscribed, application will be informed about buddy's presence status
3784 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003785 *
3786 * @param buddy_id Buddy identification.
3787 * @param subscribe Specify non-zero to activate presence subscription to
3788 * the specified buddy.
3789 *
3790 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003791 *
3792 * \par Python:
3793 * \code
3794 status = py_pjsua.buddy_subscribe_pres(buddy_id, subscribe)
3795 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003796 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003797PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3798 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003799
3800
3801/**
Benny Prijono10861432007-10-31 10:54:53 +00003802 * Update the presence information for the buddy. Although the library
3803 * periodically refreshes the presence subscription for all buddies, some
3804 * application may want to refresh the buddy's presence subscription
3805 * immediately, and in this case it can use this function to accomplish
3806 * this.
3807 *
3808 * Note that the buddy's presence subscription will only be initiated
3809 * if presence monitoring is enabled for the buddy. See
3810 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
3811 * for the buddy is already active, this function will not do anything.
3812 *
3813 * Once the presence subscription is activated successfully for the buddy,
3814 * application will be notified about the buddy's presence status in the
3815 * on_buddy_state() callback.
3816 *
3817 * @param buddy_id Buddy identification.
3818 *
3819 * @return PJ_SUCCESS on success, or the appropriate error code.
3820 */
3821PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
3822
3823
3824/**
Benny Prijono63fba012008-07-17 14:19:10 +00003825 * Send NOTIFY to inform account presence status or to terminate server
3826 * side presence subscription. If application wants to reject the incoming
3827 * request, it should set the \a state to PJSIP_EVSUB_STATE_TERMINATED.
3828 *
3829 * @param acc_id Account ID.
3830 * @param srv_pres Server presence subscription instance.
3831 * @param state New state to set.
3832 * @param state_str Optionally specify the state string name, if state
3833 * is not "active", "pending", or "terminated".
3834 * @param reason If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3835 * optionally specify the termination reason.
3836 * @param with_body If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3837 * this specifies whether the NOTIFY request should
3838 * contain message body containing account's presence
3839 * information.
3840 * @param msg_data Optional list of headers to be sent with the NOTIFY
3841 * request.
3842 *
3843 * @return PJ_SUCCESS on success.
3844 */
3845PJ_DECL(pj_status_t) pjsua_pres_notify(pjsua_acc_id acc_id,
3846 pjsua_srv_pres *srv_pres,
3847 pjsip_evsub_state state,
3848 const pj_str_t *state_str,
3849 const pj_str_t *reason,
3850 pj_bool_t with_body,
3851 const pjsua_msg_data *msg_data);
3852
3853/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003854 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003855 *
3856 * @param verbose Yes or no.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003857 *
3858 * \par Python:
3859 * \code
3860 py_pjsua.pres_dump()
3861 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003862 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003863PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003864
3865
Benny Prijonob0808372006-03-02 21:18:58 +00003866/**
3867 * The MESSAGE method (defined in pjsua_im.c)
3868 */
3869extern const pjsip_method pjsip_message_method;
3870
3871
Benny Prijonob0808372006-03-02 21:18:58 +00003872
3873/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003874 * Send instant messaging outside dialog, using the specified account for
3875 * route set and authentication.
3876 *
3877 * @param acc_id Account ID to be used to send the request.
3878 * @param to Remote URI.
3879 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3880 * assumed.
3881 * @param content The message content.
3882 * @param msg_data Optional list of headers etc to be included in outgoing
3883 * request. The body descriptor in the msg_data is
3884 * ignored.
3885 * @param user_data Optional user data, which will be given back when
3886 * the IM callback is called.
3887 *
3888 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003889 *
3890 * \par Python:
3891 * \code
3892 status = py_pjsua.im_send(acc_id, to, mime_type, content, msg_data, user_data)
3893 * \endcode
3894 * Arguments \a mime_type and \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003895 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003896PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3897 const pj_str_t *to,
3898 const pj_str_t *mime_type,
3899 const pj_str_t *content,
3900 const pjsua_msg_data *msg_data,
3901 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003902
3903
3904/**
3905 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003906 *
3907 * @param acc_id Account ID to be used to send the request.
3908 * @param to Remote URI.
3909 * @param is_typing If non-zero, it tells remote person that local person
3910 * is currently composing an IM.
3911 * @param msg_data Optional list of headers etc to be added to outgoing
3912 * request.
3913 *
3914 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003915 *
3916 * \par Python:
3917 * \code
3918 status = py_pjsua.im_typing(acc_id, to, is_typing, msg_data)
3919 * \endcode
3920 * Argument \a msg_data may be set to None if not requried.
Benny Prijonob0808372006-03-02 21:18:58 +00003921 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003922PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3923 const pj_str_t *to,
3924 pj_bool_t is_typing,
3925 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003926
3927
Benny Prijonof3195072006-02-14 21:15:30 +00003928
Benny Prijono312aff92006-06-17 04:08:30 +00003929/**
3930 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003931 */
3932
Benny Prijono312aff92006-06-17 04:08:30 +00003933
3934/*****************************************************************************
3935 * MEDIA API
3936 */
3937
3938
3939/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003940 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003941 * @ingroup PJSUA_LIB
3942 * @brief Media manipulation.
3943 * @{
3944 *
3945 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003946 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3947 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003948 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003949 * the interconnection between these terminations freely.
3950 *
3951 * The conference bridge provides powerful switching and mixing functionality
3952 * for application. With the conference bridge, each conference slot (e.g.
3953 * a call) can transmit to multiple destinations, and one destination can
3954 * receive from multiple sources. If more than one media terminations are
3955 * terminated in the same slot, the conference bridge will mix the signal
3956 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00003957 *
3958 * Application connects one media termination/slot to another by calling
3959 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003960 * media flow from the source termination to the sink termination. To
3961 * establish bidirectional media flow, application wound need to make another
3962 * call to #pjsua_conf_connect(), this time inverting the source and
3963 * destination slots in the parameter.
3964 *
3965 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00003966 * the following steps:
3967 *
3968 \code
3969
3970 pj_status_t stream_to_call( pjsua_call_id call_id )
3971 {
3972 pjsua_player_id player_id;
3973
3974 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
3975 if (status != PJ_SUCCESS)
3976 return status;
3977
3978 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
3979 pjsua_call_get_conf_port() );
3980 }
3981 \endcode
3982 *
3983 *
3984 * Other features of PJSUA media:
3985 * - efficient N to M interconnections between media terminations.
3986 * - media termination can be connected to itself to create loopback
3987 * media.
3988 * - the media termination may have different clock rates, and resampling
3989 * will be done automatically by conference bridge.
3990 * - media terminations may also have different frame time; the
3991 * conference bridge will perform the necessary bufferring to adjust
3992 * the difference between terminations.
3993 * - interconnections are removed automatically when media termination
3994 * is removed from the bridge.
3995 * - sound device may be changed even when there are active media
3996 * interconnections.
3997 * - correctly report call's media quality (in #pjsua_call_dump()) from
3998 * RTCP packet exchange.
3999 */
4000
4001/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004002 * Max ports in the conference bridge. This setting is the default value
4003 * for pjsua_media_config.max_media_ports.
Benny Prijono312aff92006-06-17 04:08:30 +00004004 */
4005#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00004006# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00004007#endif
4008
Benny Prijonob5388cf2007-01-04 22:45:08 +00004009/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004010 * The default clock rate to be used by the conference bridge. This setting
4011 * is the default value for pjsua_media_config.clock_rate.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004012 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004013#ifndef PJSUA_DEFAULT_CLOCK_RATE
4014# define PJSUA_DEFAULT_CLOCK_RATE 16000
4015#endif
4016
Benny Prijonob5388cf2007-01-04 22:45:08 +00004017/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004018 * Default frame length in the conference bridge. This setting
4019 * is the default value for pjsua_media_config.audio_frame_ptime.
4020 */
4021#ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Nanang Izzuddinaf974842008-05-08 09:51:16 +00004022# define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
Benny Prijono37c710b2008-01-10 12:09:26 +00004023#endif
4024
4025
4026/**
4027 * Default codec quality settings. This setting is the default value
4028 * for pjsua_media_config.quality.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004029 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004030#ifndef PJSUA_DEFAULT_CODEC_QUALITY
Nanang Izzuddin9dbad152008-06-10 18:56:10 +00004031# define PJSUA_DEFAULT_CODEC_QUALITY 8
Benny Prijono12a669c2006-11-23 07:32:13 +00004032#endif
4033
Benny Prijonob5388cf2007-01-04 22:45:08 +00004034/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004035 * Default iLBC mode. This setting is the default value for
4036 * pjsua_media_config.ilbc_mode.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004037 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004038#ifndef PJSUA_DEFAULT_ILBC_MODE
Benny Prijono37c710b2008-01-10 12:09:26 +00004039# define PJSUA_DEFAULT_ILBC_MODE 30
Benny Prijono12a669c2006-11-23 07:32:13 +00004040#endif
4041
Benny Prijonob5388cf2007-01-04 22:45:08 +00004042/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004043 * The default echo canceller tail length. This setting
4044 * is the default value for pjsua_media_config.ec_tail_len.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004045 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004046#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijono427439c2007-10-21 09:41:24 +00004047# define PJSUA_DEFAULT_EC_TAIL_LEN 200
Benny Prijono12a669c2006-11-23 07:32:13 +00004048#endif
Benny Prijono312aff92006-06-17 04:08:30 +00004049
4050
4051/**
Benny Prijonocba59d92007-02-16 09:22:56 +00004052 * The maximum file player.
4053 */
4054#ifndef PJSUA_MAX_PLAYERS
4055# define PJSUA_MAX_PLAYERS 32
4056#endif
4057
4058
4059/**
4060 * The maximum file player.
4061 */
4062#ifndef PJSUA_MAX_RECORDERS
4063# define PJSUA_MAX_RECORDERS 32
4064#endif
4065
4066
4067/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004068 * This structure describes media configuration, which will be specified
4069 * when calling #pjsua_init(). Application MUST initialize this structure
4070 * by calling #pjsua_media_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00004071 *
4072 * \par Python:
4073 * This data type in Python is <tt>py_pjsua.Media_Config</tt>. To create
4074 * an object of this type, it is recommended to call
4075 * <tt>py_pjsua.media_config_default()</tt> function instead:
4076 * \code
4077 media_cfg = py_pjsua.media_config_default()
4078 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00004079 */
4080struct pjsua_media_config
4081{
4082 /**
4083 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004084 * If value is zero, default clock rate will be used
4085 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00004086 */
4087 unsigned clock_rate;
4088
4089 /**
Benny Prijonof3758ee2008-02-26 15:32:16 +00004090 * Clock rate to be applied when opening the sound device.
4091 * If value is zero, conference bridge clock rate will be used.
4092 */
4093 unsigned snd_clock_rate;
4094
4095 /**
Benny Prijono7d60d052008-03-29 12:24:20 +00004096 * Channel count be applied when opening the sound device and
4097 * conference bridge.
4098 */
4099 unsigned channel_count;
4100
4101 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004102 * Specify audio frame ptime. The value here will affect the
4103 * samples per frame of both the sound device and the conference
4104 * bridge. Specifying lower ptime will normally reduce the
4105 * latency.
4106 *
Benny Prijono37c710b2008-01-10 12:09:26 +00004107 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004108 */
4109 unsigned audio_frame_ptime;
4110
4111 /**
Benny Prijono312aff92006-06-17 04:08:30 +00004112 * Specify maximum number of media ports to be created in the
4113 * conference bridge. Since all media terminate in the bridge
4114 * (calls, file player, file recorder, etc), the value must be
4115 * large enough to support all of them. However, the larger
4116 * the value, the more computations are performed.
Benny Prijono37c710b2008-01-10 12:09:26 +00004117 *
4118 * Default value: PJSUA_MAX_CONF_PORTS
Benny Prijono312aff92006-06-17 04:08:30 +00004119 */
4120 unsigned max_media_ports;
4121
4122 /**
4123 * Specify whether the media manager should manage its own
4124 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
4125 * and at least one worker thread will be created too. If no,
4126 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
4127 * and no worker thread is needed.
4128 *
4129 * Normally application would say yes here, unless it wants to
4130 * run everything from a single thread.
4131 */
4132 pj_bool_t has_ioqueue;
4133
4134 /**
4135 * Specify the number of worker threads to handle incoming RTP
4136 * packets. A value of one is recommended for most applications.
4137 */
4138 unsigned thread_cnt;
4139
Benny Prijono0498d902006-06-19 14:49:14 +00004140 /**
4141 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00004142 * 5-10: resampling use large filter,
4143 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00004144 * 1-2: resampling use linear.
4145 * The media quality also sets speex codec quality/complexity to the
4146 * number.
4147 *
Benny Prijono70972992006-08-05 11:13:58 +00004148 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00004149 */
4150 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00004151
4152 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004153 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00004154 *
4155 * Default: 0 (codec specific)
4156 */
4157 unsigned ptime;
4158
4159 /**
4160 * Disable VAD?
4161 *
4162 * Default: 0 (no (meaning VAD is enabled))
4163 */
4164 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00004165
4166 /**
4167 * iLBC mode (20 or 30).
4168 *
Benny Prijono37c710b2008-01-10 12:09:26 +00004169 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00004170 */
4171 unsigned ilbc_mode;
4172
4173 /**
4174 * Percentage of RTP packet to drop in TX direction
4175 * (to simulate packet lost).
4176 *
4177 * Default: 0
4178 */
4179 unsigned tx_drop_pct;
4180
4181 /**
4182 * Percentage of RTP packet to drop in RX direction
4183 * (to simulate packet lost).
4184 *
4185 * Default: 0
4186 */
4187 unsigned rx_drop_pct;
4188
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004189 /**
Benny Prijono5da50432006-08-07 10:24:52 +00004190 * Echo canceller options (see #pjmedia_echo_create())
4191 *
4192 * Default: 0.
4193 */
4194 unsigned ec_options;
4195
4196 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004197 * Echo canceller tail length, in miliseconds.
4198 *
Benny Prijono669643c2006-09-20 20:02:18 +00004199 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004200 */
4201 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004202
4203 /**
4204 * Jitter buffer initial prefetch delay in msec. The value must be
4205 * between jb_min_pre and jb_max_pre below.
4206 *
4207 * Default: -1 (to use default stream settings, currently 150 msec)
4208 */
4209 int jb_init;
4210
4211 /**
4212 * Jitter buffer minimum prefetch delay in msec.
4213 *
4214 * Default: -1 (to use default stream settings, currently 60 msec)
4215 */
4216 int jb_min_pre;
4217
4218 /**
4219 * Jitter buffer maximum prefetch delay in msec.
4220 *
4221 * Default: -1 (to use default stream settings, currently 240 msec)
4222 */
4223 int jb_max_pre;
4224
4225 /**
4226 * Set maximum delay that can be accomodated by the jitter buffer msec.
4227 *
4228 * Default: -1 (to use default stream settings, currently 360 msec)
4229 */
4230 int jb_max;
4231
Benny Prijonoc97608e2007-03-23 16:34:20 +00004232 /**
4233 * Enable ICE
4234 */
4235 pj_bool_t enable_ice;
4236
4237 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00004238 * Disable ICE host candidates.
Benny Prijonoc97608e2007-03-23 16:34:20 +00004239 */
Benny Prijonof76e1392008-06-06 14:51:48 +00004240 pj_bool_t ice_no_host_cands;
4241
4242 /**
Benny Prijono551af422008-08-07 09:55:52 +00004243 * Disable RTCP component.
4244 *
4245 * Default: no
4246 */
4247 pj_bool_t ice_no_rtcp;
4248
4249 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00004250 * Enable TURN relay candidate in ICE.
4251 */
4252 pj_bool_t enable_turn;
4253
4254 /**
4255 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
4256 * "HOST:PORT" format.
4257 */
4258 pj_str_t turn_server;
4259
4260 /**
4261 * Specify the connection type to be used to the TURN server. Valid
4262 * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP.
4263 *
4264 * Default: PJ_TURN_TP_UDP
4265 */
4266 pj_turn_tp_type turn_conn_type;
4267
4268 /**
4269 * Specify the credential to authenticate with the TURN server.
4270 */
4271 pj_stun_auth_cred turn_auth_cred;
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004272
4273 /**
4274 * Specify idle time of sound device before it is automatically closed,
4275 * in seconds.
4276 *
4277 * Default : -1 (Disable the auto-close feature of sound device)
4278 */
4279 int snd_auto_close_time;
Benny Prijono312aff92006-06-17 04:08:30 +00004280};
4281
4282
4283/**
4284 * Use this function to initialize media config.
4285 *
4286 * @param cfg The media config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004287 *
4288 * \par Python:
4289 * \code
4290 media_cfg = py_pjsua.media_config_default()
4291 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00004292 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00004293PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00004294
4295
4296/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004297 * This structure describes codec information, which can be retrieved by
4298 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00004299 */
4300typedef struct pjsua_codec_info
4301{
4302 /**
4303 * Codec unique identification.
4304 */
4305 pj_str_t codec_id;
4306
4307 /**
4308 * Codec priority (integer 0-255).
4309 */
4310 pj_uint8_t priority;
4311
4312 /**
4313 * Internal buffer.
4314 */
4315 char buf_[32];
4316
4317} pjsua_codec_info;
4318
4319
4320/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004321 * This structure descibes information about a particular media port that
4322 * has been registered into the conference bridge. Application can query
4323 * this info by calling #pjsua_conf_get_port_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00004324 *
4325 * \par Python:
4326 * In Python, this type is <tt>py_pjsua.Conf_Port_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00004327 */
4328typedef struct pjsua_conf_port_info
4329{
4330 /** Conference port number. */
4331 pjsua_conf_port_id slot_id;
4332
4333 /** Port name. */
4334 pj_str_t name;
4335
4336 /** Clock rate. */
4337 unsigned clock_rate;
4338
4339 /** Number of channels. */
4340 unsigned channel_count;
4341
4342 /** Samples per frame */
4343 unsigned samples_per_frame;
4344
4345 /** Bits per sample */
4346 unsigned bits_per_sample;
4347
4348 /** Number of listeners in the array. */
4349 unsigned listener_cnt;
4350
4351 /** Array of listeners (in other words, ports where this port is
4352 * transmitting to.
4353 */
4354 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
4355
4356} pjsua_conf_port_info;
4357
4358
4359/**
4360 * This structure holds information about custom media transport to
4361 * be registered to pjsua.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004362 *
4363 * \par Python:
4364 * Not applicable.
Benny Prijono312aff92006-06-17 04:08:30 +00004365 */
4366typedef struct pjsua_media_transport
4367{
4368 /**
4369 * Media socket information containing the address information
4370 * of the RTP and RTCP socket.
4371 */
4372 pjmedia_sock_info skinfo;
4373
4374 /**
4375 * The media transport instance.
4376 */
4377 pjmedia_transport *transport;
4378
4379} pjsua_media_transport;
4380
4381
4382
4383
Benny Prijono9fc735d2006-05-28 14:58:12 +00004384/**
4385 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004386 *
4387 * @return Maximum number of ports in the conference bridge.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004388 *
4389 * \par Python:
4390 * \code
4391 port_count = py_pjsua.conf_get_max_ports()
4392 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004393 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004394PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004395
4396
4397/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004398 * Get current number of active ports in the bridge.
4399 *
4400 * @return The number.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004401 *
4402 * \par Python:
4403 * \code
4404 count = py_pjsua.conf_get_active_ports()
4405 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004406 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004407PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
4408
4409
4410/**
4411 * Enumerate all conference ports.
4412 *
4413 * @param id Array of conference port ID to be initialized.
4414 * @param count On input, specifies max elements in the array.
4415 * On return, it contains actual number of elements
4416 * that have been initialized.
4417 *
4418 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004419 *
4420 * \par Python:
4421 * The Python functions returns list of conference port Ids:
4422 * \code
4423 [port_ids] = py_pjsua.enum_conf_ports()
4424 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004425 */
4426PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
4427 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004428
4429
4430/**
4431 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004432 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004433 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004434 * @param info Pointer to store the port info.
4435 *
4436 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004437 *
4438 * \par Python:
4439 * \code
4440 port_info = py_pjsua.conf_get_port_info(port_id)
4441 * \endcode
4442 * The function will return None if \a port_id is not valid.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004443 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004444PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00004445 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004446
4447
4448/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00004449 * Add arbitrary media port to PJSUA's conference bridge. Application
4450 * can use this function to add the media port that it creates. For
4451 * media ports that are created by PJSUA-LIB (such as calls, file player,
4452 * or file recorder), PJSUA-LIB will automatically add the port to
4453 * the bridge.
4454 *
4455 * @param pool Pool to use.
4456 * @param port Media port to be added to the bridge.
4457 * @param p_id Optional pointer to receive the conference
4458 * slot id.
4459 *
4460 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004461 *
4462 * \par Python:
4463 * Not applicable (for now)
Benny Prijonoe909eac2006-07-27 22:04:56 +00004464 */
4465PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
4466 pjmedia_port *port,
4467 pjsua_conf_port_id *p_id);
4468
4469
4470/**
4471 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00004472 * call this function if it registered the port manually with previous call
4473 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00004474 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004475 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00004476 *
4477 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004478 *
4479 * \par Python:
4480 * \code
4481 status = py_pjsua.conf_remove_port(port_id)
4482 * \endcode
Benny Prijonoe909eac2006-07-27 22:04:56 +00004483 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004484PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00004485
4486
4487/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004488 * Establish unidirectional media flow from souce to sink. One source
4489 * may transmit to multiple destinations/sink. And if multiple
4490 * sources are transmitting to the same sink, the media will be mixed
4491 * together. Source and sink may refer to the same ID, effectively
4492 * looping the media.
4493 *
4494 * If bidirectional media flow is desired, application needs to call
4495 * this function twice, with the second one having the arguments
4496 * reversed.
4497 *
4498 * @param source Port ID of the source media/transmitter.
4499 * @param sink Port ID of the destination media/received.
4500 *
4501 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004502 *
4503 * \par Python:
4504 * \code
4505 status = py_pjsua.conf_connect(source, sink)
4506 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004507 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004508PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
4509 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004510
4511
4512/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004513 * Disconnect media flow from the source to destination port.
4514 *
4515 * @param source Port ID of the source media/transmitter.
4516 * @param sink Port ID of the destination media/received.
4517 *
4518 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004519 *
4520 * \par Python:
4521 * \code
4522 status = py_pjsua.conf_disconnect(source, sink)
4523 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004524 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004525PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
4526 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004527
4528
Benny Prijono6dd967c2006-12-26 02:27:14 +00004529/**
4530 * Adjust the signal level to be transmitted from the bridge to the
4531 * specified port by making it louder or quieter.
4532 *
4533 * @param slot The conference bridge slot number.
4534 * @param level Signal level adjustment. Value 1.0 means no level
4535 * adjustment, while value 0 means to mute the port.
4536 *
4537 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004538 *
4539 * \par Python:
4540 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004541 */
4542PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
4543 float level);
4544
4545/**
4546 * Adjust the signal level to be received from the specified port (to
4547 * the bridge) by making it louder or quieter.
4548 *
4549 * @param slot The conference bridge slot number.
4550 * @param level Signal level adjustment. Value 1.0 means no level
4551 * adjustment, while value 0 means to mute the port.
4552 *
4553 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004554 *
4555 * \par Python:
4556 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004557 */
4558PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
4559 float level);
4560
4561/**
4562 * Get last signal level transmitted to or received from the specified port.
4563 * The signal level is an integer value in zero to 255, with zero indicates
4564 * no signal, and 255 indicates the loudest signal level.
4565 *
4566 * @param slot The conference bridge slot number.
4567 * @param tx_level Optional argument to receive the level of signal
4568 * transmitted to the specified port (i.e. the direction
4569 * is from the bridge to the port).
4570 * @param rx_level Optional argument to receive the level of signal
4571 * received from the port (i.e. the direction is from the
4572 * port to the bridge).
4573 *
4574 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004575 *
4576 * \par Python:
4577 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004578 */
4579PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
4580 unsigned *tx_level,
4581 unsigned *rx_level);
4582
Benny Prijono6dd967c2006-12-26 02:27:14 +00004583
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004584/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00004585 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004586 */
4587
Benny Prijono9fc735d2006-05-28 14:58:12 +00004588/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004589 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004590 * the conference bridge.
4591 *
4592 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00004593 * WAV files are supported, and the WAV file MUST be
4594 * formatted as 16bit PCM mono/single channel (any
4595 * clock rate is supported).
Benny Prijono58add7c2008-01-18 13:24:07 +00004596 * @param options Optional option flag. Application may specify
4597 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004598 * @param p_id Pointer to receive player ID.
4599 *
4600 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004601 *
4602 * \par Python:
4603 * The function returns (status, id) tuple:
4604 * \code
4605 status, id = py_pjsua.player_create(filename, options)
4606 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004607 */
4608PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004609 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004610 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004611
4612
4613/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004614 * Create a file playlist media port, and automatically add the port
4615 * to the conference bridge.
4616 *
4617 * @param file_names Array of file names to be added to the play list.
4618 * Note that the files must have the same clock rate,
4619 * number of channels, and number of bits per sample.
4620 * @param file_count Number of files in the array.
4621 * @param label Optional label to be set for the media port.
4622 * @param options Optional option flag. Application may specify
4623 * PJMEDIA_FILE_NO_LOOP to prevent looping.
4624 * @param p_id Optional 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 * Not implemented yet.
Benny Prijonoa66c3312007-01-21 23:12:40 +00004630 */
4631PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
4632 unsigned file_count,
4633 const pj_str_t *label,
4634 unsigned options,
4635 pjsua_player_id *p_id);
4636
4637/**
4638 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004639 *
4640 * @param id The file player ID.
4641 *
4642 * @return Conference port ID associated with this player.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004643 *
4644 * \par Python:
4645 * \code
4646 port_id = py_pjsua.player_get_conf_port(id)
4647 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004648 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004649PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004650
4651
4652/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004653 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00004654 *
4655 * @param id The player ID.
4656 * @param p_port The media port associated with the player.
4657 *
4658 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004659 *
4660 * \par Python:
4661 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004662 */
Benny Prijono58add7c2008-01-18 13:24:07 +00004663PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
Benny Prijono469b1522006-12-26 03:05:17 +00004664 pjmedia_port **p_port);
4665
4666/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004667 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004668 *
4669 * @param id The file player ID.
4670 * @param samples The playback position, in samples. Application can
4671 * specify zero to re-start the playback.
4672 *
4673 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004674 *
4675 * \par Python:
4676 * \code
4677 status = py_pjsua.player_set_pos(id, samples)
4678 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004679 */
4680PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
4681 pj_uint32_t samples);
4682
4683
4684/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004685 * Close the file of playlist, remove the player from the bridge, and free
4686 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004687 *
4688 * @param id The file player ID.
4689 *
4690 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004691 *
4692 * \par Python:
4693 * \code
4694 status = py_pjsua.player_destroy(id)
4695 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004696 */
4697PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
4698
4699
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004700/*****************************************************************************
4701 * File recorder.
4702 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00004703
4704/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004705 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004706 * the conference bridge. The recorder currently supports recording WAV file.
4707 * The type of the recorder to use is determined by the extension of the file
4708 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004709 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00004710 * @param filename Output file name. The function will determine the
4711 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004712 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00004713 * @param enc_type Optionally specify the type of encoder to be used to
4714 * compress the media, if the file can support different
4715 * encodings. This value must be zero for now.
4716 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004717 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00004718 * For .WAV recorder, this value must be NULL.
4719 * @param max_size Maximum file size. Specify zero or -1 to remove size
4720 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004721 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004722 * @param p_id Pointer to receive the recorder instance.
4723 *
4724 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004725 *
4726 * \par Python:
4727 * \code
4728 status, id = py_pjsua.recorder_create(filename, enc_type, enc_param, max_size, options)
4729 * \endcode
4730 * The \a enc_param is a string in Python.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004731 */
4732PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004733 unsigned enc_type,
4734 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004735 pj_ssize_t max_size,
4736 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004737 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004738
4739
4740/**
4741 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004742 *
4743 * @param id The recorder ID.
4744 *
4745 * @return Conference port ID associated with this recorder.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004746 *
4747 * \par Python:
4748 * \code
4749 port_id = py_pjsua.recorder_get_conf_port(id)
4750 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004751 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004752PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004753
4754
4755/**
Benny Prijono469b1522006-12-26 03:05:17 +00004756 * Get the media port for the recorder.
4757 *
4758 * @param id The recorder ID.
4759 * @param p_port The media port associated with the recorder.
4760 *
4761 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004762 *
4763 * \par Python:
4764 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004765 */
4766PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4767 pjmedia_port **p_port);
4768
4769
4770/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004771 * Destroy recorder (this will complete recording).
4772 *
4773 * @param id The recorder ID.
4774 *
4775 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004776 *
4777 * \par Python:
4778 * \code
4779 status = py_pjsua.recorder_destroy(id)
4780 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004781 */
4782PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4783
4784
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004785/*****************************************************************************
4786 * Sound devices.
4787 */
4788
Benny Prijono9fc735d2006-05-28 14:58:12 +00004789/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004790 * Enum all sound devices installed in the system.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004791 *
4792 * @param info Array of info to be initialized.
4793 * @param count On input, specifies max elements in the array.
4794 * On return, it contains actual number of elements
4795 * that have been initialized.
4796 *
4797 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004798 *
4799 *
4800 * \par Python:
4801 * The function returns list of sound device info:
4802 * \code
4803 [dev_infos] = py_pjsua.enum_snd_devs()
4804 * \endcode
4805 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00004806 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004807PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4808 unsigned *count);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004809
4810
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004811
4812/**
4813 * Get currently active sound devices. If sound devices has not been created
4814 * (for example when pjsua_start() is not called), it is possible that
4815 * the function returns PJ_SUCCESS with -1 as device IDs.
4816 *
4817 * @param capture_dev On return it will be filled with device ID of the
4818 * capture device.
4819 * @param playback_dev On return it will be filled with device ID of the
4820 * device ID of the playback device.
4821 *
4822 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004823 *
4824 * \par Python:
Benny Prijonoebdf8772007-02-01 19:25:50 +00004825 * The function takes no argument and return an (integer,integer) tuple:
Benny Prijonoe6ead542007-01-31 20:53:31 +00004826 * \code
4827 capture_dev, playback_dev = py_pjsua.get_snd_dev()
4828 * \endcode
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004829 */
4830PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4831 int *playback_dev);
4832
4833
Benny Prijono9fc735d2006-05-28 14:58:12 +00004834/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004835 * Select or change sound device. Application may call this function at
4836 * any time to replace current sound device.
4837 *
4838 * @param capture_dev Device ID of the capture device.
4839 * @param playback_dev Device ID of the playback device.
4840 *
4841 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004842 *
4843 * \par Python:
4844 * \code
4845 status = py_pjsua.set_snd_dev(capture_dev, playback_dev)
4846 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004847 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004848PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4849 int playback_dev);
4850
4851
4852/**
4853 * Set pjsua to use null sound device. The null sound device only provides
4854 * the timing needed by the conference bridge, and will not interract with
4855 * any hardware.
4856 *
4857 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004858 *
4859 * \par Python:
4860 * \code
4861 status = py_pjsua.set_null_snd_dev()
4862 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004863 */
4864PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4865
4866
Benny Prijonoe909eac2006-07-27 22:04:56 +00004867/**
4868 * Disconnect the main conference bridge from any sound devices, and let
4869 * application connect the bridge to it's own sound device/master port.
4870 *
4871 * @return The port interface of the conference bridge,
4872 * so that application can connect this to it's own
4873 * sound device or master port.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004874 *
4875 * \par Python:
4876 * Not applicable (for now).
Benny Prijonoe909eac2006-07-27 22:04:56 +00004877 */
4878PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4879
4880
Benny Prijonof20687a2006-08-04 18:27:19 +00004881/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004882 * Configure the echo canceller tail length of the sound port.
Benny Prijonof20687a2006-08-04 18:27:19 +00004883 *
4884 * @param tail_ms The tail length, in miliseconds. Set to zero to
4885 * disable AEC.
Benny Prijonoa7b376b2008-01-25 16:06:33 +00004886 * @param options Options to be passed to pjmedia_echo_create().
Benny Prijono5da50432006-08-07 10:24:52 +00004887 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004888 *
4889 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004890 *
4891 * \par Python:
4892 * \code
4893 status = py_pjsua.set_ec(tail_ms, options)
4894 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004895 */
Benny Prijono5da50432006-08-07 10:24:52 +00004896PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004897
4898
4899/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004900 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004901 *
4902 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4903 * If AEC is disabled, the value will be zero.
4904 *
4905 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004906 *
4907 * \par Python:
4908 * \code
4909 tail_ms = py_pjsua.get_ec_tail()
4910 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004911 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004912PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004913
4914
4915
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004916/*****************************************************************************
4917 * Codecs.
4918 */
4919
4920/**
4921 * Enum all supported codecs in the system.
4922 *
4923 * @param id Array of ID to be initialized.
4924 * @param count On input, specifies max elements in the array.
4925 * On return, it contains actual number of elements
4926 * that have been initialized.
4927 *
4928 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004929 *
4930 * \par Python:
4931 * This function takes no argument and returns list of codec infos:
4932 * \code
4933 [codec_info] = py_pjsua.enum_codecs()
4934 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004935 */
4936PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4937 unsigned *count );
4938
4939
4940/**
4941 * Change codec priority.
4942 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004943 * @param codec_id Codec ID, which is a string that uniquely identify
4944 * the codec (such as "speex/8000"). Please see pjsua
4945 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004946 * @param priority Codec priority, 0-255, where zero means to disable
4947 * the codec.
4948 *
4949 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004950 *
4951 * \par Python:
4952 * \code
4953 status = py_pjsua.codec_set_priority(codec_id, priority)
4954 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004955 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004956PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004957 pj_uint8_t priority );
4958
4959
4960/**
4961 * Get codec parameters.
4962 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004963 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004964 * @param param Structure to receive codec parameters.
4965 *
4966 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004967 *
4968 * \par Python:
4969 * The Python function is experimental:
4970 * \code
4971 codec_param = py_pjsua.codec_get_param(codec_id)
4972 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004973 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004974PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004975 pjmedia_codec_param *param );
4976
4977
4978/**
4979 * Set codec parameters.
4980 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004981 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004982 * @param param Codec parameter to set.
4983 *
4984 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004985 *
4986 * \par Python:
4987 * The Python function is experimental:
4988 * \code
4989 status = py_pjsua.codec_set_param(codec_id, param)
4990 * \endcode
4991
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004992 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004993PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004994 const pjmedia_codec_param *param);
4995
4996
4997
Benny Prijono9fc735d2006-05-28 14:58:12 +00004998
Benny Prijono312aff92006-06-17 04:08:30 +00004999/**
5000 * Create UDP media transports for all the calls. This function creates
5001 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00005002 *
Benny Prijono312aff92006-06-17 04:08:30 +00005003 * @param cfg Media transport configuration. The "port" field in the
5004 * configuration is used as the start port to bind the
5005 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005006 *
5007 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00005008 *
5009 * \par Python:
5010 * Not implemented yet.
Benny Prijonof3195072006-02-14 21:15:30 +00005011 */
Benny Prijono312aff92006-06-17 04:08:30 +00005012PJ_DECL(pj_status_t)
5013pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00005014
Benny Prijonodc39fe82006-05-26 12:17:46 +00005015
5016/**
Benny Prijono312aff92006-06-17 04:08:30 +00005017 * Register custom media transports to be used by calls. There must
5018 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005019 *
Benny Prijono312aff92006-06-17 04:08:30 +00005020 * @param tp The media transport array.
5021 * @param count Number of elements in the array. This number MUST
5022 * match the number of maximum calls configured when
5023 * pjsua is created.
5024 * @param auto_delete Flag to indicate whether the transports should be
5025 * destroyed when pjsua is shutdown.
5026 *
5027 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00005028 *
5029 * \par Python:
5030 * Note applicable.
Benny Prijonodc39fe82006-05-26 12:17:46 +00005031 */
Benny Prijono312aff92006-06-17 04:08:30 +00005032PJ_DECL(pj_status_t)
5033pjsua_media_transports_attach( pjsua_media_transport tp[],
5034 unsigned count,
5035 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00005036
5037
Benny Prijono312aff92006-06-17 04:08:30 +00005038/**
5039 * @}
5040 */
5041
Benny Prijonof3195072006-02-14 21:15:30 +00005042
Benny Prijono268ca612006-02-07 12:34:11 +00005043
Benny Prijono312aff92006-06-17 04:08:30 +00005044/**
5045 * @}
5046 */
5047
Benny Prijonoe6ead542007-01-31 20:53:31 +00005048PJ_END_DECL
5049
Benny Prijono312aff92006-06-17 04:08:30 +00005050
Benny Prijono268ca612006-02-07 12:34:11 +00005051#endif /* __PJSUA_H__ */