blob: eb1beb8cc9406ca61c7c28d6c2eefcebaa8be39d [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 Prijonob5388cf2007-01-04 22:45:08 +0000309 * Logging configuration, which can be (optionally) specified when calling
310 * #pjsua_init(). Application must call #pjsua_logging_config_default() to
311 * initialize this structure with the default values.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000312 */
313typedef struct pjsua_logging_config
314{
315 /**
316 * Log incoming and outgoing SIP message? Yes!
317 */
318 pj_bool_t msg_logging;
319
320 /**
321 * Input verbosity level. Value 5 is reasonable.
322 */
323 unsigned level;
324
325 /**
326 * Verbosity level for console. Value 4 is reasonable.
327 */
328 unsigned console_level;
329
330 /**
331 * Log decoration.
332 */
333 unsigned decor;
334
335 /**
336 * Optional log filename.
337 */
338 pj_str_t log_filename;
339
340 /**
Benny Prijonodbe3f4b2009-05-07 16:56:04 +0000341 * Additional flags to be given to #pj_file_open() when opening
342 * the log file. By default, the flag is PJ_O_WRONLY. Application
343 * may set PJ_O_APPEND here so that logs are appended to existing
344 * file instead of overwriting it.
345 *
346 * Default is 0.
347 */
348 unsigned log_file_flags;
349
350 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000351 * Optional callback function to be called to write log to
352 * application specific device. This function will be called for
353 * log messages on input verbosity level.
354 */
Benny Prijonofe7d87b2007-11-29 11:35:44 +0000355 void (*cb)(int level, const char *data, int len);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000356
357
358} pjsua_logging_config;
359
360
361/**
362 * Use this function to initialize logging config.
363 *
364 * @param cfg The logging config to be initialized.
365 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000366PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000367
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000368
369/**
370 * Use this function to duplicate logging config.
371 *
372 * @param pool Pool to use.
373 * @param dst Destination config.
374 * @param src Source config.
375 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000376PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool,
377 pjsua_logging_config *dst,
378 const pjsua_logging_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000379
Benny Prijonodc39fe82006-05-26 12:17:46 +0000380
381/**
Benny Prijono4dd961b2009-10-26 11:21:37 +0000382 * Structure to be passed on MWI callback.
383 */
384typedef struct pjsua_mwi_info
385{
386 pjsip_evsub *evsub; /**< Event subscription session, for
387 reference. */
388 pjsip_rx_data *rdata; /**< The received NOTIFY request. */
389} pjsua_mwi_info;
390
391
392/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000393 * This structure describes application callback to receive various event
394 * notification from PJSUA-API. All of these callbacks are OPTIONAL,
395 * although definitely application would want to implement some of
396 * the important callbacks (such as \a on_incoming_call).
Benny Prijonodc39fe82006-05-26 12:17:46 +0000397 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000398typedef struct pjsua_callback
Benny Prijonodc39fe82006-05-26 12:17:46 +0000399{
400 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000401 * Notify application when invite state has changed.
402 * Application may then query the call info to get the
Benny Prijonoe6ead542007-01-31 20:53:31 +0000403 * detail call states by calling pjsua_call_get_info() function.
Benny Prijono0875ae82006-12-26 00:11:48 +0000404 *
405 * @param call_id The call index.
406 * @param e Event which causes the call state to change.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000407 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000408 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000409
410 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000411 * Notify application on incoming call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000412 *
413 * @param acc_id The account which match the incoming call.
414 * @param call_id The call id that has just been created for
415 * the call.
416 * @param rdata The incoming INVITE request.
Benny Prijono8b1889b2006-06-06 18:40:40 +0000417 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000418 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000419 pjsip_rx_data *rdata);
420
421 /**
Benny Prijonofeb69f42007-10-05 09:12:26 +0000422 * This is a general notification callback which is called whenever
423 * a transaction within the call has changed state. Application can
424 * implement this callback for example to monitor the state of
425 * outgoing requests, or to answer unhandled incoming requests
426 * (such as INFO) with a final response.
427 *
428 * @param call_id Call identification.
429 * @param tsx The transaction which has changed state.
430 * @param e Transaction event that caused the state change.
431 */
432 void (*on_call_tsx_state)(pjsua_call_id call_id,
433 pjsip_transaction *tsx,
434 pjsip_event *e);
435
436 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000437 * Notify application when media state in the call has changed.
438 * Normal application would need to implement this callback, e.g.
Benny Prijono6ba8c542007-10-16 01:34:14 +0000439 * to connect the call's media to sound device. When ICE is used,
440 * this callback will also be called to report ICE negotiation
441 * failure.
Benny Prijono0875ae82006-12-26 00:11:48 +0000442 *
443 * @param call_id The call index.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000444 */
445 void (*on_call_media_state)(pjsua_call_id call_id);
446
Benny Prijonofc13bf62008-02-20 08:56:15 +0000447
448 /**
449 * Notify application when media session is created and before it is
450 * registered to the conference bridge. Application may return different
451 * media port if it has added media processing port to the stream. This
452 * media port then will be added to the conference bridge instead.
453 *
454 * @param call_id Call identification.
455 * @param sess Media session for the call.
456 * @param stream_idx Stream index in the media session.
457 * @param p_port On input, it specifies the media port of the
458 * stream. Application may modify this pointer to
459 * point to different media port to be registered
460 * to the conference bridge.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000461 */
462 void (*on_stream_created)(pjsua_call_id call_id,
463 pjmedia_session *sess,
464 unsigned stream_idx,
465 pjmedia_port **p_port);
466
467 /**
468 * Notify application when media session has been unregistered from the
469 * conference bridge and about to be destroyed.
470 *
471 * @param call_id Call identification.
472 * @param sess Media session for the call.
473 * @param stream_idx Stream index in the media session.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000474 */
475 void (*on_stream_destroyed)(pjsua_call_id call_id,
476 pjmedia_session *sess,
477 unsigned stream_idx);
478
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000479 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000480 * Notify application upon incoming DTMF digits.
481 *
482 * @param call_id The call index.
483 * @param digit DTMF ASCII digit.
484 */
485 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
486
487 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000488 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000489 * Application can decide to accept/reject transfer request
Benny Prijonoc54dcb32008-04-08 23:33:15 +0000490 * by setting the code (default is 202). When this callback
Benny Prijono9fc735d2006-05-28 14:58:12 +0000491 * is not defined, the default behavior is to accept the
492 * transfer.
Benny Prijono0875ae82006-12-26 00:11:48 +0000493 *
494 * @param call_id The call index.
495 * @param dst The destination where the call will be
496 * transfered to.
497 * @param code Status code to be returned for the call transfer
498 * request. On input, it contains status code 200.
Benny Prijono9fc735d2006-05-28 14:58:12 +0000499 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000500 void (*on_call_transfer_request)(pjsua_call_id call_id,
501 const pj_str_t *dst,
502 pjsip_status_code *code);
503
504 /**
505 * Notify application of the status of previously sent call
506 * transfer request. Application can monitor the status of the
507 * call transfer request, for example to decide whether to
508 * terminate existing call.
509 *
510 * @param call_id Call ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000511 * @param st_code Status progress of the transfer request.
512 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000513 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000514 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000515 * this callback is the final status.
516 * @param p_cont Initially will be set to non-zero, application
517 * can set this to FALSE if it no longer wants
518 * to receie further notification (for example,
519 * after it hangs up the call).
520 */
521 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000522 int st_code,
523 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000524 pj_bool_t final,
525 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000526
527 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000528 * Notify application about incoming INVITE with Replaces header.
529 * Application may reject the request by setting non-2xx code.
530 *
531 * @param call_id The call ID to be replaced.
532 * @param rdata The incoming INVITE request to replace the call.
533 * @param st_code Status code to be set by application. Application
534 * should only return a final status (200-699).
535 * @param st_text Optional status text to be set by application.
536 */
537 void (*on_call_replace_request)(pjsua_call_id call_id,
538 pjsip_rx_data *rdata,
539 int *st_code,
540 pj_str_t *st_text);
541
542 /**
543 * Notify application that an existing call has been replaced with
544 * a new call. This happens when PJSUA-API receives incoming INVITE
545 * request with Replaces header.
546 *
547 * After this callback is called, normally PJSUA-API will disconnect
548 * \a old_call_id and establish \a new_call_id.
549 *
550 * @param old_call_id Existing call which to be replaced with the
551 * new call.
552 * @param new_call_id The new call.
553 * @param rdata The incoming INVITE with Replaces request.
554 */
555 void (*on_call_replaced)(pjsua_call_id old_call_id,
556 pjsua_call_id new_call_id);
557
558
559 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000560 * Notify application when registration status has changed.
561 * Application may then query the account info to get the
562 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000563 *
564 * @param acc_id Account ID.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000565 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000566 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000567
568 /**
Benny Prijono63fba012008-07-17 14:19:10 +0000569 * Notification when incoming SUBSCRIBE request is received. Application
570 * may use this callback to authorize the incoming subscribe request
571 * (e.g. ask user permission if the request should be granted).
572 *
573 * If this callback is not implemented, all incoming presence subscription
574 * requests will be accepted.
575 *
576 * If this callback is implemented, application has several choices on
577 * what to do with the incoming request:
578 * - it may reject the request immediately by specifying non-200 class
579 * final response in the \a code argument.
580 * - it may immediately accept the request by specifying 200 as the
581 * \a code argument. This is the default value if application doesn't
582 * set any value to the \a code argument. In this case, the library
583 * will automatically send NOTIFY request upon returning from this
584 * callback.
585 * - it may delay the processing of the request, for example to request
586 * user permission whether to accept or reject the request. In this
587 * case, the application MUST set the \a code argument to 202, and
588 * later calls #pjsua_pres_notify() to accept or reject the
589 * subscription request.
590 *
591 * Any \a code other than 200 and 202 will be treated as 200.
592 *
593 * Application MUST return from this callback immediately (e.g. it must
594 * not block in this callback while waiting for user confirmation).
595 *
596 * @param srv_pres Server presence subscription instance. If
597 * application delays the acceptance of the request,
598 * it will need to specify this object when calling
599 * #pjsua_pres_notify().
600 * @param acc_id Account ID most appropriate for this request.
601 * @param buddy_id ID of the buddy matching the sender of the
602 * request, if any, or PJSUA_INVALID_ID if no
603 * matching buddy is found.
604 * @param from The From URI of the request.
605 * @param rdata The incoming request.
606 * @param code The status code to respond to the request. The
607 * default value is 200. Application may set this
608 * to other final status code to accept or reject
609 * the request.
610 * @param reason The reason phrase to respond to the request.
611 * @param msg_data If the application wants to send additional
612 * headers in the response, it can put it in this
613 * parameter.
614 */
615 void (*on_incoming_subscribe)(pjsua_acc_id acc_id,
616 pjsua_srv_pres *srv_pres,
617 pjsua_buddy_id buddy_id,
618 const pj_str_t *from,
619 pjsip_rx_data *rdata,
620 pjsip_status_code *code,
621 pj_str_t *reason,
622 pjsua_msg_data *msg_data);
623
624 /**
625 * Notification when server side subscription state has changed.
626 * This callback is optional as application normally does not need
627 * to do anything to maintain server side presence subscription.
628 *
629 * @param acc_id The account ID.
630 * @param srv_pres Server presence subscription object.
631 * @param remote_uri Remote URI string.
632 * @param state New subscription state.
633 * @param event PJSIP event that triggers the state change.
634 */
635 void (*on_srv_subscribe_state)(pjsua_acc_id acc_id,
636 pjsua_srv_pres *srv_pres,
637 const pj_str_t *remote_uri,
638 pjsip_evsub_state state,
639 pjsip_event *event);
640
641 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000642 * Notify application when the buddy state has changed.
643 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000644 *
645 * @param buddy_id The buddy id.
Benny Prijono9fc735d2006-05-28 14:58:12 +0000646 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000647 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000648
649 /**
650 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000651 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000652 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000653 *
Benny Prijonobbeb3992007-05-21 13:48:35 +0000654 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
655 * passed as one of the argument.
656 *
Benny Prijono0875ae82006-12-26 00:11:48 +0000657 * @param call_id Containts the ID of the call where the IM was
658 * sent, or PJSUA_INVALID_ID if the IM was sent
659 * outside call context.
660 * @param from URI of the sender.
661 * @param to URI of the destination message.
662 * @param contact The Contact URI of the sender, if present.
663 * @param mime_type MIME type of the message.
664 * @param body The message content.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000665 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000666 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
667 const pj_str_t *to, const pj_str_t *contact,
668 const pj_str_t *mime_type, const pj_str_t *body);
669
670 /**
Benny Prijonobbeb3992007-05-21 13:48:35 +0000671 * This is the alternative version of the \a on_pager() callback with
672 * \a pjsip_rx_data argument.
673 *
674 * @param call_id Containts the ID of the call where the IM was
675 * sent, or PJSUA_INVALID_ID if the IM was sent
676 * outside call context.
677 * @param from URI of the sender.
678 * @param to URI of the destination message.
679 * @param contact The Contact URI of the sender, if present.
680 * @param mime_type MIME type of the message.
681 * @param body The message content.
682 * @param rdata The incoming MESSAGE request.
Benny Prijonoba736c42008-07-10 20:45:03 +0000683 * @param acc_id Account ID most suitable for this message.
Benny Prijonobbeb3992007-05-21 13:48:35 +0000684 */
685 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
686 const pj_str_t *to, const pj_str_t *contact,
687 const pj_str_t *mime_type, const pj_str_t *body,
Benny Prijonoba736c42008-07-10 20:45:03 +0000688 pjsip_rx_data *rdata, pjsua_acc_id acc_id);
Benny Prijonobbeb3992007-05-21 13:48:35 +0000689
690 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000691 * Notify application about the delivery status of outgoing pager
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000692 * request. See also on_pager_status2() callback for the version with
693 * \a pjsip_rx_data in the argument list.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000694 *
695 * @param call_id Containts the ID of the call where the IM was
696 * sent, or PJSUA_INVALID_ID if the IM was sent
697 * outside call context.
698 * @param to Destination URI.
699 * @param body Message body.
700 * @param user_data Arbitrary data that was specified when sending
701 * IM message.
702 * @param status Delivery status.
703 * @param reason Delivery status reason.
704 */
705 void (*on_pager_status)(pjsua_call_id call_id,
706 const pj_str_t *to,
707 const pj_str_t *body,
708 void *user_data,
709 pjsip_status_code status,
710 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000711
712 /**
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000713 * Notify application about the delivery status of outgoing pager
714 * request.
715 *
716 * @param call_id Containts the ID of the call where the IM was
717 * sent, or PJSUA_INVALID_ID if the IM was sent
718 * outside call context.
719 * @param to Destination URI.
720 * @param body Message body.
721 * @param user_data Arbitrary data that was specified when sending
722 * IM message.
723 * @param status Delivery status.
724 * @param reason Delivery status reason.
Benny Prijono0a982002007-06-12 16:22:09 +0000725 * @param tdata The original MESSAGE request.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000726 * @param rdata The incoming MESSAGE response, or NULL if the
727 * message transaction fails because of time out
728 * or transport error.
Benny Prijonoba736c42008-07-10 20:45:03 +0000729 * @param acc_id Account ID from this the instant message was
730 * send.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000731 */
732 void (*on_pager_status2)(pjsua_call_id call_id,
733 const pj_str_t *to,
734 const pj_str_t *body,
735 void *user_data,
736 pjsip_status_code status,
737 const pj_str_t *reason,
Benny Prijono0a982002007-06-12 16:22:09 +0000738 pjsip_tx_data *tdata,
Benny Prijonoba736c42008-07-10 20:45:03 +0000739 pjsip_rx_data *rdata,
740 pjsua_acc_id acc_id);
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000741
742 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000743 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +0000744 *
745 * @param call_id Containts the ID of the call where the IM was
746 * sent, or PJSUA_INVALID_ID if the IM was sent
747 * outside call context.
748 * @param from URI of the sender.
749 * @param to URI of the destination message.
750 * @param contact The Contact URI of the sender, if present.
751 * @param is_typing Non-zero if peer is typing, or zero if peer
752 * has stopped typing a message.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000753 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000754 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
755 const pj_str_t *to, const pj_str_t *contact,
756 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000757
Benny Prijono6ba8c542007-10-16 01:34:14 +0000758 /**
Benny Prijonoba736c42008-07-10 20:45:03 +0000759 * Notify application about typing indication.
760 *
761 * @param call_id Containts the ID of the call where the IM was
762 * sent, or PJSUA_INVALID_ID if the IM was sent
763 * outside call context.
764 * @param from URI of the sender.
765 * @param to URI of the destination message.
766 * @param contact The Contact URI of the sender, if present.
767 * @param is_typing Non-zero if peer is typing, or zero if peer
768 * has stopped typing a message.
769 * @param rdata The received request.
770 * @param acc_id Account ID most suitable for this message.
771 */
772 void (*on_typing2)(pjsua_call_id call_id, const pj_str_t *from,
773 const pj_str_t *to, const pj_str_t *contact,
774 pj_bool_t is_typing, pjsip_rx_data *rdata,
775 pjsua_acc_id acc_id);
776
777 /**
Benny Prijono6ba8c542007-10-16 01:34:14 +0000778 * Callback when the library has finished performing NAT type
779 * detection.
780 *
781 * @param res NAT detection result.
782 */
783 void (*on_nat_detect)(const pj_stun_nat_detect_result *res);
784
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000785 /**
786 * This callback is called when the call is about to resend the
787 * INVITE request to the specified target, following the previously
788 * received redirection response.
789 *
790 * Application may accept the redirection to the specified target
791 * (the default behavior if this callback is implemented), reject
792 * this target only and make the session continue to try the next
793 * target in the list if such target exists, stop the whole
794 * redirection process altogether and cause the session to be
795 * disconnected, or defer the decision to ask for user confirmation.
796 *
797 * This callback is optional. If this callback is not implemented,
798 * the default behavior is to NOT follow the redirection response.
799 *
800 * @param call_id The call ID.
801 * @param target The current target to be tried.
Benny Prijono08a48b82008-11-27 12:42:07 +0000802 * @param e The event that caused this callback to be called.
803 * This could be the receipt of 3xx response, or
804 * 4xx/5xx response received for the INVITE sent to
805 * subsequent targets, or NULL if this callback is
806 * called from within #pjsua_call_process_redirect()
807 * context.
808 *
809 * @return Action to be performed for the target. Set this
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000810 * parameter to one of the value below:
811 * - PJSIP_REDIRECT_ACCEPT: immediately accept the
812 * redirection (default value). When set, the
813 * call will immediately resend INVITE request
814 * to the target.
815 * - PJSIP_REDIRECT_REJECT: immediately reject this
816 * target. The call will continue retrying with
817 * next target if present, or disconnect the call
818 * if there is no more target to try.
819 * - PJSIP_REDIRECT_STOP: stop the whole redirection
820 * process and immediately disconnect the call. The
821 * on_call_state() callback will be called with
822 * PJSIP_INV_STATE_DISCONNECTED state immediately
823 * after this callback returns.
824 * - PJSIP_REDIRECT_PENDING: set to this value if
825 * no decision can be made immediately (for example
826 * to request confirmation from user). Application
827 * then MUST call #pjsua_call_process_redirect()
828 * to either accept or reject the redirection upon
829 * getting user decision.
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000830 */
Benny Prijono08a48b82008-11-27 12:42:07 +0000831 pjsip_redirect_op (*on_call_redirected)(pjsua_call_id call_id,
832 const pjsip_uri *target,
833 const pjsip_event *e);
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000834
Benny Prijono4dd961b2009-10-26 11:21:37 +0000835 /**
836 * This callback is called when a NOTIFY request for message summary /
837 * message waiting indication is received.
838 *
839 * @param acc_id The account ID.
840 * @param mwi_info Structure containing details of the event,
841 * including the received NOTIFY request in the
842 * \a rdata field.
843 */
844 void (*on_mwi_info)(pjsua_acc_id acc_id, pjsua_mwi_info *mwi_info);
845
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +0000846 /**
847 * This callback is called when transport state is changed. See also
848 * #pjsip_tp_state_callback.
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +0000849 */
Nanang Izzuddin5e69da52010-02-25 11:58:19 +0000850 pjsip_tp_state_callback on_transport_state;
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +0000851
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000852} pjsua_callback;
853
854
855
Benny Prijonodc39fe82006-05-26 12:17:46 +0000856
857/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000858 * This structure describes the settings to control the API and
859 * user agent behavior, and can be specified when calling #pjsua_init().
860 * Before setting the values, application must call #pjsua_config_default()
861 * to initialize this structure with the default values.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000862 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000863typedef struct pjsua_config
864{
865
866 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000867 * Maximum calls to support (default: 4). The value specified here
868 * must be smaller than the compile time maximum settings
869 * PJSUA_MAX_CALLS, which by default is 32. To increase this
870 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
871 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000872 */
873 unsigned max_calls;
874
875 /**
876 * Number of worker threads. Normally application will want to have at
877 * least one worker thread, unless when it wants to poll the library
878 * periodically, which in this case the worker thread can be set to
879 * zero.
880 */
881 unsigned thread_cnt;
882
883 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +0000884 * Number of nameservers. If no name server is configured, the SIP SRV
885 * resolution would be disabled, and domain will be resolved with
886 * standard pj_gethostbyname() function.
887 */
888 unsigned nameserver_count;
889
890 /**
891 * Array of nameservers to be used by the SIP resolver subsystem.
892 * The order of the name server specifies the priority (first name
893 * server will be used first, unless it is not reachable).
894 */
895 pj_str_t nameserver[4];
896
897 /**
Benny Prijono91d06b62008-09-20 12:16:56 +0000898 * Force loose-route to be used in all route/proxy URIs (outbound_proxy
899 * and account's proxy settings). When this setting is enabled, the
900 * library will check all the route/proxy URIs specified in the settings
901 * and append ";lr" parameter to the URI if the parameter is not present.
902 *
903 * Default: 1
904 */
905 pj_bool_t force_lr;
906
907 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000908 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000909 */
910 unsigned outbound_proxy_cnt;
911
912 /**
913 * Specify the URL of outbound proxies to visit for all outgoing requests.
914 * The outbound proxies will be used for all accounts, and it will
915 * be used to build the route set for outgoing requests. The final
916 * route set for outgoing requests will consists of the outbound proxies
917 * and the proxy configured in the account.
918 */
919 pj_str_t outbound_proxy[4];
920
Benny Prijonoc97608e2007-03-23 16:34:20 +0000921 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +0000922 * Warning: deprecated, please use \a stun_srv field instead. To maintain
923 * backward compatibility, if \a stun_srv_cnt is zero then the value of
924 * this field will be copied to \a stun_srv field, if present.
925 *
Benny Prijonoebbf6892007-03-24 17:37:25 +0000926 * Specify domain name to be resolved with DNS SRV resolution to get the
Benny Prijonof76e1392008-06-06 14:51:48 +0000927 * address of the STUN server. Alternatively application may specify
928 * \a stun_host instead.
Benny Prijonoebbf6892007-03-24 17:37:25 +0000929 *
930 * If DNS SRV resolution failed for this domain, then DNS A resolution
931 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +0000932 */
Benny Prijonoebbf6892007-03-24 17:37:25 +0000933 pj_str_t stun_domain;
934
935 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +0000936 * Warning: deprecated, please use \a stun_srv field instead. To maintain
937 * backward compatibility, if \a stun_srv_cnt is zero then the value of
938 * this field will be copied to \a stun_srv field, if present.
939 *
Benny Prijonoaf09dc32007-04-22 12:48:30 +0000940 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
941 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +0000942 */
943 pj_str_t stun_host;
944
945 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +0000946 * Number of STUN server entries in \a stun_srv array.
947 */
948 unsigned stun_srv_cnt;
949
950 /**
951 * Array of STUN servers to try. The library will try to resolve and
952 * contact each of the STUN server entry until it finds one that is
953 * usable. Each entry may be a domain name, host name, IP address, and
954 * it may contain an optional port number. For example:
955 * - "pjsip.org" (domain name)
956 * - "sip.pjsip.org" (host name)
957 * - "pjsip.org:33478" (domain name and a non-standard port number)
958 * - "10.0.0.1:3478" (IP address and port number)
959 *
960 * When nameserver is configured in the \a pjsua_config.nameserver field,
961 * if entry is not an IP address, it will be resolved with DNS SRV
962 * resolution first, and it will fallback to use DNS A resolution if this
963 * fails. Port number may be specified even if the entry is a domain name,
964 * in case the DNS SRV resolution should fallback to a non-standard port.
965 *
966 * When nameserver is not configured, entries will be resolved with
967 * #pj_gethostbyname() if it's not an IP address. Port number may be
968 * specified if the server is not listening in standard STUN port.
969 */
970 pj_str_t stun_srv[8];
971
972 /**
973 * This specifies if the library startup should ignore failure with the
974 * STUN servers. If this is set to PJ_FALSE, the library will refuse to
975 * start if it fails to resolve or contact any of the STUN servers.
976 *
977 * Default: PJ_TRUE
978 */
979 pj_bool_t stun_ignore_failure;
980
981 /**
Benny Prijono91a6a172007-10-31 08:59:29 +0000982 * Support for adding and parsing NAT type in the SDP to assist
983 * troubleshooting. The valid values are:
984 * - 0: no information will be added in SDP, and parsing is disabled.
Benny Prijono6ba8c542007-10-16 01:34:14 +0000985 * - 1: only the NAT type number is added.
986 * - 2: add both NAT type number and name.
987 *
Benny Prijono91a6a172007-10-31 08:59:29 +0000988 * Default: 1
Benny Prijono6ba8c542007-10-16 01:34:14 +0000989 */
990 int nat_type_in_sdp;
991
992 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +0000993 * Specify whether support for reliable provisional response (100rel and
994 * PRACK) should be required by default. Note that this setting can be
995 * further customized in account configuration (#pjsua_acc_config).
996 *
997 * Default: PJ_FALSE
998 */
999 pj_bool_t require_100rel;
1000
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001001 /**
1002 * Specify whether support for Session Timers should be required by
1003 * default. Note that this setting can be further customized in account
1004 * configuration (#pjsua_acc_config).
1005 *
1006 * Default: PJ_FALSE
1007 */
1008 pj_bool_t require_timer;
1009
1010 /**
Benny Prijonofe1bd342009-11-20 23:33:07 +00001011 * Handle unsolicited NOTIFY requests containing message waiting
1012 * indication (MWI) info. Unsolicited MWI is incoming NOTIFY requests
1013 * which are not requested by client with SUBSCRIBE request.
1014 *
1015 * If this is enabled, the library will respond 200/OK to the NOTIFY
1016 * request and forward the request to \a on_mwi_info() callback.
1017 *
1018 * See also \a mwi_enabled field #on pjsua_acc_config.
1019 *
1020 * Default: PJ_TRUE
1021 *
1022 */
1023 pj_bool_t enable_unsolicited_mwi;
1024
1025 /**
Nanang Izzuddin65add622009-08-11 16:26:20 +00001026 * Specify Session Timer settings, see #pjsip_timer_setting.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001027 * Note that this setting can be further customized in account
1028 * configuration (#pjsua_acc_config).
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001029 */
Nanang Izzuddin65add622009-08-11 16:26:20 +00001030 pjsip_timer_setting timer_setting;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001031
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001032 /**
1033 * Number of credentials in the credential array.
1034 */
1035 unsigned cred_count;
1036
1037 /**
1038 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +00001039 * and can be used to authenticate against outbound proxies. If the
1040 * credential is specific to the account, then application should set
1041 * the credential in the pjsua_acc_config rather than the credential
1042 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001043 */
1044 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1045
1046 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001047 * Application callback to receive various event notifications from
1048 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001049 */
1050 pjsua_callback cb;
1051
Benny Prijono56315612006-07-18 14:39:40 +00001052 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001053 * Optional user agent string (default empty). If it's empty, no
1054 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +00001055 */
1056 pj_str_t user_agent;
1057
Benny Prijonod8179652008-01-23 20:39:07 +00001058#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
1059 /**
1060 * Specify default value of secure media transport usage.
1061 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
1062 * PJMEDIA_SRTP_MANDATORY.
1063 *
1064 * Note that this setting can be further customized in account
1065 * configuration (#pjsua_acc_config).
1066 *
1067 * Default: #PJSUA_DEFAULT_USE_SRTP
1068 */
1069 pjmedia_srtp_use use_srtp;
1070
1071 /**
1072 * Specify whether SRTP requires secure signaling to be used. This option
1073 * is only used when \a use_srtp option above is non-zero.
1074 *
1075 * Valid values are:
1076 * 0: SRTP does not require secure signaling
1077 * 1: SRTP requires secure transport such as TLS
1078 * 2: SRTP requires secure end-to-end transport (SIPS)
1079 *
1080 * Note that this setting can be further customized in account
1081 * configuration (#pjsua_acc_config).
1082 *
1083 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
1084 */
1085 int srtp_secure_signaling;
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00001086
1087 /**
1088 * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose
1089 * duplicated media in SDP offer, i.e: unsecured and secured version.
1090 * Otherwise, the SDP media will be composed as unsecured media but
1091 * with SDP "crypto" attribute.
1092 *
1093 * Default: PJ_FALSE
1094 */
1095 pj_bool_t srtp_optional_dup_offer;
Benny Prijonod8179652008-01-23 20:39:07 +00001096#endif
1097
Benny Prijono3c5e28b2008-09-24 10:10:15 +00001098 /**
1099 * Disconnect other call legs when more than one 2xx responses for
1100 * outgoing INVITE are received due to forking. Currently the library
1101 * is not able to handle simultaneous forked media, so disconnecting
1102 * the other call legs is necessary.
1103 *
1104 * With this setting enabled, the library will handle only one of the
1105 * connected call leg, and the other connected call legs will be
1106 * disconnected.
1107 *
1108 * Default: PJ_TRUE (only disable this setting for testing purposes).
1109 */
1110 pj_bool_t hangup_forked_call;
1111
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001112} pjsua_config;
1113
1114
1115/**
1116 * Use this function to initialize pjsua config.
1117 *
1118 * @param cfg pjsua config to be initialized.
1119 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001120PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001121
1122
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001123/** The implementation has been moved to sip_auth.h */
Benny Prijono7977f9f2007-10-10 11:37:56 +00001124#define pjsip_cred_dup pjsip_cred_info_dup
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001125
1126
1127/**
1128 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001129 *
1130 * @param pool The pool to get memory from.
1131 * @param dst Destination config.
1132 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001133 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001134PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1135 pjsua_config *dst,
1136 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001137
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001138
1139/**
1140 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001141 * outgoing SIP message. It can (optionally) be specified for example
1142 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1143 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1144 *
1145 * Application MUST call #pjsua_msg_data_init() to initialize this
1146 * structure before setting its values.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001147 */
Benny Prijono63fba012008-07-17 14:19:10 +00001148struct pjsua_msg_data
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001149{
1150 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001151 * Additional message headers as linked list. Application can add
1152 * headers to the list by creating the header, either from the heap/pool
1153 * or from temporary local variable, and add the header using
1154 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001155 */
1156 pjsip_hdr hdr_list;
1157
1158 /**
1159 * MIME type of optional message body.
1160 */
1161 pj_str_t content_type;
1162
1163 /**
1164 * Optional message body.
1165 */
1166 pj_str_t msg_body;
1167
Benny Prijono63fba012008-07-17 14:19:10 +00001168};
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001169
1170
1171/**
1172 * Initialize message data.
1173 *
1174 * @param msg_data Message data to be initialized.
1175 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001176PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001177
Benny Prijono268ca612006-02-07 12:34:11 +00001178
1179/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001180 * Instantiate pjsua application. Application must call this function before
1181 * calling any other functions, to make sure that the underlying libraries
1182 * are properly initialized. Once this function has returned success,
1183 * application must call pjsua_destroy() before quitting.
1184 *
1185 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00001186 */
1187PJ_DECL(pj_status_t) pjsua_create(void);
1188
1189
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001190/** Forward declaration */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001191typedef struct pjsua_media_config pjsua_media_config;
1192
1193
Benny Prijonodc39fe82006-05-26 12:17:46 +00001194/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001195 * Initialize pjsua with the specified settings. All the settings are
1196 * optional, and the default values will be used when the config is not
1197 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001198 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001199 * Note that #pjsua_create() MUST be called before calling this function.
1200 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001201 * @param ua_cfg User agent configuration.
1202 * @param log_cfg Optional logging configuration.
1203 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001204 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001205 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001206 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001207PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1208 const pjsua_logging_config *log_cfg,
1209 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001210
1211
1212/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001213 * Application is recommended to call this function after all initialization
1214 * is done, so that the library can do additional checking set up
1215 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001216 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001217 * Application may call this function anytime after #pjsua_init().
1218 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001219 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoccf95622006-02-07 18:48:01 +00001220 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001221PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001222
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001223
Benny Prijonoccf95622006-02-07 18:48:01 +00001224/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001225 * Destroy pjsua. Application is recommended to perform graceful shutdown
1226 * before calling this function (such as unregister the account from the SIP
1227 * server, terminate presense subscription, and hangup active calls), however,
1228 * this function will do all of these if it finds there are active sessions
1229 * that need to be terminated. This function will approximately block for
1230 * one second to wait for replies from remote.
1231 *
1232 * Application.may safely call this function more than once if it doesn't
1233 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001234 *
1235 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001236 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001237PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001238
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001239
Benny Prijono9fc735d2006-05-28 14:58:12 +00001240/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001241 * Poll pjsua for events, and if necessary block the caller thread for
1242 * the specified maximum interval (in miliseconds).
1243 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001244 * Application doesn't normally need to call this function if it has
1245 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1246 * because polling then will be done by these worker threads instead.
1247 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001248 * @param msec_timeout Maximum time to wait, in miliseconds.
1249 *
1250 * @return The number of events that have been handled during the
1251 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001252 * can retrieve the error as (status = -return_value).
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001253 */
1254PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1255
1256
1257/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001258 * Create memory pool to be used by the application. Once application
1259 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001260 *
1261 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001262 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001263 * @param increment Increment size.
1264 *
1265 * @return The pool, or NULL when there's no memory.
1266 */
1267PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1268 pj_size_t increment);
1269
1270
1271/**
1272 * Application can call this function at any time (after pjsua_create(), of
1273 * course) to change logging settings.
1274 *
1275 * @param c Logging configuration.
1276 *
1277 * @return PJ_SUCCESS on success, or the appropriate error code.
1278 */
1279PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1280
1281
1282/**
1283 * Internal function to get SIP endpoint instance of pjsua, which is
1284 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001285 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001286 *
1287 * @return SIP endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001288 */
1289PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1290
1291/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001292 * Internal function to get media endpoint instance.
1293 * Only valid after #pjsua_init() is called.
1294 *
1295 * @return Media endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001296 */
1297PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1298
Benny Prijono97b87172006-08-24 14:25:14 +00001299/**
1300 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001301 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001302 *
1303 * @return Pool factory currently used by PJSUA.
1304 */
1305PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1306
1307
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001308
1309/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001310 * Utilities.
1311 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001312 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001313
1314/**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001315 * This structure is used to represent the result of the STUN server
1316 * resolution and testing, the #pjsua_resolve_stun_servers() function.
1317 * This structure will be passed in #pj_stun_resolve_cb callback.
1318 */
1319typedef struct pj_stun_resolve_result
1320{
1321 /**
1322 * Arbitrary data that was passed to #pjsua_resolve_stun_servers()
1323 * function.
1324 */
1325 void *token;
1326
1327 /**
1328 * This will contain PJ_SUCCESS if at least one usable STUN server
1329 * is found, otherwise it will contain the last error code during
1330 * the operation.
1331 */
1332 pj_status_t status;
1333
1334 /**
1335 * The server name that yields successful result. This will only
1336 * contain value if status is successful.
1337 */
1338 pj_str_t name;
1339
1340 /**
1341 * The server IP address. This will only contain value if status
1342 * is successful.
1343 */
1344 pj_sockaddr addr;
1345
1346} pj_stun_resolve_result;
1347
1348
1349/**
1350 * Typedef of callback to be registered to #pjsua_resolve_stun_servers().
1351 */
1352typedef void (*pj_stun_resolve_cb)(const pj_stun_resolve_result *result);
1353
1354/**
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001355 * This is a utility function to detect NAT type in front of this
1356 * endpoint. Once invoked successfully, this function will complete
Benny Prijono6ba8c542007-10-16 01:34:14 +00001357 * asynchronously and report the result in \a on_nat_detect() callback
1358 * of pjsua_callback.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001359 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001360 * After NAT has been detected and the callback is called, application can
1361 * get the detected NAT type by calling #pjsua_get_nat_type(). Application
1362 * can also perform NAT detection by calling #pjsua_detect_nat_type()
1363 * again at later time.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001364 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001365 * Note that STUN must be enabled to run this function successfully.
1366 *
1367 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001368 */
Benny Prijono6ba8c542007-10-16 01:34:14 +00001369PJ_DECL(pj_status_t) pjsua_detect_nat_type(void);
1370
1371
1372/**
1373 * Get the NAT type as detected by #pjsua_detect_nat_type() function.
1374 * This function will only return useful NAT type after #pjsua_detect_nat_type()
1375 * has completed successfully and \a on_nat_detect() callback has been called.
1376 *
1377 * @param type NAT type.
1378 *
1379 * @return When detection is in progress, this function will
1380 * return PJ_EPENDING and \a type will be set to
1381 * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been
1382 * detected successfully, this function will return
1383 * PJ_SUCCESS and \a type will be set to the correct
1384 * value. Other return values indicate error and
1385 * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN.
Benny Prijono91a6a172007-10-31 08:59:29 +00001386 *
1387 * @see pjsua_call_get_rem_nat_type()
Benny Prijono6ba8c542007-10-16 01:34:14 +00001388 */
1389PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type);
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001390
1391
1392/**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001393 * Auxiliary function to resolve and contact each of the STUN server
1394 * entries (sequentially) to find which is usable. The #pjsua_init() must
1395 * have been called before calling this function.
1396 *
1397 * @param count Number of STUN server entries to try.
1398 * @param srv Array of STUN server entries to try. Please see
1399 * the \a stun_srv field in the #pjsua_config
1400 * documentation about the format of this entry.
1401 * @param wait Specify non-zero to make the function block until
1402 * it gets the result. In this case, the function
1403 * will block while the resolution is being done,
1404 * and the callback will be called before this function
1405 * returns.
1406 * @param token Arbitrary token to be passed back to application
1407 * in the callback.
1408 * @param cb Callback to be called to notify the result of
1409 * the function.
1410 *
1411 * @return If \a wait parameter is non-zero, this will return
1412 * PJ_SUCCESS if one usable STUN server is found.
1413 * Otherwise it will always return PJ_SUCCESS, and
1414 * application will be notified about the result in
1415 * the callback.
1416 */
1417PJ_DECL(pj_status_t) pjsua_resolve_stun_servers(unsigned count,
1418 pj_str_t srv[],
1419 pj_bool_t wait,
1420 void *token,
1421 pj_stun_resolve_cb cb);
1422
1423/**
1424 * Cancel pending STUN resolution which match the specified token.
1425 *
1426 * @param token The token to match. This token was given to
1427 * #pjsua_resolve_stun_servers()
1428 * @param notify_cb Boolean to control whether the callback should
1429 * be called for cancelled resolutions. When the
1430 * callback is called, the status in the result
1431 * will be set as PJ_ECANCELLED.
1432 *
1433 * @return PJ_SUCCESS if there is at least one pending STUN
1434 * resolution cancelled, or PJ_ENOTFOUND if there is
1435 * no matching one, or other error.
1436 */
1437PJ_DECL(pj_status_t) pjsua_cancel_stun_resolution(void *token,
1438 pj_bool_t notify_cb);
1439
1440
1441/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001442 * This is a utility function to verify that valid SIP url is given. If the
1443 * URL is valid, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001444 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001445 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001446 *
1447 * @return PJ_SUCCESS on success, or the appropriate error code.
1448 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001449PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001450
1451
1452/**
Benny Prijono73bb7232009-10-20 13:56:26 +00001453 * Schedule a timer entry. Note that the timer callback may be executed
1454 * by different thread, depending on whether worker thread is enabled or
1455 * not.
1456 *
1457 * @param entry Timer heap entry.
1458 * @param delay The interval to expire.
1459 *
1460 * @return PJ_SUCCESS on success, or the appropriate error code.
1461 *
1462 * @see pjsip_endpt_schedule_timer()
1463 */
1464PJ_DECL(pj_status_t) pjsua_schedule_timer(pj_timer_entry *entry,
1465 const pj_time_val *delay);
1466
1467
1468/**
1469 * Cancel the previously scheduled timer.
1470 *
1471 * @param entry Timer heap entry.
1472 *
1473 * @see pjsip_endpt_cancel_timer()
1474 */
1475PJ_DECL(void) pjsua_cancel_timer(pj_timer_entry *entry);
1476
1477
1478/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001479 * This is a utility function to display error message for the specified
1480 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001481 *
1482 * @param sender The log sender field.
1483 * @param title Message title for the error.
1484 * @param status Status code.
1485 */
1486PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1487 pj_status_t status);
1488
1489
Benny Prijonoda9785b2007-04-02 20:43:06 +00001490/**
1491 * This is a utility function to dump the stack states to log, using
1492 * verbosity level 3.
1493 *
1494 * @param detail Will print detailed output (such as list of
1495 * SIP transactions) when non-zero.
1496 */
1497PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001498
1499/**
1500 * @}
1501 */
1502
1503
1504
1505/*****************************************************************************
1506 * TRANSPORT API
1507 */
1508
1509/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001510 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001511 * @ingroup PJSUA_LIB
1512 * @brief API for managing SIP transports
1513 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001514 *
1515 * PJSUA-API supports creating multiple transport instances, for example UDP,
1516 * TCP, and TLS transport. SIP transport must be created before adding an
1517 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001518 */
1519
1520
Benny Prijonoe6ead542007-01-31 20:53:31 +00001521/** SIP transport identification.
1522 */
Benny Prijono312aff92006-06-17 04:08:30 +00001523typedef int pjsua_transport_id;
1524
1525
1526/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001527 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001528 * and media. Before setting some values to this structure, application
1529 * MUST call #pjsua_transport_config_default() to initialize its
1530 * values with default settings.
Benny Prijono312aff92006-06-17 04:08:30 +00001531 */
1532typedef struct pjsua_transport_config
1533{
1534 /**
1535 * UDP port number to bind locally. This setting MUST be specified
1536 * even when default port is desired. If the value is zero, the
1537 * transport will be bound to any available port, and application
1538 * can query the port by querying the transport info.
1539 */
1540 unsigned port;
1541
1542 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001543 * Optional address to advertise as the address of this transport.
1544 * Application can specify any address or hostname for this field,
1545 * for example it can point to one of the interface address in the
1546 * system, or it can point to the public address of a NAT router
1547 * where port mappings have been configured for the application.
1548 *
1549 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001550 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001551 pj_str_t public_addr;
1552
1553 /**
1554 * Optional address where the socket should be bound to. This option
1555 * SHOULD only be used to selectively bind the socket to particular
1556 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1557 * published address of a transport (the public_addr field should be
1558 * used for that purpose).
1559 *
1560 * Note that unlike public_addr field, the address (or hostname) here
1561 * MUST correspond to the actual interface address in the host, since
1562 * this address will be specified as bind() argument.
1563 */
1564 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001565
1566 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001567 * This specifies TLS settings for TLS transport. It is only be used
1568 * when this transport config is being used to create a SIP TLS
1569 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001570 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001571 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001572
Benny Prijono4d79b0f2009-10-25 09:02:07 +00001573 /**
1574 * QoS traffic type to be set on this transport. When application wants
1575 * to apply QoS tagging to the transport, it's preferable to set this
1576 * field rather than \a qos_param fields since this is more portable.
1577 *
1578 * Default is QoS not set.
1579 */
1580 pj_qos_type qos_type;
1581
1582 /**
1583 * Set the low level QoS parameters to the transport. This is a lower
1584 * level operation than setting the \a qos_type field and may not be
1585 * supported on all platforms.
1586 *
1587 * Default is QoS not set.
1588 */
1589 pj_qos_params qos_params;
1590
Benny Prijono312aff92006-06-17 04:08:30 +00001591} pjsua_transport_config;
1592
1593
1594/**
1595 * Call this function to initialize UDP config with default values.
1596 *
1597 * @param cfg The UDP config to be initialized.
1598 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001599PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001600
1601
1602/**
Benny Prijono312aff92006-06-17 04:08:30 +00001603 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001604 *
1605 * @param pool The pool.
1606 * @param dst The destination config.
1607 * @param src The source config.
Benny Prijono312aff92006-06-17 04:08:30 +00001608 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001609PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1610 pjsua_transport_config *dst,
1611 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001612
1613
1614/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001615 * This structure describes transport information returned by
1616 * #pjsua_transport_get_info() function.
Benny Prijono312aff92006-06-17 04:08:30 +00001617 */
1618typedef struct pjsua_transport_info
1619{
1620 /**
1621 * PJSUA transport identification.
1622 */
1623 pjsua_transport_id id;
1624
1625 /**
1626 * Transport type.
1627 */
1628 pjsip_transport_type_e type;
1629
1630 /**
1631 * Transport type name.
1632 */
1633 pj_str_t type_name;
1634
1635 /**
1636 * Transport string info/description.
1637 */
1638 pj_str_t info;
1639
1640 /**
1641 * Transport flag (see ##pjsip_transport_flags_e).
1642 */
1643 unsigned flag;
1644
1645 /**
1646 * Local address length.
1647 */
1648 unsigned addr_len;
1649
1650 /**
1651 * Local/bound address.
1652 */
1653 pj_sockaddr local_addr;
1654
1655 /**
1656 * Published address (or transport address name).
1657 */
1658 pjsip_host_port local_name;
1659
1660 /**
1661 * Current number of objects currently referencing this transport.
1662 */
1663 unsigned usage_count;
1664
1665
1666} pjsua_transport_info;
1667
1668
1669/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001670 * Create and start a new SIP transport according to the specified
1671 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001672 *
1673 * @param type Transport type.
1674 * @param cfg Transport configuration.
1675 * @param p_id Optional pointer to receive transport ID.
1676 *
1677 * @return PJ_SUCCESS on success, or the appropriate error code.
1678 */
1679PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1680 const pjsua_transport_config *cfg,
1681 pjsua_transport_id *p_id);
1682
1683/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001684 * Register transport that has been created by application. This function
1685 * is useful if application wants to implement custom SIP transport and use
1686 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001687 *
1688 * @param tp Transport instance.
1689 * @param p_id Optional pointer to receive transport ID.
1690 *
1691 * @return PJ_SUCCESS on success, or the appropriate error code.
1692 */
1693PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1694 pjsua_transport_id *p_id);
1695
1696
1697/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001698 * Enumerate all transports currently created in the system. This function
1699 * will return all transport IDs, and application may then call
1700 * #pjsua_transport_get_info() function to retrieve detailed information
1701 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001702 *
1703 * @param id Array to receive transport ids.
1704 * @param count In input, specifies the maximum number of elements.
1705 * On return, it contains the actual number of elements.
1706 *
1707 * @return PJ_SUCCESS on success, or the appropriate error code.
1708 */
1709PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1710 unsigned *count );
1711
1712
1713/**
1714 * Get information about transports.
1715 *
1716 * @param id Transport ID.
1717 * @param info Pointer to receive transport info.
1718 *
1719 * @return PJ_SUCCESS on success, or the appropriate error code.
1720 */
1721PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1722 pjsua_transport_info *info);
1723
1724
1725/**
1726 * Disable a transport or re-enable it. By default transport is always
1727 * enabled after it is created. Disabling a transport does not necessarily
1728 * close the socket, it will only discard incoming messages and prevent
1729 * the transport from being used to send outgoing messages.
1730 *
1731 * @param id Transport ID.
1732 * @param enabled Non-zero to enable, zero to disable.
1733 *
1734 * @return PJ_SUCCESS on success, or the appropriate error code.
1735 */
1736PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1737 pj_bool_t enabled);
1738
1739
1740/**
1741 * Close the transport. If transport is forcefully closed, it will be
1742 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00001743 * transport may not terminate properly (it may even crash). Otherwise,
1744 * the system will wait until all transactions are closed while preventing
1745 * new users from using the transport, and will close the transport when
1746 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001747 *
1748 * @param id Transport ID.
1749 * @param force Non-zero to immediately close the transport. This
1750 * is not recommended!
1751 *
1752 * @return PJ_SUCCESS on success, or the appropriate error code.
1753 */
1754PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1755 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001756
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001757/**
Benny Prijono312aff92006-06-17 04:08:30 +00001758 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001759 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001760
1761
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001762
1763
1764/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001765 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001766 */
1767
Benny Prijono312aff92006-06-17 04:08:30 +00001768
1769/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001770 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001771 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001772 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001773 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001774 *
Benny Prijono312aff92006-06-17 04:08:30 +00001775 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001776 * using the application. In SIP terms, the identity is used as the <b>From</b>
1777 * header in outgoing requests.
1778 *
1779 * PJSUA-API supports creating and managing multiple accounts. The maximum
1780 * number of accounts is limited by a compile time constant
1781 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001782 *
1783 * Account may or may not have client registration associated with it.
1784 * An account is also associated with <b>route set</b> and some <b>authentication
1785 * credentials</b>, which are used when sending SIP request messages using the
1786 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00001787 * will be reported to remote peer when they subscribe to the account's
1788 * presence, or which is published to a presence server if presence
1789 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00001790 *
1791 * At least one account MUST be created in the application. If no user
1792 * association is required, application can create a userless account by
1793 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00001794 * instead of a particular user, and it correspond with a particular
1795 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00001796 *
1797 * Also one account must be set as the <b>default account</b>, which is used as
1798 * the account to use when PJSUA fails to match a request with any other
1799 * accounts.
1800 *
1801 * When sending outgoing SIP requests (such as making calls or sending
1802 * instant messages), normally PJSUA requires the application to specify
1803 * which account to use for the request. If no account is specified,
1804 * PJSUA may be able to select the account by matching the destination
1805 * domain name, and fall back to default account when no match is found.
1806 */
1807
1808/**
1809 * Maximum accounts.
1810 */
1811#ifndef PJSUA_MAX_ACC
1812# define PJSUA_MAX_ACC 8
1813#endif
1814
1815
1816/**
1817 * Default registration interval.
1818 */
1819#ifndef PJSUA_REG_INTERVAL
Benny Prijonobddef2c2007-10-31 13:28:08 +00001820# define PJSUA_REG_INTERVAL 300
Benny Prijono312aff92006-06-17 04:08:30 +00001821#endif
1822
1823
1824/**
Benny Prijono384dab42009-10-14 01:58:04 +00001825 * Default maximum time to wait for account unregistration transactions to
1826 * complete during library shutdown sequence.
1827 *
1828 * Default: 4000 (4 seconds)
1829 */
1830#ifndef PJSUA_UNREG_TIMEOUT
1831# define PJSUA_UNREG_TIMEOUT 4000
1832#endif
1833
1834
1835/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001836 * Default PUBLISH expiration
1837 */
1838#ifndef PJSUA_PUBLISH_EXPIRATION
Benny Prijono53984d12009-04-28 22:19:49 +00001839# define PJSUA_PUBLISH_EXPIRATION PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001840#endif
1841
1842
1843/**
Benny Prijono093d3022006-09-24 00:07:11 +00001844 * Default account priority.
1845 */
1846#ifndef PJSUA_DEFAULT_ACC_PRIORITY
1847# define PJSUA_DEFAULT_ACC_PRIORITY 0
1848#endif
1849
1850
1851/**
Benny Prijono8058a622007-06-08 04:37:05 +00001852 * This macro specifies the URI scheme to use in Contact header
1853 * when secure transport such as TLS is used. Application can specify
1854 * either "sip" or "sips".
1855 */
1856#ifndef PJSUA_SECURE_SCHEME
Benny Prijono4c82c1e2008-10-16 08:14:51 +00001857# define PJSUA_SECURE_SCHEME "sip"
Benny Prijono8058a622007-06-08 04:37:05 +00001858#endif
1859
1860
1861/**
Benny Prijono534a9ba2009-10-13 14:01:59 +00001862 * Maximum time to wait for unpublication transaction(s) to complete
1863 * during shutdown process, before sending unregistration. The library
1864 * tries to wait for the unpublication (un-PUBLISH) to complete before
1865 * sending REGISTER request to unregister the account, during library
1866 * shutdown process. If the value is set too short, it is possible that
1867 * the unregistration is sent before unpublication completes, causing
1868 * unpublication request to fail.
1869 *
1870 * Default: 2000 (2 seconds)
1871 */
1872#ifndef PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
1873# define PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC 2000
1874#endif
1875
1876
1877/**
Nanang Izzuddin36dd5b62010-03-30 11:13:59 +00001878 * Default auto retry re-registration interval, in seconds. Set to 0
1879 * to disable this. Application can set the timer on per account basis
1880 * by setting the pjsua_acc_config.reg_retry_interval field instead.
1881 *
1882 * Default: 300 (5 minutes)
1883 */
1884#ifndef PJSUA_REG_RETRY_INTERVAL
1885# define PJSUA_REG_RETRY_INTERVAL 300
1886#endif
1887
1888
1889/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001890 * This structure describes account configuration to be specified when
1891 * adding a new account with #pjsua_acc_add(). Application MUST initialize
1892 * this structure first by calling #pjsua_acc_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00001893 */
1894typedef struct pjsua_acc_config
1895{
Benny Prijono093d3022006-09-24 00:07:11 +00001896 /**
Benny Prijono705e7842008-07-21 18:12:51 +00001897 * Arbitrary user data to be associated with the newly created account.
1898 * Application may set this later with #pjsua_acc_set_user_data() and
1899 * retrieve it with #pjsua_acc_get_user_data().
1900 */
1901 void *user_data;
1902
1903 /**
Benny Prijono093d3022006-09-24 00:07:11 +00001904 * Account priority, which is used to control the order of matching
1905 * incoming/outgoing requests. The higher the number means the higher
1906 * the priority is, and the account will be matched first.
1907 */
1908 int priority;
1909
Benny Prijono312aff92006-06-17 04:08:30 +00001910 /**
1911 * The full SIP URL for the account. The value can take name address or
1912 * URL format, and will look something like "sip:account@serviceprovider".
1913 *
1914 * This field is mandatory.
1915 */
1916 pj_str_t id;
1917
1918 /**
1919 * This is the URL to be put in the request URI for the registration,
1920 * and will look something like "sip:serviceprovider".
1921 *
1922 * This field should be specified if registration is desired. If the
1923 * value is empty, no account registration will be performed.
1924 */
1925 pj_str_t reg_uri;
1926
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001927 /**
Benny Prijonofe1bd342009-11-20 23:33:07 +00001928 * Subscribe to message waiting indication events (RFC 3842).
1929 *
1930 * See also \a enable_unsolicited_mwi field on #pjsua_config.
Benny Prijono4dd961b2009-10-26 11:21:37 +00001931 *
1932 * Default: no
1933 */
1934 pj_bool_t mwi_enabled;
1935
1936 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001937 * If this flag is set, the presence information of this account will
1938 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono48ab2b72007-11-08 09:24:30 +00001939 *
1940 * Default: PJ_FALSE
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001941 */
1942 pj_bool_t publish_enabled;
1943
Benny Prijonofe04fb52007-08-24 08:28:52 +00001944 /**
Benny Prijonofe50c9e2009-10-12 07:44:14 +00001945 * Event publication options.
1946 */
1947 pjsip_publishc_opt publish_opt;
1948
1949 /**
Benny Prijono534a9ba2009-10-13 14:01:59 +00001950 * Maximum time to wait for unpublication transaction(s) to complete
1951 * during shutdown process, before sending unregistration. The library
1952 * tries to wait for the unpublication (un-PUBLISH) to complete before
1953 * sending REGISTER request to unregister the account, during library
1954 * shutdown process. If the value is set too short, it is possible that
1955 * the unregistration is sent before unpublication completes, causing
1956 * unpublication request to fail.
1957 *
1958 * Default: PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
1959 */
1960 unsigned unpublish_max_wait_time_msec;
1961
1962 /**
Benny Prijono48ab2b72007-11-08 09:24:30 +00001963 * Authentication preference.
1964 */
1965 pjsip_auth_clt_pref auth_pref;
1966
1967 /**
Benny Prijonofe04fb52007-08-24 08:28:52 +00001968 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
1969 * is not specified, a random string will be used.
1970 */
1971 pj_str_t pidf_tuple_id;
1972
Benny Prijono312aff92006-06-17 04:08:30 +00001973 /**
1974 * Optional URI to be put as Contact for this account. It is recommended
1975 * that this field is left empty, so that the value will be calculated
1976 * automatically based on the transport address.
1977 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00001978 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00001979
1980 /**
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00001981 * Additional parameters that will be appended in the Contact header
Benny Prijono30fe4852008-12-10 16:54:16 +00001982 * for this account. This will affect the Contact header in all SIP
1983 * messages sent on behalf of this account, including but not limited to
1984 * REGISTER, INVITE, and SUBCRIBE requests or responses.
1985 *
1986 * The parameters should be preceeded by semicolon, and all strings must
1987 * be properly escaped. Example:
1988 * ";my-param=X;another-param=Hi%20there"
1989 */
1990 pj_str_t contact_params;
1991
1992 /**
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00001993 * Additional URI parameters that will be appended in the Contact URI
1994 * for this account. This will affect the Contact URI in all SIP
1995 * messages sent on behalf of this account, including but not limited to
1996 * REGISTER, INVITE, and SUBCRIBE requests or responses.
1997 *
1998 * The parameters should be preceeded by semicolon, and all strings must
1999 * be properly escaped. Example:
2000 * ";my-param=X;another-param=Hi%20there"
2001 */
2002 pj_str_t contact_uri_params;
2003
2004 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00002005 * Specify whether support for reliable provisional response (100rel and
2006 * PRACK) should be required for all sessions of this account.
2007 *
2008 * Default: PJ_FALSE
2009 */
2010 pj_bool_t require_100rel;
2011
2012 /**
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002013 * Specify whether support for Session Timers should be required for all
2014 * sessions of this account.
2015 *
2016 * Default: PJ_FALSE
2017 */
2018 pj_bool_t require_timer;
2019
2020 /**
Nanang Izzuddin65add622009-08-11 16:26:20 +00002021 * Specify Session Timer settings, see #pjsip_timer_setting.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002022 */
Nanang Izzuddin65add622009-08-11 16:26:20 +00002023 pjsip_timer_setting timer_setting;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002024
2025 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002026 * Number of proxies in the proxy array below.
2027 */
2028 unsigned proxy_cnt;
2029
2030 /**
2031 * Optional URI of the proxies to be visited for all outgoing requests
2032 * that are using this account (REGISTER, INVITE, etc). Application need
2033 * to specify these proxies if the service provider requires that requests
2034 * destined towards its network should go through certain proxies first
2035 * (for example, border controllers).
2036 *
2037 * These proxies will be put in the route set for this account, with
2038 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00002039 * first). If global outbound proxies are configured in pjsua_config,
2040 * then these account proxies will be placed after the global outbound
2041 * proxies in the routeset.
Benny Prijono312aff92006-06-17 04:08:30 +00002042 */
2043 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
2044
2045 /**
2046 * Optional interval for registration, in seconds. If the value is zero,
Benny Prijonobddef2c2007-10-31 13:28:08 +00002047 * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
Benny Prijono312aff92006-06-17 04:08:30 +00002048 */
2049 unsigned reg_timeout;
2050
Benny Prijono384dab42009-10-14 01:58:04 +00002051 /**
2052 * Specify the maximum time to wait for unregistration requests to
2053 * complete during library shutdown sequence.
2054 *
2055 * Default: PJSUA_UNREG_TIMEOUT
2056 */
2057 unsigned unreg_timeout;
2058
Benny Prijono312aff92006-06-17 04:08:30 +00002059 /**
2060 * Number of credentials in the credential array.
2061 */
2062 unsigned cred_count;
2063
2064 /**
2065 * Array of credentials. If registration is desired, normally there should
2066 * be at least one credential specified, to successfully authenticate
2067 * against the service provider. More credentials can be specified, for
2068 * example when the requests are expected to be challenged by the
2069 * proxies in the route set.
2070 */
2071 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
2072
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002073 /**
2074 * Optionally bind this account to specific transport. This normally is
2075 * not a good idea, as account should be able to send requests using
2076 * any available transports according to the destination. But some
2077 * application may want to have explicit control over the transport to
2078 * use, so in that case it can set this field.
2079 *
2080 * Default: -1 (PJSUA_INVALID_ID)
2081 *
2082 * @see pjsua_acc_set_transport()
2083 */
2084 pjsua_transport_id transport_id;
2085
Benny Prijono15b02302007-09-27 14:07:07 +00002086 /**
Benny Prijonocca2e432010-02-25 09:33:18 +00002087 * This option is used to update the transport address and the Contact
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002088 * header of REGISTER request. When this option is enabled, the library
2089 * will keep track of the public IP address from the response of REGISTER
2090 * request. Once it detects that the address has changed, it will
2091 * unregister current Contact, update the Contact with transport address
2092 * learned from Via header, and register a new Contact to the registrar.
2093 * This will also update the public name of UDP transport if STUN is
Benny Prijonocca2e432010-02-25 09:33:18 +00002094 * configured.
Benny Prijono15b02302007-09-27 14:07:07 +00002095 *
2096 * Default: 1 (yes)
2097 */
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002098 pj_bool_t allow_contact_rewrite;
Benny Prijono15b02302007-09-27 14:07:07 +00002099
Benny Prijonobddef2c2007-10-31 13:28:08 +00002100 /**
2101 * Set the interval for periodic keep-alive transmission for this account.
2102 * If this value is zero, keep-alive will be disabled for this account.
2103 * The keep-alive transmission will be sent to the registrar's address,
2104 * after successful registration.
2105 *
Benny Prijonobddef2c2007-10-31 13:28:08 +00002106 * Default: 15 (seconds)
2107 */
2108 unsigned ka_interval;
2109
2110 /**
2111 * Specify the data to be transmitted as keep-alive packets.
2112 *
2113 * Default: CR-LF
2114 */
2115 pj_str_t ka_data;
2116
Benny Prijonod8179652008-01-23 20:39:07 +00002117#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
2118 /**
2119 * Specify whether secure media transport should be used for this account.
2120 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
2121 * PJMEDIA_SRTP_MANDATORY.
2122 *
2123 * Default: #PJSUA_DEFAULT_USE_SRTP
2124 */
2125 pjmedia_srtp_use use_srtp;
2126
2127 /**
2128 * Specify whether SRTP requires secure signaling to be used. This option
2129 * is only used when \a use_srtp option above is non-zero.
2130 *
2131 * Valid values are:
2132 * 0: SRTP does not require secure signaling
2133 * 1: SRTP requires secure transport such as TLS
2134 * 2: SRTP requires secure end-to-end transport (SIPS)
2135 *
2136 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
2137 */
2138 int srtp_secure_signaling;
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00002139
2140 /**
2141 * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose
2142 * duplicated media in SDP offer, i.e: unsecured and secured version.
2143 * Otherwise, the SDP media will be composed as unsecured media but
2144 * with SDP "crypto" attribute.
2145 *
2146 * Default: PJ_FALSE
2147 */
2148 pj_bool_t srtp_optional_dup_offer;
Benny Prijonod8179652008-01-23 20:39:07 +00002149#endif
2150
Nanang Izzuddin36dd5b62010-03-30 11:13:59 +00002151 /**
2152 * Specify interval of auto registration retry upon registration failure
2153 * (including caused by transport problem), in second. Set to 0 to
2154 * disable auto re-registration.
2155 *
2156 * Default: #PJSUA_REG_RETRY_INTERVAL
2157 */
2158 unsigned reg_retry_interval;
2159
2160 /**
2161 * Specify whether calls of the configured account should be dropped
2162 * after registration failure and an attempt of re-registration has
2163 * also failed.
2164 *
2165 * Default: PJ_FALSE (disabled)
2166 */
2167 pj_bool_t drop_calls_on_reg_fail;
2168
Benny Prijono312aff92006-06-17 04:08:30 +00002169} pjsua_acc_config;
2170
2171
2172/**
2173 * Call this function to initialize account config with default values.
2174 *
2175 * @param cfg The account config to be initialized.
2176 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00002177PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002178
2179
2180/**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002181 * Duplicate account config.
2182 *
2183 * @param pool Pool to be used for duplicating the config.
2184 * @param dst Destination configuration.
2185 * @param src Source configuration.
2186 */
2187PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
2188 pjsua_acc_config *dst,
2189 const pjsua_acc_config *src);
2190
2191
2192/**
Benny Prijono312aff92006-06-17 04:08:30 +00002193 * Account info. Application can query account info by calling
2194 * #pjsua_acc_get_info().
2195 */
2196typedef struct pjsua_acc_info
2197{
2198 /**
2199 * The account ID.
2200 */
2201 pjsua_acc_id id;
2202
2203 /**
2204 * Flag to indicate whether this is the default account.
2205 */
2206 pj_bool_t is_default;
2207
2208 /**
2209 * Account URI
2210 */
2211 pj_str_t acc_uri;
2212
2213 /**
2214 * Flag to tell whether this account has registration setting
2215 * (reg_uri is not empty).
2216 */
2217 pj_bool_t has_registration;
2218
2219 /**
2220 * An up to date expiration interval for account registration session.
2221 */
2222 int expires;
2223
2224 /**
2225 * Last registration status code. If status code is zero, the account
2226 * is currently not registered. Any other value indicates the SIP
2227 * status code of the registration.
2228 */
2229 pjsip_status_code status;
2230
2231 /**
2232 * String describing the registration status.
2233 */
2234 pj_str_t status_text;
2235
2236 /**
2237 * Presence online status for this account.
2238 */
2239 pj_bool_t online_status;
2240
2241 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00002242 * Presence online status text.
2243 */
2244 pj_str_t online_status_text;
2245
2246 /**
2247 * Extended RPID online status information.
2248 */
2249 pjrpid_element rpid;
2250
2251 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002252 * Buffer that is used internally to store the status text.
2253 */
2254 char buf_[PJ_ERR_MSG_SIZE];
2255
2256} pjsua_acc_info;
2257
2258
2259
2260/**
2261 * Get number of current accounts.
2262 *
2263 * @return Current number of accounts.
2264 */
2265PJ_DECL(unsigned) pjsua_acc_get_count(void);
2266
2267
2268/**
2269 * Check if the specified account ID is valid.
2270 *
2271 * @param acc_id Account ID to check.
2272 *
2273 * @return Non-zero if account ID is valid.
2274 */
2275PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
2276
2277
2278/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00002279 * Set default account to be used when incoming and outgoing
2280 * requests doesn't match any accounts.
2281 *
2282 * @param acc_id The account ID to be used as default.
2283 *
2284 * @return PJ_SUCCESS on success.
2285 */
2286PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2287
2288
2289/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002290 * Get default account to be used when receiving incoming requests (calls),
2291 * when the destination of the incoming call doesn't match any other
2292 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002293 *
2294 * @return The default account ID, or PJSUA_INVALID_ID if no
2295 * default account is configured.
2296 */
2297PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2298
2299
2300/**
Benny Prijono312aff92006-06-17 04:08:30 +00002301 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002302 * #pjsua_init()) before calling this function. If registration is configured
2303 * for this account, this function would also start the SIP registration
2304 * session with the SIP registrar server. This SIP registration session
2305 * will be maintained internally by the library, and application doesn't
2306 * need to do anything to maintain the registration session.
2307 *
Benny Prijono312aff92006-06-17 04:08:30 +00002308 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002309 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002310 * @param is_default If non-zero, this account will be set as the default
2311 * account. The default account will be used when sending
2312 * outgoing requests (e.g. making call) when no account is
2313 * specified, and when receiving incoming requests when the
2314 * request does not match any accounts. It is recommended
2315 * that default account is set to local/LAN account.
2316 * @param p_acc_id Pointer to receive account ID of the new account.
2317 *
2318 * @return PJ_SUCCESS on success, or the appropriate error code.
2319 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002320PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002321 pj_bool_t is_default,
2322 pjsua_acc_id *p_acc_id);
2323
2324
2325/**
2326 * Add a local account. A local account is used to identify local endpoint
2327 * instead of a specific user, and for this reason, a transport ID is needed
2328 * to obtain the local address information.
2329 *
2330 * @param tid Transport ID to generate account address.
2331 * @param is_default If non-zero, this account will be set as the default
2332 * account. The default account will be used when sending
2333 * outgoing requests (e.g. making call) when no account is
2334 * specified, and when receiving incoming requests when the
2335 * request does not match any accounts. It is recommended
2336 * that default account is set to local/LAN account.
2337 * @param p_acc_id Pointer to receive account ID of the new account.
2338 *
2339 * @return PJ_SUCCESS on success, or the appropriate error code.
2340 */
2341PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2342 pj_bool_t is_default,
2343 pjsua_acc_id *p_acc_id);
2344
2345/**
Benny Prijono705e7842008-07-21 18:12:51 +00002346 * Set arbitrary data to be associated with the account.
2347 *
2348 * @param acc_id The account ID.
2349 * @param user_data User/application data.
2350 *
2351 * @return PJ_SUCCESS on success, or the appropriate error code.
2352 */
2353PJ_DECL(pj_status_t) pjsua_acc_set_user_data(pjsua_acc_id acc_id,
2354 void *user_data);
2355
2356
2357/**
2358 * Retrieve arbitrary data associated with the account.
2359 *
2360 * @param acc_id The account ID.
2361 *
2362 * @return The user data. In the case where the account ID is
2363 * not valid, NULL is returned.
2364 */
2365PJ_DECL(void*) pjsua_acc_get_user_data(pjsua_acc_id acc_id);
2366
2367
2368/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002369 * Delete an account. This will unregister the account from the SIP server,
2370 * if necessary, and terminate server side presence subscriptions associated
2371 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002372 *
2373 * @param acc_id Id of the account to be deleted.
2374 *
2375 * @return PJ_SUCCESS on success, or the appropriate error code.
2376 */
2377PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2378
2379
2380/**
2381 * Modify account information.
2382 *
2383 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002384 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002385 *
2386 * @return PJ_SUCCESS on success, or the appropriate error code.
2387 */
2388PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002389 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002390
2391
2392/**
2393 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002394 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002395 * if there are server side presence subscription for this account, and/or
2396 * outgoing PUBLISH if presence publication is enabled for this account.
2397 *
2398 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002399 *
2400 * @param acc_id The account ID.
2401 * @param is_online True of false.
2402 *
2403 * @return PJ_SUCCESS on success, or the appropriate error code.
2404 */
2405PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2406 pj_bool_t is_online);
2407
Benny Prijono4461c7d2007-08-25 13:36:15 +00002408/**
2409 * Modify account's presence status to be advertised to remote/presence
2410 * subscribers. This would trigger the sending of outgoing NOTIFY request
2411 * if there are server side presence subscription for this account, and/or
2412 * outgoing PUBLISH if presence publication is enabled for this account.
2413 *
2414 * @see pjsua_acc_set_online_status()
2415 *
2416 * @param acc_id The account ID.
2417 * @param is_online True of false.
2418 * @param pr Extended information in subset of RPID format
2419 * which allows setting custom presence text.
2420 *
2421 * @return PJ_SUCCESS on success, or the appropriate error code.
2422 */
2423PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2424 pj_bool_t is_online,
2425 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002426
2427/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002428 * Update registration or perform unregistration. If registration is
2429 * configured for this account, then initial SIP REGISTER will be sent
2430 * when the account is added with #pjsua_acc_add(). Application normally
2431 * only need to call this function if it wants to manually update the
2432 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002433 *
2434 * @param acc_id The account ID.
2435 * @param renew If renew argument is zero, this will start
2436 * unregistration process.
2437 *
2438 * @return PJ_SUCCESS on success, or the appropriate error code.
2439 */
2440PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2441 pj_bool_t renew);
2442
Benny Prijono312aff92006-06-17 04:08:30 +00002443/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002444 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002445 *
2446 * @param acc_id Account identification.
2447 * @param info Pointer to receive account information.
2448 *
2449 * @return PJ_SUCCESS on success, or the appropriate error code.
2450 */
2451PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2452 pjsua_acc_info *info);
2453
2454
2455/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002456 * Enumerate all account currently active in the library. This will fill
2457 * the array with the account Ids, and application can then query the
2458 * account information for each id with #pjsua_acc_get_info().
2459 *
2460 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002461 *
2462 * @param ids Array of account IDs to be initialized.
2463 * @param count In input, specifies the maximum number of elements.
2464 * On return, it contains the actual number of elements.
2465 *
2466 * @return PJ_SUCCESS on success, or the appropriate error code.
2467 */
2468PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2469 unsigned *count );
2470
2471
2472/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002473 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002474 *
2475 * @param info Array of account infos to be initialized.
2476 * @param count In input, specifies the maximum number of elements.
2477 * On return, it contains the actual number of elements.
2478 *
2479 * @return PJ_SUCCESS on success, or the appropriate error code.
2480 */
2481PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2482 unsigned *count );
2483
2484
2485/**
2486 * This is an internal function to find the most appropriate account to
2487 * used to reach to the specified URL.
2488 *
2489 * @param url The remote URL to reach.
2490 *
2491 * @return Account id.
2492 */
2493PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2494
2495
2496/**
2497 * This is an internal function to find the most appropriate account to be
2498 * used to handle incoming calls.
2499 *
2500 * @param rdata The incoming request message.
2501 *
2502 * @return Account id.
2503 */
2504PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2505
2506
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002507/**
Benny Prijonofff245c2007-04-02 11:44:47 +00002508 * Create arbitrary requests using the account. Application should only use
2509 * this function to create auxiliary requests outside dialog, such as
2510 * OPTIONS, and use the call or presence API to create dialog related
2511 * requests.
2512 *
2513 * @param acc_id The account ID.
2514 * @param method The SIP method of the request.
2515 * @param target Target URI.
2516 * @param p_tdata Pointer to receive the request.
2517 *
2518 * @return PJ_SUCCESS or the error code.
2519 */
2520PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
2521 const pjsip_method *method,
2522 const pj_str_t *target,
2523 pjsip_tx_data **p_tdata);
2524
2525
2526/**
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002527 * Create a suitable Contact header value, based on the specified target URI
2528 * for the specified account.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002529 *
2530 * @param pool Pool to allocate memory for the string.
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002531 * @param contact The string where the Contact will be stored.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002532 * @param acc_id Account ID.
2533 * @param uri Destination URI of the request.
2534 *
2535 * @return PJ_SUCCESS on success, other on error.
2536 */
2537PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
2538 pj_str_t *contact,
2539 pjsua_acc_id acc_id,
2540 const pj_str_t *uri);
2541
2542
2543
2544/**
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002545 * Create a suitable Contact header value, based on the information in the
2546 * incoming request.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002547 *
2548 * @param pool Pool to allocate memory for the string.
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002549 * @param contact The string where the Contact will be stored.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002550 * @param acc_id Account ID.
2551 * @param rdata Incoming request.
2552 *
2553 * @return PJ_SUCCESS on success, other on error.
2554 */
2555PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
2556 pj_str_t *contact,
2557 pjsua_acc_id acc_id,
2558 pjsip_rx_data *rdata );
2559
2560
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002561/**
2562 * Lock/bind this account to a specific transport/listener. Normally
2563 * application shouldn't need to do this, as transports will be selected
2564 * automatically by the stack according to the destination.
2565 *
2566 * When account is locked/bound to a specific transport, all outgoing
2567 * requests from this account will use the specified transport (this
2568 * includes SIP registration, dialog (call and event subscription), and
2569 * out-of-dialog requests such as MESSAGE).
2570 *
2571 * Note that transport_id may be specified in pjsua_acc_config too.
2572 *
2573 * @param acc_id The account ID.
2574 * @param tp_id The transport ID.
2575 *
2576 * @return PJ_SUCCESS on success.
2577 */
2578PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
2579 pjsua_transport_id tp_id);
2580
Benny Prijono312aff92006-06-17 04:08:30 +00002581
2582/**
2583 * @}
2584 */
2585
2586
2587/*****************************************************************************
2588 * CALLS API
2589 */
2590
2591
2592/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002593 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00002594 * @ingroup PJSUA_LIB
2595 * @brief Call manipulation.
2596 * @{
2597 */
2598
2599/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002600 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00002601 */
2602#ifndef PJSUA_MAX_CALLS
2603# define PJSUA_MAX_CALLS 32
2604#endif
2605
2606
2607
2608/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002609 * This enumeration specifies the media status of a call, and it's part
2610 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00002611 */
2612typedef enum pjsua_call_media_status
2613{
Benny Prijonob5388cf2007-01-04 22:45:08 +00002614 /** Call currently has no media */
Benny Prijono312aff92006-06-17 04:08:30 +00002615 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002616
2617 /** The media is active */
Benny Prijono312aff92006-06-17 04:08:30 +00002618 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002619
2620 /** The media is currently put on hold by local endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002621 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002622
2623 /** The media is currently put on hold by remote endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002624 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002625
Benny Prijono096c56c2007-09-15 08:30:16 +00002626 /** The media has reported error (e.g. ICE negotiation) */
2627 PJSUA_CALL_MEDIA_ERROR
2628
Benny Prijono312aff92006-06-17 04:08:30 +00002629} pjsua_call_media_status;
2630
2631
2632/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002633 * This structure describes the information and current status of a call.
Benny Prijono312aff92006-06-17 04:08:30 +00002634 */
2635typedef struct pjsua_call_info
2636{
2637 /** Call identification. */
2638 pjsua_call_id id;
2639
2640 /** Initial call role (UAC == caller) */
2641 pjsip_role_e role;
2642
Benny Prijono90315512006-09-14 16:05:16 +00002643 /** The account ID where this call belongs. */
2644 pjsua_acc_id acc_id;
2645
Benny Prijono312aff92006-06-17 04:08:30 +00002646 /** Local URI */
2647 pj_str_t local_info;
2648
2649 /** Local Contact */
2650 pj_str_t local_contact;
2651
2652 /** Remote URI */
2653 pj_str_t remote_info;
2654
2655 /** Remote contact */
2656 pj_str_t remote_contact;
2657
2658 /** Dialog Call-ID string. */
2659 pj_str_t call_id;
2660
2661 /** Call state */
2662 pjsip_inv_state state;
2663
2664 /** Text describing the state */
2665 pj_str_t state_text;
2666
2667 /** Last status code heard, which can be used as cause code */
2668 pjsip_status_code last_status;
2669
2670 /** The reason phrase describing the status. */
2671 pj_str_t last_status_text;
2672
2673 /** Call media status. */
2674 pjsua_call_media_status media_status;
2675
2676 /** Media direction */
2677 pjmedia_dir media_dir;
2678
2679 /** The conference port number for the call */
2680 pjsua_conf_port_id conf_slot;
2681
2682 /** Up-to-date call connected duration (zero when call is not
2683 * established)
2684 */
2685 pj_time_val connect_duration;
2686
2687 /** Total call duration, including set-up time */
2688 pj_time_val total_duration;
2689
2690 /** Internal */
2691 struct {
2692 char local_info[128];
2693 char local_contact[128];
2694 char remote_info[128];
2695 char remote_contact[128];
2696 char call_id[128];
2697 char last_status_text[128];
2698 } buf_;
2699
2700} pjsua_call_info;
2701
2702
2703
Benny Prijonoa91a0032006-02-26 21:23:45 +00002704/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002705 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002706 *
2707 * @return Maximum number of calls configured.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002708 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002709PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002710
2711/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002712 * Get number of currently active calls.
2713 *
2714 * @return Number of currently active calls.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002715 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002716PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002717
2718/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002719 * Enumerate all active calls. Application may then query the information and
2720 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002721 *
2722 * @param ids Array of account IDs to be initialized.
2723 * @param count In input, specifies the maximum number of elements.
2724 * On return, it contains the actual number of elements.
2725 *
2726 * @return PJ_SUCCESS on success, or the appropriate error code.
2727 */
2728PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
2729 unsigned *count);
2730
2731
2732/**
2733 * Make outgoing call to the specified URI using the specified account.
2734 *
2735 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002736 * @param dst_uri URI to be put in the To header (normally is the same
2737 * as the target URI).
2738 * @param options Options (must be zero at the moment).
2739 * @param user_data Arbitrary user data to be attached to the call, and
2740 * can be retrieved later.
2741 * @param msg_data Optional headers etc to be added to outgoing INVITE
2742 * request, or NULL if no custom header is desired.
2743 * @param p_call_id Pointer to receive call identification.
2744 *
2745 * @return PJ_SUCCESS on success, or the appropriate error code.
2746 */
2747PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
2748 const pj_str_t *dst_uri,
2749 unsigned options,
2750 void *user_data,
2751 const pjsua_msg_data *msg_data,
2752 pjsua_call_id *p_call_id);
2753
2754
2755/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002756 * Check if the specified call has active INVITE session and the INVITE
2757 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002758 *
2759 * @param call_id Call identification.
2760 *
2761 * @return Non-zero if call is active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002762 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002763PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002764
2765
2766/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002767 * Check if call has an active media session.
2768 *
2769 * @param call_id Call identification.
2770 *
2771 * @return Non-zero if yes.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002772 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002773PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002774
2775
2776/**
Benny Prijonocf986c42008-09-02 11:25:07 +00002777 * Retrieve the media session associated with this call. Note that the media
2778 * session may not be available depending on the current call's media status
2779 * (the pjsua_call_media_status information in pjsua_call_info). Application
2780 * may use the media session to retrieve more detailed information about the
2781 * call's media.
2782 *
2783 * @param call_id Call identification.
2784 *
2785 * @return Call media session.
2786 */
2787PJ_DECL(pjmedia_session*) pjsua_call_get_media_session(pjsua_call_id call_id);
2788
2789
2790/**
2791 * Retrieve the media transport instance that is used for this call.
2792 * Application may use the media transport to query more detailed information
2793 * about the media transport.
2794 *
2795 * @param cid Call identification (the call_id).
2796 *
2797 * @return Call media transport.
2798 */
2799PJ_DECL(pjmedia_transport*) pjsua_call_get_media_transport(pjsua_call_id cid);
2800
2801
2802/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002803 * Get the conference port identification associated with the call.
2804 *
2805 * @param call_id Call identification.
2806 *
2807 * @return Conference port ID, or PJSUA_INVALID_ID when the
2808 * media has not been established or is not active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002809 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002810PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
2811
2812/**
2813 * Obtain detail information about the specified call.
2814 *
2815 * @param call_id Call identification.
2816 * @param info Call info to be initialized.
2817 *
2818 * @return PJ_SUCCESS on success, or the appropriate error code.
2819 */
2820PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002821 pjsua_call_info *info);
2822
Nanang Izzuddin2a1b9ee2010-06-03 10:41:32 +00002823/**
2824 * Check if remote peer support the specified capability.
2825 *
2826 * @param call_id Call identification.
2827 * @param htype The header type to be checked, which value may be:
2828 * - PJSIP_H_ACCEPT
2829 * - PJSIP_H_ALLOW
2830 * - PJSIP_H_SUPPORTED
2831 * @param hname If htype specifies PJSIP_H_OTHER, then the header
2832 * name must be supplied in this argument. Otherwise the
2833 * value must be set to NULL.
2834 * @param token The capability token to check. For example, if \a
2835 * htype is PJSIP_H_ALLOW, then \a token specifies the
2836 * method names; if \a htype is PJSIP_H_SUPPORTED, then
2837 * \a token specifies the extension names such as
2838 * "100rel".
2839 *
2840 * @return PJSIP_DIALOG_CAP_SUPPORTED if the specified capability
2841 * is explicitly supported, see @pjsip_dialog_cap_status
2842 * for more info.
2843 */
2844PJ_DECL(pjsip_dialog_cap_status) pjsua_call_remote_has_cap(
2845 pjsua_call_id call_id,
2846 int htype,
2847 const pj_str_t *hname,
2848 const pj_str_t *token);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002849
2850/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002851 * Attach application specific data to the call. Application can then
2852 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002853 *
2854 * @param call_id Call identification.
2855 * @param user_data Arbitrary data to be attached to the call.
2856 *
2857 * @return The user data.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002858 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002859PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
2860 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002861
2862
2863/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002864 * Get user data attached to the call, which has been previously set with
2865 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002866 *
2867 * @param call_id Call identification.
2868 *
2869 * @return The user data.
Benny Prijono268ca612006-02-07 12:34:11 +00002870 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002871PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00002872
2873
2874/**
Benny Prijono91a6a172007-10-31 08:59:29 +00002875 * Get the NAT type of remote's endpoint. This is a proprietary feature
2876 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
2877 * is set in #pjsua_config.
2878 *
2879 * This function can only be called after SDP has been received from remote,
2880 * which means for incoming call, this function can be called as soon as
2881 * call is received as long as incoming call contains SDP, and for outgoing
2882 * call, this function can be called only after SDP is received (normally in
2883 * 200/OK response to INVITE). As a general case, application should call
2884 * this function after or in \a on_call_media_state() callback.
2885 *
2886 * @param call_id Call identification.
2887 * @param p_type Pointer to store the NAT type. Application can then
2888 * retrieve the string description of the NAT type
2889 * by calling pj_stun_get_nat_name().
2890 *
2891 * @return PJ_SUCCESS on success.
2892 *
2893 * @see pjsua_get_nat_type(), nat_type_in_sdp
2894 */
2895PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
2896 pj_stun_nat_type *p_type);
2897
2898/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002899 * Send response to incoming INVITE request. Depending on the status
2900 * code specified as parameter, this function may send provisional
2901 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002902 *
2903 * @param call_id Incoming call identification.
2904 * @param code Status code, (100-699).
2905 * @param reason Optional reason phrase. If NULL, default text
2906 * will be used.
2907 * @param msg_data Optional list of headers etc to be added to outgoing
2908 * response message.
2909 *
2910 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoa91a0032006-02-26 21:23:45 +00002911 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002912PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
2913 unsigned code,
2914 const pj_str_t *reason,
2915 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00002916
2917/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002918 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00002919 * call state. This function is different than answering the call with
2920 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
2921 * will hangup the call regardless of the state and role of the call,
2922 * while #pjsua_call_answer() only works with incoming calls on EARLY
2923 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002924 *
2925 * @param call_id Call identification.
2926 * @param code Optional status code to be sent when we're rejecting
2927 * incoming call. If the value is zero, "603/Decline"
2928 * will be sent.
2929 * @param reason Optional reason phrase to be sent when we're rejecting
2930 * incoming call. If NULL, default text will be used.
2931 * @param msg_data Optional list of headers etc to be added to outgoing
2932 * request/response message.
2933 *
2934 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00002935 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002936PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
2937 unsigned code,
2938 const pj_str_t *reason,
2939 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002940
Benny Prijono5e51a4e2008-11-27 00:06:46 +00002941/**
2942 * Accept or reject redirection response. Application MUST call this function
2943 * after it signaled PJSIP_REDIRECT_PENDING in the \a on_call_redirected()
2944 * callback, to notify the call whether to accept or reject the redirection
2945 * to the current target. Application can use the combination of
2946 * PJSIP_REDIRECT_PENDING command in \a on_call_redirected() callback and
2947 * this function to ask for user permission before redirecting the call.
2948 *
2949 * Note that if the application chooses to reject or stop redirection (by
2950 * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the
2951 * call disconnection callback will be called before this function returns.
2952 * And if the application rejects the target, the \a on_call_redirected()
2953 * callback may also be called before this function returns if there is
2954 * another target to try.
2955 *
2956 * @param call_id The call ID.
2957 * @param cmd Redirection operation to be applied to the current
2958 * target. The semantic of this argument is similar
2959 * to the description in the \a on_call_redirected()
2960 * callback, except that the PJSIP_REDIRECT_PENDING is
2961 * not accepted here.
2962 *
2963 * @return PJ_SUCCESS on successful operation.
2964 */
2965PJ_DECL(pj_status_t) pjsua_call_process_redirect(pjsua_call_id call_id,
2966 pjsip_redirect_op cmd);
Benny Prijono26ff9062006-02-21 23:47:00 +00002967
2968/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002969 * Put the specified call on hold. This will send re-INVITE with the
2970 * appropriate SDP to inform remote that the call is being put on hold.
2971 * The final status of the request itself will be reported on the
2972 * \a on_call_media_state() callback, which inform the application that
2973 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002974 *
2975 * @param call_id Call identification.
2976 * @param msg_data Optional message components to be sent with
2977 * the request.
2978 *
2979 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00002980 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002981PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
2982 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002983
2984
2985/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002986 * Send re-INVITE to release hold.
2987 * The final status of the request itself will be reported on the
2988 * \a on_call_media_state() callback, which inform the application that
2989 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002990 *
2991 * @param call_id Call identification.
2992 * @param unhold If this argument is non-zero and the call is locally
2993 * held, this will release the local hold.
2994 * @param msg_data Optional message components to be sent with
2995 * the request.
2996 *
2997 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00002998 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002999PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
3000 pj_bool_t unhold,
3001 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003002
Benny Prijonoc08682e2007-10-04 06:17:58 +00003003/**
3004 * Send UPDATE request.
3005 *
3006 * @param call_id Call identification.
3007 * @param options Must be zero for now.
3008 * @param msg_data Optional message components to be sent with
3009 * the request.
3010 *
3011 * @return PJ_SUCCESS on success, or the appropriate error code.
3012 */
3013PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
3014 unsigned options,
3015 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003016
3017/**
Benny Prijono053f5222006-11-11 16:16:04 +00003018 * Initiate call transfer to the specified address. This function will send
3019 * REFER request to instruct remote call party to initiate a new INVITE
3020 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003021 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00003022 * If application is interested to monitor the successfulness and
3023 * the progress of the transfer request, it can implement
3024 * \a on_call_transfer_status() callback which will report the progress
3025 * of the call transfer request.
3026 *
Benny Prijono053f5222006-11-11 16:16:04 +00003027 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003028 * @param dest Address of new target to be contacted.
3029 * @param msg_data Optional message components to be sent with
3030 * the request.
3031 *
3032 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003033 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003034PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
3035 const pj_str_t *dest,
3036 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003037
3038/**
Benny Prijono053f5222006-11-11 16:16:04 +00003039 * Flag to indicate that "Require: replaces" should not be put in the
3040 * outgoing INVITE request caused by REFER request created by
3041 * #pjsua_call_xfer_replaces().
3042 */
3043#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
3044
3045/**
3046 * Initiate attended call transfer. This function will send REFER request
3047 * to instruct remote call party to initiate new INVITE session to the URL
3048 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
3049 * the call with us with the new call from the REFER recipient.
3050 *
3051 * @param call_id The call id to be transfered.
3052 * @param dest_call_id The call id to be replaced.
3053 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
3054 * to suppress the inclusion of "Require: replaces" in
3055 * the outgoing INVITE request created by the REFER
3056 * request.
3057 * @param msg_data Optional message components to be sent with
3058 * the request.
3059 *
3060 * @return PJ_SUCCESS on success, or the appropriate error code.
3061 */
3062PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
3063 pjsua_call_id dest_call_id,
3064 unsigned options,
3065 const pjsua_msg_data *msg_data);
3066
3067/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003068 * Send DTMF digits to remote using RFC 2833 payload formats.
3069 *
3070 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003071 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003072 *
3073 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003074 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003075PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003076 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00003077
Benny Prijono26ff9062006-02-21 23:47:00 +00003078/**
Benny Prijonob0808372006-03-02 21:18:58 +00003079 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003080 *
3081 * @param call_id Call identification.
3082 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3083 * assumed.
3084 * @param content The message content.
3085 * @param msg_data Optional list of headers etc to be included in outgoing
3086 * request. The body descriptor in the msg_data is
3087 * ignored.
3088 * @param user_data Optional user data, which will be given back when
3089 * the IM callback is called.
3090 *
3091 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003092 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003093PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
3094 const pj_str_t *mime_type,
3095 const pj_str_t *content,
3096 const pjsua_msg_data *msg_data,
3097 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003098
3099
3100/**
3101 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003102 *
3103 * @param call_id Call identification.
3104 * @param is_typing Non-zero to indicate to remote that local person is
3105 * currently typing an IM.
3106 * @param msg_data Optional list of headers etc to be included in outgoing
3107 * request.
3108 *
3109 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003110 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003111PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
3112 pj_bool_t is_typing,
3113 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003114
3115/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00003116 * Send arbitrary request with the call. This is useful for example to send
3117 * INFO request. Note that application should not use this function to send
3118 * requests which would change the invite session's state, such as re-INVITE,
3119 * UPDATE, PRACK, and BYE.
3120 *
3121 * @param call_id Call identification.
3122 * @param method SIP method of the request.
3123 * @param msg_data Optional message body and/or list of headers to be
3124 * included in outgoing request.
3125 *
3126 * @return PJ_SUCCESS on success, or the appropriate error code.
3127 */
3128PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
3129 const pj_str_t *method,
3130 const pjsua_msg_data *msg_data);
3131
3132
3133/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003134 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
3135 * currently active calls.
Benny Prijono834aee32006-02-19 01:38:06 +00003136 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00003137PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00003138
3139
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003140/**
3141 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003142 *
3143 * @param call_id Call identification.
3144 * @param with_media Non-zero to include media information too.
3145 * @param buffer Buffer where the statistics are to be written to.
3146 * @param maxlen Maximum length of buffer.
3147 * @param indent Spaces for left indentation.
3148 *
3149 * @return PJ_SUCCESS on success.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003150 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003151PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
3152 pj_bool_t with_media,
3153 char *buffer,
3154 unsigned maxlen,
3155 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003156
Benny Prijono9fc735d2006-05-28 14:58:12 +00003157/**
Benny Prijono312aff92006-06-17 04:08:30 +00003158 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003159 */
Benny Prijono834aee32006-02-19 01:38:06 +00003160
3161
3162/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00003163 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00003164 */
3165
Benny Prijono312aff92006-06-17 04:08:30 +00003166
3167/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003168 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00003169 * @ingroup PJSUA_LIB
3170 * @brief Buddy management, buddy's presence, and instant messaging.
3171 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00003172 *
3173 * This section describes PJSUA-APIs related to buddies management,
3174 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00003175 */
3176
3177/**
3178 * Max buddies in buddy list.
3179 */
3180#ifndef PJSUA_MAX_BUDDIES
3181# define PJSUA_MAX_BUDDIES 256
3182#endif
3183
3184
3185/**
Benny Prijono6ab05322009-10-21 03:03:06 +00003186 * This specifies how long the library should wait before retrying failed
3187 * SUBSCRIBE request, and there is no rule to automatically resubscribe
3188 * (for example, no "retry-after" parameter in Subscription-State header).
3189 *
3190 * This also controls the duration before failed PUBLISH request will be
3191 * retried.
Benny Prijonoa17496a2007-10-31 10:20:31 +00003192 *
3193 * Default: 300 seconds
3194 */
3195#ifndef PJSUA_PRES_TIMER
3196# define PJSUA_PRES_TIMER 300
3197#endif
3198
3199
3200/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003201 * This structure describes buddy configuration when adding a buddy to
3202 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
3203 * the structure with #pjsua_buddy_config_default() to initialize this
3204 * structure with default configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00003205 */
3206typedef struct pjsua_buddy_config
3207{
3208 /**
3209 * Buddy URL or name address.
3210 */
3211 pj_str_t uri;
3212
3213 /**
3214 * Specify whether presence subscription should start immediately.
3215 */
3216 pj_bool_t subscribe;
3217
Benny Prijono705e7842008-07-21 18:12:51 +00003218 /**
3219 * Specify arbitrary application data to be associated with with
3220 * the buddy object.
3221 */
3222 void *user_data;
3223
Benny Prijono312aff92006-06-17 04:08:30 +00003224} pjsua_buddy_config;
3225
3226
3227/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003228 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003229 */
3230typedef enum pjsua_buddy_status
3231{
3232 /**
3233 * Online status is unknown (possibly because no presence subscription
3234 * has been established).
3235 */
3236 PJSUA_BUDDY_STATUS_UNKNOWN,
3237
3238 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003239 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003240 */
3241 PJSUA_BUDDY_STATUS_ONLINE,
3242
3243 /**
3244 * Buddy is offline.
3245 */
3246 PJSUA_BUDDY_STATUS_OFFLINE,
3247
3248} pjsua_buddy_status;
3249
3250
3251
3252/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003253 * This structure describes buddy info, which can be retrieved by calling
3254 * #pjsua_buddy_get_info().
Benny Prijono312aff92006-06-17 04:08:30 +00003255 */
3256typedef struct pjsua_buddy_info
3257{
3258 /**
3259 * The buddy ID.
3260 */
3261 pjsua_buddy_id id;
3262
3263 /**
3264 * The full URI of the buddy, as specified in the configuration.
3265 */
3266 pj_str_t uri;
3267
3268 /**
3269 * Buddy's Contact, only available when presence subscription has
3270 * been established to the buddy.
3271 */
3272 pj_str_t contact;
3273
3274 /**
3275 * Buddy's online status.
3276 */
3277 pjsua_buddy_status status;
3278
3279 /**
3280 * Text to describe buddy's online status.
3281 */
3282 pj_str_t status_text;
3283
3284 /**
3285 * Flag to indicate that we should monitor the presence information for
3286 * this buddy (normally yes, unless explicitly disabled).
3287 */
3288 pj_bool_t monitor_pres;
3289
3290 /**
Benny Prijono63fba012008-07-17 14:19:10 +00003291 * If \a monitor_pres is enabled, this specifies the last state of the
3292 * presence subscription. If presence subscription session is currently
3293 * active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence
3294 * subscription request has been rejected, the value will be
3295 * PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be
3296 * specified in \a sub_term_reason.
3297 */
3298 pjsip_evsub_state sub_state;
3299
3300 /**
Benny Prijonod06d8c52009-06-30 13:53:47 +00003301 * String representation of subscription state.
3302 */
3303 const char *sub_state_name;
3304
3305 /**
Benny Prijono73bb7232009-10-20 13:56:26 +00003306 * Specifies the last presence subscription termination code. This would
3307 * return the last status of the SUBSCRIBE request. If the subscription
3308 * is terminated with NOTIFY by the server, this value will be set to
3309 * 200, and subscription termination reason will be given in the
3310 * \a sub_term_reason field.
3311 */
3312 unsigned sub_term_code;
3313
3314 /**
3315 * Specifies the last presence subscription termination reason. If
Benny Prijono63fba012008-07-17 14:19:10 +00003316 * presence subscription is currently active, the value will be empty.
3317 */
3318 pj_str_t sub_term_reason;
3319
3320 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003321 * Extended RPID information about the person.
3322 */
3323 pjrpid_element rpid;
3324
3325 /**
Benny Prijono28add7e2009-06-15 16:03:40 +00003326 * Extended presence info.
3327 */
3328 pjsip_pres_status pres_status;
3329
3330 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003331 * Internal buffer.
3332 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003333 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003334
3335} pjsua_buddy_info;
3336
3337
Benny Prijono834aee32006-02-19 01:38:06 +00003338/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003339 * Set default values to the buddy config.
3340 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003341PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003342
3343
3344/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003345 * Get total number of buddies.
3346 *
3347 * @return Number of buddies.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003348 */
3349PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3350
3351
3352/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003353 * Check if buddy ID is valid.
3354 *
3355 * @param buddy_id Buddy ID to check.
3356 *
3357 * @return Non-zero if buddy ID is valid.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003358 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003359PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3360
3361
3362/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003363 * Enumerate all buddy IDs in the buddy list. Application then can use
3364 * #pjsua_buddy_get_info() to get the detail information for each buddy
3365 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003366 *
3367 * @param ids Array of ids to be initialized.
3368 * @param count On input, specifies max elements in the array.
3369 * On return, it contains actual number of elements
3370 * that have been initialized.
3371 *
3372 * @return PJ_SUCCESS on success, or the appropriate error code.
3373 */
3374PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3375 unsigned *count);
3376
3377/**
Benny Prijono705e7842008-07-21 18:12:51 +00003378 * Find the buddy ID with the specified URI.
3379 *
3380 * @param uri The buddy URI.
3381 *
3382 * @return The buddy ID, or PJSUA_INVALID_ID if not found.
3383 */
3384PJ_DECL(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri);
3385
3386
3387/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003388 * Get detailed buddy info.
3389 *
3390 * @param buddy_id The buddy identification.
3391 * @param info Pointer to receive information about buddy.
3392 *
3393 * @return PJ_SUCCESS on success, or the appropriate error code.
3394 */
3395PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003396 pjsua_buddy_info *info);
3397
3398/**
Benny Prijono705e7842008-07-21 18:12:51 +00003399 * Set the user data associated with the buddy object.
3400 *
3401 * @param buddy_id The buddy identification.
3402 * @param user_data Arbitrary application data to be associated with
3403 * the buddy object.
3404 *
3405 * @return PJ_SUCCESS on success, or the appropriate error code.
3406 */
3407PJ_DECL(pj_status_t) pjsua_buddy_set_user_data(pjsua_buddy_id buddy_id,
3408 void *user_data);
3409
3410
3411/**
3412 * Get the user data associated with the budy object.
3413 *
3414 * @param buddy_id The buddy identification.
3415 *
3416 * @return The application data.
3417 */
3418PJ_DECL(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id);
3419
3420
3421/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003422 * Add new buddy to the buddy list. If presence subscription is enabled
3423 * for this buddy, this function will also start the presence subscription
3424 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003425 *
Benny Prijonoa7b376b2008-01-25 16:06:33 +00003426 * @param buddy_cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003427 * @param p_buddy_id Pointer to receive buddy ID.
3428 *
3429 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003430 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003431PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003432 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003433
3434
3435/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003436 * Delete the specified buddy from the buddy list. Any presence subscription
3437 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003438 *
3439 * @param buddy_id Buddy identification.
3440 *
3441 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00003442 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003443PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003444
3445
3446/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003447 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3448 * subscribed, application will be informed about buddy's presence status
3449 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003450 *
3451 * @param buddy_id Buddy identification.
3452 * @param subscribe Specify non-zero to activate presence subscription to
3453 * the specified buddy.
3454 *
3455 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003456 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003457PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3458 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003459
3460
3461/**
Benny Prijono10861432007-10-31 10:54:53 +00003462 * Update the presence information for the buddy. Although the library
3463 * periodically refreshes the presence subscription for all buddies, some
3464 * application may want to refresh the buddy's presence subscription
3465 * immediately, and in this case it can use this function to accomplish
3466 * this.
3467 *
3468 * Note that the buddy's presence subscription will only be initiated
3469 * if presence monitoring is enabled for the buddy. See
3470 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
3471 * for the buddy is already active, this function will not do anything.
3472 *
3473 * Once the presence subscription is activated successfully for the buddy,
3474 * application will be notified about the buddy's presence status in the
3475 * on_buddy_state() callback.
3476 *
3477 * @param buddy_id Buddy identification.
3478 *
3479 * @return PJ_SUCCESS on success, or the appropriate error code.
3480 */
3481PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
3482
3483
3484/**
Benny Prijono63fba012008-07-17 14:19:10 +00003485 * Send NOTIFY to inform account presence status or to terminate server
3486 * side presence subscription. If application wants to reject the incoming
3487 * request, it should set the \a state to PJSIP_EVSUB_STATE_TERMINATED.
3488 *
3489 * @param acc_id Account ID.
3490 * @param srv_pres Server presence subscription instance.
3491 * @param state New state to set.
3492 * @param state_str Optionally specify the state string name, if state
3493 * is not "active", "pending", or "terminated".
3494 * @param reason If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3495 * optionally specify the termination reason.
3496 * @param with_body If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3497 * this specifies whether the NOTIFY request should
3498 * contain message body containing account's presence
3499 * information.
3500 * @param msg_data Optional list of headers to be sent with the NOTIFY
3501 * request.
3502 *
3503 * @return PJ_SUCCESS on success.
3504 */
3505PJ_DECL(pj_status_t) pjsua_pres_notify(pjsua_acc_id acc_id,
3506 pjsua_srv_pres *srv_pres,
3507 pjsip_evsub_state state,
3508 const pj_str_t *state_str,
3509 const pj_str_t *reason,
3510 pj_bool_t with_body,
3511 const pjsua_msg_data *msg_data);
3512
3513/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003514 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003515 *
3516 * @param verbose Yes or no.
Benny Prijono834aee32006-02-19 01:38:06 +00003517 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003518PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003519
3520
Benny Prijonob0808372006-03-02 21:18:58 +00003521/**
3522 * The MESSAGE method (defined in pjsua_im.c)
3523 */
3524extern const pjsip_method pjsip_message_method;
3525
3526
Benny Prijonob0808372006-03-02 21:18:58 +00003527
3528/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003529 * Send instant messaging outside dialog, using the specified account for
3530 * route set and authentication.
3531 *
3532 * @param acc_id Account ID to be used to send the request.
3533 * @param to Remote URI.
3534 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3535 * assumed.
3536 * @param content The message content.
3537 * @param msg_data Optional list of headers etc to be included in outgoing
3538 * request. The body descriptor in the msg_data is
3539 * ignored.
3540 * @param user_data Optional user data, which will be given back when
3541 * the IM callback is called.
3542 *
3543 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003544 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003545PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3546 const pj_str_t *to,
3547 const pj_str_t *mime_type,
3548 const pj_str_t *content,
3549 const pjsua_msg_data *msg_data,
3550 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003551
3552
3553/**
3554 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003555 *
3556 * @param acc_id Account ID to be used to send the request.
3557 * @param to Remote URI.
3558 * @param is_typing If non-zero, it tells remote person that local person
3559 * is currently composing an IM.
3560 * @param msg_data Optional list of headers etc to be added to outgoing
3561 * request.
3562 *
3563 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003564 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003565PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3566 const pj_str_t *to,
3567 pj_bool_t is_typing,
3568 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003569
3570
Benny Prijonof3195072006-02-14 21:15:30 +00003571
Benny Prijono312aff92006-06-17 04:08:30 +00003572/**
3573 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003574 */
3575
Benny Prijono312aff92006-06-17 04:08:30 +00003576
3577/*****************************************************************************
3578 * MEDIA API
3579 */
3580
3581
3582/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003583 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003584 * @ingroup PJSUA_LIB
3585 * @brief Media manipulation.
3586 * @{
3587 *
3588 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003589 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3590 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003591 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003592 * the interconnection between these terminations freely.
3593 *
3594 * The conference bridge provides powerful switching and mixing functionality
3595 * for application. With the conference bridge, each conference slot (e.g.
3596 * a call) can transmit to multiple destinations, and one destination can
3597 * receive from multiple sources. If more than one media terminations are
3598 * terminated in the same slot, the conference bridge will mix the signal
3599 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00003600 *
3601 * Application connects one media termination/slot to another by calling
3602 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003603 * media flow from the source termination to the sink termination. To
3604 * establish bidirectional media flow, application wound need to make another
3605 * call to #pjsua_conf_connect(), this time inverting the source and
3606 * destination slots in the parameter.
3607 *
3608 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00003609 * the following steps:
3610 *
3611 \code
3612
3613 pj_status_t stream_to_call( pjsua_call_id call_id )
3614 {
3615 pjsua_player_id player_id;
3616
3617 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
3618 if (status != PJ_SUCCESS)
3619 return status;
3620
3621 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
3622 pjsua_call_get_conf_port() );
3623 }
3624 \endcode
3625 *
3626 *
3627 * Other features of PJSUA media:
3628 * - efficient N to M interconnections between media terminations.
3629 * - media termination can be connected to itself to create loopback
3630 * media.
3631 * - the media termination may have different clock rates, and resampling
3632 * will be done automatically by conference bridge.
3633 * - media terminations may also have different frame time; the
3634 * conference bridge will perform the necessary bufferring to adjust
3635 * the difference between terminations.
3636 * - interconnections are removed automatically when media termination
3637 * is removed from the bridge.
3638 * - sound device may be changed even when there are active media
3639 * interconnections.
3640 * - correctly report call's media quality (in #pjsua_call_dump()) from
3641 * RTCP packet exchange.
3642 */
3643
3644/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003645 * Max ports in the conference bridge. This setting is the default value
3646 * for pjsua_media_config.max_media_ports.
Benny Prijono312aff92006-06-17 04:08:30 +00003647 */
3648#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00003649# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00003650#endif
3651
Benny Prijonob5388cf2007-01-04 22:45:08 +00003652/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003653 * The default clock rate to be used by the conference bridge. This setting
3654 * is the default value for pjsua_media_config.clock_rate.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003655 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003656#ifndef PJSUA_DEFAULT_CLOCK_RATE
3657# define PJSUA_DEFAULT_CLOCK_RATE 16000
3658#endif
3659
Benny Prijonob5388cf2007-01-04 22:45:08 +00003660/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003661 * Default frame length in the conference bridge. This setting
3662 * is the default value for pjsua_media_config.audio_frame_ptime.
3663 */
3664#ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Nanang Izzuddinaf974842008-05-08 09:51:16 +00003665# define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
Benny Prijono37c710b2008-01-10 12:09:26 +00003666#endif
3667
3668
3669/**
3670 * Default codec quality settings. This setting is the default value
3671 * for pjsua_media_config.quality.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003672 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003673#ifndef PJSUA_DEFAULT_CODEC_QUALITY
Nanang Izzuddin9dbad152008-06-10 18:56:10 +00003674# define PJSUA_DEFAULT_CODEC_QUALITY 8
Benny Prijono12a669c2006-11-23 07:32:13 +00003675#endif
3676
Benny Prijonob5388cf2007-01-04 22:45:08 +00003677/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003678 * Default iLBC mode. This setting is the default value for
3679 * pjsua_media_config.ilbc_mode.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003680 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003681#ifndef PJSUA_DEFAULT_ILBC_MODE
Benny Prijono37c710b2008-01-10 12:09:26 +00003682# define PJSUA_DEFAULT_ILBC_MODE 30
Benny Prijono12a669c2006-11-23 07:32:13 +00003683#endif
3684
Benny Prijonob5388cf2007-01-04 22:45:08 +00003685/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003686 * The default echo canceller tail length. This setting
3687 * is the default value for pjsua_media_config.ec_tail_len.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003688 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003689#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijono427439c2007-10-21 09:41:24 +00003690# define PJSUA_DEFAULT_EC_TAIL_LEN 200
Benny Prijono12a669c2006-11-23 07:32:13 +00003691#endif
Benny Prijono312aff92006-06-17 04:08:30 +00003692
3693
3694/**
Benny Prijonocba59d92007-02-16 09:22:56 +00003695 * The maximum file player.
3696 */
3697#ifndef PJSUA_MAX_PLAYERS
3698# define PJSUA_MAX_PLAYERS 32
3699#endif
3700
3701
3702/**
3703 * The maximum file player.
3704 */
3705#ifndef PJSUA_MAX_RECORDERS
3706# define PJSUA_MAX_RECORDERS 32
3707#endif
3708
3709
3710/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003711 * This structure describes media configuration, which will be specified
3712 * when calling #pjsua_init(). Application MUST initialize this structure
3713 * by calling #pjsua_media_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00003714 */
3715struct pjsua_media_config
3716{
3717 /**
3718 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003719 * If value is zero, default clock rate will be used
3720 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00003721 */
3722 unsigned clock_rate;
3723
3724 /**
Benny Prijonof3758ee2008-02-26 15:32:16 +00003725 * Clock rate to be applied when opening the sound device.
3726 * If value is zero, conference bridge clock rate will be used.
3727 */
3728 unsigned snd_clock_rate;
3729
3730 /**
Benny Prijono7d60d052008-03-29 12:24:20 +00003731 * Channel count be applied when opening the sound device and
3732 * conference bridge.
3733 */
3734 unsigned channel_count;
3735
3736 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003737 * Specify audio frame ptime. The value here will affect the
3738 * samples per frame of both the sound device and the conference
3739 * bridge. Specifying lower ptime will normally reduce the
3740 * latency.
3741 *
Benny Prijono37c710b2008-01-10 12:09:26 +00003742 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003743 */
3744 unsigned audio_frame_ptime;
3745
3746 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003747 * Specify maximum number of media ports to be created in the
3748 * conference bridge. Since all media terminate in the bridge
3749 * (calls, file player, file recorder, etc), the value must be
3750 * large enough to support all of them. However, the larger
3751 * the value, the more computations are performed.
Benny Prijono37c710b2008-01-10 12:09:26 +00003752 *
3753 * Default value: PJSUA_MAX_CONF_PORTS
Benny Prijono312aff92006-06-17 04:08:30 +00003754 */
3755 unsigned max_media_ports;
3756
3757 /**
3758 * Specify whether the media manager should manage its own
3759 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
3760 * and at least one worker thread will be created too. If no,
3761 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
3762 * and no worker thread is needed.
3763 *
3764 * Normally application would say yes here, unless it wants to
3765 * run everything from a single thread.
3766 */
3767 pj_bool_t has_ioqueue;
3768
3769 /**
3770 * Specify the number of worker threads to handle incoming RTP
3771 * packets. A value of one is recommended for most applications.
3772 */
3773 unsigned thread_cnt;
3774
Benny Prijono0498d902006-06-19 14:49:14 +00003775 /**
3776 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00003777 * 5-10: resampling use large filter,
3778 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00003779 * 1-2: resampling use linear.
3780 * The media quality also sets speex codec quality/complexity to the
3781 * number.
3782 *
Benny Prijono70972992006-08-05 11:13:58 +00003783 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00003784 */
3785 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00003786
3787 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003788 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00003789 *
3790 * Default: 0 (codec specific)
3791 */
3792 unsigned ptime;
3793
3794 /**
3795 * Disable VAD?
3796 *
3797 * Default: 0 (no (meaning VAD is enabled))
3798 */
3799 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00003800
3801 /**
3802 * iLBC mode (20 or 30).
3803 *
Benny Prijono37c710b2008-01-10 12:09:26 +00003804 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00003805 */
3806 unsigned ilbc_mode;
3807
3808 /**
3809 * Percentage of RTP packet to drop in TX direction
3810 * (to simulate packet lost).
3811 *
3812 * Default: 0
3813 */
3814 unsigned tx_drop_pct;
3815
3816 /**
3817 * Percentage of RTP packet to drop in RX direction
3818 * (to simulate packet lost).
3819 *
3820 * Default: 0
3821 */
3822 unsigned rx_drop_pct;
3823
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003824 /**
Benny Prijono5da50432006-08-07 10:24:52 +00003825 * Echo canceller options (see #pjmedia_echo_create())
3826 *
3827 * Default: 0.
3828 */
3829 unsigned ec_options;
3830
3831 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003832 * Echo canceller tail length, in miliseconds.
3833 *
Benny Prijono669643c2006-09-20 20:02:18 +00003834 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003835 */
3836 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003837
Benny Prijono10454dc2009-02-21 14:21:59 +00003838 /**
3839 * Audio capture buffer length, in milliseconds.
3840 *
3841 * Default: PJMEDIA_SND_DEFAULT_REC_LATENCY
3842 */
3843 unsigned snd_rec_latency;
3844
3845 /**
3846 * Audio playback buffer length, in milliseconds.
3847 *
3848 * Default: PJMEDIA_SND_DEFAULT_PLAY_LATENCY
3849 */
3850 unsigned snd_play_latency;
3851
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003852 /**
3853 * Jitter buffer initial prefetch delay in msec. The value must be
3854 * between jb_min_pre and jb_max_pre below.
3855 *
3856 * Default: -1 (to use default stream settings, currently 150 msec)
3857 */
3858 int jb_init;
3859
3860 /**
3861 * Jitter buffer minimum prefetch delay in msec.
3862 *
3863 * Default: -1 (to use default stream settings, currently 60 msec)
3864 */
3865 int jb_min_pre;
3866
3867 /**
3868 * Jitter buffer maximum prefetch delay in msec.
3869 *
3870 * Default: -1 (to use default stream settings, currently 240 msec)
3871 */
3872 int jb_max_pre;
3873
3874 /**
3875 * Set maximum delay that can be accomodated by the jitter buffer msec.
3876 *
3877 * Default: -1 (to use default stream settings, currently 360 msec)
3878 */
3879 int jb_max;
3880
Benny Prijonoc97608e2007-03-23 16:34:20 +00003881 /**
3882 * Enable ICE
3883 */
3884 pj_bool_t enable_ice;
3885
3886 /**
Benny Prijono329d6382009-05-29 13:04:03 +00003887 * Set the maximum number of host candidates.
3888 *
3889 * Default: -1 (maximum not set)
Benny Prijonoc97608e2007-03-23 16:34:20 +00003890 */
Benny Prijono329d6382009-05-29 13:04:03 +00003891 int ice_max_host_cands;
3892
3893 /**
3894 * ICE session options.
3895 */
3896 pj_ice_sess_options ice_opt;
Benny Prijonof76e1392008-06-06 14:51:48 +00003897
3898 /**
Benny Prijono551af422008-08-07 09:55:52 +00003899 * Disable RTCP component.
3900 *
3901 * Default: no
3902 */
3903 pj_bool_t ice_no_rtcp;
3904
3905 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00003906 * Enable TURN relay candidate in ICE.
3907 */
3908 pj_bool_t enable_turn;
3909
3910 /**
3911 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
3912 * "HOST:PORT" format.
3913 */
3914 pj_str_t turn_server;
3915
3916 /**
3917 * Specify the connection type to be used to the TURN server. Valid
3918 * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP.
3919 *
3920 * Default: PJ_TURN_TP_UDP
3921 */
3922 pj_turn_tp_type turn_conn_type;
3923
3924 /**
3925 * Specify the credential to authenticate with the TURN server.
3926 */
3927 pj_stun_auth_cred turn_auth_cred;
Nanang Izzuddin68559c32008-06-13 17:01:46 +00003928
3929 /**
3930 * Specify idle time of sound device before it is automatically closed,
Benny Prijonof798e502009-03-09 13:08:16 +00003931 * in seconds. Use value -1 to disable the auto-close feature of sound
3932 * device
Nanang Izzuddin68559c32008-06-13 17:01:46 +00003933 *
Benny Prijonof798e502009-03-09 13:08:16 +00003934 * Default : 1
Nanang Izzuddin68559c32008-06-13 17:01:46 +00003935 */
3936 int snd_auto_close_time;
Benny Prijono312aff92006-06-17 04:08:30 +00003937};
3938
3939
3940/**
3941 * Use this function to initialize media config.
3942 *
3943 * @param cfg The media config to be initialized.
3944 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003945PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00003946
3947
3948/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003949 * This structure describes codec information, which can be retrieved by
3950 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00003951 */
3952typedef struct pjsua_codec_info
3953{
3954 /**
3955 * Codec unique identification.
3956 */
3957 pj_str_t codec_id;
3958
3959 /**
3960 * Codec priority (integer 0-255).
3961 */
3962 pj_uint8_t priority;
3963
3964 /**
3965 * Internal buffer.
3966 */
3967 char buf_[32];
3968
3969} pjsua_codec_info;
3970
3971
3972/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003973 * This structure descibes information about a particular media port that
3974 * has been registered into the conference bridge. Application can query
3975 * this info by calling #pjsua_conf_get_port_info().
Benny Prijono312aff92006-06-17 04:08:30 +00003976 */
3977typedef struct pjsua_conf_port_info
3978{
3979 /** Conference port number. */
3980 pjsua_conf_port_id slot_id;
3981
3982 /** Port name. */
3983 pj_str_t name;
3984
3985 /** Clock rate. */
3986 unsigned clock_rate;
3987
3988 /** Number of channels. */
3989 unsigned channel_count;
3990
3991 /** Samples per frame */
3992 unsigned samples_per_frame;
3993
3994 /** Bits per sample */
3995 unsigned bits_per_sample;
3996
3997 /** Number of listeners in the array. */
3998 unsigned listener_cnt;
3999
4000 /** Array of listeners (in other words, ports where this port is
4001 * transmitting to.
4002 */
4003 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
4004
4005} pjsua_conf_port_info;
4006
4007
4008/**
4009 * This structure holds information about custom media transport to
4010 * be registered to pjsua.
4011 */
4012typedef struct pjsua_media_transport
4013{
4014 /**
4015 * Media socket information containing the address information
4016 * of the RTP and RTCP socket.
4017 */
4018 pjmedia_sock_info skinfo;
4019
4020 /**
4021 * The media transport instance.
4022 */
4023 pjmedia_transport *transport;
4024
4025} pjsua_media_transport;
4026
4027
4028
4029
Benny Prijono9fc735d2006-05-28 14:58:12 +00004030/**
4031 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004032 *
4033 * @return Maximum number of ports in the conference bridge.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004034 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004035PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004036
4037
4038/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004039 * Get current number of active ports in the bridge.
4040 *
4041 * @return The number.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004042 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004043PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
4044
4045
4046/**
4047 * Enumerate all conference ports.
4048 *
4049 * @param id Array of conference port ID to be initialized.
4050 * @param count On input, specifies max elements in the array.
4051 * On return, it contains actual number of elements
4052 * that have been initialized.
4053 *
4054 * @return PJ_SUCCESS on success, or the appropriate error code.
4055 */
4056PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
4057 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004058
4059
4060/**
4061 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004062 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004063 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004064 * @param info Pointer to store the port info.
4065 *
4066 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004067 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004068PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00004069 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004070
4071
4072/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00004073 * Add arbitrary media port to PJSUA's conference bridge. Application
4074 * can use this function to add the media port that it creates. For
4075 * media ports that are created by PJSUA-LIB (such as calls, file player,
4076 * or file recorder), PJSUA-LIB will automatically add the port to
4077 * the bridge.
4078 *
4079 * @param pool Pool to use.
4080 * @param port Media port to be added to the bridge.
4081 * @param p_id Optional pointer to receive the conference
4082 * slot id.
4083 *
4084 * @return PJ_SUCCESS on success, or the appropriate error code.
4085 */
4086PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
4087 pjmedia_port *port,
4088 pjsua_conf_port_id *p_id);
4089
4090
4091/**
4092 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00004093 * call this function if it registered the port manually with previous call
4094 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00004095 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004096 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00004097 *
4098 * @return PJ_SUCCESS on success, or the appropriate error code.
4099 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004100PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00004101
4102
4103/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004104 * Establish unidirectional media flow from souce to sink. One source
4105 * may transmit to multiple destinations/sink. And if multiple
4106 * sources are transmitting to the same sink, the media will be mixed
4107 * together. Source and sink may refer to the same ID, effectively
4108 * looping the media.
4109 *
4110 * If bidirectional media flow is desired, application needs to call
4111 * this function twice, with the second one having the arguments
4112 * reversed.
4113 *
4114 * @param source Port ID of the source media/transmitter.
4115 * @param sink Port ID of the destination media/received.
4116 *
4117 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004118 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004119PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
4120 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004121
4122
4123/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004124 * Disconnect media flow from the source to destination port.
4125 *
4126 * @param source Port ID of the source media/transmitter.
4127 * @param sink Port ID of the destination media/received.
4128 *
4129 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004130 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004131PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
4132 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004133
4134
Benny Prijono6dd967c2006-12-26 02:27:14 +00004135/**
4136 * Adjust the signal level to be transmitted from the bridge to the
4137 * specified port by making it louder or quieter.
4138 *
4139 * @param slot The conference bridge slot number.
4140 * @param level Signal level adjustment. Value 1.0 means no level
4141 * adjustment, while value 0 means to mute the port.
4142 *
4143 * @return PJ_SUCCESS on success, or the appropriate error code.
4144 */
4145PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
4146 float level);
4147
4148/**
4149 * Adjust the signal level to be received from the specified port (to
4150 * the bridge) by making it louder or quieter.
4151 *
4152 * @param slot The conference bridge slot number.
4153 * @param level Signal level adjustment. Value 1.0 means no level
4154 * adjustment, while value 0 means to mute the port.
4155 *
4156 * @return PJ_SUCCESS on success, or the appropriate error code.
4157 */
4158PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
4159 float level);
4160
4161/**
4162 * Get last signal level transmitted to or received from the specified port.
4163 * The signal level is an integer value in zero to 255, with zero indicates
4164 * no signal, and 255 indicates the loudest signal level.
4165 *
4166 * @param slot The conference bridge slot number.
4167 * @param tx_level Optional argument to receive the level of signal
4168 * transmitted to the specified port (i.e. the direction
4169 * is from the bridge to the port).
4170 * @param rx_level Optional argument to receive the level of signal
4171 * received from the port (i.e. the direction is from the
4172 * port to the bridge).
4173 *
4174 * @return PJ_SUCCESS on success.
4175 */
4176PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
4177 unsigned *tx_level,
4178 unsigned *rx_level);
4179
Benny Prijono6dd967c2006-12-26 02:27:14 +00004180
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004181/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00004182 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004183 */
4184
Benny Prijono9fc735d2006-05-28 14:58:12 +00004185/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004186 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004187 * the conference bridge.
4188 *
4189 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00004190 * WAV files are supported, and the WAV file MUST be
4191 * formatted as 16bit PCM mono/single channel (any
4192 * clock rate is supported).
Benny Prijono58add7c2008-01-18 13:24:07 +00004193 * @param options Optional option flag. Application may specify
4194 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004195 * @param p_id Pointer to receive player ID.
4196 *
4197 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004198 */
4199PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004200 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004201 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004202
4203
4204/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004205 * Create a file playlist media port, and automatically add the port
4206 * to the conference bridge.
4207 *
4208 * @param file_names Array of file names to be added to the play list.
4209 * Note that the files must have the same clock rate,
4210 * number of channels, and number of bits per sample.
4211 * @param file_count Number of files in the array.
4212 * @param label Optional label to be set for the media port.
4213 * @param options Optional option flag. Application may specify
4214 * PJMEDIA_FILE_NO_LOOP to prevent looping.
4215 * @param p_id Optional pointer to receive player ID.
4216 *
4217 * @return PJ_SUCCESS on success, or the appropriate error code.
4218 */
4219PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
4220 unsigned file_count,
4221 const pj_str_t *label,
4222 unsigned options,
4223 pjsua_player_id *p_id);
4224
4225/**
4226 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004227 *
4228 * @param id The file player ID.
4229 *
4230 * @return Conference port ID associated with this player.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004231 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004232PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004233
4234
4235/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004236 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00004237 *
4238 * @param id The player ID.
4239 * @param p_port The media port associated with the player.
4240 *
4241 * @return PJ_SUCCESS on success.
4242 */
Benny Prijono58add7c2008-01-18 13:24:07 +00004243PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
Benny Prijono469b1522006-12-26 03:05:17 +00004244 pjmedia_port **p_port);
4245
4246/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004247 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004248 *
4249 * @param id The file player ID.
4250 * @param samples The playback position, in samples. Application can
4251 * specify zero to re-start the playback.
4252 *
4253 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004254 */
4255PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
4256 pj_uint32_t samples);
4257
4258
4259/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004260 * Close the file of playlist, remove the player from the bridge, and free
4261 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004262 *
4263 * @param id The file player ID.
4264 *
4265 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004266 */
4267PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
4268
4269
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004270/*****************************************************************************
4271 * File recorder.
4272 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00004273
4274/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004275 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004276 * the conference bridge. The recorder currently supports recording WAV file.
4277 * The type of the recorder to use is determined by the extension of the file
4278 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004279 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00004280 * @param filename Output file name. The function will determine the
4281 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004282 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00004283 * @param enc_type Optionally specify the type of encoder to be used to
4284 * compress the media, if the file can support different
4285 * encodings. This value must be zero for now.
4286 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004287 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00004288 * For .WAV recorder, this value must be NULL.
4289 * @param max_size Maximum file size. Specify zero or -1 to remove size
4290 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004291 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004292 * @param p_id Pointer to receive the recorder instance.
4293 *
4294 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004295 */
4296PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004297 unsigned enc_type,
4298 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004299 pj_ssize_t max_size,
4300 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004301 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004302
4303
4304/**
4305 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004306 *
4307 * @param id The recorder ID.
4308 *
4309 * @return Conference port ID associated with this recorder.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004310 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004311PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004312
4313
4314/**
Benny Prijono469b1522006-12-26 03:05:17 +00004315 * Get the media port for the recorder.
4316 *
4317 * @param id The recorder ID.
4318 * @param p_port The media port associated with the recorder.
4319 *
4320 * @return PJ_SUCCESS on success.
4321 */
4322PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4323 pjmedia_port **p_port);
4324
4325
4326/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004327 * Destroy recorder (this will complete recording).
4328 *
4329 * @param id The recorder ID.
4330 *
4331 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004332 */
4333PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4334
4335
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004336/*****************************************************************************
4337 * Sound devices.
4338 */
4339
Benny Prijono9fc735d2006-05-28 14:58:12 +00004340/**
Benny Prijonof798e502009-03-09 13:08:16 +00004341 * Enum all audio devices installed in the system.
4342 *
4343 * @param info Array of info to be initialized.
4344 * @param count On input, specifies max elements in the array.
4345 * On return, it contains actual number of elements
4346 * that have been initialized.
4347 *
4348 * @return PJ_SUCCESS on success, or the appropriate error code.
4349 */
4350PJ_DECL(pj_status_t) pjsua_enum_aud_devs(pjmedia_aud_dev_info info[],
4351 unsigned *count);
4352
4353/**
4354 * Enum all sound devices installed in the system (old API).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004355 *
4356 * @param info Array of info to be initialized.
4357 * @param count On input, specifies max elements in the array.
4358 * On return, it contains actual number of elements
4359 * that have been initialized.
4360 *
4361 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004362 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004363PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4364 unsigned *count);
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004365
4366/**
4367 * Get currently active sound devices. If sound devices has not been created
4368 * (for example when pjsua_start() is not called), it is possible that
4369 * the function returns PJ_SUCCESS with -1 as device IDs.
4370 *
4371 * @param capture_dev On return it will be filled with device ID of the
4372 * capture device.
4373 * @param playback_dev On return it will be filled with device ID of the
4374 * device ID of the playback device.
4375 *
4376 * @return PJ_SUCCESS on success, or the appropriate error code.
4377 */
4378PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4379 int *playback_dev);
4380
4381
Benny Prijono9fc735d2006-05-28 14:58:12 +00004382/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004383 * Select or change sound device. Application may call this function at
4384 * any time to replace current sound device.
4385 *
4386 * @param capture_dev Device ID of the capture device.
4387 * @param playback_dev Device ID of the playback device.
4388 *
4389 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004390 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004391PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4392 int playback_dev);
4393
4394
4395/**
4396 * Set pjsua to use null sound device. The null sound device only provides
4397 * the timing needed by the conference bridge, and will not interract with
4398 * any hardware.
4399 *
4400 * @return PJ_SUCCESS on success, or the appropriate error code.
4401 */
4402PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4403
4404
Benny Prijonoe909eac2006-07-27 22:04:56 +00004405/**
4406 * Disconnect the main conference bridge from any sound devices, and let
4407 * application connect the bridge to it's own sound device/master port.
4408 *
4409 * @return The port interface of the conference bridge,
4410 * so that application can connect this to it's own
4411 * sound device or master port.
4412 */
4413PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4414
4415
Benny Prijonof20687a2006-08-04 18:27:19 +00004416/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004417 * Change the echo cancellation settings.
Benny Prijonof798e502009-03-09 13:08:16 +00004418 *
4419 * The behavior of this function depends on whether the sound device is
4420 * currently active, and if it is, whether device or software AEC is
4421 * being used.
Benny Prijono10454dc2009-02-21 14:21:59 +00004422 *
4423 * If the sound device is currently active, and if the device supports AEC,
4424 * this function will forward the change request to the device and it will
4425 * be up to the device on whether support the request. If software AEC is
4426 * being used (the software EC will be used if the device does not support
4427 * AEC), this function will change the software EC settings. In all cases,
4428 * the setting will be saved for future opening of the sound device.
4429 *
4430 * If the sound device is not currently active, this will only change the
4431 * default AEC settings and the setting will be applied next time the
4432 * sound device is opened.
Benny Prijonof20687a2006-08-04 18:27:19 +00004433 *
4434 * @param tail_ms The tail length, in miliseconds. Set to zero to
4435 * disable AEC.
Benny Prijonoa7b376b2008-01-25 16:06:33 +00004436 * @param options Options to be passed to pjmedia_echo_create().
Benny Prijono5da50432006-08-07 10:24:52 +00004437 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004438 *
4439 * @return PJ_SUCCESS on success.
4440 */
Benny Prijono5da50432006-08-07 10:24:52 +00004441PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004442
4443
4444/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004445 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004446 *
4447 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4448 * If AEC is disabled, the value will be zero.
4449 *
4450 * @return PJ_SUCCESS on success.
4451 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004452PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004453
4454
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004455/**
Benny Prijonof798e502009-03-09 13:08:16 +00004456 * Check whether the sound device is currently active. The sound device
4457 * may be inactive if the application has set the auto close feature to
4458 * non-zero (the snd_auto_close_time setting in #pjsua_media_config), or
4459 * if null sound device or no sound device has been configured via the
4460 * #pjsua_set_no_snd_dev() function.
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004461 */
Benny Prijonof798e502009-03-09 13:08:16 +00004462PJ_DECL(pj_bool_t) pjsua_snd_is_active(void);
4463
4464
4465/**
4466 * Configure sound device setting to the sound device being used. If sound
4467 * device is currently active, the function will forward the setting to the
4468 * sound device instance to be applied immediately, if it supports it.
4469 *
4470 * The setting will be saved for future opening of the sound device, if the
4471 * "keep" argument is set to non-zero. If the sound device is currently
4472 * inactive, and the "keep" argument is false, this function will return
4473 * error.
4474 *
4475 * Note that in case the setting is kept for future use, it will be applied
4476 * to any devices, even when application has changed the sound device to be
4477 * used.
4478 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004479 * Note also that the echo cancellation setting should be set with
4480 * #pjsua_set_ec() API instead.
4481 *
Benny Prijonof798e502009-03-09 13:08:16 +00004482 * See also #pjmedia_aud_stream_set_cap() for more information about setting
4483 * an audio device capability.
4484 *
4485 * @param cap The sound device setting to change.
4486 * @param pval Pointer to value. Please see #pjmedia_aud_dev_cap
4487 * documentation about the type of value to be
4488 * supplied for each setting.
4489 * @param keep Specify whether the setting is to be kept for future
4490 * use.
4491 *
4492 * @return PJ_SUCCESS on success or the appropriate error code.
4493 */
4494PJ_DECL(pj_status_t) pjsua_snd_set_setting(pjmedia_aud_dev_cap cap,
4495 const void *pval,
4496 pj_bool_t keep);
4497
4498/**
4499 * Retrieve a sound device setting. If sound device is currently active,
4500 * the function will forward the request to the sound device. If sound device
4501 * is currently inactive, and if application had previously set the setting
4502 * and mark the setting as kept, then that setting will be returned.
4503 * Otherwise, this function will return error.
4504 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004505 * Note that echo cancellation settings should be retrieved with
4506 * #pjsua_get_ec_tail() API instead.
4507 *
Benny Prijonof798e502009-03-09 13:08:16 +00004508 * @param cap The sound device setting to retrieve.
4509 * @param pval Pointer to receive the value.
4510 * Please see #pjmedia_aud_dev_cap documentation about
4511 * the type of value to be supplied for each setting.
4512 *
4513 * @return PJ_SUCCESS on success or the appropriate error code.
4514 */
4515PJ_DECL(pj_status_t) pjsua_snd_get_setting(pjmedia_aud_dev_cap cap,
4516 void *pval);
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004517
4518
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004519/*****************************************************************************
4520 * Codecs.
4521 */
4522
4523/**
4524 * Enum all supported codecs in the system.
4525 *
4526 * @param id Array of ID to be initialized.
4527 * @param count On input, specifies max elements in the array.
4528 * On return, it contains actual number of elements
4529 * that have been initialized.
4530 *
4531 * @return PJ_SUCCESS on success, or the appropriate error code.
4532 */
4533PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4534 unsigned *count );
4535
4536
4537/**
4538 * Change codec priority.
4539 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004540 * @param codec_id Codec ID, which is a string that uniquely identify
4541 * the codec (such as "speex/8000"). Please see pjsua
4542 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004543 * @param priority Codec priority, 0-255, where zero means to disable
4544 * the codec.
4545 *
4546 * @return PJ_SUCCESS on success, or the appropriate error code.
4547 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004548PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004549 pj_uint8_t priority );
4550
4551
4552/**
4553 * Get codec parameters.
4554 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004555 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004556 * @param param Structure to receive codec parameters.
4557 *
4558 * @return PJ_SUCCESS on success, or the appropriate error code.
4559 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004560PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004561 pjmedia_codec_param *param );
4562
4563
4564/**
4565 * Set codec parameters.
4566 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004567 * @param codec_id Codec ID.
Nanang Izzuddin06839e72010-01-27 11:48:31 +00004568 * @param param Codec parameter to set. Set to NULL to reset
4569 * codec parameter to library default settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004570 *
4571 * @return PJ_SUCCESS on success, or the appropriate error code.
4572 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004573PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004574 const pjmedia_codec_param *param);
4575
4576
4577
Benny Prijono9fc735d2006-05-28 14:58:12 +00004578
Benny Prijono312aff92006-06-17 04:08:30 +00004579/**
4580 * Create UDP media transports for all the calls. This function creates
4581 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00004582 *
Benny Prijono312aff92006-06-17 04:08:30 +00004583 * @param cfg Media transport configuration. The "port" field in the
4584 * configuration is used as the start port to bind the
4585 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004586 *
4587 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonof3195072006-02-14 21:15:30 +00004588 */
Benny Prijono312aff92006-06-17 04:08:30 +00004589PJ_DECL(pj_status_t)
4590pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00004591
Benny Prijonodc39fe82006-05-26 12:17:46 +00004592
4593/**
Benny Prijono312aff92006-06-17 04:08:30 +00004594 * Register custom media transports to be used by calls. There must
4595 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004596 *
Benny Prijono312aff92006-06-17 04:08:30 +00004597 * @param tp The media transport array.
4598 * @param count Number of elements in the array. This number MUST
4599 * match the number of maximum calls configured when
4600 * pjsua is created.
4601 * @param auto_delete Flag to indicate whether the transports should be
4602 * destroyed when pjsua is shutdown.
4603 *
4604 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00004605 */
Benny Prijono312aff92006-06-17 04:08:30 +00004606PJ_DECL(pj_status_t)
4607pjsua_media_transports_attach( pjsua_media_transport tp[],
4608 unsigned count,
4609 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00004610
4611
Benny Prijono312aff92006-06-17 04:08:30 +00004612/**
4613 * @}
4614 */
4615
Benny Prijonof3195072006-02-14 21:15:30 +00004616
Benny Prijono268ca612006-02-07 12:34:11 +00004617
Benny Prijono312aff92006-06-17 04:08:30 +00004618/**
4619 * @}
4620 */
4621
Benny Prijonoe6ead542007-01-31 20:53:31 +00004622PJ_END_DECL
4623
Benny Prijono312aff92006-06-17 04:08:30 +00004624
Benny Prijono268ca612006-02-07 12:34:11 +00004625#endif /* __PJSUA_H__ */