blob: 9153afd991bd5433d03542eed4326be79dd69a71 [file] [log] [blame]
Benny Prijono268ca612006-02-07 12:34:11 +00001/* $Id$ */
2/*
Benny Prijono844653c2008-12-23 17:27:53 +00003 * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
Benny Prijono32177c02008-06-20 22:44:47 +00004 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
Benny Prijono268ca612006-02-07 12:34:11 +00005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#ifndef __PJSUA_H__
21#define __PJSUA_H__
22
Benny Prijono312aff92006-06-17 04:08:30 +000023/**
24 * @file pjsua.h
25 * @brief PJSUA API.
26 */
27
28
Benny Prijono268ca612006-02-07 12:34:11 +000029/* Include all PJSIP core headers. */
30#include <pjsip.h>
31
32/* Include all PJMEDIA headers. */
33#include <pjmedia.h>
34
Benny Prijono1f9afba2006-02-10 15:57:32 +000035/* Include all PJMEDIA-CODEC headers. */
36#include <pjmedia-codec.h>
37
Benny Prijono268ca612006-02-07 12:34:11 +000038/* Include all PJSIP-UA headers */
39#include <pjsip_ua.h>
40
Benny Prijono834aee32006-02-19 01:38:06 +000041/* Include all PJSIP-SIMPLE headers */
42#include <pjsip_simple.h>
43
Benny Prijono4ab9fbb2007-10-12 12:14:27 +000044/* Include all PJNATH headers */
45#include <pjnath.h>
46
Benny Prijono268ca612006-02-07 12:34:11 +000047/* Include all PJLIB-UTIL headers. */
48#include <pjlib-util.h>
49
50/* Include all PJLIB headers. */
51#include <pjlib.h>
52
53
Benny Prijonoe6ead542007-01-31 20:53:31 +000054PJ_BEGIN_DECL
55
56
Benny Prijono312aff92006-06-17 04:08:30 +000057/**
Benny Prijono58163a22009-06-03 08:40:24 +000058 * @defgroup PJSUA_LIB PJSUA API - High Level Softphone API
Benny Prijono312aff92006-06-17 04:08:30 +000059 * @brief Very high level API for constructing SIP UA applications.
60 * @{
61 *
Benny Prijono58163a22009-06-03 08:40:24 +000062 * @section pjsua_api_intro A SIP User Agent API for C/C++
Benny Prijonoe6ead542007-01-31 20:53:31 +000063 *
Benny Prijono58163a22009-06-03 08:40:24 +000064 * PJSUA API is very high level API for constructing SIP multimedia user agent
Benny Prijono312aff92006-06-17 04:08:30 +000065 * applications. It wraps together the signaling and media functionalities
66 * into an easy to use call API, provides account management, buddy
67 * management, presence, instant messaging, along with multimedia
68 * features such as conferencing, file streaming, local playback,
69 * voice recording, and so on.
70 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000071 * @subsection pjsua_for_c_cpp C/C++ Binding
Benny Prijono312aff92006-06-17 04:08:30 +000072 * Application must link with <b>pjsua-lib</b> to use this API. In addition,
73 * this library depends on the following libraries:
74 * - <b>pjsip-ua</b>,
75 * - <b>pjsip-simple</b>,
76 * - <b>pjsip-core</b>,
77 * - <b>pjmedia</b>,
78 * - <b>pjmedia-codec</b>,
79 * - <b>pjlib-util</b>, and
80 * - <b>pjlib</b>,
81 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000082 * so application must also link with these libraries as well. For more
83 * information, please refer to
84 * <A HREF="http://www.pjsip.org/using.htm">Getting Started with PJSIP</A>
85 * page.
Benny Prijono312aff92006-06-17 04:08:30 +000086 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000087 * @section pjsua_samples
88 *
Benny Prijono58163a22009-06-03 08:40:24 +000089 * Few samples are provided:
Benny Prijonoe6ead542007-01-31 20:53:31 +000090 *
91 - @ref page_pjsip_sample_simple_pjsuaua_c\n
92 Very simple SIP User Agent with registration, call, and media, using
93 PJSUA-API, all in under 200 lines of code.
94
95 - @ref page_pjsip_samples_pjsua\n
96 This is the reference implementation for PJSIP and PJMEDIA.
97 PJSUA is a console based application, designed to be simple enough
98 to be readble, but powerful enough to demonstrate all features
99 available in PJSIP and PJMEDIA.\n
100
Benny Prijono312aff92006-06-17 04:08:30 +0000101 * @section root_using_pjsua_lib Using PJSUA API
102 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000103 * Please refer to @ref PJSUA_LIB_BASE on how to create and initialize the API.
104 * And then see the Modules on the bottom of this page for more information
105 * about specific subject.
Benny Prijono312aff92006-06-17 04:08:30 +0000106 */
107
Benny Prijonoa91a0032006-02-26 21:23:45 +0000108
Benny Prijonof3195072006-02-14 21:15:30 +0000109
Benny Prijono312aff92006-06-17 04:08:30 +0000110/*****************************************************************************
111 * BASE API
112 */
113
Benny Prijonof04ffdd2006-02-21 00:11:18 +0000114/**
Benny Prijonoe6ead542007-01-31 20:53:31 +0000115 * @defgroup PJSUA_LIB_BASE PJSUA-API Basic API
Benny Prijono312aff92006-06-17 04:08:30 +0000116 * @ingroup PJSUA_LIB
117 * @brief Basic application creation/initialization, logging configuration, etc.
118 * @{
119 *
120 * The base PJSUA API controls PJSUA creation, initialization, and startup, and
121 * also provides various auxiliary functions.
122 *
123 * @section using_pjsua_lib Using PJSUA Library
124 *
125 * @subsection creating_pjsua_lib Creating PJSUA
126 *
Benny Prijono58163a22009-06-03 08:40:24 +0000127 * Before anything else, application must create PJSUA by calling
128 * #pjsua_create().
Benny Prijono312aff92006-06-17 04:08:30 +0000129 * This, among other things, will initialize PJLIB, which is crucial before
Benny Prijonoe6ead542007-01-31 20:53:31 +0000130 * any PJLIB functions can be called, PJLIB-UTIL, and create a SIP endpoint.
131 *
132 * After this function is called, application can create a memory pool (with
133 * #pjsua_pool_create()) and read configurations from command line or file to
134 * build the settings to initialize PJSUA below.
Benny Prijono312aff92006-06-17 04:08:30 +0000135 *
136 * @subsection init_pjsua_lib Initializing PJSUA
137 *
138 * After PJSUA is created, application can initialize PJSUA by calling
Benny Prijonoe6ead542007-01-31 20:53:31 +0000139 * #pjsua_init(). This function takes several optional configuration settings
140 * in the argument, if application wants to set them.
Benny Prijono312aff92006-06-17 04:08:30 +0000141 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000142 * @subsubsection init_pjsua_lib_c_cpp PJSUA-LIB Initialization (in C)
143 * Sample code to initialize PJSUA in C code:
Benny Prijono312aff92006-06-17 04:08:30 +0000144 \code
145
Benny Prijonob5388cf2007-01-04 22:45:08 +0000146 #include <pjsua-lib/pjsua.h>
147
148 #define THIS_FILE __FILE__
149
150 static pj_status_t app_init(void)
151 {
Benny Prijono312aff92006-06-17 04:08:30 +0000152 pjsua_config ua_cfg;
153 pjsua_logging_config log_cfg;
154 pjsua_media_config media_cfg;
Benny Prijonob5388cf2007-01-04 22:45:08 +0000155 pj_status_t status;
156
157 // Must create pjsua before anything else!
158 status = pjsua_create();
159 if (status != PJ_SUCCESS) {
160 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
161 return status;
162 }
Benny Prijono312aff92006-06-17 04:08:30 +0000163
164 // Initialize configs with default settings.
165 pjsua_config_default(&ua_cfg);
166 pjsua_logging_config_default(&log_cfg);
167 pjsua_media_config_default(&media_cfg);
168
169 // At the very least, application would want to override
170 // the call callbacks in pjsua_config:
171 ua_cfg.cb.on_incoming_call = ...
172 ua_cfg.cb.on_call_state = ..
173 ...
174
175 // Customize other settings (or initialize them from application specific
176 // configuration file):
177 ...
178
179 // Initialize pjsua
180 status = pjsua_init(&ua_cfg, &log_cfg, &media_cfg);
181 if (status != PJ_SUCCESS) {
182 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
183 return status;
184 }
Benny Prijonob5388cf2007-01-04 22:45:08 +0000185 .
186 ...
187 }
Benny Prijono312aff92006-06-17 04:08:30 +0000188 \endcode
189 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000190 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000191
192
Benny Prijono312aff92006-06-17 04:08:30 +0000193 * @subsection other_init_pjsua_lib Other Initialization
194 *
195 * After PJSUA is initialized with #pjsua_init(), application will normally
196 * need/want to perform the following tasks:
197 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000198 * - create SIP transport with #pjsua_transport_create(). Application would
199 * to call #pjsua_transport_create() for each transport types that it
200 * wants to support (for example, UDP, TCP, and TLS). Please see
Benny Prijono312aff92006-06-17 04:08:30 +0000201 * @ref PJSUA_LIB_TRANSPORT section for more info.
202 * - create one or more SIP accounts with #pjsua_acc_add() or
Benny Prijonoe6ead542007-01-31 20:53:31 +0000203 * #pjsua_acc_add_local(). The SIP account is used for registering with
204 * the SIP server, if any. Please see @ref PJSUA_LIB_ACC for more info.
Benny Prijono312aff92006-06-17 04:08:30 +0000205 * - add one or more buddies with #pjsua_buddy_add(). Please see
206 * @ref PJSUA_LIB_BUDDY section for more info.
207 * - optionally configure the sound device, codec settings, and other
208 * media settings. Please see @ref PJSUA_LIB_MEDIA for more info.
209 *
210 *
211 * @subsection starting_pjsua_lib Starting PJSUA
212 *
213 * After all initializations have been done, application must call
214 * #pjsua_start() to start PJSUA. This function will check that all settings
Benny Prijonoe6ead542007-01-31 20:53:31 +0000215 * have been properly configured, and apply default settings when they haven't,
216 * or report error status when it is unable to recover from missing settings.
Benny Prijono312aff92006-06-17 04:08:30 +0000217 *
218 * Most settings can be changed during run-time. For example, application
219 * may add, modify, or delete accounts, buddies, or change media settings
220 * during run-time.
Benny Prijonob5388cf2007-01-04 22:45:08 +0000221 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000222 * @subsubsection starting_pjsua_lib_c C Example for Starting PJSUA
Benny Prijonob5388cf2007-01-04 22:45:08 +0000223 * Sample code:
224 \code
225 static pj_status_t app_run(void)
226 {
227 pj_status_t status;
228
229 // Start pjsua
230 status = pjsua_start();
231 if (status != PJ_SUCCESS) {
232 pjsua_destroy();
233 pjsua_perror(THIS_FILE, "Error starting pjsua", status);
234 return status;
235 }
236
237 // Run application loop
238 while (1) {
239 char choice[10];
240
241 printf("Select menu: ");
242 fgets(choice, sizeof(choice), stdin);
243 ...
244 }
245 }
246 \endcode
Benny Prijonoe6ead542007-01-31 20:53:31 +0000247
Benny Prijonof04ffdd2006-02-21 00:11:18 +0000248 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000249
Benny Prijono312aff92006-06-17 04:08:30 +0000250/** Constant to identify invalid ID for all sorts of IDs. */
251#define PJSUA_INVALID_ID (-1)
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000252
Benny Prijono0bc99a92011-03-17 04:34:43 +0000253/** Disabled features temporarily for media reorganization */
254#define DISABLED_FOR_TICKET_1185 0
255
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000256/** Call identification */
257typedef int pjsua_call_id;
258
Benny Prijono312aff92006-06-17 04:08:30 +0000259/** Account identification */
260typedef int pjsua_acc_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000261
262/** Buddy identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000263typedef int pjsua_buddy_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000264
265/** File player identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000266typedef int pjsua_player_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000267
268/** File recorder identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000269typedef int pjsua_recorder_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000270
271/** Conference port identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000272typedef int pjsua_conf_port_id;
273
Benny Prijono63fba012008-07-17 14:19:10 +0000274/** Opaque declaration for server side presence subscription */
275typedef struct pjsua_srv_pres pjsua_srv_pres;
276
277/** Forward declaration for pjsua_msg_data */
278typedef struct pjsua_msg_data pjsua_msg_data;
Benny Prijono8b1889b2006-06-06 18:40:40 +0000279
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000280
Benny Prijonoa91a0032006-02-26 21:23:45 +0000281/**
Benny Prijono312aff92006-06-17 04:08:30 +0000282 * Maximum proxies in account.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000283 */
Benny Prijono312aff92006-06-17 04:08:30 +0000284#ifndef PJSUA_ACC_MAX_PROXIES
285# define PJSUA_ACC_MAX_PROXIES 8
286#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000287
Benny Prijonod8179652008-01-23 20:39:07 +0000288/**
289 * Default value of SRTP mode usage. Valid values are PJMEDIA_SRTP_DISABLED,
290 * PJMEDIA_SRTP_OPTIONAL, and PJMEDIA_SRTP_MANDATORY.
291 */
292#ifndef PJSUA_DEFAULT_USE_SRTP
293 #define PJSUA_DEFAULT_USE_SRTP PJMEDIA_SRTP_DISABLED
294#endif
295
296/**
297 * Default value of secure signaling requirement for SRTP.
298 * Valid values are:
299 * 0: SRTP does not require secure signaling
300 * 1: SRTP requires secure transport such as TLS
301 * 2: SRTP requires secure end-to-end transport (SIPS)
302 */
303#ifndef PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
304 #define PJSUA_DEFAULT_SRTP_SECURE_SIGNALING 1
305#endif
306
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000307/**
Benny Prijono07fe2302010-06-24 12:33:18 +0000308 * Controls whether PJSUA-LIB should add ICE media feature tag
309 * parameter (the ";+sip.ice" parameter) to Contact header if ICE
310 * is enabled in the config.
311 *
312 * Default: 1
313 */
314#ifndef PJSUA_ADD_ICE_TAGS
315# define PJSUA_ADD_ICE_TAGS 1
316#endif
317
Sauw Ming844c1c92010-09-07 05:12:02 +0000318/**
319 * Timeout value used to acquire mutex lock on a particular call.
320 *
321 * Default: 2000 ms
322 */
323#ifndef PJSUA_ACQUIRE_CALL_TIMEOUT
324# define PJSUA_ACQUIRE_CALL_TIMEOUT 2000
325#endif
326
Benny Prijono9f468d12011-07-07 07:46:33 +0000327/**
328 * Is video enabled.
329 */
330#ifndef PJSUA_HAS_VIDEO
331# define PJSUA_HAS_VIDEO PJMEDIA_HAS_VIDEO
332#endif
Benny Prijono07fe2302010-06-24 12:33:18 +0000333
334/**
Benny Prijono0bc99a92011-03-17 04:34:43 +0000335 * This enumeration represents pjsua state.
336 */
337typedef enum pjsua_state
338{
339 /**
340 * The library has not been initialized.
341 */
342 PJSUA_STATE_NULL,
343
344 /**
345 * After pjsua_create() is called but before pjsua_init() is called.
346 */
347 PJSUA_STATE_CREATED,
348
349 /**
350 * After pjsua_init() is called but before pjsua_start() is called.
351 */
352 PJSUA_STATE_INIT,
353
354 /**
355 * After pjsua_start() is called but before everything is running.
356 */
357 PJSUA_STATE_STARTING,
358
359 /**
360 * After pjsua_start() is called and before pjsua_destroy() is called.
361 */
362 PJSUA_STATE_RUNNING,
363
364 /**
365 * After pjsua_destroy() is called but before the function returns.
366 */
367 PJSUA_STATE_CLOSING
368
369} pjsua_state;
370
371
372/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000373 * Logging configuration, which can be (optionally) specified when calling
374 * #pjsua_init(). Application must call #pjsua_logging_config_default() to
375 * initialize this structure with the default values.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000376 */
377typedef struct pjsua_logging_config
378{
379 /**
380 * Log incoming and outgoing SIP message? Yes!
381 */
382 pj_bool_t msg_logging;
383
384 /**
385 * Input verbosity level. Value 5 is reasonable.
386 */
387 unsigned level;
388
389 /**
390 * Verbosity level for console. Value 4 is reasonable.
391 */
392 unsigned console_level;
393
394 /**
395 * Log decoration.
396 */
397 unsigned decor;
398
399 /**
400 * Optional log filename.
401 */
402 pj_str_t log_filename;
403
404 /**
Benny Prijonodbe3f4b2009-05-07 16:56:04 +0000405 * Additional flags to be given to #pj_file_open() when opening
406 * the log file. By default, the flag is PJ_O_WRONLY. Application
407 * may set PJ_O_APPEND here so that logs are appended to existing
408 * file instead of overwriting it.
409 *
410 * Default is 0.
411 */
412 unsigned log_file_flags;
413
414 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000415 * Optional callback function to be called to write log to
416 * application specific device. This function will be called for
417 * log messages on input verbosity level.
418 */
Benny Prijonofe7d87b2007-11-29 11:35:44 +0000419 void (*cb)(int level, const char *data, int len);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000420
421
422} pjsua_logging_config;
423
424
425/**
426 * Use this function to initialize logging config.
427 *
428 * @param cfg The logging config to be initialized.
429 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000430PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000431
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000432
433/**
434 * Use this function to duplicate logging config.
435 *
436 * @param pool Pool to use.
437 * @param dst Destination config.
438 * @param src Source config.
439 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000440PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool,
441 pjsua_logging_config *dst,
442 const pjsua_logging_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000443
Benny Prijonodc39fe82006-05-26 12:17:46 +0000444
445/**
Benny Prijono4dd961b2009-10-26 11:21:37 +0000446 * Structure to be passed on MWI callback.
447 */
448typedef struct pjsua_mwi_info
449{
450 pjsip_evsub *evsub; /**< Event subscription session, for
451 reference. */
452 pjsip_rx_data *rdata; /**< The received NOTIFY request. */
453} pjsua_mwi_info;
454
455
456/**
Nanang Izzuddin4ea1bcc2010-09-28 04:57:01 +0000457 * Structure to be passed on registration callback.
458 */
459typedef struct pjsua_reg_info
460{
461 struct pjsip_regc_cbparam *cbparam; /**< Parameters returned by
462 registration callback. */
463} pjsua_reg_info;
464
465
466/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000467 * This structure describes application callback to receive various event
468 * notification from PJSUA-API. All of these callbacks are OPTIONAL,
469 * although definitely application would want to implement some of
470 * the important callbacks (such as \a on_incoming_call).
Benny Prijonodc39fe82006-05-26 12:17:46 +0000471 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000472typedef struct pjsua_callback
Benny Prijonodc39fe82006-05-26 12:17:46 +0000473{
474 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000475 * Notify application when invite state has changed.
476 * Application may then query the call info to get the
Benny Prijonoe6ead542007-01-31 20:53:31 +0000477 * detail call states by calling pjsua_call_get_info() function.
Benny Prijono0875ae82006-12-26 00:11:48 +0000478 *
479 * @param call_id The call index.
480 * @param e Event which causes the call state to change.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000481 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000482 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000483
484 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000485 * Notify application on incoming call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000486 *
487 * @param acc_id The account which match the incoming call.
488 * @param call_id The call id that has just been created for
489 * the call.
490 * @param rdata The incoming INVITE request.
Benny Prijono8b1889b2006-06-06 18:40:40 +0000491 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000492 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000493 pjsip_rx_data *rdata);
494
495 /**
Benny Prijonofeb69f42007-10-05 09:12:26 +0000496 * This is a general notification callback which is called whenever
497 * a transaction within the call has changed state. Application can
498 * implement this callback for example to monitor the state of
499 * outgoing requests, or to answer unhandled incoming requests
500 * (such as INFO) with a final response.
501 *
502 * @param call_id Call identification.
503 * @param tsx The transaction which has changed state.
504 * @param e Transaction event that caused the state change.
505 */
506 void (*on_call_tsx_state)(pjsua_call_id call_id,
507 pjsip_transaction *tsx,
508 pjsip_event *e);
509
510 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000511 * Notify application when media state in the call has changed.
512 * Normal application would need to implement this callback, e.g.
Benny Prijono6ba8c542007-10-16 01:34:14 +0000513 * to connect the call's media to sound device. When ICE is used,
514 * this callback will also be called to report ICE negotiation
515 * failure.
Benny Prijono0875ae82006-12-26 00:11:48 +0000516 *
517 * @param call_id The call index.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000518 */
519 void (*on_call_media_state)(pjsua_call_id call_id);
520
Benny Prijonofc13bf62008-02-20 08:56:15 +0000521
522 /**
523 * Notify application when media session is created and before it is
524 * registered to the conference bridge. Application may return different
525 * media port if it has added media processing port to the stream. This
526 * media port then will be added to the conference bridge instead.
527 *
528 * @param call_id Call identification.
Benny Prijono0bc99a92011-03-17 04:34:43 +0000529 * @param strm Media stream.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000530 * @param stream_idx Stream index in the media session.
531 * @param p_port On input, it specifies the media port of the
532 * stream. Application may modify this pointer to
533 * point to different media port to be registered
534 * to the conference bridge.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000535 */
536 void (*on_stream_created)(pjsua_call_id call_id,
Benny Prijono0bc99a92011-03-17 04:34:43 +0000537 pjmedia_stream *strm,
Benny Prijonofc13bf62008-02-20 08:56:15 +0000538 unsigned stream_idx,
539 pjmedia_port **p_port);
540
541 /**
542 * Notify application when media session has been unregistered from the
543 * conference bridge and about to be destroyed.
544 *
545 * @param call_id Call identification.
Benny Prijono0bc99a92011-03-17 04:34:43 +0000546 * @param strm Media stream.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000547 * @param stream_idx Stream index in the media session.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000548 */
549 void (*on_stream_destroyed)(pjsua_call_id call_id,
Benny Prijono0bc99a92011-03-17 04:34:43 +0000550 pjmedia_stream *strm,
Benny Prijonofc13bf62008-02-20 08:56:15 +0000551 unsigned stream_idx);
552
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000553 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000554 * Notify application upon incoming DTMF digits.
555 *
556 * @param call_id The call index.
557 * @param digit DTMF ASCII digit.
558 */
559 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
560
561 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000562 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000563 * Application can decide to accept/reject transfer request
Benny Prijonoc54dcb32008-04-08 23:33:15 +0000564 * by setting the code (default is 202). When this callback
Benny Prijono9fc735d2006-05-28 14:58:12 +0000565 * is not defined, the default behavior is to accept the
566 * transfer.
Benny Prijono0875ae82006-12-26 00:11:48 +0000567 *
568 * @param call_id The call index.
569 * @param dst The destination where the call will be
570 * transfered to.
571 * @param code Status code to be returned for the call transfer
572 * request. On input, it contains status code 200.
Benny Prijono9fc735d2006-05-28 14:58:12 +0000573 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000574 void (*on_call_transfer_request)(pjsua_call_id call_id,
575 const pj_str_t *dst,
576 pjsip_status_code *code);
577
578 /**
579 * Notify application of the status of previously sent call
580 * transfer request. Application can monitor the status of the
581 * call transfer request, for example to decide whether to
582 * terminate existing call.
583 *
584 * @param call_id Call ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000585 * @param st_code Status progress of the transfer request.
586 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000587 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000588 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000589 * this callback is the final status.
590 * @param p_cont Initially will be set to non-zero, application
591 * can set this to FALSE if it no longer wants
592 * to receie further notification (for example,
593 * after it hangs up the call).
594 */
595 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000596 int st_code,
597 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000598 pj_bool_t final,
599 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000600
601 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000602 * Notify application about incoming INVITE with Replaces header.
603 * Application may reject the request by setting non-2xx code.
604 *
605 * @param call_id The call ID to be replaced.
606 * @param rdata The incoming INVITE request to replace the call.
607 * @param st_code Status code to be set by application. Application
608 * should only return a final status (200-699).
609 * @param st_text Optional status text to be set by application.
610 */
611 void (*on_call_replace_request)(pjsua_call_id call_id,
612 pjsip_rx_data *rdata,
613 int *st_code,
614 pj_str_t *st_text);
615
616 /**
617 * Notify application that an existing call has been replaced with
618 * a new call. This happens when PJSUA-API receives incoming INVITE
619 * request with Replaces header.
620 *
621 * After this callback is called, normally PJSUA-API will disconnect
622 * \a old_call_id and establish \a new_call_id.
623 *
624 * @param old_call_id Existing call which to be replaced with the
625 * new call.
626 * @param new_call_id The new call.
627 * @param rdata The incoming INVITE with Replaces request.
628 */
629 void (*on_call_replaced)(pjsua_call_id old_call_id,
630 pjsua_call_id new_call_id);
631
632
633 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000634 * Notify application when registration status has changed.
635 * Application may then query the account info to get the
636 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000637 *
Nanang Izzuddin4ea1bcc2010-09-28 04:57:01 +0000638 * @param acc_id The account ID.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000639 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000640 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000641
642 /**
Nanang Izzuddin4ea1bcc2010-09-28 04:57:01 +0000643 * Notify application when registration status has changed.
644 * Application may inspect the registration info to get the
645 * registration status details.
646 *
647 * @param acc_id The account ID.
648 * @param info The registration info.
649 */
650 void (*on_reg_state2)(pjsua_acc_id acc_id, pjsua_reg_info *info);
651
652 /**
Benny Prijono63fba012008-07-17 14:19:10 +0000653 * Notification when incoming SUBSCRIBE request is received. Application
654 * may use this callback to authorize the incoming subscribe request
655 * (e.g. ask user permission if the request should be granted).
656 *
657 * If this callback is not implemented, all incoming presence subscription
658 * requests will be accepted.
659 *
660 * If this callback is implemented, application has several choices on
661 * what to do with the incoming request:
662 * - it may reject the request immediately by specifying non-200 class
663 * final response in the \a code argument.
664 * - it may immediately accept the request by specifying 200 as the
665 * \a code argument. This is the default value if application doesn't
666 * set any value to the \a code argument. In this case, the library
667 * will automatically send NOTIFY request upon returning from this
668 * callback.
669 * - it may delay the processing of the request, for example to request
670 * user permission whether to accept or reject the request. In this
671 * case, the application MUST set the \a code argument to 202, and
672 * later calls #pjsua_pres_notify() to accept or reject the
673 * subscription request.
674 *
675 * Any \a code other than 200 and 202 will be treated as 200.
676 *
677 * Application MUST return from this callback immediately (e.g. it must
678 * not block in this callback while waiting for user confirmation).
679 *
680 * @param srv_pres Server presence subscription instance. If
681 * application delays the acceptance of the request,
682 * it will need to specify this object when calling
683 * #pjsua_pres_notify().
684 * @param acc_id Account ID most appropriate for this request.
685 * @param buddy_id ID of the buddy matching the sender of the
686 * request, if any, or PJSUA_INVALID_ID if no
687 * matching buddy is found.
688 * @param from The From URI of the request.
689 * @param rdata The incoming request.
690 * @param code The status code to respond to the request. The
691 * default value is 200. Application may set this
692 * to other final status code to accept or reject
693 * the request.
694 * @param reason The reason phrase to respond to the request.
695 * @param msg_data If the application wants to send additional
696 * headers in the response, it can put it in this
697 * parameter.
698 */
699 void (*on_incoming_subscribe)(pjsua_acc_id acc_id,
700 pjsua_srv_pres *srv_pres,
701 pjsua_buddy_id buddy_id,
702 const pj_str_t *from,
703 pjsip_rx_data *rdata,
704 pjsip_status_code *code,
705 pj_str_t *reason,
706 pjsua_msg_data *msg_data);
707
708 /**
709 * Notification when server side subscription state has changed.
710 * This callback is optional as application normally does not need
711 * to do anything to maintain server side presence subscription.
712 *
713 * @param acc_id The account ID.
714 * @param srv_pres Server presence subscription object.
715 * @param remote_uri Remote URI string.
716 * @param state New subscription state.
717 * @param event PJSIP event that triggers the state change.
718 */
719 void (*on_srv_subscribe_state)(pjsua_acc_id acc_id,
720 pjsua_srv_pres *srv_pres,
721 const pj_str_t *remote_uri,
722 pjsip_evsub_state state,
723 pjsip_event *event);
724
725 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000726 * Notify application when the buddy state has changed.
727 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000728 *
729 * @param buddy_id The buddy id.
Benny Prijono9fc735d2006-05-28 14:58:12 +0000730 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000731 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000732
Benny Prijono63499892010-10-12 12:45:15 +0000733
734 /**
735 * Notify application when the state of client subscription session
736 * associated with a buddy has changed. Application may use this
737 * callback to retrieve more detailed information about the state
738 * changed event.
739 *
740 * @param buddy_id The buddy id.
741 * @param sub Event subscription session.
742 * @param event The event which triggers state change event.
743 */
744 void (*on_buddy_evsub_state)(pjsua_buddy_id buddy_id,
745 pjsip_evsub *sub,
746 pjsip_event *event);
747
Benny Prijono9fc735d2006-05-28 14:58:12 +0000748 /**
749 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000750 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000751 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000752 *
Benny Prijonobbeb3992007-05-21 13:48:35 +0000753 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
754 * passed as one of the argument.
755 *
Benny Prijono0875ae82006-12-26 00:11:48 +0000756 * @param call_id Containts the ID of the call where the IM was
757 * sent, or PJSUA_INVALID_ID if the IM was sent
758 * outside call context.
759 * @param from URI of the sender.
760 * @param to URI of the destination message.
761 * @param contact The Contact URI of the sender, if present.
762 * @param mime_type MIME type of the message.
763 * @param body The message content.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000764 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000765 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
766 const pj_str_t *to, const pj_str_t *contact,
767 const pj_str_t *mime_type, const pj_str_t *body);
768
769 /**
Benny Prijonobbeb3992007-05-21 13:48:35 +0000770 * This is the alternative version of the \a on_pager() callback with
771 * \a pjsip_rx_data argument.
772 *
773 * @param call_id Containts the ID of the call where the IM was
774 * sent, or PJSUA_INVALID_ID if the IM was sent
775 * outside call context.
776 * @param from URI of the sender.
777 * @param to URI of the destination message.
778 * @param contact The Contact URI of the sender, if present.
779 * @param mime_type MIME type of the message.
780 * @param body The message content.
781 * @param rdata The incoming MESSAGE request.
Benny Prijonoba736c42008-07-10 20:45:03 +0000782 * @param acc_id Account ID most suitable for this message.
Benny Prijonobbeb3992007-05-21 13:48:35 +0000783 */
784 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
785 const pj_str_t *to, const pj_str_t *contact,
786 const pj_str_t *mime_type, const pj_str_t *body,
Benny Prijonoba736c42008-07-10 20:45:03 +0000787 pjsip_rx_data *rdata, pjsua_acc_id acc_id);
Benny Prijonobbeb3992007-05-21 13:48:35 +0000788
789 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000790 * Notify application about the delivery status of outgoing pager
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000791 * request. See also on_pager_status2() callback for the version with
792 * \a pjsip_rx_data in the argument list.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000793 *
794 * @param call_id Containts the ID of the call where the IM was
795 * sent, or PJSUA_INVALID_ID if the IM was sent
796 * outside call context.
797 * @param to Destination URI.
798 * @param body Message body.
799 * @param user_data Arbitrary data that was specified when sending
800 * IM message.
801 * @param status Delivery status.
802 * @param reason Delivery status reason.
803 */
804 void (*on_pager_status)(pjsua_call_id call_id,
805 const pj_str_t *to,
806 const pj_str_t *body,
807 void *user_data,
808 pjsip_status_code status,
809 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000810
811 /**
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000812 * Notify application about the delivery status of outgoing pager
813 * request.
814 *
815 * @param call_id Containts the ID of the call where the IM was
816 * sent, or PJSUA_INVALID_ID if the IM was sent
817 * outside call context.
818 * @param to Destination URI.
819 * @param body Message body.
820 * @param user_data Arbitrary data that was specified when sending
821 * IM message.
822 * @param status Delivery status.
823 * @param reason Delivery status reason.
Benny Prijono0a982002007-06-12 16:22:09 +0000824 * @param tdata The original MESSAGE request.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000825 * @param rdata The incoming MESSAGE response, or NULL if the
826 * message transaction fails because of time out
827 * or transport error.
Benny Prijonoba736c42008-07-10 20:45:03 +0000828 * @param acc_id Account ID from this the instant message was
829 * send.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000830 */
831 void (*on_pager_status2)(pjsua_call_id call_id,
832 const pj_str_t *to,
833 const pj_str_t *body,
834 void *user_data,
835 pjsip_status_code status,
836 const pj_str_t *reason,
Benny Prijono0a982002007-06-12 16:22:09 +0000837 pjsip_tx_data *tdata,
Benny Prijonoba736c42008-07-10 20:45:03 +0000838 pjsip_rx_data *rdata,
839 pjsua_acc_id acc_id);
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000840
841 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000842 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +0000843 *
844 * @param call_id Containts the ID of the call where the IM was
845 * sent, or PJSUA_INVALID_ID if the IM was sent
846 * outside call context.
847 * @param from URI of the sender.
848 * @param to URI of the destination message.
849 * @param contact The Contact URI of the sender, if present.
850 * @param is_typing Non-zero if peer is typing, or zero if peer
851 * has stopped typing a message.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000852 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000853 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
854 const pj_str_t *to, const pj_str_t *contact,
855 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000856
Benny Prijono6ba8c542007-10-16 01:34:14 +0000857 /**
Benny Prijonoba736c42008-07-10 20:45:03 +0000858 * Notify application about typing indication.
859 *
860 * @param call_id Containts the ID of the call where the IM was
861 * sent, or PJSUA_INVALID_ID if the IM was sent
862 * outside call context.
863 * @param from URI of the sender.
864 * @param to URI of the destination message.
865 * @param contact The Contact URI of the sender, if present.
866 * @param is_typing Non-zero if peer is typing, or zero if peer
867 * has stopped typing a message.
868 * @param rdata The received request.
869 * @param acc_id Account ID most suitable for this message.
870 */
871 void (*on_typing2)(pjsua_call_id call_id, const pj_str_t *from,
872 const pj_str_t *to, const pj_str_t *contact,
873 pj_bool_t is_typing, pjsip_rx_data *rdata,
874 pjsua_acc_id acc_id);
875
876 /**
Benny Prijono6ba8c542007-10-16 01:34:14 +0000877 * Callback when the library has finished performing NAT type
878 * detection.
879 *
880 * @param res NAT detection result.
881 */
882 void (*on_nat_detect)(const pj_stun_nat_detect_result *res);
883
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000884 /**
885 * This callback is called when the call is about to resend the
886 * INVITE request to the specified target, following the previously
887 * received redirection response.
888 *
889 * Application may accept the redirection to the specified target
890 * (the default behavior if this callback is implemented), reject
891 * this target only and make the session continue to try the next
892 * target in the list if such target exists, stop the whole
893 * redirection process altogether and cause the session to be
894 * disconnected, or defer the decision to ask for user confirmation.
895 *
896 * This callback is optional. If this callback is not implemented,
897 * the default behavior is to NOT follow the redirection response.
898 *
899 * @param call_id The call ID.
900 * @param target The current target to be tried.
Benny Prijono08a48b82008-11-27 12:42:07 +0000901 * @param e The event that caused this callback to be called.
902 * This could be the receipt of 3xx response, or
903 * 4xx/5xx response received for the INVITE sent to
904 * subsequent targets, or NULL if this callback is
905 * called from within #pjsua_call_process_redirect()
906 * context.
907 *
908 * @return Action to be performed for the target. Set this
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000909 * parameter to one of the value below:
910 * - PJSIP_REDIRECT_ACCEPT: immediately accept the
911 * redirection (default value). When set, the
912 * call will immediately resend INVITE request
913 * to the target.
914 * - PJSIP_REDIRECT_REJECT: immediately reject this
915 * target. The call will continue retrying with
916 * next target if present, or disconnect the call
917 * if there is no more target to try.
918 * - PJSIP_REDIRECT_STOP: stop the whole redirection
919 * process and immediately disconnect the call. The
920 * on_call_state() callback will be called with
921 * PJSIP_INV_STATE_DISCONNECTED state immediately
922 * after this callback returns.
923 * - PJSIP_REDIRECT_PENDING: set to this value if
924 * no decision can be made immediately (for example
925 * to request confirmation from user). Application
926 * then MUST call #pjsua_call_process_redirect()
927 * to either accept or reject the redirection upon
928 * getting user decision.
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000929 */
Benny Prijono08a48b82008-11-27 12:42:07 +0000930 pjsip_redirect_op (*on_call_redirected)(pjsua_call_id call_id,
931 const pjsip_uri *target,
932 const pjsip_event *e);
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000933
Benny Prijono4dd961b2009-10-26 11:21:37 +0000934 /**
935 * This callback is called when a NOTIFY request for message summary /
936 * message waiting indication is received.
937 *
938 * @param acc_id The account ID.
939 * @param mwi_info Structure containing details of the event,
940 * including the received NOTIFY request in the
941 * \a rdata field.
942 */
943 void (*on_mwi_info)(pjsua_acc_id acc_id, pjsua_mwi_info *mwi_info);
944
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +0000945 /**
946 * This callback is called when transport state is changed. See also
947 * #pjsip_tp_state_callback.
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +0000948 */
Nanang Izzuddin5e69da52010-02-25 11:58:19 +0000949 pjsip_tp_state_callback on_transport_state;
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +0000950
Benny Prijono4d6ff4d2010-06-19 12:35:33 +0000951 /**
952 * This callback is called to report error in ICE media transport.
953 * Currently it is used to report TURN Refresh error.
954 *
955 * @param index Transport index.
956 * @param op Operation which trigger the failure.
957 * @param status Error status.
958 * @param param Additional info about the event. Currently this will
959 * always be set to NULL.
960 */
961 void (*on_ice_transport_error)(int index, pj_ice_strans_op op,
962 pj_status_t status, void *param);
963
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000964} pjsua_callback;
965
966
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +0000967/**
968 * This enumeration specifies the usage of SIP Session Timers extension.
969 */
970typedef enum pjsua_sip_timer_use
971{
972 /**
973 * When this flag is specified, Session Timers will not be used in any
974 * session, except it is explicitly required in the remote request.
975 */
976 PJSUA_SIP_TIMER_INACTIVE,
977
978 /**
979 * When this flag is specified, Session Timers will be used in all
980 * sessions whenever remote supports and uses it.
981 */
982 PJSUA_SIP_TIMER_OPTIONAL,
983
984 /**
985 * When this flag is specified, Session Timers support will be
986 * a requirement for the remote to be able to establish a session.
987 */
988 PJSUA_SIP_TIMER_REQUIRED,
989
990 /**
991 * When this flag is specified, Session Timers will always be used
992 * in all sessions, regardless whether remote supports/uses it or not.
993 */
994 PJSUA_SIP_TIMER_ALWAYS
995
996} pjsua_sip_timer_use;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000997
Benny Prijonodc39fe82006-05-26 12:17:46 +0000998
999/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001000 * This structure describes the settings to control the API and
1001 * user agent behavior, and can be specified when calling #pjsua_init().
1002 * Before setting the values, application must call #pjsua_config_default()
1003 * to initialize this structure with the default values.
Benny Prijonodc39fe82006-05-26 12:17:46 +00001004 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001005typedef struct pjsua_config
1006{
1007
1008 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001009 * Maximum calls to support (default: 4). The value specified here
1010 * must be smaller than the compile time maximum settings
1011 * PJSUA_MAX_CALLS, which by default is 32. To increase this
1012 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
1013 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001014 */
1015 unsigned max_calls;
1016
1017 /**
1018 * Number of worker threads. Normally application will want to have at
1019 * least one worker thread, unless when it wants to poll the library
1020 * periodically, which in this case the worker thread can be set to
1021 * zero.
1022 */
1023 unsigned thread_cnt;
1024
1025 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +00001026 * Number of nameservers. If no name server is configured, the SIP SRV
1027 * resolution would be disabled, and domain will be resolved with
1028 * standard pj_gethostbyname() function.
1029 */
1030 unsigned nameserver_count;
1031
1032 /**
1033 * Array of nameservers to be used by the SIP resolver subsystem.
1034 * The order of the name server specifies the priority (first name
1035 * server will be used first, unless it is not reachable).
1036 */
1037 pj_str_t nameserver[4];
1038
1039 /**
Benny Prijono91d06b62008-09-20 12:16:56 +00001040 * Force loose-route to be used in all route/proxy URIs (outbound_proxy
1041 * and account's proxy settings). When this setting is enabled, the
1042 * library will check all the route/proxy URIs specified in the settings
1043 * and append ";lr" parameter to the URI if the parameter is not present.
1044 *
1045 * Default: 1
1046 */
1047 pj_bool_t force_lr;
1048
1049 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001050 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001051 */
1052 unsigned outbound_proxy_cnt;
1053
1054 /**
1055 * Specify the URL of outbound proxies to visit for all outgoing requests.
1056 * The outbound proxies will be used for all accounts, and it will
1057 * be used to build the route set for outgoing requests. The final
1058 * route set for outgoing requests will consists of the outbound proxies
1059 * and the proxy configured in the account.
1060 */
1061 pj_str_t outbound_proxy[4];
1062
Benny Prijonoc97608e2007-03-23 16:34:20 +00001063 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001064 * Warning: deprecated, please use \a stun_srv field instead. To maintain
1065 * backward compatibility, if \a stun_srv_cnt is zero then the value of
1066 * this field will be copied to \a stun_srv field, if present.
1067 *
Benny Prijonoebbf6892007-03-24 17:37:25 +00001068 * Specify domain name to be resolved with DNS SRV resolution to get the
Benny Prijonof76e1392008-06-06 14:51:48 +00001069 * address of the STUN server. Alternatively application may specify
1070 * \a stun_host instead.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001071 *
1072 * If DNS SRV resolution failed for this domain, then DNS A resolution
1073 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +00001074 */
Benny Prijonoebbf6892007-03-24 17:37:25 +00001075 pj_str_t stun_domain;
1076
1077 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001078 * Warning: deprecated, please use \a stun_srv field instead. To maintain
1079 * backward compatibility, if \a stun_srv_cnt is zero then the value of
1080 * this field will be copied to \a stun_srv field, if present.
1081 *
Benny Prijonoaf09dc32007-04-22 12:48:30 +00001082 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
1083 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001084 */
1085 pj_str_t stun_host;
1086
1087 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001088 * Number of STUN server entries in \a stun_srv array.
1089 */
1090 unsigned stun_srv_cnt;
1091
1092 /**
1093 * Array of STUN servers to try. The library will try to resolve and
1094 * contact each of the STUN server entry until it finds one that is
1095 * usable. Each entry may be a domain name, host name, IP address, and
1096 * it may contain an optional port number. For example:
1097 * - "pjsip.org" (domain name)
1098 * - "sip.pjsip.org" (host name)
1099 * - "pjsip.org:33478" (domain name and a non-standard port number)
1100 * - "10.0.0.1:3478" (IP address and port number)
1101 *
1102 * When nameserver is configured in the \a pjsua_config.nameserver field,
1103 * if entry is not an IP address, it will be resolved with DNS SRV
1104 * resolution first, and it will fallback to use DNS A resolution if this
1105 * fails. Port number may be specified even if the entry is a domain name,
1106 * in case the DNS SRV resolution should fallback to a non-standard port.
1107 *
1108 * When nameserver is not configured, entries will be resolved with
1109 * #pj_gethostbyname() if it's not an IP address. Port number may be
1110 * specified if the server is not listening in standard STUN port.
1111 */
1112 pj_str_t stun_srv[8];
1113
1114 /**
1115 * This specifies if the library startup should ignore failure with the
1116 * STUN servers. If this is set to PJ_FALSE, the library will refuse to
1117 * start if it fails to resolve or contact any of the STUN servers.
1118 *
1119 * Default: PJ_TRUE
1120 */
1121 pj_bool_t stun_ignore_failure;
1122
1123 /**
Benny Prijono91a6a172007-10-31 08:59:29 +00001124 * Support for adding and parsing NAT type in the SDP to assist
1125 * troubleshooting. The valid values are:
1126 * - 0: no information will be added in SDP, and parsing is disabled.
Benny Prijono6ba8c542007-10-16 01:34:14 +00001127 * - 1: only the NAT type number is added.
1128 * - 2: add both NAT type number and name.
1129 *
Benny Prijono91a6a172007-10-31 08:59:29 +00001130 * Default: 1
Benny Prijono6ba8c542007-10-16 01:34:14 +00001131 */
1132 int nat_type_in_sdp;
1133
1134 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001135 * Specify whether support for reliable provisional response (100rel and
1136 * PRACK) should be required by default. Note that this setting can be
1137 * further customized in account configuration (#pjsua_acc_config).
1138 *
1139 * Default: PJ_FALSE
1140 */
1141 pj_bool_t require_100rel;
1142
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001143 /**
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001144 * Specify the usage of Session Timers for all sessions. See the
1145 * #pjsua_sip_timer_use for possible values. Note that this setting can be
1146 * further customized in account configuration (#pjsua_acc_config).
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001147 *
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001148 * Default: PJSUA_SIP_TIMER_OPTIONAL
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001149 */
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001150 pjsua_sip_timer_use use_timer;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001151
1152 /**
Benny Prijonofe1bd342009-11-20 23:33:07 +00001153 * Handle unsolicited NOTIFY requests containing message waiting
1154 * indication (MWI) info. Unsolicited MWI is incoming NOTIFY requests
1155 * which are not requested by client with SUBSCRIBE request.
1156 *
1157 * If this is enabled, the library will respond 200/OK to the NOTIFY
1158 * request and forward the request to \a on_mwi_info() callback.
1159 *
1160 * See also \a mwi_enabled field #on pjsua_acc_config.
1161 *
1162 * Default: PJ_TRUE
1163 *
1164 */
1165 pj_bool_t enable_unsolicited_mwi;
1166
1167 /**
Nanang Izzuddin65add622009-08-11 16:26:20 +00001168 * Specify Session Timer settings, see #pjsip_timer_setting.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001169 * Note that this setting can be further customized in account
1170 * configuration (#pjsua_acc_config).
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001171 */
Nanang Izzuddin65add622009-08-11 16:26:20 +00001172 pjsip_timer_setting timer_setting;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001173
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001174 /**
1175 * Number of credentials in the credential array.
1176 */
1177 unsigned cred_count;
1178
1179 /**
1180 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +00001181 * and can be used to authenticate against outbound proxies. If the
1182 * credential is specific to the account, then application should set
1183 * the credential in the pjsua_acc_config rather than the credential
1184 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001185 */
1186 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1187
1188 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001189 * Application callback to receive various event notifications from
1190 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001191 */
1192 pjsua_callback cb;
1193
Benny Prijono56315612006-07-18 14:39:40 +00001194 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001195 * Optional user agent string (default empty). If it's empty, no
1196 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +00001197 */
1198 pj_str_t user_agent;
1199
Benny Prijonod8179652008-01-23 20:39:07 +00001200 /**
1201 * Specify default value of secure media transport usage.
1202 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
1203 * PJMEDIA_SRTP_MANDATORY.
1204 *
1205 * Note that this setting can be further customized in account
1206 * configuration (#pjsua_acc_config).
1207 *
1208 * Default: #PJSUA_DEFAULT_USE_SRTP
1209 */
1210 pjmedia_srtp_use use_srtp;
1211
1212 /**
1213 * Specify whether SRTP requires secure signaling to be used. This option
1214 * is only used when \a use_srtp option above is non-zero.
1215 *
1216 * Valid values are:
1217 * 0: SRTP does not require secure signaling
1218 * 1: SRTP requires secure transport such as TLS
1219 * 2: SRTP requires secure end-to-end transport (SIPS)
1220 *
1221 * Note that this setting can be further customized in account
1222 * configuration (#pjsua_acc_config).
1223 *
1224 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
1225 */
1226 int srtp_secure_signaling;
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00001227
1228 /**
Benny Prijono0bc99a92011-03-17 04:34:43 +00001229 * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00001230 * duplicated media in SDP offer, i.e: unsecured and secured version.
Benny Prijono0bc99a92011-03-17 04:34:43 +00001231 * Otherwise, the SDP media will be composed as unsecured media but
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00001232 * with SDP "crypto" attribute.
1233 *
1234 * Default: PJ_FALSE
1235 */
1236 pj_bool_t srtp_optional_dup_offer;
Benny Prijonod8179652008-01-23 20:39:07 +00001237
Benny Prijono3c5e28b2008-09-24 10:10:15 +00001238 /**
1239 * Disconnect other call legs when more than one 2xx responses for
1240 * outgoing INVITE are received due to forking. Currently the library
1241 * is not able to handle simultaneous forked media, so disconnecting
1242 * the other call legs is necessary.
1243 *
1244 * With this setting enabled, the library will handle only one of the
1245 * connected call leg, and the other connected call legs will be
1246 * disconnected.
1247 *
1248 * Default: PJ_TRUE (only disable this setting for testing purposes).
1249 */
1250 pj_bool_t hangup_forked_call;
1251
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001252} pjsua_config;
1253
1254
1255/**
1256 * Use this function to initialize pjsua config.
1257 *
1258 * @param cfg pjsua config to be initialized.
1259 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001260PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001261
1262
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001263/** The implementation has been moved to sip_auth.h */
Benny Prijono7977f9f2007-10-10 11:37:56 +00001264#define pjsip_cred_dup pjsip_cred_info_dup
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001265
1266
1267/**
1268 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001269 *
1270 * @param pool The pool to get memory from.
1271 * @param dst Destination config.
1272 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001273 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001274PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1275 pjsua_config *dst,
1276 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001277
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001278
1279/**
1280 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001281 * outgoing SIP message. It can (optionally) be specified for example
1282 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1283 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1284 *
1285 * Application MUST call #pjsua_msg_data_init() to initialize this
1286 * structure before setting its values.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001287 */
Benny Prijono63fba012008-07-17 14:19:10 +00001288struct pjsua_msg_data
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001289{
1290 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001291 * Additional message headers as linked list. Application can add
1292 * headers to the list by creating the header, either from the heap/pool
1293 * or from temporary local variable, and add the header using
1294 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001295 */
1296 pjsip_hdr hdr_list;
1297
1298 /**
1299 * MIME type of optional message body.
1300 */
1301 pj_str_t content_type;
1302
1303 /**
Benny Prijono1c1d7342010-08-01 09:48:51 +00001304 * Optional message body to be added to the message, only when the
1305 * message doesn't have a body.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001306 */
1307 pj_str_t msg_body;
1308
Benny Prijono1c1d7342010-08-01 09:48:51 +00001309 /**
1310 * Content type of the multipart body. If application wants to send
1311 * multipart message bodies, it puts the parts in \a parts and set
1312 * the content type in \a multipart_ctype. If the message already
1313 * contains a body, the body will be added to the multipart bodies.
1314 */
1315 pjsip_media_type multipart_ctype;
1316
1317 /**
1318 * List of multipart parts. If application wants to send multipart
1319 * message bodies, it puts the parts in \a parts and set the content
1320 * type in \a multipart_ctype. If the message already contains a body,
1321 * the body will be added to the multipart bodies.
1322 */
1323 pjsip_multipart_part multipart_parts;
Benny Prijono63fba012008-07-17 14:19:10 +00001324};
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001325
1326
1327/**
1328 * Initialize message data.
1329 *
1330 * @param msg_data Message data to be initialized.
1331 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001332PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001333
Benny Prijono268ca612006-02-07 12:34:11 +00001334
1335/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001336 * Instantiate pjsua application. Application must call this function before
1337 * calling any other functions, to make sure that the underlying libraries
1338 * are properly initialized. Once this function has returned success,
1339 * application must call pjsua_destroy() before quitting.
1340 *
1341 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00001342 */
1343PJ_DECL(pj_status_t) pjsua_create(void);
1344
1345
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001346/** Forward declaration */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001347typedef struct pjsua_media_config pjsua_media_config;
1348
1349
Benny Prijonodc39fe82006-05-26 12:17:46 +00001350/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001351 * Initialize pjsua with the specified settings. All the settings are
1352 * optional, and the default values will be used when the config is not
1353 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001354 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001355 * Note that #pjsua_create() MUST be called before calling this function.
1356 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001357 * @param ua_cfg User agent configuration.
1358 * @param log_cfg Optional logging configuration.
1359 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001360 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001361 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001362 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001363PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1364 const pjsua_logging_config *log_cfg,
1365 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001366
1367
1368/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001369 * Application is recommended to call this function after all initialization
1370 * is done, so that the library can do additional checking set up
1371 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001372 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001373 * Application may call this function anytime after #pjsua_init().
1374 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001375 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoccf95622006-02-07 18:48:01 +00001376 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001377PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001378
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001379
Benny Prijonoccf95622006-02-07 18:48:01 +00001380/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001381 * Destroy pjsua. Application is recommended to perform graceful shutdown
1382 * before calling this function (such as unregister the account from the SIP
1383 * server, terminate presense subscription, and hangup active calls), however,
1384 * this function will do all of these if it finds there are active sessions
1385 * that need to be terminated. This function will approximately block for
1386 * one second to wait for replies from remote.
1387 *
1388 * Application.may safely call this function more than once if it doesn't
1389 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001390 *
1391 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001392 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001393PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001394
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001395
Benny Prijono9fc735d2006-05-28 14:58:12 +00001396/**
Benny Prijono0bc99a92011-03-17 04:34:43 +00001397 * Retrieve pjsua state.
1398 *
1399 * @return pjsua state.
1400 */
1401PJ_DECL(pjsua_state) pjsua_get_state(void);
1402
1403
1404/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001405 * Poll pjsua for events, and if necessary block the caller thread for
1406 * the specified maximum interval (in miliseconds).
1407 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001408 * Application doesn't normally need to call this function if it has
1409 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1410 * because polling then will be done by these worker threads instead.
1411 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001412 * @param msec_timeout Maximum time to wait, in miliseconds.
1413 *
1414 * @return The number of events that have been handled during the
1415 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001416 * can retrieve the error as (status = -return_value).
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001417 */
1418PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1419
1420
1421/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001422 * Create memory pool to be used by the application. Once application
1423 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001424 *
1425 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001426 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001427 * @param increment Increment size.
1428 *
1429 * @return The pool, or NULL when there's no memory.
1430 */
1431PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1432 pj_size_t increment);
1433
1434
1435/**
1436 * Application can call this function at any time (after pjsua_create(), of
1437 * course) to change logging settings.
1438 *
1439 * @param c Logging configuration.
1440 *
1441 * @return PJ_SUCCESS on success, or the appropriate error code.
1442 */
1443PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1444
1445
1446/**
1447 * Internal function to get SIP endpoint instance of pjsua, which is
1448 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001449 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001450 *
1451 * @return SIP endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001452 */
1453PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1454
1455/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001456 * Internal function to get media endpoint instance.
1457 * Only valid after #pjsua_init() is called.
1458 *
1459 * @return Media endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001460 */
1461PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1462
Benny Prijono97b87172006-08-24 14:25:14 +00001463/**
1464 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001465 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001466 *
1467 * @return Pool factory currently used by PJSUA.
1468 */
1469PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1470
1471
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001472
1473/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001474 * Utilities.
1475 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001476 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001477
1478/**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001479 * This structure is used to represent the result of the STUN server
1480 * resolution and testing, the #pjsua_resolve_stun_servers() function.
1481 * This structure will be passed in #pj_stun_resolve_cb callback.
1482 */
1483typedef struct pj_stun_resolve_result
1484{
1485 /**
1486 * Arbitrary data that was passed to #pjsua_resolve_stun_servers()
1487 * function.
1488 */
1489 void *token;
1490
1491 /**
1492 * This will contain PJ_SUCCESS if at least one usable STUN server
1493 * is found, otherwise it will contain the last error code during
1494 * the operation.
1495 */
1496 pj_status_t status;
1497
1498 /**
1499 * The server name that yields successful result. This will only
1500 * contain value if status is successful.
1501 */
1502 pj_str_t name;
1503
1504 /**
1505 * The server IP address. This will only contain value if status
1506 * is successful.
1507 */
1508 pj_sockaddr addr;
1509
1510} pj_stun_resolve_result;
1511
1512
1513/**
1514 * Typedef of callback to be registered to #pjsua_resolve_stun_servers().
1515 */
1516typedef void (*pj_stun_resolve_cb)(const pj_stun_resolve_result *result);
1517
1518/**
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001519 * This is a utility function to detect NAT type in front of this
1520 * endpoint. Once invoked successfully, this function will complete
Benny Prijono6ba8c542007-10-16 01:34:14 +00001521 * asynchronously and report the result in \a on_nat_detect() callback
1522 * of pjsua_callback.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001523 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001524 * After NAT has been detected and the callback is called, application can
1525 * get the detected NAT type by calling #pjsua_get_nat_type(). Application
1526 * can also perform NAT detection by calling #pjsua_detect_nat_type()
1527 * again at later time.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001528 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001529 * Note that STUN must be enabled to run this function successfully.
1530 *
1531 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001532 */
Benny Prijono6ba8c542007-10-16 01:34:14 +00001533PJ_DECL(pj_status_t) pjsua_detect_nat_type(void);
1534
1535
1536/**
1537 * Get the NAT type as detected by #pjsua_detect_nat_type() function.
1538 * This function will only return useful NAT type after #pjsua_detect_nat_type()
1539 * has completed successfully and \a on_nat_detect() callback has been called.
1540 *
1541 * @param type NAT type.
1542 *
1543 * @return When detection is in progress, this function will
1544 * return PJ_EPENDING and \a type will be set to
1545 * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been
1546 * detected successfully, this function will return
1547 * PJ_SUCCESS and \a type will be set to the correct
1548 * value. Other return values indicate error and
1549 * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN.
Benny Prijono91a6a172007-10-31 08:59:29 +00001550 *
1551 * @see pjsua_call_get_rem_nat_type()
Benny Prijono6ba8c542007-10-16 01:34:14 +00001552 */
1553PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type);
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001554
1555
1556/**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001557 * Auxiliary function to resolve and contact each of the STUN server
1558 * entries (sequentially) to find which is usable. The #pjsua_init() must
1559 * have been called before calling this function.
1560 *
1561 * @param count Number of STUN server entries to try.
1562 * @param srv Array of STUN server entries to try. Please see
1563 * the \a stun_srv field in the #pjsua_config
1564 * documentation about the format of this entry.
1565 * @param wait Specify non-zero to make the function block until
1566 * it gets the result. In this case, the function
1567 * will block while the resolution is being done,
1568 * and the callback will be called before this function
1569 * returns.
1570 * @param token Arbitrary token to be passed back to application
1571 * in the callback.
1572 * @param cb Callback to be called to notify the result of
1573 * the function.
1574 *
1575 * @return If \a wait parameter is non-zero, this will return
1576 * PJ_SUCCESS if one usable STUN server is found.
1577 * Otherwise it will always return PJ_SUCCESS, and
1578 * application will be notified about the result in
1579 * the callback.
1580 */
1581PJ_DECL(pj_status_t) pjsua_resolve_stun_servers(unsigned count,
1582 pj_str_t srv[],
1583 pj_bool_t wait,
1584 void *token,
1585 pj_stun_resolve_cb cb);
1586
1587/**
1588 * Cancel pending STUN resolution which match the specified token.
1589 *
1590 * @param token The token to match. This token was given to
1591 * #pjsua_resolve_stun_servers()
1592 * @param notify_cb Boolean to control whether the callback should
1593 * be called for cancelled resolutions. When the
1594 * callback is called, the status in the result
1595 * will be set as PJ_ECANCELLED.
1596 *
1597 * @return PJ_SUCCESS if there is at least one pending STUN
1598 * resolution cancelled, or PJ_ENOTFOUND if there is
1599 * no matching one, or other error.
1600 */
1601PJ_DECL(pj_status_t) pjsua_cancel_stun_resolution(void *token,
1602 pj_bool_t notify_cb);
1603
1604
1605/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001606 * This is a utility function to verify that valid SIP url is given. If the
Benny Prijonoc7545782010-09-28 07:43:18 +00001607 * URL is a valid SIP/SIPS scheme, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001608 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001609 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001610 *
1611 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoc7545782010-09-28 07:43:18 +00001612 *
1613 * @see pjsua_verify_url()
Benny Prijono312aff92006-06-17 04:08:30 +00001614 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001615PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001616
1617
1618/**
Benny Prijonoc7545782010-09-28 07:43:18 +00001619 * This is a utility function to verify that valid URI is given. Unlike
1620 * pjsua_verify_sip_url(), this function will return PJ_SUCCESS if tel: URI
1621 * is given.
1622 *
1623 * @param url The URL, as NULL terminated string.
1624 *
1625 * @return PJ_SUCCESS on success, or the appropriate error code.
1626 *
1627 * @see pjsua_verify_sip_url()
1628 */
1629PJ_DECL(pj_status_t) pjsua_verify_url(const char *url);
1630
1631
1632/**
Benny Prijono73bb7232009-10-20 13:56:26 +00001633 * Schedule a timer entry. Note that the timer callback may be executed
1634 * by different thread, depending on whether worker thread is enabled or
1635 * not.
1636 *
1637 * @param entry Timer heap entry.
1638 * @param delay The interval to expire.
1639 *
1640 * @return PJ_SUCCESS on success, or the appropriate error code.
1641 *
1642 * @see pjsip_endpt_schedule_timer()
1643 */
1644PJ_DECL(pj_status_t) pjsua_schedule_timer(pj_timer_entry *entry,
1645 const pj_time_val *delay);
1646
1647
1648/**
1649 * Cancel the previously scheduled timer.
1650 *
1651 * @param entry Timer heap entry.
1652 *
1653 * @see pjsip_endpt_cancel_timer()
1654 */
1655PJ_DECL(void) pjsua_cancel_timer(pj_timer_entry *entry);
1656
1657
1658/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001659 * This is a utility function to display error message for the specified
1660 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001661 *
1662 * @param sender The log sender field.
1663 * @param title Message title for the error.
1664 * @param status Status code.
1665 */
1666PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1667 pj_status_t status);
1668
1669
Benny Prijonoda9785b2007-04-02 20:43:06 +00001670/**
1671 * This is a utility function to dump the stack states to log, using
1672 * verbosity level 3.
1673 *
1674 * @param detail Will print detailed output (such as list of
1675 * SIP transactions) when non-zero.
1676 */
1677PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001678
1679/**
1680 * @}
1681 */
1682
1683
1684
1685/*****************************************************************************
1686 * TRANSPORT API
1687 */
1688
1689/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001690 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001691 * @ingroup PJSUA_LIB
1692 * @brief API for managing SIP transports
1693 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001694 *
1695 * PJSUA-API supports creating multiple transport instances, for example UDP,
1696 * TCP, and TLS transport. SIP transport must be created before adding an
1697 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001698 */
1699
1700
Benny Prijonoe6ead542007-01-31 20:53:31 +00001701/** SIP transport identification.
1702 */
Benny Prijono312aff92006-06-17 04:08:30 +00001703typedef int pjsua_transport_id;
1704
1705
1706/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001707 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001708 * and media. Before setting some values to this structure, application
1709 * MUST call #pjsua_transport_config_default() to initialize its
1710 * values with default settings.
Benny Prijono312aff92006-06-17 04:08:30 +00001711 */
1712typedef struct pjsua_transport_config
1713{
1714 /**
1715 * UDP port number to bind locally. This setting MUST be specified
1716 * even when default port is desired. If the value is zero, the
1717 * transport will be bound to any available port, and application
1718 * can query the port by querying the transport info.
1719 */
1720 unsigned port;
1721
1722 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001723 * Optional address to advertise as the address of this transport.
1724 * Application can specify any address or hostname for this field,
1725 * for example it can point to one of the interface address in the
1726 * system, or it can point to the public address of a NAT router
1727 * where port mappings have been configured for the application.
1728 *
1729 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001730 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001731 pj_str_t public_addr;
1732
1733 /**
1734 * Optional address where the socket should be bound to. This option
1735 * SHOULD only be used to selectively bind the socket to particular
1736 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1737 * published address of a transport (the public_addr field should be
1738 * used for that purpose).
1739 *
1740 * Note that unlike public_addr field, the address (or hostname) here
1741 * MUST correspond to the actual interface address in the host, since
1742 * this address will be specified as bind() argument.
1743 */
1744 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001745
1746 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001747 * This specifies TLS settings for TLS transport. It is only be used
1748 * when this transport config is being used to create a SIP TLS
1749 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001750 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001751 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001752
Benny Prijono4d79b0f2009-10-25 09:02:07 +00001753 /**
1754 * QoS traffic type to be set on this transport. When application wants
1755 * to apply QoS tagging to the transport, it's preferable to set this
1756 * field rather than \a qos_param fields since this is more portable.
1757 *
1758 * Default is QoS not set.
1759 */
1760 pj_qos_type qos_type;
1761
1762 /**
1763 * Set the low level QoS parameters to the transport. This is a lower
1764 * level operation than setting the \a qos_type field and may not be
1765 * supported on all platforms.
1766 *
1767 * Default is QoS not set.
1768 */
1769 pj_qos_params qos_params;
1770
Benny Prijono312aff92006-06-17 04:08:30 +00001771} pjsua_transport_config;
1772
1773
1774/**
1775 * Call this function to initialize UDP config with default values.
1776 *
1777 * @param cfg The UDP config to be initialized.
1778 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001779PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001780
1781
1782/**
Benny Prijono312aff92006-06-17 04:08:30 +00001783 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001784 *
1785 * @param pool The pool.
1786 * @param dst The destination config.
1787 * @param src The source config.
Benny Prijono312aff92006-06-17 04:08:30 +00001788 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001789PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1790 pjsua_transport_config *dst,
1791 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001792
1793
1794/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001795 * This structure describes transport information returned by
1796 * #pjsua_transport_get_info() function.
Benny Prijono312aff92006-06-17 04:08:30 +00001797 */
1798typedef struct pjsua_transport_info
1799{
1800 /**
1801 * PJSUA transport identification.
1802 */
1803 pjsua_transport_id id;
1804
1805 /**
1806 * Transport type.
1807 */
1808 pjsip_transport_type_e type;
1809
1810 /**
1811 * Transport type name.
1812 */
1813 pj_str_t type_name;
1814
1815 /**
1816 * Transport string info/description.
1817 */
1818 pj_str_t info;
1819
1820 /**
1821 * Transport flag (see ##pjsip_transport_flags_e).
1822 */
1823 unsigned flag;
1824
1825 /**
1826 * Local address length.
1827 */
1828 unsigned addr_len;
1829
1830 /**
1831 * Local/bound address.
1832 */
1833 pj_sockaddr local_addr;
1834
1835 /**
1836 * Published address (or transport address name).
1837 */
1838 pjsip_host_port local_name;
1839
1840 /**
1841 * Current number of objects currently referencing this transport.
1842 */
1843 unsigned usage_count;
1844
1845
1846} pjsua_transport_info;
1847
1848
1849/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001850 * Create and start a new SIP transport according to the specified
1851 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001852 *
1853 * @param type Transport type.
1854 * @param cfg Transport configuration.
1855 * @param p_id Optional pointer to receive transport ID.
1856 *
1857 * @return PJ_SUCCESS on success, or the appropriate error code.
1858 */
1859PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1860 const pjsua_transport_config *cfg,
1861 pjsua_transport_id *p_id);
1862
1863/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001864 * Register transport that has been created by application. This function
1865 * is useful if application wants to implement custom SIP transport and use
1866 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001867 *
1868 * @param tp Transport instance.
1869 * @param p_id Optional pointer to receive transport ID.
1870 *
1871 * @return PJ_SUCCESS on success, or the appropriate error code.
1872 */
1873PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1874 pjsua_transport_id *p_id);
1875
1876
1877/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001878 * Enumerate all transports currently created in the system. This function
1879 * will return all transport IDs, and application may then call
1880 * #pjsua_transport_get_info() function to retrieve detailed information
1881 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001882 *
1883 * @param id Array to receive transport ids.
1884 * @param count In input, specifies the maximum number of elements.
1885 * On return, it contains the actual number of elements.
1886 *
1887 * @return PJ_SUCCESS on success, or the appropriate error code.
1888 */
1889PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1890 unsigned *count );
1891
1892
1893/**
1894 * Get information about transports.
1895 *
1896 * @param id Transport ID.
1897 * @param info Pointer to receive transport info.
1898 *
1899 * @return PJ_SUCCESS on success, or the appropriate error code.
1900 */
1901PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1902 pjsua_transport_info *info);
1903
1904
1905/**
1906 * Disable a transport or re-enable it. By default transport is always
1907 * enabled after it is created. Disabling a transport does not necessarily
1908 * close the socket, it will only discard incoming messages and prevent
1909 * the transport from being used to send outgoing messages.
1910 *
1911 * @param id Transport ID.
1912 * @param enabled Non-zero to enable, zero to disable.
1913 *
1914 * @return PJ_SUCCESS on success, or the appropriate error code.
1915 */
1916PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1917 pj_bool_t enabled);
1918
1919
1920/**
1921 * Close the transport. If transport is forcefully closed, it will be
1922 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00001923 * transport may not terminate properly (it may even crash). Otherwise,
1924 * the system will wait until all transactions are closed while preventing
1925 * new users from using the transport, and will close the transport when
1926 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001927 *
1928 * @param id Transport ID.
1929 * @param force Non-zero to immediately close the transport. This
1930 * is not recommended!
1931 *
1932 * @return PJ_SUCCESS on success, or the appropriate error code.
1933 */
1934PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1935 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001936
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001937/**
Benny Prijono312aff92006-06-17 04:08:30 +00001938 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001939 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001940
1941
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001942
1943
1944/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001945 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001946 */
1947
Benny Prijono312aff92006-06-17 04:08:30 +00001948
1949/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001950 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001951 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001952 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001953 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001954 *
Benny Prijono312aff92006-06-17 04:08:30 +00001955 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001956 * using the application. In SIP terms, the identity is used as the <b>From</b>
1957 * header in outgoing requests.
1958 *
1959 * PJSUA-API supports creating and managing multiple accounts. The maximum
1960 * number of accounts is limited by a compile time constant
1961 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001962 *
1963 * Account may or may not have client registration associated with it.
1964 * An account is also associated with <b>route set</b> and some <b>authentication
1965 * credentials</b>, which are used when sending SIP request messages using the
1966 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00001967 * will be reported to remote peer when they subscribe to the account's
1968 * presence, or which is published to a presence server if presence
1969 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00001970 *
1971 * At least one account MUST be created in the application. If no user
1972 * association is required, application can create a userless account by
1973 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00001974 * instead of a particular user, and it correspond with a particular
1975 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00001976 *
1977 * Also one account must be set as the <b>default account</b>, which is used as
1978 * the account to use when PJSUA fails to match a request with any other
1979 * accounts.
1980 *
1981 * When sending outgoing SIP requests (such as making calls or sending
1982 * instant messages), normally PJSUA requires the application to specify
1983 * which account to use for the request. If no account is specified,
1984 * PJSUA may be able to select the account by matching the destination
1985 * domain name, and fall back to default account when no match is found.
1986 */
1987
1988/**
1989 * Maximum accounts.
1990 */
1991#ifndef PJSUA_MAX_ACC
1992# define PJSUA_MAX_ACC 8
1993#endif
1994
1995
1996/**
1997 * Default registration interval.
1998 */
1999#ifndef PJSUA_REG_INTERVAL
Benny Prijonobddef2c2007-10-31 13:28:08 +00002000# define PJSUA_REG_INTERVAL 300
Benny Prijono312aff92006-06-17 04:08:30 +00002001#endif
2002
2003
2004/**
Benny Prijono384dab42009-10-14 01:58:04 +00002005 * Default maximum time to wait for account unregistration transactions to
2006 * complete during library shutdown sequence.
2007 *
2008 * Default: 4000 (4 seconds)
2009 */
2010#ifndef PJSUA_UNREG_TIMEOUT
2011# define PJSUA_UNREG_TIMEOUT 4000
2012#endif
2013
2014
2015/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002016 * Default PUBLISH expiration
2017 */
2018#ifndef PJSUA_PUBLISH_EXPIRATION
Benny Prijono53984d12009-04-28 22:19:49 +00002019# define PJSUA_PUBLISH_EXPIRATION PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002020#endif
2021
2022
2023/**
Benny Prijono093d3022006-09-24 00:07:11 +00002024 * Default account priority.
2025 */
2026#ifndef PJSUA_DEFAULT_ACC_PRIORITY
2027# define PJSUA_DEFAULT_ACC_PRIORITY 0
2028#endif
2029
2030
2031/**
Benny Prijono8058a622007-06-08 04:37:05 +00002032 * This macro specifies the URI scheme to use in Contact header
2033 * when secure transport such as TLS is used. Application can specify
2034 * either "sip" or "sips".
2035 */
2036#ifndef PJSUA_SECURE_SCHEME
Benny Prijono4c82c1e2008-10-16 08:14:51 +00002037# define PJSUA_SECURE_SCHEME "sip"
Benny Prijono8058a622007-06-08 04:37:05 +00002038#endif
2039
2040
2041/**
Benny Prijono534a9ba2009-10-13 14:01:59 +00002042 * Maximum time to wait for unpublication transaction(s) to complete
2043 * during shutdown process, before sending unregistration. The library
2044 * tries to wait for the unpublication (un-PUBLISH) to complete before
2045 * sending REGISTER request to unregister the account, during library
2046 * shutdown process. If the value is set too short, it is possible that
2047 * the unregistration is sent before unpublication completes, causing
2048 * unpublication request to fail.
2049 *
2050 * Default: 2000 (2 seconds)
2051 */
2052#ifndef PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
2053# define PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC 2000
2054#endif
2055
2056
2057/**
Nanang Izzuddin36dd5b62010-03-30 11:13:59 +00002058 * Default auto retry re-registration interval, in seconds. Set to 0
2059 * to disable this. Application can set the timer on per account basis
2060 * by setting the pjsua_acc_config.reg_retry_interval field instead.
2061 *
2062 * Default: 300 (5 minutes)
2063 */
2064#ifndef PJSUA_REG_RETRY_INTERVAL
2065# define PJSUA_REG_RETRY_INTERVAL 300
2066#endif
2067
2068
2069/**
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00002070 * This macro specifies the default value for \a contact_rewrite_method
2071 * field in pjsua_acc_config. I specifies how Contact update will be
2072 * done with the registration, if \a allow_contact_rewrite is enabled in
2073 * the account config.
2074 *
2075 * If set to 1, the Contact update will be done by sending unregistration
2076 * to the currently registered Contact, while simultaneously sending new
2077 * registration (with different Call-ID) for the updated Contact.
2078 *
2079 * If set to 2, the Contact update will be done in a single, current
2080 * registration session, by removing the current binding (by setting its
2081 * Contact's expires parameter to zero) and adding a new Contact binding,
2082 * all done in a single request.
2083 *
2084 * Value 1 is the legacy behavior.
2085 *
2086 * Default value: 2
2087 */
2088#ifndef PJSUA_CONTACT_REWRITE_METHOD
2089# define PJSUA_CONTACT_REWRITE_METHOD 2
2090#endif
2091
2092
2093/**
Benny Prijono29c8ca32010-06-22 06:02:13 +00002094 * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that
2095 * the global outbound proxy list should be added to the REGISTER request.
2096 */
2097#define PJSUA_REG_USE_OUTBOUND_PROXY 1
2098
2099
2100/**
2101 * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that
2102 * the account proxy list should be added to the REGISTER request.
2103 */
2104#define PJSUA_REG_USE_ACC_PROXY 2
2105
2106
2107/**
Benny Prijonodd63b992010-10-01 02:03:42 +00002108 * This enumeration specifies how we should offer call hold request to
2109 * remote peer. The default value is set by compile time constant
2110 * PJSUA_CALL_HOLD_TYPE_DEFAULT, and application may control the setting
2111 * on per-account basis by manipulating \a call_hold_type field in
2112 * #pjsua_acc_config.
2113 */
2114typedef enum pjsua_call_hold_type
2115{
2116 /**
2117 * This will follow RFC 3264 recommendation to use a=sendonly,
2118 * a=recvonly, and a=inactive attribute as means to signal call
2119 * hold status. This is the correct value to use.
2120 */
2121 PJSUA_CALL_HOLD_TYPE_RFC3264,
2122
2123 /**
2124 * This will use the old and deprecated method as specified in RFC 2543,
2125 * and will offer c=0.0.0.0 in the SDP instead. Using this has many
2126 * drawbacks such as inability to keep the media transport alive while
2127 * the call is being put on hold, and should only be used if remote
2128 * does not understand RFC 3264 style call hold offer.
2129 */
2130 PJSUA_CALL_HOLD_TYPE_RFC2543
2131
2132} pjsua_call_hold_type;
2133
2134
2135/**
2136 * Specify the default call hold type to be used in #pjsua_acc_config.
2137 *
2138 * Default is PJSUA_CALL_HOLD_TYPE_RFC3264, and there's no reason to change
2139 * this except if you're communicating with an old/non-standard peer.
2140 */
2141#ifndef PJSUA_CALL_HOLD_TYPE_DEFAULT
2142# define PJSUA_CALL_HOLD_TYPE_DEFAULT PJSUA_CALL_HOLD_TYPE_RFC3264
2143#endif
2144
Benny Prijonodd63b992010-10-01 02:03:42 +00002145/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002146 * This structure describes account configuration to be specified when
2147 * adding a new account with #pjsua_acc_add(). Application MUST initialize
2148 * this structure first by calling #pjsua_acc_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00002149 */
2150typedef struct pjsua_acc_config
2151{
Benny Prijono093d3022006-09-24 00:07:11 +00002152 /**
Benny Prijono705e7842008-07-21 18:12:51 +00002153 * Arbitrary user data to be associated with the newly created account.
2154 * Application may set this later with #pjsua_acc_set_user_data() and
2155 * retrieve it with #pjsua_acc_get_user_data().
2156 */
2157 void *user_data;
2158
2159 /**
Benny Prijono093d3022006-09-24 00:07:11 +00002160 * Account priority, which is used to control the order of matching
2161 * incoming/outgoing requests. The higher the number means the higher
2162 * the priority is, and the account will be matched first.
2163 */
2164 int priority;
2165
Benny Prijono312aff92006-06-17 04:08:30 +00002166 /**
2167 * The full SIP URL for the account. The value can take name address or
2168 * URL format, and will look something like "sip:account@serviceprovider".
2169 *
2170 * This field is mandatory.
2171 */
2172 pj_str_t id;
2173
2174 /**
2175 * This is the URL to be put in the request URI for the registration,
2176 * and will look something like "sip:serviceprovider".
2177 *
2178 * This field should be specified if registration is desired. If the
2179 * value is empty, no account registration will be performed.
2180 */
2181 pj_str_t reg_uri;
2182
Nanang Izzuddin60e8aa92010-09-28 10:48:48 +00002183 /**
2184 * The optional custom SIP headers to be put in the registration
2185 * request.
2186 */
2187 pjsip_hdr reg_hdr_list;
2188
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002189 /**
Benny Prijonofe1bd342009-11-20 23:33:07 +00002190 * Subscribe to message waiting indication events (RFC 3842).
2191 *
2192 * See also \a enable_unsolicited_mwi field on #pjsua_config.
Benny Prijono4dd961b2009-10-26 11:21:37 +00002193 *
2194 * Default: no
2195 */
2196 pj_bool_t mwi_enabled;
2197
2198 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002199 * If this flag is set, the presence information of this account will
2200 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono48ab2b72007-11-08 09:24:30 +00002201 *
2202 * Default: PJ_FALSE
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002203 */
2204 pj_bool_t publish_enabled;
2205
Benny Prijonofe04fb52007-08-24 08:28:52 +00002206 /**
Benny Prijonofe50c9e2009-10-12 07:44:14 +00002207 * Event publication options.
2208 */
2209 pjsip_publishc_opt publish_opt;
2210
2211 /**
Benny Prijono534a9ba2009-10-13 14:01:59 +00002212 * Maximum time to wait for unpublication transaction(s) to complete
2213 * during shutdown process, before sending unregistration. The library
2214 * tries to wait for the unpublication (un-PUBLISH) to complete before
2215 * sending REGISTER request to unregister the account, during library
2216 * shutdown process. If the value is set too short, it is possible that
2217 * the unregistration is sent before unpublication completes, causing
2218 * unpublication request to fail.
2219 *
2220 * Default: PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
2221 */
2222 unsigned unpublish_max_wait_time_msec;
2223
2224 /**
Benny Prijono48ab2b72007-11-08 09:24:30 +00002225 * Authentication preference.
2226 */
2227 pjsip_auth_clt_pref auth_pref;
2228
2229 /**
Benny Prijonofe04fb52007-08-24 08:28:52 +00002230 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
2231 * is not specified, a random string will be used.
2232 */
2233 pj_str_t pidf_tuple_id;
2234
Benny Prijono312aff92006-06-17 04:08:30 +00002235 /**
2236 * Optional URI to be put as Contact for this account. It is recommended
2237 * that this field is left empty, so that the value will be calculated
2238 * automatically based on the transport address.
2239 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00002240 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00002241
2242 /**
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00002243 * Additional parameters that will be appended in the Contact header
Benny Prijono30fe4852008-12-10 16:54:16 +00002244 * for this account. This will affect the Contact header in all SIP
2245 * messages sent on behalf of this account, including but not limited to
2246 * REGISTER, INVITE, and SUBCRIBE requests or responses.
2247 *
2248 * The parameters should be preceeded by semicolon, and all strings must
2249 * be properly escaped. Example:
2250 * ";my-param=X;another-param=Hi%20there"
2251 */
2252 pj_str_t contact_params;
2253
2254 /**
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00002255 * Additional URI parameters that will be appended in the Contact URI
2256 * for this account. This will affect the Contact URI in all SIP
2257 * messages sent on behalf of this account, including but not limited to
2258 * REGISTER, INVITE, and SUBCRIBE requests or responses.
2259 *
2260 * The parameters should be preceeded by semicolon, and all strings must
2261 * be properly escaped. Example:
2262 * ";my-param=X;another-param=Hi%20there"
2263 */
2264 pj_str_t contact_uri_params;
2265
2266 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00002267 * Specify whether support for reliable provisional response (100rel and
2268 * PRACK) should be required for all sessions of this account.
2269 *
2270 * Default: PJ_FALSE
2271 */
2272 pj_bool_t require_100rel;
2273
2274 /**
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002275 * Specify the usage of Session Timers for all sessions. See the
2276 * #pjsua_sip_timer_use for possible values.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002277 *
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002278 * Default: PJSUA_SIP_TIMER_OPTIONAL
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002279 */
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002280 pjsua_sip_timer_use use_timer;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002281
2282 /**
Nanang Izzuddin65add622009-08-11 16:26:20 +00002283 * Specify Session Timer settings, see #pjsip_timer_setting.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002284 */
Nanang Izzuddin65add622009-08-11 16:26:20 +00002285 pjsip_timer_setting timer_setting;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002286
2287 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002288 * Number of proxies in the proxy array below.
2289 */
2290 unsigned proxy_cnt;
2291
2292 /**
2293 * Optional URI of the proxies to be visited for all outgoing requests
2294 * that are using this account (REGISTER, INVITE, etc). Application need
2295 * to specify these proxies if the service provider requires that requests
2296 * destined towards its network should go through certain proxies first
2297 * (for example, border controllers).
2298 *
2299 * These proxies will be put in the route set for this account, with
2300 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00002301 * first). If global outbound proxies are configured in pjsua_config,
2302 * then these account proxies will be placed after the global outbound
2303 * proxies in the routeset.
Benny Prijono312aff92006-06-17 04:08:30 +00002304 */
2305 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
2306
2307 /**
2308 * Optional interval for registration, in seconds. If the value is zero,
Benny Prijonobddef2c2007-10-31 13:28:08 +00002309 * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
Benny Prijono312aff92006-06-17 04:08:30 +00002310 */
2311 unsigned reg_timeout;
2312
Benny Prijono384dab42009-10-14 01:58:04 +00002313 /**
2314 * Specify the maximum time to wait for unregistration requests to
2315 * complete during library shutdown sequence.
2316 *
2317 * Default: PJSUA_UNREG_TIMEOUT
2318 */
2319 unsigned unreg_timeout;
2320
Benny Prijono312aff92006-06-17 04:08:30 +00002321 /**
2322 * Number of credentials in the credential array.
2323 */
2324 unsigned cred_count;
2325
2326 /**
2327 * Array of credentials. If registration is desired, normally there should
2328 * be at least one credential specified, to successfully authenticate
2329 * against the service provider. More credentials can be specified, for
2330 * example when the requests are expected to be challenged by the
2331 * proxies in the route set.
2332 */
2333 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
2334
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002335 /**
2336 * Optionally bind this account to specific transport. This normally is
2337 * not a good idea, as account should be able to send requests using
2338 * any available transports according to the destination. But some
2339 * application may want to have explicit control over the transport to
2340 * use, so in that case it can set this field.
2341 *
2342 * Default: -1 (PJSUA_INVALID_ID)
2343 *
2344 * @see pjsua_acc_set_transport()
2345 */
2346 pjsua_transport_id transport_id;
2347
Benny Prijono15b02302007-09-27 14:07:07 +00002348 /**
Benny Prijonocca2e432010-02-25 09:33:18 +00002349 * This option is used to update the transport address and the Contact
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002350 * header of REGISTER request. When this option is enabled, the library
2351 * will keep track of the public IP address from the response of REGISTER
2352 * request. Once it detects that the address has changed, it will
2353 * unregister current Contact, update the Contact with transport address
2354 * learned from Via header, and register a new Contact to the registrar.
2355 * This will also update the public name of UDP transport if STUN is
Benny Prijonocca2e432010-02-25 09:33:18 +00002356 * configured.
Benny Prijono15b02302007-09-27 14:07:07 +00002357 *
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00002358 * See also contact_rewrite_method field.
2359 *
Benny Prijono15b02302007-09-27 14:07:07 +00002360 * Default: 1 (yes)
2361 */
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002362 pj_bool_t allow_contact_rewrite;
Benny Prijono15b02302007-09-27 14:07:07 +00002363
Benny Prijonobddef2c2007-10-31 13:28:08 +00002364 /**
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00002365 * Specify how Contact update will be done with the registration, if
2366 * \a allow_contact_rewrite is enabled.
2367 *
2368 * If set to 1, the Contact update will be done by sending unregistration
2369 * to the currently registered Contact, while simultaneously sending new
2370 * registration (with different Call-ID) for the updated Contact.
2371 *
2372 * If set to 2, the Contact update will be done in a single, current
2373 * registration session, by removing the current binding (by setting its
2374 * Contact's expires parameter to zero) and adding a new Contact binding,
2375 * all done in a single request.
2376 *
2377 * Value 1 is the legacy behavior.
2378 *
2379 * Default value: PJSUA_CONTACT_REWRITE_METHOD (2)
2380 */
2381 int contact_rewrite_method;
2382
2383 /**
Benny Prijonob54719f2010-11-16 03:07:46 +00002384 * Control the use of SIP outbound feature. SIP outbound is described in
2385 * RFC 5626 to enable proxies or registrar to send inbound requests back
2386 * to UA using the same connection initiated by the UA for its
2387 * registration. This feature is highly useful in NAT-ed deployemtns,
2388 * hence it is enabled by default.
2389 *
2390 * Note: currently SIP outbound can only be used with TCP and TLS
2391 * transports. If UDP is used for the registration, the SIP outbound
2392 * feature will be silently ignored for the account.
2393 *
2394 * Default: PJ_TRUE
2395 */
2396 unsigned use_rfc5626;
2397
2398 /**
2399 * Specify SIP outbound (RFC 5626) instance ID to be used by this
2400 * application. If empty, an instance ID will be generated based on
2401 * the hostname of this agent. If application specifies this parameter, the
2402 * value will look like "<urn:uuid:00000000-0000-1000-8000-AABBCCDDEEFF>"
2403 * without the doublequote.
2404 *
2405 * Default: empty
2406 */
2407 pj_str_t rfc5626_instance_id;
2408
2409 /**
2410 * Specify SIP outbound (RFC 5626) registration ID. The default value
2411 * is empty, which would cause the library to automatically generate
2412 * a suitable value.
2413 *
2414 * Default: empty
2415 */
2416 pj_str_t rfc5626_reg_id;
2417
2418 /**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002419 * Set the interval for periodic keep-alive transmission for this account.
2420 * If this value is zero, keep-alive will be disabled for this account.
2421 * The keep-alive transmission will be sent to the registrar's address,
2422 * after successful registration.
2423 *
Benny Prijonobddef2c2007-10-31 13:28:08 +00002424 * Default: 15 (seconds)
2425 */
2426 unsigned ka_interval;
2427
2428 /**
2429 * Specify the data to be transmitted as keep-alive packets.
2430 *
2431 * Default: CR-LF
2432 */
2433 pj_str_t ka_data;
2434
Benny Prijono0bc99a92011-03-17 04:34:43 +00002435 /**
2436 * Maximum number of simultaneous active audio streams to be allowed
2437 * for calls on this account. Setting this to zero will disable audio
2438 * in calls on this account.
2439 *
2440 * Default: 1
2441 */
2442 unsigned max_audio_cnt;
2443
2444 /**
2445 * Maximum number of simultaneous active video streams to be allowed
2446 * for calls on this account. Setting this to zero will disable video
Benny Prijono9f468d12011-07-07 07:46:33 +00002447 * in calls on this account, regardless of other video settings.
Benny Prijono0bc99a92011-03-17 04:34:43 +00002448 *
Benny Prijono9f468d12011-07-07 07:46:33 +00002449 * Default: 1
Benny Prijono0bc99a92011-03-17 04:34:43 +00002450 */
2451 unsigned max_video_cnt;
2452
2453 /**
Benny Prijono9f468d12011-07-07 07:46:33 +00002454 * Specify whether incoming video should be shown to screen by default.
2455 * This applies to incoming call (INVITE), incoming re-INVITE, and
2456 * incoming UPDATE requests.
2457 *
2458 * Regardless of this setting, application can detect incoming video
2459 * by implementing \a on_call_media_state() callback and enumerating
2460 * the media stream(s) with #pjsua_call_get_info(). Once incoming
2461 * video is recognised, application may retrieve the window associated
2462 * with the incoming video and show or hide it with
2463 * #pjsua_vid_win_set_show().
2464 *
2465 * Default: PJ_FALSE
2466 */
2467 pj_bool_t vid_in_auto_show;
2468
2469 /**
2470 * Specify whether outgoing video should be activated by default when
2471 * making outgoing calls and/or when incoming video is detected. This
2472 * applies to incoming and outgoing calls, incoming re-INVITE, and
2473 * incoming UPDATE. If the setting is non-zero, outgoing video
2474 * transmission will be started as soon as response to these requests
2475 * is sent (or received).
2476 *
2477 * Regardless of the value of this setting, application can start and
2478 * stop outgoing video transmission with #pjsua_call_set_vid_out().
2479 *
2480 * Default: PJ_FALSE
2481 */
2482 pj_bool_t vid_out_auto_transmit;
2483
2484 /**
2485 * Specify the default capture device to be used by this account. If
2486 * \a vid_out_auto_transmit is enabled, this device will be used for
2487 * capturing video.
2488 *
2489 * Default: PJMEDIA_VID_DEFAULT_CAPTURE_DEV
2490 */
2491 pjmedia_vid_dev_index vid_cap_dev;
2492
2493 /**
2494 * Specify the default rendering device to be used by this account.
2495 *
2496 * Default: PJMEDIA_VID_DEFAULT_RENDER_DEV
2497 */
2498 pjmedia_vid_dev_index vid_rend_dev;
2499
2500 /**
Benny Prijono0bc99a92011-03-17 04:34:43 +00002501 * Media transport config.
2502 */
2503 pjsua_transport_config rtp_cfg;
2504
Benny Prijonod8179652008-01-23 20:39:07 +00002505 /**
2506 * Specify whether secure media transport should be used for this account.
2507 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
2508 * PJMEDIA_SRTP_MANDATORY.
2509 *
2510 * Default: #PJSUA_DEFAULT_USE_SRTP
2511 */
2512 pjmedia_srtp_use use_srtp;
2513
2514 /**
2515 * Specify whether SRTP requires secure signaling to be used. This option
2516 * is only used when \a use_srtp option above is non-zero.
2517 *
2518 * Valid values are:
2519 * 0: SRTP does not require secure signaling
2520 * 1: SRTP requires secure transport such as TLS
2521 * 2: SRTP requires secure end-to-end transport (SIPS)
2522 *
2523 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
2524 */
2525 int srtp_secure_signaling;
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00002526
2527 /**
Benny Prijono0bc99a92011-03-17 04:34:43 +00002528 * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00002529 * duplicated media in SDP offer, i.e: unsecured and secured version.
Benny Prijono0bc99a92011-03-17 04:34:43 +00002530 * Otherwise, the SDP media will be composed as unsecured media but
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00002531 * with SDP "crypto" attribute.
2532 *
2533 * Default: PJ_FALSE
2534 */
2535 pj_bool_t srtp_optional_dup_offer;
Benny Prijonod8179652008-01-23 20:39:07 +00002536
Nanang Izzuddin36dd5b62010-03-30 11:13:59 +00002537 /**
2538 * Specify interval of auto registration retry upon registration failure
2539 * (including caused by transport problem), in second. Set to 0 to
2540 * disable auto re-registration.
2541 *
2542 * Default: #PJSUA_REG_RETRY_INTERVAL
2543 */
2544 unsigned reg_retry_interval;
2545
2546 /**
2547 * Specify whether calls of the configured account should be dropped
2548 * after registration failure and an attempt of re-registration has
2549 * also failed.
2550 *
2551 * Default: PJ_FALSE (disabled)
2552 */
2553 pj_bool_t drop_calls_on_reg_fail;
2554
Benny Prijono29c8ca32010-06-22 06:02:13 +00002555 /**
2556 * Specify how the registration uses the outbound and account proxy
2557 * settings. This controls if and what Route headers will appear in
2558 * the REGISTER request of this account. The value is bitmask combination
2559 * of PJSUA_REG_USE_OUTBOUND_PROXY and PJSUA_REG_USE_ACC_PROXY bits.
2560 * If the value is set to 0, the REGISTER request will not use any proxy
2561 * (i.e. it will not have any Route headers).
2562 *
2563 * Default: 3 (PJSUA_REG_USE_OUTBOUND_PROXY | PJSUA_REG_USE_ACC_PROXY)
2564 */
2565 unsigned reg_use_proxy;
2566
Nanang Izzuddin5e39a2b2010-09-20 06:13:02 +00002567#if defined(PJMEDIA_STREAM_ENABLE_KA) && (PJMEDIA_STREAM_ENABLE_KA != 0)
2568 /**
2569 * Specify whether stream keep-alive and NAT hole punching with
2570 * non-codec-VAD mechanism (see @ref PJMEDIA_STREAM_ENABLE_KA) is enabled
2571 * for this account.
2572 *
2573 * Default: PJ_FALSE (disabled)
2574 */
2575 pj_bool_t use_stream_ka;
2576#endif
2577
Benny Prijonodd63b992010-10-01 02:03:42 +00002578 /**
2579 * Specify how to offer call hold to remote peer. Please see the
2580 * documentation on #pjsua_call_hold_type for more info.
2581 *
2582 * Default: PJSUA_CALL_HOLD_TYPE_DEFAULT
2583 */
2584 pjsua_call_hold_type call_hold_type;
2585
Benny Prijono312aff92006-06-17 04:08:30 +00002586} pjsua_acc_config;
2587
2588
2589/**
2590 * Call this function to initialize account config with default values.
2591 *
2592 * @param cfg The account config to be initialized.
2593 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00002594PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002595
2596
2597/**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002598 * Duplicate account config.
2599 *
2600 * @param pool Pool to be used for duplicating the config.
2601 * @param dst Destination configuration.
2602 * @param src Source configuration.
2603 */
2604PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
2605 pjsua_acc_config *dst,
2606 const pjsua_acc_config *src);
2607
2608
2609/**
Benny Prijono312aff92006-06-17 04:08:30 +00002610 * Account info. Application can query account info by calling
2611 * #pjsua_acc_get_info().
2612 */
2613typedef struct pjsua_acc_info
2614{
2615 /**
2616 * The account ID.
2617 */
2618 pjsua_acc_id id;
2619
2620 /**
2621 * Flag to indicate whether this is the default account.
2622 */
2623 pj_bool_t is_default;
2624
2625 /**
2626 * Account URI
2627 */
2628 pj_str_t acc_uri;
2629
2630 /**
2631 * Flag to tell whether this account has registration setting
2632 * (reg_uri is not empty).
2633 */
2634 pj_bool_t has_registration;
2635
2636 /**
2637 * An up to date expiration interval for account registration session.
2638 */
2639 int expires;
2640
2641 /**
2642 * Last registration status code. If status code is zero, the account
2643 * is currently not registered. Any other value indicates the SIP
2644 * status code of the registration.
2645 */
2646 pjsip_status_code status;
2647
2648 /**
Sauw Ming48f6dbf2010-09-07 05:10:25 +00002649 * Last registration error code. When the status field contains a SIP
2650 * status code that indicates a registration failure, last registration
2651 * error code contains the error code that causes the failure. In any
2652 * other case, its value is zero.
2653 */
2654 pj_status_t reg_last_err;
2655
2656 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002657 * String describing the registration status.
2658 */
2659 pj_str_t status_text;
2660
2661 /**
2662 * Presence online status for this account.
2663 */
2664 pj_bool_t online_status;
2665
2666 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00002667 * Presence online status text.
2668 */
2669 pj_str_t online_status_text;
2670
2671 /**
2672 * Extended RPID online status information.
2673 */
2674 pjrpid_element rpid;
2675
2676 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002677 * Buffer that is used internally to store the status text.
2678 */
2679 char buf_[PJ_ERR_MSG_SIZE];
2680
2681} pjsua_acc_info;
2682
2683
2684
2685/**
2686 * Get number of current accounts.
2687 *
2688 * @return Current number of accounts.
2689 */
2690PJ_DECL(unsigned) pjsua_acc_get_count(void);
2691
2692
2693/**
2694 * Check if the specified account ID is valid.
2695 *
2696 * @param acc_id Account ID to check.
2697 *
2698 * @return Non-zero if account ID is valid.
2699 */
2700PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
2701
2702
2703/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00002704 * Set default account to be used when incoming and outgoing
2705 * requests doesn't match any accounts.
2706 *
2707 * @param acc_id The account ID to be used as default.
2708 *
2709 * @return PJ_SUCCESS on success.
2710 */
2711PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2712
2713
2714/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002715 * Get default account to be used when receiving incoming requests (calls),
2716 * when the destination of the incoming call doesn't match any other
2717 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002718 *
2719 * @return The default account ID, or PJSUA_INVALID_ID if no
2720 * default account is configured.
2721 */
2722PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2723
2724
2725/**
Benny Prijono312aff92006-06-17 04:08:30 +00002726 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002727 * #pjsua_init()) before calling this function. If registration is configured
2728 * for this account, this function would also start the SIP registration
2729 * session with the SIP registrar server. This SIP registration session
2730 * will be maintained internally by the library, and application doesn't
2731 * need to do anything to maintain the registration session.
2732 *
Benny Prijono312aff92006-06-17 04:08:30 +00002733 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002734 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002735 * @param is_default If non-zero, this account will be set as the default
2736 * account. The default account will be used when sending
2737 * outgoing requests (e.g. making call) when no account is
2738 * specified, and when receiving incoming requests when the
2739 * request does not match any accounts. It is recommended
2740 * that default account is set to local/LAN account.
2741 * @param p_acc_id Pointer to receive account ID of the new account.
2742 *
2743 * @return PJ_SUCCESS on success, or the appropriate error code.
2744 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002745PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002746 pj_bool_t is_default,
2747 pjsua_acc_id *p_acc_id);
2748
2749
2750/**
2751 * Add a local account. A local account is used to identify local endpoint
2752 * instead of a specific user, and for this reason, a transport ID is needed
2753 * to obtain the local address information.
2754 *
2755 * @param tid Transport ID to generate account address.
2756 * @param is_default If non-zero, this account will be set as the default
2757 * account. The default account will be used when sending
2758 * outgoing requests (e.g. making call) when no account is
2759 * specified, and when receiving incoming requests when the
2760 * request does not match any accounts. It is recommended
2761 * that default account is set to local/LAN account.
2762 * @param p_acc_id Pointer to receive account ID of the new account.
2763 *
2764 * @return PJ_SUCCESS on success, or the appropriate error code.
2765 */
2766PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2767 pj_bool_t is_default,
2768 pjsua_acc_id *p_acc_id);
2769
2770/**
Benny Prijono705e7842008-07-21 18:12:51 +00002771 * Set arbitrary data to be associated with the account.
2772 *
2773 * @param acc_id The account ID.
2774 * @param user_data User/application data.
2775 *
2776 * @return PJ_SUCCESS on success, or the appropriate error code.
2777 */
2778PJ_DECL(pj_status_t) pjsua_acc_set_user_data(pjsua_acc_id acc_id,
2779 void *user_data);
2780
2781
2782/**
2783 * Retrieve arbitrary data associated with the account.
2784 *
2785 * @param acc_id The account ID.
2786 *
2787 * @return The user data. In the case where the account ID is
2788 * not valid, NULL is returned.
2789 */
2790PJ_DECL(void*) pjsua_acc_get_user_data(pjsua_acc_id acc_id);
2791
2792
2793/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002794 * Delete an account. This will unregister the account from the SIP server,
2795 * if necessary, and terminate server side presence subscriptions associated
2796 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002797 *
2798 * @param acc_id Id of the account to be deleted.
2799 *
2800 * @return PJ_SUCCESS on success, or the appropriate error code.
2801 */
2802PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2803
2804
2805/**
2806 * Modify account information.
2807 *
2808 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002809 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002810 *
2811 * @return PJ_SUCCESS on success, or the appropriate error code.
2812 */
2813PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002814 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002815
2816
2817/**
2818 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002819 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002820 * if there are server side presence subscription for this account, and/or
2821 * outgoing PUBLISH if presence publication is enabled for this account.
2822 *
2823 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002824 *
2825 * @param acc_id The account ID.
2826 * @param is_online True of false.
2827 *
2828 * @return PJ_SUCCESS on success, or the appropriate error code.
2829 */
2830PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2831 pj_bool_t is_online);
2832
Benny Prijono4461c7d2007-08-25 13:36:15 +00002833/**
2834 * Modify account's presence status to be advertised to remote/presence
2835 * subscribers. This would trigger the sending of outgoing NOTIFY request
2836 * if there are server side presence subscription for this account, and/or
2837 * outgoing PUBLISH if presence publication is enabled for this account.
2838 *
2839 * @see pjsua_acc_set_online_status()
2840 *
2841 * @param acc_id The account ID.
2842 * @param is_online True of false.
2843 * @param pr Extended information in subset of RPID format
2844 * which allows setting custom presence text.
2845 *
2846 * @return PJ_SUCCESS on success, or the appropriate error code.
2847 */
2848PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2849 pj_bool_t is_online,
2850 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002851
2852/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002853 * Update registration or perform unregistration. If registration is
2854 * configured for this account, then initial SIP REGISTER will be sent
2855 * when the account is added with #pjsua_acc_add(). Application normally
2856 * only need to call this function if it wants to manually update the
2857 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002858 *
2859 * @param acc_id The account ID.
2860 * @param renew If renew argument is zero, this will start
2861 * unregistration process.
2862 *
2863 * @return PJ_SUCCESS on success, or the appropriate error code.
2864 */
2865PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2866 pj_bool_t renew);
2867
Benny Prijono312aff92006-06-17 04:08:30 +00002868/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002869 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002870 *
2871 * @param acc_id Account identification.
2872 * @param info Pointer to receive account information.
2873 *
2874 * @return PJ_SUCCESS on success, or the appropriate error code.
2875 */
2876PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2877 pjsua_acc_info *info);
2878
2879
2880/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002881 * Enumerate all account currently active in the library. This will fill
2882 * the array with the account Ids, and application can then query the
2883 * account information for each id with #pjsua_acc_get_info().
2884 *
2885 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002886 *
2887 * @param ids Array of account IDs to be initialized.
2888 * @param count In input, specifies the maximum number of elements.
2889 * On return, it contains the actual number of elements.
2890 *
2891 * @return PJ_SUCCESS on success, or the appropriate error code.
2892 */
2893PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2894 unsigned *count );
2895
2896
2897/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002898 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002899 *
2900 * @param info Array of account infos to be initialized.
2901 * @param count In input, specifies the maximum number of elements.
2902 * On return, it contains the actual number of elements.
2903 *
2904 * @return PJ_SUCCESS on success, or the appropriate error code.
2905 */
2906PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2907 unsigned *count );
2908
2909
2910/**
2911 * This is an internal function to find the most appropriate account to
2912 * used to reach to the specified URL.
2913 *
2914 * @param url The remote URL to reach.
2915 *
2916 * @return Account id.
2917 */
2918PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2919
2920
2921/**
2922 * This is an internal function to find the most appropriate account to be
2923 * used to handle incoming calls.
2924 *
2925 * @param rdata The incoming request message.
2926 *
2927 * @return Account id.
2928 */
2929PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2930
2931
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002932/**
Benny Prijonofff245c2007-04-02 11:44:47 +00002933 * Create arbitrary requests using the account. Application should only use
2934 * this function to create auxiliary requests outside dialog, such as
2935 * OPTIONS, and use the call or presence API to create dialog related
2936 * requests.
2937 *
2938 * @param acc_id The account ID.
2939 * @param method The SIP method of the request.
2940 * @param target Target URI.
2941 * @param p_tdata Pointer to receive the request.
2942 *
2943 * @return PJ_SUCCESS or the error code.
2944 */
2945PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
2946 const pjsip_method *method,
2947 const pj_str_t *target,
2948 pjsip_tx_data **p_tdata);
2949
2950
2951/**
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002952 * Create a suitable Contact header value, based on the specified target URI
2953 * for the specified account.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002954 *
2955 * @param pool Pool to allocate memory for the string.
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002956 * @param contact The string where the Contact will be stored.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002957 * @param acc_id Account ID.
2958 * @param uri Destination URI of the request.
2959 *
2960 * @return PJ_SUCCESS on success, other on error.
2961 */
2962PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
2963 pj_str_t *contact,
2964 pjsua_acc_id acc_id,
2965 const pj_str_t *uri);
2966
2967
2968
2969/**
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002970 * Create a suitable Contact header value, based on the information in the
2971 * incoming request.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002972 *
2973 * @param pool Pool to allocate memory for the string.
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002974 * @param contact The string where the Contact will be stored.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002975 * @param acc_id Account ID.
2976 * @param rdata Incoming request.
2977 *
2978 * @return PJ_SUCCESS on success, other on error.
2979 */
2980PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
2981 pj_str_t *contact,
2982 pjsua_acc_id acc_id,
2983 pjsip_rx_data *rdata );
2984
2985
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002986/**
2987 * Lock/bind this account to a specific transport/listener. Normally
2988 * application shouldn't need to do this, as transports will be selected
2989 * automatically by the stack according to the destination.
2990 *
2991 * When account is locked/bound to a specific transport, all outgoing
2992 * requests from this account will use the specified transport (this
2993 * includes SIP registration, dialog (call and event subscription), and
2994 * out-of-dialog requests such as MESSAGE).
2995 *
2996 * Note that transport_id may be specified in pjsua_acc_config too.
2997 *
2998 * @param acc_id The account ID.
2999 * @param tp_id The transport ID.
3000 *
3001 * @return PJ_SUCCESS on success.
3002 */
3003PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
3004 pjsua_transport_id tp_id);
3005
Benny Prijono312aff92006-06-17 04:08:30 +00003006
3007/**
3008 * @}
3009 */
3010
3011
3012/*****************************************************************************
3013 * CALLS API
3014 */
3015
3016
3017/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003018 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00003019 * @ingroup PJSUA_LIB
3020 * @brief Call manipulation.
3021 * @{
3022 */
3023
3024/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003025 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00003026 */
3027#ifndef PJSUA_MAX_CALLS
3028# define PJSUA_MAX_CALLS 32
3029#endif
3030
Benny Prijono9f468d12011-07-07 07:46:33 +00003031/**
3032 * Maximum active video windows
3033 */
3034#ifndef PJSUA_MAX_VID_WINS
3035# define PJSUA_MAX_VID_WINS 16
3036#endif
3037
3038/**
3039 * Video window ID.
3040 */
3041typedef int pjsua_vid_win_id;
Benny Prijono312aff92006-06-17 04:08:30 +00003042
3043
3044/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003045 * This enumeration specifies the media status of a call, and it's part
3046 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00003047 */
3048typedef enum pjsua_call_media_status
3049{
Benny Prijono0bc99a92011-03-17 04:34:43 +00003050 /**
3051 * Call currently has no media, or the media is not used.
3052 */
Benny Prijono312aff92006-06-17 04:08:30 +00003053 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00003054
Benny Prijono0bc99a92011-03-17 04:34:43 +00003055 /**
3056 * The media is active
3057 */
Benny Prijono312aff92006-06-17 04:08:30 +00003058 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00003059
Benny Prijono0bc99a92011-03-17 04:34:43 +00003060 /**
3061 * The media is currently put on hold by local endpoint
3062 */
Benny Prijono312aff92006-06-17 04:08:30 +00003063 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00003064
Benny Prijono0bc99a92011-03-17 04:34:43 +00003065 /**
3066 * The media is currently put on hold by remote endpoint
3067 */
Benny Prijono312aff92006-06-17 04:08:30 +00003068 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00003069
Benny Prijono0bc99a92011-03-17 04:34:43 +00003070 /**
3071 * The media has reported error (e.g. ICE negotiation)
3072 */
Benny Prijono096c56c2007-09-15 08:30:16 +00003073 PJSUA_CALL_MEDIA_ERROR
3074
Benny Prijono312aff92006-06-17 04:08:30 +00003075} pjsua_call_media_status;
3076
3077
3078/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003079 * This structure describes the information and current status of a call.
Benny Prijono312aff92006-06-17 04:08:30 +00003080 */
3081typedef struct pjsua_call_info
3082{
3083 /** Call identification. */
3084 pjsua_call_id id;
3085
3086 /** Initial call role (UAC == caller) */
3087 pjsip_role_e role;
3088
Benny Prijono90315512006-09-14 16:05:16 +00003089 /** The account ID where this call belongs. */
3090 pjsua_acc_id acc_id;
3091
Benny Prijono312aff92006-06-17 04:08:30 +00003092 /** Local URI */
3093 pj_str_t local_info;
3094
3095 /** Local Contact */
3096 pj_str_t local_contact;
3097
3098 /** Remote URI */
3099 pj_str_t remote_info;
3100
3101 /** Remote contact */
3102 pj_str_t remote_contact;
3103
3104 /** Dialog Call-ID string. */
3105 pj_str_t call_id;
3106
3107 /** Call state */
3108 pjsip_inv_state state;
3109
3110 /** Text describing the state */
3111 pj_str_t state_text;
3112
3113 /** Last status code heard, which can be used as cause code */
3114 pjsip_status_code last_status;
3115
3116 /** The reason phrase describing the status. */
3117 pj_str_t last_status_text;
3118
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003119 /** Media status of the first audio stream. */
Benny Prijono312aff92006-06-17 04:08:30 +00003120 pjsua_call_media_status media_status;
3121
Benny Prijono0bc99a92011-03-17 04:34:43 +00003122 /** Media direction of the first audio stream. */
Benny Prijono312aff92006-06-17 04:08:30 +00003123 pjmedia_dir media_dir;
3124
Benny Prijono0bc99a92011-03-17 04:34:43 +00003125 /** The conference port number for the first audio stream. */
Benny Prijono312aff92006-06-17 04:08:30 +00003126 pjsua_conf_port_id conf_slot;
3127
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003128 /** Number of media streams in this call */
3129 unsigned media_cnt;
3130
3131 /** Array of media stream information */
Benny Prijono0bc99a92011-03-17 04:34:43 +00003132 struct
3133 {
3134 /** Media index in SDP. */
3135 unsigned index;
3136
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003137 /** Media type. */
3138 pjmedia_type type;
Benny Prijono0bc99a92011-03-17 04:34:43 +00003139
3140 /** Media direction. */
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003141 pjmedia_dir dir;
Benny Prijono0bc99a92011-03-17 04:34:43 +00003142
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003143 /** Call media status. */
3144 pjsua_call_media_status status;
Benny Prijono0bc99a92011-03-17 04:34:43 +00003145
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003146 /** The specific media stream info. */
3147 union {
3148 /** Audio stream */
3149 struct {
Benny Prijono9f468d12011-07-07 07:46:33 +00003150 /** The conference port number for the call. */
3151 pjsua_conf_port_id conf_slot;
3152 } aud;
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003153
3154 /** Video stream */
3155 struct {
Benny Prijono9f468d12011-07-07 07:46:33 +00003156 /**
3157 * The window id for incoming video, if any, or
3158 * PJSUA_INVALID_ID.
3159 */
3160 pjsua_vid_win_id win_in;
3161
3162 /** The video capture device for outgoing transmission,
3163 * if any, or PJMEDIA_VID_INVALID_DEV
3164 */
3165 pjmedia_vid_dev_index cap_dev;
3166
3167 } vid;
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003168 } stream;
3169
3170 } media[PJMEDIA_MAX_SDP_MEDIA];
Benny Prijono0bc99a92011-03-17 04:34:43 +00003171
Benny Prijono312aff92006-06-17 04:08:30 +00003172 /** Up-to-date call connected duration (zero when call is not
3173 * established)
3174 */
3175 pj_time_val connect_duration;
3176
3177 /** Total call duration, including set-up time */
3178 pj_time_val total_duration;
3179
3180 /** Internal */
3181 struct {
3182 char local_info[128];
3183 char local_contact[128];
3184 char remote_info[128];
3185 char remote_contact[128];
3186 char call_id[128];
3187 char last_status_text[128];
3188 } buf_;
3189
3190} pjsua_call_info;
3191
3192
Benny Prijono9f468d12011-07-07 07:46:33 +00003193/**
3194 * Media stream info.
3195 */
3196typedef struct pjsua_stream_info
3197{
3198 /** Media type of this stream. */
3199 pjmedia_type type;
3200
3201 /** Stream info (union). */
3202 union {
3203 /** Audio stream info */
3204 pjmedia_stream_info aud;
3205
3206 /** Video stream info */
3207 pjmedia_vid_stream_info vid;
3208 } info;
3209
3210} pjsua_stream_info;
3211
3212
3213/**
3214 * Media stream statistic.
3215 */
3216typedef struct pjsua_stream_stat
3217{
3218 /** RTCP statistic. */
3219 pjmedia_rtcp_stat rtcp;
3220
3221 /** Jitter buffer statistic. */
3222 pjmedia_jb_state jbuf;
3223
3224} pjsua_stream_stat;
3225
Benny Prijono312aff92006-06-17 04:08:30 +00003226
Benny Prijonoa91a0032006-02-26 21:23:45 +00003227/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00003228 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003229 *
3230 * @return Maximum number of calls configured.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003231 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003232PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003233
3234/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003235 * Get number of currently active calls.
3236 *
3237 * @return Number of currently active calls.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003238 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003239PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003240
3241/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003242 * Enumerate all active calls. Application may then query the information and
3243 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003244 *
3245 * @param ids Array of account IDs to be initialized.
3246 * @param count In input, specifies the maximum number of elements.
3247 * On return, it contains the actual number of elements.
3248 *
3249 * @return PJ_SUCCESS on success, or the appropriate error code.
3250 */
3251PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
3252 unsigned *count);
3253
3254
3255/**
3256 * Make outgoing call to the specified URI using the specified account.
3257 *
3258 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003259 * @param dst_uri URI to be put in the To header (normally is the same
3260 * as the target URI).
3261 * @param options Options (must be zero at the moment).
3262 * @param user_data Arbitrary user data to be attached to the call, and
3263 * can be retrieved later.
3264 * @param msg_data Optional headers etc to be added to outgoing INVITE
3265 * request, or NULL if no custom header is desired.
3266 * @param p_call_id Pointer to receive call identification.
3267 *
3268 * @return PJ_SUCCESS on success, or the appropriate error code.
3269 */
3270PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
3271 const pj_str_t *dst_uri,
3272 unsigned options,
3273 void *user_data,
3274 const pjsua_msg_data *msg_data,
3275 pjsua_call_id *p_call_id);
3276
3277
3278/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00003279 * Check if the specified call has active INVITE session and the INVITE
3280 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003281 *
3282 * @param call_id Call identification.
3283 *
3284 * @return Non-zero if call is active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003285 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003286PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003287
3288
3289/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003290 * Check if call has an active media session.
3291 *
3292 * @param call_id Call identification.
3293 *
3294 * @return Non-zero if yes.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003295 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003296PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003297
3298
Benny Prijonocf986c42008-09-02 11:25:07 +00003299/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003300 * Get the conference port identification associated with the call.
3301 *
3302 * @param call_id Call identification.
3303 *
Benny Prijono9f468d12011-07-07 07:46:33 +00003304 * @return Conference port ID, or PJSUA_INVALID_ID when the
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003305 * media has not been established or is not active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003306 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003307PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
3308
3309/**
3310 * Obtain detail information about the specified call.
3311 *
3312 * @param call_id Call identification.
3313 * @param info Call info to be initialized.
3314 *
3315 * @return PJ_SUCCESS on success, or the appropriate error code.
3316 */
3317PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003318 pjsua_call_info *info);
3319
Nanang Izzuddin2a1b9ee2010-06-03 10:41:32 +00003320/**
3321 * Check if remote peer support the specified capability.
3322 *
3323 * @param call_id Call identification.
3324 * @param htype The header type to be checked, which value may be:
3325 * - PJSIP_H_ACCEPT
3326 * - PJSIP_H_ALLOW
3327 * - PJSIP_H_SUPPORTED
3328 * @param hname If htype specifies PJSIP_H_OTHER, then the header
3329 * name must be supplied in this argument. Otherwise the
3330 * value must be set to NULL.
3331 * @param token The capability token to check. For example, if \a
3332 * htype is PJSIP_H_ALLOW, then \a token specifies the
3333 * method names; if \a htype is PJSIP_H_SUPPORTED, then
3334 * \a token specifies the extension names such as
3335 * "100rel".
3336 *
3337 * @return PJSIP_DIALOG_CAP_SUPPORTED if the specified capability
3338 * is explicitly supported, see @pjsip_dialog_cap_status
3339 * for more info.
3340 */
3341PJ_DECL(pjsip_dialog_cap_status) pjsua_call_remote_has_cap(
3342 pjsua_call_id call_id,
3343 int htype,
3344 const pj_str_t *hname,
3345 const pj_str_t *token);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003346
3347/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003348 * Attach application specific data to the call. Application can then
3349 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003350 *
3351 * @param call_id Call identification.
3352 * @param user_data Arbitrary data to be attached to the call.
3353 *
3354 * @return The user data.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003355 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003356PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
3357 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003358
3359
3360/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003361 * Get user data attached to the call, which has been previously set with
3362 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003363 *
3364 * @param call_id Call identification.
3365 *
3366 * @return The user data.
Benny Prijono268ca612006-02-07 12:34:11 +00003367 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003368PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00003369
3370
3371/**
Benny Prijono91a6a172007-10-31 08:59:29 +00003372 * Get the NAT type of remote's endpoint. This is a proprietary feature
3373 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
3374 * is set in #pjsua_config.
3375 *
3376 * This function can only be called after SDP has been received from remote,
3377 * which means for incoming call, this function can be called as soon as
3378 * call is received as long as incoming call contains SDP, and for outgoing
3379 * call, this function can be called only after SDP is received (normally in
3380 * 200/OK response to INVITE). As a general case, application should call
3381 * this function after or in \a on_call_media_state() callback.
3382 *
3383 * @param call_id Call identification.
3384 * @param p_type Pointer to store the NAT type. Application can then
3385 * retrieve the string description of the NAT type
3386 * by calling pj_stun_get_nat_name().
3387 *
3388 * @return PJ_SUCCESS on success.
3389 *
3390 * @see pjsua_get_nat_type(), nat_type_in_sdp
3391 */
3392PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
3393 pj_stun_nat_type *p_type);
3394
3395/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003396 * Send response to incoming INVITE request. Depending on the status
3397 * code specified as parameter, this function may send provisional
3398 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003399 *
3400 * @param call_id Incoming call identification.
3401 * @param code Status code, (100-699).
3402 * @param reason Optional reason phrase. If NULL, default text
3403 * will be used.
3404 * @param msg_data Optional list of headers etc to be added to outgoing
3405 * response message.
3406 *
3407 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoa91a0032006-02-26 21:23:45 +00003408 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003409PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
3410 unsigned code,
3411 const pj_str_t *reason,
3412 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00003413
3414/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003415 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00003416 * call state. This function is different than answering the call with
3417 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
3418 * will hangup the call regardless of the state and role of the call,
3419 * while #pjsua_call_answer() only works with incoming calls on EARLY
3420 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003421 *
3422 * @param call_id Call identification.
3423 * @param code Optional status code to be sent when we're rejecting
3424 * incoming call. If the value is zero, "603/Decline"
3425 * will be sent.
3426 * @param reason Optional reason phrase to be sent when we're rejecting
3427 * incoming call. If NULL, default text will be used.
3428 * @param msg_data Optional list of headers etc to be added to outgoing
3429 * request/response message.
3430 *
3431 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003432 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003433PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
3434 unsigned code,
3435 const pj_str_t *reason,
3436 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003437
Benny Prijono5e51a4e2008-11-27 00:06:46 +00003438/**
3439 * Accept or reject redirection response. Application MUST call this function
3440 * after it signaled PJSIP_REDIRECT_PENDING in the \a on_call_redirected()
3441 * callback, to notify the call whether to accept or reject the redirection
3442 * to the current target. Application can use the combination of
3443 * PJSIP_REDIRECT_PENDING command in \a on_call_redirected() callback and
3444 * this function to ask for user permission before redirecting the call.
3445 *
3446 * Note that if the application chooses to reject or stop redirection (by
3447 * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the
3448 * call disconnection callback will be called before this function returns.
3449 * And if the application rejects the target, the \a on_call_redirected()
3450 * callback may also be called before this function returns if there is
3451 * another target to try.
3452 *
3453 * @param call_id The call ID.
3454 * @param cmd Redirection operation to be applied to the current
3455 * target. The semantic of this argument is similar
3456 * to the description in the \a on_call_redirected()
3457 * callback, except that the PJSIP_REDIRECT_PENDING is
3458 * not accepted here.
3459 *
3460 * @return PJ_SUCCESS on successful operation.
3461 */
3462PJ_DECL(pj_status_t) pjsua_call_process_redirect(pjsua_call_id call_id,
3463 pjsip_redirect_op cmd);
Benny Prijono26ff9062006-02-21 23:47:00 +00003464
3465/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003466 * Put the specified call on hold. This will send re-INVITE with the
3467 * appropriate SDP to inform remote that the call is being put on hold.
3468 * The final status of the request itself will be reported on the
3469 * \a on_call_media_state() callback, which inform the application that
3470 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003471 *
3472 * @param call_id Call identification.
3473 * @param msg_data Optional message components to be sent with
3474 * the request.
3475 *
3476 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003477 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003478PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
3479 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003480
3481
3482/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003483 * Send re-INVITE to release hold.
3484 * The final status of the request itself will be reported on the
3485 * \a on_call_media_state() callback, which inform the application that
3486 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003487 *
3488 * @param call_id Call identification.
3489 * @param unhold If this argument is non-zero and the call is locally
3490 * held, this will release the local hold.
3491 * @param msg_data Optional message components to be sent with
3492 * the request.
3493 *
3494 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003495 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003496PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
3497 pj_bool_t unhold,
3498 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003499
Benny Prijonoc08682e2007-10-04 06:17:58 +00003500/**
3501 * Send UPDATE request.
3502 *
3503 * @param call_id Call identification.
3504 * @param options Must be zero for now.
3505 * @param msg_data Optional message components to be sent with
3506 * the request.
3507 *
3508 * @return PJ_SUCCESS on success, or the appropriate error code.
3509 */
3510PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
3511 unsigned options,
3512 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003513
3514/**
Benny Prijono053f5222006-11-11 16:16:04 +00003515 * Initiate call transfer to the specified address. This function will send
3516 * REFER request to instruct remote call party to initiate a new INVITE
3517 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003518 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00003519 * If application is interested to monitor the successfulness and
3520 * the progress of the transfer request, it can implement
3521 * \a on_call_transfer_status() callback which will report the progress
3522 * of the call transfer request.
3523 *
Benny Prijono053f5222006-11-11 16:16:04 +00003524 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003525 * @param dest Address of new target to be contacted.
3526 * @param msg_data Optional message components to be sent with
3527 * the request.
3528 *
3529 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003530 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003531PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
3532 const pj_str_t *dest,
3533 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003534
3535/**
Benny Prijono053f5222006-11-11 16:16:04 +00003536 * Flag to indicate that "Require: replaces" should not be put in the
3537 * outgoing INVITE request caused by REFER request created by
3538 * #pjsua_call_xfer_replaces().
3539 */
3540#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
3541
3542/**
3543 * Initiate attended call transfer. This function will send REFER request
3544 * to instruct remote call party to initiate new INVITE session to the URL
3545 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
3546 * the call with us with the new call from the REFER recipient.
3547 *
3548 * @param call_id The call id to be transfered.
3549 * @param dest_call_id The call id to be replaced.
3550 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
3551 * to suppress the inclusion of "Require: replaces" in
3552 * the outgoing INVITE request created by the REFER
3553 * request.
3554 * @param msg_data Optional message components to be sent with
3555 * the request.
3556 *
3557 * @return PJ_SUCCESS on success, or the appropriate error code.
3558 */
3559PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
3560 pjsua_call_id dest_call_id,
3561 unsigned options,
3562 const pjsua_msg_data *msg_data);
3563
3564/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003565 * Send DTMF digits to remote using RFC 2833 payload formats.
3566 *
3567 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003568 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003569 *
3570 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003571 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003572PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003573 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00003574
Benny Prijono26ff9062006-02-21 23:47:00 +00003575/**
Benny Prijonob0808372006-03-02 21:18:58 +00003576 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003577 *
3578 * @param call_id Call identification.
3579 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3580 * assumed.
3581 * @param content The message content.
3582 * @param msg_data Optional list of headers etc to be included in outgoing
3583 * request. The body descriptor in the msg_data is
3584 * ignored.
3585 * @param user_data Optional user data, which will be given back when
3586 * the IM callback is called.
3587 *
3588 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003589 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003590PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
3591 const pj_str_t *mime_type,
3592 const pj_str_t *content,
3593 const pjsua_msg_data *msg_data,
3594 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003595
3596
3597/**
3598 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003599 *
3600 * @param call_id Call identification.
3601 * @param is_typing Non-zero to indicate to remote that local person is
3602 * currently typing an IM.
3603 * @param msg_data Optional list of headers etc to be included in outgoing
3604 * request.
3605 *
3606 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003607 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003608PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
3609 pj_bool_t is_typing,
3610 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003611
3612/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00003613 * Send arbitrary request with the call. This is useful for example to send
3614 * INFO request. Note that application should not use this function to send
3615 * requests which would change the invite session's state, such as re-INVITE,
3616 * UPDATE, PRACK, and BYE.
3617 *
3618 * @param call_id Call identification.
3619 * @param method SIP method of the request.
3620 * @param msg_data Optional message body and/or list of headers to be
3621 * included in outgoing request.
3622 *
3623 * @return PJ_SUCCESS on success, or the appropriate error code.
3624 */
3625PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
3626 const pj_str_t *method,
3627 const pjsua_msg_data *msg_data);
3628
3629
3630/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003631 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
3632 * currently active calls.
Benny Prijono834aee32006-02-19 01:38:06 +00003633 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00003634PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00003635
3636
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003637/**
3638 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003639 *
3640 * @param call_id Call identification.
3641 * @param with_media Non-zero to include media information too.
3642 * @param buffer Buffer where the statistics are to be written to.
3643 * @param maxlen Maximum length of buffer.
3644 * @param indent Spaces for left indentation.
3645 *
3646 * @return PJ_SUCCESS on success.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003647 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003648PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
3649 pj_bool_t with_media,
3650 char *buffer,
3651 unsigned maxlen,
3652 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003653
Benny Prijono9fc735d2006-05-28 14:58:12 +00003654/**
Benny Prijono9f468d12011-07-07 07:46:33 +00003655 * Get the media stream index of the default video stream in the call.
3656 * Typically this will just retrieve the stream index of the first
3657 * activated video stream in the call.
3658 *
3659 * @param call_id Call identification.
3660 *
3661 * @return The media stream index or -1 if no video stream
3662 * is present in the call.
3663 */
3664PJ_DECL(int) pjsua_call_get_vid_stream_idx(pjsua_call_id call_id);
3665
3666/**
3667 * Start, stop, and/or manipulate video transmission for the specified
3668 * call. This would trigger a re-INVITE or UPDATE to be sent for the
3669 * call. This function may add, remove, or modify existing video media
3670 * stream, depending on the media index specified (the \a med_idx argument).
3671 *
3672 * To add a new or edit existing video stream (for transmission), specify
3673 * a valid video capture device ID or PJMEDIA_VID_DEFAULT_CAPTURE_DEV in
3674 * the \a cap_dev argument. If \a med_idx is set to default stream (-1),
3675 * then the function will modify existing video stream if one exists, or
3676 * add a new one if it doesn't. If \a med_idx is set to a specific stream
3677 * index, the function will modify that video stream. Otherwise if \a med_idx
3678 * is set to value larger than the current media count, a new video stream
3679 * will be added to the call.
3680 *
3681 * To remove an existing video stream, specify PJMEDIA_VID_INVALID_DEV in
3682 * \a cap_dev argument. If \a med_idx is set to default stream (-1), this
3683 * will remove the default/first video stream in the call, otherwise
3684 * application can put a specific value to request removal of that particular
3685 * video stream.
3686 *
3687 * @param call_id Call identification.
3688 * @param med_idx The media stream index. Currently the value MUST
3689 * be -1 to denote the default video stream in the
3690 * call.
3691 * @param cap_dev To add or modify existing video media stream,
3692 * specify PJMEDIA_VID_DEFAULT_CAPTURE_DEV to use
3693 * the default capture device as configured in the
3694 * account, or specify a specific capture device ID.
3695 * To disable an existing video stream, specify
3696 * PJMEDIA_VID_INVALID_DEV for this parameter.
3697 *
3698 * @return PJ_SUCCESS on success or the appropriate error.
3699 */
3700PJ_DECL(pj_status_t) pjsua_call_set_vid_out(pjsua_call_id call_id,
3701 int med_idx,
3702 pjmedia_vid_dev_index cap_dev);
3703
3704/**
3705 * Get media stream info for the specified media index.
3706 *
3707 * @param call_id The call identification.
3708 * @param med_idx Media stream index.
3709 * @param psi To be filled with the stream info.
3710 *
3711 * @return PJ_SUCCESS on success or the appropriate error.
3712 */
3713PJ_DECL(pj_status_t) pjsua_call_get_stream_info(pjsua_call_id call_id,
3714 unsigned med_idx,
3715 pjsua_stream_info *psi);
3716
3717/**
3718 * Get media stream statistic for the specified media index.
3719 *
3720 * @param call_id The call identification.
3721 * @param med_idx Media stream index.
3722 * @param psi To be filled with the stream statistic.
3723 *
3724 * @return PJ_SUCCESS on success or the appropriate error.
3725 */
3726PJ_DECL(pj_status_t) pjsua_call_get_stream_stat(pjsua_call_id call_id,
3727 unsigned med_idx,
3728 pjsua_stream_stat *stat);
3729
3730/**
3731 * Get media transport info for the specified media index.
3732 *
3733 * @param call_id The call identification.
3734 * @param med_idx Media stream index.
3735 * @param t To be filled with the transport info.
3736 *
3737 * @return PJ_SUCCESS on success or the appropriate error.
3738 */
3739PJ_DECL(pj_status_t) pjsua_call_get_transport_info(pjsua_call_id call_id,
3740 unsigned med_idx,
3741 pjmedia_transport_info *t);
3742
3743
3744
3745/**
Benny Prijono312aff92006-06-17 04:08:30 +00003746 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003747 */
Benny Prijono834aee32006-02-19 01:38:06 +00003748
3749
3750/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00003751 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00003752 */
3753
Benny Prijono312aff92006-06-17 04:08:30 +00003754
3755/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003756 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00003757 * @ingroup PJSUA_LIB
3758 * @brief Buddy management, buddy's presence, and instant messaging.
3759 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00003760 *
3761 * This section describes PJSUA-APIs related to buddies management,
3762 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00003763 */
3764
3765/**
3766 * Max buddies in buddy list.
3767 */
3768#ifndef PJSUA_MAX_BUDDIES
3769# define PJSUA_MAX_BUDDIES 256
3770#endif
3771
3772
3773/**
Benny Prijono6ab05322009-10-21 03:03:06 +00003774 * This specifies how long the library should wait before retrying failed
3775 * SUBSCRIBE request, and there is no rule to automatically resubscribe
3776 * (for example, no "retry-after" parameter in Subscription-State header).
3777 *
3778 * This also controls the duration before failed PUBLISH request will be
3779 * retried.
Benny Prijonoa17496a2007-10-31 10:20:31 +00003780 *
3781 * Default: 300 seconds
3782 */
3783#ifndef PJSUA_PRES_TIMER
3784# define PJSUA_PRES_TIMER 300
3785#endif
3786
3787
3788/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003789 * This structure describes buddy configuration when adding a buddy to
3790 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
3791 * the structure with #pjsua_buddy_config_default() to initialize this
3792 * structure with default configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00003793 */
3794typedef struct pjsua_buddy_config
3795{
3796 /**
3797 * Buddy URL or name address.
3798 */
3799 pj_str_t uri;
3800
3801 /**
3802 * Specify whether presence subscription should start immediately.
3803 */
3804 pj_bool_t subscribe;
3805
Benny Prijono705e7842008-07-21 18:12:51 +00003806 /**
3807 * Specify arbitrary application data to be associated with with
3808 * the buddy object.
3809 */
3810 void *user_data;
3811
Benny Prijono312aff92006-06-17 04:08:30 +00003812} pjsua_buddy_config;
3813
3814
3815/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003816 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003817 */
3818typedef enum pjsua_buddy_status
3819{
3820 /**
3821 * Online status is unknown (possibly because no presence subscription
3822 * has been established).
3823 */
3824 PJSUA_BUDDY_STATUS_UNKNOWN,
3825
3826 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003827 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003828 */
3829 PJSUA_BUDDY_STATUS_ONLINE,
3830
3831 /**
3832 * Buddy is offline.
3833 */
3834 PJSUA_BUDDY_STATUS_OFFLINE,
3835
3836} pjsua_buddy_status;
3837
3838
3839
3840/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003841 * This structure describes buddy info, which can be retrieved by calling
3842 * #pjsua_buddy_get_info().
Benny Prijono312aff92006-06-17 04:08:30 +00003843 */
3844typedef struct pjsua_buddy_info
3845{
3846 /**
3847 * The buddy ID.
3848 */
3849 pjsua_buddy_id id;
3850
3851 /**
3852 * The full URI of the buddy, as specified in the configuration.
3853 */
3854 pj_str_t uri;
3855
3856 /**
3857 * Buddy's Contact, only available when presence subscription has
3858 * been established to the buddy.
3859 */
3860 pj_str_t contact;
3861
3862 /**
3863 * Buddy's online status.
3864 */
3865 pjsua_buddy_status status;
3866
3867 /**
3868 * Text to describe buddy's online status.
3869 */
3870 pj_str_t status_text;
3871
3872 /**
3873 * Flag to indicate that we should monitor the presence information for
3874 * this buddy (normally yes, unless explicitly disabled).
3875 */
3876 pj_bool_t monitor_pres;
3877
3878 /**
Benny Prijono63fba012008-07-17 14:19:10 +00003879 * If \a monitor_pres is enabled, this specifies the last state of the
3880 * presence subscription. If presence subscription session is currently
3881 * active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence
3882 * subscription request has been rejected, the value will be
3883 * PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be
3884 * specified in \a sub_term_reason.
3885 */
3886 pjsip_evsub_state sub_state;
3887
3888 /**
Benny Prijonod06d8c52009-06-30 13:53:47 +00003889 * String representation of subscription state.
3890 */
3891 const char *sub_state_name;
3892
3893 /**
Benny Prijono73bb7232009-10-20 13:56:26 +00003894 * Specifies the last presence subscription termination code. This would
3895 * return the last status of the SUBSCRIBE request. If the subscription
3896 * is terminated with NOTIFY by the server, this value will be set to
3897 * 200, and subscription termination reason will be given in the
3898 * \a sub_term_reason field.
3899 */
3900 unsigned sub_term_code;
3901
3902 /**
3903 * Specifies the last presence subscription termination reason. If
Benny Prijono63fba012008-07-17 14:19:10 +00003904 * presence subscription is currently active, the value will be empty.
3905 */
3906 pj_str_t sub_term_reason;
3907
3908 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003909 * Extended RPID information about the person.
3910 */
3911 pjrpid_element rpid;
3912
3913 /**
Benny Prijono28add7e2009-06-15 16:03:40 +00003914 * Extended presence info.
3915 */
3916 pjsip_pres_status pres_status;
3917
3918 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003919 * Internal buffer.
3920 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003921 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003922
3923} pjsua_buddy_info;
3924
3925
Benny Prijono834aee32006-02-19 01:38:06 +00003926/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003927 * Set default values to the buddy config.
3928 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003929PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003930
3931
3932/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003933 * Get total number of buddies.
3934 *
3935 * @return Number of buddies.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003936 */
3937PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3938
3939
3940/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003941 * Check if buddy ID is valid.
3942 *
3943 * @param buddy_id Buddy ID to check.
3944 *
3945 * @return Non-zero if buddy ID is valid.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003946 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003947PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3948
3949
3950/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003951 * Enumerate all buddy IDs in the buddy list. Application then can use
3952 * #pjsua_buddy_get_info() to get the detail information for each buddy
3953 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003954 *
3955 * @param ids Array of ids to be initialized.
3956 * @param count On input, specifies max elements in the array.
3957 * On return, it contains actual number of elements
3958 * that have been initialized.
3959 *
3960 * @return PJ_SUCCESS on success, or the appropriate error code.
3961 */
3962PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3963 unsigned *count);
3964
3965/**
Benny Prijono705e7842008-07-21 18:12:51 +00003966 * Find the buddy ID with the specified URI.
3967 *
3968 * @param uri The buddy URI.
3969 *
3970 * @return The buddy ID, or PJSUA_INVALID_ID if not found.
3971 */
3972PJ_DECL(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri);
3973
3974
3975/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003976 * Get detailed buddy info.
3977 *
3978 * @param buddy_id The buddy identification.
3979 * @param info Pointer to receive information about buddy.
3980 *
3981 * @return PJ_SUCCESS on success, or the appropriate error code.
3982 */
3983PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003984 pjsua_buddy_info *info);
3985
3986/**
Benny Prijono705e7842008-07-21 18:12:51 +00003987 * Set the user data associated with the buddy object.
3988 *
3989 * @param buddy_id The buddy identification.
3990 * @param user_data Arbitrary application data to be associated with
3991 * the buddy object.
3992 *
3993 * @return PJ_SUCCESS on success, or the appropriate error code.
3994 */
3995PJ_DECL(pj_status_t) pjsua_buddy_set_user_data(pjsua_buddy_id buddy_id,
3996 void *user_data);
3997
3998
3999/**
4000 * Get the user data associated with the budy object.
4001 *
4002 * @param buddy_id The buddy identification.
4003 *
4004 * @return The application data.
4005 */
4006PJ_DECL(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id);
4007
4008
4009/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004010 * Add new buddy to the buddy list. If presence subscription is enabled
4011 * for this buddy, this function will also start the presence subscription
4012 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004013 *
Benny Prijonoa7b376b2008-01-25 16:06:33 +00004014 * @param buddy_cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004015 * @param p_buddy_id Pointer to receive buddy ID.
4016 *
4017 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004018 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004019PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004020 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004021
4022
4023/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004024 * Delete the specified buddy from the buddy list. Any presence subscription
4025 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004026 *
4027 * @param buddy_id Buddy identification.
4028 *
4029 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004030 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004031PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004032
4033
4034/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004035 * Enable/disable buddy's presence monitoring. Once buddy's presence is
4036 * subscribed, application will be informed about buddy's presence status
4037 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004038 *
4039 * @param buddy_id Buddy identification.
4040 * @param subscribe Specify non-zero to activate presence subscription to
4041 * the specified buddy.
4042 *
4043 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004044 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004045PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
4046 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004047
4048
4049/**
Benny Prijono10861432007-10-31 10:54:53 +00004050 * Update the presence information for the buddy. Although the library
4051 * periodically refreshes the presence subscription for all buddies, some
4052 * application may want to refresh the buddy's presence subscription
4053 * immediately, and in this case it can use this function to accomplish
4054 * this.
4055 *
4056 * Note that the buddy's presence subscription will only be initiated
4057 * if presence monitoring is enabled for the buddy. See
4058 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
4059 * for the buddy is already active, this function will not do anything.
4060 *
4061 * Once the presence subscription is activated successfully for the buddy,
4062 * application will be notified about the buddy's presence status in the
4063 * on_buddy_state() callback.
4064 *
4065 * @param buddy_id Buddy identification.
4066 *
4067 * @return PJ_SUCCESS on success, or the appropriate error code.
4068 */
4069PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
4070
4071
4072/**
Benny Prijono63fba012008-07-17 14:19:10 +00004073 * Send NOTIFY to inform account presence status or to terminate server
4074 * side presence subscription. If application wants to reject the incoming
4075 * request, it should set the \a state to PJSIP_EVSUB_STATE_TERMINATED.
4076 *
4077 * @param acc_id Account ID.
4078 * @param srv_pres Server presence subscription instance.
4079 * @param state New state to set.
4080 * @param state_str Optionally specify the state string name, if state
4081 * is not "active", "pending", or "terminated".
4082 * @param reason If the new state is PJSIP_EVSUB_STATE_TERMINATED,
4083 * optionally specify the termination reason.
4084 * @param with_body If the new state is PJSIP_EVSUB_STATE_TERMINATED,
4085 * this specifies whether the NOTIFY request should
4086 * contain message body containing account's presence
4087 * information.
4088 * @param msg_data Optional list of headers to be sent with the NOTIFY
4089 * request.
4090 *
4091 * @return PJ_SUCCESS on success.
4092 */
4093PJ_DECL(pj_status_t) pjsua_pres_notify(pjsua_acc_id acc_id,
4094 pjsua_srv_pres *srv_pres,
4095 pjsip_evsub_state state,
4096 const pj_str_t *state_str,
4097 const pj_str_t *reason,
4098 pj_bool_t with_body,
4099 const pjsua_msg_data *msg_data);
4100
4101/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004102 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004103 *
4104 * @param verbose Yes or no.
Benny Prijono834aee32006-02-19 01:38:06 +00004105 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004106PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00004107
4108
Benny Prijonob0808372006-03-02 21:18:58 +00004109/**
4110 * The MESSAGE method (defined in pjsua_im.c)
4111 */
4112extern const pjsip_method pjsip_message_method;
4113
4114
Benny Prijonob0808372006-03-02 21:18:58 +00004115
4116/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004117 * Send instant messaging outside dialog, using the specified account for
4118 * route set and authentication.
4119 *
4120 * @param acc_id Account ID to be used to send the request.
4121 * @param to Remote URI.
4122 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
4123 * assumed.
4124 * @param content The message content.
4125 * @param msg_data Optional list of headers etc to be included in outgoing
4126 * request. The body descriptor in the msg_data is
4127 * ignored.
4128 * @param user_data Optional user data, which will be given back when
4129 * the IM callback is called.
4130 *
4131 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00004132 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004133PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
4134 const pj_str_t *to,
4135 const pj_str_t *mime_type,
4136 const pj_str_t *content,
4137 const pjsua_msg_data *msg_data,
4138 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00004139
4140
4141/**
4142 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004143 *
4144 * @param acc_id Account ID to be used to send the request.
4145 * @param to Remote URI.
4146 * @param is_typing If non-zero, it tells remote person that local person
4147 * is currently composing an IM.
4148 * @param msg_data Optional list of headers etc to be added to outgoing
4149 * request.
4150 *
4151 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00004152 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004153PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
4154 const pj_str_t *to,
4155 pj_bool_t is_typing,
4156 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00004157
4158
Benny Prijonof3195072006-02-14 21:15:30 +00004159
Benny Prijono312aff92006-06-17 04:08:30 +00004160/**
4161 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00004162 */
4163
Benny Prijono312aff92006-06-17 04:08:30 +00004164
4165/*****************************************************************************
4166 * MEDIA API
4167 */
4168
4169
4170/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00004171 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00004172 * @ingroup PJSUA_LIB
4173 * @brief Media manipulation.
4174 * @{
4175 *
4176 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00004177 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
4178 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00004179 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00004180 * the interconnection between these terminations freely.
4181 *
4182 * The conference bridge provides powerful switching and mixing functionality
4183 * for application. With the conference bridge, each conference slot (e.g.
4184 * a call) can transmit to multiple destinations, and one destination can
4185 * receive from multiple sources. If more than one media terminations are
4186 * terminated in the same slot, the conference bridge will mix the signal
4187 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00004188 *
4189 * Application connects one media termination/slot to another by calling
4190 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00004191 * media flow from the source termination to the sink termination. To
4192 * establish bidirectional media flow, application wound need to make another
4193 * call to #pjsua_conf_connect(), this time inverting the source and
4194 * destination slots in the parameter.
4195 *
4196 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00004197 * the following steps:
4198 *
4199 \code
4200
4201 pj_status_t stream_to_call( pjsua_call_id call_id )
4202 {
4203 pjsua_player_id player_id;
4204
4205 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
4206 if (status != PJ_SUCCESS)
4207 return status;
4208
4209 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
4210 pjsua_call_get_conf_port() );
4211 }
4212 \endcode
4213 *
4214 *
4215 * Other features of PJSUA media:
4216 * - efficient N to M interconnections between media terminations.
4217 * - media termination can be connected to itself to create loopback
4218 * media.
4219 * - the media termination may have different clock rates, and resampling
4220 * will be done automatically by conference bridge.
4221 * - media terminations may also have different frame time; the
4222 * conference bridge will perform the necessary bufferring to adjust
4223 * the difference between terminations.
4224 * - interconnections are removed automatically when media termination
4225 * is removed from the bridge.
4226 * - sound device may be changed even when there are active media
4227 * interconnections.
4228 * - correctly report call's media quality (in #pjsua_call_dump()) from
4229 * RTCP packet exchange.
4230 */
4231
4232/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004233 * Max ports in the conference bridge. This setting is the default value
4234 * for pjsua_media_config.max_media_ports.
Benny Prijono312aff92006-06-17 04:08:30 +00004235 */
4236#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00004237# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00004238#endif
4239
Benny Prijonob5388cf2007-01-04 22:45:08 +00004240/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004241 * The default clock rate to be used by the conference bridge. This setting
4242 * is the default value for pjsua_media_config.clock_rate.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004243 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004244#ifndef PJSUA_DEFAULT_CLOCK_RATE
4245# define PJSUA_DEFAULT_CLOCK_RATE 16000
4246#endif
4247
Benny Prijonob5388cf2007-01-04 22:45:08 +00004248/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004249 * Default frame length in the conference bridge. This setting
4250 * is the default value for pjsua_media_config.audio_frame_ptime.
4251 */
4252#ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Nanang Izzuddinaf974842008-05-08 09:51:16 +00004253# define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
Benny Prijono37c710b2008-01-10 12:09:26 +00004254#endif
4255
4256
4257/**
4258 * Default codec quality settings. This setting is the default value
4259 * for pjsua_media_config.quality.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004260 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004261#ifndef PJSUA_DEFAULT_CODEC_QUALITY
Nanang Izzuddin9dbad152008-06-10 18:56:10 +00004262# define PJSUA_DEFAULT_CODEC_QUALITY 8
Benny Prijono12a669c2006-11-23 07:32:13 +00004263#endif
4264
Benny Prijonob5388cf2007-01-04 22:45:08 +00004265/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004266 * Default iLBC mode. This setting is the default value for
4267 * pjsua_media_config.ilbc_mode.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004268 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004269#ifndef PJSUA_DEFAULT_ILBC_MODE
Benny Prijono37c710b2008-01-10 12:09:26 +00004270# define PJSUA_DEFAULT_ILBC_MODE 30
Benny Prijono12a669c2006-11-23 07:32:13 +00004271#endif
4272
Benny Prijonob5388cf2007-01-04 22:45:08 +00004273/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004274 * The default echo canceller tail length. This setting
4275 * is the default value for pjsua_media_config.ec_tail_len.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004276 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004277#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijono427439c2007-10-21 09:41:24 +00004278# define PJSUA_DEFAULT_EC_TAIL_LEN 200
Benny Prijono12a669c2006-11-23 07:32:13 +00004279#endif
Benny Prijono312aff92006-06-17 04:08:30 +00004280
4281
4282/**
Benny Prijonocba59d92007-02-16 09:22:56 +00004283 * The maximum file player.
4284 */
4285#ifndef PJSUA_MAX_PLAYERS
4286# define PJSUA_MAX_PLAYERS 32
4287#endif
4288
4289
4290/**
4291 * The maximum file player.
4292 */
4293#ifndef PJSUA_MAX_RECORDERS
4294# define PJSUA_MAX_RECORDERS 32
4295#endif
4296
4297
4298/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004299 * This structure describes media configuration, which will be specified
4300 * when calling #pjsua_init(). Application MUST initialize this structure
4301 * by calling #pjsua_media_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00004302 */
4303struct pjsua_media_config
4304{
4305 /**
4306 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004307 * If value is zero, default clock rate will be used
4308 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00004309 */
4310 unsigned clock_rate;
4311
4312 /**
Benny Prijonof3758ee2008-02-26 15:32:16 +00004313 * Clock rate to be applied when opening the sound device.
4314 * If value is zero, conference bridge clock rate will be used.
4315 */
4316 unsigned snd_clock_rate;
4317
4318 /**
Benny Prijono7d60d052008-03-29 12:24:20 +00004319 * Channel count be applied when opening the sound device and
4320 * conference bridge.
4321 */
4322 unsigned channel_count;
4323
4324 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004325 * Specify audio frame ptime. The value here will affect the
4326 * samples per frame of both the sound device and the conference
4327 * bridge. Specifying lower ptime will normally reduce the
4328 * latency.
4329 *
Benny Prijono37c710b2008-01-10 12:09:26 +00004330 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004331 */
4332 unsigned audio_frame_ptime;
4333
4334 /**
Benny Prijono312aff92006-06-17 04:08:30 +00004335 * Specify maximum number of media ports to be created in the
4336 * conference bridge. Since all media terminate in the bridge
4337 * (calls, file player, file recorder, etc), the value must be
4338 * large enough to support all of them. However, the larger
4339 * the value, the more computations are performed.
Benny Prijono37c710b2008-01-10 12:09:26 +00004340 *
4341 * Default value: PJSUA_MAX_CONF_PORTS
Benny Prijono312aff92006-06-17 04:08:30 +00004342 */
4343 unsigned max_media_ports;
4344
4345 /**
4346 * Specify whether the media manager should manage its own
4347 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
4348 * and at least one worker thread will be created too. If no,
4349 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
4350 * and no worker thread is needed.
4351 *
4352 * Normally application would say yes here, unless it wants to
4353 * run everything from a single thread.
4354 */
4355 pj_bool_t has_ioqueue;
4356
4357 /**
4358 * Specify the number of worker threads to handle incoming RTP
4359 * packets. A value of one is recommended for most applications.
4360 */
4361 unsigned thread_cnt;
4362
Benny Prijono0498d902006-06-19 14:49:14 +00004363 /**
4364 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00004365 * 5-10: resampling use large filter,
4366 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00004367 * 1-2: resampling use linear.
4368 * The media quality also sets speex codec quality/complexity to the
4369 * number.
4370 *
Benny Prijono70972992006-08-05 11:13:58 +00004371 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00004372 */
4373 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00004374
4375 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004376 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00004377 *
4378 * Default: 0 (codec specific)
4379 */
4380 unsigned ptime;
4381
4382 /**
4383 * Disable VAD?
4384 *
4385 * Default: 0 (no (meaning VAD is enabled))
4386 */
4387 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00004388
4389 /**
4390 * iLBC mode (20 or 30).
4391 *
Benny Prijono37c710b2008-01-10 12:09:26 +00004392 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00004393 */
4394 unsigned ilbc_mode;
4395
4396 /**
4397 * Percentage of RTP packet to drop in TX direction
4398 * (to simulate packet lost).
4399 *
4400 * Default: 0
4401 */
4402 unsigned tx_drop_pct;
4403
4404 /**
4405 * Percentage of RTP packet to drop in RX direction
4406 * (to simulate packet lost).
4407 *
4408 * Default: 0
4409 */
4410 unsigned rx_drop_pct;
4411
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004412 /**
Benny Prijono5da50432006-08-07 10:24:52 +00004413 * Echo canceller options (see #pjmedia_echo_create())
4414 *
4415 * Default: 0.
4416 */
4417 unsigned ec_options;
4418
4419 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004420 * Echo canceller tail length, in miliseconds.
4421 *
Benny Prijono669643c2006-09-20 20:02:18 +00004422 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004423 */
4424 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004425
Benny Prijono10454dc2009-02-21 14:21:59 +00004426 /**
4427 * Audio capture buffer length, in milliseconds.
4428 *
4429 * Default: PJMEDIA_SND_DEFAULT_REC_LATENCY
4430 */
4431 unsigned snd_rec_latency;
4432
4433 /**
4434 * Audio playback buffer length, in milliseconds.
4435 *
4436 * Default: PJMEDIA_SND_DEFAULT_PLAY_LATENCY
4437 */
4438 unsigned snd_play_latency;
4439
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004440 /**
4441 * Jitter buffer initial prefetch delay in msec. The value must be
4442 * between jb_min_pre and jb_max_pre below.
4443 *
4444 * Default: -1 (to use default stream settings, currently 150 msec)
4445 */
4446 int jb_init;
4447
4448 /**
4449 * Jitter buffer minimum prefetch delay in msec.
4450 *
4451 * Default: -1 (to use default stream settings, currently 60 msec)
4452 */
4453 int jb_min_pre;
4454
4455 /**
4456 * Jitter buffer maximum prefetch delay in msec.
4457 *
4458 * Default: -1 (to use default stream settings, currently 240 msec)
4459 */
4460 int jb_max_pre;
4461
4462 /**
4463 * Set maximum delay that can be accomodated by the jitter buffer msec.
4464 *
4465 * Default: -1 (to use default stream settings, currently 360 msec)
4466 */
4467 int jb_max;
4468
Benny Prijonoc97608e2007-03-23 16:34:20 +00004469 /**
4470 * Enable ICE
4471 */
4472 pj_bool_t enable_ice;
4473
4474 /**
Benny Prijono329d6382009-05-29 13:04:03 +00004475 * Set the maximum number of host candidates.
4476 *
4477 * Default: -1 (maximum not set)
Benny Prijonoc97608e2007-03-23 16:34:20 +00004478 */
Benny Prijono329d6382009-05-29 13:04:03 +00004479 int ice_max_host_cands;
4480
4481 /**
4482 * ICE session options.
4483 */
4484 pj_ice_sess_options ice_opt;
Benny Prijonof76e1392008-06-06 14:51:48 +00004485
4486 /**
Benny Prijono551af422008-08-07 09:55:52 +00004487 * Disable RTCP component.
4488 *
4489 * Default: no
4490 */
4491 pj_bool_t ice_no_rtcp;
4492
4493 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00004494 * Enable TURN relay candidate in ICE.
4495 */
4496 pj_bool_t enable_turn;
4497
4498 /**
4499 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
4500 * "HOST:PORT" format.
4501 */
4502 pj_str_t turn_server;
4503
4504 /**
4505 * Specify the connection type to be used to the TURN server. Valid
4506 * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP.
4507 *
4508 * Default: PJ_TURN_TP_UDP
4509 */
4510 pj_turn_tp_type turn_conn_type;
4511
4512 /**
4513 * Specify the credential to authenticate with the TURN server.
4514 */
4515 pj_stun_auth_cred turn_auth_cred;
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004516
4517 /**
4518 * Specify idle time of sound device before it is automatically closed,
Benny Prijonof798e502009-03-09 13:08:16 +00004519 * in seconds. Use value -1 to disable the auto-close feature of sound
4520 * device
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004521 *
Benny Prijonof798e502009-03-09 13:08:16 +00004522 * Default : 1
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004523 */
4524 int snd_auto_close_time;
Benny Prijono312aff92006-06-17 04:08:30 +00004525};
4526
4527
4528/**
4529 * Use this function to initialize media config.
4530 *
4531 * @param cfg The media config to be initialized.
4532 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00004533PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00004534
4535
4536/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004537 * This structure describes codec information, which can be retrieved by
4538 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00004539 */
4540typedef struct pjsua_codec_info
4541{
4542 /**
4543 * Codec unique identification.
4544 */
4545 pj_str_t codec_id;
4546
4547 /**
4548 * Codec priority (integer 0-255).
4549 */
4550 pj_uint8_t priority;
4551
4552 /**
Nanang Izzuddin56b2ce42011-04-06 13:55:01 +00004553 * Codec description.
4554 */
4555 pj_str_t desc;
4556
4557 /**
Benny Prijono312aff92006-06-17 04:08:30 +00004558 * Internal buffer.
4559 */
Nanang Izzuddin56b2ce42011-04-06 13:55:01 +00004560 char buf_[64];
Benny Prijono312aff92006-06-17 04:08:30 +00004561
4562} pjsua_codec_info;
4563
4564
4565/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004566 * This structure descibes information about a particular media port that
4567 * has been registered into the conference bridge. Application can query
4568 * this info by calling #pjsua_conf_get_port_info().
Benny Prijono312aff92006-06-17 04:08:30 +00004569 */
4570typedef struct pjsua_conf_port_info
4571{
4572 /** Conference port number. */
4573 pjsua_conf_port_id slot_id;
4574
4575 /** Port name. */
4576 pj_str_t name;
4577
4578 /** Clock rate. */
4579 unsigned clock_rate;
4580
4581 /** Number of channels. */
4582 unsigned channel_count;
4583
4584 /** Samples per frame */
4585 unsigned samples_per_frame;
4586
4587 /** Bits per sample */
4588 unsigned bits_per_sample;
4589
4590 /** Number of listeners in the array. */
4591 unsigned listener_cnt;
4592
4593 /** Array of listeners (in other words, ports where this port is
4594 * transmitting to.
4595 */
4596 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
4597
4598} pjsua_conf_port_info;
4599
4600
4601/**
4602 * This structure holds information about custom media transport to
4603 * be registered to pjsua.
4604 */
4605typedef struct pjsua_media_transport
4606{
4607 /**
4608 * Media socket information containing the address information
4609 * of the RTP and RTCP socket.
4610 */
4611 pjmedia_sock_info skinfo;
4612
4613 /**
4614 * The media transport instance.
4615 */
4616 pjmedia_transport *transport;
4617
4618} pjsua_media_transport;
4619
4620
Benny Prijono9fc735d2006-05-28 14:58:12 +00004621/**
4622 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004623 *
4624 * @return Maximum number of ports in the conference bridge.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004625 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004626PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004627
4628
4629/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004630 * Get current number of active ports in the bridge.
4631 *
4632 * @return The number.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004633 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004634PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
4635
4636
4637/**
4638 * Enumerate all conference ports.
4639 *
4640 * @param id Array of conference port ID to be initialized.
4641 * @param count On input, specifies max elements in the array.
4642 * On return, it contains actual number of elements
4643 * that have been initialized.
4644 *
4645 * @return PJ_SUCCESS on success, or the appropriate error code.
4646 */
4647PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
4648 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004649
4650
4651/**
4652 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004653 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004654 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004655 * @param info Pointer to store the port info.
4656 *
4657 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004658 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004659PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00004660 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004661
4662
4663/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00004664 * Add arbitrary media port to PJSUA's conference bridge. Application
4665 * can use this function to add the media port that it creates. For
4666 * media ports that are created by PJSUA-LIB (such as calls, file player,
4667 * or file recorder), PJSUA-LIB will automatically add the port to
4668 * the bridge.
4669 *
4670 * @param pool Pool to use.
4671 * @param port Media port to be added to the bridge.
4672 * @param p_id Optional pointer to receive the conference
4673 * slot id.
4674 *
4675 * @return PJ_SUCCESS on success, or the appropriate error code.
4676 */
4677PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
4678 pjmedia_port *port,
4679 pjsua_conf_port_id *p_id);
4680
4681
4682/**
4683 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00004684 * call this function if it registered the port manually with previous call
4685 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00004686 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004687 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00004688 *
4689 * @return PJ_SUCCESS on success, or the appropriate error code.
4690 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004691PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00004692
4693
4694/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004695 * Establish unidirectional media flow from souce to sink. One source
4696 * may transmit to multiple destinations/sink. And if multiple
4697 * sources are transmitting to the same sink, the media will be mixed
4698 * together. Source and sink may refer to the same ID, effectively
4699 * looping the media.
4700 *
4701 * If bidirectional media flow is desired, application needs to call
4702 * this function twice, with the second one having the arguments
4703 * reversed.
4704 *
4705 * @param source Port ID of the source media/transmitter.
4706 * @param sink Port ID of the destination media/received.
4707 *
4708 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004709 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004710PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
4711 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004712
4713
4714/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004715 * Disconnect media flow from the source to destination port.
4716 *
4717 * @param source Port ID of the source media/transmitter.
4718 * @param sink Port ID of the destination media/received.
4719 *
4720 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004721 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004722PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
4723 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004724
4725
Benny Prijono6dd967c2006-12-26 02:27:14 +00004726/**
4727 * Adjust the signal level to be transmitted from the bridge to the
4728 * specified port by making it louder or quieter.
4729 *
4730 * @param slot The conference bridge slot number.
4731 * @param level Signal level adjustment. Value 1.0 means no level
4732 * adjustment, while value 0 means to mute the port.
4733 *
4734 * @return PJ_SUCCESS on success, or the appropriate error code.
4735 */
4736PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
4737 float level);
4738
4739/**
4740 * Adjust the signal level to be received from the specified port (to
4741 * the bridge) by making it louder or quieter.
4742 *
4743 * @param slot The conference bridge slot number.
4744 * @param level Signal level adjustment. Value 1.0 means no level
4745 * adjustment, while value 0 means to mute the port.
4746 *
4747 * @return PJ_SUCCESS on success, or the appropriate error code.
4748 */
4749PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
4750 float level);
4751
4752/**
4753 * Get last signal level transmitted to or received from the specified port.
4754 * The signal level is an integer value in zero to 255, with zero indicates
4755 * no signal, and 255 indicates the loudest signal level.
4756 *
4757 * @param slot The conference bridge slot number.
4758 * @param tx_level Optional argument to receive the level of signal
4759 * transmitted to the specified port (i.e. the direction
4760 * is from the bridge to the port).
4761 * @param rx_level Optional argument to receive the level of signal
4762 * received from the port (i.e. the direction is from the
4763 * port to the bridge).
4764 *
4765 * @return PJ_SUCCESS on success.
4766 */
4767PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
4768 unsigned *tx_level,
4769 unsigned *rx_level);
4770
Benny Prijono6dd967c2006-12-26 02:27:14 +00004771
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004772/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00004773 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004774 */
4775
Benny Prijono9fc735d2006-05-28 14:58:12 +00004776/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004777 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004778 * the conference bridge.
4779 *
4780 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00004781 * WAV files are supported, and the WAV file MUST be
4782 * formatted as 16bit PCM mono/single channel (any
4783 * clock rate is supported).
Benny Prijono58add7c2008-01-18 13:24:07 +00004784 * @param options Optional option flag. Application may specify
4785 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004786 * @param p_id Pointer to receive player ID.
4787 *
4788 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004789 */
4790PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004791 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004792 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004793
4794
4795/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004796 * Create a file playlist media port, and automatically add the port
4797 * to the conference bridge.
4798 *
4799 * @param file_names Array of file names to be added to the play list.
4800 * Note that the files must have the same clock rate,
4801 * number of channels, and number of bits per sample.
4802 * @param file_count Number of files in the array.
4803 * @param label Optional label to be set for the media port.
4804 * @param options Optional option flag. Application may specify
4805 * PJMEDIA_FILE_NO_LOOP to prevent looping.
4806 * @param p_id Optional pointer to receive player ID.
4807 *
4808 * @return PJ_SUCCESS on success, or the appropriate error code.
4809 */
4810PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
4811 unsigned file_count,
4812 const pj_str_t *label,
4813 unsigned options,
4814 pjsua_player_id *p_id);
4815
4816/**
4817 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004818 *
4819 * @param id The file player ID.
4820 *
4821 * @return Conference port ID associated with this player.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004822 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004823PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004824
4825
4826/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004827 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00004828 *
4829 * @param id The player ID.
4830 * @param p_port The media port associated with the player.
4831 *
4832 * @return PJ_SUCCESS on success.
4833 */
Benny Prijono58add7c2008-01-18 13:24:07 +00004834PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
Benny Prijono469b1522006-12-26 03:05:17 +00004835 pjmedia_port **p_port);
4836
4837/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004838 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004839 *
4840 * @param id The file player ID.
4841 * @param samples The playback position, in samples. Application can
4842 * specify zero to re-start the playback.
4843 *
4844 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004845 */
4846PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
4847 pj_uint32_t samples);
4848
4849
4850/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004851 * Close the file of playlist, remove the player from the bridge, and free
4852 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004853 *
4854 * @param id The file player ID.
4855 *
4856 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004857 */
4858PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
4859
4860
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004861/*****************************************************************************
4862 * File recorder.
4863 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00004864
4865/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004866 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004867 * the conference bridge. The recorder currently supports recording WAV file.
4868 * The type of the recorder to use is determined by the extension of the file
4869 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004870 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00004871 * @param filename Output file name. The function will determine the
4872 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004873 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00004874 * @param enc_type Optionally specify the type of encoder to be used to
4875 * compress the media, if the file can support different
4876 * encodings. This value must be zero for now.
4877 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004878 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00004879 * For .WAV recorder, this value must be NULL.
4880 * @param max_size Maximum file size. Specify zero or -1 to remove size
4881 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004882 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004883 * @param p_id Pointer to receive the recorder instance.
4884 *
4885 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004886 */
4887PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004888 unsigned enc_type,
4889 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004890 pj_ssize_t max_size,
4891 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004892 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004893
4894
4895/**
4896 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004897 *
4898 * @param id The recorder ID.
4899 *
4900 * @return Conference port ID associated with this recorder.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004901 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004902PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004903
4904
4905/**
Benny Prijono469b1522006-12-26 03:05:17 +00004906 * Get the media port for the recorder.
4907 *
4908 * @param id The recorder ID.
4909 * @param p_port The media port associated with the recorder.
4910 *
4911 * @return PJ_SUCCESS on success.
4912 */
4913PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4914 pjmedia_port **p_port);
4915
4916
4917/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004918 * Destroy recorder (this will complete recording).
4919 *
4920 * @param id The recorder ID.
4921 *
4922 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004923 */
4924PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4925
4926
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004927/*****************************************************************************
4928 * Sound devices.
4929 */
4930
Benny Prijono9fc735d2006-05-28 14:58:12 +00004931/**
Benny Prijonof798e502009-03-09 13:08:16 +00004932 * Enum all audio devices installed in the system.
4933 *
4934 * @param info Array of info to be initialized.
4935 * @param count On input, specifies max elements in the array.
4936 * On return, it contains actual number of elements
4937 * that have been initialized.
4938 *
4939 * @return PJ_SUCCESS on success, or the appropriate error code.
4940 */
4941PJ_DECL(pj_status_t) pjsua_enum_aud_devs(pjmedia_aud_dev_info info[],
4942 unsigned *count);
4943
4944/**
4945 * Enum all sound devices installed in the system (old API).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004946 *
4947 * @param info Array of info to be initialized.
4948 * @param count On input, specifies max elements in the array.
4949 * On return, it contains actual number of elements
4950 * that have been initialized.
4951 *
4952 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004953 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004954PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4955 unsigned *count);
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004956
4957/**
4958 * Get currently active sound devices. If sound devices has not been created
4959 * (for example when pjsua_start() is not called), it is possible that
4960 * the function returns PJ_SUCCESS with -1 as device IDs.
4961 *
4962 * @param capture_dev On return it will be filled with device ID of the
4963 * capture device.
4964 * @param playback_dev On return it will be filled with device ID of the
4965 * device ID of the playback device.
4966 *
4967 * @return PJ_SUCCESS on success, or the appropriate error code.
4968 */
4969PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4970 int *playback_dev);
4971
4972
Benny Prijono9fc735d2006-05-28 14:58:12 +00004973/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004974 * Select or change sound device. Application may call this function at
4975 * any time to replace current sound device.
4976 *
4977 * @param capture_dev Device ID of the capture device.
4978 * @param playback_dev Device ID of the playback device.
4979 *
4980 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004981 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004982PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4983 int playback_dev);
4984
4985
4986/**
4987 * Set pjsua to use null sound device. The null sound device only provides
4988 * the timing needed by the conference bridge, and will not interract with
4989 * any hardware.
4990 *
4991 * @return PJ_SUCCESS on success, or the appropriate error code.
4992 */
4993PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4994
4995
Benny Prijonoe909eac2006-07-27 22:04:56 +00004996/**
4997 * Disconnect the main conference bridge from any sound devices, and let
4998 * application connect the bridge to it's own sound device/master port.
4999 *
5000 * @return The port interface of the conference bridge,
5001 * so that application can connect this to it's own
5002 * sound device or master port.
5003 */
5004PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
5005
5006
Benny Prijonof20687a2006-08-04 18:27:19 +00005007/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00005008 * Change the echo cancellation settings.
Benny Prijonof798e502009-03-09 13:08:16 +00005009 *
5010 * The behavior of this function depends on whether the sound device is
5011 * currently active, and if it is, whether device or software AEC is
5012 * being used.
Benny Prijono10454dc2009-02-21 14:21:59 +00005013 *
5014 * If the sound device is currently active, and if the device supports AEC,
5015 * this function will forward the change request to the device and it will
5016 * be up to the device on whether support the request. If software AEC is
5017 * being used (the software EC will be used if the device does not support
5018 * AEC), this function will change the software EC settings. In all cases,
5019 * the setting will be saved for future opening of the sound device.
5020 *
5021 * If the sound device is not currently active, this will only change the
5022 * default AEC settings and the setting will be applied next time the
5023 * sound device is opened.
Benny Prijonof20687a2006-08-04 18:27:19 +00005024 *
5025 * @param tail_ms The tail length, in miliseconds. Set to zero to
5026 * disable AEC.
Benny Prijonoa7b376b2008-01-25 16:06:33 +00005027 * @param options Options to be passed to pjmedia_echo_create().
Benny Prijono5da50432006-08-07 10:24:52 +00005028 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00005029 *
5030 * @return PJ_SUCCESS on success.
5031 */
Benny Prijono5da50432006-08-07 10:24:52 +00005032PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00005033
5034
5035/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00005036 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00005037 *
5038 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
5039 * If AEC is disabled, the value will be zero.
5040 *
5041 * @return PJ_SUCCESS on success.
5042 */
Benny Prijono22dfe592006-08-06 12:07:13 +00005043PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00005044
5045
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00005046/**
Benny Prijonof798e502009-03-09 13:08:16 +00005047 * Check whether the sound device is currently active. The sound device
5048 * may be inactive if the application has set the auto close feature to
5049 * non-zero (the snd_auto_close_time setting in #pjsua_media_config), or
5050 * if null sound device or no sound device has been configured via the
5051 * #pjsua_set_no_snd_dev() function.
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00005052 */
Benny Prijonof798e502009-03-09 13:08:16 +00005053PJ_DECL(pj_bool_t) pjsua_snd_is_active(void);
5054
5055
5056/**
5057 * Configure sound device setting to the sound device being used. If sound
5058 * device is currently active, the function will forward the setting to the
5059 * sound device instance to be applied immediately, if it supports it.
5060 *
5061 * The setting will be saved for future opening of the sound device, if the
5062 * "keep" argument is set to non-zero. If the sound device is currently
5063 * inactive, and the "keep" argument is false, this function will return
5064 * error.
5065 *
5066 * Note that in case the setting is kept for future use, it will be applied
5067 * to any devices, even when application has changed the sound device to be
5068 * used.
5069 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00005070 * Note also that the echo cancellation setting should be set with
5071 * #pjsua_set_ec() API instead.
5072 *
Benny Prijonof798e502009-03-09 13:08:16 +00005073 * See also #pjmedia_aud_stream_set_cap() for more information about setting
5074 * an audio device capability.
5075 *
5076 * @param cap The sound device setting to change.
5077 * @param pval Pointer to value. Please see #pjmedia_aud_dev_cap
5078 * documentation about the type of value to be
5079 * supplied for each setting.
5080 * @param keep Specify whether the setting is to be kept for future
5081 * use.
5082 *
5083 * @return PJ_SUCCESS on success or the appropriate error code.
5084 */
5085PJ_DECL(pj_status_t) pjsua_snd_set_setting(pjmedia_aud_dev_cap cap,
5086 const void *pval,
5087 pj_bool_t keep);
5088
5089/**
5090 * Retrieve a sound device setting. If sound device is currently active,
5091 * the function will forward the request to the sound device. If sound device
5092 * is currently inactive, and if application had previously set the setting
5093 * and mark the setting as kept, then that setting will be returned.
5094 * Otherwise, this function will return error.
5095 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00005096 * Note that echo cancellation settings should be retrieved with
5097 * #pjsua_get_ec_tail() API instead.
5098 *
Benny Prijonof798e502009-03-09 13:08:16 +00005099 * @param cap The sound device setting to retrieve.
5100 * @param pval Pointer to receive the value.
5101 * Please see #pjmedia_aud_dev_cap documentation about
5102 * the type of value to be supplied for each setting.
5103 *
5104 * @return PJ_SUCCESS on success or the appropriate error code.
5105 */
5106PJ_DECL(pj_status_t) pjsua_snd_get_setting(pjmedia_aud_dev_cap cap,
5107 void *pval);
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00005108
5109
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005110/*****************************************************************************
5111 * Codecs.
5112 */
5113
5114/**
5115 * Enum all supported codecs in the system.
5116 *
5117 * @param id Array of ID to be initialized.
5118 * @param count On input, specifies max elements in the array.
5119 * On return, it contains actual number of elements
5120 * that have been initialized.
5121 *
5122 * @return PJ_SUCCESS on success, or the appropriate error code.
5123 */
5124PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
5125 unsigned *count );
5126
5127
5128/**
5129 * Change codec priority.
5130 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00005131 * @param codec_id Codec ID, which is a string that uniquely identify
5132 * the codec (such as "speex/8000"). Please see pjsua
5133 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005134 * @param priority Codec priority, 0-255, where zero means to disable
5135 * the codec.
5136 *
5137 * @return PJ_SUCCESS on success, or the appropriate error code.
5138 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00005139PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005140 pj_uint8_t priority );
5141
5142
5143/**
5144 * Get codec parameters.
5145 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00005146 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005147 * @param param Structure to receive codec parameters.
5148 *
5149 * @return PJ_SUCCESS on success, or the appropriate error code.
5150 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00005151PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005152 pjmedia_codec_param *param );
5153
5154
5155/**
5156 * Set codec parameters.
5157 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00005158 * @param codec_id Codec ID.
Nanang Izzuddin06839e72010-01-27 11:48:31 +00005159 * @param param Codec parameter to set. Set to NULL to reset
5160 * codec parameter to library default settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005161 *
5162 * @return PJ_SUCCESS on success, or the appropriate error code.
5163 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00005164PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005165 const pjmedia_codec_param *param);
5166
Benny Prijono9f468d12011-07-07 07:46:33 +00005167
5168#if DISABLED_FOR_TICKET_1185
5169/**
5170 * Create UDP media transports for all the calls. This function creates
5171 * one UDP media transport for each call.
5172 *
5173 * @param cfg Media transport configuration. The "port" field in the
5174 * configuration is used as the start port to bind the
5175 * sockets.
5176 *
5177 * @return PJ_SUCCESS on success, or the appropriate error code.
5178 */
5179PJ_DECL(pj_status_t)
5180pjsua_media_transports_create(const pjsua_transport_config *cfg);
5181
5182
5183/**
5184 * Register custom media transports to be used by calls. There must
5185 * enough media transports for all calls.
5186 *
5187 * @param tp The media transport array.
5188 * @param count Number of elements in the array. This number MUST
5189 * match the number of maximum calls configured when
5190 * pjsua is created.
5191 * @param auto_delete Flag to indicate whether the transports should be
5192 * destroyed when pjsua is shutdown.
5193 *
5194 * @return PJ_SUCCESS on success, or the appropriate error code.
5195 */
5196PJ_DECL(pj_status_t)
5197pjsua_media_transports_attach( pjsua_media_transport tp[],
5198 unsigned count,
5199 pj_bool_t auto_delete);
5200#endif
5201
5202
5203/* end of MEDIA API */
5204/**
5205 * @}
5206 */
5207
5208
Nanang Izzuddin50fae732011-03-22 09:49:23 +00005209/*****************************************************************************
Benny Prijono9f468d12011-07-07 07:46:33 +00005210 * VIDEO API
5211 */
5212
5213
5214/**
5215 * @defgroup PJSUA_LIB_VIDEO PJSUA-API Video
5216 * @ingroup PJSUA_LIB
5217 * @brief Video support
5218 * @{
5219 */
5220
5221/*
5222 * Video devices API
5223 */
5224
5225/**
5226 * Get the number of video devices installed in the system.
5227 *
5228 * @return The number of devices.
5229 */
5230PJ_DECL(unsigned) pjsua_vid_dev_count(void);
5231
5232/**
5233 * Retrieve the video device info for the specified device index.
5234 *
5235 * @param id The device index.
5236 * @param vdi Device info to be initialized.
5237 *
5238 * @return PJ_SUCCESS on success, or the appropriate error code.
5239 */
5240PJ_DECL(pj_status_t) pjsua_vid_dev_get_info(pjmedia_vid_dev_index id,
5241 pjmedia_vid_dev_info *vdi);
5242
5243/**
5244 * Enum all video devices installed in the system.
5245 *
5246 * @param info Array of info to be initialized.
5247 * @param count On input, specifies max elements in the array.
5248 * On return, it contains actual number of elements
5249 * that have been initialized.
5250 *
5251 * @return PJ_SUCCESS on success, or the appropriate error code.
5252 */
5253PJ_DECL(pj_status_t) pjsua_vid_enum_devs(pjmedia_vid_dev_info info[],
5254 unsigned *count);
5255
5256
5257/*
5258 * Video preview API
5259 */
5260
5261/**
5262 * Parameters for starting video preview with pjsua_vid_preview_start().
5263 * Application should initialize this structure with
5264 * pjsua_vid_preview_param_default().
5265 */
5266typedef struct pjsua_vid_preview_param
5267{
5268 /**
5269 * Device ID for the video renderer to be used for rendering the
5270 * capture stream for preview.
5271 */
5272 pjmedia_vid_dev_index rend_id;
5273} pjsua_vid_preview_param;
5274
5275
5276/**
5277 * Start video preview window for the specified capture device.
5278 *
5279 * @param id The capture device ID where its preview will be
5280 * started.
5281 * @param prm Optional video preview parameters. Specify NULL
5282 * to use default values.
5283 *
5284 * @return PJ_SUCCESS on success, or the appropriate error code.
5285 */
5286PJ_DECL(pj_status_t) pjsua_vid_preview_start(pjmedia_vid_dev_index id,
5287 pjsua_vid_preview_param *prm);
5288
5289/**
5290 * Get the preview window handle associated with the capture device, if any.
5291 *
5292 * @param id The capture device ID.
5293 *
5294 * @return The window ID of the preview window for the
5295 * specified capture device ID, or NULL if preview
5296 * does not exist.
5297 */
5298PJ_DECL(pjsua_vid_win_id) pjsua_vid_preview_get_win(pjmedia_vid_dev_index id);
5299
5300/**
5301 * Stop video preview.
5302 *
5303 * @param id The capture device ID.
5304 *
5305 * @return PJ_SUCCESS on success, or the appropriate error code.
5306 */
5307PJ_DECL(pj_status_t) pjsua_vid_preview_stop(pjmedia_vid_dev_index id);
5308
5309
5310/*
5311 * Video window manipulation API.
5312 */
5313
5314/**
5315 * This structure describes video window info.
5316 */
5317typedef struct pjsua_vid_win_info
5318{
5319 /**
5320 * Window show status. The window is hidden if false.
5321 */
5322 pj_bool_t show;
5323
5324 /**
5325 * Window position.
5326 */
5327 pjmedia_coord pos;
5328
5329 /**
5330 * Window size.
5331 */
5332 pjmedia_rect_size size;
5333
5334} pjsua_vid_win_info;
5335
5336
5337/**
5338 * Get window info.
5339 *
5340 * @param wid The video window ID.
5341 * @param wi The video window info to be initialized.
5342 *
5343 * @return PJ_SUCCESS on success, or the appropriate error code.
5344 */
5345PJ_DECL(pj_status_t) pjsua_vid_win_get_info(pjsua_vid_win_id wid,
5346 pjsua_vid_win_info *wi);
5347
5348/**
5349 * Show or hide window.
5350 *
5351 * @param wid The video window ID.
5352 * @param show Set to PJ_TRUE to show the window, PJ_FALSE to
5353 * hide the window.
5354 *
5355 * @return PJ_SUCCESS on success, or the appropriate error code.
5356 */
5357PJ_DECL(pj_status_t) pjsua_vid_win_set_show(pjsua_vid_win_id wid,
5358 pj_bool_t show);
5359
5360/**
5361 * Set video window position.
5362 *
5363 * @param wid The video window ID.
5364 * @param pos The window position.
5365 *
5366 * @return PJ_SUCCESS on success, or the appropriate error code.
5367 */
5368PJ_DECL(pj_status_t) pjsua_vid_win_set_pos(pjsua_vid_win_id wid,
5369 const pjmedia_coord *pos);
5370
5371/**
5372 * Resize window.
5373 *
5374 * @param wid The video window ID.
5375 * @param size The new window size.
5376 *
5377 * @return PJ_SUCCESS on success, or the appropriate error code.
5378 */
5379PJ_DECL(pj_status_t) pjsua_vid_win_set_size(pjsua_vid_win_id wid,
5380 const pjmedia_rect_size *size);
5381
5382
5383
5384/*
5385 * Video codecs API
Nanang Izzuddin50fae732011-03-22 09:49:23 +00005386 */
5387
5388/**
5389 * Enum all supported video codecs in the system.
5390 *
5391 * @param id Array of ID to be initialized.
5392 * @param count On input, specifies max elements in the array.
5393 * On return, it contains actual number of elements
5394 * that have been initialized.
5395 *
5396 * @return PJ_SUCCESS on success, or the appropriate error code.
5397 */
5398PJ_DECL(pj_status_t) pjsua_vid_enum_codecs( pjsua_codec_info id[],
5399 unsigned *count );
5400
5401
5402/**
5403 * Change video codec priority.
5404 *
5405 * @param codec_id Codec ID, which is a string that uniquely identify
5406 * the codec (such as "H263/90000"). Please see pjsua
5407 * manual or pjmedia codec reference for details.
5408 * @param priority Codec priority, 0-255, where zero means to disable
5409 * the codec.
5410 *
5411 * @return PJ_SUCCESS on success, or the appropriate error code.
5412 */
5413PJ_DECL(pj_status_t) pjsua_vid_codec_set_priority( const pj_str_t *codec_id,
5414 pj_uint8_t priority );
5415
5416
5417/**
5418 * Get video codec parameters.
5419 *
5420 * @param codec_id Codec ID.
5421 * @param param Structure to receive video codec parameters.
5422 *
5423 * @return PJ_SUCCESS on success, or the appropriate error code.
5424 */
5425PJ_DECL(pj_status_t) pjsua_vid_codec_get_param(
5426 const pj_str_t *codec_id,
5427 pjmedia_vid_codec_param *param);
5428
5429
5430/**
5431 * Set video codec parameters.
5432 *
5433 * @param codec_id Codec ID.
5434 * @param param Codec parameter to set. Set to NULL to reset
5435 * codec parameter to library default settings.
5436 *
5437 * @return PJ_SUCCESS on success, or the appropriate error code.
5438 */
5439PJ_DECL(pj_status_t) pjsua_vid_codec_set_param(
5440 const pj_str_t *codec_id,
5441 const pjmedia_vid_codec_param *param);
5442
5443
Benny Prijonof3195072006-02-14 21:15:30 +00005444
Benny Prijono9f468d12011-07-07 07:46:33 +00005445/* end of VIDEO API */
Benny Prijono312aff92006-06-17 04:08:30 +00005446/**
5447 * @}
5448 */
5449
Benny Prijonof3195072006-02-14 21:15:30 +00005450
Benny Prijono312aff92006-06-17 04:08:30 +00005451/**
5452 * @}
5453 */
5454
Benny Prijonoe6ead542007-01-31 20:53:31 +00005455PJ_END_DECL
5456
Benny Prijono312aff92006-06-17 04:08:30 +00005457
Benny Prijono268ca612006-02-07 12:34:11 +00005458#endif /* __PJSUA_H__ */