blob: 78f8b1bd9592c6d084386efe819add42adc51103 [file] [log] [blame]
Benny Prijono268ca612006-02-07 12:34:11 +00001/* $Id$ */
2/*
Benny Prijonoa771a512007-02-19 01:13:53 +00003 * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org>
Benny Prijono268ca612006-02-07 12:34:11 +00004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJSUA_H__
20#define __PJSUA_H__
21
Benny Prijono312aff92006-06-17 04:08:30 +000022/**
23 * @file pjsua.h
24 * @brief PJSUA API.
25 */
26
27
Benny Prijono268ca612006-02-07 12:34:11 +000028/* Include all PJSIP core headers. */
29#include <pjsip.h>
30
31/* Include all PJMEDIA headers. */
32#include <pjmedia.h>
33
Benny Prijono1f9afba2006-02-10 15:57:32 +000034/* Include all PJMEDIA-CODEC headers. */
35#include <pjmedia-codec.h>
36
Benny Prijono268ca612006-02-07 12:34:11 +000037/* Include all PJSIP-UA headers */
38#include <pjsip_ua.h>
39
Benny Prijono834aee32006-02-19 01:38:06 +000040/* Include all PJSIP-SIMPLE headers */
41#include <pjsip_simple.h>
42
Benny Prijono268ca612006-02-07 12:34:11 +000043/* Include all PJLIB-UTIL headers. */
44#include <pjlib-util.h>
45
46/* Include all PJLIB headers. */
47#include <pjlib.h>
48
49
Benny Prijonoe6ead542007-01-31 20:53:31 +000050PJ_BEGIN_DECL
51
52
Benny Prijono312aff92006-06-17 04:08:30 +000053/**
Benny Prijonoe6ead542007-01-31 20:53:31 +000054 * @defgroup PJSUA_LIB PJSUA API - High Level Softphone API for C/C++ and Python
Benny Prijono312aff92006-06-17 04:08:30 +000055 * @ingroup PJSIP
56 * @brief Very high level API for constructing SIP UA applications.
57 * @{
58 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000059 * @section pjsua_api_intro A SIP User Agent API for C/C++ and Python
60 *
61 * PJSUA API is very high level API, available for C/C++ and Python language,
62 * for constructing SIP multimedia user agent
Benny Prijono312aff92006-06-17 04:08:30 +000063 * applications. It wraps together the signaling and media functionalities
64 * into an easy to use call API, provides account management, buddy
65 * management, presence, instant messaging, along with multimedia
66 * features such as conferencing, file streaming, local playback,
67 * voice recording, and so on.
68 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000069 * @subsection pjsua_for_c_cpp C/C++ Binding
Benny Prijono312aff92006-06-17 04:08:30 +000070 * Application must link with <b>pjsua-lib</b> to use this API. In addition,
71 * this library depends on the following libraries:
72 * - <b>pjsip-ua</b>,
73 * - <b>pjsip-simple</b>,
74 * - <b>pjsip-core</b>,
75 * - <b>pjmedia</b>,
76 * - <b>pjmedia-codec</b>,
77 * - <b>pjlib-util</b>, and
78 * - <b>pjlib</b>,
79 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000080 * so application must also link with these libraries as well. For more
81 * information, please refer to
82 * <A HREF="http://www.pjsip.org/using.htm">Getting Started with PJSIP</A>
83 * page.
Benny Prijono312aff92006-06-17 04:08:30 +000084 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000085 * @subsection pjsua_for_python Python Binding
86 *
87 * The Python binding for PJSUA-API is implemented by <b>py_pjsua</b>
88 * module, in <tt>pjsip-apps/py_pjsua</tt> directory. This module is
89 * built by building <tt>py_pjsua</tt> project in <tt>pjsip_apps</tt>
90 * Visual Studio workspace, or by invoking the usual <tt>setup.py</tt>
91 * Python installer script.
92 *
93 * The Python script then can import the PJSUA-API Python module by
94 * using <b>import py_pjsua</b> construct as usual.
95 *
96 *
97 * @section pjsua_samples
98 *
99 * Few samples are provided both in C and Python.
100 *
101 - @ref page_pjsip_sample_simple_pjsuaua_c\n
102 Very simple SIP User Agent with registration, call, and media, using
103 PJSUA-API, all in under 200 lines of code.
104
105 - @ref page_pjsip_samples_pjsua\n
106 This is the reference implementation for PJSIP and PJMEDIA.
107 PJSUA is a console based application, designed to be simple enough
108 to be readble, but powerful enough to demonstrate all features
109 available in PJSIP and PJMEDIA.\n
110
111 - Python sample\n
112 For a real simple Python sample application, have a look at
113 <A HREF="http://www.pjsip.org/trac/browser/pjproject/trunk/pjsip-apps/src/py_pjsua/pjsua_app.py">
114 <tt>pjsip-apps/src/py_pjsua/pjsua_app.py</tt></A> file.
115
Benny Prijono312aff92006-06-17 04:08:30 +0000116 * @section root_using_pjsua_lib Using PJSUA API
117 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000118 * Please refer to @ref PJSUA_LIB_BASE on how to create and initialize the API.
119 * And then see the Modules on the bottom of this page for more information
120 * about specific subject.
Benny Prijono312aff92006-06-17 04:08:30 +0000121 */
122
Benny Prijonoa91a0032006-02-26 21:23:45 +0000123
Benny Prijonof3195072006-02-14 21:15:30 +0000124
Benny Prijono312aff92006-06-17 04:08:30 +0000125/*****************************************************************************
126 * BASE API
127 */
128
Benny Prijonof04ffdd2006-02-21 00:11:18 +0000129/**
Benny Prijonoe6ead542007-01-31 20:53:31 +0000130 * @defgroup PJSUA_LIB_BASE PJSUA-API Basic API
Benny Prijono312aff92006-06-17 04:08:30 +0000131 * @ingroup PJSUA_LIB
132 * @brief Basic application creation/initialization, logging configuration, etc.
133 * @{
134 *
135 * The base PJSUA API controls PJSUA creation, initialization, and startup, and
136 * also provides various auxiliary functions.
137 *
138 * @section using_pjsua_lib Using PJSUA Library
139 *
140 * @subsection creating_pjsua_lib Creating PJSUA
141 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000142 * Before anything else, application must create PJSUA by calling #pjsua_create()
143 * (or <tt>py_pjsua.create()</tt> from Python).
Benny Prijono312aff92006-06-17 04:08:30 +0000144 * This, among other things, will initialize PJLIB, which is crucial before
Benny Prijonoe6ead542007-01-31 20:53:31 +0000145 * any PJLIB functions can be called, PJLIB-UTIL, and create a SIP endpoint.
146 *
147 * After this function is called, application can create a memory pool (with
148 * #pjsua_pool_create()) and read configurations from command line or file to
149 * build the settings to initialize PJSUA below.
Benny Prijono312aff92006-06-17 04:08:30 +0000150 *
151 * @subsection init_pjsua_lib Initializing PJSUA
152 *
153 * After PJSUA is created, application can initialize PJSUA by calling
Benny Prijonoe6ead542007-01-31 20:53:31 +0000154 * #pjsua_init(). This function takes several optional configuration settings
155 * in the argument, if application wants to set them.
Benny Prijono312aff92006-06-17 04:08:30 +0000156 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000157 * @subsubsection init_pjsua_lib_c_cpp PJSUA-LIB Initialization (in C)
158 * Sample code to initialize PJSUA in C code:
Benny Prijono312aff92006-06-17 04:08:30 +0000159 \code
160
Benny Prijonob5388cf2007-01-04 22:45:08 +0000161 #include <pjsua-lib/pjsua.h>
162
163 #define THIS_FILE __FILE__
164
165 static pj_status_t app_init(void)
166 {
Benny Prijono312aff92006-06-17 04:08:30 +0000167 pjsua_config ua_cfg;
168 pjsua_logging_config log_cfg;
169 pjsua_media_config media_cfg;
Benny Prijonob5388cf2007-01-04 22:45:08 +0000170 pj_status_t status;
171
172 // Must create pjsua before anything else!
173 status = pjsua_create();
174 if (status != PJ_SUCCESS) {
175 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
176 return status;
177 }
Benny Prijono312aff92006-06-17 04:08:30 +0000178
179 // Initialize configs with default settings.
180 pjsua_config_default(&ua_cfg);
181 pjsua_logging_config_default(&log_cfg);
182 pjsua_media_config_default(&media_cfg);
183
184 // At the very least, application would want to override
185 // the call callbacks in pjsua_config:
186 ua_cfg.cb.on_incoming_call = ...
187 ua_cfg.cb.on_call_state = ..
188 ...
189
190 // Customize other settings (or initialize them from application specific
191 // configuration file):
192 ...
193
194 // Initialize pjsua
195 status = pjsua_init(&ua_cfg, &log_cfg, &media_cfg);
196 if (status != PJ_SUCCESS) {
197 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
198 return status;
199 }
Benny Prijonob5388cf2007-01-04 22:45:08 +0000200 .
201 ...
202 }
Benny Prijono312aff92006-06-17 04:08:30 +0000203 \endcode
204 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000205 *
206 * @subsubsection init_pjsua_lib_python PJSUA-LIB Initialization (in Python)
207 * Sample code to initialize PJSUA in Python code:
208
209 \code
210
211import py_pjsua
212
213#
214# Initialize pjsua.
215#
216def app_init():
217 # Create pjsua before anything else
218 status = py_pjsua.create()
219 if status != 0:
220 err_exit("pjsua create() error", status)
221
222 # We use default logging config for this sample
223 log_cfg = py_pjsua.logging_config_default()
224
225 # Create and initialize pjsua config
226 # Note: for this Python module, thread_cnt must be 0 since Python
227 # doesn't like to be called from alien thread (pjsua's thread
228 # in this case)
229 ua_cfg = py_pjsua.config_default()
230 ua_cfg.thread_cnt = 0
231 ua_cfg.user_agent = "PJSUA/Python 0.1"
232
233 # Override callbacks. At the very least application would want to
234 # override the call callbacks in pjsua_config
235 ua_cfg.cb.on_incoming_call = ...
236 ua_cfg.cb.on_call_state = ...
237
238 # Use default media config for this cample
239 med_cfg = py_pjsua.media_config_default()
240
241 #
242 # Initialize pjsua!!
243 #
244 status = py_pjsua.init(ua_cfg, log_cfg, med_cfg)
245 if status != 0:
246 err_exit("pjsua init() error", status)
247
248
249
250# Utility: display PJ error and exit
251#
252def err_exit(title, rc):
253 py_pjsua.perror(THIS_FILE, title, rc)
254 exit(1)
255
256 \endcode
257
258
Benny Prijono312aff92006-06-17 04:08:30 +0000259 * @subsection other_init_pjsua_lib Other Initialization
260 *
261 * After PJSUA is initialized with #pjsua_init(), application will normally
262 * need/want to perform the following tasks:
263 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000264 * - create SIP transport with #pjsua_transport_create(). Application would
265 * to call #pjsua_transport_create() for each transport types that it
266 * wants to support (for example, UDP, TCP, and TLS). Please see
Benny Prijono312aff92006-06-17 04:08:30 +0000267 * @ref PJSUA_LIB_TRANSPORT section for more info.
268 * - create one or more SIP accounts with #pjsua_acc_add() or
Benny Prijonoe6ead542007-01-31 20:53:31 +0000269 * #pjsua_acc_add_local(). The SIP account is used for registering with
270 * the SIP server, if any. Please see @ref PJSUA_LIB_ACC for more info.
Benny Prijono312aff92006-06-17 04:08:30 +0000271 * - add one or more buddies with #pjsua_buddy_add(). Please see
272 * @ref PJSUA_LIB_BUDDY section for more info.
273 * - optionally configure the sound device, codec settings, and other
274 * media settings. Please see @ref PJSUA_LIB_MEDIA for more info.
275 *
276 *
277 * @subsection starting_pjsua_lib Starting PJSUA
278 *
279 * After all initializations have been done, application must call
280 * #pjsua_start() to start PJSUA. This function will check that all settings
Benny Prijonoe6ead542007-01-31 20:53:31 +0000281 * have been properly configured, and apply default settings when they haven't,
282 * or report error status when it is unable to recover from missing settings.
Benny Prijono312aff92006-06-17 04:08:30 +0000283 *
284 * Most settings can be changed during run-time. For example, application
285 * may add, modify, or delete accounts, buddies, or change media settings
286 * during run-time.
Benny Prijonob5388cf2007-01-04 22:45:08 +0000287 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000288 * @subsubsection starting_pjsua_lib_c C Example for Starting PJSUA
Benny Prijonob5388cf2007-01-04 22:45:08 +0000289 * Sample code:
290 \code
291 static pj_status_t app_run(void)
292 {
293 pj_status_t status;
294
295 // Start pjsua
296 status = pjsua_start();
297 if (status != PJ_SUCCESS) {
298 pjsua_destroy();
299 pjsua_perror(THIS_FILE, "Error starting pjsua", status);
300 return status;
301 }
302
303 // Run application loop
304 while (1) {
305 char choice[10];
306
307 printf("Select menu: ");
308 fgets(choice, sizeof(choice), stdin);
309 ...
310 }
311 }
312 \endcode
Benny Prijonoe6ead542007-01-31 20:53:31 +0000313
314 * @subsubsection starting_pjsua_lib_python Python Example for starting PJSUA
315 * For Python, starting PJSUA-LIB takes one more step, that is to initialize
316 * Python worker thread to poll PJSUA-LIB. This step is necessary because
317 * Python doesn't like it when it is called by an "alien" thread (that is,
318 * thread that is not created using Python API).
319 *
320 * Because of this, we cannot use a worker thread in PJSUA-LIB, because then
321 * the Python callback will be called by an "alien" thread and this would
322 * crash Python (or raise assert() probably).
323 *
324 * So because worker thread is disabled, we need to create a worker thread
325 * in Python. Note that this may not be necessary if we're creating a
326 * GUI application, because then we can attach, for example, a GUI timer
327 * object to poll the PJSUA-LIB. But because we're creating a console
328 * application which will block at <tt>sys.stdin.readline()</tt>, we need
329 * to have a worker thread to poll PJSUA-LIB.
330
331 \code
332
333import thread
334
335C_QUIT = 0
336
337
338def app_start():
339 # Done with initialization, start pjsua!!
340 #
341 status = py_pjsua.start()
342 if status != 0:
343 py_pjsua.destroy()
344 err_exit("Error starting pjsua!", status)
345
346 # Start worker thread
347 thr = thread.start_new(worker_thread_main, (0,))
348
349 print "PJSUA Started!!"
350
351#
352# Worker thread function.
353# Python doesn't like it when it's called from an alien thread
354# (pjsua's worker thread, in this case), so for Python we must
355# disable worker thread in pjsua and poll pjsua from Python instead.
356#
357def worker_thread_main(arg):
358 global C_QUIT
359 thread_desc = 0
360 status = py_pjsua.thread_register("python worker", thread_desc)
361 if status != 0:
362 py_pjsua.perror(THIS_FILE, "Error registering thread", status)
363 else:
364 while C_QUIT == 0:
365 py_pjsua.handle_events(50)
366 print "Worker thread quitting.."
367 C_QUIT = 2
368
369
370 \endcode
Benny Prijonof04ffdd2006-02-21 00:11:18 +0000371 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000372
Benny Prijono312aff92006-06-17 04:08:30 +0000373/** Constant to identify invalid ID for all sorts of IDs. */
374#define PJSUA_INVALID_ID (-1)
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000375
376/** Call identification */
377typedef int pjsua_call_id;
378
Benny Prijono312aff92006-06-17 04:08:30 +0000379/** Account identification */
380typedef int pjsua_acc_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000381
382/** Buddy identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000383typedef int pjsua_buddy_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000384
385/** File player identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000386typedef int pjsua_player_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000387
388/** File recorder identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000389typedef int pjsua_recorder_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000390
391/** Conference port identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000392typedef int pjsua_conf_port_id;
393
394
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000395
Benny Prijonoa91a0032006-02-26 21:23:45 +0000396/**
Benny Prijono312aff92006-06-17 04:08:30 +0000397 * Maximum proxies in account.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000398 */
Benny Prijono312aff92006-06-17 04:08:30 +0000399#ifndef PJSUA_ACC_MAX_PROXIES
400# define PJSUA_ACC_MAX_PROXIES 8
401#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000402
403
404
405/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000406 * Logging configuration, which can be (optionally) specified when calling
407 * #pjsua_init(). Application must call #pjsua_logging_config_default() to
408 * initialize this structure with the default values.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000409 *
410 * \par Sample Python Syntax:
411 * \code
412 # Python type: py_pjsua.Logging_Config
413
414 log_cfg = py_pjsua.logging_config_default()
415 log_cfg.level = 4
416 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000417 */
418typedef struct pjsua_logging_config
419{
420 /**
421 * Log incoming and outgoing SIP message? Yes!
422 */
423 pj_bool_t msg_logging;
424
425 /**
426 * Input verbosity level. Value 5 is reasonable.
427 */
428 unsigned level;
429
430 /**
431 * Verbosity level for console. Value 4 is reasonable.
432 */
433 unsigned console_level;
434
435 /**
436 * Log decoration.
437 */
438 unsigned decor;
439
440 /**
441 * Optional log filename.
442 */
443 pj_str_t log_filename;
444
445 /**
446 * Optional callback function to be called to write log to
447 * application specific device. This function will be called for
448 * log messages on input verbosity level.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000449 *
450 * \par Sample Python Syntax:
451 * \code
452 # level: integer
453 # data: string
454 # len: integer
455
456 def cb(level, data, len):
457 print data,
458 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000459 */
460 void (*cb)(int level, const char *data, pj_size_t len);
461
462
463} pjsua_logging_config;
464
465
466/**
467 * Use this function to initialize logging config.
468 *
469 * @param cfg The logging config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000470 *
471 * \par Python Syntax:
472 * The Python function instantiates and initialize the logging config:
473 * \code
474 logging_cfg = py_pjsua.logging_config_default()
475 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000476 */
477PJ_INLINE(void) pjsua_logging_config_default(pjsua_logging_config *cfg)
478{
Benny Prijonoac623b32006-07-03 15:19:31 +0000479 pj_bzero(cfg, sizeof(*cfg));
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000480
481 cfg->msg_logging = PJ_TRUE;
482 cfg->level = 5;
483 cfg->console_level = 4;
484 cfg->decor = PJ_LOG_HAS_SENDER | PJ_LOG_HAS_TIME |
485 PJ_LOG_HAS_MICRO_SEC | PJ_LOG_HAS_NEWLINE;
486}
487
488/**
489 * Use this function to duplicate logging config.
490 *
491 * @param pool Pool to use.
492 * @param dst Destination config.
493 * @param src Source config.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000494 *
495 * \par Python Syntax:
496 * Not available (for now). Ideally we should be able to just assign
497 * one config to another, but this has not been tested.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000498 */
499PJ_INLINE(void) pjsua_logging_config_dup(pj_pool_t *pool,
500 pjsua_logging_config *dst,
501 const pjsua_logging_config *src)
502{
503 pj_memcpy(dst, src, sizeof(*src));
504 pj_strdup_with_null(pool, &dst->log_filename, &src->log_filename);
505}
506
507
Benny Prijonodc39fe82006-05-26 12:17:46 +0000508
509/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000510 * This structure describes application callback to receive various event
511 * notification from PJSUA-API. All of these callbacks are OPTIONAL,
512 * although definitely application would want to implement some of
513 * the important callbacks (such as \a on_incoming_call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000514 *
515 * \par Python Syntax:
516 * This callback structure is embedded on pjsua_config structure.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000517 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000518typedef struct pjsua_callback
Benny Prijonodc39fe82006-05-26 12:17:46 +0000519{
520 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000521 * Notify application when invite state has changed.
522 * Application may then query the call info to get the
Benny Prijonoe6ead542007-01-31 20:53:31 +0000523 * detail call states by calling pjsua_call_get_info() function.
Benny Prijono0875ae82006-12-26 00:11:48 +0000524 *
525 * @param call_id The call index.
526 * @param e Event which causes the call state to change.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000527 *
528 * \par Python Syntax:
529 * \code
530 # call_id: integer
531 # e: an opaque object
532
533 def on_call_state(call_id, e):
534 return
535 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000536 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000537 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000538
539 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000540 * Notify application on incoming call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000541 *
542 * @param acc_id The account which match the incoming call.
543 * @param call_id The call id that has just been created for
544 * the call.
545 * @param rdata The incoming INVITE request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000546 *
547 * \par Python Syntax:
548 * \code
549 # acc_id: integer
550 # call_id: integer
551 # rdata: an opaque object
552
553 def on_incoming_call(acc_id, call_id, rdata):
554 return
555 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +0000556 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000557 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000558 pjsip_rx_data *rdata);
559
560 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000561 * Notify application when media state in the call has changed.
562 * Normal application would need to implement this callback, e.g.
563 * to connect the call's media to sound device.
Benny Prijono0875ae82006-12-26 00:11:48 +0000564 *
565 * @param call_id The call index.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000566 *
567 * \par Python Syntax:
568 * \code
569 # call_id: integer
570
571 def on_call_media_state(call_id):
572 return
573 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000574 */
575 void (*on_call_media_state)(pjsua_call_id call_id);
576
577 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000578 * Notify application upon incoming DTMF digits.
579 *
580 * @param call_id The call index.
581 * @param digit DTMF ASCII digit.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000582 *
583 * \par Python Syntax:
584 * \code
585 # call_id: integer
586 # digit: integer
587
588 def on_dtmf_digit(call_id, digit):
589 return
590 * \endcode
Benny Prijono0875ae82006-12-26 00:11:48 +0000591 */
592 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
593
594 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000595 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000596 * Application can decide to accept/reject transfer request
597 * by setting the code (default is 200). When this callback
598 * is not defined, the default behavior is to accept the
599 * transfer.
Benny Prijono0875ae82006-12-26 00:11:48 +0000600 *
601 * @param call_id The call index.
602 * @param dst The destination where the call will be
603 * transfered to.
604 * @param code Status code to be returned for the call transfer
605 * request. On input, it contains status code 200.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000606 *
607 * \par Python Syntax:
608 * \code
609 # call_id: integer
610 # dst: string
611 # code: integer
612
613 def on_call_transfer_request(call_id, dst, code):
614 return code
615
616 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000617 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000618 void (*on_call_transfer_request)(pjsua_call_id call_id,
619 const pj_str_t *dst,
620 pjsip_status_code *code);
621
622 /**
623 * Notify application of the status of previously sent call
624 * transfer request. Application can monitor the status of the
625 * call transfer request, for example to decide whether to
626 * terminate existing call.
627 *
628 * @param call_id Call ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000629 * @param st_code Status progress of the transfer request.
630 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000631 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000632 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000633 * this callback is the final status.
634 * @param p_cont Initially will be set to non-zero, application
635 * can set this to FALSE if it no longer wants
636 * to receie further notification (for example,
637 * after it hangs up the call).
Benny Prijonoe6ead542007-01-31 20:53:31 +0000638 *
639 * \par Python Syntax:
640 * \code
641 # call_id: integer
642 # st_code: integer
643 # st_text: string
644 # final: integer
645 # cont: integer
646
647 # return: cont
648
649 def on_call_transfer_status(call_id, st_code, st_text, final, cont):
650 return cont
651 * \endcode
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000652 */
653 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000654 int st_code,
655 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000656 pj_bool_t final,
657 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000658
659 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000660 * Notify application about incoming INVITE with Replaces header.
661 * Application may reject the request by setting non-2xx code.
662 *
663 * @param call_id The call ID to be replaced.
664 * @param rdata The incoming INVITE request to replace the call.
665 * @param st_code Status code to be set by application. Application
666 * should only return a final status (200-699).
667 * @param st_text Optional status text to be set by application.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000668 *
669 * \par Python Syntax:
670 * \code
671 # call_id: integer
672 # rdata: an opaque object
673 # st_code: integer
674 # st_text: string
675
676 # return: (st_code, st_text) tuple
677
678 def on_call_replace_request(call_id, rdata, st_code, st_text):
679 return st_code, st_text
680 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000681 */
682 void (*on_call_replace_request)(pjsua_call_id call_id,
683 pjsip_rx_data *rdata,
684 int *st_code,
685 pj_str_t *st_text);
686
687 /**
688 * Notify application that an existing call has been replaced with
689 * a new call. This happens when PJSUA-API receives incoming INVITE
690 * request with Replaces header.
691 *
692 * After this callback is called, normally PJSUA-API will disconnect
693 * \a old_call_id and establish \a new_call_id.
694 *
695 * @param old_call_id Existing call which to be replaced with the
696 * new call.
697 * @param new_call_id The new call.
698 * @param rdata The incoming INVITE with Replaces request.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000699 *
700 * \par Python Syntax:
701 * \code
702 # old_call_id: integer
703 # new_call_id: integer
704
705 def on_call_replaced(old_call_id, new_call_id):
706 return
707 * \endcode
Benny Prijono053f5222006-11-11 16:16:04 +0000708 */
709 void (*on_call_replaced)(pjsua_call_id old_call_id,
710 pjsua_call_id new_call_id);
711
712
713 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000714 * Notify application when registration status has changed.
715 * Application may then query the account info to get the
716 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000717 *
718 * @param acc_id Account ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000719 *
720 * \par Python Syntax:
721 * \code
722 # acc_id: account ID (integer)
723
724 def on_reg_state(acc_id):
725 return
726 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000727 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000728 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000729
730 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000731 * Notify application when the buddy state has changed.
732 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000733 *
734 * @param buddy_id The buddy id.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000735 *
736 * \par Python Syntax:
737 * \code
738 # buddy_id: integer
739
740 def on_buddy_state(buddy_id):
741 return
742 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +0000743 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000744 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000745
746 /**
747 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000748 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000749 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000750 *
Benny Prijonobbeb3992007-05-21 13:48:35 +0000751 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
752 * passed as one of the argument.
753 *
Benny Prijono0875ae82006-12-26 00:11:48 +0000754 * @param call_id Containts the ID of the call where the IM was
755 * sent, or PJSUA_INVALID_ID if the IM was sent
756 * outside call context.
757 * @param from URI of the sender.
758 * @param to URI of the destination message.
759 * @param contact The Contact URI of the sender, if present.
760 * @param mime_type MIME type of the message.
761 * @param body The message content.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000762 *
763 * \par Python Syntax:
764 * \code
765 # call_id: integer
766 # from: string
767 # to: string
768 # contact: string
769 # mime_type: string
770 # body: string
771
772 def on_pager(call_id, from, to, contact, mime_type, body):
773 return
774 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000775 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000776 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
777 const pj_str_t *to, const pj_str_t *contact,
778 const pj_str_t *mime_type, const pj_str_t *body);
779
780 /**
Benny Prijonobbeb3992007-05-21 13:48:35 +0000781 * This is the alternative version of the \a on_pager() callback with
782 * \a pjsip_rx_data argument.
783 *
784 * @param call_id Containts the ID of the call where the IM was
785 * sent, or PJSUA_INVALID_ID if the IM was sent
786 * outside call context.
787 * @param from URI of the sender.
788 * @param to URI of the destination message.
789 * @param contact The Contact URI of the sender, if present.
790 * @param mime_type MIME type of the message.
791 * @param body The message content.
792 * @param rdata The incoming MESSAGE request.
793 */
794 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
795 const pj_str_t *to, const pj_str_t *contact,
796 const pj_str_t *mime_type, const pj_str_t *body,
797 pjsip_rx_data *rdata);
798
799 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000800 * Notify application about the delivery status of outgoing pager
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000801 * request. See also on_pager_status2() callback for the version with
802 * \a pjsip_rx_data in the argument list.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000803 *
804 * @param call_id Containts the ID of the call where the IM was
805 * sent, or PJSUA_INVALID_ID if the IM was sent
806 * outside call context.
807 * @param to Destination URI.
808 * @param body Message body.
809 * @param user_data Arbitrary data that was specified when sending
810 * IM message.
811 * @param status Delivery status.
812 * @param reason Delivery status reason.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000813 *
814 * \par Python Syntax
815 * \code
816 # call_id: integer
817 # to: string
818 # body: string
819 # user_data: string
820 # status: integer
821 # reason: string
822
823 def on_pager_status(call_id, to, body, user_data, status, reason):
824 return
825 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000826 */
827 void (*on_pager_status)(pjsua_call_id call_id,
828 const pj_str_t *to,
829 const pj_str_t *body,
830 void *user_data,
831 pjsip_status_code status,
832 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000833
834 /**
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000835 * Notify application about the delivery status of outgoing pager
836 * request.
837 *
838 * @param call_id Containts the ID of the call where the IM was
839 * sent, or PJSUA_INVALID_ID if the IM was sent
840 * outside call context.
841 * @param to Destination URI.
842 * @param body Message body.
843 * @param user_data Arbitrary data that was specified when sending
844 * IM message.
845 * @param status Delivery status.
846 * @param reason Delivery status reason.
Benny Prijono0a982002007-06-12 16:22:09 +0000847 * @param tdata The original MESSAGE request.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000848 * @param rdata The incoming MESSAGE response, or NULL if the
849 * message transaction fails because of time out
850 * or transport error.
851 */
852 void (*on_pager_status2)(pjsua_call_id call_id,
853 const pj_str_t *to,
854 const pj_str_t *body,
855 void *user_data,
856 pjsip_status_code status,
857 const pj_str_t *reason,
Benny Prijono0a982002007-06-12 16:22:09 +0000858 pjsip_tx_data *tdata,
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000859 pjsip_rx_data *rdata);
860
861 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000862 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +0000863 *
864 * @param call_id Containts the ID of the call where the IM was
865 * sent, or PJSUA_INVALID_ID if the IM was sent
866 * outside call context.
867 * @param from URI of the sender.
868 * @param to URI of the destination message.
869 * @param contact The Contact URI of the sender, if present.
870 * @param is_typing Non-zero if peer is typing, or zero if peer
871 * has stopped typing a message.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000872 *
873 * \par Python Syntax
874 * \code
875 # call_id: string
876 # from: string
877 # to: string
878 # contact: string
879 # is_typing: integer
880
881 def on_typing(call_id, from, to, contact, is_typing):
882 return
883 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000884 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000885 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
886 const pj_str_t *to, const pj_str_t *contact,
887 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000888
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000889} pjsua_callback;
890
891
892
Benny Prijonodc39fe82006-05-26 12:17:46 +0000893
894/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000895 * This structure describes the settings to control the API and
896 * user agent behavior, and can be specified when calling #pjsua_init().
897 * Before setting the values, application must call #pjsua_config_default()
898 * to initialize this structure with the default values.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000899 *
900 * \par Python Sample Syntax:
901 * The pjsua_config type in Python is <tt>py_pjsua.Config</tt>. Application
902 * creates the instance by calling <tt>py_pjsua.config_default()</tt>:
903 * \code
904 cfg = py_pjsua.config_default()
905 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +0000906 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000907typedef struct pjsua_config
908{
909
910 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000911 * Maximum calls to support (default: 4). The value specified here
912 * must be smaller than the compile time maximum settings
913 * PJSUA_MAX_CALLS, which by default is 32. To increase this
914 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
915 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000916 */
917 unsigned max_calls;
918
919 /**
920 * Number of worker threads. Normally application will want to have at
921 * least one worker thread, unless when it wants to poll the library
922 * periodically, which in this case the worker thread can be set to
923 * zero.
924 */
925 unsigned thread_cnt;
926
927 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +0000928 * Number of nameservers. If no name server is configured, the SIP SRV
929 * resolution would be disabled, and domain will be resolved with
930 * standard pj_gethostbyname() function.
931 */
932 unsigned nameserver_count;
933
934 /**
935 * Array of nameservers to be used by the SIP resolver subsystem.
936 * The order of the name server specifies the priority (first name
937 * server will be used first, unless it is not reachable).
938 */
939 pj_str_t nameserver[4];
940
941 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000942 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000943 */
944 unsigned outbound_proxy_cnt;
945
946 /**
947 * Specify the URL of outbound proxies to visit for all outgoing requests.
948 * The outbound proxies will be used for all accounts, and it will
949 * be used to build the route set for outgoing requests. The final
950 * route set for outgoing requests will consists of the outbound proxies
951 * and the proxy configured in the account.
952 */
953 pj_str_t outbound_proxy[4];
954
Benny Prijonoc97608e2007-03-23 16:34:20 +0000955 /**
Benny Prijonoebbf6892007-03-24 17:37:25 +0000956 * Specify domain name to be resolved with DNS SRV resolution to get the
957 * address of the STUN servers. Alternatively application may specify
958 * \a stun_host and \a stun_relay_host instead.
959 *
960 * If DNS SRV resolution failed for this domain, then DNS A resolution
961 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +0000962 */
Benny Prijonoebbf6892007-03-24 17:37:25 +0000963 pj_str_t stun_domain;
964
965 /**
Benny Prijonoaf09dc32007-04-22 12:48:30 +0000966 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
967 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +0000968 */
969 pj_str_t stun_host;
970
971 /**
972 * Specify STUN relay server to be used.
973 */
974 pj_str_t stun_relay_host;
Benny Prijonoc97608e2007-03-23 16:34:20 +0000975
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000976 /**
977 * Number of credentials in the credential array.
978 */
979 unsigned cred_count;
980
981 /**
982 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +0000983 * and can be used to authenticate against outbound proxies. If the
984 * credential is specific to the account, then application should set
985 * the credential in the pjsua_acc_config rather than the credential
986 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000987 */
988 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
989
990 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000991 * Application callback to receive various event notifications from
992 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000993 */
994 pjsua_callback cb;
995
Benny Prijono56315612006-07-18 14:39:40 +0000996 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000997 * Optional user agent string (default empty). If it's empty, no
998 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +0000999 */
1000 pj_str_t user_agent;
1001
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001002} pjsua_config;
1003
1004
1005/**
1006 * Use this function to initialize pjsua config.
1007 *
1008 * @param cfg pjsua config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001009 *
1010 * \par Python Sample Syntax:
1011 * The corresponding Python function creates an instance of the config and
1012 * initializes it to the default settings:
1013 * \code
1014 cfg = py_pjsua.config_default()
1015 * \endcode
1016
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001017 */
1018PJ_INLINE(void) pjsua_config_default(pjsua_config *cfg)
1019{
Benny Prijonoac623b32006-07-03 15:19:31 +00001020 pj_bzero(cfg, sizeof(*cfg));
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001021
1022 cfg->max_calls = 4;
1023 cfg->thread_cnt = 1;
1024}
1025
1026
1027/**
1028 * Duplicate credential.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001029 *
1030 * @param pool The memory pool.
1031 * @param dst Destination credential.
1032 * @param src Source credential.
1033 *
1034 * \par Python:
1035 * Not applicable (for now). Probably we could just assign one credential
1036 * variable to another, but this has not been tested.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001037 */
1038PJ_INLINE(void) pjsip_cred_dup( pj_pool_t *pool,
1039 pjsip_cred_info *dst,
1040 const pjsip_cred_info *src)
1041{
1042 pj_strdup_with_null(pool, &dst->realm, &src->realm);
1043 pj_strdup_with_null(pool, &dst->scheme, &src->scheme);
1044 pj_strdup_with_null(pool, &dst->username, &src->username);
1045 pj_strdup_with_null(pool, &dst->data, &src->data);
1046
1047}
1048
1049
1050/**
1051 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001052 *
1053 * @param pool The pool to get memory from.
1054 * @param dst Destination config.
1055 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001056 */
1057PJ_INLINE(void) pjsua_config_dup(pj_pool_t *pool,
1058 pjsua_config *dst,
1059 const pjsua_config *src)
1060{
1061 unsigned i;
1062
1063 pj_memcpy(dst, src, sizeof(*src));
1064
1065 for (i=0; i<src->outbound_proxy_cnt; ++i) {
1066 pj_strdup_with_null(pool, &dst->outbound_proxy[i],
1067 &src->outbound_proxy[i]);
1068 }
1069
1070 for (i=0; i<src->cred_count; ++i) {
1071 pjsip_cred_dup(pool, &dst->cred_info[i], &src->cred_info[i]);
1072 }
Benny Prijono56315612006-07-18 14:39:40 +00001073
1074 pj_strdup_with_null(pool, &dst->user_agent, &src->user_agent);
Benny Prijonoebbf6892007-03-24 17:37:25 +00001075 pj_strdup_with_null(pool, &dst->stun_domain, &src->stun_domain);
1076 pj_strdup_with_null(pool, &dst->stun_host, &src->stun_host);
1077 pj_strdup_with_null(pool, &dst->stun_relay_host, &src->stun_relay_host);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001078}
1079
1080
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001081
1082/**
1083 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001084 * outgoing SIP message. It can (optionally) be specified for example
1085 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1086 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1087 *
1088 * Application MUST call #pjsua_msg_data_init() to initialize this
1089 * structure before setting its values.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001090 *
1091 * \par Python Syntax
1092 * The data type in Python is <tt>py_pjsua.Msg_Data</tt>. Application is
1093 * recommended to instantiate the structure by using this construct:
1094 * \code
1095 msg_data = py_pjsua.msg_data_init()
1096 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001097 */
1098typedef struct pjsua_msg_data
1099{
1100 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001101 * Additional message headers as linked list. Application can add
1102 * headers to the list by creating the header, either from the heap/pool
1103 * or from temporary local variable, and add the header using
1104 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001105 *
1106 * \par Python:
1107 * This field is implemented as string linked-list in Python, where each
1108 * string describes the header. For example:
1109 \code
1110 msg_data = py_pjsua.Msg_Data()
1111 msg_data.hdr_list = ["Subject: Hello py_pjsua!", "Priority: very low"]
1112 \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001113 */
1114 pjsip_hdr hdr_list;
1115
1116 /**
1117 * MIME type of optional message body.
1118 */
1119 pj_str_t content_type;
1120
1121 /**
1122 * Optional message body.
1123 */
1124 pj_str_t msg_body;
1125
1126} pjsua_msg_data;
1127
1128
1129/**
1130 * Initialize message data.
1131 *
1132 * @param msg_data Message data to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001133 *
1134 * \par Python
1135 * The corresponding Python function creates and initializes the structure:
1136 * \code
1137 msg_data = py_pjsua.msg_data_init()
1138 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001139 */
1140PJ_INLINE(void) pjsua_msg_data_init(pjsua_msg_data *msg_data)
1141{
Benny Prijonoac623b32006-07-03 15:19:31 +00001142 pj_bzero(msg_data, sizeof(*msg_data));
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001143 pj_list_init(&msg_data->hdr_list);
1144}
Benny Prijono8b1889b2006-06-06 18:40:40 +00001145
Benny Prijono268ca612006-02-07 12:34:11 +00001146
Benny Prijono268ca612006-02-07 12:34:11 +00001147
1148/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001149 * Instantiate pjsua application. Application must call this function before
1150 * calling any other functions, to make sure that the underlying libraries
1151 * are properly initialized. Once this function has returned success,
1152 * application must call pjsua_destroy() before quitting.
1153 *
1154 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001155 *
1156 * \par Python:
1157 * \code
1158 status = py_pjsua.create()
1159 * \endcode
Benny Prijonodc39fe82006-05-26 12:17:46 +00001160 */
1161PJ_DECL(pj_status_t) pjsua_create(void);
1162
1163
Benny Prijonoe6ead542007-01-31 20:53:31 +00001164/* Forward declaration */
1165typedef struct pjsua_media_config pjsua_media_config;
1166
1167
Benny Prijonodc39fe82006-05-26 12:17:46 +00001168/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001169 * Initialize pjsua with the specified settings. All the settings are
1170 * optional, and the default values will be used when the config is not
1171 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001172 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001173 * Note that #pjsua_create() MUST be called before calling this function.
1174 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001175 * @param ua_cfg User agent configuration.
1176 * @param log_cfg Optional logging configuration.
1177 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001178 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001179 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001180 *
1181 * \par Python:
1182 * The function is similar in Python:
1183 * \code
1184 status = py_pjsua.init(ua_cfg, log_cfg, media_cfg)
1185 * \endcode
1186 * Note that \a ua_cfg, \a log_cfg, and \a media_cfg are optional, and
1187 * the Python script may pass None if it doesn't want to configure the
1188 * setting.
Benny Prijono268ca612006-02-07 12:34:11 +00001189 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001190PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1191 const pjsua_logging_config *log_cfg,
1192 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001193
1194
1195/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001196 * Application is recommended to call this function after all initialization
1197 * is done, so that the library can do additional checking set up
1198 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001199 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001200 * Application may call this function anytime after #pjsua_init().
1201 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001202 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001203 *
1204 * \par Python:
1205 * The function is similar in Python:
1206 * \code
1207 status = py_pjsua.start()
1208 * \endcode
Benny Prijonoccf95622006-02-07 18:48:01 +00001209 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001210PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001211
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001212
Benny Prijonoccf95622006-02-07 18:48:01 +00001213/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001214 * Destroy pjsua. Application is recommended to perform graceful shutdown
1215 * before calling this function (such as unregister the account from the SIP
1216 * server, terminate presense subscription, and hangup active calls), however,
1217 * this function will do all of these if it finds there are active sessions
1218 * that need to be terminated. This function will approximately block for
1219 * one second to wait for replies from remote.
1220 *
1221 * Application.may safely call this function more than once if it doesn't
1222 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001223 *
1224 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001225 *
1226 * \par Python:
1227 * The function is similar in Python:
1228 * \code
1229 status = py_pjsua.destroy()
1230 * \endcode
Benny Prijono268ca612006-02-07 12:34:11 +00001231 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001232PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001233
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001234
Benny Prijono9fc735d2006-05-28 14:58:12 +00001235/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001236 * Poll pjsua for events, and if necessary block the caller thread for
1237 * the specified maximum interval (in miliseconds).
1238 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001239 * Application doesn't normally need to call this function if it has
1240 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1241 * because polling then will be done by these worker threads instead.
1242 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001243 * @param msec_timeout Maximum time to wait, in miliseconds.
1244 *
1245 * @return The number of events that have been handled during the
1246 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001247 * can retrieve the error as (status = -return_value).
1248 *
1249 * \par Python:
1250 * The function is similar in Python:
1251 * \code
1252 n = py_pjsua.handle_events(msec_timeout)
1253 * \endcode
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001254 */
1255PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1256
1257
1258/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001259 * Create memory pool to be used by the application. Once application
1260 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001261 *
1262 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001263 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001264 * @param increment Increment size.
1265 *
1266 * @return The pool, or NULL when there's no memory.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001267 *
1268 * \par Python:
1269 * Python script may also create a pool object from the script:
1270 * \code
1271 pool = py_pjsua.pool_create(name, init_size, increment)
1272 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001273 */
1274PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1275 pj_size_t increment);
1276
1277
1278/**
1279 * Application can call this function at any time (after pjsua_create(), of
1280 * course) to change logging settings.
1281 *
1282 * @param c Logging configuration.
1283 *
1284 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001285 *
1286 * \par Python:
1287 * The function is similar in Python:
1288 * \code
1289 status = py_pjsua.reconfigure_logging(log_cfg)
1290 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001291 */
1292PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1293
1294
1295/**
1296 * Internal function to get SIP endpoint instance of pjsua, which is
1297 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001298 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001299 *
1300 * @return SIP endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001301 *
1302 * \par Python:
1303 * Application may retrieve the SIP endpoint instance:
1304 * \code
1305 endpt = py_pjsua.get_pjsip_endpt()
1306 * \endcode
1307 * However currently the object is just an opaque object and does not have
1308 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001309 */
1310PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1311
1312/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001313 * Internal function to get media endpoint instance.
1314 * Only valid after #pjsua_init() is called.
1315 *
1316 * @return Media endpoint instance.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001317 *
1318 * \par Python:
1319 * Application may retrieve the media endpoint instance:
1320 * \code
1321 endpt = py_pjsua.get_pjmedia_endpt()
1322 * \endcode
1323 * However currently the object is just an opaque object and does not have
1324 * any use for Python scripts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001325 */
1326PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1327
Benny Prijono97b87172006-08-24 14:25:14 +00001328/**
1329 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001330 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001331 *
1332 * @return Pool factory currently used by PJSUA.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001333 *
1334 * \par Python:
1335 * Application may retrieve the pool factory instance:
1336 * \code
1337 endpt = py_pjsua.get_pool_factory()
1338 * \endcode
1339 * However currently the object is just an opaque object and does not have
1340 * any use for Python scripts.
Benny Prijono97b87172006-08-24 14:25:14 +00001341 */
1342PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1343
1344
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001345
1346/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001347 * Utilities.
1348 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001349 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001350
1351/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001352 * This is a utility function to verify that valid SIP url is given. If the
1353 * URL is valid, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001354 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001355 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001356 *
1357 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001358 *
1359 * \par Python:
1360 * \code
1361 status = py_pjsua.verify_sip_url(url)
1362 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001363 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001364PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001365
1366
1367/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001368 * This is a utility function to display error message for the specified
1369 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001370 *
1371 * @param sender The log sender field.
1372 * @param title Message title for the error.
1373 * @param status Status code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001374 *
1375 * \par Python:
1376 * \code
1377 py_pjsua.perror(sender, title, status)
1378 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001379 */
1380PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1381 pj_status_t status);
1382
1383
Benny Prijonoda9785b2007-04-02 20:43:06 +00001384/**
1385 * This is a utility function to dump the stack states to log, using
1386 * verbosity level 3.
1387 *
1388 * @param detail Will print detailed output (such as list of
1389 * SIP transactions) when non-zero.
1390 */
1391PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001392
1393/**
1394 * @}
1395 */
1396
1397
1398
1399/*****************************************************************************
1400 * TRANSPORT API
1401 */
1402
1403/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001404 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001405 * @ingroup PJSUA_LIB
1406 * @brief API for managing SIP transports
1407 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001408 *
1409 * PJSUA-API supports creating multiple transport instances, for example UDP,
1410 * TCP, and TLS transport. SIP transport must be created before adding an
1411 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001412 */
1413
1414
Benny Prijonoe6ead542007-01-31 20:53:31 +00001415/** SIP transport identification.
1416 */
Benny Prijono312aff92006-06-17 04:08:30 +00001417typedef int pjsua_transport_id;
1418
1419
1420/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001421 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001422 * and media. Before setting some values to this structure, application
1423 * MUST call #pjsua_transport_config_default() to initialize its
1424 * values with default settings.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001425 *
1426 * \par Python:
1427 * The data type in Python is <tt>py_pjsua.Transport_Config</tt>,
1428 * although application can just do this to create the instance:
1429 * \code
1430 transport_cfg = py_pjsua.transport_config_default()
1431 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001432 */
1433typedef struct pjsua_transport_config
1434{
1435 /**
1436 * UDP port number to bind locally. This setting MUST be specified
1437 * even when default port is desired. If the value is zero, the
1438 * transport will be bound to any available port, and application
1439 * can query the port by querying the transport info.
1440 */
1441 unsigned port;
1442
1443 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001444 * Optional address to advertise as the address of this transport.
1445 * Application can specify any address or hostname for this field,
1446 * for example it can point to one of the interface address in the
1447 * system, or it can point to the public address of a NAT router
1448 * where port mappings have been configured for the application.
1449 *
1450 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001451 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001452 pj_str_t public_addr;
1453
1454 /**
1455 * Optional address where the socket should be bound to. This option
1456 * SHOULD only be used to selectively bind the socket to particular
1457 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1458 * published address of a transport (the public_addr field should be
1459 * used for that purpose).
1460 *
1461 * Note that unlike public_addr field, the address (or hostname) here
1462 * MUST correspond to the actual interface address in the host, since
1463 * this address will be specified as bind() argument.
1464 */
1465 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001466
1467 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001468 * This specifies TLS settings for TLS transport. It is only be used
1469 * when this transport config is being used to create a SIP TLS
1470 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001471 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001472 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001473
Benny Prijono312aff92006-06-17 04:08:30 +00001474} pjsua_transport_config;
1475
1476
1477/**
1478 * Call this function to initialize UDP config with default values.
1479 *
1480 * @param cfg The UDP config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001481 *
1482 * \par Python:
1483 * The corresponding Python function is rather different:
1484 * \code
1485 transport_cfg = py_pjsua.transport_config_default()
1486 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001487 */
1488PJ_INLINE(void) pjsua_transport_config_default(pjsua_transport_config *cfg)
1489{
Benny Prijonoac623b32006-07-03 15:19:31 +00001490 pj_bzero(cfg, sizeof(*cfg));
Benny Prijonof3bbc132006-12-25 06:43:59 +00001491 pjsip_tls_setting_default(&cfg->tls_setting);
Benny Prijono312aff92006-06-17 04:08:30 +00001492}
1493
1494
1495/**
Benny Prijono312aff92006-06-17 04:08:30 +00001496 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001497 *
1498 * @param pool The pool.
1499 * @param dst The destination config.
1500 * @param src The source config.
1501 *
1502 * \par Python:
1503 * Not applicable. One should be able to just copy one variable instance
1504 * to another in Python.
Benny Prijono312aff92006-06-17 04:08:30 +00001505 */
1506PJ_INLINE(void) pjsua_transport_config_dup(pj_pool_t *pool,
1507 pjsua_transport_config *dst,
1508 const pjsua_transport_config *src)
1509{
Benny Prijonoc97608e2007-03-23 16:34:20 +00001510 PJ_UNUSED_ARG(pool);
Benny Prijono312aff92006-06-17 04:08:30 +00001511 pj_memcpy(dst, src, sizeof(*src));
Benny Prijono312aff92006-06-17 04:08:30 +00001512}
1513
1514
1515
1516/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001517 * This structure describes transport information returned by
1518 * #pjsua_transport_get_info() function.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001519 *
1520 * \par Python:
1521 * The corresponding data type in Python is <tt>py_pjsua.Transport_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001522 */
1523typedef struct pjsua_transport_info
1524{
1525 /**
1526 * PJSUA transport identification.
1527 */
1528 pjsua_transport_id id;
1529
1530 /**
1531 * Transport type.
1532 */
1533 pjsip_transport_type_e type;
1534
1535 /**
1536 * Transport type name.
1537 */
1538 pj_str_t type_name;
1539
1540 /**
1541 * Transport string info/description.
1542 */
1543 pj_str_t info;
1544
1545 /**
1546 * Transport flag (see ##pjsip_transport_flags_e).
1547 */
1548 unsigned flag;
1549
1550 /**
1551 * Local address length.
1552 */
1553 unsigned addr_len;
1554
1555 /**
1556 * Local/bound address.
1557 */
1558 pj_sockaddr local_addr;
1559
1560 /**
1561 * Published address (or transport address name).
1562 */
1563 pjsip_host_port local_name;
1564
1565 /**
1566 * Current number of objects currently referencing this transport.
1567 */
1568 unsigned usage_count;
1569
1570
1571} pjsua_transport_info;
1572
1573
1574/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001575 * Create and start a new SIP transport according to the specified
1576 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001577 *
1578 * @param type Transport type.
1579 * @param cfg Transport configuration.
1580 * @param p_id Optional pointer to receive transport ID.
1581 *
1582 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001583 *
1584 * \par Python:
1585 * The corresponding Python function returns (status,id) tuple:
1586 * \code
1587 status, transport_id = py_pjsua.transport_create(type, cfg)
1588 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001589 */
1590PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1591 const pjsua_transport_config *cfg,
1592 pjsua_transport_id *p_id);
1593
1594/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001595 * Register transport that has been created by application. This function
1596 * is useful if application wants to implement custom SIP transport and use
1597 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001598 *
1599 * @param tp Transport instance.
1600 * @param p_id Optional pointer to receive transport ID.
1601 *
1602 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001603 *
1604 * \par Python:
1605 * Not applicable (for now), because one cannot create a custom transport
1606 * from Python script.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001607 */
1608PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1609 pjsua_transport_id *p_id);
1610
1611
1612/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001613 * Enumerate all transports currently created in the system. This function
1614 * will return all transport IDs, and application may then call
1615 * #pjsua_transport_get_info() function to retrieve detailed information
1616 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001617 *
1618 * @param id Array to receive transport ids.
1619 * @param count In input, specifies the maximum number of elements.
1620 * On return, it contains the actual number of elements.
1621 *
1622 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001623 *
1624 * \par Python:
1625 * The function returns list of integers representing transport ids:
1626 * \code
1627 [int] = py_pjsua.enum_transports()
1628 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001629 */
1630PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1631 unsigned *count );
1632
1633
1634/**
1635 * Get information about transports.
1636 *
1637 * @param id Transport ID.
1638 * @param info Pointer to receive transport info.
1639 *
1640 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001641 *
1642 * \par Python:
1643 * \code
1644 transport_info = py_pjsua.transport_get_info(id)
1645 * \endcode
1646 * The Python function returns None on error.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001647 */
1648PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1649 pjsua_transport_info *info);
1650
1651
1652/**
1653 * Disable a transport or re-enable it. By default transport is always
1654 * enabled after it is created. Disabling a transport does not necessarily
1655 * close the socket, it will only discard incoming messages and prevent
1656 * the transport from being used to send outgoing messages.
1657 *
1658 * @param id Transport ID.
1659 * @param enabled Non-zero to enable, zero to disable.
1660 *
1661 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001662 *
1663 * \par Python:
1664 * \code
1665 status = py_pjsua.transport_set_enable(id, enabled)
1666 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001667 */
1668PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1669 pj_bool_t enabled);
1670
1671
1672/**
1673 * Close the transport. If transport is forcefully closed, it will be
1674 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00001675 * transport may not terminate properly (it may even crash). Otherwise,
1676 * the system will wait until all transactions are closed while preventing
1677 * new users from using the transport, and will close the transport when
1678 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001679 *
1680 * @param id Transport ID.
1681 * @param force Non-zero to immediately close the transport. This
1682 * is not recommended!
1683 *
1684 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001685 *
1686 * \par Python:
1687 * \code
1688 status = py_pjsua.transport_close(id, force)
1689 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001690 */
1691PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1692 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001693
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001694/**
Benny Prijono312aff92006-06-17 04:08:30 +00001695 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001696 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001697
1698
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001699
1700
1701/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001702 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001703 */
1704
Benny Prijono312aff92006-06-17 04:08:30 +00001705
1706/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001707 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001708 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001709 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001710 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001711 *
Benny Prijono312aff92006-06-17 04:08:30 +00001712 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001713 * using the application. In SIP terms, the identity is used as the <b>From</b>
1714 * header in outgoing requests.
1715 *
1716 * PJSUA-API supports creating and managing multiple accounts. The maximum
1717 * number of accounts is limited by a compile time constant
1718 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001719 *
1720 * Account may or may not have client registration associated with it.
1721 * An account is also associated with <b>route set</b> and some <b>authentication
1722 * credentials</b>, which are used when sending SIP request messages using the
1723 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00001724 * will be reported to remote peer when they subscribe to the account's
1725 * presence, or which is published to a presence server if presence
1726 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00001727 *
1728 * At least one account MUST be created in the application. If no user
1729 * association is required, application can create a userless account by
1730 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00001731 * instead of a particular user, and it correspond with a particular
1732 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00001733 *
1734 * Also one account must be set as the <b>default account</b>, which is used as
1735 * the account to use when PJSUA fails to match a request with any other
1736 * accounts.
1737 *
1738 * When sending outgoing SIP requests (such as making calls or sending
1739 * instant messages), normally PJSUA requires the application to specify
1740 * which account to use for the request. If no account is specified,
1741 * PJSUA may be able to select the account by matching the destination
1742 * domain name, and fall back to default account when no match is found.
1743 */
1744
1745/**
1746 * Maximum accounts.
1747 */
1748#ifndef PJSUA_MAX_ACC
1749# define PJSUA_MAX_ACC 8
1750#endif
1751
1752
1753/**
1754 * Default registration interval.
1755 */
1756#ifndef PJSUA_REG_INTERVAL
1757# define PJSUA_REG_INTERVAL 55
1758#endif
1759
1760
1761/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001762 * Default PUBLISH expiration
1763 */
1764#ifndef PJSUA_PUBLISH_EXPIRATION
1765# define PJSUA_PUBLISH_EXPIRATION 600
1766#endif
1767
1768
1769/**
Benny Prijono093d3022006-09-24 00:07:11 +00001770 * Default account priority.
1771 */
1772#ifndef PJSUA_DEFAULT_ACC_PRIORITY
1773# define PJSUA_DEFAULT_ACC_PRIORITY 0
1774#endif
1775
1776
1777/**
Benny Prijono8058a622007-06-08 04:37:05 +00001778 * This macro specifies the URI scheme to use in Contact header
1779 * when secure transport such as TLS is used. Application can specify
1780 * either "sip" or "sips".
1781 */
1782#ifndef PJSUA_SECURE_SCHEME
Benny Prijono66ceef52007-06-08 05:12:58 +00001783# define PJSUA_SECURE_SCHEME "sip"
Benny Prijono8058a622007-06-08 04:37:05 +00001784#endif
1785
1786
1787/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001788 * This structure describes account configuration to be specified when
1789 * adding a new account with #pjsua_acc_add(). Application MUST initialize
1790 * this structure first by calling #pjsua_acc_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00001791 *
1792 * \par Python:
1793 * The data type in Python is <tt>py_pjsua.Acc_Config</tt>, but normally
1794 * application can just use the snippet below to create and initialize
1795 * the account config:
1796 * \code
1797 acc_cfg = py_pjsua.acc_config_default()
1798 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001799 */
1800typedef struct pjsua_acc_config
1801{
Benny Prijono093d3022006-09-24 00:07:11 +00001802 /**
1803 * Account priority, which is used to control the order of matching
1804 * incoming/outgoing requests. The higher the number means the higher
1805 * the priority is, and the account will be matched first.
1806 */
1807 int priority;
1808
Benny Prijono312aff92006-06-17 04:08:30 +00001809 /**
1810 * The full SIP URL for the account. The value can take name address or
1811 * URL format, and will look something like "sip:account@serviceprovider".
1812 *
1813 * This field is mandatory.
1814 */
1815 pj_str_t id;
1816
1817 /**
1818 * This is the URL to be put in the request URI for the registration,
1819 * and will look something like "sip:serviceprovider".
1820 *
1821 * This field should be specified if registration is desired. If the
1822 * value is empty, no account registration will be performed.
1823 */
1824 pj_str_t reg_uri;
1825
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001826 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001827 * If this flag is set, the presence information of this account will
1828 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001829 */
1830 pj_bool_t publish_enabled;
1831
Benny Prijono312aff92006-06-17 04:08:30 +00001832 /**
1833 * Optional URI to be put as Contact for this account. It is recommended
1834 * that this field is left empty, so that the value will be calculated
1835 * automatically based on the transport address.
1836 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00001837 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00001838
1839 /**
1840 * Number of proxies in the proxy array below.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001841 *
1842 * \par Python:
1843 * Not applicable, as \a proxy is implemented as list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001844 */
1845 unsigned proxy_cnt;
1846
1847 /**
1848 * Optional URI of the proxies to be visited for all outgoing requests
1849 * that are using this account (REGISTER, INVITE, etc). Application need
1850 * to specify these proxies if the service provider requires that requests
1851 * destined towards its network should go through certain proxies first
1852 * (for example, border controllers).
1853 *
1854 * These proxies will be put in the route set for this account, with
1855 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00001856 * first). If global outbound proxies are configured in pjsua_config,
1857 * then these account proxies will be placed after the global outbound
1858 * proxies in the routeset.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001859 *
1860 * \par Python:
1861 * This will be list of strings.
Benny Prijono312aff92006-06-17 04:08:30 +00001862 */
1863 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
1864
1865 /**
1866 * Optional interval for registration, in seconds. If the value is zero,
1867 * default interval will be used (PJSUA_REG_INTERVAL, 55 seconds).
1868 */
1869 unsigned reg_timeout;
1870
1871 /**
1872 * Number of credentials in the credential array.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001873 *
1874 * \par Python:
1875 * Not applicable, since \a cred_info is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00001876 */
1877 unsigned cred_count;
1878
1879 /**
1880 * Array of credentials. If registration is desired, normally there should
1881 * be at least one credential specified, to successfully authenticate
1882 * against the service provider. More credentials can be specified, for
1883 * example when the requests are expected to be challenged by the
1884 * proxies in the route set.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001885 *
1886 * \par Python:
1887 * This field is a list of credentials.
Benny Prijono312aff92006-06-17 04:08:30 +00001888 */
1889 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1890
Benny Prijono62c5c5b2007-01-13 23:22:40 +00001891 /**
1892 * Optionally bind this account to specific transport. This normally is
1893 * not a good idea, as account should be able to send requests using
1894 * any available transports according to the destination. But some
1895 * application may want to have explicit control over the transport to
1896 * use, so in that case it can set this field.
1897 *
1898 * Default: -1 (PJSUA_INVALID_ID)
1899 *
1900 * @see pjsua_acc_set_transport()
1901 */
1902 pjsua_transport_id transport_id;
1903
Benny Prijono312aff92006-06-17 04:08:30 +00001904} pjsua_acc_config;
1905
1906
1907/**
1908 * Call this function to initialize account config with default values.
1909 *
1910 * @param cfg The account config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001911 *
1912 * \par Python:
1913 * In Python, this function both creates and initializes the account
1914 * config:
1915 * \code
1916 acc_cfg = py_pjsua.acc_config_default()
1917 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001918 */
1919PJ_INLINE(void) pjsua_acc_config_default(pjsua_acc_config *cfg)
1920{
Benny Prijonoac623b32006-07-03 15:19:31 +00001921 pj_bzero(cfg, sizeof(*cfg));
Benny Prijono312aff92006-06-17 04:08:30 +00001922
1923 cfg->reg_timeout = PJSUA_REG_INTERVAL;
Benny Prijono62c5c5b2007-01-13 23:22:40 +00001924 cfg->transport_id = PJSUA_INVALID_ID;
Benny Prijono312aff92006-06-17 04:08:30 +00001925}
1926
1927
1928
1929/**
1930 * Account info. Application can query account info by calling
1931 * #pjsua_acc_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00001932 *
1933 * \par Python:
1934 * The data type in Python is <tt>py_pjsua.Acc_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001935 */
1936typedef struct pjsua_acc_info
1937{
1938 /**
1939 * The account ID.
1940 */
1941 pjsua_acc_id id;
1942
1943 /**
1944 * Flag to indicate whether this is the default account.
1945 */
1946 pj_bool_t is_default;
1947
1948 /**
1949 * Account URI
1950 */
1951 pj_str_t acc_uri;
1952
1953 /**
1954 * Flag to tell whether this account has registration setting
1955 * (reg_uri is not empty).
1956 */
1957 pj_bool_t has_registration;
1958
1959 /**
1960 * An up to date expiration interval for account registration session.
1961 */
1962 int expires;
1963
1964 /**
1965 * Last registration status code. If status code is zero, the account
1966 * is currently not registered. Any other value indicates the SIP
1967 * status code of the registration.
1968 */
1969 pjsip_status_code status;
1970
1971 /**
1972 * String describing the registration status.
1973 */
1974 pj_str_t status_text;
1975
1976 /**
1977 * Presence online status for this account.
1978 */
1979 pj_bool_t online_status;
1980
1981 /**
1982 * Buffer that is used internally to store the status text.
1983 */
1984 char buf_[PJ_ERR_MSG_SIZE];
1985
1986} pjsua_acc_info;
1987
1988
1989
1990/**
1991 * Get number of current accounts.
1992 *
1993 * @return Current number of accounts.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001994 *
1995 * \par Python:
1996 * \code
1997 count = py_pjsua.acc_get_count()
1998 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00001999 */
2000PJ_DECL(unsigned) pjsua_acc_get_count(void);
2001
2002
2003/**
2004 * Check if the specified account ID is valid.
2005 *
2006 * @param acc_id Account ID to check.
2007 *
2008 * @return Non-zero if account ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002009 *
2010 * \par Python:
2011 * \code
2012 is_valid = py_pjsua.acc_is_valid(acc_id)
2013 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002014 */
2015PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
2016
2017
2018/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00002019 * Set default account to be used when incoming and outgoing
2020 * requests doesn't match any accounts.
2021 *
2022 * @param acc_id The account ID to be used as default.
2023 *
2024 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002025 *
2026 * \par Python:
2027 * \code
2028 status = py_pjsua.acc_set_default(acc_id)
2029 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002030 */
2031PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2032
2033
2034/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002035 * Get default account to be used when receiving incoming requests (calls),
2036 * when the destination of the incoming call doesn't match any other
2037 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002038 *
2039 * @return The default account ID, or PJSUA_INVALID_ID if no
2040 * default account is configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002041 *
2042 * \par Python:
2043 * \code
2044 acc_id = py_pjsua.acc_get_default()
2045 * \endcode
Benny Prijono21b9ad92006-08-15 13:11:22 +00002046 */
2047PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2048
2049
2050/**
Benny Prijono312aff92006-06-17 04:08:30 +00002051 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002052 * #pjsua_init()) before calling this function. If registration is configured
2053 * for this account, this function would also start the SIP registration
2054 * session with the SIP registrar server. This SIP registration session
2055 * will be maintained internally by the library, and application doesn't
2056 * need to do anything to maintain the registration session.
2057 *
Benny Prijono312aff92006-06-17 04:08:30 +00002058 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002059 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002060 * @param is_default If non-zero, this account will be set as the default
2061 * account. The default account will be used when sending
2062 * outgoing requests (e.g. making call) when no account is
2063 * specified, and when receiving incoming requests when the
2064 * request does not match any accounts. It is recommended
2065 * that default account is set to local/LAN account.
2066 * @param p_acc_id Pointer to receive account ID of the new account.
2067 *
2068 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002069 *
2070 * \par Python:
2071 * The function returns (status, account_id) tuple:
2072 * \code
2073 status, account_id = py_pjsua.acc_add(acc_cfg, is_default)
2074 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002075 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002076PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002077 pj_bool_t is_default,
2078 pjsua_acc_id *p_acc_id);
2079
2080
2081/**
2082 * Add a local account. A local account is used to identify local endpoint
2083 * instead of a specific user, and for this reason, a transport ID is needed
2084 * to obtain the local address information.
2085 *
2086 * @param tid Transport ID to generate account address.
2087 * @param is_default If non-zero, this account will be set as the default
2088 * account. The default account will be used when sending
2089 * outgoing requests (e.g. making call) when no account is
2090 * specified, and when receiving incoming requests when the
2091 * request does not match any accounts. It is recommended
2092 * that default account is set to local/LAN account.
2093 * @param p_acc_id Pointer to receive account ID of the new account.
2094 *
2095 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002096 *
2097 * \par Python:
2098 * The function returns (status, account_id) tuple:
2099 * \code
2100 status, account_id = py_pjsua.acc_add_local(tid, is_default)
2101 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002102 */
2103PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2104 pj_bool_t is_default,
2105 pjsua_acc_id *p_acc_id);
2106
2107/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002108 * Delete an account. This will unregister the account from the SIP server,
2109 * if necessary, and terminate server side presence subscriptions associated
2110 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002111 *
2112 * @param acc_id Id of the account to be deleted.
2113 *
2114 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002115 *
2116 * \par Python:
2117 * \code
2118 status = py_pjsua.acc_del(acc_id)
2119 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002120 */
2121PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2122
2123
2124/**
2125 * Modify account information.
2126 *
2127 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002128 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002129 *
2130 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002131 *
2132 * \par Python:
2133 * \code
2134 status = py_pjsua.acc_modify(acc_id, acc_cfg)
2135 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002136 */
2137PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002138 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002139
2140
2141/**
2142 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002143 * subscribers. This would trigger the sending of outgoing NOTIFY request
2144 * if there are server side presence subscription for this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002145 *
2146 * @param acc_id The account ID.
2147 * @param is_online True of false.
2148 *
2149 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002150 *
2151 * \par Python:
2152 * \code
2153 status = py_pjsua.acc_set_online_status(acc_id, is_online)
2154 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002155 */
2156PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2157 pj_bool_t is_online);
2158
2159
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 Prijono312aff92006-06-17 04:08:30 +00002408} pjsua_call_media_status;
2409
2410
2411/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002412 * This structure describes the information and current status of a call.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002413 *
2414 * \par Python:
2415 * The type name is <tt>py_pjsua.Call_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002416 */
2417typedef struct pjsua_call_info
2418{
2419 /** Call identification. */
2420 pjsua_call_id id;
2421
2422 /** Initial call role (UAC == caller) */
2423 pjsip_role_e role;
2424
Benny Prijono90315512006-09-14 16:05:16 +00002425 /** The account ID where this call belongs. */
2426 pjsua_acc_id acc_id;
2427
Benny Prijono312aff92006-06-17 04:08:30 +00002428 /** Local URI */
2429 pj_str_t local_info;
2430
2431 /** Local Contact */
2432 pj_str_t local_contact;
2433
2434 /** Remote URI */
2435 pj_str_t remote_info;
2436
2437 /** Remote contact */
2438 pj_str_t remote_contact;
2439
2440 /** Dialog Call-ID string. */
2441 pj_str_t call_id;
2442
2443 /** Call state */
2444 pjsip_inv_state state;
2445
2446 /** Text describing the state */
2447 pj_str_t state_text;
2448
2449 /** Last status code heard, which can be used as cause code */
2450 pjsip_status_code last_status;
2451
2452 /** The reason phrase describing the status. */
2453 pj_str_t last_status_text;
2454
2455 /** Call media status. */
2456 pjsua_call_media_status media_status;
2457
2458 /** Media direction */
2459 pjmedia_dir media_dir;
2460
2461 /** The conference port number for the call */
2462 pjsua_conf_port_id conf_slot;
2463
2464 /** Up-to-date call connected duration (zero when call is not
2465 * established)
2466 */
2467 pj_time_val connect_duration;
2468
2469 /** Total call duration, including set-up time */
2470 pj_time_val total_duration;
2471
2472 /** Internal */
2473 struct {
2474 char local_info[128];
2475 char local_contact[128];
2476 char remote_info[128];
2477 char remote_contact[128];
2478 char call_id[128];
2479 char last_status_text[128];
2480 } buf_;
2481
2482} pjsua_call_info;
2483
2484
2485
Benny Prijonoa91a0032006-02-26 21:23:45 +00002486/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002487 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002488 *
2489 * @return Maximum number of calls configured.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002490 *
2491 * \par Python:
2492 * \code
2493 count = py_pjsua.call_get_max_count()
2494 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002495 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002496PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002497
2498/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002499 * Get number of currently active calls.
2500 *
2501 * @return Number of currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002502 *
2503 * \par Python:
2504 * \code
2505 count = py_pjsua.call_get_count()
2506 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002507 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002508PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002509
2510/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002511 * Enumerate all active calls. Application may then query the information and
2512 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002513 *
2514 * @param ids Array of account IDs to be initialized.
2515 * @param count In input, specifies the maximum number of elements.
2516 * On return, it contains the actual number of elements.
2517 *
2518 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002519 *
2520 * \par Python:
2521 * This function takes no argument and return list of call Ids.
2522 * \code
2523 [call_ids] = py_pjsua.enum_calls()
2524 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002525 */
2526PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
2527 unsigned *count);
2528
2529
2530/**
2531 * Make outgoing call to the specified URI using the specified account.
2532 *
2533 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002534 * @param dst_uri URI to be put in the To header (normally is the same
2535 * as the target URI).
2536 * @param options Options (must be zero at the moment).
2537 * @param user_data Arbitrary user data to be attached to the call, and
2538 * can be retrieved later.
2539 * @param msg_data Optional headers etc to be added to outgoing INVITE
2540 * request, or NULL if no custom header is desired.
2541 * @param p_call_id Pointer to receive call identification.
2542 *
2543 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002544 *
2545 * \par Python:
2546 * The Python function returns (status, call_id) tuple:
2547 * \code
2548 status, call_id = py_pjsua.call_make_call(acc_id, dst_uri, options,
2549 user_data, msg_data)
2550 * \endcode
2551 * Note: the \a user_data in Python function is an integer, and the
2552 * \a msg_data can be set to None if not required.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002553 */
2554PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
2555 const pj_str_t *dst_uri,
2556 unsigned options,
2557 void *user_data,
2558 const pjsua_msg_data *msg_data,
2559 pjsua_call_id *p_call_id);
2560
2561
2562/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002563 * Check if the specified call has active INVITE session and the INVITE
2564 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002565 *
2566 * @param call_id Call identification.
2567 *
2568 * @return Non-zero if call is active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002569 *
2570 * \par Python:
2571 * \code
2572 bool = py_pjsua.call_is_active(call_id)
2573 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002574 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002575PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002576
2577
2578/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002579 * Check if call has an active media session.
2580 *
2581 * @param call_id Call identification.
2582 *
2583 * @return Non-zero if yes.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002584 *
2585 * \par Python:
2586 * \code
2587 bool = py_pjsua.call_has_media(call_id)
2588 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002589 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002590PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002591
2592
2593/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002594 * Get the conference port identification associated with the call.
2595 *
2596 * @param call_id Call identification.
2597 *
2598 * @return Conference port ID, or PJSUA_INVALID_ID when the
2599 * media has not been established or is not active.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002600 *
2601 * \par Python:
2602 * \code
2603 slot = py_pjsua.call_get_conf_port(call_id)
2604 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002605 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002606PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
2607
2608/**
2609 * Obtain detail information about the specified call.
2610 *
2611 * @param call_id Call identification.
2612 * @param info Call info to be initialized.
2613 *
2614 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002615 *
2616 * \par Python:
2617 * \code
2618 call_info = py_pjsua.call_get_info(call_id)
2619 * \endcode
2620 * \a call_info return value will be set to None if call_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002621 */
2622PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002623 pjsua_call_info *info);
2624
2625
2626/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002627 * Attach application specific data to the call. Application can then
2628 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002629 *
2630 * @param call_id Call identification.
2631 * @param user_data Arbitrary data to be attached to the call.
2632 *
2633 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002634 *
2635 * \par Python:
2636 * \code
2637 status = py_pjsua.call_set_user_data(call_id, user_data)
2638 * \endcode
2639 * The \a user_data is an integer in the Python function.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002640 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002641PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
2642 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002643
2644
2645/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002646 * Get user data attached to the call, which has been previously set with
2647 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002648 *
2649 * @param call_id Call identification.
2650 *
2651 * @return The user data.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002652 *
2653 * \par Python:
2654 * \code
2655 user_data = py_pjsua.call_get_user_data(call_id)
2656 * \endcode
2657 * The \a user_data is an integer.
Benny Prijono268ca612006-02-07 12:34:11 +00002658 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002659PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00002660
2661
2662/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002663 * Send response to incoming INVITE request. Depending on the status
2664 * code specified as parameter, this function may send provisional
2665 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002666 *
2667 * @param call_id Incoming call identification.
2668 * @param code Status code, (100-699).
2669 * @param reason Optional reason phrase. If NULL, default text
2670 * will be used.
2671 * @param msg_data Optional list of headers etc to be added to outgoing
2672 * response message.
2673 *
2674 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002675 *
2676 * \par Python:
2677 * \code
2678 status = py_pjsua.call_answer(call_id, code, reason, msg_data)
2679 * \endcode
2680 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijonoa91a0032006-02-26 21:23:45 +00002681 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002682PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
2683 unsigned code,
2684 const pj_str_t *reason,
2685 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00002686
2687/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002688 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00002689 * call state. This function is different than answering the call with
2690 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
2691 * will hangup the call regardless of the state and role of the call,
2692 * while #pjsua_call_answer() only works with incoming calls on EARLY
2693 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002694 *
2695 * @param call_id Call identification.
2696 * @param code Optional status code to be sent when we're rejecting
2697 * incoming call. If the value is zero, "603/Decline"
2698 * will be sent.
2699 * @param reason Optional reason phrase to be sent when we're rejecting
2700 * incoming call. If NULL, default text will be used.
2701 * @param msg_data Optional list of headers etc to be added to outgoing
2702 * request/response message.
2703 *
2704 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002705 *
2706 * \par Python:
2707 * \code
2708 status = py_pjsua.call_hangup(call_id, code, reason, msg_data)
2709 * \endcode
2710 * Arguments \a reason and \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002711 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002712PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
2713 unsigned code,
2714 const pj_str_t *reason,
2715 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002716
2717
2718/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002719 * Put the specified call on hold. This will send re-INVITE with the
2720 * appropriate SDP to inform remote that the call is being put on hold.
2721 * The final status of the request itself will be reported on the
2722 * \a on_call_media_state() callback, which inform the application that
2723 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002724 *
2725 * @param call_id Call identification.
2726 * @param msg_data Optional message components to be sent with
2727 * the request.
2728 *
2729 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002730 *
2731 * \par Python:
2732 * \code
2733 status = py_pjsua.call_set_hold(call_id, msg_data)
2734 * \endcode
2735 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002736 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002737PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
2738 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002739
2740
2741/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002742 * Send re-INVITE to release hold.
2743 * The final status of the request itself will be reported on the
2744 * \a on_call_media_state() callback, which inform the application that
2745 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002746 *
2747 * @param call_id Call identification.
2748 * @param unhold If this argument is non-zero and the call is locally
2749 * held, this will release the local hold.
2750 * @param msg_data Optional message components to be sent with
2751 * the request.
2752 *
2753 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002754 *
2755 * \par Python:
2756 * \code
2757 status = py_pjsua.call_reinvite(call_id, unhold, msg_data)
2758 * \endcode
2759 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002760 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002761PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
2762 pj_bool_t unhold,
2763 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002764
2765
2766/**
Benny Prijono053f5222006-11-11 16:16:04 +00002767 * Initiate call transfer to the specified address. This function will send
2768 * REFER request to instruct remote call party to initiate a new INVITE
2769 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002770 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00002771 * If application is interested to monitor the successfulness and
2772 * the progress of the transfer request, it can implement
2773 * \a on_call_transfer_status() callback which will report the progress
2774 * of the call transfer request.
2775 *
Benny Prijono053f5222006-11-11 16:16:04 +00002776 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002777 * @param dest Address of new target to be contacted.
2778 * @param msg_data Optional message components to be sent with
2779 * the request.
2780 *
2781 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002782 *
2783 * \par Python:
2784 * \code
2785 status = py_pjsua.call_xfer(call_id, dest, msg_data)
2786 * \endcode
2787 * Argument \a msg_data may be set to None if not required.
Benny Prijono26ff9062006-02-21 23:47:00 +00002788 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002789PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
2790 const pj_str_t *dest,
2791 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002792
2793/**
Benny Prijono053f5222006-11-11 16:16:04 +00002794 * Flag to indicate that "Require: replaces" should not be put in the
2795 * outgoing INVITE request caused by REFER request created by
2796 * #pjsua_call_xfer_replaces().
2797 */
2798#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
2799
2800/**
2801 * Initiate attended call transfer. This function will send REFER request
2802 * to instruct remote call party to initiate new INVITE session to the URL
2803 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
2804 * the call with us with the new call from the REFER recipient.
2805 *
2806 * @param call_id The call id to be transfered.
2807 * @param dest_call_id The call id to be replaced.
2808 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
2809 * to suppress the inclusion of "Require: replaces" in
2810 * the outgoing INVITE request created by the REFER
2811 * request.
2812 * @param msg_data Optional message components to be sent with
2813 * the request.
2814 *
2815 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002816 *
2817 * \par Python:
2818 * \code
2819 status = py_pjsua.call_xfer_replaces(call_id, dest_call_id, options, msg_data)
2820 * \endcode
2821 * Argument \a msg_data may be set to None if not required.
Benny Prijono053f5222006-11-11 16:16:04 +00002822 */
2823PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
2824 pjsua_call_id dest_call_id,
2825 unsigned options,
2826 const pjsua_msg_data *msg_data);
2827
2828/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002829 * Send DTMF digits to remote using RFC 2833 payload formats.
2830 *
2831 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002832 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002833 *
2834 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002835 *
2836 * \par Python:
2837 * \code
2838 status = py_pjsua.call_dial_dtmf(call_id, digits)
2839 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00002840 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002841PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002842 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00002843
Benny Prijono26ff9062006-02-21 23:47:00 +00002844/**
Benny Prijonob0808372006-03-02 21:18:58 +00002845 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002846 *
2847 * @param call_id Call identification.
2848 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
2849 * assumed.
2850 * @param content The message content.
2851 * @param msg_data Optional list of headers etc to be included in outgoing
2852 * request. The body descriptor in the msg_data is
2853 * ignored.
2854 * @param user_data Optional user data, which will be given back when
2855 * the IM callback is called.
2856 *
2857 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002858 *
2859 * \par Python:
2860 * \code
2861 status = py_pjsua.call_send_im(call_id, mime_type, content, msg_data, user_data)
2862 * \endcode
2863 * Note that the \a user_data argument is an integer in Python.
Benny Prijonob0808372006-03-02 21:18:58 +00002864 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002865PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
2866 const pj_str_t *mime_type,
2867 const pj_str_t *content,
2868 const pjsua_msg_data *msg_data,
2869 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00002870
2871
2872/**
2873 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002874 *
2875 * @param call_id Call identification.
2876 * @param is_typing Non-zero to indicate to remote that local person is
2877 * currently typing an IM.
2878 * @param msg_data Optional list of headers etc to be included in outgoing
2879 * request.
2880 *
2881 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002882 *
2883 * \par Python:
2884 * \code
2885 status = py_pjsua.call_send_typing_ind(call_id, is_typing, msg_data)
2886 * \endcode
2887 * Argument \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00002888 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002889PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
2890 pj_bool_t is_typing,
2891 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00002892
2893/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002894 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
2895 * currently active calls.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002896 *
2897 * \par Python:
2898 * \code
2899 py_pjsua.call_hangup_all()
2900 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00002901 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00002902PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00002903
2904
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002905/**
2906 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002907 *
2908 * @param call_id Call identification.
2909 * @param with_media Non-zero to include media information too.
2910 * @param buffer Buffer where the statistics are to be written to.
2911 * @param maxlen Maximum length of buffer.
2912 * @param indent Spaces for left indentation.
2913 *
2914 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002915 *
2916 * \par Python:
2917 * \code
2918 string = py_pjsua.call_dump(call_id, with_media, max_len, indent)
2919 * \endcode
2920 * The \a max_len argument is the desired maximum length to be allocated.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002921 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002922PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
2923 pj_bool_t with_media,
2924 char *buffer,
2925 unsigned maxlen,
2926 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002927
Benny Prijono9fc735d2006-05-28 14:58:12 +00002928/**
Benny Prijono312aff92006-06-17 04:08:30 +00002929 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00002930 */
Benny Prijono834aee32006-02-19 01:38:06 +00002931
2932
2933/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00002934 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00002935 */
2936
Benny Prijono312aff92006-06-17 04:08:30 +00002937
2938/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002939 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00002940 * @ingroup PJSUA_LIB
2941 * @brief Buddy management, buddy's presence, and instant messaging.
2942 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00002943 *
2944 * This section describes PJSUA-APIs related to buddies management,
2945 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00002946 */
2947
2948/**
2949 * Max buddies in buddy list.
2950 */
2951#ifndef PJSUA_MAX_BUDDIES
2952# define PJSUA_MAX_BUDDIES 256
2953#endif
2954
2955
2956/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002957 * This structure describes buddy configuration when adding a buddy to
2958 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
2959 * the structure with #pjsua_buddy_config_default() to initialize this
2960 * structure with default configuration.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002961 *
2962 * \par Python:
2963 * In Python this structure is <tt>py_pjsua.Buddy_Config</tt>. However
2964 * it is recommended that application instantiates the buddy config
2965 * by calling:
2966 * \code
2967 buddy_cfg = py_pjsua.buddy_config_default()
2968 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00002969 */
2970typedef struct pjsua_buddy_config
2971{
2972 /**
2973 * Buddy URL or name address.
2974 */
2975 pj_str_t uri;
2976
2977 /**
2978 * Specify whether presence subscription should start immediately.
2979 */
2980 pj_bool_t subscribe;
2981
2982} pjsua_buddy_config;
2983
2984
2985/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002986 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00002987 */
2988typedef enum pjsua_buddy_status
2989{
2990 /**
2991 * Online status is unknown (possibly because no presence subscription
2992 * has been established).
2993 */
2994 PJSUA_BUDDY_STATUS_UNKNOWN,
2995
2996 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00002997 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00002998 */
2999 PJSUA_BUDDY_STATUS_ONLINE,
3000
3001 /**
3002 * Buddy is offline.
3003 */
3004 PJSUA_BUDDY_STATUS_OFFLINE,
3005
3006} pjsua_buddy_status;
3007
3008
3009
3010/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003011 * This structure describes buddy info, which can be retrieved by calling
3012 * #pjsua_buddy_get_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003013 *
3014 * \par Python:
3015 * This structure in Python is <tt>py_pjsua.Buddy_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003016 */
3017typedef struct pjsua_buddy_info
3018{
3019 /**
3020 * The buddy ID.
3021 */
3022 pjsua_buddy_id id;
3023
3024 /**
3025 * The full URI of the buddy, as specified in the configuration.
3026 */
3027 pj_str_t uri;
3028
3029 /**
3030 * Buddy's Contact, only available when presence subscription has
3031 * been established to the buddy.
3032 */
3033 pj_str_t contact;
3034
3035 /**
3036 * Buddy's online status.
3037 */
3038 pjsua_buddy_status status;
3039
3040 /**
3041 * Text to describe buddy's online status.
3042 */
3043 pj_str_t status_text;
3044
3045 /**
3046 * Flag to indicate that we should monitor the presence information for
3047 * this buddy (normally yes, unless explicitly disabled).
3048 */
3049 pj_bool_t monitor_pres;
3050
3051 /**
3052 * Internal buffer.
3053 */
3054 char buf_[256];
3055
3056} pjsua_buddy_info;
3057
3058
Benny Prijono834aee32006-02-19 01:38:06 +00003059/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003060 * Set default values to the buddy config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003061 *
3062 * \par Python:
3063 * \code
3064 buddy_cfg = py_pjsua.buddy_config_default()
3065 * \endcode
Benny Prijonob5388cf2007-01-04 22:45:08 +00003066 */
3067PJ_INLINE(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg)
3068{
3069 pj_bzero(cfg, sizeof(*cfg));
3070}
3071
3072
3073/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003074 * Get total number of buddies.
3075 *
3076 * @return Number of buddies.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003077 *
3078 * \par Python:
3079 * \code
3080 buddy_count = py_pjsua.get_buddy_count()
3081 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003082 */
3083PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3084
3085
3086/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003087 * Check if buddy ID is valid.
3088 *
3089 * @param buddy_id Buddy ID to check.
3090 *
3091 * @return Non-zero if buddy ID is valid.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003092 *
3093 * \par Python:
3094 * \code
3095 is_valid = py_pjsua.buddy_is_valid(buddy_id)
3096 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003097 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003098PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3099
3100
3101/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003102 * Enumerate all buddy IDs in the buddy list. Application then can use
3103 * #pjsua_buddy_get_info() to get the detail information for each buddy
3104 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003105 *
3106 * @param ids Array of ids to be initialized.
3107 * @param count On input, specifies max elements in the array.
3108 * On return, it contains actual number of elements
3109 * that have been initialized.
3110 *
3111 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003112 *
3113 * \par Python:
3114 * The Python function takes no argument and returns list of buddy IDs:
3115 * \code
3116 [buddy_ids] = py_pjsua.enum_buddies()
3117 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003118 */
3119PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3120 unsigned *count);
3121
3122/**
3123 * Get detailed buddy info.
3124 *
3125 * @param buddy_id The buddy identification.
3126 * @param info Pointer to receive information about buddy.
3127 *
3128 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003129 *
3130 * \par Python:
3131 * \code
3132 buddy_info = py_pjsua.buddy_get_info(buddy_id)
3133 * \endcode
3134 * The function returns None if buddy_id is not valid.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003135 */
3136PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003137 pjsua_buddy_info *info);
3138
3139/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003140 * Add new buddy to the buddy list. If presence subscription is enabled
3141 * for this buddy, this function will also start the presence subscription
3142 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003143 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003144 * @param buddy)cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003145 * @param p_buddy_id Pointer to receive buddy ID.
3146 *
3147 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003148 *
3149 * \par Python:
3150 * The function returns (status, buddy_id) tuple:
3151 * \code
3152 status, buddy_id = py_pjsua.buddy_add(buddy_cfg)
3153 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003154 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003155PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003156 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003157
3158
3159/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003160 * Delete the specified buddy from the buddy list. Any presence subscription
3161 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003162 *
3163 * @param buddy_id Buddy identification.
3164 *
3165 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003166 *
3167 * \par Python:
3168 * \code
3169 status = py_pjsua.buddy_del(buddy_id)
3170 * \endcode
Benny Prijono8b1889b2006-06-06 18:40:40 +00003171 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003172PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003173
3174
3175/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003176 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3177 * subscribed, application will be informed about buddy's presence status
3178 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003179 *
3180 * @param buddy_id Buddy identification.
3181 * @param subscribe Specify non-zero to activate presence subscription to
3182 * the specified buddy.
3183 *
3184 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003185 *
3186 * \par Python:
3187 * \code
3188 status = py_pjsua.buddy_subscribe_pres(buddy_id, subscribe)
3189 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003190 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003191PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3192 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003193
3194
3195/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003196 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003197 *
3198 * @param verbose Yes or no.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003199 *
3200 * \par Python:
3201 * \code
3202 py_pjsua.pres_dump()
3203 * \endcode
Benny Prijono834aee32006-02-19 01:38:06 +00003204 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003205PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003206
3207
Benny Prijonob0808372006-03-02 21:18:58 +00003208/**
3209 * The MESSAGE method (defined in pjsua_im.c)
3210 */
3211extern const pjsip_method pjsip_message_method;
3212
3213
Benny Prijonob0808372006-03-02 21:18:58 +00003214
3215/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003216 * Send instant messaging outside dialog, using the specified account for
3217 * route set and authentication.
3218 *
3219 * @param acc_id Account ID to be used to send the request.
3220 * @param to Remote URI.
3221 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3222 * assumed.
3223 * @param content The message content.
3224 * @param msg_data Optional list of headers etc to be included in outgoing
3225 * request. The body descriptor in the msg_data is
3226 * ignored.
3227 * @param user_data Optional user data, which will be given back when
3228 * the IM callback is called.
3229 *
3230 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003231 *
3232 * \par Python:
3233 * \code
3234 status = py_pjsua.im_send(acc_id, to, mime_type, content, msg_data, user_data)
3235 * \endcode
3236 * Arguments \a mime_type and \a msg_data may be set to None if not required.
Benny Prijonob0808372006-03-02 21:18:58 +00003237 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003238PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3239 const pj_str_t *to,
3240 const pj_str_t *mime_type,
3241 const pj_str_t *content,
3242 const pjsua_msg_data *msg_data,
3243 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003244
3245
3246/**
3247 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003248 *
3249 * @param acc_id Account ID to be used to send the request.
3250 * @param to Remote URI.
3251 * @param is_typing If non-zero, it tells remote person that local person
3252 * is currently composing an IM.
3253 * @param msg_data Optional list of headers etc to be added to outgoing
3254 * request.
3255 *
3256 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003257 *
3258 * \par Python:
3259 * \code
3260 status = py_pjsua.im_typing(acc_id, to, is_typing, msg_data)
3261 * \endcode
3262 * Argument \a msg_data may be set to None if not requried.
Benny Prijonob0808372006-03-02 21:18:58 +00003263 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003264PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3265 const pj_str_t *to,
3266 pj_bool_t is_typing,
3267 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003268
3269
Benny Prijonof3195072006-02-14 21:15:30 +00003270
Benny Prijono312aff92006-06-17 04:08:30 +00003271/**
3272 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003273 */
3274
Benny Prijono312aff92006-06-17 04:08:30 +00003275
3276/*****************************************************************************
3277 * MEDIA API
3278 */
3279
3280
3281/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003282 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003283 * @ingroup PJSUA_LIB
3284 * @brief Media manipulation.
3285 * @{
3286 *
3287 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003288 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3289 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003290 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003291 * the interconnection between these terminations freely.
3292 *
3293 * The conference bridge provides powerful switching and mixing functionality
3294 * for application. With the conference bridge, each conference slot (e.g.
3295 * a call) can transmit to multiple destinations, and one destination can
3296 * receive from multiple sources. If more than one media terminations are
3297 * terminated in the same slot, the conference bridge will mix the signal
3298 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00003299 *
3300 * Application connects one media termination/slot to another by calling
3301 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003302 * media flow from the source termination to the sink termination. To
3303 * establish bidirectional media flow, application wound need to make another
3304 * call to #pjsua_conf_connect(), this time inverting the source and
3305 * destination slots in the parameter.
3306 *
3307 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00003308 * the following steps:
3309 *
3310 \code
3311
3312 pj_status_t stream_to_call( pjsua_call_id call_id )
3313 {
3314 pjsua_player_id player_id;
3315
3316 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
3317 if (status != PJ_SUCCESS)
3318 return status;
3319
3320 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
3321 pjsua_call_get_conf_port() );
3322 }
3323 \endcode
3324 *
3325 *
3326 * Other features of PJSUA media:
3327 * - efficient N to M interconnections between media terminations.
3328 * - media termination can be connected to itself to create loopback
3329 * media.
3330 * - the media termination may have different clock rates, and resampling
3331 * will be done automatically by conference bridge.
3332 * - media terminations may also have different frame time; the
3333 * conference bridge will perform the necessary bufferring to adjust
3334 * the difference between terminations.
3335 * - interconnections are removed automatically when media termination
3336 * is removed from the bridge.
3337 * - sound device may be changed even when there are active media
3338 * interconnections.
3339 * - correctly report call's media quality (in #pjsua_call_dump()) from
3340 * RTCP packet exchange.
3341 */
3342
3343/**
3344 * Max ports in the conference bridge.
3345 */
3346#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00003347# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00003348#endif
3349
Benny Prijonob5388cf2007-01-04 22:45:08 +00003350/**
3351 * The default clock rate to be used by the conference bridge.
3352 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003353#ifndef PJSUA_DEFAULT_CLOCK_RATE
3354# define PJSUA_DEFAULT_CLOCK_RATE 16000
3355#endif
3356
Benny Prijonob5388cf2007-01-04 22:45:08 +00003357/**
3358 * Default codec quality settings.
3359 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003360#ifndef PJSUA_DEFAULT_CODEC_QUALITY
3361# define PJSUA_DEFAULT_CODEC_QUALITY 5
3362#endif
3363
Benny Prijonob5388cf2007-01-04 22:45:08 +00003364/**
3365 * Default iLBC mode.
3366 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003367#ifndef PJSUA_DEFAULT_ILBC_MODE
3368# define PJSUA_DEFAULT_ILBC_MODE 20
3369#endif
3370
Benny Prijonob5388cf2007-01-04 22:45:08 +00003371/**
3372 * The default echo canceller tail length.
3373 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003374#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonod2990b92006-11-23 10:19:46 +00003375# define PJSUA_DEFAULT_EC_TAIL_LEN 800
Benny Prijono12a669c2006-11-23 07:32:13 +00003376#endif
Benny Prijono312aff92006-06-17 04:08:30 +00003377
3378
3379/**
Benny Prijonocba59d92007-02-16 09:22:56 +00003380 * The maximum file player.
3381 */
3382#ifndef PJSUA_MAX_PLAYERS
3383# define PJSUA_MAX_PLAYERS 32
3384#endif
3385
3386
3387/**
3388 * The maximum file player.
3389 */
3390#ifndef PJSUA_MAX_RECORDERS
3391# define PJSUA_MAX_RECORDERS 32
3392#endif
3393
3394
3395/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003396 * This structure describes media configuration, which will be specified
3397 * when calling #pjsua_init(). Application MUST initialize this structure
3398 * by calling #pjsua_media_config_default().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003399 *
3400 * \par Python:
3401 * This data type in Python is <tt>py_pjsua.Media_Config</tt>. To create
3402 * an object of this type, it is recommended to call
3403 * <tt>py_pjsua.media_config_default()</tt> function instead:
3404 * \code
3405 media_cfg = py_pjsua.media_config_default()
3406 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003407 */
3408struct pjsua_media_config
3409{
3410 /**
3411 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003412 * If value is zero, default clock rate will be used
3413 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00003414 */
3415 unsigned clock_rate;
3416
3417 /**
3418 * Specify maximum number of media ports to be created in the
3419 * conference bridge. Since all media terminate in the bridge
3420 * (calls, file player, file recorder, etc), the value must be
3421 * large enough to support all of them. However, the larger
3422 * the value, the more computations are performed.
3423 */
3424 unsigned max_media_ports;
3425
3426 /**
3427 * Specify whether the media manager should manage its own
3428 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
3429 * and at least one worker thread will be created too. If no,
3430 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
3431 * and no worker thread is needed.
3432 *
3433 * Normally application would say yes here, unless it wants to
3434 * run everything from a single thread.
3435 */
3436 pj_bool_t has_ioqueue;
3437
3438 /**
3439 * Specify the number of worker threads to handle incoming RTP
3440 * packets. A value of one is recommended for most applications.
3441 */
3442 unsigned thread_cnt;
3443
Benny Prijono0498d902006-06-19 14:49:14 +00003444 /**
3445 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00003446 * 5-10: resampling use large filter,
3447 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00003448 * 1-2: resampling use linear.
3449 * The media quality also sets speex codec quality/complexity to the
3450 * number.
3451 *
Benny Prijono70972992006-08-05 11:13:58 +00003452 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00003453 */
3454 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00003455
3456 /**
3457 * Specify default ptime.
3458 *
3459 * Default: 0 (codec specific)
3460 */
3461 unsigned ptime;
3462
3463 /**
3464 * Disable VAD?
3465 *
3466 * Default: 0 (no (meaning VAD is enabled))
3467 */
3468 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00003469
3470 /**
3471 * iLBC mode (20 or 30).
3472 *
Benny Prijono70972992006-08-05 11:13:58 +00003473 * Default: 20 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00003474 */
3475 unsigned ilbc_mode;
3476
3477 /**
3478 * Percentage of RTP packet to drop in TX direction
3479 * (to simulate packet lost).
3480 *
3481 * Default: 0
3482 */
3483 unsigned tx_drop_pct;
3484
3485 /**
3486 * Percentage of RTP packet to drop in RX direction
3487 * (to simulate packet lost).
3488 *
3489 * Default: 0
3490 */
3491 unsigned rx_drop_pct;
3492
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003493 /**
Benny Prijono5da50432006-08-07 10:24:52 +00003494 * Echo canceller options (see #pjmedia_echo_create())
3495 *
3496 * Default: 0.
3497 */
3498 unsigned ec_options;
3499
3500 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003501 * Echo canceller tail length, in miliseconds.
3502 *
Benny Prijono669643c2006-09-20 20:02:18 +00003503 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003504 */
3505 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003506
3507 /**
3508 * Jitter buffer initial prefetch delay in msec. The value must be
3509 * between jb_min_pre and jb_max_pre below.
3510 *
3511 * Default: -1 (to use default stream settings, currently 150 msec)
3512 */
3513 int jb_init;
3514
3515 /**
3516 * Jitter buffer minimum prefetch delay in msec.
3517 *
3518 * Default: -1 (to use default stream settings, currently 60 msec)
3519 */
3520 int jb_min_pre;
3521
3522 /**
3523 * Jitter buffer maximum prefetch delay in msec.
3524 *
3525 * Default: -1 (to use default stream settings, currently 240 msec)
3526 */
3527 int jb_max_pre;
3528
3529 /**
3530 * Set maximum delay that can be accomodated by the jitter buffer msec.
3531 *
3532 * Default: -1 (to use default stream settings, currently 360 msec)
3533 */
3534 int jb_max;
3535
Benny Prijonoc97608e2007-03-23 16:34:20 +00003536 /**
3537 * Enable ICE
3538 */
3539 pj_bool_t enable_ice;
3540
3541 /**
3542 * Enable ICE media relay.
3543 */
3544 pj_bool_t enable_relay;
Benny Prijono312aff92006-06-17 04:08:30 +00003545};
3546
3547
3548/**
3549 * Use this function to initialize media config.
3550 *
3551 * @param cfg The media config to be initialized.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003552 *
3553 * \par Python:
3554 * \code
3555 media_cfg = py_pjsua.media_config_default()
3556 * \endcode
Benny Prijono312aff92006-06-17 04:08:30 +00003557 */
3558PJ_INLINE(void) pjsua_media_config_default(pjsua_media_config *cfg)
3559{
Benny Prijonoac623b32006-07-03 15:19:31 +00003560 pj_bzero(cfg, sizeof(*cfg));
Benny Prijono312aff92006-06-17 04:08:30 +00003561
Benny Prijono70972992006-08-05 11:13:58 +00003562 cfg->clock_rate = PJSUA_DEFAULT_CLOCK_RATE;
Benny Prijono312aff92006-06-17 04:08:30 +00003563 cfg->max_media_ports = 32;
3564 cfg->has_ioqueue = PJ_TRUE;
3565 cfg->thread_cnt = 1;
Benny Prijono70972992006-08-05 11:13:58 +00003566 cfg->quality = PJSUA_DEFAULT_CODEC_QUALITY;
3567 cfg->ilbc_mode = PJSUA_DEFAULT_ILBC_MODE;
3568 cfg->ec_tail_len = PJSUA_DEFAULT_EC_TAIL_LEN;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003569 cfg->jb_init = cfg->jb_min_pre = cfg->jb_max_pre = cfg->jb_max = -1;
Benny Prijono312aff92006-06-17 04:08:30 +00003570}
3571
3572
3573
3574/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003575 * This structure describes codec information, which can be retrieved by
3576 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00003577 */
3578typedef struct pjsua_codec_info
3579{
3580 /**
3581 * Codec unique identification.
3582 */
3583 pj_str_t codec_id;
3584
3585 /**
3586 * Codec priority (integer 0-255).
3587 */
3588 pj_uint8_t priority;
3589
3590 /**
3591 * Internal buffer.
3592 */
3593 char buf_[32];
3594
3595} pjsua_codec_info;
3596
3597
3598/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003599 * This structure descibes information about a particular media port that
3600 * has been registered into the conference bridge. Application can query
3601 * this info by calling #pjsua_conf_get_port_info().
Benny Prijonoe6ead542007-01-31 20:53:31 +00003602 *
3603 * \par Python:
3604 * In Python, this type is <tt>py_pjsua.Conf_Port_Info</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00003605 */
3606typedef struct pjsua_conf_port_info
3607{
3608 /** Conference port number. */
3609 pjsua_conf_port_id slot_id;
3610
3611 /** Port name. */
3612 pj_str_t name;
3613
3614 /** Clock rate. */
3615 unsigned clock_rate;
3616
3617 /** Number of channels. */
3618 unsigned channel_count;
3619
3620 /** Samples per frame */
3621 unsigned samples_per_frame;
3622
3623 /** Bits per sample */
3624 unsigned bits_per_sample;
3625
3626 /** Number of listeners in the array. */
3627 unsigned listener_cnt;
3628
3629 /** Array of listeners (in other words, ports where this port is
3630 * transmitting to.
3631 */
3632 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
3633
3634} pjsua_conf_port_info;
3635
3636
3637/**
3638 * This structure holds information about custom media transport to
3639 * be registered to pjsua.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003640 *
3641 * \par Python:
3642 * Not applicable.
Benny Prijono312aff92006-06-17 04:08:30 +00003643 */
3644typedef struct pjsua_media_transport
3645{
3646 /**
3647 * Media socket information containing the address information
3648 * of the RTP and RTCP socket.
3649 */
3650 pjmedia_sock_info skinfo;
3651
3652 /**
3653 * The media transport instance.
3654 */
3655 pjmedia_transport *transport;
3656
3657} pjsua_media_transport;
3658
3659
3660
3661
Benny Prijono9fc735d2006-05-28 14:58:12 +00003662/**
3663 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003664 *
3665 * @return Maximum number of ports in the conference bridge.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003666 *
3667 * \par Python:
3668 * \code
3669 port_count = py_pjsua.conf_get_max_ports()
3670 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003671 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003672PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003673
3674
3675/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003676 * Get current number of active ports in the bridge.
3677 *
3678 * @return The number.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003679 *
3680 * \par Python:
3681 * \code
3682 count = py_pjsua.conf_get_active_ports()
3683 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003684 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003685PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
3686
3687
3688/**
3689 * Enumerate all conference ports.
3690 *
3691 * @param id Array of conference port ID to be initialized.
3692 * @param count On input, specifies max elements in the array.
3693 * On return, it contains actual number of elements
3694 * that have been initialized.
3695 *
3696 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003697 *
3698 * \par Python:
3699 * The Python functions returns list of conference port Ids:
3700 * \code
3701 [port_ids] = py_pjsua.enum_conf_ports()
3702 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003703 */
3704PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
3705 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003706
3707
3708/**
3709 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003710 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003711 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003712 * @param info Pointer to store the port info.
3713 *
3714 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003715 *
3716 * \par Python:
3717 * \code
3718 port_info = py_pjsua.conf_get_port_info(port_id)
3719 * \endcode
3720 * The function will return None if \a port_id is not valid.
Benny Prijono8b1889b2006-06-06 18:40:40 +00003721 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003722PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00003723 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003724
3725
3726/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00003727 * Add arbitrary media port to PJSUA's conference bridge. Application
3728 * can use this function to add the media port that it creates. For
3729 * media ports that are created by PJSUA-LIB (such as calls, file player,
3730 * or file recorder), PJSUA-LIB will automatically add the port to
3731 * the bridge.
3732 *
3733 * @param pool Pool to use.
3734 * @param port Media port to be added to the bridge.
3735 * @param p_id Optional pointer to receive the conference
3736 * slot id.
3737 *
3738 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003739 *
3740 * \par Python:
3741 * Not applicable (for now)
Benny Prijonoe909eac2006-07-27 22:04:56 +00003742 */
3743PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
3744 pjmedia_port *port,
3745 pjsua_conf_port_id *p_id);
3746
3747
3748/**
3749 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00003750 * call this function if it registered the port manually with previous call
3751 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00003752 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003753 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00003754 *
3755 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003756 *
3757 * \par Python:
3758 * \code
3759 status = py_pjsua.conf_remove_port(port_id)
3760 * \endcode
Benny Prijonoe909eac2006-07-27 22:04:56 +00003761 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003762PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00003763
3764
3765/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003766 * Establish unidirectional media flow from souce to sink. One source
3767 * may transmit to multiple destinations/sink. And if multiple
3768 * sources are transmitting to the same sink, the media will be mixed
3769 * together. Source and sink may refer to the same ID, effectively
3770 * looping the media.
3771 *
3772 * If bidirectional media flow is desired, application needs to call
3773 * this function twice, with the second one having the arguments
3774 * reversed.
3775 *
3776 * @param source Port ID of the source media/transmitter.
3777 * @param sink Port ID of the destination media/received.
3778 *
3779 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003780 *
3781 * \par Python:
3782 * \code
3783 status = py_pjsua.conf_connect(source, sink)
3784 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003785 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003786PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
3787 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003788
3789
3790/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003791 * Disconnect media flow from the source to destination port.
3792 *
3793 * @param source Port ID of the source media/transmitter.
3794 * @param sink Port ID of the destination media/received.
3795 *
3796 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003797 *
3798 * \par Python:
3799 * \code
3800 status = py_pjsua.conf_disconnect(source, sink)
3801 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003802 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003803PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
3804 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003805
3806
Benny Prijono6dd967c2006-12-26 02:27:14 +00003807/**
3808 * Adjust the signal level to be transmitted from the bridge to the
3809 * specified port by making it louder or quieter.
3810 *
3811 * @param slot The conference bridge slot number.
3812 * @param level Signal level adjustment. Value 1.0 means no level
3813 * adjustment, while value 0 means to mute the port.
3814 *
3815 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003816 *
3817 * \par Python:
3818 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003819 */
3820PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
3821 float level);
3822
3823/**
3824 * Adjust the signal level to be received from the specified port (to
3825 * the bridge) by making it louder or quieter.
3826 *
3827 * @param slot The conference bridge slot number.
3828 * @param level Signal level adjustment. Value 1.0 means no level
3829 * adjustment, while value 0 means to mute the port.
3830 *
3831 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003832 *
3833 * \par Python:
3834 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003835 */
3836PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
3837 float level);
3838
3839/**
3840 * Get last signal level transmitted to or received from the specified port.
3841 * The signal level is an integer value in zero to 255, with zero indicates
3842 * no signal, and 255 indicates the loudest signal level.
3843 *
3844 * @param slot The conference bridge slot number.
3845 * @param tx_level Optional argument to receive the level of signal
3846 * transmitted to the specified port (i.e. the direction
3847 * is from the bridge to the port).
3848 * @param rx_level Optional argument to receive the level of signal
3849 * received from the port (i.e. the direction is from the
3850 * port to the bridge).
3851 *
3852 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003853 *
3854 * \par Python:
3855 * Not implemented (yet)
Benny Prijono6dd967c2006-12-26 02:27:14 +00003856 */
3857PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
3858 unsigned *tx_level,
3859 unsigned *rx_level);
3860
Benny Prijono6dd967c2006-12-26 02:27:14 +00003861
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003862/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00003863 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003864 */
3865
Benny Prijono9fc735d2006-05-28 14:58:12 +00003866/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003867 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003868 * the conference bridge.
3869 *
3870 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00003871 * WAV files are supported, and the WAV file MUST be
3872 * formatted as 16bit PCM mono/single channel (any
3873 * clock rate is supported).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003874 * @param options Options (currently zero).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003875 * @param p_id Pointer to receive player ID.
3876 *
3877 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003878 *
3879 * \par Python:
3880 * The function returns (status, id) tuple:
3881 * \code
3882 status, id = py_pjsua.player_create(filename, options)
3883 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003884 */
3885PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003886 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003887 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003888
3889
3890/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003891 * Create a file playlist media port, and automatically add the port
3892 * to the conference bridge.
3893 *
3894 * @param file_names Array of file names to be added to the play list.
3895 * Note that the files must have the same clock rate,
3896 * number of channels, and number of bits per sample.
3897 * @param file_count Number of files in the array.
3898 * @param label Optional label to be set for the media port.
3899 * @param options Optional option flag. Application may specify
3900 * PJMEDIA_FILE_NO_LOOP to prevent looping.
3901 * @param p_id Optional pointer to receive player ID.
3902 *
3903 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003904 *
3905 * \par Python:
3906 * Not implemented yet.
Benny Prijonoa66c3312007-01-21 23:12:40 +00003907 */
3908PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
3909 unsigned file_count,
3910 const pj_str_t *label,
3911 unsigned options,
3912 pjsua_player_id *p_id);
3913
3914/**
3915 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003916 *
3917 * @param id The file player ID.
3918 *
3919 * @return Conference port ID associated with this player.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003920 *
3921 * \par Python:
3922 * \code
3923 port_id = py_pjsua.player_get_conf_port(id)
3924 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003925 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003926PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003927
3928
3929/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003930 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00003931 *
3932 * @param id The player ID.
3933 * @param p_port The media port associated with the player.
3934 *
3935 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003936 *
3937 * \par Python:
3938 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00003939 */
3940PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_recorder_id id,
3941 pjmedia_port **p_port);
3942
3943/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003944 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003945 *
3946 * @param id The file player ID.
3947 * @param samples The playback position, in samples. Application can
3948 * specify zero to re-start the playback.
3949 *
3950 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003951 *
3952 * \par Python:
3953 * \code
3954 status = py_pjsua.player_set_pos(id, samples)
3955 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003956 */
3957PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
3958 pj_uint32_t samples);
3959
3960
3961/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003962 * Close the file of playlist, remove the player from the bridge, and free
3963 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003964 *
3965 * @param id The file player ID.
3966 *
3967 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003968 *
3969 * \par Python:
3970 * \code
3971 status = py_pjsua.player_destroy(id)
3972 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00003973 */
3974PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
3975
3976
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003977/*****************************************************************************
3978 * File recorder.
3979 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00003980
3981/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003982 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00003983 * the conference bridge. The recorder currently supports recording WAV file.
3984 * The type of the recorder to use is determined by the extension of the file
3985 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003986 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00003987 * @param filename Output file name. The function will determine the
3988 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00003989 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00003990 * @param enc_type Optionally specify the type of encoder to be used to
3991 * compress the media, if the file can support different
3992 * encodings. This value must be zero for now.
3993 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00003994 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00003995 * For .WAV recorder, this value must be NULL.
3996 * @param max_size Maximum file size. Specify zero or -1 to remove size
3997 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003998 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003999 * @param p_id Pointer to receive the recorder instance.
4000 *
4001 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004002 *
4003 * \par Python:
4004 * \code
4005 status, id = py_pjsua.recorder_create(filename, enc_type, enc_param, max_size, options)
4006 * \endcode
4007 * The \a enc_param is a string in Python.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004008 */
4009PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004010 unsigned enc_type,
4011 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004012 pj_ssize_t max_size,
4013 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004014 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004015
4016
4017/**
4018 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004019 *
4020 * @param id The recorder ID.
4021 *
4022 * @return Conference port ID associated with this recorder.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004023 *
4024 * \par Python:
4025 * \code
4026 port_id = py_pjsua.recorder_get_conf_port(id)
4027 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004028 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004029PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004030
4031
4032/**
Benny Prijono469b1522006-12-26 03:05:17 +00004033 * Get the media port for the recorder.
4034 *
4035 * @param id The recorder ID.
4036 * @param p_port The media port associated with the recorder.
4037 *
4038 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004039 *
4040 * \par Python:
4041 * Not applicable.
Benny Prijono469b1522006-12-26 03:05:17 +00004042 */
4043PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4044 pjmedia_port **p_port);
4045
4046
4047/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004048 * Destroy recorder (this will complete recording).
4049 *
4050 * @param id The recorder ID.
4051 *
4052 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004053 *
4054 * \par Python:
4055 * \code
4056 status = py_pjsua.recorder_destroy(id)
4057 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004058 */
4059PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4060
4061
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004062/*****************************************************************************
4063 * Sound devices.
4064 */
4065
Benny Prijono9fc735d2006-05-28 14:58:12 +00004066/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004067 * Enum all sound devices installed in the system.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004068 *
4069 * @param info Array of info to be initialized.
4070 * @param count On input, specifies max elements in the array.
4071 * On return, it contains actual number of elements
4072 * that have been initialized.
4073 *
4074 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004075 *
4076 *
4077 * \par Python:
4078 * The function returns list of sound device info:
4079 * \code
4080 [dev_infos] = py_pjsua.enum_snd_devs()
4081 * \endcode
4082 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00004083 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004084PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4085 unsigned *count);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004086
4087
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004088
4089/**
4090 * Get currently active sound devices. If sound devices has not been created
4091 * (for example when pjsua_start() is not called), it is possible that
4092 * the function returns PJ_SUCCESS with -1 as device IDs.
4093 *
4094 * @param capture_dev On return it will be filled with device ID of the
4095 * capture device.
4096 * @param playback_dev On return it will be filled with device ID of the
4097 * device ID of the playback device.
4098 *
4099 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004100 *
4101 * \par Python:
Benny Prijonoebdf8772007-02-01 19:25:50 +00004102 * The function takes no argument and return an (integer,integer) tuple:
Benny Prijonoe6ead542007-01-31 20:53:31 +00004103 * \code
4104 capture_dev, playback_dev = py_pjsua.get_snd_dev()
4105 * \endcode
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004106 */
4107PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4108 int *playback_dev);
4109
4110
Benny Prijono9fc735d2006-05-28 14:58:12 +00004111/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004112 * Select or change sound device. Application may call this function at
4113 * any time to replace current sound device.
4114 *
4115 * @param capture_dev Device ID of the capture device.
4116 * @param playback_dev Device ID of the playback device.
4117 *
4118 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004119 *
4120 * \par Python:
4121 * \code
4122 status = py_pjsua.set_snd_dev(capture_dev, playback_dev)
4123 * \endcode
Benny Prijono9fc735d2006-05-28 14:58:12 +00004124 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004125PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4126 int playback_dev);
4127
4128
4129/**
4130 * Set pjsua to use null sound device. The null sound device only provides
4131 * the timing needed by the conference bridge, and will not interract with
4132 * any hardware.
4133 *
4134 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004135 *
4136 * \par Python:
4137 * \code
4138 status = py_pjsua.set_null_snd_dev()
4139 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004140 */
4141PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4142
4143
Benny Prijonoe909eac2006-07-27 22:04:56 +00004144/**
4145 * Disconnect the main conference bridge from any sound devices, and let
4146 * application connect the bridge to it's own sound device/master port.
4147 *
4148 * @return The port interface of the conference bridge,
4149 * so that application can connect this to it's own
4150 * sound device or master port.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004151 *
4152 * \par Python:
4153 * Not applicable (for now).
Benny Prijonoe909eac2006-07-27 22:04:56 +00004154 */
4155PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4156
4157
Benny Prijonof20687a2006-08-04 18:27:19 +00004158/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004159 * Configure the echo canceller tail length of the sound port.
Benny Prijonof20687a2006-08-04 18:27:19 +00004160 *
4161 * @param tail_ms The tail length, in miliseconds. Set to zero to
4162 * disable AEC.
Benny Prijono5da50432006-08-07 10:24:52 +00004163 * @param options Options to be passed to #pjmedia_echo_create().
4164 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004165 *
4166 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004167 *
4168 * \par Python:
4169 * \code
4170 status = py_pjsua.set_ec(tail_ms, options)
4171 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004172 */
Benny Prijono5da50432006-08-07 10:24:52 +00004173PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004174
4175
4176/**
Benny Prijono22dfe592006-08-06 12:07:13 +00004177 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004178 *
4179 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4180 * If AEC is disabled, the value will be zero.
4181 *
4182 * @return PJ_SUCCESS on success.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004183 *
4184 * \par Python:
4185 * \code
4186 tail_ms = py_pjsua.get_ec_tail()
4187 * \endcode
Benny Prijonof20687a2006-08-04 18:27:19 +00004188 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004189PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004190
4191
4192
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004193/*****************************************************************************
4194 * Codecs.
4195 */
4196
4197/**
4198 * Enum all supported codecs in the system.
4199 *
4200 * @param id Array of ID to be initialized.
4201 * @param count On input, specifies max elements in the array.
4202 * On return, it contains actual number of elements
4203 * that have been initialized.
4204 *
4205 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004206 *
4207 * \par Python:
4208 * This function takes no argument and returns list of codec infos:
4209 * \code
4210 [codec_info] = py_pjsua.enum_codecs()
4211 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004212 */
4213PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4214 unsigned *count );
4215
4216
4217/**
4218 * Change codec priority.
4219 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004220 * @param codec_id Codec ID, which is a string that uniquely identify
4221 * the codec (such as "speex/8000"). Please see pjsua
4222 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004223 * @param priority Codec priority, 0-255, where zero means to disable
4224 * the codec.
4225 *
4226 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004227 *
4228 * \par Python:
4229 * \code
4230 status = py_pjsua.codec_set_priority(codec_id, priority)
4231 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004232 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004233PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004234 pj_uint8_t priority );
4235
4236
4237/**
4238 * Get codec parameters.
4239 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004240 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004241 * @param param Structure to receive codec parameters.
4242 *
4243 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004244 *
4245 * \par Python:
4246 * The Python function is experimental:
4247 * \code
4248 codec_param = py_pjsua.codec_get_param(codec_id)
4249 * \endcode
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004250 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004251PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004252 pjmedia_codec_param *param );
4253
4254
4255/**
4256 * Set codec parameters.
4257 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004258 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004259 * @param param Codec parameter to set.
4260 *
4261 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004262 *
4263 * \par Python:
4264 * The Python function is experimental:
4265 * \code
4266 status = py_pjsua.codec_set_param(codec_id, param)
4267 * \endcode
4268
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004269 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004270PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004271 const pjmedia_codec_param *param);
4272
4273
4274
Benny Prijono9fc735d2006-05-28 14:58:12 +00004275
Benny Prijono312aff92006-06-17 04:08:30 +00004276/**
4277 * Create UDP media transports for all the calls. This function creates
4278 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00004279 *
Benny Prijono312aff92006-06-17 04:08:30 +00004280 * @param cfg Media transport configuration. The "port" field in the
4281 * configuration is used as the start port to bind the
4282 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004283 *
4284 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004285 *
4286 * \par Python:
4287 * Not implemented yet.
Benny Prijonof3195072006-02-14 21:15:30 +00004288 */
Benny Prijono312aff92006-06-17 04:08:30 +00004289PJ_DECL(pj_status_t)
4290pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00004291
Benny Prijonodc39fe82006-05-26 12:17:46 +00004292
4293/**
Benny Prijono312aff92006-06-17 04:08:30 +00004294 * Register custom media transports to be used by calls. There must
4295 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004296 *
Benny Prijono312aff92006-06-17 04:08:30 +00004297 * @param tp The media transport array.
4298 * @param count Number of elements in the array. This number MUST
4299 * match the number of maximum calls configured when
4300 * pjsua is created.
4301 * @param auto_delete Flag to indicate whether the transports should be
4302 * destroyed when pjsua is shutdown.
4303 *
4304 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoe6ead542007-01-31 20:53:31 +00004305 *
4306 * \par Python:
4307 * Note applicable.
Benny Prijonodc39fe82006-05-26 12:17:46 +00004308 */
Benny Prijono312aff92006-06-17 04:08:30 +00004309PJ_DECL(pj_status_t)
4310pjsua_media_transports_attach( pjsua_media_transport tp[],
4311 unsigned count,
4312 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00004313
4314
Benny Prijono312aff92006-06-17 04:08:30 +00004315/**
4316 * @}
4317 */
4318
Benny Prijonof3195072006-02-14 21:15:30 +00004319
Benny Prijono268ca612006-02-07 12:34:11 +00004320
Benny Prijono312aff92006-06-17 04:08:30 +00004321/**
4322 * @}
4323 */
4324
Benny Prijonoe6ead542007-01-31 20:53:31 +00004325PJ_END_DECL
4326
Benny Prijono312aff92006-06-17 04:08:30 +00004327
Benny Prijono268ca612006-02-07 12:34:11 +00004328#endif /* __PJSUA_H__ */