blob: 44f73451e1dd1c203d837c70df1129bb4594625b [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
253/** Call identification */
254typedef int pjsua_call_id;
255
Benny Prijono312aff92006-06-17 04:08:30 +0000256/** Account identification */
257typedef int pjsua_acc_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000258
259/** Buddy identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000260typedef int pjsua_buddy_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000261
262/** File player identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000263typedef int pjsua_player_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000264
265/** File recorder identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000266typedef int pjsua_recorder_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000267
268/** Conference port identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000269typedef int pjsua_conf_port_id;
270
Benny Prijono63fba012008-07-17 14:19:10 +0000271/** Opaque declaration for server side presence subscription */
272typedef struct pjsua_srv_pres pjsua_srv_pres;
273
274/** Forward declaration for pjsua_msg_data */
275typedef struct pjsua_msg_data pjsua_msg_data;
Benny Prijono8b1889b2006-06-06 18:40:40 +0000276
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000277
Benny Prijonoa91a0032006-02-26 21:23:45 +0000278/**
Benny Prijono312aff92006-06-17 04:08:30 +0000279 * Maximum proxies in account.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000280 */
Benny Prijono312aff92006-06-17 04:08:30 +0000281#ifndef PJSUA_ACC_MAX_PROXIES
282# define PJSUA_ACC_MAX_PROXIES 8
283#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000284
Benny Prijonod8179652008-01-23 20:39:07 +0000285#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000286
Benny Prijonod8179652008-01-23 20:39:07 +0000287/**
288 * Default value of SRTP mode usage. Valid values are PJMEDIA_SRTP_DISABLED,
289 * PJMEDIA_SRTP_OPTIONAL, and PJMEDIA_SRTP_MANDATORY.
290 */
291#ifndef PJSUA_DEFAULT_USE_SRTP
292 #define PJSUA_DEFAULT_USE_SRTP PJMEDIA_SRTP_DISABLED
293#endif
294
295/**
296 * Default value of secure signaling requirement for SRTP.
297 * Valid values are:
298 * 0: SRTP does not require secure signaling
299 * 1: SRTP requires secure transport such as TLS
300 * 2: SRTP requires secure end-to-end transport (SIPS)
301 */
302#ifndef PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
303 #define PJSUA_DEFAULT_SRTP_SECURE_SIGNALING 1
304#endif
305
306#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000307
308/**
Benny Prijono07fe2302010-06-24 12:33:18 +0000309 * Controls whether PJSUA-LIB should add ICE media feature tag
310 * parameter (the ";+sip.ice" parameter) to Contact header if ICE
311 * is enabled in the config.
312 *
313 * Default: 1
314 */
315#ifndef PJSUA_ADD_ICE_TAGS
316# define PJSUA_ADD_ICE_TAGS 1
317#endif
318
Sauw Ming844c1c92010-09-07 05:12:02 +0000319/**
320 * Timeout value used to acquire mutex lock on a particular call.
321 *
322 * Default: 2000 ms
323 */
324#ifndef PJSUA_ACQUIRE_CALL_TIMEOUT
325# define PJSUA_ACQUIRE_CALL_TIMEOUT 2000
326#endif
327
Benny Prijono07fe2302010-06-24 12:33:18 +0000328
329/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000330 * Logging configuration, which can be (optionally) specified when calling
331 * #pjsua_init(). Application must call #pjsua_logging_config_default() to
332 * initialize this structure with the default values.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000333 */
334typedef struct pjsua_logging_config
335{
336 /**
337 * Log incoming and outgoing SIP message? Yes!
338 */
339 pj_bool_t msg_logging;
340
341 /**
342 * Input verbosity level. Value 5 is reasonable.
343 */
344 unsigned level;
345
346 /**
347 * Verbosity level for console. Value 4 is reasonable.
348 */
349 unsigned console_level;
350
351 /**
352 * Log decoration.
353 */
354 unsigned decor;
355
356 /**
357 * Optional log filename.
358 */
359 pj_str_t log_filename;
360
361 /**
Benny Prijonodbe3f4b2009-05-07 16:56:04 +0000362 * Additional flags to be given to #pj_file_open() when opening
363 * the log file. By default, the flag is PJ_O_WRONLY. Application
364 * may set PJ_O_APPEND here so that logs are appended to existing
365 * file instead of overwriting it.
366 *
367 * Default is 0.
368 */
369 unsigned log_file_flags;
370
371 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000372 * Optional callback function to be called to write log to
373 * application specific device. This function will be called for
374 * log messages on input verbosity level.
375 */
Benny Prijonofe7d87b2007-11-29 11:35:44 +0000376 void (*cb)(int level, const char *data, int len);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000377
378
379} pjsua_logging_config;
380
381
382/**
383 * Use this function to initialize logging config.
384 *
385 * @param cfg The logging config to be initialized.
386 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000387PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000388
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000389
390/**
391 * Use this function to duplicate logging config.
392 *
393 * @param pool Pool to use.
394 * @param dst Destination config.
395 * @param src Source config.
396 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000397PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool,
398 pjsua_logging_config *dst,
399 const pjsua_logging_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000400
Benny Prijonodc39fe82006-05-26 12:17:46 +0000401
402/**
Benny Prijono4dd961b2009-10-26 11:21:37 +0000403 * Structure to be passed on MWI callback.
404 */
405typedef struct pjsua_mwi_info
406{
407 pjsip_evsub *evsub; /**< Event subscription session, for
408 reference. */
409 pjsip_rx_data *rdata; /**< The received NOTIFY request. */
410} pjsua_mwi_info;
411
412
413/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000414 * This structure describes application callback to receive various event
415 * notification from PJSUA-API. All of these callbacks are OPTIONAL,
416 * although definitely application would want to implement some of
417 * the important callbacks (such as \a on_incoming_call).
Benny Prijonodc39fe82006-05-26 12:17:46 +0000418 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000419typedef struct pjsua_callback
Benny Prijonodc39fe82006-05-26 12:17:46 +0000420{
421 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000422 * Notify application when invite state has changed.
423 * Application may then query the call info to get the
Benny Prijonoe6ead542007-01-31 20:53:31 +0000424 * detail call states by calling pjsua_call_get_info() function.
Benny Prijono0875ae82006-12-26 00:11:48 +0000425 *
426 * @param call_id The call index.
427 * @param e Event which causes the call state to change.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000428 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000429 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000430
431 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000432 * Notify application on incoming call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000433 *
434 * @param acc_id The account which match the incoming call.
435 * @param call_id The call id that has just been created for
436 * the call.
437 * @param rdata The incoming INVITE request.
Benny Prijono8b1889b2006-06-06 18:40:40 +0000438 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000439 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000440 pjsip_rx_data *rdata);
441
442 /**
Benny Prijonofeb69f42007-10-05 09:12:26 +0000443 * This is a general notification callback which is called whenever
444 * a transaction within the call has changed state. Application can
445 * implement this callback for example to monitor the state of
446 * outgoing requests, or to answer unhandled incoming requests
447 * (such as INFO) with a final response.
448 *
449 * @param call_id Call identification.
450 * @param tsx The transaction which has changed state.
451 * @param e Transaction event that caused the state change.
452 */
453 void (*on_call_tsx_state)(pjsua_call_id call_id,
454 pjsip_transaction *tsx,
455 pjsip_event *e);
456
457 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000458 * Notify application when media state in the call has changed.
459 * Normal application would need to implement this callback, e.g.
Benny Prijono6ba8c542007-10-16 01:34:14 +0000460 * to connect the call's media to sound device. When ICE is used,
461 * this callback will also be called to report ICE negotiation
462 * failure.
Benny Prijono0875ae82006-12-26 00:11:48 +0000463 *
464 * @param call_id The call index.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000465 */
466 void (*on_call_media_state)(pjsua_call_id call_id);
467
Benny Prijonofc13bf62008-02-20 08:56:15 +0000468
469 /**
470 * Notify application when media session is created and before it is
471 * registered to the conference bridge. Application may return different
472 * media port if it has added media processing port to the stream. This
473 * media port then will be added to the conference bridge instead.
474 *
475 * @param call_id Call identification.
476 * @param sess Media session for the call.
477 * @param stream_idx Stream index in the media session.
478 * @param p_port On input, it specifies the media port of the
479 * stream. Application may modify this pointer to
480 * point to different media port to be registered
481 * to the conference bridge.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000482 */
483 void (*on_stream_created)(pjsua_call_id call_id,
484 pjmedia_session *sess,
485 unsigned stream_idx,
486 pjmedia_port **p_port);
487
488 /**
489 * Notify application when media session has been unregistered from the
490 * conference bridge and about to be destroyed.
491 *
492 * @param call_id Call identification.
493 * @param sess Media session for the call.
494 * @param stream_idx Stream index in the media session.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000495 */
496 void (*on_stream_destroyed)(pjsua_call_id call_id,
497 pjmedia_session *sess,
498 unsigned stream_idx);
499
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000500 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000501 * Notify application upon incoming DTMF digits.
502 *
503 * @param call_id The call index.
504 * @param digit DTMF ASCII digit.
505 */
506 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
507
508 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000509 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000510 * Application can decide to accept/reject transfer request
Benny Prijonoc54dcb32008-04-08 23:33:15 +0000511 * by setting the code (default is 202). When this callback
Benny Prijono9fc735d2006-05-28 14:58:12 +0000512 * is not defined, the default behavior is to accept the
513 * transfer.
Benny Prijono0875ae82006-12-26 00:11:48 +0000514 *
515 * @param call_id The call index.
516 * @param dst The destination where the call will be
517 * transfered to.
518 * @param code Status code to be returned for the call transfer
519 * request. On input, it contains status code 200.
Benny Prijono9fc735d2006-05-28 14:58:12 +0000520 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000521 void (*on_call_transfer_request)(pjsua_call_id call_id,
522 const pj_str_t *dst,
523 pjsip_status_code *code);
524
525 /**
526 * Notify application of the status of previously sent call
527 * transfer request. Application can monitor the status of the
528 * call transfer request, for example to decide whether to
529 * terminate existing call.
530 *
531 * @param call_id Call ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000532 * @param st_code Status progress of the transfer request.
533 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000534 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000535 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000536 * this callback is the final status.
537 * @param p_cont Initially will be set to non-zero, application
538 * can set this to FALSE if it no longer wants
539 * to receie further notification (for example,
540 * after it hangs up the call).
541 */
542 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000543 int st_code,
544 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000545 pj_bool_t final,
546 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000547
548 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000549 * Notify application about incoming INVITE with Replaces header.
550 * Application may reject the request by setting non-2xx code.
551 *
552 * @param call_id The call ID to be replaced.
553 * @param rdata The incoming INVITE request to replace the call.
554 * @param st_code Status code to be set by application. Application
555 * should only return a final status (200-699).
556 * @param st_text Optional status text to be set by application.
557 */
558 void (*on_call_replace_request)(pjsua_call_id call_id,
559 pjsip_rx_data *rdata,
560 int *st_code,
561 pj_str_t *st_text);
562
563 /**
564 * Notify application that an existing call has been replaced with
565 * a new call. This happens when PJSUA-API receives incoming INVITE
566 * request with Replaces header.
567 *
568 * After this callback is called, normally PJSUA-API will disconnect
569 * \a old_call_id and establish \a new_call_id.
570 *
571 * @param old_call_id Existing call which to be replaced with the
572 * new call.
573 * @param new_call_id The new call.
574 * @param rdata The incoming INVITE with Replaces request.
575 */
576 void (*on_call_replaced)(pjsua_call_id old_call_id,
577 pjsua_call_id new_call_id);
578
579
580 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000581 * Notify application when registration status has changed.
582 * Application may then query the account info to get the
583 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000584 *
585 * @param acc_id Account ID.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000586 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000587 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000588
589 /**
Benny Prijono63fba012008-07-17 14:19:10 +0000590 * Notification when incoming SUBSCRIBE request is received. Application
591 * may use this callback to authorize the incoming subscribe request
592 * (e.g. ask user permission if the request should be granted).
593 *
594 * If this callback is not implemented, all incoming presence subscription
595 * requests will be accepted.
596 *
597 * If this callback is implemented, application has several choices on
598 * what to do with the incoming request:
599 * - it may reject the request immediately by specifying non-200 class
600 * final response in the \a code argument.
601 * - it may immediately accept the request by specifying 200 as the
602 * \a code argument. This is the default value if application doesn't
603 * set any value to the \a code argument. In this case, the library
604 * will automatically send NOTIFY request upon returning from this
605 * callback.
606 * - it may delay the processing of the request, for example to request
607 * user permission whether to accept or reject the request. In this
608 * case, the application MUST set the \a code argument to 202, and
609 * later calls #pjsua_pres_notify() to accept or reject the
610 * subscription request.
611 *
612 * Any \a code other than 200 and 202 will be treated as 200.
613 *
614 * Application MUST return from this callback immediately (e.g. it must
615 * not block in this callback while waiting for user confirmation).
616 *
617 * @param srv_pres Server presence subscription instance. If
618 * application delays the acceptance of the request,
619 * it will need to specify this object when calling
620 * #pjsua_pres_notify().
621 * @param acc_id Account ID most appropriate for this request.
622 * @param buddy_id ID of the buddy matching the sender of the
623 * request, if any, or PJSUA_INVALID_ID if no
624 * matching buddy is found.
625 * @param from The From URI of the request.
626 * @param rdata The incoming request.
627 * @param code The status code to respond to the request. The
628 * default value is 200. Application may set this
629 * to other final status code to accept or reject
630 * the request.
631 * @param reason The reason phrase to respond to the request.
632 * @param msg_data If the application wants to send additional
633 * headers in the response, it can put it in this
634 * parameter.
635 */
636 void (*on_incoming_subscribe)(pjsua_acc_id acc_id,
637 pjsua_srv_pres *srv_pres,
638 pjsua_buddy_id buddy_id,
639 const pj_str_t *from,
640 pjsip_rx_data *rdata,
641 pjsip_status_code *code,
642 pj_str_t *reason,
643 pjsua_msg_data *msg_data);
644
645 /**
646 * Notification when server side subscription state has changed.
647 * This callback is optional as application normally does not need
648 * to do anything to maintain server side presence subscription.
649 *
650 * @param acc_id The account ID.
651 * @param srv_pres Server presence subscription object.
652 * @param remote_uri Remote URI string.
653 * @param state New subscription state.
654 * @param event PJSIP event that triggers the state change.
655 */
656 void (*on_srv_subscribe_state)(pjsua_acc_id acc_id,
657 pjsua_srv_pres *srv_pres,
658 const pj_str_t *remote_uri,
659 pjsip_evsub_state state,
660 pjsip_event *event);
661
662 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000663 * Notify application when the buddy state has changed.
664 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000665 *
666 * @param buddy_id The buddy id.
Benny Prijono9fc735d2006-05-28 14:58:12 +0000667 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000668 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000669
670 /**
671 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000672 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000673 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000674 *
Benny Prijonobbeb3992007-05-21 13:48:35 +0000675 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
676 * passed as one of the argument.
677 *
Benny Prijono0875ae82006-12-26 00:11:48 +0000678 * @param call_id Containts the ID of the call where the IM was
679 * sent, or PJSUA_INVALID_ID if the IM was sent
680 * outside call context.
681 * @param from URI of the sender.
682 * @param to URI of the destination message.
683 * @param contact The Contact URI of the sender, if present.
684 * @param mime_type MIME type of the message.
685 * @param body The message content.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000686 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000687 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
688 const pj_str_t *to, const pj_str_t *contact,
689 const pj_str_t *mime_type, const pj_str_t *body);
690
691 /**
Benny Prijonobbeb3992007-05-21 13:48:35 +0000692 * This is the alternative version of the \a on_pager() callback with
693 * \a pjsip_rx_data argument.
694 *
695 * @param call_id Containts the ID of the call where the IM was
696 * sent, or PJSUA_INVALID_ID if the IM was sent
697 * outside call context.
698 * @param from URI of the sender.
699 * @param to URI of the destination message.
700 * @param contact The Contact URI of the sender, if present.
701 * @param mime_type MIME type of the message.
702 * @param body The message content.
703 * @param rdata The incoming MESSAGE request.
Benny Prijonoba736c42008-07-10 20:45:03 +0000704 * @param acc_id Account ID most suitable for this message.
Benny Prijonobbeb3992007-05-21 13:48:35 +0000705 */
706 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
707 const pj_str_t *to, const pj_str_t *contact,
708 const pj_str_t *mime_type, const pj_str_t *body,
Benny Prijonoba736c42008-07-10 20:45:03 +0000709 pjsip_rx_data *rdata, pjsua_acc_id acc_id);
Benny Prijonobbeb3992007-05-21 13:48:35 +0000710
711 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000712 * Notify application about the delivery status of outgoing pager
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000713 * request. See also on_pager_status2() callback for the version with
714 * \a pjsip_rx_data in the argument list.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000715 *
716 * @param call_id Containts the ID of the call where the IM was
717 * sent, or PJSUA_INVALID_ID if the IM was sent
718 * outside call context.
719 * @param to Destination URI.
720 * @param body Message body.
721 * @param user_data Arbitrary data that was specified when sending
722 * IM message.
723 * @param status Delivery status.
724 * @param reason Delivery status reason.
725 */
726 void (*on_pager_status)(pjsua_call_id call_id,
727 const pj_str_t *to,
728 const pj_str_t *body,
729 void *user_data,
730 pjsip_status_code status,
731 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000732
733 /**
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000734 * Notify application about the delivery status of outgoing pager
735 * request.
736 *
737 * @param call_id Containts the ID of the call where the IM was
738 * sent, or PJSUA_INVALID_ID if the IM was sent
739 * outside call context.
740 * @param to Destination URI.
741 * @param body Message body.
742 * @param user_data Arbitrary data that was specified when sending
743 * IM message.
744 * @param status Delivery status.
745 * @param reason Delivery status reason.
Benny Prijono0a982002007-06-12 16:22:09 +0000746 * @param tdata The original MESSAGE request.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000747 * @param rdata The incoming MESSAGE response, or NULL if the
748 * message transaction fails because of time out
749 * or transport error.
Benny Prijonoba736c42008-07-10 20:45:03 +0000750 * @param acc_id Account ID from this the instant message was
751 * send.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000752 */
753 void (*on_pager_status2)(pjsua_call_id call_id,
754 const pj_str_t *to,
755 const pj_str_t *body,
756 void *user_data,
757 pjsip_status_code status,
758 const pj_str_t *reason,
Benny Prijono0a982002007-06-12 16:22:09 +0000759 pjsip_tx_data *tdata,
Benny Prijonoba736c42008-07-10 20:45:03 +0000760 pjsip_rx_data *rdata,
761 pjsua_acc_id acc_id);
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000762
763 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000764 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +0000765 *
766 * @param call_id Containts the ID of the call where the IM was
767 * sent, or PJSUA_INVALID_ID if the IM was sent
768 * outside call context.
769 * @param from URI of the sender.
770 * @param to URI of the destination message.
771 * @param contact The Contact URI of the sender, if present.
772 * @param is_typing Non-zero if peer is typing, or zero if peer
773 * has stopped typing a message.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000774 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000775 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
776 const pj_str_t *to, const pj_str_t *contact,
777 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000778
Benny Prijono6ba8c542007-10-16 01:34:14 +0000779 /**
Benny Prijonoba736c42008-07-10 20:45:03 +0000780 * Notify application about typing indication.
781 *
782 * @param call_id Containts the ID of the call where the IM was
783 * sent, or PJSUA_INVALID_ID if the IM was sent
784 * outside call context.
785 * @param from URI of the sender.
786 * @param to URI of the destination message.
787 * @param contact The Contact URI of the sender, if present.
788 * @param is_typing Non-zero if peer is typing, or zero if peer
789 * has stopped typing a message.
790 * @param rdata The received request.
791 * @param acc_id Account ID most suitable for this message.
792 */
793 void (*on_typing2)(pjsua_call_id call_id, const pj_str_t *from,
794 const pj_str_t *to, const pj_str_t *contact,
795 pj_bool_t is_typing, pjsip_rx_data *rdata,
796 pjsua_acc_id acc_id);
797
798 /**
Benny Prijono6ba8c542007-10-16 01:34:14 +0000799 * Callback when the library has finished performing NAT type
800 * detection.
801 *
802 * @param res NAT detection result.
803 */
804 void (*on_nat_detect)(const pj_stun_nat_detect_result *res);
805
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000806 /**
807 * This callback is called when the call is about to resend the
808 * INVITE request to the specified target, following the previously
809 * received redirection response.
810 *
811 * Application may accept the redirection to the specified target
812 * (the default behavior if this callback is implemented), reject
813 * this target only and make the session continue to try the next
814 * target in the list if such target exists, stop the whole
815 * redirection process altogether and cause the session to be
816 * disconnected, or defer the decision to ask for user confirmation.
817 *
818 * This callback is optional. If this callback is not implemented,
819 * the default behavior is to NOT follow the redirection response.
820 *
821 * @param call_id The call ID.
822 * @param target The current target to be tried.
Benny Prijono08a48b82008-11-27 12:42:07 +0000823 * @param e The event that caused this callback to be called.
824 * This could be the receipt of 3xx response, or
825 * 4xx/5xx response received for the INVITE sent to
826 * subsequent targets, or NULL if this callback is
827 * called from within #pjsua_call_process_redirect()
828 * context.
829 *
830 * @return Action to be performed for the target. Set this
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000831 * parameter to one of the value below:
832 * - PJSIP_REDIRECT_ACCEPT: immediately accept the
833 * redirection (default value). When set, the
834 * call will immediately resend INVITE request
835 * to the target.
836 * - PJSIP_REDIRECT_REJECT: immediately reject this
837 * target. The call will continue retrying with
838 * next target if present, or disconnect the call
839 * if there is no more target to try.
840 * - PJSIP_REDIRECT_STOP: stop the whole redirection
841 * process and immediately disconnect the call. The
842 * on_call_state() callback will be called with
843 * PJSIP_INV_STATE_DISCONNECTED state immediately
844 * after this callback returns.
845 * - PJSIP_REDIRECT_PENDING: set to this value if
846 * no decision can be made immediately (for example
847 * to request confirmation from user). Application
848 * then MUST call #pjsua_call_process_redirect()
849 * to either accept or reject the redirection upon
850 * getting user decision.
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000851 */
Benny Prijono08a48b82008-11-27 12:42:07 +0000852 pjsip_redirect_op (*on_call_redirected)(pjsua_call_id call_id,
853 const pjsip_uri *target,
854 const pjsip_event *e);
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000855
Benny Prijono4dd961b2009-10-26 11:21:37 +0000856 /**
857 * This callback is called when a NOTIFY request for message summary /
858 * message waiting indication is received.
859 *
860 * @param acc_id The account ID.
861 * @param mwi_info Structure containing details of the event,
862 * including the received NOTIFY request in the
863 * \a rdata field.
864 */
865 void (*on_mwi_info)(pjsua_acc_id acc_id, pjsua_mwi_info *mwi_info);
866
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +0000867 /**
868 * This callback is called when transport state is changed. See also
869 * #pjsip_tp_state_callback.
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +0000870 */
Nanang Izzuddin5e69da52010-02-25 11:58:19 +0000871 pjsip_tp_state_callback on_transport_state;
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +0000872
Benny Prijono4d6ff4d2010-06-19 12:35:33 +0000873 /**
874 * This callback is called to report error in ICE media transport.
875 * Currently it is used to report TURN Refresh error.
876 *
877 * @param index Transport index.
878 * @param op Operation which trigger the failure.
879 * @param status Error status.
880 * @param param Additional info about the event. Currently this will
881 * always be set to NULL.
882 */
883 void (*on_ice_transport_error)(int index, pj_ice_strans_op op,
884 pj_status_t status, void *param);
885
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000886} pjsua_callback;
887
888
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +0000889/**
890 * This enumeration specifies the usage of SIP Session Timers extension.
891 */
892typedef enum pjsua_sip_timer_use
893{
894 /**
895 * When this flag is specified, Session Timers will not be used in any
896 * session, except it is explicitly required in the remote request.
897 */
898 PJSUA_SIP_TIMER_INACTIVE,
899
900 /**
901 * When this flag is specified, Session Timers will be used in all
902 * sessions whenever remote supports and uses it.
903 */
904 PJSUA_SIP_TIMER_OPTIONAL,
905
906 /**
907 * When this flag is specified, Session Timers support will be
908 * a requirement for the remote to be able to establish a session.
909 */
910 PJSUA_SIP_TIMER_REQUIRED,
911
912 /**
913 * When this flag is specified, Session Timers will always be used
914 * in all sessions, regardless whether remote supports/uses it or not.
915 */
916 PJSUA_SIP_TIMER_ALWAYS
917
918} pjsua_sip_timer_use;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000919
Benny Prijonodc39fe82006-05-26 12:17:46 +0000920
921/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000922 * This structure describes the settings to control the API and
923 * user agent behavior, and can be specified when calling #pjsua_init().
924 * Before setting the values, application must call #pjsua_config_default()
925 * to initialize this structure with the default values.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000926 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000927typedef struct pjsua_config
928{
929
930 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000931 * Maximum calls to support (default: 4). The value specified here
932 * must be smaller than the compile time maximum settings
933 * PJSUA_MAX_CALLS, which by default is 32. To increase this
934 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
935 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000936 */
937 unsigned max_calls;
938
939 /**
940 * Number of worker threads. Normally application will want to have at
941 * least one worker thread, unless when it wants to poll the library
942 * periodically, which in this case the worker thread can be set to
943 * zero.
944 */
945 unsigned thread_cnt;
946
947 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +0000948 * Number of nameservers. If no name server is configured, the SIP SRV
949 * resolution would be disabled, and domain will be resolved with
950 * standard pj_gethostbyname() function.
951 */
952 unsigned nameserver_count;
953
954 /**
955 * Array of nameservers to be used by the SIP resolver subsystem.
956 * The order of the name server specifies the priority (first name
957 * server will be used first, unless it is not reachable).
958 */
959 pj_str_t nameserver[4];
960
961 /**
Benny Prijono91d06b62008-09-20 12:16:56 +0000962 * Force loose-route to be used in all route/proxy URIs (outbound_proxy
963 * and account's proxy settings). When this setting is enabled, the
964 * library will check all the route/proxy URIs specified in the settings
965 * and append ";lr" parameter to the URI if the parameter is not present.
966 *
967 * Default: 1
968 */
969 pj_bool_t force_lr;
970
971 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000972 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000973 */
974 unsigned outbound_proxy_cnt;
975
976 /**
977 * Specify the URL of outbound proxies to visit for all outgoing requests.
978 * The outbound proxies will be used for all accounts, and it will
979 * be used to build the route set for outgoing requests. The final
980 * route set for outgoing requests will consists of the outbound proxies
981 * and the proxy configured in the account.
982 */
983 pj_str_t outbound_proxy[4];
984
Benny Prijonoc97608e2007-03-23 16:34:20 +0000985 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +0000986 * Warning: deprecated, please use \a stun_srv field instead. To maintain
987 * backward compatibility, if \a stun_srv_cnt is zero then the value of
988 * this field will be copied to \a stun_srv field, if present.
989 *
Benny Prijonoebbf6892007-03-24 17:37:25 +0000990 * Specify domain name to be resolved with DNS SRV resolution to get the
Benny Prijonof76e1392008-06-06 14:51:48 +0000991 * address of the STUN server. Alternatively application may specify
992 * \a stun_host instead.
Benny Prijonoebbf6892007-03-24 17:37:25 +0000993 *
994 * If DNS SRV resolution failed for this domain, then DNS A resolution
995 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +0000996 */
Benny Prijonoebbf6892007-03-24 17:37:25 +0000997 pj_str_t stun_domain;
998
999 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001000 * Warning: deprecated, please use \a stun_srv field instead. To maintain
1001 * backward compatibility, if \a stun_srv_cnt is zero then the value of
1002 * this field will be copied to \a stun_srv field, if present.
1003 *
Benny Prijonoaf09dc32007-04-22 12:48:30 +00001004 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
1005 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001006 */
1007 pj_str_t stun_host;
1008
1009 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001010 * Number of STUN server entries in \a stun_srv array.
1011 */
1012 unsigned stun_srv_cnt;
1013
1014 /**
1015 * Array of STUN servers to try. The library will try to resolve and
1016 * contact each of the STUN server entry until it finds one that is
1017 * usable. Each entry may be a domain name, host name, IP address, and
1018 * it may contain an optional port number. For example:
1019 * - "pjsip.org" (domain name)
1020 * - "sip.pjsip.org" (host name)
1021 * - "pjsip.org:33478" (domain name and a non-standard port number)
1022 * - "10.0.0.1:3478" (IP address and port number)
1023 *
1024 * When nameserver is configured in the \a pjsua_config.nameserver field,
1025 * if entry is not an IP address, it will be resolved with DNS SRV
1026 * resolution first, and it will fallback to use DNS A resolution if this
1027 * fails. Port number may be specified even if the entry is a domain name,
1028 * in case the DNS SRV resolution should fallback to a non-standard port.
1029 *
1030 * When nameserver is not configured, entries will be resolved with
1031 * #pj_gethostbyname() if it's not an IP address. Port number may be
1032 * specified if the server is not listening in standard STUN port.
1033 */
1034 pj_str_t stun_srv[8];
1035
1036 /**
1037 * This specifies if the library startup should ignore failure with the
1038 * STUN servers. If this is set to PJ_FALSE, the library will refuse to
1039 * start if it fails to resolve or contact any of the STUN servers.
1040 *
1041 * Default: PJ_TRUE
1042 */
1043 pj_bool_t stun_ignore_failure;
1044
1045 /**
Benny Prijono91a6a172007-10-31 08:59:29 +00001046 * Support for adding and parsing NAT type in the SDP to assist
1047 * troubleshooting. The valid values are:
1048 * - 0: no information will be added in SDP, and parsing is disabled.
Benny Prijono6ba8c542007-10-16 01:34:14 +00001049 * - 1: only the NAT type number is added.
1050 * - 2: add both NAT type number and name.
1051 *
Benny Prijono91a6a172007-10-31 08:59:29 +00001052 * Default: 1
Benny Prijono6ba8c542007-10-16 01:34:14 +00001053 */
1054 int nat_type_in_sdp;
1055
1056 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001057 * Specify whether support for reliable provisional response (100rel and
1058 * PRACK) should be required by default. Note that this setting can be
1059 * further customized in account configuration (#pjsua_acc_config).
1060 *
1061 * Default: PJ_FALSE
1062 */
1063 pj_bool_t require_100rel;
1064
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001065 /**
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001066 * Specify the usage of Session Timers for all sessions. See the
1067 * #pjsua_sip_timer_use for possible values. Note that this setting can be
1068 * further customized in account configuration (#pjsua_acc_config).
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001069 *
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001070 * Default: PJSUA_SIP_TIMER_OPTIONAL
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001071 */
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001072 pjsua_sip_timer_use use_timer;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001073
1074 /**
Benny Prijonofe1bd342009-11-20 23:33:07 +00001075 * Handle unsolicited NOTIFY requests containing message waiting
1076 * indication (MWI) info. Unsolicited MWI is incoming NOTIFY requests
1077 * which are not requested by client with SUBSCRIBE request.
1078 *
1079 * If this is enabled, the library will respond 200/OK to the NOTIFY
1080 * request and forward the request to \a on_mwi_info() callback.
1081 *
1082 * See also \a mwi_enabled field #on pjsua_acc_config.
1083 *
1084 * Default: PJ_TRUE
1085 *
1086 */
1087 pj_bool_t enable_unsolicited_mwi;
1088
1089 /**
Nanang Izzuddin65add622009-08-11 16:26:20 +00001090 * Specify Session Timer settings, see #pjsip_timer_setting.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001091 * Note that this setting can be further customized in account
1092 * configuration (#pjsua_acc_config).
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001093 */
Nanang Izzuddin65add622009-08-11 16:26:20 +00001094 pjsip_timer_setting timer_setting;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001095
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001096 /**
1097 * Number of credentials in the credential array.
1098 */
1099 unsigned cred_count;
1100
1101 /**
1102 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +00001103 * and can be used to authenticate against outbound proxies. If the
1104 * credential is specific to the account, then application should set
1105 * the credential in the pjsua_acc_config rather than the credential
1106 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001107 */
1108 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1109
1110 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001111 * Application callback to receive various event notifications from
1112 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001113 */
1114 pjsua_callback cb;
1115
Benny Prijono56315612006-07-18 14:39:40 +00001116 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001117 * Optional user agent string (default empty). If it's empty, no
1118 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +00001119 */
1120 pj_str_t user_agent;
1121
Benny Prijonod8179652008-01-23 20:39:07 +00001122#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
1123 /**
1124 * Specify default value of secure media transport usage.
1125 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
1126 * PJMEDIA_SRTP_MANDATORY.
1127 *
1128 * Note that this setting can be further customized in account
1129 * configuration (#pjsua_acc_config).
1130 *
1131 * Default: #PJSUA_DEFAULT_USE_SRTP
1132 */
1133 pjmedia_srtp_use use_srtp;
1134
1135 /**
1136 * Specify whether SRTP requires secure signaling to be used. This option
1137 * is only used when \a use_srtp option above is non-zero.
1138 *
1139 * Valid values are:
1140 * 0: SRTP does not require secure signaling
1141 * 1: SRTP requires secure transport such as TLS
1142 * 2: SRTP requires secure end-to-end transport (SIPS)
1143 *
1144 * Note that this setting can be further customized in account
1145 * configuration (#pjsua_acc_config).
1146 *
1147 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
1148 */
1149 int srtp_secure_signaling;
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00001150
1151 /**
1152 * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose
1153 * duplicated media in SDP offer, i.e: unsecured and secured version.
1154 * Otherwise, the SDP media will be composed as unsecured media but
1155 * with SDP "crypto" attribute.
1156 *
1157 * Default: PJ_FALSE
1158 */
1159 pj_bool_t srtp_optional_dup_offer;
Benny Prijonod8179652008-01-23 20:39:07 +00001160#endif
1161
Benny Prijono3c5e28b2008-09-24 10:10:15 +00001162 /**
1163 * Disconnect other call legs when more than one 2xx responses for
1164 * outgoing INVITE are received due to forking. Currently the library
1165 * is not able to handle simultaneous forked media, so disconnecting
1166 * the other call legs is necessary.
1167 *
1168 * With this setting enabled, the library will handle only one of the
1169 * connected call leg, and the other connected call legs will be
1170 * disconnected.
1171 *
1172 * Default: PJ_TRUE (only disable this setting for testing purposes).
1173 */
1174 pj_bool_t hangup_forked_call;
1175
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001176} pjsua_config;
1177
1178
1179/**
1180 * Use this function to initialize pjsua config.
1181 *
1182 * @param cfg pjsua config to be initialized.
1183 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001184PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001185
1186
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001187/** The implementation has been moved to sip_auth.h */
Benny Prijono7977f9f2007-10-10 11:37:56 +00001188#define pjsip_cred_dup pjsip_cred_info_dup
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001189
1190
1191/**
1192 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001193 *
1194 * @param pool The pool to get memory from.
1195 * @param dst Destination config.
1196 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001197 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001198PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1199 pjsua_config *dst,
1200 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001201
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001202
1203/**
1204 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001205 * outgoing SIP message. It can (optionally) be specified for example
1206 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1207 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1208 *
1209 * Application MUST call #pjsua_msg_data_init() to initialize this
1210 * structure before setting its values.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001211 */
Benny Prijono63fba012008-07-17 14:19:10 +00001212struct pjsua_msg_data
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001213{
1214 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001215 * Additional message headers as linked list. Application can add
1216 * headers to the list by creating the header, either from the heap/pool
1217 * or from temporary local variable, and add the header using
1218 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001219 */
1220 pjsip_hdr hdr_list;
1221
1222 /**
1223 * MIME type of optional message body.
1224 */
1225 pj_str_t content_type;
1226
1227 /**
Benny Prijono1c1d7342010-08-01 09:48:51 +00001228 * Optional message body to be added to the message, only when the
1229 * message doesn't have a body.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001230 */
1231 pj_str_t msg_body;
1232
Benny Prijono1c1d7342010-08-01 09:48:51 +00001233 /**
1234 * Content type of the multipart body. If application wants to send
1235 * multipart message bodies, it puts the parts in \a parts and set
1236 * the content type in \a multipart_ctype. If the message already
1237 * contains a body, the body will be added to the multipart bodies.
1238 */
1239 pjsip_media_type multipart_ctype;
1240
1241 /**
1242 * List of multipart parts. If application wants to send multipart
1243 * message bodies, it puts the parts in \a parts and set the content
1244 * type in \a multipart_ctype. If the message already contains a body,
1245 * the body will be added to the multipart bodies.
1246 */
1247 pjsip_multipart_part multipart_parts;
Benny Prijono63fba012008-07-17 14:19:10 +00001248};
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001249
1250
1251/**
1252 * Initialize message data.
1253 *
1254 * @param msg_data Message data to be initialized.
1255 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001256PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001257
Benny Prijono268ca612006-02-07 12:34:11 +00001258
1259/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001260 * Instantiate pjsua application. Application must call this function before
1261 * calling any other functions, to make sure that the underlying libraries
1262 * are properly initialized. Once this function has returned success,
1263 * application must call pjsua_destroy() before quitting.
1264 *
1265 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00001266 */
1267PJ_DECL(pj_status_t) pjsua_create(void);
1268
1269
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001270/** Forward declaration */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001271typedef struct pjsua_media_config pjsua_media_config;
1272
1273
Benny Prijonodc39fe82006-05-26 12:17:46 +00001274/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001275 * Initialize pjsua with the specified settings. All the settings are
1276 * optional, and the default values will be used when the config is not
1277 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001278 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001279 * Note that #pjsua_create() MUST be called before calling this function.
1280 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001281 * @param ua_cfg User agent configuration.
1282 * @param log_cfg Optional logging configuration.
1283 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001284 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001285 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001286 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001287PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1288 const pjsua_logging_config *log_cfg,
1289 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001290
1291
1292/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001293 * Application is recommended to call this function after all initialization
1294 * is done, so that the library can do additional checking set up
1295 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001296 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001297 * Application may call this function anytime after #pjsua_init().
1298 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001299 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoccf95622006-02-07 18:48:01 +00001300 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001301PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001302
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001303
Benny Prijonoccf95622006-02-07 18:48:01 +00001304/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001305 * Destroy pjsua. Application is recommended to perform graceful shutdown
1306 * before calling this function (such as unregister the account from the SIP
1307 * server, terminate presense subscription, and hangup active calls), however,
1308 * this function will do all of these if it finds there are active sessions
1309 * that need to be terminated. This function will approximately block for
1310 * one second to wait for replies from remote.
1311 *
1312 * Application.may safely call this function more than once if it doesn't
1313 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001314 *
1315 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001316 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001317PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001318
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001319
Benny Prijono9fc735d2006-05-28 14:58:12 +00001320/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001321 * Poll pjsua for events, and if necessary block the caller thread for
1322 * the specified maximum interval (in miliseconds).
1323 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001324 * Application doesn't normally need to call this function if it has
1325 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1326 * because polling then will be done by these worker threads instead.
1327 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001328 * @param msec_timeout Maximum time to wait, in miliseconds.
1329 *
1330 * @return The number of events that have been handled during the
1331 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001332 * can retrieve the error as (status = -return_value).
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001333 */
1334PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1335
1336
1337/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001338 * Create memory pool to be used by the application. Once application
1339 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001340 *
1341 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001342 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001343 * @param increment Increment size.
1344 *
1345 * @return The pool, or NULL when there's no memory.
1346 */
1347PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1348 pj_size_t increment);
1349
1350
1351/**
1352 * Application can call this function at any time (after pjsua_create(), of
1353 * course) to change logging settings.
1354 *
1355 * @param c Logging configuration.
1356 *
1357 * @return PJ_SUCCESS on success, or the appropriate error code.
1358 */
1359PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1360
1361
1362/**
1363 * Internal function to get SIP endpoint instance of pjsua, which is
1364 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001365 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001366 *
1367 * @return SIP endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001368 */
1369PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1370
1371/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001372 * Internal function to get media endpoint instance.
1373 * Only valid after #pjsua_init() is called.
1374 *
1375 * @return Media endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001376 */
1377PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1378
Benny Prijono97b87172006-08-24 14:25:14 +00001379/**
1380 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001381 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001382 *
1383 * @return Pool factory currently used by PJSUA.
1384 */
1385PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1386
1387
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001388
1389/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001390 * Utilities.
1391 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001392 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001393
1394/**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001395 * This structure is used to represent the result of the STUN server
1396 * resolution and testing, the #pjsua_resolve_stun_servers() function.
1397 * This structure will be passed in #pj_stun_resolve_cb callback.
1398 */
1399typedef struct pj_stun_resolve_result
1400{
1401 /**
1402 * Arbitrary data that was passed to #pjsua_resolve_stun_servers()
1403 * function.
1404 */
1405 void *token;
1406
1407 /**
1408 * This will contain PJ_SUCCESS if at least one usable STUN server
1409 * is found, otherwise it will contain the last error code during
1410 * the operation.
1411 */
1412 pj_status_t status;
1413
1414 /**
1415 * The server name that yields successful result. This will only
1416 * contain value if status is successful.
1417 */
1418 pj_str_t name;
1419
1420 /**
1421 * The server IP address. This will only contain value if status
1422 * is successful.
1423 */
1424 pj_sockaddr addr;
1425
1426} pj_stun_resolve_result;
1427
1428
1429/**
1430 * Typedef of callback to be registered to #pjsua_resolve_stun_servers().
1431 */
1432typedef void (*pj_stun_resolve_cb)(const pj_stun_resolve_result *result);
1433
1434/**
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001435 * This is a utility function to detect NAT type in front of this
1436 * endpoint. Once invoked successfully, this function will complete
Benny Prijono6ba8c542007-10-16 01:34:14 +00001437 * asynchronously and report the result in \a on_nat_detect() callback
1438 * of pjsua_callback.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001439 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001440 * After NAT has been detected and the callback is called, application can
1441 * get the detected NAT type by calling #pjsua_get_nat_type(). Application
1442 * can also perform NAT detection by calling #pjsua_detect_nat_type()
1443 * again at later time.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001444 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001445 * Note that STUN must be enabled to run this function successfully.
1446 *
1447 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001448 */
Benny Prijono6ba8c542007-10-16 01:34:14 +00001449PJ_DECL(pj_status_t) pjsua_detect_nat_type(void);
1450
1451
1452/**
1453 * Get the NAT type as detected by #pjsua_detect_nat_type() function.
1454 * This function will only return useful NAT type after #pjsua_detect_nat_type()
1455 * has completed successfully and \a on_nat_detect() callback has been called.
1456 *
1457 * @param type NAT type.
1458 *
1459 * @return When detection is in progress, this function will
1460 * return PJ_EPENDING and \a type will be set to
1461 * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been
1462 * detected successfully, this function will return
1463 * PJ_SUCCESS and \a type will be set to the correct
1464 * value. Other return values indicate error and
1465 * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN.
Benny Prijono91a6a172007-10-31 08:59:29 +00001466 *
1467 * @see pjsua_call_get_rem_nat_type()
Benny Prijono6ba8c542007-10-16 01:34:14 +00001468 */
1469PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type);
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001470
1471
1472/**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001473 * Auxiliary function to resolve and contact each of the STUN server
1474 * entries (sequentially) to find which is usable. The #pjsua_init() must
1475 * have been called before calling this function.
1476 *
1477 * @param count Number of STUN server entries to try.
1478 * @param srv Array of STUN server entries to try. Please see
1479 * the \a stun_srv field in the #pjsua_config
1480 * documentation about the format of this entry.
1481 * @param wait Specify non-zero to make the function block until
1482 * it gets the result. In this case, the function
1483 * will block while the resolution is being done,
1484 * and the callback will be called before this function
1485 * returns.
1486 * @param token Arbitrary token to be passed back to application
1487 * in the callback.
1488 * @param cb Callback to be called to notify the result of
1489 * the function.
1490 *
1491 * @return If \a wait parameter is non-zero, this will return
1492 * PJ_SUCCESS if one usable STUN server is found.
1493 * Otherwise it will always return PJ_SUCCESS, and
1494 * application will be notified about the result in
1495 * the callback.
1496 */
1497PJ_DECL(pj_status_t) pjsua_resolve_stun_servers(unsigned count,
1498 pj_str_t srv[],
1499 pj_bool_t wait,
1500 void *token,
1501 pj_stun_resolve_cb cb);
1502
1503/**
1504 * Cancel pending STUN resolution which match the specified token.
1505 *
1506 * @param token The token to match. This token was given to
1507 * #pjsua_resolve_stun_servers()
1508 * @param notify_cb Boolean to control whether the callback should
1509 * be called for cancelled resolutions. When the
1510 * callback is called, the status in the result
1511 * will be set as PJ_ECANCELLED.
1512 *
1513 * @return PJ_SUCCESS if there is at least one pending STUN
1514 * resolution cancelled, or PJ_ENOTFOUND if there is
1515 * no matching one, or other error.
1516 */
1517PJ_DECL(pj_status_t) pjsua_cancel_stun_resolution(void *token,
1518 pj_bool_t notify_cb);
1519
1520
1521/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001522 * This is a utility function to verify that valid SIP url is given. If the
1523 * URL is valid, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001524 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001525 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001526 *
1527 * @return PJ_SUCCESS on success, or the appropriate error code.
1528 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001529PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001530
1531
1532/**
Benny Prijono73bb7232009-10-20 13:56:26 +00001533 * Schedule a timer entry. Note that the timer callback may be executed
1534 * by different thread, depending on whether worker thread is enabled or
1535 * not.
1536 *
1537 * @param entry Timer heap entry.
1538 * @param delay The interval to expire.
1539 *
1540 * @return PJ_SUCCESS on success, or the appropriate error code.
1541 *
1542 * @see pjsip_endpt_schedule_timer()
1543 */
1544PJ_DECL(pj_status_t) pjsua_schedule_timer(pj_timer_entry *entry,
1545 const pj_time_val *delay);
1546
1547
1548/**
1549 * Cancel the previously scheduled timer.
1550 *
1551 * @param entry Timer heap entry.
1552 *
1553 * @see pjsip_endpt_cancel_timer()
1554 */
1555PJ_DECL(void) pjsua_cancel_timer(pj_timer_entry *entry);
1556
1557
1558/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001559 * This is a utility function to display error message for the specified
1560 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001561 *
1562 * @param sender The log sender field.
1563 * @param title Message title for the error.
1564 * @param status Status code.
1565 */
1566PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1567 pj_status_t status);
1568
1569
Benny Prijonoda9785b2007-04-02 20:43:06 +00001570/**
1571 * This is a utility function to dump the stack states to log, using
1572 * verbosity level 3.
1573 *
1574 * @param detail Will print detailed output (such as list of
1575 * SIP transactions) when non-zero.
1576 */
1577PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001578
1579/**
1580 * @}
1581 */
1582
1583
1584
1585/*****************************************************************************
1586 * TRANSPORT API
1587 */
1588
1589/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001590 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001591 * @ingroup PJSUA_LIB
1592 * @brief API for managing SIP transports
1593 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001594 *
1595 * PJSUA-API supports creating multiple transport instances, for example UDP,
1596 * TCP, and TLS transport. SIP transport must be created before adding an
1597 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001598 */
1599
1600
Benny Prijonoe6ead542007-01-31 20:53:31 +00001601/** SIP transport identification.
1602 */
Benny Prijono312aff92006-06-17 04:08:30 +00001603typedef int pjsua_transport_id;
1604
1605
1606/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001607 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001608 * and media. Before setting some values to this structure, application
1609 * MUST call #pjsua_transport_config_default() to initialize its
1610 * values with default settings.
Benny Prijono312aff92006-06-17 04:08:30 +00001611 */
1612typedef struct pjsua_transport_config
1613{
1614 /**
1615 * UDP port number to bind locally. This setting MUST be specified
1616 * even when default port is desired. If the value is zero, the
1617 * transport will be bound to any available port, and application
1618 * can query the port by querying the transport info.
1619 */
1620 unsigned port;
1621
1622 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001623 * Optional address to advertise as the address of this transport.
1624 * Application can specify any address or hostname for this field,
1625 * for example it can point to one of the interface address in the
1626 * system, or it can point to the public address of a NAT router
1627 * where port mappings have been configured for the application.
1628 *
1629 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001630 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001631 pj_str_t public_addr;
1632
1633 /**
1634 * Optional address where the socket should be bound to. This option
1635 * SHOULD only be used to selectively bind the socket to particular
1636 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1637 * published address of a transport (the public_addr field should be
1638 * used for that purpose).
1639 *
1640 * Note that unlike public_addr field, the address (or hostname) here
1641 * MUST correspond to the actual interface address in the host, since
1642 * this address will be specified as bind() argument.
1643 */
1644 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001645
1646 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001647 * This specifies TLS settings for TLS transport. It is only be used
1648 * when this transport config is being used to create a SIP TLS
1649 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001650 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001651 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001652
Benny Prijono4d79b0f2009-10-25 09:02:07 +00001653 /**
1654 * QoS traffic type to be set on this transport. When application wants
1655 * to apply QoS tagging to the transport, it's preferable to set this
1656 * field rather than \a qos_param fields since this is more portable.
1657 *
1658 * Default is QoS not set.
1659 */
1660 pj_qos_type qos_type;
1661
1662 /**
1663 * Set the low level QoS parameters to the transport. This is a lower
1664 * level operation than setting the \a qos_type field and may not be
1665 * supported on all platforms.
1666 *
1667 * Default is QoS not set.
1668 */
1669 pj_qos_params qos_params;
1670
Benny Prijono312aff92006-06-17 04:08:30 +00001671} pjsua_transport_config;
1672
1673
1674/**
1675 * Call this function to initialize UDP config with default values.
1676 *
1677 * @param cfg The UDP config to be initialized.
1678 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001679PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001680
1681
1682/**
Benny Prijono312aff92006-06-17 04:08:30 +00001683 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001684 *
1685 * @param pool The pool.
1686 * @param dst The destination config.
1687 * @param src The source config.
Benny Prijono312aff92006-06-17 04:08:30 +00001688 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001689PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1690 pjsua_transport_config *dst,
1691 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001692
1693
1694/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001695 * This structure describes transport information returned by
1696 * #pjsua_transport_get_info() function.
Benny Prijono312aff92006-06-17 04:08:30 +00001697 */
1698typedef struct pjsua_transport_info
1699{
1700 /**
1701 * PJSUA transport identification.
1702 */
1703 pjsua_transport_id id;
1704
1705 /**
1706 * Transport type.
1707 */
1708 pjsip_transport_type_e type;
1709
1710 /**
1711 * Transport type name.
1712 */
1713 pj_str_t type_name;
1714
1715 /**
1716 * Transport string info/description.
1717 */
1718 pj_str_t info;
1719
1720 /**
1721 * Transport flag (see ##pjsip_transport_flags_e).
1722 */
1723 unsigned flag;
1724
1725 /**
1726 * Local address length.
1727 */
1728 unsigned addr_len;
1729
1730 /**
1731 * Local/bound address.
1732 */
1733 pj_sockaddr local_addr;
1734
1735 /**
1736 * Published address (or transport address name).
1737 */
1738 pjsip_host_port local_name;
1739
1740 /**
1741 * Current number of objects currently referencing this transport.
1742 */
1743 unsigned usage_count;
1744
1745
1746} pjsua_transport_info;
1747
1748
1749/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001750 * Create and start a new SIP transport according to the specified
1751 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001752 *
1753 * @param type Transport type.
1754 * @param cfg Transport configuration.
1755 * @param p_id Optional pointer to receive transport ID.
1756 *
1757 * @return PJ_SUCCESS on success, or the appropriate error code.
1758 */
1759PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1760 const pjsua_transport_config *cfg,
1761 pjsua_transport_id *p_id);
1762
1763/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001764 * Register transport that has been created by application. This function
1765 * is useful if application wants to implement custom SIP transport and use
1766 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001767 *
1768 * @param tp Transport instance.
1769 * @param p_id Optional pointer to receive transport ID.
1770 *
1771 * @return PJ_SUCCESS on success, or the appropriate error code.
1772 */
1773PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1774 pjsua_transport_id *p_id);
1775
1776
1777/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001778 * Enumerate all transports currently created in the system. This function
1779 * will return all transport IDs, and application may then call
1780 * #pjsua_transport_get_info() function to retrieve detailed information
1781 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001782 *
1783 * @param id Array to receive transport ids.
1784 * @param count In input, specifies the maximum number of elements.
1785 * On return, it contains the actual number of elements.
1786 *
1787 * @return PJ_SUCCESS on success, or the appropriate error code.
1788 */
1789PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1790 unsigned *count );
1791
1792
1793/**
1794 * Get information about transports.
1795 *
1796 * @param id Transport ID.
1797 * @param info Pointer to receive transport info.
1798 *
1799 * @return PJ_SUCCESS on success, or the appropriate error code.
1800 */
1801PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1802 pjsua_transport_info *info);
1803
1804
1805/**
1806 * Disable a transport or re-enable it. By default transport is always
1807 * enabled after it is created. Disabling a transport does not necessarily
1808 * close the socket, it will only discard incoming messages and prevent
1809 * the transport from being used to send outgoing messages.
1810 *
1811 * @param id Transport ID.
1812 * @param enabled Non-zero to enable, zero to disable.
1813 *
1814 * @return PJ_SUCCESS on success, or the appropriate error code.
1815 */
1816PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1817 pj_bool_t enabled);
1818
1819
1820/**
1821 * Close the transport. If transport is forcefully closed, it will be
1822 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00001823 * transport may not terminate properly (it may even crash). Otherwise,
1824 * the system will wait until all transactions are closed while preventing
1825 * new users from using the transport, and will close the transport when
1826 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001827 *
1828 * @param id Transport ID.
1829 * @param force Non-zero to immediately close the transport. This
1830 * is not recommended!
1831 *
1832 * @return PJ_SUCCESS on success, or the appropriate error code.
1833 */
1834PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1835 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001836
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001837/**
Benny Prijono312aff92006-06-17 04:08:30 +00001838 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001839 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001840
1841
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001842
1843
1844/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001845 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001846 */
1847
Benny Prijono312aff92006-06-17 04:08:30 +00001848
1849/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001850 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001851 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001852 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001853 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001854 *
Benny Prijono312aff92006-06-17 04:08:30 +00001855 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001856 * using the application. In SIP terms, the identity is used as the <b>From</b>
1857 * header in outgoing requests.
1858 *
1859 * PJSUA-API supports creating and managing multiple accounts. The maximum
1860 * number of accounts is limited by a compile time constant
1861 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001862 *
1863 * Account may or may not have client registration associated with it.
1864 * An account is also associated with <b>route set</b> and some <b>authentication
1865 * credentials</b>, which are used when sending SIP request messages using the
1866 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00001867 * will be reported to remote peer when they subscribe to the account's
1868 * presence, or which is published to a presence server if presence
1869 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00001870 *
1871 * At least one account MUST be created in the application. If no user
1872 * association is required, application can create a userless account by
1873 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00001874 * instead of a particular user, and it correspond with a particular
1875 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00001876 *
1877 * Also one account must be set as the <b>default account</b>, which is used as
1878 * the account to use when PJSUA fails to match a request with any other
1879 * accounts.
1880 *
1881 * When sending outgoing SIP requests (such as making calls or sending
1882 * instant messages), normally PJSUA requires the application to specify
1883 * which account to use for the request. If no account is specified,
1884 * PJSUA may be able to select the account by matching the destination
1885 * domain name, and fall back to default account when no match is found.
1886 */
1887
1888/**
1889 * Maximum accounts.
1890 */
1891#ifndef PJSUA_MAX_ACC
1892# define PJSUA_MAX_ACC 8
1893#endif
1894
1895
1896/**
1897 * Default registration interval.
1898 */
1899#ifndef PJSUA_REG_INTERVAL
Benny Prijonobddef2c2007-10-31 13:28:08 +00001900# define PJSUA_REG_INTERVAL 300
Benny Prijono312aff92006-06-17 04:08:30 +00001901#endif
1902
1903
1904/**
Benny Prijono384dab42009-10-14 01:58:04 +00001905 * Default maximum time to wait for account unregistration transactions to
1906 * complete during library shutdown sequence.
1907 *
1908 * Default: 4000 (4 seconds)
1909 */
1910#ifndef PJSUA_UNREG_TIMEOUT
1911# define PJSUA_UNREG_TIMEOUT 4000
1912#endif
1913
1914
1915/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001916 * Default PUBLISH expiration
1917 */
1918#ifndef PJSUA_PUBLISH_EXPIRATION
Benny Prijono53984d12009-04-28 22:19:49 +00001919# define PJSUA_PUBLISH_EXPIRATION PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001920#endif
1921
1922
1923/**
Benny Prijono093d3022006-09-24 00:07:11 +00001924 * Default account priority.
1925 */
1926#ifndef PJSUA_DEFAULT_ACC_PRIORITY
1927# define PJSUA_DEFAULT_ACC_PRIORITY 0
1928#endif
1929
1930
1931/**
Benny Prijono8058a622007-06-08 04:37:05 +00001932 * This macro specifies the URI scheme to use in Contact header
1933 * when secure transport such as TLS is used. Application can specify
1934 * either "sip" or "sips".
1935 */
1936#ifndef PJSUA_SECURE_SCHEME
Benny Prijono4c82c1e2008-10-16 08:14:51 +00001937# define PJSUA_SECURE_SCHEME "sip"
Benny Prijono8058a622007-06-08 04:37:05 +00001938#endif
1939
1940
1941/**
Benny Prijono534a9ba2009-10-13 14:01:59 +00001942 * Maximum time to wait for unpublication transaction(s) to complete
1943 * during shutdown process, before sending unregistration. The library
1944 * tries to wait for the unpublication (un-PUBLISH) to complete before
1945 * sending REGISTER request to unregister the account, during library
1946 * shutdown process. If the value is set too short, it is possible that
1947 * the unregistration is sent before unpublication completes, causing
1948 * unpublication request to fail.
1949 *
1950 * Default: 2000 (2 seconds)
1951 */
1952#ifndef PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
1953# define PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC 2000
1954#endif
1955
1956
1957/**
Nanang Izzuddin36dd5b62010-03-30 11:13:59 +00001958 * Default auto retry re-registration interval, in seconds. Set to 0
1959 * to disable this. Application can set the timer on per account basis
1960 * by setting the pjsua_acc_config.reg_retry_interval field instead.
1961 *
1962 * Default: 300 (5 minutes)
1963 */
1964#ifndef PJSUA_REG_RETRY_INTERVAL
1965# define PJSUA_REG_RETRY_INTERVAL 300
1966#endif
1967
1968
1969/**
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00001970 * This macro specifies the default value for \a contact_rewrite_method
1971 * field in pjsua_acc_config. I specifies how Contact update will be
1972 * done with the registration, if \a allow_contact_rewrite is enabled in
1973 * the account config.
1974 *
1975 * If set to 1, the Contact update will be done by sending unregistration
1976 * to the currently registered Contact, while simultaneously sending new
1977 * registration (with different Call-ID) for the updated Contact.
1978 *
1979 * If set to 2, the Contact update will be done in a single, current
1980 * registration session, by removing the current binding (by setting its
1981 * Contact's expires parameter to zero) and adding a new Contact binding,
1982 * all done in a single request.
1983 *
1984 * Value 1 is the legacy behavior.
1985 *
1986 * Default value: 2
1987 */
1988#ifndef PJSUA_CONTACT_REWRITE_METHOD
1989# define PJSUA_CONTACT_REWRITE_METHOD 2
1990#endif
1991
1992
1993/**
Benny Prijono29c8ca32010-06-22 06:02:13 +00001994 * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that
1995 * the global outbound proxy list should be added to the REGISTER request.
1996 */
1997#define PJSUA_REG_USE_OUTBOUND_PROXY 1
1998
1999
2000/**
2001 * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that
2002 * the account proxy list should be added to the REGISTER request.
2003 */
2004#define PJSUA_REG_USE_ACC_PROXY 2
2005
2006
2007/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002008 * This structure describes account configuration to be specified when
2009 * adding a new account with #pjsua_acc_add(). Application MUST initialize
2010 * this structure first by calling #pjsua_acc_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00002011 */
2012typedef struct pjsua_acc_config
2013{
Benny Prijono093d3022006-09-24 00:07:11 +00002014 /**
Benny Prijono705e7842008-07-21 18:12:51 +00002015 * Arbitrary user data to be associated with the newly created account.
2016 * Application may set this later with #pjsua_acc_set_user_data() and
2017 * retrieve it with #pjsua_acc_get_user_data().
2018 */
2019 void *user_data;
2020
2021 /**
Benny Prijono093d3022006-09-24 00:07:11 +00002022 * Account priority, which is used to control the order of matching
2023 * incoming/outgoing requests. The higher the number means the higher
2024 * the priority is, and the account will be matched first.
2025 */
2026 int priority;
2027
Benny Prijono312aff92006-06-17 04:08:30 +00002028 /**
2029 * The full SIP URL for the account. The value can take name address or
2030 * URL format, and will look something like "sip:account@serviceprovider".
2031 *
2032 * This field is mandatory.
2033 */
2034 pj_str_t id;
2035
2036 /**
2037 * This is the URL to be put in the request URI for the registration,
2038 * and will look something like "sip:serviceprovider".
2039 *
2040 * This field should be specified if registration is desired. If the
2041 * value is empty, no account registration will be performed.
2042 */
2043 pj_str_t reg_uri;
2044
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002045 /**
Benny Prijonofe1bd342009-11-20 23:33:07 +00002046 * Subscribe to message waiting indication events (RFC 3842).
2047 *
2048 * See also \a enable_unsolicited_mwi field on #pjsua_config.
Benny Prijono4dd961b2009-10-26 11:21:37 +00002049 *
2050 * Default: no
2051 */
2052 pj_bool_t mwi_enabled;
2053
2054 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002055 * If this flag is set, the presence information of this account will
2056 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono48ab2b72007-11-08 09:24:30 +00002057 *
2058 * Default: PJ_FALSE
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002059 */
2060 pj_bool_t publish_enabled;
2061
Benny Prijonofe04fb52007-08-24 08:28:52 +00002062 /**
Benny Prijonofe50c9e2009-10-12 07:44:14 +00002063 * Event publication options.
2064 */
2065 pjsip_publishc_opt publish_opt;
2066
2067 /**
Benny Prijono534a9ba2009-10-13 14:01:59 +00002068 * Maximum time to wait for unpublication transaction(s) to complete
2069 * during shutdown process, before sending unregistration. The library
2070 * tries to wait for the unpublication (un-PUBLISH) to complete before
2071 * sending REGISTER request to unregister the account, during library
2072 * shutdown process. If the value is set too short, it is possible that
2073 * the unregistration is sent before unpublication completes, causing
2074 * unpublication request to fail.
2075 *
2076 * Default: PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
2077 */
2078 unsigned unpublish_max_wait_time_msec;
2079
2080 /**
Benny Prijono48ab2b72007-11-08 09:24:30 +00002081 * Authentication preference.
2082 */
2083 pjsip_auth_clt_pref auth_pref;
2084
2085 /**
Benny Prijonofe04fb52007-08-24 08:28:52 +00002086 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
2087 * is not specified, a random string will be used.
2088 */
2089 pj_str_t pidf_tuple_id;
2090
Benny Prijono312aff92006-06-17 04:08:30 +00002091 /**
2092 * Optional URI to be put as Contact for this account. It is recommended
2093 * that this field is left empty, so that the value will be calculated
2094 * automatically based on the transport address.
2095 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00002096 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00002097
2098 /**
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00002099 * Additional parameters that will be appended in the Contact header
Benny Prijono30fe4852008-12-10 16:54:16 +00002100 * for this account. This will affect the Contact header in all SIP
2101 * messages sent on behalf of this account, including but not limited to
2102 * REGISTER, INVITE, and SUBCRIBE requests or responses.
2103 *
2104 * The parameters should be preceeded by semicolon, and all strings must
2105 * be properly escaped. Example:
2106 * ";my-param=X;another-param=Hi%20there"
2107 */
2108 pj_str_t contact_params;
2109
2110 /**
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00002111 * Additional URI parameters that will be appended in the Contact URI
2112 * for this account. This will affect the Contact URI in all SIP
2113 * messages sent on behalf of this account, including but not limited to
2114 * REGISTER, INVITE, and SUBCRIBE requests or responses.
2115 *
2116 * The parameters should be preceeded by semicolon, and all strings must
2117 * be properly escaped. Example:
2118 * ";my-param=X;another-param=Hi%20there"
2119 */
2120 pj_str_t contact_uri_params;
2121
2122 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00002123 * Specify whether support for reliable provisional response (100rel and
2124 * PRACK) should be required for all sessions of this account.
2125 *
2126 * Default: PJ_FALSE
2127 */
2128 pj_bool_t require_100rel;
2129
2130 /**
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002131 * Specify the usage of Session Timers for all sessions. See the
2132 * #pjsua_sip_timer_use for possible values.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002133 *
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002134 * Default: PJSUA_SIP_TIMER_OPTIONAL
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002135 */
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002136 pjsua_sip_timer_use use_timer;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002137
2138 /**
Nanang Izzuddin65add622009-08-11 16:26:20 +00002139 * Specify Session Timer settings, see #pjsip_timer_setting.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002140 */
Nanang Izzuddin65add622009-08-11 16:26:20 +00002141 pjsip_timer_setting timer_setting;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002142
2143 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002144 * Number of proxies in the proxy array below.
2145 */
2146 unsigned proxy_cnt;
2147
2148 /**
2149 * Optional URI of the proxies to be visited for all outgoing requests
2150 * that are using this account (REGISTER, INVITE, etc). Application need
2151 * to specify these proxies if the service provider requires that requests
2152 * destined towards its network should go through certain proxies first
2153 * (for example, border controllers).
2154 *
2155 * These proxies will be put in the route set for this account, with
2156 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00002157 * first). If global outbound proxies are configured in pjsua_config,
2158 * then these account proxies will be placed after the global outbound
2159 * proxies in the routeset.
Benny Prijono312aff92006-06-17 04:08:30 +00002160 */
2161 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
2162
2163 /**
2164 * Optional interval for registration, in seconds. If the value is zero,
Benny Prijonobddef2c2007-10-31 13:28:08 +00002165 * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
Benny Prijono312aff92006-06-17 04:08:30 +00002166 */
2167 unsigned reg_timeout;
2168
Benny Prijono384dab42009-10-14 01:58:04 +00002169 /**
2170 * Specify the maximum time to wait for unregistration requests to
2171 * complete during library shutdown sequence.
2172 *
2173 * Default: PJSUA_UNREG_TIMEOUT
2174 */
2175 unsigned unreg_timeout;
2176
Benny Prijono312aff92006-06-17 04:08:30 +00002177 /**
2178 * Number of credentials in the credential array.
2179 */
2180 unsigned cred_count;
2181
2182 /**
2183 * Array of credentials. If registration is desired, normally there should
2184 * be at least one credential specified, to successfully authenticate
2185 * against the service provider. More credentials can be specified, for
2186 * example when the requests are expected to be challenged by the
2187 * proxies in the route set.
2188 */
2189 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
2190
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002191 /**
2192 * Optionally bind this account to specific transport. This normally is
2193 * not a good idea, as account should be able to send requests using
2194 * any available transports according to the destination. But some
2195 * application may want to have explicit control over the transport to
2196 * use, so in that case it can set this field.
2197 *
2198 * Default: -1 (PJSUA_INVALID_ID)
2199 *
2200 * @see pjsua_acc_set_transport()
2201 */
2202 pjsua_transport_id transport_id;
2203
Benny Prijono15b02302007-09-27 14:07:07 +00002204 /**
Benny Prijonocca2e432010-02-25 09:33:18 +00002205 * This option is used to update the transport address and the Contact
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002206 * header of REGISTER request. When this option is enabled, the library
2207 * will keep track of the public IP address from the response of REGISTER
2208 * request. Once it detects that the address has changed, it will
2209 * unregister current Contact, update the Contact with transport address
2210 * learned from Via header, and register a new Contact to the registrar.
2211 * This will also update the public name of UDP transport if STUN is
Benny Prijonocca2e432010-02-25 09:33:18 +00002212 * configured.
Benny Prijono15b02302007-09-27 14:07:07 +00002213 *
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00002214 * See also contact_rewrite_method field.
2215 *
Benny Prijono15b02302007-09-27 14:07:07 +00002216 * Default: 1 (yes)
2217 */
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002218 pj_bool_t allow_contact_rewrite;
Benny Prijono15b02302007-09-27 14:07:07 +00002219
Benny Prijonobddef2c2007-10-31 13:28:08 +00002220 /**
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00002221 * Specify how Contact update will be done with the registration, if
2222 * \a allow_contact_rewrite is enabled.
2223 *
2224 * If set to 1, the Contact update will be done by sending unregistration
2225 * to the currently registered Contact, while simultaneously sending new
2226 * registration (with different Call-ID) for the updated Contact.
2227 *
2228 * If set to 2, the Contact update will be done in a single, current
2229 * registration session, by removing the current binding (by setting its
2230 * Contact's expires parameter to zero) and adding a new Contact binding,
2231 * all done in a single request.
2232 *
2233 * Value 1 is the legacy behavior.
2234 *
2235 * Default value: PJSUA_CONTACT_REWRITE_METHOD (2)
2236 */
2237 int contact_rewrite_method;
2238
2239 /**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002240 * Set the interval for periodic keep-alive transmission for this account.
2241 * If this value is zero, keep-alive will be disabled for this account.
2242 * The keep-alive transmission will be sent to the registrar's address,
2243 * after successful registration.
2244 *
Benny Prijonobddef2c2007-10-31 13:28:08 +00002245 * Default: 15 (seconds)
2246 */
2247 unsigned ka_interval;
2248
2249 /**
2250 * Specify the data to be transmitted as keep-alive packets.
2251 *
2252 * Default: CR-LF
2253 */
2254 pj_str_t ka_data;
2255
Benny Prijonod8179652008-01-23 20:39:07 +00002256#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
2257 /**
2258 * Specify whether secure media transport should be used for this account.
2259 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
2260 * PJMEDIA_SRTP_MANDATORY.
2261 *
2262 * Default: #PJSUA_DEFAULT_USE_SRTP
2263 */
2264 pjmedia_srtp_use use_srtp;
2265
2266 /**
2267 * Specify whether SRTP requires secure signaling to be used. This option
2268 * is only used when \a use_srtp option above is non-zero.
2269 *
2270 * Valid values are:
2271 * 0: SRTP does not require secure signaling
2272 * 1: SRTP requires secure transport such as TLS
2273 * 2: SRTP requires secure end-to-end transport (SIPS)
2274 *
2275 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
2276 */
2277 int srtp_secure_signaling;
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00002278
2279 /**
2280 * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose
2281 * duplicated media in SDP offer, i.e: unsecured and secured version.
2282 * Otherwise, the SDP media will be composed as unsecured media but
2283 * with SDP "crypto" attribute.
2284 *
2285 * Default: PJ_FALSE
2286 */
2287 pj_bool_t srtp_optional_dup_offer;
Benny Prijonod8179652008-01-23 20:39:07 +00002288#endif
2289
Nanang Izzuddin36dd5b62010-03-30 11:13:59 +00002290 /**
2291 * Specify interval of auto registration retry upon registration failure
2292 * (including caused by transport problem), in second. Set to 0 to
2293 * disable auto re-registration.
2294 *
2295 * Default: #PJSUA_REG_RETRY_INTERVAL
2296 */
2297 unsigned reg_retry_interval;
2298
2299 /**
2300 * Specify whether calls of the configured account should be dropped
2301 * after registration failure and an attempt of re-registration has
2302 * also failed.
2303 *
2304 * Default: PJ_FALSE (disabled)
2305 */
2306 pj_bool_t drop_calls_on_reg_fail;
2307
Benny Prijono29c8ca32010-06-22 06:02:13 +00002308 /**
2309 * Specify how the registration uses the outbound and account proxy
2310 * settings. This controls if and what Route headers will appear in
2311 * the REGISTER request of this account. The value is bitmask combination
2312 * of PJSUA_REG_USE_OUTBOUND_PROXY and PJSUA_REG_USE_ACC_PROXY bits.
2313 * If the value is set to 0, the REGISTER request will not use any proxy
2314 * (i.e. it will not have any Route headers).
2315 *
2316 * Default: 3 (PJSUA_REG_USE_OUTBOUND_PROXY | PJSUA_REG_USE_ACC_PROXY)
2317 */
2318 unsigned reg_use_proxy;
2319
Nanang Izzuddin5e39a2b2010-09-20 06:13:02 +00002320#if defined(PJMEDIA_STREAM_ENABLE_KA) && (PJMEDIA_STREAM_ENABLE_KA != 0)
2321 /**
2322 * Specify whether stream keep-alive and NAT hole punching with
2323 * non-codec-VAD mechanism (see @ref PJMEDIA_STREAM_ENABLE_KA) is enabled
2324 * for this account.
2325 *
2326 * Default: PJ_FALSE (disabled)
2327 */
2328 pj_bool_t use_stream_ka;
2329#endif
2330
Benny Prijono312aff92006-06-17 04:08:30 +00002331} pjsua_acc_config;
2332
2333
2334/**
2335 * Call this function to initialize account config with default values.
2336 *
2337 * @param cfg The account config to be initialized.
2338 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00002339PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002340
2341
2342/**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002343 * Duplicate account config.
2344 *
2345 * @param pool Pool to be used for duplicating the config.
2346 * @param dst Destination configuration.
2347 * @param src Source configuration.
2348 */
2349PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
2350 pjsua_acc_config *dst,
2351 const pjsua_acc_config *src);
2352
2353
2354/**
Benny Prijono312aff92006-06-17 04:08:30 +00002355 * Account info. Application can query account info by calling
2356 * #pjsua_acc_get_info().
2357 */
2358typedef struct pjsua_acc_info
2359{
2360 /**
2361 * The account ID.
2362 */
2363 pjsua_acc_id id;
2364
2365 /**
2366 * Flag to indicate whether this is the default account.
2367 */
2368 pj_bool_t is_default;
2369
2370 /**
2371 * Account URI
2372 */
2373 pj_str_t acc_uri;
2374
2375 /**
2376 * Flag to tell whether this account has registration setting
2377 * (reg_uri is not empty).
2378 */
2379 pj_bool_t has_registration;
2380
2381 /**
2382 * An up to date expiration interval for account registration session.
2383 */
2384 int expires;
2385
2386 /**
2387 * Last registration status code. If status code is zero, the account
2388 * is currently not registered. Any other value indicates the SIP
2389 * status code of the registration.
2390 */
2391 pjsip_status_code status;
2392
2393 /**
Sauw Ming48f6dbf2010-09-07 05:10:25 +00002394 * Last registration error code. When the status field contains a SIP
2395 * status code that indicates a registration failure, last registration
2396 * error code contains the error code that causes the failure. In any
2397 * other case, its value is zero.
2398 */
2399 pj_status_t reg_last_err;
2400
2401 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002402 * String describing the registration status.
2403 */
2404 pj_str_t status_text;
2405
2406 /**
2407 * Presence online status for this account.
2408 */
2409 pj_bool_t online_status;
2410
2411 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00002412 * Presence online status text.
2413 */
2414 pj_str_t online_status_text;
2415
2416 /**
2417 * Extended RPID online status information.
2418 */
2419 pjrpid_element rpid;
2420
2421 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002422 * Buffer that is used internally to store the status text.
2423 */
2424 char buf_[PJ_ERR_MSG_SIZE];
2425
2426} pjsua_acc_info;
2427
2428
2429
2430/**
2431 * Get number of current accounts.
2432 *
2433 * @return Current number of accounts.
2434 */
2435PJ_DECL(unsigned) pjsua_acc_get_count(void);
2436
2437
2438/**
2439 * Check if the specified account ID is valid.
2440 *
2441 * @param acc_id Account ID to check.
2442 *
2443 * @return Non-zero if account ID is valid.
2444 */
2445PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
2446
2447
2448/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00002449 * Set default account to be used when incoming and outgoing
2450 * requests doesn't match any accounts.
2451 *
2452 * @param acc_id The account ID to be used as default.
2453 *
2454 * @return PJ_SUCCESS on success.
2455 */
2456PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2457
2458
2459/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002460 * Get default account to be used when receiving incoming requests (calls),
2461 * when the destination of the incoming call doesn't match any other
2462 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002463 *
2464 * @return The default account ID, or PJSUA_INVALID_ID if no
2465 * default account is configured.
2466 */
2467PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2468
2469
2470/**
Benny Prijono312aff92006-06-17 04:08:30 +00002471 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002472 * #pjsua_init()) before calling this function. If registration is configured
2473 * for this account, this function would also start the SIP registration
2474 * session with the SIP registrar server. This SIP registration session
2475 * will be maintained internally by the library, and application doesn't
2476 * need to do anything to maintain the registration session.
2477 *
Benny Prijono312aff92006-06-17 04:08:30 +00002478 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002479 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002480 * @param is_default If non-zero, this account will be set as the default
2481 * account. The default account will be used when sending
2482 * outgoing requests (e.g. making call) when no account is
2483 * specified, and when receiving incoming requests when the
2484 * request does not match any accounts. It is recommended
2485 * that default account is set to local/LAN account.
2486 * @param p_acc_id Pointer to receive account ID of the new account.
2487 *
2488 * @return PJ_SUCCESS on success, or the appropriate error code.
2489 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002490PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002491 pj_bool_t is_default,
2492 pjsua_acc_id *p_acc_id);
2493
2494
2495/**
2496 * Add a local account. A local account is used to identify local endpoint
2497 * instead of a specific user, and for this reason, a transport ID is needed
2498 * to obtain the local address information.
2499 *
2500 * @param tid Transport ID to generate account address.
2501 * @param is_default If non-zero, this account will be set as the default
2502 * account. The default account will be used when sending
2503 * outgoing requests (e.g. making call) when no account is
2504 * specified, and when receiving incoming requests when the
2505 * request does not match any accounts. It is recommended
2506 * that default account is set to local/LAN account.
2507 * @param p_acc_id Pointer to receive account ID of the new account.
2508 *
2509 * @return PJ_SUCCESS on success, or the appropriate error code.
2510 */
2511PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2512 pj_bool_t is_default,
2513 pjsua_acc_id *p_acc_id);
2514
2515/**
Benny Prijono705e7842008-07-21 18:12:51 +00002516 * Set arbitrary data to be associated with the account.
2517 *
2518 * @param acc_id The account ID.
2519 * @param user_data User/application data.
2520 *
2521 * @return PJ_SUCCESS on success, or the appropriate error code.
2522 */
2523PJ_DECL(pj_status_t) pjsua_acc_set_user_data(pjsua_acc_id acc_id,
2524 void *user_data);
2525
2526
2527/**
2528 * Retrieve arbitrary data associated with the account.
2529 *
2530 * @param acc_id The account ID.
2531 *
2532 * @return The user data. In the case where the account ID is
2533 * not valid, NULL is returned.
2534 */
2535PJ_DECL(void*) pjsua_acc_get_user_data(pjsua_acc_id acc_id);
2536
2537
2538/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002539 * Delete an account. This will unregister the account from the SIP server,
2540 * if necessary, and terminate server side presence subscriptions associated
2541 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002542 *
2543 * @param acc_id Id of the account to be deleted.
2544 *
2545 * @return PJ_SUCCESS on success, or the appropriate error code.
2546 */
2547PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2548
2549
2550/**
2551 * Modify account information.
2552 *
2553 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002554 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002555 *
2556 * @return PJ_SUCCESS on success, or the appropriate error code.
2557 */
2558PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002559 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002560
2561
2562/**
2563 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002564 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002565 * if there are server side presence subscription for this account, and/or
2566 * outgoing PUBLISH if presence publication is enabled for this account.
2567 *
2568 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002569 *
2570 * @param acc_id The account ID.
2571 * @param is_online True of false.
2572 *
2573 * @return PJ_SUCCESS on success, or the appropriate error code.
2574 */
2575PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2576 pj_bool_t is_online);
2577
Benny Prijono4461c7d2007-08-25 13:36:15 +00002578/**
2579 * Modify account's presence status to be advertised to remote/presence
2580 * subscribers. This would trigger the sending of outgoing NOTIFY request
2581 * if there are server side presence subscription for this account, and/or
2582 * outgoing PUBLISH if presence publication is enabled for this account.
2583 *
2584 * @see pjsua_acc_set_online_status()
2585 *
2586 * @param acc_id The account ID.
2587 * @param is_online True of false.
2588 * @param pr Extended information in subset of RPID format
2589 * which allows setting custom presence text.
2590 *
2591 * @return PJ_SUCCESS on success, or the appropriate error code.
2592 */
2593PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2594 pj_bool_t is_online,
2595 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002596
2597/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002598 * Update registration or perform unregistration. If registration is
2599 * configured for this account, then initial SIP REGISTER will be sent
2600 * when the account is added with #pjsua_acc_add(). Application normally
2601 * only need to call this function if it wants to manually update the
2602 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002603 *
2604 * @param acc_id The account ID.
2605 * @param renew If renew argument is zero, this will start
2606 * unregistration process.
2607 *
2608 * @return PJ_SUCCESS on success, or the appropriate error code.
2609 */
2610PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2611 pj_bool_t renew);
2612
Benny Prijono312aff92006-06-17 04:08:30 +00002613/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002614 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002615 *
2616 * @param acc_id Account identification.
2617 * @param info Pointer to receive account information.
2618 *
2619 * @return PJ_SUCCESS on success, or the appropriate error code.
2620 */
2621PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2622 pjsua_acc_info *info);
2623
2624
2625/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002626 * Enumerate all account currently active in the library. This will fill
2627 * the array with the account Ids, and application can then query the
2628 * account information for each id with #pjsua_acc_get_info().
2629 *
2630 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002631 *
2632 * @param ids Array of account IDs to be initialized.
2633 * @param count In input, specifies the maximum number of elements.
2634 * On return, it contains the actual number of elements.
2635 *
2636 * @return PJ_SUCCESS on success, or the appropriate error code.
2637 */
2638PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2639 unsigned *count );
2640
2641
2642/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002643 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002644 *
2645 * @param info Array of account infos to be initialized.
2646 * @param count In input, specifies the maximum number of elements.
2647 * On return, it contains the actual number of elements.
2648 *
2649 * @return PJ_SUCCESS on success, or the appropriate error code.
2650 */
2651PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2652 unsigned *count );
2653
2654
2655/**
2656 * This is an internal function to find the most appropriate account to
2657 * used to reach to the specified URL.
2658 *
2659 * @param url The remote URL to reach.
2660 *
2661 * @return Account id.
2662 */
2663PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2664
2665
2666/**
2667 * This is an internal function to find the most appropriate account to be
2668 * used to handle incoming calls.
2669 *
2670 * @param rdata The incoming request message.
2671 *
2672 * @return Account id.
2673 */
2674PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2675
2676
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002677/**
Benny Prijonofff245c2007-04-02 11:44:47 +00002678 * Create arbitrary requests using the account. Application should only use
2679 * this function to create auxiliary requests outside dialog, such as
2680 * OPTIONS, and use the call or presence API to create dialog related
2681 * requests.
2682 *
2683 * @param acc_id The account ID.
2684 * @param method The SIP method of the request.
2685 * @param target Target URI.
2686 * @param p_tdata Pointer to receive the request.
2687 *
2688 * @return PJ_SUCCESS or the error code.
2689 */
2690PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
2691 const pjsip_method *method,
2692 const pj_str_t *target,
2693 pjsip_tx_data **p_tdata);
2694
2695
2696/**
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002697 * Create a suitable Contact header value, based on the specified target URI
2698 * for the specified account.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002699 *
2700 * @param pool Pool to allocate memory for the string.
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002701 * @param contact The string where the Contact will be stored.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002702 * @param acc_id Account ID.
2703 * @param uri Destination URI of the request.
2704 *
2705 * @return PJ_SUCCESS on success, other on error.
2706 */
2707PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
2708 pj_str_t *contact,
2709 pjsua_acc_id acc_id,
2710 const pj_str_t *uri);
2711
2712
2713
2714/**
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002715 * Create a suitable Contact header value, based on the information in the
2716 * incoming request.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002717 *
2718 * @param pool Pool to allocate memory for the string.
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002719 * @param contact The string where the Contact will be stored.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002720 * @param acc_id Account ID.
2721 * @param rdata Incoming request.
2722 *
2723 * @return PJ_SUCCESS on success, other on error.
2724 */
2725PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
2726 pj_str_t *contact,
2727 pjsua_acc_id acc_id,
2728 pjsip_rx_data *rdata );
2729
2730
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002731/**
2732 * Lock/bind this account to a specific transport/listener. Normally
2733 * application shouldn't need to do this, as transports will be selected
2734 * automatically by the stack according to the destination.
2735 *
2736 * When account is locked/bound to a specific transport, all outgoing
2737 * requests from this account will use the specified transport (this
2738 * includes SIP registration, dialog (call and event subscription), and
2739 * out-of-dialog requests such as MESSAGE).
2740 *
2741 * Note that transport_id may be specified in pjsua_acc_config too.
2742 *
2743 * @param acc_id The account ID.
2744 * @param tp_id The transport ID.
2745 *
2746 * @return PJ_SUCCESS on success.
2747 */
2748PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
2749 pjsua_transport_id tp_id);
2750
Benny Prijono312aff92006-06-17 04:08:30 +00002751
2752/**
2753 * @}
2754 */
2755
2756
2757/*****************************************************************************
2758 * CALLS API
2759 */
2760
2761
2762/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002763 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00002764 * @ingroup PJSUA_LIB
2765 * @brief Call manipulation.
2766 * @{
2767 */
2768
2769/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002770 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00002771 */
2772#ifndef PJSUA_MAX_CALLS
2773# define PJSUA_MAX_CALLS 32
2774#endif
2775
2776
2777
2778/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002779 * This enumeration specifies the media status of a call, and it's part
2780 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00002781 */
2782typedef enum pjsua_call_media_status
2783{
Benny Prijonob5388cf2007-01-04 22:45:08 +00002784 /** Call currently has no media */
Benny Prijono312aff92006-06-17 04:08:30 +00002785 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002786
2787 /** The media is active */
Benny Prijono312aff92006-06-17 04:08:30 +00002788 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002789
2790 /** The media is currently put on hold by local endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002791 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002792
2793 /** The media is currently put on hold by remote endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002794 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002795
Benny Prijono096c56c2007-09-15 08:30:16 +00002796 /** The media has reported error (e.g. ICE negotiation) */
2797 PJSUA_CALL_MEDIA_ERROR
2798
Benny Prijono312aff92006-06-17 04:08:30 +00002799} pjsua_call_media_status;
2800
2801
2802/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002803 * This structure describes the information and current status of a call.
Benny Prijono312aff92006-06-17 04:08:30 +00002804 */
2805typedef struct pjsua_call_info
2806{
2807 /** Call identification. */
2808 pjsua_call_id id;
2809
2810 /** Initial call role (UAC == caller) */
2811 pjsip_role_e role;
2812
Benny Prijono90315512006-09-14 16:05:16 +00002813 /** The account ID where this call belongs. */
2814 pjsua_acc_id acc_id;
2815
Benny Prijono312aff92006-06-17 04:08:30 +00002816 /** Local URI */
2817 pj_str_t local_info;
2818
2819 /** Local Contact */
2820 pj_str_t local_contact;
2821
2822 /** Remote URI */
2823 pj_str_t remote_info;
2824
2825 /** Remote contact */
2826 pj_str_t remote_contact;
2827
2828 /** Dialog Call-ID string. */
2829 pj_str_t call_id;
2830
2831 /** Call state */
2832 pjsip_inv_state state;
2833
2834 /** Text describing the state */
2835 pj_str_t state_text;
2836
2837 /** Last status code heard, which can be used as cause code */
2838 pjsip_status_code last_status;
2839
2840 /** The reason phrase describing the status. */
2841 pj_str_t last_status_text;
2842
2843 /** Call media status. */
2844 pjsua_call_media_status media_status;
2845
2846 /** Media direction */
2847 pjmedia_dir media_dir;
2848
2849 /** The conference port number for the call */
2850 pjsua_conf_port_id conf_slot;
2851
2852 /** Up-to-date call connected duration (zero when call is not
2853 * established)
2854 */
2855 pj_time_val connect_duration;
2856
2857 /** Total call duration, including set-up time */
2858 pj_time_val total_duration;
2859
2860 /** Internal */
2861 struct {
2862 char local_info[128];
2863 char local_contact[128];
2864 char remote_info[128];
2865 char remote_contact[128];
2866 char call_id[128];
2867 char last_status_text[128];
2868 } buf_;
2869
2870} pjsua_call_info;
2871
2872
2873
Benny Prijonoa91a0032006-02-26 21:23:45 +00002874/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002875 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002876 *
2877 * @return Maximum number of calls configured.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002878 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002879PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002880
2881/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002882 * Get number of currently active calls.
2883 *
2884 * @return Number of currently active calls.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002885 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002886PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002887
2888/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002889 * Enumerate all active calls. Application may then query the information and
2890 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002891 *
2892 * @param ids Array of account IDs to be initialized.
2893 * @param count In input, specifies the maximum number of elements.
2894 * On return, it contains the actual number of elements.
2895 *
2896 * @return PJ_SUCCESS on success, or the appropriate error code.
2897 */
2898PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
2899 unsigned *count);
2900
2901
2902/**
2903 * Make outgoing call to the specified URI using the specified account.
2904 *
2905 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002906 * @param dst_uri URI to be put in the To header (normally is the same
2907 * as the target URI).
2908 * @param options Options (must be zero at the moment).
2909 * @param user_data Arbitrary user data to be attached to the call, and
2910 * can be retrieved later.
2911 * @param msg_data Optional headers etc to be added to outgoing INVITE
2912 * request, or NULL if no custom header is desired.
2913 * @param p_call_id Pointer to receive call identification.
2914 *
2915 * @return PJ_SUCCESS on success, or the appropriate error code.
2916 */
2917PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
2918 const pj_str_t *dst_uri,
2919 unsigned options,
2920 void *user_data,
2921 const pjsua_msg_data *msg_data,
2922 pjsua_call_id *p_call_id);
2923
2924
2925/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002926 * Check if the specified call has active INVITE session and the INVITE
2927 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002928 *
2929 * @param call_id Call identification.
2930 *
2931 * @return Non-zero if call is active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002932 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002933PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002934
2935
2936/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002937 * Check if call has an active media session.
2938 *
2939 * @param call_id Call identification.
2940 *
2941 * @return Non-zero if yes.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002942 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002943PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002944
2945
2946/**
Benny Prijonocf986c42008-09-02 11:25:07 +00002947 * Retrieve the media session associated with this call. Note that the media
2948 * session may not be available depending on the current call's media status
2949 * (the pjsua_call_media_status information in pjsua_call_info). Application
2950 * may use the media session to retrieve more detailed information about the
2951 * call's media.
2952 *
2953 * @param call_id Call identification.
2954 *
2955 * @return Call media session.
2956 */
2957PJ_DECL(pjmedia_session*) pjsua_call_get_media_session(pjsua_call_id call_id);
2958
2959
2960/**
2961 * Retrieve the media transport instance that is used for this call.
2962 * Application may use the media transport to query more detailed information
2963 * about the media transport.
2964 *
2965 * @param cid Call identification (the call_id).
2966 *
2967 * @return Call media transport.
2968 */
2969PJ_DECL(pjmedia_transport*) pjsua_call_get_media_transport(pjsua_call_id cid);
2970
2971
2972/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002973 * Get the conference port identification associated with the call.
2974 *
2975 * @param call_id Call identification.
2976 *
2977 * @return Conference port ID, or PJSUA_INVALID_ID when the
2978 * media has not been established or is not active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002979 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002980PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
2981
2982/**
2983 * Obtain detail information about the specified call.
2984 *
2985 * @param call_id Call identification.
2986 * @param info Call info to be initialized.
2987 *
2988 * @return PJ_SUCCESS on success, or the appropriate error code.
2989 */
2990PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002991 pjsua_call_info *info);
2992
Nanang Izzuddin2a1b9ee2010-06-03 10:41:32 +00002993/**
2994 * Check if remote peer support the specified capability.
2995 *
2996 * @param call_id Call identification.
2997 * @param htype The header type to be checked, which value may be:
2998 * - PJSIP_H_ACCEPT
2999 * - PJSIP_H_ALLOW
3000 * - PJSIP_H_SUPPORTED
3001 * @param hname If htype specifies PJSIP_H_OTHER, then the header
3002 * name must be supplied in this argument. Otherwise the
3003 * value must be set to NULL.
3004 * @param token The capability token to check. For example, if \a
3005 * htype is PJSIP_H_ALLOW, then \a token specifies the
3006 * method names; if \a htype is PJSIP_H_SUPPORTED, then
3007 * \a token specifies the extension names such as
3008 * "100rel".
3009 *
3010 * @return PJSIP_DIALOG_CAP_SUPPORTED if the specified capability
3011 * is explicitly supported, see @pjsip_dialog_cap_status
3012 * for more info.
3013 */
3014PJ_DECL(pjsip_dialog_cap_status) pjsua_call_remote_has_cap(
3015 pjsua_call_id call_id,
3016 int htype,
3017 const pj_str_t *hname,
3018 const pj_str_t *token);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003019
3020/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003021 * Attach application specific data to the call. Application can then
3022 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003023 *
3024 * @param call_id Call identification.
3025 * @param user_data Arbitrary data to be attached to the call.
3026 *
3027 * @return The user data.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003028 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003029PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
3030 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003031
3032
3033/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003034 * Get user data attached to the call, which has been previously set with
3035 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003036 *
3037 * @param call_id Call identification.
3038 *
3039 * @return The user data.
Benny Prijono268ca612006-02-07 12:34:11 +00003040 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003041PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00003042
3043
3044/**
Benny Prijono91a6a172007-10-31 08:59:29 +00003045 * Get the NAT type of remote's endpoint. This is a proprietary feature
3046 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
3047 * is set in #pjsua_config.
3048 *
3049 * This function can only be called after SDP has been received from remote,
3050 * which means for incoming call, this function can be called as soon as
3051 * call is received as long as incoming call contains SDP, and for outgoing
3052 * call, this function can be called only after SDP is received (normally in
3053 * 200/OK response to INVITE). As a general case, application should call
3054 * this function after or in \a on_call_media_state() callback.
3055 *
3056 * @param call_id Call identification.
3057 * @param p_type Pointer to store the NAT type. Application can then
3058 * retrieve the string description of the NAT type
3059 * by calling pj_stun_get_nat_name().
3060 *
3061 * @return PJ_SUCCESS on success.
3062 *
3063 * @see pjsua_get_nat_type(), nat_type_in_sdp
3064 */
3065PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
3066 pj_stun_nat_type *p_type);
3067
3068/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003069 * Send response to incoming INVITE request. Depending on the status
3070 * code specified as parameter, this function may send provisional
3071 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003072 *
3073 * @param call_id Incoming call identification.
3074 * @param code Status code, (100-699).
3075 * @param reason Optional reason phrase. If NULL, default text
3076 * will be used.
3077 * @param msg_data Optional list of headers etc to be added to outgoing
3078 * response message.
3079 *
3080 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoa91a0032006-02-26 21:23:45 +00003081 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003082PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
3083 unsigned code,
3084 const pj_str_t *reason,
3085 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00003086
3087/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003088 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00003089 * call state. This function is different than answering the call with
3090 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
3091 * will hangup the call regardless of the state and role of the call,
3092 * while #pjsua_call_answer() only works with incoming calls on EARLY
3093 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003094 *
3095 * @param call_id Call identification.
3096 * @param code Optional status code to be sent when we're rejecting
3097 * incoming call. If the value is zero, "603/Decline"
3098 * will be sent.
3099 * @param reason Optional reason phrase to be sent when we're rejecting
3100 * incoming call. If NULL, default text will be used.
3101 * @param msg_data Optional list of headers etc to be added to outgoing
3102 * request/response message.
3103 *
3104 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003105 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003106PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
3107 unsigned code,
3108 const pj_str_t *reason,
3109 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003110
Benny Prijono5e51a4e2008-11-27 00:06:46 +00003111/**
3112 * Accept or reject redirection response. Application MUST call this function
3113 * after it signaled PJSIP_REDIRECT_PENDING in the \a on_call_redirected()
3114 * callback, to notify the call whether to accept or reject the redirection
3115 * to the current target. Application can use the combination of
3116 * PJSIP_REDIRECT_PENDING command in \a on_call_redirected() callback and
3117 * this function to ask for user permission before redirecting the call.
3118 *
3119 * Note that if the application chooses to reject or stop redirection (by
3120 * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the
3121 * call disconnection callback will be called before this function returns.
3122 * And if the application rejects the target, the \a on_call_redirected()
3123 * callback may also be called before this function returns if there is
3124 * another target to try.
3125 *
3126 * @param call_id The call ID.
3127 * @param cmd Redirection operation to be applied to the current
3128 * target. The semantic of this argument is similar
3129 * to the description in the \a on_call_redirected()
3130 * callback, except that the PJSIP_REDIRECT_PENDING is
3131 * not accepted here.
3132 *
3133 * @return PJ_SUCCESS on successful operation.
3134 */
3135PJ_DECL(pj_status_t) pjsua_call_process_redirect(pjsua_call_id call_id,
3136 pjsip_redirect_op cmd);
Benny Prijono26ff9062006-02-21 23:47:00 +00003137
3138/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003139 * Put the specified call on hold. This will send re-INVITE with the
3140 * appropriate SDP to inform remote that the call is being put on hold.
3141 * The final status of the request itself will be reported on the
3142 * \a on_call_media_state() callback, which inform the application that
3143 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003144 *
3145 * @param call_id Call identification.
3146 * @param msg_data Optional message components to be sent with
3147 * the request.
3148 *
3149 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003150 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003151PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
3152 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003153
3154
3155/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003156 * Send re-INVITE to release hold.
3157 * The final status of the request itself will be reported on the
3158 * \a on_call_media_state() callback, which inform the application that
3159 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003160 *
3161 * @param call_id Call identification.
3162 * @param unhold If this argument is non-zero and the call is locally
3163 * held, this will release the local hold.
3164 * @param msg_data Optional message components to be sent with
3165 * the request.
3166 *
3167 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003168 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003169PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
3170 pj_bool_t unhold,
3171 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003172
Benny Prijonoc08682e2007-10-04 06:17:58 +00003173/**
3174 * Send UPDATE request.
3175 *
3176 * @param call_id Call identification.
3177 * @param options Must be zero for now.
3178 * @param msg_data Optional message components to be sent with
3179 * the request.
3180 *
3181 * @return PJ_SUCCESS on success, or the appropriate error code.
3182 */
3183PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
3184 unsigned options,
3185 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003186
3187/**
Benny Prijono053f5222006-11-11 16:16:04 +00003188 * Initiate call transfer to the specified address. This function will send
3189 * REFER request to instruct remote call party to initiate a new INVITE
3190 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003191 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00003192 * If application is interested to monitor the successfulness and
3193 * the progress of the transfer request, it can implement
3194 * \a on_call_transfer_status() callback which will report the progress
3195 * of the call transfer request.
3196 *
Benny Prijono053f5222006-11-11 16:16:04 +00003197 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003198 * @param dest Address of new target to be contacted.
3199 * @param msg_data Optional message components to be sent with
3200 * the request.
3201 *
3202 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003203 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003204PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
3205 const pj_str_t *dest,
3206 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003207
3208/**
Benny Prijono053f5222006-11-11 16:16:04 +00003209 * Flag to indicate that "Require: replaces" should not be put in the
3210 * outgoing INVITE request caused by REFER request created by
3211 * #pjsua_call_xfer_replaces().
3212 */
3213#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
3214
3215/**
3216 * Initiate attended call transfer. This function will send REFER request
3217 * to instruct remote call party to initiate new INVITE session to the URL
3218 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
3219 * the call with us with the new call from the REFER recipient.
3220 *
3221 * @param call_id The call id to be transfered.
3222 * @param dest_call_id The call id to be replaced.
3223 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
3224 * to suppress the inclusion of "Require: replaces" in
3225 * the outgoing INVITE request created by the REFER
3226 * request.
3227 * @param msg_data Optional message components to be sent with
3228 * the request.
3229 *
3230 * @return PJ_SUCCESS on success, or the appropriate error code.
3231 */
3232PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
3233 pjsua_call_id dest_call_id,
3234 unsigned options,
3235 const pjsua_msg_data *msg_data);
3236
3237/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003238 * Send DTMF digits to remote using RFC 2833 payload formats.
3239 *
3240 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003241 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003242 *
3243 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003244 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003245PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003246 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00003247
Benny Prijono26ff9062006-02-21 23:47:00 +00003248/**
Benny Prijonob0808372006-03-02 21:18:58 +00003249 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003250 *
3251 * @param call_id Call identification.
3252 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3253 * assumed.
3254 * @param content The message content.
3255 * @param msg_data Optional list of headers etc to be included in outgoing
3256 * request. The body descriptor in the msg_data is
3257 * ignored.
3258 * @param user_data Optional user data, which will be given back when
3259 * the IM callback is called.
3260 *
3261 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003262 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003263PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
3264 const pj_str_t *mime_type,
3265 const pj_str_t *content,
3266 const pjsua_msg_data *msg_data,
3267 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003268
3269
3270/**
3271 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003272 *
3273 * @param call_id Call identification.
3274 * @param is_typing Non-zero to indicate to remote that local person is
3275 * currently typing an IM.
3276 * @param msg_data Optional list of headers etc to be included in outgoing
3277 * request.
3278 *
3279 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003280 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003281PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
3282 pj_bool_t is_typing,
3283 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003284
3285/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00003286 * Send arbitrary request with the call. This is useful for example to send
3287 * INFO request. Note that application should not use this function to send
3288 * requests which would change the invite session's state, such as re-INVITE,
3289 * UPDATE, PRACK, and BYE.
3290 *
3291 * @param call_id Call identification.
3292 * @param method SIP method of the request.
3293 * @param msg_data Optional message body and/or list of headers to be
3294 * included in outgoing request.
3295 *
3296 * @return PJ_SUCCESS on success, or the appropriate error code.
3297 */
3298PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
3299 const pj_str_t *method,
3300 const pjsua_msg_data *msg_data);
3301
3302
3303/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003304 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
3305 * currently active calls.
Benny Prijono834aee32006-02-19 01:38:06 +00003306 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00003307PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00003308
3309
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003310/**
3311 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003312 *
3313 * @param call_id Call identification.
3314 * @param with_media Non-zero to include media information too.
3315 * @param buffer Buffer where the statistics are to be written to.
3316 * @param maxlen Maximum length of buffer.
3317 * @param indent Spaces for left indentation.
3318 *
3319 * @return PJ_SUCCESS on success.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003320 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003321PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
3322 pj_bool_t with_media,
3323 char *buffer,
3324 unsigned maxlen,
3325 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003326
Benny Prijono9fc735d2006-05-28 14:58:12 +00003327/**
Benny Prijono312aff92006-06-17 04:08:30 +00003328 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003329 */
Benny Prijono834aee32006-02-19 01:38:06 +00003330
3331
3332/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00003333 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00003334 */
3335
Benny Prijono312aff92006-06-17 04:08:30 +00003336
3337/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003338 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00003339 * @ingroup PJSUA_LIB
3340 * @brief Buddy management, buddy's presence, and instant messaging.
3341 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00003342 *
3343 * This section describes PJSUA-APIs related to buddies management,
3344 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00003345 */
3346
3347/**
3348 * Max buddies in buddy list.
3349 */
3350#ifndef PJSUA_MAX_BUDDIES
3351# define PJSUA_MAX_BUDDIES 256
3352#endif
3353
3354
3355/**
Benny Prijono6ab05322009-10-21 03:03:06 +00003356 * This specifies how long the library should wait before retrying failed
3357 * SUBSCRIBE request, and there is no rule to automatically resubscribe
3358 * (for example, no "retry-after" parameter in Subscription-State header).
3359 *
3360 * This also controls the duration before failed PUBLISH request will be
3361 * retried.
Benny Prijonoa17496a2007-10-31 10:20:31 +00003362 *
3363 * Default: 300 seconds
3364 */
3365#ifndef PJSUA_PRES_TIMER
3366# define PJSUA_PRES_TIMER 300
3367#endif
3368
3369
3370/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003371 * This structure describes buddy configuration when adding a buddy to
3372 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
3373 * the structure with #pjsua_buddy_config_default() to initialize this
3374 * structure with default configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00003375 */
3376typedef struct pjsua_buddy_config
3377{
3378 /**
3379 * Buddy URL or name address.
3380 */
3381 pj_str_t uri;
3382
3383 /**
3384 * Specify whether presence subscription should start immediately.
3385 */
3386 pj_bool_t subscribe;
3387
Benny Prijono705e7842008-07-21 18:12:51 +00003388 /**
3389 * Specify arbitrary application data to be associated with with
3390 * the buddy object.
3391 */
3392 void *user_data;
3393
Benny Prijono312aff92006-06-17 04:08:30 +00003394} pjsua_buddy_config;
3395
3396
3397/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003398 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003399 */
3400typedef enum pjsua_buddy_status
3401{
3402 /**
3403 * Online status is unknown (possibly because no presence subscription
3404 * has been established).
3405 */
3406 PJSUA_BUDDY_STATUS_UNKNOWN,
3407
3408 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003409 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003410 */
3411 PJSUA_BUDDY_STATUS_ONLINE,
3412
3413 /**
3414 * Buddy is offline.
3415 */
3416 PJSUA_BUDDY_STATUS_OFFLINE,
3417
3418} pjsua_buddy_status;
3419
3420
3421
3422/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003423 * This structure describes buddy info, which can be retrieved by calling
3424 * #pjsua_buddy_get_info().
Benny Prijono312aff92006-06-17 04:08:30 +00003425 */
3426typedef struct pjsua_buddy_info
3427{
3428 /**
3429 * The buddy ID.
3430 */
3431 pjsua_buddy_id id;
3432
3433 /**
3434 * The full URI of the buddy, as specified in the configuration.
3435 */
3436 pj_str_t uri;
3437
3438 /**
3439 * Buddy's Contact, only available when presence subscription has
3440 * been established to the buddy.
3441 */
3442 pj_str_t contact;
3443
3444 /**
3445 * Buddy's online status.
3446 */
3447 pjsua_buddy_status status;
3448
3449 /**
3450 * Text to describe buddy's online status.
3451 */
3452 pj_str_t status_text;
3453
3454 /**
3455 * Flag to indicate that we should monitor the presence information for
3456 * this buddy (normally yes, unless explicitly disabled).
3457 */
3458 pj_bool_t monitor_pres;
3459
3460 /**
Benny Prijono63fba012008-07-17 14:19:10 +00003461 * If \a monitor_pres is enabled, this specifies the last state of the
3462 * presence subscription. If presence subscription session is currently
3463 * active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence
3464 * subscription request has been rejected, the value will be
3465 * PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be
3466 * specified in \a sub_term_reason.
3467 */
3468 pjsip_evsub_state sub_state;
3469
3470 /**
Benny Prijonod06d8c52009-06-30 13:53:47 +00003471 * String representation of subscription state.
3472 */
3473 const char *sub_state_name;
3474
3475 /**
Benny Prijono73bb7232009-10-20 13:56:26 +00003476 * Specifies the last presence subscription termination code. This would
3477 * return the last status of the SUBSCRIBE request. If the subscription
3478 * is terminated with NOTIFY by the server, this value will be set to
3479 * 200, and subscription termination reason will be given in the
3480 * \a sub_term_reason field.
3481 */
3482 unsigned sub_term_code;
3483
3484 /**
3485 * Specifies the last presence subscription termination reason. If
Benny Prijono63fba012008-07-17 14:19:10 +00003486 * presence subscription is currently active, the value will be empty.
3487 */
3488 pj_str_t sub_term_reason;
3489
3490 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003491 * Extended RPID information about the person.
3492 */
3493 pjrpid_element rpid;
3494
3495 /**
Benny Prijono28add7e2009-06-15 16:03:40 +00003496 * Extended presence info.
3497 */
3498 pjsip_pres_status pres_status;
3499
3500 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003501 * Internal buffer.
3502 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003503 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003504
3505} pjsua_buddy_info;
3506
3507
Benny Prijono834aee32006-02-19 01:38:06 +00003508/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003509 * Set default values to the buddy config.
3510 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003511PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003512
3513
3514/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003515 * Get total number of buddies.
3516 *
3517 * @return Number of buddies.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003518 */
3519PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3520
3521
3522/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003523 * Check if buddy ID is valid.
3524 *
3525 * @param buddy_id Buddy ID to check.
3526 *
3527 * @return Non-zero if buddy ID is valid.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003528 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003529PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3530
3531
3532/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003533 * Enumerate all buddy IDs in the buddy list. Application then can use
3534 * #pjsua_buddy_get_info() to get the detail information for each buddy
3535 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003536 *
3537 * @param ids Array of ids to be initialized.
3538 * @param count On input, specifies max elements in the array.
3539 * On return, it contains actual number of elements
3540 * that have been initialized.
3541 *
3542 * @return PJ_SUCCESS on success, or the appropriate error code.
3543 */
3544PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3545 unsigned *count);
3546
3547/**
Benny Prijono705e7842008-07-21 18:12:51 +00003548 * Find the buddy ID with the specified URI.
3549 *
3550 * @param uri The buddy URI.
3551 *
3552 * @return The buddy ID, or PJSUA_INVALID_ID if not found.
3553 */
3554PJ_DECL(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri);
3555
3556
3557/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003558 * Get detailed buddy info.
3559 *
3560 * @param buddy_id The buddy identification.
3561 * @param info Pointer to receive information about buddy.
3562 *
3563 * @return PJ_SUCCESS on success, or the appropriate error code.
3564 */
3565PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003566 pjsua_buddy_info *info);
3567
3568/**
Benny Prijono705e7842008-07-21 18:12:51 +00003569 * Set the user data associated with the buddy object.
3570 *
3571 * @param buddy_id The buddy identification.
3572 * @param user_data Arbitrary application data to be associated with
3573 * the buddy object.
3574 *
3575 * @return PJ_SUCCESS on success, or the appropriate error code.
3576 */
3577PJ_DECL(pj_status_t) pjsua_buddy_set_user_data(pjsua_buddy_id buddy_id,
3578 void *user_data);
3579
3580
3581/**
3582 * Get the user data associated with the budy object.
3583 *
3584 * @param buddy_id The buddy identification.
3585 *
3586 * @return The application data.
3587 */
3588PJ_DECL(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id);
3589
3590
3591/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003592 * Add new buddy to the buddy list. If presence subscription is enabled
3593 * for this buddy, this function will also start the presence subscription
3594 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003595 *
Benny Prijonoa7b376b2008-01-25 16:06:33 +00003596 * @param buddy_cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003597 * @param p_buddy_id Pointer to receive buddy ID.
3598 *
3599 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003600 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003601PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003602 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003603
3604
3605/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003606 * Delete the specified buddy from the buddy list. Any presence subscription
3607 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003608 *
3609 * @param buddy_id Buddy identification.
3610 *
3611 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00003612 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003613PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003614
3615
3616/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003617 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3618 * subscribed, application will be informed about buddy's presence status
3619 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003620 *
3621 * @param buddy_id Buddy identification.
3622 * @param subscribe Specify non-zero to activate presence subscription to
3623 * the specified buddy.
3624 *
3625 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003626 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003627PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3628 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003629
3630
3631/**
Benny Prijono10861432007-10-31 10:54:53 +00003632 * Update the presence information for the buddy. Although the library
3633 * periodically refreshes the presence subscription for all buddies, some
3634 * application may want to refresh the buddy's presence subscription
3635 * immediately, and in this case it can use this function to accomplish
3636 * this.
3637 *
3638 * Note that the buddy's presence subscription will only be initiated
3639 * if presence monitoring is enabled for the buddy. See
3640 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
3641 * for the buddy is already active, this function will not do anything.
3642 *
3643 * Once the presence subscription is activated successfully for the buddy,
3644 * application will be notified about the buddy's presence status in the
3645 * on_buddy_state() callback.
3646 *
3647 * @param buddy_id Buddy identification.
3648 *
3649 * @return PJ_SUCCESS on success, or the appropriate error code.
3650 */
3651PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
3652
3653
3654/**
Benny Prijono63fba012008-07-17 14:19:10 +00003655 * Send NOTIFY to inform account presence status or to terminate server
3656 * side presence subscription. If application wants to reject the incoming
3657 * request, it should set the \a state to PJSIP_EVSUB_STATE_TERMINATED.
3658 *
3659 * @param acc_id Account ID.
3660 * @param srv_pres Server presence subscription instance.
3661 * @param state New state to set.
3662 * @param state_str Optionally specify the state string name, if state
3663 * is not "active", "pending", or "terminated".
3664 * @param reason If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3665 * optionally specify the termination reason.
3666 * @param with_body If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3667 * this specifies whether the NOTIFY request should
3668 * contain message body containing account's presence
3669 * information.
3670 * @param msg_data Optional list of headers to be sent with the NOTIFY
3671 * request.
3672 *
3673 * @return PJ_SUCCESS on success.
3674 */
3675PJ_DECL(pj_status_t) pjsua_pres_notify(pjsua_acc_id acc_id,
3676 pjsua_srv_pres *srv_pres,
3677 pjsip_evsub_state state,
3678 const pj_str_t *state_str,
3679 const pj_str_t *reason,
3680 pj_bool_t with_body,
3681 const pjsua_msg_data *msg_data);
3682
3683/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003684 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003685 *
3686 * @param verbose Yes or no.
Benny Prijono834aee32006-02-19 01:38:06 +00003687 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003688PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003689
3690
Benny Prijonob0808372006-03-02 21:18:58 +00003691/**
3692 * The MESSAGE method (defined in pjsua_im.c)
3693 */
3694extern const pjsip_method pjsip_message_method;
3695
3696
Benny Prijonob0808372006-03-02 21:18:58 +00003697
3698/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003699 * Send instant messaging outside dialog, using the specified account for
3700 * route set and authentication.
3701 *
3702 * @param acc_id Account ID to be used to send the request.
3703 * @param to Remote URI.
3704 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3705 * assumed.
3706 * @param content The message content.
3707 * @param msg_data Optional list of headers etc to be included in outgoing
3708 * request. The body descriptor in the msg_data is
3709 * ignored.
3710 * @param user_data Optional user data, which will be given back when
3711 * the IM callback is called.
3712 *
3713 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003714 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003715PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3716 const pj_str_t *to,
3717 const pj_str_t *mime_type,
3718 const pj_str_t *content,
3719 const pjsua_msg_data *msg_data,
3720 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003721
3722
3723/**
3724 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003725 *
3726 * @param acc_id Account ID to be used to send the request.
3727 * @param to Remote URI.
3728 * @param is_typing If non-zero, it tells remote person that local person
3729 * is currently composing an IM.
3730 * @param msg_data Optional list of headers etc to be added to outgoing
3731 * request.
3732 *
3733 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003734 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003735PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3736 const pj_str_t *to,
3737 pj_bool_t is_typing,
3738 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003739
3740
Benny Prijonof3195072006-02-14 21:15:30 +00003741
Benny Prijono312aff92006-06-17 04:08:30 +00003742/**
3743 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003744 */
3745
Benny Prijono312aff92006-06-17 04:08:30 +00003746
3747/*****************************************************************************
3748 * MEDIA API
3749 */
3750
3751
3752/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003753 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003754 * @ingroup PJSUA_LIB
3755 * @brief Media manipulation.
3756 * @{
3757 *
3758 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003759 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3760 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003761 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003762 * the interconnection between these terminations freely.
3763 *
3764 * The conference bridge provides powerful switching and mixing functionality
3765 * for application. With the conference bridge, each conference slot (e.g.
3766 * a call) can transmit to multiple destinations, and one destination can
3767 * receive from multiple sources. If more than one media terminations are
3768 * terminated in the same slot, the conference bridge will mix the signal
3769 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00003770 *
3771 * Application connects one media termination/slot to another by calling
3772 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003773 * media flow from the source termination to the sink termination. To
3774 * establish bidirectional media flow, application wound need to make another
3775 * call to #pjsua_conf_connect(), this time inverting the source and
3776 * destination slots in the parameter.
3777 *
3778 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00003779 * the following steps:
3780 *
3781 \code
3782
3783 pj_status_t stream_to_call( pjsua_call_id call_id )
3784 {
3785 pjsua_player_id player_id;
3786
3787 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
3788 if (status != PJ_SUCCESS)
3789 return status;
3790
3791 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
3792 pjsua_call_get_conf_port() );
3793 }
3794 \endcode
3795 *
3796 *
3797 * Other features of PJSUA media:
3798 * - efficient N to M interconnections between media terminations.
3799 * - media termination can be connected to itself to create loopback
3800 * media.
3801 * - the media termination may have different clock rates, and resampling
3802 * will be done automatically by conference bridge.
3803 * - media terminations may also have different frame time; the
3804 * conference bridge will perform the necessary bufferring to adjust
3805 * the difference between terminations.
3806 * - interconnections are removed automatically when media termination
3807 * is removed from the bridge.
3808 * - sound device may be changed even when there are active media
3809 * interconnections.
3810 * - correctly report call's media quality (in #pjsua_call_dump()) from
3811 * RTCP packet exchange.
3812 */
3813
3814/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003815 * Max ports in the conference bridge. This setting is the default value
3816 * for pjsua_media_config.max_media_ports.
Benny Prijono312aff92006-06-17 04:08:30 +00003817 */
3818#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00003819# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00003820#endif
3821
Benny Prijonob5388cf2007-01-04 22:45:08 +00003822/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003823 * The default clock rate to be used by the conference bridge. This setting
3824 * is the default value for pjsua_media_config.clock_rate.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003825 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003826#ifndef PJSUA_DEFAULT_CLOCK_RATE
3827# define PJSUA_DEFAULT_CLOCK_RATE 16000
3828#endif
3829
Benny Prijonob5388cf2007-01-04 22:45:08 +00003830/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003831 * Default frame length in the conference bridge. This setting
3832 * is the default value for pjsua_media_config.audio_frame_ptime.
3833 */
3834#ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Nanang Izzuddinaf974842008-05-08 09:51:16 +00003835# define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
Benny Prijono37c710b2008-01-10 12:09:26 +00003836#endif
3837
3838
3839/**
3840 * Default codec quality settings. This setting is the default value
3841 * for pjsua_media_config.quality.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003842 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003843#ifndef PJSUA_DEFAULT_CODEC_QUALITY
Nanang Izzuddin9dbad152008-06-10 18:56:10 +00003844# define PJSUA_DEFAULT_CODEC_QUALITY 8
Benny Prijono12a669c2006-11-23 07:32:13 +00003845#endif
3846
Benny Prijonob5388cf2007-01-04 22:45:08 +00003847/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003848 * Default iLBC mode. This setting is the default value for
3849 * pjsua_media_config.ilbc_mode.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003850 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003851#ifndef PJSUA_DEFAULT_ILBC_MODE
Benny Prijono37c710b2008-01-10 12:09:26 +00003852# define PJSUA_DEFAULT_ILBC_MODE 30
Benny Prijono12a669c2006-11-23 07:32:13 +00003853#endif
3854
Benny Prijonob5388cf2007-01-04 22:45:08 +00003855/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003856 * The default echo canceller tail length. This setting
3857 * is the default value for pjsua_media_config.ec_tail_len.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003858 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003859#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijono427439c2007-10-21 09:41:24 +00003860# define PJSUA_DEFAULT_EC_TAIL_LEN 200
Benny Prijono12a669c2006-11-23 07:32:13 +00003861#endif
Benny Prijono312aff92006-06-17 04:08:30 +00003862
3863
3864/**
Benny Prijonocba59d92007-02-16 09:22:56 +00003865 * The maximum file player.
3866 */
3867#ifndef PJSUA_MAX_PLAYERS
3868# define PJSUA_MAX_PLAYERS 32
3869#endif
3870
3871
3872/**
3873 * The maximum file player.
3874 */
3875#ifndef PJSUA_MAX_RECORDERS
3876# define PJSUA_MAX_RECORDERS 32
3877#endif
3878
3879
3880/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003881 * This structure describes media configuration, which will be specified
3882 * when calling #pjsua_init(). Application MUST initialize this structure
3883 * by calling #pjsua_media_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00003884 */
3885struct pjsua_media_config
3886{
3887 /**
3888 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003889 * If value is zero, default clock rate will be used
3890 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00003891 */
3892 unsigned clock_rate;
3893
3894 /**
Benny Prijonof3758ee2008-02-26 15:32:16 +00003895 * Clock rate to be applied when opening the sound device.
3896 * If value is zero, conference bridge clock rate will be used.
3897 */
3898 unsigned snd_clock_rate;
3899
3900 /**
Benny Prijono7d60d052008-03-29 12:24:20 +00003901 * Channel count be applied when opening the sound device and
3902 * conference bridge.
3903 */
3904 unsigned channel_count;
3905
3906 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003907 * Specify audio frame ptime. The value here will affect the
3908 * samples per frame of both the sound device and the conference
3909 * bridge. Specifying lower ptime will normally reduce the
3910 * latency.
3911 *
Benny Prijono37c710b2008-01-10 12:09:26 +00003912 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003913 */
3914 unsigned audio_frame_ptime;
3915
3916 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003917 * Specify maximum number of media ports to be created in the
3918 * conference bridge. Since all media terminate in the bridge
3919 * (calls, file player, file recorder, etc), the value must be
3920 * large enough to support all of them. However, the larger
3921 * the value, the more computations are performed.
Benny Prijono37c710b2008-01-10 12:09:26 +00003922 *
3923 * Default value: PJSUA_MAX_CONF_PORTS
Benny Prijono312aff92006-06-17 04:08:30 +00003924 */
3925 unsigned max_media_ports;
3926
3927 /**
3928 * Specify whether the media manager should manage its own
3929 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
3930 * and at least one worker thread will be created too. If no,
3931 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
3932 * and no worker thread is needed.
3933 *
3934 * Normally application would say yes here, unless it wants to
3935 * run everything from a single thread.
3936 */
3937 pj_bool_t has_ioqueue;
3938
3939 /**
3940 * Specify the number of worker threads to handle incoming RTP
3941 * packets. A value of one is recommended for most applications.
3942 */
3943 unsigned thread_cnt;
3944
Benny Prijono0498d902006-06-19 14:49:14 +00003945 /**
3946 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00003947 * 5-10: resampling use large filter,
3948 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00003949 * 1-2: resampling use linear.
3950 * The media quality also sets speex codec quality/complexity to the
3951 * number.
3952 *
Benny Prijono70972992006-08-05 11:13:58 +00003953 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00003954 */
3955 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00003956
3957 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003958 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00003959 *
3960 * Default: 0 (codec specific)
3961 */
3962 unsigned ptime;
3963
3964 /**
3965 * Disable VAD?
3966 *
3967 * Default: 0 (no (meaning VAD is enabled))
3968 */
3969 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00003970
3971 /**
3972 * iLBC mode (20 or 30).
3973 *
Benny Prijono37c710b2008-01-10 12:09:26 +00003974 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00003975 */
3976 unsigned ilbc_mode;
3977
3978 /**
3979 * Percentage of RTP packet to drop in TX direction
3980 * (to simulate packet lost).
3981 *
3982 * Default: 0
3983 */
3984 unsigned tx_drop_pct;
3985
3986 /**
3987 * Percentage of RTP packet to drop in RX direction
3988 * (to simulate packet lost).
3989 *
3990 * Default: 0
3991 */
3992 unsigned rx_drop_pct;
3993
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003994 /**
Benny Prijono5da50432006-08-07 10:24:52 +00003995 * Echo canceller options (see #pjmedia_echo_create())
3996 *
3997 * Default: 0.
3998 */
3999 unsigned ec_options;
4000
4001 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004002 * Echo canceller tail length, in miliseconds.
4003 *
Benny Prijono669643c2006-09-20 20:02:18 +00004004 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004005 */
4006 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004007
Benny Prijono10454dc2009-02-21 14:21:59 +00004008 /**
4009 * Audio capture buffer length, in milliseconds.
4010 *
4011 * Default: PJMEDIA_SND_DEFAULT_REC_LATENCY
4012 */
4013 unsigned snd_rec_latency;
4014
4015 /**
4016 * Audio playback buffer length, in milliseconds.
4017 *
4018 * Default: PJMEDIA_SND_DEFAULT_PLAY_LATENCY
4019 */
4020 unsigned snd_play_latency;
4021
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004022 /**
4023 * Jitter buffer initial prefetch delay in msec. The value must be
4024 * between jb_min_pre and jb_max_pre below.
4025 *
4026 * Default: -1 (to use default stream settings, currently 150 msec)
4027 */
4028 int jb_init;
4029
4030 /**
4031 * Jitter buffer minimum prefetch delay in msec.
4032 *
4033 * Default: -1 (to use default stream settings, currently 60 msec)
4034 */
4035 int jb_min_pre;
4036
4037 /**
4038 * Jitter buffer maximum prefetch delay in msec.
4039 *
4040 * Default: -1 (to use default stream settings, currently 240 msec)
4041 */
4042 int jb_max_pre;
4043
4044 /**
4045 * Set maximum delay that can be accomodated by the jitter buffer msec.
4046 *
4047 * Default: -1 (to use default stream settings, currently 360 msec)
4048 */
4049 int jb_max;
4050
Benny Prijonoc97608e2007-03-23 16:34:20 +00004051 /**
4052 * Enable ICE
4053 */
4054 pj_bool_t enable_ice;
4055
4056 /**
Benny Prijono329d6382009-05-29 13:04:03 +00004057 * Set the maximum number of host candidates.
4058 *
4059 * Default: -1 (maximum not set)
Benny Prijonoc97608e2007-03-23 16:34:20 +00004060 */
Benny Prijono329d6382009-05-29 13:04:03 +00004061 int ice_max_host_cands;
4062
4063 /**
4064 * ICE session options.
4065 */
4066 pj_ice_sess_options ice_opt;
Benny Prijonof76e1392008-06-06 14:51:48 +00004067
4068 /**
Benny Prijono551af422008-08-07 09:55:52 +00004069 * Disable RTCP component.
4070 *
4071 * Default: no
4072 */
4073 pj_bool_t ice_no_rtcp;
4074
4075 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00004076 * Enable TURN relay candidate in ICE.
4077 */
4078 pj_bool_t enable_turn;
4079
4080 /**
4081 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
4082 * "HOST:PORT" format.
4083 */
4084 pj_str_t turn_server;
4085
4086 /**
4087 * Specify the connection type to be used to the TURN server. Valid
4088 * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP.
4089 *
4090 * Default: PJ_TURN_TP_UDP
4091 */
4092 pj_turn_tp_type turn_conn_type;
4093
4094 /**
4095 * Specify the credential to authenticate with the TURN server.
4096 */
4097 pj_stun_auth_cred turn_auth_cred;
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004098
4099 /**
4100 * Specify idle time of sound device before it is automatically closed,
Benny Prijonof798e502009-03-09 13:08:16 +00004101 * in seconds. Use value -1 to disable the auto-close feature of sound
4102 * device
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004103 *
Benny Prijonof798e502009-03-09 13:08:16 +00004104 * Default : 1
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004105 */
4106 int snd_auto_close_time;
Benny Prijono312aff92006-06-17 04:08:30 +00004107};
4108
4109
4110/**
4111 * Use this function to initialize media config.
4112 *
4113 * @param cfg The media config to be initialized.
4114 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00004115PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00004116
4117
4118/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004119 * This structure describes codec information, which can be retrieved by
4120 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00004121 */
4122typedef struct pjsua_codec_info
4123{
4124 /**
4125 * Codec unique identification.
4126 */
4127 pj_str_t codec_id;
4128
4129 /**
4130 * Codec priority (integer 0-255).
4131 */
4132 pj_uint8_t priority;
4133
4134 /**
4135 * Internal buffer.
4136 */
4137 char buf_[32];
4138
4139} pjsua_codec_info;
4140
4141
4142/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004143 * This structure descibes information about a particular media port that
4144 * has been registered into the conference bridge. Application can query
4145 * this info by calling #pjsua_conf_get_port_info().
Benny Prijono312aff92006-06-17 04:08:30 +00004146 */
4147typedef struct pjsua_conf_port_info
4148{
4149 /** Conference port number. */
4150 pjsua_conf_port_id slot_id;
4151
4152 /** Port name. */
4153 pj_str_t name;
4154
4155 /** Clock rate. */
4156 unsigned clock_rate;
4157
4158 /** Number of channels. */
4159 unsigned channel_count;
4160
4161 /** Samples per frame */
4162 unsigned samples_per_frame;
4163
4164 /** Bits per sample */
4165 unsigned bits_per_sample;
4166
4167 /** Number of listeners in the array. */
4168 unsigned listener_cnt;
4169
4170 /** Array of listeners (in other words, ports where this port is
4171 * transmitting to.
4172 */
4173 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
4174
4175} pjsua_conf_port_info;
4176
4177
4178/**
4179 * This structure holds information about custom media transport to
4180 * be registered to pjsua.
4181 */
4182typedef struct pjsua_media_transport
4183{
4184 /**
4185 * Media socket information containing the address information
4186 * of the RTP and RTCP socket.
4187 */
4188 pjmedia_sock_info skinfo;
4189
4190 /**
4191 * The media transport instance.
4192 */
4193 pjmedia_transport *transport;
4194
4195} pjsua_media_transport;
4196
4197
4198
4199
Benny Prijono9fc735d2006-05-28 14:58:12 +00004200/**
4201 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004202 *
4203 * @return Maximum number of ports in the conference bridge.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004204 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004205PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004206
4207
4208/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004209 * Get current number of active ports in the bridge.
4210 *
4211 * @return The number.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004212 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004213PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
4214
4215
4216/**
4217 * Enumerate all conference ports.
4218 *
4219 * @param id Array of conference port ID to be initialized.
4220 * @param count On input, specifies max elements in the array.
4221 * On return, it contains actual number of elements
4222 * that have been initialized.
4223 *
4224 * @return PJ_SUCCESS on success, or the appropriate error code.
4225 */
4226PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
4227 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004228
4229
4230/**
4231 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004232 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004233 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004234 * @param info Pointer to store the port info.
4235 *
4236 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004237 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004238PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00004239 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004240
4241
4242/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00004243 * Add arbitrary media port to PJSUA's conference bridge. Application
4244 * can use this function to add the media port that it creates. For
4245 * media ports that are created by PJSUA-LIB (such as calls, file player,
4246 * or file recorder), PJSUA-LIB will automatically add the port to
4247 * the bridge.
4248 *
4249 * @param pool Pool to use.
4250 * @param port Media port to be added to the bridge.
4251 * @param p_id Optional pointer to receive the conference
4252 * slot id.
4253 *
4254 * @return PJ_SUCCESS on success, or the appropriate error code.
4255 */
4256PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
4257 pjmedia_port *port,
4258 pjsua_conf_port_id *p_id);
4259
4260
4261/**
4262 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00004263 * call this function if it registered the port manually with previous call
4264 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00004265 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004266 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00004267 *
4268 * @return PJ_SUCCESS on success, or the appropriate error code.
4269 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004270PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00004271
4272
4273/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004274 * Establish unidirectional media flow from souce to sink. One source
4275 * may transmit to multiple destinations/sink. And if multiple
4276 * sources are transmitting to the same sink, the media will be mixed
4277 * together. Source and sink may refer to the same ID, effectively
4278 * looping the media.
4279 *
4280 * If bidirectional media flow is desired, application needs to call
4281 * this function twice, with the second one having the arguments
4282 * reversed.
4283 *
4284 * @param source Port ID of the source media/transmitter.
4285 * @param sink Port ID of the destination media/received.
4286 *
4287 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004288 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004289PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
4290 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004291
4292
4293/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004294 * Disconnect media flow from the source to destination port.
4295 *
4296 * @param source Port ID of the source media/transmitter.
4297 * @param sink Port ID of the destination media/received.
4298 *
4299 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004300 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004301PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
4302 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004303
4304
Benny Prijono6dd967c2006-12-26 02:27:14 +00004305/**
4306 * Adjust the signal level to be transmitted from the bridge to the
4307 * specified port by making it louder or quieter.
4308 *
4309 * @param slot The conference bridge slot number.
4310 * @param level Signal level adjustment. Value 1.0 means no level
4311 * adjustment, while value 0 means to mute the port.
4312 *
4313 * @return PJ_SUCCESS on success, or the appropriate error code.
4314 */
4315PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
4316 float level);
4317
4318/**
4319 * Adjust the signal level to be received from the specified port (to
4320 * the bridge) by making it louder or quieter.
4321 *
4322 * @param slot The conference bridge slot number.
4323 * @param level Signal level adjustment. Value 1.0 means no level
4324 * adjustment, while value 0 means to mute the port.
4325 *
4326 * @return PJ_SUCCESS on success, or the appropriate error code.
4327 */
4328PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
4329 float level);
4330
4331/**
4332 * Get last signal level transmitted to or received from the specified port.
4333 * The signal level is an integer value in zero to 255, with zero indicates
4334 * no signal, and 255 indicates the loudest signal level.
4335 *
4336 * @param slot The conference bridge slot number.
4337 * @param tx_level Optional argument to receive the level of signal
4338 * transmitted to the specified port (i.e. the direction
4339 * is from the bridge to the port).
4340 * @param rx_level Optional argument to receive the level of signal
4341 * received from the port (i.e. the direction is from the
4342 * port to the bridge).
4343 *
4344 * @return PJ_SUCCESS on success.
4345 */
4346PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
4347 unsigned *tx_level,
4348 unsigned *rx_level);
4349
Benny Prijono6dd967c2006-12-26 02:27:14 +00004350
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004351/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00004352 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004353 */
4354
Benny Prijono9fc735d2006-05-28 14:58:12 +00004355/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004356 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004357 * the conference bridge.
4358 *
4359 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00004360 * WAV files are supported, and the WAV file MUST be
4361 * formatted as 16bit PCM mono/single channel (any
4362 * clock rate is supported).
Benny Prijono58add7c2008-01-18 13:24:07 +00004363 * @param options Optional option flag. Application may specify
4364 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004365 * @param p_id Pointer to receive player ID.
4366 *
4367 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004368 */
4369PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004370 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004371 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004372
4373
4374/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004375 * Create a file playlist media port, and automatically add the port
4376 * to the conference bridge.
4377 *
4378 * @param file_names Array of file names to be added to the play list.
4379 * Note that the files must have the same clock rate,
4380 * number of channels, and number of bits per sample.
4381 * @param file_count Number of files in the array.
4382 * @param label Optional label to be set for the media port.
4383 * @param options Optional option flag. Application may specify
4384 * PJMEDIA_FILE_NO_LOOP to prevent looping.
4385 * @param p_id Optional pointer to receive player ID.
4386 *
4387 * @return PJ_SUCCESS on success, or the appropriate error code.
4388 */
4389PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
4390 unsigned file_count,
4391 const pj_str_t *label,
4392 unsigned options,
4393 pjsua_player_id *p_id);
4394
4395/**
4396 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004397 *
4398 * @param id The file player ID.
4399 *
4400 * @return Conference port ID associated with this player.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004401 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004402PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004403
4404
4405/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004406 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00004407 *
4408 * @param id The player ID.
4409 * @param p_port The media port associated with the player.
4410 *
4411 * @return PJ_SUCCESS on success.
4412 */
Benny Prijono58add7c2008-01-18 13:24:07 +00004413PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
Benny Prijono469b1522006-12-26 03:05:17 +00004414 pjmedia_port **p_port);
4415
4416/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004417 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004418 *
4419 * @param id The file player ID.
4420 * @param samples The playback position, in samples. Application can
4421 * specify zero to re-start the playback.
4422 *
4423 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004424 */
4425PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
4426 pj_uint32_t samples);
4427
4428
4429/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004430 * Close the file of playlist, remove the player from the bridge, and free
4431 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004432 *
4433 * @param id The file player ID.
4434 *
4435 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004436 */
4437PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
4438
4439
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004440/*****************************************************************************
4441 * File recorder.
4442 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00004443
4444/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004445 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004446 * the conference bridge. The recorder currently supports recording WAV file.
4447 * The type of the recorder to use is determined by the extension of the file
4448 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004449 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00004450 * @param filename Output file name. The function will determine the
4451 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004452 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00004453 * @param enc_type Optionally specify the type of encoder to be used to
4454 * compress the media, if the file can support different
4455 * encodings. This value must be zero for now.
4456 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004457 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00004458 * For .WAV recorder, this value must be NULL.
4459 * @param max_size Maximum file size. Specify zero or -1 to remove size
4460 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004461 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004462 * @param p_id Pointer to receive the recorder instance.
4463 *
4464 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004465 */
4466PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004467 unsigned enc_type,
4468 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004469 pj_ssize_t max_size,
4470 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004471 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004472
4473
4474/**
4475 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004476 *
4477 * @param id The recorder ID.
4478 *
4479 * @return Conference port ID associated with this recorder.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004480 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004481PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004482
4483
4484/**
Benny Prijono469b1522006-12-26 03:05:17 +00004485 * Get the media port for the recorder.
4486 *
4487 * @param id The recorder ID.
4488 * @param p_port The media port associated with the recorder.
4489 *
4490 * @return PJ_SUCCESS on success.
4491 */
4492PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4493 pjmedia_port **p_port);
4494
4495
4496/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004497 * Destroy recorder (this will complete recording).
4498 *
4499 * @param id The recorder ID.
4500 *
4501 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004502 */
4503PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4504
4505
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004506/*****************************************************************************
4507 * Sound devices.
4508 */
4509
Benny Prijono9fc735d2006-05-28 14:58:12 +00004510/**
Benny Prijonof798e502009-03-09 13:08:16 +00004511 * Enum all audio devices installed in the system.
4512 *
4513 * @param info Array of info to be initialized.
4514 * @param count On input, specifies max elements in the array.
4515 * On return, it contains actual number of elements
4516 * that have been initialized.
4517 *
4518 * @return PJ_SUCCESS on success, or the appropriate error code.
4519 */
4520PJ_DECL(pj_status_t) pjsua_enum_aud_devs(pjmedia_aud_dev_info info[],
4521 unsigned *count);
4522
4523/**
4524 * Enum all sound devices installed in the system (old API).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004525 *
4526 * @param info Array of info to be initialized.
4527 * @param count On input, specifies max elements in the array.
4528 * On return, it contains actual number of elements
4529 * that have been initialized.
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_enum_snd_devs(pjmedia_snd_dev_info info[],
4534 unsigned *count);
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004535
4536/**
4537 * Get currently active sound devices. If sound devices has not been created
4538 * (for example when pjsua_start() is not called), it is possible that
4539 * the function returns PJ_SUCCESS with -1 as device IDs.
4540 *
4541 * @param capture_dev On return it will be filled with device ID of the
4542 * capture device.
4543 * @param playback_dev On return it will be filled with device ID of the
4544 * device ID of the playback device.
4545 *
4546 * @return PJ_SUCCESS on success, or the appropriate error code.
4547 */
4548PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4549 int *playback_dev);
4550
4551
Benny Prijono9fc735d2006-05-28 14:58:12 +00004552/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004553 * Select or change sound device. Application may call this function at
4554 * any time to replace current sound device.
4555 *
4556 * @param capture_dev Device ID of the capture device.
4557 * @param playback_dev Device ID of the playback device.
4558 *
4559 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004560 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004561PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4562 int playback_dev);
4563
4564
4565/**
4566 * Set pjsua to use null sound device. The null sound device only provides
4567 * the timing needed by the conference bridge, and will not interract with
4568 * any hardware.
4569 *
4570 * @return PJ_SUCCESS on success, or the appropriate error code.
4571 */
4572PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4573
4574
Benny Prijonoe909eac2006-07-27 22:04:56 +00004575/**
4576 * Disconnect the main conference bridge from any sound devices, and let
4577 * application connect the bridge to it's own sound device/master port.
4578 *
4579 * @return The port interface of the conference bridge,
4580 * so that application can connect this to it's own
4581 * sound device or master port.
4582 */
4583PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4584
4585
Benny Prijonof20687a2006-08-04 18:27:19 +00004586/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004587 * Change the echo cancellation settings.
Benny Prijonof798e502009-03-09 13:08:16 +00004588 *
4589 * The behavior of this function depends on whether the sound device is
4590 * currently active, and if it is, whether device or software AEC is
4591 * being used.
Benny Prijono10454dc2009-02-21 14:21:59 +00004592 *
4593 * If the sound device is currently active, and if the device supports AEC,
4594 * this function will forward the change request to the device and it will
4595 * be up to the device on whether support the request. If software AEC is
4596 * being used (the software EC will be used if the device does not support
4597 * AEC), this function will change the software EC settings. In all cases,
4598 * the setting will be saved for future opening of the sound device.
4599 *
4600 * If the sound device is not currently active, this will only change the
4601 * default AEC settings and the setting will be applied next time the
4602 * sound device is opened.
Benny Prijonof20687a2006-08-04 18:27:19 +00004603 *
4604 * @param tail_ms The tail length, in miliseconds. Set to zero to
4605 * disable AEC.
Benny Prijonoa7b376b2008-01-25 16:06:33 +00004606 * @param options Options to be passed to pjmedia_echo_create().
Benny Prijono5da50432006-08-07 10:24:52 +00004607 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004608 *
4609 * @return PJ_SUCCESS on success.
4610 */
Benny Prijono5da50432006-08-07 10:24:52 +00004611PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004612
4613
4614/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004615 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004616 *
4617 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4618 * If AEC is disabled, the value will be zero.
4619 *
4620 * @return PJ_SUCCESS on success.
4621 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004622PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004623
4624
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004625/**
Benny Prijonof798e502009-03-09 13:08:16 +00004626 * Check whether the sound device is currently active. The sound device
4627 * may be inactive if the application has set the auto close feature to
4628 * non-zero (the snd_auto_close_time setting in #pjsua_media_config), or
4629 * if null sound device or no sound device has been configured via the
4630 * #pjsua_set_no_snd_dev() function.
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004631 */
Benny Prijonof798e502009-03-09 13:08:16 +00004632PJ_DECL(pj_bool_t) pjsua_snd_is_active(void);
4633
4634
4635/**
4636 * Configure sound device setting to the sound device being used. If sound
4637 * device is currently active, the function will forward the setting to the
4638 * sound device instance to be applied immediately, if it supports it.
4639 *
4640 * The setting will be saved for future opening of the sound device, if the
4641 * "keep" argument is set to non-zero. If the sound device is currently
4642 * inactive, and the "keep" argument is false, this function will return
4643 * error.
4644 *
4645 * Note that in case the setting is kept for future use, it will be applied
4646 * to any devices, even when application has changed the sound device to be
4647 * used.
4648 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004649 * Note also that the echo cancellation setting should be set with
4650 * #pjsua_set_ec() API instead.
4651 *
Benny Prijonof798e502009-03-09 13:08:16 +00004652 * See also #pjmedia_aud_stream_set_cap() for more information about setting
4653 * an audio device capability.
4654 *
4655 * @param cap The sound device setting to change.
4656 * @param pval Pointer to value. Please see #pjmedia_aud_dev_cap
4657 * documentation about the type of value to be
4658 * supplied for each setting.
4659 * @param keep Specify whether the setting is to be kept for future
4660 * use.
4661 *
4662 * @return PJ_SUCCESS on success or the appropriate error code.
4663 */
4664PJ_DECL(pj_status_t) pjsua_snd_set_setting(pjmedia_aud_dev_cap cap,
4665 const void *pval,
4666 pj_bool_t keep);
4667
4668/**
4669 * Retrieve a sound device setting. If sound device is currently active,
4670 * the function will forward the request to the sound device. If sound device
4671 * is currently inactive, and if application had previously set the setting
4672 * and mark the setting as kept, then that setting will be returned.
4673 * Otherwise, this function will return error.
4674 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004675 * Note that echo cancellation settings should be retrieved with
4676 * #pjsua_get_ec_tail() API instead.
4677 *
Benny Prijonof798e502009-03-09 13:08:16 +00004678 * @param cap The sound device setting to retrieve.
4679 * @param pval Pointer to receive the value.
4680 * Please see #pjmedia_aud_dev_cap documentation about
4681 * the type of value to be supplied for each setting.
4682 *
4683 * @return PJ_SUCCESS on success or the appropriate error code.
4684 */
4685PJ_DECL(pj_status_t) pjsua_snd_get_setting(pjmedia_aud_dev_cap cap,
4686 void *pval);
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004687
4688
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004689/*****************************************************************************
4690 * Codecs.
4691 */
4692
4693/**
4694 * Enum all supported codecs in the system.
4695 *
4696 * @param id Array of ID to be initialized.
4697 * @param count On input, specifies max elements in the array.
4698 * On return, it contains actual number of elements
4699 * that have been initialized.
4700 *
4701 * @return PJ_SUCCESS on success, or the appropriate error code.
4702 */
4703PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4704 unsigned *count );
4705
4706
4707/**
4708 * Change codec priority.
4709 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004710 * @param codec_id Codec ID, which is a string that uniquely identify
4711 * the codec (such as "speex/8000"). Please see pjsua
4712 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004713 * @param priority Codec priority, 0-255, where zero means to disable
4714 * the codec.
4715 *
4716 * @return PJ_SUCCESS on success, or the appropriate error code.
4717 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004718PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004719 pj_uint8_t priority );
4720
4721
4722/**
4723 * Get codec parameters.
4724 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004725 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004726 * @param param Structure to receive codec parameters.
4727 *
4728 * @return PJ_SUCCESS on success, or the appropriate error code.
4729 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004730PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004731 pjmedia_codec_param *param );
4732
4733
4734/**
4735 * Set codec parameters.
4736 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004737 * @param codec_id Codec ID.
Nanang Izzuddin06839e72010-01-27 11:48:31 +00004738 * @param param Codec parameter to set. Set to NULL to reset
4739 * codec parameter to library default settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004740 *
4741 * @return PJ_SUCCESS on success, or the appropriate error code.
4742 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004743PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004744 const pjmedia_codec_param *param);
4745
4746
4747
Benny Prijono9fc735d2006-05-28 14:58:12 +00004748
Benny Prijono312aff92006-06-17 04:08:30 +00004749/**
4750 * Create UDP media transports for all the calls. This function creates
4751 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00004752 *
Benny Prijono312aff92006-06-17 04:08:30 +00004753 * @param cfg Media transport configuration. The "port" field in the
4754 * configuration is used as the start port to bind the
4755 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004756 *
4757 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonof3195072006-02-14 21:15:30 +00004758 */
Benny Prijono312aff92006-06-17 04:08:30 +00004759PJ_DECL(pj_status_t)
4760pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00004761
Benny Prijonodc39fe82006-05-26 12:17:46 +00004762
4763/**
Benny Prijono312aff92006-06-17 04:08:30 +00004764 * Register custom media transports to be used by calls. There must
4765 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004766 *
Benny Prijono312aff92006-06-17 04:08:30 +00004767 * @param tp The media transport array.
4768 * @param count Number of elements in the array. This number MUST
4769 * match the number of maximum calls configured when
4770 * pjsua is created.
4771 * @param auto_delete Flag to indicate whether the transports should be
4772 * destroyed when pjsua is shutdown.
4773 *
4774 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00004775 */
Benny Prijono312aff92006-06-17 04:08:30 +00004776PJ_DECL(pj_status_t)
4777pjsua_media_transports_attach( pjsua_media_transport tp[],
4778 unsigned count,
4779 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00004780
4781
Benny Prijono312aff92006-06-17 04:08:30 +00004782/**
4783 * @}
4784 */
4785
Benny Prijonof3195072006-02-14 21:15:30 +00004786
Benny Prijono268ca612006-02-07 12:34:11 +00004787
Benny Prijono312aff92006-06-17 04:08:30 +00004788/**
4789 * @}
4790 */
4791
Benny Prijonoe6ead542007-01-31 20:53:31 +00004792PJ_END_DECL
4793
Benny Prijono312aff92006-06-17 04:08:30 +00004794
Benny Prijono268ca612006-02-07 12:34:11 +00004795#endif /* __PJSUA_H__ */