blob: 326f53062450b78bf3e357066d300da43e779f51 [file] [log] [blame]
Benny Prijono268ca612006-02-07 12:34:11 +00001/* $Id$ */
2/*
Benny Prijono32177c02008-06-20 22:44:47 +00003 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
Benny Prijono268ca612006-02-07 12:34:11 +00004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJSUA_H__
20#define __PJSUA_H__
21
Benny Prijono312aff92006-06-17 04:08:30 +000022/**
23 * @file pjsua.h
24 * @brief PJSUA API.
25 */
26
27
Benny Prijono268ca612006-02-07 12:34:11 +000028/* Include all PJSIP core headers. */
29#include <pjsip.h>
30
31/* Include all PJMEDIA headers. */
32#include <pjmedia.h>
33
Benny Prijono1f9afba2006-02-10 15:57:32 +000034/* Include all PJMEDIA-CODEC headers. */
35#include <pjmedia-codec.h>
36
Benny Prijono268ca612006-02-07 12:34:11 +000037/* Include all PJSIP-UA headers */
38#include <pjsip_ua.h>
39
Benny Prijono834aee32006-02-19 01:38:06 +000040/* Include all PJSIP-SIMPLE headers */
41#include <pjsip_simple.h>
42
Benny Prijono4ab9fbb2007-10-12 12:14:27 +000043/* Include all PJNATH headers */
44#include <pjnath.h>
45
Benny Prijono268ca612006-02-07 12:34:11 +000046/* Include all PJLIB-UTIL headers. */
47#include <pjlib-util.h>
48
49/* Include all PJLIB headers. */
50#include <pjlib.h>
51
52
Benny Prijonoe6ead542007-01-31 20:53:31 +000053PJ_BEGIN_DECL
54
55
Benny Prijono312aff92006-06-17 04:08:30 +000056/**
Benny Prijonoe6ead542007-01-31 20:53:31 +000057 * @defgroup PJSUA_LIB PJSUA API - High Level Softphone API for C/C++ and Python
Benny Prijono312aff92006-06-17 04:08:30 +000058 * @brief Very high level API for constructing SIP UA applications.
59 * @{
60 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000061 * @section pjsua_api_intro A SIP User Agent API for C/C++ and Python
62 *
63 * PJSUA API is very high level API, available for C/C++ and Python language,
64 * for constructing SIP multimedia user agent
Benny Prijono312aff92006-06-17 04:08:30 +000065 * applications. It wraps together the signaling and media functionalities
66 * into an easy to use call API, provides account management, buddy
67 * management, presence, instant messaging, along with multimedia
68 * features such as conferencing, file streaming, local playback,
69 * voice recording, and so on.
70 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000071 * @subsection pjsua_for_c_cpp C/C++ Binding
Benny Prijono312aff92006-06-17 04:08:30 +000072 * Application must link with <b>pjsua-lib</b> to use this API. In addition,
73 * this library depends on the following libraries:
74 * - <b>pjsip-ua</b>,
75 * - <b>pjsip-simple</b>,
76 * - <b>pjsip-core</b>,
77 * - <b>pjmedia</b>,
78 * - <b>pjmedia-codec</b>,
79 * - <b>pjlib-util</b>, and
80 * - <b>pjlib</b>,
81 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000082 * so application must also link with these libraries as well. For more
83 * information, please refer to
84 * <A HREF="http://www.pjsip.org/using.htm">Getting Started with PJSIP</A>
85 * page.
Benny Prijono312aff92006-06-17 04:08:30 +000086 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000087 * @subsection pjsua_for_python Python Binding
88 *
89 * The Python binding for PJSUA-API is implemented by <b>py_pjsua</b>
90 * module, in <tt>pjsip-apps/py_pjsua</tt> directory. This module is
91 * built by building <tt>py_pjsua</tt> project in <tt>pjsip_apps</tt>
92 * Visual Studio workspace, or by invoking the usual <tt>setup.py</tt>
93 * Python installer script.
94 *
95 * The Python script then can import the PJSUA-API Python module by
96 * using <b>import py_pjsua</b> construct as usual.
97 *
98 *
99 * @section pjsua_samples
100 *
101 * Few samples are provided both in C and Python.
102 *
103 - @ref page_pjsip_sample_simple_pjsuaua_c\n
104 Very simple SIP User Agent with registration, call, and media, using
105 PJSUA-API, all in under 200 lines of code.
106
107 - @ref page_pjsip_samples_pjsua\n
108 This is the reference implementation for PJSIP and PJMEDIA.
109 PJSUA is a console based application, designed to be simple enough
110 to be readble, but powerful enough to demonstrate all features
111 available in PJSIP and PJMEDIA.\n
112
113 - Python sample\n
114 For a real simple Python sample application, have a look at
115 <A HREF="http://www.pjsip.org/trac/browser/pjproject/trunk/pjsip-apps/src/py_pjsua/pjsua_app.py">
116 <tt>pjsip-apps/src/py_pjsua/pjsua_app.py</tt></A> file.
117
Benny Prijono312aff92006-06-17 04:08:30 +0000118 * @section root_using_pjsua_lib Using PJSUA API
119 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000120 * Please refer to @ref PJSUA_LIB_BASE on how to create and initialize the API.
121 * And then see the Modules on the bottom of this page for more information
122 * about specific subject.
Benny Prijono312aff92006-06-17 04:08:30 +0000123 */
124
Benny Prijonoa91a0032006-02-26 21:23:45 +0000125
Benny Prijonof3195072006-02-14 21:15:30 +0000126
Benny Prijono312aff92006-06-17 04:08:30 +0000127/*****************************************************************************
128 * BASE API
129 */
130
Benny Prijonof04ffdd2006-02-21 00:11:18 +0000131/**
Benny Prijonoe6ead542007-01-31 20:53:31 +0000132 * @defgroup PJSUA_LIB_BASE PJSUA-API Basic API
Benny Prijono312aff92006-06-17 04:08:30 +0000133 * @ingroup PJSUA_LIB
134 * @brief Basic application creation/initialization, logging configuration, etc.
135 * @{
136 *
137 * The base PJSUA API controls PJSUA creation, initialization, and startup, and
138 * also provides various auxiliary functions.
139 *
140 * @section using_pjsua_lib Using PJSUA Library
141 *
142 * @subsection creating_pjsua_lib Creating PJSUA
143 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000144 * Before anything else, application must create PJSUA by calling #pjsua_create()
145 * (or <tt>py_pjsua.create()</tt> from Python).
Benny Prijono312aff92006-06-17 04:08:30 +0000146 * This, among other things, will initialize PJLIB, which is crucial before
Benny Prijonoe6ead542007-01-31 20:53:31 +0000147 * any PJLIB functions can be called, PJLIB-UTIL, and create a SIP endpoint.
148 *
149 * After this function is called, application can create a memory pool (with
150 * #pjsua_pool_create()) and read configurations from command line or file to
151 * build the settings to initialize PJSUA below.
Benny Prijono312aff92006-06-17 04:08:30 +0000152 *
153 * @subsection init_pjsua_lib Initializing PJSUA
154 *
155 * After PJSUA is created, application can initialize PJSUA by calling
Benny Prijonoe6ead542007-01-31 20:53:31 +0000156 * #pjsua_init(). This function takes several optional configuration settings
157 * in the argument, if application wants to set them.
Benny Prijono312aff92006-06-17 04:08:30 +0000158 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000159 * @subsubsection init_pjsua_lib_c_cpp PJSUA-LIB Initialization (in C)
160 * Sample code to initialize PJSUA in C code:
Benny Prijono312aff92006-06-17 04:08:30 +0000161 \code
162
Benny Prijonob5388cf2007-01-04 22:45:08 +0000163 #include <pjsua-lib/pjsua.h>
164
165 #define THIS_FILE __FILE__
166
167 static pj_status_t app_init(void)
168 {
Benny Prijono312aff92006-06-17 04:08:30 +0000169 pjsua_config ua_cfg;
170 pjsua_logging_config log_cfg;
171 pjsua_media_config media_cfg;
Benny Prijonob5388cf2007-01-04 22:45:08 +0000172 pj_status_t status;
173
174 // Must create pjsua before anything else!
175 status = pjsua_create();
176 if (status != PJ_SUCCESS) {
177 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
178 return status;
179 }
Benny Prijono312aff92006-06-17 04:08:30 +0000180
181 // Initialize configs with default settings.
182 pjsua_config_default(&ua_cfg);
183 pjsua_logging_config_default(&log_cfg);
184 pjsua_media_config_default(&media_cfg);
185
186 // At the very least, application would want to override
187 // the call callbacks in pjsua_config:
188 ua_cfg.cb.on_incoming_call = ...
189 ua_cfg.cb.on_call_state = ..
190 ...
191
192 // Customize other settings (or initialize them from application specific
193 // configuration file):
194 ...
195
196 // Initialize pjsua
197 status = pjsua_init(&ua_cfg, &log_cfg, &media_cfg);
198 if (status != PJ_SUCCESS) {
199 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
200 return status;
201 }
Benny Prijonob5388cf2007-01-04 22:45:08 +0000202 .
203 ...
204 }
Benny Prijono312aff92006-06-17 04:08:30 +0000205 \endcode
206 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000207 *
208 * @subsubsection init_pjsua_lib_python PJSUA-LIB Initialization (in Python)
209 * Sample code to initialize PJSUA in Python code:
210
211 \code
212
213import py_pjsua
214
215#
216# Initialize pjsua.
217#
218def app_init():
219 # Create pjsua before anything else
220 status = py_pjsua.create()
221 if status != 0:
222 err_exit("pjsua create() error", status)
223
224 # We use default logging config for this sample
225 log_cfg = py_pjsua.logging_config_default()
226
227 # Create and initialize pjsua config
228 # Note: for this Python module, thread_cnt must be 0 since Python
229 # doesn't like to be called from alien thread (pjsua's thread
230 # in this case)
231 ua_cfg = py_pjsua.config_default()
232 ua_cfg.thread_cnt = 0
233 ua_cfg.user_agent = "PJSUA/Python 0.1"
234
235 # Override callbacks. At the very least application would want to
236 # override the call callbacks in pjsua_config
237 ua_cfg.cb.on_incoming_call = ...
238 ua_cfg.cb.on_call_state = ...
239
240 # Use default media config for this cample
241 med_cfg = py_pjsua.media_config_default()
242
243 #
244 # Initialize pjsua!!
245 #
246 status = py_pjsua.init(ua_cfg, log_cfg, med_cfg)
247 if status != 0:
248 err_exit("pjsua init() error", status)
249
250
251
252# Utility: display PJ error and exit
253#
254def err_exit(title, rc):
255 py_pjsua.perror(THIS_FILE, title, rc)
256 exit(1)
257
258 \endcode
259
260
Benny Prijono312aff92006-06-17 04:08:30 +0000261 * @subsection other_init_pjsua_lib Other Initialization
262 *
263 * After PJSUA is initialized with #pjsua_init(), application will normally
264 * need/want to perform the following tasks:
265 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000266 * - create SIP transport with #pjsua_transport_create(). Application would
267 * to call #pjsua_transport_create() for each transport types that it
268 * wants to support (for example, UDP, TCP, and TLS). Please see
Benny Prijono312aff92006-06-17 04:08:30 +0000269 * @ref PJSUA_LIB_TRANSPORT section for more info.
270 * - create one or more SIP accounts with #pjsua_acc_add() or
Benny Prijonoe6ead542007-01-31 20:53:31 +0000271 * #pjsua_acc_add_local(). The SIP account is used for registering with
272 * the SIP server, if any. Please see @ref PJSUA_LIB_ACC for more info.
Benny Prijono312aff92006-06-17 04:08:30 +0000273 * - add one or more buddies with #pjsua_buddy_add(). Please see
274 * @ref PJSUA_LIB_BUDDY section for more info.
275 * - optionally configure the sound device, codec settings, and other
276 * media settings. Please see @ref PJSUA_LIB_MEDIA for more info.
277 *
278 *
279 * @subsection starting_pjsua_lib Starting PJSUA
280 *
281 * After all initializations have been done, application must call
282 * #pjsua_start() to start PJSUA. This function will check that all settings
Benny Prijonoe6ead542007-01-31 20:53:31 +0000283 * have been properly configured, and apply default settings when they haven't,
284 * or report error status when it is unable to recover from missing settings.
Benny Prijono312aff92006-06-17 04:08:30 +0000285 *
286 * Most settings can be changed during run-time. For example, application
287 * may add, modify, or delete accounts, buddies, or change media settings
288 * during run-time.
Benny Prijonob5388cf2007-01-04 22:45:08 +0000289 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000290 * @subsubsection starting_pjsua_lib_c C Example for Starting PJSUA
Benny Prijonob5388cf2007-01-04 22:45:08 +0000291 * Sample code:
292 \code
293 static pj_status_t app_run(void)
294 {
295 pj_status_t status;
296
297 // Start pjsua
298 status = pjsua_start();
299 if (status != PJ_SUCCESS) {
300 pjsua_destroy();
301 pjsua_perror(THIS_FILE, "Error starting pjsua", status);
302 return status;
303 }
304
305 // Run application loop
306 while (1) {
307 char choice[10];
308
309 printf("Select menu: ");
310 fgets(choice, sizeof(choice), stdin);
311 ...
312 }
313 }
314 \endcode
Benny Prijonoe6ead542007-01-31 20:53:31 +0000315
316 * @subsubsection starting_pjsua_lib_python Python Example for starting PJSUA
317 * For Python, starting PJSUA-LIB takes one more step, that is to initialize
318 * Python worker thread to poll PJSUA-LIB. This step is necessary because
319 * Python doesn't like it when it is called by an "alien" thread (that is,
320 * thread that is not created using Python API).
321 *
322 * Because of this, we cannot use a worker thread in PJSUA-LIB, because then
323 * the Python callback will be called by an "alien" thread and this would
324 * crash Python (or raise assert() probably).
325 *
326 * So because worker thread is disabled, we need to create a worker thread
327 * in Python. Note that this may not be necessary if we're creating a
328 * GUI application, because then we can attach, for example, a GUI timer
329 * object to poll the PJSUA-LIB. But because we're creating a console
330 * application which will block at <tt>sys.stdin.readline()</tt>, we need
331 * to have a worker thread to poll PJSUA-LIB.
332
333 \code
334
335import thread
336
337C_QUIT = 0
338
339
340def app_start():
341 # Done with initialization, start pjsua!!
342 #
343 status = py_pjsua.start()
344 if status != 0:
345 py_pjsua.destroy()
346 err_exit("Error starting pjsua!", status)
347
348 # Start worker thread
349 thr = thread.start_new(worker_thread_main, (0,))
350
351 print "PJSUA Started!!"
352
353#
354# Worker thread function.
355# Python doesn't like it when it's called from an alien thread
356# (pjsua's worker thread, in this case), so for Python we must
357# disable worker thread in pjsua and poll pjsua from Python instead.
358#
359def worker_thread_main(arg):
360 global C_QUIT
361 thread_desc = 0
362 status = py_pjsua.thread_register("python worker", thread_desc)
363 if status != 0:
364 py_pjsua.perror(THIS_FILE, "Error registering thread", status)
365 else:
366 while C_QUIT == 0:
367 py_pjsua.handle_events(50)
368 print "Worker thread quitting.."
369 C_QUIT = 2
370
371
372 \endcode
Benny Prijonof04ffdd2006-02-21 00:11:18 +0000373 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000374
Benny Prijono312aff92006-06-17 04:08:30 +0000375/** Constant to identify invalid ID for all sorts of IDs. */
376#define PJSUA_INVALID_ID (-1)
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000377
378/** Call identification */
379typedef int pjsua_call_id;
380
Benny Prijono312aff92006-06-17 04:08:30 +0000381/** Account identification */
382typedef int pjsua_acc_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000383
384/** Buddy identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000385typedef int pjsua_buddy_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000386
387/** File player identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000388typedef int pjsua_player_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000389
390/** File recorder identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000391typedef int pjsua_recorder_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000392
393/** Conference port identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000394typedef int pjsua_conf_port_id;
395
Benny Prijono63fba012008-07-17 14:19:10 +0000396/** Opaque declaration for server side presence subscription */
397typedef struct pjsua_srv_pres pjsua_srv_pres;
398
399/** Forward declaration for pjsua_msg_data */
400typedef struct pjsua_msg_data pjsua_msg_data;
Benny Prijono8b1889b2006-06-06 18:40:40 +0000401
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000402
Benny Prijonoa91a0032006-02-26 21:23:45 +0000403/**
Benny Prijono312aff92006-06-17 04:08:30 +0000404 * Maximum proxies in account.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000405 */
Benny Prijono312aff92006-06-17 04:08:30 +0000406#ifndef PJSUA_ACC_MAX_PROXIES
407# define PJSUA_ACC_MAX_PROXIES 8
408#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000409
Benny Prijonod8179652008-01-23 20:39:07 +0000410#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000411
Benny Prijonod8179652008-01-23 20:39:07 +0000412/**
413 * Default value of SRTP mode usage. Valid values are PJMEDIA_SRTP_DISABLED,
414 * PJMEDIA_SRTP_OPTIONAL, and PJMEDIA_SRTP_MANDATORY.
415 */
416#ifndef PJSUA_DEFAULT_USE_SRTP
417 #define PJSUA_DEFAULT_USE_SRTP PJMEDIA_SRTP_DISABLED
418#endif
419
420/**
421 * Default value of secure signaling requirement for SRTP.
422 * Valid values are:
423 * 0: SRTP does not require secure signaling
424 * 1: SRTP requires secure transport such as TLS
425 * 2: SRTP requires secure end-to-end transport (SIPS)
426 */
427#ifndef PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
428 #define PJSUA_DEFAULT_SRTP_SECURE_SIGNALING 1
429#endif
430
431#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000432
433/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000434 * Logging configuration, which can be (optionally) specified when calling
435 * #pjsua_init(). Application must call #pjsua_logging_config_default() to
436 * initialize this structure with the default values.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000437 *
438 * \par Sample Python Syntax:
439 * \code
440 # Python type: py_pjsua.Logging_Config
441
442 log_cfg = py_pjsua.logging_config_default()
443 log_cfg.level = 4
444 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000445 */
446typedef struct pjsua_logging_config
447{
448 /**
449 * Log incoming and outgoing SIP message? Yes!
450 */
451 pj_bool_t msg_logging;
452
453 /**
454 * Input verbosity level. Value 5 is reasonable.
455 */
456 unsigned level;
457
458 /**
459 * Verbosity level for console. Value 4 is reasonable.
460 */
461 unsigned console_level;
462
463 /**
464 * Log decoration.
465 */
466 unsigned decor;
467
468 /**
469 * Optional log filename.
470 */
471 pj_str_t log_filename;
472
473 /**
474 * Optional callback function to be called to write log to
475 * application specific device. This function will be called for
476 * log messages on input verbosity level.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000477 *
478 * \par Sample Python Syntax:
479 * \code
480 # level: integer
481 # data: string
482 # len: integer
483
484 def cb(level, data, len):
485 print data,
486 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000487 */
Benny Prijonofe7d87b2007-11-29 11:35:44 +0000488 void (*cb)(int level, const char *data, int len);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000489
490
491} pjsua_logging_config;
492
493
494/**
495 * Use this function to initialize logging config.
496 *
497 * @param cfg The logging config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000498 *
499 * \par Python Syntax:
500 * The Python function instantiates and initialize the logging config:
501 * \code
502 logging_cfg = py_pjsua.logging_config_default()
503 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000504 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000505PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000506
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000507
508/**
509 * Use this function to duplicate logging config.
510 *
511 * @param pool Pool to use.
512 * @param dst Destination config.
513 * @param src Source config.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000514 *
515 * \par Python Syntax:
516 * Not available (for now). Ideally we should be able to just assign
517 * one config to another, but this has not been tested.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000518 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000519PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool,
520 pjsua_logging_config *dst,
521 const pjsua_logging_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000522
Benny Prijonodc39fe82006-05-26 12:17:46 +0000523
524/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000525 * This structure describes application callback to receive various event
526 * notification from PJSUA-API. All of these callbacks are OPTIONAL,
527 * although definitely application would want to implement some of
528 * the important callbacks (such as \a on_incoming_call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000529 *
530 * \par Python Syntax:
531 * This callback structure is embedded on pjsua_config structure.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000532 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000533typedef struct pjsua_callback
Benny Prijonodc39fe82006-05-26 12:17:46 +0000534{
535 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000536 * Notify application when invite state has changed.
537 * Application may then query the call info to get the
Benny Prijonoe6ead542007-01-31 20:53:31 +0000538 * detail call states by calling pjsua_call_get_info() function.
Benny Prijono0875ae82006-12-26 00:11:48 +0000539 *
540 * @param call_id The call index.
541 * @param e Event which causes the call state to change.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000542 *
543 * \par Python Syntax:
544 * \code
545 # call_id: integer
546 # e: an opaque object
547
548 def on_call_state(call_id, e):
549 return
550 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000551 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000552 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000553
554 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000555 * Notify application on incoming call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000556 *
557 * @param acc_id The account which match the incoming call.
558 * @param call_id The call id that has just been created for
559 * the call.
560 * @param rdata The incoming INVITE request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000561 *
562 * \par Python Syntax:
563 * \code
564 # acc_id: integer
565 # call_id: integer
566 # rdata: an opaque object
567
568 def on_incoming_call(acc_id, call_id, rdata):
569 return
570 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +0000571 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000572 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000573 pjsip_rx_data *rdata);
574
575 /**
Benny Prijonofeb69f42007-10-05 09:12:26 +0000576 * This is a general notification callback which is called whenever
577 * a transaction within the call has changed state. Application can
578 * implement this callback for example to monitor the state of
579 * outgoing requests, or to answer unhandled incoming requests
580 * (such as INFO) with a final response.
581 *
582 * @param call_id Call identification.
583 * @param tsx The transaction which has changed state.
584 * @param e Transaction event that caused the state change.
585 */
586 void (*on_call_tsx_state)(pjsua_call_id call_id,
587 pjsip_transaction *tsx,
588 pjsip_event *e);
589
590 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000591 * Notify application when media state in the call has changed.
592 * Normal application would need to implement this callback, e.g.
Benny Prijono6ba8c542007-10-16 01:34:14 +0000593 * to connect the call's media to sound device. When ICE is used,
594 * this callback will also be called to report ICE negotiation
595 * failure.
Benny Prijono0875ae82006-12-26 00:11:48 +0000596 *
597 * @param call_id The call index.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000598 *
599 * \par Python Syntax:
600 * \code
601 # call_id: integer
602
603 def on_call_media_state(call_id):
604 return
605 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000606 */
607 void (*on_call_media_state)(pjsua_call_id call_id);
608
Benny Prijonofc13bf62008-02-20 08:56:15 +0000609
610 /**
611 * Notify application when media session is created and before it is
612 * registered to the conference bridge. Application may return different
613 * media port if it has added media processing port to the stream. This
614 * media port then will be added to the conference bridge instead.
615 *
616 * @param call_id Call identification.
617 * @param sess Media session for the call.
618 * @param stream_idx Stream index in the media session.
619 * @param p_port On input, it specifies the media port of the
620 * stream. Application may modify this pointer to
621 * point to different media port to be registered
622 * to the conference bridge.
623 *
624 * \par Python:
625 * Not applicable.
626 */
627 void (*on_stream_created)(pjsua_call_id call_id,
628 pjmedia_session *sess,
629 unsigned stream_idx,
630 pjmedia_port **p_port);
631
632 /**
633 * Notify application when media session has been unregistered from the
634 * conference bridge and about to be destroyed.
635 *
636 * @param call_id Call identification.
637 * @param sess Media session for the call.
638 * @param stream_idx Stream index in the media session.
639 *
640 * \par Python:
641 * Not applicable.
642 */
643 void (*on_stream_destroyed)(pjsua_call_id call_id,
644 pjmedia_session *sess,
645 unsigned stream_idx);
646
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000647 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000648 * Notify application upon incoming DTMF digits.
649 *
650 * @param call_id The call index.
651 * @param digit DTMF ASCII digit.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000652 *
653 * \par Python Syntax:
654 * \code
655 # call_id: integer
Benny Prijono1f63cc42007-09-10 16:54:22 +0000656 # digit: digit string
Benny Prijonoe6ead542007-01-31 20:53:31 +0000657
658 def on_dtmf_digit(call_id, digit):
659 return
660 * \endcode
Benny Prijono0875ae82006-12-26 00:11:48 +0000661 */
662 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
663
664 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000665 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000666 * Application can decide to accept/reject transfer request
Benny Prijonoc54dcb32008-04-08 23:33:15 +0000667 * by setting the code (default is 202). When this callback
Benny Prijono9fc735d2006-05-28 14:58:12 +0000668 * is not defined, the default behavior is to accept the
669 * transfer.
Benny Prijono0875ae82006-12-26 00:11:48 +0000670 *
671 * @param call_id The call index.
672 * @param dst The destination where the call will be
673 * transfered to.
674 * @param code Status code to be returned for the call transfer
675 * request. On input, it contains status code 200.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000676 *
677 * \par Python Syntax:
678 * \code
679 # call_id: integer
680 # dst: string
681 # code: integer
682
683 def on_call_transfer_request(call_id, dst, code):
684 return code
685
686 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000687 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000688 void (*on_call_transfer_request)(pjsua_call_id call_id,
689 const pj_str_t *dst,
690 pjsip_status_code *code);
691
692 /**
693 * Notify application of the status of previously sent call
694 * transfer request. Application can monitor the status of the
695 * call transfer request, for example to decide whether to
696 * terminate existing call.
697 *
698 * @param call_id Call ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000699 * @param st_code Status progress of the transfer request.
700 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000701 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000702 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000703 * this callback is the final status.
704 * @param p_cont Initially will be set to non-zero, application
705 * can set this to FALSE if it no longer wants
706 * to receie further notification (for example,
707 * after it hangs up the call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000708 *
709 * \par Python Syntax:
710 * \code
711 # call_id: integer
712 # st_code: integer
713 # st_text: string
714 # final: integer
715 # cont: integer
716
717 # return: cont
718
719 def on_call_transfer_status(call_id, st_code, st_text, final, cont):
720 return cont
721 * \endcode
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000722 */
723 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000724 int st_code,
725 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000726 pj_bool_t final,
727 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000728
729 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000730 * Notify application about incoming INVITE with Replaces header.
731 * Application may reject the request by setting non-2xx code.
732 *
733 * @param call_id The call ID to be replaced.
734 * @param rdata The incoming INVITE request to replace the call.
735 * @param st_code Status code to be set by application. Application
736 * should only return a final status (200-699).
737 * @param st_text Optional status text to be set by application.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000738 *
739 * \par Python Syntax:
740 * \code
741 # call_id: integer
742 # rdata: an opaque object
743 # st_code: integer
744 # st_text: string
745
746 # return: (st_code, st_text) tuple
747
748 def on_call_replace_request(call_id, rdata, st_code, st_text):
749 return st_code, st_text
750 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000751 */
752 void (*on_call_replace_request)(pjsua_call_id call_id,
753 pjsip_rx_data *rdata,
754 int *st_code,
755 pj_str_t *st_text);
756
757 /**
758 * Notify application that an existing call has been replaced with
759 * a new call. This happens when PJSUA-API receives incoming INVITE
760 * request with Replaces header.
761 *
762 * After this callback is called, normally PJSUA-API will disconnect
763 * \a old_call_id and establish \a new_call_id.
764 *
765 * @param old_call_id Existing call which to be replaced with the
766 * new call.
767 * @param new_call_id The new call.
768 * @param rdata The incoming INVITE with Replaces request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000769 *
770 * \par Python Syntax:
771 * \code
772 # old_call_id: integer
773 # new_call_id: integer
774
775 def on_call_replaced(old_call_id, new_call_id):
776 return
777 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000778 */
779 void (*on_call_replaced)(pjsua_call_id old_call_id,
780 pjsua_call_id new_call_id);
781
782
783 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000784 * Notify application when registration status has changed.
785 * Application may then query the account info to get the
786 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000787 *
788 * @param acc_id Account ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000789 *
790 * \par Python Syntax:
791 * \code
792 # acc_id: account ID (integer)
793
794 def on_reg_state(acc_id):
795 return
796 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000797 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000798 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000799
800 /**
Benny Prijono63fba012008-07-17 14:19:10 +0000801 * Notification when incoming SUBSCRIBE request is received. Application
802 * may use this callback to authorize the incoming subscribe request
803 * (e.g. ask user permission if the request should be granted).
804 *
805 * If this callback is not implemented, all incoming presence subscription
806 * requests will be accepted.
807 *
808 * If this callback is implemented, application has several choices on
809 * what to do with the incoming request:
810 * - it may reject the request immediately by specifying non-200 class
811 * final response in the \a code argument.
812 * - it may immediately accept the request by specifying 200 as the
813 * \a code argument. This is the default value if application doesn't
814 * set any value to the \a code argument. In this case, the library
815 * will automatically send NOTIFY request upon returning from this
816 * callback.
817 * - it may delay the processing of the request, for example to request
818 * user permission whether to accept or reject the request. In this
819 * case, the application MUST set the \a code argument to 202, and
820 * later calls #pjsua_pres_notify() to accept or reject the
821 * subscription request.
822 *
823 * Any \a code other than 200 and 202 will be treated as 200.
824 *
825 * Application MUST return from this callback immediately (e.g. it must
826 * not block in this callback while waiting for user confirmation).
827 *
828 * @param srv_pres Server presence subscription instance. If
829 * application delays the acceptance of the request,
830 * it will need to specify this object when calling
831 * #pjsua_pres_notify().
832 * @param acc_id Account ID most appropriate for this request.
833 * @param buddy_id ID of the buddy matching the sender of the
834 * request, if any, or PJSUA_INVALID_ID if no
835 * matching buddy is found.
836 * @param from The From URI of the request.
837 * @param rdata The incoming request.
838 * @param code The status code to respond to the request. The
839 * default value is 200. Application may set this
840 * to other final status code to accept or reject
841 * the request.
842 * @param reason The reason phrase to respond to the request.
843 * @param msg_data If the application wants to send additional
844 * headers in the response, it can put it in this
845 * parameter.
846 */
847 void (*on_incoming_subscribe)(pjsua_acc_id acc_id,
848 pjsua_srv_pres *srv_pres,
849 pjsua_buddy_id buddy_id,
850 const pj_str_t *from,
851 pjsip_rx_data *rdata,
852 pjsip_status_code *code,
853 pj_str_t *reason,
854 pjsua_msg_data *msg_data);
855
856 /**
857 * Notification when server side subscription state has changed.
858 * This callback is optional as application normally does not need
859 * to do anything to maintain server side presence subscription.
860 *
861 * @param acc_id The account ID.
862 * @param srv_pres Server presence subscription object.
863 * @param remote_uri Remote URI string.
864 * @param state New subscription state.
865 * @param event PJSIP event that triggers the state change.
866 */
867 void (*on_srv_subscribe_state)(pjsua_acc_id acc_id,
868 pjsua_srv_pres *srv_pres,
869 const pj_str_t *remote_uri,
870 pjsip_evsub_state state,
871 pjsip_event *event);
872
873 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000874 * Notify application when the buddy state has changed.
875 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000876 *
877 * @param buddy_id The buddy id.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000878 *
879 * \par Python Syntax:
880 * \code
881 # buddy_id: integer
882
883 def on_buddy_state(buddy_id):
884 return
885 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000886 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000887 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000888
889 /**
890 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000891 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000892 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000893 *
Benny Prijonobbeb3992007-05-21 13:48:35 +0000894 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
895 * passed as one of the argument.
896 *
Benny Prijono0875ae82006-12-26 00:11:48 +0000897 * @param call_id Containts the ID of the call where the IM was
898 * sent, or PJSUA_INVALID_ID if the IM was sent
899 * outside call context.
900 * @param from URI of the sender.
901 * @param to URI of the destination message.
902 * @param contact The Contact URI of the sender, if present.
903 * @param mime_type MIME type of the message.
904 * @param body The message content.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000905 *
906 * \par Python Syntax:
907 * \code
908 # call_id: integer
909 # from: string
910 # to: string
911 # contact: string
912 # mime_type: string
913 # body: string
Benny Prijonoba736c42008-07-10 20:45:03 +0000914 # acc_id: integer
Benny Prijonoe6ead542007-01-31 20:53:31 +0000915
916 def on_pager(call_id, from, to, contact, mime_type, body):
917 return
918 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000919 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000920 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
921 const pj_str_t *to, const pj_str_t *contact,
922 const pj_str_t *mime_type, const pj_str_t *body);
923
924 /**
Benny Prijonobbeb3992007-05-21 13:48:35 +0000925 * This is the alternative version of the \a on_pager() callback with
926 * \a pjsip_rx_data argument.
927 *
928 * @param call_id Containts the ID of the call where the IM was
929 * sent, or PJSUA_INVALID_ID if the IM was sent
930 * outside call context.
931 * @param from URI of the sender.
932 * @param to URI of the destination message.
933 * @param contact The Contact URI of the sender, if present.
934 * @param mime_type MIME type of the message.
935 * @param body The message content.
936 * @param rdata The incoming MESSAGE request.
Benny Prijonoba736c42008-07-10 20:45:03 +0000937 * @param acc_id Account ID most suitable for this message.
Benny Prijonobbeb3992007-05-21 13:48:35 +0000938 */
939 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
940 const pj_str_t *to, const pj_str_t *contact,
941 const pj_str_t *mime_type, const pj_str_t *body,
Benny Prijonoba736c42008-07-10 20:45:03 +0000942 pjsip_rx_data *rdata, pjsua_acc_id acc_id);
Benny Prijonobbeb3992007-05-21 13:48:35 +0000943
944 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000945 * Notify application about the delivery status of outgoing pager
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000946 * request. See also on_pager_status2() callback for the version with
947 * \a pjsip_rx_data in the argument list.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000948 *
949 * @param call_id Containts the ID of the call where the IM was
950 * sent, or PJSUA_INVALID_ID if the IM was sent
951 * outside call context.
952 * @param to Destination URI.
953 * @param body Message body.
954 * @param user_data Arbitrary data that was specified when sending
955 * IM message.
956 * @param status Delivery status.
957 * @param reason Delivery status reason.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000958 *
959 * \par Python Syntax
960 * \code
961 # call_id: integer
962 # to: string
963 # body: string
964 # user_data: string
965 # status: integer
966 # reason: string
Benny Prijonoba736c42008-07-10 20:45:03 +0000967 # acc_id: integer
Benny Prijonoe6ead542007-01-31 20:53:31 +0000968
969 def on_pager_status(call_id, to, body, user_data, status, reason):
970 return
971 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000972 */
973 void (*on_pager_status)(pjsua_call_id call_id,
974 const pj_str_t *to,
975 const pj_str_t *body,
976 void *user_data,
977 pjsip_status_code status,
978 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000979
980 /**
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000981 * Notify application about the delivery status of outgoing pager
982 * request.
983 *
984 * @param call_id Containts the ID of the call where the IM was
985 * sent, or PJSUA_INVALID_ID if the IM was sent
986 * outside call context.
987 * @param to Destination URI.
988 * @param body Message body.
989 * @param user_data Arbitrary data that was specified when sending
990 * IM message.
991 * @param status Delivery status.
992 * @param reason Delivery status reason.
Benny Prijono0a982002007-06-12 16:22:09 +0000993 * @param tdata The original MESSAGE request.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000994 * @param rdata The incoming MESSAGE response, or NULL if the
995 * message transaction fails because of time out
996 * or transport error.
Benny Prijonoba736c42008-07-10 20:45:03 +0000997 * @param acc_id Account ID from this the instant message was
998 * send.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000999 */
1000 void (*on_pager_status2)(pjsua_call_id call_id,
1001 const pj_str_t *to,
1002 const pj_str_t *body,
1003 void *user_data,
1004 pjsip_status_code status,
1005 const pj_str_t *reason,
Benny Prijono0a982002007-06-12 16:22:09 +00001006 pjsip_tx_data *tdata,
Benny Prijonoba736c42008-07-10 20:45:03 +00001007 pjsip_rx_data *rdata,
1008 pjsua_acc_id acc_id);
Benny Prijono4da0b1d2007-06-11 18:22:54 +00001009
1010 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +00001011 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +00001012 *
1013 * @param call_id Containts the ID of the call where the IM was
1014 * sent, or PJSUA_INVALID_ID if the IM was sent
1015 * outside call context.
1016 * @param from URI of the sender.
1017 * @param to URI of the destination message.
1018 * @param contact The Contact URI of the sender, if present.
1019 * @param is_typing Non-zero if peer is typing, or zero if peer
1020 * has stopped typing a message.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001021 *
1022 * \par Python Syntax
1023 * \code
1024 # call_id: string
1025 # from: string
1026 # to: string
1027 # contact: string
1028 # is_typing: integer
1029
1030 def on_typing(call_id, from, to, contact, is_typing):
1031 return
1032 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001033 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001034 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
1035 const pj_str_t *to, const pj_str_t *contact,
1036 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +00001037
Benny Prijono6ba8c542007-10-16 01:34:14 +00001038 /**
Benny Prijonoba736c42008-07-10 20:45:03 +00001039 * Notify application about typing indication.
1040 *
1041 * @param call_id Containts the ID of the call where the IM was
1042 * sent, or PJSUA_INVALID_ID if the IM was sent
1043 * outside call context.
1044 * @param from URI of the sender.
1045 * @param to URI of the destination message.
1046 * @param contact The Contact URI of the sender, if present.
1047 * @param is_typing Non-zero if peer is typing, or zero if peer
1048 * has stopped typing a message.
1049 * @param rdata The received request.
1050 * @param acc_id Account ID most suitable for this message.
1051 */
1052 void (*on_typing2)(pjsua_call_id call_id, const pj_str_t *from,
1053 const pj_str_t *to, const pj_str_t *contact,
1054 pj_bool_t is_typing, pjsip_rx_data *rdata,
1055 pjsua_acc_id acc_id);
1056
1057 /**
Benny Prijono6ba8c542007-10-16 01:34:14 +00001058 * Callback when the library has finished performing NAT type
1059 * detection.
1060 *
1061 * @param res NAT detection result.
1062 */
1063 void (*on_nat_detect)(const pj_stun_nat_detect_result *res);
1064
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001065} pjsua_callback;
1066
1067
1068
Benny Prijonodc39fe82006-05-26 12:17:46 +00001069
1070/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001071 * This structure describes the settings to control the API and
1072 * user agent behavior, and can be specified when calling #pjsua_init().
1073 * Before setting the values, application must call #pjsua_config_default()
1074 * to initialize this structure with the default values.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001075 *
1076 * \par Python Sample Syntax:
1077 * The pjsua_config type in Python is <tt>py_pjsua.Config</tt>. Application
1078 * creates the instance by calling <tt>py_pjsua.config_default()</tt>:
1079 * \code
1080 cfg = py_pjsua.config_default()
1081 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001082 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001083typedef struct pjsua_config
1084{
1085
1086 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001087 * Maximum calls to support (default: 4). The value specified here
1088 * must be smaller than the compile time maximum settings
1089 * PJSUA_MAX_CALLS, which by default is 32. To increase this
1090 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
1091 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001092 */
1093 unsigned max_calls;
1094
1095 /**
1096 * Number of worker threads. Normally application will want to have at
1097 * least one worker thread, unless when it wants to poll the library
1098 * periodically, which in this case the worker thread can be set to
1099 * zero.
1100 */
1101 unsigned thread_cnt;
1102
1103 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +00001104 * Number of nameservers. If no name server is configured, the SIP SRV
1105 * resolution would be disabled, and domain will be resolved with
1106 * standard pj_gethostbyname() function.
1107 */
1108 unsigned nameserver_count;
1109
1110 /**
1111 * Array of nameservers to be used by the SIP resolver subsystem.
1112 * The order of the name server specifies the priority (first name
1113 * server will be used first, unless it is not reachable).
1114 */
1115 pj_str_t nameserver[4];
1116
1117 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001118 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001119 */
1120 unsigned outbound_proxy_cnt;
1121
1122 /**
1123 * Specify the URL of outbound proxies to visit for all outgoing requests.
1124 * The outbound proxies will be used for all accounts, and it will
1125 * be used to build the route set for outgoing requests. The final
1126 * route set for outgoing requests will consists of the outbound proxies
1127 * and the proxy configured in the account.
1128 */
1129 pj_str_t outbound_proxy[4];
1130
Benny Prijonoc97608e2007-03-23 16:34:20 +00001131 /**
Benny Prijonoebbf6892007-03-24 17:37:25 +00001132 * Specify domain name to be resolved with DNS SRV resolution to get the
Benny Prijonof76e1392008-06-06 14:51:48 +00001133 * address of the STUN server. Alternatively application may specify
1134 * \a stun_host instead.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001135 *
1136 * If DNS SRV resolution failed for this domain, then DNS A resolution
1137 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +00001138 */
Benny Prijonoebbf6892007-03-24 17:37:25 +00001139 pj_str_t stun_domain;
1140
1141 /**
Benny Prijonoaf09dc32007-04-22 12:48:30 +00001142 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
1143 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001144 */
1145 pj_str_t stun_host;
1146
1147 /**
Benny Prijono91a6a172007-10-31 08:59:29 +00001148 * Support for adding and parsing NAT type in the SDP to assist
1149 * troubleshooting. The valid values are:
1150 * - 0: no information will be added in SDP, and parsing is disabled.
Benny Prijono6ba8c542007-10-16 01:34:14 +00001151 * - 1: only the NAT type number is added.
1152 * - 2: add both NAT type number and name.
1153 *
Benny Prijono91a6a172007-10-31 08:59:29 +00001154 * Default: 1
Benny Prijono6ba8c542007-10-16 01:34:14 +00001155 */
1156 int nat_type_in_sdp;
1157
1158 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001159 * Specify whether support for reliable provisional response (100rel and
1160 * PRACK) should be required by default. Note that this setting can be
1161 * further customized in account configuration (#pjsua_acc_config).
1162 *
1163 * Default: PJ_FALSE
1164 */
1165 pj_bool_t require_100rel;
1166
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001167 /**
1168 * Number of credentials in the credential array.
1169 */
1170 unsigned cred_count;
1171
1172 /**
1173 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +00001174 * and can be used to authenticate against outbound proxies. If the
1175 * credential is specific to the account, then application should set
1176 * the credential in the pjsua_acc_config rather than the credential
1177 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001178 */
1179 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1180
1181 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001182 * Application callback to receive various event notifications from
1183 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001184 */
1185 pjsua_callback cb;
1186
Benny Prijono56315612006-07-18 14:39:40 +00001187 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001188 * Optional user agent string (default empty). If it's empty, no
1189 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +00001190 */
1191 pj_str_t user_agent;
1192
Benny Prijonod8179652008-01-23 20:39:07 +00001193#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
1194 /**
1195 * Specify default value of secure media transport usage.
1196 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
1197 * PJMEDIA_SRTP_MANDATORY.
1198 *
1199 * Note that this setting can be further customized in account
1200 * configuration (#pjsua_acc_config).
1201 *
1202 * Default: #PJSUA_DEFAULT_USE_SRTP
1203 */
1204 pjmedia_srtp_use use_srtp;
1205
1206 /**
1207 * Specify whether SRTP requires secure signaling to be used. This option
1208 * is only used when \a use_srtp option above is non-zero.
1209 *
1210 * Valid values are:
1211 * 0: SRTP does not require secure signaling
1212 * 1: SRTP requires secure transport such as TLS
1213 * 2: SRTP requires secure end-to-end transport (SIPS)
1214 *
1215 * Note that this setting can be further customized in account
1216 * configuration (#pjsua_acc_config).
1217 *
1218 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
1219 */
1220 int srtp_secure_signaling;
1221#endif
1222
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001223} pjsua_config;
1224
1225
1226/**
1227 * Use this function to initialize pjsua config.
1228 *
1229 * @param cfg pjsua config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001230 *
1231 * \par Python Sample Syntax:
1232 * The corresponding Python function creates an instance of the config and
1233 * initializes it to the default settings:
1234 * \code
1235 cfg = py_pjsua.config_default()
1236 * \endcode
1237
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001238 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001239PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001240
1241
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001242/** The implementation has been moved to sip_auth.h */
Benny Prijono7977f9f2007-10-10 11:37:56 +00001243#define pjsip_cred_dup pjsip_cred_info_dup
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001244
1245
1246/**
1247 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001248 *
1249 * @param pool The pool to get memory from.
1250 * @param dst Destination config.
1251 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001252 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001253PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1254 pjsua_config *dst,
1255 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001256
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001257
1258/**
1259 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001260 * outgoing SIP message. It can (optionally) be specified for example
1261 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1262 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1263 *
1264 * Application MUST call #pjsua_msg_data_init() to initialize this
1265 * structure before setting its values.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001266 *
1267 * \par Python Syntax
1268 * The data type in Python is <tt>py_pjsua.Msg_Data</tt>. Application is
1269 * recommended to instantiate the structure by using this construct:
1270 * \code
1271 msg_data = py_pjsua.msg_data_init()
1272 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001273 */
Benny Prijono63fba012008-07-17 14:19:10 +00001274struct pjsua_msg_data
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001275{
1276 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001277 * Additional message headers as linked list. Application can add
1278 * headers to the list by creating the header, either from the heap/pool
1279 * or from temporary local variable, and add the header using
1280 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001281 *
1282 * \par Python:
1283 * This field is implemented as string linked-list in Python, where each
1284 * string describes the header. For example:
1285 \code
1286 msg_data = py_pjsua.Msg_Data()
1287 msg_data.hdr_list = ["Subject: Hello py_pjsua!", "Priority: very low"]
1288 \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001289 */
1290 pjsip_hdr hdr_list;
1291
1292 /**
1293 * MIME type of optional message body.
1294 */
1295 pj_str_t content_type;
1296
1297 /**
1298 * Optional message body.
1299 */
1300 pj_str_t msg_body;
1301
Benny Prijono63fba012008-07-17 14:19:10 +00001302};
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001303
1304
1305/**
1306 * Initialize message data.
1307 *
1308 * @param msg_data Message data to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001309 *
1310 * \par Python
1311 * The corresponding Python function creates and initializes the structure:
1312 * \code
1313 msg_data = py_pjsua.msg_data_init()
1314 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001315 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001316PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001317
Benny Prijono268ca612006-02-07 12:34:11 +00001318
1319/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001320 * Instantiate pjsua application. Application must call this function before
1321 * calling any other functions, to make sure that the underlying libraries
1322 * are properly initialized. Once this function has returned success,
1323 * application must call pjsua_destroy() before quitting.
1324 *
1325 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001326 *
1327 * \par Python:
1328 * \code
1329 status = py_pjsua.create()
1330 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001331 */
1332PJ_DECL(pj_status_t) pjsua_create(void);
1333
1334
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001335/** Forward declaration */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001336typedef struct pjsua_media_config pjsua_media_config;
1337
1338
Benny Prijonodc39fe82006-05-26 12:17:46 +00001339/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001340 * Initialize pjsua with the specified settings. All the settings are
1341 * optional, and the default values will be used when the config is not
1342 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001343 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001344 * Note that #pjsua_create() MUST be called before calling this function.
1345 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001346 * @param ua_cfg User agent configuration.
1347 * @param log_cfg Optional logging configuration.
1348 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001349 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001350 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001351 *
1352 * \par Python:
1353 * The function is similar in Python:
1354 * \code
1355 status = py_pjsua.init(ua_cfg, log_cfg, media_cfg)
1356 * \endcode
1357 * Note that \a ua_cfg, \a log_cfg, and \a media_cfg are optional, and
1358 * the Python script may pass None if it doesn't want to configure the
1359 * setting.
Benny Prijono268ca612006-02-07 12:34:11 +00001360 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001361PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1362 const pjsua_logging_config *log_cfg,
1363 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001364
1365
1366/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001367 * Application is recommended to call this function after all initialization
1368 * is done, so that the library can do additional checking set up
1369 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001370 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001371 * Application may call this function anytime after #pjsua_init().
1372 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001373 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001374 *
1375 * \par Python:
1376 * The function is similar in Python:
1377 * \code
1378 status = py_pjsua.start()
1379 * \endcode
Benny Prijonoccf95622006-02-07 18:48:01 +00001380 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001381PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001382
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001383
Benny Prijonoccf95622006-02-07 18:48:01 +00001384/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001385 * Destroy pjsua. Application is recommended to perform graceful shutdown
1386 * before calling this function (such as unregister the account from the SIP
1387 * server, terminate presense subscription, and hangup active calls), however,
1388 * this function will do all of these if it finds there are active sessions
1389 * that need to be terminated. This function will approximately block for
1390 * one second to wait for replies from remote.
1391 *
1392 * Application.may safely call this function more than once if it doesn't
1393 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001394 *
1395 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001396 *
1397 * \par Python:
1398 * The function is similar in Python:
1399 * \code
1400 status = py_pjsua.destroy()
1401 * \endcode
Benny Prijono268ca612006-02-07 12:34:11 +00001402 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001403PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001404
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001405
Benny Prijono9fc735d2006-05-28 14:58:12 +00001406/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001407 * Poll pjsua for events, and if necessary block the caller thread for
1408 * the specified maximum interval (in miliseconds).
1409 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001410 * Application doesn't normally need to call this function if it has
1411 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1412 * because polling then will be done by these worker threads instead.
1413 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001414 * @param msec_timeout Maximum time to wait, in miliseconds.
1415 *
1416 * @return The number of events that have been handled during the
1417 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001418 * can retrieve the error as (status = -return_value).
1419 *
1420 * \par Python:
1421 * The function is similar in Python:
1422 * \code
1423 n = py_pjsua.handle_events(msec_timeout)
1424 * \endcode
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001425 */
1426PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1427
1428
1429/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001430 * Create memory pool to be used by the application. Once application
1431 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001432 *
1433 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001434 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001435 * @param increment Increment size.
1436 *
1437 * @return The pool, or NULL when there's no memory.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001438 *
1439 * \par Python:
1440 * Python script may also create a pool object from the script:
1441 * \code
1442 pool = py_pjsua.pool_create(name, init_size, increment)
1443 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001444 */
1445PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1446 pj_size_t increment);
1447
1448
1449/**
1450 * Application can call this function at any time (after pjsua_create(), of
1451 * course) to change logging settings.
1452 *
1453 * @param c Logging configuration.
1454 *
1455 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001456 *
1457 * \par Python:
1458 * The function is similar in Python:
1459 * \code
1460 status = py_pjsua.reconfigure_logging(log_cfg)
1461 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001462 */
1463PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1464
1465
1466/**
1467 * Internal function to get SIP endpoint instance of pjsua, which is
1468 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001469 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001470 *
1471 * @return SIP endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001472 *
1473 * \par Python:
1474 * Application may retrieve the SIP endpoint instance:
1475 * \code
1476 endpt = py_pjsua.get_pjsip_endpt()
1477 * \endcode
1478 * However currently the object is just an opaque object and does not have
1479 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001480 */
1481PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1482
1483/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001484 * Internal function to get media endpoint instance.
1485 * Only valid after #pjsua_init() is called.
1486 *
1487 * @return Media endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001488 *
1489 * \par Python:
1490 * Application may retrieve the media endpoint instance:
1491 * \code
1492 endpt = py_pjsua.get_pjmedia_endpt()
1493 * \endcode
1494 * However currently the object is just an opaque object and does not have
1495 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001496 */
1497PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1498
Benny Prijono97b87172006-08-24 14:25:14 +00001499/**
1500 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001501 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001502 *
1503 * @return Pool factory currently used by PJSUA.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001504 *
1505 * \par Python:
1506 * Application may retrieve the pool factory instance:
1507 * \code
1508 endpt = py_pjsua.get_pool_factory()
1509 * \endcode
1510 * However currently the object is just an opaque object and does not have
1511 * any use for Python scripts.
Benny Prijono97b87172006-08-24 14:25:14 +00001512 */
1513PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1514
1515
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001516
1517/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001518 * Utilities.
1519 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001520 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001521
1522/**
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001523 * This is a utility function to detect NAT type in front of this
1524 * endpoint. Once invoked successfully, this function will complete
Benny Prijono6ba8c542007-10-16 01:34:14 +00001525 * asynchronously and report the result in \a on_nat_detect() callback
1526 * of pjsua_callback.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001527 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001528 * After NAT has been detected and the callback is called, application can
1529 * get the detected NAT type by calling #pjsua_get_nat_type(). Application
1530 * can also perform NAT detection by calling #pjsua_detect_nat_type()
1531 * again at later time.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001532 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001533 * Note that STUN must be enabled to run this function successfully.
1534 *
1535 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001536 */
Benny Prijono6ba8c542007-10-16 01:34:14 +00001537PJ_DECL(pj_status_t) pjsua_detect_nat_type(void);
1538
1539
1540/**
1541 * Get the NAT type as detected by #pjsua_detect_nat_type() function.
1542 * This function will only return useful NAT type after #pjsua_detect_nat_type()
1543 * has completed successfully and \a on_nat_detect() callback has been called.
1544 *
1545 * @param type NAT type.
1546 *
1547 * @return When detection is in progress, this function will
1548 * return PJ_EPENDING and \a type will be set to
1549 * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been
1550 * detected successfully, this function will return
1551 * PJ_SUCCESS and \a type will be set to the correct
1552 * value. Other return values indicate error and
1553 * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN.
Benny Prijono91a6a172007-10-31 08:59:29 +00001554 *
1555 * @see pjsua_call_get_rem_nat_type()
Benny Prijono6ba8c542007-10-16 01:34:14 +00001556 */
1557PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type);
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001558
1559
1560/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001561 * This is a utility function to verify that valid SIP url is given. If the
1562 * URL is valid, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001563 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001564 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001565 *
1566 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001567 *
1568 * \par Python:
1569 * \code
1570 status = py_pjsua.verify_sip_url(url)
1571 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001572 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001573PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001574
1575
1576/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001577 * This is a utility function to display error message for the specified
1578 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001579 *
1580 * @param sender The log sender field.
1581 * @param title Message title for the error.
1582 * @param status Status code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001583 *
1584 * \par Python:
1585 * \code
1586 py_pjsua.perror(sender, title, status)
1587 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001588 */
1589PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1590 pj_status_t status);
1591
1592
Benny Prijonoda9785b2007-04-02 20:43:06 +00001593/**
1594 * This is a utility function to dump the stack states to log, using
1595 * verbosity level 3.
1596 *
1597 * @param detail Will print detailed output (such as list of
1598 * SIP transactions) when non-zero.
1599 */
1600PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001601
1602/**
1603 * @}
1604 */
1605
1606
1607
1608/*****************************************************************************
1609 * TRANSPORT API
1610 */
1611
1612/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001613 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001614 * @ingroup PJSUA_LIB
1615 * @brief API for managing SIP transports
1616 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001617 *
1618 * PJSUA-API supports creating multiple transport instances, for example UDP,
1619 * TCP, and TLS transport. SIP transport must be created before adding an
1620 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001621 */
1622
1623
Benny Prijonoe6ead542007-01-31 20:53:31 +00001624/** SIP transport identification.
1625 */
Benny Prijono312aff92006-06-17 04:08:30 +00001626typedef int pjsua_transport_id;
1627
1628
1629/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001630 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001631 * and media. Before setting some values to this structure, application
1632 * MUST call #pjsua_transport_config_default() to initialize its
1633 * values with default settings.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001634 *
1635 * \par Python:
1636 * The data type in Python is <tt>py_pjsua.Transport_Config</tt>,
1637 * although application can just do this to create the instance:
1638 * \code
1639 transport_cfg = py_pjsua.transport_config_default()
1640 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001641 */
1642typedef struct pjsua_transport_config
1643{
1644 /**
1645 * UDP port number to bind locally. This setting MUST be specified
1646 * even when default port is desired. If the value is zero, the
1647 * transport will be bound to any available port, and application
1648 * can query the port by querying the transport info.
1649 */
1650 unsigned port;
1651
1652 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001653 * Optional address to advertise as the address of this transport.
1654 * Application can specify any address or hostname for this field,
1655 * for example it can point to one of the interface address in the
1656 * system, or it can point to the public address of a NAT router
1657 * where port mappings have been configured for the application.
1658 *
1659 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001660 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001661 pj_str_t public_addr;
1662
1663 /**
1664 * Optional address where the socket should be bound to. This option
1665 * SHOULD only be used to selectively bind the socket to particular
1666 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1667 * published address of a transport (the public_addr field should be
1668 * used for that purpose).
1669 *
1670 * Note that unlike public_addr field, the address (or hostname) here
1671 * MUST correspond to the actual interface address in the host, since
1672 * this address will be specified as bind() argument.
1673 */
1674 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001675
1676 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001677 * This specifies TLS settings for TLS transport. It is only be used
1678 * when this transport config is being used to create a SIP TLS
1679 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001680 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001681 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001682
Benny Prijono312aff92006-06-17 04:08:30 +00001683} pjsua_transport_config;
1684
1685
1686/**
1687 * Call this function to initialize UDP config with default values.
1688 *
1689 * @param cfg The UDP config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001690 *
1691 * \par Python:
1692 * The corresponding Python function is rather different:
1693 * \code
1694 transport_cfg = py_pjsua.transport_config_default()
1695 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001696 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001697PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001698
1699
1700/**
Benny Prijono312aff92006-06-17 04:08:30 +00001701 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001702 *
1703 * @param pool The pool.
1704 * @param dst The destination config.
1705 * @param src The source config.
1706 *
1707 * \par Python:
1708 * Not applicable. One should be able to just copy one variable instance
1709 * to another in Python.
Benny Prijono312aff92006-06-17 04:08:30 +00001710 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001711PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1712 pjsua_transport_config *dst,
1713 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001714
1715
1716/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001717 * This structure describes transport information returned by
1718 * #pjsua_transport_get_info() function.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001719 *
1720 * \par Python:
1721 * The corresponding data type in Python is <tt>py_pjsua.Transport_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001722 */
1723typedef struct pjsua_transport_info
1724{
1725 /**
1726 * PJSUA transport identification.
1727 */
1728 pjsua_transport_id id;
1729
1730 /**
1731 * Transport type.
1732 */
1733 pjsip_transport_type_e type;
1734
1735 /**
1736 * Transport type name.
1737 */
1738 pj_str_t type_name;
1739
1740 /**
1741 * Transport string info/description.
1742 */
1743 pj_str_t info;
1744
1745 /**
1746 * Transport flag (see ##pjsip_transport_flags_e).
1747 */
1748 unsigned flag;
1749
1750 /**
1751 * Local address length.
1752 */
1753 unsigned addr_len;
1754
1755 /**
1756 * Local/bound address.
1757 */
1758 pj_sockaddr local_addr;
1759
1760 /**
1761 * Published address (or transport address name).
1762 */
1763 pjsip_host_port local_name;
1764
1765 /**
1766 * Current number of objects currently referencing this transport.
1767 */
1768 unsigned usage_count;
1769
1770
1771} pjsua_transport_info;
1772
1773
1774/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001775 * Create and start a new SIP transport according to the specified
1776 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001777 *
1778 * @param type Transport type.
1779 * @param cfg Transport configuration.
1780 * @param p_id Optional pointer to receive transport ID.
1781 *
1782 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001783 *
1784 * \par Python:
1785 * The corresponding Python function returns (status,id) tuple:
1786 * \code
1787 status, transport_id = py_pjsua.transport_create(type, cfg)
1788 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001789 */
1790PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1791 const pjsua_transport_config *cfg,
1792 pjsua_transport_id *p_id);
1793
1794/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001795 * Register transport that has been created by application. This function
1796 * is useful if application wants to implement custom SIP transport and use
1797 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001798 *
1799 * @param tp Transport instance.
1800 * @param p_id Optional pointer to receive transport ID.
1801 *
1802 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001803 *
1804 * \par Python:
1805 * Not applicable (for now), because one cannot create a custom transport
1806 * from Python script.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001807 */
1808PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1809 pjsua_transport_id *p_id);
1810
1811
1812/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001813 * Enumerate all transports currently created in the system. This function
1814 * will return all transport IDs, and application may then call
1815 * #pjsua_transport_get_info() function to retrieve detailed information
1816 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001817 *
1818 * @param id Array to receive transport ids.
1819 * @param count In input, specifies the maximum number of elements.
1820 * On return, it contains the actual number of elements.
1821 *
1822 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001823 *
1824 * \par Python:
1825 * The function returns list of integers representing transport ids:
1826 * \code
1827 [int] = py_pjsua.enum_transports()
1828 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001829 */
1830PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1831 unsigned *count );
1832
1833
1834/**
1835 * Get information about transports.
1836 *
1837 * @param id Transport ID.
1838 * @param info Pointer to receive transport info.
1839 *
1840 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001841 *
1842 * \par Python:
1843 * \code
1844 transport_info = py_pjsua.transport_get_info(id)
1845 * \endcode
1846 * The Python function returns None on error.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001847 */
1848PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1849 pjsua_transport_info *info);
1850
1851
1852/**
1853 * Disable a transport or re-enable it. By default transport is always
1854 * enabled after it is created. Disabling a transport does not necessarily
1855 * close the socket, it will only discard incoming messages and prevent
1856 * the transport from being used to send outgoing messages.
1857 *
1858 * @param id Transport ID.
1859 * @param enabled Non-zero to enable, zero to disable.
1860 *
1861 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001862 *
1863 * \par Python:
1864 * \code
1865 status = py_pjsua.transport_set_enable(id, enabled)
1866 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001867 */
1868PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1869 pj_bool_t enabled);
1870
1871
1872/**
1873 * Close the transport. If transport is forcefully closed, it will be
1874 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00001875 * transport may not terminate properly (it may even crash). Otherwise,
1876 * the system will wait until all transactions are closed while preventing
1877 * new users from using the transport, and will close the transport when
1878 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001879 *
1880 * @param id Transport ID.
1881 * @param force Non-zero to immediately close the transport. This
1882 * is not recommended!
1883 *
1884 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001885 *
1886 * \par Python:
1887 * \code
1888 status = py_pjsua.transport_close(id, force)
1889 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001890 */
1891PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1892 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001893
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001894/**
Benny Prijono312aff92006-06-17 04:08:30 +00001895 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001896 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001897
1898
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001899
1900
1901/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001902 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001903 */
1904
Benny Prijono312aff92006-06-17 04:08:30 +00001905
1906/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001907 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001908 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001909 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001910 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001911 *
Benny Prijono312aff92006-06-17 04:08:30 +00001912 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001913 * using the application. In SIP terms, the identity is used as the <b>From</b>
1914 * header in outgoing requests.
1915 *
1916 * PJSUA-API supports creating and managing multiple accounts. The maximum
1917 * number of accounts is limited by a compile time constant
1918 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001919 *
1920 * Account may or may not have client registration associated with it.
1921 * An account is also associated with <b>route set</b> and some <b>authentication
1922 * credentials</b>, which are used when sending SIP request messages using the
1923 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00001924 * will be reported to remote peer when they subscribe to the account's
1925 * presence, or which is published to a presence server if presence
1926 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00001927 *
1928 * At least one account MUST be created in the application. If no user
1929 * association is required, application can create a userless account by
1930 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00001931 * instead of a particular user, and it correspond with a particular
1932 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00001933 *
1934 * Also one account must be set as the <b>default account</b>, which is used as
1935 * the account to use when PJSUA fails to match a request with any other
1936 * accounts.
1937 *
1938 * When sending outgoing SIP requests (such as making calls or sending
1939 * instant messages), normally PJSUA requires the application to specify
1940 * which account to use for the request. If no account is specified,
1941 * PJSUA may be able to select the account by matching the destination
1942 * domain name, and fall back to default account when no match is found.
1943 */
1944
1945/**
1946 * Maximum accounts.
1947 */
1948#ifndef PJSUA_MAX_ACC
1949# define PJSUA_MAX_ACC 8
1950#endif
1951
1952
1953/**
1954 * Default registration interval.
1955 */
1956#ifndef PJSUA_REG_INTERVAL
Benny Prijonobddef2c2007-10-31 13:28:08 +00001957# define PJSUA_REG_INTERVAL 300
Benny Prijono312aff92006-06-17 04:08:30 +00001958#endif
1959
1960
1961/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001962 * Default PUBLISH expiration
1963 */
1964#ifndef PJSUA_PUBLISH_EXPIRATION
1965# define PJSUA_PUBLISH_EXPIRATION 600
1966#endif
1967
1968
1969/**
Benny Prijono093d3022006-09-24 00:07:11 +00001970 * Default account priority.
1971 */
1972#ifndef PJSUA_DEFAULT_ACC_PRIORITY
1973# define PJSUA_DEFAULT_ACC_PRIORITY 0
1974#endif
1975
1976
1977/**
Benny Prijono8058a622007-06-08 04:37:05 +00001978 * This macro specifies the URI scheme to use in Contact header
1979 * when secure transport such as TLS is used. Application can specify
1980 * either "sip" or "sips".
1981 */
1982#ifndef PJSUA_SECURE_SCHEME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00001983# define PJSUA_SECURE_SCHEME "sips"
Benny Prijono8058a622007-06-08 04:37:05 +00001984#endif
1985
1986
1987/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001988 * This structure describes account configuration to be specified when
1989 * adding a new account with #pjsua_acc_add(). Application MUST initialize
1990 * this structure first by calling #pjsua_acc_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00001991 *
1992 * \par Python:
1993 * The data type in Python is <tt>py_pjsua.Acc_Config</tt>, but normally
1994 * application can just use the snippet below to create and initialize
1995 * the account config:
1996 * \code
1997 acc_cfg = py_pjsua.acc_config_default()
1998 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001999 */
2000typedef struct pjsua_acc_config
2001{
Benny Prijono093d3022006-09-24 00:07:11 +00002002 /**
2003 * Account priority, which is used to control the order of matching
2004 * incoming/outgoing requests. The higher the number means the higher
2005 * the priority is, and the account will be matched first.
2006 */
2007 int priority;
2008
Benny Prijono312aff92006-06-17 04:08:30 +00002009 /**
2010 * The full SIP URL for the account. The value can take name address or
2011 * URL format, and will look something like "sip:account@serviceprovider".
2012 *
2013 * This field is mandatory.
2014 */
2015 pj_str_t id;
2016
2017 /**
2018 * This is the URL to be put in the request URI for the registration,
2019 * and will look something like "sip:serviceprovider".
2020 *
2021 * This field should be specified if registration is desired. If the
2022 * value is empty, no account registration will be performed.
2023 */
2024 pj_str_t reg_uri;
2025
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002026 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002027 * If this flag is set, the presence information of this account will
2028 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono48ab2b72007-11-08 09:24:30 +00002029 *
2030 * Default: PJ_FALSE
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002031 */
2032 pj_bool_t publish_enabled;
2033
Benny Prijonofe04fb52007-08-24 08:28:52 +00002034 /**
Benny Prijono48ab2b72007-11-08 09:24:30 +00002035 * Authentication preference.
2036 */
2037 pjsip_auth_clt_pref auth_pref;
2038
2039 /**
Benny Prijonofe04fb52007-08-24 08:28:52 +00002040 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
2041 * is not specified, a random string will be used.
2042 */
2043 pj_str_t pidf_tuple_id;
2044
Benny Prijono312aff92006-06-17 04:08:30 +00002045 /**
2046 * Optional URI to be put as Contact for this account. It is recommended
2047 * that this field is left empty, so that the value will be calculated
2048 * automatically based on the transport address.
2049 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00002050 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00002051
2052 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00002053 * Specify whether support for reliable provisional response (100rel and
2054 * PRACK) should be required for all sessions of this account.
2055 *
2056 * Default: PJ_FALSE
2057 */
2058 pj_bool_t require_100rel;
2059
2060 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002061 * Number of proxies in the proxy array below.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002062 *
2063 * \par Python:
2064 * Not applicable, as \a proxy is implemented as list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00002065 */
2066 unsigned proxy_cnt;
2067
2068 /**
2069 * Optional URI of the proxies to be visited for all outgoing requests
2070 * that are using this account (REGISTER, INVITE, etc). Application need
2071 * to specify these proxies if the service provider requires that requests
2072 * destined towards its network should go through certain proxies first
2073 * (for example, border controllers).
2074 *
2075 * These proxies will be put in the route set for this account, with
2076 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00002077 * first). If global outbound proxies are configured in pjsua_config,
2078 * then these account proxies will be placed after the global outbound
2079 * proxies in the routeset.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002080 *
2081 * \par Python:
2082 * This will be list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00002083 */
2084 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
2085
2086 /**
2087 * Optional interval for registration, in seconds. If the value is zero,
Benny Prijonobddef2c2007-10-31 13:28:08 +00002088 * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
Benny Prijono312aff92006-06-17 04:08:30 +00002089 */
2090 unsigned reg_timeout;
2091
2092 /**
2093 * Number of credentials in the credential array.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002094 *
2095 * \par Python:
2096 * Not applicable, since \a cred_info is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00002097 */
2098 unsigned cred_count;
2099
2100 /**
2101 * Array of credentials. If registration is desired, normally there should
2102 * be at least one credential specified, to successfully authenticate
2103 * against the service provider. More credentials can be specified, for
2104 * example when the requests are expected to be challenged by the
2105 * proxies in the route set.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002106 *
2107 * \par Python:
2108 * This field is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00002109 */
2110 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
2111
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002112 /**
2113 * Optionally bind this account to specific transport. This normally is
2114 * not a good idea, as account should be able to send requests using
2115 * any available transports according to the destination. But some
2116 * application may want to have explicit control over the transport to
2117 * use, so in that case it can set this field.
2118 *
2119 * Default: -1 (PJSUA_INVALID_ID)
2120 *
2121 * @see pjsua_acc_set_transport()
2122 */
2123 pjsua_transport_id transport_id;
2124
Benny Prijono15b02302007-09-27 14:07:07 +00002125 /**
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002126 * This option is used to update the UDP transport address and the Contact
2127 * header of REGISTER request. When this option is enabled, the library
2128 * will keep track of the public IP address from the response of REGISTER
2129 * request. Once it detects that the address has changed, it will
2130 * unregister current Contact, update the Contact with transport address
2131 * learned from Via header, and register a new Contact to the registrar.
2132 * This will also update the public name of UDP transport if STUN is
2133 * configured.
Benny Prijono15b02302007-09-27 14:07:07 +00002134 *
2135 * Default: 1 (yes)
2136 */
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002137 pj_bool_t allow_contact_rewrite;
Benny Prijono15b02302007-09-27 14:07:07 +00002138
Benny Prijonobddef2c2007-10-31 13:28:08 +00002139 /**
2140 * Set the interval for periodic keep-alive transmission for this account.
2141 * If this value is zero, keep-alive will be disabled for this account.
2142 * The keep-alive transmission will be sent to the registrar's address,
2143 * after successful registration.
2144 *
Benny Prijonobddef2c2007-10-31 13:28:08 +00002145 * Default: 15 (seconds)
2146 */
2147 unsigned ka_interval;
2148
2149 /**
2150 * Specify the data to be transmitted as keep-alive packets.
2151 *
2152 * Default: CR-LF
2153 */
2154 pj_str_t ka_data;
2155
Benny Prijonod8179652008-01-23 20:39:07 +00002156#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
2157 /**
2158 * Specify whether secure media transport should be used for this account.
2159 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
2160 * PJMEDIA_SRTP_MANDATORY.
2161 *
2162 * Default: #PJSUA_DEFAULT_USE_SRTP
2163 */
2164 pjmedia_srtp_use use_srtp;
2165
2166 /**
2167 * Specify whether SRTP requires secure signaling to be used. This option
2168 * is only used when \a use_srtp option above is non-zero.
2169 *
2170 * Valid values are:
2171 * 0: SRTP does not require secure signaling
2172 * 1: SRTP requires secure transport such as TLS
2173 * 2: SRTP requires secure end-to-end transport (SIPS)
2174 *
2175 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
2176 */
2177 int srtp_secure_signaling;
2178#endif
2179
Benny Prijono312aff92006-06-17 04:08:30 +00002180} pjsua_acc_config;
2181
2182
2183/**
2184 * Call this function to initialize account config with default values.
2185 *
2186 * @param cfg The account config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002187 *
2188 * \par Python:
2189 * In Python, this function both creates and initializes the account
2190 * config:
2191 * \code
2192 acc_cfg = py_pjsua.acc_config_default()
2193 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002194 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00002195PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002196
2197
2198/**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002199 * Duplicate account config.
2200 *
2201 * @param pool Pool to be used for duplicating the config.
2202 * @param dst Destination configuration.
2203 * @param src Source configuration.
2204 */
2205PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
2206 pjsua_acc_config *dst,
2207 const pjsua_acc_config *src);
2208
2209
2210/**
Benny Prijono312aff92006-06-17 04:08:30 +00002211 * Account info. Application can query account info by calling
2212 * #pjsua_acc_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00002213 *
2214 * \par Python:
2215 * The data type in Python is <tt>py_pjsua.Acc_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002216 */
2217typedef struct pjsua_acc_info
2218{
2219 /**
2220 * The account ID.
2221 */
2222 pjsua_acc_id id;
2223
2224 /**
2225 * Flag to indicate whether this is the default account.
2226 */
2227 pj_bool_t is_default;
2228
2229 /**
2230 * Account URI
2231 */
2232 pj_str_t acc_uri;
2233
2234 /**
2235 * Flag to tell whether this account has registration setting
2236 * (reg_uri is not empty).
2237 */
2238 pj_bool_t has_registration;
2239
2240 /**
2241 * An up to date expiration interval for account registration session.
2242 */
2243 int expires;
2244
2245 /**
2246 * Last registration status code. If status code is zero, the account
2247 * is currently not registered. Any other value indicates the SIP
2248 * status code of the registration.
2249 */
2250 pjsip_status_code status;
2251
2252 /**
2253 * String describing the registration status.
2254 */
2255 pj_str_t status_text;
2256
2257 /**
2258 * Presence online status for this account.
2259 */
2260 pj_bool_t online_status;
2261
2262 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00002263 * Presence online status text.
2264 */
2265 pj_str_t online_status_text;
2266
2267 /**
2268 * Extended RPID online status information.
2269 */
2270 pjrpid_element rpid;
2271
2272 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002273 * Buffer that is used internally to store the status text.
2274 */
2275 char buf_[PJ_ERR_MSG_SIZE];
2276
2277} pjsua_acc_info;
2278
2279
2280
2281/**
2282 * Get number of current accounts.
2283 *
2284 * @return Current number of accounts.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002285 *
2286 * \par Python:
2287 * \code
2288 count = py_pjsua.acc_get_count()
2289 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002290 */
2291PJ_DECL(unsigned) pjsua_acc_get_count(void);
2292
2293
2294/**
2295 * Check if the specified account ID is valid.
2296 *
2297 * @param acc_id Account ID to check.
2298 *
2299 * @return Non-zero if account ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002300 *
2301 * \par Python:
2302 * \code
2303 is_valid = py_pjsua.acc_is_valid(acc_id)
2304 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002305 */
2306PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
2307
2308
2309/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00002310 * Set default account to be used when incoming and outgoing
2311 * requests doesn't match any accounts.
2312 *
2313 * @param acc_id The account ID to be used as default.
2314 *
2315 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002316 *
2317 * \par Python:
2318 * \code
2319 status = py_pjsua.acc_set_default(acc_id)
2320 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002321 */
2322PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2323
2324
2325/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002326 * Get default account to be used when receiving incoming requests (calls),
2327 * when the destination of the incoming call doesn't match any other
2328 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002329 *
2330 * @return The default account ID, or PJSUA_INVALID_ID if no
2331 * default account is configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002332 *
2333 * \par Python:
2334 * \code
2335 acc_id = py_pjsua.acc_get_default()
2336 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002337 */
2338PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2339
2340
2341/**
Benny Prijono312aff92006-06-17 04:08:30 +00002342 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002343 * #pjsua_init()) before calling this function. If registration is configured
2344 * for this account, this function would also start the SIP registration
2345 * session with the SIP registrar server. This SIP registration session
2346 * will be maintained internally by the library, and application doesn't
2347 * need to do anything to maintain the registration session.
2348 *
Benny Prijono312aff92006-06-17 04:08:30 +00002349 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002350 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002351 * @param is_default If non-zero, this account will be set as the default
2352 * account. The default account will be used when sending
2353 * outgoing requests (e.g. making call) when no account is
2354 * specified, and when receiving incoming requests when the
2355 * request does not match any accounts. It is recommended
2356 * that default account is set to local/LAN account.
2357 * @param p_acc_id Pointer to receive account ID of the new account.
2358 *
2359 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002360 *
2361 * \par Python:
2362 * The function returns (status, account_id) tuple:
2363 * \code
2364 status, account_id = py_pjsua.acc_add(acc_cfg, is_default)
2365 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002366 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002367PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002368 pj_bool_t is_default,
2369 pjsua_acc_id *p_acc_id);
2370
2371
2372/**
2373 * Add a local account. A local account is used to identify local endpoint
2374 * instead of a specific user, and for this reason, a transport ID is needed
2375 * to obtain the local address information.
2376 *
2377 * @param tid Transport ID to generate account address.
2378 * @param is_default If non-zero, this account will be set as the default
2379 * account. The default account will be used when sending
2380 * outgoing requests (e.g. making call) when no account is
2381 * specified, and when receiving incoming requests when the
2382 * request does not match any accounts. It is recommended
2383 * that default account is set to local/LAN account.
2384 * @param p_acc_id Pointer to receive account ID of the new account.
2385 *
2386 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002387 *
2388 * \par Python:
2389 * The function returns (status, account_id) tuple:
2390 * \code
2391 status, account_id = py_pjsua.acc_add_local(tid, is_default)
2392 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002393 */
2394PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2395 pj_bool_t is_default,
2396 pjsua_acc_id *p_acc_id);
2397
2398/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002399 * Delete an account. This will unregister the account from the SIP server,
2400 * if necessary, and terminate server side presence subscriptions associated
2401 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002402 *
2403 * @param acc_id Id of the account to be deleted.
2404 *
2405 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002406 *
2407 * \par Python:
2408 * \code
2409 status = py_pjsua.acc_del(acc_id)
2410 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002411 */
2412PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2413
2414
2415/**
2416 * Modify account information.
2417 *
2418 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002419 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002420 *
2421 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002422 *
2423 * \par Python:
2424 * \code
2425 status = py_pjsua.acc_modify(acc_id, acc_cfg)
2426 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002427 */
2428PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002429 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002430
2431
2432/**
2433 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002434 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002435 * if there are server side presence subscription for this account, and/or
2436 * outgoing PUBLISH if presence publication is enabled for this account.
2437 *
2438 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002439 *
2440 * @param acc_id The account ID.
2441 * @param is_online True of false.
2442 *
2443 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002444 *
2445 * \par Python:
2446 * \code
2447 status = py_pjsua.acc_set_online_status(acc_id, is_online)
2448 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002449 */
2450PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2451 pj_bool_t is_online);
2452
Benny Prijono4461c7d2007-08-25 13:36:15 +00002453/**
2454 * Modify account's presence status to be advertised to remote/presence
2455 * subscribers. This would trigger the sending of outgoing NOTIFY request
2456 * if there are server side presence subscription for this account, and/or
2457 * outgoing PUBLISH if presence publication is enabled for this account.
2458 *
2459 * @see pjsua_acc_set_online_status()
2460 *
2461 * @param acc_id The account ID.
2462 * @param is_online True of false.
2463 * @param pr Extended information in subset of RPID format
2464 * which allows setting custom presence text.
2465 *
2466 * @return PJ_SUCCESS on success, or the appropriate error code.
2467 */
2468PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2469 pj_bool_t is_online,
2470 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002471
2472/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002473 * Update registration or perform unregistration. If registration is
2474 * configured for this account, then initial SIP REGISTER will be sent
2475 * when the account is added with #pjsua_acc_add(). Application normally
2476 * only need to call this function if it wants to manually update the
2477 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002478 *
2479 * @param acc_id The account ID.
2480 * @param renew If renew argument is zero, this will start
2481 * unregistration process.
2482 *
2483 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002484 *
2485 * \par Python:
2486 * \code
2487 status = py_pjsua.acc_set_registration(acc_id, renew)
2488 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002489 */
2490PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2491 pj_bool_t renew);
2492
Benny Prijono312aff92006-06-17 04:08:30 +00002493/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002494 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002495 *
2496 * @param acc_id Account identification.
2497 * @param info Pointer to receive account information.
2498 *
2499 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002500 *
2501 * \par Python:
2502 * \code
2503 acc_info = py_pjsua.acc_get_info(acc_id)
2504 * \endcode
2505 * The function returns None if account ID is not valid.
Benny Prijono312aff92006-06-17 04:08:30 +00002506 */
2507PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2508 pjsua_acc_info *info);
2509
2510
2511/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002512 * Enumerate all account currently active in the library. This will fill
2513 * the array with the account Ids, and application can then query the
2514 * account information for each id with #pjsua_acc_get_info().
2515 *
2516 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002517 *
2518 * @param ids Array of account IDs to be initialized.
2519 * @param count In input, specifies the maximum number of elements.
2520 * On return, it contains the actual number of elements.
2521 *
2522 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002523 *
2524 * \par Python:
2525 * The function takes no argument and returns list of account Ids:
2526 * \code
2527 [acc_ids] = py_pjsua.enum_accs()
2528 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002529 */
2530PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2531 unsigned *count );
2532
2533
2534/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002535 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002536 *
2537 * @param info Array of account infos to be initialized.
2538 * @param count In input, specifies the maximum number of elements.
2539 * On return, it contains the actual number of elements.
2540 *
2541 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002542 *
2543 * \par Python:
2544 * The function takes no argument and returns list of account infos:
2545 * \code
2546 [acc_info] = py_pjsua.acc_enum_info()
2547 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002548 */
2549PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2550 unsigned *count );
2551
2552
2553/**
2554 * This is an internal function to find the most appropriate account to
2555 * used to reach to the specified URL.
2556 *
2557 * @param url The remote URL to reach.
2558 *
2559 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002560 *
2561 * \par Python:
2562 * \code
2563 acc_id = py_pjsua.acc_find_for_outgoing(url)
2564 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002565 */
2566PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2567
2568
2569/**
2570 * This is an internal function to find the most appropriate account to be
2571 * used to handle incoming calls.
2572 *
2573 * @param rdata The incoming request message.
2574 *
2575 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002576 *
2577 * \par Python:
2578 * \code
2579 acc_id = py_pjsua.acc_find_for_outgoing(url)
2580 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002581 */
2582PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2583
2584
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002585/**
Benny Prijonofff245c2007-04-02 11:44:47 +00002586 * Create arbitrary requests using the account. Application should only use
2587 * this function to create auxiliary requests outside dialog, such as
2588 * OPTIONS, and use the call or presence API to create dialog related
2589 * requests.
2590 *
2591 * @param acc_id The account ID.
2592 * @param method The SIP method of the request.
2593 * @param target Target URI.
2594 * @param p_tdata Pointer to receive the request.
2595 *
2596 * @return PJ_SUCCESS or the error code.
2597 */
2598PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
2599 const pjsip_method *method,
2600 const pj_str_t *target,
2601 pjsip_tx_data **p_tdata);
2602
2603
2604/**
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002605 * Create a suitable URI to be put as Contact based on the specified
2606 * target URI for the specified account.
2607 *
2608 * @param pool Pool to allocate memory for the string.
2609 * @param contact The string where the Contact URI will be stored.
2610 * @param acc_id Account ID.
2611 * @param uri Destination URI of the request.
2612 *
2613 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002614 *
2615 * \par Python:
2616 * This function is still experimental in Python:
2617 * \code
2618 uri = py_pjsua.acc_create_uac_contact(pool, acc_id, uri)
2619 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002620 */
2621PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
2622 pj_str_t *contact,
2623 pjsua_acc_id acc_id,
2624 const pj_str_t *uri);
2625
2626
2627
2628/**
2629 * Create a suitable URI to be put as Contact based on the information
2630 * in the incoming request.
2631 *
2632 * @param pool Pool to allocate memory for the string.
2633 * @param contact The string where the Contact URI will be stored.
2634 * @param acc_id Account ID.
2635 * @param rdata Incoming request.
2636 *
2637 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002638 *
2639 * \par Python:
2640 * This function is still experimental in Python:
2641 * \code
2642 uri = py_pjsua.acc_create_uas_contact(pool, acc_id, rdata)
2643 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002644 */
2645PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
2646 pj_str_t *contact,
2647 pjsua_acc_id acc_id,
2648 pjsip_rx_data *rdata );
2649
2650
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002651/**
2652 * Lock/bind this account to a specific transport/listener. Normally
2653 * application shouldn't need to do this, as transports will be selected
2654 * automatically by the stack according to the destination.
2655 *
2656 * When account is locked/bound to a specific transport, all outgoing
2657 * requests from this account will use the specified transport (this
2658 * includes SIP registration, dialog (call and event subscription), and
2659 * out-of-dialog requests such as MESSAGE).
2660 *
2661 * Note that transport_id may be specified in pjsua_acc_config too.
2662 *
2663 * @param acc_id The account ID.
2664 * @param tp_id The transport ID.
2665 *
2666 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002667 *
2668 * \par Python:
2669 * Not yet implemented.
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002670 */
2671PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
2672 pjsua_transport_id tp_id);
2673
Benny Prijono312aff92006-06-17 04:08:30 +00002674
2675/**
2676 * @}
2677 */
2678
2679
2680/*****************************************************************************
2681 * CALLS API
2682 */
2683
2684
2685/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002686 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00002687 * @ingroup PJSUA_LIB
2688 * @brief Call manipulation.
2689 * @{
2690 */
2691
2692/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002693 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00002694 */
2695#ifndef PJSUA_MAX_CALLS
2696# define PJSUA_MAX_CALLS 32
2697#endif
2698
2699
2700
2701/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002702 * This enumeration specifies the media status of a call, and it's part
2703 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00002704 */
2705typedef enum pjsua_call_media_status
2706{
Benny Prijonob5388cf2007-01-04 22:45:08 +00002707 /** Call currently has no media */
Benny Prijono312aff92006-06-17 04:08:30 +00002708 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002709
2710 /** The media is active */
Benny Prijono312aff92006-06-17 04:08:30 +00002711 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002712
2713 /** The media is currently put on hold by local endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002714 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002715
2716 /** The media is currently put on hold by remote endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002717 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002718
Benny Prijono096c56c2007-09-15 08:30:16 +00002719 /** The media has reported error (e.g. ICE negotiation) */
2720 PJSUA_CALL_MEDIA_ERROR
2721
Benny Prijono312aff92006-06-17 04:08:30 +00002722} pjsua_call_media_status;
2723
2724
2725/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002726 * This structure describes the information and current status of a call.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002727 *
2728 * \par Python:
2729 * The type name is <tt>py_pjsua.Call_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002730 */
2731typedef struct pjsua_call_info
2732{
2733 /** Call identification. */
2734 pjsua_call_id id;
2735
2736 /** Initial call role (UAC == caller) */
2737 pjsip_role_e role;
2738
Benny Prijono90315512006-09-14 16:05:16 +00002739 /** The account ID where this call belongs. */
2740 pjsua_acc_id acc_id;
2741
Benny Prijono312aff92006-06-17 04:08:30 +00002742 /** Local URI */
2743 pj_str_t local_info;
2744
2745 /** Local Contact */
2746 pj_str_t local_contact;
2747
2748 /** Remote URI */
2749 pj_str_t remote_info;
2750
2751 /** Remote contact */
2752 pj_str_t remote_contact;
2753
2754 /** Dialog Call-ID string. */
2755 pj_str_t call_id;
2756
2757 /** Call state */
2758 pjsip_inv_state state;
2759
2760 /** Text describing the state */
2761 pj_str_t state_text;
2762
2763 /** Last status code heard, which can be used as cause code */
2764 pjsip_status_code last_status;
2765
2766 /** The reason phrase describing the status. */
2767 pj_str_t last_status_text;
2768
2769 /** Call media status. */
2770 pjsua_call_media_status media_status;
2771
2772 /** Media direction */
2773 pjmedia_dir media_dir;
2774
2775 /** The conference port number for the call */
2776 pjsua_conf_port_id conf_slot;
2777
2778 /** Up-to-date call connected duration (zero when call is not
2779 * established)
2780 */
2781 pj_time_val connect_duration;
2782
2783 /** Total call duration, including set-up time */
2784 pj_time_val total_duration;
2785
2786 /** Internal */
2787 struct {
2788 char local_info[128];
2789 char local_contact[128];
2790 char remote_info[128];
2791 char remote_contact[128];
2792 char call_id[128];
2793 char last_status_text[128];
2794 } buf_;
2795
2796} pjsua_call_info;
2797
2798
2799
Benny Prijonoa91a0032006-02-26 21:23:45 +00002800/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002801 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002802 *
2803 * @return Maximum number of calls configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002804 *
2805 * \par Python:
2806 * \code
2807 count = py_pjsua.call_get_max_count()
2808 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002809 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002810PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002811
2812/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002813 * Get number of currently active calls.
2814 *
2815 * @return Number of currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002816 *
2817 * \par Python:
2818 * \code
2819 count = py_pjsua.call_get_count()
2820 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002821 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002822PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002823
2824/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002825 * Enumerate all active calls. Application may then query the information and
2826 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002827 *
2828 * @param ids Array of account IDs to be initialized.
2829 * @param count In input, specifies the maximum number of elements.
2830 * On return, it contains the actual number of elements.
2831 *
2832 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002833 *
2834 * \par Python:
2835 * This function takes no argument and return list of call Ids.
2836 * \code
2837 [call_ids] = py_pjsua.enum_calls()
2838 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002839 */
2840PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
2841 unsigned *count);
2842
2843
2844/**
2845 * Make outgoing call to the specified URI using the specified account.
2846 *
2847 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002848 * @param dst_uri URI to be put in the To header (normally is the same
2849 * as the target URI).
2850 * @param options Options (must be zero at the moment).
2851 * @param user_data Arbitrary user data to be attached to the call, and
2852 * can be retrieved later.
2853 * @param msg_data Optional headers etc to be added to outgoing INVITE
2854 * request, or NULL if no custom header is desired.
2855 * @param p_call_id Pointer to receive call identification.
2856 *
2857 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002858 *
2859 * \par Python:
2860 * The Python function returns (status, call_id) tuple:
2861 * \code
2862 status, call_id = py_pjsua.call_make_call(acc_id, dst_uri, options,
2863 user_data, msg_data)
2864 * \endcode
2865 * Note: the \a user_data in Python function is an integer, and the
2866 * \a msg_data can be set to None if not required.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002867 */
2868PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
2869 const pj_str_t *dst_uri,
2870 unsigned options,
2871 void *user_data,
2872 const pjsua_msg_data *msg_data,
2873 pjsua_call_id *p_call_id);
2874
2875
2876/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002877 * Check if the specified call has active INVITE session and the INVITE
2878 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002879 *
2880 * @param call_id Call identification.
2881 *
2882 * @return Non-zero if call is active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002883 *
2884 * \par Python:
2885 * \code
2886 bool = py_pjsua.call_is_active(call_id)
2887 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002888 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002889PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002890
2891
2892/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002893 * Check if call has an active media session.
2894 *
2895 * @param call_id Call identification.
2896 *
2897 * @return Non-zero if yes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002898 *
2899 * \par Python:
2900 * \code
2901 bool = py_pjsua.call_has_media(call_id)
2902 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002903 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002904PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002905
2906
2907/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002908 * Get the conference port identification associated with the call.
2909 *
2910 * @param call_id Call identification.
2911 *
2912 * @return Conference port ID, or PJSUA_INVALID_ID when the
2913 * media has not been established or is not active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002914 *
2915 * \par Python:
2916 * \code
2917 slot = py_pjsua.call_get_conf_port(call_id)
2918 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002919 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002920PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
2921
2922/**
2923 * Obtain detail information about the specified call.
2924 *
2925 * @param call_id Call identification.
2926 * @param info Call info to be initialized.
2927 *
2928 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002929 *
2930 * \par Python:
2931 * \code
2932 call_info = py_pjsua.call_get_info(call_id)
2933 * \endcode
2934 * \a call_info return value will be set to None if call_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002935 */
2936PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002937 pjsua_call_info *info);
2938
2939
2940/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002941 * Attach application specific data to the call. Application can then
2942 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002943 *
2944 * @param call_id Call identification.
2945 * @param user_data Arbitrary data to be attached to the call.
2946 *
2947 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002948 *
2949 * \par Python:
2950 * \code
2951 status = py_pjsua.call_set_user_data(call_id, user_data)
2952 * \endcode
2953 * The \a user_data is an integer in the Python function.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002954 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002955PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
2956 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002957
2958
2959/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002960 * Get user data attached to the call, which has been previously set with
2961 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002962 *
2963 * @param call_id Call identification.
2964 *
2965 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002966 *
2967 * \par Python:
2968 * \code
2969 user_data = py_pjsua.call_get_user_data(call_id)
2970 * \endcode
2971 * The \a user_data is an integer.
Benny Prijono268ca612006-02-07 12:34:11 +00002972 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002973PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00002974
2975
2976/**
Benny Prijono91a6a172007-10-31 08:59:29 +00002977 * Get the NAT type of remote's endpoint. This is a proprietary feature
2978 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
2979 * is set in #pjsua_config.
2980 *
2981 * This function can only be called after SDP has been received from remote,
2982 * which means for incoming call, this function can be called as soon as
2983 * call is received as long as incoming call contains SDP, and for outgoing
2984 * call, this function can be called only after SDP is received (normally in
2985 * 200/OK response to INVITE). As a general case, application should call
2986 * this function after or in \a on_call_media_state() callback.
2987 *
2988 * @param call_id Call identification.
2989 * @param p_type Pointer to store the NAT type. Application can then
2990 * retrieve the string description of the NAT type
2991 * by calling pj_stun_get_nat_name().
2992 *
2993 * @return PJ_SUCCESS on success.
2994 *
2995 * @see pjsua_get_nat_type(), nat_type_in_sdp
2996 */
2997PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
2998 pj_stun_nat_type *p_type);
2999
3000/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003001 * Send response to incoming INVITE request. Depending on the status
3002 * code specified as parameter, this function may send provisional
3003 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003004 *
3005 * @param call_id Incoming call identification.
3006 * @param code Status code, (100-699).
3007 * @param reason Optional reason phrase. If NULL, default text
3008 * will be used.
3009 * @param msg_data Optional list of headers etc to be added to outgoing
3010 * response message.
3011 *
3012 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003013 *
3014 * \par Python:
3015 * \code
3016 status = py_pjsua.call_answer(call_id, code, reason, msg_data)
3017 * \endcode
3018 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijonoa91a0032006-02-26 21:23:45 +00003019 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003020PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
3021 unsigned code,
3022 const pj_str_t *reason,
3023 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00003024
3025/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003026 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00003027 * call state. This function is different than answering the call with
3028 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
3029 * will hangup the call regardless of the state and role of the call,
3030 * while #pjsua_call_answer() only works with incoming calls on EARLY
3031 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003032 *
3033 * @param call_id Call identification.
3034 * @param code Optional status code to be sent when we're rejecting
3035 * incoming call. If the value is zero, "603/Decline"
3036 * will be sent.
3037 * @param reason Optional reason phrase to be sent when we're rejecting
3038 * incoming call. If NULL, default text will be used.
3039 * @param msg_data Optional list of headers etc to be added to outgoing
3040 * request/response message.
3041 *
3042 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003043 *
3044 * \par Python:
3045 * \code
3046 status = py_pjsua.call_hangup(call_id, code, reason, msg_data)
3047 * \endcode
3048 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003049 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003050PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
3051 unsigned code,
3052 const pj_str_t *reason,
3053 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003054
3055
3056/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003057 * Put the specified call on hold. This will send re-INVITE with the
3058 * appropriate SDP to inform remote that the call is being put on hold.
3059 * The final status of the request itself will be reported on the
3060 * \a on_call_media_state() callback, which inform the application that
3061 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003062 *
3063 * @param call_id Call identification.
3064 * @param msg_data Optional message components to be sent with
3065 * the request.
3066 *
3067 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003068 *
3069 * \par Python:
3070 * \code
3071 status = py_pjsua.call_set_hold(call_id, msg_data)
3072 * \endcode
3073 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003074 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003075PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
3076 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003077
3078
3079/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003080 * Send re-INVITE to release hold.
3081 * The final status of the request itself will be reported on the
3082 * \a on_call_media_state() callback, which inform the application that
3083 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003084 *
3085 * @param call_id Call identification.
3086 * @param unhold If this argument is non-zero and the call is locally
3087 * held, this will release the local hold.
3088 * @param msg_data Optional message components to be sent with
3089 * the request.
3090 *
3091 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003092 *
3093 * \par Python:
3094 * \code
3095 status = py_pjsua.call_reinvite(call_id, unhold, msg_data)
3096 * \endcode
3097 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003098 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003099PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
3100 pj_bool_t unhold,
3101 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003102
Benny Prijonoc08682e2007-10-04 06:17:58 +00003103/**
3104 * Send UPDATE request.
3105 *
3106 * @param call_id Call identification.
3107 * @param options Must be zero for now.
3108 * @param msg_data Optional message components to be sent with
3109 * the request.
3110 *
3111 * @return PJ_SUCCESS on success, or the appropriate error code.
3112 */
3113PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
3114 unsigned options,
3115 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003116
3117/**
Benny Prijono053f5222006-11-11 16:16:04 +00003118 * Initiate call transfer to the specified address. This function will send
3119 * REFER request to instruct remote call party to initiate a new INVITE
3120 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003121 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00003122 * If application is interested to monitor the successfulness and
3123 * the progress of the transfer request, it can implement
3124 * \a on_call_transfer_status() callback which will report the progress
3125 * of the call transfer request.
3126 *
Benny Prijono053f5222006-11-11 16:16:04 +00003127 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003128 * @param dest Address of new target to be contacted.
3129 * @param msg_data Optional message components to be sent with
3130 * the request.
3131 *
3132 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003133 *
3134 * \par Python:
3135 * \code
3136 status = py_pjsua.call_xfer(call_id, dest, msg_data)
3137 * \endcode
3138 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00003139 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003140PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
3141 const pj_str_t *dest,
3142 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003143
3144/**
Benny Prijono053f5222006-11-11 16:16:04 +00003145 * Flag to indicate that "Require: replaces" should not be put in the
3146 * outgoing INVITE request caused by REFER request created by
3147 * #pjsua_call_xfer_replaces().
3148 */
3149#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
3150
3151/**
3152 * Initiate attended call transfer. This function will send REFER request
3153 * to instruct remote call party to initiate new INVITE session to the URL
3154 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
3155 * the call with us with the new call from the REFER recipient.
3156 *
3157 * @param call_id The call id to be transfered.
3158 * @param dest_call_id The call id to be replaced.
3159 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
3160 * to suppress the inclusion of "Require: replaces" in
3161 * the outgoing INVITE request created by the REFER
3162 * request.
3163 * @param msg_data Optional message components to be sent with
3164 * the request.
3165 *
3166 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003167 *
3168 * \par Python:
3169 * \code
3170 status = py_pjsua.call_xfer_replaces(call_id, dest_call_id, options, msg_data)
3171 * \endcode
3172 * Argument \a msg_data may be set to None if not required.
Benny Prijono053f5222006-11-11 16:16:04 +00003173 */
3174PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
3175 pjsua_call_id dest_call_id,
3176 unsigned options,
3177 const pjsua_msg_data *msg_data);
3178
3179/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003180 * Send DTMF digits to remote using RFC 2833 payload formats.
3181 *
3182 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003183 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003184 *
3185 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003186 *
3187 * \par Python:
3188 * \code
3189 status = py_pjsua.call_dial_dtmf(call_id, digits)
3190 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003191 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003192PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003193 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00003194
Benny Prijono26ff9062006-02-21 23:47:00 +00003195/**
Benny Prijonob0808372006-03-02 21:18:58 +00003196 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003197 *
3198 * @param call_id Call identification.
3199 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3200 * assumed.
3201 * @param content The message content.
3202 * @param msg_data Optional list of headers etc to be included in outgoing
3203 * request. The body descriptor in the msg_data is
3204 * ignored.
3205 * @param user_data Optional user data, which will be given back when
3206 * the IM callback is called.
3207 *
3208 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003209 *
3210 * \par Python:
3211 * \code
3212 status = py_pjsua.call_send_im(call_id, mime_type, content, msg_data, user_data)
3213 * \endcode
3214 * Note that the \a user_data argument is an integer in Python.
Benny Prijonob0808372006-03-02 21:18:58 +00003215 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003216PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
3217 const pj_str_t *mime_type,
3218 const pj_str_t *content,
3219 const pjsua_msg_data *msg_data,
3220 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003221
3222
3223/**
3224 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003225 *
3226 * @param call_id Call identification.
3227 * @param is_typing Non-zero to indicate to remote that local person is
3228 * currently typing an IM.
3229 * @param msg_data Optional list of headers etc to be included in outgoing
3230 * request.
3231 *
3232 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003233 *
3234 * \par Python:
3235 * \code
3236 status = py_pjsua.call_send_typing_ind(call_id, is_typing, msg_data)
3237 * \endcode
3238 * Argument \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003239 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003240PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
3241 pj_bool_t is_typing,
3242 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003243
3244/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00003245 * Send arbitrary request with the call. This is useful for example to send
3246 * INFO request. Note that application should not use this function to send
3247 * requests which would change the invite session's state, such as re-INVITE,
3248 * UPDATE, PRACK, and BYE.
3249 *
3250 * @param call_id Call identification.
3251 * @param method SIP method of the request.
3252 * @param msg_data Optional message body and/or list of headers to be
3253 * included in outgoing request.
3254 *
3255 * @return PJ_SUCCESS on success, or the appropriate error code.
3256 */
3257PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
3258 const pj_str_t *method,
3259 const pjsua_msg_data *msg_data);
3260
3261
3262/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003263 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
3264 * currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003265 *
3266 * \par Python:
3267 * \code
3268 py_pjsua.call_hangup_all()
3269 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003270 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00003271PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00003272
3273
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003274/**
3275 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003276 *
3277 * @param call_id Call identification.
3278 * @param with_media Non-zero to include media information too.
3279 * @param buffer Buffer where the statistics are to be written to.
3280 * @param maxlen Maximum length of buffer.
3281 * @param indent Spaces for left indentation.
3282 *
3283 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003284 *
3285 * \par Python:
3286 * \code
3287 string = py_pjsua.call_dump(call_id, with_media, max_len, indent)
3288 * \endcode
3289 * The \a max_len argument is the desired maximum length to be allocated.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003290 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003291PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
3292 pj_bool_t with_media,
3293 char *buffer,
3294 unsigned maxlen,
3295 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003296
Benny Prijono9fc735d2006-05-28 14:58:12 +00003297/**
Benny Prijono312aff92006-06-17 04:08:30 +00003298 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003299 */
Benny Prijono834aee32006-02-19 01:38:06 +00003300
3301
3302/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00003303 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00003304 */
3305
Benny Prijono312aff92006-06-17 04:08:30 +00003306
3307/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003308 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00003309 * @ingroup PJSUA_LIB
3310 * @brief Buddy management, buddy's presence, and instant messaging.
3311 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00003312 *
3313 * This section describes PJSUA-APIs related to buddies management,
3314 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00003315 */
3316
3317/**
3318 * Max buddies in buddy list.
3319 */
3320#ifndef PJSUA_MAX_BUDDIES
3321# define PJSUA_MAX_BUDDIES 256
3322#endif
3323
3324
3325/**
Benny Prijonoa17496a2007-10-31 10:20:31 +00003326 * This specifies how long the library should retry resending SUBSCRIBE
3327 * if the previous SUBSCRIBE failed.
3328 *
3329 * Default: 300 seconds
3330 */
3331#ifndef PJSUA_PRES_TIMER
3332# define PJSUA_PRES_TIMER 300
3333#endif
3334
3335
3336/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003337 * This structure describes buddy configuration when adding a buddy to
3338 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
3339 * the structure with #pjsua_buddy_config_default() to initialize this
3340 * structure with default configuration.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003341 *
3342 * \par Python:
3343 * In Python this structure is <tt>py_pjsua.Buddy_Config</tt>. However
3344 * it is recommended that application instantiates the buddy config
3345 * by calling:
3346 * \code
3347 buddy_cfg = py_pjsua.buddy_config_default()
3348 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003349 */
3350typedef struct pjsua_buddy_config
3351{
3352 /**
3353 * Buddy URL or name address.
3354 */
3355 pj_str_t uri;
3356
3357 /**
3358 * Specify whether presence subscription should start immediately.
3359 */
3360 pj_bool_t subscribe;
3361
3362} pjsua_buddy_config;
3363
3364
3365/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003366 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003367 */
3368typedef enum pjsua_buddy_status
3369{
3370 /**
3371 * Online status is unknown (possibly because no presence subscription
3372 * has been established).
3373 */
3374 PJSUA_BUDDY_STATUS_UNKNOWN,
3375
3376 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003377 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003378 */
3379 PJSUA_BUDDY_STATUS_ONLINE,
3380
3381 /**
3382 * Buddy is offline.
3383 */
3384 PJSUA_BUDDY_STATUS_OFFLINE,
3385
3386} pjsua_buddy_status;
3387
3388
3389
3390/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003391 * This structure describes buddy info, which can be retrieved by calling
3392 * #pjsua_buddy_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003393 *
3394 * \par Python:
3395 * This structure in Python is <tt>py_pjsua.Buddy_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003396 */
3397typedef struct pjsua_buddy_info
3398{
3399 /**
3400 * The buddy ID.
3401 */
3402 pjsua_buddy_id id;
3403
3404 /**
3405 * The full URI of the buddy, as specified in the configuration.
3406 */
3407 pj_str_t uri;
3408
3409 /**
3410 * Buddy's Contact, only available when presence subscription has
3411 * been established to the buddy.
3412 */
3413 pj_str_t contact;
3414
3415 /**
3416 * Buddy's online status.
3417 */
3418 pjsua_buddy_status status;
3419
3420 /**
3421 * Text to describe buddy's online status.
3422 */
3423 pj_str_t status_text;
3424
3425 /**
3426 * Flag to indicate that we should monitor the presence information for
3427 * this buddy (normally yes, unless explicitly disabled).
3428 */
3429 pj_bool_t monitor_pres;
3430
3431 /**
Benny Prijono63fba012008-07-17 14:19:10 +00003432 * If \a monitor_pres is enabled, this specifies the last state of the
3433 * presence subscription. If presence subscription session is currently
3434 * active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence
3435 * subscription request has been rejected, the value will be
3436 * PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be
3437 * specified in \a sub_term_reason.
3438 */
3439 pjsip_evsub_state sub_state;
3440
3441 /**
3442 * Specifies the last presence subscription terminatino reason. If
3443 * presence subscription is currently active, the value will be empty.
3444 */
3445 pj_str_t sub_term_reason;
3446
3447 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003448 * Extended RPID information about the person.
3449 */
3450 pjrpid_element rpid;
3451
3452 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003453 * Internal buffer.
3454 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003455 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003456
3457} pjsua_buddy_info;
3458
3459
Benny Prijono834aee32006-02-19 01:38:06 +00003460/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003461 * Set default values to the buddy config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003462 *
3463 * \par Python:
3464 * \code
3465 buddy_cfg = py_pjsua.buddy_config_default()
3466 * \endcode
Benny Prijonob5388cf2007-01-04 22:45:08 +00003467 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003468PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003469
3470
3471/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003472 * Get total number of buddies.
3473 *
3474 * @return Number of buddies.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003475 *
3476 * \par Python:
3477 * \code
3478 buddy_count = py_pjsua.get_buddy_count()
3479 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003480 */
3481PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3482
3483
3484/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003485 * Check if buddy ID is valid.
3486 *
3487 * @param buddy_id Buddy ID to check.
3488 *
3489 * @return Non-zero if buddy ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003490 *
3491 * \par Python:
3492 * \code
3493 is_valid = py_pjsua.buddy_is_valid(buddy_id)
3494 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003495 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003496PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3497
3498
3499/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003500 * Enumerate all buddy IDs in the buddy list. Application then can use
3501 * #pjsua_buddy_get_info() to get the detail information for each buddy
3502 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003503 *
3504 * @param ids Array of ids to be initialized.
3505 * @param count On input, specifies max elements in the array.
3506 * On return, it contains actual number of elements
3507 * that have been initialized.
3508 *
3509 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003510 *
3511 * \par Python:
3512 * The Python function takes no argument and returns list of buddy IDs:
3513 * \code
3514 [buddy_ids] = py_pjsua.enum_buddies()
3515 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003516 */
3517PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3518 unsigned *count);
3519
3520/**
3521 * Get detailed buddy info.
3522 *
3523 * @param buddy_id The buddy identification.
3524 * @param info Pointer to receive information about buddy.
3525 *
3526 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003527 *
3528 * \par Python:
3529 * \code
3530 buddy_info = py_pjsua.buddy_get_info(buddy_id)
3531 * \endcode
3532 * The function returns None if buddy_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003533 */
3534PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003535 pjsua_buddy_info *info);
3536
3537/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003538 * Add new buddy to the buddy list. If presence subscription is enabled
3539 * for this buddy, this function will also start the presence subscription
3540 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003541 *
Benny Prijonoa7b376b2008-01-25 16:06:33 +00003542 * @param buddy_cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003543 * @param p_buddy_id Pointer to receive buddy ID.
3544 *
3545 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003546 *
3547 * \par Python:
3548 * The function returns (status, buddy_id) tuple:
3549 * \code
3550 status, buddy_id = py_pjsua.buddy_add(buddy_cfg)
3551 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003552 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003553PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003554 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003555
3556
3557/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003558 * Delete the specified buddy from the buddy list. Any presence subscription
3559 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003560 *
3561 * @param buddy_id Buddy identification.
3562 *
3563 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003564 *
3565 * \par Python:
3566 * \code
3567 status = py_pjsua.buddy_del(buddy_id)
3568 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +00003569 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003570PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003571
3572
3573/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003574 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3575 * subscribed, application will be informed about buddy's presence status
3576 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003577 *
3578 * @param buddy_id Buddy identification.
3579 * @param subscribe Specify non-zero to activate presence subscription to
3580 * the specified buddy.
3581 *
3582 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003583 *
3584 * \par Python:
3585 * \code
3586 status = py_pjsua.buddy_subscribe_pres(buddy_id, subscribe)
3587 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003588 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003589PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3590 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003591
3592
3593/**
Benny Prijono10861432007-10-31 10:54:53 +00003594 * Update the presence information for the buddy. Although the library
3595 * periodically refreshes the presence subscription for all buddies, some
3596 * application may want to refresh the buddy's presence subscription
3597 * immediately, and in this case it can use this function to accomplish
3598 * this.
3599 *
3600 * Note that the buddy's presence subscription will only be initiated
3601 * if presence monitoring is enabled for the buddy. See
3602 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
3603 * for the buddy is already active, this function will not do anything.
3604 *
3605 * Once the presence subscription is activated successfully for the buddy,
3606 * application will be notified about the buddy's presence status in the
3607 * on_buddy_state() callback.
3608 *
3609 * @param buddy_id Buddy identification.
3610 *
3611 * @return PJ_SUCCESS on success, or the appropriate error code.
3612 */
3613PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
3614
3615
3616/**
Benny Prijono63fba012008-07-17 14:19:10 +00003617 * Send NOTIFY to inform account presence status or to terminate server
3618 * side presence subscription. If application wants to reject the incoming
3619 * request, it should set the \a state to PJSIP_EVSUB_STATE_TERMINATED.
3620 *
3621 * @param acc_id Account ID.
3622 * @param srv_pres Server presence subscription instance.
3623 * @param state New state to set.
3624 * @param state_str Optionally specify the state string name, if state
3625 * is not "active", "pending", or "terminated".
3626 * @param reason If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3627 * optionally specify the termination reason.
3628 * @param with_body If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3629 * this specifies whether the NOTIFY request should
3630 * contain message body containing account's presence
3631 * information.
3632 * @param msg_data Optional list of headers to be sent with the NOTIFY
3633 * request.
3634 *
3635 * @return PJ_SUCCESS on success.
3636 */
3637PJ_DECL(pj_status_t) pjsua_pres_notify(pjsua_acc_id acc_id,
3638 pjsua_srv_pres *srv_pres,
3639 pjsip_evsub_state state,
3640 const pj_str_t *state_str,
3641 const pj_str_t *reason,
3642 pj_bool_t with_body,
3643 const pjsua_msg_data *msg_data);
3644
3645/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003646 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003647 *
3648 * @param verbose Yes or no.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003649 *
3650 * \par Python:
3651 * \code
3652 py_pjsua.pres_dump()
3653 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003654 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003655PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003656
3657
Benny Prijonob0808372006-03-02 21:18:58 +00003658/**
3659 * The MESSAGE method (defined in pjsua_im.c)
3660 */
3661extern const pjsip_method pjsip_message_method;
3662
3663
Benny Prijonob0808372006-03-02 21:18:58 +00003664
3665/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003666 * Send instant messaging outside dialog, using the specified account for
3667 * route set and authentication.
3668 *
3669 * @param acc_id Account ID to be used to send the request.
3670 * @param to Remote URI.
3671 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3672 * assumed.
3673 * @param content The message content.
3674 * @param msg_data Optional list of headers etc to be included in outgoing
3675 * request. The body descriptor in the msg_data is
3676 * ignored.
3677 * @param user_data Optional user data, which will be given back when
3678 * the IM callback is called.
3679 *
3680 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003681 *
3682 * \par Python:
3683 * \code
3684 status = py_pjsua.im_send(acc_id, to, mime_type, content, msg_data, user_data)
3685 * \endcode
3686 * Arguments \a mime_type and \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003687 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003688PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3689 const pj_str_t *to,
3690 const pj_str_t *mime_type,
3691 const pj_str_t *content,
3692 const pjsua_msg_data *msg_data,
3693 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003694
3695
3696/**
3697 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003698 *
3699 * @param acc_id Account ID to be used to send the request.
3700 * @param to Remote URI.
3701 * @param is_typing If non-zero, it tells remote person that local person
3702 * is currently composing an IM.
3703 * @param msg_data Optional list of headers etc to be added to outgoing
3704 * request.
3705 *
3706 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003707 *
3708 * \par Python:
3709 * \code
3710 status = py_pjsua.im_typing(acc_id, to, is_typing, msg_data)
3711 * \endcode
3712 * Argument \a msg_data may be set to None if not requried.
Benny Prijonob0808372006-03-02 21:18:58 +00003713 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003714PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3715 const pj_str_t *to,
3716 pj_bool_t is_typing,
3717 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003718
3719
Benny Prijonof3195072006-02-14 21:15:30 +00003720
Benny Prijono312aff92006-06-17 04:08:30 +00003721/**
3722 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003723 */
3724
Benny Prijono312aff92006-06-17 04:08:30 +00003725
3726/*****************************************************************************
3727 * MEDIA API
3728 */
3729
3730
3731/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003732 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003733 * @ingroup PJSUA_LIB
3734 * @brief Media manipulation.
3735 * @{
3736 *
3737 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003738 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3739 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003740 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003741 * the interconnection between these terminations freely.
3742 *
3743 * The conference bridge provides powerful switching and mixing functionality
3744 * for application. With the conference bridge, each conference slot (e.g.
3745 * a call) can transmit to multiple destinations, and one destination can
3746 * receive from multiple sources. If more than one media terminations are
3747 * terminated in the same slot, the conference bridge will mix the signal
3748 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00003749 *
3750 * Application connects one media termination/slot to another by calling
3751 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003752 * media flow from the source termination to the sink termination. To
3753 * establish bidirectional media flow, application wound need to make another
3754 * call to #pjsua_conf_connect(), this time inverting the source and
3755 * destination slots in the parameter.
3756 *
3757 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00003758 * the following steps:
3759 *
3760 \code
3761
3762 pj_status_t stream_to_call( pjsua_call_id call_id )
3763 {
3764 pjsua_player_id player_id;
3765
3766 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
3767 if (status != PJ_SUCCESS)
3768 return status;
3769
3770 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
3771 pjsua_call_get_conf_port() );
3772 }
3773 \endcode
3774 *
3775 *
3776 * Other features of PJSUA media:
3777 * - efficient N to M interconnections between media terminations.
3778 * - media termination can be connected to itself to create loopback
3779 * media.
3780 * - the media termination may have different clock rates, and resampling
3781 * will be done automatically by conference bridge.
3782 * - media terminations may also have different frame time; the
3783 * conference bridge will perform the necessary bufferring to adjust
3784 * the difference between terminations.
3785 * - interconnections are removed automatically when media termination
3786 * is removed from the bridge.
3787 * - sound device may be changed even when there are active media
3788 * interconnections.
3789 * - correctly report call's media quality (in #pjsua_call_dump()) from
3790 * RTCP packet exchange.
3791 */
3792
3793/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003794 * Max ports in the conference bridge. This setting is the default value
3795 * for pjsua_media_config.max_media_ports.
Benny Prijono312aff92006-06-17 04:08:30 +00003796 */
3797#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00003798# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00003799#endif
3800
Benny Prijonob5388cf2007-01-04 22:45:08 +00003801/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003802 * The default clock rate to be used by the conference bridge. This setting
3803 * is the default value for pjsua_media_config.clock_rate.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003804 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003805#ifndef PJSUA_DEFAULT_CLOCK_RATE
3806# define PJSUA_DEFAULT_CLOCK_RATE 16000
3807#endif
3808
Benny Prijonob5388cf2007-01-04 22:45:08 +00003809/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003810 * Default frame length in the conference bridge. This setting
3811 * is the default value for pjsua_media_config.audio_frame_ptime.
3812 */
3813#ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Nanang Izzuddinaf974842008-05-08 09:51:16 +00003814# define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
Benny Prijono37c710b2008-01-10 12:09:26 +00003815#endif
3816
3817
3818/**
3819 * Default codec quality settings. This setting is the default value
3820 * for pjsua_media_config.quality.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003821 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003822#ifndef PJSUA_DEFAULT_CODEC_QUALITY
Nanang Izzuddin9dbad152008-06-10 18:56:10 +00003823# define PJSUA_DEFAULT_CODEC_QUALITY 8
Benny Prijono12a669c2006-11-23 07:32:13 +00003824#endif
3825
Benny Prijonob5388cf2007-01-04 22:45:08 +00003826/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003827 * Default iLBC mode. This setting is the default value for
3828 * pjsua_media_config.ilbc_mode.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003829 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003830#ifndef PJSUA_DEFAULT_ILBC_MODE
Benny Prijono37c710b2008-01-10 12:09:26 +00003831# define PJSUA_DEFAULT_ILBC_MODE 30
Benny Prijono12a669c2006-11-23 07:32:13 +00003832#endif
3833
Benny Prijonob5388cf2007-01-04 22:45:08 +00003834/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003835 * The default echo canceller tail length. This setting
3836 * is the default value for pjsua_media_config.ec_tail_len.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003837 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003838#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijono427439c2007-10-21 09:41:24 +00003839# define PJSUA_DEFAULT_EC_TAIL_LEN 200
Benny Prijono12a669c2006-11-23 07:32:13 +00003840#endif
Benny Prijono312aff92006-06-17 04:08:30 +00003841
3842
3843/**
Benny Prijonocba59d92007-02-16 09:22:56 +00003844 * The maximum file player.
3845 */
3846#ifndef PJSUA_MAX_PLAYERS
3847# define PJSUA_MAX_PLAYERS 32
3848#endif
3849
3850
3851/**
3852 * The maximum file player.
3853 */
3854#ifndef PJSUA_MAX_RECORDERS
3855# define PJSUA_MAX_RECORDERS 32
3856#endif
3857
3858
3859/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003860 * This structure describes media configuration, which will be specified
3861 * when calling #pjsua_init(). Application MUST initialize this structure
3862 * by calling #pjsua_media_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003863 *
3864 * \par Python:
3865 * This data type in Python is <tt>py_pjsua.Media_Config</tt>. To create
3866 * an object of this type, it is recommended to call
3867 * <tt>py_pjsua.media_config_default()</tt> function instead:
3868 * \code
3869 media_cfg = py_pjsua.media_config_default()
3870 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003871 */
3872struct pjsua_media_config
3873{
3874 /**
3875 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003876 * If value is zero, default clock rate will be used
3877 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00003878 */
3879 unsigned clock_rate;
3880
3881 /**
Benny Prijonof3758ee2008-02-26 15:32:16 +00003882 * Clock rate to be applied when opening the sound device.
3883 * If value is zero, conference bridge clock rate will be used.
3884 */
3885 unsigned snd_clock_rate;
3886
3887 /**
Benny Prijono7d60d052008-03-29 12:24:20 +00003888 * Channel count be applied when opening the sound device and
3889 * conference bridge.
3890 */
3891 unsigned channel_count;
3892
3893 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003894 * Specify audio frame ptime. The value here will affect the
3895 * samples per frame of both the sound device and the conference
3896 * bridge. Specifying lower ptime will normally reduce the
3897 * latency.
3898 *
Benny Prijono37c710b2008-01-10 12:09:26 +00003899 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003900 */
3901 unsigned audio_frame_ptime;
3902
3903 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003904 * Specify maximum number of media ports to be created in the
3905 * conference bridge. Since all media terminate in the bridge
3906 * (calls, file player, file recorder, etc), the value must be
3907 * large enough to support all of them. However, the larger
3908 * the value, the more computations are performed.
Benny Prijono37c710b2008-01-10 12:09:26 +00003909 *
3910 * Default value: PJSUA_MAX_CONF_PORTS
Benny Prijono312aff92006-06-17 04:08:30 +00003911 */
3912 unsigned max_media_ports;
3913
3914 /**
3915 * Specify whether the media manager should manage its own
3916 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
3917 * and at least one worker thread will be created too. If no,
3918 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
3919 * and no worker thread is needed.
3920 *
3921 * Normally application would say yes here, unless it wants to
3922 * run everything from a single thread.
3923 */
3924 pj_bool_t has_ioqueue;
3925
3926 /**
3927 * Specify the number of worker threads to handle incoming RTP
3928 * packets. A value of one is recommended for most applications.
3929 */
3930 unsigned thread_cnt;
3931
Benny Prijono0498d902006-06-19 14:49:14 +00003932 /**
3933 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00003934 * 5-10: resampling use large filter,
3935 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00003936 * 1-2: resampling use linear.
3937 * The media quality also sets speex codec quality/complexity to the
3938 * number.
3939 *
Benny Prijono70972992006-08-05 11:13:58 +00003940 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00003941 */
3942 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00003943
3944 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003945 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00003946 *
3947 * Default: 0 (codec specific)
3948 */
3949 unsigned ptime;
3950
3951 /**
3952 * Disable VAD?
3953 *
3954 * Default: 0 (no (meaning VAD is enabled))
3955 */
3956 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00003957
3958 /**
3959 * iLBC mode (20 or 30).
3960 *
Benny Prijono37c710b2008-01-10 12:09:26 +00003961 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00003962 */
3963 unsigned ilbc_mode;
3964
3965 /**
3966 * Percentage of RTP packet to drop in TX direction
3967 * (to simulate packet lost).
3968 *
3969 * Default: 0
3970 */
3971 unsigned tx_drop_pct;
3972
3973 /**
3974 * Percentage of RTP packet to drop in RX direction
3975 * (to simulate packet lost).
3976 *
3977 * Default: 0
3978 */
3979 unsigned rx_drop_pct;
3980
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003981 /**
Benny Prijono5da50432006-08-07 10:24:52 +00003982 * Echo canceller options (see #pjmedia_echo_create())
3983 *
3984 * Default: 0.
3985 */
3986 unsigned ec_options;
3987
3988 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003989 * Echo canceller tail length, in miliseconds.
3990 *
Benny Prijono669643c2006-09-20 20:02:18 +00003991 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003992 */
3993 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003994
3995 /**
3996 * Jitter buffer initial prefetch delay in msec. The value must be
3997 * between jb_min_pre and jb_max_pre below.
3998 *
3999 * Default: -1 (to use default stream settings, currently 150 msec)
4000 */
4001 int jb_init;
4002
4003 /**
4004 * Jitter buffer minimum prefetch delay in msec.
4005 *
4006 * Default: -1 (to use default stream settings, currently 60 msec)
4007 */
4008 int jb_min_pre;
4009
4010 /**
4011 * Jitter buffer maximum prefetch delay in msec.
4012 *
4013 * Default: -1 (to use default stream settings, currently 240 msec)
4014 */
4015 int jb_max_pre;
4016
4017 /**
4018 * Set maximum delay that can be accomodated by the jitter buffer msec.
4019 *
4020 * Default: -1 (to use default stream settings, currently 360 msec)
4021 */
4022 int jb_max;
4023
Benny Prijonoc97608e2007-03-23 16:34:20 +00004024 /**
4025 * Enable ICE
4026 */
4027 pj_bool_t enable_ice;
4028
4029 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00004030 * Disable ICE host candidates.
Benny Prijonoc97608e2007-03-23 16:34:20 +00004031 */
Benny Prijonof76e1392008-06-06 14:51:48 +00004032 pj_bool_t ice_no_host_cands;
4033
4034 /**
4035 * Enable TURN relay candidate in ICE.
4036 */
4037 pj_bool_t enable_turn;
4038
4039 /**
4040 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
4041 * "HOST:PORT" format.
4042 */
4043 pj_str_t turn_server;
4044
4045 /**
4046 * Specify the connection type to be used to the TURN server. Valid
4047 * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP.
4048 *
4049 * Default: PJ_TURN_TP_UDP
4050 */
4051 pj_turn_tp_type turn_conn_type;
4052
4053 /**
4054 * Specify the credential to authenticate with the TURN server.
4055 */
4056 pj_stun_auth_cred turn_auth_cred;
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004057
4058 /**
4059 * Specify idle time of sound device before it is automatically closed,
4060 * in seconds.
4061 *
4062 * Default : -1 (Disable the auto-close feature of sound device)
4063 */
4064 int snd_auto_close_time;
Benny Prijono312aff92006-06-17 04:08:30 +00004065};
4066
4067
4068/**
4069 * Use this function to initialize media config.
4070 *
4071 * @param cfg The media config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004072 *
4073 * \par Python:
4074 * \code
4075 media_cfg = py_pjsua.media_config_default()
4076 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00004077 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00004078PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00004079
4080
4081/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004082 * This structure describes codec information, which can be retrieved by
4083 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00004084 */
4085typedef struct pjsua_codec_info
4086{
4087 /**
4088 * Codec unique identification.
4089 */
4090 pj_str_t codec_id;
4091
4092 /**
4093 * Codec priority (integer 0-255).
4094 */
4095 pj_uint8_t priority;
4096
4097 /**
4098 * Internal buffer.
4099 */
4100 char buf_[32];
4101
4102} pjsua_codec_info;
4103
4104
4105/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004106 * This structure descibes information about a particular media port that
4107 * has been registered into the conference bridge. Application can query
4108 * this info by calling #pjsua_conf_get_port_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00004109 *
4110 * \par Python:
4111 * In Python, this type is <tt>py_pjsua.Conf_Port_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00004112 */
4113typedef struct pjsua_conf_port_info
4114{
4115 /** Conference port number. */
4116 pjsua_conf_port_id slot_id;
4117
4118 /** Port name. */
4119 pj_str_t name;
4120
4121 /** Clock rate. */
4122 unsigned clock_rate;
4123
4124 /** Number of channels. */
4125 unsigned channel_count;
4126
4127 /** Samples per frame */
4128 unsigned samples_per_frame;
4129
4130 /** Bits per sample */
4131 unsigned bits_per_sample;
4132
4133 /** Number of listeners in the array. */
4134 unsigned listener_cnt;
4135
4136 /** Array of listeners (in other words, ports where this port is
4137 * transmitting to.
4138 */
4139 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
4140
4141} pjsua_conf_port_info;
4142
4143
4144/**
4145 * This structure holds information about custom media transport to
4146 * be registered to pjsua.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004147 *
4148 * \par Python:
4149 * Not applicable.
Benny Prijono312aff92006-06-17 04:08:30 +00004150 */
4151typedef struct pjsua_media_transport
4152{
4153 /**
4154 * Media socket information containing the address information
4155 * of the RTP and RTCP socket.
4156 */
4157 pjmedia_sock_info skinfo;
4158
4159 /**
4160 * The media transport instance.
4161 */
4162 pjmedia_transport *transport;
4163
4164} pjsua_media_transport;
4165
4166
4167
4168
Benny Prijono9fc735d2006-05-28 14:58:12 +00004169/**
4170 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004171 *
4172 * @return Maximum number of ports in the conference bridge.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004173 *
4174 * \par Python:
4175 * \code
4176 port_count = py_pjsua.conf_get_max_ports()
4177 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004178 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004179PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004180
4181
4182/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004183 * Get current number of active ports in the bridge.
4184 *
4185 * @return The number.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004186 *
4187 * \par Python:
4188 * \code
4189 count = py_pjsua.conf_get_active_ports()
4190 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004191 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004192PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
4193
4194
4195/**
4196 * Enumerate all conference ports.
4197 *
4198 * @param id Array of conference port ID to be initialized.
4199 * @param count On input, specifies max elements in the array.
4200 * On return, it contains actual number of elements
4201 * that have been initialized.
4202 *
4203 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004204 *
4205 * \par Python:
4206 * The Python functions returns list of conference port Ids:
4207 * \code
4208 [port_ids] = py_pjsua.enum_conf_ports()
4209 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004210 */
4211PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
4212 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004213
4214
4215/**
4216 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004217 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004218 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004219 * @param info Pointer to store the port info.
4220 *
4221 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004222 *
4223 * \par Python:
4224 * \code
4225 port_info = py_pjsua.conf_get_port_info(port_id)
4226 * \endcode
4227 * The function will return None if \a port_id is not valid.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004228 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004229PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00004230 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004231
4232
4233/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00004234 * Add arbitrary media port to PJSUA's conference bridge. Application
4235 * can use this function to add the media port that it creates. For
4236 * media ports that are created by PJSUA-LIB (such as calls, file player,
4237 * or file recorder), PJSUA-LIB will automatically add the port to
4238 * the bridge.
4239 *
4240 * @param pool Pool to use.
4241 * @param port Media port to be added to the bridge.
4242 * @param p_id Optional pointer to receive the conference
4243 * slot id.
4244 *
4245 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004246 *
4247 * \par Python:
4248 * Not applicable (for now)
Benny Prijonoe909eac2006-07-27 22:04:56 +00004249 */
4250PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
4251 pjmedia_port *port,
4252 pjsua_conf_port_id *p_id);
4253
4254
4255/**
4256 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00004257 * call this function if it registered the port manually with previous call
4258 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00004259 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004260 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00004261 *
4262 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004263 *
4264 * \par Python:
4265 * \code
4266 status = py_pjsua.conf_remove_port(port_id)
4267 * \endcode
Benny Prijonoe909eac2006-07-27 22:04:56 +00004268 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004269PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00004270
4271
4272/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004273 * Establish unidirectional media flow from souce to sink. One source
4274 * may transmit to multiple destinations/sink. And if multiple
4275 * sources are transmitting to the same sink, the media will be mixed
4276 * together. Source and sink may refer to the same ID, effectively
4277 * looping the media.
4278 *
4279 * If bidirectional media flow is desired, application needs to call
4280 * this function twice, with the second one having the arguments
4281 * reversed.
4282 *
4283 * @param source Port ID of the source media/transmitter.
4284 * @param sink Port ID of the destination media/received.
4285 *
4286 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004287 *
4288 * \par Python:
4289 * \code
4290 status = py_pjsua.conf_connect(source, sink)
4291 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004292 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004293PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
4294 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004295
4296
4297/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004298 * Disconnect media flow from the source to destination port.
4299 *
4300 * @param source Port ID of the source media/transmitter.
4301 * @param sink Port ID of the destination media/received.
4302 *
4303 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004304 *
4305 * \par Python:
4306 * \code
4307 status = py_pjsua.conf_disconnect(source, sink)
4308 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004309 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004310PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
4311 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004312
4313
Benny Prijono6dd967c2006-12-26 02:27:14 +00004314/**
4315 * Adjust the signal level to be transmitted from the bridge to the
4316 * specified port by making it louder or quieter.
4317 *
4318 * @param slot The conference bridge slot number.
4319 * @param level Signal level adjustment. Value 1.0 means no level
4320 * adjustment, while value 0 means to mute the port.
4321 *
4322 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004323 *
4324 * \par Python:
4325 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004326 */
4327PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
4328 float level);
4329
4330/**
4331 * Adjust the signal level to be received from the specified port (to
4332 * the bridge) by making it louder or quieter.
4333 *
4334 * @param slot The conference bridge slot number.
4335 * @param level Signal level adjustment. Value 1.0 means no level
4336 * adjustment, while value 0 means to mute the port.
4337 *
4338 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004339 *
4340 * \par Python:
4341 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004342 */
4343PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
4344 float level);
4345
4346/**
4347 * Get last signal level transmitted to or received from the specified port.
4348 * The signal level is an integer value in zero to 255, with zero indicates
4349 * no signal, and 255 indicates the loudest signal level.
4350 *
4351 * @param slot The conference bridge slot number.
4352 * @param tx_level Optional argument to receive the level of signal
4353 * transmitted to the specified port (i.e. the direction
4354 * is from the bridge to the port).
4355 * @param rx_level Optional argument to receive the level of signal
4356 * received from the port (i.e. the direction is from the
4357 * port to the bridge).
4358 *
4359 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004360 *
4361 * \par Python:
4362 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00004363 */
4364PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
4365 unsigned *tx_level,
4366 unsigned *rx_level);
4367
Benny Prijono6dd967c2006-12-26 02:27:14 +00004368
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004369/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00004370 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004371 */
4372
Benny Prijono9fc735d2006-05-28 14:58:12 +00004373/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004374 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004375 * the conference bridge.
4376 *
4377 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00004378 * WAV files are supported, and the WAV file MUST be
4379 * formatted as 16bit PCM mono/single channel (any
4380 * clock rate is supported).
Benny Prijono58add7c2008-01-18 13:24:07 +00004381 * @param options Optional option flag. Application may specify
4382 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004383 * @param p_id Pointer to receive player ID.
4384 *
4385 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004386 *
4387 * \par Python:
4388 * The function returns (status, id) tuple:
4389 * \code
4390 status, id = py_pjsua.player_create(filename, options)
4391 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004392 */
4393PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004394 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004395 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004396
4397
4398/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004399 * Create a file playlist media port, and automatically add the port
4400 * to the conference bridge.
4401 *
4402 * @param file_names Array of file names to be added to the play list.
4403 * Note that the files must have the same clock rate,
4404 * number of channels, and number of bits per sample.
4405 * @param file_count Number of files in the array.
4406 * @param label Optional label to be set for the media port.
4407 * @param options Optional option flag. Application may specify
4408 * PJMEDIA_FILE_NO_LOOP to prevent looping.
4409 * @param p_id Optional pointer to receive player ID.
4410 *
4411 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004412 *
4413 * \par Python:
4414 * Not implemented yet.
Benny Prijonoa66c3312007-01-21 23:12:40 +00004415 */
4416PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
4417 unsigned file_count,
4418 const pj_str_t *label,
4419 unsigned options,
4420 pjsua_player_id *p_id);
4421
4422/**
4423 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004424 *
4425 * @param id The file player ID.
4426 *
4427 * @return Conference port ID associated with this player.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004428 *
4429 * \par Python:
4430 * \code
4431 port_id = py_pjsua.player_get_conf_port(id)
4432 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004433 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004434PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004435
4436
4437/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004438 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00004439 *
4440 * @param id The player ID.
4441 * @param p_port The media port associated with the player.
4442 *
4443 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004444 *
4445 * \par Python:
4446 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004447 */
Benny Prijono58add7c2008-01-18 13:24:07 +00004448PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
Benny Prijono469b1522006-12-26 03:05:17 +00004449 pjmedia_port **p_port);
4450
4451/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004452 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004453 *
4454 * @param id The file player ID.
4455 * @param samples The playback position, in samples. Application can
4456 * specify zero to re-start the playback.
4457 *
4458 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004459 *
4460 * \par Python:
4461 * \code
4462 status = py_pjsua.player_set_pos(id, samples)
4463 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004464 */
4465PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
4466 pj_uint32_t samples);
4467
4468
4469/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004470 * Close the file of playlist, remove the player from the bridge, and free
4471 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004472 *
4473 * @param id The file player ID.
4474 *
4475 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004476 *
4477 * \par Python:
4478 * \code
4479 status = py_pjsua.player_destroy(id)
4480 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004481 */
4482PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
4483
4484
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004485/*****************************************************************************
4486 * File recorder.
4487 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00004488
4489/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004490 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004491 * the conference bridge. The recorder currently supports recording WAV file.
4492 * The type of the recorder to use is determined by the extension of the file
4493 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004494 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00004495 * @param filename Output file name. The function will determine the
4496 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004497 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00004498 * @param enc_type Optionally specify the type of encoder to be used to
4499 * compress the media, if the file can support different
4500 * encodings. This value must be zero for now.
4501 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004502 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00004503 * For .WAV recorder, this value must be NULL.
4504 * @param max_size Maximum file size. Specify zero or -1 to remove size
4505 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004506 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004507 * @param p_id Pointer to receive the recorder instance.
4508 *
4509 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004510 *
4511 * \par Python:
4512 * \code
4513 status, id = py_pjsua.recorder_create(filename, enc_type, enc_param, max_size, options)
4514 * \endcode
4515 * The \a enc_param is a string in Python.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004516 */
4517PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004518 unsigned enc_type,
4519 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004520 pj_ssize_t max_size,
4521 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004522 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004523
4524
4525/**
4526 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004527 *
4528 * @param id The recorder ID.
4529 *
4530 * @return Conference port ID associated with this recorder.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004531 *
4532 * \par Python:
4533 * \code
4534 port_id = py_pjsua.recorder_get_conf_port(id)
4535 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004536 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004537PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004538
4539
4540/**
Benny Prijono469b1522006-12-26 03:05:17 +00004541 * Get the media port for the recorder.
4542 *
4543 * @param id The recorder ID.
4544 * @param p_port The media port associated with the recorder.
4545 *
4546 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004547 *
4548 * \par Python:
4549 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004550 */
4551PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4552 pjmedia_port **p_port);
4553
4554
4555/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004556 * Destroy recorder (this will complete recording).
4557 *
4558 * @param id The recorder ID.
4559 *
4560 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004561 *
4562 * \par Python:
4563 * \code
4564 status = py_pjsua.recorder_destroy(id)
4565 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004566 */
4567PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4568
4569
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004570/*****************************************************************************
4571 * Sound devices.
4572 */
4573
Benny Prijono9fc735d2006-05-28 14:58:12 +00004574/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004575 * Enum all sound devices installed in the system.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004576 *
4577 * @param info Array of info to be initialized.
4578 * @param count On input, specifies max elements in the array.
4579 * On return, it contains actual number of elements
4580 * that have been initialized.
4581 *
4582 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004583 *
4584 *
4585 * \par Python:
4586 * The function returns list of sound device info:
4587 * \code
4588 [dev_infos] = py_pjsua.enum_snd_devs()
4589 * \endcode
4590 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00004591 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004592PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4593 unsigned *count);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004594
4595
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004596
4597/**
4598 * Get currently active sound devices. If sound devices has not been created
4599 * (for example when pjsua_start() is not called), it is possible that
4600 * the function returns PJ_SUCCESS with -1 as device IDs.
4601 *
4602 * @param capture_dev On return it will be filled with device ID of the
4603 * capture device.
4604 * @param playback_dev On return it will be filled with device ID of the
4605 * device ID of the playback device.
4606 *
4607 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004608 *
4609 * \par Python:
Benny Prijonoebdf8772007-02-01 19:25:50 +00004610 * The function takes no argument and return an (integer,integer) tuple:
Benny Prijonoe6ead542007-01-31 20:53:31 +00004611 * \code
4612 capture_dev, playback_dev = py_pjsua.get_snd_dev()
4613 * \endcode
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004614 */
4615PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4616 int *playback_dev);
4617
4618
Benny Prijono9fc735d2006-05-28 14:58:12 +00004619/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004620 * Select or change sound device. Application may call this function at
4621 * any time to replace current sound device.
4622 *
4623 * @param capture_dev Device ID of the capture device.
4624 * @param playback_dev Device ID of the playback device.
4625 *
4626 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004627 *
4628 * \par Python:
4629 * \code
4630 status = py_pjsua.set_snd_dev(capture_dev, playback_dev)
4631 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004632 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004633PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4634 int playback_dev);
4635
4636
4637/**
4638 * Set pjsua to use null sound device. The null sound device only provides
4639 * the timing needed by the conference bridge, and will not interract with
4640 * any hardware.
4641 *
4642 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004643 *
4644 * \par Python:
4645 * \code
4646 status = py_pjsua.set_null_snd_dev()
4647 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004648 */
4649PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4650
4651
Benny Prijonoe909eac2006-07-27 22:04:56 +00004652/**
4653 * Disconnect the main conference bridge from any sound devices, and let
4654 * application connect the bridge to it's own sound device/master port.
4655 *
4656 * @return The port interface of the conference bridge,
4657 * so that application can connect this to it's own
4658 * sound device or master port.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004659 *
4660 * \par Python:
4661 * Not applicable (for now).
Benny Prijonoe909eac2006-07-27 22:04:56 +00004662 */
4663PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4664
4665
Benny Prijonof20687a2006-08-04 18:27:19 +00004666/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004667 * Configure the echo canceller tail length of the sound port.
Benny Prijonof20687a2006-08-04 18:27:19 +00004668 *
4669 * @param tail_ms The tail length, in miliseconds. Set to zero to
4670 * disable AEC.
Benny Prijonoa7b376b2008-01-25 16:06:33 +00004671 * @param options Options to be passed to pjmedia_echo_create().
Benny Prijono5da50432006-08-07 10:24:52 +00004672 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004673 *
4674 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004675 *
4676 * \par Python:
4677 * \code
4678 status = py_pjsua.set_ec(tail_ms, options)
4679 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004680 */
Benny Prijono5da50432006-08-07 10:24:52 +00004681PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004682
4683
4684/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004685 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004686 *
4687 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4688 * If AEC is disabled, the value will be zero.
4689 *
4690 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004691 *
4692 * \par Python:
4693 * \code
4694 tail_ms = py_pjsua.get_ec_tail()
4695 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004696 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004697PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004698
4699
4700
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004701/*****************************************************************************
4702 * Codecs.
4703 */
4704
4705/**
4706 * Enum all supported codecs in the system.
4707 *
4708 * @param id Array of ID to be initialized.
4709 * @param count On input, specifies max elements in the array.
4710 * On return, it contains actual number of elements
4711 * that have been initialized.
4712 *
4713 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004714 *
4715 * \par Python:
4716 * This function takes no argument and returns list of codec infos:
4717 * \code
4718 [codec_info] = py_pjsua.enum_codecs()
4719 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004720 */
4721PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4722 unsigned *count );
4723
4724
4725/**
4726 * Change codec priority.
4727 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004728 * @param codec_id Codec ID, which is a string that uniquely identify
4729 * the codec (such as "speex/8000"). Please see pjsua
4730 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004731 * @param priority Codec priority, 0-255, where zero means to disable
4732 * the codec.
4733 *
4734 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004735 *
4736 * \par Python:
4737 * \code
4738 status = py_pjsua.codec_set_priority(codec_id, priority)
4739 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004740 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004741PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004742 pj_uint8_t priority );
4743
4744
4745/**
4746 * Get codec parameters.
4747 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004748 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004749 * @param param Structure to receive codec parameters.
4750 *
4751 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004752 *
4753 * \par Python:
4754 * The Python function is experimental:
4755 * \code
4756 codec_param = py_pjsua.codec_get_param(codec_id)
4757 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004758 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004759PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004760 pjmedia_codec_param *param );
4761
4762
4763/**
4764 * Set codec parameters.
4765 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004766 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004767 * @param param Codec parameter to set.
4768 *
4769 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004770 *
4771 * \par Python:
4772 * The Python function is experimental:
4773 * \code
4774 status = py_pjsua.codec_set_param(codec_id, param)
4775 * \endcode
4776
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004777 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004778PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004779 const pjmedia_codec_param *param);
4780
4781
4782
Benny Prijono9fc735d2006-05-28 14:58:12 +00004783
Benny Prijono312aff92006-06-17 04:08:30 +00004784/**
4785 * Create UDP media transports for all the calls. This function creates
4786 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00004787 *
Benny Prijono312aff92006-06-17 04:08:30 +00004788 * @param cfg Media transport configuration. The "port" field in the
4789 * configuration is used as the start port to bind the
4790 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004791 *
4792 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004793 *
4794 * \par Python:
4795 * Not implemented yet.
Benny Prijonof3195072006-02-14 21:15:30 +00004796 */
Benny Prijono312aff92006-06-17 04:08:30 +00004797PJ_DECL(pj_status_t)
4798pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00004799
Benny Prijonodc39fe82006-05-26 12:17:46 +00004800
4801/**
Benny Prijono312aff92006-06-17 04:08:30 +00004802 * Register custom media transports to be used by calls. There must
4803 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004804 *
Benny Prijono312aff92006-06-17 04:08:30 +00004805 * @param tp The media transport array.
4806 * @param count Number of elements in the array. This number MUST
4807 * match the number of maximum calls configured when
4808 * pjsua is created.
4809 * @param auto_delete Flag to indicate whether the transports should be
4810 * destroyed when pjsua is shutdown.
4811 *
4812 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004813 *
4814 * \par Python:
4815 * Note applicable.
Benny Prijonodc39fe82006-05-26 12:17:46 +00004816 */
Benny Prijono312aff92006-06-17 04:08:30 +00004817PJ_DECL(pj_status_t)
4818pjsua_media_transports_attach( pjsua_media_transport tp[],
4819 unsigned count,
4820 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00004821
4822
Benny Prijono312aff92006-06-17 04:08:30 +00004823/**
4824 * @}
4825 */
4826
Benny Prijonof3195072006-02-14 21:15:30 +00004827
Benny Prijono268ca612006-02-07 12:34:11 +00004828
Benny Prijono312aff92006-06-17 04:08:30 +00004829/**
4830 * @}
4831 */
4832
Benny Prijonoe6ead542007-01-31 20:53:31 +00004833PJ_END_DECL
4834
Benny Prijono312aff92006-06-17 04:08:30 +00004835
Benny Prijono268ca612006-02-07 12:34:11 +00004836#endif /* __PJSUA_H__ */