blob: c8073e70e9d67e773960246d1a5789bcf47dbefb [file] [log] [blame]
Benny Prijono268ca612006-02-07 12:34:11 +00001/* $Id$ */
2/*
Benny Prijono32177c02008-06-20 22:44:47 +00003 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
Benny Prijono268ca612006-02-07 12:34:11 +00004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJSUA_H__
20#define __PJSUA_H__
21
Benny Prijono312aff92006-06-17 04:08:30 +000022/**
23 * @file pjsua.h
24 * @brief PJSUA API.
25 */
26
27
Benny Prijono268ca612006-02-07 12:34:11 +000028/* Include all PJSIP core headers. */
29#include <pjsip.h>
30
31/* Include all PJMEDIA headers. */
32#include <pjmedia.h>
33
Benny Prijono1f9afba2006-02-10 15:57:32 +000034/* Include all PJMEDIA-CODEC headers. */
35#include <pjmedia-codec.h>
36
Benny Prijono268ca612006-02-07 12:34:11 +000037/* Include all PJSIP-UA headers */
38#include <pjsip_ua.h>
39
Benny Prijono834aee32006-02-19 01:38:06 +000040/* Include all PJSIP-SIMPLE headers */
41#include <pjsip_simple.h>
42
Benny Prijono4ab9fbb2007-10-12 12:14:27 +000043/* Include all PJNATH headers */
44#include <pjnath.h>
45
Benny Prijono268ca612006-02-07 12:34:11 +000046/* Include all PJLIB-UTIL headers. */
47#include <pjlib-util.h>
48
49/* Include all PJLIB headers. */
50#include <pjlib.h>
51
52
Benny Prijonoe6ead542007-01-31 20:53:31 +000053PJ_BEGIN_DECL
54
55
Benny Prijono312aff92006-06-17 04:08:30 +000056/**
Benny Prijonoe6ead542007-01-31 20:53:31 +000057 * @defgroup PJSUA_LIB PJSUA API - High Level Softphone API for C/C++ and Python
Benny Prijono312aff92006-06-17 04:08:30 +000058 * @brief Very high level API for constructing SIP UA applications.
59 * @{
60 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000061 * @section pjsua_api_intro A SIP User Agent API for C/C++ and Python
62 *
63 * PJSUA API is very high level API, available for C/C++ and Python language,
64 * for constructing SIP multimedia user agent
Benny Prijono312aff92006-06-17 04:08:30 +000065 * applications. It wraps together the signaling and media functionalities
66 * into an easy to use call API, provides account management, buddy
67 * management, presence, instant messaging, along with multimedia
68 * features such as conferencing, file streaming, local playback,
69 * voice recording, and so on.
70 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000071 * @subsection pjsua_for_c_cpp C/C++ Binding
Benny Prijono312aff92006-06-17 04:08:30 +000072 * Application must link with <b>pjsua-lib</b> to use this API. In addition,
73 * this library depends on the following libraries:
74 * - <b>pjsip-ua</b>,
75 * - <b>pjsip-simple</b>,
76 * - <b>pjsip-core</b>,
77 * - <b>pjmedia</b>,
78 * - <b>pjmedia-codec</b>,
79 * - <b>pjlib-util</b>, and
80 * - <b>pjlib</b>,
81 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000082 * so application must also link with these libraries as well. For more
83 * information, please refer to
84 * <A HREF="http://www.pjsip.org/using.htm">Getting Started with PJSIP</A>
85 * page.
Benny Prijono312aff92006-06-17 04:08:30 +000086 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000087 * @subsection pjsua_for_python Python Binding
88 *
89 * The Python binding for PJSUA-API is implemented by <b>py_pjsua</b>
90 * module, in <tt>pjsip-apps/py_pjsua</tt> directory. This module is
91 * built by building <tt>py_pjsua</tt> project in <tt>pjsip_apps</tt>
92 * Visual Studio workspace, or by invoking the usual <tt>setup.py</tt>
93 * Python installer script.
94 *
95 * The Python script then can import the PJSUA-API Python module by
96 * using <b>import py_pjsua</b> construct as usual.
97 *
98 *
99 * @section pjsua_samples
100 *
101 * Few samples are provided both in C and Python.
102 *
103 - @ref page_pjsip_sample_simple_pjsuaua_c\n
104 Very simple SIP User Agent with registration, call, and media, using
105 PJSUA-API, all in under 200 lines of code.
106
107 - @ref page_pjsip_samples_pjsua\n
108 This is the reference implementation for PJSIP and PJMEDIA.
109 PJSUA is a console based application, designed to be simple enough
110 to be readble, but powerful enough to demonstrate all features
111 available in PJSIP and PJMEDIA.\n
112
113 - Python sample\n
114 For a real simple Python sample application, have a look at
115 <A HREF="http://www.pjsip.org/trac/browser/pjproject/trunk/pjsip-apps/src/py_pjsua/pjsua_app.py">
116 <tt>pjsip-apps/src/py_pjsua/pjsua_app.py</tt></A> file.
117
Benny Prijono312aff92006-06-17 04:08:30 +0000118 * @section root_using_pjsua_lib Using PJSUA API
119 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000120 * Please refer to @ref PJSUA_LIB_BASE on how to create and initialize the API.
121 * And then see the Modules on the bottom of this page for more information
122 * about specific subject.
Benny Prijono312aff92006-06-17 04:08:30 +0000123 */
124
Benny Prijonoa91a0032006-02-26 21:23:45 +0000125
Benny Prijonof3195072006-02-14 21:15:30 +0000126
Benny Prijono312aff92006-06-17 04:08:30 +0000127/*****************************************************************************
128 * BASE API
129 */
130
Benny Prijonof04ffdd2006-02-21 00:11:18 +0000131/**
Benny Prijonoe6ead542007-01-31 20:53:31 +0000132 * @defgroup PJSUA_LIB_BASE PJSUA-API Basic API
Benny Prijono312aff92006-06-17 04:08:30 +0000133 * @ingroup PJSUA_LIB
134 * @brief Basic application creation/initialization, logging configuration, etc.
135 * @{
136 *
137 * The base PJSUA API controls PJSUA creation, initialization, and startup, and
138 * also provides various auxiliary functions.
139 *
140 * @section using_pjsua_lib Using PJSUA Library
141 *
142 * @subsection creating_pjsua_lib Creating PJSUA
143 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000144 * Before anything else, application must create PJSUA by calling #pjsua_create()
145 * (or <tt>py_pjsua.create()</tt> from Python).
Benny Prijono312aff92006-06-17 04:08:30 +0000146 * This, among other things, will initialize PJLIB, which is crucial before
Benny Prijonoe6ead542007-01-31 20:53:31 +0000147 * any PJLIB functions can be called, PJLIB-UTIL, and create a SIP endpoint.
148 *
149 * After this function is called, application can create a memory pool (with
150 * #pjsua_pool_create()) and read configurations from command line or file to
151 * build the settings to initialize PJSUA below.
Benny Prijono312aff92006-06-17 04:08:30 +0000152 *
153 * @subsection init_pjsua_lib Initializing PJSUA
154 *
155 * After PJSUA is created, application can initialize PJSUA by calling
Benny Prijonoe6ead542007-01-31 20:53:31 +0000156 * #pjsua_init(). This function takes several optional configuration settings
157 * in the argument, if application wants to set them.
Benny Prijono312aff92006-06-17 04:08:30 +0000158 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000159 * @subsubsection init_pjsua_lib_c_cpp PJSUA-LIB Initialization (in C)
160 * Sample code to initialize PJSUA in C code:
Benny Prijono312aff92006-06-17 04:08:30 +0000161 \code
162
Benny Prijonob5388cf2007-01-04 22:45:08 +0000163 #include <pjsua-lib/pjsua.h>
164
165 #define THIS_FILE __FILE__
166
167 static pj_status_t app_init(void)
168 {
Benny Prijono312aff92006-06-17 04:08:30 +0000169 pjsua_config ua_cfg;
170 pjsua_logging_config log_cfg;
171 pjsua_media_config media_cfg;
Benny Prijonob5388cf2007-01-04 22:45:08 +0000172 pj_status_t status;
173
174 // Must create pjsua before anything else!
175 status = pjsua_create();
176 if (status != PJ_SUCCESS) {
177 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
178 return status;
179 }
Benny Prijono312aff92006-06-17 04:08:30 +0000180
181 // Initialize configs with default settings.
182 pjsua_config_default(&ua_cfg);
183 pjsua_logging_config_default(&log_cfg);
184 pjsua_media_config_default(&media_cfg);
185
186 // At the very least, application would want to override
187 // the call callbacks in pjsua_config:
188 ua_cfg.cb.on_incoming_call = ...
189 ua_cfg.cb.on_call_state = ..
190 ...
191
192 // Customize other settings (or initialize them from application specific
193 // configuration file):
194 ...
195
196 // Initialize pjsua
197 status = pjsua_init(&ua_cfg, &log_cfg, &media_cfg);
198 if (status != PJ_SUCCESS) {
199 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
200 return status;
201 }
Benny Prijonob5388cf2007-01-04 22:45:08 +0000202 .
203 ...
204 }
Benny Prijono312aff92006-06-17 04:08:30 +0000205 \endcode
206 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000207 *
208 * @subsubsection init_pjsua_lib_python PJSUA-LIB Initialization (in Python)
209 * Sample code to initialize PJSUA in Python code:
210
211 \code
212
213import py_pjsua
214
215#
216# Initialize pjsua.
217#
218def app_init():
219 # Create pjsua before anything else
220 status = py_pjsua.create()
221 if status != 0:
222 err_exit("pjsua create() error", status)
223
224 # We use default logging config for this sample
225 log_cfg = py_pjsua.logging_config_default()
226
227 # Create and initialize pjsua config
228 # Note: for this Python module, thread_cnt must be 0 since Python
229 # doesn't like to be called from alien thread (pjsua's thread
230 # in this case)
231 ua_cfg = py_pjsua.config_default()
232 ua_cfg.thread_cnt = 0
233 ua_cfg.user_agent = "PJSUA/Python 0.1"
234
235 # Override callbacks. At the very least application would want to
236 # override the call callbacks in pjsua_config
237 ua_cfg.cb.on_incoming_call = ...
238 ua_cfg.cb.on_call_state = ...
239
240 # Use default media config for this cample
241 med_cfg = py_pjsua.media_config_default()
242
243 #
244 # Initialize pjsua!!
245 #
246 status = py_pjsua.init(ua_cfg, log_cfg, med_cfg)
247 if status != 0:
248 err_exit("pjsua init() error", status)
249
250
251
252# Utility: display PJ error and exit
253#
254def err_exit(title, rc):
255 py_pjsua.perror(THIS_FILE, title, rc)
256 exit(1)
257
258 \endcode
259
260
Benny Prijono312aff92006-06-17 04:08:30 +0000261 * @subsection other_init_pjsua_lib Other Initialization
262 *
263 * After PJSUA is initialized with #pjsua_init(), application will normally
264 * need/want to perform the following tasks:
265 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000266 * - create SIP transport with #pjsua_transport_create(). Application would
267 * to call #pjsua_transport_create() for each transport types that it
268 * wants to support (for example, UDP, TCP, and TLS). Please see
Benny Prijono312aff92006-06-17 04:08:30 +0000269 * @ref PJSUA_LIB_TRANSPORT section for more info.
270 * - create one or more SIP accounts with #pjsua_acc_add() or
Benny Prijonoe6ead542007-01-31 20:53:31 +0000271 * #pjsua_acc_add_local(). The SIP account is used for registering with
272 * the SIP server, if any. Please see @ref PJSUA_LIB_ACC for more info.
Benny Prijono312aff92006-06-17 04:08:30 +0000273 * - add one or more buddies with #pjsua_buddy_add(). Please see
274 * @ref PJSUA_LIB_BUDDY section for more info.
275 * - optionally configure the sound device, codec settings, and other
276 * media settings. Please see @ref PJSUA_LIB_MEDIA for more info.
277 *
278 *
279 * @subsection starting_pjsua_lib Starting PJSUA
280 *
281 * After all initializations have been done, application must call
282 * #pjsua_start() to start PJSUA. This function will check that all settings
Benny Prijonoe6ead542007-01-31 20:53:31 +0000283 * have been properly configured, and apply default settings when they haven't,
284 * or report error status when it is unable to recover from missing settings.
Benny Prijono312aff92006-06-17 04:08:30 +0000285 *
286 * Most settings can be changed during run-time. For example, application
287 * may add, modify, or delete accounts, buddies, or change media settings
288 * during run-time.
Benny Prijonob5388cf2007-01-04 22:45:08 +0000289 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000290 * @subsubsection starting_pjsua_lib_c C Example for Starting PJSUA
Benny Prijonob5388cf2007-01-04 22:45:08 +0000291 * Sample code:
292 \code
293 static pj_status_t app_run(void)
294 {
295 pj_status_t status;
296
297 // Start pjsua
298 status = pjsua_start();
299 if (status != PJ_SUCCESS) {
300 pjsua_destroy();
301 pjsua_perror(THIS_FILE, "Error starting pjsua", status);
302 return status;
303 }
304
305 // Run application loop
306 while (1) {
307 char choice[10];
308
309 printf("Select menu: ");
310 fgets(choice, sizeof(choice), stdin);
311 ...
312 }
313 }
314 \endcode
Benny Prijonoe6ead542007-01-31 20:53:31 +0000315
316 * @subsubsection starting_pjsua_lib_python Python Example for starting PJSUA
317 * For Python, starting PJSUA-LIB takes one more step, that is to initialize
318 * Python worker thread to poll PJSUA-LIB. This step is necessary because
319 * Python doesn't like it when it is called by an "alien" thread (that is,
320 * thread that is not created using Python API).
321 *
322 * Because of this, we cannot use a worker thread in PJSUA-LIB, because then
323 * the Python callback will be called by an "alien" thread and this would
324 * crash Python (or raise assert() probably).
325 *
326 * So because worker thread is disabled, we need to create a worker thread
327 * in Python. Note that this may not be necessary if we're creating a
328 * GUI application, because then we can attach, for example, a GUI timer
329 * object to poll the PJSUA-LIB. But because we're creating a console
330 * application which will block at <tt>sys.stdin.readline()</tt>, we need
331 * to have a worker thread to poll PJSUA-LIB.
332
333 \code
334
335import thread
336
337C_QUIT = 0
338
339
340def app_start():
341 # Done with initialization, start pjsua!!
342 #
343 status = py_pjsua.start()
344 if status != 0:
345 py_pjsua.destroy()
346 err_exit("Error starting pjsua!", status)
347
348 # Start worker thread
349 thr = thread.start_new(worker_thread_main, (0,))
350
351 print "PJSUA Started!!"
352
353#
354# Worker thread function.
355# Python doesn't like it when it's called from an alien thread
356# (pjsua's worker thread, in this case), so for Python we must
357# disable worker thread in pjsua and poll pjsua from Python instead.
358#
359def worker_thread_main(arg):
360 global C_QUIT
361 thread_desc = 0
362 status = py_pjsua.thread_register("python worker", thread_desc)
363 if status != 0:
364 py_pjsua.perror(THIS_FILE, "Error registering thread", status)
365 else:
366 while C_QUIT == 0:
367 py_pjsua.handle_events(50)
368 print "Worker thread quitting.."
369 C_QUIT = 2
370
371
372 \endcode
Benny Prijonof04ffdd2006-02-21 00:11:18 +0000373 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000374
Benny Prijono312aff92006-06-17 04:08:30 +0000375/** Constant to identify invalid ID for all sorts of IDs. */
376#define PJSUA_INVALID_ID (-1)
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000377
378/** Call identification */
379typedef int pjsua_call_id;
380
Benny Prijono312aff92006-06-17 04:08:30 +0000381/** Account identification */
382typedef int pjsua_acc_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000383
384/** Buddy identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000385typedef int pjsua_buddy_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000386
387/** File player identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000388typedef int pjsua_player_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000389
390/** File recorder identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000391typedef int pjsua_recorder_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000392
393/** Conference port identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000394typedef int pjsua_conf_port_id;
395
Benny Prijono63fba012008-07-17 14:19:10 +0000396/** Opaque declaration for server side presence subscription */
397typedef struct pjsua_srv_pres pjsua_srv_pres;
398
399/** Forward declaration for pjsua_msg_data */
400typedef struct pjsua_msg_data pjsua_msg_data;
Benny Prijono8b1889b2006-06-06 18:40:40 +0000401
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000402
Benny Prijonoa91a0032006-02-26 21:23:45 +0000403/**
Benny Prijono312aff92006-06-17 04:08:30 +0000404 * Maximum proxies in account.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000405 */
Benny Prijono312aff92006-06-17 04:08:30 +0000406#ifndef PJSUA_ACC_MAX_PROXIES
407# define PJSUA_ACC_MAX_PROXIES 8
408#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000409
Benny Prijonod8179652008-01-23 20:39:07 +0000410#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000411
Benny Prijonod8179652008-01-23 20:39:07 +0000412/**
413 * Default value of SRTP mode usage. Valid values are PJMEDIA_SRTP_DISABLED,
414 * PJMEDIA_SRTP_OPTIONAL, and PJMEDIA_SRTP_MANDATORY.
415 */
416#ifndef PJSUA_DEFAULT_USE_SRTP
417 #define PJSUA_DEFAULT_USE_SRTP PJMEDIA_SRTP_DISABLED
418#endif
419
420/**
421 * Default value of secure signaling requirement for SRTP.
422 * Valid values are:
423 * 0: SRTP does not require secure signaling
424 * 1: SRTP requires secure transport such as TLS
425 * 2: SRTP requires secure end-to-end transport (SIPS)
426 */
427#ifndef PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
428 #define PJSUA_DEFAULT_SRTP_SECURE_SIGNALING 1
429#endif
430
431#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000432
433/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000434 * Logging configuration, which can be (optionally) specified when calling
435 * #pjsua_init(). Application must call #pjsua_logging_config_default() to
436 * initialize this structure with the default values.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000437 *
438 * \par Sample Python Syntax:
439 * \code
440 # Python type: py_pjsua.Logging_Config
441
442 log_cfg = py_pjsua.logging_config_default()
443 log_cfg.level = 4
444 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000445 */
446typedef struct pjsua_logging_config
447{
448 /**
449 * Log incoming and outgoing SIP message? Yes!
450 */
451 pj_bool_t msg_logging;
452
453 /**
454 * Input verbosity level. Value 5 is reasonable.
455 */
456 unsigned level;
457
458 /**
459 * Verbosity level for console. Value 4 is reasonable.
460 */
461 unsigned console_level;
462
463 /**
464 * Log decoration.
465 */
466 unsigned decor;
467
468 /**
469 * Optional log filename.
470 */
471 pj_str_t log_filename;
472
473 /**
474 * Optional callback function to be called to write log to
475 * application specific device. This function will be called for
476 * log messages on input verbosity level.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000477 *
478 * \par Sample Python Syntax:
479 * \code
480 # level: integer
481 # data: string
482 # len: integer
483
484 def cb(level, data, len):
485 print data,
486 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000487 */
Benny Prijonofe7d87b2007-11-29 11:35:44 +0000488 void (*cb)(int level, const char *data, int len);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000489
490
491} pjsua_logging_config;
492
493
494/**
495 * Use this function to initialize logging config.
496 *
497 * @param cfg The logging config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000498 *
499 * \par Python Syntax:
500 * The Python function instantiates and initialize the logging config:
501 * \code
502 logging_cfg = py_pjsua.logging_config_default()
503 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000504 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000505PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000506
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000507
508/**
509 * Use this function to duplicate logging config.
510 *
511 * @param pool Pool to use.
512 * @param dst Destination config.
513 * @param src Source config.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000514 *
515 * \par Python Syntax:
516 * Not available (for now). Ideally we should be able to just assign
517 * one config to another, but this has not been tested.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000518 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000519PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool,
520 pjsua_logging_config *dst,
521 const pjsua_logging_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000522
Benny Prijonodc39fe82006-05-26 12:17:46 +0000523
524/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000525 * This structure describes application callback to receive various event
526 * notification from PJSUA-API. All of these callbacks are OPTIONAL,
527 * although definitely application would want to implement some of
528 * the important callbacks (such as \a on_incoming_call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000529 *
530 * \par Python Syntax:
531 * This callback structure is embedded on pjsua_config structure.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000532 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000533typedef struct pjsua_callback
Benny Prijonodc39fe82006-05-26 12:17:46 +0000534{
535 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000536 * Notify application when invite state has changed.
537 * Application may then query the call info to get the
Benny Prijonoe6ead542007-01-31 20:53:31 +0000538 * detail call states by calling pjsua_call_get_info() function.
Benny Prijono0875ae82006-12-26 00:11:48 +0000539 *
540 * @param call_id The call index.
541 * @param e Event which causes the call state to change.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000542 *
543 * \par Python Syntax:
544 * \code
545 # call_id: integer
546 # e: an opaque object
547
548 def on_call_state(call_id, e):
549 return
550 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000551 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000552 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000553
554 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000555 * Notify application on incoming call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000556 *
557 * @param acc_id The account which match the incoming call.
558 * @param call_id The call id that has just been created for
559 * the call.
560 * @param rdata The incoming INVITE request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000561 *
562 * \par Python Syntax:
563 * \code
564 # acc_id: integer
565 # call_id: integer
566 # rdata: an opaque object
567
568 def on_incoming_call(acc_id, call_id, rdata):
569 return
570 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +0000571 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000572 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000573 pjsip_rx_data *rdata);
574
575 /**
Benny Prijonofeb69f42007-10-05 09:12:26 +0000576 * This is a general notification callback which is called whenever
577 * a transaction within the call has changed state. Application can
578 * implement this callback for example to monitor the state of
579 * outgoing requests, or to answer unhandled incoming requests
580 * (such as INFO) with a final response.
581 *
582 * @param call_id Call identification.
583 * @param tsx The transaction which has changed state.
584 * @param e Transaction event that caused the state change.
585 */
586 void (*on_call_tsx_state)(pjsua_call_id call_id,
587 pjsip_transaction *tsx,
588 pjsip_event *e);
589
590 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000591 * Notify application when media state in the call has changed.
592 * Normal application would need to implement this callback, e.g.
Benny Prijono6ba8c542007-10-16 01:34:14 +0000593 * to connect the call's media to sound device. When ICE is used,
594 * this callback will also be called to report ICE negotiation
595 * failure.
Benny Prijono0875ae82006-12-26 00:11:48 +0000596 *
597 * @param call_id The call index.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000598 *
599 * \par Python Syntax:
600 * \code
601 # call_id: integer
602
603 def on_call_media_state(call_id):
604 return
605 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000606 */
607 void (*on_call_media_state)(pjsua_call_id call_id);
608
Benny Prijonofc13bf62008-02-20 08:56:15 +0000609
610 /**
611 * Notify application when media session is created and before it is
612 * registered to the conference bridge. Application may return different
613 * media port if it has added media processing port to the stream. This
614 * media port then will be added to the conference bridge instead.
615 *
616 * @param call_id Call identification.
617 * @param sess Media session for the call.
618 * @param stream_idx Stream index in the media session.
619 * @param p_port On input, it specifies the media port of the
620 * stream. Application may modify this pointer to
621 * point to different media port to be registered
622 * to the conference bridge.
623 *
624 * \par Python:
625 * Not applicable.
626 */
627 void (*on_stream_created)(pjsua_call_id call_id,
628 pjmedia_session *sess,
629 unsigned stream_idx,
630 pjmedia_port **p_port);
631
632 /**
633 * Notify application when media session has been unregistered from the
634 * conference bridge and about to be destroyed.
635 *
636 * @param call_id Call identification.
637 * @param sess Media session for the call.
638 * @param stream_idx Stream index in the media session.
639 *
640 * \par Python:
641 * Not applicable.
642 */
643 void (*on_stream_destroyed)(pjsua_call_id call_id,
644 pjmedia_session *sess,
645 unsigned stream_idx);
646
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000647 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000648 * Notify application upon incoming DTMF digits.
649 *
650 * @param call_id The call index.
651 * @param digit DTMF ASCII digit.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000652 *
653 * \par Python Syntax:
654 * \code
655 # call_id: integer
Benny Prijono1f63cc42007-09-10 16:54:22 +0000656 # digit: digit string
Benny Prijonoe6ead542007-01-31 20:53:31 +0000657
658 def on_dtmf_digit(call_id, digit):
659 return
660 * \endcode
Benny Prijono0875ae82006-12-26 00:11:48 +0000661 */
662 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
663
664 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000665 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000666 * Application can decide to accept/reject transfer request
Benny Prijonoc54dcb32008-04-08 23:33:15 +0000667 * by setting the code (default is 202). When this callback
Benny Prijono9fc735d2006-05-28 14:58:12 +0000668 * is not defined, the default behavior is to accept the
669 * transfer.
Benny Prijono0875ae82006-12-26 00:11:48 +0000670 *
671 * @param call_id The call index.
672 * @param dst The destination where the call will be
673 * transfered to.
674 * @param code Status code to be returned for the call transfer
675 * request. On input, it contains status code 200.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000676 *
677 * \par Python Syntax:
678 * \code
679 # call_id: integer
680 # dst: string
681 # code: integer
682
683 def on_call_transfer_request(call_id, dst, code):
684 return code
685
686 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000687 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000688 void (*on_call_transfer_request)(pjsua_call_id call_id,
689 const pj_str_t *dst,
690 pjsip_status_code *code);
691
692 /**
693 * Notify application of the status of previously sent call
694 * transfer request. Application can monitor the status of the
695 * call transfer request, for example to decide whether to
696 * terminate existing call.
697 *
698 * @param call_id Call ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000699 * @param st_code Status progress of the transfer request.
700 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000701 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000702 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000703 * this callback is the final status.
704 * @param p_cont Initially will be set to non-zero, application
705 * can set this to FALSE if it no longer wants
706 * to receie further notification (for example,
707 * after it hangs up the call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000708 *
709 * \par Python Syntax:
710 * \code
711 # call_id: integer
712 # st_code: integer
713 # st_text: string
714 # final: integer
715 # cont: integer
716
717 # return: cont
718
719 def on_call_transfer_status(call_id, st_code, st_text, final, cont):
720 return cont
721 * \endcode
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000722 */
723 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000724 int st_code,
725 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000726 pj_bool_t final,
727 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000728
729 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000730 * Notify application about incoming INVITE with Replaces header.
731 * Application may reject the request by setting non-2xx code.
732 *
733 * @param call_id The call ID to be replaced.
734 * @param rdata The incoming INVITE request to replace the call.
735 * @param st_code Status code to be set by application. Application
736 * should only return a final status (200-699).
737 * @param st_text Optional status text to be set by application.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000738 *
739 * \par Python Syntax:
740 * \code
741 # call_id: integer
742 # rdata: an opaque object
743 # st_code: integer
744 # st_text: string
745
746 # return: (st_code, st_text) tuple
747
748 def on_call_replace_request(call_id, rdata, st_code, st_text):
749 return st_code, st_text
750 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000751 */
752 void (*on_call_replace_request)(pjsua_call_id call_id,
753 pjsip_rx_data *rdata,
754 int *st_code,
755 pj_str_t *st_text);
756
757 /**
758 * Notify application that an existing call has been replaced with
759 * a new call. This happens when PJSUA-API receives incoming INVITE
760 * request with Replaces header.
761 *
762 * After this callback is called, normally PJSUA-API will disconnect
763 * \a old_call_id and establish \a new_call_id.
764 *
765 * @param old_call_id Existing call which to be replaced with the
766 * new call.
767 * @param new_call_id The new call.
768 * @param rdata The incoming INVITE with Replaces request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000769 *
770 * \par Python Syntax:
771 * \code
772 # old_call_id: integer
773 # new_call_id: integer
774
775 def on_call_replaced(old_call_id, new_call_id):
776 return
777 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000778 */
779 void (*on_call_replaced)(pjsua_call_id old_call_id,
780 pjsua_call_id new_call_id);
781
782
783 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000784 * Notify application when registration status has changed.
785 * Application may then query the account info to get the
786 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000787 *
788 * @param acc_id Account ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000789 *
790 * \par Python Syntax:
791 * \code
792 # acc_id: account ID (integer)
793
794 def on_reg_state(acc_id):
795 return
796 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000797 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000798 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000799
800 /**
Benny Prijono63fba012008-07-17 14:19:10 +0000801 * Notification when incoming SUBSCRIBE request is received. Application
802 * may use this callback to authorize the incoming subscribe request
803 * (e.g. ask user permission if the request should be granted).
804 *
805 * If this callback is not implemented, all incoming presence subscription
806 * requests will be accepted.
807 *
808 * If this callback is implemented, application has several choices on
809 * what to do with the incoming request:
810 * - it may reject the request immediately by specifying non-200 class
811 * final response in the \a code argument.
812 * - it may immediately accept the request by specifying 200 as the
813 * \a code argument. This is the default value if application doesn't
814 * set any value to the \a code argument. In this case, the library
815 * will automatically send NOTIFY request upon returning from this
816 * callback.
817 * - it may delay the processing of the request, for example to request
818 * user permission whether to accept or reject the request. In this
819 * case, the application MUST set the \a code argument to 202, and
820 * later calls #pjsua_pres_notify() to accept or reject the
821 * subscription request.
822 *
823 * Any \a code other than 200 and 202 will be treated as 200.
824 *
825 * Application MUST return from this callback immediately (e.g. it must
826 * not block in this callback while waiting for user confirmation).
827 *
828 * @param srv_pres Server presence subscription instance. If
829 * application delays the acceptance of the request,
830 * it will need to specify this object when calling
831 * #pjsua_pres_notify().
832 * @param acc_id Account ID most appropriate for this request.
833 * @param buddy_id ID of the buddy matching the sender of the
834 * request, if any, or PJSUA_INVALID_ID if no
835 * matching buddy is found.
836 * @param from The From URI of the request.
837 * @param rdata The incoming request.
838 * @param code The status code to respond to the request. The
839 * default value is 200. Application may set this
840 * to other final status code to accept or reject
841 * the request.
842 * @param reason The reason phrase to respond to the request.
843 * @param msg_data If the application wants to send additional
844 * headers in the response, it can put it in this
845 * parameter.
846 */
847 void (*on_incoming_subscribe)(pjsua_acc_id acc_id,
848 pjsua_srv_pres *srv_pres,
849 pjsua_buddy_id buddy_id,
850 const pj_str_t *from,
851 pjsip_rx_data *rdata,
852 pjsip_status_code *code,
853 pj_str_t *reason,
854 pjsua_msg_data *msg_data);
855
856 /**
857 * Notification when server side subscription state has changed.
858 * This callback is optional as application normally does not need
859 * to do anything to maintain server side presence subscription.
860 *
861 * @param acc_id The account ID.
862 * @param srv_pres Server presence subscription object.
863 * @param remote_uri Remote URI string.
864 * @param state New subscription state.
865 * @param event PJSIP event that triggers the state change.
866 */
867 void (*on_srv_subscribe_state)(pjsua_acc_id acc_id,
868 pjsua_srv_pres *srv_pres,
869 const pj_str_t *remote_uri,
870 pjsip_evsub_state state,
871 pjsip_event *event);
872
873 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000874 * Notify application when the buddy state has changed.
875 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000876 *
877 * @param buddy_id The buddy id.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000878 *
879 * \par Python Syntax:
880 * \code
881 # buddy_id: integer
882
883 def on_buddy_state(buddy_id):
884 return
885 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000886 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000887 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000888
889 /**
890 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000891 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000892 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000893 *
Benny Prijonobbeb3992007-05-21 13:48:35 +0000894 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
895 * passed as one of the argument.
896 *
Benny Prijono0875ae82006-12-26 00:11:48 +0000897 * @param call_id Containts the ID of the call where the IM was
898 * sent, or PJSUA_INVALID_ID if the IM was sent
899 * outside call context.
900 * @param from URI of the sender.
901 * @param to URI of the destination message.
902 * @param contact The Contact URI of the sender, if present.
903 * @param mime_type MIME type of the message.
904 * @param body The message content.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000905 *
906 * \par Python Syntax:
907 * \code
908 # call_id: integer
909 # from: string
910 # to: string
911 # contact: string
912 # mime_type: string
913 # body: string
Benny Prijonoba736c42008-07-10 20:45:03 +0000914 # acc_id: integer
Benny Prijonoe6ead542007-01-31 20:53:31 +0000915
916 def on_pager(call_id, from, to, contact, mime_type, body):
917 return
918 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000919 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000920 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
921 const pj_str_t *to, const pj_str_t *contact,
922 const pj_str_t *mime_type, const pj_str_t *body);
923
924 /**
Benny Prijonobbeb3992007-05-21 13:48:35 +0000925 * This is the alternative version of the \a on_pager() callback with
926 * \a pjsip_rx_data argument.
927 *
928 * @param call_id Containts the ID of the call where the IM was
929 * sent, or PJSUA_INVALID_ID if the IM was sent
930 * outside call context.
931 * @param from URI of the sender.
932 * @param to URI of the destination message.
933 * @param contact The Contact URI of the sender, if present.
934 * @param mime_type MIME type of the message.
935 * @param body The message content.
936 * @param rdata The incoming MESSAGE request.
Benny Prijonoba736c42008-07-10 20:45:03 +0000937 * @param acc_id Account ID most suitable for this message.
Benny Prijonobbeb3992007-05-21 13:48:35 +0000938 */
939 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
940 const pj_str_t *to, const pj_str_t *contact,
941 const pj_str_t *mime_type, const pj_str_t *body,
Benny Prijonoba736c42008-07-10 20:45:03 +0000942 pjsip_rx_data *rdata, pjsua_acc_id acc_id);
Benny Prijonobbeb3992007-05-21 13:48:35 +0000943
944 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000945 * Notify application about the delivery status of outgoing pager
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000946 * request. See also on_pager_status2() callback for the version with
947 * \a pjsip_rx_data in the argument list.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000948 *
949 * @param call_id Containts the ID of the call where the IM was
950 * sent, or PJSUA_INVALID_ID if the IM was sent
951 * outside call context.
952 * @param to Destination URI.
953 * @param body Message body.
954 * @param user_data Arbitrary data that was specified when sending
955 * IM message.
956 * @param status Delivery status.
957 * @param reason Delivery status reason.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000958 *
959 * \par Python Syntax
960 * \code
961 # call_id: integer
962 # to: string
963 # body: string
964 # user_data: string
965 # status: integer
966 # reason: string
Benny Prijonoba736c42008-07-10 20:45:03 +0000967 # acc_id: integer
Benny Prijonoe6ead542007-01-31 20:53:31 +0000968
969 def on_pager_status(call_id, to, body, user_data, status, reason):
970 return
971 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000972 */
973 void (*on_pager_status)(pjsua_call_id call_id,
974 const pj_str_t *to,
975 const pj_str_t *body,
976 void *user_data,
977 pjsip_status_code status,
978 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000979
980 /**
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000981 * Notify application about the delivery status of outgoing pager
982 * request.
983 *
984 * @param call_id Containts the ID of the call where the IM was
985 * sent, or PJSUA_INVALID_ID if the IM was sent
986 * outside call context.
987 * @param to Destination URI.
988 * @param body Message body.
989 * @param user_data Arbitrary data that was specified when sending
990 * IM message.
991 * @param status Delivery status.
992 * @param reason Delivery status reason.
Benny Prijono0a982002007-06-12 16:22:09 +0000993 * @param tdata The original MESSAGE request.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000994 * @param rdata The incoming MESSAGE response, or NULL if the
995 * message transaction fails because of time out
996 * or transport error.
Benny Prijonoba736c42008-07-10 20:45:03 +0000997 * @param acc_id Account ID from this the instant message was
998 * send.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000999 */
1000 void (*on_pager_status2)(pjsua_call_id call_id,
1001 const pj_str_t *to,
1002 const pj_str_t *body,
1003 void *user_data,
1004 pjsip_status_code status,
1005 const pj_str_t *reason,
Benny Prijono0a982002007-06-12 16:22:09 +00001006 pjsip_tx_data *tdata,
Benny Prijonoba736c42008-07-10 20:45:03 +00001007 pjsip_rx_data *rdata,
1008 pjsua_acc_id acc_id);
Benny Prijono4da0b1d2007-06-11 18:22:54 +00001009
1010 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +00001011 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +00001012 *
1013 * @param call_id Containts the ID of the call where the IM was
1014 * sent, or PJSUA_INVALID_ID if the IM was sent
1015 * outside call context.
1016 * @param from URI of the sender.
1017 * @param to URI of the destination message.
1018 * @param contact The Contact URI of the sender, if present.
1019 * @param is_typing Non-zero if peer is typing, or zero if peer
1020 * has stopped typing a message.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001021 *
1022 * \par Python Syntax
1023 * \code
1024 # call_id: string
1025 # from: string
1026 # to: string
1027 # contact: string
1028 # is_typing: integer
1029
1030 def on_typing(call_id, from, to, contact, is_typing):
1031 return
1032 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001033 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001034 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
1035 const pj_str_t *to, const pj_str_t *contact,
1036 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +00001037
Benny Prijono6ba8c542007-10-16 01:34:14 +00001038 /**
Benny Prijonoba736c42008-07-10 20:45:03 +00001039 * Notify application about typing indication.
1040 *
1041 * @param call_id Containts the ID of the call where the IM was
1042 * sent, or PJSUA_INVALID_ID if the IM was sent
1043 * outside call context.
1044 * @param from URI of the sender.
1045 * @param to URI of the destination message.
1046 * @param contact The Contact URI of the sender, if present.
1047 * @param is_typing Non-zero if peer is typing, or zero if peer
1048 * has stopped typing a message.
1049 * @param rdata The received request.
1050 * @param acc_id Account ID most suitable for this message.
1051 */
1052 void (*on_typing2)(pjsua_call_id call_id, const pj_str_t *from,
1053 const pj_str_t *to, const pj_str_t *contact,
1054 pj_bool_t is_typing, pjsip_rx_data *rdata,
1055 pjsua_acc_id acc_id);
1056
1057 /**
Benny Prijono6ba8c542007-10-16 01:34:14 +00001058 * Callback when the library has finished performing NAT type
1059 * detection.
1060 *
1061 * @param res NAT detection result.
1062 */
1063 void (*on_nat_detect)(const pj_stun_nat_detect_result *res);
1064
Benny Prijono5e51a4e2008-11-27 00:06:46 +00001065 /**
1066 * This callback is called when the call is about to resend the
1067 * INVITE request to the specified target, following the previously
1068 * received redirection response.
1069 *
1070 * Application may accept the redirection to the specified target
1071 * (the default behavior if this callback is implemented), reject
1072 * this target only and make the session continue to try the next
1073 * target in the list if such target exists, stop the whole
1074 * redirection process altogether and cause the session to be
1075 * disconnected, or defer the decision to ask for user confirmation.
1076 *
1077 * This callback is optional. If this callback is not implemented,
1078 * the default behavior is to NOT follow the redirection response.
1079 *
1080 * @param call_id The call ID.
1081 * @param target The current target to be tried.
Benny Prijono08a48b82008-11-27 12:42:07 +00001082 * @param e The event that caused this callback to be called.
1083 * This could be the receipt of 3xx response, or
1084 * 4xx/5xx response received for the INVITE sent to
1085 * subsequent targets, or NULL if this callback is
1086 * called from within #pjsua_call_process_redirect()
1087 * context.
1088 *
1089 * @return Action to be performed for the target. Set this
Benny Prijono5e51a4e2008-11-27 00:06:46 +00001090 * parameter to one of the value below:
1091 * - PJSIP_REDIRECT_ACCEPT: immediately accept the
1092 * redirection (default value). When set, the
1093 * call will immediately resend INVITE request
1094 * to the target.
1095 * - PJSIP_REDIRECT_REJECT: immediately reject this
1096 * target. The call will continue retrying with
1097 * next target if present, or disconnect the call
1098 * if there is no more target to try.
1099 * - PJSIP_REDIRECT_STOP: stop the whole redirection
1100 * process and immediately disconnect the call. The
1101 * on_call_state() callback will be called with
1102 * PJSIP_INV_STATE_DISCONNECTED state immediately
1103 * after this callback returns.
1104 * - PJSIP_REDIRECT_PENDING: set to this value if
1105 * no decision can be made immediately (for example
1106 * to request confirmation from user). Application
1107 * then MUST call #pjsua_call_process_redirect()
1108 * to either accept or reject the redirection upon
1109 * getting user decision.
Benny Prijono5e51a4e2008-11-27 00:06:46 +00001110 */
Benny Prijono08a48b82008-11-27 12:42:07 +00001111 pjsip_redirect_op (*on_call_redirected)(pjsua_call_id call_id,
1112 const pjsip_uri *target,
1113 const pjsip_event *e);
Benny Prijono5e51a4e2008-11-27 00:06:46 +00001114
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001115} pjsua_callback;
1116
1117
1118
Benny Prijonodc39fe82006-05-26 12:17:46 +00001119
1120/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001121 * This structure describes the settings to control the API and
1122 * user agent behavior, and can be specified when calling #pjsua_init().
1123 * Before setting the values, application must call #pjsua_config_default()
1124 * to initialize this structure with the default values.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001125 *
1126 * \par Python Sample Syntax:
1127 * The pjsua_config type in Python is <tt>py_pjsua.Config</tt>. Application
1128 * creates the instance by calling <tt>py_pjsua.config_default()</tt>:
1129 * \code
1130 cfg = py_pjsua.config_default()
1131 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001132 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001133typedef struct pjsua_config
1134{
1135
1136 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001137 * Maximum calls to support (default: 4). The value specified here
1138 * must be smaller than the compile time maximum settings
1139 * PJSUA_MAX_CALLS, which by default is 32. To increase this
1140 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
1141 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001142 */
1143 unsigned max_calls;
1144
1145 /**
1146 * Number of worker threads. Normally application will want to have at
1147 * least one worker thread, unless when it wants to poll the library
1148 * periodically, which in this case the worker thread can be set to
1149 * zero.
1150 */
1151 unsigned thread_cnt;
1152
1153 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +00001154 * Number of nameservers. If no name server is configured, the SIP SRV
1155 * resolution would be disabled, and domain will be resolved with
1156 * standard pj_gethostbyname() function.
1157 */
1158 unsigned nameserver_count;
1159
1160 /**
1161 * Array of nameservers to be used by the SIP resolver subsystem.
1162 * The order of the name server specifies the priority (first name
1163 * server will be used first, unless it is not reachable).
1164 */
1165 pj_str_t nameserver[4];
1166
1167 /**
Benny Prijono91d06b62008-09-20 12:16:56 +00001168 * Force loose-route to be used in all route/proxy URIs (outbound_proxy
1169 * and account's proxy settings). When this setting is enabled, the
1170 * library will check all the route/proxy URIs specified in the settings
1171 * and append ";lr" parameter to the URI if the parameter is not present.
1172 *
1173 * Default: 1
1174 */
1175 pj_bool_t force_lr;
1176
1177 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001178 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001179 */
1180 unsigned outbound_proxy_cnt;
1181
1182 /**
1183 * Specify the URL of outbound proxies to visit for all outgoing requests.
1184 * The outbound proxies will be used for all accounts, and it will
1185 * be used to build the route set for outgoing requests. The final
1186 * route set for outgoing requests will consists of the outbound proxies
1187 * and the proxy configured in the account.
1188 */
1189 pj_str_t outbound_proxy[4];
1190
Benny Prijonoc97608e2007-03-23 16:34:20 +00001191 /**
Benny Prijonoebbf6892007-03-24 17:37:25 +00001192 * Specify domain name to be resolved with DNS SRV resolution to get the
Benny Prijonof76e1392008-06-06 14:51:48 +00001193 * address of the STUN server. Alternatively application may specify
1194 * \a stun_host instead.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001195 *
1196 * If DNS SRV resolution failed for this domain, then DNS A resolution
1197 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +00001198 */
Benny Prijonoebbf6892007-03-24 17:37:25 +00001199 pj_str_t stun_domain;
1200
1201 /**
Benny Prijonoaf09dc32007-04-22 12:48:30 +00001202 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
1203 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001204 */
1205 pj_str_t stun_host;
1206
1207 /**
Benny Prijono91a6a172007-10-31 08:59:29 +00001208 * Support for adding and parsing NAT type in the SDP to assist
1209 * troubleshooting. The valid values are:
1210 * - 0: no information will be added in SDP, and parsing is disabled.
Benny Prijono6ba8c542007-10-16 01:34:14 +00001211 * - 1: only the NAT type number is added.
1212 * - 2: add both NAT type number and name.
1213 *
Benny Prijono91a6a172007-10-31 08:59:29 +00001214 * Default: 1
Benny Prijono6ba8c542007-10-16 01:34:14 +00001215 */
1216 int nat_type_in_sdp;
1217
1218 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001219 * Specify whether support for reliable provisional response (100rel and
1220 * PRACK) should be required by default. Note that this setting can be
1221 * further customized in account configuration (#pjsua_acc_config).
1222 *
1223 * Default: PJ_FALSE
1224 */
1225 pj_bool_t require_100rel;
1226
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001227 /**
1228 * Number of credentials in the credential array.
1229 */
1230 unsigned cred_count;
1231
1232 /**
1233 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +00001234 * and can be used to authenticate against outbound proxies. If the
1235 * credential is specific to the account, then application should set
1236 * the credential in the pjsua_acc_config rather than the credential
1237 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001238 */
1239 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1240
1241 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001242 * Application callback to receive various event notifications from
1243 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001244 */
1245 pjsua_callback cb;
1246
Benny Prijono56315612006-07-18 14:39:40 +00001247 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001248 * Optional user agent string (default empty). If it's empty, no
1249 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +00001250 */
1251 pj_str_t user_agent;
1252
Benny Prijonod8179652008-01-23 20:39:07 +00001253#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
1254 /**
1255 * Specify default value of secure media transport usage.
1256 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
1257 * PJMEDIA_SRTP_MANDATORY.
1258 *
1259 * Note that this setting can be further customized in account
1260 * configuration (#pjsua_acc_config).
1261 *
1262 * Default: #PJSUA_DEFAULT_USE_SRTP
1263 */
1264 pjmedia_srtp_use use_srtp;
1265
1266 /**
1267 * Specify whether SRTP requires secure signaling to be used. This option
1268 * is only used when \a use_srtp option above is non-zero.
1269 *
1270 * Valid values are:
1271 * 0: SRTP does not require secure signaling
1272 * 1: SRTP requires secure transport such as TLS
1273 * 2: SRTP requires secure end-to-end transport (SIPS)
1274 *
1275 * Note that this setting can be further customized in account
1276 * configuration (#pjsua_acc_config).
1277 *
1278 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
1279 */
1280 int srtp_secure_signaling;
1281#endif
1282
Benny Prijono3c5e28b2008-09-24 10:10:15 +00001283 /**
1284 * Disconnect other call legs when more than one 2xx responses for
1285 * outgoing INVITE are received due to forking. Currently the library
1286 * is not able to handle simultaneous forked media, so disconnecting
1287 * the other call legs is necessary.
1288 *
1289 * With this setting enabled, the library will handle only one of the
1290 * connected call leg, and the other connected call legs will be
1291 * disconnected.
1292 *
1293 * Default: PJ_TRUE (only disable this setting for testing purposes).
1294 */
1295 pj_bool_t hangup_forked_call;
1296
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001297} pjsua_config;
1298
1299
1300/**
1301 * Use this function to initialize pjsua config.
1302 *
1303 * @param cfg pjsua config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001304 *
1305 * \par Python Sample Syntax:
1306 * The corresponding Python function creates an instance of the config and
1307 * initializes it to the default settings:
1308 * \code
1309 cfg = py_pjsua.config_default()
1310 * \endcode
1311
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001312 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001313PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001314
1315
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001316/** The implementation has been moved to sip_auth.h */
Benny Prijono7977f9f2007-10-10 11:37:56 +00001317#define pjsip_cred_dup pjsip_cred_info_dup
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001318
1319
1320/**
1321 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001322 *
1323 * @param pool The pool to get memory from.
1324 * @param dst Destination config.
1325 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001326 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001327PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1328 pjsua_config *dst,
1329 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001330
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001331
1332/**
1333 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001334 * outgoing SIP message. It can (optionally) be specified for example
1335 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1336 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1337 *
1338 * Application MUST call #pjsua_msg_data_init() to initialize this
1339 * structure before setting its values.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001340 *
1341 * \par Python Syntax
1342 * The data type in Python is <tt>py_pjsua.Msg_Data</tt>. Application is
1343 * recommended to instantiate the structure by using this construct:
1344 * \code
1345 msg_data = py_pjsua.msg_data_init()
1346 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001347 */
Benny Prijono63fba012008-07-17 14:19:10 +00001348struct pjsua_msg_data
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001349{
1350 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001351 * Additional message headers as linked list. Application can add
1352 * headers to the list by creating the header, either from the heap/pool
1353 * or from temporary local variable, and add the header using
1354 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001355 *
1356 * \par Python:
1357 * This field is implemented as string linked-list in Python, where each
1358 * string describes the header. For example:
1359 \code
1360 msg_data = py_pjsua.Msg_Data()
1361 msg_data.hdr_list = ["Subject: Hello py_pjsua!", "Priority: very low"]
1362 \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001363 */
1364 pjsip_hdr hdr_list;
1365
1366 /**
1367 * MIME type of optional message body.
1368 */
1369 pj_str_t content_type;
1370
1371 /**
1372 * Optional message body.
1373 */
1374 pj_str_t msg_body;
1375
Benny Prijono63fba012008-07-17 14:19:10 +00001376};
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001377
1378
1379/**
1380 * Initialize message data.
1381 *
1382 * @param msg_data Message data to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001383 *
1384 * \par Python
1385 * The corresponding Python function creates and initializes the structure:
1386 * \code
1387 msg_data = py_pjsua.msg_data_init()
1388 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001389 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001390PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001391
Benny Prijono268ca612006-02-07 12:34:11 +00001392
1393/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001394 * Instantiate pjsua application. Application must call this function before
1395 * calling any other functions, to make sure that the underlying libraries
1396 * are properly initialized. Once this function has returned success,
1397 * application must call pjsua_destroy() before quitting.
1398 *
1399 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001400 *
1401 * \par Python:
1402 * \code
1403 status = py_pjsua.create()
1404 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001405 */
1406PJ_DECL(pj_status_t) pjsua_create(void);
1407
1408
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001409/** Forward declaration */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001410typedef struct pjsua_media_config pjsua_media_config;
1411
1412
Benny Prijonodc39fe82006-05-26 12:17:46 +00001413/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001414 * Initialize pjsua with the specified settings. All the settings are
1415 * optional, and the default values will be used when the config is not
1416 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001417 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001418 * Note that #pjsua_create() MUST be called before calling this function.
1419 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001420 * @param ua_cfg User agent configuration.
1421 * @param log_cfg Optional logging configuration.
1422 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001423 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001424 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001425 *
1426 * \par Python:
1427 * The function is similar in Python:
1428 * \code
1429 status = py_pjsua.init(ua_cfg, log_cfg, media_cfg)
1430 * \endcode
1431 * Note that \a ua_cfg, \a log_cfg, and \a media_cfg are optional, and
1432 * the Python script may pass None if it doesn't want to configure the
1433 * setting.
Benny Prijono268ca612006-02-07 12:34:11 +00001434 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001435PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1436 const pjsua_logging_config *log_cfg,
1437 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001438
1439
1440/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001441 * Application is recommended to call this function after all initialization
1442 * is done, so that the library can do additional checking set up
1443 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001444 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001445 * Application may call this function anytime after #pjsua_init().
1446 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001447 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001448 *
1449 * \par Python:
1450 * The function is similar in Python:
1451 * \code
1452 status = py_pjsua.start()
1453 * \endcode
Benny Prijonoccf95622006-02-07 18:48:01 +00001454 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001455PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001456
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001457
Benny Prijonoccf95622006-02-07 18:48:01 +00001458/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001459 * Destroy pjsua. Application is recommended to perform graceful shutdown
1460 * before calling this function (such as unregister the account from the SIP
1461 * server, terminate presense subscription, and hangup active calls), however,
1462 * this function will do all of these if it finds there are active sessions
1463 * that need to be terminated. This function will approximately block for
1464 * one second to wait for replies from remote.
1465 *
1466 * Application.may safely call this function more than once if it doesn't
1467 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001468 *
1469 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001470 *
1471 * \par Python:
1472 * The function is similar in Python:
1473 * \code
1474 status = py_pjsua.destroy()
1475 * \endcode
Benny Prijono268ca612006-02-07 12:34:11 +00001476 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001477PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001478
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001479
Benny Prijono9fc735d2006-05-28 14:58:12 +00001480/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001481 * Poll pjsua for events, and if necessary block the caller thread for
1482 * the specified maximum interval (in miliseconds).
1483 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001484 * Application doesn't normally need to call this function if it has
1485 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1486 * because polling then will be done by these worker threads instead.
1487 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001488 * @param msec_timeout Maximum time to wait, in miliseconds.
1489 *
1490 * @return The number of events that have been handled during the
1491 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001492 * can retrieve the error as (status = -return_value).
1493 *
1494 * \par Python:
1495 * The function is similar in Python:
1496 * \code
1497 n = py_pjsua.handle_events(msec_timeout)
1498 * \endcode
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001499 */
1500PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1501
1502
1503/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001504 * Create memory pool to be used by the application. Once application
1505 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001506 *
1507 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001508 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001509 * @param increment Increment size.
1510 *
1511 * @return The pool, or NULL when there's no memory.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001512 *
1513 * \par Python:
1514 * Python script may also create a pool object from the script:
1515 * \code
1516 pool = py_pjsua.pool_create(name, init_size, increment)
1517 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001518 */
1519PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1520 pj_size_t increment);
1521
1522
1523/**
1524 * Application can call this function at any time (after pjsua_create(), of
1525 * course) to change logging settings.
1526 *
1527 * @param c Logging configuration.
1528 *
1529 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001530 *
1531 * \par Python:
1532 * The function is similar in Python:
1533 * \code
1534 status = py_pjsua.reconfigure_logging(log_cfg)
1535 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001536 */
1537PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1538
1539
1540/**
1541 * Internal function to get SIP endpoint instance of pjsua, which is
1542 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001543 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001544 *
1545 * @return SIP endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001546 *
1547 * \par Python:
1548 * Application may retrieve the SIP endpoint instance:
1549 * \code
1550 endpt = py_pjsua.get_pjsip_endpt()
1551 * \endcode
1552 * However currently the object is just an opaque object and does not have
1553 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001554 */
1555PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1556
1557/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001558 * Internal function to get media endpoint instance.
1559 * Only valid after #pjsua_init() is called.
1560 *
1561 * @return Media endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001562 *
1563 * \par Python:
1564 * Application may retrieve the media endpoint instance:
1565 * \code
1566 endpt = py_pjsua.get_pjmedia_endpt()
1567 * \endcode
1568 * However currently the object is just an opaque object and does not have
1569 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001570 */
1571PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1572
Benny Prijono97b87172006-08-24 14:25:14 +00001573/**
1574 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001575 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001576 *
1577 * @return Pool factory currently used by PJSUA.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001578 *
1579 * \par Python:
1580 * Application may retrieve the pool factory instance:
1581 * \code
1582 endpt = py_pjsua.get_pool_factory()
1583 * \endcode
1584 * However currently the object is just an opaque object and does not have
1585 * any use for Python scripts.
Benny Prijono97b87172006-08-24 14:25:14 +00001586 */
1587PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1588
1589
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001590
1591/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001592 * Utilities.
1593 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001594 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001595
1596/**
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001597 * This is a utility function to detect NAT type in front of this
1598 * endpoint. Once invoked successfully, this function will complete
Benny Prijono6ba8c542007-10-16 01:34:14 +00001599 * asynchronously and report the result in \a on_nat_detect() callback
1600 * of pjsua_callback.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001601 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001602 * After NAT has been detected and the callback is called, application can
1603 * get the detected NAT type by calling #pjsua_get_nat_type(). Application
1604 * can also perform NAT detection by calling #pjsua_detect_nat_type()
1605 * again at later time.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001606 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001607 * Note that STUN must be enabled to run this function successfully.
1608 *
1609 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001610 */
Benny Prijono6ba8c542007-10-16 01:34:14 +00001611PJ_DECL(pj_status_t) pjsua_detect_nat_type(void);
1612
1613
1614/**
1615 * Get the NAT type as detected by #pjsua_detect_nat_type() function.
1616 * This function will only return useful NAT type after #pjsua_detect_nat_type()
1617 * has completed successfully and \a on_nat_detect() callback has been called.
1618 *
1619 * @param type NAT type.
1620 *
1621 * @return When detection is in progress, this function will
1622 * return PJ_EPENDING and \a type will be set to
1623 * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been
1624 * detected successfully, this function will return
1625 * PJ_SUCCESS and \a type will be set to the correct
1626 * value. Other return values indicate error and
1627 * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN.
Benny Prijono91a6a172007-10-31 08:59:29 +00001628 *
1629 * @see pjsua_call_get_rem_nat_type()
Benny Prijono6ba8c542007-10-16 01:34:14 +00001630 */
1631PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type);
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001632
1633
1634/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001635 * This is a utility function to verify that valid SIP url is given. If the
1636 * URL is valid, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001637 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001638 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001639 *
1640 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001641 *
1642 * \par Python:
1643 * \code
1644 status = py_pjsua.verify_sip_url(url)
1645 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001646 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001647PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001648
1649
1650/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001651 * This is a utility function to display error message for the specified
1652 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001653 *
1654 * @param sender The log sender field.
1655 * @param title Message title for the error.
1656 * @param status Status code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001657 *
1658 * \par Python:
1659 * \code
1660 py_pjsua.perror(sender, title, status)
1661 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001662 */
1663PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1664 pj_status_t status);
1665
1666
Benny Prijonoda9785b2007-04-02 20:43:06 +00001667/**
1668 * This is a utility function to dump the stack states to log, using
1669 * verbosity level 3.
1670 *
1671 * @param detail Will print detailed output (such as list of
1672 * SIP transactions) when non-zero.
1673 */
1674PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001675
1676/**
1677 * @}
1678 */
1679
1680
1681
1682/*****************************************************************************
1683 * TRANSPORT API
1684 */
1685
1686/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001687 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001688 * @ingroup PJSUA_LIB
1689 * @brief API for managing SIP transports
1690 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001691 *
1692 * PJSUA-API supports creating multiple transport instances, for example UDP,
1693 * TCP, and TLS transport. SIP transport must be created before adding an
1694 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001695 */
1696
1697
Benny Prijonoe6ead542007-01-31 20:53:31 +00001698/** SIP transport identification.
1699 */
Benny Prijono312aff92006-06-17 04:08:30 +00001700typedef int pjsua_transport_id;
1701
1702
1703/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001704 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001705 * and media. Before setting some values to this structure, application
1706 * MUST call #pjsua_transport_config_default() to initialize its
1707 * values with default settings.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001708 *
1709 * \par Python:
1710 * The data type in Python is <tt>py_pjsua.Transport_Config</tt>,
1711 * although application can just do this to create the instance:
1712 * \code
1713 transport_cfg = py_pjsua.transport_config_default()
1714 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001715 */
1716typedef struct pjsua_transport_config
1717{
1718 /**
1719 * UDP port number to bind locally. This setting MUST be specified
1720 * even when default port is desired. If the value is zero, the
1721 * transport will be bound to any available port, and application
1722 * can query the port by querying the transport info.
1723 */
1724 unsigned port;
1725
1726 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001727 * Optional address to advertise as the address of this transport.
1728 * Application can specify any address or hostname for this field,
1729 * for example it can point to one of the interface address in the
1730 * system, or it can point to the public address of a NAT router
1731 * where port mappings have been configured for the application.
1732 *
1733 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001734 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001735 pj_str_t public_addr;
1736
1737 /**
1738 * Optional address where the socket should be bound to. This option
1739 * SHOULD only be used to selectively bind the socket to particular
1740 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1741 * published address of a transport (the public_addr field should be
1742 * used for that purpose).
1743 *
1744 * Note that unlike public_addr field, the address (or hostname) here
1745 * MUST correspond to the actual interface address in the host, since
1746 * this address will be specified as bind() argument.
1747 */
1748 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001749
1750 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001751 * This specifies TLS settings for TLS transport. It is only be used
1752 * when this transport config is being used to create a SIP TLS
1753 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001754 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001755 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001756
Benny Prijono312aff92006-06-17 04:08:30 +00001757} pjsua_transport_config;
1758
1759
1760/**
1761 * Call this function to initialize UDP config with default values.
1762 *
1763 * @param cfg The UDP config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001764 *
1765 * \par Python:
1766 * The corresponding Python function is rather different:
1767 * \code
1768 transport_cfg = py_pjsua.transport_config_default()
1769 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001770 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001771PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001772
1773
1774/**
Benny Prijono312aff92006-06-17 04:08:30 +00001775 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001776 *
1777 * @param pool The pool.
1778 * @param dst The destination config.
1779 * @param src The source config.
1780 *
1781 * \par Python:
1782 * Not applicable. One should be able to just copy one variable instance
1783 * to another in Python.
Benny Prijono312aff92006-06-17 04:08:30 +00001784 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001785PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1786 pjsua_transport_config *dst,
1787 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001788
1789
1790/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001791 * This structure describes transport information returned by
1792 * #pjsua_transport_get_info() function.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001793 *
1794 * \par Python:
1795 * The corresponding data type in Python is <tt>py_pjsua.Transport_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001796 */
1797typedef struct pjsua_transport_info
1798{
1799 /**
1800 * PJSUA transport identification.
1801 */
1802 pjsua_transport_id id;
1803
1804 /**
1805 * Transport type.
1806 */
1807 pjsip_transport_type_e type;
1808
1809 /**
1810 * Transport type name.
1811 */
1812 pj_str_t type_name;
1813
1814 /**
1815 * Transport string info/description.
1816 */
1817 pj_str_t info;
1818
1819 /**
1820 * Transport flag (see ##pjsip_transport_flags_e).
1821 */
1822 unsigned flag;
1823
1824 /**
1825 * Local address length.
1826 */
1827 unsigned addr_len;
1828
1829 /**
1830 * Local/bound address.
1831 */
1832 pj_sockaddr local_addr;
1833
1834 /**
1835 * Published address (or transport address name).
1836 */
1837 pjsip_host_port local_name;
1838
1839 /**
1840 * Current number of objects currently referencing this transport.
1841 */
1842 unsigned usage_count;
1843
1844
1845} pjsua_transport_info;
1846
1847
1848/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001849 * Create and start a new SIP transport according to the specified
1850 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001851 *
1852 * @param type Transport type.
1853 * @param cfg Transport configuration.
1854 * @param p_id Optional pointer to receive transport ID.
1855 *
1856 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001857 *
1858 * \par Python:
1859 * The corresponding Python function returns (status,id) tuple:
1860 * \code
1861 status, transport_id = py_pjsua.transport_create(type, cfg)
1862 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001863 */
1864PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1865 const pjsua_transport_config *cfg,
1866 pjsua_transport_id *p_id);
1867
1868/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001869 * Register transport that has been created by application. This function
1870 * is useful if application wants to implement custom SIP transport and use
1871 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001872 *
1873 * @param tp Transport instance.
1874 * @param p_id Optional pointer to receive transport ID.
1875 *
1876 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001877 *
1878 * \par Python:
1879 * Not applicable (for now), because one cannot create a custom transport
1880 * from Python script.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001881 */
1882PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1883 pjsua_transport_id *p_id);
1884
1885
1886/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001887 * Enumerate all transports currently created in the system. This function
1888 * will return all transport IDs, and application may then call
1889 * #pjsua_transport_get_info() function to retrieve detailed information
1890 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001891 *
1892 * @param id Array to receive transport ids.
1893 * @param count In input, specifies the maximum number of elements.
1894 * On return, it contains the actual number of elements.
1895 *
1896 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001897 *
1898 * \par Python:
1899 * The function returns list of integers representing transport ids:
1900 * \code
1901 [int] = py_pjsua.enum_transports()
1902 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001903 */
1904PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1905 unsigned *count );
1906
1907
1908/**
1909 * Get information about transports.
1910 *
1911 * @param id Transport ID.
1912 * @param info Pointer to receive transport info.
1913 *
1914 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001915 *
1916 * \par Python:
1917 * \code
1918 transport_info = py_pjsua.transport_get_info(id)
1919 * \endcode
1920 * The Python function returns None on error.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001921 */
1922PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1923 pjsua_transport_info *info);
1924
1925
1926/**
1927 * Disable a transport or re-enable it. By default transport is always
1928 * enabled after it is created. Disabling a transport does not necessarily
1929 * close the socket, it will only discard incoming messages and prevent
1930 * the transport from being used to send outgoing messages.
1931 *
1932 * @param id Transport ID.
1933 * @param enabled Non-zero to enable, zero to disable.
1934 *
1935 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001936 *
1937 * \par Python:
1938 * \code
1939 status = py_pjsua.transport_set_enable(id, enabled)
1940 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001941 */
1942PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1943 pj_bool_t enabled);
1944
1945
1946/**
1947 * Close the transport. If transport is forcefully closed, it will be
1948 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00001949 * transport may not terminate properly (it may even crash). Otherwise,
1950 * the system will wait until all transactions are closed while preventing
1951 * new users from using the transport, and will close the transport when
1952 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001953 *
1954 * @param id Transport ID.
1955 * @param force Non-zero to immediately close the transport. This
1956 * is not recommended!
1957 *
1958 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001959 *
1960 * \par Python:
1961 * \code
1962 status = py_pjsua.transport_close(id, force)
1963 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001964 */
1965PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1966 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001967
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001968/**
Benny Prijono312aff92006-06-17 04:08:30 +00001969 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001970 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001971
1972
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001973
1974
1975/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001976 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001977 */
1978
Benny Prijono312aff92006-06-17 04:08:30 +00001979
1980/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001981 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001982 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001983 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001984 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001985 *
Benny Prijono312aff92006-06-17 04:08:30 +00001986 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001987 * using the application. In SIP terms, the identity is used as the <b>From</b>
1988 * header in outgoing requests.
1989 *
1990 * PJSUA-API supports creating and managing multiple accounts. The maximum
1991 * number of accounts is limited by a compile time constant
1992 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001993 *
1994 * Account may or may not have client registration associated with it.
1995 * An account is also associated with <b>route set</b> and some <b>authentication
1996 * credentials</b>, which are used when sending SIP request messages using the
1997 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00001998 * will be reported to remote peer when they subscribe to the account's
1999 * presence, or which is published to a presence server if presence
2000 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00002001 *
2002 * At least one account MUST be created in the application. If no user
2003 * association is required, application can create a userless account by
2004 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00002005 * instead of a particular user, and it correspond with a particular
2006 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00002007 *
2008 * Also one account must be set as the <b>default account</b>, which is used as
2009 * the account to use when PJSUA fails to match a request with any other
2010 * accounts.
2011 *
2012 * When sending outgoing SIP requests (such as making calls or sending
2013 * instant messages), normally PJSUA requires the application to specify
2014 * which account to use for the request. If no account is specified,
2015 * PJSUA may be able to select the account by matching the destination
2016 * domain name, and fall back to default account when no match is found.
2017 */
2018
2019/**
2020 * Maximum accounts.
2021 */
2022#ifndef PJSUA_MAX_ACC
2023# define PJSUA_MAX_ACC 8
2024#endif
2025
2026
2027/**
2028 * Default registration interval.
2029 */
2030#ifndef PJSUA_REG_INTERVAL
Benny Prijonobddef2c2007-10-31 13:28:08 +00002031# define PJSUA_REG_INTERVAL 300
Benny Prijono312aff92006-06-17 04:08:30 +00002032#endif
2033
2034
2035/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002036 * Default PUBLISH expiration
2037 */
2038#ifndef PJSUA_PUBLISH_EXPIRATION
2039# define PJSUA_PUBLISH_EXPIRATION 600
2040#endif
2041
2042
2043/**
Benny Prijono093d3022006-09-24 00:07:11 +00002044 * Default account priority.
2045 */
2046#ifndef PJSUA_DEFAULT_ACC_PRIORITY
2047# define PJSUA_DEFAULT_ACC_PRIORITY 0
2048#endif
2049
2050
2051/**
Benny Prijono8058a622007-06-08 04:37:05 +00002052 * This macro specifies the URI scheme to use in Contact header
2053 * when secure transport such as TLS is used. Application can specify
2054 * either "sip" or "sips".
2055 */
2056#ifndef PJSUA_SECURE_SCHEME
Benny Prijono4c82c1e2008-10-16 08:14:51 +00002057# define PJSUA_SECURE_SCHEME "sip"
Benny Prijono8058a622007-06-08 04:37:05 +00002058#endif
2059
2060
2061/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002062 * This structure describes account configuration to be specified when
2063 * adding a new account with #pjsua_acc_add(). Application MUST initialize
2064 * this structure first by calling #pjsua_acc_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00002065 *
2066 * \par Python:
2067 * The data type in Python is <tt>py_pjsua.Acc_Config</tt>, but normally
2068 * application can just use the snippet below to create and initialize
2069 * the account config:
2070 * \code
2071 acc_cfg = py_pjsua.acc_config_default()
2072 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002073 */
2074typedef struct pjsua_acc_config
2075{
Benny Prijono093d3022006-09-24 00:07:11 +00002076 /**
Benny Prijono705e7842008-07-21 18:12:51 +00002077 * Arbitrary user data to be associated with the newly created account.
2078 * Application may set this later with #pjsua_acc_set_user_data() and
2079 * retrieve it with #pjsua_acc_get_user_data().
2080 */
2081 void *user_data;
2082
2083 /**
Benny Prijono093d3022006-09-24 00:07:11 +00002084 * Account priority, which is used to control the order of matching
2085 * incoming/outgoing requests. The higher the number means the higher
2086 * the priority is, and the account will be matched first.
2087 */
2088 int priority;
2089
Benny Prijono312aff92006-06-17 04:08:30 +00002090 /**
2091 * The full SIP URL for the account. The value can take name address or
2092 * URL format, and will look something like "sip:account@serviceprovider".
2093 *
2094 * This field is mandatory.
2095 */
2096 pj_str_t id;
2097
2098 /**
2099 * This is the URL to be put in the request URI for the registration,
2100 * and will look something like "sip:serviceprovider".
2101 *
2102 * This field should be specified if registration is desired. If the
2103 * value is empty, no account registration will be performed.
2104 */
2105 pj_str_t reg_uri;
2106
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002107 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002108 * If this flag is set, the presence information of this account will
2109 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono48ab2b72007-11-08 09:24:30 +00002110 *
2111 * Default: PJ_FALSE
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002112 */
2113 pj_bool_t publish_enabled;
2114
Benny Prijonofe04fb52007-08-24 08:28:52 +00002115 /**
Benny Prijono48ab2b72007-11-08 09:24:30 +00002116 * Authentication preference.
2117 */
2118 pjsip_auth_clt_pref auth_pref;
2119
2120 /**
Benny Prijonofe04fb52007-08-24 08:28:52 +00002121 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
2122 * is not specified, a random string will be used.
2123 */
2124 pj_str_t pidf_tuple_id;
2125
Benny Prijono312aff92006-06-17 04:08:30 +00002126 /**
2127 * Optional URI to be put as Contact for this account. It is recommended
2128 * that this field is left empty, so that the value will be calculated
2129 * automatically based on the transport address.
2130 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00002131 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00002132
2133 /**
Benny Prijono30fe4852008-12-10 16:54:16 +00002134 * Additional URI parameters that will be appended in the Contact header
2135 * for this account. This will affect the Contact header in all SIP
2136 * messages sent on behalf of this account, including but not limited to
2137 * REGISTER, INVITE, and SUBCRIBE requests or responses.
2138 *
2139 * The parameters should be preceeded by semicolon, and all strings must
2140 * be properly escaped. Example:
2141 * ";my-param=X;another-param=Hi%20there"
2142 */
2143 pj_str_t contact_params;
2144
2145 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00002146 * Specify whether support for reliable provisional response (100rel and
2147 * PRACK) should be required for all sessions of this account.
2148 *
2149 * Default: PJ_FALSE
2150 */
2151 pj_bool_t require_100rel;
2152
2153 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002154 * Number of proxies in the proxy array below.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002155 *
2156 * \par Python:
2157 * Not applicable, as \a proxy is implemented as list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00002158 */
2159 unsigned proxy_cnt;
2160
2161 /**
2162 * Optional URI of the proxies to be visited for all outgoing requests
2163 * that are using this account (REGISTER, INVITE, etc). Application need
2164 * to specify these proxies if the service provider requires that requests
2165 * destined towards its network should go through certain proxies first
2166 * (for example, border controllers).
2167 *
2168 * These proxies will be put in the route set for this account, with
2169 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00002170 * first). If global outbound proxies are configured in pjsua_config,
2171 * then these account proxies will be placed after the global outbound
2172 * proxies in the routeset.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002173 *
2174 * \par Python:
2175 * This will be list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00002176 */
2177 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
2178
2179 /**
2180 * Optional interval for registration, in seconds. If the value is zero,
Benny Prijonobddef2c2007-10-31 13:28:08 +00002181 * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
Benny Prijono312aff92006-06-17 04:08:30 +00002182 */
2183 unsigned reg_timeout;
2184
2185 /**
2186 * Number of credentials in the credential array.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002187 *
2188 * \par Python:
2189 * Not applicable, since \a cred_info is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00002190 */
2191 unsigned cred_count;
2192
2193 /**
2194 * Array of credentials. If registration is desired, normally there should
2195 * be at least one credential specified, to successfully authenticate
2196 * against the service provider. More credentials can be specified, for
2197 * example when the requests are expected to be challenged by the
2198 * proxies in the route set.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002199 *
2200 * \par Python:
2201 * This field is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00002202 */
2203 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
2204
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002205 /**
2206 * Optionally bind this account to specific transport. This normally is
2207 * not a good idea, as account should be able to send requests using
2208 * any available transports according to the destination. But some
2209 * application may want to have explicit control over the transport to
2210 * use, so in that case it can set this field.
2211 *
2212 * Default: -1 (PJSUA_INVALID_ID)
2213 *
2214 * @see pjsua_acc_set_transport()
2215 */
2216 pjsua_transport_id transport_id;
2217
Benny Prijono15b02302007-09-27 14:07:07 +00002218 /**
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002219 * This option is used to update the UDP transport address and the Contact
2220 * header of REGISTER request. When this option is enabled, the library
2221 * will keep track of the public IP address from the response of REGISTER
2222 * request. Once it detects that the address has changed, it will
2223 * unregister current Contact, update the Contact with transport address
2224 * learned from Via header, and register a new Contact to the registrar.
2225 * This will also update the public name of UDP transport if STUN is
2226 * configured.
Benny Prijono15b02302007-09-27 14:07:07 +00002227 *
2228 * Default: 1 (yes)
2229 */
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002230 pj_bool_t allow_contact_rewrite;
Benny Prijono15b02302007-09-27 14:07:07 +00002231
Benny Prijonobddef2c2007-10-31 13:28:08 +00002232 /**
2233 * Set the interval for periodic keep-alive transmission for this account.
2234 * If this value is zero, keep-alive will be disabled for this account.
2235 * The keep-alive transmission will be sent to the registrar's address,
2236 * after successful registration.
2237 *
Benny Prijonobddef2c2007-10-31 13:28:08 +00002238 * Default: 15 (seconds)
2239 */
2240 unsigned ka_interval;
2241
2242 /**
2243 * Specify the data to be transmitted as keep-alive packets.
2244 *
2245 * Default: CR-LF
2246 */
2247 pj_str_t ka_data;
2248
Benny Prijonod8179652008-01-23 20:39:07 +00002249#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
2250 /**
2251 * Specify whether secure media transport should be used for this account.
2252 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
2253 * PJMEDIA_SRTP_MANDATORY.
2254 *
2255 * Default: #PJSUA_DEFAULT_USE_SRTP
2256 */
2257 pjmedia_srtp_use use_srtp;
2258
2259 /**
2260 * Specify whether SRTP requires secure signaling to be used. This option
2261 * is only used when \a use_srtp option above is non-zero.
2262 *
2263 * Valid values are:
2264 * 0: SRTP does not require secure signaling
2265 * 1: SRTP requires secure transport such as TLS
2266 * 2: SRTP requires secure end-to-end transport (SIPS)
2267 *
2268 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
2269 */
2270 int srtp_secure_signaling;
2271#endif
2272
Benny Prijono312aff92006-06-17 04:08:30 +00002273} pjsua_acc_config;
2274
2275
2276/**
2277 * Call this function to initialize account config with default values.
2278 *
2279 * @param cfg The account config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002280 *
2281 * \par Python:
2282 * In Python, this function both creates and initializes the account
2283 * config:
2284 * \code
2285 acc_cfg = py_pjsua.acc_config_default()
2286 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002287 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00002288PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002289
2290
2291/**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002292 * Duplicate account config.
2293 *
2294 * @param pool Pool to be used for duplicating the config.
2295 * @param dst Destination configuration.
2296 * @param src Source configuration.
2297 */
2298PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
2299 pjsua_acc_config *dst,
2300 const pjsua_acc_config *src);
2301
2302
2303/**
Benny Prijono312aff92006-06-17 04:08:30 +00002304 * Account info. Application can query account info by calling
2305 * #pjsua_acc_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00002306 *
2307 * \par Python:
2308 * The data type in Python is <tt>py_pjsua.Acc_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002309 */
2310typedef struct pjsua_acc_info
2311{
2312 /**
2313 * The account ID.
2314 */
2315 pjsua_acc_id id;
2316
2317 /**
2318 * Flag to indicate whether this is the default account.
2319 */
2320 pj_bool_t is_default;
2321
2322 /**
2323 * Account URI
2324 */
2325 pj_str_t acc_uri;
2326
2327 /**
2328 * Flag to tell whether this account has registration setting
2329 * (reg_uri is not empty).
2330 */
2331 pj_bool_t has_registration;
2332
2333 /**
2334 * An up to date expiration interval for account registration session.
2335 */
2336 int expires;
2337
2338 /**
2339 * Last registration status code. If status code is zero, the account
2340 * is currently not registered. Any other value indicates the SIP
2341 * status code of the registration.
2342 */
2343 pjsip_status_code status;
2344
2345 /**
2346 * String describing the registration status.
2347 */
2348 pj_str_t status_text;
2349
2350 /**
2351 * Presence online status for this account.
2352 */
2353 pj_bool_t online_status;
2354
2355 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00002356 * Presence online status text.
2357 */
2358 pj_str_t online_status_text;
2359
2360 /**
2361 * Extended RPID online status information.
2362 */
2363 pjrpid_element rpid;
2364
2365 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002366 * Buffer that is used internally to store the status text.
2367 */
2368 char buf_[PJ_ERR_MSG_SIZE];
2369
2370} pjsua_acc_info;
2371
2372
2373
2374/**
2375 * Get number of current accounts.
2376 *
2377 * @return Current number of accounts.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002378 *
2379 * \par Python:
2380 * \code
2381 count = py_pjsua.acc_get_count()
2382 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002383 */
2384PJ_DECL(unsigned) pjsua_acc_get_count(void);
2385
2386
2387/**
2388 * Check if the specified account ID is valid.
2389 *
2390 * @param acc_id Account ID to check.
2391 *
2392 * @return Non-zero if account ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002393 *
2394 * \par Python:
2395 * \code
2396 is_valid = py_pjsua.acc_is_valid(acc_id)
2397 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002398 */
2399PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
2400
2401
2402/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00002403 * Set default account to be used when incoming and outgoing
2404 * requests doesn't match any accounts.
2405 *
2406 * @param acc_id The account ID to be used as default.
2407 *
2408 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002409 *
2410 * \par Python:
2411 * \code
2412 status = py_pjsua.acc_set_default(acc_id)
2413 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002414 */
2415PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2416
2417
2418/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002419 * Get default account to be used when receiving incoming requests (calls),
2420 * when the destination of the incoming call doesn't match any other
2421 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002422 *
2423 * @return The default account ID, or PJSUA_INVALID_ID if no
2424 * default account is configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002425 *
2426 * \par Python:
2427 * \code
2428 acc_id = py_pjsua.acc_get_default()
2429 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002430 */
2431PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2432
2433
2434/**
Benny Prijono312aff92006-06-17 04:08:30 +00002435 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002436 * #pjsua_init()) before calling this function. If registration is configured
2437 * for this account, this function would also start the SIP registration
2438 * session with the SIP registrar server. This SIP registration session
2439 * will be maintained internally by the library, and application doesn't
2440 * need to do anything to maintain the registration session.
2441 *
Benny Prijono312aff92006-06-17 04:08:30 +00002442 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002443 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002444 * @param is_default If non-zero, this account will be set as the default
2445 * account. The default account will be used when sending
2446 * outgoing requests (e.g. making call) when no account is
2447 * specified, and when receiving incoming requests when the
2448 * request does not match any accounts. It is recommended
2449 * that default account is set to local/LAN account.
2450 * @param p_acc_id Pointer to receive account ID of the new account.
2451 *
2452 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002453 *
2454 * \par Python:
2455 * The function returns (status, account_id) tuple:
2456 * \code
2457 status, account_id = py_pjsua.acc_add(acc_cfg, is_default)
2458 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002459 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002460PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002461 pj_bool_t is_default,
2462 pjsua_acc_id *p_acc_id);
2463
2464
2465/**
2466 * Add a local account. A local account is used to identify local endpoint
2467 * instead of a specific user, and for this reason, a transport ID is needed
2468 * to obtain the local address information.
2469 *
2470 * @param tid Transport ID to generate account address.
2471 * @param is_default If non-zero, this account will be set as the default
2472 * account. The default account will be used when sending
2473 * outgoing requests (e.g. making call) when no account is
2474 * specified, and when receiving incoming requests when the
2475 * request does not match any accounts. It is recommended
2476 * that default account is set to local/LAN account.
2477 * @param p_acc_id Pointer to receive account ID of the new account.
2478 *
2479 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002480 *
2481 * \par Python:
2482 * The function returns (status, account_id) tuple:
2483 * \code
2484 status, account_id = py_pjsua.acc_add_local(tid, is_default)
2485 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002486 */
2487PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2488 pj_bool_t is_default,
2489 pjsua_acc_id *p_acc_id);
2490
2491/**
Benny Prijono705e7842008-07-21 18:12:51 +00002492 * Set arbitrary data to be associated with the account.
2493 *
2494 * @param acc_id The account ID.
2495 * @param user_data User/application data.
2496 *
2497 * @return PJ_SUCCESS on success, or the appropriate error code.
2498 */
2499PJ_DECL(pj_status_t) pjsua_acc_set_user_data(pjsua_acc_id acc_id,
2500 void *user_data);
2501
2502
2503/**
2504 * Retrieve arbitrary data associated with the account.
2505 *
2506 * @param acc_id The account ID.
2507 *
2508 * @return The user data. In the case where the account ID is
2509 * not valid, NULL is returned.
2510 */
2511PJ_DECL(void*) pjsua_acc_get_user_data(pjsua_acc_id acc_id);
2512
2513
2514/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002515 * Delete an account. This will unregister the account from the SIP server,
2516 * if necessary, and terminate server side presence subscriptions associated
2517 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002518 *
2519 * @param acc_id Id of the account to be deleted.
2520 *
2521 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002522 *
2523 * \par Python:
2524 * \code
2525 status = py_pjsua.acc_del(acc_id)
2526 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002527 */
2528PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2529
2530
2531/**
2532 * Modify account information.
2533 *
2534 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002535 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002536 *
2537 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002538 *
2539 * \par Python:
2540 * \code
2541 status = py_pjsua.acc_modify(acc_id, acc_cfg)
2542 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002543 */
2544PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002545 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002546
2547
2548/**
2549 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002550 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002551 * if there are server side presence subscription for this account, and/or
2552 * outgoing PUBLISH if presence publication is enabled for this account.
2553 *
2554 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002555 *
2556 * @param acc_id The account ID.
2557 * @param is_online True of false.
2558 *
2559 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002560 *
2561 * \par Python:
2562 * \code
2563 status = py_pjsua.acc_set_online_status(acc_id, is_online)
2564 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002565 */
2566PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2567 pj_bool_t is_online);
2568
Benny Prijono4461c7d2007-08-25 13:36:15 +00002569/**
2570 * Modify account's presence status to be advertised to remote/presence
2571 * subscribers. This would trigger the sending of outgoing NOTIFY request
2572 * if there are server side presence subscription for this account, and/or
2573 * outgoing PUBLISH if presence publication is enabled for this account.
2574 *
2575 * @see pjsua_acc_set_online_status()
2576 *
2577 * @param acc_id The account ID.
2578 * @param is_online True of false.
2579 * @param pr Extended information in subset of RPID format
2580 * which allows setting custom presence text.
2581 *
2582 * @return PJ_SUCCESS on success, or the appropriate error code.
2583 */
2584PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2585 pj_bool_t is_online,
2586 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002587
2588/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002589 * Update registration or perform unregistration. If registration is
2590 * configured for this account, then initial SIP REGISTER will be sent
2591 * when the account is added with #pjsua_acc_add(). Application normally
2592 * only need to call this function if it wants to manually update the
2593 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002594 *
2595 * @param acc_id The account ID.
2596 * @param renew If renew argument is zero, this will start
2597 * unregistration process.
2598 *
2599 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002600 *
2601 * \par Python:
2602 * \code
2603 status = py_pjsua.acc_set_registration(acc_id, renew)
2604 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002605 */
2606PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2607 pj_bool_t renew);
2608
Benny Prijono312aff92006-06-17 04:08:30 +00002609/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002610 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002611 *
2612 * @param acc_id Account identification.
2613 * @param info Pointer to receive account information.
2614 *
2615 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002616 *
2617 * \par Python:
2618 * \code
2619 acc_info = py_pjsua.acc_get_info(acc_id)
2620 * \endcode
2621 * The function returns None if account ID is not valid.
Benny Prijono312aff92006-06-17 04:08:30 +00002622 */
2623PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2624 pjsua_acc_info *info);
2625
2626
2627/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002628 * Enumerate all account currently active in the library. This will fill
2629 * the array with the account Ids, and application can then query the
2630 * account information for each id with #pjsua_acc_get_info().
2631 *
2632 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002633 *
2634 * @param ids Array of account IDs to be initialized.
2635 * @param count In input, specifies the maximum number of elements.
2636 * On return, it contains the actual number of elements.
2637 *
2638 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002639 *
2640 * \par Python:
2641 * The function takes no argument and returns list of account Ids:
2642 * \code
2643 [acc_ids] = py_pjsua.enum_accs()
2644 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002645 */
2646PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2647 unsigned *count );
2648
2649
2650/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002651 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002652 *
2653 * @param info Array of account infos to be initialized.
2654 * @param count In input, specifies the maximum number of elements.
2655 * On return, it contains the actual number of elements.
2656 *
2657 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002658 *
2659 * \par Python:
2660 * The function takes no argument and returns list of account infos:
2661 * \code
2662 [acc_info] = py_pjsua.acc_enum_info()
2663 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002664 */
2665PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2666 unsigned *count );
2667
2668
2669/**
2670 * This is an internal function to find the most appropriate account to
2671 * used to reach to the specified URL.
2672 *
2673 * @param url The remote URL to reach.
2674 *
2675 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002676 *
2677 * \par Python:
2678 * \code
2679 acc_id = py_pjsua.acc_find_for_outgoing(url)
2680 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002681 */
2682PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2683
2684
2685/**
2686 * This is an internal function to find the most appropriate account to be
2687 * used to handle incoming calls.
2688 *
2689 * @param rdata The incoming request message.
2690 *
2691 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002692 *
2693 * \par Python:
2694 * \code
2695 acc_id = py_pjsua.acc_find_for_outgoing(url)
2696 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002697 */
2698PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2699
2700
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002701/**
Benny Prijonofff245c2007-04-02 11:44:47 +00002702 * Create arbitrary requests using the account. Application should only use
2703 * this function to create auxiliary requests outside dialog, such as
2704 * OPTIONS, and use the call or presence API to create dialog related
2705 * requests.
2706 *
2707 * @param acc_id The account ID.
2708 * @param method The SIP method of the request.
2709 * @param target Target URI.
2710 * @param p_tdata Pointer to receive the request.
2711 *
2712 * @return PJ_SUCCESS or the error code.
2713 */
2714PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
2715 const pjsip_method *method,
2716 const pj_str_t *target,
2717 pjsip_tx_data **p_tdata);
2718
2719
2720/**
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002721 * Create a suitable URI to be put as Contact based on the specified
2722 * target URI for the specified account.
2723 *
2724 * @param pool Pool to allocate memory for the string.
2725 * @param contact The string where the Contact URI will be stored.
2726 * @param acc_id Account ID.
2727 * @param uri Destination URI of the request.
2728 *
2729 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002730 *
2731 * \par Python:
2732 * This function is still experimental in Python:
2733 * \code
2734 uri = py_pjsua.acc_create_uac_contact(pool, acc_id, uri)
2735 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002736 */
2737PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
2738 pj_str_t *contact,
2739 pjsua_acc_id acc_id,
2740 const pj_str_t *uri);
2741
2742
2743
2744/**
2745 * Create a suitable URI to be put as Contact based on the information
2746 * in the incoming request.
2747 *
2748 * @param pool Pool to allocate memory for the string.
2749 * @param contact The string where the Contact URI will be stored.
2750 * @param acc_id Account ID.
2751 * @param rdata Incoming request.
2752 *
2753 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002754 *
2755 * \par Python:
2756 * This function is still experimental in Python:
2757 * \code
2758 uri = py_pjsua.acc_create_uas_contact(pool, acc_id, rdata)
2759 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002760 */
2761PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
2762 pj_str_t *contact,
2763 pjsua_acc_id acc_id,
2764 pjsip_rx_data *rdata );
2765
2766
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002767/**
2768 * Lock/bind this account to a specific transport/listener. Normally
2769 * application shouldn't need to do this, as transports will be selected
2770 * automatically by the stack according to the destination.
2771 *
2772 * When account is locked/bound to a specific transport, all outgoing
2773 * requests from this account will use the specified transport (this
2774 * includes SIP registration, dialog (call and event subscription), and
2775 * out-of-dialog requests such as MESSAGE).
2776 *
2777 * Note that transport_id may be specified in pjsua_acc_config too.
2778 *
2779 * @param acc_id The account ID.
2780 * @param tp_id The transport ID.
2781 *
2782 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002783 *
2784 * \par Python:
2785 * Not yet implemented.
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002786 */
2787PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
2788 pjsua_transport_id tp_id);
2789
Benny Prijono312aff92006-06-17 04:08:30 +00002790
2791/**
2792 * @}
2793 */
2794
2795
2796/*****************************************************************************
2797 * CALLS API
2798 */
2799
2800
2801/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002802 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00002803 * @ingroup PJSUA_LIB
2804 * @brief Call manipulation.
2805 * @{
2806 */
2807
2808/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002809 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00002810 */
2811#ifndef PJSUA_MAX_CALLS
2812# define PJSUA_MAX_CALLS 32
2813#endif
2814
2815
2816
2817/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002818 * This enumeration specifies the media status of a call, and it's part
2819 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00002820 */
2821typedef enum pjsua_call_media_status
2822{
Benny Prijonob5388cf2007-01-04 22:45:08 +00002823 /** Call currently has no media */
Benny Prijono312aff92006-06-17 04:08:30 +00002824 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002825
2826 /** The media is active */
Benny Prijono312aff92006-06-17 04:08:30 +00002827 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002828
2829 /** The media is currently put on hold by local endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002830 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002831
2832 /** The media is currently put on hold by remote endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002833 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002834
Benny Prijono096c56c2007-09-15 08:30:16 +00002835 /** The media has reported error (e.g. ICE negotiation) */
2836 PJSUA_CALL_MEDIA_ERROR
2837
Benny Prijono312aff92006-06-17 04:08:30 +00002838} pjsua_call_media_status;
2839
2840
2841/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002842 * This structure describes the information and current status of a call.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002843 *
2844 * \par Python:
2845 * The type name is <tt>py_pjsua.Call_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002846 */
2847typedef struct pjsua_call_info
2848{
2849 /** Call identification. */
2850 pjsua_call_id id;
2851
2852 /** Initial call role (UAC == caller) */
2853 pjsip_role_e role;
2854
Benny Prijono90315512006-09-14 16:05:16 +00002855 /** The account ID where this call belongs. */
2856 pjsua_acc_id acc_id;
2857
Benny Prijono312aff92006-06-17 04:08:30 +00002858 /** Local URI */
2859 pj_str_t local_info;
2860
2861 /** Local Contact */
2862 pj_str_t local_contact;
2863
2864 /** Remote URI */
2865 pj_str_t remote_info;
2866
2867 /** Remote contact */
2868 pj_str_t remote_contact;
2869
2870 /** Dialog Call-ID string. */
2871 pj_str_t call_id;
2872
2873 /** Call state */
2874 pjsip_inv_state state;
2875
2876 /** Text describing the state */
2877 pj_str_t state_text;
2878
2879 /** Last status code heard, which can be used as cause code */
2880 pjsip_status_code last_status;
2881
2882 /** The reason phrase describing the status. */
2883 pj_str_t last_status_text;
2884
2885 /** Call media status. */
2886 pjsua_call_media_status media_status;
2887
2888 /** Media direction */
2889 pjmedia_dir media_dir;
2890
2891 /** The conference port number for the call */
2892 pjsua_conf_port_id conf_slot;
2893
2894 /** Up-to-date call connected duration (zero when call is not
2895 * established)
2896 */
2897 pj_time_val connect_duration;
2898
2899 /** Total call duration, including set-up time */
2900 pj_time_val total_duration;
2901
2902 /** Internal */
2903 struct {
2904 char local_info[128];
2905 char local_contact[128];
2906 char remote_info[128];
2907 char remote_contact[128];
2908 char call_id[128];
2909 char last_status_text[128];
2910 } buf_;
2911
2912} pjsua_call_info;
2913
2914
2915
Benny Prijonoa91a0032006-02-26 21:23:45 +00002916/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002917 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002918 *
2919 * @return Maximum number of calls configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002920 *
2921 * \par Python:
2922 * \code
2923 count = py_pjsua.call_get_max_count()
2924 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002925 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002926PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002927
2928/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002929 * Get number of currently active calls.
2930 *
2931 * @return Number of currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002932 *
2933 * \par Python:
2934 * \code
2935 count = py_pjsua.call_get_count()
2936 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002937 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002938PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002939
2940/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002941 * Enumerate all active calls. Application may then query the information and
2942 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002943 *
2944 * @param ids Array of account IDs to be initialized.
2945 * @param count In input, specifies the maximum number of elements.
2946 * On return, it contains the actual number of elements.
2947 *
2948 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002949 *
2950 * \par Python:
2951 * This function takes no argument and return list of call Ids.
2952 * \code
2953 [call_ids] = py_pjsua.enum_calls()
2954 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002955 */
2956PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
2957 unsigned *count);
2958
2959
2960/**
2961 * Make outgoing call to the specified URI using the specified account.
2962 *
2963 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002964 * @param dst_uri URI to be put in the To header (normally is the same
2965 * as the target URI).
2966 * @param options Options (must be zero at the moment).
2967 * @param user_data Arbitrary user data to be attached to the call, and
2968 * can be retrieved later.
2969 * @param msg_data Optional headers etc to be added to outgoing INVITE
2970 * request, or NULL if no custom header is desired.
2971 * @param p_call_id Pointer to receive call identification.
2972 *
2973 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002974 *
2975 * \par Python:
2976 * The Python function returns (status, call_id) tuple:
2977 * \code
2978 status, call_id = py_pjsua.call_make_call(acc_id, dst_uri, options,
2979 user_data, msg_data)
2980 * \endcode
2981 * Note: the \a user_data in Python function is an integer, and the
2982 * \a msg_data can be set to None if not required.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002983 */
2984PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
2985 const pj_str_t *dst_uri,
2986 unsigned options,
2987 void *user_data,
2988 const pjsua_msg_data *msg_data,
2989 pjsua_call_id *p_call_id);
2990
2991
2992/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002993 * Check if the specified call has active INVITE session and the INVITE
2994 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002995 *
2996 * @param call_id Call identification.
2997 *
2998 * @return Non-zero if call is active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002999 *
3000 * \par Python:
3001 * \code
3002 bool = py_pjsua.call_is_active(call_id)
3003 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003004 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003005PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003006
3007
3008/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003009 * Check if call has an active media session.
3010 *
3011 * @param call_id Call identification.
3012 *
3013 * @return Non-zero if yes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003014 *
3015 * \par Python:
3016 * \code
3017 bool = py_pjsua.call_has_media(call_id)
3018 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003019 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003020PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003021
3022
3023/**
Benny Prijonocf986c42008-09-02 11:25:07 +00003024 * Retrieve the media session associated with this call. Note that the media
3025 * session may not be available depending on the current call's media status
3026 * (the pjsua_call_media_status information in pjsua_call_info). Application
3027 * may use the media session to retrieve more detailed information about the
3028 * call's media.
3029 *
3030 * @param call_id Call identification.
3031 *
3032 * @return Call media session.
3033 */
3034PJ_DECL(pjmedia_session*) pjsua_call_get_media_session(pjsua_call_id call_id);
3035
3036
3037/**
3038 * Retrieve the media transport instance that is used for this call.
3039 * Application may use the media transport to query more detailed information
3040 * about the media transport.
3041 *
3042 * @param cid Call identification (the call_id).
3043 *
3044 * @return Call media transport.
3045 */
3046PJ_DECL(pjmedia_transport*) pjsua_call_get_media_transport(pjsua_call_id cid);
3047
3048
3049/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003050 * Get the conference port identification associated with the call.
3051 *
3052 * @param call_id Call identification.
3053 *
3054 * @return Conference port ID, or PJSUA_INVALID_ID when the
3055 * media has not been established or is not active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003056 *
3057 * \par Python:
3058 * \code
3059 slot = py_pjsua.call_get_conf_port(call_id)
3060 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003061 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003062PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
3063
3064/**
3065 * Obtain detail information about the specified call.
3066 *
3067 * @param call_id Call identification.
3068 * @param info Call info to be initialized.
3069 *
3070 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003071 *
3072 * \par Python:
3073 * \code
3074 call_info = py_pjsua.call_get_info(call_id)
3075 * \endcode
3076 * \a call_info return value will be set to None if call_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003077 */
3078PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003079 pjsua_call_info *info);
3080
3081
3082/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003083 * Attach application specific data to the call. Application can then
3084 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003085 *
3086 * @param call_id Call identification.
3087 * @param user_data Arbitrary data to be attached to the call.
3088 *
3089 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003090 *
3091 * \par Python:
3092 * \code
3093 status = py_pjsua.call_set_user_data(call_id, user_data)
3094 * \endcode
3095 * The \a user_data is an integer in the Python function.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003096 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003097PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
3098 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003099
3100
3101/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003102 * Get user data attached to the call, which has been previously set with
3103 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003104 *
3105 * @param call_id Call identification.
3106 *
3107 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003108 *
3109 * \par Python:
3110 * \code
3111 user_data = py_pjsua.call_get_user_data(call_id)
3112 * \endcode
3113 * The \a user_data is an integer.
Benny Prijono268ca612006-02-07 12:34:11 +00003114 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003115PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00003116
3117
3118/**
Benny Prijono91a6a172007-10-31 08:59:29 +00003119 * Get the NAT type of remote's endpoint. This is a proprietary feature
3120 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
3121 * is set in #pjsua_config.
3122 *
3123 * This function can only be called after SDP has been received from remote,
3124 * which means for incoming call, this function can be called as soon as
3125 * call is received as long as incoming call contains SDP, and for outgoing
3126 * call, this function can be called only after SDP is received (normally in
3127 * 200/OK response to INVITE). As a general case, application should call
3128 * this function after or in \a on_call_media_state() callback.
3129 *
3130 * @param call_id Call identification.
3131 * @param p_type Pointer to store the NAT type. Application can then
3132 * retrieve the string description of the NAT type
3133 * by calling pj_stun_get_nat_name().
3134 *
3135 * @return PJ_SUCCESS on success.
3136 *
3137 * @see pjsua_get_nat_type(), nat_type_in_sdp
3138 */
3139PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
3140 pj_stun_nat_type *p_type);
3141
3142/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003143 * Send response to incoming INVITE request. Depending on the status
3144 * code specified as parameter, this function may send provisional
3145 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003146 *
3147 * @param call_id Incoming call identification.
3148 * @param code Status code, (100-699).
3149 * @param reason Optional reason phrase. If NULL, default text
3150 * will be used.
3151 * @param msg_data Optional list of headers etc to be added to outgoing
3152 * response message.
3153 *
3154 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003155 *
3156 * \par Python:
3157 * \code
3158 status = py_pjsua.call_answer(call_id, code, reason, msg_data)
3159 * \endcode
3160 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijonoa91a0032006-02-26 21:23:45 +00003161 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003162PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
3163 unsigned code,
3164 const pj_str_t *reason,
3165 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00003166
3167/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003168 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00003169 * call state. This function is different than answering the call with
3170 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
3171 * will hangup the call regardless of the state and role of the call,
3172 * while #pjsua_call_answer() only works with incoming calls on EARLY
3173 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003174 *
3175 * @param call_id Call identification.
3176 * @param code Optional status code to be sent when we're rejecting
3177 * incoming call. If the value is zero, "603/Decline"
3178 * will be sent.
3179 * @param reason Optional reason phrase to be sent when we're rejecting
3180 * incoming call. If NULL, default text will be used.
3181 * @param msg_data Optional list of headers etc to be added to outgoing
3182 * request/response message.
3183 *
3184 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003185 *
3186 * \par Python:
3187 * \code
3188 status = py_pjsua.call_hangup(call_id, code, reason, msg_data)
3189 * \endcode
3190 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003191 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003192PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
3193 unsigned code,
3194 const pj_str_t *reason,
3195 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003196
Benny Prijono5e51a4e2008-11-27 00:06:46 +00003197/**
3198 * Accept or reject redirection response. Application MUST call this function
3199 * after it signaled PJSIP_REDIRECT_PENDING in the \a on_call_redirected()
3200 * callback, to notify the call whether to accept or reject the redirection
3201 * to the current target. Application can use the combination of
3202 * PJSIP_REDIRECT_PENDING command in \a on_call_redirected() callback and
3203 * this function to ask for user permission before redirecting the call.
3204 *
3205 * Note that if the application chooses to reject or stop redirection (by
3206 * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the
3207 * call disconnection callback will be called before this function returns.
3208 * And if the application rejects the target, the \a on_call_redirected()
3209 * callback may also be called before this function returns if there is
3210 * another target to try.
3211 *
3212 * @param call_id The call ID.
3213 * @param cmd Redirection operation to be applied to the current
3214 * target. The semantic of this argument is similar
3215 * to the description in the \a on_call_redirected()
3216 * callback, except that the PJSIP_REDIRECT_PENDING is
3217 * not accepted here.
3218 *
3219 * @return PJ_SUCCESS on successful operation.
3220 */
3221PJ_DECL(pj_status_t) pjsua_call_process_redirect(pjsua_call_id call_id,
3222 pjsip_redirect_op cmd);
Benny Prijono26ff9062006-02-21 23:47:00 +00003223
3224/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003225 * Put the specified call on hold. This will send re-INVITE with the
3226 * appropriate SDP to inform remote that the call is being put on hold.
3227 * The final status of the request itself will be reported on the
3228 * \a on_call_media_state() callback, which inform the application that
3229 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003230 *
3231 * @param call_id Call identification.
3232 * @param msg_data Optional message components to be sent with
3233 * the request.
3234 *
3235 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003236 *
3237 * \par Python:
3238 * \code
3239 status = py_pjsua.call_set_hold(call_id, msg_data)
3240 * \endcode
3241 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003242 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003243PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
3244 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003245
3246
3247/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003248 * Send re-INVITE to release hold.
3249 * The final status of the request itself will be reported on the
3250 * \a on_call_media_state() callback, which inform the application that
3251 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003252 *
3253 * @param call_id Call identification.
3254 * @param unhold If this argument is non-zero and the call is locally
3255 * held, this will release the local hold.
3256 * @param msg_data Optional message components to be sent with
3257 * the request.
3258 *
3259 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003260 *
3261 * \par Python:
3262 * \code
3263 status = py_pjsua.call_reinvite(call_id, unhold, msg_data)
3264 * \endcode
3265 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003266 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003267PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
3268 pj_bool_t unhold,
3269 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003270
Benny Prijonoc08682e2007-10-04 06:17:58 +00003271/**
3272 * Send UPDATE request.
3273 *
3274 * @param call_id Call identification.
3275 * @param options Must be zero for now.
3276 * @param msg_data Optional message components to be sent with
3277 * the request.
3278 *
3279 * @return PJ_SUCCESS on success, or the appropriate error code.
3280 */
3281PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
3282 unsigned options,
3283 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003284
3285/**
Benny Prijono053f5222006-11-11 16:16:04 +00003286 * Initiate call transfer to the specified address. This function will send
3287 * REFER request to instruct remote call party to initiate a new INVITE
3288 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003289 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00003290 * If application is interested to monitor the successfulness and
3291 * the progress of the transfer request, it can implement
3292 * \a on_call_transfer_status() callback which will report the progress
3293 * of the call transfer request.
3294 *
Benny Prijono053f5222006-11-11 16:16:04 +00003295 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003296 * @param dest Address of new target to be contacted.
3297 * @param msg_data Optional message components to be sent with
3298 * the request.
3299 *
3300 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003301 *
3302 * \par Python:
3303 * \code
3304 status = py_pjsua.call_xfer(call_id, dest, msg_data)
3305 * \endcode
3306 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003307 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003308PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
3309 const pj_str_t *dest,
3310 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003311
3312/**
Benny Prijono053f5222006-11-11 16:16:04 +00003313 * Flag to indicate that "Require: replaces" should not be put in the
3314 * outgoing INVITE request caused by REFER request created by
3315 * #pjsua_call_xfer_replaces().
3316 */
3317#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
3318
3319/**
3320 * Initiate attended call transfer. This function will send REFER request
3321 * to instruct remote call party to initiate new INVITE session to the URL
3322 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
3323 * the call with us with the new call from the REFER recipient.
3324 *
3325 * @param call_id The call id to be transfered.
3326 * @param dest_call_id The call id to be replaced.
3327 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
3328 * to suppress the inclusion of "Require: replaces" in
3329 * the outgoing INVITE request created by the REFER
3330 * request.
3331 * @param msg_data Optional message components to be sent with
3332 * the request.
3333 *
3334 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003335 *
3336 * \par Python:
3337 * \code
3338 status = py_pjsua.call_xfer_replaces(call_id, dest_call_id, options, msg_data)
3339 * \endcode
3340 * Argument \a msg_data may be set to None if not required.
Benny Prijono053f5222006-11-11 16:16:04 +00003341 */
3342PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
3343 pjsua_call_id dest_call_id,
3344 unsigned options,
3345 const pjsua_msg_data *msg_data);
3346
3347/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003348 * Send DTMF digits to remote using RFC 2833 payload formats.
3349 *
3350 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003351 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003352 *
3353 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003354 *
3355 * \par Python:
3356 * \code
3357 status = py_pjsua.call_dial_dtmf(call_id, digits)
3358 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003359 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003360PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003361 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00003362
Benny Prijono26ff9062006-02-21 23:47:00 +00003363/**
Benny Prijonob0808372006-03-02 21:18:58 +00003364 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003365 *
3366 * @param call_id Call identification.
3367 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3368 * assumed.
3369 * @param content The message content.
3370 * @param msg_data Optional list of headers etc to be included in outgoing
3371 * request. The body descriptor in the msg_data is
3372 * ignored.
3373 * @param user_data Optional user data, which will be given back when
3374 * the IM callback is called.
3375 *
3376 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003377 *
3378 * \par Python:
3379 * \code
3380 status = py_pjsua.call_send_im(call_id, mime_type, content, msg_data, user_data)
3381 * \endcode
3382 * Note that the \a user_data argument is an integer in Python.
Benny Prijonob0808372006-03-02 21:18:58 +00003383 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003384PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
3385 const pj_str_t *mime_type,
3386 const pj_str_t *content,
3387 const pjsua_msg_data *msg_data,
3388 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003389
3390
3391/**
3392 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003393 *
3394 * @param call_id Call identification.
3395 * @param is_typing Non-zero to indicate to remote that local person is
3396 * currently typing an IM.
3397 * @param msg_data Optional list of headers etc to be included in outgoing
3398 * request.
3399 *
3400 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003401 *
3402 * \par Python:
3403 * \code
3404 status = py_pjsua.call_send_typing_ind(call_id, is_typing, msg_data)
3405 * \endcode
3406 * Argument \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003407 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003408PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
3409 pj_bool_t is_typing,
3410 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003411
3412/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00003413 * Send arbitrary request with the call. This is useful for example to send
3414 * INFO request. Note that application should not use this function to send
3415 * requests which would change the invite session's state, such as re-INVITE,
3416 * UPDATE, PRACK, and BYE.
3417 *
3418 * @param call_id Call identification.
3419 * @param method SIP method of the request.
3420 * @param msg_data Optional message body and/or list of headers to be
3421 * included in outgoing request.
3422 *
3423 * @return PJ_SUCCESS on success, or the appropriate error code.
3424 */
3425PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
3426 const pj_str_t *method,
3427 const pjsua_msg_data *msg_data);
3428
3429
3430/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003431 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
3432 * currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003433 *
3434 * \par Python:
3435 * \code
3436 py_pjsua.call_hangup_all()
3437 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003438 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00003439PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00003440
3441
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003442/**
3443 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003444 *
3445 * @param call_id Call identification.
3446 * @param with_media Non-zero to include media information too.
3447 * @param buffer Buffer where the statistics are to be written to.
3448 * @param maxlen Maximum length of buffer.
3449 * @param indent Spaces for left indentation.
3450 *
3451 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003452 *
3453 * \par Python:
3454 * \code
3455 string = py_pjsua.call_dump(call_id, with_media, max_len, indent)
3456 * \endcode
3457 * The \a max_len argument is the desired maximum length to be allocated.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003458 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003459PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
3460 pj_bool_t with_media,
3461 char *buffer,
3462 unsigned maxlen,
3463 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003464
Benny Prijono9fc735d2006-05-28 14:58:12 +00003465/**
Benny Prijono312aff92006-06-17 04:08:30 +00003466 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003467 */
Benny Prijono834aee32006-02-19 01:38:06 +00003468
3469
3470/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00003471 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00003472 */
3473
Benny Prijono312aff92006-06-17 04:08:30 +00003474
3475/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003476 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00003477 * @ingroup PJSUA_LIB
3478 * @brief Buddy management, buddy's presence, and instant messaging.
3479 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00003480 *
3481 * This section describes PJSUA-APIs related to buddies management,
3482 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00003483 */
3484
3485/**
3486 * Max buddies in buddy list.
3487 */
3488#ifndef PJSUA_MAX_BUDDIES
3489# define PJSUA_MAX_BUDDIES 256
3490#endif
3491
3492
3493/**
Benny Prijonoa17496a2007-10-31 10:20:31 +00003494 * This specifies how long the library should retry resending SUBSCRIBE
3495 * if the previous SUBSCRIBE failed.
3496 *
3497 * Default: 300 seconds
3498 */
3499#ifndef PJSUA_PRES_TIMER
3500# define PJSUA_PRES_TIMER 300
3501#endif
3502
3503
3504/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003505 * This structure describes buddy configuration when adding a buddy to
3506 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
3507 * the structure with #pjsua_buddy_config_default() to initialize this
3508 * structure with default configuration.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003509 *
3510 * \par Python:
3511 * In Python this structure is <tt>py_pjsua.Buddy_Config</tt>. However
3512 * it is recommended that application instantiates the buddy config
3513 * by calling:
3514 * \code
3515 buddy_cfg = py_pjsua.buddy_config_default()
3516 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003517 */
3518typedef struct pjsua_buddy_config
3519{
3520 /**
3521 * Buddy URL or name address.
3522 */
3523 pj_str_t uri;
3524
3525 /**
3526 * Specify whether presence subscription should start immediately.
3527 */
3528 pj_bool_t subscribe;
3529
Benny Prijono705e7842008-07-21 18:12:51 +00003530 /**
3531 * Specify arbitrary application data to be associated with with
3532 * the buddy object.
3533 */
3534 void *user_data;
3535
Benny Prijono312aff92006-06-17 04:08:30 +00003536} pjsua_buddy_config;
3537
3538
3539/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003540 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003541 */
3542typedef enum pjsua_buddy_status
3543{
3544 /**
3545 * Online status is unknown (possibly because no presence subscription
3546 * has been established).
3547 */
3548 PJSUA_BUDDY_STATUS_UNKNOWN,
3549
3550 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003551 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003552 */
3553 PJSUA_BUDDY_STATUS_ONLINE,
3554
3555 /**
3556 * Buddy is offline.
3557 */
3558 PJSUA_BUDDY_STATUS_OFFLINE,
3559
3560} pjsua_buddy_status;
3561
3562
3563
3564/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003565 * This structure describes buddy info, which can be retrieved by calling
3566 * #pjsua_buddy_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003567 *
3568 * \par Python:
3569 * This structure in Python is <tt>py_pjsua.Buddy_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003570 */
3571typedef struct pjsua_buddy_info
3572{
3573 /**
3574 * The buddy ID.
3575 */
3576 pjsua_buddy_id id;
3577
3578 /**
3579 * The full URI of the buddy, as specified in the configuration.
3580 */
3581 pj_str_t uri;
3582
3583 /**
3584 * Buddy's Contact, only available when presence subscription has
3585 * been established to the buddy.
3586 */
3587 pj_str_t contact;
3588
3589 /**
3590 * Buddy's online status.
3591 */
3592 pjsua_buddy_status status;
3593
3594 /**
3595 * Text to describe buddy's online status.
3596 */
3597 pj_str_t status_text;
3598
3599 /**
3600 * Flag to indicate that we should monitor the presence information for
3601 * this buddy (normally yes, unless explicitly disabled).
3602 */
3603 pj_bool_t monitor_pres;
3604
3605 /**
Benny Prijono63fba012008-07-17 14:19:10 +00003606 * If \a monitor_pres is enabled, this specifies the last state of the
3607 * presence subscription. If presence subscription session is currently
3608 * active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence
3609 * subscription request has been rejected, the value will be
3610 * PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be
3611 * specified in \a sub_term_reason.
3612 */
3613 pjsip_evsub_state sub_state;
3614
3615 /**
3616 * Specifies the last presence subscription terminatino reason. If
3617 * presence subscription is currently active, the value will be empty.
3618 */
3619 pj_str_t sub_term_reason;
3620
3621 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003622 * Extended RPID information about the person.
3623 */
3624 pjrpid_element rpid;
3625
3626 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003627 * Internal buffer.
3628 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003629 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003630
3631} pjsua_buddy_info;
3632
3633
Benny Prijono834aee32006-02-19 01:38:06 +00003634/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003635 * Set default values to the buddy config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003636 *
3637 * \par Python:
3638 * \code
3639 buddy_cfg = py_pjsua.buddy_config_default()
3640 * \endcode
Benny Prijonob5388cf2007-01-04 22:45:08 +00003641 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003642PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003643
3644
3645/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003646 * Get total number of buddies.
3647 *
3648 * @return Number of buddies.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003649 *
3650 * \par Python:
3651 * \code
3652 buddy_count = py_pjsua.get_buddy_count()
3653 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003654 */
3655PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3656
3657
3658/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003659 * Check if buddy ID is valid.
3660 *
3661 * @param buddy_id Buddy ID to check.
3662 *
3663 * @return Non-zero if buddy ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003664 *
3665 * \par Python:
3666 * \code
3667 is_valid = py_pjsua.buddy_is_valid(buddy_id)
3668 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003669 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003670PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3671
3672
3673/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003674 * Enumerate all buddy IDs in the buddy list. Application then can use
3675 * #pjsua_buddy_get_info() to get the detail information for each buddy
3676 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003677 *
3678 * @param ids Array of ids to be initialized.
3679 * @param count On input, specifies max elements in the array.
3680 * On return, it contains actual number of elements
3681 * that have been initialized.
3682 *
3683 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003684 *
3685 * \par Python:
3686 * The Python function takes no argument and returns list of buddy IDs:
3687 * \code
3688 [buddy_ids] = py_pjsua.enum_buddies()
3689 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003690 */
3691PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3692 unsigned *count);
3693
3694/**
Benny Prijono705e7842008-07-21 18:12:51 +00003695 * Find the buddy ID with the specified URI.
3696 *
3697 * @param uri The buddy URI.
3698 *
3699 * @return The buddy ID, or PJSUA_INVALID_ID if not found.
3700 */
3701PJ_DECL(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri);
3702
3703
3704/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003705 * Get detailed buddy info.
3706 *
3707 * @param buddy_id The buddy identification.
3708 * @param info Pointer to receive information about buddy.
3709 *
3710 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003711 *
3712 * \par Python:
3713 * \code
3714 buddy_info = py_pjsua.buddy_get_info(buddy_id)
3715 * \endcode
3716 * The function returns None if buddy_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003717 */
3718PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003719 pjsua_buddy_info *info);
3720
3721/**
Benny Prijono705e7842008-07-21 18:12:51 +00003722 * Set the user data associated with the buddy object.
3723 *
3724 * @param buddy_id The buddy identification.
3725 * @param user_data Arbitrary application data to be associated with
3726 * the buddy object.
3727 *
3728 * @return PJ_SUCCESS on success, or the appropriate error code.
3729 */
3730PJ_DECL(pj_status_t) pjsua_buddy_set_user_data(pjsua_buddy_id buddy_id,
3731 void *user_data);
3732
3733
3734/**
3735 * Get the user data associated with the budy object.
3736 *
3737 * @param buddy_id The buddy identification.
3738 *
3739 * @return The application data.
3740 */
3741PJ_DECL(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id);
3742
3743
3744/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003745 * Add new buddy to the buddy list. If presence subscription is enabled
3746 * for this buddy, this function will also start the presence subscription
3747 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003748 *
Benny Prijonoa7b376b2008-01-25 16:06:33 +00003749 * @param buddy_cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003750 * @param p_buddy_id Pointer to receive buddy ID.
3751 *
3752 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003753 *
3754 * \par Python:
3755 * The function returns (status, buddy_id) tuple:
3756 * \code
3757 status, buddy_id = py_pjsua.buddy_add(buddy_cfg)
3758 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003759 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003760PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003761 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003762
3763
3764/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003765 * Delete the specified buddy from the buddy list. Any presence subscription
3766 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003767 *
3768 * @param buddy_id Buddy identification.
3769 *
3770 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003771 *
3772 * \par Python:
3773 * \code
3774 status = py_pjsua.buddy_del(buddy_id)
3775 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +00003776 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003777PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003778
3779
3780/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003781 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3782 * subscribed, application will be informed about buddy's presence status
3783 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003784 *
3785 * @param buddy_id Buddy identification.
3786 * @param subscribe Specify non-zero to activate presence subscription to
3787 * the specified buddy.
3788 *
3789 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003790 *
3791 * \par Python:
3792 * \code
3793 status = py_pjsua.buddy_subscribe_pres(buddy_id, subscribe)
3794 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003795 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003796PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3797 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003798
3799
3800/**
Benny Prijono10861432007-10-31 10:54:53 +00003801 * Update the presence information for the buddy. Although the library
3802 * periodically refreshes the presence subscription for all buddies, some
3803 * application may want to refresh the buddy's presence subscription
3804 * immediately, and in this case it can use this function to accomplish
3805 * this.
3806 *
3807 * Note that the buddy's presence subscription will only be initiated
3808 * if presence monitoring is enabled for the buddy. See
3809 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
3810 * for the buddy is already active, this function will not do anything.
3811 *
3812 * Once the presence subscription is activated successfully for the buddy,
3813 * application will be notified about the buddy's presence status in the
3814 * on_buddy_state() callback.
3815 *
3816 * @param buddy_id Buddy identification.
3817 *
3818 * @return PJ_SUCCESS on success, or the appropriate error code.
3819 */
3820PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
3821
3822
3823/**
Benny Prijono63fba012008-07-17 14:19:10 +00003824 * Send NOTIFY to inform account presence status or to terminate server
3825 * side presence subscription. If application wants to reject the incoming
3826 * request, it should set the \a state to PJSIP_EVSUB_STATE_TERMINATED.
3827 *
3828 * @param acc_id Account ID.
3829 * @param srv_pres Server presence subscription instance.
3830 * @param state New state to set.
3831 * @param state_str Optionally specify the state string name, if state
3832 * is not "active", "pending", or "terminated".
3833 * @param reason If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3834 * optionally specify the termination reason.
3835 * @param with_body If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3836 * this specifies whether the NOTIFY request should
3837 * contain message body containing account's presence
3838 * information.
3839 * @param msg_data Optional list of headers to be sent with the NOTIFY
3840 * request.
3841 *
3842 * @return PJ_SUCCESS on success.
3843 */
3844PJ_DECL(pj_status_t) pjsua_pres_notify(pjsua_acc_id acc_id,
3845 pjsua_srv_pres *srv_pres,
3846 pjsip_evsub_state state,
3847 const pj_str_t *state_str,
3848 const pj_str_t *reason,
3849 pj_bool_t with_body,
3850 const pjsua_msg_data *msg_data);
3851
3852/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003853 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003854 *
3855 * @param verbose Yes or no.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003856 *
3857 * \par Python:
3858 * \code
3859 py_pjsua.pres_dump()
3860 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003861 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003862PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003863
3864
Benny Prijonob0808372006-03-02 21:18:58 +00003865/**
3866 * The MESSAGE method (defined in pjsua_im.c)
3867 */
3868extern const pjsip_method pjsip_message_method;
3869
3870
Benny Prijonob0808372006-03-02 21:18:58 +00003871
3872/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003873 * Send instant messaging outside dialog, using the specified account for
3874 * route set and authentication.
3875 *
3876 * @param acc_id Account ID to be used to send the request.
3877 * @param to Remote URI.
3878 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3879 * assumed.
3880 * @param content The message content.
3881 * @param msg_data Optional list of headers etc to be included in outgoing
3882 * request. The body descriptor in the msg_data is
3883 * ignored.
3884 * @param user_data Optional user data, which will be given back when
3885 * the IM callback is called.
3886 *
3887 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003888 *
3889 * \par Python:
3890 * \code
3891 status = py_pjsua.im_send(acc_id, to, mime_type, content, msg_data, user_data)
3892 * \endcode
3893 * Arguments \a mime_type and \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003894 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003895PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3896 const pj_str_t *to,
3897 const pj_str_t *mime_type,
3898 const pj_str_t *content,
3899 const pjsua_msg_data *msg_data,
3900 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003901
3902
3903/**
3904 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003905 *
3906 * @param acc_id Account ID to be used to send the request.
3907 * @param to Remote URI.
3908 * @param is_typing If non-zero, it tells remote person that local person
3909 * is currently composing an IM.
3910 * @param msg_data Optional list of headers etc to be added to outgoing
3911 * request.
3912 *
3913 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003914 *
3915 * \par Python:
3916 * \code
3917 status = py_pjsua.im_typing(acc_id, to, is_typing, msg_data)
3918 * \endcode
3919 * Argument \a msg_data may be set to None if not requried.
Benny Prijonob0808372006-03-02 21:18:58 +00003920 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003921PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3922 const pj_str_t *to,
3923 pj_bool_t is_typing,
3924 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003925
3926
Benny Prijonof3195072006-02-14 21:15:30 +00003927
Benny Prijono312aff92006-06-17 04:08:30 +00003928/**
3929 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003930 */
3931
Benny Prijono312aff92006-06-17 04:08:30 +00003932
3933/*****************************************************************************
3934 * MEDIA API
3935 */
3936
3937
3938/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003939 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003940 * @ingroup PJSUA_LIB
3941 * @brief Media manipulation.
3942 * @{
3943 *
3944 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003945 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3946 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003947 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003948 * the interconnection between these terminations freely.
3949 *
3950 * The conference bridge provides powerful switching and mixing functionality
3951 * for application. With the conference bridge, each conference slot (e.g.
3952 * a call) can transmit to multiple destinations, and one destination can
3953 * receive from multiple sources. If more than one media terminations are
3954 * terminated in the same slot, the conference bridge will mix the signal
3955 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00003956 *
3957 * Application connects one media termination/slot to another by calling
3958 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003959 * media flow from the source termination to the sink termination. To
3960 * establish bidirectional media flow, application wound need to make another
3961 * call to #pjsua_conf_connect(), this time inverting the source and
3962 * destination slots in the parameter.
3963 *
3964 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00003965 * the following steps:
3966 *
3967 \code
3968
3969 pj_status_t stream_to_call( pjsua_call_id call_id )
3970 {
3971 pjsua_player_id player_id;
3972
3973 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
3974 if (status != PJ_SUCCESS)
3975 return status;
3976
3977 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
3978 pjsua_call_get_conf_port() );
3979 }
3980 \endcode
3981 *
3982 *
3983 * Other features of PJSUA media:
3984 * - efficient N to M interconnections between media terminations.
3985 * - media termination can be connected to itself to create loopback
3986 * media.
3987 * - the media termination may have different clock rates, and resampling
3988 * will be done automatically by conference bridge.
3989 * - media terminations may also have different frame time; the
3990 * conference bridge will perform the necessary bufferring to adjust
3991 * the difference between terminations.
3992 * - interconnections are removed automatically when media termination
3993 * is removed from the bridge.
3994 * - sound device may be changed even when there are active media
3995 * interconnections.
3996 * - correctly report call's media quality (in #pjsua_call_dump()) from
3997 * RTCP packet exchange.
3998 */
3999
4000/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004001 * Max ports in the conference bridge. This setting is the default value
4002 * for pjsua_media_config.max_media_ports.
Benny Prijono312aff92006-06-17 04:08:30 +00004003 */
4004#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00004005# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00004006#endif
4007
Benny Prijonob5388cf2007-01-04 22:45:08 +00004008/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004009 * The default clock rate to be used by the conference bridge. This setting
4010 * is the default value for pjsua_media_config.clock_rate.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004011 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004012#ifndef PJSUA_DEFAULT_CLOCK_RATE
4013# define PJSUA_DEFAULT_CLOCK_RATE 16000
4014#endif
4015
Benny Prijonob5388cf2007-01-04 22:45:08 +00004016/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004017 * Default frame length in the conference bridge. This setting
4018 * is the default value for pjsua_media_config.audio_frame_ptime.
4019 */
4020#ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Nanang Izzuddinaf974842008-05-08 09:51:16 +00004021# define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
Benny Prijono37c710b2008-01-10 12:09:26 +00004022#endif
4023
4024
4025/**
4026 * Default codec quality settings. This setting is the default value
4027 * for pjsua_media_config.quality.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004028 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004029#ifndef PJSUA_DEFAULT_CODEC_QUALITY
Nanang Izzuddin9dbad152008-06-10 18:56:10 +00004030# define PJSUA_DEFAULT_CODEC_QUALITY 8
Benny Prijono12a669c2006-11-23 07:32:13 +00004031#endif
4032
Benny Prijonob5388cf2007-01-04 22:45:08 +00004033/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004034 * Default iLBC mode. This setting is the default value for
4035 * pjsua_media_config.ilbc_mode.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004036 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004037#ifndef PJSUA_DEFAULT_ILBC_MODE
Benny Prijono37c710b2008-01-10 12:09:26 +00004038# define PJSUA_DEFAULT_ILBC_MODE 30
Benny Prijono12a669c2006-11-23 07:32:13 +00004039#endif
4040
Benny Prijonob5388cf2007-01-04 22:45:08 +00004041/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004042 * The default echo canceller tail length. This setting
4043 * is the default value for pjsua_media_config.ec_tail_len.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004044 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004045#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijono427439c2007-10-21 09:41:24 +00004046# define PJSUA_DEFAULT_EC_TAIL_LEN 200
Benny Prijono12a669c2006-11-23 07:32:13 +00004047#endif
Benny Prijono312aff92006-06-17 04:08:30 +00004048
4049
4050/**
Benny Prijonocba59d92007-02-16 09:22:56 +00004051 * The maximum file player.
4052 */
4053#ifndef PJSUA_MAX_PLAYERS
4054# define PJSUA_MAX_PLAYERS 32
4055#endif
4056
4057
4058/**
4059 * The maximum file player.
4060 */
4061#ifndef PJSUA_MAX_RECORDERS
4062# define PJSUA_MAX_RECORDERS 32
4063#endif
4064
4065
4066/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004067 * This structure describes media configuration, which will be specified
4068 * when calling #pjsua_init(). Application MUST initialize this structure
4069 * by calling #pjsua_media_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00004070 *
4071 * \par Python:
4072 * This data type in Python is <tt>py_pjsua.Media_Config</tt>. To create
4073 * an object of this type, it is recommended to call
4074 * <tt>py_pjsua.media_config_default()</tt> function instead:
4075 * \code
4076 media_cfg = py_pjsua.media_config_default()
4077 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00004078 */
4079struct pjsua_media_config
4080{
4081 /**
4082 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004083 * If value is zero, default clock rate will be used
4084 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00004085 */
4086 unsigned clock_rate;
4087
4088 /**
Benny Prijonof3758ee2008-02-26 15:32:16 +00004089 * Clock rate to be applied when opening the sound device.
4090 * If value is zero, conference bridge clock rate will be used.
4091 */
4092 unsigned snd_clock_rate;
4093
4094 /**
Benny Prijono7d60d052008-03-29 12:24:20 +00004095 * Channel count be applied when opening the sound device and
4096 * conference bridge.
4097 */
4098 unsigned channel_count;
4099
4100 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004101 * Specify audio frame ptime. The value here will affect the
4102 * samples per frame of both the sound device and the conference
4103 * bridge. Specifying lower ptime will normally reduce the
4104 * latency.
4105 *
Benny Prijono37c710b2008-01-10 12:09:26 +00004106 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004107 */
4108 unsigned audio_frame_ptime;
4109
4110 /**
Benny Prijono312aff92006-06-17 04:08:30 +00004111 * Specify maximum number of media ports to be created in the
4112 * conference bridge. Since all media terminate in the bridge
4113 * (calls, file player, file recorder, etc), the value must be
4114 * large enough to support all of them. However, the larger
4115 * the value, the more computations are performed.
Benny Prijono37c710b2008-01-10 12:09:26 +00004116 *
4117 * Default value: PJSUA_MAX_CONF_PORTS
Benny Prijono312aff92006-06-17 04:08:30 +00004118 */
4119 unsigned max_media_ports;
4120
4121 /**
4122 * Specify whether the media manager should manage its own
4123 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
4124 * and at least one worker thread will be created too. If no,
4125 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
4126 * and no worker thread is needed.
4127 *
4128 * Normally application would say yes here, unless it wants to
4129 * run everything from a single thread.
4130 */
4131 pj_bool_t has_ioqueue;
4132
4133 /**
4134 * Specify the number of worker threads to handle incoming RTP
4135 * packets. A value of one is recommended for most applications.
4136 */
4137 unsigned thread_cnt;
4138
Benny Prijono0498d902006-06-19 14:49:14 +00004139 /**
4140 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00004141 * 5-10: resampling use large filter,
4142 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00004143 * 1-2: resampling use linear.
4144 * The media quality also sets speex codec quality/complexity to the
4145 * number.
4146 *
Benny Prijono70972992006-08-05 11:13:58 +00004147 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00004148 */
4149 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00004150
4151 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004152 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00004153 *
4154 * Default: 0 (codec specific)
4155 */
4156 unsigned ptime;
4157
4158 /**
4159 * Disable VAD?
4160 *
4161 * Default: 0 (no (meaning VAD is enabled))
4162 */
4163 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00004164
4165 /**
4166 * iLBC mode (20 or 30).
4167 *
Benny Prijono37c710b2008-01-10 12:09:26 +00004168 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00004169 */
4170 unsigned ilbc_mode;
4171
4172 /**
4173 * Percentage of RTP packet to drop in TX direction
4174 * (to simulate packet lost).
4175 *
4176 * Default: 0
4177 */
4178 unsigned tx_drop_pct;
4179
4180 /**
4181 * Percentage of RTP packet to drop in RX direction
4182 * (to simulate packet lost).
4183 *
4184 * Default: 0
4185 */
4186 unsigned rx_drop_pct;
4187
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004188 /**
Benny Prijono5da50432006-08-07 10:24:52 +00004189 * Echo canceller options (see #pjmedia_echo_create())
4190 *
4191 * Default: 0.
4192 */
4193 unsigned ec_options;
4194
4195 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004196 * Echo canceller tail length, in miliseconds.
4197 *
Benny Prijono669643c2006-09-20 20:02:18 +00004198 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004199 */
4200 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004201
4202 /**
4203 * Jitter buffer initial prefetch delay in msec. The value must be
4204 * between jb_min_pre and jb_max_pre below.
4205 *
4206 * Default: -1 (to use default stream settings, currently 150 msec)
4207 */
4208 int jb_init;
4209
4210 /**
4211 * Jitter buffer minimum prefetch delay in msec.
4212 *
4213 * Default: -1 (to use default stream settings, currently 60 msec)
4214 */
4215 int jb_min_pre;
4216
4217 /**
4218 * Jitter buffer maximum prefetch delay in msec.
4219 *
4220 * Default: -1 (to use default stream settings, currently 240 msec)
4221 */
4222 int jb_max_pre;
4223
4224 /**
4225 * Set maximum delay that can be accomodated by the jitter buffer msec.
4226 *
4227 * Default: -1 (to use default stream settings, currently 360 msec)
4228 */
4229 int jb_max;
4230
Benny Prijonoc97608e2007-03-23 16:34:20 +00004231 /**
4232 * Enable ICE
4233 */
4234 pj_bool_t enable_ice;
4235
4236 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00004237 * Disable ICE host candidates.
Benny Prijonoc97608e2007-03-23 16:34:20 +00004238 */
Benny Prijonof76e1392008-06-06 14:51:48 +00004239 pj_bool_t ice_no_host_cands;
4240
4241 /**
Benny Prijono551af422008-08-07 09:55:52 +00004242 * Disable RTCP component.
4243 *
4244 * Default: no
4245 */
4246 pj_bool_t ice_no_rtcp;
4247
4248 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00004249 * Enable TURN relay candidate in ICE.
4250 */
4251 pj_bool_t enable_turn;
4252
4253 /**
4254 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
4255 * "HOST:PORT" format.
4256 */
4257 pj_str_t turn_server;
4258
4259 /**
4260 * Specify the connection type to be used to the TURN server. Valid
4261 * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP.
4262 *
4263 * Default: PJ_TURN_TP_UDP
4264 */
4265 pj_turn_tp_type turn_conn_type;
4266
4267 /**
4268 * Specify the credential to authenticate with the TURN server.
4269 */
4270 pj_stun_auth_cred turn_auth_cred;
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004271
4272 /**
4273 * Specify idle time of sound device before it is automatically closed,
4274 * in seconds.
4275 *
4276 * Default : -1 (Disable the auto-close feature of sound device)
4277 */
4278 int snd_auto_close_time;
Benny Prijono312aff92006-06-17 04:08:30 +00004279};
4280
4281
4282/**
4283 * Use this function to initialize media config.
4284 *
4285 * @param cfg The media config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004286 *
4287 * \par Python:
4288 * \code
4289 media_cfg = py_pjsua.media_config_default()
4290 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00004291 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00004292PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00004293
4294
4295/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004296 * This structure describes codec information, which can be retrieved by
4297 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00004298 */
4299typedef struct pjsua_codec_info
4300{
4301 /**
4302 * Codec unique identification.
4303 */
4304 pj_str_t codec_id;
4305
4306 /**
4307 * Codec priority (integer 0-255).
4308 */
4309 pj_uint8_t priority;
4310
4311 /**
4312 * Internal buffer.
4313 */
4314 char buf_[32];
4315
4316} pjsua_codec_info;
4317
4318
4319/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004320 * This structure descibes information about a particular media port that
4321 * has been registered into the conference bridge. Application can query
4322 * this info by calling #pjsua_conf_get_port_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00004323 *
4324 * \par Python:
4325 * In Python, this type is <tt>py_pjsua.Conf_Port_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00004326 */
4327typedef struct pjsua_conf_port_info
4328{
4329 /** Conference port number. */
4330 pjsua_conf_port_id slot_id;
4331
4332 /** Port name. */
4333 pj_str_t name;
4334
4335 /** Clock rate. */
4336 unsigned clock_rate;
4337
4338 /** Number of channels. */
4339 unsigned channel_count;
4340
4341 /** Samples per frame */
4342 unsigned samples_per_frame;
4343
4344 /** Bits per sample */
4345 unsigned bits_per_sample;
4346
4347 /** Number of listeners in the array. */
4348 unsigned listener_cnt;
4349
4350 /** Array of listeners (in other words, ports where this port is
4351 * transmitting to.
4352 */
4353 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
4354
4355} pjsua_conf_port_info;
4356
4357
4358/**
4359 * This structure holds information about custom media transport to
4360 * be registered to pjsua.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004361 *
4362 * \par Python:
4363 * Not applicable.
Benny Prijono312aff92006-06-17 04:08:30 +00004364 */
4365typedef struct pjsua_media_transport
4366{
4367 /**
4368 * Media socket information containing the address information
4369 * of the RTP and RTCP socket.
4370 */
4371 pjmedia_sock_info skinfo;
4372
4373 /**
4374 * The media transport instance.
4375 */
4376 pjmedia_transport *transport;
4377
4378} pjsua_media_transport;
4379
4380
4381
4382
Benny Prijono9fc735d2006-05-28 14:58:12 +00004383/**
4384 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004385 *
4386 * @return Maximum number of ports in the conference bridge.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004387 *
4388 * \par Python:
4389 * \code
4390 port_count = py_pjsua.conf_get_max_ports()
4391 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004392 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004393PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004394
4395
4396/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004397 * Get current number of active ports in the bridge.
4398 *
4399 * @return The number.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004400 *
4401 * \par Python:
4402 * \code
4403 count = py_pjsua.conf_get_active_ports()
4404 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004405 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004406PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
4407
4408
4409/**
4410 * Enumerate all conference ports.
4411 *
4412 * @param id Array of conference port ID to be initialized.
4413 * @param count On input, specifies max elements in the array.
4414 * On return, it contains actual number of elements
4415 * that have been initialized.
4416 *
4417 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004418 *
4419 * \par Python:
4420 * The Python functions returns list of conference port Ids:
4421 * \code
4422 [port_ids] = py_pjsua.enum_conf_ports()
4423 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004424 */
4425PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
4426 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004427
4428
4429/**
4430 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004431 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004432 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004433 * @param info Pointer to store the port info.
4434 *
4435 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004436 *
4437 * \par Python:
4438 * \code
4439 port_info = py_pjsua.conf_get_port_info(port_id)
4440 * \endcode
4441 * The function will return None if \a port_id is not valid.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004442 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004443PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00004444 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004445
4446
4447/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00004448 * Add arbitrary media port to PJSUA's conference bridge. Application
4449 * can use this function to add the media port that it creates. For
4450 * media ports that are created by PJSUA-LIB (such as calls, file player,
4451 * or file recorder), PJSUA-LIB will automatically add the port to
4452 * the bridge.
4453 *
4454 * @param pool Pool to use.
4455 * @param port Media port to be added to the bridge.
4456 * @param p_id Optional pointer to receive the conference
4457 * slot id.
4458 *
4459 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004460 *
4461 * \par Python:
4462 * Not applicable (for now)
Benny Prijonoe909eac2006-07-27 22:04:56 +00004463 */
4464PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
4465 pjmedia_port *port,
4466 pjsua_conf_port_id *p_id);
4467
4468
4469/**
4470 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00004471 * call this function if it registered the port manually with previous call
4472 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00004473 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004474 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00004475 *
4476 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004477 *
4478 * \par Python:
4479 * \code
4480 status = py_pjsua.conf_remove_port(port_id)
4481 * \endcode
Benny Prijonoe909eac2006-07-27 22:04:56 +00004482 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004483PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00004484
4485
4486/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004487 * Establish unidirectional media flow from souce to sink. One source
4488 * may transmit to multiple destinations/sink. And if multiple
4489 * sources are transmitting to the same sink, the media will be mixed
4490 * together. Source and sink may refer to the same ID, effectively
4491 * looping the media.
4492 *
4493 * If bidirectional media flow is desired, application needs to call
4494 * this function twice, with the second one having the arguments
4495 * reversed.
4496 *
4497 * @param source Port ID of the source media/transmitter.
4498 * @param sink Port ID of the destination media/received.
4499 *
4500 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004501 *
4502 * \par Python:
4503 * \code
4504 status = py_pjsua.conf_connect(source, sink)
4505 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004506 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004507PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
4508 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004509
4510
4511/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004512 * Disconnect media flow from the source to destination port.
4513 *
4514 * @param source Port ID of the source media/transmitter.
4515 * @param sink Port ID of the destination media/received.
4516 *
4517 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004518 *
4519 * \par Python:
4520 * \code
4521 status = py_pjsua.conf_disconnect(source, sink)
4522 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004523 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004524PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
4525 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004526
4527
Benny Prijono6dd967c2006-12-26 02:27:14 +00004528/**
4529 * Adjust the signal level to be transmitted from the bridge to the
4530 * specified port by making it louder or quieter.
4531 *
4532 * @param slot The conference bridge slot number.
4533 * @param level Signal level adjustment. Value 1.0 means no level
4534 * adjustment, while value 0 means to mute the port.
4535 *
4536 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004537 *
4538 * \par Python:
4539 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004540 */
4541PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
4542 float level);
4543
4544/**
4545 * Adjust the signal level to be received from the specified port (to
4546 * the bridge) by making it louder or quieter.
4547 *
4548 * @param slot The conference bridge slot number.
4549 * @param level Signal level adjustment. Value 1.0 means no level
4550 * adjustment, while value 0 means to mute the port.
4551 *
4552 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004553 *
4554 * \par Python:
4555 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004556 */
4557PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
4558 float level);
4559
4560/**
4561 * Get last signal level transmitted to or received from the specified port.
4562 * The signal level is an integer value in zero to 255, with zero indicates
4563 * no signal, and 255 indicates the loudest signal level.
4564 *
4565 * @param slot The conference bridge slot number.
4566 * @param tx_level Optional argument to receive the level of signal
4567 * transmitted to the specified port (i.e. the direction
4568 * is from the bridge to the port).
4569 * @param rx_level Optional argument to receive the level of signal
4570 * received from the port (i.e. the direction is from the
4571 * port to the bridge).
4572 *
4573 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004574 *
4575 * \par Python:
4576 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004577 */
4578PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
4579 unsigned *tx_level,
4580 unsigned *rx_level);
4581
Benny Prijono6dd967c2006-12-26 02:27:14 +00004582
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004583/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00004584 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004585 */
4586
Benny Prijono9fc735d2006-05-28 14:58:12 +00004587/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004588 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004589 * the conference bridge.
4590 *
4591 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00004592 * WAV files are supported, and the WAV file MUST be
4593 * formatted as 16bit PCM mono/single channel (any
4594 * clock rate is supported).
Benny Prijono58add7c2008-01-18 13:24:07 +00004595 * @param options Optional option flag. Application may specify
4596 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004597 * @param p_id Pointer to receive player ID.
4598 *
4599 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004600 *
4601 * \par Python:
4602 * The function returns (status, id) tuple:
4603 * \code
4604 status, id = py_pjsua.player_create(filename, options)
4605 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004606 */
4607PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004608 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004609 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004610
4611
4612/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004613 * Create a file playlist media port, and automatically add the port
4614 * to the conference bridge.
4615 *
4616 * @param file_names Array of file names to be added to the play list.
4617 * Note that the files must have the same clock rate,
4618 * number of channels, and number of bits per sample.
4619 * @param file_count Number of files in the array.
4620 * @param label Optional label to be set for the media port.
4621 * @param options Optional option flag. Application may specify
4622 * PJMEDIA_FILE_NO_LOOP to prevent looping.
4623 * @param p_id Optional pointer to receive player ID.
4624 *
4625 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004626 *
4627 * \par Python:
4628 * Not implemented yet.
Benny Prijonoa66c3312007-01-21 23:12:40 +00004629 */
4630PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
4631 unsigned file_count,
4632 const pj_str_t *label,
4633 unsigned options,
4634 pjsua_player_id *p_id);
4635
4636/**
4637 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004638 *
4639 * @param id The file player ID.
4640 *
4641 * @return Conference port ID associated with this player.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004642 *
4643 * \par Python:
4644 * \code
4645 port_id = py_pjsua.player_get_conf_port(id)
4646 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004647 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004648PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004649
4650
4651/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004652 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00004653 *
4654 * @param id The player ID.
4655 * @param p_port The media port associated with the player.
4656 *
4657 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004658 *
4659 * \par Python:
4660 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004661 */
Benny Prijono58add7c2008-01-18 13:24:07 +00004662PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
Benny Prijono469b1522006-12-26 03:05:17 +00004663 pjmedia_port **p_port);
4664
4665/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004666 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004667 *
4668 * @param id The file player ID.
4669 * @param samples The playback position, in samples. Application can
4670 * specify zero to re-start the playback.
4671 *
4672 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004673 *
4674 * \par Python:
4675 * \code
4676 status = py_pjsua.player_set_pos(id, samples)
4677 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004678 */
4679PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
4680 pj_uint32_t samples);
4681
4682
4683/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004684 * Close the file of playlist, remove the player from the bridge, and free
4685 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004686 *
4687 * @param id The file player ID.
4688 *
4689 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004690 *
4691 * \par Python:
4692 * \code
4693 status = py_pjsua.player_destroy(id)
4694 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004695 */
4696PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
4697
4698
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004699/*****************************************************************************
4700 * File recorder.
4701 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00004702
4703/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004704 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004705 * the conference bridge. The recorder currently supports recording WAV file.
4706 * The type of the recorder to use is determined by the extension of the file
4707 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004708 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00004709 * @param filename Output file name. The function will determine the
4710 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004711 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00004712 * @param enc_type Optionally specify the type of encoder to be used to
4713 * compress the media, if the file can support different
4714 * encodings. This value must be zero for now.
4715 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004716 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00004717 * For .WAV recorder, this value must be NULL.
4718 * @param max_size Maximum file size. Specify zero or -1 to remove size
4719 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004720 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004721 * @param p_id Pointer to receive the recorder instance.
4722 *
4723 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004724 *
4725 * \par Python:
4726 * \code
4727 status, id = py_pjsua.recorder_create(filename, enc_type, enc_param, max_size, options)
4728 * \endcode
4729 * The \a enc_param is a string in Python.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004730 */
4731PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004732 unsigned enc_type,
4733 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004734 pj_ssize_t max_size,
4735 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004736 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004737
4738
4739/**
4740 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004741 *
4742 * @param id The recorder ID.
4743 *
4744 * @return Conference port ID associated with this recorder.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004745 *
4746 * \par Python:
4747 * \code
4748 port_id = py_pjsua.recorder_get_conf_port(id)
4749 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004750 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004751PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004752
4753
4754/**
Benny Prijono469b1522006-12-26 03:05:17 +00004755 * Get the media port for the recorder.
4756 *
4757 * @param id The recorder ID.
4758 * @param p_port The media port associated with the recorder.
4759 *
4760 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004761 *
4762 * \par Python:
4763 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004764 */
4765PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4766 pjmedia_port **p_port);
4767
4768
4769/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004770 * Destroy recorder (this will complete recording).
4771 *
4772 * @param id The recorder ID.
4773 *
4774 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004775 *
4776 * \par Python:
4777 * \code
4778 status = py_pjsua.recorder_destroy(id)
4779 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004780 */
4781PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4782
4783
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004784/*****************************************************************************
4785 * Sound devices.
4786 */
4787
Benny Prijono9fc735d2006-05-28 14:58:12 +00004788/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004789 * Enum all sound devices installed in the system.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004790 *
4791 * @param info Array of info to be initialized.
4792 * @param count On input, specifies max elements in the array.
4793 * On return, it contains actual number of elements
4794 * that have been initialized.
4795 *
4796 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004797 *
4798 *
4799 * \par Python:
4800 * The function returns list of sound device info:
4801 * \code
4802 [dev_infos] = py_pjsua.enum_snd_devs()
4803 * \endcode
4804 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00004805 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004806PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4807 unsigned *count);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004808
4809
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004810
4811/**
4812 * Get currently active sound devices. If sound devices has not been created
4813 * (for example when pjsua_start() is not called), it is possible that
4814 * the function returns PJ_SUCCESS with -1 as device IDs.
4815 *
4816 * @param capture_dev On return it will be filled with device ID of the
4817 * capture device.
4818 * @param playback_dev On return it will be filled with device ID of the
4819 * device ID of the playback device.
4820 *
4821 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004822 *
4823 * \par Python:
Benny Prijonoebdf8772007-02-01 19:25:50 +00004824 * The function takes no argument and return an (integer,integer) tuple:
Benny Prijonoe6ead542007-01-31 20:53:31 +00004825 * \code
4826 capture_dev, playback_dev = py_pjsua.get_snd_dev()
4827 * \endcode
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004828 */
4829PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4830 int *playback_dev);
4831
4832
Benny Prijono9fc735d2006-05-28 14:58:12 +00004833/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004834 * Select or change sound device. Application may call this function at
4835 * any time to replace current sound device.
4836 *
4837 * @param capture_dev Device ID of the capture device.
4838 * @param playback_dev Device ID of the playback device.
4839 *
4840 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004841 *
4842 * \par Python:
4843 * \code
4844 status = py_pjsua.set_snd_dev(capture_dev, playback_dev)
4845 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004846 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004847PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4848 int playback_dev);
4849
4850
4851/**
4852 * Set pjsua to use null sound device. The null sound device only provides
4853 * the timing needed by the conference bridge, and will not interract with
4854 * any hardware.
4855 *
4856 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004857 *
4858 * \par Python:
4859 * \code
4860 status = py_pjsua.set_null_snd_dev()
4861 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004862 */
4863PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4864
4865
Benny Prijonoe909eac2006-07-27 22:04:56 +00004866/**
4867 * Disconnect the main conference bridge from any sound devices, and let
4868 * application connect the bridge to it's own sound device/master port.
4869 *
4870 * @return The port interface of the conference bridge,
4871 * so that application can connect this to it's own
4872 * sound device or master port.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004873 *
4874 * \par Python:
4875 * Not applicable (for now).
Benny Prijonoe909eac2006-07-27 22:04:56 +00004876 */
4877PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4878
4879
Benny Prijonof20687a2006-08-04 18:27:19 +00004880/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004881 * Configure the echo canceller tail length of the sound port.
Benny Prijonof20687a2006-08-04 18:27:19 +00004882 *
4883 * @param tail_ms The tail length, in miliseconds. Set to zero to
4884 * disable AEC.
Benny Prijonoa7b376b2008-01-25 16:06:33 +00004885 * @param options Options to be passed to pjmedia_echo_create().
Benny Prijono5da50432006-08-07 10:24:52 +00004886 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004887 *
4888 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004889 *
4890 * \par Python:
4891 * \code
4892 status = py_pjsua.set_ec(tail_ms, options)
4893 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004894 */
Benny Prijono5da50432006-08-07 10:24:52 +00004895PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004896
4897
4898/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004899 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004900 *
4901 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4902 * If AEC is disabled, the value will be zero.
4903 *
4904 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004905 *
4906 * \par Python:
4907 * \code
4908 tail_ms = py_pjsua.get_ec_tail()
4909 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004910 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004911PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004912
4913
4914
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004915/*****************************************************************************
4916 * Codecs.
4917 */
4918
4919/**
4920 * Enum all supported codecs in the system.
4921 *
4922 * @param id Array of ID to be initialized.
4923 * @param count On input, specifies max elements in the array.
4924 * On return, it contains actual number of elements
4925 * that have been initialized.
4926 *
4927 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004928 *
4929 * \par Python:
4930 * This function takes no argument and returns list of codec infos:
4931 * \code
4932 [codec_info] = py_pjsua.enum_codecs()
4933 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004934 */
4935PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4936 unsigned *count );
4937
4938
4939/**
4940 * Change codec priority.
4941 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004942 * @param codec_id Codec ID, which is a string that uniquely identify
4943 * the codec (such as "speex/8000"). Please see pjsua
4944 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004945 * @param priority Codec priority, 0-255, where zero means to disable
4946 * the codec.
4947 *
4948 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004949 *
4950 * \par Python:
4951 * \code
4952 status = py_pjsua.codec_set_priority(codec_id, priority)
4953 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004954 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004955PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004956 pj_uint8_t priority );
4957
4958
4959/**
4960 * Get codec parameters.
4961 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004962 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004963 * @param param Structure to receive codec parameters.
4964 *
4965 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004966 *
4967 * \par Python:
4968 * The Python function is experimental:
4969 * \code
4970 codec_param = py_pjsua.codec_get_param(codec_id)
4971 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004972 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004973PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004974 pjmedia_codec_param *param );
4975
4976
4977/**
4978 * Set codec parameters.
4979 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004980 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004981 * @param param Codec parameter to set.
4982 *
4983 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004984 *
4985 * \par Python:
4986 * The Python function is experimental:
4987 * \code
4988 status = py_pjsua.codec_set_param(codec_id, param)
4989 * \endcode
4990
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004991 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004992PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004993 const pjmedia_codec_param *param);
4994
4995
4996
Benny Prijono9fc735d2006-05-28 14:58:12 +00004997
Benny Prijono312aff92006-06-17 04:08:30 +00004998/**
4999 * Create UDP media transports for all the calls. This function creates
5000 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00005001 *
Benny Prijono312aff92006-06-17 04:08:30 +00005002 * @param cfg Media transport configuration. The "port" field in the
5003 * configuration is used as the start port to bind the
5004 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005005 *
5006 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00005007 *
5008 * \par Python:
5009 * Not implemented yet.
Benny Prijonof3195072006-02-14 21:15:30 +00005010 */
Benny Prijono312aff92006-06-17 04:08:30 +00005011PJ_DECL(pj_status_t)
5012pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00005013
Benny Prijonodc39fe82006-05-26 12:17:46 +00005014
5015/**
Benny Prijono312aff92006-06-17 04:08:30 +00005016 * Register custom media transports to be used by calls. There must
5017 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005018 *
Benny Prijono312aff92006-06-17 04:08:30 +00005019 * @param tp The media transport array.
5020 * @param count Number of elements in the array. This number MUST
5021 * match the number of maximum calls configured when
5022 * pjsua is created.
5023 * @param auto_delete Flag to indicate whether the transports should be
5024 * destroyed when pjsua is shutdown.
5025 *
5026 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00005027 *
5028 * \par Python:
5029 * Note applicable.
Benny Prijonodc39fe82006-05-26 12:17:46 +00005030 */
Benny Prijono312aff92006-06-17 04:08:30 +00005031PJ_DECL(pj_status_t)
5032pjsua_media_transports_attach( pjsua_media_transport tp[],
5033 unsigned count,
5034 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00005035
5036
Benny Prijono312aff92006-06-17 04:08:30 +00005037/**
5038 * @}
5039 */
5040
Benny Prijonof3195072006-02-14 21:15:30 +00005041
Benny Prijono268ca612006-02-07 12:34:11 +00005042
Benny Prijono312aff92006-06-17 04:08:30 +00005043/**
5044 * @}
5045 */
5046
Benny Prijonoe6ead542007-01-31 20:53:31 +00005047PJ_END_DECL
5048
Benny Prijono312aff92006-06-17 04:08:30 +00005049
Benny Prijono268ca612006-02-07 12:34:11 +00005050#endif /* __PJSUA_H__ */