blob: 13e0833caa4a9dfe3a1b0e1481dde176ac2195f0 [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
3055 /** Call media status. */
3056 pjsua_call_media_status media_status;
3057
Benny Prijono0bc99a92011-03-17 04:34:43 +00003058 /** Number of active audio streams in this call */
3059 unsigned audio_cnt;
3060
3061 /** Media direction of the first audio stream. */
Benny Prijono312aff92006-06-17 04:08:30 +00003062 pjmedia_dir media_dir;
3063
Benny Prijono0bc99a92011-03-17 04:34:43 +00003064 /** The conference port number for the first audio stream. */
Benny Prijono312aff92006-06-17 04:08:30 +00003065 pjsua_conf_port_id conf_slot;
3066
Benny Prijono0bc99a92011-03-17 04:34:43 +00003067 /** Array of audio media stream information */
3068 struct
3069 {
3070 /** Media index in SDP. */
3071 unsigned index;
3072
3073 /** Call media status. */
3074 pjsua_call_media_status media_status;
3075
3076 /** Media direction. */
3077 pjmedia_dir media_dir;
3078
3079 /** The conference port number for the call. */
3080 pjsua_conf_port_id conf_slot;
3081
3082 } audio[4];
3083
Benny Prijono312aff92006-06-17 04:08:30 +00003084 /** Up-to-date call connected duration (zero when call is not
3085 * established)
3086 */
3087 pj_time_val connect_duration;
3088
3089 /** Total call duration, including set-up time */
3090 pj_time_val total_duration;
3091
3092 /** Internal */
3093 struct {
3094 char local_info[128];
3095 char local_contact[128];
3096 char remote_info[128];
3097 char remote_contact[128];
3098 char call_id[128];
3099 char last_status_text[128];
3100 } buf_;
3101
3102} pjsua_call_info;
3103
3104
3105
Benny Prijonoa91a0032006-02-26 21:23:45 +00003106/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00003107 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003108 *
3109 * @return Maximum number of calls configured.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003110 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003111PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003112
3113/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003114 * Get number of currently active calls.
3115 *
3116 * @return Number of currently active calls.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003117 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003118PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003119
3120/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003121 * Enumerate all active calls. Application may then query the information and
3122 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003123 *
3124 * @param ids Array of account IDs to be initialized.
3125 * @param count In input, specifies the maximum number of elements.
3126 * On return, it contains the actual number of elements.
3127 *
3128 * @return PJ_SUCCESS on success, or the appropriate error code.
3129 */
3130PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
3131 unsigned *count);
3132
3133
3134/**
3135 * Make outgoing call to the specified URI using the specified account.
3136 *
3137 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003138 * @param dst_uri URI to be put in the To header (normally is the same
3139 * as the target URI).
3140 * @param options Options (must be zero at the moment).
3141 * @param user_data Arbitrary user data to be attached to the call, and
3142 * can be retrieved later.
3143 * @param msg_data Optional headers etc to be added to outgoing INVITE
3144 * request, or NULL if no custom header is desired.
3145 * @param p_call_id Pointer to receive call identification.
3146 *
3147 * @return PJ_SUCCESS on success, or the appropriate error code.
3148 */
3149PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
3150 const pj_str_t *dst_uri,
3151 unsigned options,
3152 void *user_data,
3153 const pjsua_msg_data *msg_data,
3154 pjsua_call_id *p_call_id);
3155
3156
3157/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00003158 * Check if the specified call has active INVITE session and the INVITE
3159 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003160 *
3161 * @param call_id Call identification.
3162 *
3163 * @return Non-zero if call is active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003164 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003165PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003166
3167
3168/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003169 * Check if call has an active media session.
3170 *
3171 * @param call_id Call identification.
3172 *
3173 * @return Non-zero if yes.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003174 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003175PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003176
3177
Benny Prijono0bc99a92011-03-17 04:34:43 +00003178#if DISABLED_FOR_TICKET_1185
Benny Prijono9fc735d2006-05-28 14:58:12 +00003179/**
Benny Prijonocf986c42008-09-02 11:25:07 +00003180 * Retrieve the media session associated with this call. Note that the media
3181 * session may not be available depending on the current call's media status
3182 * (the pjsua_call_media_status information in pjsua_call_info). Application
3183 * may use the media session to retrieve more detailed information about the
3184 * call's media.
3185 *
3186 * @param call_id Call identification.
3187 *
3188 * @return Call media session.
3189 */
3190PJ_DECL(pjmedia_session*) pjsua_call_get_media_session(pjsua_call_id call_id);
3191
Benny Prijonocf986c42008-09-02 11:25:07 +00003192/**
3193 * Retrieve the media transport instance that is used for this call.
3194 * Application may use the media transport to query more detailed information
3195 * about the media transport.
3196 *
3197 * @param cid Call identification (the call_id).
3198 *
3199 * @return Call media transport.
3200 */
3201PJ_DECL(pjmedia_transport*) pjsua_call_get_media_transport(pjsua_call_id cid);
Benny Prijono0bc99a92011-03-17 04:34:43 +00003202#endif /* DISABLED_FOR_TICKET_1185 */
Benny Prijonocf986c42008-09-02 11:25:07 +00003203
3204/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003205 * Get the conference port identification associated with the call.
3206 *
3207 * @param call_id Call identification.
3208 *
3209 * @return Conference port ID, or PJSUA_INVALID_ID when the
3210 * media has not been established or is not active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003211 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003212PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
3213
3214/**
3215 * Obtain detail information about the specified call.
3216 *
3217 * @param call_id Call identification.
3218 * @param info Call info to be initialized.
3219 *
3220 * @return PJ_SUCCESS on success, or the appropriate error code.
3221 */
3222PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003223 pjsua_call_info *info);
3224
Nanang Izzuddin2a1b9ee2010-06-03 10:41:32 +00003225/**
3226 * Check if remote peer support the specified capability.
3227 *
3228 * @param call_id Call identification.
3229 * @param htype The header type to be checked, which value may be:
3230 * - PJSIP_H_ACCEPT
3231 * - PJSIP_H_ALLOW
3232 * - PJSIP_H_SUPPORTED
3233 * @param hname If htype specifies PJSIP_H_OTHER, then the header
3234 * name must be supplied in this argument. Otherwise the
3235 * value must be set to NULL.
3236 * @param token The capability token to check. For example, if \a
3237 * htype is PJSIP_H_ALLOW, then \a token specifies the
3238 * method names; if \a htype is PJSIP_H_SUPPORTED, then
3239 * \a token specifies the extension names such as
3240 * "100rel".
3241 *
3242 * @return PJSIP_DIALOG_CAP_SUPPORTED if the specified capability
3243 * is explicitly supported, see @pjsip_dialog_cap_status
3244 * for more info.
3245 */
3246PJ_DECL(pjsip_dialog_cap_status) pjsua_call_remote_has_cap(
3247 pjsua_call_id call_id,
3248 int htype,
3249 const pj_str_t *hname,
3250 const pj_str_t *token);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003251
3252/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003253 * Attach application specific data to the call. Application can then
3254 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003255 *
3256 * @param call_id Call identification.
3257 * @param user_data Arbitrary data to be attached to the call.
3258 *
3259 * @return The user data.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003260 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003261PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
3262 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003263
3264
3265/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003266 * Get user data attached to the call, which has been previously set with
3267 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003268 *
3269 * @param call_id Call identification.
3270 *
3271 * @return The user data.
Benny Prijono268ca612006-02-07 12:34:11 +00003272 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003273PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00003274
3275
3276/**
Benny Prijono91a6a172007-10-31 08:59:29 +00003277 * Get the NAT type of remote's endpoint. This is a proprietary feature
3278 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
3279 * is set in #pjsua_config.
3280 *
3281 * This function can only be called after SDP has been received from remote,
3282 * which means for incoming call, this function can be called as soon as
3283 * call is received as long as incoming call contains SDP, and for outgoing
3284 * call, this function can be called only after SDP is received (normally in
3285 * 200/OK response to INVITE). As a general case, application should call
3286 * this function after or in \a on_call_media_state() callback.
3287 *
3288 * @param call_id Call identification.
3289 * @param p_type Pointer to store the NAT type. Application can then
3290 * retrieve the string description of the NAT type
3291 * by calling pj_stun_get_nat_name().
3292 *
3293 * @return PJ_SUCCESS on success.
3294 *
3295 * @see pjsua_get_nat_type(), nat_type_in_sdp
3296 */
3297PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
3298 pj_stun_nat_type *p_type);
3299
3300/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003301 * Send response to incoming INVITE request. Depending on the status
3302 * code specified as parameter, this function may send provisional
3303 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003304 *
3305 * @param call_id Incoming call identification.
3306 * @param code Status code, (100-699).
3307 * @param reason Optional reason phrase. If NULL, default text
3308 * will be used.
3309 * @param msg_data Optional list of headers etc to be added to outgoing
3310 * response message.
3311 *
3312 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoa91a0032006-02-26 21:23:45 +00003313 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003314PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
3315 unsigned code,
3316 const pj_str_t *reason,
3317 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00003318
3319/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003320 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00003321 * call state. This function is different than answering the call with
3322 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
3323 * will hangup the call regardless of the state and role of the call,
3324 * while #pjsua_call_answer() only works with incoming calls on EARLY
3325 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003326 *
3327 * @param call_id Call identification.
3328 * @param code Optional status code to be sent when we're rejecting
3329 * incoming call. If the value is zero, "603/Decline"
3330 * will be sent.
3331 * @param reason Optional reason phrase to be sent when we're rejecting
3332 * incoming call. If NULL, default text will be used.
3333 * @param msg_data Optional list of headers etc to be added to outgoing
3334 * request/response message.
3335 *
3336 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003337 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003338PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
3339 unsigned code,
3340 const pj_str_t *reason,
3341 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003342
Benny Prijono5e51a4e2008-11-27 00:06:46 +00003343/**
3344 * Accept or reject redirection response. Application MUST call this function
3345 * after it signaled PJSIP_REDIRECT_PENDING in the \a on_call_redirected()
3346 * callback, to notify the call whether to accept or reject the redirection
3347 * to the current target. Application can use the combination of
3348 * PJSIP_REDIRECT_PENDING command in \a on_call_redirected() callback and
3349 * this function to ask for user permission before redirecting the call.
3350 *
3351 * Note that if the application chooses to reject or stop redirection (by
3352 * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the
3353 * call disconnection callback will be called before this function returns.
3354 * And if the application rejects the target, the \a on_call_redirected()
3355 * callback may also be called before this function returns if there is
3356 * another target to try.
3357 *
3358 * @param call_id The call ID.
3359 * @param cmd Redirection operation to be applied to the current
3360 * target. The semantic of this argument is similar
3361 * to the description in the \a on_call_redirected()
3362 * callback, except that the PJSIP_REDIRECT_PENDING is
3363 * not accepted here.
3364 *
3365 * @return PJ_SUCCESS on successful operation.
3366 */
3367PJ_DECL(pj_status_t) pjsua_call_process_redirect(pjsua_call_id call_id,
3368 pjsip_redirect_op cmd);
Benny Prijono26ff9062006-02-21 23:47:00 +00003369
3370/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003371 * Put the specified call on hold. This will send re-INVITE with the
3372 * appropriate SDP to inform remote that the call is being put on hold.
3373 * The final status of the request itself will be reported on the
3374 * \a on_call_media_state() callback, which inform the application that
3375 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003376 *
3377 * @param call_id Call identification.
3378 * @param msg_data Optional message components to be sent with
3379 * the request.
3380 *
3381 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003382 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003383PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
3384 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003385
3386
3387/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003388 * Send re-INVITE to release hold.
3389 * The final status of the request itself will be reported on the
3390 * \a on_call_media_state() callback, which inform the application that
3391 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003392 *
3393 * @param call_id Call identification.
3394 * @param unhold If this argument is non-zero and the call is locally
3395 * held, this will release the local hold.
3396 * @param msg_data Optional message components to be sent with
3397 * the request.
3398 *
3399 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003400 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003401PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
3402 pj_bool_t unhold,
3403 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003404
Benny Prijonoc08682e2007-10-04 06:17:58 +00003405/**
3406 * Send UPDATE request.
3407 *
3408 * @param call_id Call identification.
3409 * @param options Must be zero for now.
3410 * @param msg_data Optional message components to be sent with
3411 * the request.
3412 *
3413 * @return PJ_SUCCESS on success, or the appropriate error code.
3414 */
3415PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
3416 unsigned options,
3417 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003418
3419/**
Benny Prijono053f5222006-11-11 16:16:04 +00003420 * Initiate call transfer to the specified address. This function will send
3421 * REFER request to instruct remote call party to initiate a new INVITE
3422 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003423 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00003424 * If application is interested to monitor the successfulness and
3425 * the progress of the transfer request, it can implement
3426 * \a on_call_transfer_status() callback which will report the progress
3427 * of the call transfer request.
3428 *
Benny Prijono053f5222006-11-11 16:16:04 +00003429 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003430 * @param dest Address of new target to be contacted.
3431 * @param msg_data Optional message components to be sent with
3432 * the request.
3433 *
3434 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003435 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003436PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
3437 const pj_str_t *dest,
3438 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003439
3440/**
Benny Prijono053f5222006-11-11 16:16:04 +00003441 * Flag to indicate that "Require: replaces" should not be put in the
3442 * outgoing INVITE request caused by REFER request created by
3443 * #pjsua_call_xfer_replaces().
3444 */
3445#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
3446
3447/**
3448 * Initiate attended call transfer. This function will send REFER request
3449 * to instruct remote call party to initiate new INVITE session to the URL
3450 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
3451 * the call with us with the new call from the REFER recipient.
3452 *
3453 * @param call_id The call id to be transfered.
3454 * @param dest_call_id The call id to be replaced.
3455 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
3456 * to suppress the inclusion of "Require: replaces" in
3457 * the outgoing INVITE request created by the REFER
3458 * request.
3459 * @param msg_data Optional message components to be sent with
3460 * the request.
3461 *
3462 * @return PJ_SUCCESS on success, or the appropriate error code.
3463 */
3464PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
3465 pjsua_call_id dest_call_id,
3466 unsigned options,
3467 const pjsua_msg_data *msg_data);
3468
3469/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003470 * Send DTMF digits to remote using RFC 2833 payload formats.
3471 *
3472 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003473 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003474 *
3475 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003476 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003477PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003478 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00003479
Benny Prijono26ff9062006-02-21 23:47:00 +00003480/**
Benny Prijonob0808372006-03-02 21:18:58 +00003481 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003482 *
3483 * @param call_id Call identification.
3484 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3485 * assumed.
3486 * @param content The message content.
3487 * @param msg_data Optional list of headers etc to be included in outgoing
3488 * request. The body descriptor in the msg_data is
3489 * ignored.
3490 * @param user_data Optional user data, which will be given back when
3491 * the IM callback is called.
3492 *
3493 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003494 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003495PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
3496 const pj_str_t *mime_type,
3497 const pj_str_t *content,
3498 const pjsua_msg_data *msg_data,
3499 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003500
3501
3502/**
3503 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003504 *
3505 * @param call_id Call identification.
3506 * @param is_typing Non-zero to indicate to remote that local person is
3507 * currently typing an IM.
3508 * @param msg_data Optional list of headers etc to be included in outgoing
3509 * request.
3510 *
3511 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003512 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003513PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
3514 pj_bool_t is_typing,
3515 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003516
3517/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00003518 * Send arbitrary request with the call. This is useful for example to send
3519 * INFO request. Note that application should not use this function to send
3520 * requests which would change the invite session's state, such as re-INVITE,
3521 * UPDATE, PRACK, and BYE.
3522 *
3523 * @param call_id Call identification.
3524 * @param method SIP method of the request.
3525 * @param msg_data Optional message body and/or list of headers to be
3526 * included in outgoing request.
3527 *
3528 * @return PJ_SUCCESS on success, or the appropriate error code.
3529 */
3530PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
3531 const pj_str_t *method,
3532 const pjsua_msg_data *msg_data);
3533
3534
3535/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003536 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
3537 * currently active calls.
Benny Prijono834aee32006-02-19 01:38:06 +00003538 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00003539PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00003540
3541
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003542/**
3543 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003544 *
3545 * @param call_id Call identification.
3546 * @param with_media Non-zero to include media information too.
3547 * @param buffer Buffer where the statistics are to be written to.
3548 * @param maxlen Maximum length of buffer.
3549 * @param indent Spaces for left indentation.
3550 *
3551 * @return PJ_SUCCESS on success.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003552 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003553PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
3554 pj_bool_t with_media,
3555 char *buffer,
3556 unsigned maxlen,
3557 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003558
Benny Prijono9fc735d2006-05-28 14:58:12 +00003559/**
Benny Prijono312aff92006-06-17 04:08:30 +00003560 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003561 */
Benny Prijono834aee32006-02-19 01:38:06 +00003562
3563
3564/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00003565 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00003566 */
3567
Benny Prijono312aff92006-06-17 04:08:30 +00003568
3569/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003570 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00003571 * @ingroup PJSUA_LIB
3572 * @brief Buddy management, buddy's presence, and instant messaging.
3573 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00003574 *
3575 * This section describes PJSUA-APIs related to buddies management,
3576 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00003577 */
3578
3579/**
3580 * Max buddies in buddy list.
3581 */
3582#ifndef PJSUA_MAX_BUDDIES
3583# define PJSUA_MAX_BUDDIES 256
3584#endif
3585
3586
3587/**
Benny Prijono6ab05322009-10-21 03:03:06 +00003588 * This specifies how long the library should wait before retrying failed
3589 * SUBSCRIBE request, and there is no rule to automatically resubscribe
3590 * (for example, no "retry-after" parameter in Subscription-State header).
3591 *
3592 * This also controls the duration before failed PUBLISH request will be
3593 * retried.
Benny Prijonoa17496a2007-10-31 10:20:31 +00003594 *
3595 * Default: 300 seconds
3596 */
3597#ifndef PJSUA_PRES_TIMER
3598# define PJSUA_PRES_TIMER 300
3599#endif
3600
3601
3602/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003603 * This structure describes buddy configuration when adding a buddy to
3604 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
3605 * the structure with #pjsua_buddy_config_default() to initialize this
3606 * structure with default configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00003607 */
3608typedef struct pjsua_buddy_config
3609{
3610 /**
3611 * Buddy URL or name address.
3612 */
3613 pj_str_t uri;
3614
3615 /**
3616 * Specify whether presence subscription should start immediately.
3617 */
3618 pj_bool_t subscribe;
3619
Benny Prijono705e7842008-07-21 18:12:51 +00003620 /**
3621 * Specify arbitrary application data to be associated with with
3622 * the buddy object.
3623 */
3624 void *user_data;
3625
Benny Prijono312aff92006-06-17 04:08:30 +00003626} pjsua_buddy_config;
3627
3628
3629/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003630 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003631 */
3632typedef enum pjsua_buddy_status
3633{
3634 /**
3635 * Online status is unknown (possibly because no presence subscription
3636 * has been established).
3637 */
3638 PJSUA_BUDDY_STATUS_UNKNOWN,
3639
3640 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003641 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003642 */
3643 PJSUA_BUDDY_STATUS_ONLINE,
3644
3645 /**
3646 * Buddy is offline.
3647 */
3648 PJSUA_BUDDY_STATUS_OFFLINE,
3649
3650} pjsua_buddy_status;
3651
3652
3653
3654/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003655 * This structure describes buddy info, which can be retrieved by calling
3656 * #pjsua_buddy_get_info().
Benny Prijono312aff92006-06-17 04:08:30 +00003657 */
3658typedef struct pjsua_buddy_info
3659{
3660 /**
3661 * The buddy ID.
3662 */
3663 pjsua_buddy_id id;
3664
3665 /**
3666 * The full URI of the buddy, as specified in the configuration.
3667 */
3668 pj_str_t uri;
3669
3670 /**
3671 * Buddy's Contact, only available when presence subscription has
3672 * been established to the buddy.
3673 */
3674 pj_str_t contact;
3675
3676 /**
3677 * Buddy's online status.
3678 */
3679 pjsua_buddy_status status;
3680
3681 /**
3682 * Text to describe buddy's online status.
3683 */
3684 pj_str_t status_text;
3685
3686 /**
3687 * Flag to indicate that we should monitor the presence information for
3688 * this buddy (normally yes, unless explicitly disabled).
3689 */
3690 pj_bool_t monitor_pres;
3691
3692 /**
Benny Prijono63fba012008-07-17 14:19:10 +00003693 * If \a monitor_pres is enabled, this specifies the last state of the
3694 * presence subscription. If presence subscription session is currently
3695 * active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence
3696 * subscription request has been rejected, the value will be
3697 * PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be
3698 * specified in \a sub_term_reason.
3699 */
3700 pjsip_evsub_state sub_state;
3701
3702 /**
Benny Prijonod06d8c52009-06-30 13:53:47 +00003703 * String representation of subscription state.
3704 */
3705 const char *sub_state_name;
3706
3707 /**
Benny Prijono73bb7232009-10-20 13:56:26 +00003708 * Specifies the last presence subscription termination code. This would
3709 * return the last status of the SUBSCRIBE request. If the subscription
3710 * is terminated with NOTIFY by the server, this value will be set to
3711 * 200, and subscription termination reason will be given in the
3712 * \a sub_term_reason field.
3713 */
3714 unsigned sub_term_code;
3715
3716 /**
3717 * Specifies the last presence subscription termination reason. If
Benny Prijono63fba012008-07-17 14:19:10 +00003718 * presence subscription is currently active, the value will be empty.
3719 */
3720 pj_str_t sub_term_reason;
3721
3722 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003723 * Extended RPID information about the person.
3724 */
3725 pjrpid_element rpid;
3726
3727 /**
Benny Prijono28add7e2009-06-15 16:03:40 +00003728 * Extended presence info.
3729 */
3730 pjsip_pres_status pres_status;
3731
3732 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003733 * Internal buffer.
3734 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003735 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003736
3737} pjsua_buddy_info;
3738
3739
Benny Prijono834aee32006-02-19 01:38:06 +00003740/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003741 * Set default values to the buddy config.
3742 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003743PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003744
3745
3746/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003747 * Get total number of buddies.
3748 *
3749 * @return Number of buddies.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003750 */
3751PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3752
3753
3754/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003755 * Check if buddy ID is valid.
3756 *
3757 * @param buddy_id Buddy ID to check.
3758 *
3759 * @return Non-zero if buddy ID is valid.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003760 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003761PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3762
3763
3764/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003765 * Enumerate all buddy IDs in the buddy list. Application then can use
3766 * #pjsua_buddy_get_info() to get the detail information for each buddy
3767 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003768 *
3769 * @param ids Array of ids to be initialized.
3770 * @param count On input, specifies max elements in the array.
3771 * On return, it contains actual number of elements
3772 * that have been initialized.
3773 *
3774 * @return PJ_SUCCESS on success, or the appropriate error code.
3775 */
3776PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3777 unsigned *count);
3778
3779/**
Benny Prijono705e7842008-07-21 18:12:51 +00003780 * Find the buddy ID with the specified URI.
3781 *
3782 * @param uri The buddy URI.
3783 *
3784 * @return The buddy ID, or PJSUA_INVALID_ID if not found.
3785 */
3786PJ_DECL(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri);
3787
3788
3789/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003790 * Get detailed buddy info.
3791 *
3792 * @param buddy_id The buddy identification.
3793 * @param info Pointer to receive information about buddy.
3794 *
3795 * @return PJ_SUCCESS on success, or the appropriate error code.
3796 */
3797PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003798 pjsua_buddy_info *info);
3799
3800/**
Benny Prijono705e7842008-07-21 18:12:51 +00003801 * Set the user data associated with the buddy object.
3802 *
3803 * @param buddy_id The buddy identification.
3804 * @param user_data Arbitrary application data to be associated with
3805 * the buddy object.
3806 *
3807 * @return PJ_SUCCESS on success, or the appropriate error code.
3808 */
3809PJ_DECL(pj_status_t) pjsua_buddy_set_user_data(pjsua_buddy_id buddy_id,
3810 void *user_data);
3811
3812
3813/**
3814 * Get the user data associated with the budy object.
3815 *
3816 * @param buddy_id The buddy identification.
3817 *
3818 * @return The application data.
3819 */
3820PJ_DECL(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id);
3821
3822
3823/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003824 * Add new buddy to the buddy list. If presence subscription is enabled
3825 * for this buddy, this function will also start the presence subscription
3826 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003827 *
Benny Prijonoa7b376b2008-01-25 16:06:33 +00003828 * @param buddy_cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003829 * @param p_buddy_id Pointer to receive buddy ID.
3830 *
3831 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003832 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003833PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003834 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003835
3836
3837/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003838 * Delete the specified buddy from the buddy list. Any presence subscription
3839 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003840 *
3841 * @param buddy_id Buddy identification.
3842 *
3843 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00003844 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003845PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003846
3847
3848/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003849 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3850 * subscribed, application will be informed about buddy's presence status
3851 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003852 *
3853 * @param buddy_id Buddy identification.
3854 * @param subscribe Specify non-zero to activate presence subscription to
3855 * the specified buddy.
3856 *
3857 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003858 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003859PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3860 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003861
3862
3863/**
Benny Prijono10861432007-10-31 10:54:53 +00003864 * Update the presence information for the buddy. Although the library
3865 * periodically refreshes the presence subscription for all buddies, some
3866 * application may want to refresh the buddy's presence subscription
3867 * immediately, and in this case it can use this function to accomplish
3868 * this.
3869 *
3870 * Note that the buddy's presence subscription will only be initiated
3871 * if presence monitoring is enabled for the buddy. See
3872 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
3873 * for the buddy is already active, this function will not do anything.
3874 *
3875 * Once the presence subscription is activated successfully for the buddy,
3876 * application will be notified about the buddy's presence status in the
3877 * on_buddy_state() callback.
3878 *
3879 * @param buddy_id Buddy identification.
3880 *
3881 * @return PJ_SUCCESS on success, or the appropriate error code.
3882 */
3883PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
3884
3885
3886/**
Benny Prijono63fba012008-07-17 14:19:10 +00003887 * Send NOTIFY to inform account presence status or to terminate server
3888 * side presence subscription. If application wants to reject the incoming
3889 * request, it should set the \a state to PJSIP_EVSUB_STATE_TERMINATED.
3890 *
3891 * @param acc_id Account ID.
3892 * @param srv_pres Server presence subscription instance.
3893 * @param state New state to set.
3894 * @param state_str Optionally specify the state string name, if state
3895 * is not "active", "pending", or "terminated".
3896 * @param reason If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3897 * optionally specify the termination reason.
3898 * @param with_body If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3899 * this specifies whether the NOTIFY request should
3900 * contain message body containing account's presence
3901 * information.
3902 * @param msg_data Optional list of headers to be sent with the NOTIFY
3903 * request.
3904 *
3905 * @return PJ_SUCCESS on success.
3906 */
3907PJ_DECL(pj_status_t) pjsua_pres_notify(pjsua_acc_id acc_id,
3908 pjsua_srv_pres *srv_pres,
3909 pjsip_evsub_state state,
3910 const pj_str_t *state_str,
3911 const pj_str_t *reason,
3912 pj_bool_t with_body,
3913 const pjsua_msg_data *msg_data);
3914
3915/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003916 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003917 *
3918 * @param verbose Yes or no.
Benny Prijono834aee32006-02-19 01:38:06 +00003919 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003920PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003921
3922
Benny Prijonob0808372006-03-02 21:18:58 +00003923/**
3924 * The MESSAGE method (defined in pjsua_im.c)
3925 */
3926extern const pjsip_method pjsip_message_method;
3927
3928
Benny Prijonob0808372006-03-02 21:18:58 +00003929
3930/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003931 * Send instant messaging outside dialog, using the specified account for
3932 * route set and authentication.
3933 *
3934 * @param acc_id Account ID to be used to send the request.
3935 * @param to Remote URI.
3936 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3937 * assumed.
3938 * @param content The message content.
3939 * @param msg_data Optional list of headers etc to be included in outgoing
3940 * request. The body descriptor in the msg_data is
3941 * ignored.
3942 * @param user_data Optional user data, which will be given back when
3943 * the IM callback is called.
3944 *
3945 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003946 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003947PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3948 const pj_str_t *to,
3949 const pj_str_t *mime_type,
3950 const pj_str_t *content,
3951 const pjsua_msg_data *msg_data,
3952 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003953
3954
3955/**
3956 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003957 *
3958 * @param acc_id Account ID to be used to send the request.
3959 * @param to Remote URI.
3960 * @param is_typing If non-zero, it tells remote person that local person
3961 * is currently composing an IM.
3962 * @param msg_data Optional list of headers etc to be added to outgoing
3963 * request.
3964 *
3965 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003966 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003967PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3968 const pj_str_t *to,
3969 pj_bool_t is_typing,
3970 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003971
3972
Benny Prijonof3195072006-02-14 21:15:30 +00003973
Benny Prijono312aff92006-06-17 04:08:30 +00003974/**
3975 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003976 */
3977
Benny Prijono312aff92006-06-17 04:08:30 +00003978
3979/*****************************************************************************
3980 * MEDIA API
3981 */
3982
3983
3984/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003985 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003986 * @ingroup PJSUA_LIB
3987 * @brief Media manipulation.
3988 * @{
3989 *
3990 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003991 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3992 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003993 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003994 * the interconnection between these terminations freely.
3995 *
3996 * The conference bridge provides powerful switching and mixing functionality
3997 * for application. With the conference bridge, each conference slot (e.g.
3998 * a call) can transmit to multiple destinations, and one destination can
3999 * receive from multiple sources. If more than one media terminations are
4000 * terminated in the same slot, the conference bridge will mix the signal
4001 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00004002 *
4003 * Application connects one media termination/slot to another by calling
4004 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00004005 * media flow from the source termination to the sink termination. To
4006 * establish bidirectional media flow, application wound need to make another
4007 * call to #pjsua_conf_connect(), this time inverting the source and
4008 * destination slots in the parameter.
4009 *
4010 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00004011 * the following steps:
4012 *
4013 \code
4014
4015 pj_status_t stream_to_call( pjsua_call_id call_id )
4016 {
4017 pjsua_player_id player_id;
4018
4019 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
4020 if (status != PJ_SUCCESS)
4021 return status;
4022
4023 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
4024 pjsua_call_get_conf_port() );
4025 }
4026 \endcode
4027 *
4028 *
4029 * Other features of PJSUA media:
4030 * - efficient N to M interconnections between media terminations.
4031 * - media termination can be connected to itself to create loopback
4032 * media.
4033 * - the media termination may have different clock rates, and resampling
4034 * will be done automatically by conference bridge.
4035 * - media terminations may also have different frame time; the
4036 * conference bridge will perform the necessary bufferring to adjust
4037 * the difference between terminations.
4038 * - interconnections are removed automatically when media termination
4039 * is removed from the bridge.
4040 * - sound device may be changed even when there are active media
4041 * interconnections.
4042 * - correctly report call's media quality (in #pjsua_call_dump()) from
4043 * RTCP packet exchange.
4044 */
4045
4046/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004047 * Max ports in the conference bridge. This setting is the default value
4048 * for pjsua_media_config.max_media_ports.
Benny Prijono312aff92006-06-17 04:08:30 +00004049 */
4050#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00004051# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00004052#endif
4053
Benny Prijonob5388cf2007-01-04 22:45:08 +00004054/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004055 * The default clock rate to be used by the conference bridge. This setting
4056 * is the default value for pjsua_media_config.clock_rate.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004057 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004058#ifndef PJSUA_DEFAULT_CLOCK_RATE
4059# define PJSUA_DEFAULT_CLOCK_RATE 16000
4060#endif
4061
Benny Prijonob5388cf2007-01-04 22:45:08 +00004062/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004063 * Default frame length in the conference bridge. This setting
4064 * is the default value for pjsua_media_config.audio_frame_ptime.
4065 */
4066#ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Nanang Izzuddinaf974842008-05-08 09:51:16 +00004067# define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
Benny Prijono37c710b2008-01-10 12:09:26 +00004068#endif
4069
4070
4071/**
4072 * Default codec quality settings. This setting is the default value
4073 * for pjsua_media_config.quality.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004074 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004075#ifndef PJSUA_DEFAULT_CODEC_QUALITY
Nanang Izzuddin9dbad152008-06-10 18:56:10 +00004076# define PJSUA_DEFAULT_CODEC_QUALITY 8
Benny Prijono12a669c2006-11-23 07:32:13 +00004077#endif
4078
Benny Prijonob5388cf2007-01-04 22:45:08 +00004079/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004080 * Default iLBC mode. This setting is the default value for
4081 * pjsua_media_config.ilbc_mode.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004082 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004083#ifndef PJSUA_DEFAULT_ILBC_MODE
Benny Prijono37c710b2008-01-10 12:09:26 +00004084# define PJSUA_DEFAULT_ILBC_MODE 30
Benny Prijono12a669c2006-11-23 07:32:13 +00004085#endif
4086
Benny Prijonob5388cf2007-01-04 22:45:08 +00004087/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004088 * The default echo canceller tail length. This setting
4089 * is the default value for pjsua_media_config.ec_tail_len.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004090 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004091#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijono427439c2007-10-21 09:41:24 +00004092# define PJSUA_DEFAULT_EC_TAIL_LEN 200
Benny Prijono12a669c2006-11-23 07:32:13 +00004093#endif
Benny Prijono312aff92006-06-17 04:08:30 +00004094
4095
4096/**
Benny Prijonocba59d92007-02-16 09:22:56 +00004097 * The maximum file player.
4098 */
4099#ifndef PJSUA_MAX_PLAYERS
4100# define PJSUA_MAX_PLAYERS 32
4101#endif
4102
4103
4104/**
4105 * The maximum file player.
4106 */
4107#ifndef PJSUA_MAX_RECORDERS
4108# define PJSUA_MAX_RECORDERS 32
4109#endif
4110
4111
4112/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004113 * This structure describes media configuration, which will be specified
4114 * when calling #pjsua_init(). Application MUST initialize this structure
4115 * by calling #pjsua_media_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00004116 */
4117struct pjsua_media_config
4118{
4119 /**
4120 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004121 * If value is zero, default clock rate will be used
4122 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00004123 */
4124 unsigned clock_rate;
4125
4126 /**
Benny Prijonof3758ee2008-02-26 15:32:16 +00004127 * Clock rate to be applied when opening the sound device.
4128 * If value is zero, conference bridge clock rate will be used.
4129 */
4130 unsigned snd_clock_rate;
4131
4132 /**
Benny Prijono7d60d052008-03-29 12:24:20 +00004133 * Channel count be applied when opening the sound device and
4134 * conference bridge.
4135 */
4136 unsigned channel_count;
4137
4138 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004139 * Specify audio frame ptime. The value here will affect the
4140 * samples per frame of both the sound device and the conference
4141 * bridge. Specifying lower ptime will normally reduce the
4142 * latency.
4143 *
Benny Prijono37c710b2008-01-10 12:09:26 +00004144 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004145 */
4146 unsigned audio_frame_ptime;
4147
4148 /**
Benny Prijono312aff92006-06-17 04:08:30 +00004149 * Specify maximum number of media ports to be created in the
4150 * conference bridge. Since all media terminate in the bridge
4151 * (calls, file player, file recorder, etc), the value must be
4152 * large enough to support all of them. However, the larger
4153 * the value, the more computations are performed.
Benny Prijono37c710b2008-01-10 12:09:26 +00004154 *
4155 * Default value: PJSUA_MAX_CONF_PORTS
Benny Prijono312aff92006-06-17 04:08:30 +00004156 */
4157 unsigned max_media_ports;
4158
4159 /**
4160 * Specify whether the media manager should manage its own
4161 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
4162 * and at least one worker thread will be created too. If no,
4163 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
4164 * and no worker thread is needed.
4165 *
4166 * Normally application would say yes here, unless it wants to
4167 * run everything from a single thread.
4168 */
4169 pj_bool_t has_ioqueue;
4170
4171 /**
4172 * Specify the number of worker threads to handle incoming RTP
4173 * packets. A value of one is recommended for most applications.
4174 */
4175 unsigned thread_cnt;
4176
Benny Prijono0498d902006-06-19 14:49:14 +00004177 /**
4178 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00004179 * 5-10: resampling use large filter,
4180 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00004181 * 1-2: resampling use linear.
4182 * The media quality also sets speex codec quality/complexity to the
4183 * number.
4184 *
Benny Prijono70972992006-08-05 11:13:58 +00004185 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00004186 */
4187 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00004188
4189 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004190 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00004191 *
4192 * Default: 0 (codec specific)
4193 */
4194 unsigned ptime;
4195
4196 /**
4197 * Disable VAD?
4198 *
4199 * Default: 0 (no (meaning VAD is enabled))
4200 */
4201 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00004202
4203 /**
4204 * iLBC mode (20 or 30).
4205 *
Benny Prijono37c710b2008-01-10 12:09:26 +00004206 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00004207 */
4208 unsigned ilbc_mode;
4209
4210 /**
4211 * Percentage of RTP packet to drop in TX direction
4212 * (to simulate packet lost).
4213 *
4214 * Default: 0
4215 */
4216 unsigned tx_drop_pct;
4217
4218 /**
4219 * Percentage of RTP packet to drop in RX direction
4220 * (to simulate packet lost).
4221 *
4222 * Default: 0
4223 */
4224 unsigned rx_drop_pct;
4225
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004226 /**
Benny Prijono5da50432006-08-07 10:24:52 +00004227 * Echo canceller options (see #pjmedia_echo_create())
4228 *
4229 * Default: 0.
4230 */
4231 unsigned ec_options;
4232
4233 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004234 * Echo canceller tail length, in miliseconds.
4235 *
Benny Prijono669643c2006-09-20 20:02:18 +00004236 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004237 */
4238 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004239
Benny Prijono10454dc2009-02-21 14:21:59 +00004240 /**
4241 * Audio capture buffer length, in milliseconds.
4242 *
4243 * Default: PJMEDIA_SND_DEFAULT_REC_LATENCY
4244 */
4245 unsigned snd_rec_latency;
4246
4247 /**
4248 * Audio playback buffer length, in milliseconds.
4249 *
4250 * Default: PJMEDIA_SND_DEFAULT_PLAY_LATENCY
4251 */
4252 unsigned snd_play_latency;
4253
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004254 /**
4255 * Jitter buffer initial prefetch delay in msec. The value must be
4256 * between jb_min_pre and jb_max_pre below.
4257 *
4258 * Default: -1 (to use default stream settings, currently 150 msec)
4259 */
4260 int jb_init;
4261
4262 /**
4263 * Jitter buffer minimum prefetch delay in msec.
4264 *
4265 * Default: -1 (to use default stream settings, currently 60 msec)
4266 */
4267 int jb_min_pre;
4268
4269 /**
4270 * Jitter buffer maximum prefetch delay in msec.
4271 *
4272 * Default: -1 (to use default stream settings, currently 240 msec)
4273 */
4274 int jb_max_pre;
4275
4276 /**
4277 * Set maximum delay that can be accomodated by the jitter buffer msec.
4278 *
4279 * Default: -1 (to use default stream settings, currently 360 msec)
4280 */
4281 int jb_max;
4282
Benny Prijonoc97608e2007-03-23 16:34:20 +00004283 /**
4284 * Enable ICE
4285 */
4286 pj_bool_t enable_ice;
4287
4288 /**
Benny Prijono329d6382009-05-29 13:04:03 +00004289 * Set the maximum number of host candidates.
4290 *
4291 * Default: -1 (maximum not set)
Benny Prijonoc97608e2007-03-23 16:34:20 +00004292 */
Benny Prijono329d6382009-05-29 13:04:03 +00004293 int ice_max_host_cands;
4294
4295 /**
4296 * ICE session options.
4297 */
4298 pj_ice_sess_options ice_opt;
Benny Prijonof76e1392008-06-06 14:51:48 +00004299
4300 /**
Benny Prijono551af422008-08-07 09:55:52 +00004301 * Disable RTCP component.
4302 *
4303 * Default: no
4304 */
4305 pj_bool_t ice_no_rtcp;
4306
4307 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00004308 * Enable TURN relay candidate in ICE.
4309 */
4310 pj_bool_t enable_turn;
4311
4312 /**
4313 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
4314 * "HOST:PORT" format.
4315 */
4316 pj_str_t turn_server;
4317
4318 /**
4319 * Specify the connection type to be used to the TURN server. Valid
4320 * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP.
4321 *
4322 * Default: PJ_TURN_TP_UDP
4323 */
4324 pj_turn_tp_type turn_conn_type;
4325
4326 /**
4327 * Specify the credential to authenticate with the TURN server.
4328 */
4329 pj_stun_auth_cred turn_auth_cred;
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004330
4331 /**
4332 * Specify idle time of sound device before it is automatically closed,
Benny Prijonof798e502009-03-09 13:08:16 +00004333 * in seconds. Use value -1 to disable the auto-close feature of sound
4334 * device
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004335 *
Benny Prijonof798e502009-03-09 13:08:16 +00004336 * Default : 1
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004337 */
4338 int snd_auto_close_time;
Benny Prijono312aff92006-06-17 04:08:30 +00004339};
4340
4341
4342/**
4343 * Use this function to initialize media config.
4344 *
4345 * @param cfg The media config to be initialized.
4346 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00004347PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00004348
4349
4350/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004351 * This structure describes codec information, which can be retrieved by
4352 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00004353 */
4354typedef struct pjsua_codec_info
4355{
4356 /**
4357 * Codec unique identification.
4358 */
4359 pj_str_t codec_id;
4360
4361 /**
4362 * Codec priority (integer 0-255).
4363 */
4364 pj_uint8_t priority;
4365
4366 /**
4367 * Internal buffer.
4368 */
4369 char buf_[32];
4370
4371} pjsua_codec_info;
4372
4373
4374/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004375 * This structure descibes information about a particular media port that
4376 * has been registered into the conference bridge. Application can query
4377 * this info by calling #pjsua_conf_get_port_info().
Benny Prijono312aff92006-06-17 04:08:30 +00004378 */
4379typedef struct pjsua_conf_port_info
4380{
4381 /** Conference port number. */
4382 pjsua_conf_port_id slot_id;
4383
4384 /** Port name. */
4385 pj_str_t name;
4386
4387 /** Clock rate. */
4388 unsigned clock_rate;
4389
4390 /** Number of channels. */
4391 unsigned channel_count;
4392
4393 /** Samples per frame */
4394 unsigned samples_per_frame;
4395
4396 /** Bits per sample */
4397 unsigned bits_per_sample;
4398
4399 /** Number of listeners in the array. */
4400 unsigned listener_cnt;
4401
4402 /** Array of listeners (in other words, ports where this port is
4403 * transmitting to.
4404 */
4405 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
4406
4407} pjsua_conf_port_info;
4408
4409
4410/**
4411 * This structure holds information about custom media transport to
4412 * be registered to pjsua.
4413 */
4414typedef struct pjsua_media_transport
4415{
4416 /**
4417 * Media socket information containing the address information
4418 * of the RTP and RTCP socket.
4419 */
4420 pjmedia_sock_info skinfo;
4421
4422 /**
4423 * The media transport instance.
4424 */
4425 pjmedia_transport *transport;
4426
4427} pjsua_media_transport;
4428
4429
4430
4431
Benny Prijono9fc735d2006-05-28 14:58:12 +00004432/**
4433 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004434 *
4435 * @return Maximum number of ports in the conference bridge.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004436 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004437PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004438
4439
4440/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004441 * Get current number of active ports in the bridge.
4442 *
4443 * @return The number.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004444 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004445PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
4446
4447
4448/**
4449 * Enumerate all conference ports.
4450 *
4451 * @param id Array of conference port ID to be initialized.
4452 * @param count On input, specifies max elements in the array.
4453 * On return, it contains actual number of elements
4454 * that have been initialized.
4455 *
4456 * @return PJ_SUCCESS on success, or the appropriate error code.
4457 */
4458PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
4459 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004460
4461
4462/**
4463 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004464 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004465 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004466 * @param info Pointer to store the port info.
4467 *
4468 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004469 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004470PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00004471 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004472
4473
4474/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00004475 * Add arbitrary media port to PJSUA's conference bridge. Application
4476 * can use this function to add the media port that it creates. For
4477 * media ports that are created by PJSUA-LIB (such as calls, file player,
4478 * or file recorder), PJSUA-LIB will automatically add the port to
4479 * the bridge.
4480 *
4481 * @param pool Pool to use.
4482 * @param port Media port to be added to the bridge.
4483 * @param p_id Optional pointer to receive the conference
4484 * slot id.
4485 *
4486 * @return PJ_SUCCESS on success, or the appropriate error code.
4487 */
4488PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
4489 pjmedia_port *port,
4490 pjsua_conf_port_id *p_id);
4491
4492
4493/**
4494 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00004495 * call this function if it registered the port manually with previous call
4496 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00004497 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004498 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00004499 *
4500 * @return PJ_SUCCESS on success, or the appropriate error code.
4501 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004502PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00004503
4504
4505/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004506 * Establish unidirectional media flow from souce to sink. One source
4507 * may transmit to multiple destinations/sink. And if multiple
4508 * sources are transmitting to the same sink, the media will be mixed
4509 * together. Source and sink may refer to the same ID, effectively
4510 * looping the media.
4511 *
4512 * If bidirectional media flow is desired, application needs to call
4513 * this function twice, with the second one having the arguments
4514 * reversed.
4515 *
4516 * @param source Port ID of the source media/transmitter.
4517 * @param sink Port ID of the destination media/received.
4518 *
4519 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004520 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004521PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
4522 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004523
4524
4525/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004526 * Disconnect media flow from the source to destination port.
4527 *
4528 * @param source Port ID of the source media/transmitter.
4529 * @param sink Port ID of the destination media/received.
4530 *
4531 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004532 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004533PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
4534 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004535
4536
Benny Prijono6dd967c2006-12-26 02:27:14 +00004537/**
4538 * Adjust the signal level to be transmitted from the bridge to the
4539 * specified port by making it louder or quieter.
4540 *
4541 * @param slot The conference bridge slot number.
4542 * @param level Signal level adjustment. Value 1.0 means no level
4543 * adjustment, while value 0 means to mute the port.
4544 *
4545 * @return PJ_SUCCESS on success, or the appropriate error code.
4546 */
4547PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
4548 float level);
4549
4550/**
4551 * Adjust the signal level to be received from the specified port (to
4552 * the bridge) by making it louder or quieter.
4553 *
4554 * @param slot The conference bridge slot number.
4555 * @param level Signal level adjustment. Value 1.0 means no level
4556 * adjustment, while value 0 means to mute the port.
4557 *
4558 * @return PJ_SUCCESS on success, or the appropriate error code.
4559 */
4560PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
4561 float level);
4562
4563/**
4564 * Get last signal level transmitted to or received from the specified port.
4565 * The signal level is an integer value in zero to 255, with zero indicates
4566 * no signal, and 255 indicates the loudest signal level.
4567 *
4568 * @param slot The conference bridge slot number.
4569 * @param tx_level Optional argument to receive the level of signal
4570 * transmitted to the specified port (i.e. the direction
4571 * is from the bridge to the port).
4572 * @param rx_level Optional argument to receive the level of signal
4573 * received from the port (i.e. the direction is from the
4574 * port to the bridge).
4575 *
4576 * @return PJ_SUCCESS on success.
4577 */
4578PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
4579 unsigned *tx_level,
4580 unsigned *rx_level);
4581
Benny Prijono6dd967c2006-12-26 02:27:14 +00004582
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004583/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00004584 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004585 */
4586
Benny Prijono9fc735d2006-05-28 14:58:12 +00004587/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004588 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004589 * the conference bridge.
4590 *
4591 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00004592 * WAV files are supported, and the WAV file MUST be
4593 * formatted as 16bit PCM mono/single channel (any
4594 * clock rate is supported).
Benny Prijono58add7c2008-01-18 13:24:07 +00004595 * @param options Optional option flag. Application may specify
4596 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004597 * @param p_id Pointer to receive player ID.
4598 *
4599 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004600 */
4601PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004602 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004603 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004604
4605
4606/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004607 * Create a file playlist media port, and automatically add the port
4608 * to the conference bridge.
4609 *
4610 * @param file_names Array of file names to be added to the play list.
4611 * Note that the files must have the same clock rate,
4612 * number of channels, and number of bits per sample.
4613 * @param file_count Number of files in the array.
4614 * @param label Optional label to be set for the media port.
4615 * @param options Optional option flag. Application may specify
4616 * PJMEDIA_FILE_NO_LOOP to prevent looping.
4617 * @param p_id Optional pointer to receive player ID.
4618 *
4619 * @return PJ_SUCCESS on success, or the appropriate error code.
4620 */
4621PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
4622 unsigned file_count,
4623 const pj_str_t *label,
4624 unsigned options,
4625 pjsua_player_id *p_id);
4626
4627/**
4628 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004629 *
4630 * @param id The file player ID.
4631 *
4632 * @return Conference port ID associated with this player.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004633 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004634PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004635
4636
4637/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004638 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00004639 *
4640 * @param id The player ID.
4641 * @param p_port The media port associated with the player.
4642 *
4643 * @return PJ_SUCCESS on success.
4644 */
Benny Prijono58add7c2008-01-18 13:24:07 +00004645PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
Benny Prijono469b1522006-12-26 03:05:17 +00004646 pjmedia_port **p_port);
4647
4648/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004649 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004650 *
4651 * @param id The file player ID.
4652 * @param samples The playback position, in samples. Application can
4653 * specify zero to re-start the playback.
4654 *
4655 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004656 */
4657PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
4658 pj_uint32_t samples);
4659
4660
4661/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004662 * Close the file of playlist, remove the player from the bridge, and free
4663 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004664 *
4665 * @param id The file player ID.
4666 *
4667 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004668 */
4669PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
4670
4671
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004672/*****************************************************************************
4673 * File recorder.
4674 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00004675
4676/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004677 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004678 * the conference bridge. The recorder currently supports recording WAV file.
4679 * The type of the recorder to use is determined by the extension of the file
4680 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004681 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00004682 * @param filename Output file name. The function will determine the
4683 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004684 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00004685 * @param enc_type Optionally specify the type of encoder to be used to
4686 * compress the media, if the file can support different
4687 * encodings. This value must be zero for now.
4688 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004689 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00004690 * For .WAV recorder, this value must be NULL.
4691 * @param max_size Maximum file size. Specify zero or -1 to remove size
4692 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004693 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004694 * @param p_id Pointer to receive the recorder instance.
4695 *
4696 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004697 */
4698PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004699 unsigned enc_type,
4700 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004701 pj_ssize_t max_size,
4702 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004703 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004704
4705
4706/**
4707 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004708 *
4709 * @param id The recorder ID.
4710 *
4711 * @return Conference port ID associated with this recorder.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004712 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004713PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004714
4715
4716/**
Benny Prijono469b1522006-12-26 03:05:17 +00004717 * Get the media port for the recorder.
4718 *
4719 * @param id The recorder ID.
4720 * @param p_port The media port associated with the recorder.
4721 *
4722 * @return PJ_SUCCESS on success.
4723 */
4724PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4725 pjmedia_port **p_port);
4726
4727
4728/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004729 * Destroy recorder (this will complete recording).
4730 *
4731 * @param id The recorder ID.
4732 *
4733 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004734 */
4735PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4736
4737
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004738/*****************************************************************************
4739 * Sound devices.
4740 */
4741
Benny Prijono9fc735d2006-05-28 14:58:12 +00004742/**
Benny Prijonof798e502009-03-09 13:08:16 +00004743 * Enum all audio devices installed in the system.
4744 *
4745 * @param info Array of info to be initialized.
4746 * @param count On input, specifies max elements in the array.
4747 * On return, it contains actual number of elements
4748 * that have been initialized.
4749 *
4750 * @return PJ_SUCCESS on success, or the appropriate error code.
4751 */
4752PJ_DECL(pj_status_t) pjsua_enum_aud_devs(pjmedia_aud_dev_info info[],
4753 unsigned *count);
4754
4755/**
4756 * Enum all sound devices installed in the system (old API).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004757 *
4758 * @param info Array of info to be initialized.
4759 * @param count On input, specifies max elements in the array.
4760 * On return, it contains actual number of elements
4761 * that have been initialized.
4762 *
4763 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004764 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004765PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4766 unsigned *count);
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004767
4768/**
4769 * Get currently active sound devices. If sound devices has not been created
4770 * (for example when pjsua_start() is not called), it is possible that
4771 * the function returns PJ_SUCCESS with -1 as device IDs.
4772 *
4773 * @param capture_dev On return it will be filled with device ID of the
4774 * capture device.
4775 * @param playback_dev On return it will be filled with device ID of the
4776 * device ID of the playback device.
4777 *
4778 * @return PJ_SUCCESS on success, or the appropriate error code.
4779 */
4780PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4781 int *playback_dev);
4782
4783
Benny Prijono9fc735d2006-05-28 14:58:12 +00004784/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004785 * Select or change sound device. Application may call this function at
4786 * any time to replace current sound device.
4787 *
4788 * @param capture_dev Device ID of the capture device.
4789 * @param playback_dev Device ID of the playback device.
4790 *
4791 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004792 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004793PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4794 int playback_dev);
4795
4796
4797/**
4798 * Set pjsua to use null sound device. The null sound device only provides
4799 * the timing needed by the conference bridge, and will not interract with
4800 * any hardware.
4801 *
4802 * @return PJ_SUCCESS on success, or the appropriate error code.
4803 */
4804PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4805
4806
Benny Prijonoe909eac2006-07-27 22:04:56 +00004807/**
4808 * Disconnect the main conference bridge from any sound devices, and let
4809 * application connect the bridge to it's own sound device/master port.
4810 *
4811 * @return The port interface of the conference bridge,
4812 * so that application can connect this to it's own
4813 * sound device or master port.
4814 */
4815PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4816
4817
Benny Prijonof20687a2006-08-04 18:27:19 +00004818/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004819 * Change the echo cancellation settings.
Benny Prijonof798e502009-03-09 13:08:16 +00004820 *
4821 * The behavior of this function depends on whether the sound device is
4822 * currently active, and if it is, whether device or software AEC is
4823 * being used.
Benny Prijono10454dc2009-02-21 14:21:59 +00004824 *
4825 * If the sound device is currently active, and if the device supports AEC,
4826 * this function will forward the change request to the device and it will
4827 * be up to the device on whether support the request. If software AEC is
4828 * being used (the software EC will be used if the device does not support
4829 * AEC), this function will change the software EC settings. In all cases,
4830 * the setting will be saved for future opening of the sound device.
4831 *
4832 * If the sound device is not currently active, this will only change the
4833 * default AEC settings and the setting will be applied next time the
4834 * sound device is opened.
Benny Prijonof20687a2006-08-04 18:27:19 +00004835 *
4836 * @param tail_ms The tail length, in miliseconds. Set to zero to
4837 * disable AEC.
Benny Prijonoa7b376b2008-01-25 16:06:33 +00004838 * @param options Options to be passed to pjmedia_echo_create().
Benny Prijono5da50432006-08-07 10:24:52 +00004839 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004840 *
4841 * @return PJ_SUCCESS on success.
4842 */
Benny Prijono5da50432006-08-07 10:24:52 +00004843PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004844
4845
4846/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004847 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004848 *
4849 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4850 * If AEC is disabled, the value will be zero.
4851 *
4852 * @return PJ_SUCCESS on success.
4853 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004854PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004855
4856
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004857/**
Benny Prijonof798e502009-03-09 13:08:16 +00004858 * Check whether the sound device is currently active. The sound device
4859 * may be inactive if the application has set the auto close feature to
4860 * non-zero (the snd_auto_close_time setting in #pjsua_media_config), or
4861 * if null sound device or no sound device has been configured via the
4862 * #pjsua_set_no_snd_dev() function.
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004863 */
Benny Prijonof798e502009-03-09 13:08:16 +00004864PJ_DECL(pj_bool_t) pjsua_snd_is_active(void);
4865
4866
4867/**
4868 * Configure sound device setting to the sound device being used. If sound
4869 * device is currently active, the function will forward the setting to the
4870 * sound device instance to be applied immediately, if it supports it.
4871 *
4872 * The setting will be saved for future opening of the sound device, if the
4873 * "keep" argument is set to non-zero. If the sound device is currently
4874 * inactive, and the "keep" argument is false, this function will return
4875 * error.
4876 *
4877 * Note that in case the setting is kept for future use, it will be applied
4878 * to any devices, even when application has changed the sound device to be
4879 * used.
4880 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004881 * Note also that the echo cancellation setting should be set with
4882 * #pjsua_set_ec() API instead.
4883 *
Benny Prijonof798e502009-03-09 13:08:16 +00004884 * See also #pjmedia_aud_stream_set_cap() for more information about setting
4885 * an audio device capability.
4886 *
4887 * @param cap The sound device setting to change.
4888 * @param pval Pointer to value. Please see #pjmedia_aud_dev_cap
4889 * documentation about the type of value to be
4890 * supplied for each setting.
4891 * @param keep Specify whether the setting is to be kept for future
4892 * use.
4893 *
4894 * @return PJ_SUCCESS on success or the appropriate error code.
4895 */
4896PJ_DECL(pj_status_t) pjsua_snd_set_setting(pjmedia_aud_dev_cap cap,
4897 const void *pval,
4898 pj_bool_t keep);
4899
4900/**
4901 * Retrieve a sound device setting. If sound device is currently active,
4902 * the function will forward the request to the sound device. If sound device
4903 * is currently inactive, and if application had previously set the setting
4904 * and mark the setting as kept, then that setting will be returned.
4905 * Otherwise, this function will return error.
4906 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004907 * Note that echo cancellation settings should be retrieved with
4908 * #pjsua_get_ec_tail() API instead.
4909 *
Benny Prijonof798e502009-03-09 13:08:16 +00004910 * @param cap The sound device setting to retrieve.
4911 * @param pval Pointer to receive the value.
4912 * Please see #pjmedia_aud_dev_cap documentation about
4913 * the type of value to be supplied for each setting.
4914 *
4915 * @return PJ_SUCCESS on success or the appropriate error code.
4916 */
4917PJ_DECL(pj_status_t) pjsua_snd_get_setting(pjmedia_aud_dev_cap cap,
4918 void *pval);
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004919
4920
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004921/*****************************************************************************
4922 * Codecs.
4923 */
4924
4925/**
4926 * Enum all supported codecs in the system.
4927 *
4928 * @param id Array of ID to be initialized.
4929 * @param count On input, specifies max elements in the array.
4930 * On return, it contains actual number of elements
4931 * that have been initialized.
4932 *
4933 * @return PJ_SUCCESS on success, or the appropriate error code.
4934 */
4935PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4936 unsigned *count );
4937
4938
4939/**
4940 * Change codec priority.
4941 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004942 * @param codec_id Codec ID, which is a string that uniquely identify
4943 * the codec (such as "speex/8000"). Please see pjsua
4944 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004945 * @param priority Codec priority, 0-255, where zero means to disable
4946 * the codec.
4947 *
4948 * @return PJ_SUCCESS on success, or the appropriate error code.
4949 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004950PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004951 pj_uint8_t priority );
4952
4953
4954/**
4955 * Get codec parameters.
4956 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004957 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004958 * @param param Structure to receive codec parameters.
4959 *
4960 * @return PJ_SUCCESS on success, or the appropriate error code.
4961 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004962PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004963 pjmedia_codec_param *param );
4964
4965
4966/**
4967 * Set codec parameters.
4968 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004969 * @param codec_id Codec ID.
Nanang Izzuddin06839e72010-01-27 11:48:31 +00004970 * @param param Codec parameter to set. Set to NULL to reset
4971 * codec parameter to library default settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004972 *
4973 * @return PJ_SUCCESS on success, or the appropriate error code.
4974 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004975PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004976 const pjmedia_codec_param *param);
4977
Benny Prijono0bc99a92011-03-17 04:34:43 +00004978#if DISABLED_FOR_TICKET_1185
Benny Prijono312aff92006-06-17 04:08:30 +00004979/**
4980 * Create UDP media transports for all the calls. This function creates
4981 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00004982 *
Benny Prijono312aff92006-06-17 04:08:30 +00004983 * @param cfg Media transport configuration. The "port" field in the
4984 * configuration is used as the start port to bind the
4985 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004986 *
4987 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonof3195072006-02-14 21:15:30 +00004988 */
Benny Prijono312aff92006-06-17 04:08:30 +00004989PJ_DECL(pj_status_t)
4990pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00004991
Benny Prijonodc39fe82006-05-26 12:17:46 +00004992
4993/**
Benny Prijono312aff92006-06-17 04:08:30 +00004994 * Register custom media transports to be used by calls. There must
4995 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004996 *
Benny Prijono312aff92006-06-17 04:08:30 +00004997 * @param tp The media transport array.
4998 * @param count Number of elements in the array. This number MUST
4999 * match the number of maximum calls configured when
5000 * pjsua is created.
5001 * @param auto_delete Flag to indicate whether the transports should be
5002 * destroyed when pjsua is shutdown.
5003 *
5004 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00005005 */
Benny Prijono312aff92006-06-17 04:08:30 +00005006PJ_DECL(pj_status_t)
5007pjsua_media_transports_attach( pjsua_media_transport tp[],
5008 unsigned count,
5009 pj_bool_t auto_delete);
Benny Prijono0bc99a92011-03-17 04:34:43 +00005010#endif
Benny Prijonodc39fe82006-05-26 12:17:46 +00005011
5012
Benny Prijono312aff92006-06-17 04:08:30 +00005013/**
5014 * @}
5015 */
5016
Benny Prijonof3195072006-02-14 21:15:30 +00005017
Benny Prijono268ca612006-02-07 12:34:11 +00005018
Benny Prijono312aff92006-06-17 04:08:30 +00005019/**
5020 * @}
5021 */
5022
Benny Prijonoe6ead542007-01-31 20:53:31 +00005023PJ_END_DECL
5024
Benny Prijono312aff92006-06-17 04:08:30 +00005025
Benny Prijono268ca612006-02-07 12:34:11 +00005026#endif /* __PJSUA_H__ */