blob: 4422b0ea554206654469a57886cdd4dc3851d71d [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 Prijonoeebe9af2006-06-13 22:57:13 +0000548 * Notify application when media state in the call has changed.
549 * Normal application would need to implement this callback, e.g.
550 * to connect the call's media to sound device.
Benny Prijono0875ae82006-12-26 00:11:48 +0000551 *
552 * @param call_id The call index.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000553 *
554 * \par Python Syntax:
555 * \code
556 # call_id: integer
557
558 def on_call_media_state(call_id):
559 return
560 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000561 */
562 void (*on_call_media_state)(pjsua_call_id call_id);
563
564 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000565 * Notify application upon incoming DTMF digits.
566 *
567 * @param call_id The call index.
568 * @param digit DTMF ASCII digit.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000569 *
570 * \par Python Syntax:
571 * \code
572 # call_id: integer
Benny Prijono1f63cc42007-09-10 16:54:22 +0000573 # digit: digit string
Benny Prijonoe6ead542007-01-31 20:53:31 +0000574
575 def on_dtmf_digit(call_id, digit):
576 return
577 * \endcode
Benny Prijono0875ae82006-12-26 00:11:48 +0000578 */
579 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
580
581 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000582 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000583 * Application can decide to accept/reject transfer request
584 * by setting the code (default is 200). When this callback
585 * is not defined, the default behavior is to accept the
586 * transfer.
Benny Prijono0875ae82006-12-26 00:11:48 +0000587 *
588 * @param call_id The call index.
589 * @param dst The destination where the call will be
590 * transfered to.
591 * @param code Status code to be returned for the call transfer
592 * request. On input, it contains status code 200.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000593 *
594 * \par Python Syntax:
595 * \code
596 # call_id: integer
597 # dst: string
598 # code: integer
599
600 def on_call_transfer_request(call_id, dst, code):
601 return code
602
603 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000604 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000605 void (*on_call_transfer_request)(pjsua_call_id call_id,
606 const pj_str_t *dst,
607 pjsip_status_code *code);
608
609 /**
610 * Notify application of the status of previously sent call
611 * transfer request. Application can monitor the status of the
612 * call transfer request, for example to decide whether to
613 * terminate existing call.
614 *
615 * @param call_id Call ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000616 * @param st_code Status progress of the transfer request.
617 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000618 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000619 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000620 * this callback is the final status.
621 * @param p_cont Initially will be set to non-zero, application
622 * can set this to FALSE if it no longer wants
623 * to receie further notification (for example,
624 * after it hangs up the call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000625 *
626 * \par Python Syntax:
627 * \code
628 # call_id: integer
629 # st_code: integer
630 # st_text: string
631 # final: integer
632 # cont: integer
633
634 # return: cont
635
636 def on_call_transfer_status(call_id, st_code, st_text, final, cont):
637 return cont
638 * \endcode
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000639 */
640 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000641 int st_code,
642 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000643 pj_bool_t final,
644 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000645
646 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000647 * Notify application about incoming INVITE with Replaces header.
648 * Application may reject the request by setting non-2xx code.
649 *
650 * @param call_id The call ID to be replaced.
651 * @param rdata The incoming INVITE request to replace the call.
652 * @param st_code Status code to be set by application. Application
653 * should only return a final status (200-699).
654 * @param st_text Optional status text to be set by application.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000655 *
656 * \par Python Syntax:
657 * \code
658 # call_id: integer
659 # rdata: an opaque object
660 # st_code: integer
661 # st_text: string
662
663 # return: (st_code, st_text) tuple
664
665 def on_call_replace_request(call_id, rdata, st_code, st_text):
666 return st_code, st_text
667 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000668 */
669 void (*on_call_replace_request)(pjsua_call_id call_id,
670 pjsip_rx_data *rdata,
671 int *st_code,
672 pj_str_t *st_text);
673
674 /**
675 * Notify application that an existing call has been replaced with
676 * a new call. This happens when PJSUA-API receives incoming INVITE
677 * request with Replaces header.
678 *
679 * After this callback is called, normally PJSUA-API will disconnect
680 * \a old_call_id and establish \a new_call_id.
681 *
682 * @param old_call_id Existing call which to be replaced with the
683 * new call.
684 * @param new_call_id The new call.
685 * @param rdata The incoming INVITE with Replaces request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000686 *
687 * \par Python Syntax:
688 * \code
689 # old_call_id: integer
690 # new_call_id: integer
691
692 def on_call_replaced(old_call_id, new_call_id):
693 return
694 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000695 */
696 void (*on_call_replaced)(pjsua_call_id old_call_id,
697 pjsua_call_id new_call_id);
698
699
700 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000701 * Notify application when registration status has changed.
702 * Application may then query the account info to get the
703 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000704 *
705 * @param acc_id Account ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000706 *
707 * \par Python Syntax:
708 * \code
709 # acc_id: account ID (integer)
710
711 def on_reg_state(acc_id):
712 return
713 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000714 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000715 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000716
717 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000718 * Notify application when the buddy state has changed.
719 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000720 *
721 * @param buddy_id The buddy id.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000722 *
723 * \par Python Syntax:
724 * \code
725 # buddy_id: integer
726
727 def on_buddy_state(buddy_id):
728 return
729 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000730 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000731 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000732
733 /**
734 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000735 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000736 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000737 *
Benny Prijonobbeb3992007-05-21 13:48:35 +0000738 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
739 * passed as one of the argument.
740 *
Benny Prijono0875ae82006-12-26 00:11:48 +0000741 * @param call_id Containts the ID of the call where the IM was
742 * sent, or PJSUA_INVALID_ID if the IM was sent
743 * outside call context.
744 * @param from URI of the sender.
745 * @param to URI of the destination message.
746 * @param contact The Contact URI of the sender, if present.
747 * @param mime_type MIME type of the message.
748 * @param body The message content.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000749 *
750 * \par Python Syntax:
751 * \code
752 # call_id: integer
753 # from: string
754 # to: string
755 # contact: string
756 # mime_type: string
757 # body: string
758
759 def on_pager(call_id, from, to, contact, mime_type, body):
760 return
761 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000762 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000763 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
764 const pj_str_t *to, const pj_str_t *contact,
765 const pj_str_t *mime_type, const pj_str_t *body);
766
767 /**
Benny Prijonobbeb3992007-05-21 13:48:35 +0000768 * This is the alternative version of the \a on_pager() callback with
769 * \a pjsip_rx_data argument.
770 *
771 * @param call_id Containts the ID of the call where the IM was
772 * sent, or PJSUA_INVALID_ID if the IM was sent
773 * outside call context.
774 * @param from URI of the sender.
775 * @param to URI of the destination message.
776 * @param contact The Contact URI of the sender, if present.
777 * @param mime_type MIME type of the message.
778 * @param body The message content.
779 * @param rdata The incoming MESSAGE request.
780 */
781 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
782 const pj_str_t *to, const pj_str_t *contact,
783 const pj_str_t *mime_type, const pj_str_t *body,
784 pjsip_rx_data *rdata);
785
786 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000787 * Notify application about the delivery status of outgoing pager
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000788 * request. See also on_pager_status2() callback for the version with
789 * \a pjsip_rx_data in the argument list.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000790 *
791 * @param call_id Containts the ID of the call where the IM was
792 * sent, or PJSUA_INVALID_ID if the IM was sent
793 * outside call context.
794 * @param to Destination URI.
795 * @param body Message body.
796 * @param user_data Arbitrary data that was specified when sending
797 * IM message.
798 * @param status Delivery status.
799 * @param reason Delivery status reason.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000800 *
801 * \par Python Syntax
802 * \code
803 # call_id: integer
804 # to: string
805 # body: string
806 # user_data: string
807 # status: integer
808 # reason: string
809
810 def on_pager_status(call_id, to, body, user_data, status, reason):
811 return
812 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000813 */
814 void (*on_pager_status)(pjsua_call_id call_id,
815 const pj_str_t *to,
816 const pj_str_t *body,
817 void *user_data,
818 pjsip_status_code status,
819 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000820
821 /**
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000822 * Notify application about the delivery status of outgoing pager
823 * request.
824 *
825 * @param call_id Containts the ID of the call where the IM was
826 * sent, or PJSUA_INVALID_ID if the IM was sent
827 * outside call context.
828 * @param to Destination URI.
829 * @param body Message body.
830 * @param user_data Arbitrary data that was specified when sending
831 * IM message.
832 * @param status Delivery status.
833 * @param reason Delivery status reason.
Benny Prijono0a982002007-06-12 16:22:09 +0000834 * @param tdata The original MESSAGE request.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000835 * @param rdata The incoming MESSAGE response, or NULL if the
836 * message transaction fails because of time out
837 * or transport error.
838 */
839 void (*on_pager_status2)(pjsua_call_id call_id,
840 const pj_str_t *to,
841 const pj_str_t *body,
842 void *user_data,
843 pjsip_status_code status,
844 const pj_str_t *reason,
Benny Prijono0a982002007-06-12 16:22:09 +0000845 pjsip_tx_data *tdata,
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000846 pjsip_rx_data *rdata);
847
848 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000849 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +0000850 *
851 * @param call_id Containts the ID of the call where the IM was
852 * sent, or PJSUA_INVALID_ID if the IM was sent
853 * outside call context.
854 * @param from URI of the sender.
855 * @param to URI of the destination message.
856 * @param contact The Contact URI of the sender, if present.
857 * @param is_typing Non-zero if peer is typing, or zero if peer
858 * has stopped typing a message.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000859 *
860 * \par Python Syntax
861 * \code
862 # call_id: string
863 # from: string
864 # to: string
865 # contact: string
866 # is_typing: integer
867
868 def on_typing(call_id, from, to, contact, is_typing):
869 return
870 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000871 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000872 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
873 const pj_str_t *to, const pj_str_t *contact,
874 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000875
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000876} pjsua_callback;
877
878
879
Benny Prijonodc39fe82006-05-26 12:17:46 +0000880
881/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000882 * This structure describes the settings to control the API and
883 * user agent behavior, and can be specified when calling #pjsua_init().
884 * Before setting the values, application must call #pjsua_config_default()
885 * to initialize this structure with the default values.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000886 *
887 * \par Python Sample Syntax:
888 * The pjsua_config type in Python is <tt>py_pjsua.Config</tt>. Application
889 * creates the instance by calling <tt>py_pjsua.config_default()</tt>:
890 * \code
891 cfg = py_pjsua.config_default()
892 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000893 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000894typedef struct pjsua_config
895{
896
897 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000898 * Maximum calls to support (default: 4). The value specified here
899 * must be smaller than the compile time maximum settings
900 * PJSUA_MAX_CALLS, which by default is 32. To increase this
901 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
902 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000903 */
904 unsigned max_calls;
905
906 /**
907 * Number of worker threads. Normally application will want to have at
908 * least one worker thread, unless when it wants to poll the library
909 * periodically, which in this case the worker thread can be set to
910 * zero.
911 */
912 unsigned thread_cnt;
913
914 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +0000915 * Number of nameservers. If no name server is configured, the SIP SRV
916 * resolution would be disabled, and domain will be resolved with
917 * standard pj_gethostbyname() function.
918 */
919 unsigned nameserver_count;
920
921 /**
922 * Array of nameservers to be used by the SIP resolver subsystem.
923 * The order of the name server specifies the priority (first name
924 * server will be used first, unless it is not reachable).
925 */
926 pj_str_t nameserver[4];
927
928 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000929 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000930 */
931 unsigned outbound_proxy_cnt;
932
933 /**
934 * Specify the URL of outbound proxies to visit for all outgoing requests.
935 * The outbound proxies will be used for all accounts, and it will
936 * be used to build the route set for outgoing requests. The final
937 * route set for outgoing requests will consists of the outbound proxies
938 * and the proxy configured in the account.
939 */
940 pj_str_t outbound_proxy[4];
941
Benny Prijonoc97608e2007-03-23 16:34:20 +0000942 /**
Benny Prijonoebbf6892007-03-24 17:37:25 +0000943 * Specify domain name to be resolved with DNS SRV resolution to get the
944 * address of the STUN servers. Alternatively application may specify
945 * \a stun_host and \a stun_relay_host instead.
946 *
947 * If DNS SRV resolution failed for this domain, then DNS A resolution
948 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +0000949 */
Benny Prijonoebbf6892007-03-24 17:37:25 +0000950 pj_str_t stun_domain;
951
952 /**
Benny Prijonoaf09dc32007-04-22 12:48:30 +0000953 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
954 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +0000955 */
956 pj_str_t stun_host;
957
958 /**
959 * Specify STUN relay server to be used.
960 */
961 pj_str_t stun_relay_host;
Benny Prijonoc97608e2007-03-23 16:34:20 +0000962
Benny Prijonodcfc0ba2007-09-30 16:50:27 +0000963 /**
964 * Specify whether support for reliable provisional response (100rel and
965 * PRACK) should be required by default. Note that this setting can be
966 * further customized in account configuration (#pjsua_acc_config).
967 *
968 * Default: PJ_FALSE
969 */
970 pj_bool_t require_100rel;
971
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000972 /**
973 * Number of credentials in the credential array.
974 */
975 unsigned cred_count;
976
977 /**
978 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +0000979 * and can be used to authenticate against outbound proxies. If the
980 * credential is specific to the account, then application should set
981 * the credential in the pjsua_acc_config rather than the credential
982 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000983 */
984 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
985
986 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000987 * Application callback to receive various event notifications from
988 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000989 */
990 pjsua_callback cb;
991
Benny Prijono56315612006-07-18 14:39:40 +0000992 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000993 * Optional user agent string (default empty). If it's empty, no
994 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +0000995 */
996 pj_str_t user_agent;
997
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000998} pjsua_config;
999
1000
1001/**
1002 * Use this function to initialize pjsua config.
1003 *
1004 * @param cfg pjsua config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001005 *
1006 * \par Python Sample Syntax:
1007 * The corresponding Python function creates an instance of the config and
1008 * initializes it to the default settings:
1009 * \code
1010 cfg = py_pjsua.config_default()
1011 * \endcode
1012
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001013 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001014PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001015
1016
1017/**
1018 * Duplicate credential.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001019 *
1020 * @param pool The memory pool.
1021 * @param dst Destination credential.
1022 * @param src Source credential.
1023 *
1024 * \par Python:
1025 * Not applicable (for now). Probably we could just assign one credential
1026 * variable to another, but this has not been tested.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001027 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001028PJ_DECL(void) pjsip_cred_dup( pj_pool_t *pool,
1029 pjsip_cred_info *dst,
1030 const pjsip_cred_info *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001031
1032
1033/**
1034 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001035 *
1036 * @param pool The pool to get memory from.
1037 * @param dst Destination config.
1038 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001039 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001040PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1041 pjsua_config *dst,
1042 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001043
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001044
1045/**
1046 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001047 * outgoing SIP message. It can (optionally) be specified for example
1048 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1049 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1050 *
1051 * Application MUST call #pjsua_msg_data_init() to initialize this
1052 * structure before setting its values.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001053 *
1054 * \par Python Syntax
1055 * The data type in Python is <tt>py_pjsua.Msg_Data</tt>. Application is
1056 * recommended to instantiate the structure by using this construct:
1057 * \code
1058 msg_data = py_pjsua.msg_data_init()
1059 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001060 */
1061typedef struct pjsua_msg_data
1062{
1063 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001064 * Additional message headers as linked list. Application can add
1065 * headers to the list by creating the header, either from the heap/pool
1066 * or from temporary local variable, and add the header using
1067 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001068 *
1069 * \par Python:
1070 * This field is implemented as string linked-list in Python, where each
1071 * string describes the header. For example:
1072 \code
1073 msg_data = py_pjsua.Msg_Data()
1074 msg_data.hdr_list = ["Subject: Hello py_pjsua!", "Priority: very low"]
1075 \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001076 */
1077 pjsip_hdr hdr_list;
1078
1079 /**
1080 * MIME type of optional message body.
1081 */
1082 pj_str_t content_type;
1083
1084 /**
1085 * Optional message body.
1086 */
1087 pj_str_t msg_body;
1088
1089} pjsua_msg_data;
1090
1091
1092/**
1093 * Initialize message data.
1094 *
1095 * @param msg_data Message data to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001096 *
1097 * \par Python
1098 * The corresponding Python function creates and initializes the structure:
1099 * \code
1100 msg_data = py_pjsua.msg_data_init()
1101 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001102 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001103PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001104
Benny Prijono268ca612006-02-07 12:34:11 +00001105
1106/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001107 * Instantiate pjsua application. Application must call this function before
1108 * calling any other functions, to make sure that the underlying libraries
1109 * are properly initialized. Once this function has returned success,
1110 * application must call pjsua_destroy() before quitting.
1111 *
1112 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001113 *
1114 * \par Python:
1115 * \code
1116 status = py_pjsua.create()
1117 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001118 */
1119PJ_DECL(pj_status_t) pjsua_create(void);
1120
1121
Benny Prijonoe6ead542007-01-31 20:53:31 +00001122/* Forward declaration */
1123typedef struct pjsua_media_config pjsua_media_config;
1124
1125
Benny Prijonodc39fe82006-05-26 12:17:46 +00001126/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001127 * Initialize pjsua with the specified settings. All the settings are
1128 * optional, and the default values will be used when the config is not
1129 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001130 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001131 * Note that #pjsua_create() MUST be called before calling this function.
1132 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001133 * @param ua_cfg User agent configuration.
1134 * @param log_cfg Optional logging configuration.
1135 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001136 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001137 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001138 *
1139 * \par Python:
1140 * The function is similar in Python:
1141 * \code
1142 status = py_pjsua.init(ua_cfg, log_cfg, media_cfg)
1143 * \endcode
1144 * Note that \a ua_cfg, \a log_cfg, and \a media_cfg are optional, and
1145 * the Python script may pass None if it doesn't want to configure the
1146 * setting.
Benny Prijono268ca612006-02-07 12:34:11 +00001147 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001148PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1149 const pjsua_logging_config *log_cfg,
1150 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001151
1152
1153/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001154 * Application is recommended to call this function after all initialization
1155 * is done, so that the library can do additional checking set up
1156 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001157 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001158 * Application may call this function anytime after #pjsua_init().
1159 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001160 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001161 *
1162 * \par Python:
1163 * The function is similar in Python:
1164 * \code
1165 status = py_pjsua.start()
1166 * \endcode
Benny Prijonoccf95622006-02-07 18:48:01 +00001167 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001168PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001169
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001170
Benny Prijonoccf95622006-02-07 18:48:01 +00001171/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001172 * Destroy pjsua. Application is recommended to perform graceful shutdown
1173 * before calling this function (such as unregister the account from the SIP
1174 * server, terminate presense subscription, and hangup active calls), however,
1175 * this function will do all of these if it finds there are active sessions
1176 * that need to be terminated. This function will approximately block for
1177 * one second to wait for replies from remote.
1178 *
1179 * Application.may safely call this function more than once if it doesn't
1180 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001181 *
1182 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001183 *
1184 * \par Python:
1185 * The function is similar in Python:
1186 * \code
1187 status = py_pjsua.destroy()
1188 * \endcode
Benny Prijono268ca612006-02-07 12:34:11 +00001189 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001190PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001191
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001192
Benny Prijono9fc735d2006-05-28 14:58:12 +00001193/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001194 * Poll pjsua for events, and if necessary block the caller thread for
1195 * the specified maximum interval (in miliseconds).
1196 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001197 * Application doesn't normally need to call this function if it has
1198 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1199 * because polling then will be done by these worker threads instead.
1200 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001201 * @param msec_timeout Maximum time to wait, in miliseconds.
1202 *
1203 * @return The number of events that have been handled during the
1204 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001205 * can retrieve the error as (status = -return_value).
1206 *
1207 * \par Python:
1208 * The function is similar in Python:
1209 * \code
1210 n = py_pjsua.handle_events(msec_timeout)
1211 * \endcode
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001212 */
1213PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1214
1215
1216/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001217 * Create memory pool to be used by the application. Once application
1218 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001219 *
1220 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001221 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001222 * @param increment Increment size.
1223 *
1224 * @return The pool, or NULL when there's no memory.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001225 *
1226 * \par Python:
1227 * Python script may also create a pool object from the script:
1228 * \code
1229 pool = py_pjsua.pool_create(name, init_size, increment)
1230 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001231 */
1232PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1233 pj_size_t increment);
1234
1235
1236/**
1237 * Application can call this function at any time (after pjsua_create(), of
1238 * course) to change logging settings.
1239 *
1240 * @param c Logging configuration.
1241 *
1242 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001243 *
1244 * \par Python:
1245 * The function is similar in Python:
1246 * \code
1247 status = py_pjsua.reconfigure_logging(log_cfg)
1248 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001249 */
1250PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1251
1252
1253/**
1254 * Internal function to get SIP endpoint instance of pjsua, which is
1255 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001256 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001257 *
1258 * @return SIP endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001259 *
1260 * \par Python:
1261 * Application may retrieve the SIP endpoint instance:
1262 * \code
1263 endpt = py_pjsua.get_pjsip_endpt()
1264 * \endcode
1265 * However currently the object is just an opaque object and does not have
1266 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001267 */
1268PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1269
1270/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001271 * Internal function to get media endpoint instance.
1272 * Only valid after #pjsua_init() is called.
1273 *
1274 * @return Media endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001275 *
1276 * \par Python:
1277 * Application may retrieve the media endpoint instance:
1278 * \code
1279 endpt = py_pjsua.get_pjmedia_endpt()
1280 * \endcode
1281 * However currently the object is just an opaque object and does not have
1282 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001283 */
1284PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1285
Benny Prijono97b87172006-08-24 14:25:14 +00001286/**
1287 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001288 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001289 *
1290 * @return Pool factory currently used by PJSUA.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001291 *
1292 * \par Python:
1293 * Application may retrieve the pool factory instance:
1294 * \code
1295 endpt = py_pjsua.get_pool_factory()
1296 * \endcode
1297 * However currently the object is just an opaque object and does not have
1298 * any use for Python scripts.
Benny Prijono97b87172006-08-24 14:25:14 +00001299 */
1300PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1301
1302
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001303
1304/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001305 * Utilities.
1306 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001307 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001308
1309/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001310 * This is a utility function to verify that valid SIP url is given. If the
1311 * URL is valid, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001312 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001313 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001314 *
1315 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001316 *
1317 * \par Python:
1318 * \code
1319 status = py_pjsua.verify_sip_url(url)
1320 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001321 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001322PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001323
1324
1325/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001326 * This is a utility function to display error message for the specified
1327 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001328 *
1329 * @param sender The log sender field.
1330 * @param title Message title for the error.
1331 * @param status Status code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001332 *
1333 * \par Python:
1334 * \code
1335 py_pjsua.perror(sender, title, status)
1336 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001337 */
1338PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1339 pj_status_t status);
1340
1341
Benny Prijonoda9785b2007-04-02 20:43:06 +00001342/**
1343 * This is a utility function to dump the stack states to log, using
1344 * verbosity level 3.
1345 *
1346 * @param detail Will print detailed output (such as list of
1347 * SIP transactions) when non-zero.
1348 */
1349PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001350
1351/**
1352 * @}
1353 */
1354
1355
1356
1357/*****************************************************************************
1358 * TRANSPORT API
1359 */
1360
1361/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001362 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001363 * @ingroup PJSUA_LIB
1364 * @brief API for managing SIP transports
1365 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001366 *
1367 * PJSUA-API supports creating multiple transport instances, for example UDP,
1368 * TCP, and TLS transport. SIP transport must be created before adding an
1369 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001370 */
1371
1372
Benny Prijonoe6ead542007-01-31 20:53:31 +00001373/** SIP transport identification.
1374 */
Benny Prijono312aff92006-06-17 04:08:30 +00001375typedef int pjsua_transport_id;
1376
1377
1378/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001379 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001380 * and media. Before setting some values to this structure, application
1381 * MUST call #pjsua_transport_config_default() to initialize its
1382 * values with default settings.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001383 *
1384 * \par Python:
1385 * The data type in Python is <tt>py_pjsua.Transport_Config</tt>,
1386 * although application can just do this to create the instance:
1387 * \code
1388 transport_cfg = py_pjsua.transport_config_default()
1389 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001390 */
1391typedef struct pjsua_transport_config
1392{
1393 /**
1394 * UDP port number to bind locally. This setting MUST be specified
1395 * even when default port is desired. If the value is zero, the
1396 * transport will be bound to any available port, and application
1397 * can query the port by querying the transport info.
1398 */
1399 unsigned port;
1400
1401 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001402 * Optional address to advertise as the address of this transport.
1403 * Application can specify any address or hostname for this field,
1404 * for example it can point to one of the interface address in the
1405 * system, or it can point to the public address of a NAT router
1406 * where port mappings have been configured for the application.
1407 *
1408 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001409 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001410 pj_str_t public_addr;
1411
1412 /**
1413 * Optional address where the socket should be bound to. This option
1414 * SHOULD only be used to selectively bind the socket to particular
1415 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1416 * published address of a transport (the public_addr field should be
1417 * used for that purpose).
1418 *
1419 * Note that unlike public_addr field, the address (or hostname) here
1420 * MUST correspond to the actual interface address in the host, since
1421 * this address will be specified as bind() argument.
1422 */
1423 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001424
1425 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001426 * This specifies TLS settings for TLS transport. It is only be used
1427 * when this transport config is being used to create a SIP TLS
1428 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001429 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001430 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001431
Benny Prijono312aff92006-06-17 04:08:30 +00001432} pjsua_transport_config;
1433
1434
1435/**
1436 * Call this function to initialize UDP config with default values.
1437 *
1438 * @param cfg The UDP config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001439 *
1440 * \par Python:
1441 * The corresponding Python function is rather different:
1442 * \code
1443 transport_cfg = py_pjsua.transport_config_default()
1444 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001445 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001446PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001447
1448
1449/**
Benny Prijono312aff92006-06-17 04:08:30 +00001450 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001451 *
1452 * @param pool The pool.
1453 * @param dst The destination config.
1454 * @param src The source config.
1455 *
1456 * \par Python:
1457 * Not applicable. One should be able to just copy one variable instance
1458 * to another in Python.
Benny Prijono312aff92006-06-17 04:08:30 +00001459 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001460PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1461 pjsua_transport_config *dst,
1462 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001463
1464
1465/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001466 * This structure describes transport information returned by
1467 * #pjsua_transport_get_info() function.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001468 *
1469 * \par Python:
1470 * The corresponding data type in Python is <tt>py_pjsua.Transport_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001471 */
1472typedef struct pjsua_transport_info
1473{
1474 /**
1475 * PJSUA transport identification.
1476 */
1477 pjsua_transport_id id;
1478
1479 /**
1480 * Transport type.
1481 */
1482 pjsip_transport_type_e type;
1483
1484 /**
1485 * Transport type name.
1486 */
1487 pj_str_t type_name;
1488
1489 /**
1490 * Transport string info/description.
1491 */
1492 pj_str_t info;
1493
1494 /**
1495 * Transport flag (see ##pjsip_transport_flags_e).
1496 */
1497 unsigned flag;
1498
1499 /**
1500 * Local address length.
1501 */
1502 unsigned addr_len;
1503
1504 /**
1505 * Local/bound address.
1506 */
1507 pj_sockaddr local_addr;
1508
1509 /**
1510 * Published address (or transport address name).
1511 */
1512 pjsip_host_port local_name;
1513
1514 /**
1515 * Current number of objects currently referencing this transport.
1516 */
1517 unsigned usage_count;
1518
1519
1520} pjsua_transport_info;
1521
1522
1523/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001524 * Create and start a new SIP transport according to the specified
1525 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001526 *
1527 * @param type Transport type.
1528 * @param cfg Transport configuration.
1529 * @param p_id Optional pointer to receive transport ID.
1530 *
1531 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001532 *
1533 * \par Python:
1534 * The corresponding Python function returns (status,id) tuple:
1535 * \code
1536 status, transport_id = py_pjsua.transport_create(type, cfg)
1537 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001538 */
1539PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1540 const pjsua_transport_config *cfg,
1541 pjsua_transport_id *p_id);
1542
1543/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001544 * Register transport that has been created by application. This function
1545 * is useful if application wants to implement custom SIP transport and use
1546 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001547 *
1548 * @param tp Transport instance.
1549 * @param p_id Optional pointer to receive transport ID.
1550 *
1551 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001552 *
1553 * \par Python:
1554 * Not applicable (for now), because one cannot create a custom transport
1555 * from Python script.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001556 */
1557PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1558 pjsua_transport_id *p_id);
1559
1560
1561/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001562 * Enumerate all transports currently created in the system. This function
1563 * will return all transport IDs, and application may then call
1564 * #pjsua_transport_get_info() function to retrieve detailed information
1565 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001566 *
1567 * @param id Array to receive transport ids.
1568 * @param count In input, specifies the maximum number of elements.
1569 * On return, it contains the actual number of elements.
1570 *
1571 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001572 *
1573 * \par Python:
1574 * The function returns list of integers representing transport ids:
1575 * \code
1576 [int] = py_pjsua.enum_transports()
1577 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001578 */
1579PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1580 unsigned *count );
1581
1582
1583/**
1584 * Get information about transports.
1585 *
1586 * @param id Transport ID.
1587 * @param info Pointer to receive transport info.
1588 *
1589 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001590 *
1591 * \par Python:
1592 * \code
1593 transport_info = py_pjsua.transport_get_info(id)
1594 * \endcode
1595 * The Python function returns None on error.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001596 */
1597PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1598 pjsua_transport_info *info);
1599
1600
1601/**
1602 * Disable a transport or re-enable it. By default transport is always
1603 * enabled after it is created. Disabling a transport does not necessarily
1604 * close the socket, it will only discard incoming messages and prevent
1605 * the transport from being used to send outgoing messages.
1606 *
1607 * @param id Transport ID.
1608 * @param enabled Non-zero to enable, zero to disable.
1609 *
1610 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001611 *
1612 * \par Python:
1613 * \code
1614 status = py_pjsua.transport_set_enable(id, enabled)
1615 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001616 */
1617PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1618 pj_bool_t enabled);
1619
1620
1621/**
1622 * Close the transport. If transport is forcefully closed, it will be
1623 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00001624 * transport may not terminate properly (it may even crash). Otherwise,
1625 * the system will wait until all transactions are closed while preventing
1626 * new users from using the transport, and will close the transport when
1627 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001628 *
1629 * @param id Transport ID.
1630 * @param force Non-zero to immediately close the transport. This
1631 * is not recommended!
1632 *
1633 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001634 *
1635 * \par Python:
1636 * \code
1637 status = py_pjsua.transport_close(id, force)
1638 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001639 */
1640PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1641 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001642
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001643/**
Benny Prijono312aff92006-06-17 04:08:30 +00001644 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001645 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001646
1647
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001648
1649
1650/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001651 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001652 */
1653
Benny Prijono312aff92006-06-17 04:08:30 +00001654
1655/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001656 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001657 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001658 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001659 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001660 *
Benny Prijono312aff92006-06-17 04:08:30 +00001661 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001662 * using the application. In SIP terms, the identity is used as the <b>From</b>
1663 * header in outgoing requests.
1664 *
1665 * PJSUA-API supports creating and managing multiple accounts. The maximum
1666 * number of accounts is limited by a compile time constant
1667 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001668 *
1669 * Account may or may not have client registration associated with it.
1670 * An account is also associated with <b>route set</b> and some <b>authentication
1671 * credentials</b>, which are used when sending SIP request messages using the
1672 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00001673 * will be reported to remote peer when they subscribe to the account's
1674 * presence, or which is published to a presence server if presence
1675 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00001676 *
1677 * At least one account MUST be created in the application. If no user
1678 * association is required, application can create a userless account by
1679 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00001680 * instead of a particular user, and it correspond with a particular
1681 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00001682 *
1683 * Also one account must be set as the <b>default account</b>, which is used as
1684 * the account to use when PJSUA fails to match a request with any other
1685 * accounts.
1686 *
1687 * When sending outgoing SIP requests (such as making calls or sending
1688 * instant messages), normally PJSUA requires the application to specify
1689 * which account to use for the request. If no account is specified,
1690 * PJSUA may be able to select the account by matching the destination
1691 * domain name, and fall back to default account when no match is found.
1692 */
1693
1694/**
1695 * Maximum accounts.
1696 */
1697#ifndef PJSUA_MAX_ACC
1698# define PJSUA_MAX_ACC 8
1699#endif
1700
1701
1702/**
1703 * Default registration interval.
1704 */
1705#ifndef PJSUA_REG_INTERVAL
1706# define PJSUA_REG_INTERVAL 55
1707#endif
1708
1709
1710/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001711 * Default PUBLISH expiration
1712 */
1713#ifndef PJSUA_PUBLISH_EXPIRATION
1714# define PJSUA_PUBLISH_EXPIRATION 600
1715#endif
1716
1717
1718/**
Benny Prijono093d3022006-09-24 00:07:11 +00001719 * Default account priority.
1720 */
1721#ifndef PJSUA_DEFAULT_ACC_PRIORITY
1722# define PJSUA_DEFAULT_ACC_PRIORITY 0
1723#endif
1724
1725
1726/**
Benny Prijono8058a622007-06-08 04:37:05 +00001727 * This macro specifies the URI scheme to use in Contact header
1728 * when secure transport such as TLS is used. Application can specify
1729 * either "sip" or "sips".
1730 */
1731#ifndef PJSUA_SECURE_SCHEME
Benny Prijono66ceef52007-06-08 05:12:58 +00001732# define PJSUA_SECURE_SCHEME "sip"
Benny Prijono8058a622007-06-08 04:37:05 +00001733#endif
1734
1735
1736/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001737 * This structure describes account configuration to be specified when
1738 * adding a new account with #pjsua_acc_add(). Application MUST initialize
1739 * this structure first by calling #pjsua_acc_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00001740 *
1741 * \par Python:
1742 * The data type in Python is <tt>py_pjsua.Acc_Config</tt>, but normally
1743 * application can just use the snippet below to create and initialize
1744 * the account config:
1745 * \code
1746 acc_cfg = py_pjsua.acc_config_default()
1747 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001748 */
1749typedef struct pjsua_acc_config
1750{
Benny Prijono093d3022006-09-24 00:07:11 +00001751 /**
1752 * Account priority, which is used to control the order of matching
1753 * incoming/outgoing requests. The higher the number means the higher
1754 * the priority is, and the account will be matched first.
1755 */
1756 int priority;
1757
Benny Prijono312aff92006-06-17 04:08:30 +00001758 /**
1759 * The full SIP URL for the account. The value can take name address or
1760 * URL format, and will look something like "sip:account@serviceprovider".
1761 *
1762 * This field is mandatory.
1763 */
1764 pj_str_t id;
1765
1766 /**
1767 * This is the URL to be put in the request URI for the registration,
1768 * and will look something like "sip:serviceprovider".
1769 *
1770 * This field should be specified if registration is desired. If the
1771 * value is empty, no account registration will be performed.
1772 */
1773 pj_str_t reg_uri;
1774
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001775 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001776 * If this flag is set, the presence information of this account will
1777 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001778 */
1779 pj_bool_t publish_enabled;
1780
Benny Prijonofe04fb52007-08-24 08:28:52 +00001781 /**
1782 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
1783 * is not specified, a random string will be used.
1784 */
1785 pj_str_t pidf_tuple_id;
1786
Benny Prijono312aff92006-06-17 04:08:30 +00001787 /**
1788 * Optional URI to be put as Contact for this account. It is recommended
1789 * that this field is left empty, so that the value will be calculated
1790 * automatically based on the transport address.
1791 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00001792 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00001793
1794 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001795 * Specify whether support for reliable provisional response (100rel and
1796 * PRACK) should be required for all sessions of this account.
1797 *
1798 * Default: PJ_FALSE
1799 */
1800 pj_bool_t require_100rel;
1801
1802 /**
Benny Prijono312aff92006-06-17 04:08:30 +00001803 * Number of proxies in the proxy array below.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001804 *
1805 * \par Python:
1806 * Not applicable, as \a proxy is implemented as list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001807 */
1808 unsigned proxy_cnt;
1809
1810 /**
1811 * Optional URI of the proxies to be visited for all outgoing requests
1812 * that are using this account (REGISTER, INVITE, etc). Application need
1813 * to specify these proxies if the service provider requires that requests
1814 * destined towards its network should go through certain proxies first
1815 * (for example, border controllers).
1816 *
1817 * These proxies will be put in the route set for this account, with
1818 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00001819 * first). If global outbound proxies are configured in pjsua_config,
1820 * then these account proxies will be placed after the global outbound
1821 * proxies in the routeset.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001822 *
1823 * \par Python:
1824 * This will be list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001825 */
1826 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
1827
1828 /**
1829 * Optional interval for registration, in seconds. If the value is zero,
1830 * default interval will be used (PJSUA_REG_INTERVAL, 55 seconds).
1831 */
1832 unsigned reg_timeout;
1833
1834 /**
1835 * Number of credentials in the credential array.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001836 *
1837 * \par Python:
1838 * Not applicable, since \a cred_info is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00001839 */
1840 unsigned cred_count;
1841
1842 /**
1843 * Array of credentials. If registration is desired, normally there should
1844 * be at least one credential specified, to successfully authenticate
1845 * against the service provider. More credentials can be specified, for
1846 * example when the requests are expected to be challenged by the
1847 * proxies in the route set.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001848 *
1849 * \par Python:
1850 * This field is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00001851 */
1852 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1853
Benny Prijono62c5c5b2007-01-13 23:22:40 +00001854 /**
1855 * Optionally bind this account to specific transport. This normally is
1856 * not a good idea, as account should be able to send requests using
1857 * any available transports according to the destination. But some
1858 * application may want to have explicit control over the transport to
1859 * use, so in that case it can set this field.
1860 *
1861 * Default: -1 (PJSUA_INVALID_ID)
1862 *
1863 * @see pjsua_acc_set_transport()
1864 */
1865 pjsua_transport_id transport_id;
1866
Benny Prijono15b02302007-09-27 14:07:07 +00001867 /**
1868 * This option is useful for keeping the UDP transport address up to
1869 * date with the NAT public mapped address. When this option is
1870 * enabled and STUN is configured, the library will keep track of
1871 * the public IP address from the response of REGISTER request. Once
1872 * it detects that the address has changed, it will unregister current
1873 * Contact, update the UDP transport address, and register a new
1874 * Contact to the registrar.
1875 *
1876 * Default: 1 (yes)
1877 */
1878 pj_bool_t auto_update_nat;
1879
Benny Prijono312aff92006-06-17 04:08:30 +00001880} pjsua_acc_config;
1881
1882
1883/**
1884 * Call this function to initialize account config with default values.
1885 *
1886 * @param cfg The account config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001887 *
1888 * \par Python:
1889 * In Python, this function both creates and initializes the account
1890 * config:
1891 * \code
1892 acc_cfg = py_pjsua.acc_config_default()
1893 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001894 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001895PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001896
1897
1898/**
1899 * Account info. Application can query account info by calling
1900 * #pjsua_acc_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00001901 *
1902 * \par Python:
1903 * The data type in Python is <tt>py_pjsua.Acc_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001904 */
1905typedef struct pjsua_acc_info
1906{
1907 /**
1908 * The account ID.
1909 */
1910 pjsua_acc_id id;
1911
1912 /**
1913 * Flag to indicate whether this is the default account.
1914 */
1915 pj_bool_t is_default;
1916
1917 /**
1918 * Account URI
1919 */
1920 pj_str_t acc_uri;
1921
1922 /**
1923 * Flag to tell whether this account has registration setting
1924 * (reg_uri is not empty).
1925 */
1926 pj_bool_t has_registration;
1927
1928 /**
1929 * An up to date expiration interval for account registration session.
1930 */
1931 int expires;
1932
1933 /**
1934 * Last registration status code. If status code is zero, the account
1935 * is currently not registered. Any other value indicates the SIP
1936 * status code of the registration.
1937 */
1938 pjsip_status_code status;
1939
1940 /**
1941 * String describing the registration status.
1942 */
1943 pj_str_t status_text;
1944
1945 /**
1946 * Presence online status for this account.
1947 */
1948 pj_bool_t online_status;
1949
1950 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00001951 * Presence online status text.
1952 */
1953 pj_str_t online_status_text;
1954
1955 /**
1956 * Extended RPID online status information.
1957 */
1958 pjrpid_element rpid;
1959
1960 /**
Benny Prijono312aff92006-06-17 04:08:30 +00001961 * Buffer that is used internally to store the status text.
1962 */
1963 char buf_[PJ_ERR_MSG_SIZE];
1964
1965} pjsua_acc_info;
1966
1967
1968
1969/**
1970 * Get number of current accounts.
1971 *
1972 * @return Current number of accounts.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001973 *
1974 * \par Python:
1975 * \code
1976 count = py_pjsua.acc_get_count()
1977 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001978 */
1979PJ_DECL(unsigned) pjsua_acc_get_count(void);
1980
1981
1982/**
1983 * Check if the specified account ID is valid.
1984 *
1985 * @param acc_id Account ID to check.
1986 *
1987 * @return Non-zero if account ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001988 *
1989 * \par Python:
1990 * \code
1991 is_valid = py_pjsua.acc_is_valid(acc_id)
1992 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001993 */
1994PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
1995
1996
1997/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00001998 * Set default account to be used when incoming and outgoing
1999 * requests doesn't match any accounts.
2000 *
2001 * @param acc_id The account ID to be used as default.
2002 *
2003 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002004 *
2005 * \par Python:
2006 * \code
2007 status = py_pjsua.acc_set_default(acc_id)
2008 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002009 */
2010PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2011
2012
2013/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002014 * Get default account to be used when receiving incoming requests (calls),
2015 * when the destination of the incoming call doesn't match any other
2016 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002017 *
2018 * @return The default account ID, or PJSUA_INVALID_ID if no
2019 * default account is configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002020 *
2021 * \par Python:
2022 * \code
2023 acc_id = py_pjsua.acc_get_default()
2024 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002025 */
2026PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2027
2028
2029/**
Benny Prijono312aff92006-06-17 04:08:30 +00002030 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002031 * #pjsua_init()) before calling this function. If registration is configured
2032 * for this account, this function would also start the SIP registration
2033 * session with the SIP registrar server. This SIP registration session
2034 * will be maintained internally by the library, and application doesn't
2035 * need to do anything to maintain the registration session.
2036 *
Benny Prijono312aff92006-06-17 04:08:30 +00002037 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002038 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002039 * @param is_default If non-zero, this account will be set as the default
2040 * account. The default account will be used when sending
2041 * outgoing requests (e.g. making call) when no account is
2042 * specified, and when receiving incoming requests when the
2043 * request does not match any accounts. It is recommended
2044 * that default account is set to local/LAN account.
2045 * @param p_acc_id Pointer to receive account ID of the new account.
2046 *
2047 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002048 *
2049 * \par Python:
2050 * The function returns (status, account_id) tuple:
2051 * \code
2052 status, account_id = py_pjsua.acc_add(acc_cfg, is_default)
2053 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002054 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002055PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002056 pj_bool_t is_default,
2057 pjsua_acc_id *p_acc_id);
2058
2059
2060/**
2061 * Add a local account. A local account is used to identify local endpoint
2062 * instead of a specific user, and for this reason, a transport ID is needed
2063 * to obtain the local address information.
2064 *
2065 * @param tid Transport ID to generate account address.
2066 * @param is_default If non-zero, this account will be set as the default
2067 * account. The default account will be used when sending
2068 * outgoing requests (e.g. making call) when no account is
2069 * specified, and when receiving incoming requests when the
2070 * request does not match any accounts. It is recommended
2071 * that default account is set to local/LAN account.
2072 * @param p_acc_id Pointer to receive account ID of the new account.
2073 *
2074 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002075 *
2076 * \par Python:
2077 * The function returns (status, account_id) tuple:
2078 * \code
2079 status, account_id = py_pjsua.acc_add_local(tid, is_default)
2080 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002081 */
2082PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2083 pj_bool_t is_default,
2084 pjsua_acc_id *p_acc_id);
2085
2086/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002087 * Delete an account. This will unregister the account from the SIP server,
2088 * if necessary, and terminate server side presence subscriptions associated
2089 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002090 *
2091 * @param acc_id Id of the account to be deleted.
2092 *
2093 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002094 *
2095 * \par Python:
2096 * \code
2097 status = py_pjsua.acc_del(acc_id)
2098 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002099 */
2100PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2101
2102
2103/**
2104 * Modify account information.
2105 *
2106 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002107 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002108 *
2109 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002110 *
2111 * \par Python:
2112 * \code
2113 status = py_pjsua.acc_modify(acc_id, acc_cfg)
2114 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002115 */
2116PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002117 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002118
2119
2120/**
2121 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002122 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002123 * if there are server side presence subscription for this account, and/or
2124 * outgoing PUBLISH if presence publication is enabled for this account.
2125 *
2126 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002127 *
2128 * @param acc_id The account ID.
2129 * @param is_online True of false.
2130 *
2131 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002132 *
2133 * \par Python:
2134 * \code
2135 status = py_pjsua.acc_set_online_status(acc_id, is_online)
2136 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002137 */
2138PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2139 pj_bool_t is_online);
2140
Benny Prijono4461c7d2007-08-25 13:36:15 +00002141/**
2142 * Modify account's presence status to be advertised to remote/presence
2143 * subscribers. This would trigger the sending of outgoing NOTIFY request
2144 * if there are server side presence subscription for this account, and/or
2145 * outgoing PUBLISH if presence publication is enabled for this account.
2146 *
2147 * @see pjsua_acc_set_online_status()
2148 *
2149 * @param acc_id The account ID.
2150 * @param is_online True of false.
2151 * @param pr Extended information in subset of RPID format
2152 * which allows setting custom presence text.
2153 *
2154 * @return PJ_SUCCESS on success, or the appropriate error code.
2155 */
2156PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2157 pj_bool_t is_online,
2158 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002159
2160/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002161 * Update registration or perform unregistration. If registration is
2162 * configured for this account, then initial SIP REGISTER will be sent
2163 * when the account is added with #pjsua_acc_add(). Application normally
2164 * only need to call this function if it wants to manually update the
2165 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002166 *
2167 * @param acc_id The account ID.
2168 * @param renew If renew argument is zero, this will start
2169 * unregistration process.
2170 *
2171 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002172 *
2173 * \par Python:
2174 * \code
2175 status = py_pjsua.acc_set_registration(acc_id, renew)
2176 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002177 */
2178PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2179 pj_bool_t renew);
2180
2181
2182/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002183 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002184 *
2185 * @param acc_id Account identification.
2186 * @param info Pointer to receive account information.
2187 *
2188 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002189 *
2190 * \par Python:
2191 * \code
2192 acc_info = py_pjsua.acc_get_info(acc_id)
2193 * \endcode
2194 * The function returns None if account ID is not valid.
Benny Prijono312aff92006-06-17 04:08:30 +00002195 */
2196PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2197 pjsua_acc_info *info);
2198
2199
2200/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002201 * Enumerate all account currently active in the library. This will fill
2202 * the array with the account Ids, and application can then query the
2203 * account information for each id with #pjsua_acc_get_info().
2204 *
2205 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002206 *
2207 * @param ids Array of account IDs to be initialized.
2208 * @param count In input, specifies the maximum number of elements.
2209 * On return, it contains the actual number of elements.
2210 *
2211 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002212 *
2213 * \par Python:
2214 * The function takes no argument and returns list of account Ids:
2215 * \code
2216 [acc_ids] = py_pjsua.enum_accs()
2217 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002218 */
2219PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2220 unsigned *count );
2221
2222
2223/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002224 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002225 *
2226 * @param info Array of account infos to be initialized.
2227 * @param count In input, specifies the maximum number of elements.
2228 * On return, it contains the actual number of elements.
2229 *
2230 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002231 *
2232 * \par Python:
2233 * The function takes no argument and returns list of account infos:
2234 * \code
2235 [acc_info] = py_pjsua.acc_enum_info()
2236 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002237 */
2238PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2239 unsigned *count );
2240
2241
2242/**
2243 * This is an internal function to find the most appropriate account to
2244 * used to reach to the specified URL.
2245 *
2246 * @param url The remote URL to reach.
2247 *
2248 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002249 *
2250 * \par Python:
2251 * \code
2252 acc_id = py_pjsua.acc_find_for_outgoing(url)
2253 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002254 */
2255PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2256
2257
2258/**
2259 * This is an internal function to find the most appropriate account to be
2260 * used to handle incoming calls.
2261 *
2262 * @param rdata The incoming request message.
2263 *
2264 * @return Account id.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002265 *
2266 * \par Python:
2267 * \code
2268 acc_id = py_pjsua.acc_find_for_outgoing(url)
2269 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002270 */
2271PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2272
2273
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002274/**
Benny Prijonofff245c2007-04-02 11:44:47 +00002275 * Create arbitrary requests using the account. Application should only use
2276 * this function to create auxiliary requests outside dialog, such as
2277 * OPTIONS, and use the call or presence API to create dialog related
2278 * requests.
2279 *
2280 * @param acc_id The account ID.
2281 * @param method The SIP method of the request.
2282 * @param target Target URI.
2283 * @param p_tdata Pointer to receive the request.
2284 *
2285 * @return PJ_SUCCESS or the error code.
2286 */
2287PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
2288 const pjsip_method *method,
2289 const pj_str_t *target,
2290 pjsip_tx_data **p_tdata);
2291
2292
2293/**
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002294 * Create a suitable URI to be put as Contact based on the specified
2295 * target URI for the specified account.
2296 *
2297 * @param pool Pool to allocate memory for the string.
2298 * @param contact The string where the Contact URI will be stored.
2299 * @param acc_id Account ID.
2300 * @param uri Destination URI of the request.
2301 *
2302 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002303 *
2304 * \par Python:
2305 * This function is still experimental in Python:
2306 * \code
2307 uri = py_pjsua.acc_create_uac_contact(pool, acc_id, uri)
2308 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002309 */
2310PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
2311 pj_str_t *contact,
2312 pjsua_acc_id acc_id,
2313 const pj_str_t *uri);
2314
2315
2316
2317/**
2318 * Create a suitable URI to be put as Contact based on the information
2319 * in the incoming request.
2320 *
2321 * @param pool Pool to allocate memory for the string.
2322 * @param contact The string where the Contact URI will be stored.
2323 * @param acc_id Account ID.
2324 * @param rdata Incoming request.
2325 *
2326 * @return PJ_SUCCESS on success, other on error.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002327 *
2328 * \par Python:
2329 * This function is still experimental in Python:
2330 * \code
2331 uri = py_pjsua.acc_create_uas_contact(pool, acc_id, rdata)
2332 * \endcode
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002333 */
2334PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
2335 pj_str_t *contact,
2336 pjsua_acc_id acc_id,
2337 pjsip_rx_data *rdata );
2338
2339
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002340/**
2341 * Lock/bind this account to a specific transport/listener. Normally
2342 * application shouldn't need to do this, as transports will be selected
2343 * automatically by the stack according to the destination.
2344 *
2345 * When account is locked/bound to a specific transport, all outgoing
2346 * requests from this account will use the specified transport (this
2347 * includes SIP registration, dialog (call and event subscription), and
2348 * out-of-dialog requests such as MESSAGE).
2349 *
2350 * Note that transport_id may be specified in pjsua_acc_config too.
2351 *
2352 * @param acc_id The account ID.
2353 * @param tp_id The transport ID.
2354 *
2355 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002356 *
2357 * \par Python:
2358 * Not yet implemented.
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002359 */
2360PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
2361 pjsua_transport_id tp_id);
2362
Benny Prijono312aff92006-06-17 04:08:30 +00002363
2364/**
2365 * @}
2366 */
2367
2368
2369/*****************************************************************************
2370 * CALLS API
2371 */
2372
2373
2374/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002375 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00002376 * @ingroup PJSUA_LIB
2377 * @brief Call manipulation.
2378 * @{
2379 */
2380
2381/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002382 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00002383 */
2384#ifndef PJSUA_MAX_CALLS
2385# define PJSUA_MAX_CALLS 32
2386#endif
2387
2388
2389
2390/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002391 * This enumeration specifies the media status of a call, and it's part
2392 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00002393 */
2394typedef enum pjsua_call_media_status
2395{
Benny Prijonob5388cf2007-01-04 22:45:08 +00002396 /** Call currently has no media */
Benny Prijono312aff92006-06-17 04:08:30 +00002397 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002398
2399 /** The media is active */
Benny Prijono312aff92006-06-17 04:08:30 +00002400 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002401
2402 /** The media is currently put on hold by local endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002403 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002404
2405 /** The media is currently put on hold by remote endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002406 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002407
Benny Prijono096c56c2007-09-15 08:30:16 +00002408 /** The media has reported error (e.g. ICE negotiation) */
2409 PJSUA_CALL_MEDIA_ERROR
2410
Benny Prijono312aff92006-06-17 04:08:30 +00002411} pjsua_call_media_status;
2412
2413
2414/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002415 * This structure describes the information and current status of a call.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002416 *
2417 * \par Python:
2418 * The type name is <tt>py_pjsua.Call_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002419 */
2420typedef struct pjsua_call_info
2421{
2422 /** Call identification. */
2423 pjsua_call_id id;
2424
2425 /** Initial call role (UAC == caller) */
2426 pjsip_role_e role;
2427
Benny Prijono90315512006-09-14 16:05:16 +00002428 /** The account ID where this call belongs. */
2429 pjsua_acc_id acc_id;
2430
Benny Prijono312aff92006-06-17 04:08:30 +00002431 /** Local URI */
2432 pj_str_t local_info;
2433
2434 /** Local Contact */
2435 pj_str_t local_contact;
2436
2437 /** Remote URI */
2438 pj_str_t remote_info;
2439
2440 /** Remote contact */
2441 pj_str_t remote_contact;
2442
2443 /** Dialog Call-ID string. */
2444 pj_str_t call_id;
2445
2446 /** Call state */
2447 pjsip_inv_state state;
2448
2449 /** Text describing the state */
2450 pj_str_t state_text;
2451
2452 /** Last status code heard, which can be used as cause code */
2453 pjsip_status_code last_status;
2454
2455 /** The reason phrase describing the status. */
2456 pj_str_t last_status_text;
2457
2458 /** Call media status. */
2459 pjsua_call_media_status media_status;
2460
2461 /** Media direction */
2462 pjmedia_dir media_dir;
2463
2464 /** The conference port number for the call */
2465 pjsua_conf_port_id conf_slot;
2466
2467 /** Up-to-date call connected duration (zero when call is not
2468 * established)
2469 */
2470 pj_time_val connect_duration;
2471
2472 /** Total call duration, including set-up time */
2473 pj_time_val total_duration;
2474
2475 /** Internal */
2476 struct {
2477 char local_info[128];
2478 char local_contact[128];
2479 char remote_info[128];
2480 char remote_contact[128];
2481 char call_id[128];
2482 char last_status_text[128];
2483 } buf_;
2484
2485} pjsua_call_info;
2486
2487
2488
Benny Prijonoa91a0032006-02-26 21:23:45 +00002489/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002490 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002491 *
2492 * @return Maximum number of calls configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002493 *
2494 * \par Python:
2495 * \code
2496 count = py_pjsua.call_get_max_count()
2497 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002498 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002499PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002500
2501/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002502 * Get number of currently active calls.
2503 *
2504 * @return Number of currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002505 *
2506 * \par Python:
2507 * \code
2508 count = py_pjsua.call_get_count()
2509 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002510 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002511PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002512
2513/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002514 * Enumerate all active calls. Application may then query the information and
2515 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002516 *
2517 * @param ids Array of account IDs to be initialized.
2518 * @param count In input, specifies the maximum number of elements.
2519 * On return, it contains the actual number of elements.
2520 *
2521 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002522 *
2523 * \par Python:
2524 * This function takes no argument and return list of call Ids.
2525 * \code
2526 [call_ids] = py_pjsua.enum_calls()
2527 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002528 */
2529PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
2530 unsigned *count);
2531
2532
2533/**
2534 * Make outgoing call to the specified URI using the specified account.
2535 *
2536 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002537 * @param dst_uri URI to be put in the To header (normally is the same
2538 * as the target URI).
2539 * @param options Options (must be zero at the moment).
2540 * @param user_data Arbitrary user data to be attached to the call, and
2541 * can be retrieved later.
2542 * @param msg_data Optional headers etc to be added to outgoing INVITE
2543 * request, or NULL if no custom header is desired.
2544 * @param p_call_id Pointer to receive call identification.
2545 *
2546 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002547 *
2548 * \par Python:
2549 * The Python function returns (status, call_id) tuple:
2550 * \code
2551 status, call_id = py_pjsua.call_make_call(acc_id, dst_uri, options,
2552 user_data, msg_data)
2553 * \endcode
2554 * Note: the \a user_data in Python function is an integer, and the
2555 * \a msg_data can be set to None if not required.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002556 */
2557PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
2558 const pj_str_t *dst_uri,
2559 unsigned options,
2560 void *user_data,
2561 const pjsua_msg_data *msg_data,
2562 pjsua_call_id *p_call_id);
2563
2564
2565/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002566 * Check if the specified call has active INVITE session and the INVITE
2567 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002568 *
2569 * @param call_id Call identification.
2570 *
2571 * @return Non-zero if call is active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002572 *
2573 * \par Python:
2574 * \code
2575 bool = py_pjsua.call_is_active(call_id)
2576 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002577 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002578PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002579
2580
2581/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002582 * Check if call has an active media session.
2583 *
2584 * @param call_id Call identification.
2585 *
2586 * @return Non-zero if yes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002587 *
2588 * \par Python:
2589 * \code
2590 bool = py_pjsua.call_has_media(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_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002594
2595
2596/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002597 * Get the conference port identification associated with the call.
2598 *
2599 * @param call_id Call identification.
2600 *
2601 * @return Conference port ID, or PJSUA_INVALID_ID when the
2602 * media has not been established or is not active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002603 *
2604 * \par Python:
2605 * \code
2606 slot = py_pjsua.call_get_conf_port(call_id)
2607 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002608 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002609PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
2610
2611/**
2612 * Obtain detail information about the specified call.
2613 *
2614 * @param call_id Call identification.
2615 * @param info Call info to be initialized.
2616 *
2617 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002618 *
2619 * \par Python:
2620 * \code
2621 call_info = py_pjsua.call_get_info(call_id)
2622 * \endcode
2623 * \a call_info return value will be set to None if call_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002624 */
2625PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002626 pjsua_call_info *info);
2627
2628
2629/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002630 * Attach application specific data to the call. Application can then
2631 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002632 *
2633 * @param call_id Call identification.
2634 * @param user_data Arbitrary data to be attached to the call.
2635 *
2636 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002637 *
2638 * \par Python:
2639 * \code
2640 status = py_pjsua.call_set_user_data(call_id, user_data)
2641 * \endcode
2642 * The \a user_data is an integer in the Python function.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002643 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002644PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
2645 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002646
2647
2648/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002649 * Get user data attached to the call, which has been previously set with
2650 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002651 *
2652 * @param call_id Call identification.
2653 *
2654 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002655 *
2656 * \par Python:
2657 * \code
2658 user_data = py_pjsua.call_get_user_data(call_id)
2659 * \endcode
2660 * The \a user_data is an integer.
Benny Prijono268ca612006-02-07 12:34:11 +00002661 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002662PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00002663
2664
2665/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002666 * Send response to incoming INVITE request. Depending on the status
2667 * code specified as parameter, this function may send provisional
2668 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002669 *
2670 * @param call_id Incoming call identification.
2671 * @param code Status code, (100-699).
2672 * @param reason Optional reason phrase. If NULL, default text
2673 * will be used.
2674 * @param msg_data Optional list of headers etc to be added to outgoing
2675 * response message.
2676 *
2677 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002678 *
2679 * \par Python:
2680 * \code
2681 status = py_pjsua.call_answer(call_id, code, reason, msg_data)
2682 * \endcode
2683 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijonoa91a0032006-02-26 21:23:45 +00002684 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002685PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
2686 unsigned code,
2687 const pj_str_t *reason,
2688 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00002689
2690/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002691 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00002692 * call state. This function is different than answering the call with
2693 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
2694 * will hangup the call regardless of the state and role of the call,
2695 * while #pjsua_call_answer() only works with incoming calls on EARLY
2696 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002697 *
2698 * @param call_id Call identification.
2699 * @param code Optional status code to be sent when we're rejecting
2700 * incoming call. If the value is zero, "603/Decline"
2701 * will be sent.
2702 * @param reason Optional reason phrase to be sent when we're rejecting
2703 * incoming call. If NULL, default text will be used.
2704 * @param msg_data Optional list of headers etc to be added to outgoing
2705 * request/response message.
2706 *
2707 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002708 *
2709 * \par Python:
2710 * \code
2711 status = py_pjsua.call_hangup(call_id, code, reason, msg_data)
2712 * \endcode
2713 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002714 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002715PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
2716 unsigned code,
2717 const pj_str_t *reason,
2718 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002719
2720
2721/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002722 * Put the specified call on hold. This will send re-INVITE with the
2723 * appropriate SDP to inform remote that the call is being put on hold.
2724 * The final status of the request itself will be reported on the
2725 * \a on_call_media_state() callback, which inform the application that
2726 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002727 *
2728 * @param call_id Call identification.
2729 * @param msg_data Optional message components to be sent with
2730 * the request.
2731 *
2732 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002733 *
2734 * \par Python:
2735 * \code
2736 status = py_pjsua.call_set_hold(call_id, msg_data)
2737 * \endcode
2738 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002739 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002740PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
2741 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002742
2743
2744/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002745 * Send re-INVITE to release hold.
2746 * The final status of the request itself will be reported on the
2747 * \a on_call_media_state() callback, which inform the application that
2748 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002749 *
2750 * @param call_id Call identification.
2751 * @param unhold If this argument is non-zero and the call is locally
2752 * held, this will release the local hold.
2753 * @param msg_data Optional message components to be sent with
2754 * the request.
2755 *
2756 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002757 *
2758 * \par Python:
2759 * \code
2760 status = py_pjsua.call_reinvite(call_id, unhold, msg_data)
2761 * \endcode
2762 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002763 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002764PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
2765 pj_bool_t unhold,
2766 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002767
2768
2769/**
Benny Prijono053f5222006-11-11 16:16:04 +00002770 * Initiate call transfer to the specified address. This function will send
2771 * REFER request to instruct remote call party to initiate a new INVITE
2772 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002773 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00002774 * If application is interested to monitor the successfulness and
2775 * the progress of the transfer request, it can implement
2776 * \a on_call_transfer_status() callback which will report the progress
2777 * of the call transfer request.
2778 *
Benny Prijono053f5222006-11-11 16:16:04 +00002779 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002780 * @param dest Address of new target to be contacted.
2781 * @param msg_data Optional message components to be sent with
2782 * the request.
2783 *
2784 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002785 *
2786 * \par Python:
2787 * \code
2788 status = py_pjsua.call_xfer(call_id, dest, msg_data)
2789 * \endcode
2790 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002791 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002792PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
2793 const pj_str_t *dest,
2794 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002795
2796/**
Benny Prijono053f5222006-11-11 16:16:04 +00002797 * Flag to indicate that "Require: replaces" should not be put in the
2798 * outgoing INVITE request caused by REFER request created by
2799 * #pjsua_call_xfer_replaces().
2800 */
2801#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
2802
2803/**
2804 * Initiate attended call transfer. This function will send REFER request
2805 * to instruct remote call party to initiate new INVITE session to the URL
2806 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
2807 * the call with us with the new call from the REFER recipient.
2808 *
2809 * @param call_id The call id to be transfered.
2810 * @param dest_call_id The call id to be replaced.
2811 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
2812 * to suppress the inclusion of "Require: replaces" in
2813 * the outgoing INVITE request created by the REFER
2814 * request.
2815 * @param msg_data Optional message components to be sent with
2816 * the request.
2817 *
2818 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002819 *
2820 * \par Python:
2821 * \code
2822 status = py_pjsua.call_xfer_replaces(call_id, dest_call_id, options, msg_data)
2823 * \endcode
2824 * Argument \a msg_data may be set to None if not required.
Benny Prijono053f5222006-11-11 16:16:04 +00002825 */
2826PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
2827 pjsua_call_id dest_call_id,
2828 unsigned options,
2829 const pjsua_msg_data *msg_data);
2830
2831/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002832 * Send DTMF digits to remote using RFC 2833 payload formats.
2833 *
2834 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002835 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002836 *
2837 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002838 *
2839 * \par Python:
2840 * \code
2841 status = py_pjsua.call_dial_dtmf(call_id, digits)
2842 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002843 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002844PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002845 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00002846
Benny Prijono26ff9062006-02-21 23:47:00 +00002847/**
Benny Prijonob0808372006-03-02 21:18:58 +00002848 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002849 *
2850 * @param call_id Call identification.
2851 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
2852 * assumed.
2853 * @param content The message content.
2854 * @param msg_data Optional list of headers etc to be included in outgoing
2855 * request. The body descriptor in the msg_data is
2856 * ignored.
2857 * @param user_data Optional user data, which will be given back when
2858 * the IM callback is called.
2859 *
2860 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002861 *
2862 * \par Python:
2863 * \code
2864 status = py_pjsua.call_send_im(call_id, mime_type, content, msg_data, user_data)
2865 * \endcode
2866 * Note that the \a user_data argument is an integer in Python.
Benny Prijonob0808372006-03-02 21:18:58 +00002867 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002868PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
2869 const pj_str_t *mime_type,
2870 const pj_str_t *content,
2871 const pjsua_msg_data *msg_data,
2872 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00002873
2874
2875/**
2876 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002877 *
2878 * @param call_id Call identification.
2879 * @param is_typing Non-zero to indicate to remote that local person is
2880 * currently typing an IM.
2881 * @param msg_data Optional list of headers etc to be included in outgoing
2882 * request.
2883 *
2884 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002885 *
2886 * \par Python:
2887 * \code
2888 status = py_pjsua.call_send_typing_ind(call_id, is_typing, msg_data)
2889 * \endcode
2890 * Argument \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00002891 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002892PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
2893 pj_bool_t is_typing,
2894 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00002895
2896/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002897 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
2898 * currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002899 *
2900 * \par Python:
2901 * \code
2902 py_pjsua.call_hangup_all()
2903 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00002904 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00002905PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00002906
2907
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002908/**
2909 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002910 *
2911 * @param call_id Call identification.
2912 * @param with_media Non-zero to include media information too.
2913 * @param buffer Buffer where the statistics are to be written to.
2914 * @param maxlen Maximum length of buffer.
2915 * @param indent Spaces for left indentation.
2916 *
2917 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002918 *
2919 * \par Python:
2920 * \code
2921 string = py_pjsua.call_dump(call_id, with_media, max_len, indent)
2922 * \endcode
2923 * The \a max_len argument is the desired maximum length to be allocated.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002924 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002925PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
2926 pj_bool_t with_media,
2927 char *buffer,
2928 unsigned maxlen,
2929 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002930
Benny Prijono9fc735d2006-05-28 14:58:12 +00002931/**
Benny Prijono312aff92006-06-17 04:08:30 +00002932 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00002933 */
Benny Prijono834aee32006-02-19 01:38:06 +00002934
2935
2936/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00002937 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00002938 */
2939
Benny Prijono312aff92006-06-17 04:08:30 +00002940
2941/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002942 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00002943 * @ingroup PJSUA_LIB
2944 * @brief Buddy management, buddy's presence, and instant messaging.
2945 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00002946 *
2947 * This section describes PJSUA-APIs related to buddies management,
2948 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00002949 */
2950
2951/**
2952 * Max buddies in buddy list.
2953 */
2954#ifndef PJSUA_MAX_BUDDIES
2955# define PJSUA_MAX_BUDDIES 256
2956#endif
2957
2958
2959/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002960 * This structure describes buddy configuration when adding a buddy to
2961 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
2962 * the structure with #pjsua_buddy_config_default() to initialize this
2963 * structure with default configuration.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002964 *
2965 * \par Python:
2966 * In Python this structure is <tt>py_pjsua.Buddy_Config</tt>. However
2967 * it is recommended that application instantiates the buddy config
2968 * by calling:
2969 * \code
2970 buddy_cfg = py_pjsua.buddy_config_default()
2971 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002972 */
2973typedef struct pjsua_buddy_config
2974{
2975 /**
2976 * Buddy URL or name address.
2977 */
2978 pj_str_t uri;
2979
2980 /**
2981 * Specify whether presence subscription should start immediately.
2982 */
2983 pj_bool_t subscribe;
2984
2985} pjsua_buddy_config;
2986
2987
2988/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002989 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00002990 */
2991typedef enum pjsua_buddy_status
2992{
2993 /**
2994 * Online status is unknown (possibly because no presence subscription
2995 * has been established).
2996 */
2997 PJSUA_BUDDY_STATUS_UNKNOWN,
2998
2999 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003000 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003001 */
3002 PJSUA_BUDDY_STATUS_ONLINE,
3003
3004 /**
3005 * Buddy is offline.
3006 */
3007 PJSUA_BUDDY_STATUS_OFFLINE,
3008
3009} pjsua_buddy_status;
3010
3011
3012
3013/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003014 * This structure describes buddy info, which can be retrieved by calling
3015 * #pjsua_buddy_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003016 *
3017 * \par Python:
3018 * This structure in Python is <tt>py_pjsua.Buddy_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003019 */
3020typedef struct pjsua_buddy_info
3021{
3022 /**
3023 * The buddy ID.
3024 */
3025 pjsua_buddy_id id;
3026
3027 /**
3028 * The full URI of the buddy, as specified in the configuration.
3029 */
3030 pj_str_t uri;
3031
3032 /**
3033 * Buddy's Contact, only available when presence subscription has
3034 * been established to the buddy.
3035 */
3036 pj_str_t contact;
3037
3038 /**
3039 * Buddy's online status.
3040 */
3041 pjsua_buddy_status status;
3042
3043 /**
3044 * Text to describe buddy's online status.
3045 */
3046 pj_str_t status_text;
3047
3048 /**
3049 * Flag to indicate that we should monitor the presence information for
3050 * this buddy (normally yes, unless explicitly disabled).
3051 */
3052 pj_bool_t monitor_pres;
3053
3054 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003055 * Extended RPID information about the person.
3056 */
3057 pjrpid_element rpid;
3058
3059 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003060 * Internal buffer.
3061 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003062 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003063
3064} pjsua_buddy_info;
3065
3066
Benny Prijono834aee32006-02-19 01:38:06 +00003067/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003068 * Set default values to the buddy config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003069 *
3070 * \par Python:
3071 * \code
3072 buddy_cfg = py_pjsua.buddy_config_default()
3073 * \endcode
Benny Prijonob5388cf2007-01-04 22:45:08 +00003074 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003075PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003076
3077
3078/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003079 * Get total number of buddies.
3080 *
3081 * @return Number of buddies.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003082 *
3083 * \par Python:
3084 * \code
3085 buddy_count = py_pjsua.get_buddy_count()
3086 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003087 */
3088PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3089
3090
3091/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003092 * Check if buddy ID is valid.
3093 *
3094 * @param buddy_id Buddy ID to check.
3095 *
3096 * @return Non-zero if buddy ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003097 *
3098 * \par Python:
3099 * \code
3100 is_valid = py_pjsua.buddy_is_valid(buddy_id)
3101 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003102 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003103PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3104
3105
3106/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003107 * Enumerate all buddy IDs in the buddy list. Application then can use
3108 * #pjsua_buddy_get_info() to get the detail information for each buddy
3109 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003110 *
3111 * @param ids Array of ids to be initialized.
3112 * @param count On input, specifies max elements in the array.
3113 * On return, it contains actual number of elements
3114 * that have been initialized.
3115 *
3116 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003117 *
3118 * \par Python:
3119 * The Python function takes no argument and returns list of buddy IDs:
3120 * \code
3121 [buddy_ids] = py_pjsua.enum_buddies()
3122 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003123 */
3124PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3125 unsigned *count);
3126
3127/**
3128 * Get detailed buddy info.
3129 *
3130 * @param buddy_id The buddy identification.
3131 * @param info Pointer to receive information about buddy.
3132 *
3133 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003134 *
3135 * \par Python:
3136 * \code
3137 buddy_info = py_pjsua.buddy_get_info(buddy_id)
3138 * \endcode
3139 * The function returns None if buddy_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003140 */
3141PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003142 pjsua_buddy_info *info);
3143
3144/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003145 * Add new buddy to the buddy list. If presence subscription is enabled
3146 * for this buddy, this function will also start the presence subscription
3147 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003148 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003149 * @param buddy)cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003150 * @param p_buddy_id Pointer to receive buddy ID.
3151 *
3152 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003153 *
3154 * \par Python:
3155 * The function returns (status, buddy_id) tuple:
3156 * \code
3157 status, buddy_id = py_pjsua.buddy_add(buddy_cfg)
3158 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003159 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003160PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003161 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003162
3163
3164/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003165 * Delete the specified buddy from the buddy list. Any presence subscription
3166 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003167 *
3168 * @param buddy_id Buddy identification.
3169 *
3170 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003171 *
3172 * \par Python:
3173 * \code
3174 status = py_pjsua.buddy_del(buddy_id)
3175 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +00003176 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003177PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003178
3179
3180/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003181 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3182 * subscribed, application will be informed about buddy's presence status
3183 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003184 *
3185 * @param buddy_id Buddy identification.
3186 * @param subscribe Specify non-zero to activate presence subscription to
3187 * the specified buddy.
3188 *
3189 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003190 *
3191 * \par Python:
3192 * \code
3193 status = py_pjsua.buddy_subscribe_pres(buddy_id, subscribe)
3194 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003195 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003196PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3197 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003198
3199
3200/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003201 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003202 *
3203 * @param verbose Yes or no.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003204 *
3205 * \par Python:
3206 * \code
3207 py_pjsua.pres_dump()
3208 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003209 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003210PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003211
3212
Benny Prijonob0808372006-03-02 21:18:58 +00003213/**
3214 * The MESSAGE method (defined in pjsua_im.c)
3215 */
3216extern const pjsip_method pjsip_message_method;
3217
3218
Benny Prijonob0808372006-03-02 21:18:58 +00003219
3220/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003221 * Send instant messaging outside dialog, using the specified account for
3222 * route set and authentication.
3223 *
3224 * @param acc_id Account ID to be used to send the request.
3225 * @param to Remote URI.
3226 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3227 * assumed.
3228 * @param content The message content.
3229 * @param msg_data Optional list of headers etc to be included in outgoing
3230 * request. The body descriptor in the msg_data is
3231 * ignored.
3232 * @param user_data Optional user data, which will be given back when
3233 * the IM callback is called.
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.im_send(acc_id, to, mime_type, content, msg_data, user_data)
3240 * \endcode
3241 * Arguments \a mime_type and \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003242 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003243PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3244 const pj_str_t *to,
3245 const pj_str_t *mime_type,
3246 const pj_str_t *content,
3247 const pjsua_msg_data *msg_data,
3248 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003249
3250
3251/**
3252 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003253 *
3254 * @param acc_id Account ID to be used to send the request.
3255 * @param to Remote URI.
3256 * @param is_typing If non-zero, it tells remote person that local person
3257 * is currently composing an IM.
3258 * @param msg_data Optional list of headers etc to be added to outgoing
3259 * request.
3260 *
3261 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003262 *
3263 * \par Python:
3264 * \code
3265 status = py_pjsua.im_typing(acc_id, to, is_typing, msg_data)
3266 * \endcode
3267 * Argument \a msg_data may be set to None if not requried.
Benny Prijonob0808372006-03-02 21:18:58 +00003268 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003269PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3270 const pj_str_t *to,
3271 pj_bool_t is_typing,
3272 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003273
3274
Benny Prijonof3195072006-02-14 21:15:30 +00003275
Benny Prijono312aff92006-06-17 04:08:30 +00003276/**
3277 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003278 */
3279
Benny Prijono312aff92006-06-17 04:08:30 +00003280
3281/*****************************************************************************
3282 * MEDIA API
3283 */
3284
3285
3286/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003287 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003288 * @ingroup PJSUA_LIB
3289 * @brief Media manipulation.
3290 * @{
3291 *
3292 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003293 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3294 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003295 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003296 * the interconnection between these terminations freely.
3297 *
3298 * The conference bridge provides powerful switching and mixing functionality
3299 * for application. With the conference bridge, each conference slot (e.g.
3300 * a call) can transmit to multiple destinations, and one destination can
3301 * receive from multiple sources. If more than one media terminations are
3302 * terminated in the same slot, the conference bridge will mix the signal
3303 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00003304 *
3305 * Application connects one media termination/slot to another by calling
3306 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003307 * media flow from the source termination to the sink termination. To
3308 * establish bidirectional media flow, application wound need to make another
3309 * call to #pjsua_conf_connect(), this time inverting the source and
3310 * destination slots in the parameter.
3311 *
3312 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00003313 * the following steps:
3314 *
3315 \code
3316
3317 pj_status_t stream_to_call( pjsua_call_id call_id )
3318 {
3319 pjsua_player_id player_id;
3320
3321 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
3322 if (status != PJ_SUCCESS)
3323 return status;
3324
3325 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
3326 pjsua_call_get_conf_port() );
3327 }
3328 \endcode
3329 *
3330 *
3331 * Other features of PJSUA media:
3332 * - efficient N to M interconnections between media terminations.
3333 * - media termination can be connected to itself to create loopback
3334 * media.
3335 * - the media termination may have different clock rates, and resampling
3336 * will be done automatically by conference bridge.
3337 * - media terminations may also have different frame time; the
3338 * conference bridge will perform the necessary bufferring to adjust
3339 * the difference between terminations.
3340 * - interconnections are removed automatically when media termination
3341 * is removed from the bridge.
3342 * - sound device may be changed even when there are active media
3343 * interconnections.
3344 * - correctly report call's media quality (in #pjsua_call_dump()) from
3345 * RTCP packet exchange.
3346 */
3347
3348/**
3349 * Max ports in the conference bridge.
3350 */
3351#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00003352# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00003353#endif
3354
Benny Prijonob5388cf2007-01-04 22:45:08 +00003355/**
3356 * The default clock rate to be used by the conference bridge.
3357 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003358#ifndef PJSUA_DEFAULT_CLOCK_RATE
3359# define PJSUA_DEFAULT_CLOCK_RATE 16000
3360#endif
3361
Benny Prijonob5388cf2007-01-04 22:45:08 +00003362/**
3363 * Default codec quality settings.
3364 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003365#ifndef PJSUA_DEFAULT_CODEC_QUALITY
3366# define PJSUA_DEFAULT_CODEC_QUALITY 5
3367#endif
3368
Benny Prijonob5388cf2007-01-04 22:45:08 +00003369/**
3370 * Default iLBC mode.
3371 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003372#ifndef PJSUA_DEFAULT_ILBC_MODE
3373# define PJSUA_DEFAULT_ILBC_MODE 20
3374#endif
3375
Benny Prijonob5388cf2007-01-04 22:45:08 +00003376/**
3377 * The default echo canceller tail length.
3378 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003379#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonod2990b92006-11-23 10:19:46 +00003380# define PJSUA_DEFAULT_EC_TAIL_LEN 800
Benny Prijono12a669c2006-11-23 07:32:13 +00003381#endif
Benny Prijono312aff92006-06-17 04:08:30 +00003382
3383
3384/**
Benny Prijonocba59d92007-02-16 09:22:56 +00003385 * The maximum file player.
3386 */
3387#ifndef PJSUA_MAX_PLAYERS
3388# define PJSUA_MAX_PLAYERS 32
3389#endif
3390
3391
3392/**
3393 * The maximum file player.
3394 */
3395#ifndef PJSUA_MAX_RECORDERS
3396# define PJSUA_MAX_RECORDERS 32
3397#endif
3398
3399
3400/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003401 * This structure describes media configuration, which will be specified
3402 * when calling #pjsua_init(). Application MUST initialize this structure
3403 * by calling #pjsua_media_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003404 *
3405 * \par Python:
3406 * This data type in Python is <tt>py_pjsua.Media_Config</tt>. To create
3407 * an object of this type, it is recommended to call
3408 * <tt>py_pjsua.media_config_default()</tt> function instead:
3409 * \code
3410 media_cfg = py_pjsua.media_config_default()
3411 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003412 */
3413struct pjsua_media_config
3414{
3415 /**
3416 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003417 * If value is zero, default clock rate will be used
3418 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00003419 */
3420 unsigned clock_rate;
3421
3422 /**
3423 * Specify maximum number of media ports to be created in the
3424 * conference bridge. Since all media terminate in the bridge
3425 * (calls, file player, file recorder, etc), the value must be
3426 * large enough to support all of them. However, the larger
3427 * the value, the more computations are performed.
3428 */
3429 unsigned max_media_ports;
3430
3431 /**
3432 * Specify whether the media manager should manage its own
3433 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
3434 * and at least one worker thread will be created too. If no,
3435 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
3436 * and no worker thread is needed.
3437 *
3438 * Normally application would say yes here, unless it wants to
3439 * run everything from a single thread.
3440 */
3441 pj_bool_t has_ioqueue;
3442
3443 /**
3444 * Specify the number of worker threads to handle incoming RTP
3445 * packets. A value of one is recommended for most applications.
3446 */
3447 unsigned thread_cnt;
3448
Benny Prijono0498d902006-06-19 14:49:14 +00003449 /**
3450 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00003451 * 5-10: resampling use large filter,
3452 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00003453 * 1-2: resampling use linear.
3454 * The media quality also sets speex codec quality/complexity to the
3455 * number.
3456 *
Benny Prijono70972992006-08-05 11:13:58 +00003457 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00003458 */
3459 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00003460
3461 /**
3462 * Specify default ptime.
3463 *
3464 * Default: 0 (codec specific)
3465 */
3466 unsigned ptime;
3467
3468 /**
3469 * Disable VAD?
3470 *
3471 * Default: 0 (no (meaning VAD is enabled))
3472 */
3473 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00003474
3475 /**
3476 * iLBC mode (20 or 30).
3477 *
Benny Prijono70972992006-08-05 11:13:58 +00003478 * Default: 20 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00003479 */
3480 unsigned ilbc_mode;
3481
3482 /**
3483 * Percentage of RTP packet to drop in TX direction
3484 * (to simulate packet lost).
3485 *
3486 * Default: 0
3487 */
3488 unsigned tx_drop_pct;
3489
3490 /**
3491 * Percentage of RTP packet to drop in RX direction
3492 * (to simulate packet lost).
3493 *
3494 * Default: 0
3495 */
3496 unsigned rx_drop_pct;
3497
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003498 /**
Benny Prijono5da50432006-08-07 10:24:52 +00003499 * Echo canceller options (see #pjmedia_echo_create())
3500 *
3501 * Default: 0.
3502 */
3503 unsigned ec_options;
3504
3505 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003506 * Echo canceller tail length, in miliseconds.
3507 *
Benny Prijono669643c2006-09-20 20:02:18 +00003508 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003509 */
3510 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003511
3512 /**
3513 * Jitter buffer initial prefetch delay in msec. The value must be
3514 * between jb_min_pre and jb_max_pre below.
3515 *
3516 * Default: -1 (to use default stream settings, currently 150 msec)
3517 */
3518 int jb_init;
3519
3520 /**
3521 * Jitter buffer minimum prefetch delay in msec.
3522 *
3523 * Default: -1 (to use default stream settings, currently 60 msec)
3524 */
3525 int jb_min_pre;
3526
3527 /**
3528 * Jitter buffer maximum prefetch delay in msec.
3529 *
3530 * Default: -1 (to use default stream settings, currently 240 msec)
3531 */
3532 int jb_max_pre;
3533
3534 /**
3535 * Set maximum delay that can be accomodated by the jitter buffer msec.
3536 *
3537 * Default: -1 (to use default stream settings, currently 360 msec)
3538 */
3539 int jb_max;
3540
Benny Prijonoc97608e2007-03-23 16:34:20 +00003541 /**
3542 * Enable ICE
3543 */
3544 pj_bool_t enable_ice;
3545
3546 /**
3547 * Enable ICE media relay.
3548 */
3549 pj_bool_t enable_relay;
Benny Prijono312aff92006-06-17 04:08:30 +00003550};
3551
3552
3553/**
3554 * Use this function to initialize media config.
3555 *
3556 * @param cfg The media config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003557 *
3558 * \par Python:
3559 * \code
3560 media_cfg = py_pjsua.media_config_default()
3561 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003562 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003563PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00003564
3565
3566/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003567 * This structure describes codec information, which can be retrieved by
3568 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00003569 */
3570typedef struct pjsua_codec_info
3571{
3572 /**
3573 * Codec unique identification.
3574 */
3575 pj_str_t codec_id;
3576
3577 /**
3578 * Codec priority (integer 0-255).
3579 */
3580 pj_uint8_t priority;
3581
3582 /**
3583 * Internal buffer.
3584 */
3585 char buf_[32];
3586
3587} pjsua_codec_info;
3588
3589
3590/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003591 * This structure descibes information about a particular media port that
3592 * has been registered into the conference bridge. Application can query
3593 * this info by calling #pjsua_conf_get_port_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003594 *
3595 * \par Python:
3596 * In Python, this type is <tt>py_pjsua.Conf_Port_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003597 */
3598typedef struct pjsua_conf_port_info
3599{
3600 /** Conference port number. */
3601 pjsua_conf_port_id slot_id;
3602
3603 /** Port name. */
3604 pj_str_t name;
3605
3606 /** Clock rate. */
3607 unsigned clock_rate;
3608
3609 /** Number of channels. */
3610 unsigned channel_count;
3611
3612 /** Samples per frame */
3613 unsigned samples_per_frame;
3614
3615 /** Bits per sample */
3616 unsigned bits_per_sample;
3617
3618 /** Number of listeners in the array. */
3619 unsigned listener_cnt;
3620
3621 /** Array of listeners (in other words, ports where this port is
3622 * transmitting to.
3623 */
3624 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
3625
3626} pjsua_conf_port_info;
3627
3628
3629/**
3630 * This structure holds information about custom media transport to
3631 * be registered to pjsua.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003632 *
3633 * \par Python:
3634 * Not applicable.
Benny Prijono312aff92006-06-17 04:08:30 +00003635 */
3636typedef struct pjsua_media_transport
3637{
3638 /**
3639 * Media socket information containing the address information
3640 * of the RTP and RTCP socket.
3641 */
3642 pjmedia_sock_info skinfo;
3643
3644 /**
3645 * The media transport instance.
3646 */
3647 pjmedia_transport *transport;
3648
3649} pjsua_media_transport;
3650
3651
3652
3653
Benny Prijono9fc735d2006-05-28 14:58:12 +00003654/**
3655 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003656 *
3657 * @return Maximum number of ports in the conference bridge.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003658 *
3659 * \par Python:
3660 * \code
3661 port_count = py_pjsua.conf_get_max_ports()
3662 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003663 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003664PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003665
3666
3667/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003668 * Get current number of active ports in the bridge.
3669 *
3670 * @return The number.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003671 *
3672 * \par Python:
3673 * \code
3674 count = py_pjsua.conf_get_active_ports()
3675 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003676 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003677PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
3678
3679
3680/**
3681 * Enumerate all conference ports.
3682 *
3683 * @param id Array of conference port ID to be initialized.
3684 * @param count On input, specifies max elements in the array.
3685 * On return, it contains actual number of elements
3686 * that have been initialized.
3687 *
3688 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003689 *
3690 * \par Python:
3691 * The Python functions returns list of conference port Ids:
3692 * \code
3693 [port_ids] = py_pjsua.enum_conf_ports()
3694 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003695 */
3696PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
3697 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003698
3699
3700/**
3701 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003702 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003703 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003704 * @param info Pointer to store the port info.
3705 *
3706 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003707 *
3708 * \par Python:
3709 * \code
3710 port_info = py_pjsua.conf_get_port_info(port_id)
3711 * \endcode
3712 * The function will return None if \a port_id is not valid.
Benny Prijono8b1889b2006-06-06 18:40:40 +00003713 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003714PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00003715 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003716
3717
3718/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00003719 * Add arbitrary media port to PJSUA's conference bridge. Application
3720 * can use this function to add the media port that it creates. For
3721 * media ports that are created by PJSUA-LIB (such as calls, file player,
3722 * or file recorder), PJSUA-LIB will automatically add the port to
3723 * the bridge.
3724 *
3725 * @param pool Pool to use.
3726 * @param port Media port to be added to the bridge.
3727 * @param p_id Optional pointer to receive the conference
3728 * slot id.
3729 *
3730 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003731 *
3732 * \par Python:
3733 * Not applicable (for now)
Benny Prijonoe909eac2006-07-27 22:04:56 +00003734 */
3735PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
3736 pjmedia_port *port,
3737 pjsua_conf_port_id *p_id);
3738
3739
3740/**
3741 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00003742 * call this function if it registered the port manually with previous call
3743 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00003744 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003745 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00003746 *
3747 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003748 *
3749 * \par Python:
3750 * \code
3751 status = py_pjsua.conf_remove_port(port_id)
3752 * \endcode
Benny Prijonoe909eac2006-07-27 22:04:56 +00003753 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003754PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00003755
3756
3757/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003758 * Establish unidirectional media flow from souce to sink. One source
3759 * may transmit to multiple destinations/sink. And if multiple
3760 * sources are transmitting to the same sink, the media will be mixed
3761 * together. Source and sink may refer to the same ID, effectively
3762 * looping the media.
3763 *
3764 * If bidirectional media flow is desired, application needs to call
3765 * this function twice, with the second one having the arguments
3766 * reversed.
3767 *
3768 * @param source Port ID of the source media/transmitter.
3769 * @param sink Port ID of the destination media/received.
3770 *
3771 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003772 *
3773 * \par Python:
3774 * \code
3775 status = py_pjsua.conf_connect(source, sink)
3776 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003777 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003778PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
3779 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003780
3781
3782/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003783 * Disconnect media flow from the source to destination port.
3784 *
3785 * @param source Port ID of the source media/transmitter.
3786 * @param sink Port ID of the destination media/received.
3787 *
3788 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003789 *
3790 * \par Python:
3791 * \code
3792 status = py_pjsua.conf_disconnect(source, sink)
3793 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003794 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003795PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
3796 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003797
3798
Benny Prijono6dd967c2006-12-26 02:27:14 +00003799/**
3800 * Adjust the signal level to be transmitted from the bridge to the
3801 * specified port by making it louder or quieter.
3802 *
3803 * @param slot The conference bridge slot number.
3804 * @param level Signal level adjustment. Value 1.0 means no level
3805 * adjustment, while value 0 means to mute the port.
3806 *
3807 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003808 *
3809 * \par Python:
3810 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003811 */
3812PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
3813 float level);
3814
3815/**
3816 * Adjust the signal level to be received from the specified port (to
3817 * the bridge) by making it louder or quieter.
3818 *
3819 * @param slot The conference bridge slot number.
3820 * @param level Signal level adjustment. Value 1.0 means no level
3821 * adjustment, while value 0 means to mute the port.
3822 *
3823 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003824 *
3825 * \par Python:
3826 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003827 */
3828PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
3829 float level);
3830
3831/**
3832 * Get last signal level transmitted to or received from the specified port.
3833 * The signal level is an integer value in zero to 255, with zero indicates
3834 * no signal, and 255 indicates the loudest signal level.
3835 *
3836 * @param slot The conference bridge slot number.
3837 * @param tx_level Optional argument to receive the level of signal
3838 * transmitted to the specified port (i.e. the direction
3839 * is from the bridge to the port).
3840 * @param rx_level Optional argument to receive the level of signal
3841 * received from the port (i.e. the direction is from the
3842 * port to the bridge).
3843 *
3844 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003845 *
3846 * \par Python:
3847 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003848 */
3849PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
3850 unsigned *tx_level,
3851 unsigned *rx_level);
3852
Benny Prijono6dd967c2006-12-26 02:27:14 +00003853
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003854/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00003855 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003856 */
3857
Benny Prijono9fc735d2006-05-28 14:58:12 +00003858/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003859 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003860 * the conference bridge.
3861 *
3862 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00003863 * WAV files are supported, and the WAV file MUST be
3864 * formatted as 16bit PCM mono/single channel (any
3865 * clock rate is supported).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003866 * @param options Options (currently zero).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003867 * @param p_id Pointer to receive player ID.
3868 *
3869 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003870 *
3871 * \par Python:
3872 * The function returns (status, id) tuple:
3873 * \code
3874 status, id = py_pjsua.player_create(filename, options)
3875 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003876 */
3877PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003878 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003879 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003880
3881
3882/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003883 * Create a file playlist media port, and automatically add the port
3884 * to the conference bridge.
3885 *
3886 * @param file_names Array of file names to be added to the play list.
3887 * Note that the files must have the same clock rate,
3888 * number of channels, and number of bits per sample.
3889 * @param file_count Number of files in the array.
3890 * @param label Optional label to be set for the media port.
3891 * @param options Optional option flag. Application may specify
3892 * PJMEDIA_FILE_NO_LOOP to prevent looping.
3893 * @param p_id Optional pointer to receive player ID.
3894 *
3895 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003896 *
3897 * \par Python:
3898 * Not implemented yet.
Benny Prijonoa66c3312007-01-21 23:12:40 +00003899 */
3900PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
3901 unsigned file_count,
3902 const pj_str_t *label,
3903 unsigned options,
3904 pjsua_player_id *p_id);
3905
3906/**
3907 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003908 *
3909 * @param id The file player ID.
3910 *
3911 * @return Conference port ID associated with this player.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003912 *
3913 * \par Python:
3914 * \code
3915 port_id = py_pjsua.player_get_conf_port(id)
3916 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003917 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003918PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003919
3920
3921/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003922 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00003923 *
3924 * @param id The player ID.
3925 * @param p_port The media port associated with the player.
3926 *
3927 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003928 *
3929 * \par Python:
3930 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00003931 */
3932PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_recorder_id id,
3933 pjmedia_port **p_port);
3934
3935/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003936 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003937 *
3938 * @param id The file player ID.
3939 * @param samples The playback position, in samples. Application can
3940 * specify zero to re-start the playback.
3941 *
3942 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003943 *
3944 * \par Python:
3945 * \code
3946 status = py_pjsua.player_set_pos(id, samples)
3947 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003948 */
3949PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
3950 pj_uint32_t samples);
3951
3952
3953/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003954 * Close the file of playlist, remove the player from the bridge, and free
3955 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003956 *
3957 * @param id The file player ID.
3958 *
3959 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003960 *
3961 * \par Python:
3962 * \code
3963 status = py_pjsua.player_destroy(id)
3964 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003965 */
3966PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
3967
3968
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003969/*****************************************************************************
3970 * File recorder.
3971 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00003972
3973/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003974 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00003975 * the conference bridge. The recorder currently supports recording WAV file.
3976 * The type of the recorder to use is determined by the extension of the file
3977 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003978 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00003979 * @param filename Output file name. The function will determine the
3980 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00003981 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00003982 * @param enc_type Optionally specify the type of encoder to be used to
3983 * compress the media, if the file can support different
3984 * encodings. This value must be zero for now.
3985 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00003986 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00003987 * For .WAV recorder, this value must be NULL.
3988 * @param max_size Maximum file size. Specify zero or -1 to remove size
3989 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003990 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003991 * @param p_id Pointer to receive the recorder instance.
3992 *
3993 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003994 *
3995 * \par Python:
3996 * \code
3997 status, id = py_pjsua.recorder_create(filename, enc_type, enc_param, max_size, options)
3998 * \endcode
3999 * The \a enc_param is a string in Python.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004000 */
4001PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004002 unsigned enc_type,
4003 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004004 pj_ssize_t max_size,
4005 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004006 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004007
4008
4009/**
4010 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004011 *
4012 * @param id The recorder ID.
4013 *
4014 * @return Conference port ID associated with this recorder.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004015 *
4016 * \par Python:
4017 * \code
4018 port_id = py_pjsua.recorder_get_conf_port(id)
4019 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004020 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004021PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004022
4023
4024/**
Benny Prijono469b1522006-12-26 03:05:17 +00004025 * Get the media port for the recorder.
4026 *
4027 * @param id The recorder ID.
4028 * @param p_port The media port associated with the recorder.
4029 *
4030 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004031 *
4032 * \par Python:
4033 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004034 */
4035PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4036 pjmedia_port **p_port);
4037
4038
4039/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004040 * Destroy recorder (this will complete recording).
4041 *
4042 * @param id The recorder ID.
4043 *
4044 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004045 *
4046 * \par Python:
4047 * \code
4048 status = py_pjsua.recorder_destroy(id)
4049 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004050 */
4051PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4052
4053
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004054/*****************************************************************************
4055 * Sound devices.
4056 */
4057
Benny Prijono9fc735d2006-05-28 14:58:12 +00004058/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004059 * Enum all sound devices installed in the system.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004060 *
4061 * @param info Array of info to be initialized.
4062 * @param count On input, specifies max elements in the array.
4063 * On return, it contains actual number of elements
4064 * that have been initialized.
4065 *
4066 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004067 *
4068 *
4069 * \par Python:
4070 * The function returns list of sound device info:
4071 * \code
4072 [dev_infos] = py_pjsua.enum_snd_devs()
4073 * \endcode
4074 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00004075 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004076PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4077 unsigned *count);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004078
4079
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004080
4081/**
4082 * Get currently active sound devices. If sound devices has not been created
4083 * (for example when pjsua_start() is not called), it is possible that
4084 * the function returns PJ_SUCCESS with -1 as device IDs.
4085 *
4086 * @param capture_dev On return it will be filled with device ID of the
4087 * capture device.
4088 * @param playback_dev On return it will be filled with device ID of the
4089 * device ID of the playback device.
4090 *
4091 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004092 *
4093 * \par Python:
Benny Prijonoebdf8772007-02-01 19:25:50 +00004094 * The function takes no argument and return an (integer,integer) tuple:
Benny Prijonoe6ead542007-01-31 20:53:31 +00004095 * \code
4096 capture_dev, playback_dev = py_pjsua.get_snd_dev()
4097 * \endcode
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004098 */
4099PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4100 int *playback_dev);
4101
4102
Benny Prijono9fc735d2006-05-28 14:58:12 +00004103/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004104 * Select or change sound device. Application may call this function at
4105 * any time to replace current sound device.
4106 *
4107 * @param capture_dev Device ID of the capture device.
4108 * @param playback_dev Device ID of the playback device.
4109 *
4110 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004111 *
4112 * \par Python:
4113 * \code
4114 status = py_pjsua.set_snd_dev(capture_dev, playback_dev)
4115 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004116 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004117PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4118 int playback_dev);
4119
4120
4121/**
4122 * Set pjsua to use null sound device. The null sound device only provides
4123 * the timing needed by the conference bridge, and will not interract with
4124 * any hardware.
4125 *
4126 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004127 *
4128 * \par Python:
4129 * \code
4130 status = py_pjsua.set_null_snd_dev()
4131 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004132 */
4133PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4134
4135
Benny Prijonoe909eac2006-07-27 22:04:56 +00004136/**
4137 * Disconnect the main conference bridge from any sound devices, and let
4138 * application connect the bridge to it's own sound device/master port.
4139 *
4140 * @return The port interface of the conference bridge,
4141 * so that application can connect this to it's own
4142 * sound device or master port.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004143 *
4144 * \par Python:
4145 * Not applicable (for now).
Benny Prijonoe909eac2006-07-27 22:04:56 +00004146 */
4147PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4148
4149
Benny Prijonof20687a2006-08-04 18:27:19 +00004150/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004151 * Configure the echo canceller tail length of the sound port.
Benny Prijonof20687a2006-08-04 18:27:19 +00004152 *
4153 * @param tail_ms The tail length, in miliseconds. Set to zero to
4154 * disable AEC.
Benny Prijono5da50432006-08-07 10:24:52 +00004155 * @param options Options to be passed to #pjmedia_echo_create().
4156 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004157 *
4158 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004159 *
4160 * \par Python:
4161 * \code
4162 status = py_pjsua.set_ec(tail_ms, options)
4163 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004164 */
Benny Prijono5da50432006-08-07 10:24:52 +00004165PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004166
4167
4168/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004169 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004170 *
4171 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4172 * If AEC is disabled, the value will be zero.
4173 *
4174 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004175 *
4176 * \par Python:
4177 * \code
4178 tail_ms = py_pjsua.get_ec_tail()
4179 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004180 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004181PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004182
4183
4184
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004185/*****************************************************************************
4186 * Codecs.
4187 */
4188
4189/**
4190 * Enum all supported codecs in the system.
4191 *
4192 * @param id Array of ID to be initialized.
4193 * @param count On input, specifies max elements in the array.
4194 * On return, it contains actual number of elements
4195 * that have been initialized.
4196 *
4197 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004198 *
4199 * \par Python:
4200 * This function takes no argument and returns list of codec infos:
4201 * \code
4202 [codec_info] = py_pjsua.enum_codecs()
4203 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004204 */
4205PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4206 unsigned *count );
4207
4208
4209/**
4210 * Change codec priority.
4211 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004212 * @param codec_id Codec ID, which is a string that uniquely identify
4213 * the codec (such as "speex/8000"). Please see pjsua
4214 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004215 * @param priority Codec priority, 0-255, where zero means to disable
4216 * the codec.
4217 *
4218 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004219 *
4220 * \par Python:
4221 * \code
4222 status = py_pjsua.codec_set_priority(codec_id, priority)
4223 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004224 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004225PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004226 pj_uint8_t priority );
4227
4228
4229/**
4230 * Get codec parameters.
4231 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004232 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004233 * @param param Structure to receive codec parameters.
4234 *
4235 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004236 *
4237 * \par Python:
4238 * The Python function is experimental:
4239 * \code
4240 codec_param = py_pjsua.codec_get_param(codec_id)
4241 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004242 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004243PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004244 pjmedia_codec_param *param );
4245
4246
4247/**
4248 * Set codec parameters.
4249 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004250 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004251 * @param param Codec parameter to set.
4252 *
4253 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004254 *
4255 * \par Python:
4256 * The Python function is experimental:
4257 * \code
4258 status = py_pjsua.codec_set_param(codec_id, param)
4259 * \endcode
4260
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004261 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004262PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004263 const pjmedia_codec_param *param);
4264
4265
4266
Benny Prijono9fc735d2006-05-28 14:58:12 +00004267
Benny Prijono312aff92006-06-17 04:08:30 +00004268/**
4269 * Create UDP media transports for all the calls. This function creates
4270 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00004271 *
Benny Prijono312aff92006-06-17 04:08:30 +00004272 * @param cfg Media transport configuration. The "port" field in the
4273 * configuration is used as the start port to bind the
4274 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004275 *
4276 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004277 *
4278 * \par Python:
4279 * Not implemented yet.
Benny Prijonof3195072006-02-14 21:15:30 +00004280 */
Benny Prijono312aff92006-06-17 04:08:30 +00004281PJ_DECL(pj_status_t)
4282pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00004283
Benny Prijonodc39fe82006-05-26 12:17:46 +00004284
4285/**
Benny Prijono312aff92006-06-17 04:08:30 +00004286 * Register custom media transports to be used by calls. There must
4287 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004288 *
Benny Prijono312aff92006-06-17 04:08:30 +00004289 * @param tp The media transport array.
4290 * @param count Number of elements in the array. This number MUST
4291 * match the number of maximum calls configured when
4292 * pjsua is created.
4293 * @param auto_delete Flag to indicate whether the transports should be
4294 * destroyed when pjsua is shutdown.
4295 *
4296 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004297 *
4298 * \par Python:
4299 * Note applicable.
Benny Prijonodc39fe82006-05-26 12:17:46 +00004300 */
Benny Prijono312aff92006-06-17 04:08:30 +00004301PJ_DECL(pj_status_t)
4302pjsua_media_transports_attach( pjsua_media_transport tp[],
4303 unsigned count,
4304 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00004305
4306
Benny Prijono312aff92006-06-17 04:08:30 +00004307/**
4308 * @}
4309 */
4310
Benny Prijonof3195072006-02-14 21:15:30 +00004311
Benny Prijono268ca612006-02-07 12:34:11 +00004312
Benny Prijono312aff92006-06-17 04:08:30 +00004313/**
4314 * @}
4315 */
4316
Benny Prijonoe6ead542007-01-31 20:53:31 +00004317PJ_END_DECL
4318
Benny Prijono312aff92006-06-17 04:08:30 +00004319
Benny Prijono268ca612006-02-07 12:34:11 +00004320#endif /* __PJSUA_H__ */