blob: 65ccf307847eeaed8bdc77cd23628e2d3d3a844a [file] [log] [blame]
Benny Prijono268ca612006-02-07 12:34:11 +00001/* $Id$ */
2/*
Benny Prijonoa771a512007-02-19 01:13:53 +00003 * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org>
Benny Prijono268ca612006-02-07 12:34:11 +00004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJSUA_H__
20#define __PJSUA_H__
21
Benny Prijono312aff92006-06-17 04:08:30 +000022/**
23 * @file pjsua.h
24 * @brief PJSUA API.
25 */
26
27
Benny Prijono268ca612006-02-07 12:34:11 +000028/* Include all PJSIP core headers. */
29#include <pjsip.h>
30
31/* Include all PJMEDIA headers. */
32#include <pjmedia.h>
33
Benny Prijono1f9afba2006-02-10 15:57:32 +000034/* Include all PJMEDIA-CODEC headers. */
35#include <pjmedia-codec.h>
36
Benny Prijono268ca612006-02-07 12:34:11 +000037/* Include all PJSIP-UA headers */
38#include <pjsip_ua.h>
39
Benny Prijono834aee32006-02-19 01:38:06 +000040/* Include all PJSIP-SIMPLE headers */
41#include <pjsip_simple.h>
42
Benny Prijono4ab9fbb2007-10-12 12:14:27 +000043/* Include all PJNATH headers */
44#include <pjnath.h>
45
Benny Prijono268ca612006-02-07 12:34:11 +000046/* Include all PJLIB-UTIL headers. */
47#include <pjlib-util.h>
48
49/* Include all PJLIB headers. */
50#include <pjlib.h>
51
52
Benny Prijonoe6ead542007-01-31 20:53:31 +000053PJ_BEGIN_DECL
54
55
Benny Prijono312aff92006-06-17 04:08:30 +000056/**
Benny Prijonoe6ead542007-01-31 20:53:31 +000057 * @defgroup PJSUA_LIB PJSUA API - High Level Softphone API for C/C++ and Python
Benny Prijono312aff92006-06-17 04:08:30 +000058 * @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
396
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000397
Benny Prijonoa91a0032006-02-26 21:23:45 +0000398/**
Benny Prijono312aff92006-06-17 04:08:30 +0000399 * Maximum proxies in account.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000400 */
Benny Prijono312aff92006-06-17 04:08:30 +0000401#ifndef PJSUA_ACC_MAX_PROXIES
402# define PJSUA_ACC_MAX_PROXIES 8
403#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000404
Benny Prijonod8179652008-01-23 20:39:07 +0000405#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000406
Benny Prijonod8179652008-01-23 20:39:07 +0000407/**
408 * Default value of SRTP mode usage. Valid values are PJMEDIA_SRTP_DISABLED,
409 * PJMEDIA_SRTP_OPTIONAL, and PJMEDIA_SRTP_MANDATORY.
410 */
411#ifndef PJSUA_DEFAULT_USE_SRTP
412 #define PJSUA_DEFAULT_USE_SRTP PJMEDIA_SRTP_DISABLED
413#endif
414
415/**
416 * Default value of secure signaling requirement for SRTP.
417 * Valid values are:
418 * 0: SRTP does not require secure signaling
419 * 1: SRTP requires secure transport such as TLS
420 * 2: SRTP requires secure end-to-end transport (SIPS)
421 */
422#ifndef PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
423 #define PJSUA_DEFAULT_SRTP_SECURE_SIGNALING 1
424#endif
425
426#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000427
428/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000429 * Logging configuration, which can be (optionally) specified when calling
430 * #pjsua_init(). Application must call #pjsua_logging_config_default() to
431 * initialize this structure with the default values.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000432 *
433 * \par Sample Python Syntax:
434 * \code
435 # Python type: py_pjsua.Logging_Config
436
437 log_cfg = py_pjsua.logging_config_default()
438 log_cfg.level = 4
439 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000440 */
441typedef struct pjsua_logging_config
442{
443 /**
444 * Log incoming and outgoing SIP message? Yes!
445 */
446 pj_bool_t msg_logging;
447
448 /**
449 * Input verbosity level. Value 5 is reasonable.
450 */
451 unsigned level;
452
453 /**
454 * Verbosity level for console. Value 4 is reasonable.
455 */
456 unsigned console_level;
457
458 /**
459 * Log decoration.
460 */
461 unsigned decor;
462
463 /**
464 * Optional log filename.
465 */
466 pj_str_t log_filename;
467
468 /**
469 * Optional callback function to be called to write log to
470 * application specific device. This function will be called for
471 * log messages on input verbosity level.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000472 *
473 * \par Sample Python Syntax:
474 * \code
475 # level: integer
476 # data: string
477 # len: integer
478
479 def cb(level, data, len):
480 print data,
481 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000482 */
Benny Prijonofe7d87b2007-11-29 11:35:44 +0000483 void (*cb)(int level, const char *data, int len);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000484
485
486} pjsua_logging_config;
487
488
489/**
490 * Use this function to initialize logging config.
491 *
492 * @param cfg The logging config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000493 *
494 * \par Python Syntax:
495 * The Python function instantiates and initialize the logging config:
496 * \code
497 logging_cfg = py_pjsua.logging_config_default()
498 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000499 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000500PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000501
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000502
503/**
504 * Use this function to duplicate logging config.
505 *
506 * @param pool Pool to use.
507 * @param dst Destination config.
508 * @param src Source config.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000509 *
510 * \par Python Syntax:
511 * Not available (for now). Ideally we should be able to just assign
512 * one config to another, but this has not been tested.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000513 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000514PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool,
515 pjsua_logging_config *dst,
516 const pjsua_logging_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000517
Benny Prijonodc39fe82006-05-26 12:17:46 +0000518
519/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000520 * This structure describes application callback to receive various event
521 * notification from PJSUA-API. All of these callbacks are OPTIONAL,
522 * although definitely application would want to implement some of
523 * the important callbacks (such as \a on_incoming_call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000524 *
525 * \par Python Syntax:
526 * This callback structure is embedded on pjsua_config structure.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000527 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000528typedef struct pjsua_callback
Benny Prijonodc39fe82006-05-26 12:17:46 +0000529{
530 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000531 * Notify application when invite state has changed.
532 * Application may then query the call info to get the
Benny Prijonoe6ead542007-01-31 20:53:31 +0000533 * detail call states by calling pjsua_call_get_info() function.
Benny Prijono0875ae82006-12-26 00:11:48 +0000534 *
535 * @param call_id The call index.
536 * @param e Event which causes the call state to change.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000537 *
538 * \par Python Syntax:
539 * \code
540 # call_id: integer
541 # e: an opaque object
542
543 def on_call_state(call_id, e):
544 return
545 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000546 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000547 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000548
549 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000550 * Notify application on incoming call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000551 *
552 * @param acc_id The account which match the incoming call.
553 * @param call_id The call id that has just been created for
554 * the call.
555 * @param rdata The incoming INVITE request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000556 *
557 * \par Python Syntax:
558 * \code
559 # acc_id: integer
560 # call_id: integer
561 # rdata: an opaque object
562
563 def on_incoming_call(acc_id, call_id, rdata):
564 return
565 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +0000566 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000567 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000568 pjsip_rx_data *rdata);
569
570 /**
Benny Prijonofeb69f42007-10-05 09:12:26 +0000571 * This is a general notification callback which is called whenever
572 * a transaction within the call has changed state. Application can
573 * implement this callback for example to monitor the state of
574 * outgoing requests, or to answer unhandled incoming requests
575 * (such as INFO) with a final response.
576 *
577 * @param call_id Call identification.
578 * @param tsx The transaction which has changed state.
579 * @param e Transaction event that caused the state change.
580 */
581 void (*on_call_tsx_state)(pjsua_call_id call_id,
582 pjsip_transaction *tsx,
583 pjsip_event *e);
584
585 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000586 * Notify application when media state in the call has changed.
587 * Normal application would need to implement this callback, e.g.
Benny Prijono6ba8c542007-10-16 01:34:14 +0000588 * to connect the call's media to sound device. When ICE is used,
589 * this callback will also be called to report ICE negotiation
590 * failure.
Benny Prijono0875ae82006-12-26 00:11:48 +0000591 *
592 * @param call_id The call index.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000593 *
594 * \par Python Syntax:
595 * \code
596 # call_id: integer
597
598 def on_call_media_state(call_id):
599 return
600 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000601 */
602 void (*on_call_media_state)(pjsua_call_id call_id);
603
Benny Prijonofc13bf62008-02-20 08:56:15 +0000604
605 /**
606 * Notify application when media session is created and before it is
607 * registered to the conference bridge. Application may return different
608 * media port if it has added media processing port to the stream. This
609 * media port then will be added to the conference bridge instead.
610 *
611 * @param call_id Call identification.
612 * @param sess Media session for the call.
613 * @param stream_idx Stream index in the media session.
614 * @param p_port On input, it specifies the media port of the
615 * stream. Application may modify this pointer to
616 * point to different media port to be registered
617 * to the conference bridge.
618 *
619 * \par Python:
620 * Not applicable.
621 */
622 void (*on_stream_created)(pjsua_call_id call_id,
623 pjmedia_session *sess,
624 unsigned stream_idx,
625 pjmedia_port **p_port);
626
627 /**
628 * Notify application when media session has been unregistered from the
629 * conference bridge and about to be destroyed.
630 *
631 * @param call_id Call identification.
632 * @param sess Media session for the call.
633 * @param stream_idx Stream index in the media session.
634 *
635 * \par Python:
636 * Not applicable.
637 */
638 void (*on_stream_destroyed)(pjsua_call_id call_id,
639 pjmedia_session *sess,
640 unsigned stream_idx);
641
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000642 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000643 * Notify application upon incoming DTMF digits.
644 *
645 * @param call_id The call index.
646 * @param digit DTMF ASCII digit.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000647 *
648 * \par Python Syntax:
649 * \code
650 # call_id: integer
Benny Prijono1f63cc42007-09-10 16:54:22 +0000651 # digit: digit string
Benny Prijonoe6ead542007-01-31 20:53:31 +0000652
653 def on_dtmf_digit(call_id, digit):
654 return
655 * \endcode
Benny Prijono0875ae82006-12-26 00:11:48 +0000656 */
657 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
658
659 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000660 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000661 * Application can decide to accept/reject transfer request
Benny Prijonoc54dcb32008-04-08 23:33:15 +0000662 * by setting the code (default is 202). When this callback
Benny Prijono9fc735d2006-05-28 14:58:12 +0000663 * is not defined, the default behavior is to accept the
664 * transfer.
Benny Prijono0875ae82006-12-26 00:11:48 +0000665 *
666 * @param call_id The call index.
667 * @param dst The destination where the call will be
668 * transfered to.
669 * @param code Status code to be returned for the call transfer
670 * request. On input, it contains status code 200.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000671 *
672 * \par Python Syntax:
673 * \code
674 # call_id: integer
675 # dst: string
676 # code: integer
677
678 def on_call_transfer_request(call_id, dst, code):
679 return code
680
681 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000682 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000683 void (*on_call_transfer_request)(pjsua_call_id call_id,
684 const pj_str_t *dst,
685 pjsip_status_code *code);
686
687 /**
688 * Notify application of the status of previously sent call
689 * transfer request. Application can monitor the status of the
690 * call transfer request, for example to decide whether to
691 * terminate existing call.
692 *
693 * @param call_id Call ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000694 * @param st_code Status progress of the transfer request.
695 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000696 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000697 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000698 * this callback is the final status.
699 * @param p_cont Initially will be set to non-zero, application
700 * can set this to FALSE if it no longer wants
701 * to receie further notification (for example,
702 * after it hangs up the call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000703 *
704 * \par Python Syntax:
705 * \code
706 # call_id: integer
707 # st_code: integer
708 # st_text: string
709 # final: integer
710 # cont: integer
711
712 # return: cont
713
714 def on_call_transfer_status(call_id, st_code, st_text, final, cont):
715 return cont
716 * \endcode
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000717 */
718 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000719 int st_code,
720 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000721 pj_bool_t final,
722 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000723
724 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000725 * Notify application about incoming INVITE with Replaces header.
726 * Application may reject the request by setting non-2xx code.
727 *
728 * @param call_id The call ID to be replaced.
729 * @param rdata The incoming INVITE request to replace the call.
730 * @param st_code Status code to be set by application. Application
731 * should only return a final status (200-699).
732 * @param st_text Optional status text to be set by application.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000733 *
734 * \par Python Syntax:
735 * \code
736 # call_id: integer
737 # rdata: an opaque object
738 # st_code: integer
739 # st_text: string
740
741 # return: (st_code, st_text) tuple
742
743 def on_call_replace_request(call_id, rdata, st_code, st_text):
744 return st_code, st_text
745 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000746 */
747 void (*on_call_replace_request)(pjsua_call_id call_id,
748 pjsip_rx_data *rdata,
749 int *st_code,
750 pj_str_t *st_text);
751
752 /**
753 * Notify application that an existing call has been replaced with
754 * a new call. This happens when PJSUA-API receives incoming INVITE
755 * request with Replaces header.
756 *
757 * After this callback is called, normally PJSUA-API will disconnect
758 * \a old_call_id and establish \a new_call_id.
759 *
760 * @param old_call_id Existing call which to be replaced with the
761 * new call.
762 * @param new_call_id The new call.
763 * @param rdata The incoming INVITE with Replaces request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000764 *
765 * \par Python Syntax:
766 * \code
767 # old_call_id: integer
768 # new_call_id: integer
769
770 def on_call_replaced(old_call_id, new_call_id):
771 return
772 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000773 */
774 void (*on_call_replaced)(pjsua_call_id old_call_id,
775 pjsua_call_id new_call_id);
776
777
778 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000779 * Notify application when registration status has changed.
780 * Application may then query the account info to get the
781 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000782 *
783 * @param acc_id Account ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000784 *
785 * \par Python Syntax:
786 * \code
787 # acc_id: account ID (integer)
788
789 def on_reg_state(acc_id):
790 return
791 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000792 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000793 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000794
795 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000796 * Notify application when the buddy state has changed.
797 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000798 *
799 * @param buddy_id The buddy id.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000800 *
801 * \par Python Syntax:
802 * \code
803 # buddy_id: integer
804
805 def on_buddy_state(buddy_id):
806 return
807 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000808 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000809 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000810
811 /**
812 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000813 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000814 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000815 *
Benny Prijonobbeb3992007-05-21 13:48:35 +0000816 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
817 * passed as one of the argument.
818 *
Benny Prijono0875ae82006-12-26 00:11:48 +0000819 * @param call_id Containts the ID of the call where the IM was
820 * sent, or PJSUA_INVALID_ID if the IM was sent
821 * outside call context.
822 * @param from URI of the sender.
823 * @param to URI of the destination message.
824 * @param contact The Contact URI of the sender, if present.
825 * @param mime_type MIME type of the message.
826 * @param body The message content.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000827 *
828 * \par Python Syntax:
829 * \code
830 # call_id: integer
831 # from: string
832 # to: string
833 # contact: string
834 # mime_type: string
835 # body: string
836
837 def on_pager(call_id, from, to, contact, mime_type, body):
838 return
839 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000840 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000841 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
842 const pj_str_t *to, const pj_str_t *contact,
843 const pj_str_t *mime_type, const pj_str_t *body);
844
845 /**
Benny Prijonobbeb3992007-05-21 13:48:35 +0000846 * This is the alternative version of the \a on_pager() callback with
847 * \a pjsip_rx_data argument.
848 *
849 * @param call_id Containts the ID of the call where the IM was
850 * sent, or PJSUA_INVALID_ID if the IM was sent
851 * outside call context.
852 * @param from URI of the sender.
853 * @param to URI of the destination message.
854 * @param contact The Contact URI of the sender, if present.
855 * @param mime_type MIME type of the message.
856 * @param body The message content.
857 * @param rdata The incoming MESSAGE request.
858 */
859 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
860 const pj_str_t *to, const pj_str_t *contact,
861 const pj_str_t *mime_type, const pj_str_t *body,
862 pjsip_rx_data *rdata);
863
864 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000865 * Notify application about the delivery status of outgoing pager
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000866 * request. See also on_pager_status2() callback for the version with
867 * \a pjsip_rx_data in the argument list.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000868 *
869 * @param call_id Containts the ID of the call where the IM was
870 * sent, or PJSUA_INVALID_ID if the IM was sent
871 * outside call context.
872 * @param to Destination URI.
873 * @param body Message body.
874 * @param user_data Arbitrary data that was specified when sending
875 * IM message.
876 * @param status Delivery status.
877 * @param reason Delivery status reason.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000878 *
879 * \par Python Syntax
880 * \code
881 # call_id: integer
882 # to: string
883 # body: string
884 # user_data: string
885 # status: integer
886 # reason: string
887
888 def on_pager_status(call_id, to, body, user_data, status, reason):
889 return
890 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000891 */
892 void (*on_pager_status)(pjsua_call_id call_id,
893 const pj_str_t *to,
894 const pj_str_t *body,
895 void *user_data,
896 pjsip_status_code status,
897 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000898
899 /**
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000900 * Notify application about the delivery status of outgoing pager
901 * request.
902 *
903 * @param call_id Containts the ID of the call where the IM was
904 * sent, or PJSUA_INVALID_ID if the IM was sent
905 * outside call context.
906 * @param to Destination URI.
907 * @param body Message body.
908 * @param user_data Arbitrary data that was specified when sending
909 * IM message.
910 * @param status Delivery status.
911 * @param reason Delivery status reason.
Benny Prijono0a982002007-06-12 16:22:09 +0000912 * @param tdata The original MESSAGE request.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000913 * @param rdata The incoming MESSAGE response, or NULL if the
914 * message transaction fails because of time out
915 * or transport error.
916 */
917 void (*on_pager_status2)(pjsua_call_id call_id,
918 const pj_str_t *to,
919 const pj_str_t *body,
920 void *user_data,
921 pjsip_status_code status,
922 const pj_str_t *reason,
Benny Prijono0a982002007-06-12 16:22:09 +0000923 pjsip_tx_data *tdata,
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000924 pjsip_rx_data *rdata);
925
926 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000927 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +0000928 *
929 * @param call_id Containts the ID of the call where the IM was
930 * sent, or PJSUA_INVALID_ID if the IM was sent
931 * outside call context.
932 * @param from URI of the sender.
933 * @param to URI of the destination message.
934 * @param contact The Contact URI of the sender, if present.
935 * @param is_typing Non-zero if peer is typing, or zero if peer
936 * has stopped typing a message.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000937 *
938 * \par Python Syntax
939 * \code
940 # call_id: string
941 # from: string
942 # to: string
943 # contact: string
944 # is_typing: integer
945
946 def on_typing(call_id, from, to, contact, is_typing):
947 return
948 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000949 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000950 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
951 const pj_str_t *to, const pj_str_t *contact,
952 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000953
Benny Prijono6ba8c542007-10-16 01:34:14 +0000954 /**
955 * Callback when the library has finished performing NAT type
956 * detection.
957 *
958 * @param res NAT detection result.
959 */
960 void (*on_nat_detect)(const pj_stun_nat_detect_result *res);
961
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000962} pjsua_callback;
963
964
965
Benny Prijonodc39fe82006-05-26 12:17:46 +0000966
967/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000968 * This structure describes the settings to control the API and
969 * user agent behavior, and can be specified when calling #pjsua_init().
970 * Before setting the values, application must call #pjsua_config_default()
971 * to initialize this structure with the default values.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000972 *
973 * \par Python Sample Syntax:
974 * The pjsua_config type in Python is <tt>py_pjsua.Config</tt>. Application
975 * creates the instance by calling <tt>py_pjsua.config_default()</tt>:
976 * \code
977 cfg = py_pjsua.config_default()
978 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000979 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000980typedef struct pjsua_config
981{
982
983 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000984 * Maximum calls to support (default: 4). The value specified here
985 * must be smaller than the compile time maximum settings
986 * PJSUA_MAX_CALLS, which by default is 32. To increase this
987 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
988 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000989 */
990 unsigned max_calls;
991
992 /**
993 * Number of worker threads. Normally application will want to have at
994 * least one worker thread, unless when it wants to poll the library
995 * periodically, which in this case the worker thread can be set to
996 * zero.
997 */
998 unsigned thread_cnt;
999
1000 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +00001001 * Number of nameservers. If no name server is configured, the SIP SRV
1002 * resolution would be disabled, and domain will be resolved with
1003 * standard pj_gethostbyname() function.
1004 */
1005 unsigned nameserver_count;
1006
1007 /**
1008 * Array of nameservers to be used by the SIP resolver subsystem.
1009 * The order of the name server specifies the priority (first name
1010 * server will be used first, unless it is not reachable).
1011 */
1012 pj_str_t nameserver[4];
1013
1014 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001015 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001016 */
1017 unsigned outbound_proxy_cnt;
1018
1019 /**
1020 * Specify the URL of outbound proxies to visit for all outgoing requests.
1021 * The outbound proxies will be used for all accounts, and it will
1022 * be used to build the route set for outgoing requests. The final
1023 * route set for outgoing requests will consists of the outbound proxies
1024 * and the proxy configured in the account.
1025 */
1026 pj_str_t outbound_proxy[4];
1027
Benny Prijonoc97608e2007-03-23 16:34:20 +00001028 /**
Benny Prijonoebbf6892007-03-24 17:37:25 +00001029 * Specify domain name to be resolved with DNS SRV resolution to get the
Benny Prijonof76e1392008-06-06 14:51:48 +00001030 * address of the STUN server. Alternatively application may specify
1031 * \a stun_host instead.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001032 *
1033 * If DNS SRV resolution failed for this domain, then DNS A resolution
1034 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +00001035 */
Benny Prijonoebbf6892007-03-24 17:37:25 +00001036 pj_str_t stun_domain;
1037
1038 /**
Benny Prijonoaf09dc32007-04-22 12:48:30 +00001039 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
1040 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001041 */
1042 pj_str_t stun_host;
1043
1044 /**
Benny Prijono91a6a172007-10-31 08:59:29 +00001045 * Support for adding and parsing NAT type in the SDP to assist
1046 * troubleshooting. The valid values are:
1047 * - 0: no information will be added in SDP, and parsing is disabled.
Benny Prijono6ba8c542007-10-16 01:34:14 +00001048 * - 1: only the NAT type number is added.
1049 * - 2: add both NAT type number and name.
1050 *
Benny Prijono91a6a172007-10-31 08:59:29 +00001051 * Default: 1
Benny Prijono6ba8c542007-10-16 01:34:14 +00001052 */
1053 int nat_type_in_sdp;
1054
1055 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001056 * Specify whether support for reliable provisional response (100rel and
1057 * PRACK) should be required by default. Note that this setting can be
1058 * further customized in account configuration (#pjsua_acc_config).
1059 *
1060 * Default: PJ_FALSE
1061 */
1062 pj_bool_t require_100rel;
1063
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001064 /**
1065 * Number of credentials in the credential array.
1066 */
1067 unsigned cred_count;
1068
1069 /**
1070 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +00001071 * and can be used to authenticate against outbound proxies. If the
1072 * credential is specific to the account, then application should set
1073 * the credential in the pjsua_acc_config rather than the credential
1074 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001075 */
1076 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1077
1078 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001079 * Application callback to receive various event notifications from
1080 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001081 */
1082 pjsua_callback cb;
1083
Benny Prijono56315612006-07-18 14:39:40 +00001084 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001085 * Optional user agent string (default empty). If it's empty, no
1086 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +00001087 */
1088 pj_str_t user_agent;
1089
Benny Prijonod8179652008-01-23 20:39:07 +00001090#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
1091 /**
1092 * Specify default value of secure media transport usage.
1093 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
1094 * PJMEDIA_SRTP_MANDATORY.
1095 *
1096 * Note that this setting can be further customized in account
1097 * configuration (#pjsua_acc_config).
1098 *
1099 * Default: #PJSUA_DEFAULT_USE_SRTP
1100 */
1101 pjmedia_srtp_use use_srtp;
1102
1103 /**
1104 * Specify whether SRTP requires secure signaling to be used. This option
1105 * is only used when \a use_srtp option above is non-zero.
1106 *
1107 * Valid values are:
1108 * 0: SRTP does not require secure signaling
1109 * 1: SRTP requires secure transport such as TLS
1110 * 2: SRTP requires secure end-to-end transport (SIPS)
1111 *
1112 * Note that this setting can be further customized in account
1113 * configuration (#pjsua_acc_config).
1114 *
1115 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
1116 */
1117 int srtp_secure_signaling;
1118#endif
1119
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001120} pjsua_config;
1121
1122
1123/**
1124 * Use this function to initialize pjsua config.
1125 *
1126 * @param cfg pjsua config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001127 *
1128 * \par Python Sample Syntax:
1129 * The corresponding Python function creates an instance of the config and
1130 * initializes it to the default settings:
1131 * \code
1132 cfg = py_pjsua.config_default()
1133 * \endcode
1134
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001135 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001136PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001137
1138
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001139/** The implementation has been moved to sip_auth.h */
Benny Prijono7977f9f2007-10-10 11:37:56 +00001140#define pjsip_cred_dup pjsip_cred_info_dup
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001141
1142
1143/**
1144 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001145 *
1146 * @param pool The pool to get memory from.
1147 * @param dst Destination config.
1148 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001149 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001150PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1151 pjsua_config *dst,
1152 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001153
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001154
1155/**
1156 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001157 * outgoing SIP message. It can (optionally) be specified for example
1158 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1159 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1160 *
1161 * Application MUST call #pjsua_msg_data_init() to initialize this
1162 * structure before setting its values.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001163 *
1164 * \par Python Syntax
1165 * The data type in Python is <tt>py_pjsua.Msg_Data</tt>. Application is
1166 * recommended to instantiate the structure by using this construct:
1167 * \code
1168 msg_data = py_pjsua.msg_data_init()
1169 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001170 */
1171typedef struct pjsua_msg_data
1172{
1173 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001174 * Additional message headers as linked list. Application can add
1175 * headers to the list by creating the header, either from the heap/pool
1176 * or from temporary local variable, and add the header using
1177 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001178 *
1179 * \par Python:
1180 * This field is implemented as string linked-list in Python, where each
1181 * string describes the header. For example:
1182 \code
1183 msg_data = py_pjsua.Msg_Data()
1184 msg_data.hdr_list = ["Subject: Hello py_pjsua!", "Priority: very low"]
1185 \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001186 */
1187 pjsip_hdr hdr_list;
1188
1189 /**
1190 * MIME type of optional message body.
1191 */
1192 pj_str_t content_type;
1193
1194 /**
1195 * Optional message body.
1196 */
1197 pj_str_t msg_body;
1198
1199} pjsua_msg_data;
1200
1201
1202/**
1203 * Initialize message data.
1204 *
1205 * @param msg_data Message data to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001206 *
1207 * \par Python
1208 * The corresponding Python function creates and initializes the structure:
1209 * \code
1210 msg_data = py_pjsua.msg_data_init()
1211 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001212 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001213PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001214
Benny Prijono268ca612006-02-07 12:34:11 +00001215
1216/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001217 * Instantiate pjsua application. Application must call this function before
1218 * calling any other functions, to make sure that the underlying libraries
1219 * are properly initialized. Once this function has returned success,
1220 * application must call pjsua_destroy() before quitting.
1221 *
1222 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001223 *
1224 * \par Python:
1225 * \code
1226 status = py_pjsua.create()
1227 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001228 */
1229PJ_DECL(pj_status_t) pjsua_create(void);
1230
1231
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001232/** Forward declaration */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001233typedef struct pjsua_media_config pjsua_media_config;
1234
1235
Benny Prijonodc39fe82006-05-26 12:17:46 +00001236/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001237 * Initialize pjsua with the specified settings. All the settings are
1238 * optional, and the default values will be used when the config is not
1239 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001240 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001241 * Note that #pjsua_create() MUST be called before calling this function.
1242 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001243 * @param ua_cfg User agent configuration.
1244 * @param log_cfg Optional logging configuration.
1245 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001246 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001247 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001248 *
1249 * \par Python:
1250 * The function is similar in Python:
1251 * \code
1252 status = py_pjsua.init(ua_cfg, log_cfg, media_cfg)
1253 * \endcode
1254 * Note that \a ua_cfg, \a log_cfg, and \a media_cfg are optional, and
1255 * the Python script may pass None if it doesn't want to configure the
1256 * setting.
Benny Prijono268ca612006-02-07 12:34:11 +00001257 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001258PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1259 const pjsua_logging_config *log_cfg,
1260 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001261
1262
1263/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001264 * Application is recommended to call this function after all initialization
1265 * is done, so that the library can do additional checking set up
1266 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001267 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001268 * Application may call this function anytime after #pjsua_init().
1269 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001270 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001271 *
1272 * \par Python:
1273 * The function is similar in Python:
1274 * \code
1275 status = py_pjsua.start()
1276 * \endcode
Benny Prijonoccf95622006-02-07 18:48:01 +00001277 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001278PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001279
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001280
Benny Prijonoccf95622006-02-07 18:48:01 +00001281/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001282 * Destroy pjsua. Application is recommended to perform graceful shutdown
1283 * before calling this function (such as unregister the account from the SIP
1284 * server, terminate presense subscription, and hangup active calls), however,
1285 * this function will do all of these if it finds there are active sessions
1286 * that need to be terminated. This function will approximately block for
1287 * one second to wait for replies from remote.
1288 *
1289 * Application.may safely call this function more than once if it doesn't
1290 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001291 *
1292 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001293 *
1294 * \par Python:
1295 * The function is similar in Python:
1296 * \code
1297 status = py_pjsua.destroy()
1298 * \endcode
Benny Prijono268ca612006-02-07 12:34:11 +00001299 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001300PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001301
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001302
Benny Prijono9fc735d2006-05-28 14:58:12 +00001303/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001304 * Poll pjsua for events, and if necessary block the caller thread for
1305 * the specified maximum interval (in miliseconds).
1306 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001307 * Application doesn't normally need to call this function if it has
1308 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1309 * because polling then will be done by these worker threads instead.
1310 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001311 * @param msec_timeout Maximum time to wait, in miliseconds.
1312 *
1313 * @return The number of events that have been handled during the
1314 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001315 * can retrieve the error as (status = -return_value).
1316 *
1317 * \par Python:
1318 * The function is similar in Python:
1319 * \code
1320 n = py_pjsua.handle_events(msec_timeout)
1321 * \endcode
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001322 */
1323PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1324
1325
1326/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001327 * Create memory pool to be used by the application. Once application
1328 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001329 *
1330 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001331 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001332 * @param increment Increment size.
1333 *
1334 * @return The pool, or NULL when there's no memory.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001335 *
1336 * \par Python:
1337 * Python script may also create a pool object from the script:
1338 * \code
1339 pool = py_pjsua.pool_create(name, init_size, increment)
1340 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001341 */
1342PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1343 pj_size_t increment);
1344
1345
1346/**
1347 * Application can call this function at any time (after pjsua_create(), of
1348 * course) to change logging settings.
1349 *
1350 * @param c Logging configuration.
1351 *
1352 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001353 *
1354 * \par Python:
1355 * The function is similar in Python:
1356 * \code
1357 status = py_pjsua.reconfigure_logging(log_cfg)
1358 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001359 */
1360PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1361
1362
1363/**
1364 * Internal function to get SIP endpoint instance of pjsua, which is
1365 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001366 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001367 *
1368 * @return SIP endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001369 *
1370 * \par Python:
1371 * Application may retrieve the SIP endpoint instance:
1372 * \code
1373 endpt = py_pjsua.get_pjsip_endpt()
1374 * \endcode
1375 * However currently the object is just an opaque object and does not have
1376 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001377 */
1378PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1379
1380/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001381 * Internal function to get media endpoint instance.
1382 * Only valid after #pjsua_init() is called.
1383 *
1384 * @return Media endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001385 *
1386 * \par Python:
1387 * Application may retrieve the media endpoint instance:
1388 * \code
1389 endpt = py_pjsua.get_pjmedia_endpt()
1390 * \endcode
1391 * However currently the object is just an opaque object and does not have
1392 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001393 */
1394PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1395
Benny Prijono97b87172006-08-24 14:25:14 +00001396/**
1397 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001398 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001399 *
1400 * @return Pool factory currently used by PJSUA.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001401 *
1402 * \par Python:
1403 * Application may retrieve the pool factory instance:
1404 * \code
1405 endpt = py_pjsua.get_pool_factory()
1406 * \endcode
1407 * However currently the object is just an opaque object and does not have
1408 * any use for Python scripts.
Benny Prijono97b87172006-08-24 14:25:14 +00001409 */
1410PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1411
1412
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001413
1414/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001415 * Utilities.
1416 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001417 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001418
1419/**
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001420 * This is a utility function to detect NAT type in front of this
1421 * endpoint. Once invoked successfully, this function will complete
Benny Prijono6ba8c542007-10-16 01:34:14 +00001422 * asynchronously and report the result in \a on_nat_detect() callback
1423 * of pjsua_callback.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001424 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001425 * After NAT has been detected and the callback is called, application can
1426 * get the detected NAT type by calling #pjsua_get_nat_type(). Application
1427 * can also perform NAT detection by calling #pjsua_detect_nat_type()
1428 * again at later time.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001429 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001430 * Note that STUN must be enabled to run this function successfully.
1431 *
1432 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001433 */
Benny Prijono6ba8c542007-10-16 01:34:14 +00001434PJ_DECL(pj_status_t) pjsua_detect_nat_type(void);
1435
1436
1437/**
1438 * Get the NAT type as detected by #pjsua_detect_nat_type() function.
1439 * This function will only return useful NAT type after #pjsua_detect_nat_type()
1440 * has completed successfully and \a on_nat_detect() callback has been called.
1441 *
1442 * @param type NAT type.
1443 *
1444 * @return When detection is in progress, this function will
1445 * return PJ_EPENDING and \a type will be set to
1446 * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been
1447 * detected successfully, this function will return
1448 * PJ_SUCCESS and \a type will be set to the correct
1449 * value. Other return values indicate error and
1450 * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN.
Benny Prijono91a6a172007-10-31 08:59:29 +00001451 *
1452 * @see pjsua_call_get_rem_nat_type()
Benny Prijono6ba8c542007-10-16 01:34:14 +00001453 */
1454PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type);
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001455
1456
1457/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001458 * This is a utility function to verify that valid SIP url is given. If the
1459 * URL is valid, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001460 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001461 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001462 *
1463 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001464 *
1465 * \par Python:
1466 * \code
1467 status = py_pjsua.verify_sip_url(url)
1468 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001469 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001470PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001471
1472
1473/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001474 * This is a utility function to display error message for the specified
1475 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001476 *
1477 * @param sender The log sender field.
1478 * @param title Message title for the error.
1479 * @param status Status code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001480 *
1481 * \par Python:
1482 * \code
1483 py_pjsua.perror(sender, title, status)
1484 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001485 */
1486PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1487 pj_status_t status);
1488
1489
Benny Prijonoda9785b2007-04-02 20:43:06 +00001490/**
1491 * This is a utility function to dump the stack states to log, using
1492 * verbosity level 3.
1493 *
1494 * @param detail Will print detailed output (such as list of
1495 * SIP transactions) when non-zero.
1496 */
1497PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001498
1499/**
1500 * @}
1501 */
1502
1503
1504
1505/*****************************************************************************
1506 * TRANSPORT API
1507 */
1508
1509/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001510 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001511 * @ingroup PJSUA_LIB
1512 * @brief API for managing SIP transports
1513 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001514 *
1515 * PJSUA-API supports creating multiple transport instances, for example UDP,
1516 * TCP, and TLS transport. SIP transport must be created before adding an
1517 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001518 */
1519
1520
Benny Prijonoe6ead542007-01-31 20:53:31 +00001521/** SIP transport identification.
1522 */
Benny Prijono312aff92006-06-17 04:08:30 +00001523typedef int pjsua_transport_id;
1524
1525
1526/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001527 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001528 * and media. Before setting some values to this structure, application
1529 * MUST call #pjsua_transport_config_default() to initialize its
1530 * values with default settings.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001531 *
1532 * \par Python:
1533 * The data type in Python is <tt>py_pjsua.Transport_Config</tt>,
1534 * although application can just do this to create the instance:
1535 * \code
1536 transport_cfg = py_pjsua.transport_config_default()
1537 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001538 */
1539typedef struct pjsua_transport_config
1540{
1541 /**
1542 * UDP port number to bind locally. This setting MUST be specified
1543 * even when default port is desired. If the value is zero, the
1544 * transport will be bound to any available port, and application
1545 * can query the port by querying the transport info.
1546 */
1547 unsigned port;
1548
1549 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001550 * Optional address to advertise as the address of this transport.
1551 * Application can specify any address or hostname for this field,
1552 * for example it can point to one of the interface address in the
1553 * system, or it can point to the public address of a NAT router
1554 * where port mappings have been configured for the application.
1555 *
1556 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001557 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001558 pj_str_t public_addr;
1559
1560 /**
1561 * Optional address where the socket should be bound to. This option
1562 * SHOULD only be used to selectively bind the socket to particular
1563 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1564 * published address of a transport (the public_addr field should be
1565 * used for that purpose).
1566 *
1567 * Note that unlike public_addr field, the address (or hostname) here
1568 * MUST correspond to the actual interface address in the host, since
1569 * this address will be specified as bind() argument.
1570 */
1571 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001572
1573 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001574 * This specifies TLS settings for TLS transport. It is only be used
1575 * when this transport config is being used to create a SIP TLS
1576 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001577 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001578 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001579
Benny Prijono312aff92006-06-17 04:08:30 +00001580} pjsua_transport_config;
1581
1582
1583/**
1584 * Call this function to initialize UDP config with default values.
1585 *
1586 * @param cfg The UDP config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001587 *
1588 * \par Python:
1589 * The corresponding Python function is rather different:
1590 * \code
1591 transport_cfg = py_pjsua.transport_config_default()
1592 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001593 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001594PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001595
1596
1597/**
Benny Prijono312aff92006-06-17 04:08:30 +00001598 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001599 *
1600 * @param pool The pool.
1601 * @param dst The destination config.
1602 * @param src The source config.
1603 *
1604 * \par Python:
1605 * Not applicable. One should be able to just copy one variable instance
1606 * to another in Python.
Benny Prijono312aff92006-06-17 04:08:30 +00001607 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001608PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1609 pjsua_transport_config *dst,
1610 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001611
1612
1613/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001614 * This structure describes transport information returned by
1615 * #pjsua_transport_get_info() function.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001616 *
1617 * \par Python:
1618 * The corresponding data type in Python is <tt>py_pjsua.Transport_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001619 */
1620typedef struct pjsua_transport_info
1621{
1622 /**
1623 * PJSUA transport identification.
1624 */
1625 pjsua_transport_id id;
1626
1627 /**
1628 * Transport type.
1629 */
1630 pjsip_transport_type_e type;
1631
1632 /**
1633 * Transport type name.
1634 */
1635 pj_str_t type_name;
1636
1637 /**
1638 * Transport string info/description.
1639 */
1640 pj_str_t info;
1641
1642 /**
1643 * Transport flag (see ##pjsip_transport_flags_e).
1644 */
1645 unsigned flag;
1646
1647 /**
1648 * Local address length.
1649 */
1650 unsigned addr_len;
1651
1652 /**
1653 * Local/bound address.
1654 */
1655 pj_sockaddr local_addr;
1656
1657 /**
1658 * Published address (or transport address name).
1659 */
1660 pjsip_host_port local_name;
1661
1662 /**
1663 * Current number of objects currently referencing this transport.
1664 */
1665 unsigned usage_count;
1666
1667
1668} pjsua_transport_info;
1669
1670
1671/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001672 * Create and start a new SIP transport according to the specified
1673 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001674 *
1675 * @param type Transport type.
1676 * @param cfg Transport configuration.
1677 * @param p_id Optional pointer to receive transport ID.
1678 *
1679 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001680 *
1681 * \par Python:
1682 * The corresponding Python function returns (status,id) tuple:
1683 * \code
1684 status, transport_id = py_pjsua.transport_create(type, cfg)
1685 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001686 */
1687PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1688 const pjsua_transport_config *cfg,
1689 pjsua_transport_id *p_id);
1690
1691/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001692 * Register transport that has been created by application. This function
1693 * is useful if application wants to implement custom SIP transport and use
1694 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001695 *
1696 * @param tp Transport instance.
1697 * @param p_id Optional pointer to receive transport ID.
1698 *
1699 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001700 *
1701 * \par Python:
1702 * Not applicable (for now), because one cannot create a custom transport
1703 * from Python script.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001704 */
1705PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1706 pjsua_transport_id *p_id);
1707
1708
1709/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001710 * Enumerate all transports currently created in the system. This function
1711 * will return all transport IDs, and application may then call
1712 * #pjsua_transport_get_info() function to retrieve detailed information
1713 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001714 *
1715 * @param id Array to receive transport ids.
1716 * @param count In input, specifies the maximum number of elements.
1717 * On return, it contains the actual number of elements.
1718 *
1719 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001720 *
1721 * \par Python:
1722 * The function returns list of integers representing transport ids:
1723 * \code
1724 [int] = py_pjsua.enum_transports()
1725 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001726 */
1727PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1728 unsigned *count );
1729
1730
1731/**
1732 * Get information about transports.
1733 *
1734 * @param id Transport ID.
1735 * @param info Pointer to receive transport info.
1736 *
1737 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001738 *
1739 * \par Python:
1740 * \code
1741 transport_info = py_pjsua.transport_get_info(id)
1742 * \endcode
1743 * The Python function returns None on error.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001744 */
1745PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1746 pjsua_transport_info *info);
1747
1748
1749/**
1750 * Disable a transport or re-enable it. By default transport is always
1751 * enabled after it is created. Disabling a transport does not necessarily
1752 * close the socket, it will only discard incoming messages and prevent
1753 * the transport from being used to send outgoing messages.
1754 *
1755 * @param id Transport ID.
1756 * @param enabled Non-zero to enable, zero to disable.
1757 *
1758 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001759 *
1760 * \par Python:
1761 * \code
1762 status = py_pjsua.transport_set_enable(id, enabled)
1763 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001764 */
1765PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1766 pj_bool_t enabled);
1767
1768
1769/**
1770 * Close the transport. If transport is forcefully closed, it will be
1771 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00001772 * transport may not terminate properly (it may even crash). Otherwise,
1773 * the system will wait until all transactions are closed while preventing
1774 * new users from using the transport, and will close the transport when
1775 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001776 *
1777 * @param id Transport ID.
1778 * @param force Non-zero to immediately close the transport. This
1779 * is not recommended!
1780 *
1781 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001782 *
1783 * \par Python:
1784 * \code
1785 status = py_pjsua.transport_close(id, force)
1786 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001787 */
1788PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1789 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001790
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001791/**
Benny Prijono312aff92006-06-17 04:08:30 +00001792 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001793 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001794
1795
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001796
1797
1798/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001799 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001800 */
1801
Benny Prijono312aff92006-06-17 04:08:30 +00001802
1803/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001804 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001805 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001806 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001807 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001808 *
Benny Prijono312aff92006-06-17 04:08:30 +00001809 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001810 * using the application. In SIP terms, the identity is used as the <b>From</b>
1811 * header in outgoing requests.
1812 *
1813 * PJSUA-API supports creating and managing multiple accounts. The maximum
1814 * number of accounts is limited by a compile time constant
1815 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001816 *
1817 * Account may or may not have client registration associated with it.
1818 * An account is also associated with <b>route set</b> and some <b>authentication
1819 * credentials</b>, which are used when sending SIP request messages using the
1820 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00001821 * will be reported to remote peer when they subscribe to the account's
1822 * presence, or which is published to a presence server if presence
1823 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00001824 *
1825 * At least one account MUST be created in the application. If no user
1826 * association is required, application can create a userless account by
1827 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00001828 * instead of a particular user, and it correspond with a particular
1829 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00001830 *
1831 * Also one account must be set as the <b>default account</b>, which is used as
1832 * the account to use when PJSUA fails to match a request with any other
1833 * accounts.
1834 *
1835 * When sending outgoing SIP requests (such as making calls or sending
1836 * instant messages), normally PJSUA requires the application to specify
1837 * which account to use for the request. If no account is specified,
1838 * PJSUA may be able to select the account by matching the destination
1839 * domain name, and fall back to default account when no match is found.
1840 */
1841
1842/**
1843 * Maximum accounts.
1844 */
1845#ifndef PJSUA_MAX_ACC
1846# define PJSUA_MAX_ACC 8
1847#endif
1848
1849
1850/**
1851 * Default registration interval.
1852 */
1853#ifndef PJSUA_REG_INTERVAL
Benny Prijonobddef2c2007-10-31 13:28:08 +00001854# define PJSUA_REG_INTERVAL 300
Benny Prijono312aff92006-06-17 04:08:30 +00001855#endif
1856
1857
1858/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001859 * Default PUBLISH expiration
1860 */
1861#ifndef PJSUA_PUBLISH_EXPIRATION
1862# define PJSUA_PUBLISH_EXPIRATION 600
1863#endif
1864
1865
1866/**
Benny Prijono093d3022006-09-24 00:07:11 +00001867 * Default account priority.
1868 */
1869#ifndef PJSUA_DEFAULT_ACC_PRIORITY
1870# define PJSUA_DEFAULT_ACC_PRIORITY 0
1871#endif
1872
1873
1874/**
Benny Prijono8058a622007-06-08 04:37:05 +00001875 * This macro specifies the URI scheme to use in Contact header
1876 * when secure transport such as TLS is used. Application can specify
1877 * either "sip" or "sips".
1878 */
1879#ifndef PJSUA_SECURE_SCHEME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00001880# define PJSUA_SECURE_SCHEME "sips"
Benny Prijono8058a622007-06-08 04:37:05 +00001881#endif
1882
1883
1884/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001885 * This structure describes account configuration to be specified when
1886 * adding a new account with #pjsua_acc_add(). Application MUST initialize
1887 * this structure first by calling #pjsua_acc_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00001888 *
1889 * \par Python:
1890 * The data type in Python is <tt>py_pjsua.Acc_Config</tt>, but normally
1891 * application can just use the snippet below to create and initialize
1892 * the account config:
1893 * \code
1894 acc_cfg = py_pjsua.acc_config_default()
1895 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001896 */
1897typedef struct pjsua_acc_config
1898{
Benny Prijono093d3022006-09-24 00:07:11 +00001899 /**
1900 * Account priority, which is used to control the order of matching
1901 * incoming/outgoing requests. The higher the number means the higher
1902 * the priority is, and the account will be matched first.
1903 */
1904 int priority;
1905
Benny Prijono312aff92006-06-17 04:08:30 +00001906 /**
1907 * The full SIP URL for the account. The value can take name address or
1908 * URL format, and will look something like "sip:account@serviceprovider".
1909 *
1910 * This field is mandatory.
1911 */
1912 pj_str_t id;
1913
1914 /**
1915 * This is the URL to be put in the request URI for the registration,
1916 * and will look something like "sip:serviceprovider".
1917 *
1918 * This field should be specified if registration is desired. If the
1919 * value is empty, no account registration will be performed.
1920 */
1921 pj_str_t reg_uri;
1922
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001923 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001924 * If this flag is set, the presence information of this account will
1925 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono48ab2b72007-11-08 09:24:30 +00001926 *
1927 * Default: PJ_FALSE
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001928 */
1929 pj_bool_t publish_enabled;
1930
Benny Prijonofe04fb52007-08-24 08:28:52 +00001931 /**
Benny Prijono48ab2b72007-11-08 09:24:30 +00001932 * Authentication preference.
1933 */
1934 pjsip_auth_clt_pref auth_pref;
1935
1936 /**
Benny Prijonofe04fb52007-08-24 08:28:52 +00001937 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
1938 * is not specified, a random string will be used.
1939 */
1940 pj_str_t pidf_tuple_id;
1941
Benny Prijono312aff92006-06-17 04:08:30 +00001942 /**
1943 * Optional URI to be put as Contact for this account. It is recommended
1944 * that this field is left empty, so that the value will be calculated
1945 * automatically based on the transport address.
1946 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00001947 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00001948
1949 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001950 * Specify whether support for reliable provisional response (100rel and
1951 * PRACK) should be required for all sessions of this account.
1952 *
1953 * Default: PJ_FALSE
1954 */
1955 pj_bool_t require_100rel;
1956
1957 /**
Benny Prijono312aff92006-06-17 04:08:30 +00001958 * Number of proxies in the proxy array below.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001959 *
1960 * \par Python:
1961 * Not applicable, as \a proxy is implemented as list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001962 */
1963 unsigned proxy_cnt;
1964
1965 /**
1966 * Optional URI of the proxies to be visited for all outgoing requests
1967 * that are using this account (REGISTER, INVITE, etc). Application need
1968 * to specify these proxies if the service provider requires that requests
1969 * destined towards its network should go through certain proxies first
1970 * (for example, border controllers).
1971 *
1972 * These proxies will be put in the route set for this account, with
1973 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00001974 * first). If global outbound proxies are configured in pjsua_config,
1975 * then these account proxies will be placed after the global outbound
1976 * proxies in the routeset.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001977 *
1978 * \par Python:
1979 * This will be list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001980 */
1981 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
1982
1983 /**
1984 * Optional interval for registration, in seconds. If the value is zero,
Benny Prijonobddef2c2007-10-31 13:28:08 +00001985 * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
Benny Prijono312aff92006-06-17 04:08:30 +00001986 */
1987 unsigned reg_timeout;
1988
1989 /**
1990 * Number of credentials in the credential array.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001991 *
1992 * \par Python:
1993 * Not applicable, since \a cred_info is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00001994 */
1995 unsigned cred_count;
1996
1997 /**
1998 * Array of credentials. If registration is desired, normally there should
1999 * be at least one credential specified, to successfully authenticate
2000 * against the service provider. More credentials can be specified, for
2001 * example when the requests are expected to be challenged by the
2002 * proxies in the route set.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002003 *
2004 * \par Python:
2005 * This field is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00002006 */
2007 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
2008
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002009 /**
2010 * Optionally bind this account to specific transport. This normally is
2011 * not a good idea, as account should be able to send requests using
2012 * any available transports according to the destination. But some
2013 * application may want to have explicit control over the transport to
2014 * use, so in that case it can set this field.
2015 *
2016 * Default: -1 (PJSUA_INVALID_ID)
2017 *
2018 * @see pjsua_acc_set_transport()
2019 */
2020 pjsua_transport_id transport_id;
2021
Benny Prijono15b02302007-09-27 14:07:07 +00002022 /**
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002023 * This option is used to update the UDP transport address and the Contact
2024 * header of REGISTER request. When this option is enabled, the library
2025 * will keep track of the public IP address from the response of REGISTER
2026 * request. Once it detects that the address has changed, it will
2027 * unregister current Contact, update the Contact with transport address
2028 * learned from Via header, and register a new Contact to the registrar.
2029 * This will also update the public name of UDP transport if STUN is
2030 * configured.
Benny Prijono15b02302007-09-27 14:07:07 +00002031 *
2032 * Default: 1 (yes)
2033 */
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002034 pj_bool_t allow_contact_rewrite;
Benny Prijono15b02302007-09-27 14:07:07 +00002035
Benny Prijonobddef2c2007-10-31 13:28:08 +00002036 /**
2037 * Set the interval for periodic keep-alive transmission for this account.
2038 * If this value is zero, keep-alive will be disabled for this account.
2039 * The keep-alive transmission will be sent to the registrar's address,
2040 * after successful registration.
2041 *
Benny Prijonobddef2c2007-10-31 13:28:08 +00002042 * Default: 15 (seconds)
2043 */
2044 unsigned ka_interval;
2045
2046 /**
2047 * Specify the data to be transmitted as keep-alive packets.
2048 *
2049 * Default: CR-LF
2050 */
2051 pj_str_t ka_data;
2052
Benny Prijonod8179652008-01-23 20:39:07 +00002053#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
2054 /**
2055 * Specify whether secure media transport should be used for this account.
2056 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
2057 * PJMEDIA_SRTP_MANDATORY.
2058 *
2059 * Default: #PJSUA_DEFAULT_USE_SRTP
2060 */
2061 pjmedia_srtp_use use_srtp;
2062
2063 /**
2064 * Specify whether SRTP requires secure signaling to be used. This option
2065 * is only used when \a use_srtp option above is non-zero.
2066 *
2067 * Valid values are:
2068 * 0: SRTP does not require secure signaling
2069 * 1: SRTP requires secure transport such as TLS
2070 * 2: SRTP requires secure end-to-end transport (SIPS)
2071 *
2072 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
2073 */
2074 int srtp_secure_signaling;
2075#endif
2076
Benny Prijono312aff92006-06-17 04:08:30 +00002077} pjsua_acc_config;
2078
2079
2080/**
2081 * Call this function to initialize account config with default values.
2082 *
2083 * @param cfg The account config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002084 *
2085 * \par Python:
2086 * In Python, this function both creates and initializes the account
2087 * config:
2088 * \code
2089 acc_cfg = py_pjsua.acc_config_default()
2090 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002091 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00002092PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002093
2094
2095/**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002096 * Duplicate account config.
2097 *
2098 * @param pool Pool to be used for duplicating the config.
2099 * @param dst Destination configuration.
2100 * @param src Source configuration.
2101 */
2102PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
2103 pjsua_acc_config *dst,
2104 const pjsua_acc_config *src);
2105
2106
2107/**
Benny Prijono312aff92006-06-17 04:08:30 +00002108 * Account info. Application can query account info by calling
2109 * #pjsua_acc_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00002110 *
2111 * \par Python:
2112 * The data type in Python is <tt>py_pjsua.Acc_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002113 */
2114typedef struct pjsua_acc_info
2115{
2116 /**
2117 * The account ID.
2118 */
2119 pjsua_acc_id id;
2120
2121 /**
2122 * Flag to indicate whether this is the default account.
2123 */
2124 pj_bool_t is_default;
2125
2126 /**
2127 * Account URI
2128 */
2129 pj_str_t acc_uri;
2130
2131 /**
2132 * Flag to tell whether this account has registration setting
2133 * (reg_uri is not empty).
2134 */
2135 pj_bool_t has_registration;
2136
2137 /**
2138 * An up to date expiration interval for account registration session.
2139 */
2140 int expires;
2141
2142 /**
2143 * Last registration status code. If status code is zero, the account
2144 * is currently not registered. Any other value indicates the SIP
2145 * status code of the registration.
2146 */
2147 pjsip_status_code status;
2148
2149 /**
2150 * String describing the registration status.
2151 */
2152 pj_str_t status_text;
2153
2154 /**
2155 * Presence online status for this account.
2156 */
2157 pj_bool_t online_status;
2158
2159 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00002160 * Presence online status text.
2161 */
2162 pj_str_t online_status_text;
2163
2164 /**
2165 * Extended RPID online status information.
2166 */
2167 pjrpid_element rpid;
2168
2169 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002170 * Buffer that is used internally to store the status text.
2171 */
2172 char buf_[PJ_ERR_MSG_SIZE];
2173
2174} pjsua_acc_info;
2175
2176
2177
2178/**
2179 * Get number of current accounts.
2180 *
2181 * @return Current number of accounts.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002182 *
2183 * \par Python:
2184 * \code
2185 count = py_pjsua.acc_get_count()
2186 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002187 */
2188PJ_DECL(unsigned) pjsua_acc_get_count(void);
2189
2190
2191/**
2192 * Check if the specified account ID is valid.
2193 *
2194 * @param acc_id Account ID to check.
2195 *
2196 * @return Non-zero if account ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002197 *
2198 * \par Python:
2199 * \code
2200 is_valid = py_pjsua.acc_is_valid(acc_id)
2201 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002202 */
2203PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
2204
2205
2206/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00002207 * Set default account to be used when incoming and outgoing
2208 * requests doesn't match any accounts.
2209 *
2210 * @param acc_id The account ID to be used as default.
2211 *
2212 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002213 *
2214 * \par Python:
2215 * \code
2216 status = py_pjsua.acc_set_default(acc_id)
2217 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002218 */
2219PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2220
2221
2222/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002223 * Get default account to be used when receiving incoming requests (calls),
2224 * when the destination of the incoming call doesn't match any other
2225 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002226 *
2227 * @return The default account ID, or PJSUA_INVALID_ID if no
2228 * default account is configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002229 *
2230 * \par Python:
2231 * \code
2232 acc_id = py_pjsua.acc_get_default()
2233 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002234 */
2235PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2236
2237
2238/**
Benny Prijono312aff92006-06-17 04:08:30 +00002239 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002240 * #pjsua_init()) before calling this function. If registration is configured
2241 * for this account, this function would also start the SIP registration
2242 * session with the SIP registrar server. This SIP registration session
2243 * will be maintained internally by the library, and application doesn't
2244 * need to do anything to maintain the registration session.
2245 *
Benny Prijono312aff92006-06-17 04:08:30 +00002246 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002247 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002248 * @param is_default If non-zero, this account will be set as the default
2249 * account. The default account will be used when sending
2250 * outgoing requests (e.g. making call) when no account is
2251 * specified, and when receiving incoming requests when the
2252 * request does not match any accounts. It is recommended
2253 * that default account is set to local/LAN account.
2254 * @param p_acc_id Pointer to receive account ID of the new account.
2255 *
2256 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002257 *
2258 * \par Python:
2259 * The function returns (status, account_id) tuple:
2260 * \code
2261 status, account_id = py_pjsua.acc_add(acc_cfg, is_default)
2262 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002263 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002264PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002265 pj_bool_t is_default,
2266 pjsua_acc_id *p_acc_id);
2267
2268
2269/**
2270 * Add a local account. A local account is used to identify local endpoint
2271 * instead of a specific user, and for this reason, a transport ID is needed
2272 * to obtain the local address information.
2273 *
2274 * @param tid Transport ID to generate account address.
2275 * @param is_default If non-zero, this account will be set as the default
2276 * account. The default account will be used when sending
2277 * outgoing requests (e.g. making call) when no account is
2278 * specified, and when receiving incoming requests when the
2279 * request does not match any accounts. It is recommended
2280 * that default account is set to local/LAN account.
2281 * @param p_acc_id Pointer to receive account ID of the new account.
2282 *
2283 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002284 *
2285 * \par Python:
2286 * The function returns (status, account_id) tuple:
2287 * \code
2288 status, account_id = py_pjsua.acc_add_local(tid, is_default)
2289 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002290 */
2291PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2292 pj_bool_t is_default,
2293 pjsua_acc_id *p_acc_id);
2294
2295/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002296 * Delete an account. This will unregister the account from the SIP server,
2297 * if necessary, and terminate server side presence subscriptions associated
2298 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002299 *
2300 * @param acc_id Id of the account to be deleted.
2301 *
2302 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002303 *
2304 * \par Python:
2305 * \code
2306 status = py_pjsua.acc_del(acc_id)
2307 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002308 */
2309PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2310
2311
2312/**
2313 * Modify account information.
2314 *
2315 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002316 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002317 *
2318 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002319 *
2320 * \par Python:
2321 * \code
2322 status = py_pjsua.acc_modify(acc_id, acc_cfg)
2323 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002324 */
2325PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002326 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002327
2328
2329/**
2330 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002331 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002332 * if there are server side presence subscription for this account, and/or
2333 * outgoing PUBLISH if presence publication is enabled for this account.
2334 *
2335 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002336 *
2337 * @param acc_id The account ID.
2338 * @param is_online True of false.
2339 *
2340 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002341 *
2342 * \par Python:
2343 * \code
2344 status = py_pjsua.acc_set_online_status(acc_id, is_online)
2345 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002346 */
2347PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2348 pj_bool_t is_online);
2349
Benny Prijono4461c7d2007-08-25 13:36:15 +00002350/**
2351 * Modify account's presence status to be advertised to remote/presence
2352 * subscribers. This would trigger the sending of outgoing NOTIFY request
2353 * if there are server side presence subscription for this account, and/or
2354 * outgoing PUBLISH if presence publication is enabled for this account.
2355 *
2356 * @see pjsua_acc_set_online_status()
2357 *
2358 * @param acc_id The account ID.
2359 * @param is_online True of false.
2360 * @param pr Extended information in subset of RPID format
2361 * which allows setting custom presence text.
2362 *
2363 * @return PJ_SUCCESS on success, or the appropriate error code.
2364 */
2365PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2366 pj_bool_t is_online,
2367 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002368
2369/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002370 * Update registration or perform unregistration. If registration is
2371 * configured for this account, then initial SIP REGISTER will be sent
2372 * when the account is added with #pjsua_acc_add(). Application normally
2373 * only need to call this function if it wants to manually update the
2374 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002375 *
2376 * @param acc_id The account ID.
2377 * @param renew If renew argument is zero, this will start
2378 * unregistration process.
2379 *
2380 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002381 *
2382 * \par Python:
2383 * \code
2384 status = py_pjsua.acc_set_registration(acc_id, renew)
2385 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002386 */
2387PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2388 pj_bool_t renew);
2389
2390
2391/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002392 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002393 *
2394 * @param acc_id Account identification.
2395 * @param info Pointer to receive account information.
2396 *
2397 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002398 *
2399 * \par Python:
2400 * \code
2401 acc_info = py_pjsua.acc_get_info(acc_id)
2402 * \endcode
2403 * The function returns None if account ID is not valid.
Benny Prijono312aff92006-06-17 04:08:30 +00002404 */
2405PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2406 pjsua_acc_info *info);
2407
2408
2409/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002410 * Enumerate all account currently active in the library. This will fill
2411 * the array with the account Ids, and application can then query the
2412 * account information for each id with #pjsua_acc_get_info().
2413 *
2414 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002415 *
2416 * @param ids Array of account IDs to be initialized.
2417 * @param count In input, specifies the maximum number of elements.
2418 * On return, it contains the actual number of elements.
2419 *
2420 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002421 *
2422 * \par Python:
2423 * The function takes no argument and returns list of account Ids:
2424 * \code
2425 [acc_ids] = py_pjsua.enum_accs()
2426 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002427 */
2428PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2429 unsigned *count );
2430
2431
2432/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002433 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002434 *
2435 * @param info Array of account infos to be initialized.
2436 * @param count In input, specifies the maximum number of elements.
2437 * On return, it contains the actual number of elements.
2438 *
2439 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002440 *
2441 * \par Python:
2442 * The function takes no argument and returns list of account infos:
2443 * \code
2444 [acc_info] = py_pjsua.acc_enum_info()
2445 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002446 */
2447PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2448 unsigned *count );
2449
2450
2451/**
2452 * This is an internal function to find the most appropriate account to
2453 * used to reach to the specified URL.
2454 *
2455 * @param url The remote URL to reach.
2456 *
2457 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002458 *
2459 * \par Python:
2460 * \code
2461 acc_id = py_pjsua.acc_find_for_outgoing(url)
2462 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002463 */
2464PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2465
2466
2467/**
2468 * This is an internal function to find the most appropriate account to be
2469 * used to handle incoming calls.
2470 *
2471 * @param rdata The incoming request message.
2472 *
2473 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002474 *
2475 * \par Python:
2476 * \code
2477 acc_id = py_pjsua.acc_find_for_outgoing(url)
2478 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002479 */
2480PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2481
2482
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002483/**
Benny Prijonofff245c2007-04-02 11:44:47 +00002484 * Create arbitrary requests using the account. Application should only use
2485 * this function to create auxiliary requests outside dialog, such as
2486 * OPTIONS, and use the call or presence API to create dialog related
2487 * requests.
2488 *
2489 * @param acc_id The account ID.
2490 * @param method The SIP method of the request.
2491 * @param target Target URI.
2492 * @param p_tdata Pointer to receive the request.
2493 *
2494 * @return PJ_SUCCESS or the error code.
2495 */
2496PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
2497 const pjsip_method *method,
2498 const pj_str_t *target,
2499 pjsip_tx_data **p_tdata);
2500
2501
2502/**
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002503 * Create a suitable URI to be put as Contact based on the specified
2504 * target URI for the specified account.
2505 *
2506 * @param pool Pool to allocate memory for the string.
2507 * @param contact The string where the Contact URI will be stored.
2508 * @param acc_id Account ID.
2509 * @param uri Destination URI of the request.
2510 *
2511 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002512 *
2513 * \par Python:
2514 * This function is still experimental in Python:
2515 * \code
2516 uri = py_pjsua.acc_create_uac_contact(pool, acc_id, uri)
2517 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002518 */
2519PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
2520 pj_str_t *contact,
2521 pjsua_acc_id acc_id,
2522 const pj_str_t *uri);
2523
2524
2525
2526/**
2527 * Create a suitable URI to be put as Contact based on the information
2528 * in the incoming request.
2529 *
2530 * @param pool Pool to allocate memory for the string.
2531 * @param contact The string where the Contact URI will be stored.
2532 * @param acc_id Account ID.
2533 * @param rdata Incoming request.
2534 *
2535 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002536 *
2537 * \par Python:
2538 * This function is still experimental in Python:
2539 * \code
2540 uri = py_pjsua.acc_create_uas_contact(pool, acc_id, rdata)
2541 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002542 */
2543PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
2544 pj_str_t *contact,
2545 pjsua_acc_id acc_id,
2546 pjsip_rx_data *rdata );
2547
2548
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002549/**
2550 * Lock/bind this account to a specific transport/listener. Normally
2551 * application shouldn't need to do this, as transports will be selected
2552 * automatically by the stack according to the destination.
2553 *
2554 * When account is locked/bound to a specific transport, all outgoing
2555 * requests from this account will use the specified transport (this
2556 * includes SIP registration, dialog (call and event subscription), and
2557 * out-of-dialog requests such as MESSAGE).
2558 *
2559 * Note that transport_id may be specified in pjsua_acc_config too.
2560 *
2561 * @param acc_id The account ID.
2562 * @param tp_id The transport ID.
2563 *
2564 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002565 *
2566 * \par Python:
2567 * Not yet implemented.
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002568 */
2569PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
2570 pjsua_transport_id tp_id);
2571
Benny Prijono312aff92006-06-17 04:08:30 +00002572
2573/**
2574 * @}
2575 */
2576
2577
2578/*****************************************************************************
2579 * CALLS API
2580 */
2581
2582
2583/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002584 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00002585 * @ingroup PJSUA_LIB
2586 * @brief Call manipulation.
2587 * @{
2588 */
2589
2590/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002591 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00002592 */
2593#ifndef PJSUA_MAX_CALLS
2594# define PJSUA_MAX_CALLS 32
2595#endif
2596
2597
2598
2599/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002600 * This enumeration specifies the media status of a call, and it's part
2601 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00002602 */
2603typedef enum pjsua_call_media_status
2604{
Benny Prijonob5388cf2007-01-04 22:45:08 +00002605 /** Call currently has no media */
Benny Prijono312aff92006-06-17 04:08:30 +00002606 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002607
2608 /** The media is active */
Benny Prijono312aff92006-06-17 04:08:30 +00002609 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002610
2611 /** The media is currently put on hold by local endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002612 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002613
2614 /** The media is currently put on hold by remote endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002615 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002616
Benny Prijono096c56c2007-09-15 08:30:16 +00002617 /** The media has reported error (e.g. ICE negotiation) */
2618 PJSUA_CALL_MEDIA_ERROR
2619
Benny Prijono312aff92006-06-17 04:08:30 +00002620} pjsua_call_media_status;
2621
2622
2623/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002624 * This structure describes the information and current status of a call.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002625 *
2626 * \par Python:
2627 * The type name is <tt>py_pjsua.Call_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002628 */
2629typedef struct pjsua_call_info
2630{
2631 /** Call identification. */
2632 pjsua_call_id id;
2633
2634 /** Initial call role (UAC == caller) */
2635 pjsip_role_e role;
2636
Benny Prijono90315512006-09-14 16:05:16 +00002637 /** The account ID where this call belongs. */
2638 pjsua_acc_id acc_id;
2639
Benny Prijono312aff92006-06-17 04:08:30 +00002640 /** Local URI */
2641 pj_str_t local_info;
2642
2643 /** Local Contact */
2644 pj_str_t local_contact;
2645
2646 /** Remote URI */
2647 pj_str_t remote_info;
2648
2649 /** Remote contact */
2650 pj_str_t remote_contact;
2651
2652 /** Dialog Call-ID string. */
2653 pj_str_t call_id;
2654
2655 /** Call state */
2656 pjsip_inv_state state;
2657
2658 /** Text describing the state */
2659 pj_str_t state_text;
2660
2661 /** Last status code heard, which can be used as cause code */
2662 pjsip_status_code last_status;
2663
2664 /** The reason phrase describing the status. */
2665 pj_str_t last_status_text;
2666
2667 /** Call media status. */
2668 pjsua_call_media_status media_status;
2669
2670 /** Media direction */
2671 pjmedia_dir media_dir;
2672
2673 /** The conference port number for the call */
2674 pjsua_conf_port_id conf_slot;
2675
2676 /** Up-to-date call connected duration (zero when call is not
2677 * established)
2678 */
2679 pj_time_val connect_duration;
2680
2681 /** Total call duration, including set-up time */
2682 pj_time_val total_duration;
2683
2684 /** Internal */
2685 struct {
2686 char local_info[128];
2687 char local_contact[128];
2688 char remote_info[128];
2689 char remote_contact[128];
2690 char call_id[128];
2691 char last_status_text[128];
2692 } buf_;
2693
2694} pjsua_call_info;
2695
2696
2697
Benny Prijonoa91a0032006-02-26 21:23:45 +00002698/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002699 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002700 *
2701 * @return Maximum number of calls configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002702 *
2703 * \par Python:
2704 * \code
2705 count = py_pjsua.call_get_max_count()
2706 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002707 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002708PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002709
2710/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002711 * Get number of currently active calls.
2712 *
2713 * @return Number of currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002714 *
2715 * \par Python:
2716 * \code
2717 count = py_pjsua.call_get_count()
2718 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002719 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002720PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002721
2722/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002723 * Enumerate all active calls. Application may then query the information and
2724 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002725 *
2726 * @param ids Array of account IDs to be initialized.
2727 * @param count In input, specifies the maximum number of elements.
2728 * On return, it contains the actual number of elements.
2729 *
2730 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002731 *
2732 * \par Python:
2733 * This function takes no argument and return list of call Ids.
2734 * \code
2735 [call_ids] = py_pjsua.enum_calls()
2736 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002737 */
2738PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
2739 unsigned *count);
2740
2741
2742/**
2743 * Make outgoing call to the specified URI using the specified account.
2744 *
2745 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002746 * @param dst_uri URI to be put in the To header (normally is the same
2747 * as the target URI).
2748 * @param options Options (must be zero at the moment).
2749 * @param user_data Arbitrary user data to be attached to the call, and
2750 * can be retrieved later.
2751 * @param msg_data Optional headers etc to be added to outgoing INVITE
2752 * request, or NULL if no custom header is desired.
2753 * @param p_call_id Pointer to receive call identification.
2754 *
2755 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002756 *
2757 * \par Python:
2758 * The Python function returns (status, call_id) tuple:
2759 * \code
2760 status, call_id = py_pjsua.call_make_call(acc_id, dst_uri, options,
2761 user_data, msg_data)
2762 * \endcode
2763 * Note: the \a user_data in Python function is an integer, and the
2764 * \a msg_data can be set to None if not required.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002765 */
2766PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
2767 const pj_str_t *dst_uri,
2768 unsigned options,
2769 void *user_data,
2770 const pjsua_msg_data *msg_data,
2771 pjsua_call_id *p_call_id);
2772
2773
2774/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002775 * Check if the specified call has active INVITE session and the INVITE
2776 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002777 *
2778 * @param call_id Call identification.
2779 *
2780 * @return Non-zero if call is active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002781 *
2782 * \par Python:
2783 * \code
2784 bool = py_pjsua.call_is_active(call_id)
2785 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002786 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002787PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002788
2789
2790/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002791 * Check if call has an active media session.
2792 *
2793 * @param call_id Call identification.
2794 *
2795 * @return Non-zero if yes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002796 *
2797 * \par Python:
2798 * \code
2799 bool = py_pjsua.call_has_media(call_id)
2800 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002801 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002802PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002803
2804
2805/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002806 * Get the conference port identification associated with the call.
2807 *
2808 * @param call_id Call identification.
2809 *
2810 * @return Conference port ID, or PJSUA_INVALID_ID when the
2811 * media has not been established or is not active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002812 *
2813 * \par Python:
2814 * \code
2815 slot = py_pjsua.call_get_conf_port(call_id)
2816 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002817 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002818PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
2819
2820/**
2821 * Obtain detail information about the specified call.
2822 *
2823 * @param call_id Call identification.
2824 * @param info Call info to be initialized.
2825 *
2826 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002827 *
2828 * \par Python:
2829 * \code
2830 call_info = py_pjsua.call_get_info(call_id)
2831 * \endcode
2832 * \a call_info return value will be set to None if call_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002833 */
2834PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002835 pjsua_call_info *info);
2836
2837
2838/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002839 * Attach application specific data to the call. Application can then
2840 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002841 *
2842 * @param call_id Call identification.
2843 * @param user_data Arbitrary data to be attached to the call.
2844 *
2845 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002846 *
2847 * \par Python:
2848 * \code
2849 status = py_pjsua.call_set_user_data(call_id, user_data)
2850 * \endcode
2851 * The \a user_data is an integer in the Python function.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002852 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002853PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
2854 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002855
2856
2857/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002858 * Get user data attached to the call, which has been previously set with
2859 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002860 *
2861 * @param call_id Call identification.
2862 *
2863 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002864 *
2865 * \par Python:
2866 * \code
2867 user_data = py_pjsua.call_get_user_data(call_id)
2868 * \endcode
2869 * The \a user_data is an integer.
Benny Prijono268ca612006-02-07 12:34:11 +00002870 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002871PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00002872
2873
2874/**
Benny Prijono91a6a172007-10-31 08:59:29 +00002875 * Get the NAT type of remote's endpoint. This is a proprietary feature
2876 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
2877 * is set in #pjsua_config.
2878 *
2879 * This function can only be called after SDP has been received from remote,
2880 * which means for incoming call, this function can be called as soon as
2881 * call is received as long as incoming call contains SDP, and for outgoing
2882 * call, this function can be called only after SDP is received (normally in
2883 * 200/OK response to INVITE). As a general case, application should call
2884 * this function after or in \a on_call_media_state() callback.
2885 *
2886 * @param call_id Call identification.
2887 * @param p_type Pointer to store the NAT type. Application can then
2888 * retrieve the string description of the NAT type
2889 * by calling pj_stun_get_nat_name().
2890 *
2891 * @return PJ_SUCCESS on success.
2892 *
2893 * @see pjsua_get_nat_type(), nat_type_in_sdp
2894 */
2895PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
2896 pj_stun_nat_type *p_type);
2897
2898/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002899 * Send response to incoming INVITE request. Depending on the status
2900 * code specified as parameter, this function may send provisional
2901 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002902 *
2903 * @param call_id Incoming call identification.
2904 * @param code Status code, (100-699).
2905 * @param reason Optional reason phrase. If NULL, default text
2906 * will be used.
2907 * @param msg_data Optional list of headers etc to be added to outgoing
2908 * response message.
2909 *
2910 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002911 *
2912 * \par Python:
2913 * \code
2914 status = py_pjsua.call_answer(call_id, code, reason, msg_data)
2915 * \endcode
2916 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijonoa91a0032006-02-26 21:23:45 +00002917 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002918PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
2919 unsigned code,
2920 const pj_str_t *reason,
2921 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00002922
2923/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002924 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00002925 * call state. This function is different than answering the call with
2926 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
2927 * will hangup the call regardless of the state and role of the call,
2928 * while #pjsua_call_answer() only works with incoming calls on EARLY
2929 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002930 *
2931 * @param call_id Call identification.
2932 * @param code Optional status code to be sent when we're rejecting
2933 * incoming call. If the value is zero, "603/Decline"
2934 * will be sent.
2935 * @param reason Optional reason phrase to be sent when we're rejecting
2936 * incoming call. If NULL, default text will be used.
2937 * @param msg_data Optional list of headers etc to be added to outgoing
2938 * request/response message.
2939 *
2940 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002941 *
2942 * \par Python:
2943 * \code
2944 status = py_pjsua.call_hangup(call_id, code, reason, msg_data)
2945 * \endcode
2946 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002947 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002948PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
2949 unsigned code,
2950 const pj_str_t *reason,
2951 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002952
2953
2954/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002955 * Put the specified call on hold. This will send re-INVITE with the
2956 * appropriate SDP to inform remote that the call is being put on hold.
2957 * The final status of the request itself will be reported on the
2958 * \a on_call_media_state() callback, which inform the application that
2959 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002960 *
2961 * @param call_id Call identification.
2962 * @param msg_data Optional message components to be sent with
2963 * the request.
2964 *
2965 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002966 *
2967 * \par Python:
2968 * \code
2969 status = py_pjsua.call_set_hold(call_id, msg_data)
2970 * \endcode
2971 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002972 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002973PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
2974 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002975
2976
2977/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002978 * Send re-INVITE to release hold.
2979 * The final status of the request itself will be reported on the
2980 * \a on_call_media_state() callback, which inform the application that
2981 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002982 *
2983 * @param call_id Call identification.
2984 * @param unhold If this argument is non-zero and the call is locally
2985 * held, this will release the local hold.
2986 * @param msg_data Optional message components to be sent with
2987 * the request.
2988 *
2989 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002990 *
2991 * \par Python:
2992 * \code
2993 status = py_pjsua.call_reinvite(call_id, unhold, msg_data)
2994 * \endcode
2995 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002996 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002997PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
2998 pj_bool_t unhold,
2999 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003000
Benny Prijonoc08682e2007-10-04 06:17:58 +00003001/**
3002 * Send UPDATE request.
3003 *
3004 * @param call_id Call identification.
3005 * @param options Must be zero for now.
3006 * @param msg_data Optional message components to be sent with
3007 * the request.
3008 *
3009 * @return PJ_SUCCESS on success, or the appropriate error code.
3010 */
3011PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
3012 unsigned options,
3013 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003014
3015/**
Benny Prijono053f5222006-11-11 16:16:04 +00003016 * Initiate call transfer to the specified address. This function will send
3017 * REFER request to instruct remote call party to initiate a new INVITE
3018 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003019 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00003020 * If application is interested to monitor the successfulness and
3021 * the progress of the transfer request, it can implement
3022 * \a on_call_transfer_status() callback which will report the progress
3023 * of the call transfer request.
3024 *
Benny Prijono053f5222006-11-11 16:16:04 +00003025 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003026 * @param dest Address of new target to be contacted.
3027 * @param msg_data Optional message components to be sent with
3028 * the request.
3029 *
3030 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003031 *
3032 * \par Python:
3033 * \code
3034 status = py_pjsua.call_xfer(call_id, dest, msg_data)
3035 * \endcode
3036 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003037 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003038PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
3039 const pj_str_t *dest,
3040 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003041
3042/**
Benny Prijono053f5222006-11-11 16:16:04 +00003043 * Flag to indicate that "Require: replaces" should not be put in the
3044 * outgoing INVITE request caused by REFER request created by
3045 * #pjsua_call_xfer_replaces().
3046 */
3047#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
3048
3049/**
3050 * Initiate attended call transfer. This function will send REFER request
3051 * to instruct remote call party to initiate new INVITE session to the URL
3052 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
3053 * the call with us with the new call from the REFER recipient.
3054 *
3055 * @param call_id The call id to be transfered.
3056 * @param dest_call_id The call id to be replaced.
3057 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
3058 * to suppress the inclusion of "Require: replaces" in
3059 * the outgoing INVITE request created by the REFER
3060 * request.
3061 * @param msg_data Optional message components to be sent with
3062 * the request.
3063 *
3064 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003065 *
3066 * \par Python:
3067 * \code
3068 status = py_pjsua.call_xfer_replaces(call_id, dest_call_id, options, msg_data)
3069 * \endcode
3070 * Argument \a msg_data may be set to None if not required.
Benny Prijono053f5222006-11-11 16:16:04 +00003071 */
3072PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
3073 pjsua_call_id dest_call_id,
3074 unsigned options,
3075 const pjsua_msg_data *msg_data);
3076
3077/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003078 * Send DTMF digits to remote using RFC 2833 payload formats.
3079 *
3080 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003081 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003082 *
3083 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003084 *
3085 * \par Python:
3086 * \code
3087 status = py_pjsua.call_dial_dtmf(call_id, digits)
3088 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003089 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003090PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003091 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00003092
Benny Prijono26ff9062006-02-21 23:47:00 +00003093/**
Benny Prijonob0808372006-03-02 21:18:58 +00003094 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003095 *
3096 * @param call_id Call identification.
3097 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3098 * assumed.
3099 * @param content The message content.
3100 * @param msg_data Optional list of headers etc to be included in outgoing
3101 * request. The body descriptor in the msg_data is
3102 * ignored.
3103 * @param user_data Optional user data, which will be given back when
3104 * the IM callback is called.
3105 *
3106 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003107 *
3108 * \par Python:
3109 * \code
3110 status = py_pjsua.call_send_im(call_id, mime_type, content, msg_data, user_data)
3111 * \endcode
3112 * Note that the \a user_data argument is an integer in Python.
Benny Prijonob0808372006-03-02 21:18:58 +00003113 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003114PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
3115 const pj_str_t *mime_type,
3116 const pj_str_t *content,
3117 const pjsua_msg_data *msg_data,
3118 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003119
3120
3121/**
3122 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003123 *
3124 * @param call_id Call identification.
3125 * @param is_typing Non-zero to indicate to remote that local person is
3126 * currently typing an IM.
3127 * @param msg_data Optional list of headers etc to be included in outgoing
3128 * request.
3129 *
3130 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003131 *
3132 * \par Python:
3133 * \code
3134 status = py_pjsua.call_send_typing_ind(call_id, is_typing, msg_data)
3135 * \endcode
3136 * Argument \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003137 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003138PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
3139 pj_bool_t is_typing,
3140 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003141
3142/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00003143 * Send arbitrary request with the call. This is useful for example to send
3144 * INFO request. Note that application should not use this function to send
3145 * requests which would change the invite session's state, such as re-INVITE,
3146 * UPDATE, PRACK, and BYE.
3147 *
3148 * @param call_id Call identification.
3149 * @param method SIP method of the request.
3150 * @param msg_data Optional message body and/or list of headers to be
3151 * included in outgoing request.
3152 *
3153 * @return PJ_SUCCESS on success, or the appropriate error code.
3154 */
3155PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
3156 const pj_str_t *method,
3157 const pjsua_msg_data *msg_data);
3158
3159
3160/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003161 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
3162 * currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003163 *
3164 * \par Python:
3165 * \code
3166 py_pjsua.call_hangup_all()
3167 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003168 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00003169PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00003170
3171
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003172/**
3173 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003174 *
3175 * @param call_id Call identification.
3176 * @param with_media Non-zero to include media information too.
3177 * @param buffer Buffer where the statistics are to be written to.
3178 * @param maxlen Maximum length of buffer.
3179 * @param indent Spaces for left indentation.
3180 *
3181 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003182 *
3183 * \par Python:
3184 * \code
3185 string = py_pjsua.call_dump(call_id, with_media, max_len, indent)
3186 * \endcode
3187 * The \a max_len argument is the desired maximum length to be allocated.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003188 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003189PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
3190 pj_bool_t with_media,
3191 char *buffer,
3192 unsigned maxlen,
3193 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003194
Benny Prijono9fc735d2006-05-28 14:58:12 +00003195/**
Benny Prijono312aff92006-06-17 04:08:30 +00003196 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003197 */
Benny Prijono834aee32006-02-19 01:38:06 +00003198
3199
3200/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00003201 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00003202 */
3203
Benny Prijono312aff92006-06-17 04:08:30 +00003204
3205/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003206 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00003207 * @ingroup PJSUA_LIB
3208 * @brief Buddy management, buddy's presence, and instant messaging.
3209 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00003210 *
3211 * This section describes PJSUA-APIs related to buddies management,
3212 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00003213 */
3214
3215/**
3216 * Max buddies in buddy list.
3217 */
3218#ifndef PJSUA_MAX_BUDDIES
3219# define PJSUA_MAX_BUDDIES 256
3220#endif
3221
3222
3223/**
Benny Prijonoa17496a2007-10-31 10:20:31 +00003224 * This specifies how long the library should retry resending SUBSCRIBE
3225 * if the previous SUBSCRIBE failed.
3226 *
3227 * Default: 300 seconds
3228 */
3229#ifndef PJSUA_PRES_TIMER
3230# define PJSUA_PRES_TIMER 300
3231#endif
3232
3233
3234/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003235 * This structure describes buddy configuration when adding a buddy to
3236 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
3237 * the structure with #pjsua_buddy_config_default() to initialize this
3238 * structure with default configuration.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003239 *
3240 * \par Python:
3241 * In Python this structure is <tt>py_pjsua.Buddy_Config</tt>. However
3242 * it is recommended that application instantiates the buddy config
3243 * by calling:
3244 * \code
3245 buddy_cfg = py_pjsua.buddy_config_default()
3246 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003247 */
3248typedef struct pjsua_buddy_config
3249{
3250 /**
3251 * Buddy URL or name address.
3252 */
3253 pj_str_t uri;
3254
3255 /**
3256 * Specify whether presence subscription should start immediately.
3257 */
3258 pj_bool_t subscribe;
3259
3260} pjsua_buddy_config;
3261
3262
3263/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003264 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003265 */
3266typedef enum pjsua_buddy_status
3267{
3268 /**
3269 * Online status is unknown (possibly because no presence subscription
3270 * has been established).
3271 */
3272 PJSUA_BUDDY_STATUS_UNKNOWN,
3273
3274 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003275 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003276 */
3277 PJSUA_BUDDY_STATUS_ONLINE,
3278
3279 /**
3280 * Buddy is offline.
3281 */
3282 PJSUA_BUDDY_STATUS_OFFLINE,
3283
3284} pjsua_buddy_status;
3285
3286
3287
3288/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003289 * This structure describes buddy info, which can be retrieved by calling
3290 * #pjsua_buddy_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003291 *
3292 * \par Python:
3293 * This structure in Python is <tt>py_pjsua.Buddy_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003294 */
3295typedef struct pjsua_buddy_info
3296{
3297 /**
3298 * The buddy ID.
3299 */
3300 pjsua_buddy_id id;
3301
3302 /**
3303 * The full URI of the buddy, as specified in the configuration.
3304 */
3305 pj_str_t uri;
3306
3307 /**
3308 * Buddy's Contact, only available when presence subscription has
3309 * been established to the buddy.
3310 */
3311 pj_str_t contact;
3312
3313 /**
3314 * Buddy's online status.
3315 */
3316 pjsua_buddy_status status;
3317
3318 /**
3319 * Text to describe buddy's online status.
3320 */
3321 pj_str_t status_text;
3322
3323 /**
3324 * Flag to indicate that we should monitor the presence information for
3325 * this buddy (normally yes, unless explicitly disabled).
3326 */
3327 pj_bool_t monitor_pres;
3328
3329 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003330 * Extended RPID information about the person.
3331 */
3332 pjrpid_element rpid;
3333
3334 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003335 * Internal buffer.
3336 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003337 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003338
3339} pjsua_buddy_info;
3340
3341
Benny Prijono834aee32006-02-19 01:38:06 +00003342/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003343 * Set default values to the buddy config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003344 *
3345 * \par Python:
3346 * \code
3347 buddy_cfg = py_pjsua.buddy_config_default()
3348 * \endcode
Benny Prijonob5388cf2007-01-04 22:45:08 +00003349 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003350PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003351
3352
3353/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003354 * Get total number of buddies.
3355 *
3356 * @return Number of buddies.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003357 *
3358 * \par Python:
3359 * \code
3360 buddy_count = py_pjsua.get_buddy_count()
3361 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003362 */
3363PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3364
3365
3366/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003367 * Check if buddy ID is valid.
3368 *
3369 * @param buddy_id Buddy ID to check.
3370 *
3371 * @return Non-zero if buddy ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003372 *
3373 * \par Python:
3374 * \code
3375 is_valid = py_pjsua.buddy_is_valid(buddy_id)
3376 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003377 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003378PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3379
3380
3381/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003382 * Enumerate all buddy IDs in the buddy list. Application then can use
3383 * #pjsua_buddy_get_info() to get the detail information for each buddy
3384 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003385 *
3386 * @param ids Array of ids to be initialized.
3387 * @param count On input, specifies max elements in the array.
3388 * On return, it contains actual number of elements
3389 * that have been initialized.
3390 *
3391 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003392 *
3393 * \par Python:
3394 * The Python function takes no argument and returns list of buddy IDs:
3395 * \code
3396 [buddy_ids] = py_pjsua.enum_buddies()
3397 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003398 */
3399PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3400 unsigned *count);
3401
3402/**
3403 * Get detailed buddy info.
3404 *
3405 * @param buddy_id The buddy identification.
3406 * @param info Pointer to receive information about buddy.
3407 *
3408 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003409 *
3410 * \par Python:
3411 * \code
3412 buddy_info = py_pjsua.buddy_get_info(buddy_id)
3413 * \endcode
3414 * The function returns None if buddy_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003415 */
3416PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003417 pjsua_buddy_info *info);
3418
3419/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003420 * Add new buddy to the buddy list. If presence subscription is enabled
3421 * for this buddy, this function will also start the presence subscription
3422 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003423 *
Benny Prijonoa7b376b2008-01-25 16:06:33 +00003424 * @param buddy_cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003425 * @param p_buddy_id Pointer to receive buddy ID.
3426 *
3427 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003428 *
3429 * \par Python:
3430 * The function returns (status, buddy_id) tuple:
3431 * \code
3432 status, buddy_id = py_pjsua.buddy_add(buddy_cfg)
3433 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003434 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003435PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003436 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003437
3438
3439/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003440 * Delete the specified buddy from the buddy list. Any presence subscription
3441 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003442 *
3443 * @param buddy_id Buddy identification.
3444 *
3445 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003446 *
3447 * \par Python:
3448 * \code
3449 status = py_pjsua.buddy_del(buddy_id)
3450 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +00003451 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003452PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003453
3454
3455/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003456 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3457 * subscribed, application will be informed about buddy's presence status
3458 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003459 *
3460 * @param buddy_id Buddy identification.
3461 * @param subscribe Specify non-zero to activate presence subscription to
3462 * the specified buddy.
3463 *
3464 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003465 *
3466 * \par Python:
3467 * \code
3468 status = py_pjsua.buddy_subscribe_pres(buddy_id, subscribe)
3469 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003470 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003471PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3472 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003473
3474
3475/**
Benny Prijono10861432007-10-31 10:54:53 +00003476 * Update the presence information for the buddy. Although the library
3477 * periodically refreshes the presence subscription for all buddies, some
3478 * application may want to refresh the buddy's presence subscription
3479 * immediately, and in this case it can use this function to accomplish
3480 * this.
3481 *
3482 * Note that the buddy's presence subscription will only be initiated
3483 * if presence monitoring is enabled for the buddy. See
3484 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
3485 * for the buddy is already active, this function will not do anything.
3486 *
3487 * Once the presence subscription is activated successfully for the buddy,
3488 * application will be notified about the buddy's presence status in the
3489 * on_buddy_state() callback.
3490 *
3491 * @param buddy_id Buddy identification.
3492 *
3493 * @return PJ_SUCCESS on success, or the appropriate error code.
3494 */
3495PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
3496
3497
3498/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003499 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003500 *
3501 * @param verbose Yes or no.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003502 *
3503 * \par Python:
3504 * \code
3505 py_pjsua.pres_dump()
3506 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003507 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003508PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003509
3510
Benny Prijonob0808372006-03-02 21:18:58 +00003511/**
3512 * The MESSAGE method (defined in pjsua_im.c)
3513 */
3514extern const pjsip_method pjsip_message_method;
3515
3516
Benny Prijonob0808372006-03-02 21:18:58 +00003517
3518/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003519 * Send instant messaging outside dialog, using the specified account for
3520 * route set and authentication.
3521 *
3522 * @param acc_id Account ID to be used to send the request.
3523 * @param to Remote URI.
3524 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3525 * assumed.
3526 * @param content The message content.
3527 * @param msg_data Optional list of headers etc to be included in outgoing
3528 * request. The body descriptor in the msg_data is
3529 * ignored.
3530 * @param user_data Optional user data, which will be given back when
3531 * the IM callback is called.
3532 *
3533 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003534 *
3535 * \par Python:
3536 * \code
3537 status = py_pjsua.im_send(acc_id, to, mime_type, content, msg_data, user_data)
3538 * \endcode
3539 * Arguments \a mime_type and \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003540 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003541PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3542 const pj_str_t *to,
3543 const pj_str_t *mime_type,
3544 const pj_str_t *content,
3545 const pjsua_msg_data *msg_data,
3546 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003547
3548
3549/**
3550 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003551 *
3552 * @param acc_id Account ID to be used to send the request.
3553 * @param to Remote URI.
3554 * @param is_typing If non-zero, it tells remote person that local person
3555 * is currently composing an IM.
3556 * @param msg_data Optional list of headers etc to be added to outgoing
3557 * request.
3558 *
3559 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003560 *
3561 * \par Python:
3562 * \code
3563 status = py_pjsua.im_typing(acc_id, to, is_typing, msg_data)
3564 * \endcode
3565 * Argument \a msg_data may be set to None if not requried.
Benny Prijonob0808372006-03-02 21:18:58 +00003566 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003567PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3568 const pj_str_t *to,
3569 pj_bool_t is_typing,
3570 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003571
3572
Benny Prijonof3195072006-02-14 21:15:30 +00003573
Benny Prijono312aff92006-06-17 04:08:30 +00003574/**
3575 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003576 */
3577
Benny Prijono312aff92006-06-17 04:08:30 +00003578
3579/*****************************************************************************
3580 * MEDIA API
3581 */
3582
3583
3584/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003585 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003586 * @ingroup PJSUA_LIB
3587 * @brief Media manipulation.
3588 * @{
3589 *
3590 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003591 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3592 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003593 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003594 * the interconnection between these terminations freely.
3595 *
3596 * The conference bridge provides powerful switching and mixing functionality
3597 * for application. With the conference bridge, each conference slot (e.g.
3598 * a call) can transmit to multiple destinations, and one destination can
3599 * receive from multiple sources. If more than one media terminations are
3600 * terminated in the same slot, the conference bridge will mix the signal
3601 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00003602 *
3603 * Application connects one media termination/slot to another by calling
3604 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003605 * media flow from the source termination to the sink termination. To
3606 * establish bidirectional media flow, application wound need to make another
3607 * call to #pjsua_conf_connect(), this time inverting the source and
3608 * destination slots in the parameter.
3609 *
3610 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00003611 * the following steps:
3612 *
3613 \code
3614
3615 pj_status_t stream_to_call( pjsua_call_id call_id )
3616 {
3617 pjsua_player_id player_id;
3618
3619 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
3620 if (status != PJ_SUCCESS)
3621 return status;
3622
3623 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
3624 pjsua_call_get_conf_port() );
3625 }
3626 \endcode
3627 *
3628 *
3629 * Other features of PJSUA media:
3630 * - efficient N to M interconnections between media terminations.
3631 * - media termination can be connected to itself to create loopback
3632 * media.
3633 * - the media termination may have different clock rates, and resampling
3634 * will be done automatically by conference bridge.
3635 * - media terminations may also have different frame time; the
3636 * conference bridge will perform the necessary bufferring to adjust
3637 * the difference between terminations.
3638 * - interconnections are removed automatically when media termination
3639 * is removed from the bridge.
3640 * - sound device may be changed even when there are active media
3641 * interconnections.
3642 * - correctly report call's media quality (in #pjsua_call_dump()) from
3643 * RTCP packet exchange.
3644 */
3645
3646/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003647 * Max ports in the conference bridge. This setting is the default value
3648 * for pjsua_media_config.max_media_ports.
Benny Prijono312aff92006-06-17 04:08:30 +00003649 */
3650#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00003651# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00003652#endif
3653
Benny Prijonob5388cf2007-01-04 22:45:08 +00003654/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003655 * The default clock rate to be used by the conference bridge. This setting
3656 * is the default value for pjsua_media_config.clock_rate.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003657 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003658#ifndef PJSUA_DEFAULT_CLOCK_RATE
3659# define PJSUA_DEFAULT_CLOCK_RATE 16000
3660#endif
3661
Benny Prijonob5388cf2007-01-04 22:45:08 +00003662/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003663 * Default frame length in the conference bridge. This setting
3664 * is the default value for pjsua_media_config.audio_frame_ptime.
3665 */
3666#ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Nanang Izzuddinaf974842008-05-08 09:51:16 +00003667# define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
Benny Prijono37c710b2008-01-10 12:09:26 +00003668#endif
3669
3670
3671/**
3672 * Default codec quality settings. This setting is the default value
3673 * for pjsua_media_config.quality.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003674 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003675#ifndef PJSUA_DEFAULT_CODEC_QUALITY
Nanang Izzuddin9dbad152008-06-10 18:56:10 +00003676# define PJSUA_DEFAULT_CODEC_QUALITY 8
Benny Prijono12a669c2006-11-23 07:32:13 +00003677#endif
3678
Benny Prijonob5388cf2007-01-04 22:45:08 +00003679/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003680 * Default iLBC mode. This setting is the default value for
3681 * pjsua_media_config.ilbc_mode.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003682 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003683#ifndef PJSUA_DEFAULT_ILBC_MODE
Benny Prijono37c710b2008-01-10 12:09:26 +00003684# define PJSUA_DEFAULT_ILBC_MODE 30
Benny Prijono12a669c2006-11-23 07:32:13 +00003685#endif
3686
Benny Prijonob5388cf2007-01-04 22:45:08 +00003687/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003688 * The default echo canceller tail length. This setting
3689 * is the default value for pjsua_media_config.ec_tail_len.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003690 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003691#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijono427439c2007-10-21 09:41:24 +00003692# define PJSUA_DEFAULT_EC_TAIL_LEN 200
Benny Prijono12a669c2006-11-23 07:32:13 +00003693#endif
Benny Prijono312aff92006-06-17 04:08:30 +00003694
3695
3696/**
Benny Prijonocba59d92007-02-16 09:22:56 +00003697 * The maximum file player.
3698 */
3699#ifndef PJSUA_MAX_PLAYERS
3700# define PJSUA_MAX_PLAYERS 32
3701#endif
3702
3703
3704/**
3705 * The maximum file player.
3706 */
3707#ifndef PJSUA_MAX_RECORDERS
3708# define PJSUA_MAX_RECORDERS 32
3709#endif
3710
3711
3712/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003713 * This structure describes media configuration, which will be specified
3714 * when calling #pjsua_init(). Application MUST initialize this structure
3715 * by calling #pjsua_media_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003716 *
3717 * \par Python:
3718 * This data type in Python is <tt>py_pjsua.Media_Config</tt>. To create
3719 * an object of this type, it is recommended to call
3720 * <tt>py_pjsua.media_config_default()</tt> function instead:
3721 * \code
3722 media_cfg = py_pjsua.media_config_default()
3723 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003724 */
3725struct pjsua_media_config
3726{
3727 /**
3728 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003729 * If value is zero, default clock rate will be used
3730 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00003731 */
3732 unsigned clock_rate;
3733
3734 /**
Benny Prijonof3758ee2008-02-26 15:32:16 +00003735 * Clock rate to be applied when opening the sound device.
3736 * If value is zero, conference bridge clock rate will be used.
3737 */
3738 unsigned snd_clock_rate;
3739
3740 /**
Benny Prijono7d60d052008-03-29 12:24:20 +00003741 * Channel count be applied when opening the sound device and
3742 * conference bridge.
3743 */
3744 unsigned channel_count;
3745
3746 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003747 * Specify audio frame ptime. The value here will affect the
3748 * samples per frame of both the sound device and the conference
3749 * bridge. Specifying lower ptime will normally reduce the
3750 * latency.
3751 *
Benny Prijono37c710b2008-01-10 12:09:26 +00003752 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003753 */
3754 unsigned audio_frame_ptime;
3755
3756 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003757 * Specify maximum number of media ports to be created in the
3758 * conference bridge. Since all media terminate in the bridge
3759 * (calls, file player, file recorder, etc), the value must be
3760 * large enough to support all of them. However, the larger
3761 * the value, the more computations are performed.
Benny Prijono37c710b2008-01-10 12:09:26 +00003762 *
3763 * Default value: PJSUA_MAX_CONF_PORTS
Benny Prijono312aff92006-06-17 04:08:30 +00003764 */
3765 unsigned max_media_ports;
3766
3767 /**
3768 * Specify whether the media manager should manage its own
3769 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
3770 * and at least one worker thread will be created too. If no,
3771 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
3772 * and no worker thread is needed.
3773 *
3774 * Normally application would say yes here, unless it wants to
3775 * run everything from a single thread.
3776 */
3777 pj_bool_t has_ioqueue;
3778
3779 /**
3780 * Specify the number of worker threads to handle incoming RTP
3781 * packets. A value of one is recommended for most applications.
3782 */
3783 unsigned thread_cnt;
3784
Benny Prijono0498d902006-06-19 14:49:14 +00003785 /**
3786 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00003787 * 5-10: resampling use large filter,
3788 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00003789 * 1-2: resampling use linear.
3790 * The media quality also sets speex codec quality/complexity to the
3791 * number.
3792 *
Benny Prijono70972992006-08-05 11:13:58 +00003793 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00003794 */
3795 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00003796
3797 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003798 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00003799 *
3800 * Default: 0 (codec specific)
3801 */
3802 unsigned ptime;
3803
3804 /**
3805 * Disable VAD?
3806 *
3807 * Default: 0 (no (meaning VAD is enabled))
3808 */
3809 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00003810
3811 /**
3812 * iLBC mode (20 or 30).
3813 *
Benny Prijono37c710b2008-01-10 12:09:26 +00003814 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00003815 */
3816 unsigned ilbc_mode;
3817
3818 /**
3819 * Percentage of RTP packet to drop in TX direction
3820 * (to simulate packet lost).
3821 *
3822 * Default: 0
3823 */
3824 unsigned tx_drop_pct;
3825
3826 /**
3827 * Percentage of RTP packet to drop in RX direction
3828 * (to simulate packet lost).
3829 *
3830 * Default: 0
3831 */
3832 unsigned rx_drop_pct;
3833
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003834 /**
Benny Prijono5da50432006-08-07 10:24:52 +00003835 * Echo canceller options (see #pjmedia_echo_create())
3836 *
3837 * Default: 0.
3838 */
3839 unsigned ec_options;
3840
3841 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003842 * Echo canceller tail length, in miliseconds.
3843 *
Benny Prijono669643c2006-09-20 20:02:18 +00003844 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003845 */
3846 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003847
3848 /**
3849 * Jitter buffer initial prefetch delay in msec. The value must be
3850 * between jb_min_pre and jb_max_pre below.
3851 *
3852 * Default: -1 (to use default stream settings, currently 150 msec)
3853 */
3854 int jb_init;
3855
3856 /**
3857 * Jitter buffer minimum prefetch delay in msec.
3858 *
3859 * Default: -1 (to use default stream settings, currently 60 msec)
3860 */
3861 int jb_min_pre;
3862
3863 /**
3864 * Jitter buffer maximum prefetch delay in msec.
3865 *
3866 * Default: -1 (to use default stream settings, currently 240 msec)
3867 */
3868 int jb_max_pre;
3869
3870 /**
3871 * Set maximum delay that can be accomodated by the jitter buffer msec.
3872 *
3873 * Default: -1 (to use default stream settings, currently 360 msec)
3874 */
3875 int jb_max;
3876
Benny Prijonoc97608e2007-03-23 16:34:20 +00003877 /**
3878 * Enable ICE
3879 */
3880 pj_bool_t enable_ice;
3881
3882 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00003883 * Disable ICE host candidates.
Benny Prijonoc97608e2007-03-23 16:34:20 +00003884 */
Benny Prijonof76e1392008-06-06 14:51:48 +00003885 pj_bool_t ice_no_host_cands;
3886
3887 /**
3888 * Enable TURN relay candidate in ICE.
3889 */
3890 pj_bool_t enable_turn;
3891
3892 /**
3893 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
3894 * "HOST:PORT" format.
3895 */
3896 pj_str_t turn_server;
3897
3898 /**
3899 * Specify the connection type to be used to the TURN server. Valid
3900 * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP.
3901 *
3902 * Default: PJ_TURN_TP_UDP
3903 */
3904 pj_turn_tp_type turn_conn_type;
3905
3906 /**
3907 * Specify the credential to authenticate with the TURN server.
3908 */
3909 pj_stun_auth_cred turn_auth_cred;
Nanang Izzuddin68559c32008-06-13 17:01:46 +00003910
3911 /**
3912 * Specify idle time of sound device before it is automatically closed,
3913 * in seconds.
3914 *
3915 * Default : -1 (Disable the auto-close feature of sound device)
3916 */
3917 int snd_auto_close_time;
Benny Prijono312aff92006-06-17 04:08:30 +00003918};
3919
3920
3921/**
3922 * Use this function to initialize media config.
3923 *
3924 * @param cfg The media config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003925 *
3926 * \par Python:
3927 * \code
3928 media_cfg = py_pjsua.media_config_default()
3929 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003930 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003931PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00003932
3933
3934/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003935 * This structure describes codec information, which can be retrieved by
3936 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00003937 */
3938typedef struct pjsua_codec_info
3939{
3940 /**
3941 * Codec unique identification.
3942 */
3943 pj_str_t codec_id;
3944
3945 /**
3946 * Codec priority (integer 0-255).
3947 */
3948 pj_uint8_t priority;
3949
3950 /**
3951 * Internal buffer.
3952 */
3953 char buf_[32];
3954
3955} pjsua_codec_info;
3956
3957
3958/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003959 * This structure descibes information about a particular media port that
3960 * has been registered into the conference bridge. Application can query
3961 * this info by calling #pjsua_conf_get_port_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003962 *
3963 * \par Python:
3964 * In Python, this type is <tt>py_pjsua.Conf_Port_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003965 */
3966typedef struct pjsua_conf_port_info
3967{
3968 /** Conference port number. */
3969 pjsua_conf_port_id slot_id;
3970
3971 /** Port name. */
3972 pj_str_t name;
3973
3974 /** Clock rate. */
3975 unsigned clock_rate;
3976
3977 /** Number of channels. */
3978 unsigned channel_count;
3979
3980 /** Samples per frame */
3981 unsigned samples_per_frame;
3982
3983 /** Bits per sample */
3984 unsigned bits_per_sample;
3985
3986 /** Number of listeners in the array. */
3987 unsigned listener_cnt;
3988
3989 /** Array of listeners (in other words, ports where this port is
3990 * transmitting to.
3991 */
3992 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
3993
3994} pjsua_conf_port_info;
3995
3996
3997/**
3998 * This structure holds information about custom media transport to
3999 * be registered to pjsua.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004000 *
4001 * \par Python:
4002 * Not applicable.
Benny Prijono312aff92006-06-17 04:08:30 +00004003 */
4004typedef struct pjsua_media_transport
4005{
4006 /**
4007 * Media socket information containing the address information
4008 * of the RTP and RTCP socket.
4009 */
4010 pjmedia_sock_info skinfo;
4011
4012 /**
4013 * The media transport instance.
4014 */
4015 pjmedia_transport *transport;
4016
4017} pjsua_media_transport;
4018
4019
4020
4021
Benny Prijono9fc735d2006-05-28 14:58:12 +00004022/**
4023 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004024 *
4025 * @return Maximum number of ports in the conference bridge.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004026 *
4027 * \par Python:
4028 * \code
4029 port_count = py_pjsua.conf_get_max_ports()
4030 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004031 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004032PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004033
4034
4035/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004036 * Get current number of active ports in the bridge.
4037 *
4038 * @return The number.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004039 *
4040 * \par Python:
4041 * \code
4042 count = py_pjsua.conf_get_active_ports()
4043 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004044 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004045PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
4046
4047
4048/**
4049 * Enumerate all conference ports.
4050 *
4051 * @param id Array of conference port ID to be initialized.
4052 * @param count On input, specifies max elements in the array.
4053 * On return, it contains actual number of elements
4054 * that have been initialized.
4055 *
4056 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004057 *
4058 * \par Python:
4059 * The Python functions returns list of conference port Ids:
4060 * \code
4061 [port_ids] = py_pjsua.enum_conf_ports()
4062 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004063 */
4064PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
4065 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004066
4067
4068/**
4069 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004070 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004071 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004072 * @param info Pointer to store the port info.
4073 *
4074 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004075 *
4076 * \par Python:
4077 * \code
4078 port_info = py_pjsua.conf_get_port_info(port_id)
4079 * \endcode
4080 * The function will return None if \a port_id is not valid.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004081 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004082PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00004083 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004084
4085
4086/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00004087 * Add arbitrary media port to PJSUA's conference bridge. Application
4088 * can use this function to add the media port that it creates. For
4089 * media ports that are created by PJSUA-LIB (such as calls, file player,
4090 * or file recorder), PJSUA-LIB will automatically add the port to
4091 * the bridge.
4092 *
4093 * @param pool Pool to use.
4094 * @param port Media port to be added to the bridge.
4095 * @param p_id Optional pointer to receive the conference
4096 * slot id.
4097 *
4098 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004099 *
4100 * \par Python:
4101 * Not applicable (for now)
Benny Prijonoe909eac2006-07-27 22:04:56 +00004102 */
4103PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
4104 pjmedia_port *port,
4105 pjsua_conf_port_id *p_id);
4106
4107
4108/**
4109 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00004110 * call this function if it registered the port manually with previous call
4111 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00004112 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004113 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00004114 *
4115 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004116 *
4117 * \par Python:
4118 * \code
4119 status = py_pjsua.conf_remove_port(port_id)
4120 * \endcode
Benny Prijonoe909eac2006-07-27 22:04:56 +00004121 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004122PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00004123
4124
4125/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004126 * Establish unidirectional media flow from souce to sink. One source
4127 * may transmit to multiple destinations/sink. And if multiple
4128 * sources are transmitting to the same sink, the media will be mixed
4129 * together. Source and sink may refer to the same ID, effectively
4130 * looping the media.
4131 *
4132 * If bidirectional media flow is desired, application needs to call
4133 * this function twice, with the second one having the arguments
4134 * reversed.
4135 *
4136 * @param source Port ID of the source media/transmitter.
4137 * @param sink Port ID of the destination media/received.
4138 *
4139 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004140 *
4141 * \par Python:
4142 * \code
4143 status = py_pjsua.conf_connect(source, sink)
4144 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004145 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004146PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
4147 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004148
4149
4150/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004151 * Disconnect media flow from the source to destination port.
4152 *
4153 * @param source Port ID of the source media/transmitter.
4154 * @param sink Port ID of the destination media/received.
4155 *
4156 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004157 *
4158 * \par Python:
4159 * \code
4160 status = py_pjsua.conf_disconnect(source, sink)
4161 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004162 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004163PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
4164 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004165
4166
Benny Prijono6dd967c2006-12-26 02:27:14 +00004167/**
4168 * Adjust the signal level to be transmitted from the bridge to the
4169 * specified port by making it louder or quieter.
4170 *
4171 * @param slot The conference bridge slot number.
4172 * @param level Signal level adjustment. Value 1.0 means no level
4173 * adjustment, while value 0 means to mute the port.
4174 *
4175 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004176 *
4177 * \par Python:
4178 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004179 */
4180PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
4181 float level);
4182
4183/**
4184 * Adjust the signal level to be received from the specified port (to
4185 * the bridge) by making it louder or quieter.
4186 *
4187 * @param slot The conference bridge slot number.
4188 * @param level Signal level adjustment. Value 1.0 means no level
4189 * adjustment, while value 0 means to mute the port.
4190 *
4191 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004192 *
4193 * \par Python:
4194 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004195 */
4196PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
4197 float level);
4198
4199/**
4200 * Get last signal level transmitted to or received from the specified port.
4201 * The signal level is an integer value in zero to 255, with zero indicates
4202 * no signal, and 255 indicates the loudest signal level.
4203 *
4204 * @param slot The conference bridge slot number.
4205 * @param tx_level Optional argument to receive the level of signal
4206 * transmitted to the specified port (i.e. the direction
4207 * is from the bridge to the port).
4208 * @param rx_level Optional argument to receive the level of signal
4209 * received from the port (i.e. the direction is from the
4210 * port to the bridge).
4211 *
4212 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004213 *
4214 * \par Python:
4215 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004216 */
4217PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
4218 unsigned *tx_level,
4219 unsigned *rx_level);
4220
Benny Prijono6dd967c2006-12-26 02:27:14 +00004221
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004222/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00004223 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004224 */
4225
Benny Prijono9fc735d2006-05-28 14:58:12 +00004226/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004227 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004228 * the conference bridge.
4229 *
4230 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00004231 * WAV files are supported, and the WAV file MUST be
4232 * formatted as 16bit PCM mono/single channel (any
4233 * clock rate is supported).
Benny Prijono58add7c2008-01-18 13:24:07 +00004234 * @param options Optional option flag. Application may specify
4235 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004236 * @param p_id Pointer to receive player ID.
4237 *
4238 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004239 *
4240 * \par Python:
4241 * The function returns (status, id) tuple:
4242 * \code
4243 status, id = py_pjsua.player_create(filename, options)
4244 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004245 */
4246PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004247 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004248 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004249
4250
4251/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004252 * Create a file playlist media port, and automatically add the port
4253 * to the conference bridge.
4254 *
4255 * @param file_names Array of file names to be added to the play list.
4256 * Note that the files must have the same clock rate,
4257 * number of channels, and number of bits per sample.
4258 * @param file_count Number of files in the array.
4259 * @param label Optional label to be set for the media port.
4260 * @param options Optional option flag. Application may specify
4261 * PJMEDIA_FILE_NO_LOOP to prevent looping.
4262 * @param p_id Optional pointer to receive player ID.
4263 *
4264 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004265 *
4266 * \par Python:
4267 * Not implemented yet.
Benny Prijonoa66c3312007-01-21 23:12:40 +00004268 */
4269PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
4270 unsigned file_count,
4271 const pj_str_t *label,
4272 unsigned options,
4273 pjsua_player_id *p_id);
4274
4275/**
4276 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004277 *
4278 * @param id The file player ID.
4279 *
4280 * @return Conference port ID associated with this player.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004281 *
4282 * \par Python:
4283 * \code
4284 port_id = py_pjsua.player_get_conf_port(id)
4285 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004286 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004287PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004288
4289
4290/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004291 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00004292 *
4293 * @param id The player ID.
4294 * @param p_port The media port associated with the player.
4295 *
4296 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004297 *
4298 * \par Python:
4299 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004300 */
Benny Prijono58add7c2008-01-18 13:24:07 +00004301PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
Benny Prijono469b1522006-12-26 03:05:17 +00004302 pjmedia_port **p_port);
4303
4304/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004305 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004306 *
4307 * @param id The file player ID.
4308 * @param samples The playback position, in samples. Application can
4309 * specify zero to re-start the playback.
4310 *
4311 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004312 *
4313 * \par Python:
4314 * \code
4315 status = py_pjsua.player_set_pos(id, samples)
4316 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004317 */
4318PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
4319 pj_uint32_t samples);
4320
4321
4322/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004323 * Close the file of playlist, remove the player from the bridge, and free
4324 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004325 *
4326 * @param id The file player ID.
4327 *
4328 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004329 *
4330 * \par Python:
4331 * \code
4332 status = py_pjsua.player_destroy(id)
4333 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004334 */
4335PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
4336
4337
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004338/*****************************************************************************
4339 * File recorder.
4340 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00004341
4342/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004343 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004344 * the conference bridge. The recorder currently supports recording WAV file.
4345 * The type of the recorder to use is determined by the extension of the file
4346 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004347 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00004348 * @param filename Output file name. The function will determine the
4349 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004350 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00004351 * @param enc_type Optionally specify the type of encoder to be used to
4352 * compress the media, if the file can support different
4353 * encodings. This value must be zero for now.
4354 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004355 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00004356 * For .WAV recorder, this value must be NULL.
4357 * @param max_size Maximum file size. Specify zero or -1 to remove size
4358 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004359 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004360 * @param p_id Pointer to receive the recorder instance.
4361 *
4362 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004363 *
4364 * \par Python:
4365 * \code
4366 status, id = py_pjsua.recorder_create(filename, enc_type, enc_param, max_size, options)
4367 * \endcode
4368 * The \a enc_param is a string in Python.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004369 */
4370PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004371 unsigned enc_type,
4372 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004373 pj_ssize_t max_size,
4374 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004375 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004376
4377
4378/**
4379 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004380 *
4381 * @param id The recorder ID.
4382 *
4383 * @return Conference port ID associated with this recorder.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004384 *
4385 * \par Python:
4386 * \code
4387 port_id = py_pjsua.recorder_get_conf_port(id)
4388 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004389 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004390PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004391
4392
4393/**
Benny Prijono469b1522006-12-26 03:05:17 +00004394 * Get the media port for the recorder.
4395 *
4396 * @param id The recorder ID.
4397 * @param p_port The media port associated with the recorder.
4398 *
4399 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004400 *
4401 * \par Python:
4402 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004403 */
4404PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4405 pjmedia_port **p_port);
4406
4407
4408/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004409 * Destroy recorder (this will complete recording).
4410 *
4411 * @param id The recorder ID.
4412 *
4413 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004414 *
4415 * \par Python:
4416 * \code
4417 status = py_pjsua.recorder_destroy(id)
4418 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004419 */
4420PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4421
4422
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004423/*****************************************************************************
4424 * Sound devices.
4425 */
4426
Benny Prijono9fc735d2006-05-28 14:58:12 +00004427/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004428 * Enum all sound devices installed in the system.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004429 *
4430 * @param info Array of info to be initialized.
4431 * @param count On input, specifies max elements in the array.
4432 * On return, it contains actual number of elements
4433 * that have been initialized.
4434 *
4435 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004436 *
4437 *
4438 * \par Python:
4439 * The function returns list of sound device info:
4440 * \code
4441 [dev_infos] = py_pjsua.enum_snd_devs()
4442 * \endcode
4443 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00004444 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004445PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4446 unsigned *count);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004447
4448
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004449
4450/**
4451 * Get currently active sound devices. If sound devices has not been created
4452 * (for example when pjsua_start() is not called), it is possible that
4453 * the function returns PJ_SUCCESS with -1 as device IDs.
4454 *
4455 * @param capture_dev On return it will be filled with device ID of the
4456 * capture device.
4457 * @param playback_dev On return it will be filled with device ID of the
4458 * device ID of the playback device.
4459 *
4460 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004461 *
4462 * \par Python:
Benny Prijonoebdf8772007-02-01 19:25:50 +00004463 * The function takes no argument and return an (integer,integer) tuple:
Benny Prijonoe6ead542007-01-31 20:53:31 +00004464 * \code
4465 capture_dev, playback_dev = py_pjsua.get_snd_dev()
4466 * \endcode
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004467 */
4468PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4469 int *playback_dev);
4470
4471
Benny Prijono9fc735d2006-05-28 14:58:12 +00004472/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004473 * Select or change sound device. Application may call this function at
4474 * any time to replace current sound device.
4475 *
4476 * @param capture_dev Device ID of the capture device.
4477 * @param playback_dev Device ID of the playback device.
4478 *
4479 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004480 *
4481 * \par Python:
4482 * \code
4483 status = py_pjsua.set_snd_dev(capture_dev, playback_dev)
4484 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004485 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004486PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4487 int playback_dev);
4488
4489
4490/**
4491 * Set pjsua to use null sound device. The null sound device only provides
4492 * the timing needed by the conference bridge, and will not interract with
4493 * any hardware.
4494 *
4495 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004496 *
4497 * \par Python:
4498 * \code
4499 status = py_pjsua.set_null_snd_dev()
4500 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004501 */
4502PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4503
4504
Benny Prijonoe909eac2006-07-27 22:04:56 +00004505/**
4506 * Disconnect the main conference bridge from any sound devices, and let
4507 * application connect the bridge to it's own sound device/master port.
4508 *
4509 * @return The port interface of the conference bridge,
4510 * so that application can connect this to it's own
4511 * sound device or master port.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004512 *
4513 * \par Python:
4514 * Not applicable (for now).
Benny Prijonoe909eac2006-07-27 22:04:56 +00004515 */
4516PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4517
4518
Benny Prijonof20687a2006-08-04 18:27:19 +00004519/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004520 * Configure the echo canceller tail length of the sound port.
Benny Prijonof20687a2006-08-04 18:27:19 +00004521 *
4522 * @param tail_ms The tail length, in miliseconds. Set to zero to
4523 * disable AEC.
Benny Prijonoa7b376b2008-01-25 16:06:33 +00004524 * @param options Options to be passed to pjmedia_echo_create().
Benny Prijono5da50432006-08-07 10:24:52 +00004525 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004526 *
4527 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004528 *
4529 * \par Python:
4530 * \code
4531 status = py_pjsua.set_ec(tail_ms, options)
4532 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004533 */
Benny Prijono5da50432006-08-07 10:24:52 +00004534PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004535
4536
4537/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004538 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004539 *
4540 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4541 * If AEC is disabled, the value will be zero.
4542 *
4543 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004544 *
4545 * \par Python:
4546 * \code
4547 tail_ms = py_pjsua.get_ec_tail()
4548 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004549 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004550PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004551
4552
4553
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004554/*****************************************************************************
4555 * Codecs.
4556 */
4557
4558/**
4559 * Enum all supported codecs in the system.
4560 *
4561 * @param id Array of ID to be initialized.
4562 * @param count On input, specifies max elements in the array.
4563 * On return, it contains actual number of elements
4564 * that have been initialized.
4565 *
4566 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004567 *
4568 * \par Python:
4569 * This function takes no argument and returns list of codec infos:
4570 * \code
4571 [codec_info] = py_pjsua.enum_codecs()
4572 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004573 */
4574PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4575 unsigned *count );
4576
4577
4578/**
4579 * Change codec priority.
4580 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004581 * @param codec_id Codec ID, which is a string that uniquely identify
4582 * the codec (such as "speex/8000"). Please see pjsua
4583 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004584 * @param priority Codec priority, 0-255, where zero means to disable
4585 * the codec.
4586 *
4587 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004588 *
4589 * \par Python:
4590 * \code
4591 status = py_pjsua.codec_set_priority(codec_id, priority)
4592 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004593 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004594PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004595 pj_uint8_t priority );
4596
4597
4598/**
4599 * Get codec parameters.
4600 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004601 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004602 * @param param Structure to receive codec parameters.
4603 *
4604 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004605 *
4606 * \par Python:
4607 * The Python function is experimental:
4608 * \code
4609 codec_param = py_pjsua.codec_get_param(codec_id)
4610 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004611 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004612PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004613 pjmedia_codec_param *param );
4614
4615
4616/**
4617 * Set codec parameters.
4618 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004619 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004620 * @param param Codec parameter to set.
4621 *
4622 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004623 *
4624 * \par Python:
4625 * The Python function is experimental:
4626 * \code
4627 status = py_pjsua.codec_set_param(codec_id, param)
4628 * \endcode
4629
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004630 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004631PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004632 const pjmedia_codec_param *param);
4633
4634
4635
Benny Prijono9fc735d2006-05-28 14:58:12 +00004636
Benny Prijono312aff92006-06-17 04:08:30 +00004637/**
4638 * Create UDP media transports for all the calls. This function creates
4639 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00004640 *
Benny Prijono312aff92006-06-17 04:08:30 +00004641 * @param cfg Media transport configuration. The "port" field in the
4642 * configuration is used as the start port to bind the
4643 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004644 *
4645 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004646 *
4647 * \par Python:
4648 * Not implemented yet.
Benny Prijonof3195072006-02-14 21:15:30 +00004649 */
Benny Prijono312aff92006-06-17 04:08:30 +00004650PJ_DECL(pj_status_t)
4651pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00004652
Benny Prijonodc39fe82006-05-26 12:17:46 +00004653
4654/**
Benny Prijono312aff92006-06-17 04:08:30 +00004655 * Register custom media transports to be used by calls. There must
4656 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004657 *
Benny Prijono312aff92006-06-17 04:08:30 +00004658 * @param tp The media transport array.
4659 * @param count Number of elements in the array. This number MUST
4660 * match the number of maximum calls configured when
4661 * pjsua is created.
4662 * @param auto_delete Flag to indicate whether the transports should be
4663 * destroyed when pjsua is shutdown.
4664 *
4665 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004666 *
4667 * \par Python:
4668 * Note applicable.
Benny Prijonodc39fe82006-05-26 12:17:46 +00004669 */
Benny Prijono312aff92006-06-17 04:08:30 +00004670PJ_DECL(pj_status_t)
4671pjsua_media_transports_attach( pjsua_media_transport tp[],
4672 unsigned count,
4673 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00004674
4675
Benny Prijono312aff92006-06-17 04:08:30 +00004676/**
4677 * @}
4678 */
4679
Benny Prijonof3195072006-02-14 21:15:30 +00004680
Benny Prijono268ca612006-02-07 12:34:11 +00004681
Benny Prijono312aff92006-06-17 04:08:30 +00004682/**
4683 * @}
4684 */
4685
Benny Prijonoe6ead542007-01-31 20:53:31 +00004686PJ_END_DECL
4687
Benny Prijono312aff92006-06-17 04:08:30 +00004688
Benny Prijono268ca612006-02-07 12:34:11 +00004689#endif /* __PJSUA_H__ */