blob: 3aa03b935c2187b96830cd1ea3b1f048c286fa07 [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/**
Nanang Izzuddin4ea1bcc2010-09-28 04:57:01 +0000414 * Structure to be passed on registration callback.
415 */
416typedef struct pjsua_reg_info
417{
418 struct pjsip_regc_cbparam *cbparam; /**< Parameters returned by
419 registration callback. */
420} pjsua_reg_info;
421
422
423/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000424 * This structure describes application callback to receive various event
425 * notification from PJSUA-API. All of these callbacks are OPTIONAL,
426 * although definitely application would want to implement some of
427 * the important callbacks (such as \a on_incoming_call).
Benny Prijonodc39fe82006-05-26 12:17:46 +0000428 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000429typedef struct pjsua_callback
Benny Prijonodc39fe82006-05-26 12:17:46 +0000430{
431 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000432 * Notify application when invite state has changed.
433 * Application may then query the call info to get the
Benny Prijonoe6ead542007-01-31 20:53:31 +0000434 * detail call states by calling pjsua_call_get_info() function.
Benny Prijono0875ae82006-12-26 00:11:48 +0000435 *
436 * @param call_id The call index.
437 * @param e Event which causes the call state to change.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000438 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000439 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000440
441 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000442 * Notify application on incoming call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000443 *
444 * @param acc_id The account which match the incoming call.
445 * @param call_id The call id that has just been created for
446 * the call.
447 * @param rdata The incoming INVITE request.
Benny Prijono8b1889b2006-06-06 18:40:40 +0000448 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000449 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000450 pjsip_rx_data *rdata);
451
452 /**
Benny Prijonofeb69f42007-10-05 09:12:26 +0000453 * This is a general notification callback which is called whenever
454 * a transaction within the call has changed state. Application can
455 * implement this callback for example to monitor the state of
456 * outgoing requests, or to answer unhandled incoming requests
457 * (such as INFO) with a final response.
458 *
459 * @param call_id Call identification.
460 * @param tsx The transaction which has changed state.
461 * @param e Transaction event that caused the state change.
462 */
463 void (*on_call_tsx_state)(pjsua_call_id call_id,
464 pjsip_transaction *tsx,
465 pjsip_event *e);
466
467 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000468 * Notify application when media state in the call has changed.
469 * Normal application would need to implement this callback, e.g.
Benny Prijono6ba8c542007-10-16 01:34:14 +0000470 * to connect the call's media to sound device. When ICE is used,
471 * this callback will also be called to report ICE negotiation
472 * failure.
Benny Prijono0875ae82006-12-26 00:11:48 +0000473 *
474 * @param call_id The call index.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000475 */
476 void (*on_call_media_state)(pjsua_call_id call_id);
477
Benny Prijonofc13bf62008-02-20 08:56:15 +0000478
479 /**
480 * Notify application when media session is created and before it is
481 * registered to the conference bridge. Application may return different
482 * media port if it has added media processing port to the stream. This
483 * media port then will be added to the conference bridge instead.
484 *
485 * @param call_id Call identification.
486 * @param sess Media session for the call.
487 * @param stream_idx Stream index in the media session.
488 * @param p_port On input, it specifies the media port of the
489 * stream. Application may modify this pointer to
490 * point to different media port to be registered
491 * to the conference bridge.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000492 */
493 void (*on_stream_created)(pjsua_call_id call_id,
494 pjmedia_session *sess,
495 unsigned stream_idx,
496 pjmedia_port **p_port);
497
498 /**
499 * Notify application when media session has been unregistered from the
500 * conference bridge and about to be destroyed.
501 *
502 * @param call_id Call identification.
503 * @param sess Media session for the call.
504 * @param stream_idx Stream index in the media session.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000505 */
506 void (*on_stream_destroyed)(pjsua_call_id call_id,
507 pjmedia_session *sess,
508 unsigned stream_idx);
509
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000510 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000511 * Notify application upon incoming DTMF digits.
512 *
513 * @param call_id The call index.
514 * @param digit DTMF ASCII digit.
515 */
516 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
517
518 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000519 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000520 * Application can decide to accept/reject transfer request
Benny Prijonoc54dcb32008-04-08 23:33:15 +0000521 * by setting the code (default is 202). When this callback
Benny Prijono9fc735d2006-05-28 14:58:12 +0000522 * is not defined, the default behavior is to accept the
523 * transfer.
Benny Prijono0875ae82006-12-26 00:11:48 +0000524 *
525 * @param call_id The call index.
526 * @param dst The destination where the call will be
527 * transfered to.
528 * @param code Status code to be returned for the call transfer
529 * request. On input, it contains status code 200.
Benny Prijono9fc735d2006-05-28 14:58:12 +0000530 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000531 void (*on_call_transfer_request)(pjsua_call_id call_id,
532 const pj_str_t *dst,
533 pjsip_status_code *code);
534
535 /**
536 * Notify application of the status of previously sent call
537 * transfer request. Application can monitor the status of the
538 * call transfer request, for example to decide whether to
539 * terminate existing call.
540 *
541 * @param call_id Call ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000542 * @param st_code Status progress of the transfer request.
543 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000544 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000545 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000546 * this callback is the final status.
547 * @param p_cont Initially will be set to non-zero, application
548 * can set this to FALSE if it no longer wants
549 * to receie further notification (for example,
550 * after it hangs up the call).
551 */
552 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000553 int st_code,
554 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000555 pj_bool_t final,
556 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000557
558 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000559 * Notify application about incoming INVITE with Replaces header.
560 * Application may reject the request by setting non-2xx code.
561 *
562 * @param call_id The call ID to be replaced.
563 * @param rdata The incoming INVITE request to replace the call.
564 * @param st_code Status code to be set by application. Application
565 * should only return a final status (200-699).
566 * @param st_text Optional status text to be set by application.
567 */
568 void (*on_call_replace_request)(pjsua_call_id call_id,
569 pjsip_rx_data *rdata,
570 int *st_code,
571 pj_str_t *st_text);
572
573 /**
574 * Notify application that an existing call has been replaced with
575 * a new call. This happens when PJSUA-API receives incoming INVITE
576 * request with Replaces header.
577 *
578 * After this callback is called, normally PJSUA-API will disconnect
579 * \a old_call_id and establish \a new_call_id.
580 *
581 * @param old_call_id Existing call which to be replaced with the
582 * new call.
583 * @param new_call_id The new call.
584 * @param rdata The incoming INVITE with Replaces request.
585 */
586 void (*on_call_replaced)(pjsua_call_id old_call_id,
587 pjsua_call_id new_call_id);
588
589
590 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000591 * Notify application when registration status has changed.
592 * Application may then query the account info to get the
593 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000594 *
Nanang Izzuddin4ea1bcc2010-09-28 04:57:01 +0000595 * @param acc_id The account ID.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000596 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000597 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000598
599 /**
Nanang Izzuddin4ea1bcc2010-09-28 04:57:01 +0000600 * Notify application when registration status has changed.
601 * Application may inspect the registration info to get the
602 * registration status details.
603 *
604 * @param acc_id The account ID.
605 * @param info The registration info.
606 */
607 void (*on_reg_state2)(pjsua_acc_id acc_id, pjsua_reg_info *info);
608
609 /**
Benny Prijono63fba012008-07-17 14:19:10 +0000610 * Notification when incoming SUBSCRIBE request is received. Application
611 * may use this callback to authorize the incoming subscribe request
612 * (e.g. ask user permission if the request should be granted).
613 *
614 * If this callback is not implemented, all incoming presence subscription
615 * requests will be accepted.
616 *
617 * If this callback is implemented, application has several choices on
618 * what to do with the incoming request:
619 * - it may reject the request immediately by specifying non-200 class
620 * final response in the \a code argument.
621 * - it may immediately accept the request by specifying 200 as the
622 * \a code argument. This is the default value if application doesn't
623 * set any value to the \a code argument. In this case, the library
624 * will automatically send NOTIFY request upon returning from this
625 * callback.
626 * - it may delay the processing of the request, for example to request
627 * user permission whether to accept or reject the request. In this
628 * case, the application MUST set the \a code argument to 202, and
629 * later calls #pjsua_pres_notify() to accept or reject the
630 * subscription request.
631 *
632 * Any \a code other than 200 and 202 will be treated as 200.
633 *
634 * Application MUST return from this callback immediately (e.g. it must
635 * not block in this callback while waiting for user confirmation).
636 *
637 * @param srv_pres Server presence subscription instance. If
638 * application delays the acceptance of the request,
639 * it will need to specify this object when calling
640 * #pjsua_pres_notify().
641 * @param acc_id Account ID most appropriate for this request.
642 * @param buddy_id ID of the buddy matching the sender of the
643 * request, if any, or PJSUA_INVALID_ID if no
644 * matching buddy is found.
645 * @param from The From URI of the request.
646 * @param rdata The incoming request.
647 * @param code The status code to respond to the request. The
648 * default value is 200. Application may set this
649 * to other final status code to accept or reject
650 * the request.
651 * @param reason The reason phrase to respond to the request.
652 * @param msg_data If the application wants to send additional
653 * headers in the response, it can put it in this
654 * parameter.
655 */
656 void (*on_incoming_subscribe)(pjsua_acc_id acc_id,
657 pjsua_srv_pres *srv_pres,
658 pjsua_buddy_id buddy_id,
659 const pj_str_t *from,
660 pjsip_rx_data *rdata,
661 pjsip_status_code *code,
662 pj_str_t *reason,
663 pjsua_msg_data *msg_data);
664
665 /**
666 * Notification when server side subscription state has changed.
667 * This callback is optional as application normally does not need
668 * to do anything to maintain server side presence subscription.
669 *
670 * @param acc_id The account ID.
671 * @param srv_pres Server presence subscription object.
672 * @param remote_uri Remote URI string.
673 * @param state New subscription state.
674 * @param event PJSIP event that triggers the state change.
675 */
676 void (*on_srv_subscribe_state)(pjsua_acc_id acc_id,
677 pjsua_srv_pres *srv_pres,
678 const pj_str_t *remote_uri,
679 pjsip_evsub_state state,
680 pjsip_event *event);
681
682 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000683 * Notify application when the buddy state has changed.
684 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000685 *
686 * @param buddy_id The buddy id.
Benny Prijono9fc735d2006-05-28 14:58:12 +0000687 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000688 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000689
690 /**
691 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000692 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000693 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000694 *
Benny Prijonobbeb3992007-05-21 13:48:35 +0000695 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
696 * passed as one of the argument.
697 *
Benny Prijono0875ae82006-12-26 00:11:48 +0000698 * @param call_id Containts the ID of the call where the IM was
699 * sent, or PJSUA_INVALID_ID if the IM was sent
700 * outside call context.
701 * @param from URI of the sender.
702 * @param to URI of the destination message.
703 * @param contact The Contact URI of the sender, if present.
704 * @param mime_type MIME type of the message.
705 * @param body The message content.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000706 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000707 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
708 const pj_str_t *to, const pj_str_t *contact,
709 const pj_str_t *mime_type, const pj_str_t *body);
710
711 /**
Benny Prijonobbeb3992007-05-21 13:48:35 +0000712 * This is the alternative version of the \a on_pager() callback with
713 * \a pjsip_rx_data argument.
714 *
715 * @param call_id Containts the ID of the call where the IM was
716 * sent, or PJSUA_INVALID_ID if the IM was sent
717 * outside call context.
718 * @param from URI of the sender.
719 * @param to URI of the destination message.
720 * @param contact The Contact URI of the sender, if present.
721 * @param mime_type MIME type of the message.
722 * @param body The message content.
723 * @param rdata The incoming MESSAGE request.
Benny Prijonoba736c42008-07-10 20:45:03 +0000724 * @param acc_id Account ID most suitable for this message.
Benny Prijonobbeb3992007-05-21 13:48:35 +0000725 */
726 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
727 const pj_str_t *to, const pj_str_t *contact,
728 const pj_str_t *mime_type, const pj_str_t *body,
Benny Prijonoba736c42008-07-10 20:45:03 +0000729 pjsip_rx_data *rdata, pjsua_acc_id acc_id);
Benny Prijonobbeb3992007-05-21 13:48:35 +0000730
731 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000732 * Notify application about the delivery status of outgoing pager
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000733 * request. See also on_pager_status2() callback for the version with
734 * \a pjsip_rx_data in the argument list.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000735 *
736 * @param call_id Containts the ID of the call where the IM was
737 * sent, or PJSUA_INVALID_ID if the IM was sent
738 * outside call context.
739 * @param to Destination URI.
740 * @param body Message body.
741 * @param user_data Arbitrary data that was specified when sending
742 * IM message.
743 * @param status Delivery status.
744 * @param reason Delivery status reason.
745 */
746 void (*on_pager_status)(pjsua_call_id call_id,
747 const pj_str_t *to,
748 const pj_str_t *body,
749 void *user_data,
750 pjsip_status_code status,
751 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000752
753 /**
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000754 * Notify application about the delivery status of outgoing pager
755 * request.
756 *
757 * @param call_id Containts the ID of the call where the IM was
758 * sent, or PJSUA_INVALID_ID if the IM was sent
759 * outside call context.
760 * @param to Destination URI.
761 * @param body Message body.
762 * @param user_data Arbitrary data that was specified when sending
763 * IM message.
764 * @param status Delivery status.
765 * @param reason Delivery status reason.
Benny Prijono0a982002007-06-12 16:22:09 +0000766 * @param tdata The original MESSAGE request.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000767 * @param rdata The incoming MESSAGE response, or NULL if the
768 * message transaction fails because of time out
769 * or transport error.
Benny Prijonoba736c42008-07-10 20:45:03 +0000770 * @param acc_id Account ID from this the instant message was
771 * send.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000772 */
773 void (*on_pager_status2)(pjsua_call_id call_id,
774 const pj_str_t *to,
775 const pj_str_t *body,
776 void *user_data,
777 pjsip_status_code status,
778 const pj_str_t *reason,
Benny Prijono0a982002007-06-12 16:22:09 +0000779 pjsip_tx_data *tdata,
Benny Prijonoba736c42008-07-10 20:45:03 +0000780 pjsip_rx_data *rdata,
781 pjsua_acc_id acc_id);
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000782
783 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000784 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +0000785 *
786 * @param call_id Containts the ID of the call where the IM was
787 * sent, or PJSUA_INVALID_ID if the IM was sent
788 * outside call context.
789 * @param from URI of the sender.
790 * @param to URI of the destination message.
791 * @param contact The Contact URI of the sender, if present.
792 * @param is_typing Non-zero if peer is typing, or zero if peer
793 * has stopped typing a message.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000794 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000795 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
796 const pj_str_t *to, const pj_str_t *contact,
797 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000798
Benny Prijono6ba8c542007-10-16 01:34:14 +0000799 /**
Benny Prijonoba736c42008-07-10 20:45:03 +0000800 * Notify application about typing indication.
801 *
802 * @param call_id Containts the ID of the call where the IM was
803 * sent, or PJSUA_INVALID_ID if the IM was sent
804 * outside call context.
805 * @param from URI of the sender.
806 * @param to URI of the destination message.
807 * @param contact The Contact URI of the sender, if present.
808 * @param is_typing Non-zero if peer is typing, or zero if peer
809 * has stopped typing a message.
810 * @param rdata The received request.
811 * @param acc_id Account ID most suitable for this message.
812 */
813 void (*on_typing2)(pjsua_call_id call_id, const pj_str_t *from,
814 const pj_str_t *to, const pj_str_t *contact,
815 pj_bool_t is_typing, pjsip_rx_data *rdata,
816 pjsua_acc_id acc_id);
817
818 /**
Benny Prijono6ba8c542007-10-16 01:34:14 +0000819 * Callback when the library has finished performing NAT type
820 * detection.
821 *
822 * @param res NAT detection result.
823 */
824 void (*on_nat_detect)(const pj_stun_nat_detect_result *res);
825
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000826 /**
827 * This callback is called when the call is about to resend the
828 * INVITE request to the specified target, following the previously
829 * received redirection response.
830 *
831 * Application may accept the redirection to the specified target
832 * (the default behavior if this callback is implemented), reject
833 * this target only and make the session continue to try the next
834 * target in the list if such target exists, stop the whole
835 * redirection process altogether and cause the session to be
836 * disconnected, or defer the decision to ask for user confirmation.
837 *
838 * This callback is optional. If this callback is not implemented,
839 * the default behavior is to NOT follow the redirection response.
840 *
841 * @param call_id The call ID.
842 * @param target The current target to be tried.
Benny Prijono08a48b82008-11-27 12:42:07 +0000843 * @param e The event that caused this callback to be called.
844 * This could be the receipt of 3xx response, or
845 * 4xx/5xx response received for the INVITE sent to
846 * subsequent targets, or NULL if this callback is
847 * called from within #pjsua_call_process_redirect()
848 * context.
849 *
850 * @return Action to be performed for the target. Set this
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000851 * parameter to one of the value below:
852 * - PJSIP_REDIRECT_ACCEPT: immediately accept the
853 * redirection (default value). When set, the
854 * call will immediately resend INVITE request
855 * to the target.
856 * - PJSIP_REDIRECT_REJECT: immediately reject this
857 * target. The call will continue retrying with
858 * next target if present, or disconnect the call
859 * if there is no more target to try.
860 * - PJSIP_REDIRECT_STOP: stop the whole redirection
861 * process and immediately disconnect the call. The
862 * on_call_state() callback will be called with
863 * PJSIP_INV_STATE_DISCONNECTED state immediately
864 * after this callback returns.
865 * - PJSIP_REDIRECT_PENDING: set to this value if
866 * no decision can be made immediately (for example
867 * to request confirmation from user). Application
868 * then MUST call #pjsua_call_process_redirect()
869 * to either accept or reject the redirection upon
870 * getting user decision.
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000871 */
Benny Prijono08a48b82008-11-27 12:42:07 +0000872 pjsip_redirect_op (*on_call_redirected)(pjsua_call_id call_id,
873 const pjsip_uri *target,
874 const pjsip_event *e);
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000875
Benny Prijono4dd961b2009-10-26 11:21:37 +0000876 /**
877 * This callback is called when a NOTIFY request for message summary /
878 * message waiting indication is received.
879 *
880 * @param acc_id The account ID.
881 * @param mwi_info Structure containing details of the event,
882 * including the received NOTIFY request in the
883 * \a rdata field.
884 */
885 void (*on_mwi_info)(pjsua_acc_id acc_id, pjsua_mwi_info *mwi_info);
886
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +0000887 /**
888 * This callback is called when transport state is changed. See also
889 * #pjsip_tp_state_callback.
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +0000890 */
Nanang Izzuddin5e69da52010-02-25 11:58:19 +0000891 pjsip_tp_state_callback on_transport_state;
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +0000892
Benny Prijono4d6ff4d2010-06-19 12:35:33 +0000893 /**
894 * This callback is called to report error in ICE media transport.
895 * Currently it is used to report TURN Refresh error.
896 *
897 * @param index Transport index.
898 * @param op Operation which trigger the failure.
899 * @param status Error status.
900 * @param param Additional info about the event. Currently this will
901 * always be set to NULL.
902 */
903 void (*on_ice_transport_error)(int index, pj_ice_strans_op op,
904 pj_status_t status, void *param);
905
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000906} pjsua_callback;
907
908
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +0000909/**
910 * This enumeration specifies the usage of SIP Session Timers extension.
911 */
912typedef enum pjsua_sip_timer_use
913{
914 /**
915 * When this flag is specified, Session Timers will not be used in any
916 * session, except it is explicitly required in the remote request.
917 */
918 PJSUA_SIP_TIMER_INACTIVE,
919
920 /**
921 * When this flag is specified, Session Timers will be used in all
922 * sessions whenever remote supports and uses it.
923 */
924 PJSUA_SIP_TIMER_OPTIONAL,
925
926 /**
927 * When this flag is specified, Session Timers support will be
928 * a requirement for the remote to be able to establish a session.
929 */
930 PJSUA_SIP_TIMER_REQUIRED,
931
932 /**
933 * When this flag is specified, Session Timers will always be used
934 * in all sessions, regardless whether remote supports/uses it or not.
935 */
936 PJSUA_SIP_TIMER_ALWAYS
937
938} pjsua_sip_timer_use;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000939
Benny Prijonodc39fe82006-05-26 12:17:46 +0000940
941/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000942 * This structure describes the settings to control the API and
943 * user agent behavior, and can be specified when calling #pjsua_init().
944 * Before setting the values, application must call #pjsua_config_default()
945 * to initialize this structure with the default values.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000946 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000947typedef struct pjsua_config
948{
949
950 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000951 * Maximum calls to support (default: 4). The value specified here
952 * must be smaller than the compile time maximum settings
953 * PJSUA_MAX_CALLS, which by default is 32. To increase this
954 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
955 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000956 */
957 unsigned max_calls;
958
959 /**
960 * Number of worker threads. Normally application will want to have at
961 * least one worker thread, unless when it wants to poll the library
962 * periodically, which in this case the worker thread can be set to
963 * zero.
964 */
965 unsigned thread_cnt;
966
967 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +0000968 * Number of nameservers. If no name server is configured, the SIP SRV
969 * resolution would be disabled, and domain will be resolved with
970 * standard pj_gethostbyname() function.
971 */
972 unsigned nameserver_count;
973
974 /**
975 * Array of nameservers to be used by the SIP resolver subsystem.
976 * The order of the name server specifies the priority (first name
977 * server will be used first, unless it is not reachable).
978 */
979 pj_str_t nameserver[4];
980
981 /**
Benny Prijono91d06b62008-09-20 12:16:56 +0000982 * Force loose-route to be used in all route/proxy URIs (outbound_proxy
983 * and account's proxy settings). When this setting is enabled, the
984 * library will check all the route/proxy URIs specified in the settings
985 * and append ";lr" parameter to the URI if the parameter is not present.
986 *
987 * Default: 1
988 */
989 pj_bool_t force_lr;
990
991 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000992 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000993 */
994 unsigned outbound_proxy_cnt;
995
996 /**
997 * Specify the URL of outbound proxies to visit for all outgoing requests.
998 * The outbound proxies will be used for all accounts, and it will
999 * be used to build the route set for outgoing requests. The final
1000 * route set for outgoing requests will consists of the outbound proxies
1001 * and the proxy configured in the account.
1002 */
1003 pj_str_t outbound_proxy[4];
1004
Benny Prijonoc97608e2007-03-23 16:34:20 +00001005 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001006 * Warning: deprecated, please use \a stun_srv field instead. To maintain
1007 * backward compatibility, if \a stun_srv_cnt is zero then the value of
1008 * this field will be copied to \a stun_srv field, if present.
1009 *
Benny Prijonoebbf6892007-03-24 17:37:25 +00001010 * Specify domain name to be resolved with DNS SRV resolution to get the
Benny Prijonof76e1392008-06-06 14:51:48 +00001011 * address of the STUN server. Alternatively application may specify
1012 * \a stun_host instead.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001013 *
1014 * If DNS SRV resolution failed for this domain, then DNS A resolution
1015 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +00001016 */
Benny Prijonoebbf6892007-03-24 17:37:25 +00001017 pj_str_t stun_domain;
1018
1019 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001020 * Warning: deprecated, please use \a stun_srv field instead. To maintain
1021 * backward compatibility, if \a stun_srv_cnt is zero then the value of
1022 * this field will be copied to \a stun_srv field, if present.
1023 *
Benny Prijonoaf09dc32007-04-22 12:48:30 +00001024 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
1025 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001026 */
1027 pj_str_t stun_host;
1028
1029 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001030 * Number of STUN server entries in \a stun_srv array.
1031 */
1032 unsigned stun_srv_cnt;
1033
1034 /**
1035 * Array of STUN servers to try. The library will try to resolve and
1036 * contact each of the STUN server entry until it finds one that is
1037 * usable. Each entry may be a domain name, host name, IP address, and
1038 * it may contain an optional port number. For example:
1039 * - "pjsip.org" (domain name)
1040 * - "sip.pjsip.org" (host name)
1041 * - "pjsip.org:33478" (domain name and a non-standard port number)
1042 * - "10.0.0.1:3478" (IP address and port number)
1043 *
1044 * When nameserver is configured in the \a pjsua_config.nameserver field,
1045 * if entry is not an IP address, it will be resolved with DNS SRV
1046 * resolution first, and it will fallback to use DNS A resolution if this
1047 * fails. Port number may be specified even if the entry is a domain name,
1048 * in case the DNS SRV resolution should fallback to a non-standard port.
1049 *
1050 * When nameserver is not configured, entries will be resolved with
1051 * #pj_gethostbyname() if it's not an IP address. Port number may be
1052 * specified if the server is not listening in standard STUN port.
1053 */
1054 pj_str_t stun_srv[8];
1055
1056 /**
1057 * This specifies if the library startup should ignore failure with the
1058 * STUN servers. If this is set to PJ_FALSE, the library will refuse to
1059 * start if it fails to resolve or contact any of the STUN servers.
1060 *
1061 * Default: PJ_TRUE
1062 */
1063 pj_bool_t stun_ignore_failure;
1064
1065 /**
Benny Prijono91a6a172007-10-31 08:59:29 +00001066 * Support for adding and parsing NAT type in the SDP to assist
1067 * troubleshooting. The valid values are:
1068 * - 0: no information will be added in SDP, and parsing is disabled.
Benny Prijono6ba8c542007-10-16 01:34:14 +00001069 * - 1: only the NAT type number is added.
1070 * - 2: add both NAT type number and name.
1071 *
Benny Prijono91a6a172007-10-31 08:59:29 +00001072 * Default: 1
Benny Prijono6ba8c542007-10-16 01:34:14 +00001073 */
1074 int nat_type_in_sdp;
1075
1076 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001077 * Specify whether support for reliable provisional response (100rel and
1078 * PRACK) should be required by default. Note that this setting can be
1079 * further customized in account configuration (#pjsua_acc_config).
1080 *
1081 * Default: PJ_FALSE
1082 */
1083 pj_bool_t require_100rel;
1084
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001085 /**
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001086 * Specify the usage of Session Timers for all sessions. See the
1087 * #pjsua_sip_timer_use for possible values. Note that this setting can be
1088 * further customized in account configuration (#pjsua_acc_config).
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001089 *
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001090 * Default: PJSUA_SIP_TIMER_OPTIONAL
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001091 */
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001092 pjsua_sip_timer_use use_timer;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001093
1094 /**
Benny Prijonofe1bd342009-11-20 23:33:07 +00001095 * Handle unsolicited NOTIFY requests containing message waiting
1096 * indication (MWI) info. Unsolicited MWI is incoming NOTIFY requests
1097 * which are not requested by client with SUBSCRIBE request.
1098 *
1099 * If this is enabled, the library will respond 200/OK to the NOTIFY
1100 * request and forward the request to \a on_mwi_info() callback.
1101 *
1102 * See also \a mwi_enabled field #on pjsua_acc_config.
1103 *
1104 * Default: PJ_TRUE
1105 *
1106 */
1107 pj_bool_t enable_unsolicited_mwi;
1108
1109 /**
Nanang Izzuddin65add622009-08-11 16:26:20 +00001110 * Specify Session Timer settings, see #pjsip_timer_setting.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001111 * Note that this setting can be further customized in account
1112 * configuration (#pjsua_acc_config).
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001113 */
Nanang Izzuddin65add622009-08-11 16:26:20 +00001114 pjsip_timer_setting timer_setting;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001115
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001116 /**
1117 * Number of credentials in the credential array.
1118 */
1119 unsigned cred_count;
1120
1121 /**
1122 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +00001123 * and can be used to authenticate against outbound proxies. If the
1124 * credential is specific to the account, then application should set
1125 * the credential in the pjsua_acc_config rather than the credential
1126 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001127 */
1128 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1129
1130 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001131 * Application callback to receive various event notifications from
1132 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001133 */
1134 pjsua_callback cb;
1135
Benny Prijono56315612006-07-18 14:39:40 +00001136 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001137 * Optional user agent string (default empty). If it's empty, no
1138 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +00001139 */
1140 pj_str_t user_agent;
1141
Benny Prijonod8179652008-01-23 20:39:07 +00001142#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
1143 /**
1144 * Specify default value of secure media transport usage.
1145 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
1146 * PJMEDIA_SRTP_MANDATORY.
1147 *
1148 * Note that this setting can be further customized in account
1149 * configuration (#pjsua_acc_config).
1150 *
1151 * Default: #PJSUA_DEFAULT_USE_SRTP
1152 */
1153 pjmedia_srtp_use use_srtp;
1154
1155 /**
1156 * Specify whether SRTP requires secure signaling to be used. This option
1157 * is only used when \a use_srtp option above is non-zero.
1158 *
1159 * Valid values are:
1160 * 0: SRTP does not require secure signaling
1161 * 1: SRTP requires secure transport such as TLS
1162 * 2: SRTP requires secure end-to-end transport (SIPS)
1163 *
1164 * Note that this setting can be further customized in account
1165 * configuration (#pjsua_acc_config).
1166 *
1167 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
1168 */
1169 int srtp_secure_signaling;
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00001170
1171 /**
1172 * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose
1173 * duplicated media in SDP offer, i.e: unsecured and secured version.
1174 * Otherwise, the SDP media will be composed as unsecured media but
1175 * with SDP "crypto" attribute.
1176 *
1177 * Default: PJ_FALSE
1178 */
1179 pj_bool_t srtp_optional_dup_offer;
Benny Prijonod8179652008-01-23 20:39:07 +00001180#endif
1181
Benny Prijono3c5e28b2008-09-24 10:10:15 +00001182 /**
1183 * Disconnect other call legs when more than one 2xx responses for
1184 * outgoing INVITE are received due to forking. Currently the library
1185 * is not able to handle simultaneous forked media, so disconnecting
1186 * the other call legs is necessary.
1187 *
1188 * With this setting enabled, the library will handle only one of the
1189 * connected call leg, and the other connected call legs will be
1190 * disconnected.
1191 *
1192 * Default: PJ_TRUE (only disable this setting for testing purposes).
1193 */
1194 pj_bool_t hangup_forked_call;
1195
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001196} pjsua_config;
1197
1198
1199/**
1200 * Use this function to initialize pjsua config.
1201 *
1202 * @param cfg pjsua config to be initialized.
1203 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001204PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001205
1206
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001207/** The implementation has been moved to sip_auth.h */
Benny Prijono7977f9f2007-10-10 11:37:56 +00001208#define pjsip_cred_dup pjsip_cred_info_dup
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001209
1210
1211/**
1212 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001213 *
1214 * @param pool The pool to get memory from.
1215 * @param dst Destination config.
1216 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001217 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001218PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1219 pjsua_config *dst,
1220 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001221
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001222
1223/**
1224 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001225 * outgoing SIP message. It can (optionally) be specified for example
1226 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1227 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1228 *
1229 * Application MUST call #pjsua_msg_data_init() to initialize this
1230 * structure before setting its values.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001231 */
Benny Prijono63fba012008-07-17 14:19:10 +00001232struct pjsua_msg_data
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001233{
1234 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001235 * Additional message headers as linked list. Application can add
1236 * headers to the list by creating the header, either from the heap/pool
1237 * or from temporary local variable, and add the header using
1238 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001239 */
1240 pjsip_hdr hdr_list;
1241
1242 /**
1243 * MIME type of optional message body.
1244 */
1245 pj_str_t content_type;
1246
1247 /**
Benny Prijono1c1d7342010-08-01 09:48:51 +00001248 * Optional message body to be added to the message, only when the
1249 * message doesn't have a body.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001250 */
1251 pj_str_t msg_body;
1252
Benny Prijono1c1d7342010-08-01 09:48:51 +00001253 /**
1254 * Content type of the multipart body. If application wants to send
1255 * multipart message bodies, it puts the parts in \a parts and set
1256 * the content type in \a multipart_ctype. If the message already
1257 * contains a body, the body will be added to the multipart bodies.
1258 */
1259 pjsip_media_type multipart_ctype;
1260
1261 /**
1262 * List of multipart parts. If application wants to send multipart
1263 * message bodies, it puts the parts in \a parts and set the content
1264 * type in \a multipart_ctype. If the message already contains a body,
1265 * the body will be added to the multipart bodies.
1266 */
1267 pjsip_multipart_part multipart_parts;
Benny Prijono63fba012008-07-17 14:19:10 +00001268};
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001269
1270
1271/**
1272 * Initialize message data.
1273 *
1274 * @param msg_data Message data to be initialized.
1275 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001276PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001277
Benny Prijono268ca612006-02-07 12:34:11 +00001278
1279/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001280 * Instantiate pjsua application. Application must call this function before
1281 * calling any other functions, to make sure that the underlying libraries
1282 * are properly initialized. Once this function has returned success,
1283 * application must call pjsua_destroy() before quitting.
1284 *
1285 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00001286 */
1287PJ_DECL(pj_status_t) pjsua_create(void);
1288
1289
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001290/** Forward declaration */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001291typedef struct pjsua_media_config pjsua_media_config;
1292
1293
Benny Prijonodc39fe82006-05-26 12:17:46 +00001294/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001295 * Initialize pjsua with the specified settings. All the settings are
1296 * optional, and the default values will be used when the config is not
1297 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001298 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001299 * Note that #pjsua_create() MUST be called before calling this function.
1300 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001301 * @param ua_cfg User agent configuration.
1302 * @param log_cfg Optional logging configuration.
1303 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001304 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001305 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001306 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001307PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1308 const pjsua_logging_config *log_cfg,
1309 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001310
1311
1312/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001313 * Application is recommended to call this function after all initialization
1314 * is done, so that the library can do additional checking set up
1315 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001316 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001317 * Application may call this function anytime after #pjsua_init().
1318 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001319 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoccf95622006-02-07 18:48:01 +00001320 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001321PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001322
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001323
Benny Prijonoccf95622006-02-07 18:48:01 +00001324/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001325 * Destroy pjsua. Application is recommended to perform graceful shutdown
1326 * before calling this function (such as unregister the account from the SIP
1327 * server, terminate presense subscription, and hangup active calls), however,
1328 * this function will do all of these if it finds there are active sessions
1329 * that need to be terminated. This function will approximately block for
1330 * one second to wait for replies from remote.
1331 *
1332 * Application.may safely call this function more than once if it doesn't
1333 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001334 *
1335 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001336 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001337PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001338
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001339
Benny Prijono9fc735d2006-05-28 14:58:12 +00001340/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001341 * Poll pjsua for events, and if necessary block the caller thread for
1342 * the specified maximum interval (in miliseconds).
1343 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001344 * Application doesn't normally need to call this function if it has
1345 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1346 * because polling then will be done by these worker threads instead.
1347 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001348 * @param msec_timeout Maximum time to wait, in miliseconds.
1349 *
1350 * @return The number of events that have been handled during the
1351 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001352 * can retrieve the error as (status = -return_value).
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001353 */
1354PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1355
1356
1357/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001358 * Create memory pool to be used by the application. Once application
1359 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001360 *
1361 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001362 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001363 * @param increment Increment size.
1364 *
1365 * @return The pool, or NULL when there's no memory.
1366 */
1367PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1368 pj_size_t increment);
1369
1370
1371/**
1372 * Application can call this function at any time (after pjsua_create(), of
1373 * course) to change logging settings.
1374 *
1375 * @param c Logging configuration.
1376 *
1377 * @return PJ_SUCCESS on success, or the appropriate error code.
1378 */
1379PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1380
1381
1382/**
1383 * Internal function to get SIP endpoint instance of pjsua, which is
1384 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001385 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001386 *
1387 * @return SIP endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001388 */
1389PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1390
1391/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001392 * Internal function to get media endpoint instance.
1393 * Only valid after #pjsua_init() is called.
1394 *
1395 * @return Media endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001396 */
1397PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1398
Benny Prijono97b87172006-08-24 14:25:14 +00001399/**
1400 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001401 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001402 *
1403 * @return Pool factory currently used by PJSUA.
1404 */
1405PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1406
1407
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001408
1409/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001410 * Utilities.
1411 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001412 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001413
1414/**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001415 * This structure is used to represent the result of the STUN server
1416 * resolution and testing, the #pjsua_resolve_stun_servers() function.
1417 * This structure will be passed in #pj_stun_resolve_cb callback.
1418 */
1419typedef struct pj_stun_resolve_result
1420{
1421 /**
1422 * Arbitrary data that was passed to #pjsua_resolve_stun_servers()
1423 * function.
1424 */
1425 void *token;
1426
1427 /**
1428 * This will contain PJ_SUCCESS if at least one usable STUN server
1429 * is found, otherwise it will contain the last error code during
1430 * the operation.
1431 */
1432 pj_status_t status;
1433
1434 /**
1435 * The server name that yields successful result. This will only
1436 * contain value if status is successful.
1437 */
1438 pj_str_t name;
1439
1440 /**
1441 * The server IP address. This will only contain value if status
1442 * is successful.
1443 */
1444 pj_sockaddr addr;
1445
1446} pj_stun_resolve_result;
1447
1448
1449/**
1450 * Typedef of callback to be registered to #pjsua_resolve_stun_servers().
1451 */
1452typedef void (*pj_stun_resolve_cb)(const pj_stun_resolve_result *result);
1453
1454/**
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001455 * This is a utility function to detect NAT type in front of this
1456 * endpoint. Once invoked successfully, this function will complete
Benny Prijono6ba8c542007-10-16 01:34:14 +00001457 * asynchronously and report the result in \a on_nat_detect() callback
1458 * of pjsua_callback.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001459 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001460 * After NAT has been detected and the callback is called, application can
1461 * get the detected NAT type by calling #pjsua_get_nat_type(). Application
1462 * can also perform NAT detection by calling #pjsua_detect_nat_type()
1463 * again at later time.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001464 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001465 * Note that STUN must be enabled to run this function successfully.
1466 *
1467 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001468 */
Benny Prijono6ba8c542007-10-16 01:34:14 +00001469PJ_DECL(pj_status_t) pjsua_detect_nat_type(void);
1470
1471
1472/**
1473 * Get the NAT type as detected by #pjsua_detect_nat_type() function.
1474 * This function will only return useful NAT type after #pjsua_detect_nat_type()
1475 * has completed successfully and \a on_nat_detect() callback has been called.
1476 *
1477 * @param type NAT type.
1478 *
1479 * @return When detection is in progress, this function will
1480 * return PJ_EPENDING and \a type will be set to
1481 * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been
1482 * detected successfully, this function will return
1483 * PJ_SUCCESS and \a type will be set to the correct
1484 * value. Other return values indicate error and
1485 * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN.
Benny Prijono91a6a172007-10-31 08:59:29 +00001486 *
1487 * @see pjsua_call_get_rem_nat_type()
Benny Prijono6ba8c542007-10-16 01:34:14 +00001488 */
1489PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type);
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001490
1491
1492/**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001493 * Auxiliary function to resolve and contact each of the STUN server
1494 * entries (sequentially) to find which is usable. The #pjsua_init() must
1495 * have been called before calling this function.
1496 *
1497 * @param count Number of STUN server entries to try.
1498 * @param srv Array of STUN server entries to try. Please see
1499 * the \a stun_srv field in the #pjsua_config
1500 * documentation about the format of this entry.
1501 * @param wait Specify non-zero to make the function block until
1502 * it gets the result. In this case, the function
1503 * will block while the resolution is being done,
1504 * and the callback will be called before this function
1505 * returns.
1506 * @param token Arbitrary token to be passed back to application
1507 * in the callback.
1508 * @param cb Callback to be called to notify the result of
1509 * the function.
1510 *
1511 * @return If \a wait parameter is non-zero, this will return
1512 * PJ_SUCCESS if one usable STUN server is found.
1513 * Otherwise it will always return PJ_SUCCESS, and
1514 * application will be notified about the result in
1515 * the callback.
1516 */
1517PJ_DECL(pj_status_t) pjsua_resolve_stun_servers(unsigned count,
1518 pj_str_t srv[],
1519 pj_bool_t wait,
1520 void *token,
1521 pj_stun_resolve_cb cb);
1522
1523/**
1524 * Cancel pending STUN resolution which match the specified token.
1525 *
1526 * @param token The token to match. This token was given to
1527 * #pjsua_resolve_stun_servers()
1528 * @param notify_cb Boolean to control whether the callback should
1529 * be called for cancelled resolutions. When the
1530 * callback is called, the status in the result
1531 * will be set as PJ_ECANCELLED.
1532 *
1533 * @return PJ_SUCCESS if there is at least one pending STUN
1534 * resolution cancelled, or PJ_ENOTFOUND if there is
1535 * no matching one, or other error.
1536 */
1537PJ_DECL(pj_status_t) pjsua_cancel_stun_resolution(void *token,
1538 pj_bool_t notify_cb);
1539
1540
1541/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001542 * This is a utility function to verify that valid SIP url is given. If the
1543 * URL is valid, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001544 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001545 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001546 *
1547 * @return PJ_SUCCESS on success, or the appropriate error code.
1548 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001549PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001550
1551
1552/**
Benny Prijono73bb7232009-10-20 13:56:26 +00001553 * Schedule a timer entry. Note that the timer callback may be executed
1554 * by different thread, depending on whether worker thread is enabled or
1555 * not.
1556 *
1557 * @param entry Timer heap entry.
1558 * @param delay The interval to expire.
1559 *
1560 * @return PJ_SUCCESS on success, or the appropriate error code.
1561 *
1562 * @see pjsip_endpt_schedule_timer()
1563 */
1564PJ_DECL(pj_status_t) pjsua_schedule_timer(pj_timer_entry *entry,
1565 const pj_time_val *delay);
1566
1567
1568/**
1569 * Cancel the previously scheduled timer.
1570 *
1571 * @param entry Timer heap entry.
1572 *
1573 * @see pjsip_endpt_cancel_timer()
1574 */
1575PJ_DECL(void) pjsua_cancel_timer(pj_timer_entry *entry);
1576
1577
1578/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001579 * This is a utility function to display error message for the specified
1580 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001581 *
1582 * @param sender The log sender field.
1583 * @param title Message title for the error.
1584 * @param status Status code.
1585 */
1586PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1587 pj_status_t status);
1588
1589
Benny Prijonoda9785b2007-04-02 20:43:06 +00001590/**
1591 * This is a utility function to dump the stack states to log, using
1592 * verbosity level 3.
1593 *
1594 * @param detail Will print detailed output (such as list of
1595 * SIP transactions) when non-zero.
1596 */
1597PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001598
1599/**
1600 * @}
1601 */
1602
1603
1604
1605/*****************************************************************************
1606 * TRANSPORT API
1607 */
1608
1609/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001610 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001611 * @ingroup PJSUA_LIB
1612 * @brief API for managing SIP transports
1613 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001614 *
1615 * PJSUA-API supports creating multiple transport instances, for example UDP,
1616 * TCP, and TLS transport. SIP transport must be created before adding an
1617 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001618 */
1619
1620
Benny Prijonoe6ead542007-01-31 20:53:31 +00001621/** SIP transport identification.
1622 */
Benny Prijono312aff92006-06-17 04:08:30 +00001623typedef int pjsua_transport_id;
1624
1625
1626/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001627 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001628 * and media. Before setting some values to this structure, application
1629 * MUST call #pjsua_transport_config_default() to initialize its
1630 * values with default settings.
Benny Prijono312aff92006-06-17 04:08:30 +00001631 */
1632typedef struct pjsua_transport_config
1633{
1634 /**
1635 * UDP port number to bind locally. This setting MUST be specified
1636 * even when default port is desired. If the value is zero, the
1637 * transport will be bound to any available port, and application
1638 * can query the port by querying the transport info.
1639 */
1640 unsigned port;
1641
1642 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001643 * Optional address to advertise as the address of this transport.
1644 * Application can specify any address or hostname for this field,
1645 * for example it can point to one of the interface address in the
1646 * system, or it can point to the public address of a NAT router
1647 * where port mappings have been configured for the application.
1648 *
1649 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001650 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001651 pj_str_t public_addr;
1652
1653 /**
1654 * Optional address where the socket should be bound to. This option
1655 * SHOULD only be used to selectively bind the socket to particular
1656 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1657 * published address of a transport (the public_addr field should be
1658 * used for that purpose).
1659 *
1660 * Note that unlike public_addr field, the address (or hostname) here
1661 * MUST correspond to the actual interface address in the host, since
1662 * this address will be specified as bind() argument.
1663 */
1664 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001665
1666 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001667 * This specifies TLS settings for TLS transport. It is only be used
1668 * when this transport config is being used to create a SIP TLS
1669 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001670 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001671 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001672
Benny Prijono4d79b0f2009-10-25 09:02:07 +00001673 /**
1674 * QoS traffic type to be set on this transport. When application wants
1675 * to apply QoS tagging to the transport, it's preferable to set this
1676 * field rather than \a qos_param fields since this is more portable.
1677 *
1678 * Default is QoS not set.
1679 */
1680 pj_qos_type qos_type;
1681
1682 /**
1683 * Set the low level QoS parameters to the transport. This is a lower
1684 * level operation than setting the \a qos_type field and may not be
1685 * supported on all platforms.
1686 *
1687 * Default is QoS not set.
1688 */
1689 pj_qos_params qos_params;
1690
Benny Prijono312aff92006-06-17 04:08:30 +00001691} pjsua_transport_config;
1692
1693
1694/**
1695 * Call this function to initialize UDP config with default values.
1696 *
1697 * @param cfg The UDP config to be initialized.
1698 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001699PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001700
1701
1702/**
Benny Prijono312aff92006-06-17 04:08:30 +00001703 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001704 *
1705 * @param pool The pool.
1706 * @param dst The destination config.
1707 * @param src The source config.
Benny Prijono312aff92006-06-17 04:08:30 +00001708 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001709PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1710 pjsua_transport_config *dst,
1711 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001712
1713
1714/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001715 * This structure describes transport information returned by
1716 * #pjsua_transport_get_info() function.
Benny Prijono312aff92006-06-17 04:08:30 +00001717 */
1718typedef struct pjsua_transport_info
1719{
1720 /**
1721 * PJSUA transport identification.
1722 */
1723 pjsua_transport_id id;
1724
1725 /**
1726 * Transport type.
1727 */
1728 pjsip_transport_type_e type;
1729
1730 /**
1731 * Transport type name.
1732 */
1733 pj_str_t type_name;
1734
1735 /**
1736 * Transport string info/description.
1737 */
1738 pj_str_t info;
1739
1740 /**
1741 * Transport flag (see ##pjsip_transport_flags_e).
1742 */
1743 unsigned flag;
1744
1745 /**
1746 * Local address length.
1747 */
1748 unsigned addr_len;
1749
1750 /**
1751 * Local/bound address.
1752 */
1753 pj_sockaddr local_addr;
1754
1755 /**
1756 * Published address (or transport address name).
1757 */
1758 pjsip_host_port local_name;
1759
1760 /**
1761 * Current number of objects currently referencing this transport.
1762 */
1763 unsigned usage_count;
1764
1765
1766} pjsua_transport_info;
1767
1768
1769/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001770 * Create and start a new SIP transport according to the specified
1771 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001772 *
1773 * @param type Transport type.
1774 * @param cfg Transport configuration.
1775 * @param p_id Optional pointer to receive transport ID.
1776 *
1777 * @return PJ_SUCCESS on success, or the appropriate error code.
1778 */
1779PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1780 const pjsua_transport_config *cfg,
1781 pjsua_transport_id *p_id);
1782
1783/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001784 * Register transport that has been created by application. This function
1785 * is useful if application wants to implement custom SIP transport and use
1786 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001787 *
1788 * @param tp Transport instance.
1789 * @param p_id Optional pointer to receive transport ID.
1790 *
1791 * @return PJ_SUCCESS on success, or the appropriate error code.
1792 */
1793PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1794 pjsua_transport_id *p_id);
1795
1796
1797/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001798 * Enumerate all transports currently created in the system. This function
1799 * will return all transport IDs, and application may then call
1800 * #pjsua_transport_get_info() function to retrieve detailed information
1801 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001802 *
1803 * @param id Array to receive transport ids.
1804 * @param count In input, specifies the maximum number of elements.
1805 * On return, it contains the actual number of elements.
1806 *
1807 * @return PJ_SUCCESS on success, or the appropriate error code.
1808 */
1809PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1810 unsigned *count );
1811
1812
1813/**
1814 * Get information about transports.
1815 *
1816 * @param id Transport ID.
1817 * @param info Pointer to receive transport info.
1818 *
1819 * @return PJ_SUCCESS on success, or the appropriate error code.
1820 */
1821PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1822 pjsua_transport_info *info);
1823
1824
1825/**
1826 * Disable a transport or re-enable it. By default transport is always
1827 * enabled after it is created. Disabling a transport does not necessarily
1828 * close the socket, it will only discard incoming messages and prevent
1829 * the transport from being used to send outgoing messages.
1830 *
1831 * @param id Transport ID.
1832 * @param enabled Non-zero to enable, zero to disable.
1833 *
1834 * @return PJ_SUCCESS on success, or the appropriate error code.
1835 */
1836PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1837 pj_bool_t enabled);
1838
1839
1840/**
1841 * Close the transport. If transport is forcefully closed, it will be
1842 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00001843 * transport may not terminate properly (it may even crash). Otherwise,
1844 * the system will wait until all transactions are closed while preventing
1845 * new users from using the transport, and will close the transport when
1846 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001847 *
1848 * @param id Transport ID.
1849 * @param force Non-zero to immediately close the transport. This
1850 * is not recommended!
1851 *
1852 * @return PJ_SUCCESS on success, or the appropriate error code.
1853 */
1854PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1855 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001856
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001857/**
Benny Prijono312aff92006-06-17 04:08:30 +00001858 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001859 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001860
1861
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001862
1863
1864/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001865 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001866 */
1867
Benny Prijono312aff92006-06-17 04:08:30 +00001868
1869/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001870 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001871 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001872 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001873 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001874 *
Benny Prijono312aff92006-06-17 04:08:30 +00001875 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001876 * using the application. In SIP terms, the identity is used as the <b>From</b>
1877 * header in outgoing requests.
1878 *
1879 * PJSUA-API supports creating and managing multiple accounts. The maximum
1880 * number of accounts is limited by a compile time constant
1881 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001882 *
1883 * Account may or may not have client registration associated with it.
1884 * An account is also associated with <b>route set</b> and some <b>authentication
1885 * credentials</b>, which are used when sending SIP request messages using the
1886 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00001887 * will be reported to remote peer when they subscribe to the account's
1888 * presence, or which is published to a presence server if presence
1889 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00001890 *
1891 * At least one account MUST be created in the application. If no user
1892 * association is required, application can create a userless account by
1893 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00001894 * instead of a particular user, and it correspond with a particular
1895 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00001896 *
1897 * Also one account must be set as the <b>default account</b>, which is used as
1898 * the account to use when PJSUA fails to match a request with any other
1899 * accounts.
1900 *
1901 * When sending outgoing SIP requests (such as making calls or sending
1902 * instant messages), normally PJSUA requires the application to specify
1903 * which account to use for the request. If no account is specified,
1904 * PJSUA may be able to select the account by matching the destination
1905 * domain name, and fall back to default account when no match is found.
1906 */
1907
1908/**
1909 * Maximum accounts.
1910 */
1911#ifndef PJSUA_MAX_ACC
1912# define PJSUA_MAX_ACC 8
1913#endif
1914
1915
1916/**
1917 * Default registration interval.
1918 */
1919#ifndef PJSUA_REG_INTERVAL
Benny Prijonobddef2c2007-10-31 13:28:08 +00001920# define PJSUA_REG_INTERVAL 300
Benny Prijono312aff92006-06-17 04:08:30 +00001921#endif
1922
1923
1924/**
Benny Prijono384dab42009-10-14 01:58:04 +00001925 * Default maximum time to wait for account unregistration transactions to
1926 * complete during library shutdown sequence.
1927 *
1928 * Default: 4000 (4 seconds)
1929 */
1930#ifndef PJSUA_UNREG_TIMEOUT
1931# define PJSUA_UNREG_TIMEOUT 4000
1932#endif
1933
1934
1935/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001936 * Default PUBLISH expiration
1937 */
1938#ifndef PJSUA_PUBLISH_EXPIRATION
Benny Prijono53984d12009-04-28 22:19:49 +00001939# define PJSUA_PUBLISH_EXPIRATION PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001940#endif
1941
1942
1943/**
Benny Prijono093d3022006-09-24 00:07:11 +00001944 * Default account priority.
1945 */
1946#ifndef PJSUA_DEFAULT_ACC_PRIORITY
1947# define PJSUA_DEFAULT_ACC_PRIORITY 0
1948#endif
1949
1950
1951/**
Benny Prijono8058a622007-06-08 04:37:05 +00001952 * This macro specifies the URI scheme to use in Contact header
1953 * when secure transport such as TLS is used. Application can specify
1954 * either "sip" or "sips".
1955 */
1956#ifndef PJSUA_SECURE_SCHEME
Benny Prijono4c82c1e2008-10-16 08:14:51 +00001957# define PJSUA_SECURE_SCHEME "sip"
Benny Prijono8058a622007-06-08 04:37:05 +00001958#endif
1959
1960
1961/**
Benny Prijono534a9ba2009-10-13 14:01:59 +00001962 * Maximum time to wait for unpublication transaction(s) to complete
1963 * during shutdown process, before sending unregistration. The library
1964 * tries to wait for the unpublication (un-PUBLISH) to complete before
1965 * sending REGISTER request to unregister the account, during library
1966 * shutdown process. If the value is set too short, it is possible that
1967 * the unregistration is sent before unpublication completes, causing
1968 * unpublication request to fail.
1969 *
1970 * Default: 2000 (2 seconds)
1971 */
1972#ifndef PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
1973# define PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC 2000
1974#endif
1975
1976
1977/**
Nanang Izzuddin36dd5b62010-03-30 11:13:59 +00001978 * Default auto retry re-registration interval, in seconds. Set to 0
1979 * to disable this. Application can set the timer on per account basis
1980 * by setting the pjsua_acc_config.reg_retry_interval field instead.
1981 *
1982 * Default: 300 (5 minutes)
1983 */
1984#ifndef PJSUA_REG_RETRY_INTERVAL
1985# define PJSUA_REG_RETRY_INTERVAL 300
1986#endif
1987
1988
1989/**
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00001990 * This macro specifies the default value for \a contact_rewrite_method
1991 * field in pjsua_acc_config. I specifies how Contact update will be
1992 * done with the registration, if \a allow_contact_rewrite is enabled in
1993 * the account config.
1994 *
1995 * If set to 1, the Contact update will be done by sending unregistration
1996 * to the currently registered Contact, while simultaneously sending new
1997 * registration (with different Call-ID) for the updated Contact.
1998 *
1999 * If set to 2, the Contact update will be done in a single, current
2000 * registration session, by removing the current binding (by setting its
2001 * Contact's expires parameter to zero) and adding a new Contact binding,
2002 * all done in a single request.
2003 *
2004 * Value 1 is the legacy behavior.
2005 *
2006 * Default value: 2
2007 */
2008#ifndef PJSUA_CONTACT_REWRITE_METHOD
2009# define PJSUA_CONTACT_REWRITE_METHOD 2
2010#endif
2011
2012
2013/**
Benny Prijono29c8ca32010-06-22 06:02:13 +00002014 * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that
2015 * the global outbound proxy list should be added to the REGISTER request.
2016 */
2017#define PJSUA_REG_USE_OUTBOUND_PROXY 1
2018
2019
2020/**
2021 * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that
2022 * the account proxy list should be added to the REGISTER request.
2023 */
2024#define PJSUA_REG_USE_ACC_PROXY 2
2025
2026
2027/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002028 * This structure describes account configuration to be specified when
2029 * adding a new account with #pjsua_acc_add(). Application MUST initialize
2030 * this structure first by calling #pjsua_acc_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00002031 */
2032typedef struct pjsua_acc_config
2033{
Benny Prijono093d3022006-09-24 00:07:11 +00002034 /**
Benny Prijono705e7842008-07-21 18:12:51 +00002035 * Arbitrary user data to be associated with the newly created account.
2036 * Application may set this later with #pjsua_acc_set_user_data() and
2037 * retrieve it with #pjsua_acc_get_user_data().
2038 */
2039 void *user_data;
2040
2041 /**
Benny Prijono093d3022006-09-24 00:07:11 +00002042 * Account priority, which is used to control the order of matching
2043 * incoming/outgoing requests. The higher the number means the higher
2044 * the priority is, and the account will be matched first.
2045 */
2046 int priority;
2047
Benny Prijono312aff92006-06-17 04:08:30 +00002048 /**
2049 * The full SIP URL for the account. The value can take name address or
2050 * URL format, and will look something like "sip:account@serviceprovider".
2051 *
2052 * This field is mandatory.
2053 */
2054 pj_str_t id;
2055
2056 /**
2057 * This is the URL to be put in the request URI for the registration,
2058 * and will look something like "sip:serviceprovider".
2059 *
2060 * This field should be specified if registration is desired. If the
2061 * value is empty, no account registration will be performed.
2062 */
2063 pj_str_t reg_uri;
2064
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002065 /**
Benny Prijonofe1bd342009-11-20 23:33:07 +00002066 * Subscribe to message waiting indication events (RFC 3842).
2067 *
2068 * See also \a enable_unsolicited_mwi field on #pjsua_config.
Benny Prijono4dd961b2009-10-26 11:21:37 +00002069 *
2070 * Default: no
2071 */
2072 pj_bool_t mwi_enabled;
2073
2074 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002075 * If this flag is set, the presence information of this account will
2076 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono48ab2b72007-11-08 09:24:30 +00002077 *
2078 * Default: PJ_FALSE
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002079 */
2080 pj_bool_t publish_enabled;
2081
Benny Prijonofe04fb52007-08-24 08:28:52 +00002082 /**
Benny Prijonofe50c9e2009-10-12 07:44:14 +00002083 * Event publication options.
2084 */
2085 pjsip_publishc_opt publish_opt;
2086
2087 /**
Benny Prijono534a9ba2009-10-13 14:01:59 +00002088 * Maximum time to wait for unpublication transaction(s) to complete
2089 * during shutdown process, before sending unregistration. The library
2090 * tries to wait for the unpublication (un-PUBLISH) to complete before
2091 * sending REGISTER request to unregister the account, during library
2092 * shutdown process. If the value is set too short, it is possible that
2093 * the unregistration is sent before unpublication completes, causing
2094 * unpublication request to fail.
2095 *
2096 * Default: PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
2097 */
2098 unsigned unpublish_max_wait_time_msec;
2099
2100 /**
Benny Prijono48ab2b72007-11-08 09:24:30 +00002101 * Authentication preference.
2102 */
2103 pjsip_auth_clt_pref auth_pref;
2104
2105 /**
Benny Prijonofe04fb52007-08-24 08:28:52 +00002106 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
2107 * is not specified, a random string will be used.
2108 */
2109 pj_str_t pidf_tuple_id;
2110
Benny Prijono312aff92006-06-17 04:08:30 +00002111 /**
2112 * Optional URI to be put as Contact for this account. It is recommended
2113 * that this field is left empty, so that the value will be calculated
2114 * automatically based on the transport address.
2115 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00002116 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00002117
2118 /**
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00002119 * Additional parameters that will be appended in the Contact header
Benny Prijono30fe4852008-12-10 16:54:16 +00002120 * for this account. This will affect the Contact header in all SIP
2121 * messages sent on behalf of this account, including but not limited to
2122 * REGISTER, INVITE, and SUBCRIBE requests or responses.
2123 *
2124 * The parameters should be preceeded by semicolon, and all strings must
2125 * be properly escaped. Example:
2126 * ";my-param=X;another-param=Hi%20there"
2127 */
2128 pj_str_t contact_params;
2129
2130 /**
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00002131 * Additional URI parameters that will be appended in the Contact URI
2132 * for this account. This will affect the Contact URI in all SIP
2133 * messages sent on behalf of this account, including but not limited to
2134 * REGISTER, INVITE, and SUBCRIBE requests or responses.
2135 *
2136 * The parameters should be preceeded by semicolon, and all strings must
2137 * be properly escaped. Example:
2138 * ";my-param=X;another-param=Hi%20there"
2139 */
2140 pj_str_t contact_uri_params;
2141
2142 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00002143 * Specify whether support for reliable provisional response (100rel and
2144 * PRACK) should be required for all sessions of this account.
2145 *
2146 * Default: PJ_FALSE
2147 */
2148 pj_bool_t require_100rel;
2149
2150 /**
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002151 * Specify the usage of Session Timers for all sessions. See the
2152 * #pjsua_sip_timer_use for possible values.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002153 *
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002154 * Default: PJSUA_SIP_TIMER_OPTIONAL
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002155 */
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002156 pjsua_sip_timer_use use_timer;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002157
2158 /**
Nanang Izzuddin65add622009-08-11 16:26:20 +00002159 * Specify Session Timer settings, see #pjsip_timer_setting.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002160 */
Nanang Izzuddin65add622009-08-11 16:26:20 +00002161 pjsip_timer_setting timer_setting;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002162
2163 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002164 * Number of proxies in the proxy array below.
2165 */
2166 unsigned proxy_cnt;
2167
2168 /**
2169 * Optional URI of the proxies to be visited for all outgoing requests
2170 * that are using this account (REGISTER, INVITE, etc). Application need
2171 * to specify these proxies if the service provider requires that requests
2172 * destined towards its network should go through certain proxies first
2173 * (for example, border controllers).
2174 *
2175 * These proxies will be put in the route set for this account, with
2176 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00002177 * first). If global outbound proxies are configured in pjsua_config,
2178 * then these account proxies will be placed after the global outbound
2179 * proxies in the routeset.
Benny Prijono312aff92006-06-17 04:08:30 +00002180 */
2181 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
2182
2183 /**
2184 * Optional interval for registration, in seconds. If the value is zero,
Benny Prijonobddef2c2007-10-31 13:28:08 +00002185 * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
Benny Prijono312aff92006-06-17 04:08:30 +00002186 */
2187 unsigned reg_timeout;
2188
Benny Prijono384dab42009-10-14 01:58:04 +00002189 /**
2190 * Specify the maximum time to wait for unregistration requests to
2191 * complete during library shutdown sequence.
2192 *
2193 * Default: PJSUA_UNREG_TIMEOUT
2194 */
2195 unsigned unreg_timeout;
2196
Benny Prijono312aff92006-06-17 04:08:30 +00002197 /**
2198 * Number of credentials in the credential array.
2199 */
2200 unsigned cred_count;
2201
2202 /**
2203 * Array of credentials. If registration is desired, normally there should
2204 * be at least one credential specified, to successfully authenticate
2205 * against the service provider. More credentials can be specified, for
2206 * example when the requests are expected to be challenged by the
2207 * proxies in the route set.
2208 */
2209 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
2210
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002211 /**
2212 * Optionally bind this account to specific transport. This normally is
2213 * not a good idea, as account should be able to send requests using
2214 * any available transports according to the destination. But some
2215 * application may want to have explicit control over the transport to
2216 * use, so in that case it can set this field.
2217 *
2218 * Default: -1 (PJSUA_INVALID_ID)
2219 *
2220 * @see pjsua_acc_set_transport()
2221 */
2222 pjsua_transport_id transport_id;
2223
Benny Prijono15b02302007-09-27 14:07:07 +00002224 /**
Benny Prijonocca2e432010-02-25 09:33:18 +00002225 * This option is used to update the transport address and the Contact
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002226 * header of REGISTER request. When this option is enabled, the library
2227 * will keep track of the public IP address from the response of REGISTER
2228 * request. Once it detects that the address has changed, it will
2229 * unregister current Contact, update the Contact with transport address
2230 * learned from Via header, and register a new Contact to the registrar.
2231 * This will also update the public name of UDP transport if STUN is
Benny Prijonocca2e432010-02-25 09:33:18 +00002232 * configured.
Benny Prijono15b02302007-09-27 14:07:07 +00002233 *
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00002234 * See also contact_rewrite_method field.
2235 *
Benny Prijono15b02302007-09-27 14:07:07 +00002236 * Default: 1 (yes)
2237 */
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002238 pj_bool_t allow_contact_rewrite;
Benny Prijono15b02302007-09-27 14:07:07 +00002239
Benny Prijonobddef2c2007-10-31 13:28:08 +00002240 /**
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00002241 * Specify how Contact update will be done with the registration, if
2242 * \a allow_contact_rewrite is enabled.
2243 *
2244 * If set to 1, the Contact update will be done by sending unregistration
2245 * to the currently registered Contact, while simultaneously sending new
2246 * registration (with different Call-ID) for the updated Contact.
2247 *
2248 * If set to 2, the Contact update will be done in a single, current
2249 * registration session, by removing the current binding (by setting its
2250 * Contact's expires parameter to zero) and adding a new Contact binding,
2251 * all done in a single request.
2252 *
2253 * Value 1 is the legacy behavior.
2254 *
2255 * Default value: PJSUA_CONTACT_REWRITE_METHOD (2)
2256 */
2257 int contact_rewrite_method;
2258
2259 /**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002260 * Set the interval for periodic keep-alive transmission for this account.
2261 * If this value is zero, keep-alive will be disabled for this account.
2262 * The keep-alive transmission will be sent to the registrar's address,
2263 * after successful registration.
2264 *
Benny Prijonobddef2c2007-10-31 13:28:08 +00002265 * Default: 15 (seconds)
2266 */
2267 unsigned ka_interval;
2268
2269 /**
2270 * Specify the data to be transmitted as keep-alive packets.
2271 *
2272 * Default: CR-LF
2273 */
2274 pj_str_t ka_data;
2275
Benny Prijonod8179652008-01-23 20:39:07 +00002276#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
2277 /**
2278 * Specify whether secure media transport should be used for this account.
2279 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
2280 * PJMEDIA_SRTP_MANDATORY.
2281 *
2282 * Default: #PJSUA_DEFAULT_USE_SRTP
2283 */
2284 pjmedia_srtp_use use_srtp;
2285
2286 /**
2287 * Specify whether SRTP requires secure signaling to be used. This option
2288 * is only used when \a use_srtp option above is non-zero.
2289 *
2290 * Valid values are:
2291 * 0: SRTP does not require secure signaling
2292 * 1: SRTP requires secure transport such as TLS
2293 * 2: SRTP requires secure end-to-end transport (SIPS)
2294 *
2295 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
2296 */
2297 int srtp_secure_signaling;
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00002298
2299 /**
2300 * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose
2301 * duplicated media in SDP offer, i.e: unsecured and secured version.
2302 * Otherwise, the SDP media will be composed as unsecured media but
2303 * with SDP "crypto" attribute.
2304 *
2305 * Default: PJ_FALSE
2306 */
2307 pj_bool_t srtp_optional_dup_offer;
Benny Prijonod8179652008-01-23 20:39:07 +00002308#endif
2309
Nanang Izzuddin36dd5b62010-03-30 11:13:59 +00002310 /**
2311 * Specify interval of auto registration retry upon registration failure
2312 * (including caused by transport problem), in second. Set to 0 to
2313 * disable auto re-registration.
2314 *
2315 * Default: #PJSUA_REG_RETRY_INTERVAL
2316 */
2317 unsigned reg_retry_interval;
2318
2319 /**
2320 * Specify whether calls of the configured account should be dropped
2321 * after registration failure and an attempt of re-registration has
2322 * also failed.
2323 *
2324 * Default: PJ_FALSE (disabled)
2325 */
2326 pj_bool_t drop_calls_on_reg_fail;
2327
Benny Prijono29c8ca32010-06-22 06:02:13 +00002328 /**
2329 * Specify how the registration uses the outbound and account proxy
2330 * settings. This controls if and what Route headers will appear in
2331 * the REGISTER request of this account. The value is bitmask combination
2332 * of PJSUA_REG_USE_OUTBOUND_PROXY and PJSUA_REG_USE_ACC_PROXY bits.
2333 * If the value is set to 0, the REGISTER request will not use any proxy
2334 * (i.e. it will not have any Route headers).
2335 *
2336 * Default: 3 (PJSUA_REG_USE_OUTBOUND_PROXY | PJSUA_REG_USE_ACC_PROXY)
2337 */
2338 unsigned reg_use_proxy;
2339
Nanang Izzuddin5e39a2b2010-09-20 06:13:02 +00002340#if defined(PJMEDIA_STREAM_ENABLE_KA) && (PJMEDIA_STREAM_ENABLE_KA != 0)
2341 /**
2342 * Specify whether stream keep-alive and NAT hole punching with
2343 * non-codec-VAD mechanism (see @ref PJMEDIA_STREAM_ENABLE_KA) is enabled
2344 * for this account.
2345 *
2346 * Default: PJ_FALSE (disabled)
2347 */
2348 pj_bool_t use_stream_ka;
2349#endif
2350
Benny Prijono312aff92006-06-17 04:08:30 +00002351} pjsua_acc_config;
2352
2353
2354/**
2355 * Call this function to initialize account config with default values.
2356 *
2357 * @param cfg The account config to be initialized.
2358 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00002359PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002360
2361
2362/**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002363 * Duplicate account config.
2364 *
2365 * @param pool Pool to be used for duplicating the config.
2366 * @param dst Destination configuration.
2367 * @param src Source configuration.
2368 */
2369PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
2370 pjsua_acc_config *dst,
2371 const pjsua_acc_config *src);
2372
2373
2374/**
Benny Prijono312aff92006-06-17 04:08:30 +00002375 * Account info. Application can query account info by calling
2376 * #pjsua_acc_get_info().
2377 */
2378typedef struct pjsua_acc_info
2379{
2380 /**
2381 * The account ID.
2382 */
2383 pjsua_acc_id id;
2384
2385 /**
2386 * Flag to indicate whether this is the default account.
2387 */
2388 pj_bool_t is_default;
2389
2390 /**
2391 * Account URI
2392 */
2393 pj_str_t acc_uri;
2394
2395 /**
2396 * Flag to tell whether this account has registration setting
2397 * (reg_uri is not empty).
2398 */
2399 pj_bool_t has_registration;
2400
2401 /**
2402 * An up to date expiration interval for account registration session.
2403 */
2404 int expires;
2405
2406 /**
2407 * Last registration status code. If status code is zero, the account
2408 * is currently not registered. Any other value indicates the SIP
2409 * status code of the registration.
2410 */
2411 pjsip_status_code status;
2412
2413 /**
Sauw Ming48f6dbf2010-09-07 05:10:25 +00002414 * Last registration error code. When the status field contains a SIP
2415 * status code that indicates a registration failure, last registration
2416 * error code contains the error code that causes the failure. In any
2417 * other case, its value is zero.
2418 */
2419 pj_status_t reg_last_err;
2420
2421 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002422 * String describing the registration status.
2423 */
2424 pj_str_t status_text;
2425
2426 /**
2427 * Presence online status for this account.
2428 */
2429 pj_bool_t online_status;
2430
2431 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00002432 * Presence online status text.
2433 */
2434 pj_str_t online_status_text;
2435
2436 /**
2437 * Extended RPID online status information.
2438 */
2439 pjrpid_element rpid;
2440
2441 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002442 * Buffer that is used internally to store the status text.
2443 */
2444 char buf_[PJ_ERR_MSG_SIZE];
2445
2446} pjsua_acc_info;
2447
2448
2449
2450/**
2451 * Get number of current accounts.
2452 *
2453 * @return Current number of accounts.
2454 */
2455PJ_DECL(unsigned) pjsua_acc_get_count(void);
2456
2457
2458/**
2459 * Check if the specified account ID is valid.
2460 *
2461 * @param acc_id Account ID to check.
2462 *
2463 * @return Non-zero if account ID is valid.
2464 */
2465PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
2466
2467
2468/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00002469 * Set default account to be used when incoming and outgoing
2470 * requests doesn't match any accounts.
2471 *
2472 * @param acc_id The account ID to be used as default.
2473 *
2474 * @return PJ_SUCCESS on success.
2475 */
2476PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2477
2478
2479/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002480 * Get default account to be used when receiving incoming requests (calls),
2481 * when the destination of the incoming call doesn't match any other
2482 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002483 *
2484 * @return The default account ID, or PJSUA_INVALID_ID if no
2485 * default account is configured.
2486 */
2487PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2488
2489
2490/**
Benny Prijono312aff92006-06-17 04:08:30 +00002491 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002492 * #pjsua_init()) before calling this function. If registration is configured
2493 * for this account, this function would also start the SIP registration
2494 * session with the SIP registrar server. This SIP registration session
2495 * will be maintained internally by the library, and application doesn't
2496 * need to do anything to maintain the registration session.
2497 *
Benny Prijono312aff92006-06-17 04:08:30 +00002498 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002499 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002500 * @param is_default If non-zero, this account will be set as the default
2501 * account. The default account will be used when sending
2502 * outgoing requests (e.g. making call) when no account is
2503 * specified, and when receiving incoming requests when the
2504 * request does not match any accounts. It is recommended
2505 * that default account is set to local/LAN account.
2506 * @param p_acc_id Pointer to receive account ID of the new account.
2507 *
2508 * @return PJ_SUCCESS on success, or the appropriate error code.
2509 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002510PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002511 pj_bool_t is_default,
2512 pjsua_acc_id *p_acc_id);
2513
2514
2515/**
2516 * Add a local account. A local account is used to identify local endpoint
2517 * instead of a specific user, and for this reason, a transport ID is needed
2518 * to obtain the local address information.
2519 *
2520 * @param tid Transport ID to generate account address.
2521 * @param is_default If non-zero, this account will be set as the default
2522 * account. The default account will be used when sending
2523 * outgoing requests (e.g. making call) when no account is
2524 * specified, and when receiving incoming requests when the
2525 * request does not match any accounts. It is recommended
2526 * that default account is set to local/LAN account.
2527 * @param p_acc_id Pointer to receive account ID of the new account.
2528 *
2529 * @return PJ_SUCCESS on success, or the appropriate error code.
2530 */
2531PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2532 pj_bool_t is_default,
2533 pjsua_acc_id *p_acc_id);
2534
2535/**
Benny Prijono705e7842008-07-21 18:12:51 +00002536 * Set arbitrary data to be associated with the account.
2537 *
2538 * @param acc_id The account ID.
2539 * @param user_data User/application data.
2540 *
2541 * @return PJ_SUCCESS on success, or the appropriate error code.
2542 */
2543PJ_DECL(pj_status_t) pjsua_acc_set_user_data(pjsua_acc_id acc_id,
2544 void *user_data);
2545
2546
2547/**
2548 * Retrieve arbitrary data associated with the account.
2549 *
2550 * @param acc_id The account ID.
2551 *
2552 * @return The user data. In the case where the account ID is
2553 * not valid, NULL is returned.
2554 */
2555PJ_DECL(void*) pjsua_acc_get_user_data(pjsua_acc_id acc_id);
2556
2557
2558/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002559 * Delete an account. This will unregister the account from the SIP server,
2560 * if necessary, and terminate server side presence subscriptions associated
2561 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002562 *
2563 * @param acc_id Id of the account to be deleted.
2564 *
2565 * @return PJ_SUCCESS on success, or the appropriate error code.
2566 */
2567PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2568
2569
2570/**
2571 * Modify account information.
2572 *
2573 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002574 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002575 *
2576 * @return PJ_SUCCESS on success, or the appropriate error code.
2577 */
2578PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002579 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002580
2581
2582/**
2583 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002584 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002585 * if there are server side presence subscription for this account, and/or
2586 * outgoing PUBLISH if presence publication is enabled for this account.
2587 *
2588 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002589 *
2590 * @param acc_id The account ID.
2591 * @param is_online True of false.
2592 *
2593 * @return PJ_SUCCESS on success, or the appropriate error code.
2594 */
2595PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2596 pj_bool_t is_online);
2597
Benny Prijono4461c7d2007-08-25 13:36:15 +00002598/**
2599 * Modify account's presence status to be advertised to remote/presence
2600 * subscribers. This would trigger the sending of outgoing NOTIFY request
2601 * if there are server side presence subscription for this account, and/or
2602 * outgoing PUBLISH if presence publication is enabled for this account.
2603 *
2604 * @see pjsua_acc_set_online_status()
2605 *
2606 * @param acc_id The account ID.
2607 * @param is_online True of false.
2608 * @param pr Extended information in subset of RPID format
2609 * which allows setting custom presence text.
2610 *
2611 * @return PJ_SUCCESS on success, or the appropriate error code.
2612 */
2613PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2614 pj_bool_t is_online,
2615 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002616
2617/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002618 * Update registration or perform unregistration. If registration is
2619 * configured for this account, then initial SIP REGISTER will be sent
2620 * when the account is added with #pjsua_acc_add(). Application normally
2621 * only need to call this function if it wants to manually update the
2622 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002623 *
2624 * @param acc_id The account ID.
2625 * @param renew If renew argument is zero, this will start
2626 * unregistration process.
2627 *
2628 * @return PJ_SUCCESS on success, or the appropriate error code.
2629 */
2630PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2631 pj_bool_t renew);
2632
Benny Prijono312aff92006-06-17 04:08:30 +00002633/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002634 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002635 *
2636 * @param acc_id Account identification.
2637 * @param info Pointer to receive account information.
2638 *
2639 * @return PJ_SUCCESS on success, or the appropriate error code.
2640 */
2641PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2642 pjsua_acc_info *info);
2643
2644
2645/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002646 * Enumerate all account currently active in the library. This will fill
2647 * the array with the account Ids, and application can then query the
2648 * account information for each id with #pjsua_acc_get_info().
2649 *
2650 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002651 *
2652 * @param ids Array of account IDs to be initialized.
2653 * @param count In input, specifies the maximum number of elements.
2654 * On return, it contains the actual number of elements.
2655 *
2656 * @return PJ_SUCCESS on success, or the appropriate error code.
2657 */
2658PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2659 unsigned *count );
2660
2661
2662/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002663 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002664 *
2665 * @param info Array of account infos to be initialized.
2666 * @param count In input, specifies the maximum number of elements.
2667 * On return, it contains the actual number of elements.
2668 *
2669 * @return PJ_SUCCESS on success, or the appropriate error code.
2670 */
2671PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2672 unsigned *count );
2673
2674
2675/**
2676 * This is an internal function to find the most appropriate account to
2677 * used to reach to the specified URL.
2678 *
2679 * @param url The remote URL to reach.
2680 *
2681 * @return Account id.
2682 */
2683PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2684
2685
2686/**
2687 * This is an internal function to find the most appropriate account to be
2688 * used to handle incoming calls.
2689 *
2690 * @param rdata The incoming request message.
2691 *
2692 * @return Account id.
2693 */
2694PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2695
2696
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002697/**
Benny Prijonofff245c2007-04-02 11:44:47 +00002698 * Create arbitrary requests using the account. Application should only use
2699 * this function to create auxiliary requests outside dialog, such as
2700 * OPTIONS, and use the call or presence API to create dialog related
2701 * requests.
2702 *
2703 * @param acc_id The account ID.
2704 * @param method The SIP method of the request.
2705 * @param target Target URI.
2706 * @param p_tdata Pointer to receive the request.
2707 *
2708 * @return PJ_SUCCESS or the error code.
2709 */
2710PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
2711 const pjsip_method *method,
2712 const pj_str_t *target,
2713 pjsip_tx_data **p_tdata);
2714
2715
2716/**
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002717 * Create a suitable Contact header value, based on the specified target URI
2718 * for the specified account.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002719 *
2720 * @param pool Pool to allocate memory for the string.
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002721 * @param contact The string where the Contact will be stored.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002722 * @param acc_id Account ID.
2723 * @param uri Destination URI of the request.
2724 *
2725 * @return PJ_SUCCESS on success, other on error.
2726 */
2727PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
2728 pj_str_t *contact,
2729 pjsua_acc_id acc_id,
2730 const pj_str_t *uri);
2731
2732
2733
2734/**
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002735 * Create a suitable Contact header value, based on the information in the
2736 * incoming request.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002737 *
2738 * @param pool Pool to allocate memory for the string.
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002739 * @param contact The string where the Contact will be stored.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002740 * @param acc_id Account ID.
2741 * @param rdata Incoming request.
2742 *
2743 * @return PJ_SUCCESS on success, other on error.
2744 */
2745PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
2746 pj_str_t *contact,
2747 pjsua_acc_id acc_id,
2748 pjsip_rx_data *rdata );
2749
2750
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002751/**
2752 * Lock/bind this account to a specific transport/listener. Normally
2753 * application shouldn't need to do this, as transports will be selected
2754 * automatically by the stack according to the destination.
2755 *
2756 * When account is locked/bound to a specific transport, all outgoing
2757 * requests from this account will use the specified transport (this
2758 * includes SIP registration, dialog (call and event subscription), and
2759 * out-of-dialog requests such as MESSAGE).
2760 *
2761 * Note that transport_id may be specified in pjsua_acc_config too.
2762 *
2763 * @param acc_id The account ID.
2764 * @param tp_id The transport ID.
2765 *
2766 * @return PJ_SUCCESS on success.
2767 */
2768PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
2769 pjsua_transport_id tp_id);
2770
Benny Prijono312aff92006-06-17 04:08:30 +00002771
2772/**
2773 * @}
2774 */
2775
2776
2777/*****************************************************************************
2778 * CALLS API
2779 */
2780
2781
2782/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002783 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00002784 * @ingroup PJSUA_LIB
2785 * @brief Call manipulation.
2786 * @{
2787 */
2788
2789/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002790 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00002791 */
2792#ifndef PJSUA_MAX_CALLS
2793# define PJSUA_MAX_CALLS 32
2794#endif
2795
2796
2797
2798/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002799 * This enumeration specifies the media status of a call, and it's part
2800 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00002801 */
2802typedef enum pjsua_call_media_status
2803{
Benny Prijonob5388cf2007-01-04 22:45:08 +00002804 /** Call currently has no media */
Benny Prijono312aff92006-06-17 04:08:30 +00002805 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002806
2807 /** The media is active */
Benny Prijono312aff92006-06-17 04:08:30 +00002808 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002809
2810 /** The media is currently put on hold by local endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002811 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002812
2813 /** The media is currently put on hold by remote endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002814 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002815
Benny Prijono096c56c2007-09-15 08:30:16 +00002816 /** The media has reported error (e.g. ICE negotiation) */
2817 PJSUA_CALL_MEDIA_ERROR
2818
Benny Prijono312aff92006-06-17 04:08:30 +00002819} pjsua_call_media_status;
2820
2821
2822/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002823 * This structure describes the information and current status of a call.
Benny Prijono312aff92006-06-17 04:08:30 +00002824 */
2825typedef struct pjsua_call_info
2826{
2827 /** Call identification. */
2828 pjsua_call_id id;
2829
2830 /** Initial call role (UAC == caller) */
2831 pjsip_role_e role;
2832
Benny Prijono90315512006-09-14 16:05:16 +00002833 /** The account ID where this call belongs. */
2834 pjsua_acc_id acc_id;
2835
Benny Prijono312aff92006-06-17 04:08:30 +00002836 /** Local URI */
2837 pj_str_t local_info;
2838
2839 /** Local Contact */
2840 pj_str_t local_contact;
2841
2842 /** Remote URI */
2843 pj_str_t remote_info;
2844
2845 /** Remote contact */
2846 pj_str_t remote_contact;
2847
2848 /** Dialog Call-ID string. */
2849 pj_str_t call_id;
2850
2851 /** Call state */
2852 pjsip_inv_state state;
2853
2854 /** Text describing the state */
2855 pj_str_t state_text;
2856
2857 /** Last status code heard, which can be used as cause code */
2858 pjsip_status_code last_status;
2859
2860 /** The reason phrase describing the status. */
2861 pj_str_t last_status_text;
2862
2863 /** Call media status. */
2864 pjsua_call_media_status media_status;
2865
2866 /** Media direction */
2867 pjmedia_dir media_dir;
2868
2869 /** The conference port number for the call */
2870 pjsua_conf_port_id conf_slot;
2871
2872 /** Up-to-date call connected duration (zero when call is not
2873 * established)
2874 */
2875 pj_time_val connect_duration;
2876
2877 /** Total call duration, including set-up time */
2878 pj_time_val total_duration;
2879
2880 /** Internal */
2881 struct {
2882 char local_info[128];
2883 char local_contact[128];
2884 char remote_info[128];
2885 char remote_contact[128];
2886 char call_id[128];
2887 char last_status_text[128];
2888 } buf_;
2889
2890} pjsua_call_info;
2891
2892
2893
Benny Prijonoa91a0032006-02-26 21:23:45 +00002894/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002895 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002896 *
2897 * @return Maximum number of calls configured.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002898 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002899PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002900
2901/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002902 * Get number of currently active calls.
2903 *
2904 * @return Number of currently active calls.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002905 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002906PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002907
2908/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002909 * Enumerate all active calls. Application may then query the information and
2910 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002911 *
2912 * @param ids Array of account IDs to be initialized.
2913 * @param count In input, specifies the maximum number of elements.
2914 * On return, it contains the actual number of elements.
2915 *
2916 * @return PJ_SUCCESS on success, or the appropriate error code.
2917 */
2918PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
2919 unsigned *count);
2920
2921
2922/**
2923 * Make outgoing call to the specified URI using the specified account.
2924 *
2925 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002926 * @param dst_uri URI to be put in the To header (normally is the same
2927 * as the target URI).
2928 * @param options Options (must be zero at the moment).
2929 * @param user_data Arbitrary user data to be attached to the call, and
2930 * can be retrieved later.
2931 * @param msg_data Optional headers etc to be added to outgoing INVITE
2932 * request, or NULL if no custom header is desired.
2933 * @param p_call_id Pointer to receive call identification.
2934 *
2935 * @return PJ_SUCCESS on success, or the appropriate error code.
2936 */
2937PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
2938 const pj_str_t *dst_uri,
2939 unsigned options,
2940 void *user_data,
2941 const pjsua_msg_data *msg_data,
2942 pjsua_call_id *p_call_id);
2943
2944
2945/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002946 * Check if the specified call has active INVITE session and the INVITE
2947 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002948 *
2949 * @param call_id Call identification.
2950 *
2951 * @return Non-zero if call is active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002952 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002953PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002954
2955
2956/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002957 * Check if call has an active media session.
2958 *
2959 * @param call_id Call identification.
2960 *
2961 * @return Non-zero if yes.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002962 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002963PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002964
2965
2966/**
Benny Prijonocf986c42008-09-02 11:25:07 +00002967 * Retrieve the media session associated with this call. Note that the media
2968 * session may not be available depending on the current call's media status
2969 * (the pjsua_call_media_status information in pjsua_call_info). Application
2970 * may use the media session to retrieve more detailed information about the
2971 * call's media.
2972 *
2973 * @param call_id Call identification.
2974 *
2975 * @return Call media session.
2976 */
2977PJ_DECL(pjmedia_session*) pjsua_call_get_media_session(pjsua_call_id call_id);
2978
2979
2980/**
2981 * Retrieve the media transport instance that is used for this call.
2982 * Application may use the media transport to query more detailed information
2983 * about the media transport.
2984 *
2985 * @param cid Call identification (the call_id).
2986 *
2987 * @return Call media transport.
2988 */
2989PJ_DECL(pjmedia_transport*) pjsua_call_get_media_transport(pjsua_call_id cid);
2990
2991
2992/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002993 * Get the conference port identification associated with the call.
2994 *
2995 * @param call_id Call identification.
2996 *
2997 * @return Conference port ID, or PJSUA_INVALID_ID when the
2998 * media has not been established or is not active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002999 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003000PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
3001
3002/**
3003 * Obtain detail information about the specified call.
3004 *
3005 * @param call_id Call identification.
3006 * @param info Call info to be initialized.
3007 *
3008 * @return PJ_SUCCESS on success, or the appropriate error code.
3009 */
3010PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003011 pjsua_call_info *info);
3012
Nanang Izzuddin2a1b9ee2010-06-03 10:41:32 +00003013/**
3014 * Check if remote peer support the specified capability.
3015 *
3016 * @param call_id Call identification.
3017 * @param htype The header type to be checked, which value may be:
3018 * - PJSIP_H_ACCEPT
3019 * - PJSIP_H_ALLOW
3020 * - PJSIP_H_SUPPORTED
3021 * @param hname If htype specifies PJSIP_H_OTHER, then the header
3022 * name must be supplied in this argument. Otherwise the
3023 * value must be set to NULL.
3024 * @param token The capability token to check. For example, if \a
3025 * htype is PJSIP_H_ALLOW, then \a token specifies the
3026 * method names; if \a htype is PJSIP_H_SUPPORTED, then
3027 * \a token specifies the extension names such as
3028 * "100rel".
3029 *
3030 * @return PJSIP_DIALOG_CAP_SUPPORTED if the specified capability
3031 * is explicitly supported, see @pjsip_dialog_cap_status
3032 * for more info.
3033 */
3034PJ_DECL(pjsip_dialog_cap_status) pjsua_call_remote_has_cap(
3035 pjsua_call_id call_id,
3036 int htype,
3037 const pj_str_t *hname,
3038 const pj_str_t *token);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003039
3040/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003041 * Attach application specific data to the call. Application can then
3042 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003043 *
3044 * @param call_id Call identification.
3045 * @param user_data Arbitrary data to be attached to the call.
3046 *
3047 * @return The user data.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003048 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003049PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
3050 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003051
3052
3053/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003054 * Get user data attached to the call, which has been previously set with
3055 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003056 *
3057 * @param call_id Call identification.
3058 *
3059 * @return The user data.
Benny Prijono268ca612006-02-07 12:34:11 +00003060 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003061PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00003062
3063
3064/**
Benny Prijono91a6a172007-10-31 08:59:29 +00003065 * Get the NAT type of remote's endpoint. This is a proprietary feature
3066 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
3067 * is set in #pjsua_config.
3068 *
3069 * This function can only be called after SDP has been received from remote,
3070 * which means for incoming call, this function can be called as soon as
3071 * call is received as long as incoming call contains SDP, and for outgoing
3072 * call, this function can be called only after SDP is received (normally in
3073 * 200/OK response to INVITE). As a general case, application should call
3074 * this function after or in \a on_call_media_state() callback.
3075 *
3076 * @param call_id Call identification.
3077 * @param p_type Pointer to store the NAT type. Application can then
3078 * retrieve the string description of the NAT type
3079 * by calling pj_stun_get_nat_name().
3080 *
3081 * @return PJ_SUCCESS on success.
3082 *
3083 * @see pjsua_get_nat_type(), nat_type_in_sdp
3084 */
3085PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
3086 pj_stun_nat_type *p_type);
3087
3088/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003089 * Send response to incoming INVITE request. Depending on the status
3090 * code specified as parameter, this function may send provisional
3091 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003092 *
3093 * @param call_id Incoming call identification.
3094 * @param code Status code, (100-699).
3095 * @param reason Optional reason phrase. If NULL, default text
3096 * will be used.
3097 * @param msg_data Optional list of headers etc to be added to outgoing
3098 * response message.
3099 *
3100 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoa91a0032006-02-26 21:23:45 +00003101 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003102PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
3103 unsigned code,
3104 const pj_str_t *reason,
3105 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00003106
3107/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003108 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00003109 * call state. This function is different than answering the call with
3110 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
3111 * will hangup the call regardless of the state and role of the call,
3112 * while #pjsua_call_answer() only works with incoming calls on EARLY
3113 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003114 *
3115 * @param call_id Call identification.
3116 * @param code Optional status code to be sent when we're rejecting
3117 * incoming call. If the value is zero, "603/Decline"
3118 * will be sent.
3119 * @param reason Optional reason phrase to be sent when we're rejecting
3120 * incoming call. If NULL, default text will be used.
3121 * @param msg_data Optional list of headers etc to be added to outgoing
3122 * request/response message.
3123 *
3124 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003125 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003126PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
3127 unsigned code,
3128 const pj_str_t *reason,
3129 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003130
Benny Prijono5e51a4e2008-11-27 00:06:46 +00003131/**
3132 * Accept or reject redirection response. Application MUST call this function
3133 * after it signaled PJSIP_REDIRECT_PENDING in the \a on_call_redirected()
3134 * callback, to notify the call whether to accept or reject the redirection
3135 * to the current target. Application can use the combination of
3136 * PJSIP_REDIRECT_PENDING command in \a on_call_redirected() callback and
3137 * this function to ask for user permission before redirecting the call.
3138 *
3139 * Note that if the application chooses to reject or stop redirection (by
3140 * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the
3141 * call disconnection callback will be called before this function returns.
3142 * And if the application rejects the target, the \a on_call_redirected()
3143 * callback may also be called before this function returns if there is
3144 * another target to try.
3145 *
3146 * @param call_id The call ID.
3147 * @param cmd Redirection operation to be applied to the current
3148 * target. The semantic of this argument is similar
3149 * to the description in the \a on_call_redirected()
3150 * callback, except that the PJSIP_REDIRECT_PENDING is
3151 * not accepted here.
3152 *
3153 * @return PJ_SUCCESS on successful operation.
3154 */
3155PJ_DECL(pj_status_t) pjsua_call_process_redirect(pjsua_call_id call_id,
3156 pjsip_redirect_op cmd);
Benny Prijono26ff9062006-02-21 23:47:00 +00003157
3158/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003159 * Put the specified call on hold. This will send re-INVITE with the
3160 * appropriate SDP to inform remote that the call is being put on hold.
3161 * The final status of the request itself will be reported on the
3162 * \a on_call_media_state() callback, which inform the application that
3163 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003164 *
3165 * @param call_id Call identification.
3166 * @param msg_data Optional message components to be sent with
3167 * the request.
3168 *
3169 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003170 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003171PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
3172 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003173
3174
3175/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003176 * Send re-INVITE to release hold.
3177 * The final status of the request itself will be reported on the
3178 * \a on_call_media_state() callback, which inform the application that
3179 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003180 *
3181 * @param call_id Call identification.
3182 * @param unhold If this argument is non-zero and the call is locally
3183 * held, this will release the local hold.
3184 * @param msg_data Optional message components to be sent with
3185 * the request.
3186 *
3187 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003188 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003189PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
3190 pj_bool_t unhold,
3191 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003192
Benny Prijonoc08682e2007-10-04 06:17:58 +00003193/**
3194 * Send UPDATE request.
3195 *
3196 * @param call_id Call identification.
3197 * @param options Must be zero for now.
3198 * @param msg_data Optional message components to be sent with
3199 * the request.
3200 *
3201 * @return PJ_SUCCESS on success, or the appropriate error code.
3202 */
3203PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
3204 unsigned options,
3205 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003206
3207/**
Benny Prijono053f5222006-11-11 16:16:04 +00003208 * Initiate call transfer to the specified address. This function will send
3209 * REFER request to instruct remote call party to initiate a new INVITE
3210 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003211 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00003212 * If application is interested to monitor the successfulness and
3213 * the progress of the transfer request, it can implement
3214 * \a on_call_transfer_status() callback which will report the progress
3215 * of the call transfer request.
3216 *
Benny Prijono053f5222006-11-11 16:16:04 +00003217 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003218 * @param dest Address of new target to be contacted.
3219 * @param msg_data Optional message components to be sent with
3220 * the request.
3221 *
3222 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003223 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003224PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
3225 const pj_str_t *dest,
3226 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003227
3228/**
Benny Prijono053f5222006-11-11 16:16:04 +00003229 * Flag to indicate that "Require: replaces" should not be put in the
3230 * outgoing INVITE request caused by REFER request created by
3231 * #pjsua_call_xfer_replaces().
3232 */
3233#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
3234
3235/**
3236 * Initiate attended call transfer. This function will send REFER request
3237 * to instruct remote call party to initiate new INVITE session to the URL
3238 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
3239 * the call with us with the new call from the REFER recipient.
3240 *
3241 * @param call_id The call id to be transfered.
3242 * @param dest_call_id The call id to be replaced.
3243 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
3244 * to suppress the inclusion of "Require: replaces" in
3245 * the outgoing INVITE request created by the REFER
3246 * request.
3247 * @param msg_data Optional message components to be sent with
3248 * the request.
3249 *
3250 * @return PJ_SUCCESS on success, or the appropriate error code.
3251 */
3252PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
3253 pjsua_call_id dest_call_id,
3254 unsigned options,
3255 const pjsua_msg_data *msg_data);
3256
3257/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003258 * Send DTMF digits to remote using RFC 2833 payload formats.
3259 *
3260 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003261 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003262 *
3263 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003264 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003265PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003266 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00003267
Benny Prijono26ff9062006-02-21 23:47:00 +00003268/**
Benny Prijonob0808372006-03-02 21:18:58 +00003269 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003270 *
3271 * @param call_id Call identification.
3272 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3273 * assumed.
3274 * @param content The message content.
3275 * @param msg_data Optional list of headers etc to be included in outgoing
3276 * request. The body descriptor in the msg_data is
3277 * ignored.
3278 * @param user_data Optional user data, which will be given back when
3279 * the IM callback is called.
3280 *
3281 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003282 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003283PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
3284 const pj_str_t *mime_type,
3285 const pj_str_t *content,
3286 const pjsua_msg_data *msg_data,
3287 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003288
3289
3290/**
3291 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003292 *
3293 * @param call_id Call identification.
3294 * @param is_typing Non-zero to indicate to remote that local person is
3295 * currently typing an IM.
3296 * @param msg_data Optional list of headers etc to be included in outgoing
3297 * request.
3298 *
3299 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003300 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003301PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
3302 pj_bool_t is_typing,
3303 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003304
3305/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00003306 * Send arbitrary request with the call. This is useful for example to send
3307 * INFO request. Note that application should not use this function to send
3308 * requests which would change the invite session's state, such as re-INVITE,
3309 * UPDATE, PRACK, and BYE.
3310 *
3311 * @param call_id Call identification.
3312 * @param method SIP method of the request.
3313 * @param msg_data Optional message body and/or list of headers to be
3314 * included in outgoing request.
3315 *
3316 * @return PJ_SUCCESS on success, or the appropriate error code.
3317 */
3318PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
3319 const pj_str_t *method,
3320 const pjsua_msg_data *msg_data);
3321
3322
3323/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003324 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
3325 * currently active calls.
Benny Prijono834aee32006-02-19 01:38:06 +00003326 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00003327PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00003328
3329
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003330/**
3331 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003332 *
3333 * @param call_id Call identification.
3334 * @param with_media Non-zero to include media information too.
3335 * @param buffer Buffer where the statistics are to be written to.
3336 * @param maxlen Maximum length of buffer.
3337 * @param indent Spaces for left indentation.
3338 *
3339 * @return PJ_SUCCESS on success.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003340 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003341PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
3342 pj_bool_t with_media,
3343 char *buffer,
3344 unsigned maxlen,
3345 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003346
Benny Prijono9fc735d2006-05-28 14:58:12 +00003347/**
Benny Prijono312aff92006-06-17 04:08:30 +00003348 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003349 */
Benny Prijono834aee32006-02-19 01:38:06 +00003350
3351
3352/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00003353 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00003354 */
3355
Benny Prijono312aff92006-06-17 04:08:30 +00003356
3357/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003358 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00003359 * @ingroup PJSUA_LIB
3360 * @brief Buddy management, buddy's presence, and instant messaging.
3361 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00003362 *
3363 * This section describes PJSUA-APIs related to buddies management,
3364 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00003365 */
3366
3367/**
3368 * Max buddies in buddy list.
3369 */
3370#ifndef PJSUA_MAX_BUDDIES
3371# define PJSUA_MAX_BUDDIES 256
3372#endif
3373
3374
3375/**
Benny Prijono6ab05322009-10-21 03:03:06 +00003376 * This specifies how long the library should wait before retrying failed
3377 * SUBSCRIBE request, and there is no rule to automatically resubscribe
3378 * (for example, no "retry-after" parameter in Subscription-State header).
3379 *
3380 * This also controls the duration before failed PUBLISH request will be
3381 * retried.
Benny Prijonoa17496a2007-10-31 10:20:31 +00003382 *
3383 * Default: 300 seconds
3384 */
3385#ifndef PJSUA_PRES_TIMER
3386# define PJSUA_PRES_TIMER 300
3387#endif
3388
3389
3390/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003391 * This structure describes buddy configuration when adding a buddy to
3392 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
3393 * the structure with #pjsua_buddy_config_default() to initialize this
3394 * structure with default configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00003395 */
3396typedef struct pjsua_buddy_config
3397{
3398 /**
3399 * Buddy URL or name address.
3400 */
3401 pj_str_t uri;
3402
3403 /**
3404 * Specify whether presence subscription should start immediately.
3405 */
3406 pj_bool_t subscribe;
3407
Benny Prijono705e7842008-07-21 18:12:51 +00003408 /**
3409 * Specify arbitrary application data to be associated with with
3410 * the buddy object.
3411 */
3412 void *user_data;
3413
Benny Prijono312aff92006-06-17 04:08:30 +00003414} pjsua_buddy_config;
3415
3416
3417/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003418 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003419 */
3420typedef enum pjsua_buddy_status
3421{
3422 /**
3423 * Online status is unknown (possibly because no presence subscription
3424 * has been established).
3425 */
3426 PJSUA_BUDDY_STATUS_UNKNOWN,
3427
3428 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003429 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003430 */
3431 PJSUA_BUDDY_STATUS_ONLINE,
3432
3433 /**
3434 * Buddy is offline.
3435 */
3436 PJSUA_BUDDY_STATUS_OFFLINE,
3437
3438} pjsua_buddy_status;
3439
3440
3441
3442/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003443 * This structure describes buddy info, which can be retrieved by calling
3444 * #pjsua_buddy_get_info().
Benny Prijono312aff92006-06-17 04:08:30 +00003445 */
3446typedef struct pjsua_buddy_info
3447{
3448 /**
3449 * The buddy ID.
3450 */
3451 pjsua_buddy_id id;
3452
3453 /**
3454 * The full URI of the buddy, as specified in the configuration.
3455 */
3456 pj_str_t uri;
3457
3458 /**
3459 * Buddy's Contact, only available when presence subscription has
3460 * been established to the buddy.
3461 */
3462 pj_str_t contact;
3463
3464 /**
3465 * Buddy's online status.
3466 */
3467 pjsua_buddy_status status;
3468
3469 /**
3470 * Text to describe buddy's online status.
3471 */
3472 pj_str_t status_text;
3473
3474 /**
3475 * Flag to indicate that we should monitor the presence information for
3476 * this buddy (normally yes, unless explicitly disabled).
3477 */
3478 pj_bool_t monitor_pres;
3479
3480 /**
Benny Prijono63fba012008-07-17 14:19:10 +00003481 * If \a monitor_pres is enabled, this specifies the last state of the
3482 * presence subscription. If presence subscription session is currently
3483 * active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence
3484 * subscription request has been rejected, the value will be
3485 * PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be
3486 * specified in \a sub_term_reason.
3487 */
3488 pjsip_evsub_state sub_state;
3489
3490 /**
Benny Prijonod06d8c52009-06-30 13:53:47 +00003491 * String representation of subscription state.
3492 */
3493 const char *sub_state_name;
3494
3495 /**
Benny Prijono73bb7232009-10-20 13:56:26 +00003496 * Specifies the last presence subscription termination code. This would
3497 * return the last status of the SUBSCRIBE request. If the subscription
3498 * is terminated with NOTIFY by the server, this value will be set to
3499 * 200, and subscription termination reason will be given in the
3500 * \a sub_term_reason field.
3501 */
3502 unsigned sub_term_code;
3503
3504 /**
3505 * Specifies the last presence subscription termination reason. If
Benny Prijono63fba012008-07-17 14:19:10 +00003506 * presence subscription is currently active, the value will be empty.
3507 */
3508 pj_str_t sub_term_reason;
3509
3510 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003511 * Extended RPID information about the person.
3512 */
3513 pjrpid_element rpid;
3514
3515 /**
Benny Prijono28add7e2009-06-15 16:03:40 +00003516 * Extended presence info.
3517 */
3518 pjsip_pres_status pres_status;
3519
3520 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003521 * Internal buffer.
3522 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003523 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003524
3525} pjsua_buddy_info;
3526
3527
Benny Prijono834aee32006-02-19 01:38:06 +00003528/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003529 * Set default values to the buddy config.
3530 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003531PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003532
3533
3534/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003535 * Get total number of buddies.
3536 *
3537 * @return Number of buddies.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003538 */
3539PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3540
3541
3542/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003543 * Check if buddy ID is valid.
3544 *
3545 * @param buddy_id Buddy ID to check.
3546 *
3547 * @return Non-zero if buddy ID is valid.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003548 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003549PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3550
3551
3552/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003553 * Enumerate all buddy IDs in the buddy list. Application then can use
3554 * #pjsua_buddy_get_info() to get the detail information for each buddy
3555 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003556 *
3557 * @param ids Array of ids to be initialized.
3558 * @param count On input, specifies max elements in the array.
3559 * On return, it contains actual number of elements
3560 * that have been initialized.
3561 *
3562 * @return PJ_SUCCESS on success, or the appropriate error code.
3563 */
3564PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3565 unsigned *count);
3566
3567/**
Benny Prijono705e7842008-07-21 18:12:51 +00003568 * Find the buddy ID with the specified URI.
3569 *
3570 * @param uri The buddy URI.
3571 *
3572 * @return The buddy ID, or PJSUA_INVALID_ID if not found.
3573 */
3574PJ_DECL(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri);
3575
3576
3577/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003578 * Get detailed buddy info.
3579 *
3580 * @param buddy_id The buddy identification.
3581 * @param info Pointer to receive information about buddy.
3582 *
3583 * @return PJ_SUCCESS on success, or the appropriate error code.
3584 */
3585PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003586 pjsua_buddy_info *info);
3587
3588/**
Benny Prijono705e7842008-07-21 18:12:51 +00003589 * Set the user data associated with the buddy object.
3590 *
3591 * @param buddy_id The buddy identification.
3592 * @param user_data Arbitrary application data to be associated with
3593 * the buddy object.
3594 *
3595 * @return PJ_SUCCESS on success, or the appropriate error code.
3596 */
3597PJ_DECL(pj_status_t) pjsua_buddy_set_user_data(pjsua_buddy_id buddy_id,
3598 void *user_data);
3599
3600
3601/**
3602 * Get the user data associated with the budy object.
3603 *
3604 * @param buddy_id The buddy identification.
3605 *
3606 * @return The application data.
3607 */
3608PJ_DECL(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id);
3609
3610
3611/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003612 * Add new buddy to the buddy list. If presence subscription is enabled
3613 * for this buddy, this function will also start the presence subscription
3614 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003615 *
Benny Prijonoa7b376b2008-01-25 16:06:33 +00003616 * @param buddy_cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003617 * @param p_buddy_id Pointer to receive buddy ID.
3618 *
3619 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003620 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003621PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003622 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003623
3624
3625/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003626 * Delete the specified buddy from the buddy list. Any presence subscription
3627 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003628 *
3629 * @param buddy_id Buddy identification.
3630 *
3631 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00003632 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003633PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003634
3635
3636/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003637 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3638 * subscribed, application will be informed about buddy's presence status
3639 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003640 *
3641 * @param buddy_id Buddy identification.
3642 * @param subscribe Specify non-zero to activate presence subscription to
3643 * the specified buddy.
3644 *
3645 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003646 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003647PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3648 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003649
3650
3651/**
Benny Prijono10861432007-10-31 10:54:53 +00003652 * Update the presence information for the buddy. Although the library
3653 * periodically refreshes the presence subscription for all buddies, some
3654 * application may want to refresh the buddy's presence subscription
3655 * immediately, and in this case it can use this function to accomplish
3656 * this.
3657 *
3658 * Note that the buddy's presence subscription will only be initiated
3659 * if presence monitoring is enabled for the buddy. See
3660 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
3661 * for the buddy is already active, this function will not do anything.
3662 *
3663 * Once the presence subscription is activated successfully for the buddy,
3664 * application will be notified about the buddy's presence status in the
3665 * on_buddy_state() callback.
3666 *
3667 * @param buddy_id Buddy identification.
3668 *
3669 * @return PJ_SUCCESS on success, or the appropriate error code.
3670 */
3671PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
3672
3673
3674/**
Benny Prijono63fba012008-07-17 14:19:10 +00003675 * Send NOTIFY to inform account presence status or to terminate server
3676 * side presence subscription. If application wants to reject the incoming
3677 * request, it should set the \a state to PJSIP_EVSUB_STATE_TERMINATED.
3678 *
3679 * @param acc_id Account ID.
3680 * @param srv_pres Server presence subscription instance.
3681 * @param state New state to set.
3682 * @param state_str Optionally specify the state string name, if state
3683 * is not "active", "pending", or "terminated".
3684 * @param reason If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3685 * optionally specify the termination reason.
3686 * @param with_body If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3687 * this specifies whether the NOTIFY request should
3688 * contain message body containing account's presence
3689 * information.
3690 * @param msg_data Optional list of headers to be sent with the NOTIFY
3691 * request.
3692 *
3693 * @return PJ_SUCCESS on success.
3694 */
3695PJ_DECL(pj_status_t) pjsua_pres_notify(pjsua_acc_id acc_id,
3696 pjsua_srv_pres *srv_pres,
3697 pjsip_evsub_state state,
3698 const pj_str_t *state_str,
3699 const pj_str_t *reason,
3700 pj_bool_t with_body,
3701 const pjsua_msg_data *msg_data);
3702
3703/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003704 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003705 *
3706 * @param verbose Yes or no.
Benny Prijono834aee32006-02-19 01:38:06 +00003707 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003708PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003709
3710
Benny Prijonob0808372006-03-02 21:18:58 +00003711/**
3712 * The MESSAGE method (defined in pjsua_im.c)
3713 */
3714extern const pjsip_method pjsip_message_method;
3715
3716
Benny Prijonob0808372006-03-02 21:18:58 +00003717
3718/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003719 * Send instant messaging outside dialog, using the specified account for
3720 * route set and authentication.
3721 *
3722 * @param acc_id Account ID to be used to send the request.
3723 * @param to Remote URI.
3724 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3725 * assumed.
3726 * @param content The message content.
3727 * @param msg_data Optional list of headers etc to be included in outgoing
3728 * request. The body descriptor in the msg_data is
3729 * ignored.
3730 * @param user_data Optional user data, which will be given back when
3731 * the IM callback is called.
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_send(pjsua_acc_id acc_id,
3736 const pj_str_t *to,
3737 const pj_str_t *mime_type,
3738 const pj_str_t *content,
3739 const pjsua_msg_data *msg_data,
3740 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003741
3742
3743/**
3744 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003745 *
3746 * @param acc_id Account ID to be used to send the request.
3747 * @param to Remote URI.
3748 * @param is_typing If non-zero, it tells remote person that local person
3749 * is currently composing an IM.
3750 * @param msg_data Optional list of headers etc to be added to outgoing
3751 * request.
3752 *
3753 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003754 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003755PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3756 const pj_str_t *to,
3757 pj_bool_t is_typing,
3758 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003759
3760
Benny Prijonof3195072006-02-14 21:15:30 +00003761
Benny Prijono312aff92006-06-17 04:08:30 +00003762/**
3763 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003764 */
3765
Benny Prijono312aff92006-06-17 04:08:30 +00003766
3767/*****************************************************************************
3768 * MEDIA API
3769 */
3770
3771
3772/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003773 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003774 * @ingroup PJSUA_LIB
3775 * @brief Media manipulation.
3776 * @{
3777 *
3778 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003779 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3780 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003781 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003782 * the interconnection between these terminations freely.
3783 *
3784 * The conference bridge provides powerful switching and mixing functionality
3785 * for application. With the conference bridge, each conference slot (e.g.
3786 * a call) can transmit to multiple destinations, and one destination can
3787 * receive from multiple sources. If more than one media terminations are
3788 * terminated in the same slot, the conference bridge will mix the signal
3789 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00003790 *
3791 * Application connects one media termination/slot to another by calling
3792 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003793 * media flow from the source termination to the sink termination. To
3794 * establish bidirectional media flow, application wound need to make another
3795 * call to #pjsua_conf_connect(), this time inverting the source and
3796 * destination slots in the parameter.
3797 *
3798 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00003799 * the following steps:
3800 *
3801 \code
3802
3803 pj_status_t stream_to_call( pjsua_call_id call_id )
3804 {
3805 pjsua_player_id player_id;
3806
3807 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
3808 if (status != PJ_SUCCESS)
3809 return status;
3810
3811 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
3812 pjsua_call_get_conf_port() );
3813 }
3814 \endcode
3815 *
3816 *
3817 * Other features of PJSUA media:
3818 * - efficient N to M interconnections between media terminations.
3819 * - media termination can be connected to itself to create loopback
3820 * media.
3821 * - the media termination may have different clock rates, and resampling
3822 * will be done automatically by conference bridge.
3823 * - media terminations may also have different frame time; the
3824 * conference bridge will perform the necessary bufferring to adjust
3825 * the difference between terminations.
3826 * - interconnections are removed automatically when media termination
3827 * is removed from the bridge.
3828 * - sound device may be changed even when there are active media
3829 * interconnections.
3830 * - correctly report call's media quality (in #pjsua_call_dump()) from
3831 * RTCP packet exchange.
3832 */
3833
3834/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003835 * Max ports in the conference bridge. This setting is the default value
3836 * for pjsua_media_config.max_media_ports.
Benny Prijono312aff92006-06-17 04:08:30 +00003837 */
3838#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00003839# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00003840#endif
3841
Benny Prijonob5388cf2007-01-04 22:45:08 +00003842/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003843 * The default clock rate to be used by the conference bridge. This setting
3844 * is the default value for pjsua_media_config.clock_rate.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003845 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003846#ifndef PJSUA_DEFAULT_CLOCK_RATE
3847# define PJSUA_DEFAULT_CLOCK_RATE 16000
3848#endif
3849
Benny Prijonob5388cf2007-01-04 22:45:08 +00003850/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003851 * Default frame length in the conference bridge. This setting
3852 * is the default value for pjsua_media_config.audio_frame_ptime.
3853 */
3854#ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Nanang Izzuddinaf974842008-05-08 09:51:16 +00003855# define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
Benny Prijono37c710b2008-01-10 12:09:26 +00003856#endif
3857
3858
3859/**
3860 * Default codec quality settings. This setting is the default value
3861 * for pjsua_media_config.quality.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003862 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003863#ifndef PJSUA_DEFAULT_CODEC_QUALITY
Nanang Izzuddin9dbad152008-06-10 18:56:10 +00003864# define PJSUA_DEFAULT_CODEC_QUALITY 8
Benny Prijono12a669c2006-11-23 07:32:13 +00003865#endif
3866
Benny Prijonob5388cf2007-01-04 22:45:08 +00003867/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003868 * Default iLBC mode. This setting is the default value for
3869 * pjsua_media_config.ilbc_mode.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003870 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003871#ifndef PJSUA_DEFAULT_ILBC_MODE
Benny Prijono37c710b2008-01-10 12:09:26 +00003872# define PJSUA_DEFAULT_ILBC_MODE 30
Benny Prijono12a669c2006-11-23 07:32:13 +00003873#endif
3874
Benny Prijonob5388cf2007-01-04 22:45:08 +00003875/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003876 * The default echo canceller tail length. This setting
3877 * is the default value for pjsua_media_config.ec_tail_len.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003878 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003879#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijono427439c2007-10-21 09:41:24 +00003880# define PJSUA_DEFAULT_EC_TAIL_LEN 200
Benny Prijono12a669c2006-11-23 07:32:13 +00003881#endif
Benny Prijono312aff92006-06-17 04:08:30 +00003882
3883
3884/**
Benny Prijonocba59d92007-02-16 09:22:56 +00003885 * The maximum file player.
3886 */
3887#ifndef PJSUA_MAX_PLAYERS
3888# define PJSUA_MAX_PLAYERS 32
3889#endif
3890
3891
3892/**
3893 * The maximum file player.
3894 */
3895#ifndef PJSUA_MAX_RECORDERS
3896# define PJSUA_MAX_RECORDERS 32
3897#endif
3898
3899
3900/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003901 * This structure describes media configuration, which will be specified
3902 * when calling #pjsua_init(). Application MUST initialize this structure
3903 * by calling #pjsua_media_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00003904 */
3905struct pjsua_media_config
3906{
3907 /**
3908 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003909 * If value is zero, default clock rate will be used
3910 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00003911 */
3912 unsigned clock_rate;
3913
3914 /**
Benny Prijonof3758ee2008-02-26 15:32:16 +00003915 * Clock rate to be applied when opening the sound device.
3916 * If value is zero, conference bridge clock rate will be used.
3917 */
3918 unsigned snd_clock_rate;
3919
3920 /**
Benny Prijono7d60d052008-03-29 12:24:20 +00003921 * Channel count be applied when opening the sound device and
3922 * conference bridge.
3923 */
3924 unsigned channel_count;
3925
3926 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003927 * Specify audio frame ptime. The value here will affect the
3928 * samples per frame of both the sound device and the conference
3929 * bridge. Specifying lower ptime will normally reduce the
3930 * latency.
3931 *
Benny Prijono37c710b2008-01-10 12:09:26 +00003932 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003933 */
3934 unsigned audio_frame_ptime;
3935
3936 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003937 * Specify maximum number of media ports to be created in the
3938 * conference bridge. Since all media terminate in the bridge
3939 * (calls, file player, file recorder, etc), the value must be
3940 * large enough to support all of them. However, the larger
3941 * the value, the more computations are performed.
Benny Prijono37c710b2008-01-10 12:09:26 +00003942 *
3943 * Default value: PJSUA_MAX_CONF_PORTS
Benny Prijono312aff92006-06-17 04:08:30 +00003944 */
3945 unsigned max_media_ports;
3946
3947 /**
3948 * Specify whether the media manager should manage its own
3949 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
3950 * and at least one worker thread will be created too. If no,
3951 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
3952 * and no worker thread is needed.
3953 *
3954 * Normally application would say yes here, unless it wants to
3955 * run everything from a single thread.
3956 */
3957 pj_bool_t has_ioqueue;
3958
3959 /**
3960 * Specify the number of worker threads to handle incoming RTP
3961 * packets. A value of one is recommended for most applications.
3962 */
3963 unsigned thread_cnt;
3964
Benny Prijono0498d902006-06-19 14:49:14 +00003965 /**
3966 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00003967 * 5-10: resampling use large filter,
3968 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00003969 * 1-2: resampling use linear.
3970 * The media quality also sets speex codec quality/complexity to the
3971 * number.
3972 *
Benny Prijono70972992006-08-05 11:13:58 +00003973 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00003974 */
3975 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00003976
3977 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003978 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00003979 *
3980 * Default: 0 (codec specific)
3981 */
3982 unsigned ptime;
3983
3984 /**
3985 * Disable VAD?
3986 *
3987 * Default: 0 (no (meaning VAD is enabled))
3988 */
3989 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00003990
3991 /**
3992 * iLBC mode (20 or 30).
3993 *
Benny Prijono37c710b2008-01-10 12:09:26 +00003994 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00003995 */
3996 unsigned ilbc_mode;
3997
3998 /**
3999 * Percentage of RTP packet to drop in TX direction
4000 * (to simulate packet lost).
4001 *
4002 * Default: 0
4003 */
4004 unsigned tx_drop_pct;
4005
4006 /**
4007 * Percentage of RTP packet to drop in RX direction
4008 * (to simulate packet lost).
4009 *
4010 * Default: 0
4011 */
4012 unsigned rx_drop_pct;
4013
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004014 /**
Benny Prijono5da50432006-08-07 10:24:52 +00004015 * Echo canceller options (see #pjmedia_echo_create())
4016 *
4017 * Default: 0.
4018 */
4019 unsigned ec_options;
4020
4021 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004022 * Echo canceller tail length, in miliseconds.
4023 *
Benny Prijono669643c2006-09-20 20:02:18 +00004024 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004025 */
4026 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004027
Benny Prijono10454dc2009-02-21 14:21:59 +00004028 /**
4029 * Audio capture buffer length, in milliseconds.
4030 *
4031 * Default: PJMEDIA_SND_DEFAULT_REC_LATENCY
4032 */
4033 unsigned snd_rec_latency;
4034
4035 /**
4036 * Audio playback buffer length, in milliseconds.
4037 *
4038 * Default: PJMEDIA_SND_DEFAULT_PLAY_LATENCY
4039 */
4040 unsigned snd_play_latency;
4041
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004042 /**
4043 * Jitter buffer initial prefetch delay in msec. The value must be
4044 * between jb_min_pre and jb_max_pre below.
4045 *
4046 * Default: -1 (to use default stream settings, currently 150 msec)
4047 */
4048 int jb_init;
4049
4050 /**
4051 * Jitter buffer minimum prefetch delay in msec.
4052 *
4053 * Default: -1 (to use default stream settings, currently 60 msec)
4054 */
4055 int jb_min_pre;
4056
4057 /**
4058 * Jitter buffer maximum prefetch delay in msec.
4059 *
4060 * Default: -1 (to use default stream settings, currently 240 msec)
4061 */
4062 int jb_max_pre;
4063
4064 /**
4065 * Set maximum delay that can be accomodated by the jitter buffer msec.
4066 *
4067 * Default: -1 (to use default stream settings, currently 360 msec)
4068 */
4069 int jb_max;
4070
Benny Prijonoc97608e2007-03-23 16:34:20 +00004071 /**
4072 * Enable ICE
4073 */
4074 pj_bool_t enable_ice;
4075
4076 /**
Benny Prijono329d6382009-05-29 13:04:03 +00004077 * Set the maximum number of host candidates.
4078 *
4079 * Default: -1 (maximum not set)
Benny Prijonoc97608e2007-03-23 16:34:20 +00004080 */
Benny Prijono329d6382009-05-29 13:04:03 +00004081 int ice_max_host_cands;
4082
4083 /**
4084 * ICE session options.
4085 */
4086 pj_ice_sess_options ice_opt;
Benny Prijonof76e1392008-06-06 14:51:48 +00004087
4088 /**
Benny Prijono551af422008-08-07 09:55:52 +00004089 * Disable RTCP component.
4090 *
4091 * Default: no
4092 */
4093 pj_bool_t ice_no_rtcp;
4094
4095 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00004096 * Enable TURN relay candidate in ICE.
4097 */
4098 pj_bool_t enable_turn;
4099
4100 /**
4101 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
4102 * "HOST:PORT" format.
4103 */
4104 pj_str_t turn_server;
4105
4106 /**
4107 * Specify the connection type to be used to the TURN server. Valid
4108 * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP.
4109 *
4110 * Default: PJ_TURN_TP_UDP
4111 */
4112 pj_turn_tp_type turn_conn_type;
4113
4114 /**
4115 * Specify the credential to authenticate with the TURN server.
4116 */
4117 pj_stun_auth_cred turn_auth_cred;
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004118
4119 /**
4120 * Specify idle time of sound device before it is automatically closed,
Benny Prijonof798e502009-03-09 13:08:16 +00004121 * in seconds. Use value -1 to disable the auto-close feature of sound
4122 * device
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004123 *
Benny Prijonof798e502009-03-09 13:08:16 +00004124 * Default : 1
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004125 */
4126 int snd_auto_close_time;
Benny Prijono312aff92006-06-17 04:08:30 +00004127};
4128
4129
4130/**
4131 * Use this function to initialize media config.
4132 *
4133 * @param cfg The media config to be initialized.
4134 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00004135PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00004136
4137
4138/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004139 * This structure describes codec information, which can be retrieved by
4140 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00004141 */
4142typedef struct pjsua_codec_info
4143{
4144 /**
4145 * Codec unique identification.
4146 */
4147 pj_str_t codec_id;
4148
4149 /**
4150 * Codec priority (integer 0-255).
4151 */
4152 pj_uint8_t priority;
4153
4154 /**
4155 * Internal buffer.
4156 */
4157 char buf_[32];
4158
4159} pjsua_codec_info;
4160
4161
4162/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004163 * This structure descibes information about a particular media port that
4164 * has been registered into the conference bridge. Application can query
4165 * this info by calling #pjsua_conf_get_port_info().
Benny Prijono312aff92006-06-17 04:08:30 +00004166 */
4167typedef struct pjsua_conf_port_info
4168{
4169 /** Conference port number. */
4170 pjsua_conf_port_id slot_id;
4171
4172 /** Port name. */
4173 pj_str_t name;
4174
4175 /** Clock rate. */
4176 unsigned clock_rate;
4177
4178 /** Number of channels. */
4179 unsigned channel_count;
4180
4181 /** Samples per frame */
4182 unsigned samples_per_frame;
4183
4184 /** Bits per sample */
4185 unsigned bits_per_sample;
4186
4187 /** Number of listeners in the array. */
4188 unsigned listener_cnt;
4189
4190 /** Array of listeners (in other words, ports where this port is
4191 * transmitting to.
4192 */
4193 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
4194
4195} pjsua_conf_port_info;
4196
4197
4198/**
4199 * This structure holds information about custom media transport to
4200 * be registered to pjsua.
4201 */
4202typedef struct pjsua_media_transport
4203{
4204 /**
4205 * Media socket information containing the address information
4206 * of the RTP and RTCP socket.
4207 */
4208 pjmedia_sock_info skinfo;
4209
4210 /**
4211 * The media transport instance.
4212 */
4213 pjmedia_transport *transport;
4214
4215} pjsua_media_transport;
4216
4217
4218
4219
Benny Prijono9fc735d2006-05-28 14:58:12 +00004220/**
4221 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004222 *
4223 * @return Maximum number of ports in the conference bridge.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004224 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004225PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004226
4227
4228/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004229 * Get current number of active ports in the bridge.
4230 *
4231 * @return The number.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004232 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004233PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
4234
4235
4236/**
4237 * Enumerate all conference ports.
4238 *
4239 * @param id Array of conference port ID to be initialized.
4240 * @param count On input, specifies max elements in the array.
4241 * On return, it contains actual number of elements
4242 * that have been initialized.
4243 *
4244 * @return PJ_SUCCESS on success, or the appropriate error code.
4245 */
4246PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
4247 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004248
4249
4250/**
4251 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004252 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004253 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004254 * @param info Pointer to store the port info.
4255 *
4256 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004257 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004258PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00004259 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004260
4261
4262/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00004263 * Add arbitrary media port to PJSUA's conference bridge. Application
4264 * can use this function to add the media port that it creates. For
4265 * media ports that are created by PJSUA-LIB (such as calls, file player,
4266 * or file recorder), PJSUA-LIB will automatically add the port to
4267 * the bridge.
4268 *
4269 * @param pool Pool to use.
4270 * @param port Media port to be added to the bridge.
4271 * @param p_id Optional pointer to receive the conference
4272 * slot id.
4273 *
4274 * @return PJ_SUCCESS on success, or the appropriate error code.
4275 */
4276PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
4277 pjmedia_port *port,
4278 pjsua_conf_port_id *p_id);
4279
4280
4281/**
4282 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00004283 * call this function if it registered the port manually with previous call
4284 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00004285 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004286 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00004287 *
4288 * @return PJ_SUCCESS on success, or the appropriate error code.
4289 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004290PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00004291
4292
4293/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004294 * Establish unidirectional media flow from souce to sink. One source
4295 * may transmit to multiple destinations/sink. And if multiple
4296 * sources are transmitting to the same sink, the media will be mixed
4297 * together. Source and sink may refer to the same ID, effectively
4298 * looping the media.
4299 *
4300 * If bidirectional media flow is desired, application needs to call
4301 * this function twice, with the second one having the arguments
4302 * reversed.
4303 *
4304 * @param source Port ID of the source media/transmitter.
4305 * @param sink Port ID of the destination media/received.
4306 *
4307 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004308 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004309PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
4310 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004311
4312
4313/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004314 * Disconnect media flow from the source to destination port.
4315 *
4316 * @param source Port ID of the source media/transmitter.
4317 * @param sink Port ID of the destination media/received.
4318 *
4319 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004320 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004321PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
4322 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004323
4324
Benny Prijono6dd967c2006-12-26 02:27:14 +00004325/**
4326 * Adjust the signal level to be transmitted from the bridge to the
4327 * specified port by making it louder or quieter.
4328 *
4329 * @param slot The conference bridge slot number.
4330 * @param level Signal level adjustment. Value 1.0 means no level
4331 * adjustment, while value 0 means to mute the port.
4332 *
4333 * @return PJ_SUCCESS on success, or the appropriate error code.
4334 */
4335PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
4336 float level);
4337
4338/**
4339 * Adjust the signal level to be received from the specified port (to
4340 * the bridge) by making it louder or quieter.
4341 *
4342 * @param slot The conference bridge slot number.
4343 * @param level Signal level adjustment. Value 1.0 means no level
4344 * adjustment, while value 0 means to mute the port.
4345 *
4346 * @return PJ_SUCCESS on success, or the appropriate error code.
4347 */
4348PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
4349 float level);
4350
4351/**
4352 * Get last signal level transmitted to or received from the specified port.
4353 * The signal level is an integer value in zero to 255, with zero indicates
4354 * no signal, and 255 indicates the loudest signal level.
4355 *
4356 * @param slot The conference bridge slot number.
4357 * @param tx_level Optional argument to receive the level of signal
4358 * transmitted to the specified port (i.e. the direction
4359 * is from the bridge to the port).
4360 * @param rx_level Optional argument to receive the level of signal
4361 * received from the port (i.e. the direction is from the
4362 * port to the bridge).
4363 *
4364 * @return PJ_SUCCESS on success.
4365 */
4366PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
4367 unsigned *tx_level,
4368 unsigned *rx_level);
4369
Benny Prijono6dd967c2006-12-26 02:27:14 +00004370
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004371/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00004372 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004373 */
4374
Benny Prijono9fc735d2006-05-28 14:58:12 +00004375/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004376 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004377 * the conference bridge.
4378 *
4379 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00004380 * WAV files are supported, and the WAV file MUST be
4381 * formatted as 16bit PCM mono/single channel (any
4382 * clock rate is supported).
Benny Prijono58add7c2008-01-18 13:24:07 +00004383 * @param options Optional option flag. Application may specify
4384 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004385 * @param p_id Pointer to receive player ID.
4386 *
4387 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004388 */
4389PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004390 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004391 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004392
4393
4394/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004395 * Create a file playlist media port, and automatically add the port
4396 * to the conference bridge.
4397 *
4398 * @param file_names Array of file names to be added to the play list.
4399 * Note that the files must have the same clock rate,
4400 * number of channels, and number of bits per sample.
4401 * @param file_count Number of files in the array.
4402 * @param label Optional label to be set for the media port.
4403 * @param options Optional option flag. Application may specify
4404 * PJMEDIA_FILE_NO_LOOP to prevent looping.
4405 * @param p_id Optional pointer to receive player ID.
4406 *
4407 * @return PJ_SUCCESS on success, or the appropriate error code.
4408 */
4409PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
4410 unsigned file_count,
4411 const pj_str_t *label,
4412 unsigned options,
4413 pjsua_player_id *p_id);
4414
4415/**
4416 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004417 *
4418 * @param id The file player ID.
4419 *
4420 * @return Conference port ID associated with this player.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004421 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004422PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004423
4424
4425/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004426 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00004427 *
4428 * @param id The player ID.
4429 * @param p_port The media port associated with the player.
4430 *
4431 * @return PJ_SUCCESS on success.
4432 */
Benny Prijono58add7c2008-01-18 13:24:07 +00004433PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
Benny Prijono469b1522006-12-26 03:05:17 +00004434 pjmedia_port **p_port);
4435
4436/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004437 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004438 *
4439 * @param id The file player ID.
4440 * @param samples The playback position, in samples. Application can
4441 * specify zero to re-start the playback.
4442 *
4443 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004444 */
4445PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
4446 pj_uint32_t samples);
4447
4448
4449/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004450 * Close the file of playlist, remove the player from the bridge, and free
4451 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004452 *
4453 * @param id The file player ID.
4454 *
4455 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004456 */
4457PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
4458
4459
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004460/*****************************************************************************
4461 * File recorder.
4462 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00004463
4464/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004465 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004466 * the conference bridge. The recorder currently supports recording WAV file.
4467 * The type of the recorder to use is determined by the extension of the file
4468 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004469 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00004470 * @param filename Output file name. The function will determine the
4471 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004472 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00004473 * @param enc_type Optionally specify the type of encoder to be used to
4474 * compress the media, if the file can support different
4475 * encodings. This value must be zero for now.
4476 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004477 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00004478 * For .WAV recorder, this value must be NULL.
4479 * @param max_size Maximum file size. Specify zero or -1 to remove size
4480 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004481 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004482 * @param p_id Pointer to receive the recorder instance.
4483 *
4484 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004485 */
4486PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004487 unsigned enc_type,
4488 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004489 pj_ssize_t max_size,
4490 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004491 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004492
4493
4494/**
4495 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004496 *
4497 * @param id The recorder ID.
4498 *
4499 * @return Conference port ID associated with this recorder.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004500 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004501PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004502
4503
4504/**
Benny Prijono469b1522006-12-26 03:05:17 +00004505 * Get the media port for the recorder.
4506 *
4507 * @param id The recorder ID.
4508 * @param p_port The media port associated with the recorder.
4509 *
4510 * @return PJ_SUCCESS on success.
4511 */
4512PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4513 pjmedia_port **p_port);
4514
4515
4516/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004517 * Destroy recorder (this will complete recording).
4518 *
4519 * @param id The recorder ID.
4520 *
4521 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004522 */
4523PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4524
4525
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004526/*****************************************************************************
4527 * Sound devices.
4528 */
4529
Benny Prijono9fc735d2006-05-28 14:58:12 +00004530/**
Benny Prijonof798e502009-03-09 13:08:16 +00004531 * Enum all audio devices installed in the system.
4532 *
4533 * @param info Array of info to be initialized.
4534 * @param count On input, specifies max elements in the array.
4535 * On return, it contains actual number of elements
4536 * that have been initialized.
4537 *
4538 * @return PJ_SUCCESS on success, or the appropriate error code.
4539 */
4540PJ_DECL(pj_status_t) pjsua_enum_aud_devs(pjmedia_aud_dev_info info[],
4541 unsigned *count);
4542
4543/**
4544 * Enum all sound devices installed in the system (old API).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004545 *
4546 * @param info Array of info to be initialized.
4547 * @param count On input, specifies max elements in the array.
4548 * On return, it contains actual number of elements
4549 * that have been initialized.
4550 *
4551 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004552 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004553PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4554 unsigned *count);
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004555
4556/**
4557 * Get currently active sound devices. If sound devices has not been created
4558 * (for example when pjsua_start() is not called), it is possible that
4559 * the function returns PJ_SUCCESS with -1 as device IDs.
4560 *
4561 * @param capture_dev On return it will be filled with device ID of the
4562 * capture device.
4563 * @param playback_dev On return it will be filled with device ID of the
4564 * device ID of the playback device.
4565 *
4566 * @return PJ_SUCCESS on success, or the appropriate error code.
4567 */
4568PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4569 int *playback_dev);
4570
4571
Benny Prijono9fc735d2006-05-28 14:58:12 +00004572/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004573 * Select or change sound device. Application may call this function at
4574 * any time to replace current sound device.
4575 *
4576 * @param capture_dev Device ID of the capture device.
4577 * @param playback_dev Device ID of the playback device.
4578 *
4579 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004580 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004581PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4582 int playback_dev);
4583
4584
4585/**
4586 * Set pjsua to use null sound device. The null sound device only provides
4587 * the timing needed by the conference bridge, and will not interract with
4588 * any hardware.
4589 *
4590 * @return PJ_SUCCESS on success, or the appropriate error code.
4591 */
4592PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4593
4594
Benny Prijonoe909eac2006-07-27 22:04:56 +00004595/**
4596 * Disconnect the main conference bridge from any sound devices, and let
4597 * application connect the bridge to it's own sound device/master port.
4598 *
4599 * @return The port interface of the conference bridge,
4600 * so that application can connect this to it's own
4601 * sound device or master port.
4602 */
4603PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4604
4605
Benny Prijonof20687a2006-08-04 18:27:19 +00004606/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004607 * Change the echo cancellation settings.
Benny Prijonof798e502009-03-09 13:08:16 +00004608 *
4609 * The behavior of this function depends on whether the sound device is
4610 * currently active, and if it is, whether device or software AEC is
4611 * being used.
Benny Prijono10454dc2009-02-21 14:21:59 +00004612 *
4613 * If the sound device is currently active, and if the device supports AEC,
4614 * this function will forward the change request to the device and it will
4615 * be up to the device on whether support the request. If software AEC is
4616 * being used (the software EC will be used if the device does not support
4617 * AEC), this function will change the software EC settings. In all cases,
4618 * the setting will be saved for future opening of the sound device.
4619 *
4620 * If the sound device is not currently active, this will only change the
4621 * default AEC settings and the setting will be applied next time the
4622 * sound device is opened.
Benny Prijonof20687a2006-08-04 18:27:19 +00004623 *
4624 * @param tail_ms The tail length, in miliseconds. Set to zero to
4625 * disable AEC.
Benny Prijonoa7b376b2008-01-25 16:06:33 +00004626 * @param options Options to be passed to pjmedia_echo_create().
Benny Prijono5da50432006-08-07 10:24:52 +00004627 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004628 *
4629 * @return PJ_SUCCESS on success.
4630 */
Benny Prijono5da50432006-08-07 10:24:52 +00004631PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004632
4633
4634/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004635 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004636 *
4637 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4638 * If AEC is disabled, the value will be zero.
4639 *
4640 * @return PJ_SUCCESS on success.
4641 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004642PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004643
4644
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004645/**
Benny Prijonof798e502009-03-09 13:08:16 +00004646 * Check whether the sound device is currently active. The sound device
4647 * may be inactive if the application has set the auto close feature to
4648 * non-zero (the snd_auto_close_time setting in #pjsua_media_config), or
4649 * if null sound device or no sound device has been configured via the
4650 * #pjsua_set_no_snd_dev() function.
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004651 */
Benny Prijonof798e502009-03-09 13:08:16 +00004652PJ_DECL(pj_bool_t) pjsua_snd_is_active(void);
4653
4654
4655/**
4656 * Configure sound device setting to the sound device being used. If sound
4657 * device is currently active, the function will forward the setting to the
4658 * sound device instance to be applied immediately, if it supports it.
4659 *
4660 * The setting will be saved for future opening of the sound device, if the
4661 * "keep" argument is set to non-zero. If the sound device is currently
4662 * inactive, and the "keep" argument is false, this function will return
4663 * error.
4664 *
4665 * Note that in case the setting is kept for future use, it will be applied
4666 * to any devices, even when application has changed the sound device to be
4667 * used.
4668 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004669 * Note also that the echo cancellation setting should be set with
4670 * #pjsua_set_ec() API instead.
4671 *
Benny Prijonof798e502009-03-09 13:08:16 +00004672 * See also #pjmedia_aud_stream_set_cap() for more information about setting
4673 * an audio device capability.
4674 *
4675 * @param cap The sound device setting to change.
4676 * @param pval Pointer to value. Please see #pjmedia_aud_dev_cap
4677 * documentation about the type of value to be
4678 * supplied for each setting.
4679 * @param keep Specify whether the setting is to be kept for future
4680 * use.
4681 *
4682 * @return PJ_SUCCESS on success or the appropriate error code.
4683 */
4684PJ_DECL(pj_status_t) pjsua_snd_set_setting(pjmedia_aud_dev_cap cap,
4685 const void *pval,
4686 pj_bool_t keep);
4687
4688/**
4689 * Retrieve a sound device setting. If sound device is currently active,
4690 * the function will forward the request to the sound device. If sound device
4691 * is currently inactive, and if application had previously set the setting
4692 * and mark the setting as kept, then that setting will be returned.
4693 * Otherwise, this function will return error.
4694 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004695 * Note that echo cancellation settings should be retrieved with
4696 * #pjsua_get_ec_tail() API instead.
4697 *
Benny Prijonof798e502009-03-09 13:08:16 +00004698 * @param cap The sound device setting to retrieve.
4699 * @param pval Pointer to receive the value.
4700 * Please see #pjmedia_aud_dev_cap documentation about
4701 * the type of value to be supplied for each setting.
4702 *
4703 * @return PJ_SUCCESS on success or the appropriate error code.
4704 */
4705PJ_DECL(pj_status_t) pjsua_snd_get_setting(pjmedia_aud_dev_cap cap,
4706 void *pval);
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004707
4708
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004709/*****************************************************************************
4710 * Codecs.
4711 */
4712
4713/**
4714 * Enum all supported codecs in the system.
4715 *
4716 * @param id Array of ID to be initialized.
4717 * @param count On input, specifies max elements in the array.
4718 * On return, it contains actual number of elements
4719 * that have been initialized.
4720 *
4721 * @return PJ_SUCCESS on success, or the appropriate error code.
4722 */
4723PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4724 unsigned *count );
4725
4726
4727/**
4728 * Change codec priority.
4729 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004730 * @param codec_id Codec ID, which is a string that uniquely identify
4731 * the codec (such as "speex/8000"). Please see pjsua
4732 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004733 * @param priority Codec priority, 0-255, where zero means to disable
4734 * the codec.
4735 *
4736 * @return PJ_SUCCESS on success, or the appropriate error code.
4737 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004738PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004739 pj_uint8_t priority );
4740
4741
4742/**
4743 * Get codec parameters.
4744 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004745 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004746 * @param param Structure to receive codec parameters.
4747 *
4748 * @return PJ_SUCCESS on success, or the appropriate error code.
4749 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004750PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004751 pjmedia_codec_param *param );
4752
4753
4754/**
4755 * Set codec parameters.
4756 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004757 * @param codec_id Codec ID.
Nanang Izzuddin06839e72010-01-27 11:48:31 +00004758 * @param param Codec parameter to set. Set to NULL to reset
4759 * codec parameter to library default settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004760 *
4761 * @return PJ_SUCCESS on success, or the appropriate error code.
4762 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004763PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004764 const pjmedia_codec_param *param);
4765
4766
4767
Benny Prijono9fc735d2006-05-28 14:58:12 +00004768
Benny Prijono312aff92006-06-17 04:08:30 +00004769/**
4770 * Create UDP media transports for all the calls. This function creates
4771 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00004772 *
Benny Prijono312aff92006-06-17 04:08:30 +00004773 * @param cfg Media transport configuration. The "port" field in the
4774 * configuration is used as the start port to bind the
4775 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004776 *
4777 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonof3195072006-02-14 21:15:30 +00004778 */
Benny Prijono312aff92006-06-17 04:08:30 +00004779PJ_DECL(pj_status_t)
4780pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00004781
Benny Prijonodc39fe82006-05-26 12:17:46 +00004782
4783/**
Benny Prijono312aff92006-06-17 04:08:30 +00004784 * Register custom media transports to be used by calls. There must
4785 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004786 *
Benny Prijono312aff92006-06-17 04:08:30 +00004787 * @param tp The media transport array.
4788 * @param count Number of elements in the array. This number MUST
4789 * match the number of maximum calls configured when
4790 * pjsua is created.
4791 * @param auto_delete Flag to indicate whether the transports should be
4792 * destroyed when pjsua is shutdown.
4793 *
4794 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00004795 */
Benny Prijono312aff92006-06-17 04:08:30 +00004796PJ_DECL(pj_status_t)
4797pjsua_media_transports_attach( pjsua_media_transport tp[],
4798 unsigned count,
4799 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00004800
4801
Benny Prijono312aff92006-06-17 04:08:30 +00004802/**
4803 * @}
4804 */
4805
Benny Prijonof3195072006-02-14 21:15:30 +00004806
Benny Prijono268ca612006-02-07 12:34:11 +00004807
Benny Prijono312aff92006-06-17 04:08:30 +00004808/**
4809 * @}
4810 */
4811
Benny Prijonoe6ead542007-01-31 20:53:31 +00004812PJ_END_DECL
4813
Benny Prijono312aff92006-06-17 04:08:30 +00004814
Benny Prijono268ca612006-02-07 12:34:11 +00004815#endif /* __PJSUA_H__ */