blob: b6ba7d535e09b5b788f3c52733bca00067d648cf [file] [log] [blame]
Benny Prijono268ca612006-02-07 12:34:11 +00001/* $Id$ */
2/*
Benny Prijonoa771a512007-02-19 01:13:53 +00003 * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org>
Benny Prijono268ca612006-02-07 12:34:11 +00004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJSUA_H__
20#define __PJSUA_H__
21
Benny Prijono312aff92006-06-17 04:08:30 +000022/**
23 * @file pjsua.h
24 * @brief PJSUA API.
25 */
26
27
Benny Prijono268ca612006-02-07 12:34:11 +000028/* Include all PJSIP core headers. */
29#include <pjsip.h>
30
31/* Include all PJMEDIA headers. */
32#include <pjmedia.h>
33
Benny Prijono1f9afba2006-02-10 15:57:32 +000034/* Include all PJMEDIA-CODEC headers. */
35#include <pjmedia-codec.h>
36
Benny Prijono268ca612006-02-07 12:34:11 +000037/* Include all PJSIP-UA headers */
38#include <pjsip_ua.h>
39
Benny Prijono834aee32006-02-19 01:38:06 +000040/* Include all PJSIP-SIMPLE headers */
41#include <pjsip_simple.h>
42
Benny Prijono268ca612006-02-07 12:34:11 +000043/* Include all PJLIB-UTIL headers. */
44#include <pjlib-util.h>
45
46/* Include all PJLIB headers. */
47#include <pjlib.h>
48
49
Benny Prijonoe6ead542007-01-31 20:53:31 +000050PJ_BEGIN_DECL
51
52
Benny Prijono312aff92006-06-17 04:08:30 +000053/**
Benny Prijonoe6ead542007-01-31 20:53:31 +000054 * @defgroup PJSUA_LIB PJSUA API - High Level Softphone API for C/C++ and Python
Benny Prijono312aff92006-06-17 04:08:30 +000055 * @ingroup PJSIP
56 * @brief Very high level API for constructing SIP UA applications.
57 * @{
58 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000059 * @section pjsua_api_intro A SIP User Agent API for C/C++ and Python
60 *
61 * PJSUA API is very high level API, available for C/C++ and Python language,
62 * for constructing SIP multimedia user agent
Benny Prijono312aff92006-06-17 04:08:30 +000063 * applications. It wraps together the signaling and media functionalities
64 * into an easy to use call API, provides account management, buddy
65 * management, presence, instant messaging, along with multimedia
66 * features such as conferencing, file streaming, local playback,
67 * voice recording, and so on.
68 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000069 * @subsection pjsua_for_c_cpp C/C++ Binding
Benny Prijono312aff92006-06-17 04:08:30 +000070 * Application must link with <b>pjsua-lib</b> to use this API. In addition,
71 * this library depends on the following libraries:
72 * - <b>pjsip-ua</b>,
73 * - <b>pjsip-simple</b>,
74 * - <b>pjsip-core</b>,
75 * - <b>pjmedia</b>,
76 * - <b>pjmedia-codec</b>,
77 * - <b>pjlib-util</b>, and
78 * - <b>pjlib</b>,
79 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000080 * so application must also link with these libraries as well. For more
81 * information, please refer to
82 * <A HREF="http://www.pjsip.org/using.htm">Getting Started with PJSIP</A>
83 * page.
Benny Prijono312aff92006-06-17 04:08:30 +000084 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000085 * @subsection pjsua_for_python Python Binding
86 *
87 * The Python binding for PJSUA-API is implemented by <b>py_pjsua</b>
88 * module, in <tt>pjsip-apps/py_pjsua</tt> directory. This module is
89 * built by building <tt>py_pjsua</tt> project in <tt>pjsip_apps</tt>
90 * Visual Studio workspace, or by invoking the usual <tt>setup.py</tt>
91 * Python installer script.
92 *
93 * The Python script then can import the PJSUA-API Python module by
94 * using <b>import py_pjsua</b> construct as usual.
95 *
96 *
97 * @section pjsua_samples
98 *
99 * Few samples are provided both in C and Python.
100 *
101 - @ref page_pjsip_sample_simple_pjsuaua_c\n
102 Very simple SIP User Agent with registration, call, and media, using
103 PJSUA-API, all in under 200 lines of code.
104
105 - @ref page_pjsip_samples_pjsua\n
106 This is the reference implementation for PJSIP and PJMEDIA.
107 PJSUA is a console based application, designed to be simple enough
108 to be readble, but powerful enough to demonstrate all features
109 available in PJSIP and PJMEDIA.\n
110
111 - Python sample\n
112 For a real simple Python sample application, have a look at
113 <A HREF="http://www.pjsip.org/trac/browser/pjproject/trunk/pjsip-apps/src/py_pjsua/pjsua_app.py">
114 <tt>pjsip-apps/src/py_pjsua/pjsua_app.py</tt></A> file.
115
Benny Prijono312aff92006-06-17 04:08:30 +0000116 * @section root_using_pjsua_lib Using PJSUA API
117 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000118 * Please refer to @ref PJSUA_LIB_BASE on how to create and initialize the API.
119 * And then see the Modules on the bottom of this page for more information
120 * about specific subject.
Benny Prijono312aff92006-06-17 04:08:30 +0000121 */
122
Benny Prijonoa91a0032006-02-26 21:23:45 +0000123
Benny Prijonof3195072006-02-14 21:15:30 +0000124
Benny Prijono312aff92006-06-17 04:08:30 +0000125/*****************************************************************************
126 * BASE API
127 */
128
Benny Prijonof04ffdd2006-02-21 00:11:18 +0000129/**
Benny Prijonoe6ead542007-01-31 20:53:31 +0000130 * @defgroup PJSUA_LIB_BASE PJSUA-API Basic API
Benny Prijono312aff92006-06-17 04:08:30 +0000131 * @ingroup PJSUA_LIB
132 * @brief Basic application creation/initialization, logging configuration, etc.
133 * @{
134 *
135 * The base PJSUA API controls PJSUA creation, initialization, and startup, and
136 * also provides various auxiliary functions.
137 *
138 * @section using_pjsua_lib Using PJSUA Library
139 *
140 * @subsection creating_pjsua_lib Creating PJSUA
141 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000142 * Before anything else, application must create PJSUA by calling #pjsua_create()
143 * (or <tt>py_pjsua.create()</tt> from Python).
Benny Prijono312aff92006-06-17 04:08:30 +0000144 * This, among other things, will initialize PJLIB, which is crucial before
Benny Prijonoe6ead542007-01-31 20:53:31 +0000145 * any PJLIB functions can be called, PJLIB-UTIL, and create a SIP endpoint.
146 *
147 * After this function is called, application can create a memory pool (with
148 * #pjsua_pool_create()) and read configurations from command line or file to
149 * build the settings to initialize PJSUA below.
Benny Prijono312aff92006-06-17 04:08:30 +0000150 *
151 * @subsection init_pjsua_lib Initializing PJSUA
152 *
153 * After PJSUA is created, application can initialize PJSUA by calling
Benny Prijonoe6ead542007-01-31 20:53:31 +0000154 * #pjsua_init(). This function takes several optional configuration settings
155 * in the argument, if application wants to set them.
Benny Prijono312aff92006-06-17 04:08:30 +0000156 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000157 * @subsubsection init_pjsua_lib_c_cpp PJSUA-LIB Initialization (in C)
158 * Sample code to initialize PJSUA in C code:
Benny Prijono312aff92006-06-17 04:08:30 +0000159 \code
160
Benny Prijonob5388cf2007-01-04 22:45:08 +0000161 #include <pjsua-lib/pjsua.h>
162
163 #define THIS_FILE __FILE__
164
165 static pj_status_t app_init(void)
166 {
Benny Prijono312aff92006-06-17 04:08:30 +0000167 pjsua_config ua_cfg;
168 pjsua_logging_config log_cfg;
169 pjsua_media_config media_cfg;
Benny Prijonob5388cf2007-01-04 22:45:08 +0000170 pj_status_t status;
171
172 // Must create pjsua before anything else!
173 status = pjsua_create();
174 if (status != PJ_SUCCESS) {
175 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
176 return status;
177 }
Benny Prijono312aff92006-06-17 04:08:30 +0000178
179 // Initialize configs with default settings.
180 pjsua_config_default(&ua_cfg);
181 pjsua_logging_config_default(&log_cfg);
182 pjsua_media_config_default(&media_cfg);
183
184 // At the very least, application would want to override
185 // the call callbacks in pjsua_config:
186 ua_cfg.cb.on_incoming_call = ...
187 ua_cfg.cb.on_call_state = ..
188 ...
189
190 // Customize other settings (or initialize them from application specific
191 // configuration file):
192 ...
193
194 // Initialize pjsua
195 status = pjsua_init(&ua_cfg, &log_cfg, &media_cfg);
196 if (status != PJ_SUCCESS) {
197 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
198 return status;
199 }
Benny Prijonob5388cf2007-01-04 22:45:08 +0000200 .
201 ...
202 }
Benny Prijono312aff92006-06-17 04:08:30 +0000203 \endcode
204 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000205 *
206 * @subsubsection init_pjsua_lib_python PJSUA-LIB Initialization (in Python)
207 * Sample code to initialize PJSUA in Python code:
208
209 \code
210
211import py_pjsua
212
213#
214# Initialize pjsua.
215#
216def app_init():
217 # Create pjsua before anything else
218 status = py_pjsua.create()
219 if status != 0:
220 err_exit("pjsua create() error", status)
221
222 # We use default logging config for this sample
223 log_cfg = py_pjsua.logging_config_default()
224
225 # Create and initialize pjsua config
226 # Note: for this Python module, thread_cnt must be 0 since Python
227 # doesn't like to be called from alien thread (pjsua's thread
228 # in this case)
229 ua_cfg = py_pjsua.config_default()
230 ua_cfg.thread_cnt = 0
231 ua_cfg.user_agent = "PJSUA/Python 0.1"
232
233 # Override callbacks. At the very least application would want to
234 # override the call callbacks in pjsua_config
235 ua_cfg.cb.on_incoming_call = ...
236 ua_cfg.cb.on_call_state = ...
237
238 # Use default media config for this cample
239 med_cfg = py_pjsua.media_config_default()
240
241 #
242 # Initialize pjsua!!
243 #
244 status = py_pjsua.init(ua_cfg, log_cfg, med_cfg)
245 if status != 0:
246 err_exit("pjsua init() error", status)
247
248
249
250# Utility: display PJ error and exit
251#
252def err_exit(title, rc):
253 py_pjsua.perror(THIS_FILE, title, rc)
254 exit(1)
255
256 \endcode
257
258
Benny Prijono312aff92006-06-17 04:08:30 +0000259 * @subsection other_init_pjsua_lib Other Initialization
260 *
261 * After PJSUA is initialized with #pjsua_init(), application will normally
262 * need/want to perform the following tasks:
263 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000264 * - create SIP transport with #pjsua_transport_create(). Application would
265 * to call #pjsua_transport_create() for each transport types that it
266 * wants to support (for example, UDP, TCP, and TLS). Please see
Benny Prijono312aff92006-06-17 04:08:30 +0000267 * @ref PJSUA_LIB_TRANSPORT section for more info.
268 * - create one or more SIP accounts with #pjsua_acc_add() or
Benny Prijonoe6ead542007-01-31 20:53:31 +0000269 * #pjsua_acc_add_local(). The SIP account is used for registering with
270 * the SIP server, if any. Please see @ref PJSUA_LIB_ACC for more info.
Benny Prijono312aff92006-06-17 04:08:30 +0000271 * - add one or more buddies with #pjsua_buddy_add(). Please see
272 * @ref PJSUA_LIB_BUDDY section for more info.
273 * - optionally configure the sound device, codec settings, and other
274 * media settings. Please see @ref PJSUA_LIB_MEDIA for more info.
275 *
276 *
277 * @subsection starting_pjsua_lib Starting PJSUA
278 *
279 * After all initializations have been done, application must call
280 * #pjsua_start() to start PJSUA. This function will check that all settings
Benny Prijonoe6ead542007-01-31 20:53:31 +0000281 * have been properly configured, and apply default settings when they haven't,
282 * or report error status when it is unable to recover from missing settings.
Benny Prijono312aff92006-06-17 04:08:30 +0000283 *
284 * Most settings can be changed during run-time. For example, application
285 * may add, modify, or delete accounts, buddies, or change media settings
286 * during run-time.
Benny Prijonob5388cf2007-01-04 22:45:08 +0000287 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000288 * @subsubsection starting_pjsua_lib_c C Example for Starting PJSUA
Benny Prijonob5388cf2007-01-04 22:45:08 +0000289 * Sample code:
290 \code
291 static pj_status_t app_run(void)
292 {
293 pj_status_t status;
294
295 // Start pjsua
296 status = pjsua_start();
297 if (status != PJ_SUCCESS) {
298 pjsua_destroy();
299 pjsua_perror(THIS_FILE, "Error starting pjsua", status);
300 return status;
301 }
302
303 // Run application loop
304 while (1) {
305 char choice[10];
306
307 printf("Select menu: ");
308 fgets(choice, sizeof(choice), stdin);
309 ...
310 }
311 }
312 \endcode
Benny Prijonoe6ead542007-01-31 20:53:31 +0000313
314 * @subsubsection starting_pjsua_lib_python Python Example for starting PJSUA
315 * For Python, starting PJSUA-LIB takes one more step, that is to initialize
316 * Python worker thread to poll PJSUA-LIB. This step is necessary because
317 * Python doesn't like it when it is called by an "alien" thread (that is,
318 * thread that is not created using Python API).
319 *
320 * Because of this, we cannot use a worker thread in PJSUA-LIB, because then
321 * the Python callback will be called by an "alien" thread and this would
322 * crash Python (or raise assert() probably).
323 *
324 * So because worker thread is disabled, we need to create a worker thread
325 * in Python. Note that this may not be necessary if we're creating a
326 * GUI application, because then we can attach, for example, a GUI timer
327 * object to poll the PJSUA-LIB. But because we're creating a console
328 * application which will block at <tt>sys.stdin.readline()</tt>, we need
329 * to have a worker thread to poll PJSUA-LIB.
330
331 \code
332
333import thread
334
335C_QUIT = 0
336
337
338def app_start():
339 # Done with initialization, start pjsua!!
340 #
341 status = py_pjsua.start()
342 if status != 0:
343 py_pjsua.destroy()
344 err_exit("Error starting pjsua!", status)
345
346 # Start worker thread
347 thr = thread.start_new(worker_thread_main, (0,))
348
349 print "PJSUA Started!!"
350
351#
352# Worker thread function.
353# Python doesn't like it when it's called from an alien thread
354# (pjsua's worker thread, in this case), so for Python we must
355# disable worker thread in pjsua and poll pjsua from Python instead.
356#
357def worker_thread_main(arg):
358 global C_QUIT
359 thread_desc = 0
360 status = py_pjsua.thread_register("python worker", thread_desc)
361 if status != 0:
362 py_pjsua.perror(THIS_FILE, "Error registering thread", status)
363 else:
364 while C_QUIT == 0:
365 py_pjsua.handle_events(50)
366 print "Worker thread quitting.."
367 C_QUIT = 2
368
369
370 \endcode
Benny Prijonof04ffdd2006-02-21 00:11:18 +0000371 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000372
Benny Prijono312aff92006-06-17 04:08:30 +0000373/** Constant to identify invalid ID for all sorts of IDs. */
374#define PJSUA_INVALID_ID (-1)
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000375
376/** Call identification */
377typedef int pjsua_call_id;
378
Benny Prijono312aff92006-06-17 04:08:30 +0000379/** Account identification */
380typedef int pjsua_acc_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000381
382/** Buddy identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000383typedef int pjsua_buddy_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000384
385/** File player identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000386typedef int pjsua_player_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000387
388/** File recorder identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000389typedef int pjsua_recorder_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000390
391/** Conference port identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000392typedef int pjsua_conf_port_id;
393
394
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000395
Benny Prijonoa91a0032006-02-26 21:23:45 +0000396/**
Benny Prijono312aff92006-06-17 04:08:30 +0000397 * Maximum proxies in account.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000398 */
Benny Prijono312aff92006-06-17 04:08:30 +0000399#ifndef PJSUA_ACC_MAX_PROXIES
400# define PJSUA_ACC_MAX_PROXIES 8
401#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000402
403
404
405/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000406 * Logging configuration, which can be (optionally) specified when calling
407 * #pjsua_init(). Application must call #pjsua_logging_config_default() to
408 * initialize this structure with the default values.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000409 *
410 * \par Sample Python Syntax:
411 * \code
412 # Python type: py_pjsua.Logging_Config
413
414 log_cfg = py_pjsua.logging_config_default()
415 log_cfg.level = 4
416 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000417 */
418typedef struct pjsua_logging_config
419{
420 /**
421 * Log incoming and outgoing SIP message? Yes!
422 */
423 pj_bool_t msg_logging;
424
425 /**
426 * Input verbosity level. Value 5 is reasonable.
427 */
428 unsigned level;
429
430 /**
431 * Verbosity level for console. Value 4 is reasonable.
432 */
433 unsigned console_level;
434
435 /**
436 * Log decoration.
437 */
438 unsigned decor;
439
440 /**
441 * Optional log filename.
442 */
443 pj_str_t log_filename;
444
445 /**
446 * Optional callback function to be called to write log to
447 * application specific device. This function will be called for
448 * log messages on input verbosity level.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000449 *
450 * \par Sample Python Syntax:
451 * \code
452 # level: integer
453 # data: string
454 # len: integer
455
456 def cb(level, data, len):
457 print data,
458 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000459 */
460 void (*cb)(int level, const char *data, pj_size_t len);
461
462
463} pjsua_logging_config;
464
465
466/**
467 * Use this function to initialize logging config.
468 *
469 * @param cfg The logging config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000470 *
471 * \par Python Syntax:
472 * The Python function instantiates and initialize the logging config:
473 * \code
474 logging_cfg = py_pjsua.logging_config_default()
475 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000476 */
477PJ_INLINE(void) pjsua_logging_config_default(pjsua_logging_config *cfg)
478{
Benny Prijonoac623b32006-07-03 15:19:31 +0000479 pj_bzero(cfg, sizeof(*cfg));
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000480
481 cfg->msg_logging = PJ_TRUE;
482 cfg->level = 5;
483 cfg->console_level = 4;
484 cfg->decor = PJ_LOG_HAS_SENDER | PJ_LOG_HAS_TIME |
485 PJ_LOG_HAS_MICRO_SEC | PJ_LOG_HAS_NEWLINE;
486}
487
488/**
489 * Use this function to duplicate logging config.
490 *
491 * @param pool Pool to use.
492 * @param dst Destination config.
493 * @param src Source config.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000494 *
495 * \par Python Syntax:
496 * Not available (for now). Ideally we should be able to just assign
497 * one config to another, but this has not been tested.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000498 */
499PJ_INLINE(void) pjsua_logging_config_dup(pj_pool_t *pool,
500 pjsua_logging_config *dst,
501 const pjsua_logging_config *src)
502{
503 pj_memcpy(dst, src, sizeof(*src));
504 pj_strdup_with_null(pool, &dst->log_filename, &src->log_filename);
505}
506
507
Benny Prijonodc39fe82006-05-26 12:17:46 +0000508
509/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000510 * This structure describes application callback to receive various event
511 * notification from PJSUA-API. All of these callbacks are OPTIONAL,
512 * although definitely application would want to implement some of
513 * the important callbacks (such as \a on_incoming_call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000514 *
515 * \par Python Syntax:
516 * This callback structure is embedded on pjsua_config structure.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000517 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000518typedef struct pjsua_callback
Benny Prijonodc39fe82006-05-26 12:17:46 +0000519{
520 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000521 * Notify application when invite state has changed.
522 * Application may then query the call info to get the
Benny Prijonoe6ead542007-01-31 20:53:31 +0000523 * detail call states by calling pjsua_call_get_info() function.
Benny Prijono0875ae82006-12-26 00:11:48 +0000524 *
525 * @param call_id The call index.
526 * @param e Event which causes the call state to change.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000527 *
528 * \par Python Syntax:
529 * \code
530 # call_id: integer
531 # e: an opaque object
532
533 def on_call_state(call_id, e):
534 return
535 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000536 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000537 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000538
539 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000540 * Notify application on incoming call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000541 *
542 * @param acc_id The account which match the incoming call.
543 * @param call_id The call id that has just been created for
544 * the call.
545 * @param rdata The incoming INVITE request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000546 *
547 * \par Python Syntax:
548 * \code
549 # acc_id: integer
550 # call_id: integer
551 # rdata: an opaque object
552
553 def on_incoming_call(acc_id, call_id, rdata):
554 return
555 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +0000556 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000557 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000558 pjsip_rx_data *rdata);
559
560 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000561 * Notify application when media state in the call has changed.
562 * Normal application would need to implement this callback, e.g.
563 * to connect the call's media to sound device.
Benny Prijono0875ae82006-12-26 00:11:48 +0000564 *
565 * @param call_id The call index.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000566 *
567 * \par Python Syntax:
568 * \code
569 # call_id: integer
570
571 def on_call_media_state(call_id):
572 return
573 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000574 */
575 void (*on_call_media_state)(pjsua_call_id call_id);
576
577 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000578 * Notify application upon incoming DTMF digits.
579 *
580 * @param call_id The call index.
581 * @param digit DTMF ASCII digit.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000582 *
583 * \par Python Syntax:
584 * \code
585 # call_id: integer
586 # digit: integer
587
588 def on_dtmf_digit(call_id, digit):
589 return
590 * \endcode
Benny Prijono0875ae82006-12-26 00:11:48 +0000591 */
592 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
593
594 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000595 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000596 * Application can decide to accept/reject transfer request
597 * by setting the code (default is 200). When this callback
598 * is not defined, the default behavior is to accept the
599 * transfer.
Benny Prijono0875ae82006-12-26 00:11:48 +0000600 *
601 * @param call_id The call index.
602 * @param dst The destination where the call will be
603 * transfered to.
604 * @param code Status code to be returned for the call transfer
605 * request. On input, it contains status code 200.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000606 *
607 * \par Python Syntax:
608 * \code
609 # call_id: integer
610 # dst: string
611 # code: integer
612
613 def on_call_transfer_request(call_id, dst, code):
614 return code
615
616 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000617 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000618 void (*on_call_transfer_request)(pjsua_call_id call_id,
619 const pj_str_t *dst,
620 pjsip_status_code *code);
621
622 /**
623 * Notify application of the status of previously sent call
624 * transfer request. Application can monitor the status of the
625 * call transfer request, for example to decide whether to
626 * terminate existing call.
627 *
628 * @param call_id Call ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000629 * @param st_code Status progress of the transfer request.
630 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000631 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000632 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000633 * this callback is the final status.
634 * @param p_cont Initially will be set to non-zero, application
635 * can set this to FALSE if it no longer wants
636 * to receie further notification (for example,
637 * after it hangs up the call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000638 *
639 * \par Python Syntax:
640 * \code
641 # call_id: integer
642 # st_code: integer
643 # st_text: string
644 # final: integer
645 # cont: integer
646
647 # return: cont
648
649 def on_call_transfer_status(call_id, st_code, st_text, final, cont):
650 return cont
651 * \endcode
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000652 */
653 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000654 int st_code,
655 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000656 pj_bool_t final,
657 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000658
659 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000660 * Notify application about incoming INVITE with Replaces header.
661 * Application may reject the request by setting non-2xx code.
662 *
663 * @param call_id The call ID to be replaced.
664 * @param rdata The incoming INVITE request to replace the call.
665 * @param st_code Status code to be set by application. Application
666 * should only return a final status (200-699).
667 * @param st_text Optional status text to be set by application.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000668 *
669 * \par Python Syntax:
670 * \code
671 # call_id: integer
672 # rdata: an opaque object
673 # st_code: integer
674 # st_text: string
675
676 # return: (st_code, st_text) tuple
677
678 def on_call_replace_request(call_id, rdata, st_code, st_text):
679 return st_code, st_text
680 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000681 */
682 void (*on_call_replace_request)(pjsua_call_id call_id,
683 pjsip_rx_data *rdata,
684 int *st_code,
685 pj_str_t *st_text);
686
687 /**
688 * Notify application that an existing call has been replaced with
689 * a new call. This happens when PJSUA-API receives incoming INVITE
690 * request with Replaces header.
691 *
692 * After this callback is called, normally PJSUA-API will disconnect
693 * \a old_call_id and establish \a new_call_id.
694 *
695 * @param old_call_id Existing call which to be replaced with the
696 * new call.
697 * @param new_call_id The new call.
698 * @param rdata The incoming INVITE with Replaces request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000699 *
700 * \par Python Syntax:
701 * \code
702 # old_call_id: integer
703 # new_call_id: integer
704
705 def on_call_replaced(old_call_id, new_call_id):
706 return
707 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000708 */
709 void (*on_call_replaced)(pjsua_call_id old_call_id,
710 pjsua_call_id new_call_id);
711
712
713 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000714 * Notify application when registration status has changed.
715 * Application may then query the account info to get the
716 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000717 *
718 * @param acc_id Account ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000719 *
720 * \par Python Syntax:
721 * \code
722 # acc_id: account ID (integer)
723
724 def on_reg_state(acc_id):
725 return
726 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000727 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000728 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000729
730 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000731 * Notify application when the buddy state has changed.
732 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000733 *
734 * @param buddy_id The buddy id.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000735 *
736 * \par Python Syntax:
737 * \code
738 # buddy_id: integer
739
740 def on_buddy_state(buddy_id):
741 return
742 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000743 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000744 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000745
746 /**
747 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000748 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000749 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000750 *
751 * @param call_id Containts the ID of the call where the IM was
752 * sent, or PJSUA_INVALID_ID if the IM was sent
753 * outside call context.
754 * @param from URI of the sender.
755 * @param to URI of the destination message.
756 * @param contact The Contact URI of the sender, if present.
757 * @param mime_type MIME type of the message.
758 * @param body The message content.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000759 *
760 * \par Python Syntax:
761 * \code
762 # call_id: integer
763 # from: string
764 # to: string
765 # contact: string
766 # mime_type: string
767 # body: string
768
769 def on_pager(call_id, from, to, contact, mime_type, body):
770 return
771 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000772 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000773 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
774 const pj_str_t *to, const pj_str_t *contact,
775 const pj_str_t *mime_type, const pj_str_t *body);
776
777 /**
778 * Notify application about the delivery status of outgoing pager
779 * request.
780 *
781 * @param call_id Containts the ID of the call where the IM was
782 * sent, or PJSUA_INVALID_ID if the IM was sent
783 * outside call context.
784 * @param to Destination URI.
785 * @param body Message body.
786 * @param user_data Arbitrary data that was specified when sending
787 * IM message.
788 * @param status Delivery status.
789 * @param reason Delivery status reason.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000790 *
791 * \par Python Syntax
792 * \code
793 # call_id: integer
794 # to: string
795 # body: string
796 # user_data: string
797 # status: integer
798 # reason: string
799
800 def on_pager_status(call_id, to, body, user_data, status, reason):
801 return
802 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000803 */
804 void (*on_pager_status)(pjsua_call_id call_id,
805 const pj_str_t *to,
806 const pj_str_t *body,
807 void *user_data,
808 pjsip_status_code status,
809 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000810
811 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000812 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +0000813 *
814 * @param call_id Containts the ID of the call where the IM was
815 * sent, or PJSUA_INVALID_ID if the IM was sent
816 * outside call context.
817 * @param from URI of the sender.
818 * @param to URI of the destination message.
819 * @param contact The Contact URI of the sender, if present.
820 * @param is_typing Non-zero if peer is typing, or zero if peer
821 * has stopped typing a message.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000822 *
823 * \par Python Syntax
824 * \code
825 # call_id: string
826 # from: string
827 # to: string
828 # contact: string
829 # is_typing: integer
830
831 def on_typing(call_id, from, to, contact, is_typing):
832 return
833 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000834 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000835 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
836 const pj_str_t *to, const pj_str_t *contact,
837 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000838
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000839} pjsua_callback;
840
841
842
Benny Prijonodc39fe82006-05-26 12:17:46 +0000843
844/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000845 * This structure describes the settings to control the API and
846 * user agent behavior, and can be specified when calling #pjsua_init().
847 * Before setting the values, application must call #pjsua_config_default()
848 * to initialize this structure with the default values.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000849 *
850 * \par Python Sample Syntax:
851 * The pjsua_config type in Python is <tt>py_pjsua.Config</tt>. Application
852 * creates the instance by calling <tt>py_pjsua.config_default()</tt>:
853 * \code
854 cfg = py_pjsua.config_default()
855 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000856 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000857typedef struct pjsua_config
858{
859
860 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000861 * Maximum calls to support (default: 4). The value specified here
862 * must be smaller than the compile time maximum settings
863 * PJSUA_MAX_CALLS, which by default is 32. To increase this
864 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
865 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000866 */
867 unsigned max_calls;
868
869 /**
870 * Number of worker threads. Normally application will want to have at
871 * least one worker thread, unless when it wants to poll the library
872 * periodically, which in this case the worker thread can be set to
873 * zero.
874 */
875 unsigned thread_cnt;
876
877 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +0000878 * Number of nameservers. If no name server is configured, the SIP SRV
879 * resolution would be disabled, and domain will be resolved with
880 * standard pj_gethostbyname() function.
881 */
882 unsigned nameserver_count;
883
884 /**
885 * Array of nameservers to be used by the SIP resolver subsystem.
886 * The order of the name server specifies the priority (first name
887 * server will be used first, unless it is not reachable).
888 */
889 pj_str_t nameserver[4];
890
891 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000892 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000893 */
894 unsigned outbound_proxy_cnt;
895
896 /**
897 * Specify the URL of outbound proxies to visit for all outgoing requests.
898 * The outbound proxies will be used for all accounts, and it will
899 * be used to build the route set for outgoing requests. The final
900 * route set for outgoing requests will consists of the outbound proxies
901 * and the proxy configured in the account.
902 */
903 pj_str_t outbound_proxy[4];
904
Benny Prijonoc97608e2007-03-23 16:34:20 +0000905 /**
Benny Prijonoebbf6892007-03-24 17:37:25 +0000906 * Specify domain name to be resolved with DNS SRV resolution to get the
907 * address of the STUN servers. Alternatively application may specify
908 * \a stun_host and \a stun_relay_host instead.
909 *
910 * If DNS SRV resolution failed for this domain, then DNS A resolution
911 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +0000912 */
Benny Prijonoebbf6892007-03-24 17:37:25 +0000913 pj_str_t stun_domain;
914
915 /**
916 * Specify STUN server to be used.
917 */
918 pj_str_t stun_host;
919
920 /**
921 * Specify STUN relay server to be used.
922 */
923 pj_str_t stun_relay_host;
Benny Prijonoc97608e2007-03-23 16:34:20 +0000924
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000925 /**
926 * Number of credentials in the credential array.
927 */
928 unsigned cred_count;
929
930 /**
931 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +0000932 * and can be used to authenticate against outbound proxies. If the
933 * credential is specific to the account, then application should set
934 * the credential in the pjsua_acc_config rather than the credential
935 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000936 */
937 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
938
939 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000940 * Application callback to receive various event notifications from
941 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000942 */
943 pjsua_callback cb;
944
Benny Prijono56315612006-07-18 14:39:40 +0000945 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000946 * Optional user agent string (default empty). If it's empty, no
947 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +0000948 */
949 pj_str_t user_agent;
950
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000951} pjsua_config;
952
953
954/**
955 * Use this function to initialize pjsua config.
956 *
957 * @param cfg pjsua config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000958 *
959 * \par Python Sample Syntax:
960 * The corresponding Python function creates an instance of the config and
961 * initializes it to the default settings:
962 * \code
963 cfg = py_pjsua.config_default()
964 * \endcode
965
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000966 */
967PJ_INLINE(void) pjsua_config_default(pjsua_config *cfg)
968{
Benny Prijonoac623b32006-07-03 15:19:31 +0000969 pj_bzero(cfg, sizeof(*cfg));
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000970
971 cfg->max_calls = 4;
972 cfg->thread_cnt = 1;
973}
974
975
976/**
977 * Duplicate credential.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000978 *
979 * @param pool The memory pool.
980 * @param dst Destination credential.
981 * @param src Source credential.
982 *
983 * \par Python:
984 * Not applicable (for now). Probably we could just assign one credential
985 * variable to another, but this has not been tested.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000986 */
987PJ_INLINE(void) pjsip_cred_dup( pj_pool_t *pool,
988 pjsip_cred_info *dst,
989 const pjsip_cred_info *src)
990{
991 pj_strdup_with_null(pool, &dst->realm, &src->realm);
992 pj_strdup_with_null(pool, &dst->scheme, &src->scheme);
993 pj_strdup_with_null(pool, &dst->username, &src->username);
994 pj_strdup_with_null(pool, &dst->data, &src->data);
995
996}
997
998
999/**
1000 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001001 *
1002 * @param pool The pool to get memory from.
1003 * @param dst Destination config.
1004 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001005 */
1006PJ_INLINE(void) pjsua_config_dup(pj_pool_t *pool,
1007 pjsua_config *dst,
1008 const pjsua_config *src)
1009{
1010 unsigned i;
1011
1012 pj_memcpy(dst, src, sizeof(*src));
1013
1014 for (i=0; i<src->outbound_proxy_cnt; ++i) {
1015 pj_strdup_with_null(pool, &dst->outbound_proxy[i],
1016 &src->outbound_proxy[i]);
1017 }
1018
1019 for (i=0; i<src->cred_count; ++i) {
1020 pjsip_cred_dup(pool, &dst->cred_info[i], &src->cred_info[i]);
1021 }
Benny Prijono56315612006-07-18 14:39:40 +00001022
1023 pj_strdup_with_null(pool, &dst->user_agent, &src->user_agent);
Benny Prijonoebbf6892007-03-24 17:37:25 +00001024 pj_strdup_with_null(pool, &dst->stun_domain, &src->stun_domain);
1025 pj_strdup_with_null(pool, &dst->stun_host, &src->stun_host);
1026 pj_strdup_with_null(pool, &dst->stun_relay_host, &src->stun_relay_host);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001027}
1028
1029
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001030
1031/**
1032 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001033 * outgoing SIP message. It can (optionally) be specified for example
1034 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1035 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1036 *
1037 * Application MUST call #pjsua_msg_data_init() to initialize this
1038 * structure before setting its values.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001039 *
1040 * \par Python Syntax
1041 * The data type in Python is <tt>py_pjsua.Msg_Data</tt>. Application is
1042 * recommended to instantiate the structure by using this construct:
1043 * \code
1044 msg_data = py_pjsua.msg_data_init()
1045 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001046 */
1047typedef struct pjsua_msg_data
1048{
1049 /**
1050 * Additional message headers as linked list.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001051 *
1052 * \par Python:
1053 * This field is implemented as string linked-list in Python, where each
1054 * string describes the header. For example:
1055 \code
1056 msg_data = py_pjsua.Msg_Data()
1057 msg_data.hdr_list = ["Subject: Hello py_pjsua!", "Priority: very low"]
1058 \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001059 */
1060 pjsip_hdr hdr_list;
1061
1062 /**
1063 * MIME type of optional message body.
1064 */
1065 pj_str_t content_type;
1066
1067 /**
1068 * Optional message body.
1069 */
1070 pj_str_t msg_body;
1071
1072} pjsua_msg_data;
1073
1074
1075/**
1076 * Initialize message data.
1077 *
1078 * @param msg_data Message data to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001079 *
1080 * \par Python
1081 * The corresponding Python function creates and initializes the structure:
1082 * \code
1083 msg_data = py_pjsua.msg_data_init()
1084 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001085 */
1086PJ_INLINE(void) pjsua_msg_data_init(pjsua_msg_data *msg_data)
1087{
Benny Prijonoac623b32006-07-03 15:19:31 +00001088 pj_bzero(msg_data, sizeof(*msg_data));
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001089 pj_list_init(&msg_data->hdr_list);
1090}
Benny Prijono8b1889b2006-06-06 18:40:40 +00001091
Benny Prijono268ca612006-02-07 12:34:11 +00001092
Benny Prijono268ca612006-02-07 12:34:11 +00001093
1094/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001095 * Instantiate pjsua application. Application must call this function before
1096 * calling any other functions, to make sure that the underlying libraries
1097 * are properly initialized. Once this function has returned success,
1098 * application must call pjsua_destroy() before quitting.
1099 *
1100 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001101 *
1102 * \par Python:
1103 * \code
1104 status = py_pjsua.create()
1105 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001106 */
1107PJ_DECL(pj_status_t) pjsua_create(void);
1108
1109
Benny Prijonoe6ead542007-01-31 20:53:31 +00001110/* Forward declaration */
1111typedef struct pjsua_media_config pjsua_media_config;
1112
1113
Benny Prijonodc39fe82006-05-26 12:17:46 +00001114/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001115 * Initialize pjsua with the specified settings. All the settings are
1116 * optional, and the default values will be used when the config is not
1117 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001118 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001119 * Note that #pjsua_create() MUST be called before calling this function.
1120 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001121 * @param ua_cfg User agent configuration.
1122 * @param log_cfg Optional logging configuration.
1123 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001124 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001125 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001126 *
1127 * \par Python:
1128 * The function is similar in Python:
1129 * \code
1130 status = py_pjsua.init(ua_cfg, log_cfg, media_cfg)
1131 * \endcode
1132 * Note that \a ua_cfg, \a log_cfg, and \a media_cfg are optional, and
1133 * the Python script may pass None if it doesn't want to configure the
1134 * setting.
Benny Prijono268ca612006-02-07 12:34:11 +00001135 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001136PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1137 const pjsua_logging_config *log_cfg,
1138 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001139
1140
1141/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001142 * Application is recommended to call this function after all initialization
1143 * is done, so that the library can do additional checking set up
1144 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001145 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001146 * Application may call this function anytime after #pjsua_init().
1147 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001148 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001149 *
1150 * \par Python:
1151 * The function is similar in Python:
1152 * \code
1153 status = py_pjsua.start()
1154 * \endcode
Benny Prijonoccf95622006-02-07 18:48:01 +00001155 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001156PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001157
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001158
Benny Prijonoccf95622006-02-07 18:48:01 +00001159/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001160 * Destroy pjsua. Application is recommended to perform graceful shutdown
1161 * before calling this function (such as unregister the account from the SIP
1162 * server, terminate presense subscription, and hangup active calls), however,
1163 * this function will do all of these if it finds there are active sessions
1164 * that need to be terminated. This function will approximately block for
1165 * one second to wait for replies from remote.
1166 *
1167 * Application.may safely call this function more than once if it doesn't
1168 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001169 *
1170 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001171 *
1172 * \par Python:
1173 * The function is similar in Python:
1174 * \code
1175 status = py_pjsua.destroy()
1176 * \endcode
Benny Prijono268ca612006-02-07 12:34:11 +00001177 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001178PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001179
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001180
Benny Prijono9fc735d2006-05-28 14:58:12 +00001181/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001182 * Poll pjsua for events, and if necessary block the caller thread for
1183 * the specified maximum interval (in miliseconds).
1184 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001185 * Application doesn't normally need to call this function if it has
1186 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1187 * because polling then will be done by these worker threads instead.
1188 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001189 * @param msec_timeout Maximum time to wait, in miliseconds.
1190 *
1191 * @return The number of events that have been handled during the
1192 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001193 * can retrieve the error as (status = -return_value).
1194 *
1195 * \par Python:
1196 * The function is similar in Python:
1197 * \code
1198 n = py_pjsua.handle_events(msec_timeout)
1199 * \endcode
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001200 */
1201PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1202
1203
1204/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001205 * Create memory pool to be used by the application. Once application
1206 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001207 *
1208 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001209 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001210 * @param increment Increment size.
1211 *
1212 * @return The pool, or NULL when there's no memory.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001213 *
1214 * \par Python:
1215 * Python script may also create a pool object from the script:
1216 * \code
1217 pool = py_pjsua.pool_create(name, init_size, increment)
1218 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001219 */
1220PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1221 pj_size_t increment);
1222
1223
1224/**
1225 * Application can call this function at any time (after pjsua_create(), of
1226 * course) to change logging settings.
1227 *
1228 * @param c Logging configuration.
1229 *
1230 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001231 *
1232 * \par Python:
1233 * The function is similar in Python:
1234 * \code
1235 status = py_pjsua.reconfigure_logging(log_cfg)
1236 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001237 */
1238PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1239
1240
1241/**
1242 * Internal function to get SIP endpoint instance of pjsua, which is
1243 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001244 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001245 *
1246 * @return SIP endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001247 *
1248 * \par Python:
1249 * Application may retrieve the SIP endpoint instance:
1250 * \code
1251 endpt = py_pjsua.get_pjsip_endpt()
1252 * \endcode
1253 * However currently the object is just an opaque object and does not have
1254 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001255 */
1256PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1257
1258/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001259 * Internal function to get media endpoint instance.
1260 * Only valid after #pjsua_init() is called.
1261 *
1262 * @return Media endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001263 *
1264 * \par Python:
1265 * Application may retrieve the media endpoint instance:
1266 * \code
1267 endpt = py_pjsua.get_pjmedia_endpt()
1268 * \endcode
1269 * However currently the object is just an opaque object and does not have
1270 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001271 */
1272PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1273
Benny Prijono97b87172006-08-24 14:25:14 +00001274/**
1275 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001276 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001277 *
1278 * @return Pool factory currently used by PJSUA.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001279 *
1280 * \par Python:
1281 * Application may retrieve the pool factory instance:
1282 * \code
1283 endpt = py_pjsua.get_pool_factory()
1284 * \endcode
1285 * However currently the object is just an opaque object and does not have
1286 * any use for Python scripts.
Benny Prijono97b87172006-08-24 14:25:14 +00001287 */
1288PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1289
1290
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001291
1292/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001293 * Utilities.
1294 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001295 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001296
1297/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001298 * This is a utility function to verify that valid SIP url is given. If the
1299 * URL is valid, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001300 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001301 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001302 *
1303 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001304 *
1305 * \par Python:
1306 * \code
1307 status = py_pjsua.verify_sip_url(url)
1308 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001309 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001310PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001311
1312
1313/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001314 * This is a utility function to display error message for the specified
1315 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001316 *
1317 * @param sender The log sender field.
1318 * @param title Message title for the error.
1319 * @param status Status code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001320 *
1321 * \par Python:
1322 * \code
1323 py_pjsua.perror(sender, title, status)
1324 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001325 */
1326PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1327 pj_status_t status);
1328
1329
1330
1331
1332/**
1333 * @}
1334 */
1335
1336
1337
1338/*****************************************************************************
1339 * TRANSPORT API
1340 */
1341
1342/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001343 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001344 * @ingroup PJSUA_LIB
1345 * @brief API for managing SIP transports
1346 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001347 *
1348 * PJSUA-API supports creating multiple transport instances, for example UDP,
1349 * TCP, and TLS transport. SIP transport must be created before adding an
1350 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001351 */
1352
1353
Benny Prijonoe6ead542007-01-31 20:53:31 +00001354/** SIP transport identification.
1355 */
Benny Prijono312aff92006-06-17 04:08:30 +00001356typedef int pjsua_transport_id;
1357
1358
1359/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001360 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001361 * and media. Before setting some values to this structure, application
1362 * MUST call #pjsua_transport_config_default() to initialize its
1363 * values with default settings.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001364 *
1365 * \par Python:
1366 * The data type in Python is <tt>py_pjsua.Transport_Config</tt>,
1367 * although application can just do this to create the instance:
1368 * \code
1369 transport_cfg = py_pjsua.transport_config_default()
1370 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001371 */
1372typedef struct pjsua_transport_config
1373{
1374 /**
1375 * UDP port number to bind locally. This setting MUST be specified
1376 * even when default port is desired. If the value is zero, the
1377 * transport will be bound to any available port, and application
1378 * can query the port by querying the transport info.
1379 */
1380 unsigned port;
1381
1382 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001383 * Optional address to advertise as the address of this transport.
1384 * Application can specify any address or hostname for this field,
1385 * for example it can point to one of the interface address in the
1386 * system, or it can point to the public address of a NAT router
1387 * where port mappings have been configured for the application.
1388 *
1389 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001390 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001391 pj_str_t public_addr;
1392
1393 /**
1394 * Optional address where the socket should be bound to. This option
1395 * SHOULD only be used to selectively bind the socket to particular
1396 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1397 * published address of a transport (the public_addr field should be
1398 * used for that purpose).
1399 *
1400 * Note that unlike public_addr field, the address (or hostname) here
1401 * MUST correspond to the actual interface address in the host, since
1402 * this address will be specified as bind() argument.
1403 */
1404 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001405
1406 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001407 * This specifies TLS settings for TLS transport. It is only be used
1408 * when this transport config is being used to create a SIP TLS
1409 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001410 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001411 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001412
Benny Prijono312aff92006-06-17 04:08:30 +00001413} pjsua_transport_config;
1414
1415
1416/**
1417 * Call this function to initialize UDP config with default values.
1418 *
1419 * @param cfg The UDP config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001420 *
1421 * \par Python:
1422 * The corresponding Python function is rather different:
1423 * \code
1424 transport_cfg = py_pjsua.transport_config_default()
1425 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001426 */
1427PJ_INLINE(void) pjsua_transport_config_default(pjsua_transport_config *cfg)
1428{
Benny Prijonoac623b32006-07-03 15:19:31 +00001429 pj_bzero(cfg, sizeof(*cfg));
Benny Prijonof3bbc132006-12-25 06:43:59 +00001430 pjsip_tls_setting_default(&cfg->tls_setting);
Benny Prijono312aff92006-06-17 04:08:30 +00001431}
1432
1433
1434/**
Benny Prijono312aff92006-06-17 04:08:30 +00001435 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001436 *
1437 * @param pool The pool.
1438 * @param dst The destination config.
1439 * @param src The source config.
1440 *
1441 * \par Python:
1442 * Not applicable. One should be able to just copy one variable instance
1443 * to another in Python.
Benny Prijono312aff92006-06-17 04:08:30 +00001444 */
1445PJ_INLINE(void) pjsua_transport_config_dup(pj_pool_t *pool,
1446 pjsua_transport_config *dst,
1447 const pjsua_transport_config *src)
1448{
Benny Prijonoc97608e2007-03-23 16:34:20 +00001449 PJ_UNUSED_ARG(pool);
Benny Prijono312aff92006-06-17 04:08:30 +00001450 pj_memcpy(dst, src, sizeof(*src));
Benny Prijono312aff92006-06-17 04:08:30 +00001451}
1452
1453
1454
1455/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001456 * This structure describes transport information returned by
1457 * #pjsua_transport_get_info() function.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001458 *
1459 * \par Python:
1460 * The corresponding data type in Python is <tt>py_pjsua.Transport_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001461 */
1462typedef struct pjsua_transport_info
1463{
1464 /**
1465 * PJSUA transport identification.
1466 */
1467 pjsua_transport_id id;
1468
1469 /**
1470 * Transport type.
1471 */
1472 pjsip_transport_type_e type;
1473
1474 /**
1475 * Transport type name.
1476 */
1477 pj_str_t type_name;
1478
1479 /**
1480 * Transport string info/description.
1481 */
1482 pj_str_t info;
1483
1484 /**
1485 * Transport flag (see ##pjsip_transport_flags_e).
1486 */
1487 unsigned flag;
1488
1489 /**
1490 * Local address length.
1491 */
1492 unsigned addr_len;
1493
1494 /**
1495 * Local/bound address.
1496 */
1497 pj_sockaddr local_addr;
1498
1499 /**
1500 * Published address (or transport address name).
1501 */
1502 pjsip_host_port local_name;
1503
1504 /**
1505 * Current number of objects currently referencing this transport.
1506 */
1507 unsigned usage_count;
1508
1509
1510} pjsua_transport_info;
1511
1512
1513/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001514 * Create and start a new SIP transport according to the specified
1515 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001516 *
1517 * @param type Transport type.
1518 * @param cfg Transport configuration.
1519 * @param p_id Optional pointer to receive transport ID.
1520 *
1521 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001522 *
1523 * \par Python:
1524 * The corresponding Python function returns (status,id) tuple:
1525 * \code
1526 status, transport_id = py_pjsua.transport_create(type, cfg)
1527 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001528 */
1529PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1530 const pjsua_transport_config *cfg,
1531 pjsua_transport_id *p_id);
1532
1533/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001534 * Register transport that has been created by application. This function
1535 * is useful if application wants to implement custom SIP transport and use
1536 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001537 *
1538 * @param tp Transport instance.
1539 * @param p_id Optional pointer to receive transport ID.
1540 *
1541 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001542 *
1543 * \par Python:
1544 * Not applicable (for now), because one cannot create a custom transport
1545 * from Python script.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001546 */
1547PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1548 pjsua_transport_id *p_id);
1549
1550
1551/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001552 * Enumerate all transports currently created in the system. This function
1553 * will return all transport IDs, and application may then call
1554 * #pjsua_transport_get_info() function to retrieve detailed information
1555 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001556 *
1557 * @param id Array to receive transport ids.
1558 * @param count In input, specifies the maximum number of elements.
1559 * On return, it contains the actual number of elements.
1560 *
1561 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001562 *
1563 * \par Python:
1564 * The function returns list of integers representing transport ids:
1565 * \code
1566 [int] = py_pjsua.enum_transports()
1567 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001568 */
1569PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1570 unsigned *count );
1571
1572
1573/**
1574 * Get information about transports.
1575 *
1576 * @param id Transport ID.
1577 * @param info Pointer to receive transport info.
1578 *
1579 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001580 *
1581 * \par Python:
1582 * \code
1583 transport_info = py_pjsua.transport_get_info(id)
1584 * \endcode
1585 * The Python function returns None on error.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001586 */
1587PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1588 pjsua_transport_info *info);
1589
1590
1591/**
1592 * Disable a transport or re-enable it. By default transport is always
1593 * enabled after it is created. Disabling a transport does not necessarily
1594 * close the socket, it will only discard incoming messages and prevent
1595 * the transport from being used to send outgoing messages.
1596 *
1597 * @param id Transport ID.
1598 * @param enabled Non-zero to enable, zero to disable.
1599 *
1600 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001601 *
1602 * \par Python:
1603 * \code
1604 status = py_pjsua.transport_set_enable(id, enabled)
1605 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001606 */
1607PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1608 pj_bool_t enabled);
1609
1610
1611/**
1612 * Close the transport. If transport is forcefully closed, it will be
1613 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00001614 * transport may not terminate properly (it may even crash). Otherwise,
1615 * the system will wait until all transactions are closed while preventing
1616 * new users from using the transport, and will close the transport when
1617 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001618 *
1619 * @param id Transport ID.
1620 * @param force Non-zero to immediately close the transport. This
1621 * is not recommended!
1622 *
1623 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001624 *
1625 * \par Python:
1626 * \code
1627 status = py_pjsua.transport_close(id, force)
1628 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001629 */
1630PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1631 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001632
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001633/**
Benny Prijono312aff92006-06-17 04:08:30 +00001634 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001635 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001636
1637
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001638
1639
1640/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001641 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001642 */
1643
Benny Prijono312aff92006-06-17 04:08:30 +00001644
1645/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001646 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001647 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001648 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001649 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001650 *
Benny Prijono312aff92006-06-17 04:08:30 +00001651 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001652 * using the application. In SIP terms, the identity is used as the <b>From</b>
1653 * header in outgoing requests.
1654 *
1655 * PJSUA-API supports creating and managing multiple accounts. The maximum
1656 * number of accounts is limited by a compile time constant
1657 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001658 *
1659 * Account may or may not have client registration associated with it.
1660 * An account is also associated with <b>route set</b> and some <b>authentication
1661 * credentials</b>, which are used when sending SIP request messages using the
1662 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00001663 * will be reported to remote peer when they subscribe to the account's
1664 * presence, or which is published to a presence server if presence
1665 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00001666 *
1667 * At least one account MUST be created in the application. If no user
1668 * association is required, application can create a userless account by
1669 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00001670 * instead of a particular user, and it correspond with a particular
1671 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00001672 *
1673 * Also one account must be set as the <b>default account</b>, which is used as
1674 * the account to use when PJSUA fails to match a request with any other
1675 * accounts.
1676 *
1677 * When sending outgoing SIP requests (such as making calls or sending
1678 * instant messages), normally PJSUA requires the application to specify
1679 * which account to use for the request. If no account is specified,
1680 * PJSUA may be able to select the account by matching the destination
1681 * domain name, and fall back to default account when no match is found.
1682 */
1683
1684/**
1685 * Maximum accounts.
1686 */
1687#ifndef PJSUA_MAX_ACC
1688# define PJSUA_MAX_ACC 8
1689#endif
1690
1691
1692/**
1693 * Default registration interval.
1694 */
1695#ifndef PJSUA_REG_INTERVAL
1696# define PJSUA_REG_INTERVAL 55
1697#endif
1698
1699
1700/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001701 * Default PUBLISH expiration
1702 */
1703#ifndef PJSUA_PUBLISH_EXPIRATION
1704# define PJSUA_PUBLISH_EXPIRATION 600
1705#endif
1706
1707
1708/**
Benny Prijono093d3022006-09-24 00:07:11 +00001709 * Default account priority.
1710 */
1711#ifndef PJSUA_DEFAULT_ACC_PRIORITY
1712# define PJSUA_DEFAULT_ACC_PRIORITY 0
1713#endif
1714
1715
1716/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001717 * This structure describes account configuration to be specified when
1718 * adding a new account with #pjsua_acc_add(). Application MUST initialize
1719 * this structure first by calling #pjsua_acc_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00001720 *
1721 * \par Python:
1722 * The data type in Python is <tt>py_pjsua.Acc_Config</tt>, but normally
1723 * application can just use the snippet below to create and initialize
1724 * the account config:
1725 * \code
1726 acc_cfg = py_pjsua.acc_config_default()
1727 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001728 */
1729typedef struct pjsua_acc_config
1730{
Benny Prijono093d3022006-09-24 00:07:11 +00001731 /**
1732 * Account priority, which is used to control the order of matching
1733 * incoming/outgoing requests. The higher the number means the higher
1734 * the priority is, and the account will be matched first.
1735 */
1736 int priority;
1737
Benny Prijono312aff92006-06-17 04:08:30 +00001738 /**
1739 * The full SIP URL for the account. The value can take name address or
1740 * URL format, and will look something like "sip:account@serviceprovider".
1741 *
1742 * This field is mandatory.
1743 */
1744 pj_str_t id;
1745
1746 /**
1747 * This is the URL to be put in the request URI for the registration,
1748 * and will look something like "sip:serviceprovider".
1749 *
1750 * This field should be specified if registration is desired. If the
1751 * value is empty, no account registration will be performed.
1752 */
1753 pj_str_t reg_uri;
1754
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001755 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001756 * If this flag is set, the presence information of this account will
1757 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001758 */
1759 pj_bool_t publish_enabled;
1760
Benny Prijono312aff92006-06-17 04:08:30 +00001761 /**
1762 * Optional URI to be put as Contact for this account. It is recommended
1763 * that this field is left empty, so that the value will be calculated
1764 * automatically based on the transport address.
1765 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00001766 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00001767
1768 /**
1769 * Number of proxies in the proxy array below.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001770 *
1771 * \par Python:
1772 * Not applicable, as \a proxy is implemented as list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001773 */
1774 unsigned proxy_cnt;
1775
1776 /**
1777 * Optional URI of the proxies to be visited for all outgoing requests
1778 * that are using this account (REGISTER, INVITE, etc). Application need
1779 * to specify these proxies if the service provider requires that requests
1780 * destined towards its network should go through certain proxies first
1781 * (for example, border controllers).
1782 *
1783 * These proxies will be put in the route set for this account, with
1784 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00001785 * first). If global outbound proxies are configured in pjsua_config,
1786 * then these account proxies will be placed after the global outbound
1787 * proxies in the routeset.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001788 *
1789 * \par Python:
1790 * This will be list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001791 */
1792 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
1793
1794 /**
1795 * Optional interval for registration, in seconds. If the value is zero,
1796 * default interval will be used (PJSUA_REG_INTERVAL, 55 seconds).
1797 */
1798 unsigned reg_timeout;
1799
1800 /**
1801 * Number of credentials in the credential array.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001802 *
1803 * \par Python:
1804 * Not applicable, since \a cred_info is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00001805 */
1806 unsigned cred_count;
1807
1808 /**
1809 * Array of credentials. If registration is desired, normally there should
1810 * be at least one credential specified, to successfully authenticate
1811 * against the service provider. More credentials can be specified, for
1812 * example when the requests are expected to be challenged by the
1813 * proxies in the route set.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001814 *
1815 * \par Python:
1816 * This field is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00001817 */
1818 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1819
Benny Prijono62c5c5b2007-01-13 23:22:40 +00001820 /**
1821 * Optionally bind this account to specific transport. This normally is
1822 * not a good idea, as account should be able to send requests using
1823 * any available transports according to the destination. But some
1824 * application may want to have explicit control over the transport to
1825 * use, so in that case it can set this field.
1826 *
1827 * Default: -1 (PJSUA_INVALID_ID)
1828 *
1829 * @see pjsua_acc_set_transport()
1830 */
1831 pjsua_transport_id transport_id;
1832
Benny Prijono312aff92006-06-17 04:08:30 +00001833} pjsua_acc_config;
1834
1835
1836/**
1837 * Call this function to initialize account config with default values.
1838 *
1839 * @param cfg The account config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001840 *
1841 * \par Python:
1842 * In Python, this function both creates and initializes the account
1843 * config:
1844 * \code
1845 acc_cfg = py_pjsua.acc_config_default()
1846 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001847 */
1848PJ_INLINE(void) pjsua_acc_config_default(pjsua_acc_config *cfg)
1849{
Benny Prijonoac623b32006-07-03 15:19:31 +00001850 pj_bzero(cfg, sizeof(*cfg));
Benny Prijono312aff92006-06-17 04:08:30 +00001851
1852 cfg->reg_timeout = PJSUA_REG_INTERVAL;
Benny Prijono62c5c5b2007-01-13 23:22:40 +00001853 cfg->transport_id = PJSUA_INVALID_ID;
Benny Prijono312aff92006-06-17 04:08:30 +00001854}
1855
1856
1857
1858/**
1859 * Account info. Application can query account info by calling
1860 * #pjsua_acc_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00001861 *
1862 * \par Python:
1863 * The data type in Python is <tt>py_pjsua.Acc_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001864 */
1865typedef struct pjsua_acc_info
1866{
1867 /**
1868 * The account ID.
1869 */
1870 pjsua_acc_id id;
1871
1872 /**
1873 * Flag to indicate whether this is the default account.
1874 */
1875 pj_bool_t is_default;
1876
1877 /**
1878 * Account URI
1879 */
1880 pj_str_t acc_uri;
1881
1882 /**
1883 * Flag to tell whether this account has registration setting
1884 * (reg_uri is not empty).
1885 */
1886 pj_bool_t has_registration;
1887
1888 /**
1889 * An up to date expiration interval for account registration session.
1890 */
1891 int expires;
1892
1893 /**
1894 * Last registration status code. If status code is zero, the account
1895 * is currently not registered. Any other value indicates the SIP
1896 * status code of the registration.
1897 */
1898 pjsip_status_code status;
1899
1900 /**
1901 * String describing the registration status.
1902 */
1903 pj_str_t status_text;
1904
1905 /**
1906 * Presence online status for this account.
1907 */
1908 pj_bool_t online_status;
1909
1910 /**
1911 * Buffer that is used internally to store the status text.
1912 */
1913 char buf_[PJ_ERR_MSG_SIZE];
1914
1915} pjsua_acc_info;
1916
1917
1918
1919/**
1920 * Get number of current accounts.
1921 *
1922 * @return Current number of accounts.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001923 *
1924 * \par Python:
1925 * \code
1926 count = py_pjsua.acc_get_count()
1927 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001928 */
1929PJ_DECL(unsigned) pjsua_acc_get_count(void);
1930
1931
1932/**
1933 * Check if the specified account ID is valid.
1934 *
1935 * @param acc_id Account ID to check.
1936 *
1937 * @return Non-zero if account ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001938 *
1939 * \par Python:
1940 * \code
1941 is_valid = py_pjsua.acc_is_valid(acc_id)
1942 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001943 */
1944PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
1945
1946
1947/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00001948 * Set default account to be used when incoming and outgoing
1949 * requests doesn't match any accounts.
1950 *
1951 * @param acc_id The account ID to be used as default.
1952 *
1953 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001954 *
1955 * \par Python:
1956 * \code
1957 status = py_pjsua.acc_set_default(acc_id)
1958 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00001959 */
1960PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
1961
1962
1963/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001964 * Get default account to be used when receiving incoming requests (calls),
1965 * when the destination of the incoming call doesn't match any other
1966 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00001967 *
1968 * @return The default account ID, or PJSUA_INVALID_ID if no
1969 * default account is configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001970 *
1971 * \par Python:
1972 * \code
1973 acc_id = py_pjsua.acc_get_default()
1974 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00001975 */
1976PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
1977
1978
1979/**
Benny Prijono312aff92006-06-17 04:08:30 +00001980 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001981 * #pjsua_init()) before calling this function. If registration is configured
1982 * for this account, this function would also start the SIP registration
1983 * session with the SIP registrar server. This SIP registration session
1984 * will be maintained internally by the library, and application doesn't
1985 * need to do anything to maintain the registration session.
1986 *
Benny Prijono312aff92006-06-17 04:08:30 +00001987 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001988 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00001989 * @param is_default If non-zero, this account will be set as the default
1990 * account. The default account will be used when sending
1991 * outgoing requests (e.g. making call) when no account is
1992 * specified, and when receiving incoming requests when the
1993 * request does not match any accounts. It is recommended
1994 * that default account is set to local/LAN account.
1995 * @param p_acc_id Pointer to receive account ID of the new account.
1996 *
1997 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001998 *
1999 * \par Python:
2000 * The function returns (status, account_id) tuple:
2001 * \code
2002 status, account_id = py_pjsua.acc_add(acc_cfg, is_default)
2003 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002004 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002005PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002006 pj_bool_t is_default,
2007 pjsua_acc_id *p_acc_id);
2008
2009
2010/**
2011 * Add a local account. A local account is used to identify local endpoint
2012 * instead of a specific user, and for this reason, a transport ID is needed
2013 * to obtain the local address information.
2014 *
2015 * @param tid Transport ID to generate account address.
2016 * @param is_default If non-zero, this account will be set as the default
2017 * account. The default account will be used when sending
2018 * outgoing requests (e.g. making call) when no account is
2019 * specified, and when receiving incoming requests when the
2020 * request does not match any accounts. It is recommended
2021 * that default account is set to local/LAN account.
2022 * @param p_acc_id Pointer to receive account ID of the new account.
2023 *
2024 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002025 *
2026 * \par Python:
2027 * The function returns (status, account_id) tuple:
2028 * \code
2029 status, account_id = py_pjsua.acc_add_local(tid, is_default)
2030 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002031 */
2032PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2033 pj_bool_t is_default,
2034 pjsua_acc_id *p_acc_id);
2035
2036/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002037 * Delete an account. This will unregister the account from the SIP server,
2038 * if necessary, and terminate server side presence subscriptions associated
2039 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002040 *
2041 * @param acc_id Id of the account to be deleted.
2042 *
2043 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002044 *
2045 * \par Python:
2046 * \code
2047 status = py_pjsua.acc_del(acc_id)
2048 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002049 */
2050PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2051
2052
2053/**
2054 * Modify account information.
2055 *
2056 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002057 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002058 *
2059 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002060 *
2061 * \par Python:
2062 * \code
2063 status = py_pjsua.acc_modify(acc_id, acc_cfg)
2064 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002065 */
2066PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002067 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002068
2069
2070/**
2071 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002072 * subscribers. This would trigger the sending of outgoing NOTIFY request
2073 * if there are server side presence subscription for this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002074 *
2075 * @param acc_id The account ID.
2076 * @param is_online True of false.
2077 *
2078 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002079 *
2080 * \par Python:
2081 * \code
2082 status = py_pjsua.acc_set_online_status(acc_id, is_online)
2083 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002084 */
2085PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2086 pj_bool_t is_online);
2087
2088
2089/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002090 * Update registration or perform unregistration. If registration is
2091 * configured for this account, then initial SIP REGISTER will be sent
2092 * when the account is added with #pjsua_acc_add(). Application normally
2093 * only need to call this function if it wants to manually update the
2094 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002095 *
2096 * @param acc_id The account ID.
2097 * @param renew If renew argument is zero, this will start
2098 * unregistration process.
2099 *
2100 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002101 *
2102 * \par Python:
2103 * \code
2104 status = py_pjsua.acc_set_registration(acc_id, renew)
2105 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002106 */
2107PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2108 pj_bool_t renew);
2109
2110
2111/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002112 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002113 *
2114 * @param acc_id Account identification.
2115 * @param info Pointer to receive account information.
2116 *
2117 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002118 *
2119 * \par Python:
2120 * \code
2121 acc_info = py_pjsua.acc_get_info(acc_id)
2122 * \endcode
2123 * The function returns None if account ID is not valid.
Benny Prijono312aff92006-06-17 04:08:30 +00002124 */
2125PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2126 pjsua_acc_info *info);
2127
2128
2129/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002130 * Enumerate all account currently active in the library. This will fill
2131 * the array with the account Ids, and application can then query the
2132 * account information for each id with #pjsua_acc_get_info().
2133 *
2134 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002135 *
2136 * @param ids Array of account IDs to be initialized.
2137 * @param count In input, specifies the maximum number of elements.
2138 * On return, it contains the actual number of elements.
2139 *
2140 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002141 *
2142 * \par Python:
2143 * The function takes no argument and returns list of account Ids:
2144 * \code
2145 [acc_ids] = py_pjsua.enum_accs()
2146 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002147 */
2148PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2149 unsigned *count );
2150
2151
2152/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002153 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002154 *
2155 * @param info Array of account infos to be initialized.
2156 * @param count In input, specifies the maximum number of elements.
2157 * On return, it contains the actual number of elements.
2158 *
2159 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002160 *
2161 * \par Python:
2162 * The function takes no argument and returns list of account infos:
2163 * \code
2164 [acc_info] = py_pjsua.acc_enum_info()
2165 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002166 */
2167PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2168 unsigned *count );
2169
2170
2171/**
2172 * This is an internal function to find the most appropriate account to
2173 * used to reach to the specified URL.
2174 *
2175 * @param url The remote URL to reach.
2176 *
2177 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002178 *
2179 * \par Python:
2180 * \code
2181 acc_id = py_pjsua.acc_find_for_outgoing(url)
2182 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002183 */
2184PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2185
2186
2187/**
2188 * This is an internal function to find the most appropriate account to be
2189 * used to handle incoming calls.
2190 *
2191 * @param rdata The incoming request message.
2192 *
2193 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002194 *
2195 * \par Python:
2196 * \code
2197 acc_id = py_pjsua.acc_find_for_outgoing(url)
2198 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002199 */
2200PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2201
2202
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002203/**
Benny Prijonofff245c2007-04-02 11:44:47 +00002204 * Create arbitrary requests using the account. Application should only use
2205 * this function to create auxiliary requests outside dialog, such as
2206 * OPTIONS, and use the call or presence API to create dialog related
2207 * requests.
2208 *
2209 * @param acc_id The account ID.
2210 * @param method The SIP method of the request.
2211 * @param target Target URI.
2212 * @param p_tdata Pointer to receive the request.
2213 *
2214 * @return PJ_SUCCESS or the error code.
2215 */
2216PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
2217 const pjsip_method *method,
2218 const pj_str_t *target,
2219 pjsip_tx_data **p_tdata);
2220
2221
2222/**
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002223 * Create a suitable URI to be put as Contact based on the specified
2224 * target URI for the specified account.
2225 *
2226 * @param pool Pool to allocate memory for the string.
2227 * @param contact The string where the Contact URI will be stored.
2228 * @param acc_id Account ID.
2229 * @param uri Destination URI of the request.
2230 *
2231 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002232 *
2233 * \par Python:
2234 * This function is still experimental in Python:
2235 * \code
2236 uri = py_pjsua.acc_create_uac_contact(pool, acc_id, uri)
2237 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002238 */
2239PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
2240 pj_str_t *contact,
2241 pjsua_acc_id acc_id,
2242 const pj_str_t *uri);
2243
2244
2245
2246/**
2247 * Create a suitable URI to be put as Contact based on the information
2248 * in the incoming request.
2249 *
2250 * @param pool Pool to allocate memory for the string.
2251 * @param contact The string where the Contact URI will be stored.
2252 * @param acc_id Account ID.
2253 * @param rdata Incoming request.
2254 *
2255 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002256 *
2257 * \par Python:
2258 * This function is still experimental in Python:
2259 * \code
2260 uri = py_pjsua.acc_create_uas_contact(pool, acc_id, rdata)
2261 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002262 */
2263PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
2264 pj_str_t *contact,
2265 pjsua_acc_id acc_id,
2266 pjsip_rx_data *rdata );
2267
2268
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002269/**
2270 * Lock/bind this account to a specific transport/listener. Normally
2271 * application shouldn't need to do this, as transports will be selected
2272 * automatically by the stack according to the destination.
2273 *
2274 * When account is locked/bound to a specific transport, all outgoing
2275 * requests from this account will use the specified transport (this
2276 * includes SIP registration, dialog (call and event subscription), and
2277 * out-of-dialog requests such as MESSAGE).
2278 *
2279 * Note that transport_id may be specified in pjsua_acc_config too.
2280 *
2281 * @param acc_id The account ID.
2282 * @param tp_id The transport ID.
2283 *
2284 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002285 *
2286 * \par Python:
2287 * Not yet implemented.
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002288 */
2289PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
2290 pjsua_transport_id tp_id);
2291
Benny Prijono312aff92006-06-17 04:08:30 +00002292
2293/**
2294 * @}
2295 */
2296
2297
2298/*****************************************************************************
2299 * CALLS API
2300 */
2301
2302
2303/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002304 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00002305 * @ingroup PJSUA_LIB
2306 * @brief Call manipulation.
2307 * @{
2308 */
2309
2310/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002311 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00002312 */
2313#ifndef PJSUA_MAX_CALLS
2314# define PJSUA_MAX_CALLS 32
2315#endif
2316
2317
2318
2319/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002320 * This enumeration specifies the media status of a call, and it's part
2321 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00002322 */
2323typedef enum pjsua_call_media_status
2324{
Benny Prijonob5388cf2007-01-04 22:45:08 +00002325 /** Call currently has no media */
Benny Prijono312aff92006-06-17 04:08:30 +00002326 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002327
2328 /** The media is active */
Benny Prijono312aff92006-06-17 04:08:30 +00002329 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002330
2331 /** The media is currently put on hold by local endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002332 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002333
2334 /** The media is currently put on hold by remote endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002335 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002336
Benny Prijono312aff92006-06-17 04:08:30 +00002337} pjsua_call_media_status;
2338
2339
2340/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002341 * This structure describes the information and current status of a call.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002342 *
2343 * \par Python:
2344 * The type name is <tt>py_pjsua.Call_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002345 */
2346typedef struct pjsua_call_info
2347{
2348 /** Call identification. */
2349 pjsua_call_id id;
2350
2351 /** Initial call role (UAC == caller) */
2352 pjsip_role_e role;
2353
Benny Prijono90315512006-09-14 16:05:16 +00002354 /** The account ID where this call belongs. */
2355 pjsua_acc_id acc_id;
2356
Benny Prijono312aff92006-06-17 04:08:30 +00002357 /** Local URI */
2358 pj_str_t local_info;
2359
2360 /** Local Contact */
2361 pj_str_t local_contact;
2362
2363 /** Remote URI */
2364 pj_str_t remote_info;
2365
2366 /** Remote contact */
2367 pj_str_t remote_contact;
2368
2369 /** Dialog Call-ID string. */
2370 pj_str_t call_id;
2371
2372 /** Call state */
2373 pjsip_inv_state state;
2374
2375 /** Text describing the state */
2376 pj_str_t state_text;
2377
2378 /** Last status code heard, which can be used as cause code */
2379 pjsip_status_code last_status;
2380
2381 /** The reason phrase describing the status. */
2382 pj_str_t last_status_text;
2383
2384 /** Call media status. */
2385 pjsua_call_media_status media_status;
2386
2387 /** Media direction */
2388 pjmedia_dir media_dir;
2389
2390 /** The conference port number for the call */
2391 pjsua_conf_port_id conf_slot;
2392
2393 /** Up-to-date call connected duration (zero when call is not
2394 * established)
2395 */
2396 pj_time_val connect_duration;
2397
2398 /** Total call duration, including set-up time */
2399 pj_time_val total_duration;
2400
2401 /** Internal */
2402 struct {
2403 char local_info[128];
2404 char local_contact[128];
2405 char remote_info[128];
2406 char remote_contact[128];
2407 char call_id[128];
2408 char last_status_text[128];
2409 } buf_;
2410
2411} pjsua_call_info;
2412
2413
2414
Benny Prijonoa91a0032006-02-26 21:23:45 +00002415/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002416 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002417 *
2418 * @return Maximum number of calls configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002419 *
2420 * \par Python:
2421 * \code
2422 count = py_pjsua.call_get_max_count()
2423 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002424 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002425PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002426
2427/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002428 * Get number of currently active calls.
2429 *
2430 * @return Number of currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002431 *
2432 * \par Python:
2433 * \code
2434 count = py_pjsua.call_get_count()
2435 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002436 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002437PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002438
2439/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002440 * Enumerate all active calls. Application may then query the information and
2441 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002442 *
2443 * @param ids Array of account IDs to be initialized.
2444 * @param count In input, specifies the maximum number of elements.
2445 * On return, it contains the actual number of elements.
2446 *
2447 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002448 *
2449 * \par Python:
2450 * This function takes no argument and return list of call Ids.
2451 * \code
2452 [call_ids] = py_pjsua.enum_calls()
2453 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002454 */
2455PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
2456 unsigned *count);
2457
2458
2459/**
2460 * Make outgoing call to the specified URI using the specified account.
2461 *
2462 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002463 * @param dst_uri URI to be put in the To header (normally is the same
2464 * as the target URI).
2465 * @param options Options (must be zero at the moment).
2466 * @param user_data Arbitrary user data to be attached to the call, and
2467 * can be retrieved later.
2468 * @param msg_data Optional headers etc to be added to outgoing INVITE
2469 * request, or NULL if no custom header is desired.
2470 * @param p_call_id Pointer to receive call identification.
2471 *
2472 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002473 *
2474 * \par Python:
2475 * The Python function returns (status, call_id) tuple:
2476 * \code
2477 status, call_id = py_pjsua.call_make_call(acc_id, dst_uri, options,
2478 user_data, msg_data)
2479 * \endcode
2480 * Note: the \a user_data in Python function is an integer, and the
2481 * \a msg_data can be set to None if not required.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002482 */
2483PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
2484 const pj_str_t *dst_uri,
2485 unsigned options,
2486 void *user_data,
2487 const pjsua_msg_data *msg_data,
2488 pjsua_call_id *p_call_id);
2489
2490
2491/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002492 * Check if the specified call has active INVITE session and the INVITE
2493 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002494 *
2495 * @param call_id Call identification.
2496 *
2497 * @return Non-zero if call is active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002498 *
2499 * \par Python:
2500 * \code
2501 bool = py_pjsua.call_is_active(call_id)
2502 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002503 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002504PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002505
2506
2507/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002508 * Check if call has an active media session.
2509 *
2510 * @param call_id Call identification.
2511 *
2512 * @return Non-zero if yes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002513 *
2514 * \par Python:
2515 * \code
2516 bool = py_pjsua.call_has_media(call_id)
2517 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002518 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002519PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002520
2521
2522/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002523 * Get the conference port identification associated with the call.
2524 *
2525 * @param call_id Call identification.
2526 *
2527 * @return Conference port ID, or PJSUA_INVALID_ID when the
2528 * media has not been established or is not active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002529 *
2530 * \par Python:
2531 * \code
2532 slot = py_pjsua.call_get_conf_port(call_id)
2533 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002534 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002535PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
2536
2537/**
2538 * Obtain detail information about the specified call.
2539 *
2540 * @param call_id Call identification.
2541 * @param info Call info to be initialized.
2542 *
2543 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002544 *
2545 * \par Python:
2546 * \code
2547 call_info = py_pjsua.call_get_info(call_id)
2548 * \endcode
2549 * \a call_info return value will be set to None if call_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002550 */
2551PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002552 pjsua_call_info *info);
2553
2554
2555/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002556 * Attach application specific data to the call. Application can then
2557 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002558 *
2559 * @param call_id Call identification.
2560 * @param user_data Arbitrary data to be attached to the call.
2561 *
2562 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002563 *
2564 * \par Python:
2565 * \code
2566 status = py_pjsua.call_set_user_data(call_id, user_data)
2567 * \endcode
2568 * The \a user_data is an integer in the Python function.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002569 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002570PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
2571 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002572
2573
2574/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002575 * Get user data attached to the call, which has been previously set with
2576 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002577 *
2578 * @param call_id Call identification.
2579 *
2580 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002581 *
2582 * \par Python:
2583 * \code
2584 user_data = py_pjsua.call_get_user_data(call_id)
2585 * \endcode
2586 * The \a user_data is an integer.
Benny Prijono268ca612006-02-07 12:34:11 +00002587 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002588PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00002589
2590
2591/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002592 * Send response to incoming INVITE request. Depending on the status
2593 * code specified as parameter, this function may send provisional
2594 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002595 *
2596 * @param call_id Incoming call identification.
2597 * @param code Status code, (100-699).
2598 * @param reason Optional reason phrase. If NULL, default text
2599 * will be used.
2600 * @param msg_data Optional list of headers etc to be added to outgoing
2601 * response message.
2602 *
2603 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002604 *
2605 * \par Python:
2606 * \code
2607 status = py_pjsua.call_answer(call_id, code, reason, msg_data)
2608 * \endcode
2609 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijonoa91a0032006-02-26 21:23:45 +00002610 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002611PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
2612 unsigned code,
2613 const pj_str_t *reason,
2614 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00002615
2616/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002617 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00002618 * call state. This function is different than answering the call with
2619 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
2620 * will hangup the call regardless of the state and role of the call,
2621 * while #pjsua_call_answer() only works with incoming calls on EARLY
2622 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002623 *
2624 * @param call_id Call identification.
2625 * @param code Optional status code to be sent when we're rejecting
2626 * incoming call. If the value is zero, "603/Decline"
2627 * will be sent.
2628 * @param reason Optional reason phrase to be sent when we're rejecting
2629 * incoming call. If NULL, default text will be used.
2630 * @param msg_data Optional list of headers etc to be added to outgoing
2631 * request/response message.
2632 *
2633 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002634 *
2635 * \par Python:
2636 * \code
2637 status = py_pjsua.call_hangup(call_id, code, reason, msg_data)
2638 * \endcode
2639 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002640 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002641PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
2642 unsigned code,
2643 const pj_str_t *reason,
2644 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002645
2646
2647/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002648 * Put the specified call on hold. This will send re-INVITE with the
2649 * appropriate SDP to inform remote that the call is being put on hold.
2650 * The final status of the request itself will be reported on the
2651 * \a on_call_media_state() callback, which inform the application that
2652 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002653 *
2654 * @param call_id Call identification.
2655 * @param msg_data Optional message components to be sent with
2656 * the request.
2657 *
2658 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002659 *
2660 * \par Python:
2661 * \code
2662 status = py_pjsua.call_set_hold(call_id, msg_data)
2663 * \endcode
2664 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002665 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002666PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
2667 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002668
2669
2670/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002671 * Send re-INVITE to release hold.
2672 * The final status of the request itself will be reported on the
2673 * \a on_call_media_state() callback, which inform the application that
2674 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002675 *
2676 * @param call_id Call identification.
2677 * @param unhold If this argument is non-zero and the call is locally
2678 * held, this will release the local hold.
2679 * @param msg_data Optional message components to be sent with
2680 * the request.
2681 *
2682 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002683 *
2684 * \par Python:
2685 * \code
2686 status = py_pjsua.call_reinvite(call_id, unhold, msg_data)
2687 * \endcode
2688 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002689 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002690PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
2691 pj_bool_t unhold,
2692 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002693
2694
2695/**
Benny Prijono053f5222006-11-11 16:16:04 +00002696 * Initiate call transfer to the specified address. This function will send
2697 * REFER request to instruct remote call party to initiate a new INVITE
2698 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002699 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00002700 * If application is interested to monitor the successfulness and
2701 * the progress of the transfer request, it can implement
2702 * \a on_call_transfer_status() callback which will report the progress
2703 * of the call transfer request.
2704 *
Benny Prijono053f5222006-11-11 16:16:04 +00002705 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002706 * @param dest Address of new target to be contacted.
2707 * @param msg_data Optional message components to be sent with
2708 * the request.
2709 *
2710 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002711 *
2712 * \par Python:
2713 * \code
2714 status = py_pjsua.call_xfer(call_id, dest, msg_data)
2715 * \endcode
2716 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002717 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002718PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
2719 const pj_str_t *dest,
2720 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002721
2722/**
Benny Prijono053f5222006-11-11 16:16:04 +00002723 * Flag to indicate that "Require: replaces" should not be put in the
2724 * outgoing INVITE request caused by REFER request created by
2725 * #pjsua_call_xfer_replaces().
2726 */
2727#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
2728
2729/**
2730 * Initiate attended call transfer. This function will send REFER request
2731 * to instruct remote call party to initiate new INVITE session to the URL
2732 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
2733 * the call with us with the new call from the REFER recipient.
2734 *
2735 * @param call_id The call id to be transfered.
2736 * @param dest_call_id The call id to be replaced.
2737 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
2738 * to suppress the inclusion of "Require: replaces" in
2739 * the outgoing INVITE request created by the REFER
2740 * request.
2741 * @param msg_data Optional message components to be sent with
2742 * the request.
2743 *
2744 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002745 *
2746 * \par Python:
2747 * \code
2748 status = py_pjsua.call_xfer_replaces(call_id, dest_call_id, options, msg_data)
2749 * \endcode
2750 * Argument \a msg_data may be set to None if not required.
Benny Prijono053f5222006-11-11 16:16:04 +00002751 */
2752PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
2753 pjsua_call_id dest_call_id,
2754 unsigned options,
2755 const pjsua_msg_data *msg_data);
2756
2757/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002758 * Send DTMF digits to remote using RFC 2833 payload formats.
2759 *
2760 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002761 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002762 *
2763 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002764 *
2765 * \par Python:
2766 * \code
2767 status = py_pjsua.call_dial_dtmf(call_id, digits)
2768 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002769 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002770PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002771 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00002772
Benny Prijono26ff9062006-02-21 23:47:00 +00002773/**
Benny Prijonob0808372006-03-02 21:18:58 +00002774 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002775 *
2776 * @param call_id Call identification.
2777 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
2778 * assumed.
2779 * @param content The message content.
2780 * @param msg_data Optional list of headers etc to be included in outgoing
2781 * request. The body descriptor in the msg_data is
2782 * ignored.
2783 * @param user_data Optional user data, which will be given back when
2784 * the IM callback is called.
2785 *
2786 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002787 *
2788 * \par Python:
2789 * \code
2790 status = py_pjsua.call_send_im(call_id, mime_type, content, msg_data, user_data)
2791 * \endcode
2792 * Note that the \a user_data argument is an integer in Python.
Benny Prijonob0808372006-03-02 21:18:58 +00002793 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002794PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
2795 const pj_str_t *mime_type,
2796 const pj_str_t *content,
2797 const pjsua_msg_data *msg_data,
2798 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00002799
2800
2801/**
2802 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002803 *
2804 * @param call_id Call identification.
2805 * @param is_typing Non-zero to indicate to remote that local person is
2806 * currently typing an IM.
2807 * @param msg_data Optional list of headers etc to be included in outgoing
2808 * request.
2809 *
2810 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002811 *
2812 * \par Python:
2813 * \code
2814 status = py_pjsua.call_send_typing_ind(call_id, is_typing, msg_data)
2815 * \endcode
2816 * Argument \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00002817 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002818PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
2819 pj_bool_t is_typing,
2820 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00002821
2822/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002823 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
2824 * currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002825 *
2826 * \par Python:
2827 * \code
2828 py_pjsua.call_hangup_all()
2829 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00002830 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00002831PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00002832
2833
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002834/**
2835 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002836 *
2837 * @param call_id Call identification.
2838 * @param with_media Non-zero to include media information too.
2839 * @param buffer Buffer where the statistics are to be written to.
2840 * @param maxlen Maximum length of buffer.
2841 * @param indent Spaces for left indentation.
2842 *
2843 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002844 *
2845 * \par Python:
2846 * \code
2847 string = py_pjsua.call_dump(call_id, with_media, max_len, indent)
2848 * \endcode
2849 * The \a max_len argument is the desired maximum length to be allocated.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002850 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002851PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
2852 pj_bool_t with_media,
2853 char *buffer,
2854 unsigned maxlen,
2855 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002856
Benny Prijono9fc735d2006-05-28 14:58:12 +00002857/**
Benny Prijono312aff92006-06-17 04:08:30 +00002858 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00002859 */
Benny Prijono834aee32006-02-19 01:38:06 +00002860
2861
2862/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00002863 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00002864 */
2865
Benny Prijono312aff92006-06-17 04:08:30 +00002866
2867/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002868 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00002869 * @ingroup PJSUA_LIB
2870 * @brief Buddy management, buddy's presence, and instant messaging.
2871 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00002872 *
2873 * This section describes PJSUA-APIs related to buddies management,
2874 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00002875 */
2876
2877/**
2878 * Max buddies in buddy list.
2879 */
2880#ifndef PJSUA_MAX_BUDDIES
2881# define PJSUA_MAX_BUDDIES 256
2882#endif
2883
2884
2885/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002886 * This structure describes buddy configuration when adding a buddy to
2887 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
2888 * the structure with #pjsua_buddy_config_default() to initialize this
2889 * structure with default configuration.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002890 *
2891 * \par Python:
2892 * In Python this structure is <tt>py_pjsua.Buddy_Config</tt>. However
2893 * it is recommended that application instantiates the buddy config
2894 * by calling:
2895 * \code
2896 buddy_cfg = py_pjsua.buddy_config_default()
2897 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002898 */
2899typedef struct pjsua_buddy_config
2900{
2901 /**
2902 * Buddy URL or name address.
2903 */
2904 pj_str_t uri;
2905
2906 /**
2907 * Specify whether presence subscription should start immediately.
2908 */
2909 pj_bool_t subscribe;
2910
2911} pjsua_buddy_config;
2912
2913
2914/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002915 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00002916 */
2917typedef enum pjsua_buddy_status
2918{
2919 /**
2920 * Online status is unknown (possibly because no presence subscription
2921 * has been established).
2922 */
2923 PJSUA_BUDDY_STATUS_UNKNOWN,
2924
2925 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00002926 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00002927 */
2928 PJSUA_BUDDY_STATUS_ONLINE,
2929
2930 /**
2931 * Buddy is offline.
2932 */
2933 PJSUA_BUDDY_STATUS_OFFLINE,
2934
2935} pjsua_buddy_status;
2936
2937
2938
2939/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002940 * This structure describes buddy info, which can be retrieved by calling
2941 * #pjsua_buddy_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00002942 *
2943 * \par Python:
2944 * This structure in Python is <tt>py_pjsua.Buddy_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002945 */
2946typedef struct pjsua_buddy_info
2947{
2948 /**
2949 * The buddy ID.
2950 */
2951 pjsua_buddy_id id;
2952
2953 /**
2954 * The full URI of the buddy, as specified in the configuration.
2955 */
2956 pj_str_t uri;
2957
2958 /**
2959 * Buddy's Contact, only available when presence subscription has
2960 * been established to the buddy.
2961 */
2962 pj_str_t contact;
2963
2964 /**
2965 * Buddy's online status.
2966 */
2967 pjsua_buddy_status status;
2968
2969 /**
2970 * Text to describe buddy's online status.
2971 */
2972 pj_str_t status_text;
2973
2974 /**
2975 * Flag to indicate that we should monitor the presence information for
2976 * this buddy (normally yes, unless explicitly disabled).
2977 */
2978 pj_bool_t monitor_pres;
2979
2980 /**
2981 * Internal buffer.
2982 */
2983 char buf_[256];
2984
2985} pjsua_buddy_info;
2986
2987
Benny Prijono834aee32006-02-19 01:38:06 +00002988/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002989 * Set default values to the buddy config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002990 *
2991 * \par Python:
2992 * \code
2993 buddy_cfg = py_pjsua.buddy_config_default()
2994 * \endcode
Benny Prijonob5388cf2007-01-04 22:45:08 +00002995 */
2996PJ_INLINE(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg)
2997{
2998 pj_bzero(cfg, sizeof(*cfg));
2999}
3000
3001
3002/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003003 * Get total number of buddies.
3004 *
3005 * @return Number of buddies.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003006 *
3007 * \par Python:
3008 * \code
3009 buddy_count = py_pjsua.get_buddy_count()
3010 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003011 */
3012PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3013
3014
3015/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003016 * Check if buddy ID is valid.
3017 *
3018 * @param buddy_id Buddy ID to check.
3019 *
3020 * @return Non-zero if buddy ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003021 *
3022 * \par Python:
3023 * \code
3024 is_valid = py_pjsua.buddy_is_valid(buddy_id)
3025 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003026 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003027PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3028
3029
3030/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003031 * Enumerate all buddy IDs in the buddy list. Application then can use
3032 * #pjsua_buddy_get_info() to get the detail information for each buddy
3033 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003034 *
3035 * @param ids Array of ids to be initialized.
3036 * @param count On input, specifies max elements in the array.
3037 * On return, it contains actual number of elements
3038 * that have been initialized.
3039 *
3040 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003041 *
3042 * \par Python:
3043 * The Python function takes no argument and returns list of buddy IDs:
3044 * \code
3045 [buddy_ids] = py_pjsua.enum_buddies()
3046 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003047 */
3048PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3049 unsigned *count);
3050
3051/**
3052 * Get detailed buddy info.
3053 *
3054 * @param buddy_id The buddy identification.
3055 * @param info Pointer to receive information about buddy.
3056 *
3057 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003058 *
3059 * \par Python:
3060 * \code
3061 buddy_info = py_pjsua.buddy_get_info(buddy_id)
3062 * \endcode
3063 * The function returns None if buddy_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003064 */
3065PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003066 pjsua_buddy_info *info);
3067
3068/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003069 * Add new buddy to the buddy list. If presence subscription is enabled
3070 * for this buddy, this function will also start the presence subscription
3071 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003072 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003073 * @param buddy)cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003074 * @param p_buddy_id Pointer to receive buddy ID.
3075 *
3076 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003077 *
3078 * \par Python:
3079 * The function returns (status, buddy_id) tuple:
3080 * \code
3081 status, buddy_id = py_pjsua.buddy_add(buddy_cfg)
3082 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003083 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003084PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003085 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003086
3087
3088/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003089 * Delete the specified buddy from the buddy list. Any presence subscription
3090 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003091 *
3092 * @param buddy_id Buddy identification.
3093 *
3094 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003095 *
3096 * \par Python:
3097 * \code
3098 status = py_pjsua.buddy_del(buddy_id)
3099 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +00003100 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003101PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003102
3103
3104/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003105 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3106 * subscribed, application will be informed about buddy's presence status
3107 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003108 *
3109 * @param buddy_id Buddy identification.
3110 * @param subscribe Specify non-zero to activate presence subscription to
3111 * the specified buddy.
3112 *
3113 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003114 *
3115 * \par Python:
3116 * \code
3117 status = py_pjsua.buddy_subscribe_pres(buddy_id, subscribe)
3118 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003119 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003120PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3121 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003122
3123
3124/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003125 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003126 *
3127 * @param verbose Yes or no.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003128 *
3129 * \par Python:
3130 * \code
3131 py_pjsua.pres_dump()
3132 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003133 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003134PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003135
3136
Benny Prijonob0808372006-03-02 21:18:58 +00003137/**
3138 * The MESSAGE method (defined in pjsua_im.c)
3139 */
3140extern const pjsip_method pjsip_message_method;
3141
3142
Benny Prijonob0808372006-03-02 21:18:58 +00003143
3144/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003145 * Send instant messaging outside dialog, using the specified account for
3146 * route set and authentication.
3147 *
3148 * @param acc_id Account ID to be used to send the request.
3149 * @param to Remote URI.
3150 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3151 * assumed.
3152 * @param content The message content.
3153 * @param msg_data Optional list of headers etc to be included in outgoing
3154 * request. The body descriptor in the msg_data is
3155 * ignored.
3156 * @param user_data Optional user data, which will be given back when
3157 * the IM callback is called.
3158 *
3159 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003160 *
3161 * \par Python:
3162 * \code
3163 status = py_pjsua.im_send(acc_id, to, mime_type, content, msg_data, user_data)
3164 * \endcode
3165 * Arguments \a mime_type and \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003166 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003167PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3168 const pj_str_t *to,
3169 const pj_str_t *mime_type,
3170 const pj_str_t *content,
3171 const pjsua_msg_data *msg_data,
3172 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003173
3174
3175/**
3176 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003177 *
3178 * @param acc_id Account ID to be used to send the request.
3179 * @param to Remote URI.
3180 * @param is_typing If non-zero, it tells remote person that local person
3181 * is currently composing an IM.
3182 * @param msg_data Optional list of headers etc to be added to outgoing
3183 * request.
3184 *
3185 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003186 *
3187 * \par Python:
3188 * \code
3189 status = py_pjsua.im_typing(acc_id, to, is_typing, msg_data)
3190 * \endcode
3191 * Argument \a msg_data may be set to None if not requried.
Benny Prijonob0808372006-03-02 21:18:58 +00003192 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003193PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3194 const pj_str_t *to,
3195 pj_bool_t is_typing,
3196 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003197
3198
Benny Prijonof3195072006-02-14 21:15:30 +00003199
Benny Prijono312aff92006-06-17 04:08:30 +00003200/**
3201 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003202 */
3203
Benny Prijono312aff92006-06-17 04:08:30 +00003204
3205/*****************************************************************************
3206 * MEDIA API
3207 */
3208
3209
3210/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003211 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003212 * @ingroup PJSUA_LIB
3213 * @brief Media manipulation.
3214 * @{
3215 *
3216 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003217 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3218 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003219 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003220 * the interconnection between these terminations freely.
3221 *
3222 * The conference bridge provides powerful switching and mixing functionality
3223 * for application. With the conference bridge, each conference slot (e.g.
3224 * a call) can transmit to multiple destinations, and one destination can
3225 * receive from multiple sources. If more than one media terminations are
3226 * terminated in the same slot, the conference bridge will mix the signal
3227 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00003228 *
3229 * Application connects one media termination/slot to another by calling
3230 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003231 * media flow from the source termination to the sink termination. To
3232 * establish bidirectional media flow, application wound need to make another
3233 * call to #pjsua_conf_connect(), this time inverting the source and
3234 * destination slots in the parameter.
3235 *
3236 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00003237 * the following steps:
3238 *
3239 \code
3240
3241 pj_status_t stream_to_call( pjsua_call_id call_id )
3242 {
3243 pjsua_player_id player_id;
3244
3245 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
3246 if (status != PJ_SUCCESS)
3247 return status;
3248
3249 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
3250 pjsua_call_get_conf_port() );
3251 }
3252 \endcode
3253 *
3254 *
3255 * Other features of PJSUA media:
3256 * - efficient N to M interconnections between media terminations.
3257 * - media termination can be connected to itself to create loopback
3258 * media.
3259 * - the media termination may have different clock rates, and resampling
3260 * will be done automatically by conference bridge.
3261 * - media terminations may also have different frame time; the
3262 * conference bridge will perform the necessary bufferring to adjust
3263 * the difference between terminations.
3264 * - interconnections are removed automatically when media termination
3265 * is removed from the bridge.
3266 * - sound device may be changed even when there are active media
3267 * interconnections.
3268 * - correctly report call's media quality (in #pjsua_call_dump()) from
3269 * RTCP packet exchange.
3270 */
3271
3272/**
3273 * Max ports in the conference bridge.
3274 */
3275#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00003276# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00003277#endif
3278
Benny Prijonob5388cf2007-01-04 22:45:08 +00003279/**
3280 * The default clock rate to be used by the conference bridge.
3281 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003282#ifndef PJSUA_DEFAULT_CLOCK_RATE
3283# define PJSUA_DEFAULT_CLOCK_RATE 16000
3284#endif
3285
Benny Prijonob5388cf2007-01-04 22:45:08 +00003286/**
3287 * Default codec quality settings.
3288 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003289#ifndef PJSUA_DEFAULT_CODEC_QUALITY
3290# define PJSUA_DEFAULT_CODEC_QUALITY 5
3291#endif
3292
Benny Prijonob5388cf2007-01-04 22:45:08 +00003293/**
3294 * Default iLBC mode.
3295 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003296#ifndef PJSUA_DEFAULT_ILBC_MODE
3297# define PJSUA_DEFAULT_ILBC_MODE 20
3298#endif
3299
Benny Prijonob5388cf2007-01-04 22:45:08 +00003300/**
3301 * The default echo canceller tail length.
3302 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003303#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonod2990b92006-11-23 10:19:46 +00003304# define PJSUA_DEFAULT_EC_TAIL_LEN 800
Benny Prijono12a669c2006-11-23 07:32:13 +00003305#endif
Benny Prijono312aff92006-06-17 04:08:30 +00003306
3307
3308/**
Benny Prijonocba59d92007-02-16 09:22:56 +00003309 * The maximum file player.
3310 */
3311#ifndef PJSUA_MAX_PLAYERS
3312# define PJSUA_MAX_PLAYERS 32
3313#endif
3314
3315
3316/**
3317 * The maximum file player.
3318 */
3319#ifndef PJSUA_MAX_RECORDERS
3320# define PJSUA_MAX_RECORDERS 32
3321#endif
3322
3323
3324/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003325 * This structure describes media configuration, which will be specified
3326 * when calling #pjsua_init(). Application MUST initialize this structure
3327 * by calling #pjsua_media_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003328 *
3329 * \par Python:
3330 * This data type in Python is <tt>py_pjsua.Media_Config</tt>. To create
3331 * an object of this type, it is recommended to call
3332 * <tt>py_pjsua.media_config_default()</tt> function instead:
3333 * \code
3334 media_cfg = py_pjsua.media_config_default()
3335 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003336 */
3337struct pjsua_media_config
3338{
3339 /**
3340 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003341 * If value is zero, default clock rate will be used
3342 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00003343 */
3344 unsigned clock_rate;
3345
3346 /**
3347 * Specify maximum number of media ports to be created in the
3348 * conference bridge. Since all media terminate in the bridge
3349 * (calls, file player, file recorder, etc), the value must be
3350 * large enough to support all of them. However, the larger
3351 * the value, the more computations are performed.
3352 */
3353 unsigned max_media_ports;
3354
3355 /**
3356 * Specify whether the media manager should manage its own
3357 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
3358 * and at least one worker thread will be created too. If no,
3359 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
3360 * and no worker thread is needed.
3361 *
3362 * Normally application would say yes here, unless it wants to
3363 * run everything from a single thread.
3364 */
3365 pj_bool_t has_ioqueue;
3366
3367 /**
3368 * Specify the number of worker threads to handle incoming RTP
3369 * packets. A value of one is recommended for most applications.
3370 */
3371 unsigned thread_cnt;
3372
Benny Prijono0498d902006-06-19 14:49:14 +00003373 /**
3374 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00003375 * 5-10: resampling use large filter,
3376 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00003377 * 1-2: resampling use linear.
3378 * The media quality also sets speex codec quality/complexity to the
3379 * number.
3380 *
Benny Prijono70972992006-08-05 11:13:58 +00003381 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00003382 */
3383 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00003384
3385 /**
3386 * Specify default ptime.
3387 *
3388 * Default: 0 (codec specific)
3389 */
3390 unsigned ptime;
3391
3392 /**
3393 * Disable VAD?
3394 *
3395 * Default: 0 (no (meaning VAD is enabled))
3396 */
3397 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00003398
3399 /**
3400 * iLBC mode (20 or 30).
3401 *
Benny Prijono70972992006-08-05 11:13:58 +00003402 * Default: 20 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00003403 */
3404 unsigned ilbc_mode;
3405
3406 /**
3407 * Percentage of RTP packet to drop in TX direction
3408 * (to simulate packet lost).
3409 *
3410 * Default: 0
3411 */
3412 unsigned tx_drop_pct;
3413
3414 /**
3415 * Percentage of RTP packet to drop in RX direction
3416 * (to simulate packet lost).
3417 *
3418 * Default: 0
3419 */
3420 unsigned rx_drop_pct;
3421
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003422 /**
Benny Prijono5da50432006-08-07 10:24:52 +00003423 * Echo canceller options (see #pjmedia_echo_create())
3424 *
3425 * Default: 0.
3426 */
3427 unsigned ec_options;
3428
3429 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003430 * Echo canceller tail length, in miliseconds.
3431 *
Benny Prijono669643c2006-09-20 20:02:18 +00003432 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003433 */
3434 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003435
3436 /**
3437 * Jitter buffer initial prefetch delay in msec. The value must be
3438 * between jb_min_pre and jb_max_pre below.
3439 *
3440 * Default: -1 (to use default stream settings, currently 150 msec)
3441 */
3442 int jb_init;
3443
3444 /**
3445 * Jitter buffer minimum prefetch delay in msec.
3446 *
3447 * Default: -1 (to use default stream settings, currently 60 msec)
3448 */
3449 int jb_min_pre;
3450
3451 /**
3452 * Jitter buffer maximum prefetch delay in msec.
3453 *
3454 * Default: -1 (to use default stream settings, currently 240 msec)
3455 */
3456 int jb_max_pre;
3457
3458 /**
3459 * Set maximum delay that can be accomodated by the jitter buffer msec.
3460 *
3461 * Default: -1 (to use default stream settings, currently 360 msec)
3462 */
3463 int jb_max;
3464
Benny Prijonoc97608e2007-03-23 16:34:20 +00003465 /**
3466 * Enable ICE
3467 */
3468 pj_bool_t enable_ice;
3469
3470 /**
3471 * Enable ICE media relay.
3472 */
3473 pj_bool_t enable_relay;
Benny Prijono312aff92006-06-17 04:08:30 +00003474};
3475
3476
3477/**
3478 * Use this function to initialize media config.
3479 *
3480 * @param cfg The media config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003481 *
3482 * \par Python:
3483 * \code
3484 media_cfg = py_pjsua.media_config_default()
3485 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003486 */
3487PJ_INLINE(void) pjsua_media_config_default(pjsua_media_config *cfg)
3488{
Benny Prijonoac623b32006-07-03 15:19:31 +00003489 pj_bzero(cfg, sizeof(*cfg));
Benny Prijono312aff92006-06-17 04:08:30 +00003490
Benny Prijono70972992006-08-05 11:13:58 +00003491 cfg->clock_rate = PJSUA_DEFAULT_CLOCK_RATE;
Benny Prijono312aff92006-06-17 04:08:30 +00003492 cfg->max_media_ports = 32;
3493 cfg->has_ioqueue = PJ_TRUE;
3494 cfg->thread_cnt = 1;
Benny Prijono70972992006-08-05 11:13:58 +00003495 cfg->quality = PJSUA_DEFAULT_CODEC_QUALITY;
3496 cfg->ilbc_mode = PJSUA_DEFAULT_ILBC_MODE;
3497 cfg->ec_tail_len = PJSUA_DEFAULT_EC_TAIL_LEN;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003498 cfg->jb_init = cfg->jb_min_pre = cfg->jb_max_pre = cfg->jb_max = -1;
Benny Prijono312aff92006-06-17 04:08:30 +00003499}
3500
3501
3502
3503/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003504 * This structure describes codec information, which can be retrieved by
3505 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00003506 */
3507typedef struct pjsua_codec_info
3508{
3509 /**
3510 * Codec unique identification.
3511 */
3512 pj_str_t codec_id;
3513
3514 /**
3515 * Codec priority (integer 0-255).
3516 */
3517 pj_uint8_t priority;
3518
3519 /**
3520 * Internal buffer.
3521 */
3522 char buf_[32];
3523
3524} pjsua_codec_info;
3525
3526
3527/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003528 * This structure descibes information about a particular media port that
3529 * has been registered into the conference bridge. Application can query
3530 * this info by calling #pjsua_conf_get_port_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003531 *
3532 * \par Python:
3533 * In Python, this type is <tt>py_pjsua.Conf_Port_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003534 */
3535typedef struct pjsua_conf_port_info
3536{
3537 /** Conference port number. */
3538 pjsua_conf_port_id slot_id;
3539
3540 /** Port name. */
3541 pj_str_t name;
3542
3543 /** Clock rate. */
3544 unsigned clock_rate;
3545
3546 /** Number of channels. */
3547 unsigned channel_count;
3548
3549 /** Samples per frame */
3550 unsigned samples_per_frame;
3551
3552 /** Bits per sample */
3553 unsigned bits_per_sample;
3554
3555 /** Number of listeners in the array. */
3556 unsigned listener_cnt;
3557
3558 /** Array of listeners (in other words, ports where this port is
3559 * transmitting to.
3560 */
3561 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
3562
3563} pjsua_conf_port_info;
3564
3565
3566/**
3567 * This structure holds information about custom media transport to
3568 * be registered to pjsua.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003569 *
3570 * \par Python:
3571 * Not applicable.
Benny Prijono312aff92006-06-17 04:08:30 +00003572 */
3573typedef struct pjsua_media_transport
3574{
3575 /**
3576 * Media socket information containing the address information
3577 * of the RTP and RTCP socket.
3578 */
3579 pjmedia_sock_info skinfo;
3580
3581 /**
3582 * The media transport instance.
3583 */
3584 pjmedia_transport *transport;
3585
3586} pjsua_media_transport;
3587
3588
3589
3590
Benny Prijono9fc735d2006-05-28 14:58:12 +00003591/**
3592 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003593 *
3594 * @return Maximum number of ports in the conference bridge.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003595 *
3596 * \par Python:
3597 * \code
3598 port_count = py_pjsua.conf_get_max_ports()
3599 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003600 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003601PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003602
3603
3604/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003605 * Get current number of active ports in the bridge.
3606 *
3607 * @return The number.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003608 *
3609 * \par Python:
3610 * \code
3611 count = py_pjsua.conf_get_active_ports()
3612 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003613 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003614PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
3615
3616
3617/**
3618 * Enumerate all conference ports.
3619 *
3620 * @param id Array of conference port ID to be initialized.
3621 * @param count On input, specifies max elements in the array.
3622 * On return, it contains actual number of elements
3623 * that have been initialized.
3624 *
3625 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003626 *
3627 * \par Python:
3628 * The Python functions returns list of conference port Ids:
3629 * \code
3630 [port_ids] = py_pjsua.enum_conf_ports()
3631 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003632 */
3633PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
3634 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003635
3636
3637/**
3638 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003639 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003640 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003641 * @param info Pointer to store the port info.
3642 *
3643 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003644 *
3645 * \par Python:
3646 * \code
3647 port_info = py_pjsua.conf_get_port_info(port_id)
3648 * \endcode
3649 * The function will return None if \a port_id is not valid.
Benny Prijono8b1889b2006-06-06 18:40:40 +00003650 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003651PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00003652 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003653
3654
3655/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00003656 * Add arbitrary media port to PJSUA's conference bridge. Application
3657 * can use this function to add the media port that it creates. For
3658 * media ports that are created by PJSUA-LIB (such as calls, file player,
3659 * or file recorder), PJSUA-LIB will automatically add the port to
3660 * the bridge.
3661 *
3662 * @param pool Pool to use.
3663 * @param port Media port to be added to the bridge.
3664 * @param p_id Optional pointer to receive the conference
3665 * slot id.
3666 *
3667 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003668 *
3669 * \par Python:
3670 * Not applicable (for now)
Benny Prijonoe909eac2006-07-27 22:04:56 +00003671 */
3672PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
3673 pjmedia_port *port,
3674 pjsua_conf_port_id *p_id);
3675
3676
3677/**
3678 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00003679 * call this function if it registered the port manually with previous call
3680 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00003681 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003682 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00003683 *
3684 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003685 *
3686 * \par Python:
3687 * \code
3688 status = py_pjsua.conf_remove_port(port_id)
3689 * \endcode
Benny Prijonoe909eac2006-07-27 22:04:56 +00003690 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003691PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00003692
3693
3694/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003695 * Establish unidirectional media flow from souce to sink. One source
3696 * may transmit to multiple destinations/sink. And if multiple
3697 * sources are transmitting to the same sink, the media will be mixed
3698 * together. Source and sink may refer to the same ID, effectively
3699 * looping the media.
3700 *
3701 * If bidirectional media flow is desired, application needs to call
3702 * this function twice, with the second one having the arguments
3703 * reversed.
3704 *
3705 * @param source Port ID of the source media/transmitter.
3706 * @param sink Port ID of the destination media/received.
3707 *
3708 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003709 *
3710 * \par Python:
3711 * \code
3712 status = py_pjsua.conf_connect(source, sink)
3713 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003714 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003715PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
3716 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003717
3718
3719/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003720 * Disconnect media flow from the source to destination port.
3721 *
3722 * @param source Port ID of the source media/transmitter.
3723 * @param sink Port ID of the destination media/received.
3724 *
3725 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003726 *
3727 * \par Python:
3728 * \code
3729 status = py_pjsua.conf_disconnect(source, sink)
3730 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003731 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003732PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
3733 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003734
3735
Benny Prijono6dd967c2006-12-26 02:27:14 +00003736/**
3737 * Adjust the signal level to be transmitted from the bridge to the
3738 * specified port by making it louder or quieter.
3739 *
3740 * @param slot The conference bridge slot number.
3741 * @param level Signal level adjustment. Value 1.0 means no level
3742 * adjustment, while value 0 means to mute the port.
3743 *
3744 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003745 *
3746 * \par Python:
3747 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003748 */
3749PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
3750 float level);
3751
3752/**
3753 * Adjust the signal level to be received from the specified port (to
3754 * the bridge) by making it louder or quieter.
3755 *
3756 * @param slot The conference bridge slot number.
3757 * @param level Signal level adjustment. Value 1.0 means no level
3758 * adjustment, while value 0 means to mute the port.
3759 *
3760 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003761 *
3762 * \par Python:
3763 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003764 */
3765PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
3766 float level);
3767
3768/**
3769 * Get last signal level transmitted to or received from the specified port.
3770 * The signal level is an integer value in zero to 255, with zero indicates
3771 * no signal, and 255 indicates the loudest signal level.
3772 *
3773 * @param slot The conference bridge slot number.
3774 * @param tx_level Optional argument to receive the level of signal
3775 * transmitted to the specified port (i.e. the direction
3776 * is from the bridge to the port).
3777 * @param rx_level Optional argument to receive the level of signal
3778 * received from the port (i.e. the direction is from the
3779 * port to the bridge).
3780 *
3781 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003782 *
3783 * \par Python:
3784 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003785 */
3786PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
3787 unsigned *tx_level,
3788 unsigned *rx_level);
3789
Benny Prijono6dd967c2006-12-26 02:27:14 +00003790
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003791/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00003792 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003793 */
3794
Benny Prijono9fc735d2006-05-28 14:58:12 +00003795/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003796 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003797 * the conference bridge.
3798 *
3799 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00003800 * WAV files are supported, and the WAV file MUST be
3801 * formatted as 16bit PCM mono/single channel (any
3802 * clock rate is supported).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003803 * @param options Options (currently zero).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003804 * @param p_id Pointer to receive player ID.
3805 *
3806 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003807 *
3808 * \par Python:
3809 * The function returns (status, id) tuple:
3810 * \code
3811 status, id = py_pjsua.player_create(filename, options)
3812 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003813 */
3814PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003815 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003816 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003817
3818
3819/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003820 * Create a file playlist media port, and automatically add the port
3821 * to the conference bridge.
3822 *
3823 * @param file_names Array of file names to be added to the play list.
3824 * Note that the files must have the same clock rate,
3825 * number of channels, and number of bits per sample.
3826 * @param file_count Number of files in the array.
3827 * @param label Optional label to be set for the media port.
3828 * @param options Optional option flag. Application may specify
3829 * PJMEDIA_FILE_NO_LOOP to prevent looping.
3830 * @param p_id Optional pointer to receive player ID.
3831 *
3832 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003833 *
3834 * \par Python:
3835 * Not implemented yet.
Benny Prijonoa66c3312007-01-21 23:12:40 +00003836 */
3837PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
3838 unsigned file_count,
3839 const pj_str_t *label,
3840 unsigned options,
3841 pjsua_player_id *p_id);
3842
3843/**
3844 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003845 *
3846 * @param id The file player ID.
3847 *
3848 * @return Conference port ID associated with this player.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003849 *
3850 * \par Python:
3851 * \code
3852 port_id = py_pjsua.player_get_conf_port(id)
3853 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003854 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003855PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003856
3857
3858/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003859 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00003860 *
3861 * @param id The player ID.
3862 * @param p_port The media port associated with the player.
3863 *
3864 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003865 *
3866 * \par Python:
3867 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00003868 */
3869PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_recorder_id id,
3870 pjmedia_port **p_port);
3871
3872/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003873 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003874 *
3875 * @param id The file player ID.
3876 * @param samples The playback position, in samples. Application can
3877 * specify zero to re-start the playback.
3878 *
3879 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003880 *
3881 * \par Python:
3882 * \code
3883 status = py_pjsua.player_set_pos(id, samples)
3884 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003885 */
3886PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
3887 pj_uint32_t samples);
3888
3889
3890/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003891 * Close the file of playlist, remove the player from the bridge, and free
3892 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003893 *
3894 * @param id The file player ID.
3895 *
3896 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003897 *
3898 * \par Python:
3899 * \code
3900 status = py_pjsua.player_destroy(id)
3901 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003902 */
3903PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
3904
3905
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003906/*****************************************************************************
3907 * File recorder.
3908 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00003909
3910/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003911 * Create a file recorder, and automatically connect this recorder to
Benny Prijono8f310522006-10-20 11:08:49 +00003912 * the conference bridge. The recorder currently supports recording WAV file,
3913 * and on Windows, MP3 file. The type of the recorder to use is determined
3914 * by the extension of the file (e.g. ".wav" or ".mp3").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003915 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00003916 * @param filename Output file name. The function will determine the
3917 * default format to be used based on the file extension.
3918 * Currently ".wav" is supported on all platforms, and
3919 * also ".mp3" is support on Windows.
Benny Prijono8f310522006-10-20 11:08:49 +00003920 * @param enc_type Optionally specify the type of encoder to be used to
3921 * compress the media, if the file can support different
3922 * encodings. This value must be zero for now.
3923 * @param enc_param Optionally specify codec specific parameter to be
3924 * passed to the file writer. For .MP3 recorder, this
3925 * can point to pjmedia_mp3_encoder_option structure to
3926 * specify additional settings for the .mp3 recorder.
3927 * For .WAV recorder, this value must be NULL.
3928 * @param max_size Maximum file size. Specify zero or -1 to remove size
3929 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003930 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003931 * @param p_id Pointer to receive the recorder instance.
3932 *
3933 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003934 *
3935 * \par Python:
3936 * \code
3937 status, id = py_pjsua.recorder_create(filename, enc_type, enc_param, max_size, options)
3938 * \endcode
3939 * The \a enc_param is a string in Python.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003940 */
3941PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00003942 unsigned enc_type,
3943 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003944 pj_ssize_t max_size,
3945 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003946 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003947
3948
3949/**
3950 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003951 *
3952 * @param id The recorder ID.
3953 *
3954 * @return Conference port ID associated with this recorder.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003955 *
3956 * \par Python:
3957 * \code
3958 port_id = py_pjsua.recorder_get_conf_port(id)
3959 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003960 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003961PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003962
3963
3964/**
Benny Prijono469b1522006-12-26 03:05:17 +00003965 * Get the media port for the recorder.
3966 *
3967 * @param id The recorder ID.
3968 * @param p_port The media port associated with the recorder.
3969 *
3970 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003971 *
3972 * \par Python:
3973 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00003974 */
3975PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
3976 pjmedia_port **p_port);
3977
3978
3979/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003980 * Destroy recorder (this will complete recording).
3981 *
3982 * @param id The recorder ID.
3983 *
3984 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003985 *
3986 * \par Python:
3987 * \code
3988 status = py_pjsua.recorder_destroy(id)
3989 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003990 */
3991PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
3992
3993
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003994/*****************************************************************************
3995 * Sound devices.
3996 */
3997
Benny Prijono9fc735d2006-05-28 14:58:12 +00003998/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003999 * Enum all sound devices installed in the system.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004000 *
4001 * @param info Array of info to be initialized.
4002 * @param count On input, specifies max elements in the array.
4003 * On return, it contains actual number of elements
4004 * that have been initialized.
4005 *
4006 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004007 *
4008 *
4009 * \par Python:
4010 * The function returns list of sound device info:
4011 * \code
4012 [dev_infos] = py_pjsua.enum_snd_devs()
4013 * \endcode
4014 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00004015 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004016PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4017 unsigned *count);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004018
4019
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004020
4021/**
4022 * Get currently active sound devices. If sound devices has not been created
4023 * (for example when pjsua_start() is not called), it is possible that
4024 * the function returns PJ_SUCCESS with -1 as device IDs.
4025 *
4026 * @param capture_dev On return it will be filled with device ID of the
4027 * capture device.
4028 * @param playback_dev On return it will be filled with device ID of the
4029 * device ID of the playback device.
4030 *
4031 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004032 *
4033 * \par Python:
Benny Prijonoebdf8772007-02-01 19:25:50 +00004034 * The function takes no argument and return an (integer,integer) tuple:
Benny Prijonoe6ead542007-01-31 20:53:31 +00004035 * \code
4036 capture_dev, playback_dev = py_pjsua.get_snd_dev()
4037 * \endcode
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004038 */
4039PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4040 int *playback_dev);
4041
4042
Benny Prijono9fc735d2006-05-28 14:58:12 +00004043/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004044 * Select or change sound device. Application may call this function at
4045 * any time to replace current sound device.
4046 *
4047 * @param capture_dev Device ID of the capture device.
4048 * @param playback_dev Device ID of the playback device.
4049 *
4050 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004051 *
4052 * \par Python:
4053 * \code
4054 status = py_pjsua.set_snd_dev(capture_dev, playback_dev)
4055 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004056 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004057PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4058 int playback_dev);
4059
4060
4061/**
4062 * Set pjsua to use null sound device. The null sound device only provides
4063 * the timing needed by the conference bridge, and will not interract with
4064 * any hardware.
4065 *
4066 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004067 *
4068 * \par Python:
4069 * \code
4070 status = py_pjsua.set_null_snd_dev()
4071 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004072 */
4073PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4074
4075
Benny Prijonoe909eac2006-07-27 22:04:56 +00004076/**
4077 * Disconnect the main conference bridge from any sound devices, and let
4078 * application connect the bridge to it's own sound device/master port.
4079 *
4080 * @return The port interface of the conference bridge,
4081 * so that application can connect this to it's own
4082 * sound device or master port.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004083 *
4084 * \par Python:
4085 * Not applicable (for now).
Benny Prijonoe909eac2006-07-27 22:04:56 +00004086 */
4087PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4088
4089
Benny Prijonof20687a2006-08-04 18:27:19 +00004090/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004091 * Configure the echo canceller tail length of the sound port.
Benny Prijonof20687a2006-08-04 18:27:19 +00004092 *
4093 * @param tail_ms The tail length, in miliseconds. Set to zero to
4094 * disable AEC.
Benny Prijono5da50432006-08-07 10:24:52 +00004095 * @param options Options to be passed to #pjmedia_echo_create().
4096 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004097 *
4098 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004099 *
4100 * \par Python:
4101 * \code
4102 status = py_pjsua.set_ec(tail_ms, options)
4103 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004104 */
Benny Prijono5da50432006-08-07 10:24:52 +00004105PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004106
4107
4108/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004109 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004110 *
4111 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4112 * If AEC is disabled, the value will be zero.
4113 *
4114 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004115 *
4116 * \par Python:
4117 * \code
4118 tail_ms = py_pjsua.get_ec_tail()
4119 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004120 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004121PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004122
4123
4124
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004125/*****************************************************************************
4126 * Codecs.
4127 */
4128
4129/**
4130 * Enum all supported codecs in the system.
4131 *
4132 * @param id Array of ID to be initialized.
4133 * @param count On input, specifies max elements in the array.
4134 * On return, it contains actual number of elements
4135 * that have been initialized.
4136 *
4137 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004138 *
4139 * \par Python:
4140 * This function takes no argument and returns list of codec infos:
4141 * \code
4142 [codec_info] = py_pjsua.enum_codecs()
4143 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004144 */
4145PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4146 unsigned *count );
4147
4148
4149/**
4150 * Change codec priority.
4151 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004152 * @param codec_id Codec ID, which is a string that uniquely identify
4153 * the codec (such as "speex/8000"). Please see pjsua
4154 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004155 * @param priority Codec priority, 0-255, where zero means to disable
4156 * the codec.
4157 *
4158 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004159 *
4160 * \par Python:
4161 * \code
4162 status = py_pjsua.codec_set_priority(codec_id, priority)
4163 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004164 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004165PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004166 pj_uint8_t priority );
4167
4168
4169/**
4170 * Get codec parameters.
4171 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004172 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004173 * @param param Structure to receive codec parameters.
4174 *
4175 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004176 *
4177 * \par Python:
4178 * The Python function is experimental:
4179 * \code
4180 codec_param = py_pjsua.codec_get_param(codec_id)
4181 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004182 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004183PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004184 pjmedia_codec_param *param );
4185
4186
4187/**
4188 * Set codec parameters.
4189 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004190 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004191 * @param param Codec parameter to set.
4192 *
4193 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004194 *
4195 * \par Python:
4196 * The Python function is experimental:
4197 * \code
4198 status = py_pjsua.codec_set_param(codec_id, param)
4199 * \endcode
4200
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004201 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004202PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004203 const pjmedia_codec_param *param);
4204
4205
4206
Benny Prijono9fc735d2006-05-28 14:58:12 +00004207
Benny Prijono312aff92006-06-17 04:08:30 +00004208/**
4209 * Create UDP media transports for all the calls. This function creates
4210 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00004211 *
Benny Prijono312aff92006-06-17 04:08:30 +00004212 * @param cfg Media transport configuration. The "port" field in the
4213 * configuration is used as the start port to bind the
4214 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004215 *
4216 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004217 *
4218 * \par Python:
4219 * Not implemented yet.
Benny Prijonof3195072006-02-14 21:15:30 +00004220 */
Benny Prijono312aff92006-06-17 04:08:30 +00004221PJ_DECL(pj_status_t)
4222pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00004223
Benny Prijonodc39fe82006-05-26 12:17:46 +00004224
4225/**
Benny Prijono312aff92006-06-17 04:08:30 +00004226 * Register custom media transports to be used by calls. There must
4227 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004228 *
Benny Prijono312aff92006-06-17 04:08:30 +00004229 * @param tp The media transport array.
4230 * @param count Number of elements in the array. This number MUST
4231 * match the number of maximum calls configured when
4232 * pjsua is created.
4233 * @param auto_delete Flag to indicate whether the transports should be
4234 * destroyed when pjsua is shutdown.
4235 *
4236 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004237 *
4238 * \par Python:
4239 * Note applicable.
Benny Prijonodc39fe82006-05-26 12:17:46 +00004240 */
Benny Prijono312aff92006-06-17 04:08:30 +00004241PJ_DECL(pj_status_t)
4242pjsua_media_transports_attach( pjsua_media_transport tp[],
4243 unsigned count,
4244 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00004245
4246
Benny Prijono312aff92006-06-17 04:08:30 +00004247/**
4248 * @}
4249 */
4250
Benny Prijonof3195072006-02-14 21:15:30 +00004251
Benny Prijono268ca612006-02-07 12:34:11 +00004252
Benny Prijono312aff92006-06-17 04:08:30 +00004253/**
4254 * @}
4255 */
4256
Benny Prijonoe6ead542007-01-31 20:53:31 +00004257PJ_END_DECL
4258
Benny Prijono312aff92006-06-17 04:08:30 +00004259
Benny Prijono268ca612006-02-07 12:34:11 +00004260#endif /* __PJSUA_H__ */