blob: b727528b637237b5006cd0fea5acfe52dca4ec8f [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
Benny Prijonoc08682e2007-10-04 06:17:58 +00002768/**
2769 * Send UPDATE request.
2770 *
2771 * @param call_id Call identification.
2772 * @param options Must be zero for now.
2773 * @param msg_data Optional message components to be sent with
2774 * the request.
2775 *
2776 * @return PJ_SUCCESS on success, or the appropriate error code.
2777 */
2778PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
2779 unsigned options,
2780 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002781
2782/**
Benny Prijono053f5222006-11-11 16:16:04 +00002783 * Initiate call transfer to the specified address. This function will send
2784 * REFER request to instruct remote call party to initiate a new INVITE
2785 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002786 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00002787 * If application is interested to monitor the successfulness and
2788 * the progress of the transfer request, it can implement
2789 * \a on_call_transfer_status() callback which will report the progress
2790 * of the call transfer request.
2791 *
Benny Prijono053f5222006-11-11 16:16:04 +00002792 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002793 * @param dest Address of new target to be contacted.
2794 * @param msg_data Optional message components to be sent with
2795 * the request.
2796 *
2797 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002798 *
2799 * \par Python:
2800 * \code
2801 status = py_pjsua.call_xfer(call_id, dest, msg_data)
2802 * \endcode
2803 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002804 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002805PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
2806 const pj_str_t *dest,
2807 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002808
2809/**
Benny Prijono053f5222006-11-11 16:16:04 +00002810 * Flag to indicate that "Require: replaces" should not be put in the
2811 * outgoing INVITE request caused by REFER request created by
2812 * #pjsua_call_xfer_replaces().
2813 */
2814#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
2815
2816/**
2817 * Initiate attended call transfer. This function will send REFER request
2818 * to instruct remote call party to initiate new INVITE session to the URL
2819 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
2820 * the call with us with the new call from the REFER recipient.
2821 *
2822 * @param call_id The call id to be transfered.
2823 * @param dest_call_id The call id to be replaced.
2824 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
2825 * to suppress the inclusion of "Require: replaces" in
2826 * the outgoing INVITE request created by the REFER
2827 * request.
2828 * @param msg_data Optional message components to be sent with
2829 * the request.
2830 *
2831 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002832 *
2833 * \par Python:
2834 * \code
2835 status = py_pjsua.call_xfer_replaces(call_id, dest_call_id, options, msg_data)
2836 * \endcode
2837 * Argument \a msg_data may be set to None if not required.
Benny Prijono053f5222006-11-11 16:16:04 +00002838 */
2839PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
2840 pjsua_call_id dest_call_id,
2841 unsigned options,
2842 const pjsua_msg_data *msg_data);
2843
2844/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002845 * Send DTMF digits to remote using RFC 2833 payload formats.
2846 *
2847 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002848 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002849 *
2850 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002851 *
2852 * \par Python:
2853 * \code
2854 status = py_pjsua.call_dial_dtmf(call_id, digits)
2855 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002856 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002857PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002858 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00002859
Benny Prijono26ff9062006-02-21 23:47:00 +00002860/**
Benny Prijonob0808372006-03-02 21:18:58 +00002861 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002862 *
2863 * @param call_id Call identification.
2864 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
2865 * assumed.
2866 * @param content The message content.
2867 * @param msg_data Optional list of headers etc to be included in outgoing
2868 * request. The body descriptor in the msg_data is
2869 * ignored.
2870 * @param user_data Optional user data, which will be given back when
2871 * the IM callback is called.
2872 *
2873 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002874 *
2875 * \par Python:
2876 * \code
2877 status = py_pjsua.call_send_im(call_id, mime_type, content, msg_data, user_data)
2878 * \endcode
2879 * Note that the \a user_data argument is an integer in Python.
Benny Prijonob0808372006-03-02 21:18:58 +00002880 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002881PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
2882 const pj_str_t *mime_type,
2883 const pj_str_t *content,
2884 const pjsua_msg_data *msg_data,
2885 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00002886
2887
2888/**
2889 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002890 *
2891 * @param call_id Call identification.
2892 * @param is_typing Non-zero to indicate to remote that local person is
2893 * currently typing an IM.
2894 * @param msg_data Optional list of headers etc to be included in outgoing
2895 * request.
2896 *
2897 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002898 *
2899 * \par Python:
2900 * \code
2901 status = py_pjsua.call_send_typing_ind(call_id, is_typing, msg_data)
2902 * \endcode
2903 * Argument \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00002904 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002905PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
2906 pj_bool_t is_typing,
2907 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00002908
2909/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002910 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
2911 * currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002912 *
2913 * \par Python:
2914 * \code
2915 py_pjsua.call_hangup_all()
2916 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00002917 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00002918PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00002919
2920
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002921/**
2922 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002923 *
2924 * @param call_id Call identification.
2925 * @param with_media Non-zero to include media information too.
2926 * @param buffer Buffer where the statistics are to be written to.
2927 * @param maxlen Maximum length of buffer.
2928 * @param indent Spaces for left indentation.
2929 *
2930 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002931 *
2932 * \par Python:
2933 * \code
2934 string = py_pjsua.call_dump(call_id, with_media, max_len, indent)
2935 * \endcode
2936 * The \a max_len argument is the desired maximum length to be allocated.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002937 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002938PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
2939 pj_bool_t with_media,
2940 char *buffer,
2941 unsigned maxlen,
2942 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002943
Benny Prijono9fc735d2006-05-28 14:58:12 +00002944/**
Benny Prijono312aff92006-06-17 04:08:30 +00002945 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00002946 */
Benny Prijono834aee32006-02-19 01:38:06 +00002947
2948
2949/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00002950 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00002951 */
2952
Benny Prijono312aff92006-06-17 04:08:30 +00002953
2954/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002955 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00002956 * @ingroup PJSUA_LIB
2957 * @brief Buddy management, buddy's presence, and instant messaging.
2958 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00002959 *
2960 * This section describes PJSUA-APIs related to buddies management,
2961 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00002962 */
2963
2964/**
2965 * Max buddies in buddy list.
2966 */
2967#ifndef PJSUA_MAX_BUDDIES
2968# define PJSUA_MAX_BUDDIES 256
2969#endif
2970
2971
2972/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002973 * This structure describes buddy configuration when adding a buddy to
2974 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
2975 * the structure with #pjsua_buddy_config_default() to initialize this
2976 * structure with default configuration.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002977 *
2978 * \par Python:
2979 * In Python this structure is <tt>py_pjsua.Buddy_Config</tt>. However
2980 * it is recommended that application instantiates the buddy config
2981 * by calling:
2982 * \code
2983 buddy_cfg = py_pjsua.buddy_config_default()
2984 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002985 */
2986typedef struct pjsua_buddy_config
2987{
2988 /**
2989 * Buddy URL or name address.
2990 */
2991 pj_str_t uri;
2992
2993 /**
2994 * Specify whether presence subscription should start immediately.
2995 */
2996 pj_bool_t subscribe;
2997
2998} pjsua_buddy_config;
2999
3000
3001/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003002 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003003 */
3004typedef enum pjsua_buddy_status
3005{
3006 /**
3007 * Online status is unknown (possibly because no presence subscription
3008 * has been established).
3009 */
3010 PJSUA_BUDDY_STATUS_UNKNOWN,
3011
3012 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003013 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003014 */
3015 PJSUA_BUDDY_STATUS_ONLINE,
3016
3017 /**
3018 * Buddy is offline.
3019 */
3020 PJSUA_BUDDY_STATUS_OFFLINE,
3021
3022} pjsua_buddy_status;
3023
3024
3025
3026/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003027 * This structure describes buddy info, which can be retrieved by calling
3028 * #pjsua_buddy_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003029 *
3030 * \par Python:
3031 * This structure in Python is <tt>py_pjsua.Buddy_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003032 */
3033typedef struct pjsua_buddy_info
3034{
3035 /**
3036 * The buddy ID.
3037 */
3038 pjsua_buddy_id id;
3039
3040 /**
3041 * The full URI of the buddy, as specified in the configuration.
3042 */
3043 pj_str_t uri;
3044
3045 /**
3046 * Buddy's Contact, only available when presence subscription has
3047 * been established to the buddy.
3048 */
3049 pj_str_t contact;
3050
3051 /**
3052 * Buddy's online status.
3053 */
3054 pjsua_buddy_status status;
3055
3056 /**
3057 * Text to describe buddy's online status.
3058 */
3059 pj_str_t status_text;
3060
3061 /**
3062 * Flag to indicate that we should monitor the presence information for
3063 * this buddy (normally yes, unless explicitly disabled).
3064 */
3065 pj_bool_t monitor_pres;
3066
3067 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003068 * Extended RPID information about the person.
3069 */
3070 pjrpid_element rpid;
3071
3072 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003073 * Internal buffer.
3074 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003075 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003076
3077} pjsua_buddy_info;
3078
3079
Benny Prijono834aee32006-02-19 01:38:06 +00003080/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003081 * Set default values to the buddy config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003082 *
3083 * \par Python:
3084 * \code
3085 buddy_cfg = py_pjsua.buddy_config_default()
3086 * \endcode
Benny Prijonob5388cf2007-01-04 22:45:08 +00003087 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003088PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003089
3090
3091/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003092 * Get total number of buddies.
3093 *
3094 * @return Number of buddies.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003095 *
3096 * \par Python:
3097 * \code
3098 buddy_count = py_pjsua.get_buddy_count()
3099 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003100 */
3101PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3102
3103
3104/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003105 * Check if buddy ID is valid.
3106 *
3107 * @param buddy_id Buddy ID to check.
3108 *
3109 * @return Non-zero if buddy ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003110 *
3111 * \par Python:
3112 * \code
3113 is_valid = py_pjsua.buddy_is_valid(buddy_id)
3114 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003115 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003116PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3117
3118
3119/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003120 * Enumerate all buddy IDs in the buddy list. Application then can use
3121 * #pjsua_buddy_get_info() to get the detail information for each buddy
3122 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003123 *
3124 * @param ids Array of ids to be initialized.
3125 * @param count On input, specifies max elements in the array.
3126 * On return, it contains actual number of elements
3127 * that have been initialized.
3128 *
3129 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003130 *
3131 * \par Python:
3132 * The Python function takes no argument and returns list of buddy IDs:
3133 * \code
3134 [buddy_ids] = py_pjsua.enum_buddies()
3135 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003136 */
3137PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3138 unsigned *count);
3139
3140/**
3141 * Get detailed buddy info.
3142 *
3143 * @param buddy_id The buddy identification.
3144 * @param info Pointer to receive information about buddy.
3145 *
3146 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003147 *
3148 * \par Python:
3149 * \code
3150 buddy_info = py_pjsua.buddy_get_info(buddy_id)
3151 * \endcode
3152 * The function returns None if buddy_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003153 */
3154PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003155 pjsua_buddy_info *info);
3156
3157/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003158 * Add new buddy to the buddy list. If presence subscription is enabled
3159 * for this buddy, this function will also start the presence subscription
3160 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003161 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003162 * @param buddy)cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003163 * @param p_buddy_id Pointer to receive buddy ID.
3164 *
3165 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003166 *
3167 * \par Python:
3168 * The function returns (status, buddy_id) tuple:
3169 * \code
3170 status, buddy_id = py_pjsua.buddy_add(buddy_cfg)
3171 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003172 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003173PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003174 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003175
3176
3177/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003178 * Delete the specified buddy from the buddy list. Any presence subscription
3179 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003180 *
3181 * @param buddy_id Buddy identification.
3182 *
3183 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003184 *
3185 * \par Python:
3186 * \code
3187 status = py_pjsua.buddy_del(buddy_id)
3188 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +00003189 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003190PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003191
3192
3193/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003194 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3195 * subscribed, application will be informed about buddy's presence status
3196 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003197 *
3198 * @param buddy_id Buddy identification.
3199 * @param subscribe Specify non-zero to activate presence subscription to
3200 * the specified buddy.
3201 *
3202 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003203 *
3204 * \par Python:
3205 * \code
3206 status = py_pjsua.buddy_subscribe_pres(buddy_id, subscribe)
3207 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003208 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003209PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3210 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003211
3212
3213/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003214 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003215 *
3216 * @param verbose Yes or no.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003217 *
3218 * \par Python:
3219 * \code
3220 py_pjsua.pres_dump()
3221 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003222 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003223PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003224
3225
Benny Prijonob0808372006-03-02 21:18:58 +00003226/**
3227 * The MESSAGE method (defined in pjsua_im.c)
3228 */
3229extern const pjsip_method pjsip_message_method;
3230
3231
Benny Prijonob0808372006-03-02 21:18:58 +00003232
3233/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003234 * Send instant messaging outside dialog, using the specified account for
3235 * route set and authentication.
3236 *
3237 * @param acc_id Account ID to be used to send the request.
3238 * @param to Remote URI.
3239 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3240 * assumed.
3241 * @param content The message content.
3242 * @param msg_data Optional list of headers etc to be included in outgoing
3243 * request. The body descriptor in the msg_data is
3244 * ignored.
3245 * @param user_data Optional user data, which will be given back when
3246 * the IM callback is called.
3247 *
3248 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003249 *
3250 * \par Python:
3251 * \code
3252 status = py_pjsua.im_send(acc_id, to, mime_type, content, msg_data, user_data)
3253 * \endcode
3254 * Arguments \a mime_type and \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003255 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003256PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3257 const pj_str_t *to,
3258 const pj_str_t *mime_type,
3259 const pj_str_t *content,
3260 const pjsua_msg_data *msg_data,
3261 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003262
3263
3264/**
3265 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003266 *
3267 * @param acc_id Account ID to be used to send the request.
3268 * @param to Remote URI.
3269 * @param is_typing If non-zero, it tells remote person that local person
3270 * is currently composing an IM.
3271 * @param msg_data Optional list of headers etc to be added to outgoing
3272 * request.
3273 *
3274 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003275 *
3276 * \par Python:
3277 * \code
3278 status = py_pjsua.im_typing(acc_id, to, is_typing, msg_data)
3279 * \endcode
3280 * Argument \a msg_data may be set to None if not requried.
Benny Prijonob0808372006-03-02 21:18:58 +00003281 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003282PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3283 const pj_str_t *to,
3284 pj_bool_t is_typing,
3285 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003286
3287
Benny Prijonof3195072006-02-14 21:15:30 +00003288
Benny Prijono312aff92006-06-17 04:08:30 +00003289/**
3290 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003291 */
3292
Benny Prijono312aff92006-06-17 04:08:30 +00003293
3294/*****************************************************************************
3295 * MEDIA API
3296 */
3297
3298
3299/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003300 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003301 * @ingroup PJSUA_LIB
3302 * @brief Media manipulation.
3303 * @{
3304 *
3305 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003306 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3307 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003308 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003309 * the interconnection between these terminations freely.
3310 *
3311 * The conference bridge provides powerful switching and mixing functionality
3312 * for application. With the conference bridge, each conference slot (e.g.
3313 * a call) can transmit to multiple destinations, and one destination can
3314 * receive from multiple sources. If more than one media terminations are
3315 * terminated in the same slot, the conference bridge will mix the signal
3316 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00003317 *
3318 * Application connects one media termination/slot to another by calling
3319 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003320 * media flow from the source termination to the sink termination. To
3321 * establish bidirectional media flow, application wound need to make another
3322 * call to #pjsua_conf_connect(), this time inverting the source and
3323 * destination slots in the parameter.
3324 *
3325 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00003326 * the following steps:
3327 *
3328 \code
3329
3330 pj_status_t stream_to_call( pjsua_call_id call_id )
3331 {
3332 pjsua_player_id player_id;
3333
3334 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
3335 if (status != PJ_SUCCESS)
3336 return status;
3337
3338 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
3339 pjsua_call_get_conf_port() );
3340 }
3341 \endcode
3342 *
3343 *
3344 * Other features of PJSUA media:
3345 * - efficient N to M interconnections between media terminations.
3346 * - media termination can be connected to itself to create loopback
3347 * media.
3348 * - the media termination may have different clock rates, and resampling
3349 * will be done automatically by conference bridge.
3350 * - media terminations may also have different frame time; the
3351 * conference bridge will perform the necessary bufferring to adjust
3352 * the difference between terminations.
3353 * - interconnections are removed automatically when media termination
3354 * is removed from the bridge.
3355 * - sound device may be changed even when there are active media
3356 * interconnections.
3357 * - correctly report call's media quality (in #pjsua_call_dump()) from
3358 * RTCP packet exchange.
3359 */
3360
3361/**
3362 * Max ports in the conference bridge.
3363 */
3364#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00003365# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00003366#endif
3367
Benny Prijonob5388cf2007-01-04 22:45:08 +00003368/**
3369 * The default clock rate to be used by the conference bridge.
3370 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003371#ifndef PJSUA_DEFAULT_CLOCK_RATE
3372# define PJSUA_DEFAULT_CLOCK_RATE 16000
3373#endif
3374
Benny Prijonob5388cf2007-01-04 22:45:08 +00003375/**
3376 * Default codec quality settings.
3377 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003378#ifndef PJSUA_DEFAULT_CODEC_QUALITY
3379# define PJSUA_DEFAULT_CODEC_QUALITY 5
3380#endif
3381
Benny Prijonob5388cf2007-01-04 22:45:08 +00003382/**
3383 * Default iLBC mode.
3384 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003385#ifndef PJSUA_DEFAULT_ILBC_MODE
3386# define PJSUA_DEFAULT_ILBC_MODE 20
3387#endif
3388
Benny Prijonob5388cf2007-01-04 22:45:08 +00003389/**
3390 * The default echo canceller tail length.
3391 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003392#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonod2990b92006-11-23 10:19:46 +00003393# define PJSUA_DEFAULT_EC_TAIL_LEN 800
Benny Prijono12a669c2006-11-23 07:32:13 +00003394#endif
Benny Prijono312aff92006-06-17 04:08:30 +00003395
3396
3397/**
Benny Prijonocba59d92007-02-16 09:22:56 +00003398 * The maximum file player.
3399 */
3400#ifndef PJSUA_MAX_PLAYERS
3401# define PJSUA_MAX_PLAYERS 32
3402#endif
3403
3404
3405/**
3406 * The maximum file player.
3407 */
3408#ifndef PJSUA_MAX_RECORDERS
3409# define PJSUA_MAX_RECORDERS 32
3410#endif
3411
3412
3413/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003414 * This structure describes media configuration, which will be specified
3415 * when calling #pjsua_init(). Application MUST initialize this structure
3416 * by calling #pjsua_media_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003417 *
3418 * \par Python:
3419 * This data type in Python is <tt>py_pjsua.Media_Config</tt>. To create
3420 * an object of this type, it is recommended to call
3421 * <tt>py_pjsua.media_config_default()</tt> function instead:
3422 * \code
3423 media_cfg = py_pjsua.media_config_default()
3424 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003425 */
3426struct pjsua_media_config
3427{
3428 /**
3429 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003430 * If value is zero, default clock rate will be used
3431 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00003432 */
3433 unsigned clock_rate;
3434
3435 /**
3436 * Specify maximum number of media ports to be created in the
3437 * conference bridge. Since all media terminate in the bridge
3438 * (calls, file player, file recorder, etc), the value must be
3439 * large enough to support all of them. However, the larger
3440 * the value, the more computations are performed.
3441 */
3442 unsigned max_media_ports;
3443
3444 /**
3445 * Specify whether the media manager should manage its own
3446 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
3447 * and at least one worker thread will be created too. If no,
3448 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
3449 * and no worker thread is needed.
3450 *
3451 * Normally application would say yes here, unless it wants to
3452 * run everything from a single thread.
3453 */
3454 pj_bool_t has_ioqueue;
3455
3456 /**
3457 * Specify the number of worker threads to handle incoming RTP
3458 * packets. A value of one is recommended for most applications.
3459 */
3460 unsigned thread_cnt;
3461
Benny Prijono0498d902006-06-19 14:49:14 +00003462 /**
3463 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00003464 * 5-10: resampling use large filter,
3465 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00003466 * 1-2: resampling use linear.
3467 * The media quality also sets speex codec quality/complexity to the
3468 * number.
3469 *
Benny Prijono70972992006-08-05 11:13:58 +00003470 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00003471 */
3472 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00003473
3474 /**
3475 * Specify default ptime.
3476 *
3477 * Default: 0 (codec specific)
3478 */
3479 unsigned ptime;
3480
3481 /**
3482 * Disable VAD?
3483 *
3484 * Default: 0 (no (meaning VAD is enabled))
3485 */
3486 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00003487
3488 /**
3489 * iLBC mode (20 or 30).
3490 *
Benny Prijono70972992006-08-05 11:13:58 +00003491 * Default: 20 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00003492 */
3493 unsigned ilbc_mode;
3494
3495 /**
3496 * Percentage of RTP packet to drop in TX direction
3497 * (to simulate packet lost).
3498 *
3499 * Default: 0
3500 */
3501 unsigned tx_drop_pct;
3502
3503 /**
3504 * Percentage of RTP packet to drop in RX direction
3505 * (to simulate packet lost).
3506 *
3507 * Default: 0
3508 */
3509 unsigned rx_drop_pct;
3510
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003511 /**
Benny Prijono5da50432006-08-07 10:24:52 +00003512 * Echo canceller options (see #pjmedia_echo_create())
3513 *
3514 * Default: 0.
3515 */
3516 unsigned ec_options;
3517
3518 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003519 * Echo canceller tail length, in miliseconds.
3520 *
Benny Prijono669643c2006-09-20 20:02:18 +00003521 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003522 */
3523 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003524
3525 /**
3526 * Jitter buffer initial prefetch delay in msec. The value must be
3527 * between jb_min_pre and jb_max_pre below.
3528 *
3529 * Default: -1 (to use default stream settings, currently 150 msec)
3530 */
3531 int jb_init;
3532
3533 /**
3534 * Jitter buffer minimum prefetch delay in msec.
3535 *
3536 * Default: -1 (to use default stream settings, currently 60 msec)
3537 */
3538 int jb_min_pre;
3539
3540 /**
3541 * Jitter buffer maximum prefetch delay in msec.
3542 *
3543 * Default: -1 (to use default stream settings, currently 240 msec)
3544 */
3545 int jb_max_pre;
3546
3547 /**
3548 * Set maximum delay that can be accomodated by the jitter buffer msec.
3549 *
3550 * Default: -1 (to use default stream settings, currently 360 msec)
3551 */
3552 int jb_max;
3553
Benny Prijonoc97608e2007-03-23 16:34:20 +00003554 /**
3555 * Enable ICE
3556 */
3557 pj_bool_t enable_ice;
3558
3559 /**
3560 * Enable ICE media relay.
3561 */
3562 pj_bool_t enable_relay;
Benny Prijono312aff92006-06-17 04:08:30 +00003563};
3564
3565
3566/**
3567 * Use this function to initialize media config.
3568 *
3569 * @param cfg The media config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003570 *
3571 * \par Python:
3572 * \code
3573 media_cfg = py_pjsua.media_config_default()
3574 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003575 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003576PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00003577
3578
3579/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003580 * This structure describes codec information, which can be retrieved by
3581 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00003582 */
3583typedef struct pjsua_codec_info
3584{
3585 /**
3586 * Codec unique identification.
3587 */
3588 pj_str_t codec_id;
3589
3590 /**
3591 * Codec priority (integer 0-255).
3592 */
3593 pj_uint8_t priority;
3594
3595 /**
3596 * Internal buffer.
3597 */
3598 char buf_[32];
3599
3600} pjsua_codec_info;
3601
3602
3603/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003604 * This structure descibes information about a particular media port that
3605 * has been registered into the conference bridge. Application can query
3606 * this info by calling #pjsua_conf_get_port_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003607 *
3608 * \par Python:
3609 * In Python, this type is <tt>py_pjsua.Conf_Port_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003610 */
3611typedef struct pjsua_conf_port_info
3612{
3613 /** Conference port number. */
3614 pjsua_conf_port_id slot_id;
3615
3616 /** Port name. */
3617 pj_str_t name;
3618
3619 /** Clock rate. */
3620 unsigned clock_rate;
3621
3622 /** Number of channels. */
3623 unsigned channel_count;
3624
3625 /** Samples per frame */
3626 unsigned samples_per_frame;
3627
3628 /** Bits per sample */
3629 unsigned bits_per_sample;
3630
3631 /** Number of listeners in the array. */
3632 unsigned listener_cnt;
3633
3634 /** Array of listeners (in other words, ports where this port is
3635 * transmitting to.
3636 */
3637 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
3638
3639} pjsua_conf_port_info;
3640
3641
3642/**
3643 * This structure holds information about custom media transport to
3644 * be registered to pjsua.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003645 *
3646 * \par Python:
3647 * Not applicable.
Benny Prijono312aff92006-06-17 04:08:30 +00003648 */
3649typedef struct pjsua_media_transport
3650{
3651 /**
3652 * Media socket information containing the address information
3653 * of the RTP and RTCP socket.
3654 */
3655 pjmedia_sock_info skinfo;
3656
3657 /**
3658 * The media transport instance.
3659 */
3660 pjmedia_transport *transport;
3661
3662} pjsua_media_transport;
3663
3664
3665
3666
Benny Prijono9fc735d2006-05-28 14:58:12 +00003667/**
3668 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003669 *
3670 * @return Maximum number of ports in the conference bridge.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003671 *
3672 * \par Python:
3673 * \code
3674 port_count = py_pjsua.conf_get_max_ports()
3675 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003676 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003677PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003678
3679
3680/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003681 * Get current number of active ports in the bridge.
3682 *
3683 * @return The number.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003684 *
3685 * \par Python:
3686 * \code
3687 count = py_pjsua.conf_get_active_ports()
3688 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003689 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003690PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
3691
3692
3693/**
3694 * Enumerate all conference ports.
3695 *
3696 * @param id Array of conference port ID to be initialized.
3697 * @param count On input, specifies max elements in the array.
3698 * On return, it contains actual number of elements
3699 * that have been initialized.
3700 *
3701 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003702 *
3703 * \par Python:
3704 * The Python functions returns list of conference port Ids:
3705 * \code
3706 [port_ids] = py_pjsua.enum_conf_ports()
3707 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003708 */
3709PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
3710 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003711
3712
3713/**
3714 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003715 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003716 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003717 * @param info Pointer to store the port info.
3718 *
3719 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003720 *
3721 * \par Python:
3722 * \code
3723 port_info = py_pjsua.conf_get_port_info(port_id)
3724 * \endcode
3725 * The function will return None if \a port_id is not valid.
Benny Prijono8b1889b2006-06-06 18:40:40 +00003726 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003727PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00003728 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003729
3730
3731/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00003732 * Add arbitrary media port to PJSUA's conference bridge. Application
3733 * can use this function to add the media port that it creates. For
3734 * media ports that are created by PJSUA-LIB (such as calls, file player,
3735 * or file recorder), PJSUA-LIB will automatically add the port to
3736 * the bridge.
3737 *
3738 * @param pool Pool to use.
3739 * @param port Media port to be added to the bridge.
3740 * @param p_id Optional pointer to receive the conference
3741 * slot id.
3742 *
3743 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003744 *
3745 * \par Python:
3746 * Not applicable (for now)
Benny Prijonoe909eac2006-07-27 22:04:56 +00003747 */
3748PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
3749 pjmedia_port *port,
3750 pjsua_conf_port_id *p_id);
3751
3752
3753/**
3754 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00003755 * call this function if it registered the port manually with previous call
3756 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00003757 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003758 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00003759 *
3760 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003761 *
3762 * \par Python:
3763 * \code
3764 status = py_pjsua.conf_remove_port(port_id)
3765 * \endcode
Benny Prijonoe909eac2006-07-27 22:04:56 +00003766 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003767PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00003768
3769
3770/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003771 * Establish unidirectional media flow from souce to sink. One source
3772 * may transmit to multiple destinations/sink. And if multiple
3773 * sources are transmitting to the same sink, the media will be mixed
3774 * together. Source and sink may refer to the same ID, effectively
3775 * looping the media.
3776 *
3777 * If bidirectional media flow is desired, application needs to call
3778 * this function twice, with the second one having the arguments
3779 * reversed.
3780 *
3781 * @param source Port ID of the source media/transmitter.
3782 * @param sink Port ID of the destination media/received.
3783 *
3784 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003785 *
3786 * \par Python:
3787 * \code
3788 status = py_pjsua.conf_connect(source, sink)
3789 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003790 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003791PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
3792 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003793
3794
3795/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003796 * Disconnect media flow from the source to destination port.
3797 *
3798 * @param source Port ID of the source media/transmitter.
3799 * @param sink Port ID of the destination media/received.
3800 *
3801 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003802 *
3803 * \par Python:
3804 * \code
3805 status = py_pjsua.conf_disconnect(source, sink)
3806 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003807 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003808PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
3809 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003810
3811
Benny Prijono6dd967c2006-12-26 02:27:14 +00003812/**
3813 * Adjust the signal level to be transmitted from the bridge to the
3814 * specified port by making it louder or quieter.
3815 *
3816 * @param slot The conference bridge slot number.
3817 * @param level Signal level adjustment. Value 1.0 means no level
3818 * adjustment, while value 0 means to mute the port.
3819 *
3820 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003821 *
3822 * \par Python:
3823 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003824 */
3825PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
3826 float level);
3827
3828/**
3829 * Adjust the signal level to be received from the specified port (to
3830 * the bridge) by making it louder or quieter.
3831 *
3832 * @param slot The conference bridge slot number.
3833 * @param level Signal level adjustment. Value 1.0 means no level
3834 * adjustment, while value 0 means to mute the port.
3835 *
3836 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003837 *
3838 * \par Python:
3839 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003840 */
3841PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
3842 float level);
3843
3844/**
3845 * Get last signal level transmitted to or received from the specified port.
3846 * The signal level is an integer value in zero to 255, with zero indicates
3847 * no signal, and 255 indicates the loudest signal level.
3848 *
3849 * @param slot The conference bridge slot number.
3850 * @param tx_level Optional argument to receive the level of signal
3851 * transmitted to the specified port (i.e. the direction
3852 * is from the bridge to the port).
3853 * @param rx_level Optional argument to receive the level of signal
3854 * received from the port (i.e. the direction is from the
3855 * port to the bridge).
3856 *
3857 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003858 *
3859 * \par Python:
3860 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003861 */
3862PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
3863 unsigned *tx_level,
3864 unsigned *rx_level);
3865
Benny Prijono6dd967c2006-12-26 02:27:14 +00003866
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003867/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00003868 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003869 */
3870
Benny Prijono9fc735d2006-05-28 14:58:12 +00003871/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003872 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003873 * the conference bridge.
3874 *
3875 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00003876 * WAV files are supported, and the WAV file MUST be
3877 * formatted as 16bit PCM mono/single channel (any
3878 * clock rate is supported).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003879 * @param options Options (currently zero).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003880 * @param p_id Pointer to receive player ID.
3881 *
3882 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003883 *
3884 * \par Python:
3885 * The function returns (status, id) tuple:
3886 * \code
3887 status, id = py_pjsua.player_create(filename, options)
3888 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003889 */
3890PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003891 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003892 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003893
3894
3895/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003896 * Create a file playlist media port, and automatically add the port
3897 * to the conference bridge.
3898 *
3899 * @param file_names Array of file names to be added to the play list.
3900 * Note that the files must have the same clock rate,
3901 * number of channels, and number of bits per sample.
3902 * @param file_count Number of files in the array.
3903 * @param label Optional label to be set for the media port.
3904 * @param options Optional option flag. Application may specify
3905 * PJMEDIA_FILE_NO_LOOP to prevent looping.
3906 * @param p_id Optional pointer to receive player ID.
3907 *
3908 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003909 *
3910 * \par Python:
3911 * Not implemented yet.
Benny Prijonoa66c3312007-01-21 23:12:40 +00003912 */
3913PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
3914 unsigned file_count,
3915 const pj_str_t *label,
3916 unsigned options,
3917 pjsua_player_id *p_id);
3918
3919/**
3920 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003921 *
3922 * @param id The file player ID.
3923 *
3924 * @return Conference port ID associated with this player.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003925 *
3926 * \par Python:
3927 * \code
3928 port_id = py_pjsua.player_get_conf_port(id)
3929 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003930 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003931PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003932
3933
3934/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003935 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00003936 *
3937 * @param id The player ID.
3938 * @param p_port The media port associated with the player.
3939 *
3940 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003941 *
3942 * \par Python:
3943 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00003944 */
3945PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_recorder_id id,
3946 pjmedia_port **p_port);
3947
3948/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003949 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003950 *
3951 * @param id The file player ID.
3952 * @param samples The playback position, in samples. Application can
3953 * specify zero to re-start the playback.
3954 *
3955 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003956 *
3957 * \par Python:
3958 * \code
3959 status = py_pjsua.player_set_pos(id, samples)
3960 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003961 */
3962PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
3963 pj_uint32_t samples);
3964
3965
3966/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003967 * Close the file of playlist, remove the player from the bridge, and free
3968 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003969 *
3970 * @param id The file player ID.
3971 *
3972 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003973 *
3974 * \par Python:
3975 * \code
3976 status = py_pjsua.player_destroy(id)
3977 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003978 */
3979PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
3980
3981
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003982/*****************************************************************************
3983 * File recorder.
3984 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00003985
3986/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003987 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00003988 * the conference bridge. The recorder currently supports recording WAV file.
3989 * The type of the recorder to use is determined by the extension of the file
3990 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003991 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00003992 * @param filename Output file name. The function will determine the
3993 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00003994 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00003995 * @param enc_type Optionally specify the type of encoder to be used to
3996 * compress the media, if the file can support different
3997 * encodings. This value must be zero for now.
3998 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00003999 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00004000 * For .WAV recorder, this value must be NULL.
4001 * @param max_size Maximum file size. Specify zero or -1 to remove size
4002 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004003 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004004 * @param p_id Pointer to receive the recorder instance.
4005 *
4006 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004007 *
4008 * \par Python:
4009 * \code
4010 status, id = py_pjsua.recorder_create(filename, enc_type, enc_param, max_size, options)
4011 * \endcode
4012 * The \a enc_param is a string in Python.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004013 */
4014PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004015 unsigned enc_type,
4016 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004017 pj_ssize_t max_size,
4018 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004019 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004020
4021
4022/**
4023 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004024 *
4025 * @param id The recorder ID.
4026 *
4027 * @return Conference port ID associated with this recorder.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004028 *
4029 * \par Python:
4030 * \code
4031 port_id = py_pjsua.recorder_get_conf_port(id)
4032 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004033 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004034PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004035
4036
4037/**
Benny Prijono469b1522006-12-26 03:05:17 +00004038 * Get the media port for the recorder.
4039 *
4040 * @param id The recorder ID.
4041 * @param p_port The media port associated with the recorder.
4042 *
4043 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004044 *
4045 * \par Python:
4046 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004047 */
4048PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4049 pjmedia_port **p_port);
4050
4051
4052/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004053 * Destroy recorder (this will complete recording).
4054 *
4055 * @param id The recorder ID.
4056 *
4057 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004058 *
4059 * \par Python:
4060 * \code
4061 status = py_pjsua.recorder_destroy(id)
4062 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004063 */
4064PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4065
4066
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004067/*****************************************************************************
4068 * Sound devices.
4069 */
4070
Benny Prijono9fc735d2006-05-28 14:58:12 +00004071/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004072 * Enum all sound devices installed in the system.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004073 *
4074 * @param info Array of info to be initialized.
4075 * @param count On input, specifies max elements in the array.
4076 * On return, it contains actual number of elements
4077 * that have been initialized.
4078 *
4079 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004080 *
4081 *
4082 * \par Python:
4083 * The function returns list of sound device info:
4084 * \code
4085 [dev_infos] = py_pjsua.enum_snd_devs()
4086 * \endcode
4087 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00004088 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004089PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4090 unsigned *count);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004091
4092
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004093
4094/**
4095 * Get currently active sound devices. If sound devices has not been created
4096 * (for example when pjsua_start() is not called), it is possible that
4097 * the function returns PJ_SUCCESS with -1 as device IDs.
4098 *
4099 * @param capture_dev On return it will be filled with device ID of the
4100 * capture device.
4101 * @param playback_dev On return it will be filled with device ID of the
4102 * device ID of the playback device.
4103 *
4104 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004105 *
4106 * \par Python:
Benny Prijonoebdf8772007-02-01 19:25:50 +00004107 * The function takes no argument and return an (integer,integer) tuple:
Benny Prijonoe6ead542007-01-31 20:53:31 +00004108 * \code
4109 capture_dev, playback_dev = py_pjsua.get_snd_dev()
4110 * \endcode
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004111 */
4112PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4113 int *playback_dev);
4114
4115
Benny Prijono9fc735d2006-05-28 14:58:12 +00004116/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004117 * Select or change sound device. Application may call this function at
4118 * any time to replace current sound device.
4119 *
4120 * @param capture_dev Device ID of the capture device.
4121 * @param playback_dev Device ID of the playback device.
4122 *
4123 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004124 *
4125 * \par Python:
4126 * \code
4127 status = py_pjsua.set_snd_dev(capture_dev, playback_dev)
4128 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004129 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004130PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4131 int playback_dev);
4132
4133
4134/**
4135 * Set pjsua to use null sound device. The null sound device only provides
4136 * the timing needed by the conference bridge, and will not interract with
4137 * any hardware.
4138 *
4139 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004140 *
4141 * \par Python:
4142 * \code
4143 status = py_pjsua.set_null_snd_dev()
4144 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004145 */
4146PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4147
4148
Benny Prijonoe909eac2006-07-27 22:04:56 +00004149/**
4150 * Disconnect the main conference bridge from any sound devices, and let
4151 * application connect the bridge to it's own sound device/master port.
4152 *
4153 * @return The port interface of the conference bridge,
4154 * so that application can connect this to it's own
4155 * sound device or master port.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004156 *
4157 * \par Python:
4158 * Not applicable (for now).
Benny Prijonoe909eac2006-07-27 22:04:56 +00004159 */
4160PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4161
4162
Benny Prijonof20687a2006-08-04 18:27:19 +00004163/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004164 * Configure the echo canceller tail length of the sound port.
Benny Prijonof20687a2006-08-04 18:27:19 +00004165 *
4166 * @param tail_ms The tail length, in miliseconds. Set to zero to
4167 * disable AEC.
Benny Prijono5da50432006-08-07 10:24:52 +00004168 * @param options Options to be passed to #pjmedia_echo_create().
4169 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004170 *
4171 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004172 *
4173 * \par Python:
4174 * \code
4175 status = py_pjsua.set_ec(tail_ms, options)
4176 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004177 */
Benny Prijono5da50432006-08-07 10:24:52 +00004178PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004179
4180
4181/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004182 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004183 *
4184 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4185 * If AEC is disabled, the value will be zero.
4186 *
4187 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004188 *
4189 * \par Python:
4190 * \code
4191 tail_ms = py_pjsua.get_ec_tail()
4192 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004193 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004194PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004195
4196
4197
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004198/*****************************************************************************
4199 * Codecs.
4200 */
4201
4202/**
4203 * Enum all supported codecs in the system.
4204 *
4205 * @param id Array of ID to be initialized.
4206 * @param count On input, specifies max elements in the array.
4207 * On return, it contains actual number of elements
4208 * that have been initialized.
4209 *
4210 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004211 *
4212 * \par Python:
4213 * This function takes no argument and returns list of codec infos:
4214 * \code
4215 [codec_info] = py_pjsua.enum_codecs()
4216 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004217 */
4218PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4219 unsigned *count );
4220
4221
4222/**
4223 * Change codec priority.
4224 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004225 * @param codec_id Codec ID, which is a string that uniquely identify
4226 * the codec (such as "speex/8000"). Please see pjsua
4227 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004228 * @param priority Codec priority, 0-255, where zero means to disable
4229 * the codec.
4230 *
4231 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004232 *
4233 * \par Python:
4234 * \code
4235 status = py_pjsua.codec_set_priority(codec_id, priority)
4236 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004237 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004238PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004239 pj_uint8_t priority );
4240
4241
4242/**
4243 * Get codec parameters.
4244 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004245 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004246 * @param param Structure to receive codec parameters.
4247 *
4248 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004249 *
4250 * \par Python:
4251 * The Python function is experimental:
4252 * \code
4253 codec_param = py_pjsua.codec_get_param(codec_id)
4254 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004255 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004256PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004257 pjmedia_codec_param *param );
4258
4259
4260/**
4261 * Set codec parameters.
4262 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004263 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004264 * @param param Codec parameter to set.
4265 *
4266 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004267 *
4268 * \par Python:
4269 * The Python function is experimental:
4270 * \code
4271 status = py_pjsua.codec_set_param(codec_id, param)
4272 * \endcode
4273
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004274 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004275PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004276 const pjmedia_codec_param *param);
4277
4278
4279
Benny Prijono9fc735d2006-05-28 14:58:12 +00004280
Benny Prijono312aff92006-06-17 04:08:30 +00004281/**
4282 * Create UDP media transports for all the calls. This function creates
4283 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00004284 *
Benny Prijono312aff92006-06-17 04:08:30 +00004285 * @param cfg Media transport configuration. The "port" field in the
4286 * configuration is used as the start port to bind the
4287 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004288 *
4289 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004290 *
4291 * \par Python:
4292 * Not implemented yet.
Benny Prijonof3195072006-02-14 21:15:30 +00004293 */
Benny Prijono312aff92006-06-17 04:08:30 +00004294PJ_DECL(pj_status_t)
4295pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00004296
Benny Prijonodc39fe82006-05-26 12:17:46 +00004297
4298/**
Benny Prijono312aff92006-06-17 04:08:30 +00004299 * Register custom media transports to be used by calls. There must
4300 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004301 *
Benny Prijono312aff92006-06-17 04:08:30 +00004302 * @param tp The media transport array.
4303 * @param count Number of elements in the array. This number MUST
4304 * match the number of maximum calls configured when
4305 * pjsua is created.
4306 * @param auto_delete Flag to indicate whether the transports should be
4307 * destroyed when pjsua is shutdown.
4308 *
4309 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004310 *
4311 * \par Python:
4312 * Note applicable.
Benny Prijonodc39fe82006-05-26 12:17:46 +00004313 */
Benny Prijono312aff92006-06-17 04:08:30 +00004314PJ_DECL(pj_status_t)
4315pjsua_media_transports_attach( pjsua_media_transport tp[],
4316 unsigned count,
4317 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00004318
4319
Benny Prijono312aff92006-06-17 04:08:30 +00004320/**
4321 * @}
4322 */
4323
Benny Prijonof3195072006-02-14 21:15:30 +00004324
Benny Prijono268ca612006-02-07 12:34:11 +00004325
Benny Prijono312aff92006-06-17 04:08:30 +00004326/**
4327 * @}
4328 */
4329
Benny Prijonoe6ead542007-01-31 20:53:31 +00004330PJ_END_DECL
4331
Benny Prijono312aff92006-06-17 04:08:30 +00004332
Benny Prijono268ca612006-02-07 12:34:11 +00004333#endif /* __PJSUA_H__ */