blob: 74cbffecd072fbad9fe27532e7c343abbcfadf65 [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 Prijonodcfc0ba2007-09-30 16:50:27 +00002134 * Specify whether support for reliable provisional response (100rel and
2135 * PRACK) should be required for all sessions of this account.
2136 *
2137 * Default: PJ_FALSE
2138 */
2139 pj_bool_t require_100rel;
2140
2141 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002142 * Number of proxies in the proxy array below.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002143 *
2144 * \par Python:
2145 * Not applicable, as \a proxy is implemented as list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00002146 */
2147 unsigned proxy_cnt;
2148
2149 /**
2150 * Optional URI of the proxies to be visited for all outgoing requests
2151 * that are using this account (REGISTER, INVITE, etc). Application need
2152 * to specify these proxies if the service provider requires that requests
2153 * destined towards its network should go through certain proxies first
2154 * (for example, border controllers).
2155 *
2156 * These proxies will be put in the route set for this account, with
2157 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00002158 * first). If global outbound proxies are configured in pjsua_config,
2159 * then these account proxies will be placed after the global outbound
2160 * proxies in the routeset.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002161 *
2162 * \par Python:
2163 * This will be list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00002164 */
2165 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
2166
2167 /**
2168 * Optional interval for registration, in seconds. If the value is zero,
Benny Prijonobddef2c2007-10-31 13:28:08 +00002169 * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
Benny Prijono312aff92006-06-17 04:08:30 +00002170 */
2171 unsigned reg_timeout;
2172
2173 /**
2174 * Number of credentials in the credential array.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002175 *
2176 * \par Python:
2177 * Not applicable, since \a cred_info is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00002178 */
2179 unsigned cred_count;
2180
2181 /**
2182 * Array of credentials. If registration is desired, normally there should
2183 * be at least one credential specified, to successfully authenticate
2184 * against the service provider. More credentials can be specified, for
2185 * example when the requests are expected to be challenged by the
2186 * proxies in the route set.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002187 *
2188 * \par Python:
2189 * This field is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00002190 */
2191 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
2192
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002193 /**
2194 * Optionally bind this account to specific transport. This normally is
2195 * not a good idea, as account should be able to send requests using
2196 * any available transports according to the destination. But some
2197 * application may want to have explicit control over the transport to
2198 * use, so in that case it can set this field.
2199 *
2200 * Default: -1 (PJSUA_INVALID_ID)
2201 *
2202 * @see pjsua_acc_set_transport()
2203 */
2204 pjsua_transport_id transport_id;
2205
Benny Prijono15b02302007-09-27 14:07:07 +00002206 /**
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002207 * This option is used to update the UDP transport address and the Contact
2208 * header of REGISTER request. When this option is enabled, the library
2209 * will keep track of the public IP address from the response of REGISTER
2210 * request. Once it detects that the address has changed, it will
2211 * unregister current Contact, update the Contact with transport address
2212 * learned from Via header, and register a new Contact to the registrar.
2213 * This will also update the public name of UDP transport if STUN is
2214 * configured.
Benny Prijono15b02302007-09-27 14:07:07 +00002215 *
2216 * Default: 1 (yes)
2217 */
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002218 pj_bool_t allow_contact_rewrite;
Benny Prijono15b02302007-09-27 14:07:07 +00002219
Benny Prijonobddef2c2007-10-31 13:28:08 +00002220 /**
2221 * Set the interval for periodic keep-alive transmission for this account.
2222 * If this value is zero, keep-alive will be disabled for this account.
2223 * The keep-alive transmission will be sent to the registrar's address,
2224 * after successful registration.
2225 *
Benny Prijonobddef2c2007-10-31 13:28:08 +00002226 * Default: 15 (seconds)
2227 */
2228 unsigned ka_interval;
2229
2230 /**
2231 * Specify the data to be transmitted as keep-alive packets.
2232 *
2233 * Default: CR-LF
2234 */
2235 pj_str_t ka_data;
2236
Benny Prijonod8179652008-01-23 20:39:07 +00002237#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
2238 /**
2239 * Specify whether secure media transport should be used for this account.
2240 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
2241 * PJMEDIA_SRTP_MANDATORY.
2242 *
2243 * Default: #PJSUA_DEFAULT_USE_SRTP
2244 */
2245 pjmedia_srtp_use use_srtp;
2246
2247 /**
2248 * Specify whether SRTP requires secure signaling to be used. This option
2249 * is only used when \a use_srtp option above is non-zero.
2250 *
2251 * Valid values are:
2252 * 0: SRTP does not require secure signaling
2253 * 1: SRTP requires secure transport such as TLS
2254 * 2: SRTP requires secure end-to-end transport (SIPS)
2255 *
2256 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
2257 */
2258 int srtp_secure_signaling;
2259#endif
2260
Benny Prijono312aff92006-06-17 04:08:30 +00002261} pjsua_acc_config;
2262
2263
2264/**
2265 * Call this function to initialize account config with default values.
2266 *
2267 * @param cfg The account config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002268 *
2269 * \par Python:
2270 * In Python, this function both creates and initializes the account
2271 * config:
2272 * \code
2273 acc_cfg = py_pjsua.acc_config_default()
2274 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002275 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00002276PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002277
2278
2279/**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002280 * Duplicate account config.
2281 *
2282 * @param pool Pool to be used for duplicating the config.
2283 * @param dst Destination configuration.
2284 * @param src Source configuration.
2285 */
2286PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
2287 pjsua_acc_config *dst,
2288 const pjsua_acc_config *src);
2289
2290
2291/**
Benny Prijono312aff92006-06-17 04:08:30 +00002292 * Account info. Application can query account info by calling
2293 * #pjsua_acc_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00002294 *
2295 * \par Python:
2296 * The data type in Python is <tt>py_pjsua.Acc_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002297 */
2298typedef struct pjsua_acc_info
2299{
2300 /**
2301 * The account ID.
2302 */
2303 pjsua_acc_id id;
2304
2305 /**
2306 * Flag to indicate whether this is the default account.
2307 */
2308 pj_bool_t is_default;
2309
2310 /**
2311 * Account URI
2312 */
2313 pj_str_t acc_uri;
2314
2315 /**
2316 * Flag to tell whether this account has registration setting
2317 * (reg_uri is not empty).
2318 */
2319 pj_bool_t has_registration;
2320
2321 /**
2322 * An up to date expiration interval for account registration session.
2323 */
2324 int expires;
2325
2326 /**
2327 * Last registration status code. If status code is zero, the account
2328 * is currently not registered. Any other value indicates the SIP
2329 * status code of the registration.
2330 */
2331 pjsip_status_code status;
2332
2333 /**
2334 * String describing the registration status.
2335 */
2336 pj_str_t status_text;
2337
2338 /**
2339 * Presence online status for this account.
2340 */
2341 pj_bool_t online_status;
2342
2343 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00002344 * Presence online status text.
2345 */
2346 pj_str_t online_status_text;
2347
2348 /**
2349 * Extended RPID online status information.
2350 */
2351 pjrpid_element rpid;
2352
2353 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002354 * Buffer that is used internally to store the status text.
2355 */
2356 char buf_[PJ_ERR_MSG_SIZE];
2357
2358} pjsua_acc_info;
2359
2360
2361
2362/**
2363 * Get number of current accounts.
2364 *
2365 * @return Current number of accounts.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002366 *
2367 * \par Python:
2368 * \code
2369 count = py_pjsua.acc_get_count()
2370 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002371 */
2372PJ_DECL(unsigned) pjsua_acc_get_count(void);
2373
2374
2375/**
2376 * Check if the specified account ID is valid.
2377 *
2378 * @param acc_id Account ID to check.
2379 *
2380 * @return Non-zero if account ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002381 *
2382 * \par Python:
2383 * \code
2384 is_valid = py_pjsua.acc_is_valid(acc_id)
2385 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002386 */
2387PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
2388
2389
2390/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00002391 * Set default account to be used when incoming and outgoing
2392 * requests doesn't match any accounts.
2393 *
2394 * @param acc_id The account ID to be used as default.
2395 *
2396 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002397 *
2398 * \par Python:
2399 * \code
2400 status = py_pjsua.acc_set_default(acc_id)
2401 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002402 */
2403PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2404
2405
2406/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002407 * Get default account to be used when receiving incoming requests (calls),
2408 * when the destination of the incoming call doesn't match any other
2409 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002410 *
2411 * @return The default account ID, or PJSUA_INVALID_ID if no
2412 * default account is configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002413 *
2414 * \par Python:
2415 * \code
2416 acc_id = py_pjsua.acc_get_default()
2417 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002418 */
2419PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2420
2421
2422/**
Benny Prijono312aff92006-06-17 04:08:30 +00002423 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002424 * #pjsua_init()) before calling this function. If registration is configured
2425 * for this account, this function would also start the SIP registration
2426 * session with the SIP registrar server. This SIP registration session
2427 * will be maintained internally by the library, and application doesn't
2428 * need to do anything to maintain the registration session.
2429 *
Benny Prijono312aff92006-06-17 04:08:30 +00002430 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002431 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002432 * @param is_default If non-zero, this account will be set as the default
2433 * account. The default account will be used when sending
2434 * outgoing requests (e.g. making call) when no account is
2435 * specified, and when receiving incoming requests when the
2436 * request does not match any accounts. It is recommended
2437 * that default account is set to local/LAN account.
2438 * @param p_acc_id Pointer to receive account ID of the new account.
2439 *
2440 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002441 *
2442 * \par Python:
2443 * The function returns (status, account_id) tuple:
2444 * \code
2445 status, account_id = py_pjsua.acc_add(acc_cfg, is_default)
2446 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002447 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002448PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002449 pj_bool_t is_default,
2450 pjsua_acc_id *p_acc_id);
2451
2452
2453/**
2454 * Add a local account. A local account is used to identify local endpoint
2455 * instead of a specific user, and for this reason, a transport ID is needed
2456 * to obtain the local address information.
2457 *
2458 * @param tid Transport ID to generate account address.
2459 * @param is_default If non-zero, this account will be set as the default
2460 * account. The default account will be used when sending
2461 * outgoing requests (e.g. making call) when no account is
2462 * specified, and when receiving incoming requests when the
2463 * request does not match any accounts. It is recommended
2464 * that default account is set to local/LAN account.
2465 * @param p_acc_id Pointer to receive account ID of the new account.
2466 *
2467 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002468 *
2469 * \par Python:
2470 * The function returns (status, account_id) tuple:
2471 * \code
2472 status, account_id = py_pjsua.acc_add_local(tid, is_default)
2473 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002474 */
2475PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2476 pj_bool_t is_default,
2477 pjsua_acc_id *p_acc_id);
2478
2479/**
Benny Prijono705e7842008-07-21 18:12:51 +00002480 * Set arbitrary data to be associated with the account.
2481 *
2482 * @param acc_id The account ID.
2483 * @param user_data User/application data.
2484 *
2485 * @return PJ_SUCCESS on success, or the appropriate error code.
2486 */
2487PJ_DECL(pj_status_t) pjsua_acc_set_user_data(pjsua_acc_id acc_id,
2488 void *user_data);
2489
2490
2491/**
2492 * Retrieve arbitrary data associated with the account.
2493 *
2494 * @param acc_id The account ID.
2495 *
2496 * @return The user data. In the case where the account ID is
2497 * not valid, NULL is returned.
2498 */
2499PJ_DECL(void*) pjsua_acc_get_user_data(pjsua_acc_id acc_id);
2500
2501
2502/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002503 * Delete an account. This will unregister the account from the SIP server,
2504 * if necessary, and terminate server side presence subscriptions associated
2505 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002506 *
2507 * @param acc_id Id of the account to be deleted.
2508 *
2509 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002510 *
2511 * \par Python:
2512 * \code
2513 status = py_pjsua.acc_del(acc_id)
2514 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002515 */
2516PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2517
2518
2519/**
2520 * Modify account information.
2521 *
2522 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002523 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002524 *
2525 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002526 *
2527 * \par Python:
2528 * \code
2529 status = py_pjsua.acc_modify(acc_id, acc_cfg)
2530 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002531 */
2532PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002533 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002534
2535
2536/**
2537 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002538 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002539 * if there are server side presence subscription for this account, and/or
2540 * outgoing PUBLISH if presence publication is enabled for this account.
2541 *
2542 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002543 *
2544 * @param acc_id The account ID.
2545 * @param is_online True of false.
2546 *
2547 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002548 *
2549 * \par Python:
2550 * \code
2551 status = py_pjsua.acc_set_online_status(acc_id, is_online)
2552 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002553 */
2554PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2555 pj_bool_t is_online);
2556
Benny Prijono4461c7d2007-08-25 13:36:15 +00002557/**
2558 * Modify account's presence status to be advertised to remote/presence
2559 * subscribers. This would trigger the sending of outgoing NOTIFY request
2560 * if there are server side presence subscription for this account, and/or
2561 * outgoing PUBLISH if presence publication is enabled for this account.
2562 *
2563 * @see pjsua_acc_set_online_status()
2564 *
2565 * @param acc_id The account ID.
2566 * @param is_online True of false.
2567 * @param pr Extended information in subset of RPID format
2568 * which allows setting custom presence text.
2569 *
2570 * @return PJ_SUCCESS on success, or the appropriate error code.
2571 */
2572PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2573 pj_bool_t is_online,
2574 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002575
2576/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002577 * Update registration or perform unregistration. If registration is
2578 * configured for this account, then initial SIP REGISTER will be sent
2579 * when the account is added with #pjsua_acc_add(). Application normally
2580 * only need to call this function if it wants to manually update the
2581 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002582 *
2583 * @param acc_id The account ID.
2584 * @param renew If renew argument is zero, this will start
2585 * unregistration process.
2586 *
2587 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002588 *
2589 * \par Python:
2590 * \code
2591 status = py_pjsua.acc_set_registration(acc_id, renew)
2592 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002593 */
2594PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2595 pj_bool_t renew);
2596
Benny Prijono312aff92006-06-17 04:08:30 +00002597/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002598 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002599 *
2600 * @param acc_id Account identification.
2601 * @param info Pointer to receive account information.
2602 *
2603 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002604 *
2605 * \par Python:
2606 * \code
2607 acc_info = py_pjsua.acc_get_info(acc_id)
2608 * \endcode
2609 * The function returns None if account ID is not valid.
Benny Prijono312aff92006-06-17 04:08:30 +00002610 */
2611PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2612 pjsua_acc_info *info);
2613
2614
2615/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002616 * Enumerate all account currently active in the library. This will fill
2617 * the array with the account Ids, and application can then query the
2618 * account information for each id with #pjsua_acc_get_info().
2619 *
2620 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002621 *
2622 * @param ids Array of account IDs to be initialized.
2623 * @param count In input, specifies the maximum number of elements.
2624 * On return, it contains the actual number of elements.
2625 *
2626 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002627 *
2628 * \par Python:
2629 * The function takes no argument and returns list of account Ids:
2630 * \code
2631 [acc_ids] = py_pjsua.enum_accs()
2632 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002633 */
2634PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2635 unsigned *count );
2636
2637
2638/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002639 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002640 *
2641 * @param info Array of account infos to be initialized.
2642 * @param count In input, specifies the maximum number of elements.
2643 * On return, it contains the actual number of elements.
2644 *
2645 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002646 *
2647 * \par Python:
2648 * The function takes no argument and returns list of account infos:
2649 * \code
2650 [acc_info] = py_pjsua.acc_enum_info()
2651 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002652 */
2653PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2654 unsigned *count );
2655
2656
2657/**
2658 * This is an internal function to find the most appropriate account to
2659 * used to reach to the specified URL.
2660 *
2661 * @param url The remote URL to reach.
2662 *
2663 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002664 *
2665 * \par Python:
2666 * \code
2667 acc_id = py_pjsua.acc_find_for_outgoing(url)
2668 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002669 */
2670PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2671
2672
2673/**
2674 * This is an internal function to find the most appropriate account to be
2675 * used to handle incoming calls.
2676 *
2677 * @param rdata The incoming request message.
2678 *
2679 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002680 *
2681 * \par Python:
2682 * \code
2683 acc_id = py_pjsua.acc_find_for_outgoing(url)
2684 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002685 */
2686PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2687
2688
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002689/**
Benny Prijonofff245c2007-04-02 11:44:47 +00002690 * Create arbitrary requests using the account. Application should only use
2691 * this function to create auxiliary requests outside dialog, such as
2692 * OPTIONS, and use the call or presence API to create dialog related
2693 * requests.
2694 *
2695 * @param acc_id The account ID.
2696 * @param method The SIP method of the request.
2697 * @param target Target URI.
2698 * @param p_tdata Pointer to receive the request.
2699 *
2700 * @return PJ_SUCCESS or the error code.
2701 */
2702PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
2703 const pjsip_method *method,
2704 const pj_str_t *target,
2705 pjsip_tx_data **p_tdata);
2706
2707
2708/**
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002709 * Create a suitable URI to be put as Contact based on the specified
2710 * target URI for the specified account.
2711 *
2712 * @param pool Pool to allocate memory for the string.
2713 * @param contact The string where the Contact URI will be stored.
2714 * @param acc_id Account ID.
2715 * @param uri Destination URI of the request.
2716 *
2717 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002718 *
2719 * \par Python:
2720 * This function is still experimental in Python:
2721 * \code
2722 uri = py_pjsua.acc_create_uac_contact(pool, acc_id, uri)
2723 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002724 */
2725PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
2726 pj_str_t *contact,
2727 pjsua_acc_id acc_id,
2728 const pj_str_t *uri);
2729
2730
2731
2732/**
2733 * Create a suitable URI to be put as Contact based on the information
2734 * in the incoming request.
2735 *
2736 * @param pool Pool to allocate memory for the string.
2737 * @param contact The string where the Contact URI will be stored.
2738 * @param acc_id Account ID.
2739 * @param rdata Incoming request.
2740 *
2741 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002742 *
2743 * \par Python:
2744 * This function is still experimental in Python:
2745 * \code
2746 uri = py_pjsua.acc_create_uas_contact(pool, acc_id, rdata)
2747 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002748 */
2749PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
2750 pj_str_t *contact,
2751 pjsua_acc_id acc_id,
2752 pjsip_rx_data *rdata );
2753
2754
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002755/**
2756 * Lock/bind this account to a specific transport/listener. Normally
2757 * application shouldn't need to do this, as transports will be selected
2758 * automatically by the stack according to the destination.
2759 *
2760 * When account is locked/bound to a specific transport, all outgoing
2761 * requests from this account will use the specified transport (this
2762 * includes SIP registration, dialog (call and event subscription), and
2763 * out-of-dialog requests such as MESSAGE).
2764 *
2765 * Note that transport_id may be specified in pjsua_acc_config too.
2766 *
2767 * @param acc_id The account ID.
2768 * @param tp_id The transport ID.
2769 *
2770 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002771 *
2772 * \par Python:
2773 * Not yet implemented.
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002774 */
2775PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
2776 pjsua_transport_id tp_id);
2777
Benny Prijono312aff92006-06-17 04:08:30 +00002778
2779/**
2780 * @}
2781 */
2782
2783
2784/*****************************************************************************
2785 * CALLS API
2786 */
2787
2788
2789/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002790 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00002791 * @ingroup PJSUA_LIB
2792 * @brief Call manipulation.
2793 * @{
2794 */
2795
2796/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002797 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00002798 */
2799#ifndef PJSUA_MAX_CALLS
2800# define PJSUA_MAX_CALLS 32
2801#endif
2802
2803
2804
2805/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002806 * This enumeration specifies the media status of a call, and it's part
2807 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00002808 */
2809typedef enum pjsua_call_media_status
2810{
Benny Prijonob5388cf2007-01-04 22:45:08 +00002811 /** Call currently has no media */
Benny Prijono312aff92006-06-17 04:08:30 +00002812 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002813
2814 /** The media is active */
Benny Prijono312aff92006-06-17 04:08:30 +00002815 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002816
2817 /** The media is currently put on hold by local endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002818 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002819
2820 /** The media is currently put on hold by remote endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002821 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002822
Benny Prijono096c56c2007-09-15 08:30:16 +00002823 /** The media has reported error (e.g. ICE negotiation) */
2824 PJSUA_CALL_MEDIA_ERROR
2825
Benny Prijono312aff92006-06-17 04:08:30 +00002826} pjsua_call_media_status;
2827
2828
2829/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002830 * This structure describes the information and current status of a call.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002831 *
2832 * \par Python:
2833 * The type name is <tt>py_pjsua.Call_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002834 */
2835typedef struct pjsua_call_info
2836{
2837 /** Call identification. */
2838 pjsua_call_id id;
2839
2840 /** Initial call role (UAC == caller) */
2841 pjsip_role_e role;
2842
Benny Prijono90315512006-09-14 16:05:16 +00002843 /** The account ID where this call belongs. */
2844 pjsua_acc_id acc_id;
2845
Benny Prijono312aff92006-06-17 04:08:30 +00002846 /** Local URI */
2847 pj_str_t local_info;
2848
2849 /** Local Contact */
2850 pj_str_t local_contact;
2851
2852 /** Remote URI */
2853 pj_str_t remote_info;
2854
2855 /** Remote contact */
2856 pj_str_t remote_contact;
2857
2858 /** Dialog Call-ID string. */
2859 pj_str_t call_id;
2860
2861 /** Call state */
2862 pjsip_inv_state state;
2863
2864 /** Text describing the state */
2865 pj_str_t state_text;
2866
2867 /** Last status code heard, which can be used as cause code */
2868 pjsip_status_code last_status;
2869
2870 /** The reason phrase describing the status. */
2871 pj_str_t last_status_text;
2872
2873 /** Call media status. */
2874 pjsua_call_media_status media_status;
2875
2876 /** Media direction */
2877 pjmedia_dir media_dir;
2878
2879 /** The conference port number for the call */
2880 pjsua_conf_port_id conf_slot;
2881
2882 /** Up-to-date call connected duration (zero when call is not
2883 * established)
2884 */
2885 pj_time_val connect_duration;
2886
2887 /** Total call duration, including set-up time */
2888 pj_time_val total_duration;
2889
2890 /** Internal */
2891 struct {
2892 char local_info[128];
2893 char local_contact[128];
2894 char remote_info[128];
2895 char remote_contact[128];
2896 char call_id[128];
2897 char last_status_text[128];
2898 } buf_;
2899
2900} pjsua_call_info;
2901
2902
2903
Benny Prijonoa91a0032006-02-26 21:23:45 +00002904/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002905 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002906 *
2907 * @return Maximum number of calls configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002908 *
2909 * \par Python:
2910 * \code
2911 count = py_pjsua.call_get_max_count()
2912 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002913 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002914PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002915
2916/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002917 * Get number of currently active calls.
2918 *
2919 * @return Number of currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002920 *
2921 * \par Python:
2922 * \code
2923 count = py_pjsua.call_get_count()
2924 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002925 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002926PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002927
2928/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002929 * Enumerate all active calls. Application may then query the information and
2930 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002931 *
2932 * @param ids Array of account IDs to be initialized.
2933 * @param count In input, specifies the maximum number of elements.
2934 * On return, it contains the actual number of elements.
2935 *
2936 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002937 *
2938 * \par Python:
2939 * This function takes no argument and return list of call Ids.
2940 * \code
2941 [call_ids] = py_pjsua.enum_calls()
2942 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002943 */
2944PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
2945 unsigned *count);
2946
2947
2948/**
2949 * Make outgoing call to the specified URI using the specified account.
2950 *
2951 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002952 * @param dst_uri URI to be put in the To header (normally is the same
2953 * as the target URI).
2954 * @param options Options (must be zero at the moment).
2955 * @param user_data Arbitrary user data to be attached to the call, and
2956 * can be retrieved later.
2957 * @param msg_data Optional headers etc to be added to outgoing INVITE
2958 * request, or NULL if no custom header is desired.
2959 * @param p_call_id Pointer to receive call identification.
2960 *
2961 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002962 *
2963 * \par Python:
2964 * The Python function returns (status, call_id) tuple:
2965 * \code
2966 status, call_id = py_pjsua.call_make_call(acc_id, dst_uri, options,
2967 user_data, msg_data)
2968 * \endcode
2969 * Note: the \a user_data in Python function is an integer, and the
2970 * \a msg_data can be set to None if not required.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002971 */
2972PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
2973 const pj_str_t *dst_uri,
2974 unsigned options,
2975 void *user_data,
2976 const pjsua_msg_data *msg_data,
2977 pjsua_call_id *p_call_id);
2978
2979
2980/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002981 * Check if the specified call has active INVITE session and the INVITE
2982 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002983 *
2984 * @param call_id Call identification.
2985 *
2986 * @return Non-zero if call is active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002987 *
2988 * \par Python:
2989 * \code
2990 bool = py_pjsua.call_is_active(call_id)
2991 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002992 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002993PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002994
2995
2996/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002997 * Check if call has an active media session.
2998 *
2999 * @param call_id Call identification.
3000 *
3001 * @return Non-zero if yes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003002 *
3003 * \par Python:
3004 * \code
3005 bool = py_pjsua.call_has_media(call_id)
3006 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003007 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003008PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003009
3010
3011/**
Benny Prijonocf986c42008-09-02 11:25:07 +00003012 * Retrieve the media session associated with this call. Note that the media
3013 * session may not be available depending on the current call's media status
3014 * (the pjsua_call_media_status information in pjsua_call_info). Application
3015 * may use the media session to retrieve more detailed information about the
3016 * call's media.
3017 *
3018 * @param call_id Call identification.
3019 *
3020 * @return Call media session.
3021 */
3022PJ_DECL(pjmedia_session*) pjsua_call_get_media_session(pjsua_call_id call_id);
3023
3024
3025/**
3026 * Retrieve the media transport instance that is used for this call.
3027 * Application may use the media transport to query more detailed information
3028 * about the media transport.
3029 *
3030 * @param cid Call identification (the call_id).
3031 *
3032 * @return Call media transport.
3033 */
3034PJ_DECL(pjmedia_transport*) pjsua_call_get_media_transport(pjsua_call_id cid);
3035
3036
3037/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003038 * Get the conference port identification associated with the call.
3039 *
3040 * @param call_id Call identification.
3041 *
3042 * @return Conference port ID, or PJSUA_INVALID_ID when the
3043 * media has not been established or is not active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003044 *
3045 * \par Python:
3046 * \code
3047 slot = py_pjsua.call_get_conf_port(call_id)
3048 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003049 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003050PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
3051
3052/**
3053 * Obtain detail information about the specified call.
3054 *
3055 * @param call_id Call identification.
3056 * @param info Call info to be initialized.
3057 *
3058 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003059 *
3060 * \par Python:
3061 * \code
3062 call_info = py_pjsua.call_get_info(call_id)
3063 * \endcode
3064 * \a call_info return value will be set to None if call_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003065 */
3066PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003067 pjsua_call_info *info);
3068
3069
3070/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003071 * Attach application specific data to the call. Application can then
3072 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003073 *
3074 * @param call_id Call identification.
3075 * @param user_data Arbitrary data to be attached to the call.
3076 *
3077 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003078 *
3079 * \par Python:
3080 * \code
3081 status = py_pjsua.call_set_user_data(call_id, user_data)
3082 * \endcode
3083 * The \a user_data is an integer in the Python function.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003084 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003085PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
3086 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003087
3088
3089/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003090 * Get user data attached to the call, which has been previously set with
3091 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003092 *
3093 * @param call_id Call identification.
3094 *
3095 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003096 *
3097 * \par Python:
3098 * \code
3099 user_data = py_pjsua.call_get_user_data(call_id)
3100 * \endcode
3101 * The \a user_data is an integer.
Benny Prijono268ca612006-02-07 12:34:11 +00003102 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003103PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00003104
3105
3106/**
Benny Prijono91a6a172007-10-31 08:59:29 +00003107 * Get the NAT type of remote's endpoint. This is a proprietary feature
3108 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
3109 * is set in #pjsua_config.
3110 *
3111 * This function can only be called after SDP has been received from remote,
3112 * which means for incoming call, this function can be called as soon as
3113 * call is received as long as incoming call contains SDP, and for outgoing
3114 * call, this function can be called only after SDP is received (normally in
3115 * 200/OK response to INVITE). As a general case, application should call
3116 * this function after or in \a on_call_media_state() callback.
3117 *
3118 * @param call_id Call identification.
3119 * @param p_type Pointer to store the NAT type. Application can then
3120 * retrieve the string description of the NAT type
3121 * by calling pj_stun_get_nat_name().
3122 *
3123 * @return PJ_SUCCESS on success.
3124 *
3125 * @see pjsua_get_nat_type(), nat_type_in_sdp
3126 */
3127PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
3128 pj_stun_nat_type *p_type);
3129
3130/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003131 * Send response to incoming INVITE request. Depending on the status
3132 * code specified as parameter, this function may send provisional
3133 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003134 *
3135 * @param call_id Incoming call identification.
3136 * @param code Status code, (100-699).
3137 * @param reason Optional reason phrase. If NULL, default text
3138 * will be used.
3139 * @param msg_data Optional list of headers etc to be added to outgoing
3140 * response message.
3141 *
3142 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003143 *
3144 * \par Python:
3145 * \code
3146 status = py_pjsua.call_answer(call_id, code, reason, msg_data)
3147 * \endcode
3148 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijonoa91a0032006-02-26 21:23:45 +00003149 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003150PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
3151 unsigned code,
3152 const pj_str_t *reason,
3153 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00003154
3155/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003156 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00003157 * call state. This function is different than answering the call with
3158 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
3159 * will hangup the call regardless of the state and role of the call,
3160 * while #pjsua_call_answer() only works with incoming calls on EARLY
3161 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003162 *
3163 * @param call_id Call identification.
3164 * @param code Optional status code to be sent when we're rejecting
3165 * incoming call. If the value is zero, "603/Decline"
3166 * will be sent.
3167 * @param reason Optional reason phrase to be sent when we're rejecting
3168 * incoming call. If NULL, default text will be used.
3169 * @param msg_data Optional list of headers etc to be added to outgoing
3170 * request/response message.
3171 *
3172 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003173 *
3174 * \par Python:
3175 * \code
3176 status = py_pjsua.call_hangup(call_id, code, reason, msg_data)
3177 * \endcode
3178 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003179 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003180PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
3181 unsigned code,
3182 const pj_str_t *reason,
3183 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003184
Benny Prijono5e51a4e2008-11-27 00:06:46 +00003185/**
3186 * Accept or reject redirection response. Application MUST call this function
3187 * after it signaled PJSIP_REDIRECT_PENDING in the \a on_call_redirected()
3188 * callback, to notify the call whether to accept or reject the redirection
3189 * to the current target. Application can use the combination of
3190 * PJSIP_REDIRECT_PENDING command in \a on_call_redirected() callback and
3191 * this function to ask for user permission before redirecting the call.
3192 *
3193 * Note that if the application chooses to reject or stop redirection (by
3194 * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the
3195 * call disconnection callback will be called before this function returns.
3196 * And if the application rejects the target, the \a on_call_redirected()
3197 * callback may also be called before this function returns if there is
3198 * another target to try.
3199 *
3200 * @param call_id The call ID.
3201 * @param cmd Redirection operation to be applied to the current
3202 * target. The semantic of this argument is similar
3203 * to the description in the \a on_call_redirected()
3204 * callback, except that the PJSIP_REDIRECT_PENDING is
3205 * not accepted here.
3206 *
3207 * @return PJ_SUCCESS on successful operation.
3208 */
3209PJ_DECL(pj_status_t) pjsua_call_process_redirect(pjsua_call_id call_id,
3210 pjsip_redirect_op cmd);
Benny Prijono26ff9062006-02-21 23:47:00 +00003211
3212/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003213 * Put the specified call on hold. This will send re-INVITE with the
3214 * appropriate SDP to inform remote that the call is being put on hold.
3215 * The final status of the request itself will be reported on the
3216 * \a on_call_media_state() callback, which inform the application that
3217 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003218 *
3219 * @param call_id Call identification.
3220 * @param msg_data Optional message components to be sent with
3221 * the request.
3222 *
3223 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003224 *
3225 * \par Python:
3226 * \code
3227 status = py_pjsua.call_set_hold(call_id, msg_data)
3228 * \endcode
3229 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003230 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003231PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
3232 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003233
3234
3235/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003236 * Send re-INVITE to release hold.
3237 * The final status of the request itself will be reported on the
3238 * \a on_call_media_state() callback, which inform the application that
3239 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003240 *
3241 * @param call_id Call identification.
3242 * @param unhold If this argument is non-zero and the call is locally
3243 * held, this will release the local hold.
3244 * @param msg_data Optional message components to be sent with
3245 * the request.
3246 *
3247 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003248 *
3249 * \par Python:
3250 * \code
3251 status = py_pjsua.call_reinvite(call_id, unhold, msg_data)
3252 * \endcode
3253 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003254 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003255PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
3256 pj_bool_t unhold,
3257 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003258
Benny Prijonoc08682e2007-10-04 06:17:58 +00003259/**
3260 * Send UPDATE request.
3261 *
3262 * @param call_id Call identification.
3263 * @param options Must be zero for now.
3264 * @param msg_data Optional message components to be sent with
3265 * the request.
3266 *
3267 * @return PJ_SUCCESS on success, or the appropriate error code.
3268 */
3269PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
3270 unsigned options,
3271 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003272
3273/**
Benny Prijono053f5222006-11-11 16:16:04 +00003274 * Initiate call transfer to the specified address. This function will send
3275 * REFER request to instruct remote call party to initiate a new INVITE
3276 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003277 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00003278 * If application is interested to monitor the successfulness and
3279 * the progress of the transfer request, it can implement
3280 * \a on_call_transfer_status() callback which will report the progress
3281 * of the call transfer request.
3282 *
Benny Prijono053f5222006-11-11 16:16:04 +00003283 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003284 * @param dest Address of new target to be contacted.
3285 * @param msg_data Optional message components to be sent with
3286 * the request.
3287 *
3288 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003289 *
3290 * \par Python:
3291 * \code
3292 status = py_pjsua.call_xfer(call_id, dest, msg_data)
3293 * \endcode
3294 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003295 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003296PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
3297 const pj_str_t *dest,
3298 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003299
3300/**
Benny Prijono053f5222006-11-11 16:16:04 +00003301 * Flag to indicate that "Require: replaces" should not be put in the
3302 * outgoing INVITE request caused by REFER request created by
3303 * #pjsua_call_xfer_replaces().
3304 */
3305#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
3306
3307/**
3308 * Initiate attended call transfer. This function will send REFER request
3309 * to instruct remote call party to initiate new INVITE session to the URL
3310 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
3311 * the call with us with the new call from the REFER recipient.
3312 *
3313 * @param call_id The call id to be transfered.
3314 * @param dest_call_id The call id to be replaced.
3315 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
3316 * to suppress the inclusion of "Require: replaces" in
3317 * the outgoing INVITE request created by the REFER
3318 * request.
3319 * @param msg_data Optional message components to be sent with
3320 * the request.
3321 *
3322 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003323 *
3324 * \par Python:
3325 * \code
3326 status = py_pjsua.call_xfer_replaces(call_id, dest_call_id, options, msg_data)
3327 * \endcode
3328 * Argument \a msg_data may be set to None if not required.
Benny Prijono053f5222006-11-11 16:16:04 +00003329 */
3330PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
3331 pjsua_call_id dest_call_id,
3332 unsigned options,
3333 const pjsua_msg_data *msg_data);
3334
3335/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003336 * Send DTMF digits to remote using RFC 2833 payload formats.
3337 *
3338 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003339 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003340 *
3341 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003342 *
3343 * \par Python:
3344 * \code
3345 status = py_pjsua.call_dial_dtmf(call_id, digits)
3346 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003347 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003348PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003349 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00003350
Benny Prijono26ff9062006-02-21 23:47:00 +00003351/**
Benny Prijonob0808372006-03-02 21:18:58 +00003352 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003353 *
3354 * @param call_id Call identification.
3355 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3356 * assumed.
3357 * @param content The message content.
3358 * @param msg_data Optional list of headers etc to be included in outgoing
3359 * request. The body descriptor in the msg_data is
3360 * ignored.
3361 * @param user_data Optional user data, which will be given back when
3362 * the IM callback is called.
3363 *
3364 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003365 *
3366 * \par Python:
3367 * \code
3368 status = py_pjsua.call_send_im(call_id, mime_type, content, msg_data, user_data)
3369 * \endcode
3370 * Note that the \a user_data argument is an integer in Python.
Benny Prijonob0808372006-03-02 21:18:58 +00003371 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003372PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
3373 const pj_str_t *mime_type,
3374 const pj_str_t *content,
3375 const pjsua_msg_data *msg_data,
3376 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003377
3378
3379/**
3380 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003381 *
3382 * @param call_id Call identification.
3383 * @param is_typing Non-zero to indicate to remote that local person is
3384 * currently typing an IM.
3385 * @param msg_data Optional list of headers etc to be included in outgoing
3386 * request.
3387 *
3388 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003389 *
3390 * \par Python:
3391 * \code
3392 status = py_pjsua.call_send_typing_ind(call_id, is_typing, msg_data)
3393 * \endcode
3394 * Argument \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003395 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003396PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
3397 pj_bool_t is_typing,
3398 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003399
3400/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00003401 * Send arbitrary request with the call. This is useful for example to send
3402 * INFO request. Note that application should not use this function to send
3403 * requests which would change the invite session's state, such as re-INVITE,
3404 * UPDATE, PRACK, and BYE.
3405 *
3406 * @param call_id Call identification.
3407 * @param method SIP method of the request.
3408 * @param msg_data Optional message body and/or list of headers to be
3409 * included in outgoing request.
3410 *
3411 * @return PJ_SUCCESS on success, or the appropriate error code.
3412 */
3413PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
3414 const pj_str_t *method,
3415 const pjsua_msg_data *msg_data);
3416
3417
3418/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003419 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
3420 * currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003421 *
3422 * \par Python:
3423 * \code
3424 py_pjsua.call_hangup_all()
3425 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003426 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00003427PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00003428
3429
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003430/**
3431 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003432 *
3433 * @param call_id Call identification.
3434 * @param with_media Non-zero to include media information too.
3435 * @param buffer Buffer where the statistics are to be written to.
3436 * @param maxlen Maximum length of buffer.
3437 * @param indent Spaces for left indentation.
3438 *
3439 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003440 *
3441 * \par Python:
3442 * \code
3443 string = py_pjsua.call_dump(call_id, with_media, max_len, indent)
3444 * \endcode
3445 * The \a max_len argument is the desired maximum length to be allocated.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003446 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003447PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
3448 pj_bool_t with_media,
3449 char *buffer,
3450 unsigned maxlen,
3451 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003452
Benny Prijono9fc735d2006-05-28 14:58:12 +00003453/**
Benny Prijono312aff92006-06-17 04:08:30 +00003454 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003455 */
Benny Prijono834aee32006-02-19 01:38:06 +00003456
3457
3458/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00003459 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00003460 */
3461
Benny Prijono312aff92006-06-17 04:08:30 +00003462
3463/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003464 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00003465 * @ingroup PJSUA_LIB
3466 * @brief Buddy management, buddy's presence, and instant messaging.
3467 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00003468 *
3469 * This section describes PJSUA-APIs related to buddies management,
3470 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00003471 */
3472
3473/**
3474 * Max buddies in buddy list.
3475 */
3476#ifndef PJSUA_MAX_BUDDIES
3477# define PJSUA_MAX_BUDDIES 256
3478#endif
3479
3480
3481/**
Benny Prijonoa17496a2007-10-31 10:20:31 +00003482 * This specifies how long the library should retry resending SUBSCRIBE
3483 * if the previous SUBSCRIBE failed.
3484 *
3485 * Default: 300 seconds
3486 */
3487#ifndef PJSUA_PRES_TIMER
3488# define PJSUA_PRES_TIMER 300
3489#endif
3490
3491
3492/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003493 * This structure describes buddy configuration when adding a buddy to
3494 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
3495 * the structure with #pjsua_buddy_config_default() to initialize this
3496 * structure with default configuration.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003497 *
3498 * \par Python:
3499 * In Python this structure is <tt>py_pjsua.Buddy_Config</tt>. However
3500 * it is recommended that application instantiates the buddy config
3501 * by calling:
3502 * \code
3503 buddy_cfg = py_pjsua.buddy_config_default()
3504 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003505 */
3506typedef struct pjsua_buddy_config
3507{
3508 /**
3509 * Buddy URL or name address.
3510 */
3511 pj_str_t uri;
3512
3513 /**
3514 * Specify whether presence subscription should start immediately.
3515 */
3516 pj_bool_t subscribe;
3517
Benny Prijono705e7842008-07-21 18:12:51 +00003518 /**
3519 * Specify arbitrary application data to be associated with with
3520 * the buddy object.
3521 */
3522 void *user_data;
3523
Benny Prijono312aff92006-06-17 04:08:30 +00003524} pjsua_buddy_config;
3525
3526
3527/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003528 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003529 */
3530typedef enum pjsua_buddy_status
3531{
3532 /**
3533 * Online status is unknown (possibly because no presence subscription
3534 * has been established).
3535 */
3536 PJSUA_BUDDY_STATUS_UNKNOWN,
3537
3538 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003539 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003540 */
3541 PJSUA_BUDDY_STATUS_ONLINE,
3542
3543 /**
3544 * Buddy is offline.
3545 */
3546 PJSUA_BUDDY_STATUS_OFFLINE,
3547
3548} pjsua_buddy_status;
3549
3550
3551
3552/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003553 * This structure describes buddy info, which can be retrieved by calling
3554 * #pjsua_buddy_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003555 *
3556 * \par Python:
3557 * This structure in Python is <tt>py_pjsua.Buddy_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003558 */
3559typedef struct pjsua_buddy_info
3560{
3561 /**
3562 * The buddy ID.
3563 */
3564 pjsua_buddy_id id;
3565
3566 /**
3567 * The full URI of the buddy, as specified in the configuration.
3568 */
3569 pj_str_t uri;
3570
3571 /**
3572 * Buddy's Contact, only available when presence subscription has
3573 * been established to the buddy.
3574 */
3575 pj_str_t contact;
3576
3577 /**
3578 * Buddy's online status.
3579 */
3580 pjsua_buddy_status status;
3581
3582 /**
3583 * Text to describe buddy's online status.
3584 */
3585 pj_str_t status_text;
3586
3587 /**
3588 * Flag to indicate that we should monitor the presence information for
3589 * this buddy (normally yes, unless explicitly disabled).
3590 */
3591 pj_bool_t monitor_pres;
3592
3593 /**
Benny Prijono63fba012008-07-17 14:19:10 +00003594 * If \a monitor_pres is enabled, this specifies the last state of the
3595 * presence subscription. If presence subscription session is currently
3596 * active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence
3597 * subscription request has been rejected, the value will be
3598 * PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be
3599 * specified in \a sub_term_reason.
3600 */
3601 pjsip_evsub_state sub_state;
3602
3603 /**
3604 * Specifies the last presence subscription terminatino reason. If
3605 * presence subscription is currently active, the value will be empty.
3606 */
3607 pj_str_t sub_term_reason;
3608
3609 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003610 * Extended RPID information about the person.
3611 */
3612 pjrpid_element rpid;
3613
3614 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003615 * Internal buffer.
3616 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003617 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003618
3619} pjsua_buddy_info;
3620
3621
Benny Prijono834aee32006-02-19 01:38:06 +00003622/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003623 * Set default values to the buddy config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003624 *
3625 * \par Python:
3626 * \code
3627 buddy_cfg = py_pjsua.buddy_config_default()
3628 * \endcode
Benny Prijonob5388cf2007-01-04 22:45:08 +00003629 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003630PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003631
3632
3633/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003634 * Get total number of buddies.
3635 *
3636 * @return Number of buddies.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003637 *
3638 * \par Python:
3639 * \code
3640 buddy_count = py_pjsua.get_buddy_count()
3641 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003642 */
3643PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3644
3645
3646/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003647 * Check if buddy ID is valid.
3648 *
3649 * @param buddy_id Buddy ID to check.
3650 *
3651 * @return Non-zero if buddy ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003652 *
3653 * \par Python:
3654 * \code
3655 is_valid = py_pjsua.buddy_is_valid(buddy_id)
3656 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003657 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003658PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3659
3660
3661/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003662 * Enumerate all buddy IDs in the buddy list. Application then can use
3663 * #pjsua_buddy_get_info() to get the detail information for each buddy
3664 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003665 *
3666 * @param ids Array of ids to be initialized.
3667 * @param count On input, specifies max elements in the array.
3668 * On return, it contains actual number of elements
3669 * that have been initialized.
3670 *
3671 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003672 *
3673 * \par Python:
3674 * The Python function takes no argument and returns list of buddy IDs:
3675 * \code
3676 [buddy_ids] = py_pjsua.enum_buddies()
3677 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003678 */
3679PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3680 unsigned *count);
3681
3682/**
Benny Prijono705e7842008-07-21 18:12:51 +00003683 * Find the buddy ID with the specified URI.
3684 *
3685 * @param uri The buddy URI.
3686 *
3687 * @return The buddy ID, or PJSUA_INVALID_ID if not found.
3688 */
3689PJ_DECL(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri);
3690
3691
3692/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003693 * Get detailed buddy info.
3694 *
3695 * @param buddy_id The buddy identification.
3696 * @param info Pointer to receive information about buddy.
3697 *
3698 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003699 *
3700 * \par Python:
3701 * \code
3702 buddy_info = py_pjsua.buddy_get_info(buddy_id)
3703 * \endcode
3704 * The function returns None if buddy_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003705 */
3706PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003707 pjsua_buddy_info *info);
3708
3709/**
Benny Prijono705e7842008-07-21 18:12:51 +00003710 * Set the user data associated with the buddy object.
3711 *
3712 * @param buddy_id The buddy identification.
3713 * @param user_data Arbitrary application data to be associated with
3714 * the buddy object.
3715 *
3716 * @return PJ_SUCCESS on success, or the appropriate error code.
3717 */
3718PJ_DECL(pj_status_t) pjsua_buddy_set_user_data(pjsua_buddy_id buddy_id,
3719 void *user_data);
3720
3721
3722/**
3723 * Get the user data associated with the budy object.
3724 *
3725 * @param buddy_id The buddy identification.
3726 *
3727 * @return The application data.
3728 */
3729PJ_DECL(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id);
3730
3731
3732/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003733 * Add new buddy to the buddy list. If presence subscription is enabled
3734 * for this buddy, this function will also start the presence subscription
3735 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003736 *
Benny Prijonoa7b376b2008-01-25 16:06:33 +00003737 * @param buddy_cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003738 * @param p_buddy_id Pointer to receive buddy ID.
3739 *
3740 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003741 *
3742 * \par Python:
3743 * The function returns (status, buddy_id) tuple:
3744 * \code
3745 status, buddy_id = py_pjsua.buddy_add(buddy_cfg)
3746 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003747 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003748PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003749 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003750
3751
3752/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003753 * Delete the specified buddy from the buddy list. Any presence subscription
3754 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003755 *
3756 * @param buddy_id Buddy identification.
3757 *
3758 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003759 *
3760 * \par Python:
3761 * \code
3762 status = py_pjsua.buddy_del(buddy_id)
3763 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +00003764 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003765PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003766
3767
3768/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003769 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3770 * subscribed, application will be informed about buddy's presence status
3771 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003772 *
3773 * @param buddy_id Buddy identification.
3774 * @param subscribe Specify non-zero to activate presence subscription to
3775 * the specified buddy.
3776 *
3777 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003778 *
3779 * \par Python:
3780 * \code
3781 status = py_pjsua.buddy_subscribe_pres(buddy_id, subscribe)
3782 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003783 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003784PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3785 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003786
3787
3788/**
Benny Prijono10861432007-10-31 10:54:53 +00003789 * Update the presence information for the buddy. Although the library
3790 * periodically refreshes the presence subscription for all buddies, some
3791 * application may want to refresh the buddy's presence subscription
3792 * immediately, and in this case it can use this function to accomplish
3793 * this.
3794 *
3795 * Note that the buddy's presence subscription will only be initiated
3796 * if presence monitoring is enabled for the buddy. See
3797 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
3798 * for the buddy is already active, this function will not do anything.
3799 *
3800 * Once the presence subscription is activated successfully for the buddy,
3801 * application will be notified about the buddy's presence status in the
3802 * on_buddy_state() callback.
3803 *
3804 * @param buddy_id Buddy identification.
3805 *
3806 * @return PJ_SUCCESS on success, or the appropriate error code.
3807 */
3808PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
3809
3810
3811/**
Benny Prijono63fba012008-07-17 14:19:10 +00003812 * Send NOTIFY to inform account presence status or to terminate server
3813 * side presence subscription. If application wants to reject the incoming
3814 * request, it should set the \a state to PJSIP_EVSUB_STATE_TERMINATED.
3815 *
3816 * @param acc_id Account ID.
3817 * @param srv_pres Server presence subscription instance.
3818 * @param state New state to set.
3819 * @param state_str Optionally specify the state string name, if state
3820 * is not "active", "pending", or "terminated".
3821 * @param reason If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3822 * optionally specify the termination reason.
3823 * @param with_body If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3824 * this specifies whether the NOTIFY request should
3825 * contain message body containing account's presence
3826 * information.
3827 * @param msg_data Optional list of headers to be sent with the NOTIFY
3828 * request.
3829 *
3830 * @return PJ_SUCCESS on success.
3831 */
3832PJ_DECL(pj_status_t) pjsua_pres_notify(pjsua_acc_id acc_id,
3833 pjsua_srv_pres *srv_pres,
3834 pjsip_evsub_state state,
3835 const pj_str_t *state_str,
3836 const pj_str_t *reason,
3837 pj_bool_t with_body,
3838 const pjsua_msg_data *msg_data);
3839
3840/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003841 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003842 *
3843 * @param verbose Yes or no.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003844 *
3845 * \par Python:
3846 * \code
3847 py_pjsua.pres_dump()
3848 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003849 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003850PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003851
3852
Benny Prijonob0808372006-03-02 21:18:58 +00003853/**
3854 * The MESSAGE method (defined in pjsua_im.c)
3855 */
3856extern const pjsip_method pjsip_message_method;
3857
3858
Benny Prijonob0808372006-03-02 21:18:58 +00003859
3860/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003861 * Send instant messaging outside dialog, using the specified account for
3862 * route set and authentication.
3863 *
3864 * @param acc_id Account ID to be used to send the request.
3865 * @param to Remote URI.
3866 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3867 * assumed.
3868 * @param content The message content.
3869 * @param msg_data Optional list of headers etc to be included in outgoing
3870 * request. The body descriptor in the msg_data is
3871 * ignored.
3872 * @param user_data Optional user data, which will be given back when
3873 * the IM callback is called.
3874 *
3875 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003876 *
3877 * \par Python:
3878 * \code
3879 status = py_pjsua.im_send(acc_id, to, mime_type, content, msg_data, user_data)
3880 * \endcode
3881 * Arguments \a mime_type and \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003882 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003883PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3884 const pj_str_t *to,
3885 const pj_str_t *mime_type,
3886 const pj_str_t *content,
3887 const pjsua_msg_data *msg_data,
3888 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003889
3890
3891/**
3892 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003893 *
3894 * @param acc_id Account ID to be used to send the request.
3895 * @param to Remote URI.
3896 * @param is_typing If non-zero, it tells remote person that local person
3897 * is currently composing an IM.
3898 * @param msg_data Optional list of headers etc to be added to outgoing
3899 * request.
3900 *
3901 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003902 *
3903 * \par Python:
3904 * \code
3905 status = py_pjsua.im_typing(acc_id, to, is_typing, msg_data)
3906 * \endcode
3907 * Argument \a msg_data may be set to None if not requried.
Benny Prijonob0808372006-03-02 21:18:58 +00003908 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003909PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3910 const pj_str_t *to,
3911 pj_bool_t is_typing,
3912 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003913
3914
Benny Prijonof3195072006-02-14 21:15:30 +00003915
Benny Prijono312aff92006-06-17 04:08:30 +00003916/**
3917 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003918 */
3919
Benny Prijono312aff92006-06-17 04:08:30 +00003920
3921/*****************************************************************************
3922 * MEDIA API
3923 */
3924
3925
3926/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003927 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003928 * @ingroup PJSUA_LIB
3929 * @brief Media manipulation.
3930 * @{
3931 *
3932 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003933 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3934 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003935 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003936 * the interconnection between these terminations freely.
3937 *
3938 * The conference bridge provides powerful switching and mixing functionality
3939 * for application. With the conference bridge, each conference slot (e.g.
3940 * a call) can transmit to multiple destinations, and one destination can
3941 * receive from multiple sources. If more than one media terminations are
3942 * terminated in the same slot, the conference bridge will mix the signal
3943 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00003944 *
3945 * Application connects one media termination/slot to another by calling
3946 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003947 * media flow from the source termination to the sink termination. To
3948 * establish bidirectional media flow, application wound need to make another
3949 * call to #pjsua_conf_connect(), this time inverting the source and
3950 * destination slots in the parameter.
3951 *
3952 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00003953 * the following steps:
3954 *
3955 \code
3956
3957 pj_status_t stream_to_call( pjsua_call_id call_id )
3958 {
3959 pjsua_player_id player_id;
3960
3961 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
3962 if (status != PJ_SUCCESS)
3963 return status;
3964
3965 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
3966 pjsua_call_get_conf_port() );
3967 }
3968 \endcode
3969 *
3970 *
3971 * Other features of PJSUA media:
3972 * - efficient N to M interconnections between media terminations.
3973 * - media termination can be connected to itself to create loopback
3974 * media.
3975 * - the media termination may have different clock rates, and resampling
3976 * will be done automatically by conference bridge.
3977 * - media terminations may also have different frame time; the
3978 * conference bridge will perform the necessary bufferring to adjust
3979 * the difference between terminations.
3980 * - interconnections are removed automatically when media termination
3981 * is removed from the bridge.
3982 * - sound device may be changed even when there are active media
3983 * interconnections.
3984 * - correctly report call's media quality (in #pjsua_call_dump()) from
3985 * RTCP packet exchange.
3986 */
3987
3988/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003989 * Max ports in the conference bridge. This setting is the default value
3990 * for pjsua_media_config.max_media_ports.
Benny Prijono312aff92006-06-17 04:08:30 +00003991 */
3992#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00003993# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00003994#endif
3995
Benny Prijonob5388cf2007-01-04 22:45:08 +00003996/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003997 * The default clock rate to be used by the conference bridge. This setting
3998 * is the default value for pjsua_media_config.clock_rate.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003999 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004000#ifndef PJSUA_DEFAULT_CLOCK_RATE
4001# define PJSUA_DEFAULT_CLOCK_RATE 16000
4002#endif
4003
Benny Prijonob5388cf2007-01-04 22:45:08 +00004004/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004005 * Default frame length in the conference bridge. This setting
4006 * is the default value for pjsua_media_config.audio_frame_ptime.
4007 */
4008#ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Nanang Izzuddinaf974842008-05-08 09:51:16 +00004009# define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
Benny Prijono37c710b2008-01-10 12:09:26 +00004010#endif
4011
4012
4013/**
4014 * Default codec quality settings. This setting is the default value
4015 * for pjsua_media_config.quality.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004016 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004017#ifndef PJSUA_DEFAULT_CODEC_QUALITY
Nanang Izzuddin9dbad152008-06-10 18:56:10 +00004018# define PJSUA_DEFAULT_CODEC_QUALITY 8
Benny Prijono12a669c2006-11-23 07:32:13 +00004019#endif
4020
Benny Prijonob5388cf2007-01-04 22:45:08 +00004021/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004022 * Default iLBC mode. This setting is the default value for
4023 * pjsua_media_config.ilbc_mode.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004024 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004025#ifndef PJSUA_DEFAULT_ILBC_MODE
Benny Prijono37c710b2008-01-10 12:09:26 +00004026# define PJSUA_DEFAULT_ILBC_MODE 30
Benny Prijono12a669c2006-11-23 07:32:13 +00004027#endif
4028
Benny Prijonob5388cf2007-01-04 22:45:08 +00004029/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004030 * The default echo canceller tail length. This setting
4031 * is the default value for pjsua_media_config.ec_tail_len.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004032 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004033#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijono427439c2007-10-21 09:41:24 +00004034# define PJSUA_DEFAULT_EC_TAIL_LEN 200
Benny Prijono12a669c2006-11-23 07:32:13 +00004035#endif
Benny Prijono312aff92006-06-17 04:08:30 +00004036
4037
4038/**
Benny Prijonocba59d92007-02-16 09:22:56 +00004039 * The maximum file player.
4040 */
4041#ifndef PJSUA_MAX_PLAYERS
4042# define PJSUA_MAX_PLAYERS 32
4043#endif
4044
4045
4046/**
4047 * The maximum file player.
4048 */
4049#ifndef PJSUA_MAX_RECORDERS
4050# define PJSUA_MAX_RECORDERS 32
4051#endif
4052
4053
4054/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004055 * This structure describes media configuration, which will be specified
4056 * when calling #pjsua_init(). Application MUST initialize this structure
4057 * by calling #pjsua_media_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00004058 *
4059 * \par Python:
4060 * This data type in Python is <tt>py_pjsua.Media_Config</tt>. To create
4061 * an object of this type, it is recommended to call
4062 * <tt>py_pjsua.media_config_default()</tt> function instead:
4063 * \code
4064 media_cfg = py_pjsua.media_config_default()
4065 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00004066 */
4067struct pjsua_media_config
4068{
4069 /**
4070 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004071 * If value is zero, default clock rate will be used
4072 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00004073 */
4074 unsigned clock_rate;
4075
4076 /**
Benny Prijonof3758ee2008-02-26 15:32:16 +00004077 * Clock rate to be applied when opening the sound device.
4078 * If value is zero, conference bridge clock rate will be used.
4079 */
4080 unsigned snd_clock_rate;
4081
4082 /**
Benny Prijono7d60d052008-03-29 12:24:20 +00004083 * Channel count be applied when opening the sound device and
4084 * conference bridge.
4085 */
4086 unsigned channel_count;
4087
4088 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004089 * Specify audio frame ptime. The value here will affect the
4090 * samples per frame of both the sound device and the conference
4091 * bridge. Specifying lower ptime will normally reduce the
4092 * latency.
4093 *
Benny Prijono37c710b2008-01-10 12:09:26 +00004094 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004095 */
4096 unsigned audio_frame_ptime;
4097
4098 /**
Benny Prijono312aff92006-06-17 04:08:30 +00004099 * Specify maximum number of media ports to be created in the
4100 * conference bridge. Since all media terminate in the bridge
4101 * (calls, file player, file recorder, etc), the value must be
4102 * large enough to support all of them. However, the larger
4103 * the value, the more computations are performed.
Benny Prijono37c710b2008-01-10 12:09:26 +00004104 *
4105 * Default value: PJSUA_MAX_CONF_PORTS
Benny Prijono312aff92006-06-17 04:08:30 +00004106 */
4107 unsigned max_media_ports;
4108
4109 /**
4110 * Specify whether the media manager should manage its own
4111 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
4112 * and at least one worker thread will be created too. If no,
4113 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
4114 * and no worker thread is needed.
4115 *
4116 * Normally application would say yes here, unless it wants to
4117 * run everything from a single thread.
4118 */
4119 pj_bool_t has_ioqueue;
4120
4121 /**
4122 * Specify the number of worker threads to handle incoming RTP
4123 * packets. A value of one is recommended for most applications.
4124 */
4125 unsigned thread_cnt;
4126
Benny Prijono0498d902006-06-19 14:49:14 +00004127 /**
4128 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00004129 * 5-10: resampling use large filter,
4130 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00004131 * 1-2: resampling use linear.
4132 * The media quality also sets speex codec quality/complexity to the
4133 * number.
4134 *
Benny Prijono70972992006-08-05 11:13:58 +00004135 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00004136 */
4137 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00004138
4139 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004140 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00004141 *
4142 * Default: 0 (codec specific)
4143 */
4144 unsigned ptime;
4145
4146 /**
4147 * Disable VAD?
4148 *
4149 * Default: 0 (no (meaning VAD is enabled))
4150 */
4151 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00004152
4153 /**
4154 * iLBC mode (20 or 30).
4155 *
Benny Prijono37c710b2008-01-10 12:09:26 +00004156 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00004157 */
4158 unsigned ilbc_mode;
4159
4160 /**
4161 * Percentage of RTP packet to drop in TX direction
4162 * (to simulate packet lost).
4163 *
4164 * Default: 0
4165 */
4166 unsigned tx_drop_pct;
4167
4168 /**
4169 * Percentage of RTP packet to drop in RX direction
4170 * (to simulate packet lost).
4171 *
4172 * Default: 0
4173 */
4174 unsigned rx_drop_pct;
4175
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004176 /**
Benny Prijono5da50432006-08-07 10:24:52 +00004177 * Echo canceller options (see #pjmedia_echo_create())
4178 *
4179 * Default: 0.
4180 */
4181 unsigned ec_options;
4182
4183 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004184 * Echo canceller tail length, in miliseconds.
4185 *
Benny Prijono669643c2006-09-20 20:02:18 +00004186 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004187 */
4188 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004189
4190 /**
4191 * Jitter buffer initial prefetch delay in msec. The value must be
4192 * between jb_min_pre and jb_max_pre below.
4193 *
4194 * Default: -1 (to use default stream settings, currently 150 msec)
4195 */
4196 int jb_init;
4197
4198 /**
4199 * Jitter buffer minimum prefetch delay in msec.
4200 *
4201 * Default: -1 (to use default stream settings, currently 60 msec)
4202 */
4203 int jb_min_pre;
4204
4205 /**
4206 * Jitter buffer maximum prefetch delay in msec.
4207 *
4208 * Default: -1 (to use default stream settings, currently 240 msec)
4209 */
4210 int jb_max_pre;
4211
4212 /**
4213 * Set maximum delay that can be accomodated by the jitter buffer msec.
4214 *
4215 * Default: -1 (to use default stream settings, currently 360 msec)
4216 */
4217 int jb_max;
4218
Benny Prijonoc97608e2007-03-23 16:34:20 +00004219 /**
4220 * Enable ICE
4221 */
4222 pj_bool_t enable_ice;
4223
4224 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00004225 * Disable ICE host candidates.
Benny Prijonoc97608e2007-03-23 16:34:20 +00004226 */
Benny Prijonof76e1392008-06-06 14:51:48 +00004227 pj_bool_t ice_no_host_cands;
4228
4229 /**
Benny Prijono551af422008-08-07 09:55:52 +00004230 * Disable RTCP component.
4231 *
4232 * Default: no
4233 */
4234 pj_bool_t ice_no_rtcp;
4235
4236 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00004237 * Enable TURN relay candidate in ICE.
4238 */
4239 pj_bool_t enable_turn;
4240
4241 /**
4242 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
4243 * "HOST:PORT" format.
4244 */
4245 pj_str_t turn_server;
4246
4247 /**
4248 * Specify the connection type to be used to the TURN server. Valid
4249 * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP.
4250 *
4251 * Default: PJ_TURN_TP_UDP
4252 */
4253 pj_turn_tp_type turn_conn_type;
4254
4255 /**
4256 * Specify the credential to authenticate with the TURN server.
4257 */
4258 pj_stun_auth_cred turn_auth_cred;
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004259
4260 /**
4261 * Specify idle time of sound device before it is automatically closed,
4262 * in seconds.
4263 *
4264 * Default : -1 (Disable the auto-close feature of sound device)
4265 */
4266 int snd_auto_close_time;
Benny Prijono312aff92006-06-17 04:08:30 +00004267};
4268
4269
4270/**
4271 * Use this function to initialize media config.
4272 *
4273 * @param cfg The media config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004274 *
4275 * \par Python:
4276 * \code
4277 media_cfg = py_pjsua.media_config_default()
4278 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00004279 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00004280PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00004281
4282
4283/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004284 * This structure describes codec information, which can be retrieved by
4285 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00004286 */
4287typedef struct pjsua_codec_info
4288{
4289 /**
4290 * Codec unique identification.
4291 */
4292 pj_str_t codec_id;
4293
4294 /**
4295 * Codec priority (integer 0-255).
4296 */
4297 pj_uint8_t priority;
4298
4299 /**
4300 * Internal buffer.
4301 */
4302 char buf_[32];
4303
4304} pjsua_codec_info;
4305
4306
4307/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004308 * This structure descibes information about a particular media port that
4309 * has been registered into the conference bridge. Application can query
4310 * this info by calling #pjsua_conf_get_port_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00004311 *
4312 * \par Python:
4313 * In Python, this type is <tt>py_pjsua.Conf_Port_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00004314 */
4315typedef struct pjsua_conf_port_info
4316{
4317 /** Conference port number. */
4318 pjsua_conf_port_id slot_id;
4319
4320 /** Port name. */
4321 pj_str_t name;
4322
4323 /** Clock rate. */
4324 unsigned clock_rate;
4325
4326 /** Number of channels. */
4327 unsigned channel_count;
4328
4329 /** Samples per frame */
4330 unsigned samples_per_frame;
4331
4332 /** Bits per sample */
4333 unsigned bits_per_sample;
4334
4335 /** Number of listeners in the array. */
4336 unsigned listener_cnt;
4337
4338 /** Array of listeners (in other words, ports where this port is
4339 * transmitting to.
4340 */
4341 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
4342
4343} pjsua_conf_port_info;
4344
4345
4346/**
4347 * This structure holds information about custom media transport to
4348 * be registered to pjsua.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004349 *
4350 * \par Python:
4351 * Not applicable.
Benny Prijono312aff92006-06-17 04:08:30 +00004352 */
4353typedef struct pjsua_media_transport
4354{
4355 /**
4356 * Media socket information containing the address information
4357 * of the RTP and RTCP socket.
4358 */
4359 pjmedia_sock_info skinfo;
4360
4361 /**
4362 * The media transport instance.
4363 */
4364 pjmedia_transport *transport;
4365
4366} pjsua_media_transport;
4367
4368
4369
4370
Benny Prijono9fc735d2006-05-28 14:58:12 +00004371/**
4372 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004373 *
4374 * @return Maximum number of ports in the conference bridge.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004375 *
4376 * \par Python:
4377 * \code
4378 port_count = py_pjsua.conf_get_max_ports()
4379 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004380 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004381PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004382
4383
4384/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004385 * Get current number of active ports in the bridge.
4386 *
4387 * @return The number.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004388 *
4389 * \par Python:
4390 * \code
4391 count = py_pjsua.conf_get_active_ports()
4392 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004393 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004394PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
4395
4396
4397/**
4398 * Enumerate all conference ports.
4399 *
4400 * @param id Array of conference port ID to be initialized.
4401 * @param count On input, specifies max elements in the array.
4402 * On return, it contains actual number of elements
4403 * that have been initialized.
4404 *
4405 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004406 *
4407 * \par Python:
4408 * The Python functions returns list of conference port Ids:
4409 * \code
4410 [port_ids] = py_pjsua.enum_conf_ports()
4411 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004412 */
4413PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
4414 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004415
4416
4417/**
4418 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004419 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004420 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004421 * @param info Pointer to store the port info.
4422 *
4423 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004424 *
4425 * \par Python:
4426 * \code
4427 port_info = py_pjsua.conf_get_port_info(port_id)
4428 * \endcode
4429 * The function will return None if \a port_id is not valid.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004430 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004431PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00004432 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004433
4434
4435/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00004436 * Add arbitrary media port to PJSUA's conference bridge. Application
4437 * can use this function to add the media port that it creates. For
4438 * media ports that are created by PJSUA-LIB (such as calls, file player,
4439 * or file recorder), PJSUA-LIB will automatically add the port to
4440 * the bridge.
4441 *
4442 * @param pool Pool to use.
4443 * @param port Media port to be added to the bridge.
4444 * @param p_id Optional pointer to receive the conference
4445 * slot id.
4446 *
4447 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004448 *
4449 * \par Python:
4450 * Not applicable (for now)
Benny Prijonoe909eac2006-07-27 22:04:56 +00004451 */
4452PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
4453 pjmedia_port *port,
4454 pjsua_conf_port_id *p_id);
4455
4456
4457/**
4458 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00004459 * call this function if it registered the port manually with previous call
4460 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00004461 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004462 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00004463 *
4464 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004465 *
4466 * \par Python:
4467 * \code
4468 status = py_pjsua.conf_remove_port(port_id)
4469 * \endcode
Benny Prijonoe909eac2006-07-27 22:04:56 +00004470 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004471PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00004472
4473
4474/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004475 * Establish unidirectional media flow from souce to sink. One source
4476 * may transmit to multiple destinations/sink. And if multiple
4477 * sources are transmitting to the same sink, the media will be mixed
4478 * together. Source and sink may refer to the same ID, effectively
4479 * looping the media.
4480 *
4481 * If bidirectional media flow is desired, application needs to call
4482 * this function twice, with the second one having the arguments
4483 * reversed.
4484 *
4485 * @param source Port ID of the source media/transmitter.
4486 * @param sink Port ID of the destination media/received.
4487 *
4488 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004489 *
4490 * \par Python:
4491 * \code
4492 status = py_pjsua.conf_connect(source, sink)
4493 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004494 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004495PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
4496 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004497
4498
4499/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004500 * Disconnect media flow from the source to destination port.
4501 *
4502 * @param source Port ID of the source media/transmitter.
4503 * @param sink Port ID of the destination media/received.
4504 *
4505 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004506 *
4507 * \par Python:
4508 * \code
4509 status = py_pjsua.conf_disconnect(source, sink)
4510 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004511 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004512PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
4513 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004514
4515
Benny Prijono6dd967c2006-12-26 02:27:14 +00004516/**
4517 * Adjust the signal level to be transmitted from the bridge to the
4518 * specified port by making it louder or quieter.
4519 *
4520 * @param slot The conference bridge slot number.
4521 * @param level Signal level adjustment. Value 1.0 means no level
4522 * adjustment, while value 0 means to mute the port.
4523 *
4524 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004525 *
4526 * \par Python:
4527 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004528 */
4529PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
4530 float level);
4531
4532/**
4533 * Adjust the signal level to be received from the specified port (to
4534 * the bridge) by making it louder or quieter.
4535 *
4536 * @param slot The conference bridge slot number.
4537 * @param level Signal level adjustment. Value 1.0 means no level
4538 * adjustment, while value 0 means to mute the port.
4539 *
4540 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004541 *
4542 * \par Python:
4543 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004544 */
4545PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
4546 float level);
4547
4548/**
4549 * Get last signal level transmitted to or received from the specified port.
4550 * The signal level is an integer value in zero to 255, with zero indicates
4551 * no signal, and 255 indicates the loudest signal level.
4552 *
4553 * @param slot The conference bridge slot number.
4554 * @param tx_level Optional argument to receive the level of signal
4555 * transmitted to the specified port (i.e. the direction
4556 * is from the bridge to the port).
4557 * @param rx_level Optional argument to receive the level of signal
4558 * received from the port (i.e. the direction is from the
4559 * port to the bridge).
4560 *
4561 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004562 *
4563 * \par Python:
4564 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004565 */
4566PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
4567 unsigned *tx_level,
4568 unsigned *rx_level);
4569
Benny Prijono6dd967c2006-12-26 02:27:14 +00004570
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004571/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00004572 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004573 */
4574
Benny Prijono9fc735d2006-05-28 14:58:12 +00004575/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004576 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004577 * the conference bridge.
4578 *
4579 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00004580 * WAV files are supported, and the WAV file MUST be
4581 * formatted as 16bit PCM mono/single channel (any
4582 * clock rate is supported).
Benny Prijono58add7c2008-01-18 13:24:07 +00004583 * @param options Optional option flag. Application may specify
4584 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004585 * @param p_id Pointer to receive player ID.
4586 *
4587 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004588 *
4589 * \par Python:
4590 * The function returns (status, id) tuple:
4591 * \code
4592 status, id = py_pjsua.player_create(filename, options)
4593 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004594 */
4595PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004596 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004597 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004598
4599
4600/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004601 * Create a file playlist media port, and automatically add the port
4602 * to the conference bridge.
4603 *
4604 * @param file_names Array of file names to be added to the play list.
4605 * Note that the files must have the same clock rate,
4606 * number of channels, and number of bits per sample.
4607 * @param file_count Number of files in the array.
4608 * @param label Optional label to be set for the media port.
4609 * @param options Optional option flag. Application may specify
4610 * PJMEDIA_FILE_NO_LOOP to prevent looping.
4611 * @param p_id Optional pointer to receive player ID.
4612 *
4613 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004614 *
4615 * \par Python:
4616 * Not implemented yet.
Benny Prijonoa66c3312007-01-21 23:12:40 +00004617 */
4618PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
4619 unsigned file_count,
4620 const pj_str_t *label,
4621 unsigned options,
4622 pjsua_player_id *p_id);
4623
4624/**
4625 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004626 *
4627 * @param id The file player ID.
4628 *
4629 * @return Conference port ID associated with this player.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004630 *
4631 * \par Python:
4632 * \code
4633 port_id = py_pjsua.player_get_conf_port(id)
4634 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004635 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004636PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004637
4638
4639/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004640 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00004641 *
4642 * @param id The player ID.
4643 * @param p_port The media port associated with the player.
4644 *
4645 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004646 *
4647 * \par Python:
4648 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004649 */
Benny Prijono58add7c2008-01-18 13:24:07 +00004650PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
Benny Prijono469b1522006-12-26 03:05:17 +00004651 pjmedia_port **p_port);
4652
4653/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004654 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004655 *
4656 * @param id The file player ID.
4657 * @param samples The playback position, in samples. Application can
4658 * specify zero to re-start the playback.
4659 *
4660 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004661 *
4662 * \par Python:
4663 * \code
4664 status = py_pjsua.player_set_pos(id, samples)
4665 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004666 */
4667PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
4668 pj_uint32_t samples);
4669
4670
4671/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004672 * Close the file of playlist, remove the player from the bridge, and free
4673 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004674 *
4675 * @param id The file player ID.
4676 *
4677 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004678 *
4679 * \par Python:
4680 * \code
4681 status = py_pjsua.player_destroy(id)
4682 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004683 */
4684PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
4685
4686
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004687/*****************************************************************************
4688 * File recorder.
4689 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00004690
4691/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004692 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004693 * the conference bridge. The recorder currently supports recording WAV file.
4694 * The type of the recorder to use is determined by the extension of the file
4695 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004696 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00004697 * @param filename Output file name. The function will determine the
4698 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004699 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00004700 * @param enc_type Optionally specify the type of encoder to be used to
4701 * compress the media, if the file can support different
4702 * encodings. This value must be zero for now.
4703 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004704 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00004705 * For .WAV recorder, this value must be NULL.
4706 * @param max_size Maximum file size. Specify zero or -1 to remove size
4707 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004708 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004709 * @param p_id Pointer to receive the recorder instance.
4710 *
4711 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004712 *
4713 * \par Python:
4714 * \code
4715 status, id = py_pjsua.recorder_create(filename, enc_type, enc_param, max_size, options)
4716 * \endcode
4717 * The \a enc_param is a string in Python.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004718 */
4719PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004720 unsigned enc_type,
4721 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004722 pj_ssize_t max_size,
4723 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004724 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004725
4726
4727/**
4728 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004729 *
4730 * @param id The recorder ID.
4731 *
4732 * @return Conference port ID associated with this recorder.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004733 *
4734 * \par Python:
4735 * \code
4736 port_id = py_pjsua.recorder_get_conf_port(id)
4737 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004738 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004739PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004740
4741
4742/**
Benny Prijono469b1522006-12-26 03:05:17 +00004743 * Get the media port for the recorder.
4744 *
4745 * @param id The recorder ID.
4746 * @param p_port The media port associated with the recorder.
4747 *
4748 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004749 *
4750 * \par Python:
4751 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004752 */
4753PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4754 pjmedia_port **p_port);
4755
4756
4757/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004758 * Destroy recorder (this will complete recording).
4759 *
4760 * @param id The recorder ID.
4761 *
4762 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004763 *
4764 * \par Python:
4765 * \code
4766 status = py_pjsua.recorder_destroy(id)
4767 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004768 */
4769PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4770
4771
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004772/*****************************************************************************
4773 * Sound devices.
4774 */
4775
Benny Prijono9fc735d2006-05-28 14:58:12 +00004776/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004777 * Enum all sound devices installed in the system.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004778 *
4779 * @param info Array of info to be initialized.
4780 * @param count On input, specifies max elements in the array.
4781 * On return, it contains actual number of elements
4782 * that have been initialized.
4783 *
4784 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004785 *
4786 *
4787 * \par Python:
4788 * The function returns list of sound device info:
4789 * \code
4790 [dev_infos] = py_pjsua.enum_snd_devs()
4791 * \endcode
4792 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00004793 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004794PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4795 unsigned *count);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004796
4797
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004798
4799/**
4800 * Get currently active sound devices. If sound devices has not been created
4801 * (for example when pjsua_start() is not called), it is possible that
4802 * the function returns PJ_SUCCESS with -1 as device IDs.
4803 *
4804 * @param capture_dev On return it will be filled with device ID of the
4805 * capture device.
4806 * @param playback_dev On return it will be filled with device ID of the
4807 * device ID of the playback device.
4808 *
4809 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004810 *
4811 * \par Python:
Benny Prijonoebdf8772007-02-01 19:25:50 +00004812 * The function takes no argument and return an (integer,integer) tuple:
Benny Prijonoe6ead542007-01-31 20:53:31 +00004813 * \code
4814 capture_dev, playback_dev = py_pjsua.get_snd_dev()
4815 * \endcode
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004816 */
4817PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4818 int *playback_dev);
4819
4820
Benny Prijono9fc735d2006-05-28 14:58:12 +00004821/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004822 * Select or change sound device. Application may call this function at
4823 * any time to replace current sound device.
4824 *
4825 * @param capture_dev Device ID of the capture device.
4826 * @param playback_dev Device ID of the playback device.
4827 *
4828 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004829 *
4830 * \par Python:
4831 * \code
4832 status = py_pjsua.set_snd_dev(capture_dev, playback_dev)
4833 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004834 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004835PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4836 int playback_dev);
4837
4838
4839/**
4840 * Set pjsua to use null sound device. The null sound device only provides
4841 * the timing needed by the conference bridge, and will not interract with
4842 * any hardware.
4843 *
4844 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004845 *
4846 * \par Python:
4847 * \code
4848 status = py_pjsua.set_null_snd_dev()
4849 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004850 */
4851PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4852
4853
Benny Prijonoe909eac2006-07-27 22:04:56 +00004854/**
4855 * Disconnect the main conference bridge from any sound devices, and let
4856 * application connect the bridge to it's own sound device/master port.
4857 *
4858 * @return The port interface of the conference bridge,
4859 * so that application can connect this to it's own
4860 * sound device or master port.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004861 *
4862 * \par Python:
4863 * Not applicable (for now).
Benny Prijonoe909eac2006-07-27 22:04:56 +00004864 */
4865PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4866
4867
Benny Prijonof20687a2006-08-04 18:27:19 +00004868/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004869 * Configure the echo canceller tail length of the sound port.
Benny Prijonof20687a2006-08-04 18:27:19 +00004870 *
4871 * @param tail_ms The tail length, in miliseconds. Set to zero to
4872 * disable AEC.
Benny Prijonoa7b376b2008-01-25 16:06:33 +00004873 * @param options Options to be passed to pjmedia_echo_create().
Benny Prijono5da50432006-08-07 10:24:52 +00004874 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004875 *
4876 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004877 *
4878 * \par Python:
4879 * \code
4880 status = py_pjsua.set_ec(tail_ms, options)
4881 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004882 */
Benny Prijono5da50432006-08-07 10:24:52 +00004883PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004884
4885
4886/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004887 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004888 *
4889 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4890 * If AEC is disabled, the value will be zero.
4891 *
4892 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004893 *
4894 * \par Python:
4895 * \code
4896 tail_ms = py_pjsua.get_ec_tail()
4897 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004898 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004899PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004900
4901
4902
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004903/*****************************************************************************
4904 * Codecs.
4905 */
4906
4907/**
4908 * Enum all supported codecs in the system.
4909 *
4910 * @param id Array of ID to be initialized.
4911 * @param count On input, specifies max elements in the array.
4912 * On return, it contains actual number of elements
4913 * that have been initialized.
4914 *
4915 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004916 *
4917 * \par Python:
4918 * This function takes no argument and returns list of codec infos:
4919 * \code
4920 [codec_info] = py_pjsua.enum_codecs()
4921 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004922 */
4923PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4924 unsigned *count );
4925
4926
4927/**
4928 * Change codec priority.
4929 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004930 * @param codec_id Codec ID, which is a string that uniquely identify
4931 * the codec (such as "speex/8000"). Please see pjsua
4932 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004933 * @param priority Codec priority, 0-255, where zero means to disable
4934 * the codec.
4935 *
4936 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004937 *
4938 * \par Python:
4939 * \code
4940 status = py_pjsua.codec_set_priority(codec_id, priority)
4941 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004942 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004943PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004944 pj_uint8_t priority );
4945
4946
4947/**
4948 * Get codec parameters.
4949 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004950 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004951 * @param param Structure to receive codec parameters.
4952 *
4953 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004954 *
4955 * \par Python:
4956 * The Python function is experimental:
4957 * \code
4958 codec_param = py_pjsua.codec_get_param(codec_id)
4959 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004960 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004961PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004962 pjmedia_codec_param *param );
4963
4964
4965/**
4966 * Set codec parameters.
4967 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004968 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004969 * @param param Codec parameter to set.
4970 *
4971 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004972 *
4973 * \par Python:
4974 * The Python function is experimental:
4975 * \code
4976 status = py_pjsua.codec_set_param(codec_id, param)
4977 * \endcode
4978
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004979 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004980PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004981 const pjmedia_codec_param *param);
4982
4983
4984
Benny Prijono9fc735d2006-05-28 14:58:12 +00004985
Benny Prijono312aff92006-06-17 04:08:30 +00004986/**
4987 * Create UDP media transports for all the calls. This function creates
4988 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00004989 *
Benny Prijono312aff92006-06-17 04:08:30 +00004990 * @param cfg Media transport configuration. The "port" field in the
4991 * configuration is used as the start port to bind the
4992 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004993 *
4994 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004995 *
4996 * \par Python:
4997 * Not implemented yet.
Benny Prijonof3195072006-02-14 21:15:30 +00004998 */
Benny Prijono312aff92006-06-17 04:08:30 +00004999PJ_DECL(pj_status_t)
5000pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00005001
Benny Prijonodc39fe82006-05-26 12:17:46 +00005002
5003/**
Benny Prijono312aff92006-06-17 04:08:30 +00005004 * Register custom media transports to be used by calls. There must
5005 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005006 *
Benny Prijono312aff92006-06-17 04:08:30 +00005007 * @param tp The media transport array.
5008 * @param count Number of elements in the array. This number MUST
5009 * match the number of maximum calls configured when
5010 * pjsua is created.
5011 * @param auto_delete Flag to indicate whether the transports should be
5012 * destroyed when pjsua is shutdown.
5013 *
5014 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00005015 *
5016 * \par Python:
5017 * Note applicable.
Benny Prijonodc39fe82006-05-26 12:17:46 +00005018 */
Benny Prijono312aff92006-06-17 04:08:30 +00005019PJ_DECL(pj_status_t)
5020pjsua_media_transports_attach( pjsua_media_transport tp[],
5021 unsigned count,
5022 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00005023
5024
Benny Prijono312aff92006-06-17 04:08:30 +00005025/**
5026 * @}
5027 */
5028
Benny Prijonof3195072006-02-14 21:15:30 +00005029
Benny Prijono268ca612006-02-07 12:34:11 +00005030
Benny Prijono312aff92006-06-17 04:08:30 +00005031/**
5032 * @}
5033 */
5034
Benny Prijonoe6ead542007-01-31 20:53:31 +00005035PJ_END_DECL
5036
Benny Prijono312aff92006-06-17 04:08:30 +00005037
Benny Prijono268ca612006-02-07 12:34:11 +00005038#endif /* __PJSUA_H__ */