blob: fcd0549ac145408d5949abfce92dc0e7f996c3f7 [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 /**
906 * Specify STUN server. This server will be first resolved with DNS SRV
907 * to get the actual server address. If DNS SRV resolution failed, or
908 * when nameserver is not configured, the server will be resolved using
909 * DNS A resolution (i.e. gethostbyname()).
910 */
911 pj_str_t stun_srv;
912
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000913 /**
914 * Number of credentials in the credential array.
915 */
916 unsigned cred_count;
917
918 /**
919 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +0000920 * and can be used to authenticate against outbound proxies. If the
921 * credential is specific to the account, then application should set
922 * the credential in the pjsua_acc_config rather than the credential
923 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000924 */
925 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
926
927 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000928 * Application callback to receive various event notifications from
929 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000930 */
931 pjsua_callback cb;
932
Benny Prijono56315612006-07-18 14:39:40 +0000933 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000934 * Optional user agent string (default empty). If it's empty, no
935 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +0000936 */
937 pj_str_t user_agent;
938
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000939} pjsua_config;
940
941
942/**
943 * Use this function to initialize pjsua config.
944 *
945 * @param cfg pjsua config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000946 *
947 * \par Python Sample Syntax:
948 * The corresponding Python function creates an instance of the config and
949 * initializes it to the default settings:
950 * \code
951 cfg = py_pjsua.config_default()
952 * \endcode
953
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000954 */
955PJ_INLINE(void) pjsua_config_default(pjsua_config *cfg)
956{
Benny Prijonoac623b32006-07-03 15:19:31 +0000957 pj_bzero(cfg, sizeof(*cfg));
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000958
959 cfg->max_calls = 4;
960 cfg->thread_cnt = 1;
961}
962
963
964/**
965 * Duplicate credential.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000966 *
967 * @param pool The memory pool.
968 * @param dst Destination credential.
969 * @param src Source credential.
970 *
971 * \par Python:
972 * Not applicable (for now). Probably we could just assign one credential
973 * variable to another, but this has not been tested.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000974 */
975PJ_INLINE(void) pjsip_cred_dup( pj_pool_t *pool,
976 pjsip_cred_info *dst,
977 const pjsip_cred_info *src)
978{
979 pj_strdup_with_null(pool, &dst->realm, &src->realm);
980 pj_strdup_with_null(pool, &dst->scheme, &src->scheme);
981 pj_strdup_with_null(pool, &dst->username, &src->username);
982 pj_strdup_with_null(pool, &dst->data, &src->data);
983
984}
985
986
987/**
988 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000989 *
990 * @param pool The pool to get memory from.
991 * @param dst Destination config.
992 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000993 */
994PJ_INLINE(void) pjsua_config_dup(pj_pool_t *pool,
995 pjsua_config *dst,
996 const pjsua_config *src)
997{
998 unsigned i;
999
1000 pj_memcpy(dst, src, sizeof(*src));
1001
1002 for (i=0; i<src->outbound_proxy_cnt; ++i) {
1003 pj_strdup_with_null(pool, &dst->outbound_proxy[i],
1004 &src->outbound_proxy[i]);
1005 }
1006
1007 for (i=0; i<src->cred_count; ++i) {
1008 pjsip_cred_dup(pool, &dst->cred_info[i], &src->cred_info[i]);
1009 }
Benny Prijono56315612006-07-18 14:39:40 +00001010
1011 pj_strdup_with_null(pool, &dst->user_agent, &src->user_agent);
Benny Prijonoc97608e2007-03-23 16:34:20 +00001012 pj_strdup_with_null(pool, &dst->stun_srv, &src->stun_srv);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001013}
1014
1015
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001016
1017/**
1018 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001019 * outgoing SIP message. It can (optionally) be specified for example
1020 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1021 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1022 *
1023 * Application MUST call #pjsua_msg_data_init() to initialize this
1024 * structure before setting its values.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001025 *
1026 * \par Python Syntax
1027 * The data type in Python is <tt>py_pjsua.Msg_Data</tt>. Application is
1028 * recommended to instantiate the structure by using this construct:
1029 * \code
1030 msg_data = py_pjsua.msg_data_init()
1031 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001032 */
1033typedef struct pjsua_msg_data
1034{
1035 /**
1036 * Additional message headers as linked list.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001037 *
1038 * \par Python:
1039 * This field is implemented as string linked-list in Python, where each
1040 * string describes the header. For example:
1041 \code
1042 msg_data = py_pjsua.Msg_Data()
1043 msg_data.hdr_list = ["Subject: Hello py_pjsua!", "Priority: very low"]
1044 \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001045 */
1046 pjsip_hdr hdr_list;
1047
1048 /**
1049 * MIME type of optional message body.
1050 */
1051 pj_str_t content_type;
1052
1053 /**
1054 * Optional message body.
1055 */
1056 pj_str_t msg_body;
1057
1058} pjsua_msg_data;
1059
1060
1061/**
1062 * Initialize message data.
1063 *
1064 * @param msg_data Message data to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001065 *
1066 * \par Python
1067 * The corresponding Python function creates and initializes the structure:
1068 * \code
1069 msg_data = py_pjsua.msg_data_init()
1070 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001071 */
1072PJ_INLINE(void) pjsua_msg_data_init(pjsua_msg_data *msg_data)
1073{
Benny Prijonoac623b32006-07-03 15:19:31 +00001074 pj_bzero(msg_data, sizeof(*msg_data));
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001075 pj_list_init(&msg_data->hdr_list);
1076}
Benny Prijono8b1889b2006-06-06 18:40:40 +00001077
Benny Prijono268ca612006-02-07 12:34:11 +00001078
Benny Prijono268ca612006-02-07 12:34:11 +00001079
1080/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001081 * Instantiate pjsua application. Application must call this function before
1082 * calling any other functions, to make sure that the underlying libraries
1083 * are properly initialized. Once this function has returned success,
1084 * application must call pjsua_destroy() before quitting.
1085 *
1086 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001087 *
1088 * \par Python:
1089 * \code
1090 status = py_pjsua.create()
1091 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001092 */
1093PJ_DECL(pj_status_t) pjsua_create(void);
1094
1095
Benny Prijonoe6ead542007-01-31 20:53:31 +00001096/* Forward declaration */
1097typedef struct pjsua_media_config pjsua_media_config;
1098
1099
Benny Prijonodc39fe82006-05-26 12:17:46 +00001100/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001101 * Initialize pjsua with the specified settings. All the settings are
1102 * optional, and the default values will be used when the config is not
1103 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001104 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001105 * Note that #pjsua_create() MUST be called before calling this function.
1106 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001107 * @param ua_cfg User agent configuration.
1108 * @param log_cfg Optional logging configuration.
1109 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001110 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001111 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001112 *
1113 * \par Python:
1114 * The function is similar in Python:
1115 * \code
1116 status = py_pjsua.init(ua_cfg, log_cfg, media_cfg)
1117 * \endcode
1118 * Note that \a ua_cfg, \a log_cfg, and \a media_cfg are optional, and
1119 * the Python script may pass None if it doesn't want to configure the
1120 * setting.
Benny Prijono268ca612006-02-07 12:34:11 +00001121 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001122PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1123 const pjsua_logging_config *log_cfg,
1124 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001125
1126
1127/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001128 * Application is recommended to call this function after all initialization
1129 * is done, so that the library can do additional checking set up
1130 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001131 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001132 * Application may call this function anytime after #pjsua_init().
1133 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001134 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001135 *
1136 * \par Python:
1137 * The function is similar in Python:
1138 * \code
1139 status = py_pjsua.start()
1140 * \endcode
Benny Prijonoccf95622006-02-07 18:48:01 +00001141 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001142PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001143
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001144
Benny Prijonoccf95622006-02-07 18:48:01 +00001145/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001146 * Destroy pjsua. Application is recommended to perform graceful shutdown
1147 * before calling this function (such as unregister the account from the SIP
1148 * server, terminate presense subscription, and hangup active calls), however,
1149 * this function will do all of these if it finds there are active sessions
1150 * that need to be terminated. This function will approximately block for
1151 * one second to wait for replies from remote.
1152 *
1153 * Application.may safely call this function more than once if it doesn't
1154 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001155 *
1156 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001157 *
1158 * \par Python:
1159 * The function is similar in Python:
1160 * \code
1161 status = py_pjsua.destroy()
1162 * \endcode
Benny Prijono268ca612006-02-07 12:34:11 +00001163 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001164PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001165
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001166
Benny Prijono9fc735d2006-05-28 14:58:12 +00001167/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001168 * Poll pjsua for events, and if necessary block the caller thread for
1169 * the specified maximum interval (in miliseconds).
1170 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001171 * Application doesn't normally need to call this function if it has
1172 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1173 * because polling then will be done by these worker threads instead.
1174 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001175 * @param msec_timeout Maximum time to wait, in miliseconds.
1176 *
1177 * @return The number of events that have been handled during the
1178 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001179 * can retrieve the error as (status = -return_value).
1180 *
1181 * \par Python:
1182 * The function is similar in Python:
1183 * \code
1184 n = py_pjsua.handle_events(msec_timeout)
1185 * \endcode
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001186 */
1187PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1188
1189
1190/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001191 * Create memory pool to be used by the application. Once application
1192 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001193 *
1194 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001195 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001196 * @param increment Increment size.
1197 *
1198 * @return The pool, or NULL when there's no memory.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001199 *
1200 * \par Python:
1201 * Python script may also create a pool object from the script:
1202 * \code
1203 pool = py_pjsua.pool_create(name, init_size, increment)
1204 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001205 */
1206PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1207 pj_size_t increment);
1208
1209
1210/**
1211 * Application can call this function at any time (after pjsua_create(), of
1212 * course) to change logging settings.
1213 *
1214 * @param c Logging configuration.
1215 *
1216 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001217 *
1218 * \par Python:
1219 * The function is similar in Python:
1220 * \code
1221 status = py_pjsua.reconfigure_logging(log_cfg)
1222 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001223 */
1224PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1225
1226
1227/**
1228 * Internal function to get SIP endpoint instance of pjsua, which is
1229 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001230 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001231 *
1232 * @return SIP endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001233 *
1234 * \par Python:
1235 * Application may retrieve the SIP endpoint instance:
1236 * \code
1237 endpt = py_pjsua.get_pjsip_endpt()
1238 * \endcode
1239 * However currently the object is just an opaque object and does not have
1240 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001241 */
1242PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1243
1244/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001245 * Internal function to get media endpoint instance.
1246 * Only valid after #pjsua_init() is called.
1247 *
1248 * @return Media endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001249 *
1250 * \par Python:
1251 * Application may retrieve the media endpoint instance:
1252 * \code
1253 endpt = py_pjsua.get_pjmedia_endpt()
1254 * \endcode
1255 * However currently the object is just an opaque object and does not have
1256 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001257 */
1258PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1259
Benny Prijono97b87172006-08-24 14:25:14 +00001260/**
1261 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001262 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001263 *
1264 * @return Pool factory currently used by PJSUA.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001265 *
1266 * \par Python:
1267 * Application may retrieve the pool factory instance:
1268 * \code
1269 endpt = py_pjsua.get_pool_factory()
1270 * \endcode
1271 * However currently the object is just an opaque object and does not have
1272 * any use for Python scripts.
Benny Prijono97b87172006-08-24 14:25:14 +00001273 */
1274PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1275
1276
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001277
1278/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001279 * Utilities.
1280 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001281 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001282
1283/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001284 * This is a utility function to verify that valid SIP url is given. If the
1285 * URL is valid, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001286 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001287 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001288 *
1289 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001290 *
1291 * \par Python:
1292 * \code
1293 status = py_pjsua.verify_sip_url(url)
1294 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001295 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001296PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001297
1298
1299/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001300 * This is a utility function to display error message for the specified
1301 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001302 *
1303 * @param sender The log sender field.
1304 * @param title Message title for the error.
1305 * @param status Status code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001306 *
1307 * \par Python:
1308 * \code
1309 py_pjsua.perror(sender, title, status)
1310 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001311 */
1312PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1313 pj_status_t status);
1314
1315
1316
1317
1318/**
1319 * @}
1320 */
1321
1322
1323
1324/*****************************************************************************
1325 * TRANSPORT API
1326 */
1327
1328/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001329 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001330 * @ingroup PJSUA_LIB
1331 * @brief API for managing SIP transports
1332 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001333 *
1334 * PJSUA-API supports creating multiple transport instances, for example UDP,
1335 * TCP, and TLS transport. SIP transport must be created before adding an
1336 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001337 */
1338
1339
Benny Prijonoe6ead542007-01-31 20:53:31 +00001340/** SIP transport identification.
1341 */
Benny Prijono312aff92006-06-17 04:08:30 +00001342typedef int pjsua_transport_id;
1343
1344
1345/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001346 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001347 * and media. Before setting some values to this structure, application
1348 * MUST call #pjsua_transport_config_default() to initialize its
1349 * values with default settings.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001350 *
1351 * \par Python:
1352 * The data type in Python is <tt>py_pjsua.Transport_Config</tt>,
1353 * although application can just do this to create the instance:
1354 * \code
1355 transport_cfg = py_pjsua.transport_config_default()
1356 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001357 */
1358typedef struct pjsua_transport_config
1359{
1360 /**
1361 * UDP port number to bind locally. This setting MUST be specified
1362 * even when default port is desired. If the value is zero, the
1363 * transport will be bound to any available port, and application
1364 * can query the port by querying the transport info.
1365 */
1366 unsigned port;
1367
1368 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001369 * Optional address to advertise as the address of this transport.
1370 * Application can specify any address or hostname for this field,
1371 * for example it can point to one of the interface address in the
1372 * system, or it can point to the public address of a NAT router
1373 * where port mappings have been configured for the application.
1374 *
1375 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001376 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001377 pj_str_t public_addr;
1378
1379 /**
1380 * Optional address where the socket should be bound to. This option
1381 * SHOULD only be used to selectively bind the socket to particular
1382 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1383 * published address of a transport (the public_addr field should be
1384 * used for that purpose).
1385 *
1386 * Note that unlike public_addr field, the address (or hostname) here
1387 * MUST correspond to the actual interface address in the host, since
1388 * this address will be specified as bind() argument.
1389 */
1390 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001391
1392 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001393 * This specifies TLS settings for TLS transport. It is only be used
1394 * when this transport config is being used to create a SIP TLS
1395 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001396 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001397 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001398
Benny Prijono312aff92006-06-17 04:08:30 +00001399} pjsua_transport_config;
1400
1401
1402/**
1403 * Call this function to initialize UDP config with default values.
1404 *
1405 * @param cfg The UDP config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001406 *
1407 * \par Python:
1408 * The corresponding Python function is rather different:
1409 * \code
1410 transport_cfg = py_pjsua.transport_config_default()
1411 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001412 */
1413PJ_INLINE(void) pjsua_transport_config_default(pjsua_transport_config *cfg)
1414{
Benny Prijonoac623b32006-07-03 15:19:31 +00001415 pj_bzero(cfg, sizeof(*cfg));
Benny Prijonof3bbc132006-12-25 06:43:59 +00001416 pjsip_tls_setting_default(&cfg->tls_setting);
Benny Prijono312aff92006-06-17 04:08:30 +00001417}
1418
1419
1420/**
Benny Prijono312aff92006-06-17 04:08:30 +00001421 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001422 *
1423 * @param pool The pool.
1424 * @param dst The destination config.
1425 * @param src The source config.
1426 *
1427 * \par Python:
1428 * Not applicable. One should be able to just copy one variable instance
1429 * to another in Python.
Benny Prijono312aff92006-06-17 04:08:30 +00001430 */
1431PJ_INLINE(void) pjsua_transport_config_dup(pj_pool_t *pool,
1432 pjsua_transport_config *dst,
1433 const pjsua_transport_config *src)
1434{
Benny Prijonoc97608e2007-03-23 16:34:20 +00001435 PJ_UNUSED_ARG(pool);
Benny Prijono312aff92006-06-17 04:08:30 +00001436 pj_memcpy(dst, src, sizeof(*src));
Benny Prijono312aff92006-06-17 04:08:30 +00001437}
1438
1439
1440
1441/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001442 * This structure describes transport information returned by
1443 * #pjsua_transport_get_info() function.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001444 *
1445 * \par Python:
1446 * The corresponding data type in Python is <tt>py_pjsua.Transport_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001447 */
1448typedef struct pjsua_transport_info
1449{
1450 /**
1451 * PJSUA transport identification.
1452 */
1453 pjsua_transport_id id;
1454
1455 /**
1456 * Transport type.
1457 */
1458 pjsip_transport_type_e type;
1459
1460 /**
1461 * Transport type name.
1462 */
1463 pj_str_t type_name;
1464
1465 /**
1466 * Transport string info/description.
1467 */
1468 pj_str_t info;
1469
1470 /**
1471 * Transport flag (see ##pjsip_transport_flags_e).
1472 */
1473 unsigned flag;
1474
1475 /**
1476 * Local address length.
1477 */
1478 unsigned addr_len;
1479
1480 /**
1481 * Local/bound address.
1482 */
1483 pj_sockaddr local_addr;
1484
1485 /**
1486 * Published address (or transport address name).
1487 */
1488 pjsip_host_port local_name;
1489
1490 /**
1491 * Current number of objects currently referencing this transport.
1492 */
1493 unsigned usage_count;
1494
1495
1496} pjsua_transport_info;
1497
1498
1499/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001500 * Create and start a new SIP transport according to the specified
1501 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001502 *
1503 * @param type Transport type.
1504 * @param cfg Transport configuration.
1505 * @param p_id Optional pointer to receive transport ID.
1506 *
1507 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001508 *
1509 * \par Python:
1510 * The corresponding Python function returns (status,id) tuple:
1511 * \code
1512 status, transport_id = py_pjsua.transport_create(type, cfg)
1513 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001514 */
1515PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1516 const pjsua_transport_config *cfg,
1517 pjsua_transport_id *p_id);
1518
1519/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001520 * Register transport that has been created by application. This function
1521 * is useful if application wants to implement custom SIP transport and use
1522 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001523 *
1524 * @param tp Transport instance.
1525 * @param p_id Optional pointer to receive transport ID.
1526 *
1527 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001528 *
1529 * \par Python:
1530 * Not applicable (for now), because one cannot create a custom transport
1531 * from Python script.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001532 */
1533PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1534 pjsua_transport_id *p_id);
1535
1536
1537/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001538 * Enumerate all transports currently created in the system. This function
1539 * will return all transport IDs, and application may then call
1540 * #pjsua_transport_get_info() function to retrieve detailed information
1541 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001542 *
1543 * @param id Array to receive transport ids.
1544 * @param count In input, specifies the maximum number of elements.
1545 * On return, it contains the actual number of elements.
1546 *
1547 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001548 *
1549 * \par Python:
1550 * The function returns list of integers representing transport ids:
1551 * \code
1552 [int] = py_pjsua.enum_transports()
1553 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001554 */
1555PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1556 unsigned *count );
1557
1558
1559/**
1560 * Get information about transports.
1561 *
1562 * @param id Transport ID.
1563 * @param info Pointer to receive transport info.
1564 *
1565 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001566 *
1567 * \par Python:
1568 * \code
1569 transport_info = py_pjsua.transport_get_info(id)
1570 * \endcode
1571 * The Python function returns None on error.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001572 */
1573PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1574 pjsua_transport_info *info);
1575
1576
1577/**
1578 * Disable a transport or re-enable it. By default transport is always
1579 * enabled after it is created. Disabling a transport does not necessarily
1580 * close the socket, it will only discard incoming messages and prevent
1581 * the transport from being used to send outgoing messages.
1582 *
1583 * @param id Transport ID.
1584 * @param enabled Non-zero to enable, zero to disable.
1585 *
1586 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001587 *
1588 * \par Python:
1589 * \code
1590 status = py_pjsua.transport_set_enable(id, enabled)
1591 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001592 */
1593PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1594 pj_bool_t enabled);
1595
1596
1597/**
1598 * Close the transport. If transport is forcefully closed, it will be
1599 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00001600 * transport may not terminate properly (it may even crash). Otherwise,
1601 * the system will wait until all transactions are closed while preventing
1602 * new users from using the transport, and will close the transport when
1603 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001604 *
1605 * @param id Transport ID.
1606 * @param force Non-zero to immediately close the transport. This
1607 * is not recommended!
1608 *
1609 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001610 *
1611 * \par Python:
1612 * \code
1613 status = py_pjsua.transport_close(id, force)
1614 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001615 */
1616PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1617 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001618
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001619/**
Benny Prijono312aff92006-06-17 04:08:30 +00001620 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001621 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001622
1623
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001624
1625
1626/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001627 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001628 */
1629
Benny Prijono312aff92006-06-17 04:08:30 +00001630
1631/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001632 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001633 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001634 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001635 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001636 *
Benny Prijono312aff92006-06-17 04:08:30 +00001637 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001638 * using the application. In SIP terms, the identity is used as the <b>From</b>
1639 * header in outgoing requests.
1640 *
1641 * PJSUA-API supports creating and managing multiple accounts. The maximum
1642 * number of accounts is limited by a compile time constant
1643 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001644 *
1645 * Account may or may not have client registration associated with it.
1646 * An account is also associated with <b>route set</b> and some <b>authentication
1647 * credentials</b>, which are used when sending SIP request messages using the
1648 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00001649 * will be reported to remote peer when they subscribe to the account's
1650 * presence, or which is published to a presence server if presence
1651 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00001652 *
1653 * At least one account MUST be created in the application. If no user
1654 * association is required, application can create a userless account by
1655 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00001656 * instead of a particular user, and it correspond with a particular
1657 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00001658 *
1659 * Also one account must be set as the <b>default account</b>, which is used as
1660 * the account to use when PJSUA fails to match a request with any other
1661 * accounts.
1662 *
1663 * When sending outgoing SIP requests (such as making calls or sending
1664 * instant messages), normally PJSUA requires the application to specify
1665 * which account to use for the request. If no account is specified,
1666 * PJSUA may be able to select the account by matching the destination
1667 * domain name, and fall back to default account when no match is found.
1668 */
1669
1670/**
1671 * Maximum accounts.
1672 */
1673#ifndef PJSUA_MAX_ACC
1674# define PJSUA_MAX_ACC 8
1675#endif
1676
1677
1678/**
1679 * Default registration interval.
1680 */
1681#ifndef PJSUA_REG_INTERVAL
1682# define PJSUA_REG_INTERVAL 55
1683#endif
1684
1685
1686/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001687 * Default PUBLISH expiration
1688 */
1689#ifndef PJSUA_PUBLISH_EXPIRATION
1690# define PJSUA_PUBLISH_EXPIRATION 600
1691#endif
1692
1693
1694/**
Benny Prijono093d3022006-09-24 00:07:11 +00001695 * Default account priority.
1696 */
1697#ifndef PJSUA_DEFAULT_ACC_PRIORITY
1698# define PJSUA_DEFAULT_ACC_PRIORITY 0
1699#endif
1700
1701
1702/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001703 * This structure describes account configuration to be specified when
1704 * adding a new account with #pjsua_acc_add(). Application MUST initialize
1705 * this structure first by calling #pjsua_acc_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00001706 *
1707 * \par Python:
1708 * The data type in Python is <tt>py_pjsua.Acc_Config</tt>, but normally
1709 * application can just use the snippet below to create and initialize
1710 * the account config:
1711 * \code
1712 acc_cfg = py_pjsua.acc_config_default()
1713 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001714 */
1715typedef struct pjsua_acc_config
1716{
Benny Prijono093d3022006-09-24 00:07:11 +00001717 /**
1718 * Account priority, which is used to control the order of matching
1719 * incoming/outgoing requests. The higher the number means the higher
1720 * the priority is, and the account will be matched first.
1721 */
1722 int priority;
1723
Benny Prijono312aff92006-06-17 04:08:30 +00001724 /**
1725 * The full SIP URL for the account. The value can take name address or
1726 * URL format, and will look something like "sip:account@serviceprovider".
1727 *
1728 * This field is mandatory.
1729 */
1730 pj_str_t id;
1731
1732 /**
1733 * This is the URL to be put in the request URI for the registration,
1734 * and will look something like "sip:serviceprovider".
1735 *
1736 * This field should be specified if registration is desired. If the
1737 * value is empty, no account registration will be performed.
1738 */
1739 pj_str_t reg_uri;
1740
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001741 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001742 * If this flag is set, the presence information of this account will
1743 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001744 */
1745 pj_bool_t publish_enabled;
1746
Benny Prijono312aff92006-06-17 04:08:30 +00001747 /**
1748 * Optional URI to be put as Contact for this account. It is recommended
1749 * that this field is left empty, so that the value will be calculated
1750 * automatically based on the transport address.
1751 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00001752 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00001753
1754 /**
1755 * Number of proxies in the proxy array below.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001756 *
1757 * \par Python:
1758 * Not applicable, as \a proxy is implemented as list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001759 */
1760 unsigned proxy_cnt;
1761
1762 /**
1763 * Optional URI of the proxies to be visited for all outgoing requests
1764 * that are using this account (REGISTER, INVITE, etc). Application need
1765 * to specify these proxies if the service provider requires that requests
1766 * destined towards its network should go through certain proxies first
1767 * (for example, border controllers).
1768 *
1769 * These proxies will be put in the route set for this account, with
1770 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00001771 * first). If global outbound proxies are configured in pjsua_config,
1772 * then these account proxies will be placed after the global outbound
1773 * proxies in the routeset.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001774 *
1775 * \par Python:
1776 * This will be list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001777 */
1778 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
1779
1780 /**
1781 * Optional interval for registration, in seconds. If the value is zero,
1782 * default interval will be used (PJSUA_REG_INTERVAL, 55 seconds).
1783 */
1784 unsigned reg_timeout;
1785
1786 /**
1787 * Number of credentials in the credential array.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001788 *
1789 * \par Python:
1790 * Not applicable, since \a cred_info is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00001791 */
1792 unsigned cred_count;
1793
1794 /**
1795 * Array of credentials. If registration is desired, normally there should
1796 * be at least one credential specified, to successfully authenticate
1797 * against the service provider. More credentials can be specified, for
1798 * example when the requests are expected to be challenged by the
1799 * proxies in the route set.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001800 *
1801 * \par Python:
1802 * This field is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00001803 */
1804 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1805
Benny Prijono62c5c5b2007-01-13 23:22:40 +00001806 /**
1807 * Optionally bind this account to specific transport. This normally is
1808 * not a good idea, as account should be able to send requests using
1809 * any available transports according to the destination. But some
1810 * application may want to have explicit control over the transport to
1811 * use, so in that case it can set this field.
1812 *
1813 * Default: -1 (PJSUA_INVALID_ID)
1814 *
1815 * @see pjsua_acc_set_transport()
1816 */
1817 pjsua_transport_id transport_id;
1818
Benny Prijono312aff92006-06-17 04:08:30 +00001819} pjsua_acc_config;
1820
1821
1822/**
1823 * Call this function to initialize account config with default values.
1824 *
1825 * @param cfg The account config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001826 *
1827 * \par Python:
1828 * In Python, this function both creates and initializes the account
1829 * config:
1830 * \code
1831 acc_cfg = py_pjsua.acc_config_default()
1832 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001833 */
1834PJ_INLINE(void) pjsua_acc_config_default(pjsua_acc_config *cfg)
1835{
Benny Prijonoac623b32006-07-03 15:19:31 +00001836 pj_bzero(cfg, sizeof(*cfg));
Benny Prijono312aff92006-06-17 04:08:30 +00001837
1838 cfg->reg_timeout = PJSUA_REG_INTERVAL;
Benny Prijono62c5c5b2007-01-13 23:22:40 +00001839 cfg->transport_id = PJSUA_INVALID_ID;
Benny Prijono312aff92006-06-17 04:08:30 +00001840}
1841
1842
1843
1844/**
1845 * Account info. Application can query account info by calling
1846 * #pjsua_acc_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00001847 *
1848 * \par Python:
1849 * The data type in Python is <tt>py_pjsua.Acc_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001850 */
1851typedef struct pjsua_acc_info
1852{
1853 /**
1854 * The account ID.
1855 */
1856 pjsua_acc_id id;
1857
1858 /**
1859 * Flag to indicate whether this is the default account.
1860 */
1861 pj_bool_t is_default;
1862
1863 /**
1864 * Account URI
1865 */
1866 pj_str_t acc_uri;
1867
1868 /**
1869 * Flag to tell whether this account has registration setting
1870 * (reg_uri is not empty).
1871 */
1872 pj_bool_t has_registration;
1873
1874 /**
1875 * An up to date expiration interval for account registration session.
1876 */
1877 int expires;
1878
1879 /**
1880 * Last registration status code. If status code is zero, the account
1881 * is currently not registered. Any other value indicates the SIP
1882 * status code of the registration.
1883 */
1884 pjsip_status_code status;
1885
1886 /**
1887 * String describing the registration status.
1888 */
1889 pj_str_t status_text;
1890
1891 /**
1892 * Presence online status for this account.
1893 */
1894 pj_bool_t online_status;
1895
1896 /**
1897 * Buffer that is used internally to store the status text.
1898 */
1899 char buf_[PJ_ERR_MSG_SIZE];
1900
1901} pjsua_acc_info;
1902
1903
1904
1905/**
1906 * Get number of current accounts.
1907 *
1908 * @return Current number of accounts.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001909 *
1910 * \par Python:
1911 * \code
1912 count = py_pjsua.acc_get_count()
1913 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001914 */
1915PJ_DECL(unsigned) pjsua_acc_get_count(void);
1916
1917
1918/**
1919 * Check if the specified account ID is valid.
1920 *
1921 * @param acc_id Account ID to check.
1922 *
1923 * @return Non-zero if account ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001924 *
1925 * \par Python:
1926 * \code
1927 is_valid = py_pjsua.acc_is_valid(acc_id)
1928 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001929 */
1930PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
1931
1932
1933/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00001934 * Set default account to be used when incoming and outgoing
1935 * requests doesn't match any accounts.
1936 *
1937 * @param acc_id The account ID to be used as default.
1938 *
1939 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001940 *
1941 * \par Python:
1942 * \code
1943 status = py_pjsua.acc_set_default(acc_id)
1944 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00001945 */
1946PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
1947
1948
1949/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001950 * Get default account to be used when receiving incoming requests (calls),
1951 * when the destination of the incoming call doesn't match any other
1952 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00001953 *
1954 * @return The default account ID, or PJSUA_INVALID_ID if no
1955 * default account is configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001956 *
1957 * \par Python:
1958 * \code
1959 acc_id = py_pjsua.acc_get_default()
1960 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00001961 */
1962PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
1963
1964
1965/**
Benny Prijono312aff92006-06-17 04:08:30 +00001966 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001967 * #pjsua_init()) before calling this function. If registration is configured
1968 * for this account, this function would also start the SIP registration
1969 * session with the SIP registrar server. This SIP registration session
1970 * will be maintained internally by the library, and application doesn't
1971 * need to do anything to maintain the registration session.
1972 *
Benny Prijono312aff92006-06-17 04:08:30 +00001973 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001974 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00001975 * @param is_default If non-zero, this account will be set as the default
1976 * account. The default account will be used when sending
1977 * outgoing requests (e.g. making call) when no account is
1978 * specified, and when receiving incoming requests when the
1979 * request does not match any accounts. It is recommended
1980 * that default account is set to local/LAN account.
1981 * @param p_acc_id Pointer to receive account ID of the new account.
1982 *
1983 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001984 *
1985 * \par Python:
1986 * The function returns (status, account_id) tuple:
1987 * \code
1988 status, account_id = py_pjsua.acc_add(acc_cfg, is_default)
1989 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001990 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001991PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00001992 pj_bool_t is_default,
1993 pjsua_acc_id *p_acc_id);
1994
1995
1996/**
1997 * Add a local account. A local account is used to identify local endpoint
1998 * instead of a specific user, and for this reason, a transport ID is needed
1999 * to obtain the local address information.
2000 *
2001 * @param tid Transport ID to generate account address.
2002 * @param is_default If non-zero, this account will be set as the default
2003 * account. The default account will be used when sending
2004 * outgoing requests (e.g. making call) when no account is
2005 * specified, and when receiving incoming requests when the
2006 * request does not match any accounts. It is recommended
2007 * that default account is set to local/LAN account.
2008 * @param p_acc_id Pointer to receive account ID of the new account.
2009 *
2010 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002011 *
2012 * \par Python:
2013 * The function returns (status, account_id) tuple:
2014 * \code
2015 status, account_id = py_pjsua.acc_add_local(tid, is_default)
2016 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002017 */
2018PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2019 pj_bool_t is_default,
2020 pjsua_acc_id *p_acc_id);
2021
2022/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002023 * Delete an account. This will unregister the account from the SIP server,
2024 * if necessary, and terminate server side presence subscriptions associated
2025 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002026 *
2027 * @param acc_id Id of the account to be deleted.
2028 *
2029 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002030 *
2031 * \par Python:
2032 * \code
2033 status = py_pjsua.acc_del(acc_id)
2034 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002035 */
2036PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2037
2038
2039/**
2040 * Modify account information.
2041 *
2042 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002043 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002044 *
2045 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002046 *
2047 * \par Python:
2048 * \code
2049 status = py_pjsua.acc_modify(acc_id, acc_cfg)
2050 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002051 */
2052PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002053 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002054
2055
2056/**
2057 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002058 * subscribers. This would trigger the sending of outgoing NOTIFY request
2059 * if there are server side presence subscription for this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002060 *
2061 * @param acc_id The account ID.
2062 * @param is_online True of false.
2063 *
2064 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002065 *
2066 * \par Python:
2067 * \code
2068 status = py_pjsua.acc_set_online_status(acc_id, is_online)
2069 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002070 */
2071PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2072 pj_bool_t is_online);
2073
2074
2075/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002076 * Update registration or perform unregistration. If registration is
2077 * configured for this account, then initial SIP REGISTER will be sent
2078 * when the account is added with #pjsua_acc_add(). Application normally
2079 * only need to call this function if it wants to manually update the
2080 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002081 *
2082 * @param acc_id The account ID.
2083 * @param renew If renew argument is zero, this will start
2084 * unregistration process.
2085 *
2086 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002087 *
2088 * \par Python:
2089 * \code
2090 status = py_pjsua.acc_set_registration(acc_id, renew)
2091 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002092 */
2093PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2094 pj_bool_t renew);
2095
2096
2097/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002098 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002099 *
2100 * @param acc_id Account identification.
2101 * @param info Pointer to receive account information.
2102 *
2103 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002104 *
2105 * \par Python:
2106 * \code
2107 acc_info = py_pjsua.acc_get_info(acc_id)
2108 * \endcode
2109 * The function returns None if account ID is not valid.
Benny Prijono312aff92006-06-17 04:08:30 +00002110 */
2111PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2112 pjsua_acc_info *info);
2113
2114
2115/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002116 * Enumerate all account currently active in the library. This will fill
2117 * the array with the account Ids, and application can then query the
2118 * account information for each id with #pjsua_acc_get_info().
2119 *
2120 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002121 *
2122 * @param ids Array of account IDs to be initialized.
2123 * @param count In input, specifies the maximum number of elements.
2124 * On return, it contains the actual number of elements.
2125 *
2126 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002127 *
2128 * \par Python:
2129 * The function takes no argument and returns list of account Ids:
2130 * \code
2131 [acc_ids] = py_pjsua.enum_accs()
2132 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002133 */
2134PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2135 unsigned *count );
2136
2137
2138/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002139 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002140 *
2141 * @param info Array of account infos to be initialized.
2142 * @param count In input, specifies the maximum number of elements.
2143 * On return, it contains the actual number of elements.
2144 *
2145 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002146 *
2147 * \par Python:
2148 * The function takes no argument and returns list of account infos:
2149 * \code
2150 [acc_info] = py_pjsua.acc_enum_info()
2151 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002152 */
2153PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2154 unsigned *count );
2155
2156
2157/**
2158 * This is an internal function to find the most appropriate account to
2159 * used to reach to the specified URL.
2160 *
2161 * @param url The remote URL to reach.
2162 *
2163 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002164 *
2165 * \par Python:
2166 * \code
2167 acc_id = py_pjsua.acc_find_for_outgoing(url)
2168 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002169 */
2170PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2171
2172
2173/**
2174 * This is an internal function to find the most appropriate account to be
2175 * used to handle incoming calls.
2176 *
2177 * @param rdata The incoming request message.
2178 *
2179 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002180 *
2181 * \par Python:
2182 * \code
2183 acc_id = py_pjsua.acc_find_for_outgoing(url)
2184 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002185 */
2186PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2187
2188
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002189/**
2190 * Create a suitable URI to be put as Contact based on the specified
2191 * target URI for the specified account.
2192 *
2193 * @param pool Pool to allocate memory for the string.
2194 * @param contact The string where the Contact URI will be stored.
2195 * @param acc_id Account ID.
2196 * @param uri Destination URI of the request.
2197 *
2198 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002199 *
2200 * \par Python:
2201 * This function is still experimental in Python:
2202 * \code
2203 uri = py_pjsua.acc_create_uac_contact(pool, acc_id, uri)
2204 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002205 */
2206PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
2207 pj_str_t *contact,
2208 pjsua_acc_id acc_id,
2209 const pj_str_t *uri);
2210
2211
2212
2213/**
2214 * Create a suitable URI to be put as Contact based on the information
2215 * in the incoming request.
2216 *
2217 * @param pool Pool to allocate memory for the string.
2218 * @param contact The string where the Contact URI will be stored.
2219 * @param acc_id Account ID.
2220 * @param rdata Incoming request.
2221 *
2222 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002223 *
2224 * \par Python:
2225 * This function is still experimental in Python:
2226 * \code
2227 uri = py_pjsua.acc_create_uas_contact(pool, acc_id, rdata)
2228 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002229 */
2230PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
2231 pj_str_t *contact,
2232 pjsua_acc_id acc_id,
2233 pjsip_rx_data *rdata );
2234
2235
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002236/**
2237 * Lock/bind this account to a specific transport/listener. Normally
2238 * application shouldn't need to do this, as transports will be selected
2239 * automatically by the stack according to the destination.
2240 *
2241 * When account is locked/bound to a specific transport, all outgoing
2242 * requests from this account will use the specified transport (this
2243 * includes SIP registration, dialog (call and event subscription), and
2244 * out-of-dialog requests such as MESSAGE).
2245 *
2246 * Note that transport_id may be specified in pjsua_acc_config too.
2247 *
2248 * @param acc_id The account ID.
2249 * @param tp_id The transport ID.
2250 *
2251 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002252 *
2253 * \par Python:
2254 * Not yet implemented.
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002255 */
2256PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
2257 pjsua_transport_id tp_id);
2258
Benny Prijono312aff92006-06-17 04:08:30 +00002259
2260/**
2261 * @}
2262 */
2263
2264
2265/*****************************************************************************
2266 * CALLS API
2267 */
2268
2269
2270/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002271 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00002272 * @ingroup PJSUA_LIB
2273 * @brief Call manipulation.
2274 * @{
2275 */
2276
2277/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002278 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00002279 */
2280#ifndef PJSUA_MAX_CALLS
2281# define PJSUA_MAX_CALLS 32
2282#endif
2283
2284
2285
2286/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002287 * This enumeration specifies the media status of a call, and it's part
2288 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00002289 */
2290typedef enum pjsua_call_media_status
2291{
Benny Prijonob5388cf2007-01-04 22:45:08 +00002292 /** Call currently has no media */
Benny Prijono312aff92006-06-17 04:08:30 +00002293 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002294
2295 /** The media is active */
Benny Prijono312aff92006-06-17 04:08:30 +00002296 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002297
2298 /** The media is currently put on hold by local endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002299 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002300
2301 /** The media is currently put on hold by remote endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002302 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002303
Benny Prijono312aff92006-06-17 04:08:30 +00002304} pjsua_call_media_status;
2305
2306
2307/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002308 * This structure describes the information and current status of a call.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002309 *
2310 * \par Python:
2311 * The type name is <tt>py_pjsua.Call_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002312 */
2313typedef struct pjsua_call_info
2314{
2315 /** Call identification. */
2316 pjsua_call_id id;
2317
2318 /** Initial call role (UAC == caller) */
2319 pjsip_role_e role;
2320
Benny Prijono90315512006-09-14 16:05:16 +00002321 /** The account ID where this call belongs. */
2322 pjsua_acc_id acc_id;
2323
Benny Prijono312aff92006-06-17 04:08:30 +00002324 /** Local URI */
2325 pj_str_t local_info;
2326
2327 /** Local Contact */
2328 pj_str_t local_contact;
2329
2330 /** Remote URI */
2331 pj_str_t remote_info;
2332
2333 /** Remote contact */
2334 pj_str_t remote_contact;
2335
2336 /** Dialog Call-ID string. */
2337 pj_str_t call_id;
2338
2339 /** Call state */
2340 pjsip_inv_state state;
2341
2342 /** Text describing the state */
2343 pj_str_t state_text;
2344
2345 /** Last status code heard, which can be used as cause code */
2346 pjsip_status_code last_status;
2347
2348 /** The reason phrase describing the status. */
2349 pj_str_t last_status_text;
2350
2351 /** Call media status. */
2352 pjsua_call_media_status media_status;
2353
2354 /** Media direction */
2355 pjmedia_dir media_dir;
2356
2357 /** The conference port number for the call */
2358 pjsua_conf_port_id conf_slot;
2359
2360 /** Up-to-date call connected duration (zero when call is not
2361 * established)
2362 */
2363 pj_time_val connect_duration;
2364
2365 /** Total call duration, including set-up time */
2366 pj_time_val total_duration;
2367
2368 /** Internal */
2369 struct {
2370 char local_info[128];
2371 char local_contact[128];
2372 char remote_info[128];
2373 char remote_contact[128];
2374 char call_id[128];
2375 char last_status_text[128];
2376 } buf_;
2377
2378} pjsua_call_info;
2379
2380
2381
Benny Prijonoa91a0032006-02-26 21:23:45 +00002382/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002383 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002384 *
2385 * @return Maximum number of calls configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002386 *
2387 * \par Python:
2388 * \code
2389 count = py_pjsua.call_get_max_count()
2390 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002391 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002392PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002393
2394/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002395 * Get number of currently active calls.
2396 *
2397 * @return Number of currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002398 *
2399 * \par Python:
2400 * \code
2401 count = py_pjsua.call_get_count()
2402 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002403 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002404PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002405
2406/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002407 * Enumerate all active calls. Application may then query the information and
2408 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002409 *
2410 * @param ids Array of account IDs to be initialized.
2411 * @param count In input, specifies the maximum number of elements.
2412 * On return, it contains the actual number of elements.
2413 *
2414 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002415 *
2416 * \par Python:
2417 * This function takes no argument and return list of call Ids.
2418 * \code
2419 [call_ids] = py_pjsua.enum_calls()
2420 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002421 */
2422PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
2423 unsigned *count);
2424
2425
2426/**
2427 * Make outgoing call to the specified URI using the specified account.
2428 *
2429 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002430 * @param dst_uri URI to be put in the To header (normally is the same
2431 * as the target URI).
2432 * @param options Options (must be zero at the moment).
2433 * @param user_data Arbitrary user data to be attached to the call, and
2434 * can be retrieved later.
2435 * @param msg_data Optional headers etc to be added to outgoing INVITE
2436 * request, or NULL if no custom header is desired.
2437 * @param p_call_id Pointer to receive call identification.
2438 *
2439 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002440 *
2441 * \par Python:
2442 * The Python function returns (status, call_id) tuple:
2443 * \code
2444 status, call_id = py_pjsua.call_make_call(acc_id, dst_uri, options,
2445 user_data, msg_data)
2446 * \endcode
2447 * Note: the \a user_data in Python function is an integer, and the
2448 * \a msg_data can be set to None if not required.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002449 */
2450PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
2451 const pj_str_t *dst_uri,
2452 unsigned options,
2453 void *user_data,
2454 const pjsua_msg_data *msg_data,
2455 pjsua_call_id *p_call_id);
2456
2457
2458/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002459 * Check if the specified call has active INVITE session and the INVITE
2460 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002461 *
2462 * @param call_id Call identification.
2463 *
2464 * @return Non-zero if call is active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002465 *
2466 * \par Python:
2467 * \code
2468 bool = py_pjsua.call_is_active(call_id)
2469 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002470 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002471PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002472
2473
2474/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002475 * Check if call has an active media session.
2476 *
2477 * @param call_id Call identification.
2478 *
2479 * @return Non-zero if yes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002480 *
2481 * \par Python:
2482 * \code
2483 bool = py_pjsua.call_has_media(call_id)
2484 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002485 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002486PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002487
2488
2489/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002490 * Get the conference port identification associated with the call.
2491 *
2492 * @param call_id Call identification.
2493 *
2494 * @return Conference port ID, or PJSUA_INVALID_ID when the
2495 * media has not been established or is not active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002496 *
2497 * \par Python:
2498 * \code
2499 slot = py_pjsua.call_get_conf_port(call_id)
2500 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002501 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002502PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
2503
2504/**
2505 * Obtain detail information about the specified call.
2506 *
2507 * @param call_id Call identification.
2508 * @param info Call info to be initialized.
2509 *
2510 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002511 *
2512 * \par Python:
2513 * \code
2514 call_info = py_pjsua.call_get_info(call_id)
2515 * \endcode
2516 * \a call_info return value will be set to None if call_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002517 */
2518PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002519 pjsua_call_info *info);
2520
2521
2522/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002523 * Attach application specific data to the call. Application can then
2524 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002525 *
2526 * @param call_id Call identification.
2527 * @param user_data Arbitrary data to be attached to the call.
2528 *
2529 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002530 *
2531 * \par Python:
2532 * \code
2533 status = py_pjsua.call_set_user_data(call_id, user_data)
2534 * \endcode
2535 * The \a user_data is an integer in the Python function.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002536 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002537PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
2538 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002539
2540
2541/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002542 * Get user data attached to the call, which has been previously set with
2543 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002544 *
2545 * @param call_id Call identification.
2546 *
2547 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002548 *
2549 * \par Python:
2550 * \code
2551 user_data = py_pjsua.call_get_user_data(call_id)
2552 * \endcode
2553 * The \a user_data is an integer.
Benny Prijono268ca612006-02-07 12:34:11 +00002554 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002555PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00002556
2557
2558/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002559 * Send response to incoming INVITE request. Depending on the status
2560 * code specified as parameter, this function may send provisional
2561 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002562 *
2563 * @param call_id Incoming call identification.
2564 * @param code Status code, (100-699).
2565 * @param reason Optional reason phrase. If NULL, default text
2566 * will be used.
2567 * @param msg_data Optional list of headers etc to be added to outgoing
2568 * response message.
2569 *
2570 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002571 *
2572 * \par Python:
2573 * \code
2574 status = py_pjsua.call_answer(call_id, code, reason, msg_data)
2575 * \endcode
2576 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijonoa91a0032006-02-26 21:23:45 +00002577 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002578PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
2579 unsigned code,
2580 const pj_str_t *reason,
2581 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00002582
2583/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002584 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00002585 * call state. This function is different than answering the call with
2586 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
2587 * will hangup the call regardless of the state and role of the call,
2588 * while #pjsua_call_answer() only works with incoming calls on EARLY
2589 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002590 *
2591 * @param call_id Call identification.
2592 * @param code Optional status code to be sent when we're rejecting
2593 * incoming call. If the value is zero, "603/Decline"
2594 * will be sent.
2595 * @param reason Optional reason phrase to be sent when we're rejecting
2596 * incoming call. If NULL, default text will be used.
2597 * @param msg_data Optional list of headers etc to be added to outgoing
2598 * request/response message.
2599 *
2600 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002601 *
2602 * \par Python:
2603 * \code
2604 status = py_pjsua.call_hangup(call_id, code, reason, msg_data)
2605 * \endcode
2606 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002607 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002608PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
2609 unsigned code,
2610 const pj_str_t *reason,
2611 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002612
2613
2614/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002615 * Put the specified call on hold. This will send re-INVITE with the
2616 * appropriate SDP to inform remote that the call is being put on hold.
2617 * The final status of the request itself will be reported on the
2618 * \a on_call_media_state() callback, which inform the application that
2619 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002620 *
2621 * @param call_id Call identification.
2622 * @param msg_data Optional message components to be sent with
2623 * the request.
2624 *
2625 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002626 *
2627 * \par Python:
2628 * \code
2629 status = py_pjsua.call_set_hold(call_id, msg_data)
2630 * \endcode
2631 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002632 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002633PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
2634 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002635
2636
2637/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002638 * Send re-INVITE to release hold.
2639 * The final status of the request itself will be reported on the
2640 * \a on_call_media_state() callback, which inform the application that
2641 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002642 *
2643 * @param call_id Call identification.
2644 * @param unhold If this argument is non-zero and the call is locally
2645 * held, this will release the local hold.
2646 * @param msg_data Optional message components to be sent with
2647 * the request.
2648 *
2649 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002650 *
2651 * \par Python:
2652 * \code
2653 status = py_pjsua.call_reinvite(call_id, unhold, msg_data)
2654 * \endcode
2655 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002656 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002657PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
2658 pj_bool_t unhold,
2659 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002660
2661
2662/**
Benny Prijono053f5222006-11-11 16:16:04 +00002663 * Initiate call transfer to the specified address. This function will send
2664 * REFER request to instruct remote call party to initiate a new INVITE
2665 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002666 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00002667 * If application is interested to monitor the successfulness and
2668 * the progress of the transfer request, it can implement
2669 * \a on_call_transfer_status() callback which will report the progress
2670 * of the call transfer request.
2671 *
Benny Prijono053f5222006-11-11 16:16:04 +00002672 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002673 * @param dest Address of new target to be contacted.
2674 * @param msg_data Optional message components to be sent with
2675 * the request.
2676 *
2677 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002678 *
2679 * \par Python:
2680 * \code
2681 status = py_pjsua.call_xfer(call_id, dest, msg_data)
2682 * \endcode
2683 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002684 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002685PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
2686 const pj_str_t *dest,
2687 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002688
2689/**
Benny Prijono053f5222006-11-11 16:16:04 +00002690 * Flag to indicate that "Require: replaces" should not be put in the
2691 * outgoing INVITE request caused by REFER request created by
2692 * #pjsua_call_xfer_replaces().
2693 */
2694#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
2695
2696/**
2697 * Initiate attended call transfer. This function will send REFER request
2698 * to instruct remote call party to initiate new INVITE session to the URL
2699 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
2700 * the call with us with the new call from the REFER recipient.
2701 *
2702 * @param call_id The call id to be transfered.
2703 * @param dest_call_id The call id to be replaced.
2704 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
2705 * to suppress the inclusion of "Require: replaces" in
2706 * the outgoing INVITE request created by the REFER
2707 * request.
2708 * @param msg_data Optional message components to be sent with
2709 * the request.
2710 *
2711 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002712 *
2713 * \par Python:
2714 * \code
2715 status = py_pjsua.call_xfer_replaces(call_id, dest_call_id, options, msg_data)
2716 * \endcode
2717 * Argument \a msg_data may be set to None if not required.
Benny Prijono053f5222006-11-11 16:16:04 +00002718 */
2719PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
2720 pjsua_call_id dest_call_id,
2721 unsigned options,
2722 const pjsua_msg_data *msg_data);
2723
2724/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002725 * Send DTMF digits to remote using RFC 2833 payload formats.
2726 *
2727 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002728 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002729 *
2730 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002731 *
2732 * \par Python:
2733 * \code
2734 status = py_pjsua.call_dial_dtmf(call_id, digits)
2735 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002736 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002737PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002738 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00002739
Benny Prijono26ff9062006-02-21 23:47:00 +00002740/**
Benny Prijonob0808372006-03-02 21:18:58 +00002741 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002742 *
2743 * @param call_id Call identification.
2744 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
2745 * assumed.
2746 * @param content The message content.
2747 * @param msg_data Optional list of headers etc to be included in outgoing
2748 * request. The body descriptor in the msg_data is
2749 * ignored.
2750 * @param user_data Optional user data, which will be given back when
2751 * the IM callback is called.
2752 *
2753 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002754 *
2755 * \par Python:
2756 * \code
2757 status = py_pjsua.call_send_im(call_id, mime_type, content, msg_data, user_data)
2758 * \endcode
2759 * Note that the \a user_data argument is an integer in Python.
Benny Prijonob0808372006-03-02 21:18:58 +00002760 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002761PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
2762 const pj_str_t *mime_type,
2763 const pj_str_t *content,
2764 const pjsua_msg_data *msg_data,
2765 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00002766
2767
2768/**
2769 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002770 *
2771 * @param call_id Call identification.
2772 * @param is_typing Non-zero to indicate to remote that local person is
2773 * currently typing an IM.
2774 * @param msg_data Optional list of headers etc to be included in outgoing
2775 * request.
2776 *
2777 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002778 *
2779 * \par Python:
2780 * \code
2781 status = py_pjsua.call_send_typing_ind(call_id, is_typing, msg_data)
2782 * \endcode
2783 * Argument \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00002784 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002785PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
2786 pj_bool_t is_typing,
2787 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00002788
2789/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002790 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
2791 * currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002792 *
2793 * \par Python:
2794 * \code
2795 py_pjsua.call_hangup_all()
2796 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00002797 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00002798PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00002799
2800
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002801/**
2802 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002803 *
2804 * @param call_id Call identification.
2805 * @param with_media Non-zero to include media information too.
2806 * @param buffer Buffer where the statistics are to be written to.
2807 * @param maxlen Maximum length of buffer.
2808 * @param indent Spaces for left indentation.
2809 *
2810 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002811 *
2812 * \par Python:
2813 * \code
2814 string = py_pjsua.call_dump(call_id, with_media, max_len, indent)
2815 * \endcode
2816 * The \a max_len argument is the desired maximum length to be allocated.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002817 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002818PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
2819 pj_bool_t with_media,
2820 char *buffer,
2821 unsigned maxlen,
2822 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002823
Benny Prijono9fc735d2006-05-28 14:58:12 +00002824/**
Benny Prijono312aff92006-06-17 04:08:30 +00002825 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00002826 */
Benny Prijono834aee32006-02-19 01:38:06 +00002827
2828
2829/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00002830 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00002831 */
2832
Benny Prijono312aff92006-06-17 04:08:30 +00002833
2834/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002835 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00002836 * @ingroup PJSUA_LIB
2837 * @brief Buddy management, buddy's presence, and instant messaging.
2838 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00002839 *
2840 * This section describes PJSUA-APIs related to buddies management,
2841 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00002842 */
2843
2844/**
2845 * Max buddies in buddy list.
2846 */
2847#ifndef PJSUA_MAX_BUDDIES
2848# define PJSUA_MAX_BUDDIES 256
2849#endif
2850
2851
2852/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002853 * This structure describes buddy configuration when adding a buddy to
2854 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
2855 * the structure with #pjsua_buddy_config_default() to initialize this
2856 * structure with default configuration.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002857 *
2858 * \par Python:
2859 * In Python this structure is <tt>py_pjsua.Buddy_Config</tt>. However
2860 * it is recommended that application instantiates the buddy config
2861 * by calling:
2862 * \code
2863 buddy_cfg = py_pjsua.buddy_config_default()
2864 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002865 */
2866typedef struct pjsua_buddy_config
2867{
2868 /**
2869 * Buddy URL or name address.
2870 */
2871 pj_str_t uri;
2872
2873 /**
2874 * Specify whether presence subscription should start immediately.
2875 */
2876 pj_bool_t subscribe;
2877
2878} pjsua_buddy_config;
2879
2880
2881/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002882 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00002883 */
2884typedef enum pjsua_buddy_status
2885{
2886 /**
2887 * Online status is unknown (possibly because no presence subscription
2888 * has been established).
2889 */
2890 PJSUA_BUDDY_STATUS_UNKNOWN,
2891
2892 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00002893 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00002894 */
2895 PJSUA_BUDDY_STATUS_ONLINE,
2896
2897 /**
2898 * Buddy is offline.
2899 */
2900 PJSUA_BUDDY_STATUS_OFFLINE,
2901
2902} pjsua_buddy_status;
2903
2904
2905
2906/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002907 * This structure describes buddy info, which can be retrieved by calling
2908 * #pjsua_buddy_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00002909 *
2910 * \par Python:
2911 * This structure in Python is <tt>py_pjsua.Buddy_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002912 */
2913typedef struct pjsua_buddy_info
2914{
2915 /**
2916 * The buddy ID.
2917 */
2918 pjsua_buddy_id id;
2919
2920 /**
2921 * The full URI of the buddy, as specified in the configuration.
2922 */
2923 pj_str_t uri;
2924
2925 /**
2926 * Buddy's Contact, only available when presence subscription has
2927 * been established to the buddy.
2928 */
2929 pj_str_t contact;
2930
2931 /**
2932 * Buddy's online status.
2933 */
2934 pjsua_buddy_status status;
2935
2936 /**
2937 * Text to describe buddy's online status.
2938 */
2939 pj_str_t status_text;
2940
2941 /**
2942 * Flag to indicate that we should monitor the presence information for
2943 * this buddy (normally yes, unless explicitly disabled).
2944 */
2945 pj_bool_t monitor_pres;
2946
2947 /**
2948 * Internal buffer.
2949 */
2950 char buf_[256];
2951
2952} pjsua_buddy_info;
2953
2954
Benny Prijono834aee32006-02-19 01:38:06 +00002955/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002956 * Set default values to the buddy config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002957 *
2958 * \par Python:
2959 * \code
2960 buddy_cfg = py_pjsua.buddy_config_default()
2961 * \endcode
Benny Prijonob5388cf2007-01-04 22:45:08 +00002962 */
2963PJ_INLINE(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg)
2964{
2965 pj_bzero(cfg, sizeof(*cfg));
2966}
2967
2968
2969/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002970 * Get total number of buddies.
2971 *
2972 * @return Number of buddies.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002973 *
2974 * \par Python:
2975 * \code
2976 buddy_count = py_pjsua.get_buddy_count()
2977 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002978 */
2979PJ_DECL(unsigned) pjsua_get_buddy_count(void);
2980
2981
2982/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002983 * Check if buddy ID is valid.
2984 *
2985 * @param buddy_id Buddy ID to check.
2986 *
2987 * @return Non-zero if buddy ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002988 *
2989 * \par Python:
2990 * \code
2991 is_valid = py_pjsua.buddy_is_valid(buddy_id)
2992 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002993 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002994PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
2995
2996
2997/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002998 * Enumerate all buddy IDs in the buddy list. Application then can use
2999 * #pjsua_buddy_get_info() to get the detail information for each buddy
3000 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003001 *
3002 * @param ids Array of ids to be initialized.
3003 * @param count On input, specifies max elements in the array.
3004 * On return, it contains actual number of elements
3005 * that have been initialized.
3006 *
3007 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003008 *
3009 * \par Python:
3010 * The Python function takes no argument and returns list of buddy IDs:
3011 * \code
3012 [buddy_ids] = py_pjsua.enum_buddies()
3013 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003014 */
3015PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3016 unsigned *count);
3017
3018/**
3019 * Get detailed buddy info.
3020 *
3021 * @param buddy_id The buddy identification.
3022 * @param info Pointer to receive information about buddy.
3023 *
3024 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003025 *
3026 * \par Python:
3027 * \code
3028 buddy_info = py_pjsua.buddy_get_info(buddy_id)
3029 * \endcode
3030 * The function returns None if buddy_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003031 */
3032PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003033 pjsua_buddy_info *info);
3034
3035/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003036 * Add new buddy to the buddy list. If presence subscription is enabled
3037 * for this buddy, this function will also start the presence subscription
3038 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003039 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003040 * @param buddy)cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003041 * @param p_buddy_id Pointer to receive buddy ID.
3042 *
3043 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003044 *
3045 * \par Python:
3046 * The function returns (status, buddy_id) tuple:
3047 * \code
3048 status, buddy_id = py_pjsua.buddy_add(buddy_cfg)
3049 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003050 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003051PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003052 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003053
3054
3055/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003056 * Delete the specified buddy from the buddy list. Any presence subscription
3057 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003058 *
3059 * @param buddy_id Buddy identification.
3060 *
3061 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003062 *
3063 * \par Python:
3064 * \code
3065 status = py_pjsua.buddy_del(buddy_id)
3066 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +00003067 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003068PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003069
3070
3071/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003072 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3073 * subscribed, application will be informed about buddy's presence status
3074 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003075 *
3076 * @param buddy_id Buddy identification.
3077 * @param subscribe Specify non-zero to activate presence subscription to
3078 * the specified buddy.
3079 *
3080 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003081 *
3082 * \par Python:
3083 * \code
3084 status = py_pjsua.buddy_subscribe_pres(buddy_id, subscribe)
3085 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003086 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003087PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3088 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003089
3090
3091/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003092 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003093 *
3094 * @param verbose Yes or no.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003095 *
3096 * \par Python:
3097 * \code
3098 py_pjsua.pres_dump()
3099 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003100 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003101PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003102
3103
Benny Prijonob0808372006-03-02 21:18:58 +00003104/**
3105 * The MESSAGE method (defined in pjsua_im.c)
3106 */
3107extern const pjsip_method pjsip_message_method;
3108
3109
Benny Prijonob0808372006-03-02 21:18:58 +00003110
3111/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003112 * Send instant messaging outside dialog, using the specified account for
3113 * route set and authentication.
3114 *
3115 * @param acc_id Account ID to be used to send the request.
3116 * @param to Remote URI.
3117 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3118 * assumed.
3119 * @param content The message content.
3120 * @param msg_data Optional list of headers etc to be included in outgoing
3121 * request. The body descriptor in the msg_data is
3122 * ignored.
3123 * @param user_data Optional user data, which will be given back when
3124 * the IM callback is called.
3125 *
3126 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003127 *
3128 * \par Python:
3129 * \code
3130 status = py_pjsua.im_send(acc_id, to, mime_type, content, msg_data, user_data)
3131 * \endcode
3132 * Arguments \a mime_type and \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003133 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003134PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3135 const pj_str_t *to,
3136 const pj_str_t *mime_type,
3137 const pj_str_t *content,
3138 const pjsua_msg_data *msg_data,
3139 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003140
3141
3142/**
3143 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003144 *
3145 * @param acc_id Account ID to be used to send the request.
3146 * @param to Remote URI.
3147 * @param is_typing If non-zero, it tells remote person that local person
3148 * is currently composing an IM.
3149 * @param msg_data Optional list of headers etc to be added to outgoing
3150 * request.
3151 *
3152 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003153 *
3154 * \par Python:
3155 * \code
3156 status = py_pjsua.im_typing(acc_id, to, is_typing, msg_data)
3157 * \endcode
3158 * Argument \a msg_data may be set to None if not requried.
Benny Prijonob0808372006-03-02 21:18:58 +00003159 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003160PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3161 const pj_str_t *to,
3162 pj_bool_t is_typing,
3163 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003164
3165
Benny Prijonof3195072006-02-14 21:15:30 +00003166
Benny Prijono312aff92006-06-17 04:08:30 +00003167/**
3168 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003169 */
3170
Benny Prijono312aff92006-06-17 04:08:30 +00003171
3172/*****************************************************************************
3173 * MEDIA API
3174 */
3175
3176
3177/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003178 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003179 * @ingroup PJSUA_LIB
3180 * @brief Media manipulation.
3181 * @{
3182 *
3183 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003184 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3185 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003186 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003187 * the interconnection between these terminations freely.
3188 *
3189 * The conference bridge provides powerful switching and mixing functionality
3190 * for application. With the conference bridge, each conference slot (e.g.
3191 * a call) can transmit to multiple destinations, and one destination can
3192 * receive from multiple sources. If more than one media terminations are
3193 * terminated in the same slot, the conference bridge will mix the signal
3194 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00003195 *
3196 * Application connects one media termination/slot to another by calling
3197 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003198 * media flow from the source termination to the sink termination. To
3199 * establish bidirectional media flow, application wound need to make another
3200 * call to #pjsua_conf_connect(), this time inverting the source and
3201 * destination slots in the parameter.
3202 *
3203 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00003204 * the following steps:
3205 *
3206 \code
3207
3208 pj_status_t stream_to_call( pjsua_call_id call_id )
3209 {
3210 pjsua_player_id player_id;
3211
3212 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
3213 if (status != PJ_SUCCESS)
3214 return status;
3215
3216 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
3217 pjsua_call_get_conf_port() );
3218 }
3219 \endcode
3220 *
3221 *
3222 * Other features of PJSUA media:
3223 * - efficient N to M interconnections between media terminations.
3224 * - media termination can be connected to itself to create loopback
3225 * media.
3226 * - the media termination may have different clock rates, and resampling
3227 * will be done automatically by conference bridge.
3228 * - media terminations may also have different frame time; the
3229 * conference bridge will perform the necessary bufferring to adjust
3230 * the difference between terminations.
3231 * - interconnections are removed automatically when media termination
3232 * is removed from the bridge.
3233 * - sound device may be changed even when there are active media
3234 * interconnections.
3235 * - correctly report call's media quality (in #pjsua_call_dump()) from
3236 * RTCP packet exchange.
3237 */
3238
3239/**
3240 * Max ports in the conference bridge.
3241 */
3242#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00003243# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00003244#endif
3245
Benny Prijonob5388cf2007-01-04 22:45:08 +00003246/**
3247 * The default clock rate to be used by the conference bridge.
3248 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003249#ifndef PJSUA_DEFAULT_CLOCK_RATE
3250# define PJSUA_DEFAULT_CLOCK_RATE 16000
3251#endif
3252
Benny Prijonob5388cf2007-01-04 22:45:08 +00003253/**
3254 * Default codec quality settings.
3255 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003256#ifndef PJSUA_DEFAULT_CODEC_QUALITY
3257# define PJSUA_DEFAULT_CODEC_QUALITY 5
3258#endif
3259
Benny Prijonob5388cf2007-01-04 22:45:08 +00003260/**
3261 * Default iLBC mode.
3262 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003263#ifndef PJSUA_DEFAULT_ILBC_MODE
3264# define PJSUA_DEFAULT_ILBC_MODE 20
3265#endif
3266
Benny Prijonob5388cf2007-01-04 22:45:08 +00003267/**
3268 * The default echo canceller tail length.
3269 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003270#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonod2990b92006-11-23 10:19:46 +00003271# define PJSUA_DEFAULT_EC_TAIL_LEN 800
Benny Prijono12a669c2006-11-23 07:32:13 +00003272#endif
Benny Prijono312aff92006-06-17 04:08:30 +00003273
3274
3275/**
Benny Prijonocba59d92007-02-16 09:22:56 +00003276 * The maximum file player.
3277 */
3278#ifndef PJSUA_MAX_PLAYERS
3279# define PJSUA_MAX_PLAYERS 32
3280#endif
3281
3282
3283/**
3284 * The maximum file player.
3285 */
3286#ifndef PJSUA_MAX_RECORDERS
3287# define PJSUA_MAX_RECORDERS 32
3288#endif
3289
3290
3291/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003292 * This structure describes media configuration, which will be specified
3293 * when calling #pjsua_init(). Application MUST initialize this structure
3294 * by calling #pjsua_media_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003295 *
3296 * \par Python:
3297 * This data type in Python is <tt>py_pjsua.Media_Config</tt>. To create
3298 * an object of this type, it is recommended to call
3299 * <tt>py_pjsua.media_config_default()</tt> function instead:
3300 * \code
3301 media_cfg = py_pjsua.media_config_default()
3302 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003303 */
3304struct pjsua_media_config
3305{
3306 /**
3307 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003308 * If value is zero, default clock rate will be used
3309 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00003310 */
3311 unsigned clock_rate;
3312
3313 /**
3314 * Specify maximum number of media ports to be created in the
3315 * conference bridge. Since all media terminate in the bridge
3316 * (calls, file player, file recorder, etc), the value must be
3317 * large enough to support all of them. However, the larger
3318 * the value, the more computations are performed.
3319 */
3320 unsigned max_media_ports;
3321
3322 /**
3323 * Specify whether the media manager should manage its own
3324 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
3325 * and at least one worker thread will be created too. If no,
3326 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
3327 * and no worker thread is needed.
3328 *
3329 * Normally application would say yes here, unless it wants to
3330 * run everything from a single thread.
3331 */
3332 pj_bool_t has_ioqueue;
3333
3334 /**
3335 * Specify the number of worker threads to handle incoming RTP
3336 * packets. A value of one is recommended for most applications.
3337 */
3338 unsigned thread_cnt;
3339
Benny Prijono0498d902006-06-19 14:49:14 +00003340 /**
3341 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00003342 * 5-10: resampling use large filter,
3343 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00003344 * 1-2: resampling use linear.
3345 * The media quality also sets speex codec quality/complexity to the
3346 * number.
3347 *
Benny Prijono70972992006-08-05 11:13:58 +00003348 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00003349 */
3350 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00003351
3352 /**
3353 * Specify default ptime.
3354 *
3355 * Default: 0 (codec specific)
3356 */
3357 unsigned ptime;
3358
3359 /**
3360 * Disable VAD?
3361 *
3362 * Default: 0 (no (meaning VAD is enabled))
3363 */
3364 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00003365
3366 /**
3367 * iLBC mode (20 or 30).
3368 *
Benny Prijono70972992006-08-05 11:13:58 +00003369 * Default: 20 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00003370 */
3371 unsigned ilbc_mode;
3372
3373 /**
3374 * Percentage of RTP packet to drop in TX direction
3375 * (to simulate packet lost).
3376 *
3377 * Default: 0
3378 */
3379 unsigned tx_drop_pct;
3380
3381 /**
3382 * Percentage of RTP packet to drop in RX direction
3383 * (to simulate packet lost).
3384 *
3385 * Default: 0
3386 */
3387 unsigned rx_drop_pct;
3388
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003389 /**
Benny Prijono5da50432006-08-07 10:24:52 +00003390 * Echo canceller options (see #pjmedia_echo_create())
3391 *
3392 * Default: 0.
3393 */
3394 unsigned ec_options;
3395
3396 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003397 * Echo canceller tail length, in miliseconds.
3398 *
Benny Prijono669643c2006-09-20 20:02:18 +00003399 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003400 */
3401 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003402
3403 /**
3404 * Jitter buffer initial prefetch delay in msec. The value must be
3405 * between jb_min_pre and jb_max_pre below.
3406 *
3407 * Default: -1 (to use default stream settings, currently 150 msec)
3408 */
3409 int jb_init;
3410
3411 /**
3412 * Jitter buffer minimum prefetch delay in msec.
3413 *
3414 * Default: -1 (to use default stream settings, currently 60 msec)
3415 */
3416 int jb_min_pre;
3417
3418 /**
3419 * Jitter buffer maximum prefetch delay in msec.
3420 *
3421 * Default: -1 (to use default stream settings, currently 240 msec)
3422 */
3423 int jb_max_pre;
3424
3425 /**
3426 * Set maximum delay that can be accomodated by the jitter buffer msec.
3427 *
3428 * Default: -1 (to use default stream settings, currently 360 msec)
3429 */
3430 int jb_max;
3431
Benny Prijonoc97608e2007-03-23 16:34:20 +00003432 /**
3433 * Enable ICE
3434 */
3435 pj_bool_t enable_ice;
3436
3437 /**
3438 * Enable ICE media relay.
3439 */
3440 pj_bool_t enable_relay;
Benny Prijono312aff92006-06-17 04:08:30 +00003441};
3442
3443
3444/**
3445 * Use this function to initialize media config.
3446 *
3447 * @param cfg The media config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003448 *
3449 * \par Python:
3450 * \code
3451 media_cfg = py_pjsua.media_config_default()
3452 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003453 */
3454PJ_INLINE(void) pjsua_media_config_default(pjsua_media_config *cfg)
3455{
Benny Prijonoac623b32006-07-03 15:19:31 +00003456 pj_bzero(cfg, sizeof(*cfg));
Benny Prijono312aff92006-06-17 04:08:30 +00003457
Benny Prijono70972992006-08-05 11:13:58 +00003458 cfg->clock_rate = PJSUA_DEFAULT_CLOCK_RATE;
Benny Prijono312aff92006-06-17 04:08:30 +00003459 cfg->max_media_ports = 32;
3460 cfg->has_ioqueue = PJ_TRUE;
3461 cfg->thread_cnt = 1;
Benny Prijono70972992006-08-05 11:13:58 +00003462 cfg->quality = PJSUA_DEFAULT_CODEC_QUALITY;
3463 cfg->ilbc_mode = PJSUA_DEFAULT_ILBC_MODE;
3464 cfg->ec_tail_len = PJSUA_DEFAULT_EC_TAIL_LEN;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003465 cfg->jb_init = cfg->jb_min_pre = cfg->jb_max_pre = cfg->jb_max = -1;
Benny Prijono312aff92006-06-17 04:08:30 +00003466}
3467
3468
3469
3470/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003471 * This structure describes codec information, which can be retrieved by
3472 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00003473 */
3474typedef struct pjsua_codec_info
3475{
3476 /**
3477 * Codec unique identification.
3478 */
3479 pj_str_t codec_id;
3480
3481 /**
3482 * Codec priority (integer 0-255).
3483 */
3484 pj_uint8_t priority;
3485
3486 /**
3487 * Internal buffer.
3488 */
3489 char buf_[32];
3490
3491} pjsua_codec_info;
3492
3493
3494/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003495 * This structure descibes information about a particular media port that
3496 * has been registered into the conference bridge. Application can query
3497 * this info by calling #pjsua_conf_get_port_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003498 *
3499 * \par Python:
3500 * In Python, this type is <tt>py_pjsua.Conf_Port_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003501 */
3502typedef struct pjsua_conf_port_info
3503{
3504 /** Conference port number. */
3505 pjsua_conf_port_id slot_id;
3506
3507 /** Port name. */
3508 pj_str_t name;
3509
3510 /** Clock rate. */
3511 unsigned clock_rate;
3512
3513 /** Number of channels. */
3514 unsigned channel_count;
3515
3516 /** Samples per frame */
3517 unsigned samples_per_frame;
3518
3519 /** Bits per sample */
3520 unsigned bits_per_sample;
3521
3522 /** Number of listeners in the array. */
3523 unsigned listener_cnt;
3524
3525 /** Array of listeners (in other words, ports where this port is
3526 * transmitting to.
3527 */
3528 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
3529
3530} pjsua_conf_port_info;
3531
3532
3533/**
3534 * This structure holds information about custom media transport to
3535 * be registered to pjsua.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003536 *
3537 * \par Python:
3538 * Not applicable.
Benny Prijono312aff92006-06-17 04:08:30 +00003539 */
3540typedef struct pjsua_media_transport
3541{
3542 /**
3543 * Media socket information containing the address information
3544 * of the RTP and RTCP socket.
3545 */
3546 pjmedia_sock_info skinfo;
3547
3548 /**
3549 * The media transport instance.
3550 */
3551 pjmedia_transport *transport;
3552
3553} pjsua_media_transport;
3554
3555
3556
3557
Benny Prijono9fc735d2006-05-28 14:58:12 +00003558/**
3559 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003560 *
3561 * @return Maximum number of ports in the conference bridge.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003562 *
3563 * \par Python:
3564 * \code
3565 port_count = py_pjsua.conf_get_max_ports()
3566 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003567 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003568PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003569
3570
3571/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003572 * Get current number of active ports in the bridge.
3573 *
3574 * @return The number.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003575 *
3576 * \par Python:
3577 * \code
3578 count = py_pjsua.conf_get_active_ports()
3579 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003580 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003581PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
3582
3583
3584/**
3585 * Enumerate all conference ports.
3586 *
3587 * @param id Array of conference port ID to be initialized.
3588 * @param count On input, specifies max elements in the array.
3589 * On return, it contains actual number of elements
3590 * that have been initialized.
3591 *
3592 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003593 *
3594 * \par Python:
3595 * The Python functions returns list of conference port Ids:
3596 * \code
3597 [port_ids] = py_pjsua.enum_conf_ports()
3598 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003599 */
3600PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
3601 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003602
3603
3604/**
3605 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003606 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003607 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003608 * @param info Pointer to store the port info.
3609 *
3610 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003611 *
3612 * \par Python:
3613 * \code
3614 port_info = py_pjsua.conf_get_port_info(port_id)
3615 * \endcode
3616 * The function will return None if \a port_id is not valid.
Benny Prijono8b1889b2006-06-06 18:40:40 +00003617 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003618PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00003619 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003620
3621
3622/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00003623 * Add arbitrary media port to PJSUA's conference bridge. Application
3624 * can use this function to add the media port that it creates. For
3625 * media ports that are created by PJSUA-LIB (such as calls, file player,
3626 * or file recorder), PJSUA-LIB will automatically add the port to
3627 * the bridge.
3628 *
3629 * @param pool Pool to use.
3630 * @param port Media port to be added to the bridge.
3631 * @param p_id Optional pointer to receive the conference
3632 * slot id.
3633 *
3634 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003635 *
3636 * \par Python:
3637 * Not applicable (for now)
Benny Prijonoe909eac2006-07-27 22:04:56 +00003638 */
3639PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
3640 pjmedia_port *port,
3641 pjsua_conf_port_id *p_id);
3642
3643
3644/**
3645 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00003646 * call this function if it registered the port manually with previous call
3647 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00003648 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003649 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00003650 *
3651 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003652 *
3653 * \par Python:
3654 * \code
3655 status = py_pjsua.conf_remove_port(port_id)
3656 * \endcode
Benny Prijonoe909eac2006-07-27 22:04:56 +00003657 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003658PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00003659
3660
3661/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003662 * Establish unidirectional media flow from souce to sink. One source
3663 * may transmit to multiple destinations/sink. And if multiple
3664 * sources are transmitting to the same sink, the media will be mixed
3665 * together. Source and sink may refer to the same ID, effectively
3666 * looping the media.
3667 *
3668 * If bidirectional media flow is desired, application needs to call
3669 * this function twice, with the second one having the arguments
3670 * reversed.
3671 *
3672 * @param source Port ID of the source media/transmitter.
3673 * @param sink Port ID of the destination media/received.
3674 *
3675 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003676 *
3677 * \par Python:
3678 * \code
3679 status = py_pjsua.conf_connect(source, sink)
3680 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003681 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003682PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
3683 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003684
3685
3686/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003687 * Disconnect media flow from the source to destination port.
3688 *
3689 * @param source Port ID of the source media/transmitter.
3690 * @param sink Port ID of the destination media/received.
3691 *
3692 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003693 *
3694 * \par Python:
3695 * \code
3696 status = py_pjsua.conf_disconnect(source, sink)
3697 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003698 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003699PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
3700 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003701
3702
Benny Prijono6dd967c2006-12-26 02:27:14 +00003703/**
3704 * Adjust the signal level to be transmitted from the bridge to the
3705 * specified port by making it louder or quieter.
3706 *
3707 * @param slot The conference bridge slot number.
3708 * @param level Signal level adjustment. Value 1.0 means no level
3709 * adjustment, while value 0 means to mute the port.
3710 *
3711 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003712 *
3713 * \par Python:
3714 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003715 */
3716PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
3717 float level);
3718
3719/**
3720 * Adjust the signal level to be received from the specified port (to
3721 * the bridge) by making it louder or quieter.
3722 *
3723 * @param slot The conference bridge slot number.
3724 * @param level Signal level adjustment. Value 1.0 means no level
3725 * adjustment, while value 0 means to mute the port.
3726 *
3727 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003728 *
3729 * \par Python:
3730 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003731 */
3732PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
3733 float level);
3734
3735/**
3736 * Get last signal level transmitted to or received from the specified port.
3737 * The signal level is an integer value in zero to 255, with zero indicates
3738 * no signal, and 255 indicates the loudest signal level.
3739 *
3740 * @param slot The conference bridge slot number.
3741 * @param tx_level Optional argument to receive the level of signal
3742 * transmitted to the specified port (i.e. the direction
3743 * is from the bridge to the port).
3744 * @param rx_level Optional argument to receive the level of signal
3745 * received from the port (i.e. the direction is from the
3746 * port to the bridge).
3747 *
3748 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003749 *
3750 * \par Python:
3751 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003752 */
3753PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
3754 unsigned *tx_level,
3755 unsigned *rx_level);
3756
Benny Prijono6dd967c2006-12-26 02:27:14 +00003757
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003758/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00003759 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003760 */
3761
Benny Prijono9fc735d2006-05-28 14:58:12 +00003762/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003763 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003764 * the conference bridge.
3765 *
3766 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00003767 * WAV files are supported, and the WAV file MUST be
3768 * formatted as 16bit PCM mono/single channel (any
3769 * clock rate is supported).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003770 * @param options Options (currently zero).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003771 * @param p_id Pointer to receive player ID.
3772 *
3773 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003774 *
3775 * \par Python:
3776 * The function returns (status, id) tuple:
3777 * \code
3778 status, id = py_pjsua.player_create(filename, options)
3779 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003780 */
3781PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003782 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003783 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003784
3785
3786/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003787 * Create a file playlist media port, and automatically add the port
3788 * to the conference bridge.
3789 *
3790 * @param file_names Array of file names to be added to the play list.
3791 * Note that the files must have the same clock rate,
3792 * number of channels, and number of bits per sample.
3793 * @param file_count Number of files in the array.
3794 * @param label Optional label to be set for the media port.
3795 * @param options Optional option flag. Application may specify
3796 * PJMEDIA_FILE_NO_LOOP to prevent looping.
3797 * @param p_id Optional pointer to receive player ID.
3798 *
3799 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003800 *
3801 * \par Python:
3802 * Not implemented yet.
Benny Prijonoa66c3312007-01-21 23:12:40 +00003803 */
3804PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
3805 unsigned file_count,
3806 const pj_str_t *label,
3807 unsigned options,
3808 pjsua_player_id *p_id);
3809
3810/**
3811 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003812 *
3813 * @param id The file player ID.
3814 *
3815 * @return Conference port ID associated with this player.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003816 *
3817 * \par Python:
3818 * \code
3819 port_id = py_pjsua.player_get_conf_port(id)
3820 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003821 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003822PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003823
3824
3825/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003826 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00003827 *
3828 * @param id The player ID.
3829 * @param p_port The media port associated with the player.
3830 *
3831 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003832 *
3833 * \par Python:
3834 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00003835 */
3836PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_recorder_id id,
3837 pjmedia_port **p_port);
3838
3839/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003840 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003841 *
3842 * @param id The file player ID.
3843 * @param samples The playback position, in samples. Application can
3844 * specify zero to re-start the playback.
3845 *
3846 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003847 *
3848 * \par Python:
3849 * \code
3850 status = py_pjsua.player_set_pos(id, samples)
3851 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003852 */
3853PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
3854 pj_uint32_t samples);
3855
3856
3857/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003858 * Close the file of playlist, remove the player from the bridge, and free
3859 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003860 *
3861 * @param id The file player ID.
3862 *
3863 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003864 *
3865 * \par Python:
3866 * \code
3867 status = py_pjsua.player_destroy(id)
3868 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003869 */
3870PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
3871
3872
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003873/*****************************************************************************
3874 * File recorder.
3875 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00003876
3877/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003878 * Create a file recorder, and automatically connect this recorder to
Benny Prijono8f310522006-10-20 11:08:49 +00003879 * the conference bridge. The recorder currently supports recording WAV file,
3880 * and on Windows, MP3 file. The type of the recorder to use is determined
3881 * by the extension of the file (e.g. ".wav" or ".mp3").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003882 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00003883 * @param filename Output file name. The function will determine the
3884 * default format to be used based on the file extension.
3885 * Currently ".wav" is supported on all platforms, and
3886 * also ".mp3" is support on Windows.
Benny Prijono8f310522006-10-20 11:08:49 +00003887 * @param enc_type Optionally specify the type of encoder to be used to
3888 * compress the media, if the file can support different
3889 * encodings. This value must be zero for now.
3890 * @param enc_param Optionally specify codec specific parameter to be
3891 * passed to the file writer. For .MP3 recorder, this
3892 * can point to pjmedia_mp3_encoder_option structure to
3893 * specify additional settings for the .mp3 recorder.
3894 * For .WAV recorder, this value must be NULL.
3895 * @param max_size Maximum file size. Specify zero or -1 to remove size
3896 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003897 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003898 * @param p_id Pointer to receive the recorder instance.
3899 *
3900 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003901 *
3902 * \par Python:
3903 * \code
3904 status, id = py_pjsua.recorder_create(filename, enc_type, enc_param, max_size, options)
3905 * \endcode
3906 * The \a enc_param is a string in Python.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003907 */
3908PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00003909 unsigned enc_type,
3910 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003911 pj_ssize_t max_size,
3912 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003913 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003914
3915
3916/**
3917 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003918 *
3919 * @param id The recorder ID.
3920 *
3921 * @return Conference port ID associated with this recorder.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003922 *
3923 * \par Python:
3924 * \code
3925 port_id = py_pjsua.recorder_get_conf_port(id)
3926 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003927 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003928PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003929
3930
3931/**
Benny Prijono469b1522006-12-26 03:05:17 +00003932 * Get the media port for the recorder.
3933 *
3934 * @param id The recorder ID.
3935 * @param p_port The media port associated with the recorder.
3936 *
3937 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003938 *
3939 * \par Python:
3940 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00003941 */
3942PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
3943 pjmedia_port **p_port);
3944
3945
3946/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003947 * Destroy recorder (this will complete recording).
3948 *
3949 * @param id The recorder ID.
3950 *
3951 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003952 *
3953 * \par Python:
3954 * \code
3955 status = py_pjsua.recorder_destroy(id)
3956 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003957 */
3958PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
3959
3960
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003961/*****************************************************************************
3962 * Sound devices.
3963 */
3964
Benny Prijono9fc735d2006-05-28 14:58:12 +00003965/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003966 * Enum all sound devices installed in the system.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003967 *
3968 * @param info Array of info to be initialized.
3969 * @param count On input, specifies max elements in the array.
3970 * On return, it contains actual number of elements
3971 * that have been initialized.
3972 *
3973 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003974 *
3975 *
3976 * \par Python:
3977 * The function returns list of sound device info:
3978 * \code
3979 [dev_infos] = py_pjsua.enum_snd_devs()
3980 * \endcode
3981 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00003982 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003983PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
3984 unsigned *count);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003985
3986
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00003987
3988/**
3989 * Get currently active sound devices. If sound devices has not been created
3990 * (for example when pjsua_start() is not called), it is possible that
3991 * the function returns PJ_SUCCESS with -1 as device IDs.
3992 *
3993 * @param capture_dev On return it will be filled with device ID of the
3994 * capture device.
3995 * @param playback_dev On return it will be filled with device ID of the
3996 * device ID of the playback device.
3997 *
3998 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003999 *
4000 * \par Python:
Benny Prijonoebdf8772007-02-01 19:25:50 +00004001 * The function takes no argument and return an (integer,integer) tuple:
Benny Prijonoe6ead542007-01-31 20:53:31 +00004002 * \code
4003 capture_dev, playback_dev = py_pjsua.get_snd_dev()
4004 * \endcode
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004005 */
4006PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4007 int *playback_dev);
4008
4009
Benny Prijono9fc735d2006-05-28 14:58:12 +00004010/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004011 * Select or change sound device. Application may call this function at
4012 * any time to replace current sound device.
4013 *
4014 * @param capture_dev Device ID of the capture device.
4015 * @param playback_dev Device ID of the playback device.
4016 *
4017 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004018 *
4019 * \par Python:
4020 * \code
4021 status = py_pjsua.set_snd_dev(capture_dev, playback_dev)
4022 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004023 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004024PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4025 int playback_dev);
4026
4027
4028/**
4029 * Set pjsua to use null sound device. The null sound device only provides
4030 * the timing needed by the conference bridge, and will not interract with
4031 * any hardware.
4032 *
4033 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004034 *
4035 * \par Python:
4036 * \code
4037 status = py_pjsua.set_null_snd_dev()
4038 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004039 */
4040PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4041
4042
Benny Prijonoe909eac2006-07-27 22:04:56 +00004043/**
4044 * Disconnect the main conference bridge from any sound devices, and let
4045 * application connect the bridge to it's own sound device/master port.
4046 *
4047 * @return The port interface of the conference bridge,
4048 * so that application can connect this to it's own
4049 * sound device or master port.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004050 *
4051 * \par Python:
4052 * Not applicable (for now).
Benny Prijonoe909eac2006-07-27 22:04:56 +00004053 */
4054PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4055
4056
Benny Prijonof20687a2006-08-04 18:27:19 +00004057/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004058 * Configure the echo canceller tail length of the sound port.
Benny Prijonof20687a2006-08-04 18:27:19 +00004059 *
4060 * @param tail_ms The tail length, in miliseconds. Set to zero to
4061 * disable AEC.
Benny Prijono5da50432006-08-07 10:24:52 +00004062 * @param options Options to be passed to #pjmedia_echo_create().
4063 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004064 *
4065 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004066 *
4067 * \par Python:
4068 * \code
4069 status = py_pjsua.set_ec(tail_ms, options)
4070 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004071 */
Benny Prijono5da50432006-08-07 10:24:52 +00004072PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004073
4074
4075/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004076 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004077 *
4078 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4079 * If AEC is disabled, the value will be zero.
4080 *
4081 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004082 *
4083 * \par Python:
4084 * \code
4085 tail_ms = py_pjsua.get_ec_tail()
4086 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004087 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004088PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004089
4090
4091
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004092/*****************************************************************************
4093 * Codecs.
4094 */
4095
4096/**
4097 * Enum all supported codecs in the system.
4098 *
4099 * @param id Array of ID to be initialized.
4100 * @param count On input, specifies max elements in the array.
4101 * On return, it contains actual number of elements
4102 * that have been initialized.
4103 *
4104 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004105 *
4106 * \par Python:
4107 * This function takes no argument and returns list of codec infos:
4108 * \code
4109 [codec_info] = py_pjsua.enum_codecs()
4110 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004111 */
4112PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4113 unsigned *count );
4114
4115
4116/**
4117 * Change codec priority.
4118 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004119 * @param codec_id Codec ID, which is a string that uniquely identify
4120 * the codec (such as "speex/8000"). Please see pjsua
4121 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004122 * @param priority Codec priority, 0-255, where zero means to disable
4123 * the codec.
4124 *
4125 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004126 *
4127 * \par Python:
4128 * \code
4129 status = py_pjsua.codec_set_priority(codec_id, priority)
4130 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004131 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004132PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004133 pj_uint8_t priority );
4134
4135
4136/**
4137 * Get codec parameters.
4138 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004139 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004140 * @param param Structure to receive codec parameters.
4141 *
4142 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004143 *
4144 * \par Python:
4145 * The Python function is experimental:
4146 * \code
4147 codec_param = py_pjsua.codec_get_param(codec_id)
4148 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004149 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004150PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004151 pjmedia_codec_param *param );
4152
4153
4154/**
4155 * Set codec parameters.
4156 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004157 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004158 * @param param Codec parameter to set.
4159 *
4160 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004161 *
4162 * \par Python:
4163 * The Python function is experimental:
4164 * \code
4165 status = py_pjsua.codec_set_param(codec_id, param)
4166 * \endcode
4167
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004168 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004169PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004170 const pjmedia_codec_param *param);
4171
4172
4173
Benny Prijono9fc735d2006-05-28 14:58:12 +00004174
Benny Prijono312aff92006-06-17 04:08:30 +00004175/**
4176 * Create UDP media transports for all the calls. This function creates
4177 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00004178 *
Benny Prijono312aff92006-06-17 04:08:30 +00004179 * @param cfg Media transport configuration. The "port" field in the
4180 * configuration is used as the start port to bind the
4181 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004182 *
4183 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004184 *
4185 * \par Python:
4186 * Not implemented yet.
Benny Prijonof3195072006-02-14 21:15:30 +00004187 */
Benny Prijono312aff92006-06-17 04:08:30 +00004188PJ_DECL(pj_status_t)
4189pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00004190
Benny Prijonodc39fe82006-05-26 12:17:46 +00004191
4192/**
Benny Prijono312aff92006-06-17 04:08:30 +00004193 * Register custom media transports to be used by calls. There must
4194 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004195 *
Benny Prijono312aff92006-06-17 04:08:30 +00004196 * @param tp The media transport array.
4197 * @param count Number of elements in the array. This number MUST
4198 * match the number of maximum calls configured when
4199 * pjsua is created.
4200 * @param auto_delete Flag to indicate whether the transports should be
4201 * destroyed when pjsua is shutdown.
4202 *
4203 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004204 *
4205 * \par Python:
4206 * Note applicable.
Benny Prijonodc39fe82006-05-26 12:17:46 +00004207 */
Benny Prijono312aff92006-06-17 04:08:30 +00004208PJ_DECL(pj_status_t)
4209pjsua_media_transports_attach( pjsua_media_transport tp[],
4210 unsigned count,
4211 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00004212
4213
Benny Prijono312aff92006-06-17 04:08:30 +00004214/**
4215 * @}
4216 */
4217
Benny Prijonof3195072006-02-14 21:15:30 +00004218
Benny Prijono268ca612006-02-07 12:34:11 +00004219
Benny Prijono312aff92006-06-17 04:08:30 +00004220/**
4221 * @}
4222 */
4223
Benny Prijonoe6ead542007-01-31 20:53:31 +00004224PJ_END_DECL
4225
Benny Prijono312aff92006-06-17 04:08:30 +00004226
Benny Prijono268ca612006-02-07 12:34:11 +00004227#endif /* __PJSUA_H__ */