blob: 012f5b191bb61729e590e1dc3957ac877e2d00fb [file] [log] [blame]
Benny Prijono268ca612006-02-07 12:34:11 +00001/* $Id$ */
2/*
Benny Prijono844653c2008-12-23 17:27:53 +00003 * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
Benny Prijono32177c02008-06-20 22:44:47 +00004 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
Benny Prijono268ca612006-02-07 12:34:11 +00005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#ifndef __PJSUA_H__
21#define __PJSUA_H__
22
Benny Prijono312aff92006-06-17 04:08:30 +000023/**
24 * @file pjsua.h
25 * @brief PJSUA API.
26 */
27
28
Benny Prijono268ca612006-02-07 12:34:11 +000029/* Include all PJSIP core headers. */
30#include <pjsip.h>
31
32/* Include all PJMEDIA headers. */
33#include <pjmedia.h>
34
Benny Prijono1f9afba2006-02-10 15:57:32 +000035/* Include all PJMEDIA-CODEC headers. */
36#include <pjmedia-codec.h>
37
Benny Prijono268ca612006-02-07 12:34:11 +000038/* Include all PJSIP-UA headers */
39#include <pjsip_ua.h>
40
Benny Prijono834aee32006-02-19 01:38:06 +000041/* Include all PJSIP-SIMPLE headers */
42#include <pjsip_simple.h>
43
Benny Prijono4ab9fbb2007-10-12 12:14:27 +000044/* Include all PJNATH headers */
45#include <pjnath.h>
46
Benny Prijono268ca612006-02-07 12:34:11 +000047/* Include all PJLIB-UTIL headers. */
48#include <pjlib-util.h>
49
50/* Include all PJLIB headers. */
51#include <pjlib.h>
52
53
Benny Prijonoe6ead542007-01-31 20:53:31 +000054PJ_BEGIN_DECL
55
56
Benny Prijono312aff92006-06-17 04:08:30 +000057/**
Benny Prijono58163a22009-06-03 08:40:24 +000058 * @defgroup PJSUA_LIB PJSUA API - High Level Softphone API
Benny Prijono312aff92006-06-17 04:08:30 +000059 * @brief Very high level API for constructing SIP UA applications.
60 * @{
61 *
Benny Prijono58163a22009-06-03 08:40:24 +000062 * @section pjsua_api_intro A SIP User Agent API for C/C++
Benny Prijonoe6ead542007-01-31 20:53:31 +000063 *
Benny Prijono58163a22009-06-03 08:40:24 +000064 * PJSUA API is very high level API for constructing SIP multimedia user agent
Benny Prijono312aff92006-06-17 04:08:30 +000065 * applications. It wraps together the signaling and media functionalities
66 * into an easy to use call API, provides account management, buddy
67 * management, presence, instant messaging, along with multimedia
68 * features such as conferencing, file streaming, local playback,
69 * voice recording, and so on.
70 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000071 * @subsection pjsua_for_c_cpp C/C++ Binding
Benny Prijono312aff92006-06-17 04:08:30 +000072 * Application must link with <b>pjsua-lib</b> to use this API. In addition,
73 * this library depends on the following libraries:
74 * - <b>pjsip-ua</b>,
75 * - <b>pjsip-simple</b>,
76 * - <b>pjsip-core</b>,
77 * - <b>pjmedia</b>,
78 * - <b>pjmedia-codec</b>,
79 * - <b>pjlib-util</b>, and
80 * - <b>pjlib</b>,
81 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000082 * so application must also link with these libraries as well. For more
83 * information, please refer to
84 * <A HREF="http://www.pjsip.org/using.htm">Getting Started with PJSIP</A>
85 * page.
Benny Prijono312aff92006-06-17 04:08:30 +000086 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000087 * @section pjsua_samples
88 *
Benny Prijono58163a22009-06-03 08:40:24 +000089 * Few samples are provided:
Benny Prijonoe6ead542007-01-31 20:53:31 +000090 *
91 - @ref page_pjsip_sample_simple_pjsuaua_c\n
92 Very simple SIP User Agent with registration, call, and media, using
93 PJSUA-API, all in under 200 lines of code.
94
95 - @ref page_pjsip_samples_pjsua\n
96 This is the reference implementation for PJSIP and PJMEDIA.
97 PJSUA is a console based application, designed to be simple enough
98 to be readble, but powerful enough to demonstrate all features
99 available in PJSIP and PJMEDIA.\n
100
Benny Prijono312aff92006-06-17 04:08:30 +0000101 * @section root_using_pjsua_lib Using PJSUA API
102 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000103 * Please refer to @ref PJSUA_LIB_BASE on how to create and initialize the API.
104 * And then see the Modules on the bottom of this page for more information
105 * about specific subject.
Benny Prijono312aff92006-06-17 04:08:30 +0000106 */
107
Benny Prijonoa91a0032006-02-26 21:23:45 +0000108
Benny Prijonof3195072006-02-14 21:15:30 +0000109
Benny Prijono312aff92006-06-17 04:08:30 +0000110/*****************************************************************************
111 * BASE API
112 */
113
Benny Prijonof04ffdd2006-02-21 00:11:18 +0000114/**
Benny Prijonoe6ead542007-01-31 20:53:31 +0000115 * @defgroup PJSUA_LIB_BASE PJSUA-API Basic API
Benny Prijono312aff92006-06-17 04:08:30 +0000116 * @ingroup PJSUA_LIB
117 * @brief Basic application creation/initialization, logging configuration, etc.
118 * @{
119 *
120 * The base PJSUA API controls PJSUA creation, initialization, and startup, and
121 * also provides various auxiliary functions.
122 *
123 * @section using_pjsua_lib Using PJSUA Library
124 *
125 * @subsection creating_pjsua_lib Creating PJSUA
126 *
Benny Prijono58163a22009-06-03 08:40:24 +0000127 * Before anything else, application must create PJSUA by calling
128 * #pjsua_create().
Benny Prijono312aff92006-06-17 04:08:30 +0000129 * This, among other things, will initialize PJLIB, which is crucial before
Benny Prijonoe6ead542007-01-31 20:53:31 +0000130 * any PJLIB functions can be called, PJLIB-UTIL, and create a SIP endpoint.
131 *
132 * After this function is called, application can create a memory pool (with
133 * #pjsua_pool_create()) and read configurations from command line or file to
134 * build the settings to initialize PJSUA below.
Benny Prijono312aff92006-06-17 04:08:30 +0000135 *
136 * @subsection init_pjsua_lib Initializing PJSUA
137 *
138 * After PJSUA is created, application can initialize PJSUA by calling
Benny Prijonoe6ead542007-01-31 20:53:31 +0000139 * #pjsua_init(). This function takes several optional configuration settings
140 * in the argument, if application wants to set them.
Benny Prijono312aff92006-06-17 04:08:30 +0000141 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000142 * @subsubsection init_pjsua_lib_c_cpp PJSUA-LIB Initialization (in C)
143 * Sample code to initialize PJSUA in C code:
Benny Prijono312aff92006-06-17 04:08:30 +0000144 \code
145
Benny Prijonob5388cf2007-01-04 22:45:08 +0000146 #include <pjsua-lib/pjsua.h>
147
148 #define THIS_FILE __FILE__
149
150 static pj_status_t app_init(void)
151 {
Benny Prijono312aff92006-06-17 04:08:30 +0000152 pjsua_config ua_cfg;
153 pjsua_logging_config log_cfg;
154 pjsua_media_config media_cfg;
Benny Prijonob5388cf2007-01-04 22:45:08 +0000155 pj_status_t status;
156
157 // Must create pjsua before anything else!
158 status = pjsua_create();
159 if (status != PJ_SUCCESS) {
160 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
161 return status;
162 }
Benny Prijono312aff92006-06-17 04:08:30 +0000163
164 // Initialize configs with default settings.
165 pjsua_config_default(&ua_cfg);
166 pjsua_logging_config_default(&log_cfg);
167 pjsua_media_config_default(&media_cfg);
168
169 // At the very least, application would want to override
170 // the call callbacks in pjsua_config:
171 ua_cfg.cb.on_incoming_call = ...
172 ua_cfg.cb.on_call_state = ..
173 ...
174
175 // Customize other settings (or initialize them from application specific
176 // configuration file):
177 ...
178
179 // Initialize pjsua
180 status = pjsua_init(&ua_cfg, &log_cfg, &media_cfg);
181 if (status != PJ_SUCCESS) {
182 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
183 return status;
184 }
Benny Prijonob5388cf2007-01-04 22:45:08 +0000185 .
186 ...
187 }
Benny Prijono312aff92006-06-17 04:08:30 +0000188 \endcode
189 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000190 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000191
192
Benny Prijono312aff92006-06-17 04:08:30 +0000193 * @subsection other_init_pjsua_lib Other Initialization
194 *
195 * After PJSUA is initialized with #pjsua_init(), application will normally
196 * need/want to perform the following tasks:
197 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000198 * - create SIP transport with #pjsua_transport_create(). Application would
199 * to call #pjsua_transport_create() for each transport types that it
200 * wants to support (for example, UDP, TCP, and TLS). Please see
Benny Prijono312aff92006-06-17 04:08:30 +0000201 * @ref PJSUA_LIB_TRANSPORT section for more info.
202 * - create one or more SIP accounts with #pjsua_acc_add() or
Benny Prijonoe6ead542007-01-31 20:53:31 +0000203 * #pjsua_acc_add_local(). The SIP account is used for registering with
204 * the SIP server, if any. Please see @ref PJSUA_LIB_ACC for more info.
Benny Prijono312aff92006-06-17 04:08:30 +0000205 * - add one or more buddies with #pjsua_buddy_add(). Please see
206 * @ref PJSUA_LIB_BUDDY section for more info.
207 * - optionally configure the sound device, codec settings, and other
208 * media settings. Please see @ref PJSUA_LIB_MEDIA for more info.
209 *
210 *
211 * @subsection starting_pjsua_lib Starting PJSUA
212 *
213 * After all initializations have been done, application must call
214 * #pjsua_start() to start PJSUA. This function will check that all settings
Benny Prijonoe6ead542007-01-31 20:53:31 +0000215 * have been properly configured, and apply default settings when they haven't,
216 * or report error status when it is unable to recover from missing settings.
Benny Prijono312aff92006-06-17 04:08:30 +0000217 *
218 * Most settings can be changed during run-time. For example, application
219 * may add, modify, or delete accounts, buddies, or change media settings
220 * during run-time.
Benny Prijonob5388cf2007-01-04 22:45:08 +0000221 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000222 * @subsubsection starting_pjsua_lib_c C Example for Starting PJSUA
Benny Prijonob5388cf2007-01-04 22:45:08 +0000223 * Sample code:
224 \code
225 static pj_status_t app_run(void)
226 {
227 pj_status_t status;
228
229 // Start pjsua
230 status = pjsua_start();
231 if (status != PJ_SUCCESS) {
232 pjsua_destroy();
233 pjsua_perror(THIS_FILE, "Error starting pjsua", status);
234 return status;
235 }
236
237 // Run application loop
238 while (1) {
239 char choice[10];
240
241 printf("Select menu: ");
242 fgets(choice, sizeof(choice), stdin);
243 ...
244 }
245 }
246 \endcode
Benny Prijonoe6ead542007-01-31 20:53:31 +0000247
Benny Prijonof04ffdd2006-02-21 00:11:18 +0000248 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000249
Benny Prijono312aff92006-06-17 04:08:30 +0000250/** Constant to identify invalid ID for all sorts of IDs. */
251#define PJSUA_INVALID_ID (-1)
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000252
Benny Prijono0bc99a92011-03-17 04:34:43 +0000253/** Disabled features temporarily for media reorganization */
254#define DISABLED_FOR_TICKET_1185 0
255
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000256/** Call identification */
257typedef int pjsua_call_id;
258
Benny Prijono312aff92006-06-17 04:08:30 +0000259/** Account identification */
260typedef int pjsua_acc_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000261
262/** Buddy identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000263typedef int pjsua_buddy_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000264
265/** File player identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000266typedef int pjsua_player_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000267
268/** File recorder identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000269typedef int pjsua_recorder_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000270
271/** Conference port identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000272typedef int pjsua_conf_port_id;
273
Benny Prijono63fba012008-07-17 14:19:10 +0000274/** Opaque declaration for server side presence subscription */
275typedef struct pjsua_srv_pres pjsua_srv_pres;
276
277/** Forward declaration for pjsua_msg_data */
278typedef struct pjsua_msg_data pjsua_msg_data;
Benny Prijono8b1889b2006-06-06 18:40:40 +0000279
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000280
Benny Prijonoa91a0032006-02-26 21:23:45 +0000281/**
Benny Prijono312aff92006-06-17 04:08:30 +0000282 * Maximum proxies in account.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000283 */
Benny Prijono312aff92006-06-17 04:08:30 +0000284#ifndef PJSUA_ACC_MAX_PROXIES
285# define PJSUA_ACC_MAX_PROXIES 8
286#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000287
Benny Prijonod8179652008-01-23 20:39:07 +0000288/**
289 * Default value of SRTP mode usage. Valid values are PJMEDIA_SRTP_DISABLED,
290 * PJMEDIA_SRTP_OPTIONAL, and PJMEDIA_SRTP_MANDATORY.
291 */
292#ifndef PJSUA_DEFAULT_USE_SRTP
293 #define PJSUA_DEFAULT_USE_SRTP PJMEDIA_SRTP_DISABLED
294#endif
295
296/**
297 * Default value of secure signaling requirement for SRTP.
298 * Valid values are:
299 * 0: SRTP does not require secure signaling
300 * 1: SRTP requires secure transport such as TLS
301 * 2: SRTP requires secure end-to-end transport (SIPS)
302 */
303#ifndef PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
304 #define PJSUA_DEFAULT_SRTP_SECURE_SIGNALING 1
305#endif
306
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000307/**
Benny Prijono07fe2302010-06-24 12:33:18 +0000308 * Controls whether PJSUA-LIB should add ICE media feature tag
309 * parameter (the ";+sip.ice" parameter) to Contact header if ICE
310 * is enabled in the config.
311 *
312 * Default: 1
313 */
314#ifndef PJSUA_ADD_ICE_TAGS
315# define PJSUA_ADD_ICE_TAGS 1
316#endif
317
Sauw Ming844c1c92010-09-07 05:12:02 +0000318/**
319 * Timeout value used to acquire mutex lock on a particular call.
320 *
321 * Default: 2000 ms
322 */
323#ifndef PJSUA_ACQUIRE_CALL_TIMEOUT
324# define PJSUA_ACQUIRE_CALL_TIMEOUT 2000
325#endif
326
Benny Prijono07fe2302010-06-24 12:33:18 +0000327
328/**
Benny Prijono0bc99a92011-03-17 04:34:43 +0000329 * This enumeration represents pjsua state.
330 */
331typedef enum pjsua_state
332{
333 /**
334 * The library has not been initialized.
335 */
336 PJSUA_STATE_NULL,
337
338 /**
339 * After pjsua_create() is called but before pjsua_init() is called.
340 */
341 PJSUA_STATE_CREATED,
342
343 /**
344 * After pjsua_init() is called but before pjsua_start() is called.
345 */
346 PJSUA_STATE_INIT,
347
348 /**
349 * After pjsua_start() is called but before everything is running.
350 */
351 PJSUA_STATE_STARTING,
352
353 /**
354 * After pjsua_start() is called and before pjsua_destroy() is called.
355 */
356 PJSUA_STATE_RUNNING,
357
358 /**
359 * After pjsua_destroy() is called but before the function returns.
360 */
361 PJSUA_STATE_CLOSING
362
363} pjsua_state;
364
365
366/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000367 * Logging configuration, which can be (optionally) specified when calling
368 * #pjsua_init(). Application must call #pjsua_logging_config_default() to
369 * initialize this structure with the default values.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000370 */
371typedef struct pjsua_logging_config
372{
373 /**
374 * Log incoming and outgoing SIP message? Yes!
375 */
376 pj_bool_t msg_logging;
377
378 /**
379 * Input verbosity level. Value 5 is reasonable.
380 */
381 unsigned level;
382
383 /**
384 * Verbosity level for console. Value 4 is reasonable.
385 */
386 unsigned console_level;
387
388 /**
389 * Log decoration.
390 */
391 unsigned decor;
392
393 /**
394 * Optional log filename.
395 */
396 pj_str_t log_filename;
397
398 /**
Benny Prijonodbe3f4b2009-05-07 16:56:04 +0000399 * Additional flags to be given to #pj_file_open() when opening
400 * the log file. By default, the flag is PJ_O_WRONLY. Application
401 * may set PJ_O_APPEND here so that logs are appended to existing
402 * file instead of overwriting it.
403 *
404 * Default is 0.
405 */
406 unsigned log_file_flags;
407
408 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000409 * Optional callback function to be called to write log to
410 * application specific device. This function will be called for
411 * log messages on input verbosity level.
412 */
Benny Prijonofe7d87b2007-11-29 11:35:44 +0000413 void (*cb)(int level, const char *data, int len);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000414
415
416} pjsua_logging_config;
417
418
419/**
420 * Use this function to initialize logging config.
421 *
422 * @param cfg The logging config to be initialized.
423 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000424PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000425
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000426
427/**
428 * Use this function to duplicate logging config.
429 *
430 * @param pool Pool to use.
431 * @param dst Destination config.
432 * @param src Source config.
433 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000434PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool,
435 pjsua_logging_config *dst,
436 const pjsua_logging_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000437
Benny Prijonodc39fe82006-05-26 12:17:46 +0000438
439/**
Benny Prijono4dd961b2009-10-26 11:21:37 +0000440 * Structure to be passed on MWI callback.
441 */
442typedef struct pjsua_mwi_info
443{
444 pjsip_evsub *evsub; /**< Event subscription session, for
445 reference. */
446 pjsip_rx_data *rdata; /**< The received NOTIFY request. */
447} pjsua_mwi_info;
448
449
450/**
Nanang Izzuddin4ea1bcc2010-09-28 04:57:01 +0000451 * Structure to be passed on registration callback.
452 */
453typedef struct pjsua_reg_info
454{
455 struct pjsip_regc_cbparam *cbparam; /**< Parameters returned by
456 registration callback. */
457} pjsua_reg_info;
458
459
460/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000461 * This structure describes application callback to receive various event
462 * notification from PJSUA-API. All of these callbacks are OPTIONAL,
463 * although definitely application would want to implement some of
464 * the important callbacks (such as \a on_incoming_call).
Benny Prijonodc39fe82006-05-26 12:17:46 +0000465 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000466typedef struct pjsua_callback
Benny Prijonodc39fe82006-05-26 12:17:46 +0000467{
468 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000469 * Notify application when invite state has changed.
470 * Application may then query the call info to get the
Benny Prijonoe6ead542007-01-31 20:53:31 +0000471 * detail call states by calling pjsua_call_get_info() function.
Benny Prijono0875ae82006-12-26 00:11:48 +0000472 *
473 * @param call_id The call index.
474 * @param e Event which causes the call state to change.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000475 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000476 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000477
478 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000479 * Notify application on incoming call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000480 *
481 * @param acc_id The account which match the incoming call.
482 * @param call_id The call id that has just been created for
483 * the call.
484 * @param rdata The incoming INVITE request.
Benny Prijono8b1889b2006-06-06 18:40:40 +0000485 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000486 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000487 pjsip_rx_data *rdata);
488
489 /**
Benny Prijonofeb69f42007-10-05 09:12:26 +0000490 * This is a general notification callback which is called whenever
491 * a transaction within the call has changed state. Application can
492 * implement this callback for example to monitor the state of
493 * outgoing requests, or to answer unhandled incoming requests
494 * (such as INFO) with a final response.
495 *
496 * @param call_id Call identification.
497 * @param tsx The transaction which has changed state.
498 * @param e Transaction event that caused the state change.
499 */
500 void (*on_call_tsx_state)(pjsua_call_id call_id,
501 pjsip_transaction *tsx,
502 pjsip_event *e);
503
504 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000505 * Notify application when media state in the call has changed.
506 * Normal application would need to implement this callback, e.g.
Benny Prijono6ba8c542007-10-16 01:34:14 +0000507 * to connect the call's media to sound device. When ICE is used,
508 * this callback will also be called to report ICE negotiation
509 * failure.
Benny Prijono0875ae82006-12-26 00:11:48 +0000510 *
511 * @param call_id The call index.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000512 */
513 void (*on_call_media_state)(pjsua_call_id call_id);
514
Benny Prijonofc13bf62008-02-20 08:56:15 +0000515
516 /**
517 * Notify application when media session is created and before it is
518 * registered to the conference bridge. Application may return different
519 * media port if it has added media processing port to the stream. This
520 * media port then will be added to the conference bridge instead.
521 *
522 * @param call_id Call identification.
Benny Prijono0bc99a92011-03-17 04:34:43 +0000523 * @param strm Media stream.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000524 * @param stream_idx Stream index in the media session.
525 * @param p_port On input, it specifies the media port of the
526 * stream. Application may modify this pointer to
527 * point to different media port to be registered
528 * to the conference bridge.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000529 */
530 void (*on_stream_created)(pjsua_call_id call_id,
Benny Prijono0bc99a92011-03-17 04:34:43 +0000531 pjmedia_stream *strm,
Benny Prijonofc13bf62008-02-20 08:56:15 +0000532 unsigned stream_idx,
533 pjmedia_port **p_port);
534
535 /**
536 * Notify application when media session has been unregistered from the
537 * conference bridge and about to be destroyed.
538 *
539 * @param call_id Call identification.
Benny Prijono0bc99a92011-03-17 04:34:43 +0000540 * @param strm Media stream.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000541 * @param stream_idx Stream index in the media session.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000542 */
543 void (*on_stream_destroyed)(pjsua_call_id call_id,
Benny Prijono0bc99a92011-03-17 04:34:43 +0000544 pjmedia_stream *strm,
Benny Prijonofc13bf62008-02-20 08:56:15 +0000545 unsigned stream_idx);
546
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000547 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000548 * Notify application upon incoming DTMF digits.
549 *
550 * @param call_id The call index.
551 * @param digit DTMF ASCII digit.
552 */
553 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
554
555 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000556 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000557 * Application can decide to accept/reject transfer request
Benny Prijonoc54dcb32008-04-08 23:33:15 +0000558 * by setting the code (default is 202). When this callback
Benny Prijono9fc735d2006-05-28 14:58:12 +0000559 * is not defined, the default behavior is to accept the
560 * transfer.
Benny Prijono0875ae82006-12-26 00:11:48 +0000561 *
562 * @param call_id The call index.
563 * @param dst The destination where the call will be
564 * transfered to.
565 * @param code Status code to be returned for the call transfer
566 * request. On input, it contains status code 200.
Benny Prijono9fc735d2006-05-28 14:58:12 +0000567 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000568 void (*on_call_transfer_request)(pjsua_call_id call_id,
569 const pj_str_t *dst,
570 pjsip_status_code *code);
571
572 /**
573 * Notify application of the status of previously sent call
574 * transfer request. Application can monitor the status of the
575 * call transfer request, for example to decide whether to
576 * terminate existing call.
577 *
578 * @param call_id Call ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000579 * @param st_code Status progress of the transfer request.
580 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000581 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000582 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000583 * this callback is the final status.
584 * @param p_cont Initially will be set to non-zero, application
585 * can set this to FALSE if it no longer wants
586 * to receie further notification (for example,
587 * after it hangs up the call).
588 */
589 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000590 int st_code,
591 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000592 pj_bool_t final,
593 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000594
595 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000596 * Notify application about incoming INVITE with Replaces header.
597 * Application may reject the request by setting non-2xx code.
598 *
599 * @param call_id The call ID to be replaced.
600 * @param rdata The incoming INVITE request to replace the call.
601 * @param st_code Status code to be set by application. Application
602 * should only return a final status (200-699).
603 * @param st_text Optional status text to be set by application.
604 */
605 void (*on_call_replace_request)(pjsua_call_id call_id,
606 pjsip_rx_data *rdata,
607 int *st_code,
608 pj_str_t *st_text);
609
610 /**
611 * Notify application that an existing call has been replaced with
612 * a new call. This happens when PJSUA-API receives incoming INVITE
613 * request with Replaces header.
614 *
615 * After this callback is called, normally PJSUA-API will disconnect
616 * \a old_call_id and establish \a new_call_id.
617 *
618 * @param old_call_id Existing call which to be replaced with the
619 * new call.
620 * @param new_call_id The new call.
621 * @param rdata The incoming INVITE with Replaces request.
622 */
623 void (*on_call_replaced)(pjsua_call_id old_call_id,
624 pjsua_call_id new_call_id);
625
626
627 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000628 * Notify application when registration status has changed.
629 * Application may then query the account info to get the
630 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000631 *
Nanang Izzuddin4ea1bcc2010-09-28 04:57:01 +0000632 * @param acc_id The account ID.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000633 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000634 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000635
636 /**
Nanang Izzuddin4ea1bcc2010-09-28 04:57:01 +0000637 * Notify application when registration status has changed.
638 * Application may inspect the registration info to get the
639 * registration status details.
640 *
641 * @param acc_id The account ID.
642 * @param info The registration info.
643 */
644 void (*on_reg_state2)(pjsua_acc_id acc_id, pjsua_reg_info *info);
645
646 /**
Benny Prijono63fba012008-07-17 14:19:10 +0000647 * Notification when incoming SUBSCRIBE request is received. Application
648 * may use this callback to authorize the incoming subscribe request
649 * (e.g. ask user permission if the request should be granted).
650 *
651 * If this callback is not implemented, all incoming presence subscription
652 * requests will be accepted.
653 *
654 * If this callback is implemented, application has several choices on
655 * what to do with the incoming request:
656 * - it may reject the request immediately by specifying non-200 class
657 * final response in the \a code argument.
658 * - it may immediately accept the request by specifying 200 as the
659 * \a code argument. This is the default value if application doesn't
660 * set any value to the \a code argument. In this case, the library
661 * will automatically send NOTIFY request upon returning from this
662 * callback.
663 * - it may delay the processing of the request, for example to request
664 * user permission whether to accept or reject the request. In this
665 * case, the application MUST set the \a code argument to 202, and
666 * later calls #pjsua_pres_notify() to accept or reject the
667 * subscription request.
668 *
669 * Any \a code other than 200 and 202 will be treated as 200.
670 *
671 * Application MUST return from this callback immediately (e.g. it must
672 * not block in this callback while waiting for user confirmation).
673 *
674 * @param srv_pres Server presence subscription instance. If
675 * application delays the acceptance of the request,
676 * it will need to specify this object when calling
677 * #pjsua_pres_notify().
678 * @param acc_id Account ID most appropriate for this request.
679 * @param buddy_id ID of the buddy matching the sender of the
680 * request, if any, or PJSUA_INVALID_ID if no
681 * matching buddy is found.
682 * @param from The From URI of the request.
683 * @param rdata The incoming request.
684 * @param code The status code to respond to the request. The
685 * default value is 200. Application may set this
686 * to other final status code to accept or reject
687 * the request.
688 * @param reason The reason phrase to respond to the request.
689 * @param msg_data If the application wants to send additional
690 * headers in the response, it can put it in this
691 * parameter.
692 */
693 void (*on_incoming_subscribe)(pjsua_acc_id acc_id,
694 pjsua_srv_pres *srv_pres,
695 pjsua_buddy_id buddy_id,
696 const pj_str_t *from,
697 pjsip_rx_data *rdata,
698 pjsip_status_code *code,
699 pj_str_t *reason,
700 pjsua_msg_data *msg_data);
701
702 /**
703 * Notification when server side subscription state has changed.
704 * This callback is optional as application normally does not need
705 * to do anything to maintain server side presence subscription.
706 *
707 * @param acc_id The account ID.
708 * @param srv_pres Server presence subscription object.
709 * @param remote_uri Remote URI string.
710 * @param state New subscription state.
711 * @param event PJSIP event that triggers the state change.
712 */
713 void (*on_srv_subscribe_state)(pjsua_acc_id acc_id,
714 pjsua_srv_pres *srv_pres,
715 const pj_str_t *remote_uri,
716 pjsip_evsub_state state,
717 pjsip_event *event);
718
719 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000720 * Notify application when the buddy state has changed.
721 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000722 *
723 * @param buddy_id The buddy id.
Benny Prijono9fc735d2006-05-28 14:58:12 +0000724 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000725 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000726
Benny Prijono63499892010-10-12 12:45:15 +0000727
728 /**
729 * Notify application when the state of client subscription session
730 * associated with a buddy has changed. Application may use this
731 * callback to retrieve more detailed information about the state
732 * changed event.
733 *
734 * @param buddy_id The buddy id.
735 * @param sub Event subscription session.
736 * @param event The event which triggers state change event.
737 */
738 void (*on_buddy_evsub_state)(pjsua_buddy_id buddy_id,
739 pjsip_evsub *sub,
740 pjsip_event *event);
741
Benny Prijono9fc735d2006-05-28 14:58:12 +0000742 /**
743 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000744 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000745 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000746 *
Benny Prijonobbeb3992007-05-21 13:48:35 +0000747 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
748 * passed as one of the argument.
749 *
Benny Prijono0875ae82006-12-26 00:11:48 +0000750 * @param call_id Containts the ID of the call where the IM was
751 * sent, or PJSUA_INVALID_ID if the IM was sent
752 * outside call context.
753 * @param from URI of the sender.
754 * @param to URI of the destination message.
755 * @param contact The Contact URI of the sender, if present.
756 * @param mime_type MIME type of the message.
757 * @param body The message content.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000758 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000759 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
760 const pj_str_t *to, const pj_str_t *contact,
761 const pj_str_t *mime_type, const pj_str_t *body);
762
763 /**
Benny Prijonobbeb3992007-05-21 13:48:35 +0000764 * This is the alternative version of the \a on_pager() callback with
765 * \a pjsip_rx_data argument.
766 *
767 * @param call_id Containts the ID of the call where the IM was
768 * sent, or PJSUA_INVALID_ID if the IM was sent
769 * outside call context.
770 * @param from URI of the sender.
771 * @param to URI of the destination message.
772 * @param contact The Contact URI of the sender, if present.
773 * @param mime_type MIME type of the message.
774 * @param body The message content.
775 * @param rdata The incoming MESSAGE request.
Benny Prijonoba736c42008-07-10 20:45:03 +0000776 * @param acc_id Account ID most suitable for this message.
Benny Prijonobbeb3992007-05-21 13:48:35 +0000777 */
778 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
779 const pj_str_t *to, const pj_str_t *contact,
780 const pj_str_t *mime_type, const pj_str_t *body,
Benny Prijonoba736c42008-07-10 20:45:03 +0000781 pjsip_rx_data *rdata, pjsua_acc_id acc_id);
Benny Prijonobbeb3992007-05-21 13:48:35 +0000782
783 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000784 * Notify application about the delivery status of outgoing pager
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000785 * request. See also on_pager_status2() callback for the version with
786 * \a pjsip_rx_data in the argument list.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000787 *
788 * @param call_id Containts the ID of the call where the IM was
789 * sent, or PJSUA_INVALID_ID if the IM was sent
790 * outside call context.
791 * @param to Destination URI.
792 * @param body Message body.
793 * @param user_data Arbitrary data that was specified when sending
794 * IM message.
795 * @param status Delivery status.
796 * @param reason Delivery status reason.
797 */
798 void (*on_pager_status)(pjsua_call_id call_id,
799 const pj_str_t *to,
800 const pj_str_t *body,
801 void *user_data,
802 pjsip_status_code status,
803 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000804
805 /**
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000806 * Notify application about the delivery status of outgoing pager
807 * request.
808 *
809 * @param call_id Containts the ID of the call where the IM was
810 * sent, or PJSUA_INVALID_ID if the IM was sent
811 * outside call context.
812 * @param to Destination URI.
813 * @param body Message body.
814 * @param user_data Arbitrary data that was specified when sending
815 * IM message.
816 * @param status Delivery status.
817 * @param reason Delivery status reason.
Benny Prijono0a982002007-06-12 16:22:09 +0000818 * @param tdata The original MESSAGE request.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000819 * @param rdata The incoming MESSAGE response, or NULL if the
820 * message transaction fails because of time out
821 * or transport error.
Benny Prijonoba736c42008-07-10 20:45:03 +0000822 * @param acc_id Account ID from this the instant message was
823 * send.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000824 */
825 void (*on_pager_status2)(pjsua_call_id call_id,
826 const pj_str_t *to,
827 const pj_str_t *body,
828 void *user_data,
829 pjsip_status_code status,
830 const pj_str_t *reason,
Benny Prijono0a982002007-06-12 16:22:09 +0000831 pjsip_tx_data *tdata,
Benny Prijonoba736c42008-07-10 20:45:03 +0000832 pjsip_rx_data *rdata,
833 pjsua_acc_id acc_id);
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000834
835 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000836 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +0000837 *
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 from URI of the sender.
842 * @param to URI of the destination message.
843 * @param contact The Contact URI of the sender, if present.
844 * @param is_typing Non-zero if peer is typing, or zero if peer
845 * has stopped typing a message.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000846 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000847 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
848 const pj_str_t *to, const pj_str_t *contact,
849 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000850
Benny Prijono6ba8c542007-10-16 01:34:14 +0000851 /**
Benny Prijonoba736c42008-07-10 20:45:03 +0000852 * Notify application about typing indication.
853 *
854 * @param call_id Containts the ID of the call where the IM was
855 * sent, or PJSUA_INVALID_ID if the IM was sent
856 * outside call context.
857 * @param from URI of the sender.
858 * @param to URI of the destination message.
859 * @param contact The Contact URI of the sender, if present.
860 * @param is_typing Non-zero if peer is typing, or zero if peer
861 * has stopped typing a message.
862 * @param rdata The received request.
863 * @param acc_id Account ID most suitable for this message.
864 */
865 void (*on_typing2)(pjsua_call_id call_id, const pj_str_t *from,
866 const pj_str_t *to, const pj_str_t *contact,
867 pj_bool_t is_typing, pjsip_rx_data *rdata,
868 pjsua_acc_id acc_id);
869
870 /**
Benny Prijono6ba8c542007-10-16 01:34:14 +0000871 * Callback when the library has finished performing NAT type
872 * detection.
873 *
874 * @param res NAT detection result.
875 */
876 void (*on_nat_detect)(const pj_stun_nat_detect_result *res);
877
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000878 /**
879 * This callback is called when the call is about to resend the
880 * INVITE request to the specified target, following the previously
881 * received redirection response.
882 *
883 * Application may accept the redirection to the specified target
884 * (the default behavior if this callback is implemented), reject
885 * this target only and make the session continue to try the next
886 * target in the list if such target exists, stop the whole
887 * redirection process altogether and cause the session to be
888 * disconnected, or defer the decision to ask for user confirmation.
889 *
890 * This callback is optional. If this callback is not implemented,
891 * the default behavior is to NOT follow the redirection response.
892 *
893 * @param call_id The call ID.
894 * @param target The current target to be tried.
Benny Prijono08a48b82008-11-27 12:42:07 +0000895 * @param e The event that caused this callback to be called.
896 * This could be the receipt of 3xx response, or
897 * 4xx/5xx response received for the INVITE sent to
898 * subsequent targets, or NULL if this callback is
899 * called from within #pjsua_call_process_redirect()
900 * context.
901 *
902 * @return Action to be performed for the target. Set this
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000903 * parameter to one of the value below:
904 * - PJSIP_REDIRECT_ACCEPT: immediately accept the
905 * redirection (default value). When set, the
906 * call will immediately resend INVITE request
907 * to the target.
908 * - PJSIP_REDIRECT_REJECT: immediately reject this
909 * target. The call will continue retrying with
910 * next target if present, or disconnect the call
911 * if there is no more target to try.
912 * - PJSIP_REDIRECT_STOP: stop the whole redirection
913 * process and immediately disconnect the call. The
914 * on_call_state() callback will be called with
915 * PJSIP_INV_STATE_DISCONNECTED state immediately
916 * after this callback returns.
917 * - PJSIP_REDIRECT_PENDING: set to this value if
918 * no decision can be made immediately (for example
919 * to request confirmation from user). Application
920 * then MUST call #pjsua_call_process_redirect()
921 * to either accept or reject the redirection upon
922 * getting user decision.
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000923 */
Benny Prijono08a48b82008-11-27 12:42:07 +0000924 pjsip_redirect_op (*on_call_redirected)(pjsua_call_id call_id,
925 const pjsip_uri *target,
926 const pjsip_event *e);
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000927
Benny Prijono4dd961b2009-10-26 11:21:37 +0000928 /**
929 * This callback is called when a NOTIFY request for message summary /
930 * message waiting indication is received.
931 *
932 * @param acc_id The account ID.
933 * @param mwi_info Structure containing details of the event,
934 * including the received NOTIFY request in the
935 * \a rdata field.
936 */
937 void (*on_mwi_info)(pjsua_acc_id acc_id, pjsua_mwi_info *mwi_info);
938
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +0000939 /**
940 * This callback is called when transport state is changed. See also
941 * #pjsip_tp_state_callback.
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +0000942 */
Nanang Izzuddin5e69da52010-02-25 11:58:19 +0000943 pjsip_tp_state_callback on_transport_state;
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +0000944
Benny Prijono4d6ff4d2010-06-19 12:35:33 +0000945 /**
946 * This callback is called to report error in ICE media transport.
947 * Currently it is used to report TURN Refresh error.
948 *
949 * @param index Transport index.
950 * @param op Operation which trigger the failure.
951 * @param status Error status.
952 * @param param Additional info about the event. Currently this will
953 * always be set to NULL.
954 */
955 void (*on_ice_transport_error)(int index, pj_ice_strans_op op,
956 pj_status_t status, void *param);
957
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000958} pjsua_callback;
959
960
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +0000961/**
962 * This enumeration specifies the usage of SIP Session Timers extension.
963 */
964typedef enum pjsua_sip_timer_use
965{
966 /**
967 * When this flag is specified, Session Timers will not be used in any
968 * session, except it is explicitly required in the remote request.
969 */
970 PJSUA_SIP_TIMER_INACTIVE,
971
972 /**
973 * When this flag is specified, Session Timers will be used in all
974 * sessions whenever remote supports and uses it.
975 */
976 PJSUA_SIP_TIMER_OPTIONAL,
977
978 /**
979 * When this flag is specified, Session Timers support will be
980 * a requirement for the remote to be able to establish a session.
981 */
982 PJSUA_SIP_TIMER_REQUIRED,
983
984 /**
985 * When this flag is specified, Session Timers will always be used
986 * in all sessions, regardless whether remote supports/uses it or not.
987 */
988 PJSUA_SIP_TIMER_ALWAYS
989
990} pjsua_sip_timer_use;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000991
Benny Prijonodc39fe82006-05-26 12:17:46 +0000992
993/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000994 * This structure describes the settings to control the API and
995 * user agent behavior, and can be specified when calling #pjsua_init().
996 * Before setting the values, application must call #pjsua_config_default()
997 * to initialize this structure with the default values.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000998 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000999typedef struct pjsua_config
1000{
1001
1002 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001003 * Maximum calls to support (default: 4). The value specified here
1004 * must be smaller than the compile time maximum settings
1005 * PJSUA_MAX_CALLS, which by default is 32. To increase this
1006 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
1007 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001008 */
1009 unsigned max_calls;
1010
1011 /**
1012 * Number of worker threads. Normally application will want to have at
1013 * least one worker thread, unless when it wants to poll the library
1014 * periodically, which in this case the worker thread can be set to
1015 * zero.
1016 */
1017 unsigned thread_cnt;
1018
1019 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +00001020 * Number of nameservers. If no name server is configured, the SIP SRV
1021 * resolution would be disabled, and domain will be resolved with
1022 * standard pj_gethostbyname() function.
1023 */
1024 unsigned nameserver_count;
1025
1026 /**
1027 * Array of nameservers to be used by the SIP resolver subsystem.
1028 * The order of the name server specifies the priority (first name
1029 * server will be used first, unless it is not reachable).
1030 */
1031 pj_str_t nameserver[4];
1032
1033 /**
Benny Prijono91d06b62008-09-20 12:16:56 +00001034 * Force loose-route to be used in all route/proxy URIs (outbound_proxy
1035 * and account's proxy settings). When this setting is enabled, the
1036 * library will check all the route/proxy URIs specified in the settings
1037 * and append ";lr" parameter to the URI if the parameter is not present.
1038 *
1039 * Default: 1
1040 */
1041 pj_bool_t force_lr;
1042
1043 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001044 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001045 */
1046 unsigned outbound_proxy_cnt;
1047
1048 /**
1049 * Specify the URL of outbound proxies to visit for all outgoing requests.
1050 * The outbound proxies will be used for all accounts, and it will
1051 * be used to build the route set for outgoing requests. The final
1052 * route set for outgoing requests will consists of the outbound proxies
1053 * and the proxy configured in the account.
1054 */
1055 pj_str_t outbound_proxy[4];
1056
Benny Prijonoc97608e2007-03-23 16:34:20 +00001057 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001058 * Warning: deprecated, please use \a stun_srv field instead. To maintain
1059 * backward compatibility, if \a stun_srv_cnt is zero then the value of
1060 * this field will be copied to \a stun_srv field, if present.
1061 *
Benny Prijonoebbf6892007-03-24 17:37:25 +00001062 * Specify domain name to be resolved with DNS SRV resolution to get the
Benny Prijonof76e1392008-06-06 14:51:48 +00001063 * address of the STUN server. Alternatively application may specify
1064 * \a stun_host instead.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001065 *
1066 * If DNS SRV resolution failed for this domain, then DNS A resolution
1067 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +00001068 */
Benny Prijonoebbf6892007-03-24 17:37:25 +00001069 pj_str_t stun_domain;
1070
1071 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001072 * Warning: deprecated, please use \a stun_srv field instead. To maintain
1073 * backward compatibility, if \a stun_srv_cnt is zero then the value of
1074 * this field will be copied to \a stun_srv field, if present.
1075 *
Benny Prijonoaf09dc32007-04-22 12:48:30 +00001076 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
1077 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001078 */
1079 pj_str_t stun_host;
1080
1081 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001082 * Number of STUN server entries in \a stun_srv array.
1083 */
1084 unsigned stun_srv_cnt;
1085
1086 /**
1087 * Array of STUN servers to try. The library will try to resolve and
1088 * contact each of the STUN server entry until it finds one that is
1089 * usable. Each entry may be a domain name, host name, IP address, and
1090 * it may contain an optional port number. For example:
1091 * - "pjsip.org" (domain name)
1092 * - "sip.pjsip.org" (host name)
1093 * - "pjsip.org:33478" (domain name and a non-standard port number)
1094 * - "10.0.0.1:3478" (IP address and port number)
1095 *
1096 * When nameserver is configured in the \a pjsua_config.nameserver field,
1097 * if entry is not an IP address, it will be resolved with DNS SRV
1098 * resolution first, and it will fallback to use DNS A resolution if this
1099 * fails. Port number may be specified even if the entry is a domain name,
1100 * in case the DNS SRV resolution should fallback to a non-standard port.
1101 *
1102 * When nameserver is not configured, entries will be resolved with
1103 * #pj_gethostbyname() if it's not an IP address. Port number may be
1104 * specified if the server is not listening in standard STUN port.
1105 */
1106 pj_str_t stun_srv[8];
1107
1108 /**
1109 * This specifies if the library startup should ignore failure with the
1110 * STUN servers. If this is set to PJ_FALSE, the library will refuse to
1111 * start if it fails to resolve or contact any of the STUN servers.
1112 *
1113 * Default: PJ_TRUE
1114 */
1115 pj_bool_t stun_ignore_failure;
1116
1117 /**
Benny Prijono91a6a172007-10-31 08:59:29 +00001118 * Support for adding and parsing NAT type in the SDP to assist
1119 * troubleshooting. The valid values are:
1120 * - 0: no information will be added in SDP, and parsing is disabled.
Benny Prijono6ba8c542007-10-16 01:34:14 +00001121 * - 1: only the NAT type number is added.
1122 * - 2: add both NAT type number and name.
1123 *
Benny Prijono91a6a172007-10-31 08:59:29 +00001124 * Default: 1
Benny Prijono6ba8c542007-10-16 01:34:14 +00001125 */
1126 int nat_type_in_sdp;
1127
1128 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001129 * Specify whether support for reliable provisional response (100rel and
1130 * PRACK) should be required by default. Note that this setting can be
1131 * further customized in account configuration (#pjsua_acc_config).
1132 *
1133 * Default: PJ_FALSE
1134 */
1135 pj_bool_t require_100rel;
1136
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001137 /**
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001138 * Specify the usage of Session Timers for all sessions. See the
1139 * #pjsua_sip_timer_use for possible values. Note that this setting can be
1140 * further customized in account configuration (#pjsua_acc_config).
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001141 *
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001142 * Default: PJSUA_SIP_TIMER_OPTIONAL
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001143 */
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001144 pjsua_sip_timer_use use_timer;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001145
1146 /**
Benny Prijonofe1bd342009-11-20 23:33:07 +00001147 * Handle unsolicited NOTIFY requests containing message waiting
1148 * indication (MWI) info. Unsolicited MWI is incoming NOTIFY requests
1149 * which are not requested by client with SUBSCRIBE request.
1150 *
1151 * If this is enabled, the library will respond 200/OK to the NOTIFY
1152 * request and forward the request to \a on_mwi_info() callback.
1153 *
1154 * See also \a mwi_enabled field #on pjsua_acc_config.
1155 *
1156 * Default: PJ_TRUE
1157 *
1158 */
1159 pj_bool_t enable_unsolicited_mwi;
1160
1161 /**
Nanang Izzuddin65add622009-08-11 16:26:20 +00001162 * Specify Session Timer settings, see #pjsip_timer_setting.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001163 * Note that this setting can be further customized in account
1164 * configuration (#pjsua_acc_config).
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001165 */
Nanang Izzuddin65add622009-08-11 16:26:20 +00001166 pjsip_timer_setting timer_setting;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001167
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001168 /**
1169 * Number of credentials in the credential array.
1170 */
1171 unsigned cred_count;
1172
1173 /**
1174 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +00001175 * and can be used to authenticate against outbound proxies. If the
1176 * credential is specific to the account, then application should set
1177 * the credential in the pjsua_acc_config rather than the credential
1178 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001179 */
1180 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1181
1182 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001183 * Application callback to receive various event notifications from
1184 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001185 */
1186 pjsua_callback cb;
1187
Benny Prijono56315612006-07-18 14:39:40 +00001188 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001189 * Optional user agent string (default empty). If it's empty, no
1190 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +00001191 */
1192 pj_str_t user_agent;
1193
Benny Prijonod8179652008-01-23 20:39:07 +00001194 /**
1195 * Specify default value of secure media transport usage.
1196 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
1197 * PJMEDIA_SRTP_MANDATORY.
1198 *
1199 * Note that this setting can be further customized in account
1200 * configuration (#pjsua_acc_config).
1201 *
1202 * Default: #PJSUA_DEFAULT_USE_SRTP
1203 */
1204 pjmedia_srtp_use use_srtp;
1205
1206 /**
1207 * Specify whether SRTP requires secure signaling to be used. This option
1208 * is only used when \a use_srtp option above is non-zero.
1209 *
1210 * Valid values are:
1211 * 0: SRTP does not require secure signaling
1212 * 1: SRTP requires secure transport such as TLS
1213 * 2: SRTP requires secure end-to-end transport (SIPS)
1214 *
1215 * Note that this setting can be further customized in account
1216 * configuration (#pjsua_acc_config).
1217 *
1218 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
1219 */
1220 int srtp_secure_signaling;
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00001221
1222 /**
Benny Prijono0bc99a92011-03-17 04:34:43 +00001223 * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00001224 * duplicated media in SDP offer, i.e: unsecured and secured version.
Benny Prijono0bc99a92011-03-17 04:34:43 +00001225 * Otherwise, the SDP media will be composed as unsecured media but
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00001226 * with SDP "crypto" attribute.
1227 *
1228 * Default: PJ_FALSE
1229 */
1230 pj_bool_t srtp_optional_dup_offer;
Benny Prijonod8179652008-01-23 20:39:07 +00001231
Benny Prijono3c5e28b2008-09-24 10:10:15 +00001232 /**
1233 * Disconnect other call legs when more than one 2xx responses for
1234 * outgoing INVITE are received due to forking. Currently the library
1235 * is not able to handle simultaneous forked media, so disconnecting
1236 * the other call legs is necessary.
1237 *
1238 * With this setting enabled, the library will handle only one of the
1239 * connected call leg, and the other connected call legs will be
1240 * disconnected.
1241 *
1242 * Default: PJ_TRUE (only disable this setting for testing purposes).
1243 */
1244 pj_bool_t hangup_forked_call;
1245
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001246} pjsua_config;
1247
1248
1249/**
1250 * Use this function to initialize pjsua config.
1251 *
1252 * @param cfg pjsua config to be initialized.
1253 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001254PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001255
1256
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001257/** The implementation has been moved to sip_auth.h */
Benny Prijono7977f9f2007-10-10 11:37:56 +00001258#define pjsip_cred_dup pjsip_cred_info_dup
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001259
1260
1261/**
1262 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001263 *
1264 * @param pool The pool to get memory from.
1265 * @param dst Destination config.
1266 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001267 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001268PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1269 pjsua_config *dst,
1270 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001271
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001272
1273/**
1274 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001275 * outgoing SIP message. It can (optionally) be specified for example
1276 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1277 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1278 *
1279 * Application MUST call #pjsua_msg_data_init() to initialize this
1280 * structure before setting its values.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001281 */
Benny Prijono63fba012008-07-17 14:19:10 +00001282struct pjsua_msg_data
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001283{
1284 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001285 * Additional message headers as linked list. Application can add
1286 * headers to the list by creating the header, either from the heap/pool
1287 * or from temporary local variable, and add the header using
1288 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001289 */
1290 pjsip_hdr hdr_list;
1291
1292 /**
1293 * MIME type of optional message body.
1294 */
1295 pj_str_t content_type;
1296
1297 /**
Benny Prijono1c1d7342010-08-01 09:48:51 +00001298 * Optional message body to be added to the message, only when the
1299 * message doesn't have a body.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001300 */
1301 pj_str_t msg_body;
1302
Benny Prijono1c1d7342010-08-01 09:48:51 +00001303 /**
1304 * Content type of the multipart body. If application wants to send
1305 * multipart message bodies, it puts the parts in \a parts and set
1306 * the content type in \a multipart_ctype. If the message already
1307 * contains a body, the body will be added to the multipart bodies.
1308 */
1309 pjsip_media_type multipart_ctype;
1310
1311 /**
1312 * List of multipart parts. If application wants to send multipart
1313 * message bodies, it puts the parts in \a parts and set the content
1314 * type in \a multipart_ctype. If the message already contains a body,
1315 * the body will be added to the multipart bodies.
1316 */
1317 pjsip_multipart_part multipart_parts;
Benny Prijono63fba012008-07-17 14:19:10 +00001318};
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001319
1320
1321/**
1322 * Initialize message data.
1323 *
1324 * @param msg_data Message data to be initialized.
1325 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001326PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001327
Benny Prijono268ca612006-02-07 12:34:11 +00001328
1329/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001330 * Instantiate pjsua application. Application must call this function before
1331 * calling any other functions, to make sure that the underlying libraries
1332 * are properly initialized. Once this function has returned success,
1333 * application must call pjsua_destroy() before quitting.
1334 *
1335 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00001336 */
1337PJ_DECL(pj_status_t) pjsua_create(void);
1338
1339
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001340/** Forward declaration */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001341typedef struct pjsua_media_config pjsua_media_config;
1342
1343
Benny Prijonodc39fe82006-05-26 12:17:46 +00001344/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001345 * Initialize pjsua with the specified settings. All the settings are
1346 * optional, and the default values will be used when the config is not
1347 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001348 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001349 * Note that #pjsua_create() MUST be called before calling this function.
1350 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001351 * @param ua_cfg User agent configuration.
1352 * @param log_cfg Optional logging configuration.
1353 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001354 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001355 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001356 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001357PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1358 const pjsua_logging_config *log_cfg,
1359 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001360
1361
1362/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001363 * Application is recommended to call this function after all initialization
1364 * is done, so that the library can do additional checking set up
1365 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001366 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001367 * Application may call this function anytime after #pjsua_init().
1368 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001369 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoccf95622006-02-07 18:48:01 +00001370 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001371PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001372
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001373
Benny Prijonoccf95622006-02-07 18:48:01 +00001374/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001375 * Destroy pjsua. Application is recommended to perform graceful shutdown
1376 * before calling this function (such as unregister the account from the SIP
1377 * server, terminate presense subscription, and hangup active calls), however,
1378 * this function will do all of these if it finds there are active sessions
1379 * that need to be terminated. This function will approximately block for
1380 * one second to wait for replies from remote.
1381 *
1382 * Application.may safely call this function more than once if it doesn't
1383 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001384 *
1385 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001386 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001387PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001388
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001389
Benny Prijono9fc735d2006-05-28 14:58:12 +00001390/**
Benny Prijono0bc99a92011-03-17 04:34:43 +00001391 * Retrieve pjsua state.
1392 *
1393 * @return pjsua state.
1394 */
1395PJ_DECL(pjsua_state) pjsua_get_state(void);
1396
1397
1398/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001399 * Poll pjsua for events, and if necessary block the caller thread for
1400 * the specified maximum interval (in miliseconds).
1401 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001402 * Application doesn't normally need to call this function if it has
1403 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1404 * because polling then will be done by these worker threads instead.
1405 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001406 * @param msec_timeout Maximum time to wait, in miliseconds.
1407 *
1408 * @return The number of events that have been handled during the
1409 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001410 * can retrieve the error as (status = -return_value).
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001411 */
1412PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1413
1414
1415/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001416 * Create memory pool to be used by the application. Once application
1417 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001418 *
1419 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001420 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001421 * @param increment Increment size.
1422 *
1423 * @return The pool, or NULL when there's no memory.
1424 */
1425PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1426 pj_size_t increment);
1427
1428
1429/**
1430 * Application can call this function at any time (after pjsua_create(), of
1431 * course) to change logging settings.
1432 *
1433 * @param c Logging configuration.
1434 *
1435 * @return PJ_SUCCESS on success, or the appropriate error code.
1436 */
1437PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1438
1439
1440/**
1441 * Internal function to get SIP endpoint instance of pjsua, which is
1442 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001443 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001444 *
1445 * @return SIP endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001446 */
1447PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1448
1449/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001450 * Internal function to get media endpoint instance.
1451 * Only valid after #pjsua_init() is called.
1452 *
1453 * @return Media endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001454 */
1455PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1456
Benny Prijono97b87172006-08-24 14:25:14 +00001457/**
1458 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001459 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001460 *
1461 * @return Pool factory currently used by PJSUA.
1462 */
1463PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1464
1465
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001466
1467/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001468 * Utilities.
1469 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001470 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001471
1472/**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001473 * This structure is used to represent the result of the STUN server
1474 * resolution and testing, the #pjsua_resolve_stun_servers() function.
1475 * This structure will be passed in #pj_stun_resolve_cb callback.
1476 */
1477typedef struct pj_stun_resolve_result
1478{
1479 /**
1480 * Arbitrary data that was passed to #pjsua_resolve_stun_servers()
1481 * function.
1482 */
1483 void *token;
1484
1485 /**
1486 * This will contain PJ_SUCCESS if at least one usable STUN server
1487 * is found, otherwise it will contain the last error code during
1488 * the operation.
1489 */
1490 pj_status_t status;
1491
1492 /**
1493 * The server name that yields successful result. This will only
1494 * contain value if status is successful.
1495 */
1496 pj_str_t name;
1497
1498 /**
1499 * The server IP address. This will only contain value if status
1500 * is successful.
1501 */
1502 pj_sockaddr addr;
1503
1504} pj_stun_resolve_result;
1505
1506
1507/**
1508 * Typedef of callback to be registered to #pjsua_resolve_stun_servers().
1509 */
1510typedef void (*pj_stun_resolve_cb)(const pj_stun_resolve_result *result);
1511
1512/**
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001513 * This is a utility function to detect NAT type in front of this
1514 * endpoint. Once invoked successfully, this function will complete
Benny Prijono6ba8c542007-10-16 01:34:14 +00001515 * asynchronously and report the result in \a on_nat_detect() callback
1516 * of pjsua_callback.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001517 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001518 * After NAT has been detected and the callback is called, application can
1519 * get the detected NAT type by calling #pjsua_get_nat_type(). Application
1520 * can also perform NAT detection by calling #pjsua_detect_nat_type()
1521 * again at later time.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001522 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001523 * Note that STUN must be enabled to run this function successfully.
1524 *
1525 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001526 */
Benny Prijono6ba8c542007-10-16 01:34:14 +00001527PJ_DECL(pj_status_t) pjsua_detect_nat_type(void);
1528
1529
1530/**
1531 * Get the NAT type as detected by #pjsua_detect_nat_type() function.
1532 * This function will only return useful NAT type after #pjsua_detect_nat_type()
1533 * has completed successfully and \a on_nat_detect() callback has been called.
1534 *
1535 * @param type NAT type.
1536 *
1537 * @return When detection is in progress, this function will
1538 * return PJ_EPENDING and \a type will be set to
1539 * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been
1540 * detected successfully, this function will return
1541 * PJ_SUCCESS and \a type will be set to the correct
1542 * value. Other return values indicate error and
1543 * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN.
Benny Prijono91a6a172007-10-31 08:59:29 +00001544 *
1545 * @see pjsua_call_get_rem_nat_type()
Benny Prijono6ba8c542007-10-16 01:34:14 +00001546 */
1547PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type);
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001548
1549
1550/**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001551 * Auxiliary function to resolve and contact each of the STUN server
1552 * entries (sequentially) to find which is usable. The #pjsua_init() must
1553 * have been called before calling this function.
1554 *
1555 * @param count Number of STUN server entries to try.
1556 * @param srv Array of STUN server entries to try. Please see
1557 * the \a stun_srv field in the #pjsua_config
1558 * documentation about the format of this entry.
1559 * @param wait Specify non-zero to make the function block until
1560 * it gets the result. In this case, the function
1561 * will block while the resolution is being done,
1562 * and the callback will be called before this function
1563 * returns.
1564 * @param token Arbitrary token to be passed back to application
1565 * in the callback.
1566 * @param cb Callback to be called to notify the result of
1567 * the function.
1568 *
1569 * @return If \a wait parameter is non-zero, this will return
1570 * PJ_SUCCESS if one usable STUN server is found.
1571 * Otherwise it will always return PJ_SUCCESS, and
1572 * application will be notified about the result in
1573 * the callback.
1574 */
1575PJ_DECL(pj_status_t) pjsua_resolve_stun_servers(unsigned count,
1576 pj_str_t srv[],
1577 pj_bool_t wait,
1578 void *token,
1579 pj_stun_resolve_cb cb);
1580
1581/**
1582 * Cancel pending STUN resolution which match the specified token.
1583 *
1584 * @param token The token to match. This token was given to
1585 * #pjsua_resolve_stun_servers()
1586 * @param notify_cb Boolean to control whether the callback should
1587 * be called for cancelled resolutions. When the
1588 * callback is called, the status in the result
1589 * will be set as PJ_ECANCELLED.
1590 *
1591 * @return PJ_SUCCESS if there is at least one pending STUN
1592 * resolution cancelled, or PJ_ENOTFOUND if there is
1593 * no matching one, or other error.
1594 */
1595PJ_DECL(pj_status_t) pjsua_cancel_stun_resolution(void *token,
1596 pj_bool_t notify_cb);
1597
1598
1599/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001600 * This is a utility function to verify that valid SIP url is given. If the
Benny Prijonoc7545782010-09-28 07:43:18 +00001601 * URL is a valid SIP/SIPS scheme, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001602 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001603 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001604 *
1605 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoc7545782010-09-28 07:43:18 +00001606 *
1607 * @see pjsua_verify_url()
Benny Prijono312aff92006-06-17 04:08:30 +00001608 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001609PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001610
1611
1612/**
Benny Prijonoc7545782010-09-28 07:43:18 +00001613 * This is a utility function to verify that valid URI is given. Unlike
1614 * pjsua_verify_sip_url(), this function will return PJ_SUCCESS if tel: URI
1615 * is given.
1616 *
1617 * @param url The URL, as NULL terminated string.
1618 *
1619 * @return PJ_SUCCESS on success, or the appropriate error code.
1620 *
1621 * @see pjsua_verify_sip_url()
1622 */
1623PJ_DECL(pj_status_t) pjsua_verify_url(const char *url);
1624
1625
1626/**
Benny Prijono73bb7232009-10-20 13:56:26 +00001627 * Schedule a timer entry. Note that the timer callback may be executed
1628 * by different thread, depending on whether worker thread is enabled or
1629 * not.
1630 *
1631 * @param entry Timer heap entry.
1632 * @param delay The interval to expire.
1633 *
1634 * @return PJ_SUCCESS on success, or the appropriate error code.
1635 *
1636 * @see pjsip_endpt_schedule_timer()
1637 */
1638PJ_DECL(pj_status_t) pjsua_schedule_timer(pj_timer_entry *entry,
1639 const pj_time_val *delay);
1640
1641
1642/**
1643 * Cancel the previously scheduled timer.
1644 *
1645 * @param entry Timer heap entry.
1646 *
1647 * @see pjsip_endpt_cancel_timer()
1648 */
1649PJ_DECL(void) pjsua_cancel_timer(pj_timer_entry *entry);
1650
1651
1652/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001653 * This is a utility function to display error message for the specified
1654 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001655 *
1656 * @param sender The log sender field.
1657 * @param title Message title for the error.
1658 * @param status Status code.
1659 */
1660PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1661 pj_status_t status);
1662
1663
Benny Prijonoda9785b2007-04-02 20:43:06 +00001664/**
1665 * This is a utility function to dump the stack states to log, using
1666 * verbosity level 3.
1667 *
1668 * @param detail Will print detailed output (such as list of
1669 * SIP transactions) when non-zero.
1670 */
1671PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001672
1673/**
1674 * @}
1675 */
1676
1677
1678
1679/*****************************************************************************
1680 * TRANSPORT API
1681 */
1682
1683/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001684 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001685 * @ingroup PJSUA_LIB
1686 * @brief API for managing SIP transports
1687 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001688 *
1689 * PJSUA-API supports creating multiple transport instances, for example UDP,
1690 * TCP, and TLS transport. SIP transport must be created before adding an
1691 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001692 */
1693
1694
Benny Prijonoe6ead542007-01-31 20:53:31 +00001695/** SIP transport identification.
1696 */
Benny Prijono312aff92006-06-17 04:08:30 +00001697typedef int pjsua_transport_id;
1698
1699
1700/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001701 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001702 * and media. Before setting some values to this structure, application
1703 * MUST call #pjsua_transport_config_default() to initialize its
1704 * values with default settings.
Benny Prijono312aff92006-06-17 04:08:30 +00001705 */
1706typedef struct pjsua_transport_config
1707{
1708 /**
1709 * UDP port number to bind locally. This setting MUST be specified
1710 * even when default port is desired. If the value is zero, the
1711 * transport will be bound to any available port, and application
1712 * can query the port by querying the transport info.
1713 */
1714 unsigned port;
1715
1716 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001717 * Optional address to advertise as the address of this transport.
1718 * Application can specify any address or hostname for this field,
1719 * for example it can point to one of the interface address in the
1720 * system, or it can point to the public address of a NAT router
1721 * where port mappings have been configured for the application.
1722 *
1723 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001724 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001725 pj_str_t public_addr;
1726
1727 /**
1728 * Optional address where the socket should be bound to. This option
1729 * SHOULD only be used to selectively bind the socket to particular
1730 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1731 * published address of a transport (the public_addr field should be
1732 * used for that purpose).
1733 *
1734 * Note that unlike public_addr field, the address (or hostname) here
1735 * MUST correspond to the actual interface address in the host, since
1736 * this address will be specified as bind() argument.
1737 */
1738 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001739
1740 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001741 * This specifies TLS settings for TLS transport. It is only be used
1742 * when this transport config is being used to create a SIP TLS
1743 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001744 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001745 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001746
Benny Prijono4d79b0f2009-10-25 09:02:07 +00001747 /**
1748 * QoS traffic type to be set on this transport. When application wants
1749 * to apply QoS tagging to the transport, it's preferable to set this
1750 * field rather than \a qos_param fields since this is more portable.
1751 *
1752 * Default is QoS not set.
1753 */
1754 pj_qos_type qos_type;
1755
1756 /**
1757 * Set the low level QoS parameters to the transport. This is a lower
1758 * level operation than setting the \a qos_type field and may not be
1759 * supported on all platforms.
1760 *
1761 * Default is QoS not set.
1762 */
1763 pj_qos_params qos_params;
1764
Benny Prijono312aff92006-06-17 04:08:30 +00001765} pjsua_transport_config;
1766
1767
1768/**
1769 * Call this function to initialize UDP config with default values.
1770 *
1771 * @param cfg The UDP config to be initialized.
1772 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001773PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001774
1775
1776/**
Benny Prijono312aff92006-06-17 04:08:30 +00001777 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001778 *
1779 * @param pool The pool.
1780 * @param dst The destination config.
1781 * @param src The source config.
Benny Prijono312aff92006-06-17 04:08:30 +00001782 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001783PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1784 pjsua_transport_config *dst,
1785 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001786
1787
1788/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001789 * This structure describes transport information returned by
1790 * #pjsua_transport_get_info() function.
Benny Prijono312aff92006-06-17 04:08:30 +00001791 */
1792typedef struct pjsua_transport_info
1793{
1794 /**
1795 * PJSUA transport identification.
1796 */
1797 pjsua_transport_id id;
1798
1799 /**
1800 * Transport type.
1801 */
1802 pjsip_transport_type_e type;
1803
1804 /**
1805 * Transport type name.
1806 */
1807 pj_str_t type_name;
1808
1809 /**
1810 * Transport string info/description.
1811 */
1812 pj_str_t info;
1813
1814 /**
1815 * Transport flag (see ##pjsip_transport_flags_e).
1816 */
1817 unsigned flag;
1818
1819 /**
1820 * Local address length.
1821 */
1822 unsigned addr_len;
1823
1824 /**
1825 * Local/bound address.
1826 */
1827 pj_sockaddr local_addr;
1828
1829 /**
1830 * Published address (or transport address name).
1831 */
1832 pjsip_host_port local_name;
1833
1834 /**
1835 * Current number of objects currently referencing this transport.
1836 */
1837 unsigned usage_count;
1838
1839
1840} pjsua_transport_info;
1841
1842
1843/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001844 * Create and start a new SIP transport according to the specified
1845 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001846 *
1847 * @param type Transport type.
1848 * @param cfg Transport configuration.
1849 * @param p_id Optional pointer to receive transport ID.
1850 *
1851 * @return PJ_SUCCESS on success, or the appropriate error code.
1852 */
1853PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1854 const pjsua_transport_config *cfg,
1855 pjsua_transport_id *p_id);
1856
1857/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001858 * Register transport that has been created by application. This function
1859 * is useful if application wants to implement custom SIP transport and use
1860 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001861 *
1862 * @param tp Transport instance.
1863 * @param p_id Optional pointer to receive transport ID.
1864 *
1865 * @return PJ_SUCCESS on success, or the appropriate error code.
1866 */
1867PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1868 pjsua_transport_id *p_id);
1869
1870
1871/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001872 * Enumerate all transports currently created in the system. This function
1873 * will return all transport IDs, and application may then call
1874 * #pjsua_transport_get_info() function to retrieve detailed information
1875 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001876 *
1877 * @param id Array to receive transport ids.
1878 * @param count In input, specifies the maximum number of elements.
1879 * On return, it contains the actual number of elements.
1880 *
1881 * @return PJ_SUCCESS on success, or the appropriate error code.
1882 */
1883PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1884 unsigned *count );
1885
1886
1887/**
1888 * Get information about transports.
1889 *
1890 * @param id Transport ID.
1891 * @param info Pointer to receive transport info.
1892 *
1893 * @return PJ_SUCCESS on success, or the appropriate error code.
1894 */
1895PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1896 pjsua_transport_info *info);
1897
1898
1899/**
1900 * Disable a transport or re-enable it. By default transport is always
1901 * enabled after it is created. Disabling a transport does not necessarily
1902 * close the socket, it will only discard incoming messages and prevent
1903 * the transport from being used to send outgoing messages.
1904 *
1905 * @param id Transport ID.
1906 * @param enabled Non-zero to enable, zero to disable.
1907 *
1908 * @return PJ_SUCCESS on success, or the appropriate error code.
1909 */
1910PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1911 pj_bool_t enabled);
1912
1913
1914/**
1915 * Close the transport. If transport is forcefully closed, it will be
1916 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00001917 * transport may not terminate properly (it may even crash). Otherwise,
1918 * the system will wait until all transactions are closed while preventing
1919 * new users from using the transport, and will close the transport when
1920 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001921 *
1922 * @param id Transport ID.
1923 * @param force Non-zero to immediately close the transport. This
1924 * is not recommended!
1925 *
1926 * @return PJ_SUCCESS on success, or the appropriate error code.
1927 */
1928PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1929 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001930
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001931/**
Benny Prijono312aff92006-06-17 04:08:30 +00001932 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001933 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001934
1935
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001936
1937
1938/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001939 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001940 */
1941
Benny Prijono312aff92006-06-17 04:08:30 +00001942
1943/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001944 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001945 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001946 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001947 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001948 *
Benny Prijono312aff92006-06-17 04:08:30 +00001949 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001950 * using the application. In SIP terms, the identity is used as the <b>From</b>
1951 * header in outgoing requests.
1952 *
1953 * PJSUA-API supports creating and managing multiple accounts. The maximum
1954 * number of accounts is limited by a compile time constant
1955 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001956 *
1957 * Account may or may not have client registration associated with it.
1958 * An account is also associated with <b>route set</b> and some <b>authentication
1959 * credentials</b>, which are used when sending SIP request messages using the
1960 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00001961 * will be reported to remote peer when they subscribe to the account's
1962 * presence, or which is published to a presence server if presence
1963 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00001964 *
1965 * At least one account MUST be created in the application. If no user
1966 * association is required, application can create a userless account by
1967 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00001968 * instead of a particular user, and it correspond with a particular
1969 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00001970 *
1971 * Also one account must be set as the <b>default account</b>, which is used as
1972 * the account to use when PJSUA fails to match a request with any other
1973 * accounts.
1974 *
1975 * When sending outgoing SIP requests (such as making calls or sending
1976 * instant messages), normally PJSUA requires the application to specify
1977 * which account to use for the request. If no account is specified,
1978 * PJSUA may be able to select the account by matching the destination
1979 * domain name, and fall back to default account when no match is found.
1980 */
1981
1982/**
1983 * Maximum accounts.
1984 */
1985#ifndef PJSUA_MAX_ACC
1986# define PJSUA_MAX_ACC 8
1987#endif
1988
1989
1990/**
1991 * Default registration interval.
1992 */
1993#ifndef PJSUA_REG_INTERVAL
Benny Prijonobddef2c2007-10-31 13:28:08 +00001994# define PJSUA_REG_INTERVAL 300
Benny Prijono312aff92006-06-17 04:08:30 +00001995#endif
1996
1997
1998/**
Benny Prijono384dab42009-10-14 01:58:04 +00001999 * Default maximum time to wait for account unregistration transactions to
2000 * complete during library shutdown sequence.
2001 *
2002 * Default: 4000 (4 seconds)
2003 */
2004#ifndef PJSUA_UNREG_TIMEOUT
2005# define PJSUA_UNREG_TIMEOUT 4000
2006#endif
2007
2008
2009/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002010 * Default PUBLISH expiration
2011 */
2012#ifndef PJSUA_PUBLISH_EXPIRATION
Benny Prijono53984d12009-04-28 22:19:49 +00002013# define PJSUA_PUBLISH_EXPIRATION PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002014#endif
2015
2016
2017/**
Benny Prijono093d3022006-09-24 00:07:11 +00002018 * Default account priority.
2019 */
2020#ifndef PJSUA_DEFAULT_ACC_PRIORITY
2021# define PJSUA_DEFAULT_ACC_PRIORITY 0
2022#endif
2023
2024
2025/**
Benny Prijono8058a622007-06-08 04:37:05 +00002026 * This macro specifies the URI scheme to use in Contact header
2027 * when secure transport such as TLS is used. Application can specify
2028 * either "sip" or "sips".
2029 */
2030#ifndef PJSUA_SECURE_SCHEME
Benny Prijono4c82c1e2008-10-16 08:14:51 +00002031# define PJSUA_SECURE_SCHEME "sip"
Benny Prijono8058a622007-06-08 04:37:05 +00002032#endif
2033
2034
2035/**
Benny Prijono534a9ba2009-10-13 14:01:59 +00002036 * Maximum time to wait for unpublication transaction(s) to complete
2037 * during shutdown process, before sending unregistration. The library
2038 * tries to wait for the unpublication (un-PUBLISH) to complete before
2039 * sending REGISTER request to unregister the account, during library
2040 * shutdown process. If the value is set too short, it is possible that
2041 * the unregistration is sent before unpublication completes, causing
2042 * unpublication request to fail.
2043 *
2044 * Default: 2000 (2 seconds)
2045 */
2046#ifndef PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
2047# define PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC 2000
2048#endif
2049
2050
2051/**
Nanang Izzuddin36dd5b62010-03-30 11:13:59 +00002052 * Default auto retry re-registration interval, in seconds. Set to 0
2053 * to disable this. Application can set the timer on per account basis
2054 * by setting the pjsua_acc_config.reg_retry_interval field instead.
2055 *
2056 * Default: 300 (5 minutes)
2057 */
2058#ifndef PJSUA_REG_RETRY_INTERVAL
2059# define PJSUA_REG_RETRY_INTERVAL 300
2060#endif
2061
2062
2063/**
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00002064 * This macro specifies the default value for \a contact_rewrite_method
2065 * field in pjsua_acc_config. I specifies how Contact update will be
2066 * done with the registration, if \a allow_contact_rewrite is enabled in
2067 * the account config.
2068 *
2069 * If set to 1, the Contact update will be done by sending unregistration
2070 * to the currently registered Contact, while simultaneously sending new
2071 * registration (with different Call-ID) for the updated Contact.
2072 *
2073 * If set to 2, the Contact update will be done in a single, current
2074 * registration session, by removing the current binding (by setting its
2075 * Contact's expires parameter to zero) and adding a new Contact binding,
2076 * all done in a single request.
2077 *
2078 * Value 1 is the legacy behavior.
2079 *
2080 * Default value: 2
2081 */
2082#ifndef PJSUA_CONTACT_REWRITE_METHOD
2083# define PJSUA_CONTACT_REWRITE_METHOD 2
2084#endif
2085
2086
2087/**
Benny Prijono29c8ca32010-06-22 06:02:13 +00002088 * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that
2089 * the global outbound proxy list should be added to the REGISTER request.
2090 */
2091#define PJSUA_REG_USE_OUTBOUND_PROXY 1
2092
2093
2094/**
2095 * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that
2096 * the account proxy list should be added to the REGISTER request.
2097 */
2098#define PJSUA_REG_USE_ACC_PROXY 2
2099
2100
2101/**
Benny Prijonodd63b992010-10-01 02:03:42 +00002102 * This enumeration specifies how we should offer call hold request to
2103 * remote peer. The default value is set by compile time constant
2104 * PJSUA_CALL_HOLD_TYPE_DEFAULT, and application may control the setting
2105 * on per-account basis by manipulating \a call_hold_type field in
2106 * #pjsua_acc_config.
2107 */
2108typedef enum pjsua_call_hold_type
2109{
2110 /**
2111 * This will follow RFC 3264 recommendation to use a=sendonly,
2112 * a=recvonly, and a=inactive attribute as means to signal call
2113 * hold status. This is the correct value to use.
2114 */
2115 PJSUA_CALL_HOLD_TYPE_RFC3264,
2116
2117 /**
2118 * This will use the old and deprecated method as specified in RFC 2543,
2119 * and will offer c=0.0.0.0 in the SDP instead. Using this has many
2120 * drawbacks such as inability to keep the media transport alive while
2121 * the call is being put on hold, and should only be used if remote
2122 * does not understand RFC 3264 style call hold offer.
2123 */
2124 PJSUA_CALL_HOLD_TYPE_RFC2543
2125
2126} pjsua_call_hold_type;
2127
2128
2129/**
2130 * Specify the default call hold type to be used in #pjsua_acc_config.
2131 *
2132 * Default is PJSUA_CALL_HOLD_TYPE_RFC3264, and there's no reason to change
2133 * this except if you're communicating with an old/non-standard peer.
2134 */
2135#ifndef PJSUA_CALL_HOLD_TYPE_DEFAULT
2136# define PJSUA_CALL_HOLD_TYPE_DEFAULT PJSUA_CALL_HOLD_TYPE_RFC3264
2137#endif
2138
Benny Prijonodd63b992010-10-01 02:03:42 +00002139/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002140 * This structure describes account configuration to be specified when
2141 * adding a new account with #pjsua_acc_add(). Application MUST initialize
2142 * this structure first by calling #pjsua_acc_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00002143 */
2144typedef struct pjsua_acc_config
2145{
Benny Prijono093d3022006-09-24 00:07:11 +00002146 /**
Benny Prijono705e7842008-07-21 18:12:51 +00002147 * Arbitrary user data to be associated with the newly created account.
2148 * Application may set this later with #pjsua_acc_set_user_data() and
2149 * retrieve it with #pjsua_acc_get_user_data().
2150 */
2151 void *user_data;
2152
2153 /**
Benny Prijono093d3022006-09-24 00:07:11 +00002154 * Account priority, which is used to control the order of matching
2155 * incoming/outgoing requests. The higher the number means the higher
2156 * the priority is, and the account will be matched first.
2157 */
2158 int priority;
2159
Benny Prijono312aff92006-06-17 04:08:30 +00002160 /**
2161 * The full SIP URL for the account. The value can take name address or
2162 * URL format, and will look something like "sip:account@serviceprovider".
2163 *
2164 * This field is mandatory.
2165 */
2166 pj_str_t id;
2167
2168 /**
2169 * This is the URL to be put in the request URI for the registration,
2170 * and will look something like "sip:serviceprovider".
2171 *
2172 * This field should be specified if registration is desired. If the
2173 * value is empty, no account registration will be performed.
2174 */
2175 pj_str_t reg_uri;
2176
Nanang Izzuddin60e8aa92010-09-28 10:48:48 +00002177 /**
2178 * The optional custom SIP headers to be put in the registration
2179 * request.
2180 */
2181 pjsip_hdr reg_hdr_list;
2182
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002183 /**
Benny Prijonofe1bd342009-11-20 23:33:07 +00002184 * Subscribe to message waiting indication events (RFC 3842).
2185 *
2186 * See also \a enable_unsolicited_mwi field on #pjsua_config.
Benny Prijono4dd961b2009-10-26 11:21:37 +00002187 *
2188 * Default: no
2189 */
2190 pj_bool_t mwi_enabled;
2191
2192 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002193 * If this flag is set, the presence information of this account will
2194 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono48ab2b72007-11-08 09:24:30 +00002195 *
2196 * Default: PJ_FALSE
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002197 */
2198 pj_bool_t publish_enabled;
2199
Benny Prijonofe04fb52007-08-24 08:28:52 +00002200 /**
Benny Prijonofe50c9e2009-10-12 07:44:14 +00002201 * Event publication options.
2202 */
2203 pjsip_publishc_opt publish_opt;
2204
2205 /**
Benny Prijono534a9ba2009-10-13 14:01:59 +00002206 * Maximum time to wait for unpublication transaction(s) to complete
2207 * during shutdown process, before sending unregistration. The library
2208 * tries to wait for the unpublication (un-PUBLISH) to complete before
2209 * sending REGISTER request to unregister the account, during library
2210 * shutdown process. If the value is set too short, it is possible that
2211 * the unregistration is sent before unpublication completes, causing
2212 * unpublication request to fail.
2213 *
2214 * Default: PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
2215 */
2216 unsigned unpublish_max_wait_time_msec;
2217
2218 /**
Benny Prijono48ab2b72007-11-08 09:24:30 +00002219 * Authentication preference.
2220 */
2221 pjsip_auth_clt_pref auth_pref;
2222
2223 /**
Benny Prijonofe04fb52007-08-24 08:28:52 +00002224 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
2225 * is not specified, a random string will be used.
2226 */
2227 pj_str_t pidf_tuple_id;
2228
Benny Prijono312aff92006-06-17 04:08:30 +00002229 /**
2230 * Optional URI to be put as Contact for this account. It is recommended
2231 * that this field is left empty, so that the value will be calculated
2232 * automatically based on the transport address.
2233 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00002234 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00002235
2236 /**
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00002237 * Additional parameters that will be appended in the Contact header
Benny Prijono30fe4852008-12-10 16:54:16 +00002238 * for this account. This will affect the Contact header in all SIP
2239 * messages sent on behalf of this account, including but not limited to
2240 * REGISTER, INVITE, and SUBCRIBE requests or responses.
2241 *
2242 * The parameters should be preceeded by semicolon, and all strings must
2243 * be properly escaped. Example:
2244 * ";my-param=X;another-param=Hi%20there"
2245 */
2246 pj_str_t contact_params;
2247
2248 /**
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00002249 * Additional URI parameters that will be appended in the Contact URI
2250 * for this account. This will affect the Contact URI in all SIP
2251 * messages sent on behalf of this account, including but not limited to
2252 * REGISTER, INVITE, and SUBCRIBE requests or responses.
2253 *
2254 * The parameters should be preceeded by semicolon, and all strings must
2255 * be properly escaped. Example:
2256 * ";my-param=X;another-param=Hi%20there"
2257 */
2258 pj_str_t contact_uri_params;
2259
2260 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00002261 * Specify whether support for reliable provisional response (100rel and
2262 * PRACK) should be required for all sessions of this account.
2263 *
2264 * Default: PJ_FALSE
2265 */
2266 pj_bool_t require_100rel;
2267
2268 /**
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002269 * Specify the usage of Session Timers for all sessions. See the
2270 * #pjsua_sip_timer_use for possible values.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002271 *
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002272 * Default: PJSUA_SIP_TIMER_OPTIONAL
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002273 */
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002274 pjsua_sip_timer_use use_timer;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002275
2276 /**
Nanang Izzuddin65add622009-08-11 16:26:20 +00002277 * Specify Session Timer settings, see #pjsip_timer_setting.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002278 */
Nanang Izzuddin65add622009-08-11 16:26:20 +00002279 pjsip_timer_setting timer_setting;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002280
2281 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002282 * Number of proxies in the proxy array below.
2283 */
2284 unsigned proxy_cnt;
2285
2286 /**
2287 * Optional URI of the proxies to be visited for all outgoing requests
2288 * that are using this account (REGISTER, INVITE, etc). Application need
2289 * to specify these proxies if the service provider requires that requests
2290 * destined towards its network should go through certain proxies first
2291 * (for example, border controllers).
2292 *
2293 * These proxies will be put in the route set for this account, with
2294 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00002295 * first). If global outbound proxies are configured in pjsua_config,
2296 * then these account proxies will be placed after the global outbound
2297 * proxies in the routeset.
Benny Prijono312aff92006-06-17 04:08:30 +00002298 */
2299 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
2300
2301 /**
2302 * Optional interval for registration, in seconds. If the value is zero,
Benny Prijonobddef2c2007-10-31 13:28:08 +00002303 * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
Benny Prijono312aff92006-06-17 04:08:30 +00002304 */
2305 unsigned reg_timeout;
2306
Benny Prijono384dab42009-10-14 01:58:04 +00002307 /**
2308 * Specify the maximum time to wait for unregistration requests to
2309 * complete during library shutdown sequence.
2310 *
2311 * Default: PJSUA_UNREG_TIMEOUT
2312 */
2313 unsigned unreg_timeout;
2314
Benny Prijono312aff92006-06-17 04:08:30 +00002315 /**
2316 * Number of credentials in the credential array.
2317 */
2318 unsigned cred_count;
2319
2320 /**
2321 * Array of credentials. If registration is desired, normally there should
2322 * be at least one credential specified, to successfully authenticate
2323 * against the service provider. More credentials can be specified, for
2324 * example when the requests are expected to be challenged by the
2325 * proxies in the route set.
2326 */
2327 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
2328
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002329 /**
2330 * Optionally bind this account to specific transport. This normally is
2331 * not a good idea, as account should be able to send requests using
2332 * any available transports according to the destination. But some
2333 * application may want to have explicit control over the transport to
2334 * use, so in that case it can set this field.
2335 *
2336 * Default: -1 (PJSUA_INVALID_ID)
2337 *
2338 * @see pjsua_acc_set_transport()
2339 */
2340 pjsua_transport_id transport_id;
2341
Benny Prijono15b02302007-09-27 14:07:07 +00002342 /**
Benny Prijonocca2e432010-02-25 09:33:18 +00002343 * This option is used to update the transport address and the Contact
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002344 * header of REGISTER request. When this option is enabled, the library
2345 * will keep track of the public IP address from the response of REGISTER
2346 * request. Once it detects that the address has changed, it will
2347 * unregister current Contact, update the Contact with transport address
2348 * learned from Via header, and register a new Contact to the registrar.
2349 * This will also update the public name of UDP transport if STUN is
Benny Prijonocca2e432010-02-25 09:33:18 +00002350 * configured.
Benny Prijono15b02302007-09-27 14:07:07 +00002351 *
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00002352 * See also contact_rewrite_method field.
2353 *
Benny Prijono15b02302007-09-27 14:07:07 +00002354 * Default: 1 (yes)
2355 */
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002356 pj_bool_t allow_contact_rewrite;
Benny Prijono15b02302007-09-27 14:07:07 +00002357
Benny Prijonobddef2c2007-10-31 13:28:08 +00002358 /**
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00002359 * Specify how Contact update will be done with the registration, if
2360 * \a allow_contact_rewrite is enabled.
2361 *
2362 * If set to 1, the Contact update will be done by sending unregistration
2363 * to the currently registered Contact, while simultaneously sending new
2364 * registration (with different Call-ID) for the updated Contact.
2365 *
2366 * If set to 2, the Contact update will be done in a single, current
2367 * registration session, by removing the current binding (by setting its
2368 * Contact's expires parameter to zero) and adding a new Contact binding,
2369 * all done in a single request.
2370 *
2371 * Value 1 is the legacy behavior.
2372 *
2373 * Default value: PJSUA_CONTACT_REWRITE_METHOD (2)
2374 */
2375 int contact_rewrite_method;
2376
2377 /**
Benny Prijonob54719f2010-11-16 03:07:46 +00002378 * Control the use of SIP outbound feature. SIP outbound is described in
2379 * RFC 5626 to enable proxies or registrar to send inbound requests back
2380 * to UA using the same connection initiated by the UA for its
2381 * registration. This feature is highly useful in NAT-ed deployemtns,
2382 * hence it is enabled by default.
2383 *
2384 * Note: currently SIP outbound can only be used with TCP and TLS
2385 * transports. If UDP is used for the registration, the SIP outbound
2386 * feature will be silently ignored for the account.
2387 *
2388 * Default: PJ_TRUE
2389 */
2390 unsigned use_rfc5626;
2391
2392 /**
2393 * Specify SIP outbound (RFC 5626) instance ID to be used by this
2394 * application. If empty, an instance ID will be generated based on
2395 * the hostname of this agent. If application specifies this parameter, the
2396 * value will look like "<urn:uuid:00000000-0000-1000-8000-AABBCCDDEEFF>"
2397 * without the doublequote.
2398 *
2399 * Default: empty
2400 */
2401 pj_str_t rfc5626_instance_id;
2402
2403 /**
2404 * Specify SIP outbound (RFC 5626) registration ID. The default value
2405 * is empty, which would cause the library to automatically generate
2406 * a suitable value.
2407 *
2408 * Default: empty
2409 */
2410 pj_str_t rfc5626_reg_id;
2411
2412 /**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002413 * Set the interval for periodic keep-alive transmission for this account.
2414 * If this value is zero, keep-alive will be disabled for this account.
2415 * The keep-alive transmission will be sent to the registrar's address,
2416 * after successful registration.
2417 *
Benny Prijonobddef2c2007-10-31 13:28:08 +00002418 * Default: 15 (seconds)
2419 */
2420 unsigned ka_interval;
2421
2422 /**
2423 * Specify the data to be transmitted as keep-alive packets.
2424 *
2425 * Default: CR-LF
2426 */
2427 pj_str_t ka_data;
2428
Benny Prijono0bc99a92011-03-17 04:34:43 +00002429 /**
2430 * Maximum number of simultaneous active audio streams to be allowed
2431 * for calls on this account. Setting this to zero will disable audio
2432 * in calls on this account.
2433 *
2434 * Default: 1
2435 */
2436 unsigned max_audio_cnt;
2437
2438 /**
2439 * Maximum number of simultaneous active video streams to be allowed
2440 * for calls on this account. Setting this to zero will disable video
2441 * in calls on this account.
2442 *
2443 * Default: 0
2444 */
2445 unsigned max_video_cnt;
2446
2447 /**
2448 * Media transport config.
2449 */
2450 pjsua_transport_config rtp_cfg;
2451
Benny Prijonod8179652008-01-23 20:39:07 +00002452 /**
2453 * Specify whether secure media transport should be used for this account.
2454 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
2455 * PJMEDIA_SRTP_MANDATORY.
2456 *
2457 * Default: #PJSUA_DEFAULT_USE_SRTP
2458 */
2459 pjmedia_srtp_use use_srtp;
2460
2461 /**
2462 * Specify whether SRTP requires secure signaling to be used. This option
2463 * is only used when \a use_srtp option above is non-zero.
2464 *
2465 * Valid values are:
2466 * 0: SRTP does not require secure signaling
2467 * 1: SRTP requires secure transport such as TLS
2468 * 2: SRTP requires secure end-to-end transport (SIPS)
2469 *
2470 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
2471 */
2472 int srtp_secure_signaling;
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00002473
2474 /**
Benny Prijono0bc99a92011-03-17 04:34:43 +00002475 * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00002476 * duplicated media in SDP offer, i.e: unsecured and secured version.
Benny Prijono0bc99a92011-03-17 04:34:43 +00002477 * Otherwise, the SDP media will be composed as unsecured media but
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00002478 * with SDP "crypto" attribute.
2479 *
2480 * Default: PJ_FALSE
2481 */
2482 pj_bool_t srtp_optional_dup_offer;
Benny Prijonod8179652008-01-23 20:39:07 +00002483
Nanang Izzuddin36dd5b62010-03-30 11:13:59 +00002484 /**
2485 * Specify interval of auto registration retry upon registration failure
2486 * (including caused by transport problem), in second. Set to 0 to
2487 * disable auto re-registration.
2488 *
2489 * Default: #PJSUA_REG_RETRY_INTERVAL
2490 */
2491 unsigned reg_retry_interval;
2492
2493 /**
2494 * Specify whether calls of the configured account should be dropped
2495 * after registration failure and an attempt of re-registration has
2496 * also failed.
2497 *
2498 * Default: PJ_FALSE (disabled)
2499 */
2500 pj_bool_t drop_calls_on_reg_fail;
2501
Benny Prijono29c8ca32010-06-22 06:02:13 +00002502 /**
2503 * Specify how the registration uses the outbound and account proxy
2504 * settings. This controls if and what Route headers will appear in
2505 * the REGISTER request of this account. The value is bitmask combination
2506 * of PJSUA_REG_USE_OUTBOUND_PROXY and PJSUA_REG_USE_ACC_PROXY bits.
2507 * If the value is set to 0, the REGISTER request will not use any proxy
2508 * (i.e. it will not have any Route headers).
2509 *
2510 * Default: 3 (PJSUA_REG_USE_OUTBOUND_PROXY | PJSUA_REG_USE_ACC_PROXY)
2511 */
2512 unsigned reg_use_proxy;
2513
Nanang Izzuddin5e39a2b2010-09-20 06:13:02 +00002514#if defined(PJMEDIA_STREAM_ENABLE_KA) && (PJMEDIA_STREAM_ENABLE_KA != 0)
2515 /**
2516 * Specify whether stream keep-alive and NAT hole punching with
2517 * non-codec-VAD mechanism (see @ref PJMEDIA_STREAM_ENABLE_KA) is enabled
2518 * for this account.
2519 *
2520 * Default: PJ_FALSE (disabled)
2521 */
2522 pj_bool_t use_stream_ka;
2523#endif
2524
Benny Prijonodd63b992010-10-01 02:03:42 +00002525 /**
2526 * Specify how to offer call hold to remote peer. Please see the
2527 * documentation on #pjsua_call_hold_type for more info.
2528 *
2529 * Default: PJSUA_CALL_HOLD_TYPE_DEFAULT
2530 */
2531 pjsua_call_hold_type call_hold_type;
2532
Benny Prijono312aff92006-06-17 04:08:30 +00002533} pjsua_acc_config;
2534
2535
2536/**
2537 * Call this function to initialize account config with default values.
2538 *
2539 * @param cfg The account config to be initialized.
2540 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00002541PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002542
2543
2544/**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002545 * Duplicate account config.
2546 *
2547 * @param pool Pool to be used for duplicating the config.
2548 * @param dst Destination configuration.
2549 * @param src Source configuration.
2550 */
2551PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
2552 pjsua_acc_config *dst,
2553 const pjsua_acc_config *src);
2554
2555
2556/**
Benny Prijono312aff92006-06-17 04:08:30 +00002557 * Account info. Application can query account info by calling
2558 * #pjsua_acc_get_info().
2559 */
2560typedef struct pjsua_acc_info
2561{
2562 /**
2563 * The account ID.
2564 */
2565 pjsua_acc_id id;
2566
2567 /**
2568 * Flag to indicate whether this is the default account.
2569 */
2570 pj_bool_t is_default;
2571
2572 /**
2573 * Account URI
2574 */
2575 pj_str_t acc_uri;
2576
2577 /**
2578 * Flag to tell whether this account has registration setting
2579 * (reg_uri is not empty).
2580 */
2581 pj_bool_t has_registration;
2582
2583 /**
2584 * An up to date expiration interval for account registration session.
2585 */
2586 int expires;
2587
2588 /**
2589 * Last registration status code. If status code is zero, the account
2590 * is currently not registered. Any other value indicates the SIP
2591 * status code of the registration.
2592 */
2593 pjsip_status_code status;
2594
2595 /**
Sauw Ming48f6dbf2010-09-07 05:10:25 +00002596 * Last registration error code. When the status field contains a SIP
2597 * status code that indicates a registration failure, last registration
2598 * error code contains the error code that causes the failure. In any
2599 * other case, its value is zero.
2600 */
2601 pj_status_t reg_last_err;
2602
2603 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002604 * String describing the registration status.
2605 */
2606 pj_str_t status_text;
2607
2608 /**
2609 * Presence online status for this account.
2610 */
2611 pj_bool_t online_status;
2612
2613 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00002614 * Presence online status text.
2615 */
2616 pj_str_t online_status_text;
2617
2618 /**
2619 * Extended RPID online status information.
2620 */
2621 pjrpid_element rpid;
2622
2623 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002624 * Buffer that is used internally to store the status text.
2625 */
2626 char buf_[PJ_ERR_MSG_SIZE];
2627
2628} pjsua_acc_info;
2629
2630
2631
2632/**
2633 * Get number of current accounts.
2634 *
2635 * @return Current number of accounts.
2636 */
2637PJ_DECL(unsigned) pjsua_acc_get_count(void);
2638
2639
2640/**
2641 * Check if the specified account ID is valid.
2642 *
2643 * @param acc_id Account ID to check.
2644 *
2645 * @return Non-zero if account ID is valid.
2646 */
2647PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
2648
2649
2650/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00002651 * Set default account to be used when incoming and outgoing
2652 * requests doesn't match any accounts.
2653 *
2654 * @param acc_id The account ID to be used as default.
2655 *
2656 * @return PJ_SUCCESS on success.
2657 */
2658PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2659
2660
2661/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002662 * Get default account to be used when receiving incoming requests (calls),
2663 * when the destination of the incoming call doesn't match any other
2664 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002665 *
2666 * @return The default account ID, or PJSUA_INVALID_ID if no
2667 * default account is configured.
2668 */
2669PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2670
2671
2672/**
Benny Prijono312aff92006-06-17 04:08:30 +00002673 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002674 * #pjsua_init()) before calling this function. If registration is configured
2675 * for this account, this function would also start the SIP registration
2676 * session with the SIP registrar server. This SIP registration session
2677 * will be maintained internally by the library, and application doesn't
2678 * need to do anything to maintain the registration session.
2679 *
Benny Prijono312aff92006-06-17 04:08:30 +00002680 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002681 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002682 * @param is_default If non-zero, this account will be set as the default
2683 * account. The default account will be used when sending
2684 * outgoing requests (e.g. making call) when no account is
2685 * specified, and when receiving incoming requests when the
2686 * request does not match any accounts. It is recommended
2687 * that default account is set to local/LAN account.
2688 * @param p_acc_id Pointer to receive account ID of the new account.
2689 *
2690 * @return PJ_SUCCESS on success, or the appropriate error code.
2691 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002692PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002693 pj_bool_t is_default,
2694 pjsua_acc_id *p_acc_id);
2695
2696
2697/**
2698 * Add a local account. A local account is used to identify local endpoint
2699 * instead of a specific user, and for this reason, a transport ID is needed
2700 * to obtain the local address information.
2701 *
2702 * @param tid Transport ID to generate account address.
2703 * @param is_default If non-zero, this account will be set as the default
2704 * account. The default account will be used when sending
2705 * outgoing requests (e.g. making call) when no account is
2706 * specified, and when receiving incoming requests when the
2707 * request does not match any accounts. It is recommended
2708 * that default account is set to local/LAN account.
2709 * @param p_acc_id Pointer to receive account ID of the new account.
2710 *
2711 * @return PJ_SUCCESS on success, or the appropriate error code.
2712 */
2713PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2714 pj_bool_t is_default,
2715 pjsua_acc_id *p_acc_id);
2716
2717/**
Benny Prijono705e7842008-07-21 18:12:51 +00002718 * Set arbitrary data to be associated with the account.
2719 *
2720 * @param acc_id The account ID.
2721 * @param user_data User/application data.
2722 *
2723 * @return PJ_SUCCESS on success, or the appropriate error code.
2724 */
2725PJ_DECL(pj_status_t) pjsua_acc_set_user_data(pjsua_acc_id acc_id,
2726 void *user_data);
2727
2728
2729/**
2730 * Retrieve arbitrary data associated with the account.
2731 *
2732 * @param acc_id The account ID.
2733 *
2734 * @return The user data. In the case where the account ID is
2735 * not valid, NULL is returned.
2736 */
2737PJ_DECL(void*) pjsua_acc_get_user_data(pjsua_acc_id acc_id);
2738
2739
2740/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002741 * Delete an account. This will unregister the account from the SIP server,
2742 * if necessary, and terminate server side presence subscriptions associated
2743 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002744 *
2745 * @param acc_id Id of the account to be deleted.
2746 *
2747 * @return PJ_SUCCESS on success, or the appropriate error code.
2748 */
2749PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2750
2751
2752/**
2753 * Modify account information.
2754 *
2755 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002756 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002757 *
2758 * @return PJ_SUCCESS on success, or the appropriate error code.
2759 */
2760PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002761 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002762
2763
2764/**
2765 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002766 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002767 * if there are server side presence subscription for this account, and/or
2768 * outgoing PUBLISH if presence publication is enabled for this account.
2769 *
2770 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002771 *
2772 * @param acc_id The account ID.
2773 * @param is_online True of false.
2774 *
2775 * @return PJ_SUCCESS on success, or the appropriate error code.
2776 */
2777PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2778 pj_bool_t is_online);
2779
Benny Prijono4461c7d2007-08-25 13:36:15 +00002780/**
2781 * Modify account's presence status to be advertised to remote/presence
2782 * subscribers. This would trigger the sending of outgoing NOTIFY request
2783 * if there are server side presence subscription for this account, and/or
2784 * outgoing PUBLISH if presence publication is enabled for this account.
2785 *
2786 * @see pjsua_acc_set_online_status()
2787 *
2788 * @param acc_id The account ID.
2789 * @param is_online True of false.
2790 * @param pr Extended information in subset of RPID format
2791 * which allows setting custom presence text.
2792 *
2793 * @return PJ_SUCCESS on success, or the appropriate error code.
2794 */
2795PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2796 pj_bool_t is_online,
2797 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002798
2799/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002800 * Update registration or perform unregistration. If registration is
2801 * configured for this account, then initial SIP REGISTER will be sent
2802 * when the account is added with #pjsua_acc_add(). Application normally
2803 * only need to call this function if it wants to manually update the
2804 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002805 *
2806 * @param acc_id The account ID.
2807 * @param renew If renew argument is zero, this will start
2808 * unregistration process.
2809 *
2810 * @return PJ_SUCCESS on success, or the appropriate error code.
2811 */
2812PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2813 pj_bool_t renew);
2814
Benny Prijono312aff92006-06-17 04:08:30 +00002815/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002816 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002817 *
2818 * @param acc_id Account identification.
2819 * @param info Pointer to receive account information.
2820 *
2821 * @return PJ_SUCCESS on success, or the appropriate error code.
2822 */
2823PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2824 pjsua_acc_info *info);
2825
2826
2827/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002828 * Enumerate all account currently active in the library. This will fill
2829 * the array with the account Ids, and application can then query the
2830 * account information for each id with #pjsua_acc_get_info().
2831 *
2832 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002833 *
2834 * @param ids Array of account IDs to be initialized.
2835 * @param count In input, specifies the maximum number of elements.
2836 * On return, it contains the actual number of elements.
2837 *
2838 * @return PJ_SUCCESS on success, or the appropriate error code.
2839 */
2840PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2841 unsigned *count );
2842
2843
2844/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002845 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002846 *
2847 * @param info Array of account infos to be initialized.
2848 * @param count In input, specifies the maximum number of elements.
2849 * On return, it contains the actual number of elements.
2850 *
2851 * @return PJ_SUCCESS on success, or the appropriate error code.
2852 */
2853PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2854 unsigned *count );
2855
2856
2857/**
2858 * This is an internal function to find the most appropriate account to
2859 * used to reach to the specified URL.
2860 *
2861 * @param url The remote URL to reach.
2862 *
2863 * @return Account id.
2864 */
2865PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2866
2867
2868/**
2869 * This is an internal function to find the most appropriate account to be
2870 * used to handle incoming calls.
2871 *
2872 * @param rdata The incoming request message.
2873 *
2874 * @return Account id.
2875 */
2876PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2877
2878
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002879/**
Benny Prijonofff245c2007-04-02 11:44:47 +00002880 * Create arbitrary requests using the account. Application should only use
2881 * this function to create auxiliary requests outside dialog, such as
2882 * OPTIONS, and use the call or presence API to create dialog related
2883 * requests.
2884 *
2885 * @param acc_id The account ID.
2886 * @param method The SIP method of the request.
2887 * @param target Target URI.
2888 * @param p_tdata Pointer to receive the request.
2889 *
2890 * @return PJ_SUCCESS or the error code.
2891 */
2892PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
2893 const pjsip_method *method,
2894 const pj_str_t *target,
2895 pjsip_tx_data **p_tdata);
2896
2897
2898/**
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002899 * Create a suitable Contact header value, based on the specified target URI
2900 * for the specified account.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002901 *
2902 * @param pool Pool to allocate memory for the string.
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002903 * @param contact The string where the Contact will be stored.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002904 * @param acc_id Account ID.
2905 * @param uri Destination URI of the request.
2906 *
2907 * @return PJ_SUCCESS on success, other on error.
2908 */
2909PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
2910 pj_str_t *contact,
2911 pjsua_acc_id acc_id,
2912 const pj_str_t *uri);
2913
2914
2915
2916/**
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002917 * Create a suitable Contact header value, based on the information in the
2918 * incoming request.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002919 *
2920 * @param pool Pool to allocate memory for the string.
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002921 * @param contact The string where the Contact will be stored.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002922 * @param acc_id Account ID.
2923 * @param rdata Incoming request.
2924 *
2925 * @return PJ_SUCCESS on success, other on error.
2926 */
2927PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
2928 pj_str_t *contact,
2929 pjsua_acc_id acc_id,
2930 pjsip_rx_data *rdata );
2931
2932
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002933/**
2934 * Lock/bind this account to a specific transport/listener. Normally
2935 * application shouldn't need to do this, as transports will be selected
2936 * automatically by the stack according to the destination.
2937 *
2938 * When account is locked/bound to a specific transport, all outgoing
2939 * requests from this account will use the specified transport (this
2940 * includes SIP registration, dialog (call and event subscription), and
2941 * out-of-dialog requests such as MESSAGE).
2942 *
2943 * Note that transport_id may be specified in pjsua_acc_config too.
2944 *
2945 * @param acc_id The account ID.
2946 * @param tp_id The transport ID.
2947 *
2948 * @return PJ_SUCCESS on success.
2949 */
2950PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
2951 pjsua_transport_id tp_id);
2952
Benny Prijono312aff92006-06-17 04:08:30 +00002953
2954/**
2955 * @}
2956 */
2957
2958
2959/*****************************************************************************
2960 * CALLS API
2961 */
2962
2963
2964/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002965 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00002966 * @ingroup PJSUA_LIB
2967 * @brief Call manipulation.
2968 * @{
2969 */
2970
2971/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002972 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00002973 */
2974#ifndef PJSUA_MAX_CALLS
2975# define PJSUA_MAX_CALLS 32
2976#endif
2977
2978
2979
2980/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002981 * This enumeration specifies the media status of a call, and it's part
2982 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00002983 */
2984typedef enum pjsua_call_media_status
2985{
Benny Prijono0bc99a92011-03-17 04:34:43 +00002986 /**
2987 * Call currently has no media, or the media is not used.
2988 */
Benny Prijono312aff92006-06-17 04:08:30 +00002989 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002990
Benny Prijono0bc99a92011-03-17 04:34:43 +00002991 /**
2992 * The media is active
2993 */
Benny Prijono312aff92006-06-17 04:08:30 +00002994 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002995
Benny Prijono0bc99a92011-03-17 04:34:43 +00002996 /**
2997 * The media is currently put on hold by local endpoint
2998 */
Benny Prijono312aff92006-06-17 04:08:30 +00002999 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00003000
Benny Prijono0bc99a92011-03-17 04:34:43 +00003001 /**
3002 * The media is currently put on hold by remote endpoint
3003 */
Benny Prijono312aff92006-06-17 04:08:30 +00003004 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00003005
Benny Prijono0bc99a92011-03-17 04:34:43 +00003006 /**
3007 * The media has reported error (e.g. ICE negotiation)
3008 */
Benny Prijono096c56c2007-09-15 08:30:16 +00003009 PJSUA_CALL_MEDIA_ERROR
3010
Benny Prijono312aff92006-06-17 04:08:30 +00003011} pjsua_call_media_status;
3012
3013
3014/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003015 * This structure describes the information and current status of a call.
Benny Prijono312aff92006-06-17 04:08:30 +00003016 */
3017typedef struct pjsua_call_info
3018{
3019 /** Call identification. */
3020 pjsua_call_id id;
3021
3022 /** Initial call role (UAC == caller) */
3023 pjsip_role_e role;
3024
Benny Prijono90315512006-09-14 16:05:16 +00003025 /** The account ID where this call belongs. */
3026 pjsua_acc_id acc_id;
3027
Benny Prijono312aff92006-06-17 04:08:30 +00003028 /** Local URI */
3029 pj_str_t local_info;
3030
3031 /** Local Contact */
3032 pj_str_t local_contact;
3033
3034 /** Remote URI */
3035 pj_str_t remote_info;
3036
3037 /** Remote contact */
3038 pj_str_t remote_contact;
3039
3040 /** Dialog Call-ID string. */
3041 pj_str_t call_id;
3042
3043 /** Call state */
3044 pjsip_inv_state state;
3045
3046 /** Text describing the state */
3047 pj_str_t state_text;
3048
3049 /** Last status code heard, which can be used as cause code */
3050 pjsip_status_code last_status;
3051
3052 /** The reason phrase describing the status. */
3053 pj_str_t last_status_text;
3054
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003055 /** Media status of the first audio stream. */
Benny Prijono312aff92006-06-17 04:08:30 +00003056 pjsua_call_media_status media_status;
3057
Benny Prijono0bc99a92011-03-17 04:34:43 +00003058 /** Media direction of the first audio stream. */
Benny Prijono312aff92006-06-17 04:08:30 +00003059 pjmedia_dir media_dir;
3060
Benny Prijono0bc99a92011-03-17 04:34:43 +00003061 /** The conference port number for the first audio stream. */
Benny Prijono312aff92006-06-17 04:08:30 +00003062 pjsua_conf_port_id conf_slot;
3063
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003064 /** Number of media streams in this call */
3065 unsigned media_cnt;
3066
3067 /** Array of media stream information */
Benny Prijono0bc99a92011-03-17 04:34:43 +00003068 struct
3069 {
3070 /** Media index in SDP. */
3071 unsigned index;
3072
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003073 /** Media type. */
3074 pjmedia_type type;
Benny Prijono0bc99a92011-03-17 04:34:43 +00003075
3076 /** Media direction. */
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003077 pjmedia_dir dir;
Benny Prijono0bc99a92011-03-17 04:34:43 +00003078
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003079 /** Call media status. */
3080 pjsua_call_media_status status;
Benny Prijono0bc99a92011-03-17 04:34:43 +00003081
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003082 /** The specific media stream info. */
3083 union {
3084 /** Audio stream */
3085 struct {
3086 pjsua_conf_port_id conf_slot; /**< The conference port
3087 number for the call. */
3088 } audio;
3089
3090 /** Video stream */
3091 struct {
3092 pjmedia_vid_port *capturer; /**< Video capturer. */
3093 pjmedia_vid_port *renderer; /**< Video renderer. */
3094 } video;
3095 } stream;
3096
3097 } media[PJMEDIA_MAX_SDP_MEDIA];
Benny Prijono0bc99a92011-03-17 04:34:43 +00003098
Benny Prijono312aff92006-06-17 04:08:30 +00003099 /** Up-to-date call connected duration (zero when call is not
3100 * established)
3101 */
3102 pj_time_val connect_duration;
3103
3104 /** Total call duration, including set-up time */
3105 pj_time_val total_duration;
3106
3107 /** Internal */
3108 struct {
3109 char local_info[128];
3110 char local_contact[128];
3111 char remote_info[128];
3112 char remote_contact[128];
3113 char call_id[128];
3114 char last_status_text[128];
3115 } buf_;
3116
3117} pjsua_call_info;
3118
3119
3120
Benny Prijonoa91a0032006-02-26 21:23:45 +00003121/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00003122 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003123 *
3124 * @return Maximum number of calls configured.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003125 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003126PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003127
3128/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003129 * Get number of currently active calls.
3130 *
3131 * @return Number of currently active calls.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003132 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003133PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003134
3135/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003136 * Enumerate all active calls. Application may then query the information and
3137 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003138 *
3139 * @param ids Array of account IDs to be initialized.
3140 * @param count In input, specifies the maximum number of elements.
3141 * On return, it contains the actual number of elements.
3142 *
3143 * @return PJ_SUCCESS on success, or the appropriate error code.
3144 */
3145PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
3146 unsigned *count);
3147
3148
3149/**
3150 * Make outgoing call to the specified URI using the specified account.
3151 *
3152 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003153 * @param dst_uri URI to be put in the To header (normally is the same
3154 * as the target URI).
3155 * @param options Options (must be zero at the moment).
3156 * @param user_data Arbitrary user data to be attached to the call, and
3157 * can be retrieved later.
3158 * @param msg_data Optional headers etc to be added to outgoing INVITE
3159 * request, or NULL if no custom header is desired.
3160 * @param p_call_id Pointer to receive call identification.
3161 *
3162 * @return PJ_SUCCESS on success, or the appropriate error code.
3163 */
3164PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
3165 const pj_str_t *dst_uri,
3166 unsigned options,
3167 void *user_data,
3168 const pjsua_msg_data *msg_data,
3169 pjsua_call_id *p_call_id);
3170
3171
3172/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00003173 * Check if the specified call has active INVITE session and the INVITE
3174 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003175 *
3176 * @param call_id Call identification.
3177 *
3178 * @return Non-zero if call is active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003179 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003180PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003181
3182
3183/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003184 * Check if call has an active media session.
3185 *
3186 * @param call_id Call identification.
3187 *
3188 * @return Non-zero if yes.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003189 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003190PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003191
3192
Benny Prijono0bc99a92011-03-17 04:34:43 +00003193#if DISABLED_FOR_TICKET_1185
Benny Prijono9fc735d2006-05-28 14:58:12 +00003194/**
Benny Prijonocf986c42008-09-02 11:25:07 +00003195 * Retrieve the media session associated with this call. Note that the media
3196 * session may not be available depending on the current call's media status
3197 * (the pjsua_call_media_status information in pjsua_call_info). Application
3198 * may use the media session to retrieve more detailed information about the
3199 * call's media.
3200 *
3201 * @param call_id Call identification.
3202 *
3203 * @return Call media session.
3204 */
3205PJ_DECL(pjmedia_session*) pjsua_call_get_media_session(pjsua_call_id call_id);
3206
Benny Prijonocf986c42008-09-02 11:25:07 +00003207/**
3208 * Retrieve the media transport instance that is used for this call.
3209 * Application may use the media transport to query more detailed information
3210 * about the media transport.
3211 *
3212 * @param cid Call identification (the call_id).
3213 *
3214 * @return Call media transport.
3215 */
3216PJ_DECL(pjmedia_transport*) pjsua_call_get_media_transport(pjsua_call_id cid);
Benny Prijono0bc99a92011-03-17 04:34:43 +00003217#endif /* DISABLED_FOR_TICKET_1185 */
Benny Prijonocf986c42008-09-02 11:25:07 +00003218
3219/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003220 * Get the conference port identification associated with the call.
3221 *
3222 * @param call_id Call identification.
3223 *
3224 * @return Conference port ID, or PJSUA_INVALID_ID when the
3225 * media has not been established or is not active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003226 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003227PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
3228
3229/**
3230 * Obtain detail information about the specified call.
3231 *
3232 * @param call_id Call identification.
3233 * @param info Call info to be initialized.
3234 *
3235 * @return PJ_SUCCESS on success, or the appropriate error code.
3236 */
3237PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003238 pjsua_call_info *info);
3239
Nanang Izzuddin2a1b9ee2010-06-03 10:41:32 +00003240/**
3241 * Check if remote peer support the specified capability.
3242 *
3243 * @param call_id Call identification.
3244 * @param htype The header type to be checked, which value may be:
3245 * - PJSIP_H_ACCEPT
3246 * - PJSIP_H_ALLOW
3247 * - PJSIP_H_SUPPORTED
3248 * @param hname If htype specifies PJSIP_H_OTHER, then the header
3249 * name must be supplied in this argument. Otherwise the
3250 * value must be set to NULL.
3251 * @param token The capability token to check. For example, if \a
3252 * htype is PJSIP_H_ALLOW, then \a token specifies the
3253 * method names; if \a htype is PJSIP_H_SUPPORTED, then
3254 * \a token specifies the extension names such as
3255 * "100rel".
3256 *
3257 * @return PJSIP_DIALOG_CAP_SUPPORTED if the specified capability
3258 * is explicitly supported, see @pjsip_dialog_cap_status
3259 * for more info.
3260 */
3261PJ_DECL(pjsip_dialog_cap_status) pjsua_call_remote_has_cap(
3262 pjsua_call_id call_id,
3263 int htype,
3264 const pj_str_t *hname,
3265 const pj_str_t *token);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003266
3267/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003268 * Attach application specific data to the call. Application can then
3269 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003270 *
3271 * @param call_id Call identification.
3272 * @param user_data Arbitrary data to be attached to the call.
3273 *
3274 * @return The user data.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003275 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003276PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
3277 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003278
3279
3280/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003281 * Get user data attached to the call, which has been previously set with
3282 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003283 *
3284 * @param call_id Call identification.
3285 *
3286 * @return The user data.
Benny Prijono268ca612006-02-07 12:34:11 +00003287 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003288PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00003289
3290
3291/**
Benny Prijono91a6a172007-10-31 08:59:29 +00003292 * Get the NAT type of remote's endpoint. This is a proprietary feature
3293 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
3294 * is set in #pjsua_config.
3295 *
3296 * This function can only be called after SDP has been received from remote,
3297 * which means for incoming call, this function can be called as soon as
3298 * call is received as long as incoming call contains SDP, and for outgoing
3299 * call, this function can be called only after SDP is received (normally in
3300 * 200/OK response to INVITE). As a general case, application should call
3301 * this function after or in \a on_call_media_state() callback.
3302 *
3303 * @param call_id Call identification.
3304 * @param p_type Pointer to store the NAT type. Application can then
3305 * retrieve the string description of the NAT type
3306 * by calling pj_stun_get_nat_name().
3307 *
3308 * @return PJ_SUCCESS on success.
3309 *
3310 * @see pjsua_get_nat_type(), nat_type_in_sdp
3311 */
3312PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
3313 pj_stun_nat_type *p_type);
3314
3315/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003316 * Send response to incoming INVITE request. Depending on the status
3317 * code specified as parameter, this function may send provisional
3318 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003319 *
3320 * @param call_id Incoming call identification.
3321 * @param code Status code, (100-699).
3322 * @param reason Optional reason phrase. If NULL, default text
3323 * will be used.
3324 * @param msg_data Optional list of headers etc to be added to outgoing
3325 * response message.
3326 *
3327 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoa91a0032006-02-26 21:23:45 +00003328 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003329PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
3330 unsigned code,
3331 const pj_str_t *reason,
3332 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00003333
3334/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003335 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00003336 * call state. This function is different than answering the call with
3337 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
3338 * will hangup the call regardless of the state and role of the call,
3339 * while #pjsua_call_answer() only works with incoming calls on EARLY
3340 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003341 *
3342 * @param call_id Call identification.
3343 * @param code Optional status code to be sent when we're rejecting
3344 * incoming call. If the value is zero, "603/Decline"
3345 * will be sent.
3346 * @param reason Optional reason phrase to be sent when we're rejecting
3347 * incoming call. If NULL, default text will be used.
3348 * @param msg_data Optional list of headers etc to be added to outgoing
3349 * request/response message.
3350 *
3351 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003352 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003353PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
3354 unsigned code,
3355 const pj_str_t *reason,
3356 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003357
Benny Prijono5e51a4e2008-11-27 00:06:46 +00003358/**
3359 * Accept or reject redirection response. Application MUST call this function
3360 * after it signaled PJSIP_REDIRECT_PENDING in the \a on_call_redirected()
3361 * callback, to notify the call whether to accept or reject the redirection
3362 * to the current target. Application can use the combination of
3363 * PJSIP_REDIRECT_PENDING command in \a on_call_redirected() callback and
3364 * this function to ask for user permission before redirecting the call.
3365 *
3366 * Note that if the application chooses to reject or stop redirection (by
3367 * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the
3368 * call disconnection callback will be called before this function returns.
3369 * And if the application rejects the target, the \a on_call_redirected()
3370 * callback may also be called before this function returns if there is
3371 * another target to try.
3372 *
3373 * @param call_id The call ID.
3374 * @param cmd Redirection operation to be applied to the current
3375 * target. The semantic of this argument is similar
3376 * to the description in the \a on_call_redirected()
3377 * callback, except that the PJSIP_REDIRECT_PENDING is
3378 * not accepted here.
3379 *
3380 * @return PJ_SUCCESS on successful operation.
3381 */
3382PJ_DECL(pj_status_t) pjsua_call_process_redirect(pjsua_call_id call_id,
3383 pjsip_redirect_op cmd);
Benny Prijono26ff9062006-02-21 23:47:00 +00003384
3385/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003386 * Put the specified call on hold. This will send re-INVITE with the
3387 * appropriate SDP to inform remote that the call is being put on hold.
3388 * The final status of the request itself will be reported on the
3389 * \a on_call_media_state() callback, which inform the application that
3390 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003391 *
3392 * @param call_id Call identification.
3393 * @param msg_data Optional message components to be sent with
3394 * the request.
3395 *
3396 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003397 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003398PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
3399 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003400
3401
3402/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003403 * Send re-INVITE to release hold.
3404 * The final status of the request itself will be reported on the
3405 * \a on_call_media_state() callback, which inform the application that
3406 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003407 *
3408 * @param call_id Call identification.
3409 * @param unhold If this argument is non-zero and the call is locally
3410 * held, this will release the local hold.
3411 * @param msg_data Optional message components to be sent with
3412 * the request.
3413 *
3414 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003415 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003416PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
3417 pj_bool_t unhold,
3418 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003419
Benny Prijonoc08682e2007-10-04 06:17:58 +00003420/**
3421 * Send UPDATE request.
3422 *
3423 * @param call_id Call identification.
3424 * @param options Must be zero for now.
3425 * @param msg_data Optional message components to be sent with
3426 * the request.
3427 *
3428 * @return PJ_SUCCESS on success, or the appropriate error code.
3429 */
3430PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
3431 unsigned options,
3432 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003433
3434/**
Benny Prijono053f5222006-11-11 16:16:04 +00003435 * Initiate call transfer to the specified address. This function will send
3436 * REFER request to instruct remote call party to initiate a new INVITE
3437 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003438 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00003439 * If application is interested to monitor the successfulness and
3440 * the progress of the transfer request, it can implement
3441 * \a on_call_transfer_status() callback which will report the progress
3442 * of the call transfer request.
3443 *
Benny Prijono053f5222006-11-11 16:16:04 +00003444 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003445 * @param dest Address of new target to be contacted.
3446 * @param msg_data Optional message components to be sent with
3447 * the request.
3448 *
3449 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003450 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003451PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
3452 const pj_str_t *dest,
3453 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003454
3455/**
Benny Prijono053f5222006-11-11 16:16:04 +00003456 * Flag to indicate that "Require: replaces" should not be put in the
3457 * outgoing INVITE request caused by REFER request created by
3458 * #pjsua_call_xfer_replaces().
3459 */
3460#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
3461
3462/**
3463 * Initiate attended call transfer. This function will send REFER request
3464 * to instruct remote call party to initiate new INVITE session to the URL
3465 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
3466 * the call with us with the new call from the REFER recipient.
3467 *
3468 * @param call_id The call id to be transfered.
3469 * @param dest_call_id The call id to be replaced.
3470 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
3471 * to suppress the inclusion of "Require: replaces" in
3472 * the outgoing INVITE request created by the REFER
3473 * request.
3474 * @param msg_data Optional message components to be sent with
3475 * the request.
3476 *
3477 * @return PJ_SUCCESS on success, or the appropriate error code.
3478 */
3479PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
3480 pjsua_call_id dest_call_id,
3481 unsigned options,
3482 const pjsua_msg_data *msg_data);
3483
3484/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003485 * Send DTMF digits to remote using RFC 2833 payload formats.
3486 *
3487 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003488 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003489 *
3490 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003491 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003492PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003493 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00003494
Benny Prijono26ff9062006-02-21 23:47:00 +00003495/**
Benny Prijonob0808372006-03-02 21:18:58 +00003496 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003497 *
3498 * @param call_id Call identification.
3499 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3500 * assumed.
3501 * @param content The message content.
3502 * @param msg_data Optional list of headers etc to be included in outgoing
3503 * request. The body descriptor in the msg_data is
3504 * ignored.
3505 * @param user_data Optional user data, which will be given back when
3506 * the IM callback is called.
3507 *
3508 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003509 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003510PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
3511 const pj_str_t *mime_type,
3512 const pj_str_t *content,
3513 const pjsua_msg_data *msg_data,
3514 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003515
3516
3517/**
3518 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003519 *
3520 * @param call_id Call identification.
3521 * @param is_typing Non-zero to indicate to remote that local person is
3522 * currently typing an IM.
3523 * @param msg_data Optional list of headers etc to be included in outgoing
3524 * request.
3525 *
3526 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003527 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003528PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
3529 pj_bool_t is_typing,
3530 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003531
3532/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00003533 * Send arbitrary request with the call. This is useful for example to send
3534 * INFO request. Note that application should not use this function to send
3535 * requests which would change the invite session's state, such as re-INVITE,
3536 * UPDATE, PRACK, and BYE.
3537 *
3538 * @param call_id Call identification.
3539 * @param method SIP method of the request.
3540 * @param msg_data Optional message body and/or list of headers to be
3541 * included in outgoing request.
3542 *
3543 * @return PJ_SUCCESS on success, or the appropriate error code.
3544 */
3545PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
3546 const pj_str_t *method,
3547 const pjsua_msg_data *msg_data);
3548
3549
3550/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003551 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
3552 * currently active calls.
Benny Prijono834aee32006-02-19 01:38:06 +00003553 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00003554PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00003555
3556
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003557/**
3558 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003559 *
3560 * @param call_id Call identification.
3561 * @param with_media Non-zero to include media information too.
3562 * @param buffer Buffer where the statistics are to be written to.
3563 * @param maxlen Maximum length of buffer.
3564 * @param indent Spaces for left indentation.
3565 *
3566 * @return PJ_SUCCESS on success.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003567 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003568PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
3569 pj_bool_t with_media,
3570 char *buffer,
3571 unsigned maxlen,
3572 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003573
Benny Prijono9fc735d2006-05-28 14:58:12 +00003574/**
Benny Prijono312aff92006-06-17 04:08:30 +00003575 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003576 */
Benny Prijono834aee32006-02-19 01:38:06 +00003577
3578
3579/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00003580 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00003581 */
3582
Benny Prijono312aff92006-06-17 04:08:30 +00003583
3584/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003585 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00003586 * @ingroup PJSUA_LIB
3587 * @brief Buddy management, buddy's presence, and instant messaging.
3588 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00003589 *
3590 * This section describes PJSUA-APIs related to buddies management,
3591 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00003592 */
3593
3594/**
3595 * Max buddies in buddy list.
3596 */
3597#ifndef PJSUA_MAX_BUDDIES
3598# define PJSUA_MAX_BUDDIES 256
3599#endif
3600
3601
3602/**
Benny Prijono6ab05322009-10-21 03:03:06 +00003603 * This specifies how long the library should wait before retrying failed
3604 * SUBSCRIBE request, and there is no rule to automatically resubscribe
3605 * (for example, no "retry-after" parameter in Subscription-State header).
3606 *
3607 * This also controls the duration before failed PUBLISH request will be
3608 * retried.
Benny Prijonoa17496a2007-10-31 10:20:31 +00003609 *
3610 * Default: 300 seconds
3611 */
3612#ifndef PJSUA_PRES_TIMER
3613# define PJSUA_PRES_TIMER 300
3614#endif
3615
3616
3617/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003618 * This structure describes buddy configuration when adding a buddy to
3619 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
3620 * the structure with #pjsua_buddy_config_default() to initialize this
3621 * structure with default configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00003622 */
3623typedef struct pjsua_buddy_config
3624{
3625 /**
3626 * Buddy URL or name address.
3627 */
3628 pj_str_t uri;
3629
3630 /**
3631 * Specify whether presence subscription should start immediately.
3632 */
3633 pj_bool_t subscribe;
3634
Benny Prijono705e7842008-07-21 18:12:51 +00003635 /**
3636 * Specify arbitrary application data to be associated with with
3637 * the buddy object.
3638 */
3639 void *user_data;
3640
Benny Prijono312aff92006-06-17 04:08:30 +00003641} pjsua_buddy_config;
3642
3643
3644/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003645 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003646 */
3647typedef enum pjsua_buddy_status
3648{
3649 /**
3650 * Online status is unknown (possibly because no presence subscription
3651 * has been established).
3652 */
3653 PJSUA_BUDDY_STATUS_UNKNOWN,
3654
3655 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003656 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003657 */
3658 PJSUA_BUDDY_STATUS_ONLINE,
3659
3660 /**
3661 * Buddy is offline.
3662 */
3663 PJSUA_BUDDY_STATUS_OFFLINE,
3664
3665} pjsua_buddy_status;
3666
3667
3668
3669/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003670 * This structure describes buddy info, which can be retrieved by calling
3671 * #pjsua_buddy_get_info().
Benny Prijono312aff92006-06-17 04:08:30 +00003672 */
3673typedef struct pjsua_buddy_info
3674{
3675 /**
3676 * The buddy ID.
3677 */
3678 pjsua_buddy_id id;
3679
3680 /**
3681 * The full URI of the buddy, as specified in the configuration.
3682 */
3683 pj_str_t uri;
3684
3685 /**
3686 * Buddy's Contact, only available when presence subscription has
3687 * been established to the buddy.
3688 */
3689 pj_str_t contact;
3690
3691 /**
3692 * Buddy's online status.
3693 */
3694 pjsua_buddy_status status;
3695
3696 /**
3697 * Text to describe buddy's online status.
3698 */
3699 pj_str_t status_text;
3700
3701 /**
3702 * Flag to indicate that we should monitor the presence information for
3703 * this buddy (normally yes, unless explicitly disabled).
3704 */
3705 pj_bool_t monitor_pres;
3706
3707 /**
Benny Prijono63fba012008-07-17 14:19:10 +00003708 * If \a monitor_pres is enabled, this specifies the last state of the
3709 * presence subscription. If presence subscription session is currently
3710 * active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence
3711 * subscription request has been rejected, the value will be
3712 * PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be
3713 * specified in \a sub_term_reason.
3714 */
3715 pjsip_evsub_state sub_state;
3716
3717 /**
Benny Prijonod06d8c52009-06-30 13:53:47 +00003718 * String representation of subscription state.
3719 */
3720 const char *sub_state_name;
3721
3722 /**
Benny Prijono73bb7232009-10-20 13:56:26 +00003723 * Specifies the last presence subscription termination code. This would
3724 * return the last status of the SUBSCRIBE request. If the subscription
3725 * is terminated with NOTIFY by the server, this value will be set to
3726 * 200, and subscription termination reason will be given in the
3727 * \a sub_term_reason field.
3728 */
3729 unsigned sub_term_code;
3730
3731 /**
3732 * Specifies the last presence subscription termination reason. If
Benny Prijono63fba012008-07-17 14:19:10 +00003733 * presence subscription is currently active, the value will be empty.
3734 */
3735 pj_str_t sub_term_reason;
3736
3737 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003738 * Extended RPID information about the person.
3739 */
3740 pjrpid_element rpid;
3741
3742 /**
Benny Prijono28add7e2009-06-15 16:03:40 +00003743 * Extended presence info.
3744 */
3745 pjsip_pres_status pres_status;
3746
3747 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003748 * Internal buffer.
3749 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003750 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003751
3752} pjsua_buddy_info;
3753
3754
Benny Prijono834aee32006-02-19 01:38:06 +00003755/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003756 * Set default values to the buddy config.
3757 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003758PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003759
3760
3761/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003762 * Get total number of buddies.
3763 *
3764 * @return Number of buddies.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003765 */
3766PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3767
3768
3769/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003770 * Check if buddy ID is valid.
3771 *
3772 * @param buddy_id Buddy ID to check.
3773 *
3774 * @return Non-zero if buddy ID is valid.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003775 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003776PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3777
3778
3779/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003780 * Enumerate all buddy IDs in the buddy list. Application then can use
3781 * #pjsua_buddy_get_info() to get the detail information for each buddy
3782 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003783 *
3784 * @param ids Array of ids to be initialized.
3785 * @param count On input, specifies max elements in the array.
3786 * On return, it contains actual number of elements
3787 * that have been initialized.
3788 *
3789 * @return PJ_SUCCESS on success, or the appropriate error code.
3790 */
3791PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3792 unsigned *count);
3793
3794/**
Benny Prijono705e7842008-07-21 18:12:51 +00003795 * Find the buddy ID with the specified URI.
3796 *
3797 * @param uri The buddy URI.
3798 *
3799 * @return The buddy ID, or PJSUA_INVALID_ID if not found.
3800 */
3801PJ_DECL(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri);
3802
3803
3804/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003805 * Get detailed buddy info.
3806 *
3807 * @param buddy_id The buddy identification.
3808 * @param info Pointer to receive information about buddy.
3809 *
3810 * @return PJ_SUCCESS on success, or the appropriate error code.
3811 */
3812PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003813 pjsua_buddy_info *info);
3814
3815/**
Benny Prijono705e7842008-07-21 18:12:51 +00003816 * Set the user data associated with the buddy object.
3817 *
3818 * @param buddy_id The buddy identification.
3819 * @param user_data Arbitrary application data to be associated with
3820 * the buddy object.
3821 *
3822 * @return PJ_SUCCESS on success, or the appropriate error code.
3823 */
3824PJ_DECL(pj_status_t) pjsua_buddy_set_user_data(pjsua_buddy_id buddy_id,
3825 void *user_data);
3826
3827
3828/**
3829 * Get the user data associated with the budy object.
3830 *
3831 * @param buddy_id The buddy identification.
3832 *
3833 * @return The application data.
3834 */
3835PJ_DECL(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id);
3836
3837
3838/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003839 * Add new buddy to the buddy list. If presence subscription is enabled
3840 * for this buddy, this function will also start the presence subscription
3841 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003842 *
Benny Prijonoa7b376b2008-01-25 16:06:33 +00003843 * @param buddy_cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003844 * @param p_buddy_id Pointer to receive buddy ID.
3845 *
3846 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003847 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003848PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003849 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003850
3851
3852/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003853 * Delete the specified buddy from the buddy list. Any presence subscription
3854 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003855 *
3856 * @param buddy_id Buddy identification.
3857 *
3858 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00003859 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003860PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003861
3862
3863/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003864 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3865 * subscribed, application will be informed about buddy's presence status
3866 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003867 *
3868 * @param buddy_id Buddy identification.
3869 * @param subscribe Specify non-zero to activate presence subscription to
3870 * the specified buddy.
3871 *
3872 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003873 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003874PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3875 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003876
3877
3878/**
Benny Prijono10861432007-10-31 10:54:53 +00003879 * Update the presence information for the buddy. Although the library
3880 * periodically refreshes the presence subscription for all buddies, some
3881 * application may want to refresh the buddy's presence subscription
3882 * immediately, and in this case it can use this function to accomplish
3883 * this.
3884 *
3885 * Note that the buddy's presence subscription will only be initiated
3886 * if presence monitoring is enabled for the buddy. See
3887 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
3888 * for the buddy is already active, this function will not do anything.
3889 *
3890 * Once the presence subscription is activated successfully for the buddy,
3891 * application will be notified about the buddy's presence status in the
3892 * on_buddy_state() callback.
3893 *
3894 * @param buddy_id Buddy identification.
3895 *
3896 * @return PJ_SUCCESS on success, or the appropriate error code.
3897 */
3898PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
3899
3900
3901/**
Benny Prijono63fba012008-07-17 14:19:10 +00003902 * Send NOTIFY to inform account presence status or to terminate server
3903 * side presence subscription. If application wants to reject the incoming
3904 * request, it should set the \a state to PJSIP_EVSUB_STATE_TERMINATED.
3905 *
3906 * @param acc_id Account ID.
3907 * @param srv_pres Server presence subscription instance.
3908 * @param state New state to set.
3909 * @param state_str Optionally specify the state string name, if state
3910 * is not "active", "pending", or "terminated".
3911 * @param reason If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3912 * optionally specify the termination reason.
3913 * @param with_body If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3914 * this specifies whether the NOTIFY request should
3915 * contain message body containing account's presence
3916 * information.
3917 * @param msg_data Optional list of headers to be sent with the NOTIFY
3918 * request.
3919 *
3920 * @return PJ_SUCCESS on success.
3921 */
3922PJ_DECL(pj_status_t) pjsua_pres_notify(pjsua_acc_id acc_id,
3923 pjsua_srv_pres *srv_pres,
3924 pjsip_evsub_state state,
3925 const pj_str_t *state_str,
3926 const pj_str_t *reason,
3927 pj_bool_t with_body,
3928 const pjsua_msg_data *msg_data);
3929
3930/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003931 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003932 *
3933 * @param verbose Yes or no.
Benny Prijono834aee32006-02-19 01:38:06 +00003934 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003935PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003936
3937
Benny Prijonob0808372006-03-02 21:18:58 +00003938/**
3939 * The MESSAGE method (defined in pjsua_im.c)
3940 */
3941extern const pjsip_method pjsip_message_method;
3942
3943
Benny Prijonob0808372006-03-02 21:18:58 +00003944
3945/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003946 * Send instant messaging outside dialog, using the specified account for
3947 * route set and authentication.
3948 *
3949 * @param acc_id Account ID to be used to send the request.
3950 * @param to Remote URI.
3951 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3952 * assumed.
3953 * @param content The message content.
3954 * @param msg_data Optional list of headers etc to be included in outgoing
3955 * request. The body descriptor in the msg_data is
3956 * ignored.
3957 * @param user_data Optional user data, which will be given back when
3958 * the IM callback is called.
3959 *
3960 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003961 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003962PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3963 const pj_str_t *to,
3964 const pj_str_t *mime_type,
3965 const pj_str_t *content,
3966 const pjsua_msg_data *msg_data,
3967 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003968
3969
3970/**
3971 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003972 *
3973 * @param acc_id Account ID to be used to send the request.
3974 * @param to Remote URI.
3975 * @param is_typing If non-zero, it tells remote person that local person
3976 * is currently composing an IM.
3977 * @param msg_data Optional list of headers etc to be added to outgoing
3978 * request.
3979 *
3980 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003981 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003982PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3983 const pj_str_t *to,
3984 pj_bool_t is_typing,
3985 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003986
3987
Benny Prijonof3195072006-02-14 21:15:30 +00003988
Benny Prijono312aff92006-06-17 04:08:30 +00003989/**
3990 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003991 */
3992
Benny Prijono312aff92006-06-17 04:08:30 +00003993
3994/*****************************************************************************
3995 * MEDIA API
3996 */
3997
3998
3999/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00004000 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00004001 * @ingroup PJSUA_LIB
4002 * @brief Media manipulation.
4003 * @{
4004 *
4005 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00004006 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
4007 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00004008 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00004009 * the interconnection between these terminations freely.
4010 *
4011 * The conference bridge provides powerful switching and mixing functionality
4012 * for application. With the conference bridge, each conference slot (e.g.
4013 * a call) can transmit to multiple destinations, and one destination can
4014 * receive from multiple sources. If more than one media terminations are
4015 * terminated in the same slot, the conference bridge will mix the signal
4016 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00004017 *
4018 * Application connects one media termination/slot to another by calling
4019 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00004020 * media flow from the source termination to the sink termination. To
4021 * establish bidirectional media flow, application wound need to make another
4022 * call to #pjsua_conf_connect(), this time inverting the source and
4023 * destination slots in the parameter.
4024 *
4025 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00004026 * the following steps:
4027 *
4028 \code
4029
4030 pj_status_t stream_to_call( pjsua_call_id call_id )
4031 {
4032 pjsua_player_id player_id;
4033
4034 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
4035 if (status != PJ_SUCCESS)
4036 return status;
4037
4038 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
4039 pjsua_call_get_conf_port() );
4040 }
4041 \endcode
4042 *
4043 *
4044 * Other features of PJSUA media:
4045 * - efficient N to M interconnections between media terminations.
4046 * - media termination can be connected to itself to create loopback
4047 * media.
4048 * - the media termination may have different clock rates, and resampling
4049 * will be done automatically by conference bridge.
4050 * - media terminations may also have different frame time; the
4051 * conference bridge will perform the necessary bufferring to adjust
4052 * the difference between terminations.
4053 * - interconnections are removed automatically when media termination
4054 * is removed from the bridge.
4055 * - sound device may be changed even when there are active media
4056 * interconnections.
4057 * - correctly report call's media quality (in #pjsua_call_dump()) from
4058 * RTCP packet exchange.
4059 */
4060
4061/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004062 * Max ports in the conference bridge. This setting is the default value
4063 * for pjsua_media_config.max_media_ports.
Benny Prijono312aff92006-06-17 04:08:30 +00004064 */
4065#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00004066# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00004067#endif
4068
Benny Prijonob5388cf2007-01-04 22:45:08 +00004069/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004070 * The default clock rate to be used by the conference bridge. This setting
4071 * is the default value for pjsua_media_config.clock_rate.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004072 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004073#ifndef PJSUA_DEFAULT_CLOCK_RATE
4074# define PJSUA_DEFAULT_CLOCK_RATE 16000
4075#endif
4076
Benny Prijonob5388cf2007-01-04 22:45:08 +00004077/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004078 * Default frame length in the conference bridge. This setting
4079 * is the default value for pjsua_media_config.audio_frame_ptime.
4080 */
4081#ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Nanang Izzuddinaf974842008-05-08 09:51:16 +00004082# define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
Benny Prijono37c710b2008-01-10 12:09:26 +00004083#endif
4084
4085
4086/**
4087 * Default codec quality settings. This setting is the default value
4088 * for pjsua_media_config.quality.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004089 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004090#ifndef PJSUA_DEFAULT_CODEC_QUALITY
Nanang Izzuddin9dbad152008-06-10 18:56:10 +00004091# define PJSUA_DEFAULT_CODEC_QUALITY 8
Benny Prijono12a669c2006-11-23 07:32:13 +00004092#endif
4093
Benny Prijonob5388cf2007-01-04 22:45:08 +00004094/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004095 * Default iLBC mode. This setting is the default value for
4096 * pjsua_media_config.ilbc_mode.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004097 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004098#ifndef PJSUA_DEFAULT_ILBC_MODE
Benny Prijono37c710b2008-01-10 12:09:26 +00004099# define PJSUA_DEFAULT_ILBC_MODE 30
Benny Prijono12a669c2006-11-23 07:32:13 +00004100#endif
4101
Benny Prijonob5388cf2007-01-04 22:45:08 +00004102/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004103 * The default echo canceller tail length. This setting
4104 * is the default value for pjsua_media_config.ec_tail_len.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004105 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004106#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijono427439c2007-10-21 09:41:24 +00004107# define PJSUA_DEFAULT_EC_TAIL_LEN 200
Benny Prijono12a669c2006-11-23 07:32:13 +00004108#endif
Benny Prijono312aff92006-06-17 04:08:30 +00004109
4110
4111/**
Benny Prijonocba59d92007-02-16 09:22:56 +00004112 * The maximum file player.
4113 */
4114#ifndef PJSUA_MAX_PLAYERS
4115# define PJSUA_MAX_PLAYERS 32
4116#endif
4117
4118
4119/**
4120 * The maximum file player.
4121 */
4122#ifndef PJSUA_MAX_RECORDERS
4123# define PJSUA_MAX_RECORDERS 32
4124#endif
4125
4126
4127/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004128 * This structure describes media configuration, which will be specified
4129 * when calling #pjsua_init(). Application MUST initialize this structure
4130 * by calling #pjsua_media_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00004131 */
4132struct pjsua_media_config
4133{
4134 /**
4135 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004136 * If value is zero, default clock rate will be used
4137 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00004138 */
4139 unsigned clock_rate;
4140
4141 /**
Benny Prijonof3758ee2008-02-26 15:32:16 +00004142 * Clock rate to be applied when opening the sound device.
4143 * If value is zero, conference bridge clock rate will be used.
4144 */
4145 unsigned snd_clock_rate;
4146
4147 /**
Benny Prijono7d60d052008-03-29 12:24:20 +00004148 * Channel count be applied when opening the sound device and
4149 * conference bridge.
4150 */
4151 unsigned channel_count;
4152
4153 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004154 * Specify audio frame ptime. The value here will affect the
4155 * samples per frame of both the sound device and the conference
4156 * bridge. Specifying lower ptime will normally reduce the
4157 * latency.
4158 *
Benny Prijono37c710b2008-01-10 12:09:26 +00004159 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004160 */
4161 unsigned audio_frame_ptime;
4162
4163 /**
Benny Prijono312aff92006-06-17 04:08:30 +00004164 * Specify maximum number of media ports to be created in the
4165 * conference bridge. Since all media terminate in the bridge
4166 * (calls, file player, file recorder, etc), the value must be
4167 * large enough to support all of them. However, the larger
4168 * the value, the more computations are performed.
Benny Prijono37c710b2008-01-10 12:09:26 +00004169 *
4170 * Default value: PJSUA_MAX_CONF_PORTS
Benny Prijono312aff92006-06-17 04:08:30 +00004171 */
4172 unsigned max_media_ports;
4173
4174 /**
4175 * Specify whether the media manager should manage its own
4176 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
4177 * and at least one worker thread will be created too. If no,
4178 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
4179 * and no worker thread is needed.
4180 *
4181 * Normally application would say yes here, unless it wants to
4182 * run everything from a single thread.
4183 */
4184 pj_bool_t has_ioqueue;
4185
4186 /**
4187 * Specify the number of worker threads to handle incoming RTP
4188 * packets. A value of one is recommended for most applications.
4189 */
4190 unsigned thread_cnt;
4191
Benny Prijono0498d902006-06-19 14:49:14 +00004192 /**
4193 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00004194 * 5-10: resampling use large filter,
4195 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00004196 * 1-2: resampling use linear.
4197 * The media quality also sets speex codec quality/complexity to the
4198 * number.
4199 *
Benny Prijono70972992006-08-05 11:13:58 +00004200 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00004201 */
4202 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00004203
4204 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004205 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00004206 *
4207 * Default: 0 (codec specific)
4208 */
4209 unsigned ptime;
4210
4211 /**
4212 * Disable VAD?
4213 *
4214 * Default: 0 (no (meaning VAD is enabled))
4215 */
4216 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00004217
4218 /**
4219 * iLBC mode (20 or 30).
4220 *
Benny Prijono37c710b2008-01-10 12:09:26 +00004221 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00004222 */
4223 unsigned ilbc_mode;
4224
4225 /**
4226 * Percentage of RTP packet to drop in TX direction
4227 * (to simulate packet lost).
4228 *
4229 * Default: 0
4230 */
4231 unsigned tx_drop_pct;
4232
4233 /**
4234 * Percentage of RTP packet to drop in RX direction
4235 * (to simulate packet lost).
4236 *
4237 * Default: 0
4238 */
4239 unsigned rx_drop_pct;
4240
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004241 /**
Benny Prijono5da50432006-08-07 10:24:52 +00004242 * Echo canceller options (see #pjmedia_echo_create())
4243 *
4244 * Default: 0.
4245 */
4246 unsigned ec_options;
4247
4248 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004249 * Echo canceller tail length, in miliseconds.
4250 *
Benny Prijono669643c2006-09-20 20:02:18 +00004251 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004252 */
4253 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004254
Benny Prijono10454dc2009-02-21 14:21:59 +00004255 /**
4256 * Audio capture buffer length, in milliseconds.
4257 *
4258 * Default: PJMEDIA_SND_DEFAULT_REC_LATENCY
4259 */
4260 unsigned snd_rec_latency;
4261
4262 /**
4263 * Audio playback buffer length, in milliseconds.
4264 *
4265 * Default: PJMEDIA_SND_DEFAULT_PLAY_LATENCY
4266 */
4267 unsigned snd_play_latency;
4268
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004269 /**
4270 * Jitter buffer initial prefetch delay in msec. The value must be
4271 * between jb_min_pre and jb_max_pre below.
4272 *
4273 * Default: -1 (to use default stream settings, currently 150 msec)
4274 */
4275 int jb_init;
4276
4277 /**
4278 * Jitter buffer minimum prefetch delay in msec.
4279 *
4280 * Default: -1 (to use default stream settings, currently 60 msec)
4281 */
4282 int jb_min_pre;
4283
4284 /**
4285 * Jitter buffer maximum prefetch delay in msec.
4286 *
4287 * Default: -1 (to use default stream settings, currently 240 msec)
4288 */
4289 int jb_max_pre;
4290
4291 /**
4292 * Set maximum delay that can be accomodated by the jitter buffer msec.
4293 *
4294 * Default: -1 (to use default stream settings, currently 360 msec)
4295 */
4296 int jb_max;
4297
Benny Prijonoc97608e2007-03-23 16:34:20 +00004298 /**
4299 * Enable ICE
4300 */
4301 pj_bool_t enable_ice;
4302
4303 /**
Benny Prijono329d6382009-05-29 13:04:03 +00004304 * Set the maximum number of host candidates.
4305 *
4306 * Default: -1 (maximum not set)
Benny Prijonoc97608e2007-03-23 16:34:20 +00004307 */
Benny Prijono329d6382009-05-29 13:04:03 +00004308 int ice_max_host_cands;
4309
4310 /**
4311 * ICE session options.
4312 */
4313 pj_ice_sess_options ice_opt;
Benny Prijonof76e1392008-06-06 14:51:48 +00004314
4315 /**
Benny Prijono551af422008-08-07 09:55:52 +00004316 * Disable RTCP component.
4317 *
4318 * Default: no
4319 */
4320 pj_bool_t ice_no_rtcp;
4321
4322 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00004323 * Enable TURN relay candidate in ICE.
4324 */
4325 pj_bool_t enable_turn;
4326
4327 /**
4328 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
4329 * "HOST:PORT" format.
4330 */
4331 pj_str_t turn_server;
4332
4333 /**
4334 * Specify the connection type to be used to the TURN server. Valid
4335 * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP.
4336 *
4337 * Default: PJ_TURN_TP_UDP
4338 */
4339 pj_turn_tp_type turn_conn_type;
4340
4341 /**
4342 * Specify the credential to authenticate with the TURN server.
4343 */
4344 pj_stun_auth_cred turn_auth_cred;
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004345
4346 /**
4347 * Specify idle time of sound device before it is automatically closed,
Benny Prijonof798e502009-03-09 13:08:16 +00004348 * in seconds. Use value -1 to disable the auto-close feature of sound
4349 * device
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004350 *
Benny Prijonof798e502009-03-09 13:08:16 +00004351 * Default : 1
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004352 */
4353 int snd_auto_close_time;
Benny Prijono312aff92006-06-17 04:08:30 +00004354};
4355
4356
4357/**
4358 * Use this function to initialize media config.
4359 *
4360 * @param cfg The media config to be initialized.
4361 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00004362PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00004363
4364
4365/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004366 * This structure describes codec information, which can be retrieved by
4367 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00004368 */
4369typedef struct pjsua_codec_info
4370{
4371 /**
4372 * Codec unique identification.
4373 */
4374 pj_str_t codec_id;
4375
4376 /**
4377 * Codec priority (integer 0-255).
4378 */
4379 pj_uint8_t priority;
4380
4381 /**
Nanang Izzuddin56b2ce42011-04-06 13:55:01 +00004382 * Codec description.
4383 */
4384 pj_str_t desc;
4385
4386 /**
Benny Prijono312aff92006-06-17 04:08:30 +00004387 * Internal buffer.
4388 */
Nanang Izzuddin56b2ce42011-04-06 13:55:01 +00004389 char buf_[64];
Benny Prijono312aff92006-06-17 04:08:30 +00004390
4391} pjsua_codec_info;
4392
4393
4394/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004395 * This structure descibes information about a particular media port that
4396 * has been registered into the conference bridge. Application can query
4397 * this info by calling #pjsua_conf_get_port_info().
Benny Prijono312aff92006-06-17 04:08:30 +00004398 */
4399typedef struct pjsua_conf_port_info
4400{
4401 /** Conference port number. */
4402 pjsua_conf_port_id slot_id;
4403
4404 /** Port name. */
4405 pj_str_t name;
4406
4407 /** Clock rate. */
4408 unsigned clock_rate;
4409
4410 /** Number of channels. */
4411 unsigned channel_count;
4412
4413 /** Samples per frame */
4414 unsigned samples_per_frame;
4415
4416 /** Bits per sample */
4417 unsigned bits_per_sample;
4418
4419 /** Number of listeners in the array. */
4420 unsigned listener_cnt;
4421
4422 /** Array of listeners (in other words, ports where this port is
4423 * transmitting to.
4424 */
4425 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
4426
4427} pjsua_conf_port_info;
4428
4429
4430/**
4431 * This structure holds information about custom media transport to
4432 * be registered to pjsua.
4433 */
4434typedef struct pjsua_media_transport
4435{
4436 /**
4437 * Media socket information containing the address information
4438 * of the RTP and RTCP socket.
4439 */
4440 pjmedia_sock_info skinfo;
4441
4442 /**
4443 * The media transport instance.
4444 */
4445 pjmedia_transport *transport;
4446
4447} pjsua_media_transport;
4448
4449
4450
4451
Benny Prijono9fc735d2006-05-28 14:58:12 +00004452/**
4453 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004454 *
4455 * @return Maximum number of ports in the conference bridge.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004456 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004457PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004458
4459
4460/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004461 * Get current number of active ports in the bridge.
4462 *
4463 * @return The number.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004464 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004465PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
4466
4467
4468/**
4469 * Enumerate all conference ports.
4470 *
4471 * @param id Array of conference port ID to be initialized.
4472 * @param count On input, specifies max elements in the array.
4473 * On return, it contains actual number of elements
4474 * that have been initialized.
4475 *
4476 * @return PJ_SUCCESS on success, or the appropriate error code.
4477 */
4478PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
4479 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004480
4481
4482/**
4483 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004484 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004485 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004486 * @param info Pointer to store the port info.
4487 *
4488 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004489 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004490PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00004491 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004492
4493
4494/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00004495 * Add arbitrary media port to PJSUA's conference bridge. Application
4496 * can use this function to add the media port that it creates. For
4497 * media ports that are created by PJSUA-LIB (such as calls, file player,
4498 * or file recorder), PJSUA-LIB will automatically add the port to
4499 * the bridge.
4500 *
4501 * @param pool Pool to use.
4502 * @param port Media port to be added to the bridge.
4503 * @param p_id Optional pointer to receive the conference
4504 * slot id.
4505 *
4506 * @return PJ_SUCCESS on success, or the appropriate error code.
4507 */
4508PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
4509 pjmedia_port *port,
4510 pjsua_conf_port_id *p_id);
4511
4512
4513/**
4514 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00004515 * call this function if it registered the port manually with previous call
4516 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00004517 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004518 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00004519 *
4520 * @return PJ_SUCCESS on success, or the appropriate error code.
4521 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004522PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00004523
4524
4525/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004526 * Establish unidirectional media flow from souce to sink. One source
4527 * may transmit to multiple destinations/sink. And if multiple
4528 * sources are transmitting to the same sink, the media will be mixed
4529 * together. Source and sink may refer to the same ID, effectively
4530 * looping the media.
4531 *
4532 * If bidirectional media flow is desired, application needs to call
4533 * this function twice, with the second one having the arguments
4534 * reversed.
4535 *
4536 * @param source Port ID of the source media/transmitter.
4537 * @param sink Port ID of the destination media/received.
4538 *
4539 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004540 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004541PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
4542 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004543
4544
4545/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004546 * Disconnect media flow from the source to destination port.
4547 *
4548 * @param source Port ID of the source media/transmitter.
4549 * @param sink Port ID of the destination media/received.
4550 *
4551 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004552 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004553PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
4554 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004555
4556
Benny Prijono6dd967c2006-12-26 02:27:14 +00004557/**
4558 * Adjust the signal level to be transmitted from the bridge to the
4559 * specified port by making it louder or quieter.
4560 *
4561 * @param slot The conference bridge slot number.
4562 * @param level Signal level adjustment. Value 1.0 means no level
4563 * adjustment, while value 0 means to mute the port.
4564 *
4565 * @return PJ_SUCCESS on success, or the appropriate error code.
4566 */
4567PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
4568 float level);
4569
4570/**
4571 * Adjust the signal level to be received from the specified port (to
4572 * the bridge) by making it louder or quieter.
4573 *
4574 * @param slot The conference bridge slot number.
4575 * @param level Signal level adjustment. Value 1.0 means no level
4576 * adjustment, while value 0 means to mute the port.
4577 *
4578 * @return PJ_SUCCESS on success, or the appropriate error code.
4579 */
4580PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
4581 float level);
4582
4583/**
4584 * Get last signal level transmitted to or received from the specified port.
4585 * The signal level is an integer value in zero to 255, with zero indicates
4586 * no signal, and 255 indicates the loudest signal level.
4587 *
4588 * @param slot The conference bridge slot number.
4589 * @param tx_level Optional argument to receive the level of signal
4590 * transmitted to the specified port (i.e. the direction
4591 * is from the bridge to the port).
4592 * @param rx_level Optional argument to receive the level of signal
4593 * received from the port (i.e. the direction is from the
4594 * port to the bridge).
4595 *
4596 * @return PJ_SUCCESS on success.
4597 */
4598PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
4599 unsigned *tx_level,
4600 unsigned *rx_level);
4601
Benny Prijono6dd967c2006-12-26 02:27:14 +00004602
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004603/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00004604 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004605 */
4606
Benny Prijono9fc735d2006-05-28 14:58:12 +00004607/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004608 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004609 * the conference bridge.
4610 *
4611 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00004612 * WAV files are supported, and the WAV file MUST be
4613 * formatted as 16bit PCM mono/single channel (any
4614 * clock rate is supported).
Benny Prijono58add7c2008-01-18 13:24:07 +00004615 * @param options Optional option flag. Application may specify
4616 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004617 * @param p_id Pointer to receive player ID.
4618 *
4619 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004620 */
4621PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004622 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004623 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004624
4625
4626/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004627 * Create a file playlist media port, and automatically add the port
4628 * to the conference bridge.
4629 *
4630 * @param file_names Array of file names to be added to the play list.
4631 * Note that the files must have the same clock rate,
4632 * number of channels, and number of bits per sample.
4633 * @param file_count Number of files in the array.
4634 * @param label Optional label to be set for the media port.
4635 * @param options Optional option flag. Application may specify
4636 * PJMEDIA_FILE_NO_LOOP to prevent looping.
4637 * @param p_id Optional pointer to receive player ID.
4638 *
4639 * @return PJ_SUCCESS on success, or the appropriate error code.
4640 */
4641PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
4642 unsigned file_count,
4643 const pj_str_t *label,
4644 unsigned options,
4645 pjsua_player_id *p_id);
4646
4647/**
4648 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004649 *
4650 * @param id The file player ID.
4651 *
4652 * @return Conference port ID associated with this player.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004653 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004654PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004655
4656
4657/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004658 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00004659 *
4660 * @param id The player ID.
4661 * @param p_port The media port associated with the player.
4662 *
4663 * @return PJ_SUCCESS on success.
4664 */
Benny Prijono58add7c2008-01-18 13:24:07 +00004665PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
Benny Prijono469b1522006-12-26 03:05:17 +00004666 pjmedia_port **p_port);
4667
4668/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004669 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004670 *
4671 * @param id The file player ID.
4672 * @param samples The playback position, in samples. Application can
4673 * specify zero to re-start the playback.
4674 *
4675 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004676 */
4677PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
4678 pj_uint32_t samples);
4679
4680
4681/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004682 * Close the file of playlist, remove the player from the bridge, and free
4683 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004684 *
4685 * @param id The file player ID.
4686 *
4687 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004688 */
4689PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
4690
4691
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004692/*****************************************************************************
4693 * File recorder.
4694 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00004695
4696/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004697 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004698 * the conference bridge. The recorder currently supports recording WAV file.
4699 * The type of the recorder to use is determined by the extension of the file
4700 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004701 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00004702 * @param filename Output file name. The function will determine the
4703 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004704 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00004705 * @param enc_type Optionally specify the type of encoder to be used to
4706 * compress the media, if the file can support different
4707 * encodings. This value must be zero for now.
4708 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004709 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00004710 * For .WAV recorder, this value must be NULL.
4711 * @param max_size Maximum file size. Specify zero or -1 to remove size
4712 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004713 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004714 * @param p_id Pointer to receive the recorder instance.
4715 *
4716 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004717 */
4718PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004719 unsigned enc_type,
4720 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004721 pj_ssize_t max_size,
4722 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004723 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004724
4725
4726/**
4727 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004728 *
4729 * @param id The recorder ID.
4730 *
4731 * @return Conference port ID associated with this recorder.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004732 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004733PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004734
4735
4736/**
Benny Prijono469b1522006-12-26 03:05:17 +00004737 * Get the media port for the recorder.
4738 *
4739 * @param id The recorder ID.
4740 * @param p_port The media port associated with the recorder.
4741 *
4742 * @return PJ_SUCCESS on success.
4743 */
4744PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4745 pjmedia_port **p_port);
4746
4747
4748/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004749 * Destroy recorder (this will complete recording).
4750 *
4751 * @param id The recorder ID.
4752 *
4753 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004754 */
4755PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4756
4757
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004758/*****************************************************************************
4759 * Sound devices.
4760 */
4761
Benny Prijono9fc735d2006-05-28 14:58:12 +00004762/**
Benny Prijonof798e502009-03-09 13:08:16 +00004763 * Enum all audio devices installed in the system.
4764 *
4765 * @param info Array of info to be initialized.
4766 * @param count On input, specifies max elements in the array.
4767 * On return, it contains actual number of elements
4768 * that have been initialized.
4769 *
4770 * @return PJ_SUCCESS on success, or the appropriate error code.
4771 */
4772PJ_DECL(pj_status_t) pjsua_enum_aud_devs(pjmedia_aud_dev_info info[],
4773 unsigned *count);
4774
4775/**
4776 * Enum all sound devices installed in the system (old API).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004777 *
4778 * @param info Array of info to be initialized.
4779 * @param count On input, specifies max elements in the array.
4780 * On return, it contains actual number of elements
4781 * that have been initialized.
4782 *
4783 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004784 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004785PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4786 unsigned *count);
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004787
4788/**
4789 * Get currently active sound devices. If sound devices has not been created
4790 * (for example when pjsua_start() is not called), it is possible that
4791 * the function returns PJ_SUCCESS with -1 as device IDs.
4792 *
4793 * @param capture_dev On return it will be filled with device ID of the
4794 * capture device.
4795 * @param playback_dev On return it will be filled with device ID of the
4796 * device ID of the playback device.
4797 *
4798 * @return PJ_SUCCESS on success, or the appropriate error code.
4799 */
4800PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4801 int *playback_dev);
4802
4803
Benny Prijono9fc735d2006-05-28 14:58:12 +00004804/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004805 * Select or change sound device. Application may call this function at
4806 * any time to replace current sound device.
4807 *
4808 * @param capture_dev Device ID of the capture device.
4809 * @param playback_dev Device ID of the playback device.
4810 *
4811 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004812 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004813PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4814 int playback_dev);
4815
4816
4817/**
4818 * Set pjsua to use null sound device. The null sound device only provides
4819 * the timing needed by the conference bridge, and will not interract with
4820 * any hardware.
4821 *
4822 * @return PJ_SUCCESS on success, or the appropriate error code.
4823 */
4824PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4825
4826
Benny Prijonoe909eac2006-07-27 22:04:56 +00004827/**
4828 * Disconnect the main conference bridge from any sound devices, and let
4829 * application connect the bridge to it's own sound device/master port.
4830 *
4831 * @return The port interface of the conference bridge,
4832 * so that application can connect this to it's own
4833 * sound device or master port.
4834 */
4835PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4836
4837
Benny Prijonof20687a2006-08-04 18:27:19 +00004838/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004839 * Change the echo cancellation settings.
Benny Prijonof798e502009-03-09 13:08:16 +00004840 *
4841 * The behavior of this function depends on whether the sound device is
4842 * currently active, and if it is, whether device or software AEC is
4843 * being used.
Benny Prijono10454dc2009-02-21 14:21:59 +00004844 *
4845 * If the sound device is currently active, and if the device supports AEC,
4846 * this function will forward the change request to the device and it will
4847 * be up to the device on whether support the request. If software AEC is
4848 * being used (the software EC will be used if the device does not support
4849 * AEC), this function will change the software EC settings. In all cases,
4850 * the setting will be saved for future opening of the sound device.
4851 *
4852 * If the sound device is not currently active, this will only change the
4853 * default AEC settings and the setting will be applied next time the
4854 * sound device is opened.
Benny Prijonof20687a2006-08-04 18:27:19 +00004855 *
4856 * @param tail_ms The tail length, in miliseconds. Set to zero to
4857 * disable AEC.
Benny Prijonoa7b376b2008-01-25 16:06:33 +00004858 * @param options Options to be passed to pjmedia_echo_create().
Benny Prijono5da50432006-08-07 10:24:52 +00004859 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004860 *
4861 * @return PJ_SUCCESS on success.
4862 */
Benny Prijono5da50432006-08-07 10:24:52 +00004863PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004864
4865
4866/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004867 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004868 *
4869 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4870 * If AEC is disabled, the value will be zero.
4871 *
4872 * @return PJ_SUCCESS on success.
4873 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004874PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004875
4876
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004877/**
Benny Prijonof798e502009-03-09 13:08:16 +00004878 * Check whether the sound device is currently active. The sound device
4879 * may be inactive if the application has set the auto close feature to
4880 * non-zero (the snd_auto_close_time setting in #pjsua_media_config), or
4881 * if null sound device or no sound device has been configured via the
4882 * #pjsua_set_no_snd_dev() function.
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004883 */
Benny Prijonof798e502009-03-09 13:08:16 +00004884PJ_DECL(pj_bool_t) pjsua_snd_is_active(void);
4885
4886
4887/**
4888 * Configure sound device setting to the sound device being used. If sound
4889 * device is currently active, the function will forward the setting to the
4890 * sound device instance to be applied immediately, if it supports it.
4891 *
4892 * The setting will be saved for future opening of the sound device, if the
4893 * "keep" argument is set to non-zero. If the sound device is currently
4894 * inactive, and the "keep" argument is false, this function will return
4895 * error.
4896 *
4897 * Note that in case the setting is kept for future use, it will be applied
4898 * to any devices, even when application has changed the sound device to be
4899 * used.
4900 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004901 * Note also that the echo cancellation setting should be set with
4902 * #pjsua_set_ec() API instead.
4903 *
Benny Prijonof798e502009-03-09 13:08:16 +00004904 * See also #pjmedia_aud_stream_set_cap() for more information about setting
4905 * an audio device capability.
4906 *
4907 * @param cap The sound device setting to change.
4908 * @param pval Pointer to value. Please see #pjmedia_aud_dev_cap
4909 * documentation about the type of value to be
4910 * supplied for each setting.
4911 * @param keep Specify whether the setting is to be kept for future
4912 * use.
4913 *
4914 * @return PJ_SUCCESS on success or the appropriate error code.
4915 */
4916PJ_DECL(pj_status_t) pjsua_snd_set_setting(pjmedia_aud_dev_cap cap,
4917 const void *pval,
4918 pj_bool_t keep);
4919
4920/**
4921 * Retrieve a sound device setting. If sound device is currently active,
4922 * the function will forward the request to the sound device. If sound device
4923 * is currently inactive, and if application had previously set the setting
4924 * and mark the setting as kept, then that setting will be returned.
4925 * Otherwise, this function will return error.
4926 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004927 * Note that echo cancellation settings should be retrieved with
4928 * #pjsua_get_ec_tail() API instead.
4929 *
Benny Prijonof798e502009-03-09 13:08:16 +00004930 * @param cap The sound device setting to retrieve.
4931 * @param pval Pointer to receive the value.
4932 * Please see #pjmedia_aud_dev_cap documentation about
4933 * the type of value to be supplied for each setting.
4934 *
4935 * @return PJ_SUCCESS on success or the appropriate error code.
4936 */
4937PJ_DECL(pj_status_t) pjsua_snd_get_setting(pjmedia_aud_dev_cap cap,
4938 void *pval);
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004939
4940
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004941/*****************************************************************************
Nanang Izzuddin50fae732011-03-22 09:49:23 +00004942 * Video devices.
4943 */
4944
4945/**
4946 * Enum all video devices installed in the system.
4947 *
4948 * @param info Array of info to be initialized.
4949 * @param count On input, specifies max elements in the array.
4950 * On return, it contains actual number of elements
4951 * that have been initialized.
4952 *
4953 * @return PJ_SUCCESS on success, or the appropriate error code.
4954 */
4955PJ_DECL(pj_status_t) pjsua_vid_enum_devs(pjmedia_vid_dev_info info[],
4956 unsigned *count);
4957
4958
4959/**
4960 * Get currently active video devices. If video devices has not been created
4961 * (for example when pjsua_start() is not called), it is possible that
4962 * the function returns PJ_SUCCESS with -1 as device IDs.
4963 *
4964 * @param capture_dev On return it will be filled with device ID of the
4965 * capture device.
4966 * @param render_dev On return it will be filled with device ID of the
4967 * device ID of the render device.
4968 *
4969 * @return PJ_SUCCESS on success, or the appropriate error code.
4970 */
4971PJ_DECL(pj_status_t) pjsua_vid_get_dev(int *capture_dev, int *render_dev);
4972
4973
4974/**
4975 * Select video device for the next video sessions.
4976 *
4977 * @param capture_dev Device ID of the capture device.
4978 * @param render_dev Device ID of the render device.
4979 *
4980 * @return PJ_SUCCESS on success, or the appropriate error code.
4981 */
4982PJ_DECL(pj_status_t) pjsua_vid_set_dev(int capture_dev, int render_dev);
4983
4984
4985/**
4986 * Configure video device setting to the video device being used. If video
4987 * device is currently active, the function will forward the setting to the
4988 * video device instance to be applied immediately, if it supports it.
4989 *
4990 * The setting will be saved for future opening of the video device, if the
4991 * "keep" argument is set to non-zero. If the video device is currently
4992 * inactive, and the "keep" argument is false, this function will return
4993 * error.
4994 *
4995 * Note that in case the setting is kept for future use, it will be applied
4996 * to any devices, even when application has changed the video device to be
4997 * used.
4998 *
4999 * See also #pjmedia_vid_dev_stream_set_cap() for more information about
5000 * setting an video device capability.
5001 *
5002 * @param cap The video device setting to change.
5003 * @param pval Pointer to value. Please see #pjmedia_vid_dev_cap
5004 * documentation about the type of value to be
5005 * supplied for each setting.
5006 * @param keep Specify whether the setting is to be kept for future
5007 * use.
5008 *
5009 * @return PJ_SUCCESS on success or the appropriate error code.
5010 */
5011PJ_DECL(pj_status_t) pjsua_vid_set_setting(pjmedia_vid_dev_cap cap,
5012 const void *pval,
5013 pj_bool_t keep);
5014
5015/**
5016 * Retrieve a video device setting. If video device is currently active,
5017 * the function will forward the request to the video device. If video device
5018 * is currently inactive, and if application had previously set the setting
5019 * and mark the setting as kept, then that setting will be returned.
5020 * Otherwise, this function will return error.
5021 *
5022 * @param cap The video device setting to retrieve.
5023 * @param pval Pointer to receive the value.
5024 * Please see #pjmedia_vid_dev_cap documentation about
5025 * the type of value to be supplied for each setting.
5026 *
5027 * @return PJ_SUCCESS on success or the appropriate error code.
5028 */
5029PJ_DECL(pj_status_t) pjsua_vid_get_setting(pjmedia_vid_dev_cap cap,
5030 void *pval);
5031
5032
5033/*****************************************************************************
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005034 * Codecs.
5035 */
5036
5037/**
5038 * Enum all supported codecs in the system.
5039 *
5040 * @param id Array of ID to be initialized.
5041 * @param count On input, specifies max elements in the array.
5042 * On return, it contains actual number of elements
5043 * that have been initialized.
5044 *
5045 * @return PJ_SUCCESS on success, or the appropriate error code.
5046 */
5047PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
5048 unsigned *count );
5049
5050
5051/**
5052 * Change codec priority.
5053 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00005054 * @param codec_id Codec ID, which is a string that uniquely identify
5055 * the codec (such as "speex/8000"). Please see pjsua
5056 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005057 * @param priority Codec priority, 0-255, where zero means to disable
5058 * the codec.
5059 *
5060 * @return PJ_SUCCESS on success, or the appropriate error code.
5061 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00005062PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005063 pj_uint8_t priority );
5064
5065
5066/**
5067 * Get codec parameters.
5068 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00005069 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005070 * @param param Structure to receive codec parameters.
5071 *
5072 * @return PJ_SUCCESS on success, or the appropriate error code.
5073 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00005074PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005075 pjmedia_codec_param *param );
5076
5077
5078/**
5079 * Set codec parameters.
5080 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00005081 * @param codec_id Codec ID.
Nanang Izzuddin06839e72010-01-27 11:48:31 +00005082 * @param param Codec parameter to set. Set to NULL to reset
5083 * codec parameter to library default settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005084 *
5085 * @return PJ_SUCCESS on success, or the appropriate error code.
5086 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00005087PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005088 const pjmedia_codec_param *param);
5089
Nanang Izzuddin50fae732011-03-22 09:49:23 +00005090/*****************************************************************************
5091 * Video codecs.
5092 */
5093
5094/**
5095 * Enum all supported video codecs in the system.
5096 *
5097 * @param id Array of ID to be initialized.
5098 * @param count On input, specifies max elements in the array.
5099 * On return, it contains actual number of elements
5100 * that have been initialized.
5101 *
5102 * @return PJ_SUCCESS on success, or the appropriate error code.
5103 */
5104PJ_DECL(pj_status_t) pjsua_vid_enum_codecs( pjsua_codec_info id[],
5105 unsigned *count );
5106
5107
5108/**
5109 * Change video codec priority.
5110 *
5111 * @param codec_id Codec ID, which is a string that uniquely identify
5112 * the codec (such as "H263/90000"). Please see pjsua
5113 * manual or pjmedia codec reference for details.
5114 * @param priority Codec priority, 0-255, where zero means to disable
5115 * the codec.
5116 *
5117 * @return PJ_SUCCESS on success, or the appropriate error code.
5118 */
5119PJ_DECL(pj_status_t) pjsua_vid_codec_set_priority( const pj_str_t *codec_id,
5120 pj_uint8_t priority );
5121
5122
5123/**
5124 * Get video codec parameters.
5125 *
5126 * @param codec_id Codec ID.
5127 * @param param Structure to receive video codec parameters.
5128 *
5129 * @return PJ_SUCCESS on success, or the appropriate error code.
5130 */
5131PJ_DECL(pj_status_t) pjsua_vid_codec_get_param(
5132 const pj_str_t *codec_id,
5133 pjmedia_vid_codec_param *param);
5134
5135
5136/**
5137 * Set video codec parameters.
5138 *
5139 * @param codec_id Codec ID.
5140 * @param param Codec parameter to set. Set to NULL to reset
5141 * codec parameter to library default settings.
5142 *
5143 * @return PJ_SUCCESS on success, or the appropriate error code.
5144 */
5145PJ_DECL(pj_status_t) pjsua_vid_codec_set_param(
5146 const pj_str_t *codec_id,
5147 const pjmedia_vid_codec_param *param);
5148
5149
Benny Prijono0bc99a92011-03-17 04:34:43 +00005150#if DISABLED_FOR_TICKET_1185
Benny Prijono312aff92006-06-17 04:08:30 +00005151/**
5152 * Create UDP media transports for all the calls. This function creates
5153 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00005154 *
Benny Prijono312aff92006-06-17 04:08:30 +00005155 * @param cfg Media transport configuration. The "port" field in the
5156 * configuration is used as the start port to bind the
5157 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005158 *
5159 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonof3195072006-02-14 21:15:30 +00005160 */
Benny Prijono312aff92006-06-17 04:08:30 +00005161PJ_DECL(pj_status_t)
5162pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00005163
Benny Prijonodc39fe82006-05-26 12:17:46 +00005164
5165/**
Benny Prijono312aff92006-06-17 04:08:30 +00005166 * Register custom media transports to be used by calls. There must
5167 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005168 *
Benny Prijono312aff92006-06-17 04:08:30 +00005169 * @param tp The media transport array.
5170 * @param count Number of elements in the array. This number MUST
5171 * match the number of maximum calls configured when
5172 * pjsua is created.
5173 * @param auto_delete Flag to indicate whether the transports should be
5174 * destroyed when pjsua is shutdown.
5175 *
5176 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00005177 */
Benny Prijono312aff92006-06-17 04:08:30 +00005178PJ_DECL(pj_status_t)
5179pjsua_media_transports_attach( pjsua_media_transport tp[],
5180 unsigned count,
5181 pj_bool_t auto_delete);
Benny Prijono0bc99a92011-03-17 04:34:43 +00005182#endif
Benny Prijonodc39fe82006-05-26 12:17:46 +00005183
5184
Benny Prijono312aff92006-06-17 04:08:30 +00005185/**
5186 * @}
5187 */
5188
Benny Prijonof3195072006-02-14 21:15:30 +00005189
Benny Prijono268ca612006-02-07 12:34:11 +00005190
Benny Prijono312aff92006-06-17 04:08:30 +00005191/**
5192 * @}
5193 */
5194
Benny Prijonoe6ead542007-01-31 20:53:31 +00005195PJ_END_DECL
5196
Benny Prijono312aff92006-06-17 04:08:30 +00005197
Benny Prijono268ca612006-02-07 12:34:11 +00005198#endif /* __PJSUA_H__ */