blob: fad79178fc8fd70bd76723954398c21816939b4a [file] [log] [blame]
Benny Prijono268ca612006-02-07 12:34:11 +00001/* $Id$ */
2/*
Benny Prijonoa771a512007-02-19 01:13:53 +00003 * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org>
Benny Prijono268ca612006-02-07 12:34:11 +00004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJSUA_H__
20#define __PJSUA_H__
21
Benny Prijono312aff92006-06-17 04:08:30 +000022/**
23 * @file pjsua.h
24 * @brief PJSUA API.
25 */
26
27
Benny Prijono268ca612006-02-07 12:34:11 +000028/* Include all PJSIP core headers. */
29#include <pjsip.h>
30
31/* Include all PJMEDIA headers. */
32#include <pjmedia.h>
33
Benny Prijono1f9afba2006-02-10 15:57:32 +000034/* Include all PJMEDIA-CODEC headers. */
35#include <pjmedia-codec.h>
36
Benny Prijono268ca612006-02-07 12:34:11 +000037/* Include all PJSIP-UA headers */
38#include <pjsip_ua.h>
39
Benny Prijono834aee32006-02-19 01:38:06 +000040/* Include all PJSIP-SIMPLE headers */
41#include <pjsip_simple.h>
42
Benny Prijono268ca612006-02-07 12:34:11 +000043/* Include all PJLIB-UTIL headers. */
44#include <pjlib-util.h>
45
46/* Include all PJLIB headers. */
47#include <pjlib.h>
48
49
Benny Prijonoe6ead542007-01-31 20:53:31 +000050PJ_BEGIN_DECL
51
52
Benny Prijono312aff92006-06-17 04:08:30 +000053/**
Benny Prijonoe6ead542007-01-31 20:53:31 +000054 * @defgroup PJSUA_LIB PJSUA API - High Level Softphone API for C/C++ and Python
Benny Prijono312aff92006-06-17 04:08:30 +000055 * @ingroup PJSIP
56 * @brief Very high level API for constructing SIP UA applications.
57 * @{
58 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000059 * @section pjsua_api_intro A SIP User Agent API for C/C++ and Python
60 *
61 * PJSUA API is very high level API, available for C/C++ and Python language,
62 * for constructing SIP multimedia user agent
Benny Prijono312aff92006-06-17 04:08:30 +000063 * applications. It wraps together the signaling and media functionalities
64 * into an easy to use call API, provides account management, buddy
65 * management, presence, instant messaging, along with multimedia
66 * features such as conferencing, file streaming, local playback,
67 * voice recording, and so on.
68 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000069 * @subsection pjsua_for_c_cpp C/C++ Binding
Benny Prijono312aff92006-06-17 04:08:30 +000070 * Application must link with <b>pjsua-lib</b> to use this API. In addition,
71 * this library depends on the following libraries:
72 * - <b>pjsip-ua</b>,
73 * - <b>pjsip-simple</b>,
74 * - <b>pjsip-core</b>,
75 * - <b>pjmedia</b>,
76 * - <b>pjmedia-codec</b>,
77 * - <b>pjlib-util</b>, and
78 * - <b>pjlib</b>,
79 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000080 * so application must also link with these libraries as well. For more
81 * information, please refer to
82 * <A HREF="http://www.pjsip.org/using.htm">Getting Started with PJSIP</A>
83 * page.
Benny Prijono312aff92006-06-17 04:08:30 +000084 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000085 * @subsection pjsua_for_python Python Binding
86 *
87 * The Python binding for PJSUA-API is implemented by <b>py_pjsua</b>
88 * module, in <tt>pjsip-apps/py_pjsua</tt> directory. This module is
89 * built by building <tt>py_pjsua</tt> project in <tt>pjsip_apps</tt>
90 * Visual Studio workspace, or by invoking the usual <tt>setup.py</tt>
91 * Python installer script.
92 *
93 * The Python script then can import the PJSUA-API Python module by
94 * using <b>import py_pjsua</b> construct as usual.
95 *
96 *
97 * @section pjsua_samples
98 *
99 * Few samples are provided both in C and Python.
100 *
101 - @ref page_pjsip_sample_simple_pjsuaua_c\n
102 Very simple SIP User Agent with registration, call, and media, using
103 PJSUA-API, all in under 200 lines of code.
104
105 - @ref page_pjsip_samples_pjsua\n
106 This is the reference implementation for PJSIP and PJMEDIA.
107 PJSUA is a console based application, designed to be simple enough
108 to be readble, but powerful enough to demonstrate all features
109 available in PJSIP and PJMEDIA.\n
110
111 - Python sample\n
112 For a real simple Python sample application, have a look at
113 <A HREF="http://www.pjsip.org/trac/browser/pjproject/trunk/pjsip-apps/src/py_pjsua/pjsua_app.py">
114 <tt>pjsip-apps/src/py_pjsua/pjsua_app.py</tt></A> file.
115
Benny Prijono312aff92006-06-17 04:08:30 +0000116 * @section root_using_pjsua_lib Using PJSUA API
117 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000118 * Please refer to @ref PJSUA_LIB_BASE on how to create and initialize the API.
119 * And then see the Modules on the bottom of this page for more information
120 * about specific subject.
Benny Prijono312aff92006-06-17 04:08:30 +0000121 */
122
Benny Prijonoa91a0032006-02-26 21:23:45 +0000123
Benny Prijonof3195072006-02-14 21:15:30 +0000124
Benny Prijono312aff92006-06-17 04:08:30 +0000125/*****************************************************************************
126 * BASE API
127 */
128
Benny Prijonof04ffdd2006-02-21 00:11:18 +0000129/**
Benny Prijonoe6ead542007-01-31 20:53:31 +0000130 * @defgroup PJSUA_LIB_BASE PJSUA-API Basic API
Benny Prijono312aff92006-06-17 04:08:30 +0000131 * @ingroup PJSUA_LIB
132 * @brief Basic application creation/initialization, logging configuration, etc.
133 * @{
134 *
135 * The base PJSUA API controls PJSUA creation, initialization, and startup, and
136 * also provides various auxiliary functions.
137 *
138 * @section using_pjsua_lib Using PJSUA Library
139 *
140 * @subsection creating_pjsua_lib Creating PJSUA
141 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000142 * Before anything else, application must create PJSUA by calling #pjsua_create()
143 * (or <tt>py_pjsua.create()</tt> from Python).
Benny Prijono312aff92006-06-17 04:08:30 +0000144 * This, among other things, will initialize PJLIB, which is crucial before
Benny Prijonoe6ead542007-01-31 20:53:31 +0000145 * any PJLIB functions can be called, PJLIB-UTIL, and create a SIP endpoint.
146 *
147 * After this function is called, application can create a memory pool (with
148 * #pjsua_pool_create()) and read configurations from command line or file to
149 * build the settings to initialize PJSUA below.
Benny Prijono312aff92006-06-17 04:08:30 +0000150 *
151 * @subsection init_pjsua_lib Initializing PJSUA
152 *
153 * After PJSUA is created, application can initialize PJSUA by calling
Benny Prijonoe6ead542007-01-31 20:53:31 +0000154 * #pjsua_init(). This function takes several optional configuration settings
155 * in the argument, if application wants to set them.
Benny Prijono312aff92006-06-17 04:08:30 +0000156 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000157 * @subsubsection init_pjsua_lib_c_cpp PJSUA-LIB Initialization (in C)
158 * Sample code to initialize PJSUA in C code:
Benny Prijono312aff92006-06-17 04:08:30 +0000159 \code
160
Benny Prijonob5388cf2007-01-04 22:45:08 +0000161 #include <pjsua-lib/pjsua.h>
162
163 #define THIS_FILE __FILE__
164
165 static pj_status_t app_init(void)
166 {
Benny Prijono312aff92006-06-17 04:08:30 +0000167 pjsua_config ua_cfg;
168 pjsua_logging_config log_cfg;
169 pjsua_media_config media_cfg;
Benny Prijonob5388cf2007-01-04 22:45:08 +0000170 pj_status_t status;
171
172 // Must create pjsua before anything else!
173 status = pjsua_create();
174 if (status != PJ_SUCCESS) {
175 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
176 return status;
177 }
Benny Prijono312aff92006-06-17 04:08:30 +0000178
179 // Initialize configs with default settings.
180 pjsua_config_default(&ua_cfg);
181 pjsua_logging_config_default(&log_cfg);
182 pjsua_media_config_default(&media_cfg);
183
184 // At the very least, application would want to override
185 // the call callbacks in pjsua_config:
186 ua_cfg.cb.on_incoming_call = ...
187 ua_cfg.cb.on_call_state = ..
188 ...
189
190 // Customize other settings (or initialize them from application specific
191 // configuration file):
192 ...
193
194 // Initialize pjsua
195 status = pjsua_init(&ua_cfg, &log_cfg, &media_cfg);
196 if (status != PJ_SUCCESS) {
197 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
198 return status;
199 }
Benny Prijonob5388cf2007-01-04 22:45:08 +0000200 .
201 ...
202 }
Benny Prijono312aff92006-06-17 04:08:30 +0000203 \endcode
204 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000205 *
206 * @subsubsection init_pjsua_lib_python PJSUA-LIB Initialization (in Python)
207 * Sample code to initialize PJSUA in Python code:
208
209 \code
210
211import py_pjsua
212
213#
214# Initialize pjsua.
215#
216def app_init():
217 # Create pjsua before anything else
218 status = py_pjsua.create()
219 if status != 0:
220 err_exit("pjsua create() error", status)
221
222 # We use default logging config for this sample
223 log_cfg = py_pjsua.logging_config_default()
224
225 # Create and initialize pjsua config
226 # Note: for this Python module, thread_cnt must be 0 since Python
227 # doesn't like to be called from alien thread (pjsua's thread
228 # in this case)
229 ua_cfg = py_pjsua.config_default()
230 ua_cfg.thread_cnt = 0
231 ua_cfg.user_agent = "PJSUA/Python 0.1"
232
233 # Override callbacks. At the very least application would want to
234 # override the call callbacks in pjsua_config
235 ua_cfg.cb.on_incoming_call = ...
236 ua_cfg.cb.on_call_state = ...
237
238 # Use default media config for this cample
239 med_cfg = py_pjsua.media_config_default()
240
241 #
242 # Initialize pjsua!!
243 #
244 status = py_pjsua.init(ua_cfg, log_cfg, med_cfg)
245 if status != 0:
246 err_exit("pjsua init() error", status)
247
248
249
250# Utility: display PJ error and exit
251#
252def err_exit(title, rc):
253 py_pjsua.perror(THIS_FILE, title, rc)
254 exit(1)
255
256 \endcode
257
258
Benny Prijono312aff92006-06-17 04:08:30 +0000259 * @subsection other_init_pjsua_lib Other Initialization
260 *
261 * After PJSUA is initialized with #pjsua_init(), application will normally
262 * need/want to perform the following tasks:
263 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000264 * - create SIP transport with #pjsua_transport_create(). Application would
265 * to call #pjsua_transport_create() for each transport types that it
266 * wants to support (for example, UDP, TCP, and TLS). Please see
Benny Prijono312aff92006-06-17 04:08:30 +0000267 * @ref PJSUA_LIB_TRANSPORT section for more info.
268 * - create one or more SIP accounts with #pjsua_acc_add() or
Benny Prijonoe6ead542007-01-31 20:53:31 +0000269 * #pjsua_acc_add_local(). The SIP account is used for registering with
270 * the SIP server, if any. Please see @ref PJSUA_LIB_ACC for more info.
Benny Prijono312aff92006-06-17 04:08:30 +0000271 * - add one or more buddies with #pjsua_buddy_add(). Please see
272 * @ref PJSUA_LIB_BUDDY section for more info.
273 * - optionally configure the sound device, codec settings, and other
274 * media settings. Please see @ref PJSUA_LIB_MEDIA for more info.
275 *
276 *
277 * @subsection starting_pjsua_lib Starting PJSUA
278 *
279 * After all initializations have been done, application must call
280 * #pjsua_start() to start PJSUA. This function will check that all settings
Benny Prijonoe6ead542007-01-31 20:53:31 +0000281 * have been properly configured, and apply default settings when they haven't,
282 * or report error status when it is unable to recover from missing settings.
Benny Prijono312aff92006-06-17 04:08:30 +0000283 *
284 * Most settings can be changed during run-time. For example, application
285 * may add, modify, or delete accounts, buddies, or change media settings
286 * during run-time.
Benny Prijonob5388cf2007-01-04 22:45:08 +0000287 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000288 * @subsubsection starting_pjsua_lib_c C Example for Starting PJSUA
Benny Prijonob5388cf2007-01-04 22:45:08 +0000289 * Sample code:
290 \code
291 static pj_status_t app_run(void)
292 {
293 pj_status_t status;
294
295 // Start pjsua
296 status = pjsua_start();
297 if (status != PJ_SUCCESS) {
298 pjsua_destroy();
299 pjsua_perror(THIS_FILE, "Error starting pjsua", status);
300 return status;
301 }
302
303 // Run application loop
304 while (1) {
305 char choice[10];
306
307 printf("Select menu: ");
308 fgets(choice, sizeof(choice), stdin);
309 ...
310 }
311 }
312 \endcode
Benny Prijonoe6ead542007-01-31 20:53:31 +0000313
314 * @subsubsection starting_pjsua_lib_python Python Example for starting PJSUA
315 * For Python, starting PJSUA-LIB takes one more step, that is to initialize
316 * Python worker thread to poll PJSUA-LIB. This step is necessary because
317 * Python doesn't like it when it is called by an "alien" thread (that is,
318 * thread that is not created using Python API).
319 *
320 * Because of this, we cannot use a worker thread in PJSUA-LIB, because then
321 * the Python callback will be called by an "alien" thread and this would
322 * crash Python (or raise assert() probably).
323 *
324 * So because worker thread is disabled, we need to create a worker thread
325 * in Python. Note that this may not be necessary if we're creating a
326 * GUI application, because then we can attach, for example, a GUI timer
327 * object to poll the PJSUA-LIB. But because we're creating a console
328 * application which will block at <tt>sys.stdin.readline()</tt>, we need
329 * to have a worker thread to poll PJSUA-LIB.
330
331 \code
332
333import thread
334
335C_QUIT = 0
336
337
338def app_start():
339 # Done with initialization, start pjsua!!
340 #
341 status = py_pjsua.start()
342 if status != 0:
343 py_pjsua.destroy()
344 err_exit("Error starting pjsua!", status)
345
346 # Start worker thread
347 thr = thread.start_new(worker_thread_main, (0,))
348
349 print "PJSUA Started!!"
350
351#
352# Worker thread function.
353# Python doesn't like it when it's called from an alien thread
354# (pjsua's worker thread, in this case), so for Python we must
355# disable worker thread in pjsua and poll pjsua from Python instead.
356#
357def worker_thread_main(arg):
358 global C_QUIT
359 thread_desc = 0
360 status = py_pjsua.thread_register("python worker", thread_desc)
361 if status != 0:
362 py_pjsua.perror(THIS_FILE, "Error registering thread", status)
363 else:
364 while C_QUIT == 0:
365 py_pjsua.handle_events(50)
366 print "Worker thread quitting.."
367 C_QUIT = 2
368
369
370 \endcode
Benny Prijonof04ffdd2006-02-21 00:11:18 +0000371 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000372
Benny Prijono312aff92006-06-17 04:08:30 +0000373/** Constant to identify invalid ID for all sorts of IDs. */
374#define PJSUA_INVALID_ID (-1)
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000375
376/** Call identification */
377typedef int pjsua_call_id;
378
Benny Prijono312aff92006-06-17 04:08:30 +0000379/** Account identification */
380typedef int pjsua_acc_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000381
382/** Buddy identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000383typedef int pjsua_buddy_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000384
385/** File player identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000386typedef int pjsua_player_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000387
388/** File recorder identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000389typedef int pjsua_recorder_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000390
391/** Conference port identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000392typedef int pjsua_conf_port_id;
393
394
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000395
Benny Prijonoa91a0032006-02-26 21:23:45 +0000396/**
Benny Prijono312aff92006-06-17 04:08:30 +0000397 * Maximum proxies in account.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000398 */
Benny Prijono312aff92006-06-17 04:08:30 +0000399#ifndef PJSUA_ACC_MAX_PROXIES
400# define PJSUA_ACC_MAX_PROXIES 8
401#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000402
403
404
405/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000406 * Logging configuration, which can be (optionally) specified when calling
407 * #pjsua_init(). Application must call #pjsua_logging_config_default() to
408 * initialize this structure with the default values.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000409 *
410 * \par Sample Python Syntax:
411 * \code
412 # Python type: py_pjsua.Logging_Config
413
414 log_cfg = py_pjsua.logging_config_default()
415 log_cfg.level = 4
416 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000417 */
418typedef struct pjsua_logging_config
419{
420 /**
421 * Log incoming and outgoing SIP message? Yes!
422 */
423 pj_bool_t msg_logging;
424
425 /**
426 * Input verbosity level. Value 5 is reasonable.
427 */
428 unsigned level;
429
430 /**
431 * Verbosity level for console. Value 4 is reasonable.
432 */
433 unsigned console_level;
434
435 /**
436 * Log decoration.
437 */
438 unsigned decor;
439
440 /**
441 * Optional log filename.
442 */
443 pj_str_t log_filename;
444
445 /**
446 * Optional callback function to be called to write log to
447 * application specific device. This function will be called for
448 * log messages on input verbosity level.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000449 *
450 * \par Sample Python Syntax:
451 * \code
452 # level: integer
453 # data: string
454 # len: integer
455
456 def cb(level, data, len):
457 print data,
458 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000459 */
460 void (*cb)(int level, const char *data, pj_size_t len);
461
462
463} pjsua_logging_config;
464
465
466/**
467 * Use this function to initialize logging config.
468 *
469 * @param cfg The logging config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000470 *
471 * \par Python Syntax:
472 * The Python function instantiates and initialize the logging config:
473 * \code
474 logging_cfg = py_pjsua.logging_config_default()
475 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000476 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000477PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000478
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000479
480/**
481 * Use this function to duplicate logging config.
482 *
483 * @param pool Pool to use.
484 * @param dst Destination config.
485 * @param src Source config.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000486 *
487 * \par Python Syntax:
488 * Not available (for now). Ideally we should be able to just assign
489 * one config to another, but this has not been tested.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000490 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000491PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool,
492 pjsua_logging_config *dst,
493 const pjsua_logging_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000494
Benny Prijonodc39fe82006-05-26 12:17:46 +0000495
496/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000497 * This structure describes application callback to receive various event
498 * notification from PJSUA-API. All of these callbacks are OPTIONAL,
499 * although definitely application would want to implement some of
500 * the important callbacks (such as \a on_incoming_call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000501 *
502 * \par Python Syntax:
503 * This callback structure is embedded on pjsua_config structure.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000504 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000505typedef struct pjsua_callback
Benny Prijonodc39fe82006-05-26 12:17:46 +0000506{
507 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000508 * Notify application when invite state has changed.
509 * Application may then query the call info to get the
Benny Prijonoe6ead542007-01-31 20:53:31 +0000510 * detail call states by calling pjsua_call_get_info() function.
Benny Prijono0875ae82006-12-26 00:11:48 +0000511 *
512 * @param call_id The call index.
513 * @param e Event which causes the call state to change.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000514 *
515 * \par Python Syntax:
516 * \code
517 # call_id: integer
518 # e: an opaque object
519
520 def on_call_state(call_id, e):
521 return
522 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000523 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000524 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000525
526 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000527 * Notify application on incoming call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000528 *
529 * @param acc_id The account which match the incoming call.
530 * @param call_id The call id that has just been created for
531 * the call.
532 * @param rdata The incoming INVITE request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000533 *
534 * \par Python Syntax:
535 * \code
536 # acc_id: integer
537 # call_id: integer
538 # rdata: an opaque object
539
540 def on_incoming_call(acc_id, call_id, rdata):
541 return
542 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +0000543 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000544 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000545 pjsip_rx_data *rdata);
546
547 /**
Benny Prijonofeb69f42007-10-05 09:12:26 +0000548 * This is a general notification callback which is called whenever
549 * a transaction within the call has changed state. Application can
550 * implement this callback for example to monitor the state of
551 * outgoing requests, or to answer unhandled incoming requests
552 * (such as INFO) with a final response.
553 *
554 * @param call_id Call identification.
555 * @param tsx The transaction which has changed state.
556 * @param e Transaction event that caused the state change.
557 */
558 void (*on_call_tsx_state)(pjsua_call_id call_id,
559 pjsip_transaction *tsx,
560 pjsip_event *e);
561
562 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000563 * Notify application when media state in the call has changed.
564 * Normal application would need to implement this callback, e.g.
565 * to connect the call's media to sound device.
Benny Prijono0875ae82006-12-26 00:11:48 +0000566 *
567 * @param call_id The call index.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000568 *
569 * \par Python Syntax:
570 * \code
571 # call_id: integer
572
573 def on_call_media_state(call_id):
574 return
575 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000576 */
577 void (*on_call_media_state)(pjsua_call_id call_id);
578
579 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000580 * Notify application upon incoming DTMF digits.
581 *
582 * @param call_id The call index.
583 * @param digit DTMF ASCII digit.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000584 *
585 * \par Python Syntax:
586 * \code
587 # call_id: integer
Benny Prijono1f63cc42007-09-10 16:54:22 +0000588 # digit: digit string
Benny Prijonoe6ead542007-01-31 20:53:31 +0000589
590 def on_dtmf_digit(call_id, digit):
591 return
592 * \endcode
Benny Prijono0875ae82006-12-26 00:11:48 +0000593 */
594 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
595
596 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000597 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000598 * Application can decide to accept/reject transfer request
599 * by setting the code (default is 200). When this callback
600 * is not defined, the default behavior is to accept the
601 * transfer.
Benny Prijono0875ae82006-12-26 00:11:48 +0000602 *
603 * @param call_id The call index.
604 * @param dst The destination where the call will be
605 * transfered to.
606 * @param code Status code to be returned for the call transfer
607 * request. On input, it contains status code 200.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000608 *
609 * \par Python Syntax:
610 * \code
611 # call_id: integer
612 # dst: string
613 # code: integer
614
615 def on_call_transfer_request(call_id, dst, code):
616 return code
617
618 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000619 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000620 void (*on_call_transfer_request)(pjsua_call_id call_id,
621 const pj_str_t *dst,
622 pjsip_status_code *code);
623
624 /**
625 * Notify application of the status of previously sent call
626 * transfer request. Application can monitor the status of the
627 * call transfer request, for example to decide whether to
628 * terminate existing call.
629 *
630 * @param call_id Call ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000631 * @param st_code Status progress of the transfer request.
632 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000633 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000634 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000635 * this callback is the final status.
636 * @param p_cont Initially will be set to non-zero, application
637 * can set this to FALSE if it no longer wants
638 * to receie further notification (for example,
639 * after it hangs up the call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000640 *
641 * \par Python Syntax:
642 * \code
643 # call_id: integer
644 # st_code: integer
645 # st_text: string
646 # final: integer
647 # cont: integer
648
649 # return: cont
650
651 def on_call_transfer_status(call_id, st_code, st_text, final, cont):
652 return cont
653 * \endcode
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000654 */
655 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000656 int st_code,
657 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000658 pj_bool_t final,
659 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000660
661 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000662 * Notify application about incoming INVITE with Replaces header.
663 * Application may reject the request by setting non-2xx code.
664 *
665 * @param call_id The call ID to be replaced.
666 * @param rdata The incoming INVITE request to replace the call.
667 * @param st_code Status code to be set by application. Application
668 * should only return a final status (200-699).
669 * @param st_text Optional status text to be set by application.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000670 *
671 * \par Python Syntax:
672 * \code
673 # call_id: integer
674 # rdata: an opaque object
675 # st_code: integer
676 # st_text: string
677
678 # return: (st_code, st_text) tuple
679
680 def on_call_replace_request(call_id, rdata, st_code, st_text):
681 return st_code, st_text
682 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000683 */
684 void (*on_call_replace_request)(pjsua_call_id call_id,
685 pjsip_rx_data *rdata,
686 int *st_code,
687 pj_str_t *st_text);
688
689 /**
690 * Notify application that an existing call has been replaced with
691 * a new call. This happens when PJSUA-API receives incoming INVITE
692 * request with Replaces header.
693 *
694 * After this callback is called, normally PJSUA-API will disconnect
695 * \a old_call_id and establish \a new_call_id.
696 *
697 * @param old_call_id Existing call which to be replaced with the
698 * new call.
699 * @param new_call_id The new call.
700 * @param rdata The incoming INVITE with Replaces request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000701 *
702 * \par Python Syntax:
703 * \code
704 # old_call_id: integer
705 # new_call_id: integer
706
707 def on_call_replaced(old_call_id, new_call_id):
708 return
709 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000710 */
711 void (*on_call_replaced)(pjsua_call_id old_call_id,
712 pjsua_call_id new_call_id);
713
714
715 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000716 * Notify application when registration status has changed.
717 * Application may then query the account info to get the
718 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000719 *
720 * @param acc_id Account ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000721 *
722 * \par Python Syntax:
723 * \code
724 # acc_id: account ID (integer)
725
726 def on_reg_state(acc_id):
727 return
728 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000729 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000730 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000731
732 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000733 * Notify application when the buddy state has changed.
734 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000735 *
736 * @param buddy_id The buddy id.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000737 *
738 * \par Python Syntax:
739 * \code
740 # buddy_id: integer
741
742 def on_buddy_state(buddy_id):
743 return
744 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000745 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000746 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000747
748 /**
749 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000750 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000751 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000752 *
Benny Prijonobbeb3992007-05-21 13:48:35 +0000753 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
754 * passed as one of the argument.
755 *
Benny Prijono0875ae82006-12-26 00:11:48 +0000756 * @param call_id Containts the ID of the call where the IM was
757 * sent, or PJSUA_INVALID_ID if the IM was sent
758 * outside call context.
759 * @param from URI of the sender.
760 * @param to URI of the destination message.
761 * @param contact The Contact URI of the sender, if present.
762 * @param mime_type MIME type of the message.
763 * @param body The message content.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000764 *
765 * \par Python Syntax:
766 * \code
767 # call_id: integer
768 # from: string
769 # to: string
770 # contact: string
771 # mime_type: string
772 # body: string
773
774 def on_pager(call_id, from, to, contact, mime_type, body):
775 return
776 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000777 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000778 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
779 const pj_str_t *to, const pj_str_t *contact,
780 const pj_str_t *mime_type, const pj_str_t *body);
781
782 /**
Benny Prijonobbeb3992007-05-21 13:48:35 +0000783 * This is the alternative version of the \a on_pager() callback with
784 * \a pjsip_rx_data argument.
785 *
786 * @param call_id Containts the ID of the call where the IM was
787 * sent, or PJSUA_INVALID_ID if the IM was sent
788 * outside call context.
789 * @param from URI of the sender.
790 * @param to URI of the destination message.
791 * @param contact The Contact URI of the sender, if present.
792 * @param mime_type MIME type of the message.
793 * @param body The message content.
794 * @param rdata The incoming MESSAGE request.
795 */
796 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
797 const pj_str_t *to, const pj_str_t *contact,
798 const pj_str_t *mime_type, const pj_str_t *body,
799 pjsip_rx_data *rdata);
800
801 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000802 * Notify application about the delivery status of outgoing pager
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000803 * request. See also on_pager_status2() callback for the version with
804 * \a pjsip_rx_data in the argument list.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000805 *
806 * @param call_id Containts the ID of the call where the IM was
807 * sent, or PJSUA_INVALID_ID if the IM was sent
808 * outside call context.
809 * @param to Destination URI.
810 * @param body Message body.
811 * @param user_data Arbitrary data that was specified when sending
812 * IM message.
813 * @param status Delivery status.
814 * @param reason Delivery status reason.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000815 *
816 * \par Python Syntax
817 * \code
818 # call_id: integer
819 # to: string
820 # body: string
821 # user_data: string
822 # status: integer
823 # reason: string
824
825 def on_pager_status(call_id, to, body, user_data, status, reason):
826 return
827 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000828 */
829 void (*on_pager_status)(pjsua_call_id call_id,
830 const pj_str_t *to,
831 const pj_str_t *body,
832 void *user_data,
833 pjsip_status_code status,
834 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000835
836 /**
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000837 * Notify application about the delivery status of outgoing pager
838 * request.
839 *
840 * @param call_id Containts the ID of the call where the IM was
841 * sent, or PJSUA_INVALID_ID if the IM was sent
842 * outside call context.
843 * @param to Destination URI.
844 * @param body Message body.
845 * @param user_data Arbitrary data that was specified when sending
846 * IM message.
847 * @param status Delivery status.
848 * @param reason Delivery status reason.
Benny Prijono0a982002007-06-12 16:22:09 +0000849 * @param tdata The original MESSAGE request.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000850 * @param rdata The incoming MESSAGE response, or NULL if the
851 * message transaction fails because of time out
852 * or transport error.
853 */
854 void (*on_pager_status2)(pjsua_call_id call_id,
855 const pj_str_t *to,
856 const pj_str_t *body,
857 void *user_data,
858 pjsip_status_code status,
859 const pj_str_t *reason,
Benny Prijono0a982002007-06-12 16:22:09 +0000860 pjsip_tx_data *tdata,
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000861 pjsip_rx_data *rdata);
862
863 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000864 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +0000865 *
866 * @param call_id Containts the ID of the call where the IM was
867 * sent, or PJSUA_INVALID_ID if the IM was sent
868 * outside call context.
869 * @param from URI of the sender.
870 * @param to URI of the destination message.
871 * @param contact The Contact URI of the sender, if present.
872 * @param is_typing Non-zero if peer is typing, or zero if peer
873 * has stopped typing a message.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000874 *
875 * \par Python Syntax
876 * \code
877 # call_id: string
878 # from: string
879 # to: string
880 # contact: string
881 # is_typing: integer
882
883 def on_typing(call_id, from, to, contact, is_typing):
884 return
885 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000886 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000887 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
888 const pj_str_t *to, const pj_str_t *contact,
889 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000890
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000891} pjsua_callback;
892
893
894
Benny Prijonodc39fe82006-05-26 12:17:46 +0000895
896/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000897 * This structure describes the settings to control the API and
898 * user agent behavior, and can be specified when calling #pjsua_init().
899 * Before setting the values, application must call #pjsua_config_default()
900 * to initialize this structure with the default values.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000901 *
902 * \par Python Sample Syntax:
903 * The pjsua_config type in Python is <tt>py_pjsua.Config</tt>. Application
904 * creates the instance by calling <tt>py_pjsua.config_default()</tt>:
905 * \code
906 cfg = py_pjsua.config_default()
907 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000908 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000909typedef struct pjsua_config
910{
911
912 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000913 * Maximum calls to support (default: 4). The value specified here
914 * must be smaller than the compile time maximum settings
915 * PJSUA_MAX_CALLS, which by default is 32. To increase this
916 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
917 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000918 */
919 unsigned max_calls;
920
921 /**
922 * Number of worker threads. Normally application will want to have at
923 * least one worker thread, unless when it wants to poll the library
924 * periodically, which in this case the worker thread can be set to
925 * zero.
926 */
927 unsigned thread_cnt;
928
929 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +0000930 * Number of nameservers. If no name server is configured, the SIP SRV
931 * resolution would be disabled, and domain will be resolved with
932 * standard pj_gethostbyname() function.
933 */
934 unsigned nameserver_count;
935
936 /**
937 * Array of nameservers to be used by the SIP resolver subsystem.
938 * The order of the name server specifies the priority (first name
939 * server will be used first, unless it is not reachable).
940 */
941 pj_str_t nameserver[4];
942
943 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000944 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000945 */
946 unsigned outbound_proxy_cnt;
947
948 /**
949 * Specify the URL of outbound proxies to visit for all outgoing requests.
950 * The outbound proxies will be used for all accounts, and it will
951 * be used to build the route set for outgoing requests. The final
952 * route set for outgoing requests will consists of the outbound proxies
953 * and the proxy configured in the account.
954 */
955 pj_str_t outbound_proxy[4];
956
Benny Prijonoc97608e2007-03-23 16:34:20 +0000957 /**
Benny Prijonoebbf6892007-03-24 17:37:25 +0000958 * Specify domain name to be resolved with DNS SRV resolution to get the
959 * address of the STUN servers. Alternatively application may specify
960 * \a stun_host and \a stun_relay_host instead.
961 *
962 * If DNS SRV resolution failed for this domain, then DNS A resolution
963 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +0000964 */
Benny Prijonoebbf6892007-03-24 17:37:25 +0000965 pj_str_t stun_domain;
966
967 /**
Benny Prijonoaf09dc32007-04-22 12:48:30 +0000968 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
969 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +0000970 */
971 pj_str_t stun_host;
972
973 /**
974 * Specify STUN relay server to be used.
975 */
976 pj_str_t stun_relay_host;
Benny Prijonoc97608e2007-03-23 16:34:20 +0000977
Benny Prijonodcfc0ba2007-09-30 16:50:27 +0000978 /**
979 * Specify whether support for reliable provisional response (100rel and
980 * PRACK) should be required by default. Note that this setting can be
981 * further customized in account configuration (#pjsua_acc_config).
982 *
983 * Default: PJ_FALSE
984 */
985 pj_bool_t require_100rel;
986
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000987 /**
988 * Number of credentials in the credential array.
989 */
990 unsigned cred_count;
991
992 /**
993 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +0000994 * and can be used to authenticate against outbound proxies. If the
995 * credential is specific to the account, then application should set
996 * the credential in the pjsua_acc_config rather than the credential
997 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000998 */
999 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1000
1001 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001002 * Application callback to receive various event notifications from
1003 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001004 */
1005 pjsua_callback cb;
1006
Benny Prijono56315612006-07-18 14:39:40 +00001007 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001008 * Optional user agent string (default empty). If it's empty, no
1009 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +00001010 */
1011 pj_str_t user_agent;
1012
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001013} pjsua_config;
1014
1015
1016/**
1017 * Use this function to initialize pjsua config.
1018 *
1019 * @param cfg pjsua config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001020 *
1021 * \par Python Sample Syntax:
1022 * The corresponding Python function creates an instance of the config and
1023 * initializes it to the default settings:
1024 * \code
1025 cfg = py_pjsua.config_default()
1026 * \endcode
1027
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001028 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001029PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001030
1031
1032/**
1033 * Duplicate credential.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001034 *
1035 * @param pool The memory pool.
1036 * @param dst Destination credential.
1037 * @param src Source credential.
1038 *
1039 * \par Python:
1040 * Not applicable (for now). Probably we could just assign one credential
1041 * variable to another, but this has not been tested.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001042 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001043PJ_DECL(void) pjsip_cred_dup( pj_pool_t *pool,
1044 pjsip_cred_info *dst,
1045 const pjsip_cred_info *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001046
1047
1048/**
1049 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001050 *
1051 * @param pool The pool to get memory from.
1052 * @param dst Destination config.
1053 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001054 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001055PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1056 pjsua_config *dst,
1057 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001058
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001059
1060/**
1061 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001062 * outgoing SIP message. It can (optionally) be specified for example
1063 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1064 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1065 *
1066 * Application MUST call #pjsua_msg_data_init() to initialize this
1067 * structure before setting its values.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001068 *
1069 * \par Python Syntax
1070 * The data type in Python is <tt>py_pjsua.Msg_Data</tt>. Application is
1071 * recommended to instantiate the structure by using this construct:
1072 * \code
1073 msg_data = py_pjsua.msg_data_init()
1074 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001075 */
1076typedef struct pjsua_msg_data
1077{
1078 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001079 * Additional message headers as linked list. Application can add
1080 * headers to the list by creating the header, either from the heap/pool
1081 * or from temporary local variable, and add the header using
1082 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001083 *
1084 * \par Python:
1085 * This field is implemented as string linked-list in Python, where each
1086 * string describes the header. For example:
1087 \code
1088 msg_data = py_pjsua.Msg_Data()
1089 msg_data.hdr_list = ["Subject: Hello py_pjsua!", "Priority: very low"]
1090 \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001091 */
1092 pjsip_hdr hdr_list;
1093
1094 /**
1095 * MIME type of optional message body.
1096 */
1097 pj_str_t content_type;
1098
1099 /**
1100 * Optional message body.
1101 */
1102 pj_str_t msg_body;
1103
1104} pjsua_msg_data;
1105
1106
1107/**
1108 * Initialize message data.
1109 *
1110 * @param msg_data Message data to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001111 *
1112 * \par Python
1113 * The corresponding Python function creates and initializes the structure:
1114 * \code
1115 msg_data = py_pjsua.msg_data_init()
1116 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001117 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001118PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001119
Benny Prijono268ca612006-02-07 12:34:11 +00001120
1121/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001122 * Instantiate pjsua application. Application must call this function before
1123 * calling any other functions, to make sure that the underlying libraries
1124 * are properly initialized. Once this function has returned success,
1125 * application must call pjsua_destroy() before quitting.
1126 *
1127 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001128 *
1129 * \par Python:
1130 * \code
1131 status = py_pjsua.create()
1132 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001133 */
1134PJ_DECL(pj_status_t) pjsua_create(void);
1135
1136
Benny Prijonoe6ead542007-01-31 20:53:31 +00001137/* Forward declaration */
1138typedef struct pjsua_media_config pjsua_media_config;
1139
1140
Benny Prijonodc39fe82006-05-26 12:17:46 +00001141/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001142 * Initialize pjsua with the specified settings. All the settings are
1143 * optional, and the default values will be used when the config is not
1144 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001145 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001146 * Note that #pjsua_create() MUST be called before calling this function.
1147 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001148 * @param ua_cfg User agent configuration.
1149 * @param log_cfg Optional logging configuration.
1150 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001151 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001152 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001153 *
1154 * \par Python:
1155 * The function is similar in Python:
1156 * \code
1157 status = py_pjsua.init(ua_cfg, log_cfg, media_cfg)
1158 * \endcode
1159 * Note that \a ua_cfg, \a log_cfg, and \a media_cfg are optional, and
1160 * the Python script may pass None if it doesn't want to configure the
1161 * setting.
Benny Prijono268ca612006-02-07 12:34:11 +00001162 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001163PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1164 const pjsua_logging_config *log_cfg,
1165 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001166
1167
1168/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001169 * Application is recommended to call this function after all initialization
1170 * is done, so that the library can do additional checking set up
1171 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001172 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001173 * Application may call this function anytime after #pjsua_init().
1174 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001175 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001176 *
1177 * \par Python:
1178 * The function is similar in Python:
1179 * \code
1180 status = py_pjsua.start()
1181 * \endcode
Benny Prijonoccf95622006-02-07 18:48:01 +00001182 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001183PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001184
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001185
Benny Prijonoccf95622006-02-07 18:48:01 +00001186/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001187 * Destroy pjsua. Application is recommended to perform graceful shutdown
1188 * before calling this function (such as unregister the account from the SIP
1189 * server, terminate presense subscription, and hangup active calls), however,
1190 * this function will do all of these if it finds there are active sessions
1191 * that need to be terminated. This function will approximately block for
1192 * one second to wait for replies from remote.
1193 *
1194 * Application.may safely call this function more than once if it doesn't
1195 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001196 *
1197 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001198 *
1199 * \par Python:
1200 * The function is similar in Python:
1201 * \code
1202 status = py_pjsua.destroy()
1203 * \endcode
Benny Prijono268ca612006-02-07 12:34:11 +00001204 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001205PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001206
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001207
Benny Prijono9fc735d2006-05-28 14:58:12 +00001208/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001209 * Poll pjsua for events, and if necessary block the caller thread for
1210 * the specified maximum interval (in miliseconds).
1211 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001212 * Application doesn't normally need to call this function if it has
1213 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1214 * because polling then will be done by these worker threads instead.
1215 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001216 * @param msec_timeout Maximum time to wait, in miliseconds.
1217 *
1218 * @return The number of events that have been handled during the
1219 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001220 * can retrieve the error as (status = -return_value).
1221 *
1222 * \par Python:
1223 * The function is similar in Python:
1224 * \code
1225 n = py_pjsua.handle_events(msec_timeout)
1226 * \endcode
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001227 */
1228PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1229
1230
1231/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001232 * Create memory pool to be used by the application. Once application
1233 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001234 *
1235 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001236 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001237 * @param increment Increment size.
1238 *
1239 * @return The pool, or NULL when there's no memory.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001240 *
1241 * \par Python:
1242 * Python script may also create a pool object from the script:
1243 * \code
1244 pool = py_pjsua.pool_create(name, init_size, increment)
1245 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001246 */
1247PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1248 pj_size_t increment);
1249
1250
1251/**
1252 * Application can call this function at any time (after pjsua_create(), of
1253 * course) to change logging settings.
1254 *
1255 * @param c Logging configuration.
1256 *
1257 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001258 *
1259 * \par Python:
1260 * The function is similar in Python:
1261 * \code
1262 status = py_pjsua.reconfigure_logging(log_cfg)
1263 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001264 */
1265PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1266
1267
1268/**
1269 * Internal function to get SIP endpoint instance of pjsua, which is
1270 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001271 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001272 *
1273 * @return SIP endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001274 *
1275 * \par Python:
1276 * Application may retrieve the SIP endpoint instance:
1277 * \code
1278 endpt = py_pjsua.get_pjsip_endpt()
1279 * \endcode
1280 * However currently the object is just an opaque object and does not have
1281 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001282 */
1283PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1284
1285/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001286 * Internal function to get media endpoint instance.
1287 * Only valid after #pjsua_init() is called.
1288 *
1289 * @return Media endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001290 *
1291 * \par Python:
1292 * Application may retrieve the media endpoint instance:
1293 * \code
1294 endpt = py_pjsua.get_pjmedia_endpt()
1295 * \endcode
1296 * However currently the object is just an opaque object and does not have
1297 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001298 */
1299PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1300
Benny Prijono97b87172006-08-24 14:25:14 +00001301/**
1302 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001303 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001304 *
1305 * @return Pool factory currently used by PJSUA.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001306 *
1307 * \par Python:
1308 * Application may retrieve the pool factory instance:
1309 * \code
1310 endpt = py_pjsua.get_pool_factory()
1311 * \endcode
1312 * However currently the object is just an opaque object and does not have
1313 * any use for Python scripts.
Benny Prijono97b87172006-08-24 14:25:14 +00001314 */
1315PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1316
1317
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001318
1319/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001320 * Utilities.
1321 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001322 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001323
1324/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001325 * This is a utility function to verify that valid SIP url is given. If the
1326 * URL is valid, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001327 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001328 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001329 *
1330 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001331 *
1332 * \par Python:
1333 * \code
1334 status = py_pjsua.verify_sip_url(url)
1335 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001336 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001337PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001338
1339
1340/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001341 * This is a utility function to display error message for the specified
1342 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001343 *
1344 * @param sender The log sender field.
1345 * @param title Message title for the error.
1346 * @param status Status code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001347 *
1348 * \par Python:
1349 * \code
1350 py_pjsua.perror(sender, title, status)
1351 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001352 */
1353PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1354 pj_status_t status);
1355
1356
Benny Prijonoda9785b2007-04-02 20:43:06 +00001357/**
1358 * This is a utility function to dump the stack states to log, using
1359 * verbosity level 3.
1360 *
1361 * @param detail Will print detailed output (such as list of
1362 * SIP transactions) when non-zero.
1363 */
1364PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001365
1366/**
1367 * @}
1368 */
1369
1370
1371
1372/*****************************************************************************
1373 * TRANSPORT API
1374 */
1375
1376/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001377 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001378 * @ingroup PJSUA_LIB
1379 * @brief API for managing SIP transports
1380 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001381 *
1382 * PJSUA-API supports creating multiple transport instances, for example UDP,
1383 * TCP, and TLS transport. SIP transport must be created before adding an
1384 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001385 */
1386
1387
Benny Prijonoe6ead542007-01-31 20:53:31 +00001388/** SIP transport identification.
1389 */
Benny Prijono312aff92006-06-17 04:08:30 +00001390typedef int pjsua_transport_id;
1391
1392
1393/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001394 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001395 * and media. Before setting some values to this structure, application
1396 * MUST call #pjsua_transport_config_default() to initialize its
1397 * values with default settings.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001398 *
1399 * \par Python:
1400 * The data type in Python is <tt>py_pjsua.Transport_Config</tt>,
1401 * although application can just do this to create the instance:
1402 * \code
1403 transport_cfg = py_pjsua.transport_config_default()
1404 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001405 */
1406typedef struct pjsua_transport_config
1407{
1408 /**
1409 * UDP port number to bind locally. This setting MUST be specified
1410 * even when default port is desired. If the value is zero, the
1411 * transport will be bound to any available port, and application
1412 * can query the port by querying the transport info.
1413 */
1414 unsigned port;
1415
1416 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001417 * Optional address to advertise as the address of this transport.
1418 * Application can specify any address or hostname for this field,
1419 * for example it can point to one of the interface address in the
1420 * system, or it can point to the public address of a NAT router
1421 * where port mappings have been configured for the application.
1422 *
1423 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001424 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001425 pj_str_t public_addr;
1426
1427 /**
1428 * Optional address where the socket should be bound to. This option
1429 * SHOULD only be used to selectively bind the socket to particular
1430 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1431 * published address of a transport (the public_addr field should be
1432 * used for that purpose).
1433 *
1434 * Note that unlike public_addr field, the address (or hostname) here
1435 * MUST correspond to the actual interface address in the host, since
1436 * this address will be specified as bind() argument.
1437 */
1438 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001439
1440 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001441 * This specifies TLS settings for TLS transport. It is only be used
1442 * when this transport config is being used to create a SIP TLS
1443 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001444 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001445 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001446
Benny Prijono312aff92006-06-17 04:08:30 +00001447} pjsua_transport_config;
1448
1449
1450/**
1451 * Call this function to initialize UDP config with default values.
1452 *
1453 * @param cfg The UDP config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001454 *
1455 * \par Python:
1456 * The corresponding Python function is rather different:
1457 * \code
1458 transport_cfg = py_pjsua.transport_config_default()
1459 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001460 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001461PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001462
1463
1464/**
Benny Prijono312aff92006-06-17 04:08:30 +00001465 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001466 *
1467 * @param pool The pool.
1468 * @param dst The destination config.
1469 * @param src The source config.
1470 *
1471 * \par Python:
1472 * Not applicable. One should be able to just copy one variable instance
1473 * to another in Python.
Benny Prijono312aff92006-06-17 04:08:30 +00001474 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001475PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1476 pjsua_transport_config *dst,
1477 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001478
1479
1480/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001481 * This structure describes transport information returned by
1482 * #pjsua_transport_get_info() function.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001483 *
1484 * \par Python:
1485 * The corresponding data type in Python is <tt>py_pjsua.Transport_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001486 */
1487typedef struct pjsua_transport_info
1488{
1489 /**
1490 * PJSUA transport identification.
1491 */
1492 pjsua_transport_id id;
1493
1494 /**
1495 * Transport type.
1496 */
1497 pjsip_transport_type_e type;
1498
1499 /**
1500 * Transport type name.
1501 */
1502 pj_str_t type_name;
1503
1504 /**
1505 * Transport string info/description.
1506 */
1507 pj_str_t info;
1508
1509 /**
1510 * Transport flag (see ##pjsip_transport_flags_e).
1511 */
1512 unsigned flag;
1513
1514 /**
1515 * Local address length.
1516 */
1517 unsigned addr_len;
1518
1519 /**
1520 * Local/bound address.
1521 */
1522 pj_sockaddr local_addr;
1523
1524 /**
1525 * Published address (or transport address name).
1526 */
1527 pjsip_host_port local_name;
1528
1529 /**
1530 * Current number of objects currently referencing this transport.
1531 */
1532 unsigned usage_count;
1533
1534
1535} pjsua_transport_info;
1536
1537
1538/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001539 * Create and start a new SIP transport according to the specified
1540 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001541 *
1542 * @param type Transport type.
1543 * @param cfg Transport configuration.
1544 * @param p_id Optional pointer to receive transport ID.
1545 *
1546 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001547 *
1548 * \par Python:
1549 * The corresponding Python function returns (status,id) tuple:
1550 * \code
1551 status, transport_id = py_pjsua.transport_create(type, cfg)
1552 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001553 */
1554PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1555 const pjsua_transport_config *cfg,
1556 pjsua_transport_id *p_id);
1557
1558/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001559 * Register transport that has been created by application. This function
1560 * is useful if application wants to implement custom SIP transport and use
1561 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001562 *
1563 * @param tp Transport instance.
1564 * @param p_id Optional pointer to receive transport ID.
1565 *
1566 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001567 *
1568 * \par Python:
1569 * Not applicable (for now), because one cannot create a custom transport
1570 * from Python script.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001571 */
1572PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1573 pjsua_transport_id *p_id);
1574
1575
1576/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001577 * Enumerate all transports currently created in the system. This function
1578 * will return all transport IDs, and application may then call
1579 * #pjsua_transport_get_info() function to retrieve detailed information
1580 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001581 *
1582 * @param id Array to receive transport ids.
1583 * @param count In input, specifies the maximum number of elements.
1584 * On return, it contains the actual number of elements.
1585 *
1586 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001587 *
1588 * \par Python:
1589 * The function returns list of integers representing transport ids:
1590 * \code
1591 [int] = py_pjsua.enum_transports()
1592 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001593 */
1594PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1595 unsigned *count );
1596
1597
1598/**
1599 * Get information about transports.
1600 *
1601 * @param id Transport ID.
1602 * @param info Pointer to receive transport info.
1603 *
1604 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001605 *
1606 * \par Python:
1607 * \code
1608 transport_info = py_pjsua.transport_get_info(id)
1609 * \endcode
1610 * The Python function returns None on error.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001611 */
1612PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1613 pjsua_transport_info *info);
1614
1615
1616/**
1617 * Disable a transport or re-enable it. By default transport is always
1618 * enabled after it is created. Disabling a transport does not necessarily
1619 * close the socket, it will only discard incoming messages and prevent
1620 * the transport from being used to send outgoing messages.
1621 *
1622 * @param id Transport ID.
1623 * @param enabled Non-zero to enable, zero to disable.
1624 *
1625 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001626 *
1627 * \par Python:
1628 * \code
1629 status = py_pjsua.transport_set_enable(id, enabled)
1630 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001631 */
1632PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1633 pj_bool_t enabled);
1634
1635
1636/**
1637 * Close the transport. If transport is forcefully closed, it will be
1638 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00001639 * transport may not terminate properly (it may even crash). Otherwise,
1640 * the system will wait until all transactions are closed while preventing
1641 * new users from using the transport, and will close the transport when
1642 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001643 *
1644 * @param id Transport ID.
1645 * @param force Non-zero to immediately close the transport. This
1646 * is not recommended!
1647 *
1648 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001649 *
1650 * \par Python:
1651 * \code
1652 status = py_pjsua.transport_close(id, force)
1653 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001654 */
1655PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1656 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001657
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001658/**
Benny Prijono312aff92006-06-17 04:08:30 +00001659 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001660 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001661
1662
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001663
1664
1665/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001666 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001667 */
1668
Benny Prijono312aff92006-06-17 04:08:30 +00001669
1670/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001671 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001672 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001673 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001674 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001675 *
Benny Prijono312aff92006-06-17 04:08:30 +00001676 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001677 * using the application. In SIP terms, the identity is used as the <b>From</b>
1678 * header in outgoing requests.
1679 *
1680 * PJSUA-API supports creating and managing multiple accounts. The maximum
1681 * number of accounts is limited by a compile time constant
1682 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001683 *
1684 * Account may or may not have client registration associated with it.
1685 * An account is also associated with <b>route set</b> and some <b>authentication
1686 * credentials</b>, which are used when sending SIP request messages using the
1687 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00001688 * will be reported to remote peer when they subscribe to the account's
1689 * presence, or which is published to a presence server if presence
1690 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00001691 *
1692 * At least one account MUST be created in the application. If no user
1693 * association is required, application can create a userless account by
1694 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00001695 * instead of a particular user, and it correspond with a particular
1696 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00001697 *
1698 * Also one account must be set as the <b>default account</b>, which is used as
1699 * the account to use when PJSUA fails to match a request with any other
1700 * accounts.
1701 *
1702 * When sending outgoing SIP requests (such as making calls or sending
1703 * instant messages), normally PJSUA requires the application to specify
1704 * which account to use for the request. If no account is specified,
1705 * PJSUA may be able to select the account by matching the destination
1706 * domain name, and fall back to default account when no match is found.
1707 */
1708
1709/**
1710 * Maximum accounts.
1711 */
1712#ifndef PJSUA_MAX_ACC
1713# define PJSUA_MAX_ACC 8
1714#endif
1715
1716
1717/**
1718 * Default registration interval.
1719 */
1720#ifndef PJSUA_REG_INTERVAL
1721# define PJSUA_REG_INTERVAL 55
1722#endif
1723
1724
1725/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001726 * Default PUBLISH expiration
1727 */
1728#ifndef PJSUA_PUBLISH_EXPIRATION
1729# define PJSUA_PUBLISH_EXPIRATION 600
1730#endif
1731
1732
1733/**
Benny Prijono093d3022006-09-24 00:07:11 +00001734 * Default account priority.
1735 */
1736#ifndef PJSUA_DEFAULT_ACC_PRIORITY
1737# define PJSUA_DEFAULT_ACC_PRIORITY 0
1738#endif
1739
1740
1741/**
Benny Prijono8058a622007-06-08 04:37:05 +00001742 * This macro specifies the URI scheme to use in Contact header
1743 * when secure transport such as TLS is used. Application can specify
1744 * either "sip" or "sips".
1745 */
1746#ifndef PJSUA_SECURE_SCHEME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00001747# define PJSUA_SECURE_SCHEME "sips"
Benny Prijono8058a622007-06-08 04:37:05 +00001748#endif
1749
1750
1751/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001752 * This structure describes account configuration to be specified when
1753 * adding a new account with #pjsua_acc_add(). Application MUST initialize
1754 * this structure first by calling #pjsua_acc_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00001755 *
1756 * \par Python:
1757 * The data type in Python is <tt>py_pjsua.Acc_Config</tt>, but normally
1758 * application can just use the snippet below to create and initialize
1759 * the account config:
1760 * \code
1761 acc_cfg = py_pjsua.acc_config_default()
1762 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001763 */
1764typedef struct pjsua_acc_config
1765{
Benny Prijono093d3022006-09-24 00:07:11 +00001766 /**
1767 * Account priority, which is used to control the order of matching
1768 * incoming/outgoing requests. The higher the number means the higher
1769 * the priority is, and the account will be matched first.
1770 */
1771 int priority;
1772
Benny Prijono312aff92006-06-17 04:08:30 +00001773 /**
1774 * The full SIP URL for the account. The value can take name address or
1775 * URL format, and will look something like "sip:account@serviceprovider".
1776 *
1777 * This field is mandatory.
1778 */
1779 pj_str_t id;
1780
1781 /**
1782 * This is the URL to be put in the request URI for the registration,
1783 * and will look something like "sip:serviceprovider".
1784 *
1785 * This field should be specified if registration is desired. If the
1786 * value is empty, no account registration will be performed.
1787 */
1788 pj_str_t reg_uri;
1789
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001790 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001791 * If this flag is set, the presence information of this account will
1792 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001793 */
1794 pj_bool_t publish_enabled;
1795
Benny Prijonofe04fb52007-08-24 08:28:52 +00001796 /**
1797 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
1798 * is not specified, a random string will be used.
1799 */
1800 pj_str_t pidf_tuple_id;
1801
Benny Prijono312aff92006-06-17 04:08:30 +00001802 /**
1803 * Optional URI to be put as Contact for this account. It is recommended
1804 * that this field is left empty, so that the value will be calculated
1805 * automatically based on the transport address.
1806 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00001807 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00001808
1809 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001810 * Specify whether support for reliable provisional response (100rel and
1811 * PRACK) should be required for all sessions of this account.
1812 *
1813 * Default: PJ_FALSE
1814 */
1815 pj_bool_t require_100rel;
1816
1817 /**
Benny Prijono312aff92006-06-17 04:08:30 +00001818 * Number of proxies in the proxy array below.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001819 *
1820 * \par Python:
1821 * Not applicable, as \a proxy is implemented as list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001822 */
1823 unsigned proxy_cnt;
1824
1825 /**
1826 * Optional URI of the proxies to be visited for all outgoing requests
1827 * that are using this account (REGISTER, INVITE, etc). Application need
1828 * to specify these proxies if the service provider requires that requests
1829 * destined towards its network should go through certain proxies first
1830 * (for example, border controllers).
1831 *
1832 * These proxies will be put in the route set for this account, with
1833 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00001834 * first). If global outbound proxies are configured in pjsua_config,
1835 * then these account proxies will be placed after the global outbound
1836 * proxies in the routeset.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001837 *
1838 * \par Python:
1839 * This will be list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001840 */
1841 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
1842
1843 /**
1844 * Optional interval for registration, in seconds. If the value is zero,
1845 * default interval will be used (PJSUA_REG_INTERVAL, 55 seconds).
1846 */
1847 unsigned reg_timeout;
1848
1849 /**
1850 * Number of credentials in the credential array.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001851 *
1852 * \par Python:
1853 * Not applicable, since \a cred_info is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00001854 */
1855 unsigned cred_count;
1856
1857 /**
1858 * Array of credentials. If registration is desired, normally there should
1859 * be at least one credential specified, to successfully authenticate
1860 * against the service provider. More credentials can be specified, for
1861 * example when the requests are expected to be challenged by the
1862 * proxies in the route set.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001863 *
1864 * \par Python:
1865 * This field is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00001866 */
1867 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1868
Benny Prijono62c5c5b2007-01-13 23:22:40 +00001869 /**
1870 * Optionally bind this account to specific transport. This normally is
1871 * not a good idea, as account should be able to send requests using
1872 * any available transports according to the destination. But some
1873 * application may want to have explicit control over the transport to
1874 * use, so in that case it can set this field.
1875 *
1876 * Default: -1 (PJSUA_INVALID_ID)
1877 *
1878 * @see pjsua_acc_set_transport()
1879 */
1880 pjsua_transport_id transport_id;
1881
Benny Prijono15b02302007-09-27 14:07:07 +00001882 /**
1883 * This option is useful for keeping the UDP transport address up to
1884 * date with the NAT public mapped address. When this option is
1885 * enabled and STUN is configured, the library will keep track of
1886 * the public IP address from the response of REGISTER request. Once
1887 * it detects that the address has changed, it will unregister current
1888 * Contact, update the UDP transport address, and register a new
1889 * Contact to the registrar.
1890 *
1891 * Default: 1 (yes)
1892 */
1893 pj_bool_t auto_update_nat;
1894
Benny Prijono312aff92006-06-17 04:08:30 +00001895} pjsua_acc_config;
1896
1897
1898/**
1899 * Call this function to initialize account config with default values.
1900 *
1901 * @param cfg The account config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001902 *
1903 * \par Python:
1904 * In Python, this function both creates and initializes the account
1905 * config:
1906 * \code
1907 acc_cfg = py_pjsua.acc_config_default()
1908 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001909 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001910PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001911
1912
1913/**
1914 * Account info. Application can query account info by calling
1915 * #pjsua_acc_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00001916 *
1917 * \par Python:
1918 * The data type in Python is <tt>py_pjsua.Acc_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001919 */
1920typedef struct pjsua_acc_info
1921{
1922 /**
1923 * The account ID.
1924 */
1925 pjsua_acc_id id;
1926
1927 /**
1928 * Flag to indicate whether this is the default account.
1929 */
1930 pj_bool_t is_default;
1931
1932 /**
1933 * Account URI
1934 */
1935 pj_str_t acc_uri;
1936
1937 /**
1938 * Flag to tell whether this account has registration setting
1939 * (reg_uri is not empty).
1940 */
1941 pj_bool_t has_registration;
1942
1943 /**
1944 * An up to date expiration interval for account registration session.
1945 */
1946 int expires;
1947
1948 /**
1949 * Last registration status code. If status code is zero, the account
1950 * is currently not registered. Any other value indicates the SIP
1951 * status code of the registration.
1952 */
1953 pjsip_status_code status;
1954
1955 /**
1956 * String describing the registration status.
1957 */
1958 pj_str_t status_text;
1959
1960 /**
1961 * Presence online status for this account.
1962 */
1963 pj_bool_t online_status;
1964
1965 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00001966 * Presence online status text.
1967 */
1968 pj_str_t online_status_text;
1969
1970 /**
1971 * Extended RPID online status information.
1972 */
1973 pjrpid_element rpid;
1974
1975 /**
Benny Prijono312aff92006-06-17 04:08:30 +00001976 * Buffer that is used internally to store the status text.
1977 */
1978 char buf_[PJ_ERR_MSG_SIZE];
1979
1980} pjsua_acc_info;
1981
1982
1983
1984/**
1985 * Get number of current accounts.
1986 *
1987 * @return Current number of accounts.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001988 *
1989 * \par Python:
1990 * \code
1991 count = py_pjsua.acc_get_count()
1992 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001993 */
1994PJ_DECL(unsigned) pjsua_acc_get_count(void);
1995
1996
1997/**
1998 * Check if the specified account ID is valid.
1999 *
2000 * @param acc_id Account ID to check.
2001 *
2002 * @return Non-zero if account ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002003 *
2004 * \par Python:
2005 * \code
2006 is_valid = py_pjsua.acc_is_valid(acc_id)
2007 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002008 */
2009PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
2010
2011
2012/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00002013 * Set default account to be used when incoming and outgoing
2014 * requests doesn't match any accounts.
2015 *
2016 * @param acc_id The account ID to be used as default.
2017 *
2018 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002019 *
2020 * \par Python:
2021 * \code
2022 status = py_pjsua.acc_set_default(acc_id)
2023 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002024 */
2025PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2026
2027
2028/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002029 * Get default account to be used when receiving incoming requests (calls),
2030 * when the destination of the incoming call doesn't match any other
2031 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002032 *
2033 * @return The default account ID, or PJSUA_INVALID_ID if no
2034 * default account is configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002035 *
2036 * \par Python:
2037 * \code
2038 acc_id = py_pjsua.acc_get_default()
2039 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002040 */
2041PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2042
2043
2044/**
Benny Prijono312aff92006-06-17 04:08:30 +00002045 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002046 * #pjsua_init()) before calling this function. If registration is configured
2047 * for this account, this function would also start the SIP registration
2048 * session with the SIP registrar server. This SIP registration session
2049 * will be maintained internally by the library, and application doesn't
2050 * need to do anything to maintain the registration session.
2051 *
Benny Prijono312aff92006-06-17 04:08:30 +00002052 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002053 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002054 * @param is_default If non-zero, this account will be set as the default
2055 * account. The default account will be used when sending
2056 * outgoing requests (e.g. making call) when no account is
2057 * specified, and when receiving incoming requests when the
2058 * request does not match any accounts. It is recommended
2059 * that default account is set to local/LAN account.
2060 * @param p_acc_id Pointer to receive account ID of the new account.
2061 *
2062 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002063 *
2064 * \par Python:
2065 * The function returns (status, account_id) tuple:
2066 * \code
2067 status, account_id = py_pjsua.acc_add(acc_cfg, is_default)
2068 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002069 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002070PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002071 pj_bool_t is_default,
2072 pjsua_acc_id *p_acc_id);
2073
2074
2075/**
2076 * Add a local account. A local account is used to identify local endpoint
2077 * instead of a specific user, and for this reason, a transport ID is needed
2078 * to obtain the local address information.
2079 *
2080 * @param tid Transport ID to generate account address.
2081 * @param is_default If non-zero, this account will be set as the default
2082 * account. The default account will be used when sending
2083 * outgoing requests (e.g. making call) when no account is
2084 * specified, and when receiving incoming requests when the
2085 * request does not match any accounts. It is recommended
2086 * that default account is set to local/LAN account.
2087 * @param p_acc_id Pointer to receive account ID of the new account.
2088 *
2089 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002090 *
2091 * \par Python:
2092 * The function returns (status, account_id) tuple:
2093 * \code
2094 status, account_id = py_pjsua.acc_add_local(tid, is_default)
2095 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002096 */
2097PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2098 pj_bool_t is_default,
2099 pjsua_acc_id *p_acc_id);
2100
2101/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002102 * Delete an account. This will unregister the account from the SIP server,
2103 * if necessary, and terminate server side presence subscriptions associated
2104 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002105 *
2106 * @param acc_id Id of the account to be deleted.
2107 *
2108 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002109 *
2110 * \par Python:
2111 * \code
2112 status = py_pjsua.acc_del(acc_id)
2113 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002114 */
2115PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2116
2117
2118/**
2119 * Modify account information.
2120 *
2121 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002122 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002123 *
2124 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002125 *
2126 * \par Python:
2127 * \code
2128 status = py_pjsua.acc_modify(acc_id, acc_cfg)
2129 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002130 */
2131PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002132 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002133
2134
2135/**
2136 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002137 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002138 * if there are server side presence subscription for this account, and/or
2139 * outgoing PUBLISH if presence publication is enabled for this account.
2140 *
2141 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002142 *
2143 * @param acc_id The account ID.
2144 * @param is_online True of false.
2145 *
2146 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002147 *
2148 * \par Python:
2149 * \code
2150 status = py_pjsua.acc_set_online_status(acc_id, is_online)
2151 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002152 */
2153PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2154 pj_bool_t is_online);
2155
Benny Prijono4461c7d2007-08-25 13:36:15 +00002156/**
2157 * Modify account's presence status to be advertised to remote/presence
2158 * subscribers. This would trigger the sending of outgoing NOTIFY request
2159 * if there are server side presence subscription for this account, and/or
2160 * outgoing PUBLISH if presence publication is enabled for this account.
2161 *
2162 * @see pjsua_acc_set_online_status()
2163 *
2164 * @param acc_id The account ID.
2165 * @param is_online True of false.
2166 * @param pr Extended information in subset of RPID format
2167 * which allows setting custom presence text.
2168 *
2169 * @return PJ_SUCCESS on success, or the appropriate error code.
2170 */
2171PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2172 pj_bool_t is_online,
2173 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002174
2175/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002176 * Update registration or perform unregistration. If registration is
2177 * configured for this account, then initial SIP REGISTER will be sent
2178 * when the account is added with #pjsua_acc_add(). Application normally
2179 * only need to call this function if it wants to manually update the
2180 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002181 *
2182 * @param acc_id The account ID.
2183 * @param renew If renew argument is zero, this will start
2184 * unregistration process.
2185 *
2186 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002187 *
2188 * \par Python:
2189 * \code
2190 status = py_pjsua.acc_set_registration(acc_id, renew)
2191 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002192 */
2193PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2194 pj_bool_t renew);
2195
2196
2197/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002198 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002199 *
2200 * @param acc_id Account identification.
2201 * @param info Pointer to receive account information.
2202 *
2203 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002204 *
2205 * \par Python:
2206 * \code
2207 acc_info = py_pjsua.acc_get_info(acc_id)
2208 * \endcode
2209 * The function returns None if account ID is not valid.
Benny Prijono312aff92006-06-17 04:08:30 +00002210 */
2211PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2212 pjsua_acc_info *info);
2213
2214
2215/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002216 * Enumerate all account currently active in the library. This will fill
2217 * the array with the account Ids, and application can then query the
2218 * account information for each id with #pjsua_acc_get_info().
2219 *
2220 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002221 *
2222 * @param ids Array of account IDs to be initialized.
2223 * @param count In input, specifies the maximum number of elements.
2224 * On return, it contains the actual number of elements.
2225 *
2226 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002227 *
2228 * \par Python:
2229 * The function takes no argument and returns list of account Ids:
2230 * \code
2231 [acc_ids] = py_pjsua.enum_accs()
2232 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002233 */
2234PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2235 unsigned *count );
2236
2237
2238/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002239 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002240 *
2241 * @param info Array of account infos to be initialized.
2242 * @param count In input, specifies the maximum number of elements.
2243 * On return, it contains the actual number of elements.
2244 *
2245 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002246 *
2247 * \par Python:
2248 * The function takes no argument and returns list of account infos:
2249 * \code
2250 [acc_info] = py_pjsua.acc_enum_info()
2251 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002252 */
2253PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2254 unsigned *count );
2255
2256
2257/**
2258 * This is an internal function to find the most appropriate account to
2259 * used to reach to the specified URL.
2260 *
2261 * @param url The remote URL to reach.
2262 *
2263 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002264 *
2265 * \par Python:
2266 * \code
2267 acc_id = py_pjsua.acc_find_for_outgoing(url)
2268 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002269 */
2270PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2271
2272
2273/**
2274 * This is an internal function to find the most appropriate account to be
2275 * used to handle incoming calls.
2276 *
2277 * @param rdata The incoming request message.
2278 *
2279 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002280 *
2281 * \par Python:
2282 * \code
2283 acc_id = py_pjsua.acc_find_for_outgoing(url)
2284 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002285 */
2286PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2287
2288
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002289/**
Benny Prijonofff245c2007-04-02 11:44:47 +00002290 * Create arbitrary requests using the account. Application should only use
2291 * this function to create auxiliary requests outside dialog, such as
2292 * OPTIONS, and use the call or presence API to create dialog related
2293 * requests.
2294 *
2295 * @param acc_id The account ID.
2296 * @param method The SIP method of the request.
2297 * @param target Target URI.
2298 * @param p_tdata Pointer to receive the request.
2299 *
2300 * @return PJ_SUCCESS or the error code.
2301 */
2302PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
2303 const pjsip_method *method,
2304 const pj_str_t *target,
2305 pjsip_tx_data **p_tdata);
2306
2307
2308/**
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002309 * Create a suitable URI to be put as Contact based on the specified
2310 * target URI for the specified account.
2311 *
2312 * @param pool Pool to allocate memory for the string.
2313 * @param contact The string where the Contact URI will be stored.
2314 * @param acc_id Account ID.
2315 * @param uri Destination URI of the request.
2316 *
2317 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002318 *
2319 * \par Python:
2320 * This function is still experimental in Python:
2321 * \code
2322 uri = py_pjsua.acc_create_uac_contact(pool, acc_id, uri)
2323 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002324 */
2325PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
2326 pj_str_t *contact,
2327 pjsua_acc_id acc_id,
2328 const pj_str_t *uri);
2329
2330
2331
2332/**
2333 * Create a suitable URI to be put as Contact based on the information
2334 * in the incoming request.
2335 *
2336 * @param pool Pool to allocate memory for the string.
2337 * @param contact The string where the Contact URI will be stored.
2338 * @param acc_id Account ID.
2339 * @param rdata Incoming request.
2340 *
2341 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002342 *
2343 * \par Python:
2344 * This function is still experimental in Python:
2345 * \code
2346 uri = py_pjsua.acc_create_uas_contact(pool, acc_id, rdata)
2347 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002348 */
2349PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
2350 pj_str_t *contact,
2351 pjsua_acc_id acc_id,
2352 pjsip_rx_data *rdata );
2353
2354
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002355/**
2356 * Lock/bind this account to a specific transport/listener. Normally
2357 * application shouldn't need to do this, as transports will be selected
2358 * automatically by the stack according to the destination.
2359 *
2360 * When account is locked/bound to a specific transport, all outgoing
2361 * requests from this account will use the specified transport (this
2362 * includes SIP registration, dialog (call and event subscription), and
2363 * out-of-dialog requests such as MESSAGE).
2364 *
2365 * Note that transport_id may be specified in pjsua_acc_config too.
2366 *
2367 * @param acc_id The account ID.
2368 * @param tp_id The transport ID.
2369 *
2370 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002371 *
2372 * \par Python:
2373 * Not yet implemented.
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002374 */
2375PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
2376 pjsua_transport_id tp_id);
2377
Benny Prijono312aff92006-06-17 04:08:30 +00002378
2379/**
2380 * @}
2381 */
2382
2383
2384/*****************************************************************************
2385 * CALLS API
2386 */
2387
2388
2389/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002390 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00002391 * @ingroup PJSUA_LIB
2392 * @brief Call manipulation.
2393 * @{
2394 */
2395
2396/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002397 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00002398 */
2399#ifndef PJSUA_MAX_CALLS
2400# define PJSUA_MAX_CALLS 32
2401#endif
2402
2403
2404
2405/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002406 * This enumeration specifies the media status of a call, and it's part
2407 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00002408 */
2409typedef enum pjsua_call_media_status
2410{
Benny Prijonob5388cf2007-01-04 22:45:08 +00002411 /** Call currently has no media */
Benny Prijono312aff92006-06-17 04:08:30 +00002412 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002413
2414 /** The media is active */
Benny Prijono312aff92006-06-17 04:08:30 +00002415 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002416
2417 /** The media is currently put on hold by local endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002418 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002419
2420 /** The media is currently put on hold by remote endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002421 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002422
Benny Prijono096c56c2007-09-15 08:30:16 +00002423 /** The media has reported error (e.g. ICE negotiation) */
2424 PJSUA_CALL_MEDIA_ERROR
2425
Benny Prijono312aff92006-06-17 04:08:30 +00002426} pjsua_call_media_status;
2427
2428
2429/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002430 * This structure describes the information and current status of a call.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002431 *
2432 * \par Python:
2433 * The type name is <tt>py_pjsua.Call_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002434 */
2435typedef struct pjsua_call_info
2436{
2437 /** Call identification. */
2438 pjsua_call_id id;
2439
2440 /** Initial call role (UAC == caller) */
2441 pjsip_role_e role;
2442
Benny Prijono90315512006-09-14 16:05:16 +00002443 /** The account ID where this call belongs. */
2444 pjsua_acc_id acc_id;
2445
Benny Prijono312aff92006-06-17 04:08:30 +00002446 /** Local URI */
2447 pj_str_t local_info;
2448
2449 /** Local Contact */
2450 pj_str_t local_contact;
2451
2452 /** Remote URI */
2453 pj_str_t remote_info;
2454
2455 /** Remote contact */
2456 pj_str_t remote_contact;
2457
2458 /** Dialog Call-ID string. */
2459 pj_str_t call_id;
2460
2461 /** Call state */
2462 pjsip_inv_state state;
2463
2464 /** Text describing the state */
2465 pj_str_t state_text;
2466
2467 /** Last status code heard, which can be used as cause code */
2468 pjsip_status_code last_status;
2469
2470 /** The reason phrase describing the status. */
2471 pj_str_t last_status_text;
2472
2473 /** Call media status. */
2474 pjsua_call_media_status media_status;
2475
2476 /** Media direction */
2477 pjmedia_dir media_dir;
2478
2479 /** The conference port number for the call */
2480 pjsua_conf_port_id conf_slot;
2481
2482 /** Up-to-date call connected duration (zero when call is not
2483 * established)
2484 */
2485 pj_time_val connect_duration;
2486
2487 /** Total call duration, including set-up time */
2488 pj_time_val total_duration;
2489
2490 /** Internal */
2491 struct {
2492 char local_info[128];
2493 char local_contact[128];
2494 char remote_info[128];
2495 char remote_contact[128];
2496 char call_id[128];
2497 char last_status_text[128];
2498 } buf_;
2499
2500} pjsua_call_info;
2501
2502
2503
Benny Prijonoa91a0032006-02-26 21:23:45 +00002504/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002505 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002506 *
2507 * @return Maximum number of calls configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002508 *
2509 * \par Python:
2510 * \code
2511 count = py_pjsua.call_get_max_count()
2512 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002513 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002514PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002515
2516/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002517 * Get number of currently active calls.
2518 *
2519 * @return Number of currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002520 *
2521 * \par Python:
2522 * \code
2523 count = py_pjsua.call_get_count()
2524 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002525 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002526PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002527
2528/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002529 * Enumerate all active calls. Application may then query the information and
2530 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002531 *
2532 * @param ids Array of account IDs to be initialized.
2533 * @param count In input, specifies the maximum number of elements.
2534 * On return, it contains the actual number of elements.
2535 *
2536 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002537 *
2538 * \par Python:
2539 * This function takes no argument and return list of call Ids.
2540 * \code
2541 [call_ids] = py_pjsua.enum_calls()
2542 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002543 */
2544PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
2545 unsigned *count);
2546
2547
2548/**
2549 * Make outgoing call to the specified URI using the specified account.
2550 *
2551 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002552 * @param dst_uri URI to be put in the To header (normally is the same
2553 * as the target URI).
2554 * @param options Options (must be zero at the moment).
2555 * @param user_data Arbitrary user data to be attached to the call, and
2556 * can be retrieved later.
2557 * @param msg_data Optional headers etc to be added to outgoing INVITE
2558 * request, or NULL if no custom header is desired.
2559 * @param p_call_id Pointer to receive call identification.
2560 *
2561 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002562 *
2563 * \par Python:
2564 * The Python function returns (status, call_id) tuple:
2565 * \code
2566 status, call_id = py_pjsua.call_make_call(acc_id, dst_uri, options,
2567 user_data, msg_data)
2568 * \endcode
2569 * Note: the \a user_data in Python function is an integer, and the
2570 * \a msg_data can be set to None if not required.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002571 */
2572PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
2573 const pj_str_t *dst_uri,
2574 unsigned options,
2575 void *user_data,
2576 const pjsua_msg_data *msg_data,
2577 pjsua_call_id *p_call_id);
2578
2579
2580/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002581 * Check if the specified call has active INVITE session and the INVITE
2582 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002583 *
2584 * @param call_id Call identification.
2585 *
2586 * @return Non-zero if call is active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002587 *
2588 * \par Python:
2589 * \code
2590 bool = py_pjsua.call_is_active(call_id)
2591 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002592 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002593PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002594
2595
2596/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002597 * Check if call has an active media session.
2598 *
2599 * @param call_id Call identification.
2600 *
2601 * @return Non-zero if yes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002602 *
2603 * \par Python:
2604 * \code
2605 bool = py_pjsua.call_has_media(call_id)
2606 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002607 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002608PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002609
2610
2611/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002612 * Get the conference port identification associated with the call.
2613 *
2614 * @param call_id Call identification.
2615 *
2616 * @return Conference port ID, or PJSUA_INVALID_ID when the
2617 * media has not been established or is not active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002618 *
2619 * \par Python:
2620 * \code
2621 slot = py_pjsua.call_get_conf_port(call_id)
2622 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002623 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002624PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
2625
2626/**
2627 * Obtain detail information about the specified call.
2628 *
2629 * @param call_id Call identification.
2630 * @param info Call info to be initialized.
2631 *
2632 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002633 *
2634 * \par Python:
2635 * \code
2636 call_info = py_pjsua.call_get_info(call_id)
2637 * \endcode
2638 * \a call_info return value will be set to None if call_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002639 */
2640PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002641 pjsua_call_info *info);
2642
2643
2644/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002645 * Attach application specific data to the call. Application can then
2646 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002647 *
2648 * @param call_id Call identification.
2649 * @param user_data Arbitrary data to be attached to the call.
2650 *
2651 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002652 *
2653 * \par Python:
2654 * \code
2655 status = py_pjsua.call_set_user_data(call_id, user_data)
2656 * \endcode
2657 * The \a user_data is an integer in the Python function.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002658 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002659PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
2660 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002661
2662
2663/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002664 * Get user data attached to the call, which has been previously set with
2665 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002666 *
2667 * @param call_id Call identification.
2668 *
2669 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002670 *
2671 * \par Python:
2672 * \code
2673 user_data = py_pjsua.call_get_user_data(call_id)
2674 * \endcode
2675 * The \a user_data is an integer.
Benny Prijono268ca612006-02-07 12:34:11 +00002676 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002677PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00002678
2679
2680/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002681 * Send response to incoming INVITE request. Depending on the status
2682 * code specified as parameter, this function may send provisional
2683 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002684 *
2685 * @param call_id Incoming call identification.
2686 * @param code Status code, (100-699).
2687 * @param reason Optional reason phrase. If NULL, default text
2688 * will be used.
2689 * @param msg_data Optional list of headers etc to be added to outgoing
2690 * response message.
2691 *
2692 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002693 *
2694 * \par Python:
2695 * \code
2696 status = py_pjsua.call_answer(call_id, code, reason, msg_data)
2697 * \endcode
2698 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijonoa91a0032006-02-26 21:23:45 +00002699 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002700PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
2701 unsigned code,
2702 const pj_str_t *reason,
2703 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00002704
2705/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002706 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00002707 * call state. This function is different than answering the call with
2708 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
2709 * will hangup the call regardless of the state and role of the call,
2710 * while #pjsua_call_answer() only works with incoming calls on EARLY
2711 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002712 *
2713 * @param call_id Call identification.
2714 * @param code Optional status code to be sent when we're rejecting
2715 * incoming call. If the value is zero, "603/Decline"
2716 * will be sent.
2717 * @param reason Optional reason phrase to be sent when we're rejecting
2718 * incoming call. If NULL, default text will be used.
2719 * @param msg_data Optional list of headers etc to be added to outgoing
2720 * request/response message.
2721 *
2722 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002723 *
2724 * \par Python:
2725 * \code
2726 status = py_pjsua.call_hangup(call_id, code, reason, msg_data)
2727 * \endcode
2728 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002729 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002730PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
2731 unsigned code,
2732 const pj_str_t *reason,
2733 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002734
2735
2736/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002737 * Put the specified call on hold. This will send re-INVITE with the
2738 * appropriate SDP to inform remote that the call is being put on hold.
2739 * The final status of the request itself will be reported on the
2740 * \a on_call_media_state() callback, which inform the application that
2741 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002742 *
2743 * @param call_id Call identification.
2744 * @param msg_data Optional message components to be sent with
2745 * the request.
2746 *
2747 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002748 *
2749 * \par Python:
2750 * \code
2751 status = py_pjsua.call_set_hold(call_id, msg_data)
2752 * \endcode
2753 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002754 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002755PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
2756 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002757
2758
2759/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002760 * Send re-INVITE to release hold.
2761 * The final status of the request itself will be reported on the
2762 * \a on_call_media_state() callback, which inform the application that
2763 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002764 *
2765 * @param call_id Call identification.
2766 * @param unhold If this argument is non-zero and the call is locally
2767 * held, this will release the local hold.
2768 * @param msg_data Optional message components to be sent with
2769 * the request.
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_reinvite(call_id, unhold, msg_data)
2776 * \endcode
2777 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002778 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002779PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
2780 pj_bool_t unhold,
2781 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002782
Benny Prijonoc08682e2007-10-04 06:17:58 +00002783/**
2784 * Send UPDATE request.
2785 *
2786 * @param call_id Call identification.
2787 * @param options Must be zero for now.
2788 * @param msg_data Optional message components to be sent with
2789 * the request.
2790 *
2791 * @return PJ_SUCCESS on success, or the appropriate error code.
2792 */
2793PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
2794 unsigned options,
2795 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002796
2797/**
Benny Prijono053f5222006-11-11 16:16:04 +00002798 * Initiate call transfer to the specified address. This function will send
2799 * REFER request to instruct remote call party to initiate a new INVITE
2800 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002801 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00002802 * If application is interested to monitor the successfulness and
2803 * the progress of the transfer request, it can implement
2804 * \a on_call_transfer_status() callback which will report the progress
2805 * of the call transfer request.
2806 *
Benny Prijono053f5222006-11-11 16:16:04 +00002807 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002808 * @param dest Address of new target to be contacted.
2809 * @param msg_data Optional message components to be sent with
2810 * the request.
2811 *
2812 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002813 *
2814 * \par Python:
2815 * \code
2816 status = py_pjsua.call_xfer(call_id, dest, msg_data)
2817 * \endcode
2818 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002819 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002820PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
2821 const pj_str_t *dest,
2822 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002823
2824/**
Benny Prijono053f5222006-11-11 16:16:04 +00002825 * Flag to indicate that "Require: replaces" should not be put in the
2826 * outgoing INVITE request caused by REFER request created by
2827 * #pjsua_call_xfer_replaces().
2828 */
2829#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
2830
2831/**
2832 * Initiate attended call transfer. This function will send REFER request
2833 * to instruct remote call party to initiate new INVITE session to the URL
2834 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
2835 * the call with us with the new call from the REFER recipient.
2836 *
2837 * @param call_id The call id to be transfered.
2838 * @param dest_call_id The call id to be replaced.
2839 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
2840 * to suppress the inclusion of "Require: replaces" in
2841 * the outgoing INVITE request created by the REFER
2842 * request.
2843 * @param msg_data Optional message components to be sent with
2844 * the request.
2845 *
2846 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002847 *
2848 * \par Python:
2849 * \code
2850 status = py_pjsua.call_xfer_replaces(call_id, dest_call_id, options, msg_data)
2851 * \endcode
2852 * Argument \a msg_data may be set to None if not required.
Benny Prijono053f5222006-11-11 16:16:04 +00002853 */
2854PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
2855 pjsua_call_id dest_call_id,
2856 unsigned options,
2857 const pjsua_msg_data *msg_data);
2858
2859/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002860 * Send DTMF digits to remote using RFC 2833 payload formats.
2861 *
2862 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002863 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002864 *
2865 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002866 *
2867 * \par Python:
2868 * \code
2869 status = py_pjsua.call_dial_dtmf(call_id, digits)
2870 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002871 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002872PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002873 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00002874
Benny Prijono26ff9062006-02-21 23:47:00 +00002875/**
Benny Prijonob0808372006-03-02 21:18:58 +00002876 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002877 *
2878 * @param call_id Call identification.
2879 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
2880 * assumed.
2881 * @param content The message content.
2882 * @param msg_data Optional list of headers etc to be included in outgoing
2883 * request. The body descriptor in the msg_data is
2884 * ignored.
2885 * @param user_data Optional user data, which will be given back when
2886 * the IM callback is called.
2887 *
2888 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002889 *
2890 * \par Python:
2891 * \code
2892 status = py_pjsua.call_send_im(call_id, mime_type, content, msg_data, user_data)
2893 * \endcode
2894 * Note that the \a user_data argument is an integer in Python.
Benny Prijonob0808372006-03-02 21:18:58 +00002895 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002896PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
2897 const pj_str_t *mime_type,
2898 const pj_str_t *content,
2899 const pjsua_msg_data *msg_data,
2900 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00002901
2902
2903/**
2904 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002905 *
2906 * @param call_id Call identification.
2907 * @param is_typing Non-zero to indicate to remote that local person is
2908 * currently typing an IM.
2909 * @param msg_data Optional list of headers etc to be included in outgoing
2910 * request.
2911 *
2912 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002913 *
2914 * \par Python:
2915 * \code
2916 status = py_pjsua.call_send_typing_ind(call_id, is_typing, msg_data)
2917 * \endcode
2918 * Argument \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00002919 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002920PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
2921 pj_bool_t is_typing,
2922 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00002923
2924/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00002925 * Send arbitrary request with the call. This is useful for example to send
2926 * INFO request. Note that application should not use this function to send
2927 * requests which would change the invite session's state, such as re-INVITE,
2928 * UPDATE, PRACK, and BYE.
2929 *
2930 * @param call_id Call identification.
2931 * @param method SIP method of the request.
2932 * @param msg_data Optional message body and/or list of headers to be
2933 * included in outgoing request.
2934 *
2935 * @return PJ_SUCCESS on success, or the appropriate error code.
2936 */
2937PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
2938 const pj_str_t *method,
2939 const pjsua_msg_data *msg_data);
2940
2941
2942/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002943 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
2944 * currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002945 *
2946 * \par Python:
2947 * \code
2948 py_pjsua.call_hangup_all()
2949 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00002950 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00002951PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00002952
2953
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002954/**
2955 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002956 *
2957 * @param call_id Call identification.
2958 * @param with_media Non-zero to include media information too.
2959 * @param buffer Buffer where the statistics are to be written to.
2960 * @param maxlen Maximum length of buffer.
2961 * @param indent Spaces for left indentation.
2962 *
2963 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002964 *
2965 * \par Python:
2966 * \code
2967 string = py_pjsua.call_dump(call_id, with_media, max_len, indent)
2968 * \endcode
2969 * The \a max_len argument is the desired maximum length to be allocated.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002970 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002971PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
2972 pj_bool_t with_media,
2973 char *buffer,
2974 unsigned maxlen,
2975 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002976
Benny Prijono9fc735d2006-05-28 14:58:12 +00002977/**
Benny Prijono312aff92006-06-17 04:08:30 +00002978 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00002979 */
Benny Prijono834aee32006-02-19 01:38:06 +00002980
2981
2982/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00002983 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00002984 */
2985
Benny Prijono312aff92006-06-17 04:08:30 +00002986
2987/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002988 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00002989 * @ingroup PJSUA_LIB
2990 * @brief Buddy management, buddy's presence, and instant messaging.
2991 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00002992 *
2993 * This section describes PJSUA-APIs related to buddies management,
2994 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00002995 */
2996
2997/**
2998 * Max buddies in buddy list.
2999 */
3000#ifndef PJSUA_MAX_BUDDIES
3001# define PJSUA_MAX_BUDDIES 256
3002#endif
3003
3004
3005/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003006 * This structure describes buddy configuration when adding a buddy to
3007 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
3008 * the structure with #pjsua_buddy_config_default() to initialize this
3009 * structure with default configuration.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003010 *
3011 * \par Python:
3012 * In Python this structure is <tt>py_pjsua.Buddy_Config</tt>. However
3013 * it is recommended that application instantiates the buddy config
3014 * by calling:
3015 * \code
3016 buddy_cfg = py_pjsua.buddy_config_default()
3017 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003018 */
3019typedef struct pjsua_buddy_config
3020{
3021 /**
3022 * Buddy URL or name address.
3023 */
3024 pj_str_t uri;
3025
3026 /**
3027 * Specify whether presence subscription should start immediately.
3028 */
3029 pj_bool_t subscribe;
3030
3031} pjsua_buddy_config;
3032
3033
3034/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003035 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003036 */
3037typedef enum pjsua_buddy_status
3038{
3039 /**
3040 * Online status is unknown (possibly because no presence subscription
3041 * has been established).
3042 */
3043 PJSUA_BUDDY_STATUS_UNKNOWN,
3044
3045 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003046 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003047 */
3048 PJSUA_BUDDY_STATUS_ONLINE,
3049
3050 /**
3051 * Buddy is offline.
3052 */
3053 PJSUA_BUDDY_STATUS_OFFLINE,
3054
3055} pjsua_buddy_status;
3056
3057
3058
3059/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003060 * This structure describes buddy info, which can be retrieved by calling
3061 * #pjsua_buddy_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003062 *
3063 * \par Python:
3064 * This structure in Python is <tt>py_pjsua.Buddy_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003065 */
3066typedef struct pjsua_buddy_info
3067{
3068 /**
3069 * The buddy ID.
3070 */
3071 pjsua_buddy_id id;
3072
3073 /**
3074 * The full URI of the buddy, as specified in the configuration.
3075 */
3076 pj_str_t uri;
3077
3078 /**
3079 * Buddy's Contact, only available when presence subscription has
3080 * been established to the buddy.
3081 */
3082 pj_str_t contact;
3083
3084 /**
3085 * Buddy's online status.
3086 */
3087 pjsua_buddy_status status;
3088
3089 /**
3090 * Text to describe buddy's online status.
3091 */
3092 pj_str_t status_text;
3093
3094 /**
3095 * Flag to indicate that we should monitor the presence information for
3096 * this buddy (normally yes, unless explicitly disabled).
3097 */
3098 pj_bool_t monitor_pres;
3099
3100 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003101 * Extended RPID information about the person.
3102 */
3103 pjrpid_element rpid;
3104
3105 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003106 * Internal buffer.
3107 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003108 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003109
3110} pjsua_buddy_info;
3111
3112
Benny Prijono834aee32006-02-19 01:38:06 +00003113/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003114 * Set default values to the buddy config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003115 *
3116 * \par Python:
3117 * \code
3118 buddy_cfg = py_pjsua.buddy_config_default()
3119 * \endcode
Benny Prijonob5388cf2007-01-04 22:45:08 +00003120 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003121PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003122
3123
3124/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003125 * Get total number of buddies.
3126 *
3127 * @return Number of buddies.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003128 *
3129 * \par Python:
3130 * \code
3131 buddy_count = py_pjsua.get_buddy_count()
3132 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003133 */
3134PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3135
3136
3137/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003138 * Check if buddy ID is valid.
3139 *
3140 * @param buddy_id Buddy ID to check.
3141 *
3142 * @return Non-zero if buddy ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003143 *
3144 * \par Python:
3145 * \code
3146 is_valid = py_pjsua.buddy_is_valid(buddy_id)
3147 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003148 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003149PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3150
3151
3152/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003153 * Enumerate all buddy IDs in the buddy list. Application then can use
3154 * #pjsua_buddy_get_info() to get the detail information for each buddy
3155 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003156 *
3157 * @param ids Array of ids to be initialized.
3158 * @param count On input, specifies max elements in the array.
3159 * On return, it contains actual number of elements
3160 * that have been initialized.
3161 *
3162 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003163 *
3164 * \par Python:
3165 * The Python function takes no argument and returns list of buddy IDs:
3166 * \code
3167 [buddy_ids] = py_pjsua.enum_buddies()
3168 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003169 */
3170PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3171 unsigned *count);
3172
3173/**
3174 * Get detailed buddy info.
3175 *
3176 * @param buddy_id The buddy identification.
3177 * @param info Pointer to receive information about buddy.
3178 *
3179 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003180 *
3181 * \par Python:
3182 * \code
3183 buddy_info = py_pjsua.buddy_get_info(buddy_id)
3184 * \endcode
3185 * The function returns None if buddy_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003186 */
3187PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003188 pjsua_buddy_info *info);
3189
3190/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003191 * Add new buddy to the buddy list. If presence subscription is enabled
3192 * for this buddy, this function will also start the presence subscription
3193 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003194 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003195 * @param buddy)cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003196 * @param p_buddy_id Pointer to receive buddy ID.
3197 *
3198 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003199 *
3200 * \par Python:
3201 * The function returns (status, buddy_id) tuple:
3202 * \code
3203 status, buddy_id = py_pjsua.buddy_add(buddy_cfg)
3204 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003205 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003206PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003207 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003208
3209
3210/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003211 * Delete the specified buddy from the buddy list. Any presence subscription
3212 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003213 *
3214 * @param buddy_id Buddy identification.
3215 *
3216 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003217 *
3218 * \par Python:
3219 * \code
3220 status = py_pjsua.buddy_del(buddy_id)
3221 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +00003222 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003223PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003224
3225
3226/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003227 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3228 * subscribed, application will be informed about buddy's presence status
3229 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003230 *
3231 * @param buddy_id Buddy identification.
3232 * @param subscribe Specify non-zero to activate presence subscription to
3233 * the specified buddy.
3234 *
3235 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003236 *
3237 * \par Python:
3238 * \code
3239 status = py_pjsua.buddy_subscribe_pres(buddy_id, subscribe)
3240 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003241 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003242PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3243 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003244
3245
3246/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003247 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003248 *
3249 * @param verbose Yes or no.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003250 *
3251 * \par Python:
3252 * \code
3253 py_pjsua.pres_dump()
3254 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003255 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003256PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003257
3258
Benny Prijonob0808372006-03-02 21:18:58 +00003259/**
3260 * The MESSAGE method (defined in pjsua_im.c)
3261 */
3262extern const pjsip_method pjsip_message_method;
3263
3264
Benny Prijonob0808372006-03-02 21:18:58 +00003265
3266/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003267 * Send instant messaging outside dialog, using the specified account for
3268 * route set and authentication.
3269 *
3270 * @param acc_id Account ID to be used to send the request.
3271 * @param to Remote URI.
3272 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3273 * assumed.
3274 * @param content The message content.
3275 * @param msg_data Optional list of headers etc to be included in outgoing
3276 * request. The body descriptor in the msg_data is
3277 * ignored.
3278 * @param user_data Optional user data, which will be given back when
3279 * the IM callback is called.
3280 *
3281 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003282 *
3283 * \par Python:
3284 * \code
3285 status = py_pjsua.im_send(acc_id, to, mime_type, content, msg_data, user_data)
3286 * \endcode
3287 * Arguments \a mime_type and \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003288 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003289PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3290 const pj_str_t *to,
3291 const pj_str_t *mime_type,
3292 const pj_str_t *content,
3293 const pjsua_msg_data *msg_data,
3294 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003295
3296
3297/**
3298 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003299 *
3300 * @param acc_id Account ID to be used to send the request.
3301 * @param to Remote URI.
3302 * @param is_typing If non-zero, it tells remote person that local person
3303 * is currently composing an IM.
3304 * @param msg_data Optional list of headers etc to be added to outgoing
3305 * request.
3306 *
3307 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003308 *
3309 * \par Python:
3310 * \code
3311 status = py_pjsua.im_typing(acc_id, to, is_typing, msg_data)
3312 * \endcode
3313 * Argument \a msg_data may be set to None if not requried.
Benny Prijonob0808372006-03-02 21:18:58 +00003314 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003315PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3316 const pj_str_t *to,
3317 pj_bool_t is_typing,
3318 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003319
3320
Benny Prijonof3195072006-02-14 21:15:30 +00003321
Benny Prijono312aff92006-06-17 04:08:30 +00003322/**
3323 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003324 */
3325
Benny Prijono312aff92006-06-17 04:08:30 +00003326
3327/*****************************************************************************
3328 * MEDIA API
3329 */
3330
3331
3332/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003333 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003334 * @ingroup PJSUA_LIB
3335 * @brief Media manipulation.
3336 * @{
3337 *
3338 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003339 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3340 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003341 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003342 * the interconnection between these terminations freely.
3343 *
3344 * The conference bridge provides powerful switching and mixing functionality
3345 * for application. With the conference bridge, each conference slot (e.g.
3346 * a call) can transmit to multiple destinations, and one destination can
3347 * receive from multiple sources. If more than one media terminations are
3348 * terminated in the same slot, the conference bridge will mix the signal
3349 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00003350 *
3351 * Application connects one media termination/slot to another by calling
3352 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003353 * media flow from the source termination to the sink termination. To
3354 * establish bidirectional media flow, application wound need to make another
3355 * call to #pjsua_conf_connect(), this time inverting the source and
3356 * destination slots in the parameter.
3357 *
3358 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00003359 * the following steps:
3360 *
3361 \code
3362
3363 pj_status_t stream_to_call( pjsua_call_id call_id )
3364 {
3365 pjsua_player_id player_id;
3366
3367 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
3368 if (status != PJ_SUCCESS)
3369 return status;
3370
3371 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
3372 pjsua_call_get_conf_port() );
3373 }
3374 \endcode
3375 *
3376 *
3377 * Other features of PJSUA media:
3378 * - efficient N to M interconnections between media terminations.
3379 * - media termination can be connected to itself to create loopback
3380 * media.
3381 * - the media termination may have different clock rates, and resampling
3382 * will be done automatically by conference bridge.
3383 * - media terminations may also have different frame time; the
3384 * conference bridge will perform the necessary bufferring to adjust
3385 * the difference between terminations.
3386 * - interconnections are removed automatically when media termination
3387 * is removed from the bridge.
3388 * - sound device may be changed even when there are active media
3389 * interconnections.
3390 * - correctly report call's media quality (in #pjsua_call_dump()) from
3391 * RTCP packet exchange.
3392 */
3393
3394/**
3395 * Max ports in the conference bridge.
3396 */
3397#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00003398# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00003399#endif
3400
Benny Prijonob5388cf2007-01-04 22:45:08 +00003401/**
3402 * The default clock rate to be used by the conference bridge.
3403 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003404#ifndef PJSUA_DEFAULT_CLOCK_RATE
3405# define PJSUA_DEFAULT_CLOCK_RATE 16000
3406#endif
3407
Benny Prijonob5388cf2007-01-04 22:45:08 +00003408/**
3409 * Default codec quality settings.
3410 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003411#ifndef PJSUA_DEFAULT_CODEC_QUALITY
3412# define PJSUA_DEFAULT_CODEC_QUALITY 5
3413#endif
3414
Benny Prijonob5388cf2007-01-04 22:45:08 +00003415/**
3416 * Default iLBC mode.
3417 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003418#ifndef PJSUA_DEFAULT_ILBC_MODE
3419# define PJSUA_DEFAULT_ILBC_MODE 20
3420#endif
3421
Benny Prijonob5388cf2007-01-04 22:45:08 +00003422/**
3423 * The default echo canceller tail length.
3424 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003425#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonod2990b92006-11-23 10:19:46 +00003426# define PJSUA_DEFAULT_EC_TAIL_LEN 800
Benny Prijono12a669c2006-11-23 07:32:13 +00003427#endif
Benny Prijono312aff92006-06-17 04:08:30 +00003428
3429
3430/**
Benny Prijonocba59d92007-02-16 09:22:56 +00003431 * The maximum file player.
3432 */
3433#ifndef PJSUA_MAX_PLAYERS
3434# define PJSUA_MAX_PLAYERS 32
3435#endif
3436
3437
3438/**
3439 * The maximum file player.
3440 */
3441#ifndef PJSUA_MAX_RECORDERS
3442# define PJSUA_MAX_RECORDERS 32
3443#endif
3444
3445
3446/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003447 * This structure describes media configuration, which will be specified
3448 * when calling #pjsua_init(). Application MUST initialize this structure
3449 * by calling #pjsua_media_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003450 *
3451 * \par Python:
3452 * This data type in Python is <tt>py_pjsua.Media_Config</tt>. To create
3453 * an object of this type, it is recommended to call
3454 * <tt>py_pjsua.media_config_default()</tt> function instead:
3455 * \code
3456 media_cfg = py_pjsua.media_config_default()
3457 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003458 */
3459struct pjsua_media_config
3460{
3461 /**
3462 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003463 * If value is zero, default clock rate will be used
3464 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00003465 */
3466 unsigned clock_rate;
3467
3468 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003469 * Specify audio frame ptime. The value here will affect the
3470 * samples per frame of both the sound device and the conference
3471 * bridge. Specifying lower ptime will normally reduce the
3472 * latency.
3473 *
3474 * Default: 20 (miliseconds)
3475 */
3476 unsigned audio_frame_ptime;
3477
3478 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003479 * Specify maximum number of media ports to be created in the
3480 * conference bridge. Since all media terminate in the bridge
3481 * (calls, file player, file recorder, etc), the value must be
3482 * large enough to support all of them. However, the larger
3483 * the value, the more computations are performed.
3484 */
3485 unsigned max_media_ports;
3486
3487 /**
3488 * Specify whether the media manager should manage its own
3489 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
3490 * and at least one worker thread will be created too. If no,
3491 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
3492 * and no worker thread is needed.
3493 *
3494 * Normally application would say yes here, unless it wants to
3495 * run everything from a single thread.
3496 */
3497 pj_bool_t has_ioqueue;
3498
3499 /**
3500 * Specify the number of worker threads to handle incoming RTP
3501 * packets. A value of one is recommended for most applications.
3502 */
3503 unsigned thread_cnt;
3504
Benny Prijono0498d902006-06-19 14:49:14 +00003505 /**
3506 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00003507 * 5-10: resampling use large filter,
3508 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00003509 * 1-2: resampling use linear.
3510 * The media quality also sets speex codec quality/complexity to the
3511 * number.
3512 *
Benny Prijono70972992006-08-05 11:13:58 +00003513 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00003514 */
3515 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00003516
3517 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003518 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00003519 *
3520 * Default: 0 (codec specific)
3521 */
3522 unsigned ptime;
3523
3524 /**
3525 * Disable VAD?
3526 *
3527 * Default: 0 (no (meaning VAD is enabled))
3528 */
3529 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00003530
3531 /**
3532 * iLBC mode (20 or 30).
3533 *
Benny Prijono70972992006-08-05 11:13:58 +00003534 * Default: 20 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00003535 */
3536 unsigned ilbc_mode;
3537
3538 /**
3539 * Percentage of RTP packet to drop in TX direction
3540 * (to simulate packet lost).
3541 *
3542 * Default: 0
3543 */
3544 unsigned tx_drop_pct;
3545
3546 /**
3547 * Percentage of RTP packet to drop in RX direction
3548 * (to simulate packet lost).
3549 *
3550 * Default: 0
3551 */
3552 unsigned rx_drop_pct;
3553
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003554 /**
Benny Prijono5da50432006-08-07 10:24:52 +00003555 * Echo canceller options (see #pjmedia_echo_create())
3556 *
3557 * Default: 0.
3558 */
3559 unsigned ec_options;
3560
3561 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003562 * Echo canceller tail length, in miliseconds.
3563 *
Benny Prijono669643c2006-09-20 20:02:18 +00003564 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003565 */
3566 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003567
3568 /**
3569 * Jitter buffer initial prefetch delay in msec. The value must be
3570 * between jb_min_pre and jb_max_pre below.
3571 *
3572 * Default: -1 (to use default stream settings, currently 150 msec)
3573 */
3574 int jb_init;
3575
3576 /**
3577 * Jitter buffer minimum prefetch delay in msec.
3578 *
3579 * Default: -1 (to use default stream settings, currently 60 msec)
3580 */
3581 int jb_min_pre;
3582
3583 /**
3584 * Jitter buffer maximum prefetch delay in msec.
3585 *
3586 * Default: -1 (to use default stream settings, currently 240 msec)
3587 */
3588 int jb_max_pre;
3589
3590 /**
3591 * Set maximum delay that can be accomodated by the jitter buffer msec.
3592 *
3593 * Default: -1 (to use default stream settings, currently 360 msec)
3594 */
3595 int jb_max;
3596
Benny Prijonoc97608e2007-03-23 16:34:20 +00003597 /**
3598 * Enable ICE
3599 */
3600 pj_bool_t enable_ice;
3601
3602 /**
3603 * Enable ICE media relay.
3604 */
3605 pj_bool_t enable_relay;
Benny Prijono312aff92006-06-17 04:08:30 +00003606};
3607
3608
3609/**
3610 * Use this function to initialize media config.
3611 *
3612 * @param cfg The media config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003613 *
3614 * \par Python:
3615 * \code
3616 media_cfg = py_pjsua.media_config_default()
3617 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003618 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003619PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00003620
3621
3622/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003623 * This structure describes codec information, which can be retrieved by
3624 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00003625 */
3626typedef struct pjsua_codec_info
3627{
3628 /**
3629 * Codec unique identification.
3630 */
3631 pj_str_t codec_id;
3632
3633 /**
3634 * Codec priority (integer 0-255).
3635 */
3636 pj_uint8_t priority;
3637
3638 /**
3639 * Internal buffer.
3640 */
3641 char buf_[32];
3642
3643} pjsua_codec_info;
3644
3645
3646/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003647 * This structure descibes information about a particular media port that
3648 * has been registered into the conference bridge. Application can query
3649 * this info by calling #pjsua_conf_get_port_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003650 *
3651 * \par Python:
3652 * In Python, this type is <tt>py_pjsua.Conf_Port_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003653 */
3654typedef struct pjsua_conf_port_info
3655{
3656 /** Conference port number. */
3657 pjsua_conf_port_id slot_id;
3658
3659 /** Port name. */
3660 pj_str_t name;
3661
3662 /** Clock rate. */
3663 unsigned clock_rate;
3664
3665 /** Number of channels. */
3666 unsigned channel_count;
3667
3668 /** Samples per frame */
3669 unsigned samples_per_frame;
3670
3671 /** Bits per sample */
3672 unsigned bits_per_sample;
3673
3674 /** Number of listeners in the array. */
3675 unsigned listener_cnt;
3676
3677 /** Array of listeners (in other words, ports where this port is
3678 * transmitting to.
3679 */
3680 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
3681
3682} pjsua_conf_port_info;
3683
3684
3685/**
3686 * This structure holds information about custom media transport to
3687 * be registered to pjsua.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003688 *
3689 * \par Python:
3690 * Not applicable.
Benny Prijono312aff92006-06-17 04:08:30 +00003691 */
3692typedef struct pjsua_media_transport
3693{
3694 /**
3695 * Media socket information containing the address information
3696 * of the RTP and RTCP socket.
3697 */
3698 pjmedia_sock_info skinfo;
3699
3700 /**
3701 * The media transport instance.
3702 */
3703 pjmedia_transport *transport;
3704
3705} pjsua_media_transport;
3706
3707
3708
3709
Benny Prijono9fc735d2006-05-28 14:58:12 +00003710/**
3711 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003712 *
3713 * @return Maximum number of ports in the conference bridge.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003714 *
3715 * \par Python:
3716 * \code
3717 port_count = py_pjsua.conf_get_max_ports()
3718 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003719 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003720PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003721
3722
3723/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003724 * Get current number of active ports in the bridge.
3725 *
3726 * @return The number.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003727 *
3728 * \par Python:
3729 * \code
3730 count = py_pjsua.conf_get_active_ports()
3731 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003732 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003733PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
3734
3735
3736/**
3737 * Enumerate all conference ports.
3738 *
3739 * @param id Array of conference port ID to be initialized.
3740 * @param count On input, specifies max elements in the array.
3741 * On return, it contains actual number of elements
3742 * that have been initialized.
3743 *
3744 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003745 *
3746 * \par Python:
3747 * The Python functions returns list of conference port Ids:
3748 * \code
3749 [port_ids] = py_pjsua.enum_conf_ports()
3750 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003751 */
3752PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
3753 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003754
3755
3756/**
3757 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003758 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003759 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003760 * @param info Pointer to store the port info.
3761 *
3762 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003763 *
3764 * \par Python:
3765 * \code
3766 port_info = py_pjsua.conf_get_port_info(port_id)
3767 * \endcode
3768 * The function will return None if \a port_id is not valid.
Benny Prijono8b1889b2006-06-06 18:40:40 +00003769 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003770PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00003771 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003772
3773
3774/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00003775 * Add arbitrary media port to PJSUA's conference bridge. Application
3776 * can use this function to add the media port that it creates. For
3777 * media ports that are created by PJSUA-LIB (such as calls, file player,
3778 * or file recorder), PJSUA-LIB will automatically add the port to
3779 * the bridge.
3780 *
3781 * @param pool Pool to use.
3782 * @param port Media port to be added to the bridge.
3783 * @param p_id Optional pointer to receive the conference
3784 * slot id.
3785 *
3786 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003787 *
3788 * \par Python:
3789 * Not applicable (for now)
Benny Prijonoe909eac2006-07-27 22:04:56 +00003790 */
3791PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
3792 pjmedia_port *port,
3793 pjsua_conf_port_id *p_id);
3794
3795
3796/**
3797 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00003798 * call this function if it registered the port manually with previous call
3799 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00003800 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003801 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00003802 *
3803 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003804 *
3805 * \par Python:
3806 * \code
3807 status = py_pjsua.conf_remove_port(port_id)
3808 * \endcode
Benny Prijonoe909eac2006-07-27 22:04:56 +00003809 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003810PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00003811
3812
3813/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003814 * Establish unidirectional media flow from souce to sink. One source
3815 * may transmit to multiple destinations/sink. And if multiple
3816 * sources are transmitting to the same sink, the media will be mixed
3817 * together. Source and sink may refer to the same ID, effectively
3818 * looping the media.
3819 *
3820 * If bidirectional media flow is desired, application needs to call
3821 * this function twice, with the second one having the arguments
3822 * reversed.
3823 *
3824 * @param source Port ID of the source media/transmitter.
3825 * @param sink Port ID of the destination media/received.
3826 *
3827 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003828 *
3829 * \par Python:
3830 * \code
3831 status = py_pjsua.conf_connect(source, sink)
3832 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003833 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003834PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
3835 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003836
3837
3838/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003839 * Disconnect media flow from the source to destination port.
3840 *
3841 * @param source Port ID of the source media/transmitter.
3842 * @param sink Port ID of the destination media/received.
3843 *
3844 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003845 *
3846 * \par Python:
3847 * \code
3848 status = py_pjsua.conf_disconnect(source, sink)
3849 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003850 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003851PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
3852 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003853
3854
Benny Prijono6dd967c2006-12-26 02:27:14 +00003855/**
3856 * Adjust the signal level to be transmitted from the bridge to the
3857 * specified port by making it louder or quieter.
3858 *
3859 * @param slot The conference bridge slot number.
3860 * @param level Signal level adjustment. Value 1.0 means no level
3861 * adjustment, while value 0 means to mute the port.
3862 *
3863 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003864 *
3865 * \par Python:
3866 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003867 */
3868PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
3869 float level);
3870
3871/**
3872 * Adjust the signal level to be received from the specified port (to
3873 * the bridge) by making it louder or quieter.
3874 *
3875 * @param slot The conference bridge slot number.
3876 * @param level Signal level adjustment. Value 1.0 means no level
3877 * adjustment, while value 0 means to mute the port.
3878 *
3879 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003880 *
3881 * \par Python:
3882 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003883 */
3884PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
3885 float level);
3886
3887/**
3888 * Get last signal level transmitted to or received from the specified port.
3889 * The signal level is an integer value in zero to 255, with zero indicates
3890 * no signal, and 255 indicates the loudest signal level.
3891 *
3892 * @param slot The conference bridge slot number.
3893 * @param tx_level Optional argument to receive the level of signal
3894 * transmitted to the specified port (i.e. the direction
3895 * is from the bridge to the port).
3896 * @param rx_level Optional argument to receive the level of signal
3897 * received from the port (i.e. the direction is from the
3898 * port to the bridge).
3899 *
3900 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003901 *
3902 * \par Python:
3903 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003904 */
3905PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
3906 unsigned *tx_level,
3907 unsigned *rx_level);
3908
Benny Prijono6dd967c2006-12-26 02:27:14 +00003909
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003910/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00003911 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003912 */
3913
Benny Prijono9fc735d2006-05-28 14:58:12 +00003914/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003915 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003916 * the conference bridge.
3917 *
3918 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00003919 * WAV files are supported, and the WAV file MUST be
3920 * formatted as 16bit PCM mono/single channel (any
3921 * clock rate is supported).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003922 * @param options Options (currently zero).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003923 * @param p_id Pointer to receive player ID.
3924 *
3925 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003926 *
3927 * \par Python:
3928 * The function returns (status, id) tuple:
3929 * \code
3930 status, id = py_pjsua.player_create(filename, options)
3931 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003932 */
3933PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003934 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003935 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003936
3937
3938/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003939 * Create a file playlist media port, and automatically add the port
3940 * to the conference bridge.
3941 *
3942 * @param file_names Array of file names to be added to the play list.
3943 * Note that the files must have the same clock rate,
3944 * number of channels, and number of bits per sample.
3945 * @param file_count Number of files in the array.
3946 * @param label Optional label to be set for the media port.
3947 * @param options Optional option flag. Application may specify
3948 * PJMEDIA_FILE_NO_LOOP to prevent looping.
3949 * @param p_id Optional pointer to receive player ID.
3950 *
3951 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003952 *
3953 * \par Python:
3954 * Not implemented yet.
Benny Prijonoa66c3312007-01-21 23:12:40 +00003955 */
3956PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
3957 unsigned file_count,
3958 const pj_str_t *label,
3959 unsigned options,
3960 pjsua_player_id *p_id);
3961
3962/**
3963 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003964 *
3965 * @param id The file player ID.
3966 *
3967 * @return Conference port ID associated with this player.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003968 *
3969 * \par Python:
3970 * \code
3971 port_id = py_pjsua.player_get_conf_port(id)
3972 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003973 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003974PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003975
3976
3977/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003978 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00003979 *
3980 * @param id The player ID.
3981 * @param p_port The media port associated with the player.
3982 *
3983 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003984 *
3985 * \par Python:
3986 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00003987 */
3988PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_recorder_id id,
3989 pjmedia_port **p_port);
3990
3991/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003992 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003993 *
3994 * @param id The file player ID.
3995 * @param samples The playback position, in samples. Application can
3996 * specify zero to re-start the playback.
3997 *
3998 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003999 *
4000 * \par Python:
4001 * \code
4002 status = py_pjsua.player_set_pos(id, samples)
4003 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004004 */
4005PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
4006 pj_uint32_t samples);
4007
4008
4009/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004010 * Close the file of playlist, remove the player from the bridge, and free
4011 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004012 *
4013 * @param id The file player ID.
4014 *
4015 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004016 *
4017 * \par Python:
4018 * \code
4019 status = py_pjsua.player_destroy(id)
4020 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004021 */
4022PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
4023
4024
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004025/*****************************************************************************
4026 * File recorder.
4027 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00004028
4029/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004030 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004031 * the conference bridge. The recorder currently supports recording WAV file.
4032 * The type of the recorder to use is determined by the extension of the file
4033 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004034 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00004035 * @param filename Output file name. The function will determine the
4036 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004037 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00004038 * @param enc_type Optionally specify the type of encoder to be used to
4039 * compress the media, if the file can support different
4040 * encodings. This value must be zero for now.
4041 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004042 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00004043 * For .WAV recorder, this value must be NULL.
4044 * @param max_size Maximum file size. Specify zero or -1 to remove size
4045 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004046 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004047 * @param p_id Pointer to receive the recorder instance.
4048 *
4049 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004050 *
4051 * \par Python:
4052 * \code
4053 status, id = py_pjsua.recorder_create(filename, enc_type, enc_param, max_size, options)
4054 * \endcode
4055 * The \a enc_param is a string in Python.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004056 */
4057PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004058 unsigned enc_type,
4059 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004060 pj_ssize_t max_size,
4061 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004062 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004063
4064
4065/**
4066 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004067 *
4068 * @param id The recorder ID.
4069 *
4070 * @return Conference port ID associated with this recorder.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004071 *
4072 * \par Python:
4073 * \code
4074 port_id = py_pjsua.recorder_get_conf_port(id)
4075 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004076 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004077PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004078
4079
4080/**
Benny Prijono469b1522006-12-26 03:05:17 +00004081 * Get the media port for the recorder.
4082 *
4083 * @param id The recorder ID.
4084 * @param p_port The media port associated with the recorder.
4085 *
4086 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004087 *
4088 * \par Python:
4089 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004090 */
4091PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4092 pjmedia_port **p_port);
4093
4094
4095/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004096 * Destroy recorder (this will complete recording).
4097 *
4098 * @param id The recorder ID.
4099 *
4100 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004101 *
4102 * \par Python:
4103 * \code
4104 status = py_pjsua.recorder_destroy(id)
4105 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004106 */
4107PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4108
4109
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004110/*****************************************************************************
4111 * Sound devices.
4112 */
4113
Benny Prijono9fc735d2006-05-28 14:58:12 +00004114/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004115 * Enum all sound devices installed in the system.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004116 *
4117 * @param info Array of info to be initialized.
4118 * @param count On input, specifies max elements in the array.
4119 * On return, it contains actual number of elements
4120 * that have been initialized.
4121 *
4122 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004123 *
4124 *
4125 * \par Python:
4126 * The function returns list of sound device info:
4127 * \code
4128 [dev_infos] = py_pjsua.enum_snd_devs()
4129 * \endcode
4130 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00004131 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004132PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4133 unsigned *count);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004134
4135
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004136
4137/**
4138 * Get currently active sound devices. If sound devices has not been created
4139 * (for example when pjsua_start() is not called), it is possible that
4140 * the function returns PJ_SUCCESS with -1 as device IDs.
4141 *
4142 * @param capture_dev On return it will be filled with device ID of the
4143 * capture device.
4144 * @param playback_dev On return it will be filled with device ID of the
4145 * device ID of the playback device.
4146 *
4147 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004148 *
4149 * \par Python:
Benny Prijonoebdf8772007-02-01 19:25:50 +00004150 * The function takes no argument and return an (integer,integer) tuple:
Benny Prijonoe6ead542007-01-31 20:53:31 +00004151 * \code
4152 capture_dev, playback_dev = py_pjsua.get_snd_dev()
4153 * \endcode
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004154 */
4155PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4156 int *playback_dev);
4157
4158
Benny Prijono9fc735d2006-05-28 14:58:12 +00004159/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004160 * Select or change sound device. Application may call this function at
4161 * any time to replace current sound device.
4162 *
4163 * @param capture_dev Device ID of the capture device.
4164 * @param playback_dev Device ID of the playback device.
4165 *
4166 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004167 *
4168 * \par Python:
4169 * \code
4170 status = py_pjsua.set_snd_dev(capture_dev, playback_dev)
4171 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004172 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004173PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4174 int playback_dev);
4175
4176
4177/**
4178 * Set pjsua to use null sound device. The null sound device only provides
4179 * the timing needed by the conference bridge, and will not interract with
4180 * any hardware.
4181 *
4182 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004183 *
4184 * \par Python:
4185 * \code
4186 status = py_pjsua.set_null_snd_dev()
4187 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004188 */
4189PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4190
4191
Benny Prijonoe909eac2006-07-27 22:04:56 +00004192/**
4193 * Disconnect the main conference bridge from any sound devices, and let
4194 * application connect the bridge to it's own sound device/master port.
4195 *
4196 * @return The port interface of the conference bridge,
4197 * so that application can connect this to it's own
4198 * sound device or master port.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004199 *
4200 * \par Python:
4201 * Not applicable (for now).
Benny Prijonoe909eac2006-07-27 22:04:56 +00004202 */
4203PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4204
4205
Benny Prijonof20687a2006-08-04 18:27:19 +00004206/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004207 * Configure the echo canceller tail length of the sound port.
Benny Prijonof20687a2006-08-04 18:27:19 +00004208 *
4209 * @param tail_ms The tail length, in miliseconds. Set to zero to
4210 * disable AEC.
Benny Prijono5da50432006-08-07 10:24:52 +00004211 * @param options Options to be passed to #pjmedia_echo_create().
4212 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004213 *
4214 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004215 *
4216 * \par Python:
4217 * \code
4218 status = py_pjsua.set_ec(tail_ms, options)
4219 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004220 */
Benny Prijono5da50432006-08-07 10:24:52 +00004221PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004222
4223
4224/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004225 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004226 *
4227 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4228 * If AEC is disabled, the value will be zero.
4229 *
4230 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004231 *
4232 * \par Python:
4233 * \code
4234 tail_ms = py_pjsua.get_ec_tail()
4235 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004236 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004237PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004238
4239
4240
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004241/*****************************************************************************
4242 * Codecs.
4243 */
4244
4245/**
4246 * Enum all supported codecs in the system.
4247 *
4248 * @param id Array of ID to be initialized.
4249 * @param count On input, specifies max elements in the array.
4250 * On return, it contains actual number of elements
4251 * that have been initialized.
4252 *
4253 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004254 *
4255 * \par Python:
4256 * This function takes no argument and returns list of codec infos:
4257 * \code
4258 [codec_info] = py_pjsua.enum_codecs()
4259 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004260 */
4261PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4262 unsigned *count );
4263
4264
4265/**
4266 * Change codec priority.
4267 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004268 * @param codec_id Codec ID, which is a string that uniquely identify
4269 * the codec (such as "speex/8000"). Please see pjsua
4270 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004271 * @param priority Codec priority, 0-255, where zero means to disable
4272 * the codec.
4273 *
4274 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004275 *
4276 * \par Python:
4277 * \code
4278 status = py_pjsua.codec_set_priority(codec_id, priority)
4279 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004280 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004281PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004282 pj_uint8_t priority );
4283
4284
4285/**
4286 * Get codec parameters.
4287 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004288 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004289 * @param param Structure to receive codec parameters.
4290 *
4291 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004292 *
4293 * \par Python:
4294 * The Python function is experimental:
4295 * \code
4296 codec_param = py_pjsua.codec_get_param(codec_id)
4297 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004298 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004299PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004300 pjmedia_codec_param *param );
4301
4302
4303/**
4304 * Set codec parameters.
4305 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004306 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004307 * @param param Codec parameter to set.
4308 *
4309 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004310 *
4311 * \par Python:
4312 * The Python function is experimental:
4313 * \code
4314 status = py_pjsua.codec_set_param(codec_id, param)
4315 * \endcode
4316
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004317 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004318PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004319 const pjmedia_codec_param *param);
4320
4321
4322
Benny Prijono9fc735d2006-05-28 14:58:12 +00004323
Benny Prijono312aff92006-06-17 04:08:30 +00004324/**
4325 * Create UDP media transports for all the calls. This function creates
4326 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00004327 *
Benny Prijono312aff92006-06-17 04:08:30 +00004328 * @param cfg Media transport configuration. The "port" field in the
4329 * configuration is used as the start port to bind the
4330 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004331 *
4332 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004333 *
4334 * \par Python:
4335 * Not implemented yet.
Benny Prijonof3195072006-02-14 21:15:30 +00004336 */
Benny Prijono312aff92006-06-17 04:08:30 +00004337PJ_DECL(pj_status_t)
4338pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00004339
Benny Prijonodc39fe82006-05-26 12:17:46 +00004340
4341/**
Benny Prijono312aff92006-06-17 04:08:30 +00004342 * Register custom media transports to be used by calls. There must
4343 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004344 *
Benny Prijono312aff92006-06-17 04:08:30 +00004345 * @param tp The media transport array.
4346 * @param count Number of elements in the array. This number MUST
4347 * match the number of maximum calls configured when
4348 * pjsua is created.
4349 * @param auto_delete Flag to indicate whether the transports should be
4350 * destroyed when pjsua is shutdown.
4351 *
4352 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004353 *
4354 * \par Python:
4355 * Note applicable.
Benny Prijonodc39fe82006-05-26 12:17:46 +00004356 */
Benny Prijono312aff92006-06-17 04:08:30 +00004357PJ_DECL(pj_status_t)
4358pjsua_media_transports_attach( pjsua_media_transport tp[],
4359 unsigned count,
4360 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00004361
4362
Benny Prijono312aff92006-06-17 04:08:30 +00004363/**
4364 * @}
4365 */
4366
Benny Prijonof3195072006-02-14 21:15:30 +00004367
Benny Prijono268ca612006-02-07 12:34:11 +00004368
Benny Prijono312aff92006-06-17 04:08:30 +00004369/**
4370 * @}
4371 */
4372
Benny Prijonoe6ead542007-01-31 20:53:31 +00004373PJ_END_DECL
4374
Benny Prijono312aff92006-06-17 04:08:30 +00004375
Benny Prijono268ca612006-02-07 12:34:11 +00004376#endif /* __PJSUA_H__ */