blob: 695e2c8c275d5ed2a29e7b9b53489b44bd5ff5bd [file] [log] [blame]
Benny Prijono268ca612006-02-07 12:34:11 +00001/* $Id$ */
2/*
Benny Prijonoa771a512007-02-19 01:13:53 +00003 * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org>
Benny Prijono268ca612006-02-07 12:34:11 +00004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJSUA_H__
20#define __PJSUA_H__
21
Benny Prijono312aff92006-06-17 04:08:30 +000022/**
23 * @file pjsua.h
24 * @brief PJSUA API.
25 */
26
27
Benny Prijono268ca612006-02-07 12:34:11 +000028/* Include all PJSIP core headers. */
29#include <pjsip.h>
30
31/* Include all PJMEDIA headers. */
32#include <pjmedia.h>
33
Benny Prijono1f9afba2006-02-10 15:57:32 +000034/* Include all PJMEDIA-CODEC headers. */
35#include <pjmedia-codec.h>
36
Benny Prijono268ca612006-02-07 12:34:11 +000037/* Include all PJSIP-UA headers */
38#include <pjsip_ua.h>
39
Benny Prijono834aee32006-02-19 01:38:06 +000040/* Include all PJSIP-SIMPLE headers */
41#include <pjsip_simple.h>
42
Benny Prijono4ab9fbb2007-10-12 12:14:27 +000043/* Include all PJNATH headers */
44#include <pjnath.h>
45
Benny Prijono268ca612006-02-07 12:34:11 +000046/* Include all PJLIB-UTIL headers. */
47#include <pjlib-util.h>
48
49/* Include all PJLIB headers. */
50#include <pjlib.h>
51
52
Benny Prijonoe6ead542007-01-31 20:53:31 +000053PJ_BEGIN_DECL
54
55
Benny Prijono312aff92006-06-17 04:08:30 +000056/**
Benny Prijonoe6ead542007-01-31 20:53:31 +000057 * @defgroup PJSUA_LIB PJSUA API - High Level Softphone API for C/C++ and Python
Benny Prijono312aff92006-06-17 04:08:30 +000058 * @ingroup PJSIP
59 * @brief Very high level API for constructing SIP UA applications.
60 * @{
61 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000062 * @section pjsua_api_intro A SIP User Agent API for C/C++ and Python
63 *
64 * PJSUA API is very high level API, available for C/C++ and Python language,
65 * for constructing SIP multimedia user agent
Benny Prijono312aff92006-06-17 04:08:30 +000066 * applications. It wraps together the signaling and media functionalities
67 * into an easy to use call API, provides account management, buddy
68 * management, presence, instant messaging, along with multimedia
69 * features such as conferencing, file streaming, local playback,
70 * voice recording, and so on.
71 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000072 * @subsection pjsua_for_c_cpp C/C++ Binding
Benny Prijono312aff92006-06-17 04:08:30 +000073 * Application must link with <b>pjsua-lib</b> to use this API. In addition,
74 * this library depends on the following libraries:
75 * - <b>pjsip-ua</b>,
76 * - <b>pjsip-simple</b>,
77 * - <b>pjsip-core</b>,
78 * - <b>pjmedia</b>,
79 * - <b>pjmedia-codec</b>,
80 * - <b>pjlib-util</b>, and
81 * - <b>pjlib</b>,
82 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000083 * so application must also link with these libraries as well. For more
84 * information, please refer to
85 * <A HREF="http://www.pjsip.org/using.htm">Getting Started with PJSIP</A>
86 * page.
Benny Prijono312aff92006-06-17 04:08:30 +000087 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000088 * @subsection pjsua_for_python Python Binding
89 *
90 * The Python binding for PJSUA-API is implemented by <b>py_pjsua</b>
91 * module, in <tt>pjsip-apps/py_pjsua</tt> directory. This module is
92 * built by building <tt>py_pjsua</tt> project in <tt>pjsip_apps</tt>
93 * Visual Studio workspace, or by invoking the usual <tt>setup.py</tt>
94 * Python installer script.
95 *
96 * The Python script then can import the PJSUA-API Python module by
97 * using <b>import py_pjsua</b> construct as usual.
98 *
99 *
100 * @section pjsua_samples
101 *
102 * Few samples are provided both in C and Python.
103 *
104 - @ref page_pjsip_sample_simple_pjsuaua_c\n
105 Very simple SIP User Agent with registration, call, and media, using
106 PJSUA-API, all in under 200 lines of code.
107
108 - @ref page_pjsip_samples_pjsua\n
109 This is the reference implementation for PJSIP and PJMEDIA.
110 PJSUA is a console based application, designed to be simple enough
111 to be readble, but powerful enough to demonstrate all features
112 available in PJSIP and PJMEDIA.\n
113
114 - Python sample\n
115 For a real simple Python sample application, have a look at
116 <A HREF="http://www.pjsip.org/trac/browser/pjproject/trunk/pjsip-apps/src/py_pjsua/pjsua_app.py">
117 <tt>pjsip-apps/src/py_pjsua/pjsua_app.py</tt></A> file.
118
Benny Prijono312aff92006-06-17 04:08:30 +0000119 * @section root_using_pjsua_lib Using PJSUA API
120 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000121 * Please refer to @ref PJSUA_LIB_BASE on how to create and initialize the API.
122 * And then see the Modules on the bottom of this page for more information
123 * about specific subject.
Benny Prijono312aff92006-06-17 04:08:30 +0000124 */
125
Benny Prijonoa91a0032006-02-26 21:23:45 +0000126
Benny Prijonof3195072006-02-14 21:15:30 +0000127
Benny Prijono312aff92006-06-17 04:08:30 +0000128/*****************************************************************************
129 * BASE API
130 */
131
Benny Prijonof04ffdd2006-02-21 00:11:18 +0000132/**
Benny Prijonoe6ead542007-01-31 20:53:31 +0000133 * @defgroup PJSUA_LIB_BASE PJSUA-API Basic API
Benny Prijono312aff92006-06-17 04:08:30 +0000134 * @ingroup PJSUA_LIB
135 * @brief Basic application creation/initialization, logging configuration, etc.
136 * @{
137 *
138 * The base PJSUA API controls PJSUA creation, initialization, and startup, and
139 * also provides various auxiliary functions.
140 *
141 * @section using_pjsua_lib Using PJSUA Library
142 *
143 * @subsection creating_pjsua_lib Creating PJSUA
144 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000145 * Before anything else, application must create PJSUA by calling #pjsua_create()
146 * (or <tt>py_pjsua.create()</tt> from Python).
Benny Prijono312aff92006-06-17 04:08:30 +0000147 * This, among other things, will initialize PJLIB, which is crucial before
Benny Prijonoe6ead542007-01-31 20:53:31 +0000148 * any PJLIB functions can be called, PJLIB-UTIL, and create a SIP endpoint.
149 *
150 * After this function is called, application can create a memory pool (with
151 * #pjsua_pool_create()) and read configurations from command line or file to
152 * build the settings to initialize PJSUA below.
Benny Prijono312aff92006-06-17 04:08:30 +0000153 *
154 * @subsection init_pjsua_lib Initializing PJSUA
155 *
156 * After PJSUA is created, application can initialize PJSUA by calling
Benny Prijonoe6ead542007-01-31 20:53:31 +0000157 * #pjsua_init(). This function takes several optional configuration settings
158 * in the argument, if application wants to set them.
Benny Prijono312aff92006-06-17 04:08:30 +0000159 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000160 * @subsubsection init_pjsua_lib_c_cpp PJSUA-LIB Initialization (in C)
161 * Sample code to initialize PJSUA in C code:
Benny Prijono312aff92006-06-17 04:08:30 +0000162 \code
163
Benny Prijonob5388cf2007-01-04 22:45:08 +0000164 #include <pjsua-lib/pjsua.h>
165
166 #define THIS_FILE __FILE__
167
168 static pj_status_t app_init(void)
169 {
Benny Prijono312aff92006-06-17 04:08:30 +0000170 pjsua_config ua_cfg;
171 pjsua_logging_config log_cfg;
172 pjsua_media_config media_cfg;
Benny Prijonob5388cf2007-01-04 22:45:08 +0000173 pj_status_t status;
174
175 // Must create pjsua before anything else!
176 status = pjsua_create();
177 if (status != PJ_SUCCESS) {
178 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
179 return status;
180 }
Benny Prijono312aff92006-06-17 04:08:30 +0000181
182 // Initialize configs with default settings.
183 pjsua_config_default(&ua_cfg);
184 pjsua_logging_config_default(&log_cfg);
185 pjsua_media_config_default(&media_cfg);
186
187 // At the very least, application would want to override
188 // the call callbacks in pjsua_config:
189 ua_cfg.cb.on_incoming_call = ...
190 ua_cfg.cb.on_call_state = ..
191 ...
192
193 // Customize other settings (or initialize them from application specific
194 // configuration file):
195 ...
196
197 // Initialize pjsua
198 status = pjsua_init(&ua_cfg, &log_cfg, &media_cfg);
199 if (status != PJ_SUCCESS) {
200 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
201 return status;
202 }
Benny Prijonob5388cf2007-01-04 22:45:08 +0000203 .
204 ...
205 }
Benny Prijono312aff92006-06-17 04:08:30 +0000206 \endcode
207 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000208 *
209 * @subsubsection init_pjsua_lib_python PJSUA-LIB Initialization (in Python)
210 * Sample code to initialize PJSUA in Python code:
211
212 \code
213
214import py_pjsua
215
216#
217# Initialize pjsua.
218#
219def app_init():
220 # Create pjsua before anything else
221 status = py_pjsua.create()
222 if status != 0:
223 err_exit("pjsua create() error", status)
224
225 # We use default logging config for this sample
226 log_cfg = py_pjsua.logging_config_default()
227
228 # Create and initialize pjsua config
229 # Note: for this Python module, thread_cnt must be 0 since Python
230 # doesn't like to be called from alien thread (pjsua's thread
231 # in this case)
232 ua_cfg = py_pjsua.config_default()
233 ua_cfg.thread_cnt = 0
234 ua_cfg.user_agent = "PJSUA/Python 0.1"
235
236 # Override callbacks. At the very least application would want to
237 # override the call callbacks in pjsua_config
238 ua_cfg.cb.on_incoming_call = ...
239 ua_cfg.cb.on_call_state = ...
240
241 # Use default media config for this cample
242 med_cfg = py_pjsua.media_config_default()
243
244 #
245 # Initialize pjsua!!
246 #
247 status = py_pjsua.init(ua_cfg, log_cfg, med_cfg)
248 if status != 0:
249 err_exit("pjsua init() error", status)
250
251
252
253# Utility: display PJ error and exit
254#
255def err_exit(title, rc):
256 py_pjsua.perror(THIS_FILE, title, rc)
257 exit(1)
258
259 \endcode
260
261
Benny Prijono312aff92006-06-17 04:08:30 +0000262 * @subsection other_init_pjsua_lib Other Initialization
263 *
264 * After PJSUA is initialized with #pjsua_init(), application will normally
265 * need/want to perform the following tasks:
266 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000267 * - create SIP transport with #pjsua_transport_create(). Application would
268 * to call #pjsua_transport_create() for each transport types that it
269 * wants to support (for example, UDP, TCP, and TLS). Please see
Benny Prijono312aff92006-06-17 04:08:30 +0000270 * @ref PJSUA_LIB_TRANSPORT section for more info.
271 * - create one or more SIP accounts with #pjsua_acc_add() or
Benny Prijonoe6ead542007-01-31 20:53:31 +0000272 * #pjsua_acc_add_local(). The SIP account is used for registering with
273 * the SIP server, if any. Please see @ref PJSUA_LIB_ACC for more info.
Benny Prijono312aff92006-06-17 04:08:30 +0000274 * - add one or more buddies with #pjsua_buddy_add(). Please see
275 * @ref PJSUA_LIB_BUDDY section for more info.
276 * - optionally configure the sound device, codec settings, and other
277 * media settings. Please see @ref PJSUA_LIB_MEDIA for more info.
278 *
279 *
280 * @subsection starting_pjsua_lib Starting PJSUA
281 *
282 * After all initializations have been done, application must call
283 * #pjsua_start() to start PJSUA. This function will check that all settings
Benny Prijonoe6ead542007-01-31 20:53:31 +0000284 * have been properly configured, and apply default settings when they haven't,
285 * or report error status when it is unable to recover from missing settings.
Benny Prijono312aff92006-06-17 04:08:30 +0000286 *
287 * Most settings can be changed during run-time. For example, application
288 * may add, modify, or delete accounts, buddies, or change media settings
289 * during run-time.
Benny Prijonob5388cf2007-01-04 22:45:08 +0000290 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000291 * @subsubsection starting_pjsua_lib_c C Example for Starting PJSUA
Benny Prijonob5388cf2007-01-04 22:45:08 +0000292 * Sample code:
293 \code
294 static pj_status_t app_run(void)
295 {
296 pj_status_t status;
297
298 // Start pjsua
299 status = pjsua_start();
300 if (status != PJ_SUCCESS) {
301 pjsua_destroy();
302 pjsua_perror(THIS_FILE, "Error starting pjsua", status);
303 return status;
304 }
305
306 // Run application loop
307 while (1) {
308 char choice[10];
309
310 printf("Select menu: ");
311 fgets(choice, sizeof(choice), stdin);
312 ...
313 }
314 }
315 \endcode
Benny Prijonoe6ead542007-01-31 20:53:31 +0000316
317 * @subsubsection starting_pjsua_lib_python Python Example for starting PJSUA
318 * For Python, starting PJSUA-LIB takes one more step, that is to initialize
319 * Python worker thread to poll PJSUA-LIB. This step is necessary because
320 * Python doesn't like it when it is called by an "alien" thread (that is,
321 * thread that is not created using Python API).
322 *
323 * Because of this, we cannot use a worker thread in PJSUA-LIB, because then
324 * the Python callback will be called by an "alien" thread and this would
325 * crash Python (or raise assert() probably).
326 *
327 * So because worker thread is disabled, we need to create a worker thread
328 * in Python. Note that this may not be necessary if we're creating a
329 * GUI application, because then we can attach, for example, a GUI timer
330 * object to poll the PJSUA-LIB. But because we're creating a console
331 * application which will block at <tt>sys.stdin.readline()</tt>, we need
332 * to have a worker thread to poll PJSUA-LIB.
333
334 \code
335
336import thread
337
338C_QUIT = 0
339
340
341def app_start():
342 # Done with initialization, start pjsua!!
343 #
344 status = py_pjsua.start()
345 if status != 0:
346 py_pjsua.destroy()
347 err_exit("Error starting pjsua!", status)
348
349 # Start worker thread
350 thr = thread.start_new(worker_thread_main, (0,))
351
352 print "PJSUA Started!!"
353
354#
355# Worker thread function.
356# Python doesn't like it when it's called from an alien thread
357# (pjsua's worker thread, in this case), so for Python we must
358# disable worker thread in pjsua and poll pjsua from Python instead.
359#
360def worker_thread_main(arg):
361 global C_QUIT
362 thread_desc = 0
363 status = py_pjsua.thread_register("python worker", thread_desc)
364 if status != 0:
365 py_pjsua.perror(THIS_FILE, "Error registering thread", status)
366 else:
367 while C_QUIT == 0:
368 py_pjsua.handle_events(50)
369 print "Worker thread quitting.."
370 C_QUIT = 2
371
372
373 \endcode
Benny Prijonof04ffdd2006-02-21 00:11:18 +0000374 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000375
Benny Prijono312aff92006-06-17 04:08:30 +0000376/** Constant to identify invalid ID for all sorts of IDs. */
377#define PJSUA_INVALID_ID (-1)
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000378
379/** Call identification */
380typedef int pjsua_call_id;
381
Benny Prijono312aff92006-06-17 04:08:30 +0000382/** Account identification */
383typedef int pjsua_acc_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000384
385/** Buddy identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000386typedef int pjsua_buddy_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000387
388/** File player identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000389typedef int pjsua_player_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000390
391/** File recorder identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000392typedef int pjsua_recorder_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000393
394/** Conference port identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000395typedef int pjsua_conf_port_id;
396
397
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000398
Benny Prijonoa91a0032006-02-26 21:23:45 +0000399/**
Benny Prijono312aff92006-06-17 04:08:30 +0000400 * Maximum proxies in account.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000401 */
Benny Prijono312aff92006-06-17 04:08:30 +0000402#ifndef PJSUA_ACC_MAX_PROXIES
403# define PJSUA_ACC_MAX_PROXIES 8
404#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000405
406
407
408/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000409 * Logging configuration, which can be (optionally) specified when calling
410 * #pjsua_init(). Application must call #pjsua_logging_config_default() to
411 * initialize this structure with the default values.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000412 *
413 * \par Sample Python Syntax:
414 * \code
415 # Python type: py_pjsua.Logging_Config
416
417 log_cfg = py_pjsua.logging_config_default()
418 log_cfg.level = 4
419 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000420 */
421typedef struct pjsua_logging_config
422{
423 /**
424 * Log incoming and outgoing SIP message? Yes!
425 */
426 pj_bool_t msg_logging;
427
428 /**
429 * Input verbosity level. Value 5 is reasonable.
430 */
431 unsigned level;
432
433 /**
434 * Verbosity level for console. Value 4 is reasonable.
435 */
436 unsigned console_level;
437
438 /**
439 * Log decoration.
440 */
441 unsigned decor;
442
443 /**
444 * Optional log filename.
445 */
446 pj_str_t log_filename;
447
448 /**
449 * Optional callback function to be called to write log to
450 * application specific device. This function will be called for
451 * log messages on input verbosity level.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000452 *
453 * \par Sample Python Syntax:
454 * \code
455 # level: integer
456 # data: string
457 # len: integer
458
459 def cb(level, data, len):
460 print data,
461 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000462 */
463 void (*cb)(int level, const char *data, pj_size_t len);
464
465
466} pjsua_logging_config;
467
468
469/**
470 * Use this function to initialize logging config.
471 *
472 * @param cfg The logging config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000473 *
474 * \par Python Syntax:
475 * The Python function instantiates and initialize the logging config:
476 * \code
477 logging_cfg = py_pjsua.logging_config_default()
478 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000479 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000480PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000481
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000482
483/**
484 * Use this function to duplicate logging config.
485 *
486 * @param pool Pool to use.
487 * @param dst Destination config.
488 * @param src Source config.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000489 *
490 * \par Python Syntax:
491 * Not available (for now). Ideally we should be able to just assign
492 * one config to another, but this has not been tested.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000493 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000494PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool,
495 pjsua_logging_config *dst,
496 const pjsua_logging_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000497
Benny Prijonodc39fe82006-05-26 12:17:46 +0000498
499/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000500 * This structure describes application callback to receive various event
501 * notification from PJSUA-API. All of these callbacks are OPTIONAL,
502 * although definitely application would want to implement some of
503 * the important callbacks (such as \a on_incoming_call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000504 *
505 * \par Python Syntax:
506 * This callback structure is embedded on pjsua_config structure.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000507 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000508typedef struct pjsua_callback
Benny Prijonodc39fe82006-05-26 12:17:46 +0000509{
510 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000511 * Notify application when invite state has changed.
512 * Application may then query the call info to get the
Benny Prijonoe6ead542007-01-31 20:53:31 +0000513 * detail call states by calling pjsua_call_get_info() function.
Benny Prijono0875ae82006-12-26 00:11:48 +0000514 *
515 * @param call_id The call index.
516 * @param e Event which causes the call state to change.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000517 *
518 * \par Python Syntax:
519 * \code
520 # call_id: integer
521 # e: an opaque object
522
523 def on_call_state(call_id, e):
524 return
525 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000526 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000527 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000528
529 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000530 * Notify application on incoming call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000531 *
532 * @param acc_id The account which match the incoming call.
533 * @param call_id The call id that has just been created for
534 * the call.
535 * @param rdata The incoming INVITE request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000536 *
537 * \par Python Syntax:
538 * \code
539 # acc_id: integer
540 # call_id: integer
541 # rdata: an opaque object
542
543 def on_incoming_call(acc_id, call_id, rdata):
544 return
545 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +0000546 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000547 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000548 pjsip_rx_data *rdata);
549
550 /**
Benny Prijonofeb69f42007-10-05 09:12:26 +0000551 * This is a general notification callback which is called whenever
552 * a transaction within the call has changed state. Application can
553 * implement this callback for example to monitor the state of
554 * outgoing requests, or to answer unhandled incoming requests
555 * (such as INFO) with a final response.
556 *
557 * @param call_id Call identification.
558 * @param tsx The transaction which has changed state.
559 * @param e Transaction event that caused the state change.
560 */
561 void (*on_call_tsx_state)(pjsua_call_id call_id,
562 pjsip_transaction *tsx,
563 pjsip_event *e);
564
565 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000566 * Notify application when media state in the call has changed.
567 * Normal application would need to implement this callback, e.g.
Benny Prijono6ba8c542007-10-16 01:34:14 +0000568 * to connect the call's media to sound device. When ICE is used,
569 * this callback will also be called to report ICE negotiation
570 * failure.
Benny Prijono0875ae82006-12-26 00:11:48 +0000571 *
572 * @param call_id The call index.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000573 *
574 * \par Python Syntax:
575 * \code
576 # call_id: integer
577
578 def on_call_media_state(call_id):
579 return
580 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000581 */
582 void (*on_call_media_state)(pjsua_call_id call_id);
583
584 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000585 * Notify application upon incoming DTMF digits.
586 *
587 * @param call_id The call index.
588 * @param digit DTMF ASCII digit.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000589 *
590 * \par Python Syntax:
591 * \code
592 # call_id: integer
Benny Prijono1f63cc42007-09-10 16:54:22 +0000593 # digit: digit string
Benny Prijonoe6ead542007-01-31 20:53:31 +0000594
595 def on_dtmf_digit(call_id, digit):
596 return
597 * \endcode
Benny Prijono0875ae82006-12-26 00:11:48 +0000598 */
599 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
600
601 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000602 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000603 * Application can decide to accept/reject transfer request
604 * by setting the code (default is 200). When this callback
605 * is not defined, the default behavior is to accept the
606 * transfer.
Benny Prijono0875ae82006-12-26 00:11:48 +0000607 *
608 * @param call_id The call index.
609 * @param dst The destination where the call will be
610 * transfered to.
611 * @param code Status code to be returned for the call transfer
612 * request. On input, it contains status code 200.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000613 *
614 * \par Python Syntax:
615 * \code
616 # call_id: integer
617 # dst: string
618 # code: integer
619
620 def on_call_transfer_request(call_id, dst, code):
621 return code
622
623 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000624 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000625 void (*on_call_transfer_request)(pjsua_call_id call_id,
626 const pj_str_t *dst,
627 pjsip_status_code *code);
628
629 /**
630 * Notify application of the status of previously sent call
631 * transfer request. Application can monitor the status of the
632 * call transfer request, for example to decide whether to
633 * terminate existing call.
634 *
635 * @param call_id Call ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000636 * @param st_code Status progress of the transfer request.
637 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000638 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000639 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000640 * this callback is the final status.
641 * @param p_cont Initially will be set to non-zero, application
642 * can set this to FALSE if it no longer wants
643 * to receie further notification (for example,
644 * after it hangs up the call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000645 *
646 * \par Python Syntax:
647 * \code
648 # call_id: integer
649 # st_code: integer
650 # st_text: string
651 # final: integer
652 # cont: integer
653
654 # return: cont
655
656 def on_call_transfer_status(call_id, st_code, st_text, final, cont):
657 return cont
658 * \endcode
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000659 */
660 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000661 int st_code,
662 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000663 pj_bool_t final,
664 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000665
666 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000667 * Notify application about incoming INVITE with Replaces header.
668 * Application may reject the request by setting non-2xx code.
669 *
670 * @param call_id The call ID to be replaced.
671 * @param rdata The incoming INVITE request to replace the call.
672 * @param st_code Status code to be set by application. Application
673 * should only return a final status (200-699).
674 * @param st_text Optional status text to be set by application.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000675 *
676 * \par Python Syntax:
677 * \code
678 # call_id: integer
679 # rdata: an opaque object
680 # st_code: integer
681 # st_text: string
682
683 # return: (st_code, st_text) tuple
684
685 def on_call_replace_request(call_id, rdata, st_code, st_text):
686 return st_code, st_text
687 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000688 */
689 void (*on_call_replace_request)(pjsua_call_id call_id,
690 pjsip_rx_data *rdata,
691 int *st_code,
692 pj_str_t *st_text);
693
694 /**
695 * Notify application that an existing call has been replaced with
696 * a new call. This happens when PJSUA-API receives incoming INVITE
697 * request with Replaces header.
698 *
699 * After this callback is called, normally PJSUA-API will disconnect
700 * \a old_call_id and establish \a new_call_id.
701 *
702 * @param old_call_id Existing call which to be replaced with the
703 * new call.
704 * @param new_call_id The new call.
705 * @param rdata The incoming INVITE with Replaces request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000706 *
707 * \par Python Syntax:
708 * \code
709 # old_call_id: integer
710 # new_call_id: integer
711
712 def on_call_replaced(old_call_id, new_call_id):
713 return
714 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000715 */
716 void (*on_call_replaced)(pjsua_call_id old_call_id,
717 pjsua_call_id new_call_id);
718
719
720 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000721 * Notify application when registration status has changed.
722 * Application may then query the account info to get the
723 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000724 *
725 * @param acc_id Account ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000726 *
727 * \par Python Syntax:
728 * \code
729 # acc_id: account ID (integer)
730
731 def on_reg_state(acc_id):
732 return
733 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000734 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000735 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000736
737 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000738 * Notify application when the buddy state has changed.
739 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000740 *
741 * @param buddy_id The buddy id.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000742 *
743 * \par Python Syntax:
744 * \code
745 # buddy_id: integer
746
747 def on_buddy_state(buddy_id):
748 return
749 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000750 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000751 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000752
753 /**
754 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000755 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000756 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000757 *
Benny Prijonobbeb3992007-05-21 13:48:35 +0000758 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
759 * passed as one of the argument.
760 *
Benny Prijono0875ae82006-12-26 00:11:48 +0000761 * @param call_id Containts the ID of the call where the IM was
762 * sent, or PJSUA_INVALID_ID if the IM was sent
763 * outside call context.
764 * @param from URI of the sender.
765 * @param to URI of the destination message.
766 * @param contact The Contact URI of the sender, if present.
767 * @param mime_type MIME type of the message.
768 * @param body The message content.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000769 *
770 * \par Python Syntax:
771 * \code
772 # call_id: integer
773 # from: string
774 # to: string
775 # contact: string
776 # mime_type: string
777 # body: string
778
779 def on_pager(call_id, from, to, contact, mime_type, body):
780 return
781 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000782 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000783 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
784 const pj_str_t *to, const pj_str_t *contact,
785 const pj_str_t *mime_type, const pj_str_t *body);
786
787 /**
Benny Prijonobbeb3992007-05-21 13:48:35 +0000788 * This is the alternative version of the \a on_pager() callback with
789 * \a pjsip_rx_data argument.
790 *
791 * @param call_id Containts the ID of the call where the IM was
792 * sent, or PJSUA_INVALID_ID if the IM was sent
793 * outside call context.
794 * @param from URI of the sender.
795 * @param to URI of the destination message.
796 * @param contact The Contact URI of the sender, if present.
797 * @param mime_type MIME type of the message.
798 * @param body The message content.
799 * @param rdata The incoming MESSAGE request.
800 */
801 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
802 const pj_str_t *to, const pj_str_t *contact,
803 const pj_str_t *mime_type, const pj_str_t *body,
804 pjsip_rx_data *rdata);
805
806 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000807 * Notify application about the delivery status of outgoing pager
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000808 * request. See also on_pager_status2() callback for the version with
809 * \a pjsip_rx_data in the argument list.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000810 *
811 * @param call_id Containts the ID of the call where the IM was
812 * sent, or PJSUA_INVALID_ID if the IM was sent
813 * outside call context.
814 * @param to Destination URI.
815 * @param body Message body.
816 * @param user_data Arbitrary data that was specified when sending
817 * IM message.
818 * @param status Delivery status.
819 * @param reason Delivery status reason.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000820 *
821 * \par Python Syntax
822 * \code
823 # call_id: integer
824 # to: string
825 # body: string
826 # user_data: string
827 # status: integer
828 # reason: string
829
830 def on_pager_status(call_id, to, body, user_data, status, reason):
831 return
832 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000833 */
834 void (*on_pager_status)(pjsua_call_id call_id,
835 const pj_str_t *to,
836 const pj_str_t *body,
837 void *user_data,
838 pjsip_status_code status,
839 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000840
841 /**
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000842 * Notify application about the delivery status of outgoing pager
843 * request.
844 *
845 * @param call_id Containts the ID of the call where the IM was
846 * sent, or PJSUA_INVALID_ID if the IM was sent
847 * outside call context.
848 * @param to Destination URI.
849 * @param body Message body.
850 * @param user_data Arbitrary data that was specified when sending
851 * IM message.
852 * @param status Delivery status.
853 * @param reason Delivery status reason.
Benny Prijono0a982002007-06-12 16:22:09 +0000854 * @param tdata The original MESSAGE request.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000855 * @param rdata The incoming MESSAGE response, or NULL if the
856 * message transaction fails because of time out
857 * or transport error.
858 */
859 void (*on_pager_status2)(pjsua_call_id call_id,
860 const pj_str_t *to,
861 const pj_str_t *body,
862 void *user_data,
863 pjsip_status_code status,
864 const pj_str_t *reason,
Benny Prijono0a982002007-06-12 16:22:09 +0000865 pjsip_tx_data *tdata,
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000866 pjsip_rx_data *rdata);
867
868 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000869 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +0000870 *
871 * @param call_id Containts the ID of the call where the IM was
872 * sent, or PJSUA_INVALID_ID if the IM was sent
873 * outside call context.
874 * @param from URI of the sender.
875 * @param to URI of the destination message.
876 * @param contact The Contact URI of the sender, if present.
877 * @param is_typing Non-zero if peer is typing, or zero if peer
878 * has stopped typing a message.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000879 *
880 * \par Python Syntax
881 * \code
882 # call_id: string
883 # from: string
884 # to: string
885 # contact: string
886 # is_typing: integer
887
888 def on_typing(call_id, from, to, contact, is_typing):
889 return
890 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000891 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000892 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
893 const pj_str_t *to, const pj_str_t *contact,
894 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000895
Benny Prijono6ba8c542007-10-16 01:34:14 +0000896 /**
897 * Callback when the library has finished performing NAT type
898 * detection.
899 *
900 * @param res NAT detection result.
901 */
902 void (*on_nat_detect)(const pj_stun_nat_detect_result *res);
903
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000904} pjsua_callback;
905
906
907
Benny Prijonodc39fe82006-05-26 12:17:46 +0000908
909/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000910 * This structure describes the settings to control the API and
911 * user agent behavior, and can be specified when calling #pjsua_init().
912 * Before setting the values, application must call #pjsua_config_default()
913 * to initialize this structure with the default values.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000914 *
915 * \par Python Sample Syntax:
916 * The pjsua_config type in Python is <tt>py_pjsua.Config</tt>. Application
917 * creates the instance by calling <tt>py_pjsua.config_default()</tt>:
918 * \code
919 cfg = py_pjsua.config_default()
920 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000921 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000922typedef struct pjsua_config
923{
924
925 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000926 * Maximum calls to support (default: 4). The value specified here
927 * must be smaller than the compile time maximum settings
928 * PJSUA_MAX_CALLS, which by default is 32. To increase this
929 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
930 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000931 */
932 unsigned max_calls;
933
934 /**
935 * Number of worker threads. Normally application will want to have at
936 * least one worker thread, unless when it wants to poll the library
937 * periodically, which in this case the worker thread can be set to
938 * zero.
939 */
940 unsigned thread_cnt;
941
942 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +0000943 * Number of nameservers. If no name server is configured, the SIP SRV
944 * resolution would be disabled, and domain will be resolved with
945 * standard pj_gethostbyname() function.
946 */
947 unsigned nameserver_count;
948
949 /**
950 * Array of nameservers to be used by the SIP resolver subsystem.
951 * The order of the name server specifies the priority (first name
952 * server will be used first, unless it is not reachable).
953 */
954 pj_str_t nameserver[4];
955
956 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000957 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000958 */
959 unsigned outbound_proxy_cnt;
960
961 /**
962 * Specify the URL of outbound proxies to visit for all outgoing requests.
963 * The outbound proxies will be used for all accounts, and it will
964 * be used to build the route set for outgoing requests. The final
965 * route set for outgoing requests will consists of the outbound proxies
966 * and the proxy configured in the account.
967 */
968 pj_str_t outbound_proxy[4];
969
Benny Prijonoc97608e2007-03-23 16:34:20 +0000970 /**
Benny Prijonoebbf6892007-03-24 17:37:25 +0000971 * Specify domain name to be resolved with DNS SRV resolution to get the
972 * address of the STUN servers. Alternatively application may specify
973 * \a stun_host and \a stun_relay_host instead.
974 *
975 * If DNS SRV resolution failed for this domain, then DNS A resolution
976 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +0000977 */
Benny Prijonoebbf6892007-03-24 17:37:25 +0000978 pj_str_t stun_domain;
979
980 /**
Benny Prijonoaf09dc32007-04-22 12:48:30 +0000981 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
982 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +0000983 */
984 pj_str_t stun_host;
985
986 /**
987 * Specify STUN relay server to be used.
988 */
989 pj_str_t stun_relay_host;
Benny Prijonoc97608e2007-03-23 16:34:20 +0000990
Benny Prijonodcfc0ba2007-09-30 16:50:27 +0000991 /**
Benny Prijono91a6a172007-10-31 08:59:29 +0000992 * Support for adding and parsing NAT type in the SDP to assist
993 * troubleshooting. The valid values are:
994 * - 0: no information will be added in SDP, and parsing is disabled.
Benny Prijono6ba8c542007-10-16 01:34:14 +0000995 * - 1: only the NAT type number is added.
996 * - 2: add both NAT type number and name.
997 *
Benny Prijono91a6a172007-10-31 08:59:29 +0000998 * Default: 1
Benny Prijono6ba8c542007-10-16 01:34:14 +0000999 */
1000 int nat_type_in_sdp;
1001
1002 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001003 * Specify whether support for reliable provisional response (100rel and
1004 * PRACK) should be required by default. Note that this setting can be
1005 * further customized in account configuration (#pjsua_acc_config).
1006 *
1007 * Default: PJ_FALSE
1008 */
1009 pj_bool_t require_100rel;
1010
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001011 /**
1012 * Number of credentials in the credential array.
1013 */
1014 unsigned cred_count;
1015
1016 /**
1017 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +00001018 * and can be used to authenticate against outbound proxies. If the
1019 * credential is specific to the account, then application should set
1020 * the credential in the pjsua_acc_config rather than the credential
1021 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001022 */
1023 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1024
1025 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001026 * Application callback to receive various event notifications from
1027 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001028 */
1029 pjsua_callback cb;
1030
Benny Prijono56315612006-07-18 14:39:40 +00001031 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001032 * Optional user agent string (default empty). If it's empty, no
1033 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +00001034 */
1035 pj_str_t user_agent;
1036
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001037} pjsua_config;
1038
1039
1040/**
1041 * Use this function to initialize pjsua config.
1042 *
1043 * @param cfg pjsua config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001044 *
1045 * \par Python Sample Syntax:
1046 * The corresponding Python function creates an instance of the config and
1047 * initializes it to the default settings:
1048 * \code
1049 cfg = py_pjsua.config_default()
1050 * \endcode
1051
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001052 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001053PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001054
1055
Benny Prijono7977f9f2007-10-10 11:37:56 +00001056/* The implementation has been moved to sip_auth.h */
1057#define pjsip_cred_dup pjsip_cred_info_dup
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001058
1059
1060/**
1061 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001062 *
1063 * @param pool The pool to get memory from.
1064 * @param dst Destination config.
1065 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001066 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001067PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1068 pjsua_config *dst,
1069 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001070
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001071
1072/**
1073 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001074 * outgoing SIP message. It can (optionally) be specified for example
1075 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1076 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1077 *
1078 * Application MUST call #pjsua_msg_data_init() to initialize this
1079 * structure before setting its values.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001080 *
1081 * \par Python Syntax
1082 * The data type in Python is <tt>py_pjsua.Msg_Data</tt>. Application is
1083 * recommended to instantiate the structure by using this construct:
1084 * \code
1085 msg_data = py_pjsua.msg_data_init()
1086 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001087 */
1088typedef struct pjsua_msg_data
1089{
1090 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001091 * Additional message headers as linked list. Application can add
1092 * headers to the list by creating the header, either from the heap/pool
1093 * or from temporary local variable, and add the header using
1094 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001095 *
1096 * \par Python:
1097 * This field is implemented as string linked-list in Python, where each
1098 * string describes the header. For example:
1099 \code
1100 msg_data = py_pjsua.Msg_Data()
1101 msg_data.hdr_list = ["Subject: Hello py_pjsua!", "Priority: very low"]
1102 \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001103 */
1104 pjsip_hdr hdr_list;
1105
1106 /**
1107 * MIME type of optional message body.
1108 */
1109 pj_str_t content_type;
1110
1111 /**
1112 * Optional message body.
1113 */
1114 pj_str_t msg_body;
1115
1116} pjsua_msg_data;
1117
1118
1119/**
1120 * Initialize message data.
1121 *
1122 * @param msg_data Message data to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001123 *
1124 * \par Python
1125 * The corresponding Python function creates and initializes the structure:
1126 * \code
1127 msg_data = py_pjsua.msg_data_init()
1128 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001129 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001130PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001131
Benny Prijono268ca612006-02-07 12:34:11 +00001132
1133/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001134 * Instantiate pjsua application. Application must call this function before
1135 * calling any other functions, to make sure that the underlying libraries
1136 * are properly initialized. Once this function has returned success,
1137 * application must call pjsua_destroy() before quitting.
1138 *
1139 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001140 *
1141 * \par Python:
1142 * \code
1143 status = py_pjsua.create()
1144 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001145 */
1146PJ_DECL(pj_status_t) pjsua_create(void);
1147
1148
Benny Prijonoe6ead542007-01-31 20:53:31 +00001149/* Forward declaration */
1150typedef struct pjsua_media_config pjsua_media_config;
1151
1152
Benny Prijonodc39fe82006-05-26 12:17:46 +00001153/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001154 * Initialize pjsua with the specified settings. All the settings are
1155 * optional, and the default values will be used when the config is not
1156 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001157 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001158 * Note that #pjsua_create() MUST be called before calling this function.
1159 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001160 * @param ua_cfg User agent configuration.
1161 * @param log_cfg Optional logging configuration.
1162 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001163 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001164 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001165 *
1166 * \par Python:
1167 * The function is similar in Python:
1168 * \code
1169 status = py_pjsua.init(ua_cfg, log_cfg, media_cfg)
1170 * \endcode
1171 * Note that \a ua_cfg, \a log_cfg, and \a media_cfg are optional, and
1172 * the Python script may pass None if it doesn't want to configure the
1173 * setting.
Benny Prijono268ca612006-02-07 12:34:11 +00001174 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001175PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1176 const pjsua_logging_config *log_cfg,
1177 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001178
1179
1180/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001181 * Application is recommended to call this function after all initialization
1182 * is done, so that the library can do additional checking set up
1183 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001184 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001185 * Application may call this function anytime after #pjsua_init().
1186 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001187 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001188 *
1189 * \par Python:
1190 * The function is similar in Python:
1191 * \code
1192 status = py_pjsua.start()
1193 * \endcode
Benny Prijonoccf95622006-02-07 18:48:01 +00001194 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001195PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001196
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001197
Benny Prijonoccf95622006-02-07 18:48:01 +00001198/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001199 * Destroy pjsua. Application is recommended to perform graceful shutdown
1200 * before calling this function (such as unregister the account from the SIP
1201 * server, terminate presense subscription, and hangup active calls), however,
1202 * this function will do all of these if it finds there are active sessions
1203 * that need to be terminated. This function will approximately block for
1204 * one second to wait for replies from remote.
1205 *
1206 * Application.may safely call this function more than once if it doesn't
1207 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001208 *
1209 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001210 *
1211 * \par Python:
1212 * The function is similar in Python:
1213 * \code
1214 status = py_pjsua.destroy()
1215 * \endcode
Benny Prijono268ca612006-02-07 12:34:11 +00001216 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001217PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001218
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001219
Benny Prijono9fc735d2006-05-28 14:58:12 +00001220/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001221 * Poll pjsua for events, and if necessary block the caller thread for
1222 * the specified maximum interval (in miliseconds).
1223 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001224 * Application doesn't normally need to call this function if it has
1225 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1226 * because polling then will be done by these worker threads instead.
1227 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001228 * @param msec_timeout Maximum time to wait, in miliseconds.
1229 *
1230 * @return The number of events that have been handled during the
1231 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001232 * can retrieve the error as (status = -return_value).
1233 *
1234 * \par Python:
1235 * The function is similar in Python:
1236 * \code
1237 n = py_pjsua.handle_events(msec_timeout)
1238 * \endcode
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001239 */
1240PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1241
1242
1243/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001244 * Create memory pool to be used by the application. Once application
1245 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001246 *
1247 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001248 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001249 * @param increment Increment size.
1250 *
1251 * @return The pool, or NULL when there's no memory.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001252 *
1253 * \par Python:
1254 * Python script may also create a pool object from the script:
1255 * \code
1256 pool = py_pjsua.pool_create(name, init_size, increment)
1257 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001258 */
1259PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1260 pj_size_t increment);
1261
1262
1263/**
1264 * Application can call this function at any time (after pjsua_create(), of
1265 * course) to change logging settings.
1266 *
1267 * @param c Logging configuration.
1268 *
1269 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001270 *
1271 * \par Python:
1272 * The function is similar in Python:
1273 * \code
1274 status = py_pjsua.reconfigure_logging(log_cfg)
1275 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001276 */
1277PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1278
1279
1280/**
1281 * Internal function to get SIP endpoint instance of pjsua, which is
1282 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001283 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001284 *
1285 * @return SIP endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001286 *
1287 * \par Python:
1288 * Application may retrieve the SIP endpoint instance:
1289 * \code
1290 endpt = py_pjsua.get_pjsip_endpt()
1291 * \endcode
1292 * However currently the object is just an opaque object and does not have
1293 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001294 */
1295PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1296
1297/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001298 * Internal function to get media endpoint instance.
1299 * Only valid after #pjsua_init() is called.
1300 *
1301 * @return Media endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001302 *
1303 * \par Python:
1304 * Application may retrieve the media endpoint instance:
1305 * \code
1306 endpt = py_pjsua.get_pjmedia_endpt()
1307 * \endcode
1308 * However currently the object is just an opaque object and does not have
1309 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001310 */
1311PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1312
Benny Prijono97b87172006-08-24 14:25:14 +00001313/**
1314 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001315 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001316 *
1317 * @return Pool factory currently used by PJSUA.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001318 *
1319 * \par Python:
1320 * Application may retrieve the pool factory instance:
1321 * \code
1322 endpt = py_pjsua.get_pool_factory()
1323 * \endcode
1324 * However currently the object is just an opaque object and does not have
1325 * any use for Python scripts.
Benny Prijono97b87172006-08-24 14:25:14 +00001326 */
1327PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1328
1329
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001330
1331/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001332 * Utilities.
1333 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001334 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001335
1336/**
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001337 * This is a utility function to detect NAT type in front of this
1338 * endpoint. Once invoked successfully, this function will complete
Benny Prijono6ba8c542007-10-16 01:34:14 +00001339 * asynchronously and report the result in \a on_nat_detect() callback
1340 * of pjsua_callback.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001341 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001342 * After NAT has been detected and the callback is called, application can
1343 * get the detected NAT type by calling #pjsua_get_nat_type(). Application
1344 * can also perform NAT detection by calling #pjsua_detect_nat_type()
1345 * again at later time.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001346 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001347 * Note that STUN must be enabled to run this function successfully.
1348 *
1349 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001350 */
Benny Prijono6ba8c542007-10-16 01:34:14 +00001351PJ_DECL(pj_status_t) pjsua_detect_nat_type(void);
1352
1353
1354/**
1355 * Get the NAT type as detected by #pjsua_detect_nat_type() function.
1356 * This function will only return useful NAT type after #pjsua_detect_nat_type()
1357 * has completed successfully and \a on_nat_detect() callback has been called.
1358 *
1359 * @param type NAT type.
1360 *
1361 * @return When detection is in progress, this function will
1362 * return PJ_EPENDING and \a type will be set to
1363 * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been
1364 * detected successfully, this function will return
1365 * PJ_SUCCESS and \a type will be set to the correct
1366 * value. Other return values indicate error and
1367 * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN.
Benny Prijono91a6a172007-10-31 08:59:29 +00001368 *
1369 * @see pjsua_call_get_rem_nat_type()
Benny Prijono6ba8c542007-10-16 01:34:14 +00001370 */
1371PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type);
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001372
1373
1374/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001375 * This is a utility function to verify that valid SIP url is given. If the
1376 * URL is valid, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001377 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001378 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001379 *
1380 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001381 *
1382 * \par Python:
1383 * \code
1384 status = py_pjsua.verify_sip_url(url)
1385 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001386 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001387PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001388
1389
1390/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001391 * This is a utility function to display error message for the specified
1392 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001393 *
1394 * @param sender The log sender field.
1395 * @param title Message title for the error.
1396 * @param status Status code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001397 *
1398 * \par Python:
1399 * \code
1400 py_pjsua.perror(sender, title, status)
1401 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001402 */
1403PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1404 pj_status_t status);
1405
1406
Benny Prijonoda9785b2007-04-02 20:43:06 +00001407/**
1408 * This is a utility function to dump the stack states to log, using
1409 * verbosity level 3.
1410 *
1411 * @param detail Will print detailed output (such as list of
1412 * SIP transactions) when non-zero.
1413 */
1414PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001415
1416/**
1417 * @}
1418 */
1419
1420
1421
1422/*****************************************************************************
1423 * TRANSPORT API
1424 */
1425
1426/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001427 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001428 * @ingroup PJSUA_LIB
1429 * @brief API for managing SIP transports
1430 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001431 *
1432 * PJSUA-API supports creating multiple transport instances, for example UDP,
1433 * TCP, and TLS transport. SIP transport must be created before adding an
1434 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001435 */
1436
1437
Benny Prijonoe6ead542007-01-31 20:53:31 +00001438/** SIP transport identification.
1439 */
Benny Prijono312aff92006-06-17 04:08:30 +00001440typedef int pjsua_transport_id;
1441
1442
1443/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001444 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001445 * and media. Before setting some values to this structure, application
1446 * MUST call #pjsua_transport_config_default() to initialize its
1447 * values with default settings.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001448 *
1449 * \par Python:
1450 * The data type in Python is <tt>py_pjsua.Transport_Config</tt>,
1451 * although application can just do this to create the instance:
1452 * \code
1453 transport_cfg = py_pjsua.transport_config_default()
1454 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001455 */
1456typedef struct pjsua_transport_config
1457{
1458 /**
1459 * UDP port number to bind locally. This setting MUST be specified
1460 * even when default port is desired. If the value is zero, the
1461 * transport will be bound to any available port, and application
1462 * can query the port by querying the transport info.
1463 */
1464 unsigned port;
1465
1466 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001467 * Optional address to advertise as the address of this transport.
1468 * Application can specify any address or hostname for this field,
1469 * for example it can point to one of the interface address in the
1470 * system, or it can point to the public address of a NAT router
1471 * where port mappings have been configured for the application.
1472 *
1473 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001474 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001475 pj_str_t public_addr;
1476
1477 /**
1478 * Optional address where the socket should be bound to. This option
1479 * SHOULD only be used to selectively bind the socket to particular
1480 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1481 * published address of a transport (the public_addr field should be
1482 * used for that purpose).
1483 *
1484 * Note that unlike public_addr field, the address (or hostname) here
1485 * MUST correspond to the actual interface address in the host, since
1486 * this address will be specified as bind() argument.
1487 */
1488 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001489
1490 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001491 * This specifies TLS settings for TLS transport. It is only be used
1492 * when this transport config is being used to create a SIP TLS
1493 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001494 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001495 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001496
Benny Prijono312aff92006-06-17 04:08:30 +00001497} pjsua_transport_config;
1498
1499
1500/**
1501 * Call this function to initialize UDP config with default values.
1502 *
1503 * @param cfg The UDP config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001504 *
1505 * \par Python:
1506 * The corresponding Python function is rather different:
1507 * \code
1508 transport_cfg = py_pjsua.transport_config_default()
1509 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001510 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001511PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001512
1513
1514/**
Benny Prijono312aff92006-06-17 04:08:30 +00001515 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001516 *
1517 * @param pool The pool.
1518 * @param dst The destination config.
1519 * @param src The source config.
1520 *
1521 * \par Python:
1522 * Not applicable. One should be able to just copy one variable instance
1523 * to another in Python.
Benny Prijono312aff92006-06-17 04:08:30 +00001524 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001525PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1526 pjsua_transport_config *dst,
1527 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001528
1529
1530/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001531 * This structure describes transport information returned by
1532 * #pjsua_transport_get_info() function.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001533 *
1534 * \par Python:
1535 * The corresponding data type in Python is <tt>py_pjsua.Transport_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001536 */
1537typedef struct pjsua_transport_info
1538{
1539 /**
1540 * PJSUA transport identification.
1541 */
1542 pjsua_transport_id id;
1543
1544 /**
1545 * Transport type.
1546 */
1547 pjsip_transport_type_e type;
1548
1549 /**
1550 * Transport type name.
1551 */
1552 pj_str_t type_name;
1553
1554 /**
1555 * Transport string info/description.
1556 */
1557 pj_str_t info;
1558
1559 /**
1560 * Transport flag (see ##pjsip_transport_flags_e).
1561 */
1562 unsigned flag;
1563
1564 /**
1565 * Local address length.
1566 */
1567 unsigned addr_len;
1568
1569 /**
1570 * Local/bound address.
1571 */
1572 pj_sockaddr local_addr;
1573
1574 /**
1575 * Published address (or transport address name).
1576 */
1577 pjsip_host_port local_name;
1578
1579 /**
1580 * Current number of objects currently referencing this transport.
1581 */
1582 unsigned usage_count;
1583
1584
1585} pjsua_transport_info;
1586
1587
1588/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001589 * Create and start a new SIP transport according to the specified
1590 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001591 *
1592 * @param type Transport type.
1593 * @param cfg Transport configuration.
1594 * @param p_id Optional pointer to receive transport ID.
1595 *
1596 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001597 *
1598 * \par Python:
1599 * The corresponding Python function returns (status,id) tuple:
1600 * \code
1601 status, transport_id = py_pjsua.transport_create(type, cfg)
1602 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001603 */
1604PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1605 const pjsua_transport_config *cfg,
1606 pjsua_transport_id *p_id);
1607
1608/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001609 * Register transport that has been created by application. This function
1610 * is useful if application wants to implement custom SIP transport and use
1611 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001612 *
1613 * @param tp Transport instance.
1614 * @param p_id Optional pointer to receive transport ID.
1615 *
1616 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001617 *
1618 * \par Python:
1619 * Not applicable (for now), because one cannot create a custom transport
1620 * from Python script.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001621 */
1622PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1623 pjsua_transport_id *p_id);
1624
1625
1626/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001627 * Enumerate all transports currently created in the system. This function
1628 * will return all transport IDs, and application may then call
1629 * #pjsua_transport_get_info() function to retrieve detailed information
1630 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001631 *
1632 * @param id Array to receive transport ids.
1633 * @param count In input, specifies the maximum number of elements.
1634 * On return, it contains the actual number of elements.
1635 *
1636 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001637 *
1638 * \par Python:
1639 * The function returns list of integers representing transport ids:
1640 * \code
1641 [int] = py_pjsua.enum_transports()
1642 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001643 */
1644PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1645 unsigned *count );
1646
1647
1648/**
1649 * Get information about transports.
1650 *
1651 * @param id Transport ID.
1652 * @param info Pointer to receive transport info.
1653 *
1654 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001655 *
1656 * \par Python:
1657 * \code
1658 transport_info = py_pjsua.transport_get_info(id)
1659 * \endcode
1660 * The Python function returns None on error.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001661 */
1662PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1663 pjsua_transport_info *info);
1664
1665
1666/**
1667 * Disable a transport or re-enable it. By default transport is always
1668 * enabled after it is created. Disabling a transport does not necessarily
1669 * close the socket, it will only discard incoming messages and prevent
1670 * the transport from being used to send outgoing messages.
1671 *
1672 * @param id Transport ID.
1673 * @param enabled Non-zero to enable, zero to disable.
1674 *
1675 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001676 *
1677 * \par Python:
1678 * \code
1679 status = py_pjsua.transport_set_enable(id, enabled)
1680 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001681 */
1682PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1683 pj_bool_t enabled);
1684
1685
1686/**
1687 * Close the transport. If transport is forcefully closed, it will be
1688 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00001689 * transport may not terminate properly (it may even crash). Otherwise,
1690 * the system will wait until all transactions are closed while preventing
1691 * new users from using the transport, and will close the transport when
1692 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001693 *
1694 * @param id Transport ID.
1695 * @param force Non-zero to immediately close the transport. This
1696 * is not recommended!
1697 *
1698 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001699 *
1700 * \par Python:
1701 * \code
1702 status = py_pjsua.transport_close(id, force)
1703 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001704 */
1705PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1706 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001707
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001708/**
Benny Prijono312aff92006-06-17 04:08:30 +00001709 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001710 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001711
1712
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001713
1714
1715/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001716 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001717 */
1718
Benny Prijono312aff92006-06-17 04:08:30 +00001719
1720/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001721 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001722 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001723 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001724 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001725 *
Benny Prijono312aff92006-06-17 04:08:30 +00001726 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001727 * using the application. In SIP terms, the identity is used as the <b>From</b>
1728 * header in outgoing requests.
1729 *
1730 * PJSUA-API supports creating and managing multiple accounts. The maximum
1731 * number of accounts is limited by a compile time constant
1732 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001733 *
1734 * Account may or may not have client registration associated with it.
1735 * An account is also associated with <b>route set</b> and some <b>authentication
1736 * credentials</b>, which are used when sending SIP request messages using the
1737 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00001738 * will be reported to remote peer when they subscribe to the account's
1739 * presence, or which is published to a presence server if presence
1740 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00001741 *
1742 * At least one account MUST be created in the application. If no user
1743 * association is required, application can create a userless account by
1744 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00001745 * instead of a particular user, and it correspond with a particular
1746 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00001747 *
1748 * Also one account must be set as the <b>default account</b>, which is used as
1749 * the account to use when PJSUA fails to match a request with any other
1750 * accounts.
1751 *
1752 * When sending outgoing SIP requests (such as making calls or sending
1753 * instant messages), normally PJSUA requires the application to specify
1754 * which account to use for the request. If no account is specified,
1755 * PJSUA may be able to select the account by matching the destination
1756 * domain name, and fall back to default account when no match is found.
1757 */
1758
1759/**
1760 * Maximum accounts.
1761 */
1762#ifndef PJSUA_MAX_ACC
1763# define PJSUA_MAX_ACC 8
1764#endif
1765
1766
1767/**
1768 * Default registration interval.
1769 */
1770#ifndef PJSUA_REG_INTERVAL
1771# define PJSUA_REG_INTERVAL 55
1772#endif
1773
1774
1775/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001776 * Default PUBLISH expiration
1777 */
1778#ifndef PJSUA_PUBLISH_EXPIRATION
1779# define PJSUA_PUBLISH_EXPIRATION 600
1780#endif
1781
1782
1783/**
Benny Prijono093d3022006-09-24 00:07:11 +00001784 * Default account priority.
1785 */
1786#ifndef PJSUA_DEFAULT_ACC_PRIORITY
1787# define PJSUA_DEFAULT_ACC_PRIORITY 0
1788#endif
1789
1790
1791/**
Benny Prijono8058a622007-06-08 04:37:05 +00001792 * This macro specifies the URI scheme to use in Contact header
1793 * when secure transport such as TLS is used. Application can specify
1794 * either "sip" or "sips".
1795 */
1796#ifndef PJSUA_SECURE_SCHEME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00001797# define PJSUA_SECURE_SCHEME "sips"
Benny Prijono8058a622007-06-08 04:37:05 +00001798#endif
1799
1800
1801/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001802 * This structure describes account configuration to be specified when
1803 * adding a new account with #pjsua_acc_add(). Application MUST initialize
1804 * this structure first by calling #pjsua_acc_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00001805 *
1806 * \par Python:
1807 * The data type in Python is <tt>py_pjsua.Acc_Config</tt>, but normally
1808 * application can just use the snippet below to create and initialize
1809 * the account config:
1810 * \code
1811 acc_cfg = py_pjsua.acc_config_default()
1812 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001813 */
1814typedef struct pjsua_acc_config
1815{
Benny Prijono093d3022006-09-24 00:07:11 +00001816 /**
1817 * Account priority, which is used to control the order of matching
1818 * incoming/outgoing requests. The higher the number means the higher
1819 * the priority is, and the account will be matched first.
1820 */
1821 int priority;
1822
Benny Prijono312aff92006-06-17 04:08:30 +00001823 /**
1824 * The full SIP URL for the account. The value can take name address or
1825 * URL format, and will look something like "sip:account@serviceprovider".
1826 *
1827 * This field is mandatory.
1828 */
1829 pj_str_t id;
1830
1831 /**
1832 * This is the URL to be put in the request URI for the registration,
1833 * and will look something like "sip:serviceprovider".
1834 *
1835 * This field should be specified if registration is desired. If the
1836 * value is empty, no account registration will be performed.
1837 */
1838 pj_str_t reg_uri;
1839
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001840 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001841 * If this flag is set, the presence information of this account will
1842 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001843 */
1844 pj_bool_t publish_enabled;
1845
Benny Prijonofe04fb52007-08-24 08:28:52 +00001846 /**
1847 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
1848 * is not specified, a random string will be used.
1849 */
1850 pj_str_t pidf_tuple_id;
1851
Benny Prijono312aff92006-06-17 04:08:30 +00001852 /**
1853 * Optional URI to be put as Contact for this account. It is recommended
1854 * that this field is left empty, so that the value will be calculated
1855 * automatically based on the transport address.
1856 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00001857 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00001858
1859 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001860 * Specify whether support for reliable provisional response (100rel and
1861 * PRACK) should be required for all sessions of this account.
1862 *
1863 * Default: PJ_FALSE
1864 */
1865 pj_bool_t require_100rel;
1866
1867 /**
Benny Prijono312aff92006-06-17 04:08:30 +00001868 * Number of proxies in the proxy array below.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001869 *
1870 * \par Python:
1871 * Not applicable, as \a proxy is implemented as list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001872 */
1873 unsigned proxy_cnt;
1874
1875 /**
1876 * Optional URI of the proxies to be visited for all outgoing requests
1877 * that are using this account (REGISTER, INVITE, etc). Application need
1878 * to specify these proxies if the service provider requires that requests
1879 * destined towards its network should go through certain proxies first
1880 * (for example, border controllers).
1881 *
1882 * These proxies will be put in the route set for this account, with
1883 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00001884 * first). If global outbound proxies are configured in pjsua_config,
1885 * then these account proxies will be placed after the global outbound
1886 * proxies in the routeset.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001887 *
1888 * \par Python:
1889 * This will be list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001890 */
1891 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
1892
Benny Prijono2a67ea42007-10-25 02:51:33 +00001893 /**
1894 * Enable Service-Route processing for this account.
1895 */
1896 pj_bool_t enable_service_route;
1897
Benny Prijono312aff92006-06-17 04:08:30 +00001898 /**
1899 * Optional interval for registration, in seconds. If the value is zero,
1900 * default interval will be used (PJSUA_REG_INTERVAL, 55 seconds).
1901 */
1902 unsigned reg_timeout;
1903
1904 /**
1905 * Number of credentials in the credential array.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001906 *
1907 * \par Python:
1908 * Not applicable, since \a cred_info is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00001909 */
1910 unsigned cred_count;
1911
1912 /**
1913 * Array of credentials. If registration is desired, normally there should
1914 * be at least one credential specified, to successfully authenticate
1915 * against the service provider. More credentials can be specified, for
1916 * example when the requests are expected to be challenged by the
1917 * proxies in the route set.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001918 *
1919 * \par Python:
1920 * This field is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00001921 */
1922 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1923
Benny Prijono62c5c5b2007-01-13 23:22:40 +00001924 /**
1925 * Optionally bind this account to specific transport. This normally is
1926 * not a good idea, as account should be able to send requests using
1927 * any available transports according to the destination. But some
1928 * application may want to have explicit control over the transport to
1929 * use, so in that case it can set this field.
1930 *
1931 * Default: -1 (PJSUA_INVALID_ID)
1932 *
1933 * @see pjsua_acc_set_transport()
1934 */
1935 pjsua_transport_id transport_id;
1936
Benny Prijono15b02302007-09-27 14:07:07 +00001937 /**
1938 * This option is useful for keeping the UDP transport address up to
1939 * date with the NAT public mapped address. When this option is
1940 * enabled and STUN is configured, the library will keep track of
1941 * the public IP address from the response of REGISTER request. Once
1942 * it detects that the address has changed, it will unregister current
1943 * Contact, update the UDP transport address, and register a new
1944 * Contact to the registrar.
1945 *
1946 * Default: 1 (yes)
1947 */
1948 pj_bool_t auto_update_nat;
1949
Benny Prijono312aff92006-06-17 04:08:30 +00001950} pjsua_acc_config;
1951
1952
1953/**
1954 * Call this function to initialize account config with default values.
1955 *
1956 * @param cfg The account config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001957 *
1958 * \par Python:
1959 * In Python, this function both creates and initializes the account
1960 * config:
1961 * \code
1962 acc_cfg = py_pjsua.acc_config_default()
1963 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001964 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001965PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001966
1967
1968/**
1969 * Account info. Application can query account info by calling
1970 * #pjsua_acc_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00001971 *
1972 * \par Python:
1973 * The data type in Python is <tt>py_pjsua.Acc_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001974 */
1975typedef struct pjsua_acc_info
1976{
1977 /**
1978 * The account ID.
1979 */
1980 pjsua_acc_id id;
1981
1982 /**
1983 * Flag to indicate whether this is the default account.
1984 */
1985 pj_bool_t is_default;
1986
1987 /**
1988 * Account URI
1989 */
1990 pj_str_t acc_uri;
1991
1992 /**
1993 * Flag to tell whether this account has registration setting
1994 * (reg_uri is not empty).
1995 */
1996 pj_bool_t has_registration;
1997
1998 /**
1999 * An up to date expiration interval for account registration session.
2000 */
2001 int expires;
2002
2003 /**
2004 * Last registration status code. If status code is zero, the account
2005 * is currently not registered. Any other value indicates the SIP
2006 * status code of the registration.
2007 */
2008 pjsip_status_code status;
2009
2010 /**
2011 * String describing the registration status.
2012 */
2013 pj_str_t status_text;
2014
2015 /**
2016 * Presence online status for this account.
2017 */
2018 pj_bool_t online_status;
2019
2020 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00002021 * Presence online status text.
2022 */
2023 pj_str_t online_status_text;
2024
2025 /**
2026 * Extended RPID online status information.
2027 */
2028 pjrpid_element rpid;
2029
2030 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002031 * Buffer that is used internally to store the status text.
2032 */
2033 char buf_[PJ_ERR_MSG_SIZE];
2034
2035} pjsua_acc_info;
2036
2037
2038
2039/**
2040 * Get number of current accounts.
2041 *
2042 * @return Current number of accounts.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002043 *
2044 * \par Python:
2045 * \code
2046 count = py_pjsua.acc_get_count()
2047 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002048 */
2049PJ_DECL(unsigned) pjsua_acc_get_count(void);
2050
2051
2052/**
2053 * Check if the specified account ID is valid.
2054 *
2055 * @param acc_id Account ID to check.
2056 *
2057 * @return Non-zero if account ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002058 *
2059 * \par Python:
2060 * \code
2061 is_valid = py_pjsua.acc_is_valid(acc_id)
2062 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002063 */
2064PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
2065
2066
2067/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00002068 * Set default account to be used when incoming and outgoing
2069 * requests doesn't match any accounts.
2070 *
2071 * @param acc_id The account ID to be used as default.
2072 *
2073 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002074 *
2075 * \par Python:
2076 * \code
2077 status = py_pjsua.acc_set_default(acc_id)
2078 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002079 */
2080PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2081
2082
2083/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002084 * Get default account to be used when receiving incoming requests (calls),
2085 * when the destination of the incoming call doesn't match any other
2086 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002087 *
2088 * @return The default account ID, or PJSUA_INVALID_ID if no
2089 * default account is configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002090 *
2091 * \par Python:
2092 * \code
2093 acc_id = py_pjsua.acc_get_default()
2094 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002095 */
2096PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2097
2098
2099/**
Benny Prijono312aff92006-06-17 04:08:30 +00002100 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002101 * #pjsua_init()) before calling this function. If registration is configured
2102 * for this account, this function would also start the SIP registration
2103 * session with the SIP registrar server. This SIP registration session
2104 * will be maintained internally by the library, and application doesn't
2105 * need to do anything to maintain the registration session.
2106 *
Benny Prijono312aff92006-06-17 04:08:30 +00002107 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002108 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002109 * @param is_default If non-zero, this account will be set as the default
2110 * account. The default account will be used when sending
2111 * outgoing requests (e.g. making call) when no account is
2112 * specified, and when receiving incoming requests when the
2113 * request does not match any accounts. It is recommended
2114 * that default account is set to local/LAN account.
2115 * @param p_acc_id Pointer to receive account ID of the new account.
2116 *
2117 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002118 *
2119 * \par Python:
2120 * The function returns (status, account_id) tuple:
2121 * \code
2122 status, account_id = py_pjsua.acc_add(acc_cfg, is_default)
2123 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002124 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002125PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002126 pj_bool_t is_default,
2127 pjsua_acc_id *p_acc_id);
2128
2129
2130/**
2131 * Add a local account. A local account is used to identify local endpoint
2132 * instead of a specific user, and for this reason, a transport ID is needed
2133 * to obtain the local address information.
2134 *
2135 * @param tid Transport ID to generate account address.
2136 * @param is_default If non-zero, this account will be set as the default
2137 * account. The default account will be used when sending
2138 * outgoing requests (e.g. making call) when no account is
2139 * specified, and when receiving incoming requests when the
2140 * request does not match any accounts. It is recommended
2141 * that default account is set to local/LAN account.
2142 * @param p_acc_id Pointer to receive account ID of the new account.
2143 *
2144 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002145 *
2146 * \par Python:
2147 * The function returns (status, account_id) tuple:
2148 * \code
2149 status, account_id = py_pjsua.acc_add_local(tid, is_default)
2150 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002151 */
2152PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2153 pj_bool_t is_default,
2154 pjsua_acc_id *p_acc_id);
2155
2156/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002157 * Delete an account. This will unregister the account from the SIP server,
2158 * if necessary, and terminate server side presence subscriptions associated
2159 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002160 *
2161 * @param acc_id Id of the account to be deleted.
2162 *
2163 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002164 *
2165 * \par Python:
2166 * \code
2167 status = py_pjsua.acc_del(acc_id)
2168 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002169 */
2170PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2171
2172
2173/**
2174 * Modify account information.
2175 *
2176 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002177 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002178 *
2179 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002180 *
2181 * \par Python:
2182 * \code
2183 status = py_pjsua.acc_modify(acc_id, acc_cfg)
2184 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002185 */
2186PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002187 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002188
2189
2190/**
2191 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002192 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002193 * if there are server side presence subscription for this account, and/or
2194 * outgoing PUBLISH if presence publication is enabled for this account.
2195 *
2196 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002197 *
2198 * @param acc_id The account ID.
2199 * @param is_online True of false.
2200 *
2201 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002202 *
2203 * \par Python:
2204 * \code
2205 status = py_pjsua.acc_set_online_status(acc_id, is_online)
2206 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002207 */
2208PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2209 pj_bool_t is_online);
2210
Benny Prijono4461c7d2007-08-25 13:36:15 +00002211/**
2212 * Modify account's presence status to be advertised to remote/presence
2213 * subscribers. This would trigger the sending of outgoing NOTIFY request
2214 * if there are server side presence subscription for this account, and/or
2215 * outgoing PUBLISH if presence publication is enabled for this account.
2216 *
2217 * @see pjsua_acc_set_online_status()
2218 *
2219 * @param acc_id The account ID.
2220 * @param is_online True of false.
2221 * @param pr Extended information in subset of RPID format
2222 * which allows setting custom presence text.
2223 *
2224 * @return PJ_SUCCESS on success, or the appropriate error code.
2225 */
2226PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2227 pj_bool_t is_online,
2228 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002229
2230/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002231 * Update registration or perform unregistration. If registration is
2232 * configured for this account, then initial SIP REGISTER will be sent
2233 * when the account is added with #pjsua_acc_add(). Application normally
2234 * only need to call this function if it wants to manually update the
2235 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002236 *
2237 * @param acc_id The account ID.
2238 * @param renew If renew argument is zero, this will start
2239 * unregistration process.
2240 *
2241 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002242 *
2243 * \par Python:
2244 * \code
2245 status = py_pjsua.acc_set_registration(acc_id, renew)
2246 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002247 */
2248PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2249 pj_bool_t renew);
2250
2251
2252/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002253 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002254 *
2255 * @param acc_id Account identification.
2256 * @param info Pointer to receive account information.
2257 *
2258 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002259 *
2260 * \par Python:
2261 * \code
2262 acc_info = py_pjsua.acc_get_info(acc_id)
2263 * \endcode
2264 * The function returns None if account ID is not valid.
Benny Prijono312aff92006-06-17 04:08:30 +00002265 */
2266PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2267 pjsua_acc_info *info);
2268
2269
2270/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002271 * Enumerate all account currently active in the library. This will fill
2272 * the array with the account Ids, and application can then query the
2273 * account information for each id with #pjsua_acc_get_info().
2274 *
2275 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002276 *
2277 * @param ids Array of account IDs to be initialized.
2278 * @param count In input, specifies the maximum number of elements.
2279 * On return, it contains the actual number of elements.
2280 *
2281 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002282 *
2283 * \par Python:
2284 * The function takes no argument and returns list of account Ids:
2285 * \code
2286 [acc_ids] = py_pjsua.enum_accs()
2287 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002288 */
2289PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2290 unsigned *count );
2291
2292
2293/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002294 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002295 *
2296 * @param info Array of account infos to be initialized.
2297 * @param count In input, specifies the maximum number of elements.
2298 * On return, it contains the actual number of elements.
2299 *
2300 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002301 *
2302 * \par Python:
2303 * The function takes no argument and returns list of account infos:
2304 * \code
2305 [acc_info] = py_pjsua.acc_enum_info()
2306 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002307 */
2308PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2309 unsigned *count );
2310
2311
2312/**
2313 * This is an internal function to find the most appropriate account to
2314 * used to reach to the specified URL.
2315 *
2316 * @param url The remote URL to reach.
2317 *
2318 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002319 *
2320 * \par Python:
2321 * \code
2322 acc_id = py_pjsua.acc_find_for_outgoing(url)
2323 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002324 */
2325PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2326
2327
2328/**
2329 * This is an internal function to find the most appropriate account to be
2330 * used to handle incoming calls.
2331 *
2332 * @param rdata The incoming request message.
2333 *
2334 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002335 *
2336 * \par Python:
2337 * \code
2338 acc_id = py_pjsua.acc_find_for_outgoing(url)
2339 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002340 */
2341PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2342
2343
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002344/**
Benny Prijonofff245c2007-04-02 11:44:47 +00002345 * Create arbitrary requests using the account. Application should only use
2346 * this function to create auxiliary requests outside dialog, such as
2347 * OPTIONS, and use the call or presence API to create dialog related
2348 * requests.
2349 *
2350 * @param acc_id The account ID.
2351 * @param method The SIP method of the request.
2352 * @param target Target URI.
2353 * @param p_tdata Pointer to receive the request.
2354 *
2355 * @return PJ_SUCCESS or the error code.
2356 */
2357PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
2358 const pjsip_method *method,
2359 const pj_str_t *target,
2360 pjsip_tx_data **p_tdata);
2361
2362
2363/**
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002364 * Create a suitable URI to be put as Contact based on the specified
2365 * target URI for the specified account.
2366 *
2367 * @param pool Pool to allocate memory for the string.
2368 * @param contact The string where the Contact URI will be stored.
2369 * @param acc_id Account ID.
2370 * @param uri Destination URI of the request.
2371 *
2372 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002373 *
2374 * \par Python:
2375 * This function is still experimental in Python:
2376 * \code
2377 uri = py_pjsua.acc_create_uac_contact(pool, acc_id, uri)
2378 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002379 */
2380PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
2381 pj_str_t *contact,
2382 pjsua_acc_id acc_id,
2383 const pj_str_t *uri);
2384
2385
2386
2387/**
2388 * Create a suitable URI to be put as Contact based on the information
2389 * in the incoming request.
2390 *
2391 * @param pool Pool to allocate memory for the string.
2392 * @param contact The string where the Contact URI will be stored.
2393 * @param acc_id Account ID.
2394 * @param rdata Incoming request.
2395 *
2396 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002397 *
2398 * \par Python:
2399 * This function is still experimental in Python:
2400 * \code
2401 uri = py_pjsua.acc_create_uas_contact(pool, acc_id, rdata)
2402 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002403 */
2404PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
2405 pj_str_t *contact,
2406 pjsua_acc_id acc_id,
2407 pjsip_rx_data *rdata );
2408
2409
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002410/**
2411 * Lock/bind this account to a specific transport/listener. Normally
2412 * application shouldn't need to do this, as transports will be selected
2413 * automatically by the stack according to the destination.
2414 *
2415 * When account is locked/bound to a specific transport, all outgoing
2416 * requests from this account will use the specified transport (this
2417 * includes SIP registration, dialog (call and event subscription), and
2418 * out-of-dialog requests such as MESSAGE).
2419 *
2420 * Note that transport_id may be specified in pjsua_acc_config too.
2421 *
2422 * @param acc_id The account ID.
2423 * @param tp_id The transport ID.
2424 *
2425 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002426 *
2427 * \par Python:
2428 * Not yet implemented.
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002429 */
2430PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
2431 pjsua_transport_id tp_id);
2432
Benny Prijono312aff92006-06-17 04:08:30 +00002433
2434/**
2435 * @}
2436 */
2437
2438
2439/*****************************************************************************
2440 * CALLS API
2441 */
2442
2443
2444/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002445 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00002446 * @ingroup PJSUA_LIB
2447 * @brief Call manipulation.
2448 * @{
2449 */
2450
2451/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002452 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00002453 */
2454#ifndef PJSUA_MAX_CALLS
2455# define PJSUA_MAX_CALLS 32
2456#endif
2457
2458
2459
2460/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002461 * This enumeration specifies the media status of a call, and it's part
2462 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00002463 */
2464typedef enum pjsua_call_media_status
2465{
Benny Prijonob5388cf2007-01-04 22:45:08 +00002466 /** Call currently has no media */
Benny Prijono312aff92006-06-17 04:08:30 +00002467 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002468
2469 /** The media is active */
Benny Prijono312aff92006-06-17 04:08:30 +00002470 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002471
2472 /** The media is currently put on hold by local endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002473 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002474
2475 /** The media is currently put on hold by remote endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002476 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002477
Benny Prijono096c56c2007-09-15 08:30:16 +00002478 /** The media has reported error (e.g. ICE negotiation) */
2479 PJSUA_CALL_MEDIA_ERROR
2480
Benny Prijono312aff92006-06-17 04:08:30 +00002481} pjsua_call_media_status;
2482
2483
2484/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002485 * This structure describes the information and current status of a call.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002486 *
2487 * \par Python:
2488 * The type name is <tt>py_pjsua.Call_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002489 */
2490typedef struct pjsua_call_info
2491{
2492 /** Call identification. */
2493 pjsua_call_id id;
2494
2495 /** Initial call role (UAC == caller) */
2496 pjsip_role_e role;
2497
Benny Prijono90315512006-09-14 16:05:16 +00002498 /** The account ID where this call belongs. */
2499 pjsua_acc_id acc_id;
2500
Benny Prijono312aff92006-06-17 04:08:30 +00002501 /** Local URI */
2502 pj_str_t local_info;
2503
2504 /** Local Contact */
2505 pj_str_t local_contact;
2506
2507 /** Remote URI */
2508 pj_str_t remote_info;
2509
2510 /** Remote contact */
2511 pj_str_t remote_contact;
2512
2513 /** Dialog Call-ID string. */
2514 pj_str_t call_id;
2515
2516 /** Call state */
2517 pjsip_inv_state state;
2518
2519 /** Text describing the state */
2520 pj_str_t state_text;
2521
2522 /** Last status code heard, which can be used as cause code */
2523 pjsip_status_code last_status;
2524
2525 /** The reason phrase describing the status. */
2526 pj_str_t last_status_text;
2527
2528 /** Call media status. */
2529 pjsua_call_media_status media_status;
2530
2531 /** Media direction */
2532 pjmedia_dir media_dir;
2533
2534 /** The conference port number for the call */
2535 pjsua_conf_port_id conf_slot;
2536
2537 /** Up-to-date call connected duration (zero when call is not
2538 * established)
2539 */
2540 pj_time_val connect_duration;
2541
2542 /** Total call duration, including set-up time */
2543 pj_time_val total_duration;
2544
2545 /** Internal */
2546 struct {
2547 char local_info[128];
2548 char local_contact[128];
2549 char remote_info[128];
2550 char remote_contact[128];
2551 char call_id[128];
2552 char last_status_text[128];
2553 } buf_;
2554
2555} pjsua_call_info;
2556
2557
2558
Benny Prijonoa91a0032006-02-26 21:23:45 +00002559/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002560 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002561 *
2562 * @return Maximum number of calls configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002563 *
2564 * \par Python:
2565 * \code
2566 count = py_pjsua.call_get_max_count()
2567 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002568 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002569PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002570
2571/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002572 * Get number of currently active calls.
2573 *
2574 * @return Number of currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002575 *
2576 * \par Python:
2577 * \code
2578 count = py_pjsua.call_get_count()
2579 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002580 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002581PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002582
2583/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002584 * Enumerate all active calls. Application may then query the information and
2585 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002586 *
2587 * @param ids Array of account IDs to be initialized.
2588 * @param count In input, specifies the maximum number of elements.
2589 * On return, it contains the actual number of elements.
2590 *
2591 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002592 *
2593 * \par Python:
2594 * This function takes no argument and return list of call Ids.
2595 * \code
2596 [call_ids] = py_pjsua.enum_calls()
2597 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002598 */
2599PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
2600 unsigned *count);
2601
2602
2603/**
2604 * Make outgoing call to the specified URI using the specified account.
2605 *
2606 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002607 * @param dst_uri URI to be put in the To header (normally is the same
2608 * as the target URI).
2609 * @param options Options (must be zero at the moment).
2610 * @param user_data Arbitrary user data to be attached to the call, and
2611 * can be retrieved later.
2612 * @param msg_data Optional headers etc to be added to outgoing INVITE
2613 * request, or NULL if no custom header is desired.
2614 * @param p_call_id Pointer to receive call identification.
2615 *
2616 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002617 *
2618 * \par Python:
2619 * The Python function returns (status, call_id) tuple:
2620 * \code
2621 status, call_id = py_pjsua.call_make_call(acc_id, dst_uri, options,
2622 user_data, msg_data)
2623 * \endcode
2624 * Note: the \a user_data in Python function is an integer, and the
2625 * \a msg_data can be set to None if not required.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002626 */
2627PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
2628 const pj_str_t *dst_uri,
2629 unsigned options,
2630 void *user_data,
2631 const pjsua_msg_data *msg_data,
2632 pjsua_call_id *p_call_id);
2633
2634
2635/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002636 * Check if the specified call has active INVITE session and the INVITE
2637 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002638 *
2639 * @param call_id Call identification.
2640 *
2641 * @return Non-zero if call is active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002642 *
2643 * \par Python:
2644 * \code
2645 bool = py_pjsua.call_is_active(call_id)
2646 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002647 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002648PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002649
2650
2651/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002652 * Check if call has an active media session.
2653 *
2654 * @param call_id Call identification.
2655 *
2656 * @return Non-zero if yes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002657 *
2658 * \par Python:
2659 * \code
2660 bool = py_pjsua.call_has_media(call_id)
2661 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002662 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002663PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002664
2665
2666/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002667 * Get the conference port identification associated with the call.
2668 *
2669 * @param call_id Call identification.
2670 *
2671 * @return Conference port ID, or PJSUA_INVALID_ID when the
2672 * media has not been established or is not active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002673 *
2674 * \par Python:
2675 * \code
2676 slot = py_pjsua.call_get_conf_port(call_id)
2677 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002678 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002679PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
2680
2681/**
2682 * Obtain detail information about the specified call.
2683 *
2684 * @param call_id Call identification.
2685 * @param info Call info to be initialized.
2686 *
2687 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002688 *
2689 * \par Python:
2690 * \code
2691 call_info = py_pjsua.call_get_info(call_id)
2692 * \endcode
2693 * \a call_info return value will be set to None if call_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002694 */
2695PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002696 pjsua_call_info *info);
2697
2698
2699/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002700 * Attach application specific data to the call. Application can then
2701 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002702 *
2703 * @param call_id Call identification.
2704 * @param user_data Arbitrary data to be attached to the call.
2705 *
2706 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002707 *
2708 * \par Python:
2709 * \code
2710 status = py_pjsua.call_set_user_data(call_id, user_data)
2711 * \endcode
2712 * The \a user_data is an integer in the Python function.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002713 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002714PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
2715 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002716
2717
2718/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002719 * Get user data attached to the call, which has been previously set with
2720 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002721 *
2722 * @param call_id Call identification.
2723 *
2724 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002725 *
2726 * \par Python:
2727 * \code
2728 user_data = py_pjsua.call_get_user_data(call_id)
2729 * \endcode
2730 * The \a user_data is an integer.
Benny Prijono268ca612006-02-07 12:34:11 +00002731 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002732PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00002733
2734
2735/**
Benny Prijono91a6a172007-10-31 08:59:29 +00002736 * Get the NAT type of remote's endpoint. This is a proprietary feature
2737 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
2738 * is set in #pjsua_config.
2739 *
2740 * This function can only be called after SDP has been received from remote,
2741 * which means for incoming call, this function can be called as soon as
2742 * call is received as long as incoming call contains SDP, and for outgoing
2743 * call, this function can be called only after SDP is received (normally in
2744 * 200/OK response to INVITE). As a general case, application should call
2745 * this function after or in \a on_call_media_state() callback.
2746 *
2747 * @param call_id Call identification.
2748 * @param p_type Pointer to store the NAT type. Application can then
2749 * retrieve the string description of the NAT type
2750 * by calling pj_stun_get_nat_name().
2751 *
2752 * @return PJ_SUCCESS on success.
2753 *
2754 * @see pjsua_get_nat_type(), nat_type_in_sdp
2755 */
2756PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
2757 pj_stun_nat_type *p_type);
2758
2759/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002760 * Send response to incoming INVITE request. Depending on the status
2761 * code specified as parameter, this function may send provisional
2762 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002763 *
2764 * @param call_id Incoming call identification.
2765 * @param code Status code, (100-699).
2766 * @param reason Optional reason phrase. If NULL, default text
2767 * will be used.
2768 * @param msg_data Optional list of headers etc to be added to outgoing
2769 * response message.
2770 *
2771 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002772 *
2773 * \par Python:
2774 * \code
2775 status = py_pjsua.call_answer(call_id, code, reason, msg_data)
2776 * \endcode
2777 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijonoa91a0032006-02-26 21:23:45 +00002778 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002779PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
2780 unsigned code,
2781 const pj_str_t *reason,
2782 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00002783
2784/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002785 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00002786 * call state. This function is different than answering the call with
2787 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
2788 * will hangup the call regardless of the state and role of the call,
2789 * while #pjsua_call_answer() only works with incoming calls on EARLY
2790 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002791 *
2792 * @param call_id Call identification.
2793 * @param code Optional status code to be sent when we're rejecting
2794 * incoming call. If the value is zero, "603/Decline"
2795 * will be sent.
2796 * @param reason Optional reason phrase to be sent when we're rejecting
2797 * incoming call. If NULL, default text will be used.
2798 * @param msg_data Optional list of headers etc to be added to outgoing
2799 * request/response message.
2800 *
2801 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002802 *
2803 * \par Python:
2804 * \code
2805 status = py_pjsua.call_hangup(call_id, code, reason, msg_data)
2806 * \endcode
2807 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002808 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002809PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
2810 unsigned code,
2811 const pj_str_t *reason,
2812 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002813
2814
2815/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002816 * Put the specified call on hold. This will send re-INVITE with the
2817 * appropriate SDP to inform remote that the call is being put on hold.
2818 * The final status of the request itself will be reported on the
2819 * \a on_call_media_state() callback, which inform the application that
2820 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002821 *
2822 * @param call_id Call identification.
2823 * @param msg_data Optional message components to be sent with
2824 * the request.
2825 *
2826 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002827 *
2828 * \par Python:
2829 * \code
2830 status = py_pjsua.call_set_hold(call_id, msg_data)
2831 * \endcode
2832 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002833 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002834PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
2835 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002836
2837
2838/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002839 * Send re-INVITE to release hold.
2840 * The final status of the request itself will be reported on the
2841 * \a on_call_media_state() callback, which inform the application that
2842 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002843 *
2844 * @param call_id Call identification.
2845 * @param unhold If this argument is non-zero and the call is locally
2846 * held, this will release the local hold.
2847 * @param msg_data Optional message components to be sent with
2848 * the request.
2849 *
2850 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002851 *
2852 * \par Python:
2853 * \code
2854 status = py_pjsua.call_reinvite(call_id, unhold, msg_data)
2855 * \endcode
2856 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002857 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002858PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
2859 pj_bool_t unhold,
2860 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002861
Benny Prijonoc08682e2007-10-04 06:17:58 +00002862/**
2863 * Send UPDATE request.
2864 *
2865 * @param call_id Call identification.
2866 * @param options Must be zero for now.
2867 * @param msg_data Optional message components to be sent with
2868 * the request.
2869 *
2870 * @return PJ_SUCCESS on success, or the appropriate error code.
2871 */
2872PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
2873 unsigned options,
2874 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002875
2876/**
Benny Prijono053f5222006-11-11 16:16:04 +00002877 * Initiate call transfer to the specified address. This function will send
2878 * REFER request to instruct remote call party to initiate a new INVITE
2879 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002880 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00002881 * If application is interested to monitor the successfulness and
2882 * the progress of the transfer request, it can implement
2883 * \a on_call_transfer_status() callback which will report the progress
2884 * of the call transfer request.
2885 *
Benny Prijono053f5222006-11-11 16:16:04 +00002886 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002887 * @param dest Address of new target to be contacted.
2888 * @param msg_data Optional message components to be sent with
2889 * the request.
2890 *
2891 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002892 *
2893 * \par Python:
2894 * \code
2895 status = py_pjsua.call_xfer(call_id, dest, msg_data)
2896 * \endcode
2897 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002898 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002899PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
2900 const pj_str_t *dest,
2901 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002902
2903/**
Benny Prijono053f5222006-11-11 16:16:04 +00002904 * Flag to indicate that "Require: replaces" should not be put in the
2905 * outgoing INVITE request caused by REFER request created by
2906 * #pjsua_call_xfer_replaces().
2907 */
2908#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
2909
2910/**
2911 * Initiate attended call transfer. This function will send REFER request
2912 * to instruct remote call party to initiate new INVITE session to the URL
2913 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
2914 * the call with us with the new call from the REFER recipient.
2915 *
2916 * @param call_id The call id to be transfered.
2917 * @param dest_call_id The call id to be replaced.
2918 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
2919 * to suppress the inclusion of "Require: replaces" in
2920 * the outgoing INVITE request created by the REFER
2921 * request.
2922 * @param msg_data Optional message components to be sent with
2923 * the request.
2924 *
2925 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002926 *
2927 * \par Python:
2928 * \code
2929 status = py_pjsua.call_xfer_replaces(call_id, dest_call_id, options, msg_data)
2930 * \endcode
2931 * Argument \a msg_data may be set to None if not required.
Benny Prijono053f5222006-11-11 16:16:04 +00002932 */
2933PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
2934 pjsua_call_id dest_call_id,
2935 unsigned options,
2936 const pjsua_msg_data *msg_data);
2937
2938/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002939 * Send DTMF digits to remote using RFC 2833 payload formats.
2940 *
2941 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002942 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002943 *
2944 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002945 *
2946 * \par Python:
2947 * \code
2948 status = py_pjsua.call_dial_dtmf(call_id, digits)
2949 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002950 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002951PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002952 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00002953
Benny Prijono26ff9062006-02-21 23:47:00 +00002954/**
Benny Prijonob0808372006-03-02 21:18:58 +00002955 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002956 *
2957 * @param call_id Call identification.
2958 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
2959 * assumed.
2960 * @param content The message content.
2961 * @param msg_data Optional list of headers etc to be included in outgoing
2962 * request. The body descriptor in the msg_data is
2963 * ignored.
2964 * @param user_data Optional user data, which will be given back when
2965 * the IM callback is called.
2966 *
2967 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002968 *
2969 * \par Python:
2970 * \code
2971 status = py_pjsua.call_send_im(call_id, mime_type, content, msg_data, user_data)
2972 * \endcode
2973 * Note that the \a user_data argument is an integer in Python.
Benny Prijonob0808372006-03-02 21:18:58 +00002974 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002975PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
2976 const pj_str_t *mime_type,
2977 const pj_str_t *content,
2978 const pjsua_msg_data *msg_data,
2979 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00002980
2981
2982/**
2983 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002984 *
2985 * @param call_id Call identification.
2986 * @param is_typing Non-zero to indicate to remote that local person is
2987 * currently typing an IM.
2988 * @param msg_data Optional list of headers etc to be included in outgoing
2989 * request.
2990 *
2991 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002992 *
2993 * \par Python:
2994 * \code
2995 status = py_pjsua.call_send_typing_ind(call_id, is_typing, msg_data)
2996 * \endcode
2997 * Argument \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00002998 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002999PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
3000 pj_bool_t is_typing,
3001 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003002
3003/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00003004 * Send arbitrary request with the call. This is useful for example to send
3005 * INFO request. Note that application should not use this function to send
3006 * requests which would change the invite session's state, such as re-INVITE,
3007 * UPDATE, PRACK, and BYE.
3008 *
3009 * @param call_id Call identification.
3010 * @param method SIP method of the request.
3011 * @param msg_data Optional message body and/or list of headers to be
3012 * included in outgoing request.
3013 *
3014 * @return PJ_SUCCESS on success, or the appropriate error code.
3015 */
3016PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
3017 const pj_str_t *method,
3018 const pjsua_msg_data *msg_data);
3019
3020
3021/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003022 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
3023 * currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003024 *
3025 * \par Python:
3026 * \code
3027 py_pjsua.call_hangup_all()
3028 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003029 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00003030PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00003031
3032
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003033/**
3034 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003035 *
3036 * @param call_id Call identification.
3037 * @param with_media Non-zero to include media information too.
3038 * @param buffer Buffer where the statistics are to be written to.
3039 * @param maxlen Maximum length of buffer.
3040 * @param indent Spaces for left indentation.
3041 *
3042 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003043 *
3044 * \par Python:
3045 * \code
3046 string = py_pjsua.call_dump(call_id, with_media, max_len, indent)
3047 * \endcode
3048 * The \a max_len argument is the desired maximum length to be allocated.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003049 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003050PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
3051 pj_bool_t with_media,
3052 char *buffer,
3053 unsigned maxlen,
3054 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003055
Benny Prijono9fc735d2006-05-28 14:58:12 +00003056/**
Benny Prijono312aff92006-06-17 04:08:30 +00003057 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003058 */
Benny Prijono834aee32006-02-19 01:38:06 +00003059
3060
3061/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00003062 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00003063 */
3064
Benny Prijono312aff92006-06-17 04:08:30 +00003065
3066/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003067 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00003068 * @ingroup PJSUA_LIB
3069 * @brief Buddy management, buddy's presence, and instant messaging.
3070 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00003071 *
3072 * This section describes PJSUA-APIs related to buddies management,
3073 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00003074 */
3075
3076/**
3077 * Max buddies in buddy list.
3078 */
3079#ifndef PJSUA_MAX_BUDDIES
3080# define PJSUA_MAX_BUDDIES 256
3081#endif
3082
3083
3084/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003085 * This structure describes buddy configuration when adding a buddy to
3086 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
3087 * the structure with #pjsua_buddy_config_default() to initialize this
3088 * structure with default configuration.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003089 *
3090 * \par Python:
3091 * In Python this structure is <tt>py_pjsua.Buddy_Config</tt>. However
3092 * it is recommended that application instantiates the buddy config
3093 * by calling:
3094 * \code
3095 buddy_cfg = py_pjsua.buddy_config_default()
3096 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003097 */
3098typedef struct pjsua_buddy_config
3099{
3100 /**
3101 * Buddy URL or name address.
3102 */
3103 pj_str_t uri;
3104
3105 /**
3106 * Specify whether presence subscription should start immediately.
3107 */
3108 pj_bool_t subscribe;
3109
3110} pjsua_buddy_config;
3111
3112
3113/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003114 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003115 */
3116typedef enum pjsua_buddy_status
3117{
3118 /**
3119 * Online status is unknown (possibly because no presence subscription
3120 * has been established).
3121 */
3122 PJSUA_BUDDY_STATUS_UNKNOWN,
3123
3124 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003125 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003126 */
3127 PJSUA_BUDDY_STATUS_ONLINE,
3128
3129 /**
3130 * Buddy is offline.
3131 */
3132 PJSUA_BUDDY_STATUS_OFFLINE,
3133
3134} pjsua_buddy_status;
3135
3136
3137
3138/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003139 * This structure describes buddy info, which can be retrieved by calling
3140 * #pjsua_buddy_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003141 *
3142 * \par Python:
3143 * This structure in Python is <tt>py_pjsua.Buddy_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003144 */
3145typedef struct pjsua_buddy_info
3146{
3147 /**
3148 * The buddy ID.
3149 */
3150 pjsua_buddy_id id;
3151
3152 /**
3153 * The full URI of the buddy, as specified in the configuration.
3154 */
3155 pj_str_t uri;
3156
3157 /**
3158 * Buddy's Contact, only available when presence subscription has
3159 * been established to the buddy.
3160 */
3161 pj_str_t contact;
3162
3163 /**
3164 * Buddy's online status.
3165 */
3166 pjsua_buddy_status status;
3167
3168 /**
3169 * Text to describe buddy's online status.
3170 */
3171 pj_str_t status_text;
3172
3173 /**
3174 * Flag to indicate that we should monitor the presence information for
3175 * this buddy (normally yes, unless explicitly disabled).
3176 */
3177 pj_bool_t monitor_pres;
3178
3179 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003180 * Extended RPID information about the person.
3181 */
3182 pjrpid_element rpid;
3183
3184 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003185 * Internal buffer.
3186 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003187 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003188
3189} pjsua_buddy_info;
3190
3191
Benny Prijono834aee32006-02-19 01:38:06 +00003192/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003193 * Set default values to the buddy config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003194 *
3195 * \par Python:
3196 * \code
3197 buddy_cfg = py_pjsua.buddy_config_default()
3198 * \endcode
Benny Prijonob5388cf2007-01-04 22:45:08 +00003199 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003200PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003201
3202
3203/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003204 * Get total number of buddies.
3205 *
3206 * @return Number of buddies.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003207 *
3208 * \par Python:
3209 * \code
3210 buddy_count = py_pjsua.get_buddy_count()
3211 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003212 */
3213PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3214
3215
3216/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003217 * Check if buddy ID is valid.
3218 *
3219 * @param buddy_id Buddy ID to check.
3220 *
3221 * @return Non-zero if buddy ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003222 *
3223 * \par Python:
3224 * \code
3225 is_valid = py_pjsua.buddy_is_valid(buddy_id)
3226 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003227 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003228PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3229
3230
3231/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003232 * Enumerate all buddy IDs in the buddy list. Application then can use
3233 * #pjsua_buddy_get_info() to get the detail information for each buddy
3234 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003235 *
3236 * @param ids Array of ids to be initialized.
3237 * @param count On input, specifies max elements in the array.
3238 * On return, it contains actual number of elements
3239 * that have been initialized.
3240 *
3241 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003242 *
3243 * \par Python:
3244 * The Python function takes no argument and returns list of buddy IDs:
3245 * \code
3246 [buddy_ids] = py_pjsua.enum_buddies()
3247 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003248 */
3249PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3250 unsigned *count);
3251
3252/**
3253 * Get detailed buddy info.
3254 *
3255 * @param buddy_id The buddy identification.
3256 * @param info Pointer to receive information about buddy.
3257 *
3258 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003259 *
3260 * \par Python:
3261 * \code
3262 buddy_info = py_pjsua.buddy_get_info(buddy_id)
3263 * \endcode
3264 * The function returns None if buddy_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003265 */
3266PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003267 pjsua_buddy_info *info);
3268
3269/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003270 * Add new buddy to the buddy list. If presence subscription is enabled
3271 * for this buddy, this function will also start the presence subscription
3272 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003273 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003274 * @param buddy)cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003275 * @param p_buddy_id Pointer to receive buddy ID.
3276 *
3277 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003278 *
3279 * \par Python:
3280 * The function returns (status, buddy_id) tuple:
3281 * \code
3282 status, buddy_id = py_pjsua.buddy_add(buddy_cfg)
3283 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003284 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003285PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003286 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003287
3288
3289/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003290 * Delete the specified buddy from the buddy list. Any presence subscription
3291 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003292 *
3293 * @param buddy_id Buddy identification.
3294 *
3295 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003296 *
3297 * \par Python:
3298 * \code
3299 status = py_pjsua.buddy_del(buddy_id)
3300 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +00003301 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003302PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003303
3304
3305/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003306 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3307 * subscribed, application will be informed about buddy's presence status
3308 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003309 *
3310 * @param buddy_id Buddy identification.
3311 * @param subscribe Specify non-zero to activate presence subscription to
3312 * the specified buddy.
3313 *
3314 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003315 *
3316 * \par Python:
3317 * \code
3318 status = py_pjsua.buddy_subscribe_pres(buddy_id, subscribe)
3319 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003320 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003321PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3322 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003323
3324
3325/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003326 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003327 *
3328 * @param verbose Yes or no.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003329 *
3330 * \par Python:
3331 * \code
3332 py_pjsua.pres_dump()
3333 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003334 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003335PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003336
3337
Benny Prijonob0808372006-03-02 21:18:58 +00003338/**
3339 * The MESSAGE method (defined in pjsua_im.c)
3340 */
3341extern const pjsip_method pjsip_message_method;
3342
3343
Benny Prijonob0808372006-03-02 21:18:58 +00003344
3345/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003346 * Send instant messaging outside dialog, using the specified account for
3347 * route set and authentication.
3348 *
3349 * @param acc_id Account ID to be used to send the request.
3350 * @param to Remote URI.
3351 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3352 * assumed.
3353 * @param content The message content.
3354 * @param msg_data Optional list of headers etc to be included in outgoing
3355 * request. The body descriptor in the msg_data is
3356 * ignored.
3357 * @param user_data Optional user data, which will be given back when
3358 * the IM callback is called.
3359 *
3360 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003361 *
3362 * \par Python:
3363 * \code
3364 status = py_pjsua.im_send(acc_id, to, mime_type, content, msg_data, user_data)
3365 * \endcode
3366 * Arguments \a mime_type and \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003367 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003368PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3369 const pj_str_t *to,
3370 const pj_str_t *mime_type,
3371 const pj_str_t *content,
3372 const pjsua_msg_data *msg_data,
3373 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003374
3375
3376/**
3377 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003378 *
3379 * @param acc_id Account ID to be used to send the request.
3380 * @param to Remote URI.
3381 * @param is_typing If non-zero, it tells remote person that local person
3382 * is currently composing an IM.
3383 * @param msg_data Optional list of headers etc to be added to outgoing
3384 * request.
3385 *
3386 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003387 *
3388 * \par Python:
3389 * \code
3390 status = py_pjsua.im_typing(acc_id, to, is_typing, msg_data)
3391 * \endcode
3392 * Argument \a msg_data may be set to None if not requried.
Benny Prijonob0808372006-03-02 21:18:58 +00003393 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003394PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3395 const pj_str_t *to,
3396 pj_bool_t is_typing,
3397 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003398
3399
Benny Prijonof3195072006-02-14 21:15:30 +00003400
Benny Prijono312aff92006-06-17 04:08:30 +00003401/**
3402 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003403 */
3404
Benny Prijono312aff92006-06-17 04:08:30 +00003405
3406/*****************************************************************************
3407 * MEDIA API
3408 */
3409
3410
3411/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003412 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003413 * @ingroup PJSUA_LIB
3414 * @brief Media manipulation.
3415 * @{
3416 *
3417 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003418 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3419 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003420 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003421 * the interconnection between these terminations freely.
3422 *
3423 * The conference bridge provides powerful switching and mixing functionality
3424 * for application. With the conference bridge, each conference slot (e.g.
3425 * a call) can transmit to multiple destinations, and one destination can
3426 * receive from multiple sources. If more than one media terminations are
3427 * terminated in the same slot, the conference bridge will mix the signal
3428 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00003429 *
3430 * Application connects one media termination/slot to another by calling
3431 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003432 * media flow from the source termination to the sink termination. To
3433 * establish bidirectional media flow, application wound need to make another
3434 * call to #pjsua_conf_connect(), this time inverting the source and
3435 * destination slots in the parameter.
3436 *
3437 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00003438 * the following steps:
3439 *
3440 \code
3441
3442 pj_status_t stream_to_call( pjsua_call_id call_id )
3443 {
3444 pjsua_player_id player_id;
3445
3446 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
3447 if (status != PJ_SUCCESS)
3448 return status;
3449
3450 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
3451 pjsua_call_get_conf_port() );
3452 }
3453 \endcode
3454 *
3455 *
3456 * Other features of PJSUA media:
3457 * - efficient N to M interconnections between media terminations.
3458 * - media termination can be connected to itself to create loopback
3459 * media.
3460 * - the media termination may have different clock rates, and resampling
3461 * will be done automatically by conference bridge.
3462 * - media terminations may also have different frame time; the
3463 * conference bridge will perform the necessary bufferring to adjust
3464 * the difference between terminations.
3465 * - interconnections are removed automatically when media termination
3466 * is removed from the bridge.
3467 * - sound device may be changed even when there are active media
3468 * interconnections.
3469 * - correctly report call's media quality (in #pjsua_call_dump()) from
3470 * RTCP packet exchange.
3471 */
3472
3473/**
3474 * Max ports in the conference bridge.
3475 */
3476#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00003477# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00003478#endif
3479
Benny Prijonob5388cf2007-01-04 22:45:08 +00003480/**
3481 * The default clock rate to be used by the conference bridge.
3482 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003483#ifndef PJSUA_DEFAULT_CLOCK_RATE
3484# define PJSUA_DEFAULT_CLOCK_RATE 16000
3485#endif
3486
Benny Prijonob5388cf2007-01-04 22:45:08 +00003487/**
3488 * Default codec quality settings.
3489 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003490#ifndef PJSUA_DEFAULT_CODEC_QUALITY
3491# define PJSUA_DEFAULT_CODEC_QUALITY 5
3492#endif
3493
Benny Prijonob5388cf2007-01-04 22:45:08 +00003494/**
3495 * Default iLBC mode.
3496 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003497#ifndef PJSUA_DEFAULT_ILBC_MODE
3498# define PJSUA_DEFAULT_ILBC_MODE 20
3499#endif
3500
Benny Prijonob5388cf2007-01-04 22:45:08 +00003501/**
3502 * The default echo canceller tail length.
3503 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003504#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijono427439c2007-10-21 09:41:24 +00003505# define PJSUA_DEFAULT_EC_TAIL_LEN 200
Benny Prijono12a669c2006-11-23 07:32:13 +00003506#endif
Benny Prijono312aff92006-06-17 04:08:30 +00003507
3508
3509/**
Benny Prijonocba59d92007-02-16 09:22:56 +00003510 * The maximum file player.
3511 */
3512#ifndef PJSUA_MAX_PLAYERS
3513# define PJSUA_MAX_PLAYERS 32
3514#endif
3515
3516
3517/**
3518 * The maximum file player.
3519 */
3520#ifndef PJSUA_MAX_RECORDERS
3521# define PJSUA_MAX_RECORDERS 32
3522#endif
3523
3524
3525/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003526 * This structure describes media configuration, which will be specified
3527 * when calling #pjsua_init(). Application MUST initialize this structure
3528 * by calling #pjsua_media_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003529 *
3530 * \par Python:
3531 * This data type in Python is <tt>py_pjsua.Media_Config</tt>. To create
3532 * an object of this type, it is recommended to call
3533 * <tt>py_pjsua.media_config_default()</tt> function instead:
3534 * \code
3535 media_cfg = py_pjsua.media_config_default()
3536 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003537 */
3538struct pjsua_media_config
3539{
3540 /**
3541 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003542 * If value is zero, default clock rate will be used
3543 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00003544 */
3545 unsigned clock_rate;
3546
3547 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003548 * Specify audio frame ptime. The value here will affect the
3549 * samples per frame of both the sound device and the conference
3550 * bridge. Specifying lower ptime will normally reduce the
3551 * latency.
3552 *
3553 * Default: 20 (miliseconds)
3554 */
3555 unsigned audio_frame_ptime;
3556
3557 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003558 * Specify maximum number of media ports to be created in the
3559 * conference bridge. Since all media terminate in the bridge
3560 * (calls, file player, file recorder, etc), the value must be
3561 * large enough to support all of them. However, the larger
3562 * the value, the more computations are performed.
3563 */
3564 unsigned max_media_ports;
3565
3566 /**
3567 * Specify whether the media manager should manage its own
3568 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
3569 * and at least one worker thread will be created too. If no,
3570 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
3571 * and no worker thread is needed.
3572 *
3573 * Normally application would say yes here, unless it wants to
3574 * run everything from a single thread.
3575 */
3576 pj_bool_t has_ioqueue;
3577
3578 /**
3579 * Specify the number of worker threads to handle incoming RTP
3580 * packets. A value of one is recommended for most applications.
3581 */
3582 unsigned thread_cnt;
3583
Benny Prijono0498d902006-06-19 14:49:14 +00003584 /**
3585 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00003586 * 5-10: resampling use large filter,
3587 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00003588 * 1-2: resampling use linear.
3589 * The media quality also sets speex codec quality/complexity to the
3590 * number.
3591 *
Benny Prijono70972992006-08-05 11:13:58 +00003592 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00003593 */
3594 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00003595
3596 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003597 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00003598 *
3599 * Default: 0 (codec specific)
3600 */
3601 unsigned ptime;
3602
3603 /**
3604 * Disable VAD?
3605 *
3606 * Default: 0 (no (meaning VAD is enabled))
3607 */
3608 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00003609
3610 /**
3611 * iLBC mode (20 or 30).
3612 *
Benny Prijono70972992006-08-05 11:13:58 +00003613 * Default: 20 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00003614 */
3615 unsigned ilbc_mode;
3616
3617 /**
3618 * Percentage of RTP packet to drop in TX direction
3619 * (to simulate packet lost).
3620 *
3621 * Default: 0
3622 */
3623 unsigned tx_drop_pct;
3624
3625 /**
3626 * Percentage of RTP packet to drop in RX direction
3627 * (to simulate packet lost).
3628 *
3629 * Default: 0
3630 */
3631 unsigned rx_drop_pct;
3632
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003633 /**
Benny Prijono5da50432006-08-07 10:24:52 +00003634 * Echo canceller options (see #pjmedia_echo_create())
3635 *
3636 * Default: 0.
3637 */
3638 unsigned ec_options;
3639
3640 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003641 * Echo canceller tail length, in miliseconds.
3642 *
Benny Prijono669643c2006-09-20 20:02:18 +00003643 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003644 */
3645 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003646
3647 /**
3648 * Jitter buffer initial prefetch delay in msec. The value must be
3649 * between jb_min_pre and jb_max_pre below.
3650 *
3651 * Default: -1 (to use default stream settings, currently 150 msec)
3652 */
3653 int jb_init;
3654
3655 /**
3656 * Jitter buffer minimum prefetch delay in msec.
3657 *
3658 * Default: -1 (to use default stream settings, currently 60 msec)
3659 */
3660 int jb_min_pre;
3661
3662 /**
3663 * Jitter buffer maximum prefetch delay in msec.
3664 *
3665 * Default: -1 (to use default stream settings, currently 240 msec)
3666 */
3667 int jb_max_pre;
3668
3669 /**
3670 * Set maximum delay that can be accomodated by the jitter buffer msec.
3671 *
3672 * Default: -1 (to use default stream settings, currently 360 msec)
3673 */
3674 int jb_max;
3675
Benny Prijonoc97608e2007-03-23 16:34:20 +00003676 /**
3677 * Enable ICE
3678 */
3679 pj_bool_t enable_ice;
3680
3681 /**
3682 * Enable ICE media relay.
3683 */
3684 pj_bool_t enable_relay;
Benny Prijono312aff92006-06-17 04:08:30 +00003685};
3686
3687
3688/**
3689 * Use this function to initialize media config.
3690 *
3691 * @param cfg The media config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003692 *
3693 * \par Python:
3694 * \code
3695 media_cfg = py_pjsua.media_config_default()
3696 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003697 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003698PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00003699
3700
3701/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003702 * This structure describes codec information, which can be retrieved by
3703 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00003704 */
3705typedef struct pjsua_codec_info
3706{
3707 /**
3708 * Codec unique identification.
3709 */
3710 pj_str_t codec_id;
3711
3712 /**
3713 * Codec priority (integer 0-255).
3714 */
3715 pj_uint8_t priority;
3716
3717 /**
3718 * Internal buffer.
3719 */
3720 char buf_[32];
3721
3722} pjsua_codec_info;
3723
3724
3725/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003726 * This structure descibes information about a particular media port that
3727 * has been registered into the conference bridge. Application can query
3728 * this info by calling #pjsua_conf_get_port_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003729 *
3730 * \par Python:
3731 * In Python, this type is <tt>py_pjsua.Conf_Port_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003732 */
3733typedef struct pjsua_conf_port_info
3734{
3735 /** Conference port number. */
3736 pjsua_conf_port_id slot_id;
3737
3738 /** Port name. */
3739 pj_str_t name;
3740
3741 /** Clock rate. */
3742 unsigned clock_rate;
3743
3744 /** Number of channels. */
3745 unsigned channel_count;
3746
3747 /** Samples per frame */
3748 unsigned samples_per_frame;
3749
3750 /** Bits per sample */
3751 unsigned bits_per_sample;
3752
3753 /** Number of listeners in the array. */
3754 unsigned listener_cnt;
3755
3756 /** Array of listeners (in other words, ports where this port is
3757 * transmitting to.
3758 */
3759 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
3760
3761} pjsua_conf_port_info;
3762
3763
3764/**
3765 * This structure holds information about custom media transport to
3766 * be registered to pjsua.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003767 *
3768 * \par Python:
3769 * Not applicable.
Benny Prijono312aff92006-06-17 04:08:30 +00003770 */
3771typedef struct pjsua_media_transport
3772{
3773 /**
3774 * Media socket information containing the address information
3775 * of the RTP and RTCP socket.
3776 */
3777 pjmedia_sock_info skinfo;
3778
3779 /**
3780 * The media transport instance.
3781 */
3782 pjmedia_transport *transport;
3783
3784} pjsua_media_transport;
3785
3786
3787
3788
Benny Prijono9fc735d2006-05-28 14:58:12 +00003789/**
3790 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003791 *
3792 * @return Maximum number of ports in the conference bridge.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003793 *
3794 * \par Python:
3795 * \code
3796 port_count = py_pjsua.conf_get_max_ports()
3797 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003798 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003799PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003800
3801
3802/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003803 * Get current number of active ports in the bridge.
3804 *
3805 * @return The number.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003806 *
3807 * \par Python:
3808 * \code
3809 count = py_pjsua.conf_get_active_ports()
3810 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003811 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003812PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
3813
3814
3815/**
3816 * Enumerate all conference ports.
3817 *
3818 * @param id Array of conference port ID to be initialized.
3819 * @param count On input, specifies max elements in the array.
3820 * On return, it contains actual number of elements
3821 * that have been initialized.
3822 *
3823 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003824 *
3825 * \par Python:
3826 * The Python functions returns list of conference port Ids:
3827 * \code
3828 [port_ids] = py_pjsua.enum_conf_ports()
3829 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003830 */
3831PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
3832 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003833
3834
3835/**
3836 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003837 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003838 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003839 * @param info Pointer to store the port info.
3840 *
3841 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003842 *
3843 * \par Python:
3844 * \code
3845 port_info = py_pjsua.conf_get_port_info(port_id)
3846 * \endcode
3847 * The function will return None if \a port_id is not valid.
Benny Prijono8b1889b2006-06-06 18:40:40 +00003848 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003849PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00003850 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003851
3852
3853/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00003854 * Add arbitrary media port to PJSUA's conference bridge. Application
3855 * can use this function to add the media port that it creates. For
3856 * media ports that are created by PJSUA-LIB (such as calls, file player,
3857 * or file recorder), PJSUA-LIB will automatically add the port to
3858 * the bridge.
3859 *
3860 * @param pool Pool to use.
3861 * @param port Media port to be added to the bridge.
3862 * @param p_id Optional pointer to receive the conference
3863 * slot id.
3864 *
3865 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003866 *
3867 * \par Python:
3868 * Not applicable (for now)
Benny Prijonoe909eac2006-07-27 22:04:56 +00003869 */
3870PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
3871 pjmedia_port *port,
3872 pjsua_conf_port_id *p_id);
3873
3874
3875/**
3876 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00003877 * call this function if it registered the port manually with previous call
3878 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00003879 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003880 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00003881 *
3882 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003883 *
3884 * \par Python:
3885 * \code
3886 status = py_pjsua.conf_remove_port(port_id)
3887 * \endcode
Benny Prijonoe909eac2006-07-27 22:04:56 +00003888 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003889PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00003890
3891
3892/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003893 * Establish unidirectional media flow from souce to sink. One source
3894 * may transmit to multiple destinations/sink. And if multiple
3895 * sources are transmitting to the same sink, the media will be mixed
3896 * together. Source and sink may refer to the same ID, effectively
3897 * looping the media.
3898 *
3899 * If bidirectional media flow is desired, application needs to call
3900 * this function twice, with the second one having the arguments
3901 * reversed.
3902 *
3903 * @param source Port ID of the source media/transmitter.
3904 * @param sink Port ID of the destination media/received.
3905 *
3906 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003907 *
3908 * \par Python:
3909 * \code
3910 status = py_pjsua.conf_connect(source, sink)
3911 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003912 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003913PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
3914 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003915
3916
3917/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003918 * Disconnect media flow from the source to destination port.
3919 *
3920 * @param source Port ID of the source media/transmitter.
3921 * @param sink Port ID of the destination media/received.
3922 *
3923 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003924 *
3925 * \par Python:
3926 * \code
3927 status = py_pjsua.conf_disconnect(source, sink)
3928 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003929 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003930PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
3931 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003932
3933
Benny Prijono6dd967c2006-12-26 02:27:14 +00003934/**
3935 * Adjust the signal level to be transmitted from the bridge to the
3936 * specified port by making it louder or quieter.
3937 *
3938 * @param slot The conference bridge slot number.
3939 * @param level Signal level adjustment. Value 1.0 means no level
3940 * adjustment, while value 0 means to mute the port.
3941 *
3942 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003943 *
3944 * \par Python:
3945 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003946 */
3947PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
3948 float level);
3949
3950/**
3951 * Adjust the signal level to be received from the specified port (to
3952 * the bridge) by making it louder or quieter.
3953 *
3954 * @param slot The conference bridge slot number.
3955 * @param level Signal level adjustment. Value 1.0 means no level
3956 * adjustment, while value 0 means to mute the port.
3957 *
3958 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003959 *
3960 * \par Python:
3961 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003962 */
3963PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
3964 float level);
3965
3966/**
3967 * Get last signal level transmitted to or received from the specified port.
3968 * The signal level is an integer value in zero to 255, with zero indicates
3969 * no signal, and 255 indicates the loudest signal level.
3970 *
3971 * @param slot The conference bridge slot number.
3972 * @param tx_level Optional argument to receive the level of signal
3973 * transmitted to the specified port (i.e. the direction
3974 * is from the bridge to the port).
3975 * @param rx_level Optional argument to receive the level of signal
3976 * received from the port (i.e. the direction is from the
3977 * port to the bridge).
3978 *
3979 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003980 *
3981 * \par Python:
3982 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003983 */
3984PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
3985 unsigned *tx_level,
3986 unsigned *rx_level);
3987
Benny Prijono6dd967c2006-12-26 02:27:14 +00003988
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003989/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00003990 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003991 */
3992
Benny Prijono9fc735d2006-05-28 14:58:12 +00003993/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003994 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003995 * the conference bridge.
3996 *
3997 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00003998 * WAV files are supported, and the WAV file MUST be
3999 * formatted as 16bit PCM mono/single channel (any
4000 * clock rate is supported).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004001 * @param options Options (currently zero).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004002 * @param p_id Pointer to receive player ID.
4003 *
4004 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004005 *
4006 * \par Python:
4007 * The function returns (status, id) tuple:
4008 * \code
4009 status, id = py_pjsua.player_create(filename, options)
4010 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004011 */
4012PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004013 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004014 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004015
4016
4017/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004018 * Create a file playlist media port, and automatically add the port
4019 * to the conference bridge.
4020 *
4021 * @param file_names Array of file names to be added to the play list.
4022 * Note that the files must have the same clock rate,
4023 * number of channels, and number of bits per sample.
4024 * @param file_count Number of files in the array.
4025 * @param label Optional label to be set for the media port.
4026 * @param options Optional option flag. Application may specify
4027 * PJMEDIA_FILE_NO_LOOP to prevent looping.
4028 * @param p_id Optional pointer to receive player ID.
4029 *
4030 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004031 *
4032 * \par Python:
4033 * Not implemented yet.
Benny Prijonoa66c3312007-01-21 23:12:40 +00004034 */
4035PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
4036 unsigned file_count,
4037 const pj_str_t *label,
4038 unsigned options,
4039 pjsua_player_id *p_id);
4040
4041/**
4042 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004043 *
4044 * @param id The file player ID.
4045 *
4046 * @return Conference port ID associated with this player.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004047 *
4048 * \par Python:
4049 * \code
4050 port_id = py_pjsua.player_get_conf_port(id)
4051 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004052 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004053PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004054
4055
4056/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004057 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00004058 *
4059 * @param id The player ID.
4060 * @param p_port The media port associated with the player.
4061 *
4062 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004063 *
4064 * \par Python:
4065 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004066 */
4067PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_recorder_id id,
4068 pjmedia_port **p_port);
4069
4070/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004071 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004072 *
4073 * @param id The file player ID.
4074 * @param samples The playback position, in samples. Application can
4075 * specify zero to re-start the playback.
4076 *
4077 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004078 *
4079 * \par Python:
4080 * \code
4081 status = py_pjsua.player_set_pos(id, samples)
4082 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004083 */
4084PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
4085 pj_uint32_t samples);
4086
4087
4088/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004089 * Close the file of playlist, remove the player from the bridge, and free
4090 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004091 *
4092 * @param id The file player ID.
4093 *
4094 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004095 *
4096 * \par Python:
4097 * \code
4098 status = py_pjsua.player_destroy(id)
4099 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004100 */
4101PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
4102
4103
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004104/*****************************************************************************
4105 * File recorder.
4106 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00004107
4108/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004109 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004110 * the conference bridge. The recorder currently supports recording WAV file.
4111 * The type of the recorder to use is determined by the extension of the file
4112 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004113 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00004114 * @param filename Output file name. The function will determine the
4115 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004116 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00004117 * @param enc_type Optionally specify the type of encoder to be used to
4118 * compress the media, if the file can support different
4119 * encodings. This value must be zero for now.
4120 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004121 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00004122 * For .WAV recorder, this value must be NULL.
4123 * @param max_size Maximum file size. Specify zero or -1 to remove size
4124 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004125 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004126 * @param p_id Pointer to receive the recorder instance.
4127 *
4128 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004129 *
4130 * \par Python:
4131 * \code
4132 status, id = py_pjsua.recorder_create(filename, enc_type, enc_param, max_size, options)
4133 * \endcode
4134 * The \a enc_param is a string in Python.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004135 */
4136PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004137 unsigned enc_type,
4138 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004139 pj_ssize_t max_size,
4140 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004141 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004142
4143
4144/**
4145 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004146 *
4147 * @param id The recorder ID.
4148 *
4149 * @return Conference port ID associated with this recorder.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004150 *
4151 * \par Python:
4152 * \code
4153 port_id = py_pjsua.recorder_get_conf_port(id)
4154 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004155 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004156PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004157
4158
4159/**
Benny Prijono469b1522006-12-26 03:05:17 +00004160 * Get the media port for the recorder.
4161 *
4162 * @param id The recorder ID.
4163 * @param p_port The media port associated with the recorder.
4164 *
4165 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004166 *
4167 * \par Python:
4168 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004169 */
4170PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4171 pjmedia_port **p_port);
4172
4173
4174/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004175 * Destroy recorder (this will complete recording).
4176 *
4177 * @param id The recorder ID.
4178 *
4179 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004180 *
4181 * \par Python:
4182 * \code
4183 status = py_pjsua.recorder_destroy(id)
4184 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004185 */
4186PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4187
4188
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004189/*****************************************************************************
4190 * Sound devices.
4191 */
4192
Benny Prijono9fc735d2006-05-28 14:58:12 +00004193/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004194 * Enum all sound devices installed in the system.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004195 *
4196 * @param info Array of info to be initialized.
4197 * @param count On input, specifies max elements in the array.
4198 * On return, it contains actual number of elements
4199 * that have been initialized.
4200 *
4201 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004202 *
4203 *
4204 * \par Python:
4205 * The function returns list of sound device info:
4206 * \code
4207 [dev_infos] = py_pjsua.enum_snd_devs()
4208 * \endcode
4209 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00004210 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004211PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4212 unsigned *count);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004213
4214
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004215
4216/**
4217 * Get currently active sound devices. If sound devices has not been created
4218 * (for example when pjsua_start() is not called), it is possible that
4219 * the function returns PJ_SUCCESS with -1 as device IDs.
4220 *
4221 * @param capture_dev On return it will be filled with device ID of the
4222 * capture device.
4223 * @param playback_dev On return it will be filled with device ID of the
4224 * device ID of the playback device.
4225 *
4226 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004227 *
4228 * \par Python:
Benny Prijonoebdf8772007-02-01 19:25:50 +00004229 * The function takes no argument and return an (integer,integer) tuple:
Benny Prijonoe6ead542007-01-31 20:53:31 +00004230 * \code
4231 capture_dev, playback_dev = py_pjsua.get_snd_dev()
4232 * \endcode
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004233 */
4234PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4235 int *playback_dev);
4236
4237
Benny Prijono9fc735d2006-05-28 14:58:12 +00004238/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004239 * Select or change sound device. Application may call this function at
4240 * any time to replace current sound device.
4241 *
4242 * @param capture_dev Device ID of the capture device.
4243 * @param playback_dev Device ID of the playback device.
4244 *
4245 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004246 *
4247 * \par Python:
4248 * \code
4249 status = py_pjsua.set_snd_dev(capture_dev, playback_dev)
4250 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004251 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004252PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4253 int playback_dev);
4254
4255
4256/**
4257 * Set pjsua to use null sound device. The null sound device only provides
4258 * the timing needed by the conference bridge, and will not interract with
4259 * any hardware.
4260 *
4261 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004262 *
4263 * \par Python:
4264 * \code
4265 status = py_pjsua.set_null_snd_dev()
4266 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004267 */
4268PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4269
4270
Benny Prijonoe909eac2006-07-27 22:04:56 +00004271/**
4272 * Disconnect the main conference bridge from any sound devices, and let
4273 * application connect the bridge to it's own sound device/master port.
4274 *
4275 * @return The port interface of the conference bridge,
4276 * so that application can connect this to it's own
4277 * sound device or master port.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004278 *
4279 * \par Python:
4280 * Not applicable (for now).
Benny Prijonoe909eac2006-07-27 22:04:56 +00004281 */
4282PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4283
4284
Benny Prijonof20687a2006-08-04 18:27:19 +00004285/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004286 * Configure the echo canceller tail length of the sound port.
Benny Prijonof20687a2006-08-04 18:27:19 +00004287 *
4288 * @param tail_ms The tail length, in miliseconds. Set to zero to
4289 * disable AEC.
Benny Prijono5da50432006-08-07 10:24:52 +00004290 * @param options Options to be passed to #pjmedia_echo_create().
4291 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004292 *
4293 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004294 *
4295 * \par Python:
4296 * \code
4297 status = py_pjsua.set_ec(tail_ms, options)
4298 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004299 */
Benny Prijono5da50432006-08-07 10:24:52 +00004300PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004301
4302
4303/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004304 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004305 *
4306 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4307 * If AEC is disabled, the value will be zero.
4308 *
4309 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004310 *
4311 * \par Python:
4312 * \code
4313 tail_ms = py_pjsua.get_ec_tail()
4314 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004315 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004316PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004317
4318
4319
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004320/*****************************************************************************
4321 * Codecs.
4322 */
4323
4324/**
4325 * Enum all supported codecs in the system.
4326 *
4327 * @param id Array of ID to be initialized.
4328 * @param count On input, specifies max elements in the array.
4329 * On return, it contains actual number of elements
4330 * that have been initialized.
4331 *
4332 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004333 *
4334 * \par Python:
4335 * This function takes no argument and returns list of codec infos:
4336 * \code
4337 [codec_info] = py_pjsua.enum_codecs()
4338 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004339 */
4340PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4341 unsigned *count );
4342
4343
4344/**
4345 * Change codec priority.
4346 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004347 * @param codec_id Codec ID, which is a string that uniquely identify
4348 * the codec (such as "speex/8000"). Please see pjsua
4349 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004350 * @param priority Codec priority, 0-255, where zero means to disable
4351 * the codec.
4352 *
4353 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004354 *
4355 * \par Python:
4356 * \code
4357 status = py_pjsua.codec_set_priority(codec_id, priority)
4358 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004359 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004360PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004361 pj_uint8_t priority );
4362
4363
4364/**
4365 * Get codec parameters.
4366 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004367 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004368 * @param param Structure to receive codec parameters.
4369 *
4370 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004371 *
4372 * \par Python:
4373 * The Python function is experimental:
4374 * \code
4375 codec_param = py_pjsua.codec_get_param(codec_id)
4376 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004377 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004378PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004379 pjmedia_codec_param *param );
4380
4381
4382/**
4383 * Set codec parameters.
4384 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004385 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004386 * @param param Codec parameter to set.
4387 *
4388 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004389 *
4390 * \par Python:
4391 * The Python function is experimental:
4392 * \code
4393 status = py_pjsua.codec_set_param(codec_id, param)
4394 * \endcode
4395
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004396 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004397PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004398 const pjmedia_codec_param *param);
4399
4400
4401
Benny Prijono9fc735d2006-05-28 14:58:12 +00004402
Benny Prijono312aff92006-06-17 04:08:30 +00004403/**
4404 * Create UDP media transports for all the calls. This function creates
4405 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00004406 *
Benny Prijono312aff92006-06-17 04:08:30 +00004407 * @param cfg Media transport configuration. The "port" field in the
4408 * configuration is used as the start port to bind the
4409 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004410 *
4411 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004412 *
4413 * \par Python:
4414 * Not implemented yet.
Benny Prijonof3195072006-02-14 21:15:30 +00004415 */
Benny Prijono312aff92006-06-17 04:08:30 +00004416PJ_DECL(pj_status_t)
4417pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00004418
Benny Prijonodc39fe82006-05-26 12:17:46 +00004419
4420/**
Benny Prijono312aff92006-06-17 04:08:30 +00004421 * Register custom media transports to be used by calls. There must
4422 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004423 *
Benny Prijono312aff92006-06-17 04:08:30 +00004424 * @param tp The media transport array.
4425 * @param count Number of elements in the array. This number MUST
4426 * match the number of maximum calls configured when
4427 * pjsua is created.
4428 * @param auto_delete Flag to indicate whether the transports should be
4429 * destroyed when pjsua is shutdown.
4430 *
4431 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004432 *
4433 * \par Python:
4434 * Note applicable.
Benny Prijonodc39fe82006-05-26 12:17:46 +00004435 */
Benny Prijono312aff92006-06-17 04:08:30 +00004436PJ_DECL(pj_status_t)
4437pjsua_media_transports_attach( pjsua_media_transport tp[],
4438 unsigned count,
4439 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00004440
4441
Benny Prijono312aff92006-06-17 04:08:30 +00004442/**
4443 * @}
4444 */
4445
Benny Prijonof3195072006-02-14 21:15:30 +00004446
Benny Prijono268ca612006-02-07 12:34:11 +00004447
Benny Prijono312aff92006-06-17 04:08:30 +00004448/**
4449 * @}
4450 */
4451
Benny Prijonoe6ead542007-01-31 20:53:31 +00004452PJ_END_DECL
4453
Benny Prijono312aff92006-06-17 04:08:30 +00004454
Benny Prijono268ca612006-02-07 12:34:11 +00004455#endif /* __PJSUA_H__ */