blob: bd09888115df05008f171a6892c266b17bc65d71 [file] [log] [blame]
Benny Prijono268ca612006-02-07 12:34:11 +00001/* $Id$ */
2/*
Nanang Izzuddina62ffc92011-05-05 06:14:19 +00003 * Copyright (C) 2008-2011 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/**
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +0000373 * This enumeration represents video stream operation on a call.
374 * See also #pjsua_call_vid_strm_op_param for further info.
375 */
376typedef enum pjsua_call_vid_strm_op
377{
378 /**
379 * Add a new video stream.
380 */
381 PJSUA_CALL_VID_STRM_ADD,
382
383 /**
Nanang Izzuddin98085612011-07-15 07:41:02 +0000384 * Remove/disable an existing video stream.
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +0000385 */
Nanang Izzuddin98085612011-07-15 07:41:02 +0000386 PJSUA_CALL_VID_STRM_REMOVE,
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +0000387
388 /**
Nanang Izzuddin98085612011-07-15 07:41:02 +0000389 * Change direction of a video stream.
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +0000390 */
Nanang Izzuddin98085612011-07-15 07:41:02 +0000391 PJSUA_CALL_VID_STRM_CHANGE_DIR,
Nanang Izzuddin7ad53c32011-07-13 13:31:08 +0000392
393 /**
Nanang Izzuddin98085612011-07-15 07:41:02 +0000394 * Change capture device of a video stream.
Nanang Izzuddin7ad53c32011-07-13 13:31:08 +0000395 */
396 PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV,
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +0000397
398 /**
399 * Start transmitting video stream.
400 */
401 PJSUA_CALL_VID_STRM_START_TRANSMIT,
402
403 /**
404 * Stop transmitting video stream.
405 */
406 PJSUA_CALL_VID_STRM_STOP_TRANSMIT,
407
408} pjsua_call_vid_strm_op;
409
410
411/**
412 * Parameters for video stream operation on a call.
413 */
414typedef struct pjsua_call_vid_strm_op_param
415{
416 /**
417 * Specify the media stream index. This can be set to -1 to denote
418 * the default video stream in the call, which is the first active
419 * video stream or any first video stream if none is active.
420 *
421 * This field is valid for all video stream operations, except
422 * PJSUA_CALL_VID_STRM_ADD.
Nanang Izzuddin98085612011-07-15 07:41:02 +0000423 *
424 * Default: -1 (first active video stream, or any first video stream
425 * if none is active)
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +0000426 */
427 int med_idx;
428
429 /**
Nanang Izzuddin98085612011-07-15 07:41:02 +0000430 * Specify the media stream direction.
431 *
432 * This field is valid for the following video stream operations:
433 * PJSUA_CALL_VID_STRM_ADD and PJSUA_CALL_VID_STRM_CHANGE_DIR.
434 *
435 * Default: PJMEDIA_DIR_ENCODING_DECODING
436 */
437 pjmedia_dir dir;
438
439 /**
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +0000440 * Specify the video capture device ID. This can be set to
441 * PJMEDIA_VID_DEFAULT_CAPTURE_DEV to specify the default capture
442 * device as configured in the account.
443 *
444 * This field is valid for the following video stream operations:
Nanang Izzuddin98085612011-07-15 07:41:02 +0000445 * PJSUA_CALL_VID_STRM_ADD and PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV.
446 *
447 * Default: capture device configured in account.
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +0000448 */
449 pjmedia_vid_dev_index cap_dev;
450
451} pjsua_call_vid_strm_op_param;
452
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000453
454/**
455 * Logging configuration, which can be (optionally) specified when calling
456 * #pjsua_init(). Application must call #pjsua_logging_config_default() to
457 * initialize this structure with the default values.
458 */
459typedef struct pjsua_logging_config
460{
461 /**
462 * Log incoming and outgoing SIP message? Yes!
463 */
464 pj_bool_t msg_logging;
465
466 /**
467 * Input verbosity level. Value 5 is reasonable.
468 */
469 unsigned level;
470
471 /**
472 * Verbosity level for console. Value 4 is reasonable.
473 */
474 unsigned console_level;
Benny Prijonodbe3f4b2009-05-07 16:56:04 +0000475
476 /**
477 * Log decoration.
478 */
479 unsigned decor;
480
481 /**
482 * Optional log filename.
483 */
484 pj_str_t log_filename;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000485
486 /**
487 * Additional flags to be given to #pj_file_open() when opening
488 * the log file. By default, the flag is PJ_O_WRONLY. Application
Benny Prijonofe7d87b2007-11-29 11:35:44 +0000489 * may set PJ_O_APPEND here so that logs are appended to existing
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000490 * file instead of overwriting it.
491 *
492 * Default is 0.
493 */
494 unsigned log_file_flags;
495
496 /**
497 * Optional callback function to be called to write log to
498 * application specific device. This function will be called for
499 * log messages on input verbosity level.
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000500 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000501 void (*cb)(int level, const char *data, int len);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000502
503
504} pjsua_logging_config;
505
506
507/**
508 * Use this function to initialize logging config.
509 *
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000510 * @param cfg The logging config to be initialized.
511 */
512PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000513
Benny Prijonodc39fe82006-05-26 12:17:46 +0000514
515/**
Benny Prijono4dd961b2009-10-26 11:21:37 +0000516 * Use this function to duplicate logging config.
517 *
518 * @param pool Pool to use.
519 * @param dst Destination config.
520 * @param src Source config.
521 */
522PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool,
523 pjsua_logging_config *dst,
524 const pjsua_logging_config *src);
525
526
Benny Prijonob5388cf2007-01-04 22:45:08 +0000527/**
528 * Structure to be passed on MWI callback.
529 */
530typedef struct pjsua_mwi_info
Benny Prijonodc39fe82006-05-26 12:17:46 +0000531{
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000532 pjsip_evsub *evsub; /**< Event subscription session, for
Benny Prijonodc39fe82006-05-26 12:17:46 +0000533 reference. */
534 pjsip_rx_data *rdata; /**< The received NOTIFY request. */
Benny Prijono9fc735d2006-05-28 14:58:12 +0000535} pjsua_mwi_info;
536
Benny Prijonoe6ead542007-01-31 20:53:31 +0000537
Benny Prijono0875ae82006-12-26 00:11:48 +0000538/**
Nanang Izzuddin4ea1bcc2010-09-28 04:57:01 +0000539 * Structure to be passed on registration callback.
540 */
541typedef struct pjsua_reg_info
542{
543 struct pjsip_regc_cbparam *cbparam; /**< Parameters returned by
544 registration callback. */
545} pjsua_reg_info;
546
547
548/**
Benny Prijonodc39fe82006-05-26 12:17:46 +0000549 * This structure describes application callback to receive various event
550 * notification from PJSUA-API. All of these callbacks are OPTIONAL,
551 * although definitely application would want to implement some of
552 * the important callbacks (such as \a on_incoming_call).
553 */
554typedef struct pjsua_callback
555{
556 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000557 * Notify application when invite state has changed.
558 * Application may then query the call info to get the
559 * detail call states by calling pjsua_call_get_info() function.
Benny Prijono0875ae82006-12-26 00:11:48 +0000560 *
561 * @param call_id The call index.
562 * @param e Event which causes the call state to change.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000563 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000564 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000565
566 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000567 * Notify application on incoming call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000568 *
569 * @param acc_id The account which match the incoming call.
570 * @param call_id The call id that has just been created for
571 * the call.
572 * @param rdata The incoming INVITE request.
Benny Prijono8b1889b2006-06-06 18:40:40 +0000573 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000574 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000575 pjsip_rx_data *rdata);
576
577 /**
Benny Prijonofeb69f42007-10-05 09:12:26 +0000578 * This is a general notification callback which is called whenever
579 * a transaction within the call has changed state. Application can
580 * implement this callback for example to monitor the state of
581 * outgoing requests, or to answer unhandled incoming requests
582 * (such as INFO) with a final response.
583 *
584 * @param call_id Call identification.
585 * @param tsx The transaction which has changed state.
586 * @param e Transaction event that caused the state change.
587 */
588 void (*on_call_tsx_state)(pjsua_call_id call_id,
589 pjsip_transaction *tsx,
590 pjsip_event *e);
591
592 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000593 * Notify application when media state in the call has changed.
594 * Normal application would need to implement this callback, e.g.
Benny Prijono6ba8c542007-10-16 01:34:14 +0000595 * to connect the call's media to sound device. When ICE is used,
596 * this callback will also be called to report ICE negotiation
597 * failure.
Benny Prijono0875ae82006-12-26 00:11:48 +0000598 *
599 * @param call_id The call index.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000600 */
601 void (*on_call_media_state)(pjsua_call_id call_id);
602
Benny Prijonofc13bf62008-02-20 08:56:15 +0000603
604 /**
605 * Notify application when media session is created and before it is
606 * registered to the conference bridge. Application may return different
607 * media port if it has added media processing port to the stream. This
608 * media port then will be added to the conference bridge instead.
609 *
610 * @param call_id Call identification.
Benny Prijono0bc99a92011-03-17 04:34:43 +0000611 * @param strm Media stream.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000612 * @param stream_idx Stream index in the media session.
613 * @param p_port On input, it specifies the media port of the
614 * stream. Application may modify this pointer to
615 * point to different media port to be registered
616 * to the conference bridge.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000617 */
618 void (*on_stream_created)(pjsua_call_id call_id,
Benny Prijono0bc99a92011-03-17 04:34:43 +0000619 pjmedia_stream *strm,
Benny Prijonofc13bf62008-02-20 08:56:15 +0000620 unsigned stream_idx,
621 pjmedia_port **p_port);
622
623 /**
624 * Notify application when media session has been unregistered from the
625 * conference bridge and about to be destroyed.
626 *
627 * @param call_id Call identification.
Benny Prijono0bc99a92011-03-17 04:34:43 +0000628 * @param strm Media stream.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000629 * @param stream_idx Stream index in the media session.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000630 */
631 void (*on_stream_destroyed)(pjsua_call_id call_id,
Benny Prijono0bc99a92011-03-17 04:34:43 +0000632 pjmedia_stream *strm,
Benny Prijonofc13bf62008-02-20 08:56:15 +0000633 unsigned stream_idx);
634
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000635 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000636 * Notify application upon incoming DTMF digits.
637 *
638 * @param call_id The call index.
639 * @param digit DTMF ASCII digit.
640 */
641 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
642
643 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000644 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000645 * Application can decide to accept/reject transfer request
Benny Prijonoc54dcb32008-04-08 23:33:15 +0000646 * by setting the code (default is 202). When this callback
Benny Prijono9fc735d2006-05-28 14:58:12 +0000647 * is not defined, the default behavior is to accept the
648 * transfer.
Benny Prijono0875ae82006-12-26 00:11:48 +0000649 *
650 * @param call_id The call index.
651 * @param dst The destination where the call will be
652 * transfered to.
653 * @param code Status code to be returned for the call transfer
654 * request. On input, it contains status code 200.
Benny Prijono9fc735d2006-05-28 14:58:12 +0000655 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000656 void (*on_call_transfer_request)(pjsua_call_id call_id,
657 const pj_str_t *dst,
658 pjsip_status_code *code);
659
660 /**
661 * Notify application of the status of previously sent call
662 * transfer request. Application can monitor the status of the
663 * call transfer request, for example to decide whether to
664 * terminate existing call.
665 *
666 * @param call_id Call ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000667 * @param st_code Status progress of the transfer request.
668 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000669 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000670 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000671 * this callback is the final status.
672 * @param p_cont Initially will be set to non-zero, application
673 * can set this to FALSE if it no longer wants
674 * to receie further notification (for example,
675 * after it hangs up the call).
676 */
677 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000678 int st_code,
679 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000680 pj_bool_t final,
681 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000682
683 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000684 * Notify application about incoming INVITE with Replaces header.
685 * Application may reject the request by setting non-2xx code.
686 *
687 * @param call_id The call ID to be replaced.
688 * @param rdata The incoming INVITE request to replace the call.
689 * @param st_code Status code to be set by application. Application
690 * should only return a final status (200-699).
691 * @param st_text Optional status text to be set by application.
692 */
693 void (*on_call_replace_request)(pjsua_call_id call_id,
694 pjsip_rx_data *rdata,
695 int *st_code,
696 pj_str_t *st_text);
697
698 /**
699 * Notify application that an existing call has been replaced with
700 * a new call. This happens when PJSUA-API receives incoming INVITE
701 * request with Replaces header.
702 *
703 * After this callback is called, normally PJSUA-API will disconnect
704 * \a old_call_id and establish \a new_call_id.
705 *
706 * @param old_call_id Existing call which to be replaced with the
707 * new call.
708 * @param new_call_id The new call.
709 * @param rdata The incoming INVITE with Replaces request.
710 */
711 void (*on_call_replaced)(pjsua_call_id old_call_id,
712 pjsua_call_id new_call_id);
713
714
715 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000716 * Notify application when registration status has changed.
717 * Application may then query the account info to get the
718 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000719 *
Nanang Izzuddin4ea1bcc2010-09-28 04:57:01 +0000720 * @param acc_id The account ID.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000721 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000722 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000723
724 /**
Nanang Izzuddin4ea1bcc2010-09-28 04:57:01 +0000725 * Notify application when registration status has changed.
726 * Application may inspect the registration info to get the
727 * registration status details.
728 *
729 * @param acc_id The account ID.
730 * @param info The registration info.
731 */
732 void (*on_reg_state2)(pjsua_acc_id acc_id, pjsua_reg_info *info);
733
734 /**
Benny Prijono63fba012008-07-17 14:19:10 +0000735 * Notification when incoming SUBSCRIBE request is received. Application
736 * may use this callback to authorize the incoming subscribe request
737 * (e.g. ask user permission if the request should be granted).
738 *
739 * If this callback is not implemented, all incoming presence subscription
740 * requests will be accepted.
741 *
742 * If this callback is implemented, application has several choices on
743 * what to do with the incoming request:
744 * - it may reject the request immediately by specifying non-200 class
745 * final response in the \a code argument.
746 * - it may immediately accept the request by specifying 200 as the
747 * \a code argument. This is the default value if application doesn't
748 * set any value to the \a code argument. In this case, the library
749 * will automatically send NOTIFY request upon returning from this
750 * callback.
751 * - it may delay the processing of the request, for example to request
752 * user permission whether to accept or reject the request. In this
753 * case, the application MUST set the \a code argument to 202, and
754 * later calls #pjsua_pres_notify() to accept or reject the
755 * subscription request.
756 *
757 * Any \a code other than 200 and 202 will be treated as 200.
758 *
759 * Application MUST return from this callback immediately (e.g. it must
760 * not block in this callback while waiting for user confirmation).
761 *
762 * @param srv_pres Server presence subscription instance. If
763 * application delays the acceptance of the request,
764 * it will need to specify this object when calling
765 * #pjsua_pres_notify().
766 * @param acc_id Account ID most appropriate for this request.
767 * @param buddy_id ID of the buddy matching the sender of the
768 * request, if any, or PJSUA_INVALID_ID if no
769 * matching buddy is found.
770 * @param from The From URI of the request.
771 * @param rdata The incoming request.
772 * @param code The status code to respond to the request. The
773 * default value is 200. Application may set this
774 * to other final status code to accept or reject
775 * the request.
776 * @param reason The reason phrase to respond to the request.
777 * @param msg_data If the application wants to send additional
778 * headers in the response, it can put it in this
779 * parameter.
780 */
781 void (*on_incoming_subscribe)(pjsua_acc_id acc_id,
782 pjsua_srv_pres *srv_pres,
783 pjsua_buddy_id buddy_id,
784 const pj_str_t *from,
785 pjsip_rx_data *rdata,
786 pjsip_status_code *code,
787 pj_str_t *reason,
788 pjsua_msg_data *msg_data);
789
790 /**
791 * Notification when server side subscription state has changed.
792 * This callback is optional as application normally does not need
793 * to do anything to maintain server side presence subscription.
794 *
795 * @param acc_id The account ID.
796 * @param srv_pres Server presence subscription object.
797 * @param remote_uri Remote URI string.
798 * @param state New subscription state.
799 * @param event PJSIP event that triggers the state change.
800 */
801 void (*on_srv_subscribe_state)(pjsua_acc_id acc_id,
802 pjsua_srv_pres *srv_pres,
803 const pj_str_t *remote_uri,
804 pjsip_evsub_state state,
805 pjsip_event *event);
806
807 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000808 * Notify application when the buddy state has changed.
809 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000810 *
811 * @param buddy_id The buddy id.
Benny Prijono9fc735d2006-05-28 14:58:12 +0000812 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000813 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000814
Benny Prijono63499892010-10-12 12:45:15 +0000815
816 /**
817 * Notify application when the state of client subscription session
818 * associated with a buddy has changed. Application may use this
819 * callback to retrieve more detailed information about the state
820 * changed event.
821 *
822 * @param buddy_id The buddy id.
823 * @param sub Event subscription session.
824 * @param event The event which triggers state change event.
825 */
826 void (*on_buddy_evsub_state)(pjsua_buddy_id buddy_id,
827 pjsip_evsub *sub,
828 pjsip_event *event);
829
Benny Prijono9fc735d2006-05-28 14:58:12 +0000830 /**
831 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000832 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000833 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000834 *
Benny Prijonobbeb3992007-05-21 13:48:35 +0000835 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
836 * passed as one of the argument.
837 *
Benny Prijono0875ae82006-12-26 00:11:48 +0000838 * @param call_id Containts the ID of the call where the IM was
839 * sent, or PJSUA_INVALID_ID if the IM was sent
840 * outside call context.
841 * @param from URI of the sender.
842 * @param to URI of the destination message.
843 * @param contact The Contact URI of the sender, if present.
844 * @param mime_type MIME type of the message.
845 * @param body The message content.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000846 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000847 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
848 const pj_str_t *to, const pj_str_t *contact,
849 const pj_str_t *mime_type, const pj_str_t *body);
850
851 /**
Benny Prijonobbeb3992007-05-21 13:48:35 +0000852 * This is the alternative version of the \a on_pager() callback with
853 * \a pjsip_rx_data argument.
854 *
855 * @param call_id Containts the ID of the call where the IM was
856 * sent, or PJSUA_INVALID_ID if the IM was sent
857 * outside call context.
858 * @param from URI of the sender.
859 * @param to URI of the destination message.
860 * @param contact The Contact URI of the sender, if present.
861 * @param mime_type MIME type of the message.
862 * @param body The message content.
863 * @param rdata The incoming MESSAGE request.
Benny Prijonoba736c42008-07-10 20:45:03 +0000864 * @param acc_id Account ID most suitable for this message.
Benny Prijonobbeb3992007-05-21 13:48:35 +0000865 */
866 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
867 const pj_str_t *to, const pj_str_t *contact,
868 const pj_str_t *mime_type, const pj_str_t *body,
Benny Prijonoba736c42008-07-10 20:45:03 +0000869 pjsip_rx_data *rdata, pjsua_acc_id acc_id);
Benny Prijonobbeb3992007-05-21 13:48:35 +0000870
871 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000872 * Notify application about the delivery status of outgoing pager
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000873 * request. See also on_pager_status2() callback for the version with
874 * \a pjsip_rx_data in the argument list.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000875 *
876 * @param call_id Containts the ID of the call where the IM was
877 * sent, or PJSUA_INVALID_ID if the IM was sent
878 * outside call context.
879 * @param to Destination URI.
880 * @param body Message body.
881 * @param user_data Arbitrary data that was specified when sending
882 * IM message.
883 * @param status Delivery status.
884 * @param reason Delivery status reason.
885 */
886 void (*on_pager_status)(pjsua_call_id call_id,
887 const pj_str_t *to,
888 const pj_str_t *body,
889 void *user_data,
890 pjsip_status_code status,
891 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000892
893 /**
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000894 * Notify application about the delivery status of outgoing pager
895 * request.
896 *
897 * @param call_id Containts the ID of the call where the IM was
898 * sent, or PJSUA_INVALID_ID if the IM was sent
899 * outside call context.
900 * @param to Destination URI.
901 * @param body Message body.
902 * @param user_data Arbitrary data that was specified when sending
903 * IM message.
904 * @param status Delivery status.
905 * @param reason Delivery status reason.
Benny Prijono0a982002007-06-12 16:22:09 +0000906 * @param tdata The original MESSAGE request.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000907 * @param rdata The incoming MESSAGE response, or NULL if the
908 * message transaction fails because of time out
909 * or transport error.
Benny Prijonoba736c42008-07-10 20:45:03 +0000910 * @param acc_id Account ID from this the instant message was
911 * send.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000912 */
913 void (*on_pager_status2)(pjsua_call_id call_id,
914 const pj_str_t *to,
915 const pj_str_t *body,
916 void *user_data,
917 pjsip_status_code status,
918 const pj_str_t *reason,
Benny Prijono0a982002007-06-12 16:22:09 +0000919 pjsip_tx_data *tdata,
Benny Prijonoba736c42008-07-10 20:45:03 +0000920 pjsip_rx_data *rdata,
921 pjsua_acc_id acc_id);
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000922
923 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000924 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +0000925 *
926 * @param call_id Containts the ID of the call where the IM was
927 * sent, or PJSUA_INVALID_ID if the IM was sent
928 * outside call context.
929 * @param from URI of the sender.
930 * @param to URI of the destination message.
931 * @param contact The Contact URI of the sender, if present.
932 * @param is_typing Non-zero if peer is typing, or zero if peer
933 * has stopped typing a message.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000934 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000935 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
936 const pj_str_t *to, const pj_str_t *contact,
937 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000938
Benny Prijono6ba8c542007-10-16 01:34:14 +0000939 /**
Benny Prijonoba736c42008-07-10 20:45:03 +0000940 * Notify application about typing indication.
941 *
942 * @param call_id Containts the ID of the call where the IM was
943 * sent, or PJSUA_INVALID_ID if the IM was sent
944 * outside call context.
945 * @param from URI of the sender.
946 * @param to URI of the destination message.
947 * @param contact The Contact URI of the sender, if present.
948 * @param is_typing Non-zero if peer is typing, or zero if peer
949 * has stopped typing a message.
950 * @param rdata The received request.
951 * @param acc_id Account ID most suitable for this message.
952 */
953 void (*on_typing2)(pjsua_call_id call_id, const pj_str_t *from,
954 const pj_str_t *to, const pj_str_t *contact,
955 pj_bool_t is_typing, pjsip_rx_data *rdata,
956 pjsua_acc_id acc_id);
957
958 /**
Benny Prijono6ba8c542007-10-16 01:34:14 +0000959 * Callback when the library has finished performing NAT type
960 * detection.
961 *
962 * @param res NAT detection result.
963 */
964 void (*on_nat_detect)(const pj_stun_nat_detect_result *res);
965
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000966 /**
967 * This callback is called when the call is about to resend the
968 * INVITE request to the specified target, following the previously
969 * received redirection response.
970 *
971 * Application may accept the redirection to the specified target
972 * (the default behavior if this callback is implemented), reject
973 * this target only and make the session continue to try the next
974 * target in the list if such target exists, stop the whole
975 * redirection process altogether and cause the session to be
976 * disconnected, or defer the decision to ask for user confirmation.
977 *
978 * This callback is optional. If this callback is not implemented,
979 * the default behavior is to NOT follow the redirection response.
980 *
981 * @param call_id The call ID.
982 * @param target The current target to be tried.
Benny Prijono08a48b82008-11-27 12:42:07 +0000983 * @param e The event that caused this callback to be called.
984 * This could be the receipt of 3xx response, or
985 * 4xx/5xx response received for the INVITE sent to
986 * subsequent targets, or NULL if this callback is
987 * called from within #pjsua_call_process_redirect()
988 * context.
989 *
990 * @return Action to be performed for the target. Set this
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000991 * parameter to one of the value below:
992 * - PJSIP_REDIRECT_ACCEPT: immediately accept the
993 * redirection (default value). When set, the
994 * call will immediately resend INVITE request
995 * to the target.
996 * - PJSIP_REDIRECT_REJECT: immediately reject this
997 * target. The call will continue retrying with
998 * next target if present, or disconnect the call
999 * if there is no more target to try.
1000 * - PJSIP_REDIRECT_STOP: stop the whole redirection
1001 * process and immediately disconnect the call. The
1002 * on_call_state() callback will be called with
1003 * PJSIP_INV_STATE_DISCONNECTED state immediately
1004 * after this callback returns.
1005 * - PJSIP_REDIRECT_PENDING: set to this value if
1006 * no decision can be made immediately (for example
1007 * to request confirmation from user). Application
1008 * then MUST call #pjsua_call_process_redirect()
1009 * to either accept or reject the redirection upon
1010 * getting user decision.
Benny Prijono5e51a4e2008-11-27 00:06:46 +00001011 */
Benny Prijono08a48b82008-11-27 12:42:07 +00001012 pjsip_redirect_op (*on_call_redirected)(pjsua_call_id call_id,
1013 const pjsip_uri *target,
1014 const pjsip_event *e);
Benny Prijono5e51a4e2008-11-27 00:06:46 +00001015
Benny Prijono4dd961b2009-10-26 11:21:37 +00001016 /**
1017 * This callback is called when a NOTIFY request for message summary /
1018 * message waiting indication is received.
1019 *
1020 * @param acc_id The account ID.
1021 * @param mwi_info Structure containing details of the event,
1022 * including the received NOTIFY request in the
1023 * \a rdata field.
1024 */
1025 void (*on_mwi_info)(pjsua_acc_id acc_id, pjsua_mwi_info *mwi_info);
1026
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +00001027 /**
1028 * This callback is called when transport state is changed. See also
1029 * #pjsip_tp_state_callback.
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +00001030 */
Nanang Izzuddin5e69da52010-02-25 11:58:19 +00001031 pjsip_tp_state_callback on_transport_state;
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +00001032
Benny Prijono4d6ff4d2010-06-19 12:35:33 +00001033 /**
1034 * This callback is called to report error in ICE media transport.
1035 * Currently it is used to report TURN Refresh error.
1036 *
1037 * @param index Transport index.
1038 * @param op Operation which trigger the failure.
1039 * @param status Error status.
1040 * @param param Additional info about the event. Currently this will
1041 * always be set to NULL.
1042 */
1043 void (*on_ice_transport_error)(int index, pj_ice_strans_op op,
1044 pj_status_t status, void *param);
1045
Benny Prijono2d647722011-07-13 03:05:22 +00001046 /**
1047 * Callback when the sound device is about to be opened or closed.
1048 * This callback will be called even when null sound device or no
1049 * sound device is configured by the application (i.e. the
1050 * #pjsua_set_null_snd_dev() and #pjsua_set_no_snd_dev() APIs).
1051 * This API is mostly useful when the application wants to manage
1052 * the sound device by itself (i.e. with #pjsua_set_no_snd_dev()),
1053 * to get notified when it should open or close the sound device.
1054 *
1055 * @param operation The value will be set to 0 to signal that sound
1056 * device is about to be closed, and 1 to be opened.
1057 *
1058 * @return The callback must return PJ_SUCCESS at the moment.
1059 */
1060 pj_status_t (*on_snd_dev_operation)(int operation);
1061
Benny Prijonoee0ba182011-07-15 06:18:29 +00001062 /**
1063 * Notification about media events such as video notifications. This
1064 * callback will most likely be called from media threads, thus
1065 * application must not perform heavy processing in this callback.
1066 * Especially, application must not destroy the call or media in this
1067 * callback. If application needs to perform more complex tasks to
1068 * handle the event, it should post the task to another thread.
1069 *
1070 * @param call_id The call id.
1071 * @param med_idx The media stream index.
1072 * @param event The media event.
1073 */
1074 void (*on_call_media_event)(pjsua_call_id call_id,
1075 unsigned med_idx,
1076 pjmedia_event *event);
Benny Prijono2d647722011-07-13 03:05:22 +00001077
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001078} pjsua_callback;
1079
1080
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001081/**
1082 * This enumeration specifies the usage of SIP Session Timers extension.
1083 */
1084typedef enum pjsua_sip_timer_use
1085{
1086 /**
1087 * When this flag is specified, Session Timers will not be used in any
1088 * session, except it is explicitly required in the remote request.
1089 */
1090 PJSUA_SIP_TIMER_INACTIVE,
1091
1092 /**
1093 * When this flag is specified, Session Timers will be used in all
1094 * sessions whenever remote supports and uses it.
1095 */
1096 PJSUA_SIP_TIMER_OPTIONAL,
1097
1098 /**
1099 * When this flag is specified, Session Timers support will be
1100 * a requirement for the remote to be able to establish a session.
1101 */
1102 PJSUA_SIP_TIMER_REQUIRED,
1103
1104 /**
1105 * When this flag is specified, Session Timers will always be used
1106 * in all sessions, regardless whether remote supports/uses it or not.
1107 */
1108 PJSUA_SIP_TIMER_ALWAYS
1109
1110} pjsua_sip_timer_use;
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001111
Benny Prijonodc39fe82006-05-26 12:17:46 +00001112
1113/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001114 * This structure describes the settings to control the API and
1115 * user agent behavior, and can be specified when calling #pjsua_init().
1116 * Before setting the values, application must call #pjsua_config_default()
1117 * to initialize this structure with the default values.
Benny Prijonodc39fe82006-05-26 12:17:46 +00001118 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001119typedef struct pjsua_config
1120{
1121
1122 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001123 * Maximum calls to support (default: 4). The value specified here
1124 * must be smaller than the compile time maximum settings
1125 * PJSUA_MAX_CALLS, which by default is 32. To increase this
1126 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
1127 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001128 */
1129 unsigned max_calls;
1130
1131 /**
1132 * Number of worker threads. Normally application will want to have at
1133 * least one worker thread, unless when it wants to poll the library
1134 * periodically, which in this case the worker thread can be set to
1135 * zero.
1136 */
1137 unsigned thread_cnt;
1138
1139 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +00001140 * Number of nameservers. If no name server is configured, the SIP SRV
1141 * resolution would be disabled, and domain will be resolved with
1142 * standard pj_gethostbyname() function.
1143 */
1144 unsigned nameserver_count;
1145
1146 /**
1147 * Array of nameservers to be used by the SIP resolver subsystem.
1148 * The order of the name server specifies the priority (first name
1149 * server will be used first, unless it is not reachable).
1150 */
1151 pj_str_t nameserver[4];
1152
1153 /**
Benny Prijono91d06b62008-09-20 12:16:56 +00001154 * Force loose-route to be used in all route/proxy URIs (outbound_proxy
1155 * and account's proxy settings). When this setting is enabled, the
1156 * library will check all the route/proxy URIs specified in the settings
1157 * and append ";lr" parameter to the URI if the parameter is not present.
1158 *
1159 * Default: 1
1160 */
1161 pj_bool_t force_lr;
1162
1163 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001164 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001165 */
1166 unsigned outbound_proxy_cnt;
1167
1168 /**
1169 * Specify the URL of outbound proxies to visit for all outgoing requests.
1170 * The outbound proxies will be used for all accounts, and it will
1171 * be used to build the route set for outgoing requests. The final
1172 * route set for outgoing requests will consists of the outbound proxies
1173 * and the proxy configured in the account.
1174 */
1175 pj_str_t outbound_proxy[4];
1176
Benny Prijonoc97608e2007-03-23 16:34:20 +00001177 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001178 * Warning: deprecated, please use \a stun_srv field instead. To maintain
1179 * backward compatibility, if \a stun_srv_cnt is zero then the value of
1180 * this field will be copied to \a stun_srv field, if present.
1181 *
Benny Prijonoebbf6892007-03-24 17:37:25 +00001182 * Specify domain name to be resolved with DNS SRV resolution to get the
Benny Prijonof76e1392008-06-06 14:51:48 +00001183 * address of the STUN server. Alternatively application may specify
1184 * \a stun_host instead.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001185 *
1186 * If DNS SRV resolution failed for this domain, then DNS A resolution
1187 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +00001188 */
Benny Prijonoebbf6892007-03-24 17:37:25 +00001189 pj_str_t stun_domain;
1190
1191 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001192 * Warning: deprecated, please use \a stun_srv field instead. To maintain
1193 * backward compatibility, if \a stun_srv_cnt is zero then the value of
1194 * this field will be copied to \a stun_srv field, if present.
1195 *
Benny Prijonoaf09dc32007-04-22 12:48:30 +00001196 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
1197 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001198 */
1199 pj_str_t stun_host;
1200
1201 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001202 * Number of STUN server entries in \a stun_srv array.
1203 */
1204 unsigned stun_srv_cnt;
1205
1206 /**
1207 * Array of STUN servers to try. The library will try to resolve and
1208 * contact each of the STUN server entry until it finds one that is
1209 * usable. Each entry may be a domain name, host name, IP address, and
1210 * it may contain an optional port number. For example:
1211 * - "pjsip.org" (domain name)
1212 * - "sip.pjsip.org" (host name)
1213 * - "pjsip.org:33478" (domain name and a non-standard port number)
1214 * - "10.0.0.1:3478" (IP address and port number)
1215 *
1216 * When nameserver is configured in the \a pjsua_config.nameserver field,
1217 * if entry is not an IP address, it will be resolved with DNS SRV
1218 * resolution first, and it will fallback to use DNS A resolution if this
1219 * fails. Port number may be specified even if the entry is a domain name,
1220 * in case the DNS SRV resolution should fallback to a non-standard port.
1221 *
1222 * When nameserver is not configured, entries will be resolved with
1223 * #pj_gethostbyname() if it's not an IP address. Port number may be
1224 * specified if the server is not listening in standard STUN port.
1225 */
1226 pj_str_t stun_srv[8];
1227
1228 /**
1229 * This specifies if the library startup should ignore failure with the
1230 * STUN servers. If this is set to PJ_FALSE, the library will refuse to
1231 * start if it fails to resolve or contact any of the STUN servers.
1232 *
1233 * Default: PJ_TRUE
1234 */
1235 pj_bool_t stun_ignore_failure;
1236
1237 /**
Benny Prijono91a6a172007-10-31 08:59:29 +00001238 * Support for adding and parsing NAT type in the SDP to assist
1239 * troubleshooting. The valid values are:
1240 * - 0: no information will be added in SDP, and parsing is disabled.
Benny Prijono6ba8c542007-10-16 01:34:14 +00001241 * - 1: only the NAT type number is added.
1242 * - 2: add both NAT type number and name.
1243 *
Benny Prijono91a6a172007-10-31 08:59:29 +00001244 * Default: 1
Benny Prijono6ba8c542007-10-16 01:34:14 +00001245 */
1246 int nat_type_in_sdp;
1247
1248 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001249 * Specify whether support for reliable provisional response (100rel and
1250 * PRACK) should be required by default. Note that this setting can be
1251 * further customized in account configuration (#pjsua_acc_config).
1252 *
1253 * Default: PJ_FALSE
1254 */
1255 pj_bool_t require_100rel;
1256
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001257 /**
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001258 * Specify the usage of Session Timers for all sessions. See the
1259 * #pjsua_sip_timer_use for possible values. Note that this setting can be
1260 * further customized in account configuration (#pjsua_acc_config).
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001261 *
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001262 * Default: PJSUA_SIP_TIMER_OPTIONAL
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001263 */
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001264 pjsua_sip_timer_use use_timer;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001265
1266 /**
Benny Prijonofe1bd342009-11-20 23:33:07 +00001267 * Handle unsolicited NOTIFY requests containing message waiting
1268 * indication (MWI) info. Unsolicited MWI is incoming NOTIFY requests
1269 * which are not requested by client with SUBSCRIBE request.
1270 *
1271 * If this is enabled, the library will respond 200/OK to the NOTIFY
1272 * request and forward the request to \a on_mwi_info() callback.
1273 *
1274 * See also \a mwi_enabled field #on pjsua_acc_config.
1275 *
1276 * Default: PJ_TRUE
1277 *
1278 */
1279 pj_bool_t enable_unsolicited_mwi;
1280
1281 /**
Nanang Izzuddin65add622009-08-11 16:26:20 +00001282 * Specify Session Timer settings, see #pjsip_timer_setting.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001283 * Note that this setting can be further customized in account
1284 * configuration (#pjsua_acc_config).
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001285 */
Nanang Izzuddin65add622009-08-11 16:26:20 +00001286 pjsip_timer_setting timer_setting;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001287
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001288 /**
1289 * Number of credentials in the credential array.
1290 */
1291 unsigned cred_count;
1292
1293 /**
1294 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +00001295 * and can be used to authenticate against outbound proxies. If the
1296 * credential is specific to the account, then application should set
1297 * the credential in the pjsua_acc_config rather than the credential
1298 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001299 */
1300 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1301
1302 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001303 * Application callback to receive various event notifications from
1304 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001305 */
1306 pjsua_callback cb;
1307
Benny Prijono56315612006-07-18 14:39:40 +00001308 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001309 * Optional user agent string (default empty). If it's empty, no
1310 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +00001311 */
1312 pj_str_t user_agent;
1313
Benny Prijonod8179652008-01-23 20:39:07 +00001314 /**
1315 * Specify default value of secure media transport usage.
1316 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
1317 * PJMEDIA_SRTP_MANDATORY.
1318 *
1319 * Note that this setting can be further customized in account
1320 * configuration (#pjsua_acc_config).
1321 *
1322 * Default: #PJSUA_DEFAULT_USE_SRTP
1323 */
1324 pjmedia_srtp_use use_srtp;
1325
1326 /**
1327 * Specify whether SRTP requires secure signaling to be used. This option
1328 * is only used when \a use_srtp option above is non-zero.
1329 *
1330 * Valid values are:
1331 * 0: SRTP does not require secure signaling
1332 * 1: SRTP requires secure transport such as TLS
1333 * 2: SRTP requires secure end-to-end transport (SIPS)
1334 *
1335 * Note that this setting can be further customized in account
1336 * configuration (#pjsua_acc_config).
1337 *
1338 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
1339 */
1340 int srtp_secure_signaling;
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00001341
1342 /**
Benny Prijono0bc99a92011-03-17 04:34:43 +00001343 * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00001344 * duplicated media in SDP offer, i.e: unsecured and secured version.
Benny Prijono0bc99a92011-03-17 04:34:43 +00001345 * Otherwise, the SDP media will be composed as unsecured media but
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00001346 * with SDP "crypto" attribute.
1347 *
1348 * Default: PJ_FALSE
1349 */
1350 pj_bool_t srtp_optional_dup_offer;
Benny Prijonod8179652008-01-23 20:39:07 +00001351
Benny Prijono3c5e28b2008-09-24 10:10:15 +00001352 /**
1353 * Disconnect other call legs when more than one 2xx responses for
1354 * outgoing INVITE are received due to forking. Currently the library
1355 * is not able to handle simultaneous forked media, so disconnecting
1356 * the other call legs is necessary.
1357 *
1358 * With this setting enabled, the library will handle only one of the
1359 * connected call leg, and the other connected call legs will be
1360 * disconnected.
1361 *
1362 * Default: PJ_TRUE (only disable this setting for testing purposes).
1363 */
1364 pj_bool_t hangup_forked_call;
1365
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001366} pjsua_config;
1367
1368
1369/**
1370 * Use this function to initialize pjsua config.
1371 *
1372 * @param cfg pjsua config to be initialized.
1373 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001374PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001375
1376
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001377/** The implementation has been moved to sip_auth.h */
Benny Prijono7977f9f2007-10-10 11:37:56 +00001378#define pjsip_cred_dup pjsip_cred_info_dup
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001379
1380
1381/**
1382 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001383 *
1384 * @param pool The pool to get memory from.
1385 * @param dst Destination config.
1386 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001387 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001388PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1389 pjsua_config *dst,
1390 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001391
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001392
1393/**
1394 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001395 * outgoing SIP message. It can (optionally) be specified for example
1396 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1397 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1398 *
1399 * Application MUST call #pjsua_msg_data_init() to initialize this
1400 * structure before setting its values.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001401 */
Benny Prijono63fba012008-07-17 14:19:10 +00001402struct pjsua_msg_data
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001403{
1404 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001405 * Additional message headers as linked list. Application can add
1406 * headers to the list by creating the header, either from the heap/pool
1407 * or from temporary local variable, and add the header using
1408 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001409 */
1410 pjsip_hdr hdr_list;
1411
1412 /**
1413 * MIME type of optional message body.
1414 */
1415 pj_str_t content_type;
1416
1417 /**
Benny Prijono1c1d7342010-08-01 09:48:51 +00001418 * Optional message body to be added to the message, only when the
1419 * message doesn't have a body.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001420 */
1421 pj_str_t msg_body;
1422
Benny Prijono1c1d7342010-08-01 09:48:51 +00001423 /**
1424 * Content type of the multipart body. If application wants to send
1425 * multipart message bodies, it puts the parts in \a parts and set
1426 * the content type in \a multipart_ctype. If the message already
1427 * contains a body, the body will be added to the multipart bodies.
1428 */
1429 pjsip_media_type multipart_ctype;
1430
1431 /**
1432 * List of multipart parts. If application wants to send multipart
1433 * message bodies, it puts the parts in \a parts and set the content
1434 * type in \a multipart_ctype. If the message already contains a body,
1435 * the body will be added to the multipart bodies.
1436 */
1437 pjsip_multipart_part multipart_parts;
Benny Prijono63fba012008-07-17 14:19:10 +00001438};
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001439
1440
1441/**
1442 * Initialize message data.
1443 *
1444 * @param msg_data Message data to be initialized.
1445 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001446PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001447
Benny Prijono268ca612006-02-07 12:34:11 +00001448
1449/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001450 * Instantiate pjsua application. Application must call this function before
1451 * calling any other functions, to make sure that the underlying libraries
1452 * are properly initialized. Once this function has returned success,
1453 * application must call pjsua_destroy() before quitting.
1454 *
1455 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00001456 */
1457PJ_DECL(pj_status_t) pjsua_create(void);
1458
1459
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001460/** Forward declaration */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001461typedef struct pjsua_media_config pjsua_media_config;
1462
1463
Benny Prijonodc39fe82006-05-26 12:17:46 +00001464/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001465 * Initialize pjsua with the specified settings. All the settings are
1466 * optional, and the default values will be used when the config is not
1467 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001468 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001469 * Note that #pjsua_create() MUST be called before calling this function.
1470 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001471 * @param ua_cfg User agent configuration.
1472 * @param log_cfg Optional logging configuration.
1473 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001474 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001475 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001476 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001477PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1478 const pjsua_logging_config *log_cfg,
1479 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001480
1481
1482/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001483 * Application is recommended to call this function after all initialization
1484 * is done, so that the library can do additional checking set up
1485 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001486 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001487 * Application may call this function anytime after #pjsua_init().
1488 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001489 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoccf95622006-02-07 18:48:01 +00001490 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001491PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001492
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001493
Benny Prijonoccf95622006-02-07 18:48:01 +00001494/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001495 * Destroy pjsua. Application is recommended to perform graceful shutdown
1496 * before calling this function (such as unregister the account from the SIP
1497 * server, terminate presense subscription, and hangup active calls), however,
1498 * this function will do all of these if it finds there are active sessions
1499 * that need to be terminated. This function will approximately block for
1500 * one second to wait for replies from remote.
1501 *
1502 * Application.may safely call this function more than once if it doesn't
1503 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001504 *
1505 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001506 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001507PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001508
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001509
Benny Prijono9fc735d2006-05-28 14:58:12 +00001510/**
Benny Prijono0bc99a92011-03-17 04:34:43 +00001511 * Retrieve pjsua state.
1512 *
1513 * @return pjsua state.
1514 */
1515PJ_DECL(pjsua_state) pjsua_get_state(void);
1516
1517
1518/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001519 * Poll pjsua for events, and if necessary block the caller thread for
1520 * the specified maximum interval (in miliseconds).
1521 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001522 * Application doesn't normally need to call this function if it has
1523 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1524 * because polling then will be done by these worker threads instead.
1525 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001526 * @param msec_timeout Maximum time to wait, in miliseconds.
1527 *
1528 * @return The number of events that have been handled during the
1529 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001530 * can retrieve the error as (status = -return_value).
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001531 */
1532PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1533
1534
1535/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001536 * Create memory pool to be used by the application. Once application
1537 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001538 *
1539 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001540 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001541 * @param increment Increment size.
1542 *
1543 * @return The pool, or NULL when there's no memory.
1544 */
1545PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1546 pj_size_t increment);
1547
1548
1549/**
1550 * Application can call this function at any time (after pjsua_create(), of
1551 * course) to change logging settings.
1552 *
1553 * @param c Logging configuration.
1554 *
1555 * @return PJ_SUCCESS on success, or the appropriate error code.
1556 */
1557PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1558
1559
1560/**
1561 * Internal function to get SIP endpoint instance of pjsua, which is
1562 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001563 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001564 *
1565 * @return SIP endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001566 */
1567PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1568
1569/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001570 * Internal function to get media endpoint instance.
1571 * Only valid after #pjsua_init() is called.
1572 *
1573 * @return Media endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001574 */
1575PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1576
Benny Prijono97b87172006-08-24 14:25:14 +00001577/**
1578 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001579 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001580 *
1581 * @return Pool factory currently used by PJSUA.
1582 */
1583PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1584
1585
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001586
1587/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001588 * Utilities.
1589 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001590 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001591
1592/**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001593 * This structure is used to represent the result of the STUN server
1594 * resolution and testing, the #pjsua_resolve_stun_servers() function.
1595 * This structure will be passed in #pj_stun_resolve_cb callback.
1596 */
1597typedef struct pj_stun_resolve_result
1598{
1599 /**
1600 * Arbitrary data that was passed to #pjsua_resolve_stun_servers()
1601 * function.
1602 */
1603 void *token;
1604
1605 /**
1606 * This will contain PJ_SUCCESS if at least one usable STUN server
1607 * is found, otherwise it will contain the last error code during
1608 * the operation.
1609 */
1610 pj_status_t status;
1611
1612 /**
1613 * The server name that yields successful result. This will only
1614 * contain value if status is successful.
1615 */
1616 pj_str_t name;
1617
1618 /**
1619 * The server IP address. This will only contain value if status
1620 * is successful.
1621 */
1622 pj_sockaddr addr;
1623
1624} pj_stun_resolve_result;
1625
1626
1627/**
1628 * Typedef of callback to be registered to #pjsua_resolve_stun_servers().
1629 */
1630typedef void (*pj_stun_resolve_cb)(const pj_stun_resolve_result *result);
1631
1632/**
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001633 * This is a utility function to detect NAT type in front of this
1634 * endpoint. Once invoked successfully, this function will complete
Benny Prijono6ba8c542007-10-16 01:34:14 +00001635 * asynchronously and report the result in \a on_nat_detect() callback
1636 * of pjsua_callback.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001637 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001638 * After NAT has been detected and the callback is called, application can
1639 * get the detected NAT type by calling #pjsua_get_nat_type(). Application
1640 * can also perform NAT detection by calling #pjsua_detect_nat_type()
1641 * again at later time.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001642 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001643 * Note that STUN must be enabled to run this function successfully.
1644 *
1645 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001646 */
Benny Prijono6ba8c542007-10-16 01:34:14 +00001647PJ_DECL(pj_status_t) pjsua_detect_nat_type(void);
1648
1649
1650/**
1651 * Get the NAT type as detected by #pjsua_detect_nat_type() function.
1652 * This function will only return useful NAT type after #pjsua_detect_nat_type()
1653 * has completed successfully and \a on_nat_detect() callback has been called.
1654 *
1655 * @param type NAT type.
1656 *
1657 * @return When detection is in progress, this function will
1658 * return PJ_EPENDING and \a type will be set to
1659 * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been
1660 * detected successfully, this function will return
1661 * PJ_SUCCESS and \a type will be set to the correct
1662 * value. Other return values indicate error and
1663 * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN.
Benny Prijono91a6a172007-10-31 08:59:29 +00001664 *
1665 * @see pjsua_call_get_rem_nat_type()
Benny Prijono6ba8c542007-10-16 01:34:14 +00001666 */
1667PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type);
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001668
1669
1670/**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001671 * Auxiliary function to resolve and contact each of the STUN server
1672 * entries (sequentially) to find which is usable. The #pjsua_init() must
1673 * have been called before calling this function.
1674 *
1675 * @param count Number of STUN server entries to try.
1676 * @param srv Array of STUN server entries to try. Please see
1677 * the \a stun_srv field in the #pjsua_config
1678 * documentation about the format of this entry.
1679 * @param wait Specify non-zero to make the function block until
1680 * it gets the result. In this case, the function
1681 * will block while the resolution is being done,
1682 * and the callback will be called before this function
1683 * returns.
1684 * @param token Arbitrary token to be passed back to application
1685 * in the callback.
1686 * @param cb Callback to be called to notify the result of
1687 * the function.
1688 *
1689 * @return If \a wait parameter is non-zero, this will return
1690 * PJ_SUCCESS if one usable STUN server is found.
1691 * Otherwise it will always return PJ_SUCCESS, and
1692 * application will be notified about the result in
1693 * the callback.
1694 */
1695PJ_DECL(pj_status_t) pjsua_resolve_stun_servers(unsigned count,
1696 pj_str_t srv[],
1697 pj_bool_t wait,
1698 void *token,
1699 pj_stun_resolve_cb cb);
1700
1701/**
1702 * Cancel pending STUN resolution which match the specified token.
1703 *
1704 * @param token The token to match. This token was given to
1705 * #pjsua_resolve_stun_servers()
1706 * @param notify_cb Boolean to control whether the callback should
1707 * be called for cancelled resolutions. When the
1708 * callback is called, the status in the result
1709 * will be set as PJ_ECANCELLED.
1710 *
1711 * @return PJ_SUCCESS if there is at least one pending STUN
1712 * resolution cancelled, or PJ_ENOTFOUND if there is
1713 * no matching one, or other error.
1714 */
1715PJ_DECL(pj_status_t) pjsua_cancel_stun_resolution(void *token,
1716 pj_bool_t notify_cb);
1717
1718
1719/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001720 * This is a utility function to verify that valid SIP url is given. If the
Benny Prijonoc7545782010-09-28 07:43:18 +00001721 * URL is a valid SIP/SIPS scheme, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001722 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001723 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001724 *
1725 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoc7545782010-09-28 07:43:18 +00001726 *
1727 * @see pjsua_verify_url()
Benny Prijono312aff92006-06-17 04:08:30 +00001728 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001729PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001730
1731
1732/**
Benny Prijonoc7545782010-09-28 07:43:18 +00001733 * This is a utility function to verify that valid URI is given. Unlike
1734 * pjsua_verify_sip_url(), this function will return PJ_SUCCESS if tel: URI
1735 * is given.
1736 *
1737 * @param url The URL, as NULL terminated string.
1738 *
1739 * @return PJ_SUCCESS on success, or the appropriate error code.
1740 *
1741 * @see pjsua_verify_sip_url()
1742 */
1743PJ_DECL(pj_status_t) pjsua_verify_url(const char *url);
1744
1745
1746/**
Benny Prijono73bb7232009-10-20 13:56:26 +00001747 * Schedule a timer entry. Note that the timer callback may be executed
1748 * by different thread, depending on whether worker thread is enabled or
1749 * not.
1750 *
1751 * @param entry Timer heap entry.
1752 * @param delay The interval to expire.
1753 *
1754 * @return PJ_SUCCESS on success, or the appropriate error code.
1755 *
1756 * @see pjsip_endpt_schedule_timer()
1757 */
1758PJ_DECL(pj_status_t) pjsua_schedule_timer(pj_timer_entry *entry,
1759 const pj_time_val *delay);
1760
1761
1762/**
1763 * Cancel the previously scheduled timer.
1764 *
1765 * @param entry Timer heap entry.
1766 *
1767 * @see pjsip_endpt_cancel_timer()
1768 */
1769PJ_DECL(void) pjsua_cancel_timer(pj_timer_entry *entry);
1770
1771
1772/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001773 * This is a utility function to display error message for the specified
1774 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001775 *
1776 * @param sender The log sender field.
1777 * @param title Message title for the error.
1778 * @param status Status code.
1779 */
1780PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1781 pj_status_t status);
1782
1783
Benny Prijonoda9785b2007-04-02 20:43:06 +00001784/**
1785 * This is a utility function to dump the stack states to log, using
1786 * verbosity level 3.
1787 *
1788 * @param detail Will print detailed output (such as list of
1789 * SIP transactions) when non-zero.
1790 */
1791PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001792
1793/**
1794 * @}
1795 */
1796
1797
1798
1799/*****************************************************************************
1800 * TRANSPORT API
1801 */
1802
1803/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001804 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001805 * @ingroup PJSUA_LIB
1806 * @brief API for managing SIP transports
1807 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001808 *
1809 * PJSUA-API supports creating multiple transport instances, for example UDP,
1810 * TCP, and TLS transport. SIP transport must be created before adding an
1811 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001812 */
1813
1814
Benny Prijonoe6ead542007-01-31 20:53:31 +00001815/** SIP transport identification.
1816 */
Benny Prijono312aff92006-06-17 04:08:30 +00001817typedef int pjsua_transport_id;
1818
1819
1820/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001821 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001822 * and media. Before setting some values to this structure, application
1823 * MUST call #pjsua_transport_config_default() to initialize its
1824 * values with default settings.
Benny Prijono312aff92006-06-17 04:08:30 +00001825 */
1826typedef struct pjsua_transport_config
1827{
1828 /**
1829 * UDP port number to bind locally. This setting MUST be specified
1830 * even when default port is desired. If the value is zero, the
1831 * transport will be bound to any available port, and application
1832 * can query the port by querying the transport info.
1833 */
1834 unsigned port;
1835
1836 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001837 * Optional address to advertise as the address of this transport.
1838 * Application can specify any address or hostname for this field,
1839 * for example it can point to one of the interface address in the
1840 * system, or it can point to the public address of a NAT router
1841 * where port mappings have been configured for the application.
1842 *
1843 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001844 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001845 pj_str_t public_addr;
1846
1847 /**
1848 * Optional address where the socket should be bound to. This option
1849 * SHOULD only be used to selectively bind the socket to particular
1850 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1851 * published address of a transport (the public_addr field should be
1852 * used for that purpose).
1853 *
1854 * Note that unlike public_addr field, the address (or hostname) here
1855 * MUST correspond to the actual interface address in the host, since
1856 * this address will be specified as bind() argument.
1857 */
1858 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001859
1860 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001861 * This specifies TLS settings for TLS transport. It is only be used
1862 * when this transport config is being used to create a SIP TLS
1863 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001864 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001865 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001866
Benny Prijono4d79b0f2009-10-25 09:02:07 +00001867 /**
1868 * QoS traffic type to be set on this transport. When application wants
1869 * to apply QoS tagging to the transport, it's preferable to set this
1870 * field rather than \a qos_param fields since this is more portable.
1871 *
1872 * Default is QoS not set.
1873 */
1874 pj_qos_type qos_type;
1875
1876 /**
1877 * Set the low level QoS parameters to the transport. This is a lower
1878 * level operation than setting the \a qos_type field and may not be
1879 * supported on all platforms.
1880 *
1881 * Default is QoS not set.
1882 */
1883 pj_qos_params qos_params;
1884
Benny Prijono312aff92006-06-17 04:08:30 +00001885} pjsua_transport_config;
1886
1887
1888/**
1889 * Call this function to initialize UDP config with default values.
1890 *
1891 * @param cfg The UDP config to be initialized.
1892 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001893PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001894
1895
1896/**
Benny Prijono312aff92006-06-17 04:08:30 +00001897 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001898 *
1899 * @param pool The pool.
1900 * @param dst The destination config.
1901 * @param src The source config.
Benny Prijono312aff92006-06-17 04:08:30 +00001902 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001903PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1904 pjsua_transport_config *dst,
1905 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001906
1907
1908/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001909 * This structure describes transport information returned by
1910 * #pjsua_transport_get_info() function.
Benny Prijono312aff92006-06-17 04:08:30 +00001911 */
1912typedef struct pjsua_transport_info
1913{
1914 /**
1915 * PJSUA transport identification.
1916 */
1917 pjsua_transport_id id;
1918
1919 /**
1920 * Transport type.
1921 */
1922 pjsip_transport_type_e type;
1923
1924 /**
1925 * Transport type name.
1926 */
1927 pj_str_t type_name;
1928
1929 /**
1930 * Transport string info/description.
1931 */
1932 pj_str_t info;
1933
1934 /**
1935 * Transport flag (see ##pjsip_transport_flags_e).
1936 */
1937 unsigned flag;
1938
1939 /**
1940 * Local address length.
1941 */
1942 unsigned addr_len;
1943
1944 /**
1945 * Local/bound address.
1946 */
1947 pj_sockaddr local_addr;
1948
1949 /**
1950 * Published address (or transport address name).
1951 */
1952 pjsip_host_port local_name;
1953
1954 /**
1955 * Current number of objects currently referencing this transport.
1956 */
1957 unsigned usage_count;
1958
1959
1960} pjsua_transport_info;
1961
1962
1963/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001964 * Create and start a new SIP transport according to the specified
1965 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001966 *
1967 * @param type Transport type.
1968 * @param cfg Transport configuration.
1969 * @param p_id Optional pointer to receive transport ID.
1970 *
1971 * @return PJ_SUCCESS on success, or the appropriate error code.
1972 */
1973PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1974 const pjsua_transport_config *cfg,
1975 pjsua_transport_id *p_id);
1976
1977/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001978 * Register transport that has been created by application. This function
1979 * is useful if application wants to implement custom SIP transport and use
1980 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001981 *
1982 * @param tp Transport instance.
1983 * @param p_id Optional pointer to receive transport ID.
1984 *
1985 * @return PJ_SUCCESS on success, or the appropriate error code.
1986 */
1987PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1988 pjsua_transport_id *p_id);
1989
1990
1991/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001992 * Enumerate all transports currently created in the system. This function
1993 * will return all transport IDs, and application may then call
1994 * #pjsua_transport_get_info() function to retrieve detailed information
1995 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001996 *
1997 * @param id Array to receive transport ids.
1998 * @param count In input, specifies the maximum number of elements.
1999 * On return, it contains the actual number of elements.
2000 *
2001 * @return PJ_SUCCESS on success, or the appropriate error code.
2002 */
2003PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
2004 unsigned *count );
2005
2006
2007/**
2008 * Get information about transports.
2009 *
2010 * @param id Transport ID.
2011 * @param info Pointer to receive transport info.
2012 *
2013 * @return PJ_SUCCESS on success, or the appropriate error code.
2014 */
2015PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
2016 pjsua_transport_info *info);
2017
2018
2019/**
2020 * Disable a transport or re-enable it. By default transport is always
2021 * enabled after it is created. Disabling a transport does not necessarily
2022 * close the socket, it will only discard incoming messages and prevent
2023 * the transport from being used to send outgoing messages.
2024 *
2025 * @param id Transport ID.
2026 * @param enabled Non-zero to enable, zero to disable.
2027 *
2028 * @return PJ_SUCCESS on success, or the appropriate error code.
2029 */
2030PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
2031 pj_bool_t enabled);
2032
2033
2034/**
2035 * Close the transport. If transport is forcefully closed, it will be
2036 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00002037 * transport may not terminate properly (it may even crash). Otherwise,
2038 * the system will wait until all transactions are closed while preventing
2039 * new users from using the transport, and will close the transport when
2040 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002041 *
2042 * @param id Transport ID.
2043 * @param force Non-zero to immediately close the transport. This
2044 * is not recommended!
2045 *
2046 * @return PJ_SUCCESS on success, or the appropriate error code.
2047 */
2048PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
2049 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00002050
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002051/**
Benny Prijono312aff92006-06-17 04:08:30 +00002052 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002053 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002054
2055
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002056
2057
2058/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00002059 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00002060 */
2061
Benny Prijono312aff92006-06-17 04:08:30 +00002062
2063/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002064 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00002065 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00002066 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00002067 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00002068 *
Benny Prijono312aff92006-06-17 04:08:30 +00002069 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00002070 * using the application. In SIP terms, the identity is used as the <b>From</b>
2071 * header in outgoing requests.
2072 *
2073 * PJSUA-API supports creating and managing multiple accounts. The maximum
2074 * number of accounts is limited by a compile time constant
2075 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002076 *
2077 * Account may or may not have client registration associated with it.
2078 * An account is also associated with <b>route set</b> and some <b>authentication
2079 * credentials</b>, which are used when sending SIP request messages using the
2080 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00002081 * will be reported to remote peer when they subscribe to the account's
2082 * presence, or which is published to a presence server if presence
2083 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00002084 *
2085 * At least one account MUST be created in the application. If no user
2086 * association is required, application can create a userless account by
2087 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00002088 * instead of a particular user, and it correspond with a particular
2089 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00002090 *
2091 * Also one account must be set as the <b>default account</b>, which is used as
2092 * the account to use when PJSUA fails to match a request with any other
2093 * accounts.
2094 *
2095 * When sending outgoing SIP requests (such as making calls or sending
2096 * instant messages), normally PJSUA requires the application to specify
2097 * which account to use for the request. If no account is specified,
2098 * PJSUA may be able to select the account by matching the destination
2099 * domain name, and fall back to default account when no match is found.
2100 */
2101
2102/**
2103 * Maximum accounts.
2104 */
2105#ifndef PJSUA_MAX_ACC
2106# define PJSUA_MAX_ACC 8
2107#endif
2108
2109
2110/**
2111 * Default registration interval.
2112 */
2113#ifndef PJSUA_REG_INTERVAL
Benny Prijonobddef2c2007-10-31 13:28:08 +00002114# define PJSUA_REG_INTERVAL 300
Benny Prijono312aff92006-06-17 04:08:30 +00002115#endif
2116
2117
2118/**
Benny Prijono384dab42009-10-14 01:58:04 +00002119 * Default maximum time to wait for account unregistration transactions to
2120 * complete during library shutdown sequence.
2121 *
2122 * Default: 4000 (4 seconds)
2123 */
2124#ifndef PJSUA_UNREG_TIMEOUT
2125# define PJSUA_UNREG_TIMEOUT 4000
2126#endif
2127
2128
2129/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002130 * Default PUBLISH expiration
2131 */
2132#ifndef PJSUA_PUBLISH_EXPIRATION
Benny Prijono53984d12009-04-28 22:19:49 +00002133# define PJSUA_PUBLISH_EXPIRATION PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002134#endif
2135
2136
2137/**
Benny Prijono093d3022006-09-24 00:07:11 +00002138 * Default account priority.
2139 */
2140#ifndef PJSUA_DEFAULT_ACC_PRIORITY
2141# define PJSUA_DEFAULT_ACC_PRIORITY 0
2142#endif
2143
2144
2145/**
Benny Prijono8058a622007-06-08 04:37:05 +00002146 * This macro specifies the URI scheme to use in Contact header
2147 * when secure transport such as TLS is used. Application can specify
2148 * either "sip" or "sips".
2149 */
2150#ifndef PJSUA_SECURE_SCHEME
Benny Prijono4c82c1e2008-10-16 08:14:51 +00002151# define PJSUA_SECURE_SCHEME "sip"
Benny Prijono8058a622007-06-08 04:37:05 +00002152#endif
2153
2154
2155/**
Benny Prijono534a9ba2009-10-13 14:01:59 +00002156 * Maximum time to wait for unpublication transaction(s) to complete
2157 * during shutdown process, before sending unregistration. The library
2158 * tries to wait for the unpublication (un-PUBLISH) to complete before
2159 * sending REGISTER request to unregister the account, during library
2160 * shutdown process. If the value is set too short, it is possible that
2161 * the unregistration is sent before unpublication completes, causing
2162 * unpublication request to fail.
2163 *
2164 * Default: 2000 (2 seconds)
2165 */
2166#ifndef PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
2167# define PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC 2000
2168#endif
2169
2170
2171/**
Nanang Izzuddin36dd5b62010-03-30 11:13:59 +00002172 * Default auto retry re-registration interval, in seconds. Set to 0
2173 * to disable this. Application can set the timer on per account basis
2174 * by setting the pjsua_acc_config.reg_retry_interval field instead.
2175 *
2176 * Default: 300 (5 minutes)
2177 */
2178#ifndef PJSUA_REG_RETRY_INTERVAL
2179# define PJSUA_REG_RETRY_INTERVAL 300
2180#endif
2181
2182
2183/**
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00002184 * This macro specifies the default value for \a contact_rewrite_method
2185 * field in pjsua_acc_config. I specifies how Contact update will be
2186 * done with the registration, if \a allow_contact_rewrite is enabled in
2187 * the account config.
2188 *
2189 * If set to 1, the Contact update will be done by sending unregistration
2190 * to the currently registered Contact, while simultaneously sending new
2191 * registration (with different Call-ID) for the updated Contact.
2192 *
2193 * If set to 2, the Contact update will be done in a single, current
2194 * registration session, by removing the current binding (by setting its
2195 * Contact's expires parameter to zero) and adding a new Contact binding,
2196 * all done in a single request.
2197 *
2198 * Value 1 is the legacy behavior.
2199 *
2200 * Default value: 2
2201 */
2202#ifndef PJSUA_CONTACT_REWRITE_METHOD
2203# define PJSUA_CONTACT_REWRITE_METHOD 2
2204#endif
2205
2206
2207/**
Benny Prijono29c8ca32010-06-22 06:02:13 +00002208 * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that
2209 * the global outbound proxy list should be added to the REGISTER request.
2210 */
2211#define PJSUA_REG_USE_OUTBOUND_PROXY 1
2212
2213
2214/**
2215 * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that
2216 * the account proxy list should be added to the REGISTER request.
2217 */
2218#define PJSUA_REG_USE_ACC_PROXY 2
2219
2220
2221/**
Benny Prijonodd63b992010-10-01 02:03:42 +00002222 * This enumeration specifies how we should offer call hold request to
2223 * remote peer. The default value is set by compile time constant
2224 * PJSUA_CALL_HOLD_TYPE_DEFAULT, and application may control the setting
2225 * on per-account basis by manipulating \a call_hold_type field in
2226 * #pjsua_acc_config.
2227 */
2228typedef enum pjsua_call_hold_type
2229{
2230 /**
2231 * This will follow RFC 3264 recommendation to use a=sendonly,
2232 * a=recvonly, and a=inactive attribute as means to signal call
2233 * hold status. This is the correct value to use.
2234 */
2235 PJSUA_CALL_HOLD_TYPE_RFC3264,
2236
2237 /**
2238 * This will use the old and deprecated method as specified in RFC 2543,
2239 * and will offer c=0.0.0.0 in the SDP instead. Using this has many
2240 * drawbacks such as inability to keep the media transport alive while
2241 * the call is being put on hold, and should only be used if remote
2242 * does not understand RFC 3264 style call hold offer.
2243 */
2244 PJSUA_CALL_HOLD_TYPE_RFC2543
2245
2246} pjsua_call_hold_type;
2247
2248
2249/**
2250 * Specify the default call hold type to be used in #pjsua_acc_config.
2251 *
2252 * Default is PJSUA_CALL_HOLD_TYPE_RFC3264, and there's no reason to change
2253 * this except if you're communicating with an old/non-standard peer.
2254 */
2255#ifndef PJSUA_CALL_HOLD_TYPE_DEFAULT
2256# define PJSUA_CALL_HOLD_TYPE_DEFAULT PJSUA_CALL_HOLD_TYPE_RFC3264
2257#endif
2258
Benny Prijonodd63b992010-10-01 02:03:42 +00002259/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002260 * This structure describes account configuration to be specified when
2261 * adding a new account with #pjsua_acc_add(). Application MUST initialize
2262 * this structure first by calling #pjsua_acc_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00002263 */
2264typedef struct pjsua_acc_config
2265{
Benny Prijono093d3022006-09-24 00:07:11 +00002266 /**
Benny Prijono705e7842008-07-21 18:12:51 +00002267 * Arbitrary user data to be associated with the newly created account.
2268 * Application may set this later with #pjsua_acc_set_user_data() and
2269 * retrieve it with #pjsua_acc_get_user_data().
2270 */
2271 void *user_data;
2272
2273 /**
Benny Prijono093d3022006-09-24 00:07:11 +00002274 * Account priority, which is used to control the order of matching
2275 * incoming/outgoing requests. The higher the number means the higher
2276 * the priority is, and the account will be matched first.
2277 */
2278 int priority;
2279
Benny Prijono312aff92006-06-17 04:08:30 +00002280 /**
2281 * The full SIP URL for the account. The value can take name address or
2282 * URL format, and will look something like "sip:account@serviceprovider".
2283 *
2284 * This field is mandatory.
2285 */
2286 pj_str_t id;
2287
2288 /**
2289 * This is the URL to be put in the request URI for the registration,
2290 * and will look something like "sip:serviceprovider".
2291 *
2292 * This field should be specified if registration is desired. If the
2293 * value is empty, no account registration will be performed.
2294 */
2295 pj_str_t reg_uri;
2296
Nanang Izzuddin60e8aa92010-09-28 10:48:48 +00002297 /**
2298 * The optional custom SIP headers to be put in the registration
2299 * request.
2300 */
2301 pjsip_hdr reg_hdr_list;
2302
Sauw Ming5c2f6da2011-02-11 07:39:14 +00002303 /**
2304 * The optional custom SIP headers to be put in the presence
2305 * subscription request.
2306 */
2307 pjsip_hdr sub_hdr_list;
2308
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002309 /**
Benny Prijonofe1bd342009-11-20 23:33:07 +00002310 * Subscribe to message waiting indication events (RFC 3842).
2311 *
2312 * See also \a enable_unsolicited_mwi field on #pjsua_config.
Benny Prijono4dd961b2009-10-26 11:21:37 +00002313 *
2314 * Default: no
2315 */
2316 pj_bool_t mwi_enabled;
2317
2318 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002319 * If this flag is set, the presence information of this account will
2320 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono48ab2b72007-11-08 09:24:30 +00002321 *
2322 * Default: PJ_FALSE
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002323 */
2324 pj_bool_t publish_enabled;
2325
Benny Prijonofe04fb52007-08-24 08:28:52 +00002326 /**
Benny Prijonofe50c9e2009-10-12 07:44:14 +00002327 * Event publication options.
2328 */
2329 pjsip_publishc_opt publish_opt;
2330
2331 /**
Benny Prijono534a9ba2009-10-13 14:01:59 +00002332 * Maximum time to wait for unpublication transaction(s) to complete
2333 * during shutdown process, before sending unregistration. The library
2334 * tries to wait for the unpublication (un-PUBLISH) to complete before
2335 * sending REGISTER request to unregister the account, during library
2336 * shutdown process. If the value is set too short, it is possible that
2337 * the unregistration is sent before unpublication completes, causing
2338 * unpublication request to fail.
2339 *
2340 * Default: PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
2341 */
2342 unsigned unpublish_max_wait_time_msec;
2343
2344 /**
Benny Prijono48ab2b72007-11-08 09:24:30 +00002345 * Authentication preference.
2346 */
2347 pjsip_auth_clt_pref auth_pref;
2348
2349 /**
Benny Prijonofe04fb52007-08-24 08:28:52 +00002350 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
2351 * is not specified, a random string will be used.
2352 */
2353 pj_str_t pidf_tuple_id;
2354
Benny Prijono312aff92006-06-17 04:08:30 +00002355 /**
2356 * Optional URI to be put as Contact for this account. It is recommended
2357 * that this field is left empty, so that the value will be calculated
2358 * automatically based on the transport address.
2359 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00002360 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00002361
2362 /**
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00002363 * Additional parameters that will be appended in the Contact header
Benny Prijono30fe4852008-12-10 16:54:16 +00002364 * for this account. This will affect the Contact header in all SIP
2365 * messages sent on behalf of this account, including but not limited to
2366 * REGISTER, INVITE, and SUBCRIBE requests or responses.
2367 *
2368 * The parameters should be preceeded by semicolon, and all strings must
2369 * be properly escaped. Example:
2370 * ";my-param=X;another-param=Hi%20there"
2371 */
2372 pj_str_t contact_params;
2373
2374 /**
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00002375 * Additional URI parameters that will be appended in the Contact URI
2376 * for this account. This will affect the Contact URI in all SIP
2377 * messages sent on behalf of this account, including but not limited to
2378 * REGISTER, INVITE, and SUBCRIBE requests or responses.
2379 *
2380 * The parameters should be preceeded by semicolon, and all strings must
2381 * be properly escaped. Example:
2382 * ";my-param=X;another-param=Hi%20there"
2383 */
2384 pj_str_t contact_uri_params;
2385
2386 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00002387 * Specify whether support for reliable provisional response (100rel and
2388 * PRACK) should be required for all sessions of this account.
2389 *
2390 * Default: PJ_FALSE
2391 */
2392 pj_bool_t require_100rel;
2393
2394 /**
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002395 * Specify the usage of Session Timers for all sessions. See the
2396 * #pjsua_sip_timer_use for possible values.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002397 *
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002398 * Default: PJSUA_SIP_TIMER_OPTIONAL
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002399 */
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002400 pjsua_sip_timer_use use_timer;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002401
2402 /**
Nanang Izzuddin65add622009-08-11 16:26:20 +00002403 * Specify Session Timer settings, see #pjsip_timer_setting.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002404 */
Nanang Izzuddin65add622009-08-11 16:26:20 +00002405 pjsip_timer_setting timer_setting;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002406
2407 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002408 * Number of proxies in the proxy array below.
2409 */
2410 unsigned proxy_cnt;
2411
2412 /**
2413 * Optional URI of the proxies to be visited for all outgoing requests
2414 * that are using this account (REGISTER, INVITE, etc). Application need
2415 * to specify these proxies if the service provider requires that requests
2416 * destined towards its network should go through certain proxies first
2417 * (for example, border controllers).
2418 *
2419 * These proxies will be put in the route set for this account, with
2420 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00002421 * first). If global outbound proxies are configured in pjsua_config,
2422 * then these account proxies will be placed after the global outbound
2423 * proxies in the routeset.
Benny Prijono312aff92006-06-17 04:08:30 +00002424 */
2425 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
2426
2427 /**
2428 * Optional interval for registration, in seconds. If the value is zero,
Benny Prijonobddef2c2007-10-31 13:28:08 +00002429 * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
Benny Prijono312aff92006-06-17 04:08:30 +00002430 */
2431 unsigned reg_timeout;
2432
Benny Prijono384dab42009-10-14 01:58:04 +00002433 /**
Sauw Ming9b80d512011-03-15 03:20:37 +00002434 * Specify the number of seconds to refresh the client registration
2435 * before the registration expires.
2436 *
2437 * Default: PJSIP_REGISTER_CLIENT_DELAY_BEFORE_REFRESH, 5 seconds
2438 */
2439 unsigned reg_delay_before_refresh;
2440
2441 /**
Benny Prijono384dab42009-10-14 01:58:04 +00002442 * Specify the maximum time to wait for unregistration requests to
2443 * complete during library shutdown sequence.
2444 *
2445 * Default: PJSUA_UNREG_TIMEOUT
2446 */
2447 unsigned unreg_timeout;
2448
Benny Prijono312aff92006-06-17 04:08:30 +00002449 /**
2450 * Number of credentials in the credential array.
2451 */
2452 unsigned cred_count;
2453
2454 /**
2455 * Array of credentials. If registration is desired, normally there should
2456 * be at least one credential specified, to successfully authenticate
2457 * against the service provider. More credentials can be specified, for
2458 * example when the requests are expected to be challenged by the
2459 * proxies in the route set.
2460 */
2461 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
2462
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002463 /**
2464 * Optionally bind this account to specific transport. This normally is
2465 * not a good idea, as account should be able to send requests using
2466 * any available transports according to the destination. But some
2467 * application may want to have explicit control over the transport to
2468 * use, so in that case it can set this field.
2469 *
2470 * Default: -1 (PJSUA_INVALID_ID)
2471 *
2472 * @see pjsua_acc_set_transport()
2473 */
2474 pjsua_transport_id transport_id;
2475
Benny Prijono15b02302007-09-27 14:07:07 +00002476 /**
Benny Prijonocca2e432010-02-25 09:33:18 +00002477 * This option is used to update the transport address and the Contact
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002478 * header of REGISTER request. When this option is enabled, the library
2479 * will keep track of the public IP address from the response of REGISTER
2480 * request. Once it detects that the address has changed, it will
2481 * unregister current Contact, update the Contact with transport address
2482 * learned from Via header, and register a new Contact to the registrar.
2483 * This will also update the public name of UDP transport if STUN is
Benny Prijonocca2e432010-02-25 09:33:18 +00002484 * configured.
Benny Prijono15b02302007-09-27 14:07:07 +00002485 *
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00002486 * See also contact_rewrite_method field.
2487 *
Benny Prijono15b02302007-09-27 14:07:07 +00002488 * Default: 1 (yes)
2489 */
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002490 pj_bool_t allow_contact_rewrite;
Benny Prijono15b02302007-09-27 14:07:07 +00002491
Benny Prijonobddef2c2007-10-31 13:28:08 +00002492 /**
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00002493 * Specify how Contact update will be done with the registration, if
2494 * \a allow_contact_rewrite is enabled.
2495 *
2496 * If set to 1, the Contact update will be done by sending unregistration
2497 * to the currently registered Contact, while simultaneously sending new
2498 * registration (with different Call-ID) for the updated Contact.
2499 *
2500 * If set to 2, the Contact update will be done in a single, current
2501 * registration session, by removing the current binding (by setting its
2502 * Contact's expires parameter to zero) and adding a new Contact binding,
2503 * all done in a single request.
2504 *
2505 * Value 1 is the legacy behavior.
2506 *
2507 * Default value: PJSUA_CONTACT_REWRITE_METHOD (2)
2508 */
2509 int contact_rewrite_method;
2510
2511 /**
Benny Prijonob54719f2010-11-16 03:07:46 +00002512 * Control the use of SIP outbound feature. SIP outbound is described in
2513 * RFC 5626 to enable proxies or registrar to send inbound requests back
2514 * to UA using the same connection initiated by the UA for its
2515 * registration. This feature is highly useful in NAT-ed deployemtns,
2516 * hence it is enabled by default.
2517 *
2518 * Note: currently SIP outbound can only be used with TCP and TLS
2519 * transports. If UDP is used for the registration, the SIP outbound
2520 * feature will be silently ignored for the account.
2521 *
2522 * Default: PJ_TRUE
2523 */
2524 unsigned use_rfc5626;
2525
2526 /**
2527 * Specify SIP outbound (RFC 5626) instance ID to be used by this
2528 * application. If empty, an instance ID will be generated based on
2529 * the hostname of this agent. If application specifies this parameter, the
2530 * value will look like "<urn:uuid:00000000-0000-1000-8000-AABBCCDDEEFF>"
2531 * without the doublequote.
2532 *
2533 * Default: empty
2534 */
2535 pj_str_t rfc5626_instance_id;
2536
2537 /**
2538 * Specify SIP outbound (RFC 5626) registration ID. The default value
2539 * is empty, which would cause the library to automatically generate
2540 * a suitable value.
2541 *
2542 * Default: empty
2543 */
2544 pj_str_t rfc5626_reg_id;
2545
2546 /**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002547 * Set the interval for periodic keep-alive transmission for this account.
2548 * If this value is zero, keep-alive will be disabled for this account.
2549 * The keep-alive transmission will be sent to the registrar's address,
2550 * after successful registration.
2551 *
Benny Prijonobddef2c2007-10-31 13:28:08 +00002552 * Default: 15 (seconds)
2553 */
2554 unsigned ka_interval;
2555
2556 /**
2557 * Specify the data to be transmitted as keep-alive packets.
2558 *
2559 * Default: CR-LF
2560 */
2561 pj_str_t ka_data;
2562
Benny Prijono0bc99a92011-03-17 04:34:43 +00002563 /**
2564 * Maximum number of simultaneous active audio streams to be allowed
2565 * for calls on this account. Setting this to zero will disable audio
2566 * in calls on this account.
2567 *
2568 * Default: 1
2569 */
2570 unsigned max_audio_cnt;
2571
2572 /**
2573 * Maximum number of simultaneous active video streams to be allowed
2574 * for calls on this account. Setting this to zero will disable video
Benny Prijono9f468d12011-07-07 07:46:33 +00002575 * in calls on this account, regardless of other video settings.
Benny Prijono0bc99a92011-03-17 04:34:43 +00002576 *
Benny Prijono9f468d12011-07-07 07:46:33 +00002577 * Default: 1
Benny Prijono0bc99a92011-03-17 04:34:43 +00002578 */
2579 unsigned max_video_cnt;
2580
2581 /**
Benny Prijono9f468d12011-07-07 07:46:33 +00002582 * Specify whether incoming video should be shown to screen by default.
2583 * This applies to incoming call (INVITE), incoming re-INVITE, and
2584 * incoming UPDATE requests.
2585 *
2586 * Regardless of this setting, application can detect incoming video
2587 * by implementing \a on_call_media_state() callback and enumerating
2588 * the media stream(s) with #pjsua_call_get_info(). Once incoming
2589 * video is recognised, application may retrieve the window associated
2590 * with the incoming video and show or hide it with
2591 * #pjsua_vid_win_set_show().
2592 *
2593 * Default: PJ_FALSE
2594 */
2595 pj_bool_t vid_in_auto_show;
2596
2597 /**
2598 * Specify whether outgoing video should be activated by default when
2599 * making outgoing calls and/or when incoming video is detected. This
2600 * applies to incoming and outgoing calls, incoming re-INVITE, and
2601 * incoming UPDATE. If the setting is non-zero, outgoing video
2602 * transmission will be started as soon as response to these requests
2603 * is sent (or received).
2604 *
2605 * Regardless of the value of this setting, application can start and
2606 * stop outgoing video transmission with #pjsua_call_set_vid_out().
2607 *
2608 * Default: PJ_FALSE
2609 */
2610 pj_bool_t vid_out_auto_transmit;
2611
2612 /**
2613 * Specify the default capture device to be used by this account. If
2614 * \a vid_out_auto_transmit is enabled, this device will be used for
2615 * capturing video.
2616 *
2617 * Default: PJMEDIA_VID_DEFAULT_CAPTURE_DEV
2618 */
2619 pjmedia_vid_dev_index vid_cap_dev;
2620
2621 /**
2622 * Specify the default rendering device to be used by this account.
2623 *
2624 * Default: PJMEDIA_VID_DEFAULT_RENDER_DEV
2625 */
2626 pjmedia_vid_dev_index vid_rend_dev;
2627
2628 /**
Benny Prijono0bc99a92011-03-17 04:34:43 +00002629 * Media transport config.
2630 */
2631 pjsua_transport_config rtp_cfg;
2632
Benny Prijonod8179652008-01-23 20:39:07 +00002633 /**
2634 * Specify whether secure media transport should be used for this account.
2635 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
2636 * PJMEDIA_SRTP_MANDATORY.
2637 *
2638 * Default: #PJSUA_DEFAULT_USE_SRTP
2639 */
2640 pjmedia_srtp_use use_srtp;
2641
2642 /**
2643 * Specify whether SRTP requires secure signaling to be used. This option
2644 * is only used when \a use_srtp option above is non-zero.
2645 *
2646 * Valid values are:
2647 * 0: SRTP does not require secure signaling
2648 * 1: SRTP requires secure transport such as TLS
2649 * 2: SRTP requires secure end-to-end transport (SIPS)
2650 *
2651 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
2652 */
2653 int srtp_secure_signaling;
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00002654
2655 /**
Benny Prijono0bc99a92011-03-17 04:34:43 +00002656 * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00002657 * duplicated media in SDP offer, i.e: unsecured and secured version.
Benny Prijono0bc99a92011-03-17 04:34:43 +00002658 * Otherwise, the SDP media will be composed as unsecured media but
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00002659 * with SDP "crypto" attribute.
2660 *
2661 * Default: PJ_FALSE
2662 */
2663 pj_bool_t srtp_optional_dup_offer;
Benny Prijonod8179652008-01-23 20:39:07 +00002664
Nanang Izzuddin36dd5b62010-03-30 11:13:59 +00002665 /**
2666 * Specify interval of auto registration retry upon registration failure
2667 * (including caused by transport problem), in second. Set to 0 to
2668 * disable auto re-registration.
2669 *
2670 * Default: #PJSUA_REG_RETRY_INTERVAL
2671 */
2672 unsigned reg_retry_interval;
2673
2674 /**
2675 * Specify whether calls of the configured account should be dropped
2676 * after registration failure and an attempt of re-registration has
2677 * also failed.
2678 *
2679 * Default: PJ_FALSE (disabled)
2680 */
2681 pj_bool_t drop_calls_on_reg_fail;
2682
Benny Prijono29c8ca32010-06-22 06:02:13 +00002683 /**
2684 * Specify how the registration uses the outbound and account proxy
2685 * settings. This controls if and what Route headers will appear in
2686 * the REGISTER request of this account. The value is bitmask combination
2687 * of PJSUA_REG_USE_OUTBOUND_PROXY and PJSUA_REG_USE_ACC_PROXY bits.
2688 * If the value is set to 0, the REGISTER request will not use any proxy
2689 * (i.e. it will not have any Route headers).
2690 *
2691 * Default: 3 (PJSUA_REG_USE_OUTBOUND_PROXY | PJSUA_REG_USE_ACC_PROXY)
2692 */
2693 unsigned reg_use_proxy;
2694
Nanang Izzuddin5e39a2b2010-09-20 06:13:02 +00002695#if defined(PJMEDIA_STREAM_ENABLE_KA) && (PJMEDIA_STREAM_ENABLE_KA != 0)
2696 /**
2697 * Specify whether stream keep-alive and NAT hole punching with
2698 * non-codec-VAD mechanism (see @ref PJMEDIA_STREAM_ENABLE_KA) is enabled
2699 * for this account.
2700 *
2701 * Default: PJ_FALSE (disabled)
2702 */
2703 pj_bool_t use_stream_ka;
2704#endif
2705
Benny Prijonodd63b992010-10-01 02:03:42 +00002706 /**
2707 * Specify how to offer call hold to remote peer. Please see the
2708 * documentation on #pjsua_call_hold_type for more info.
2709 *
2710 * Default: PJSUA_CALL_HOLD_TYPE_DEFAULT
2711 */
2712 pjsua_call_hold_type call_hold_type;
2713
Benny Prijono312aff92006-06-17 04:08:30 +00002714} pjsua_acc_config;
2715
2716
2717/**
2718 * Call this function to initialize account config with default values.
2719 *
2720 * @param cfg The account config to be initialized.
2721 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00002722PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002723
2724
2725/**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002726 * Duplicate account config.
2727 *
2728 * @param pool Pool to be used for duplicating the config.
2729 * @param dst Destination configuration.
2730 * @param src Source configuration.
2731 */
2732PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
2733 pjsua_acc_config *dst,
2734 const pjsua_acc_config *src);
2735
2736
2737/**
Benny Prijono312aff92006-06-17 04:08:30 +00002738 * Account info. Application can query account info by calling
2739 * #pjsua_acc_get_info().
2740 */
2741typedef struct pjsua_acc_info
2742{
2743 /**
2744 * The account ID.
2745 */
2746 pjsua_acc_id id;
2747
2748 /**
2749 * Flag to indicate whether this is the default account.
2750 */
2751 pj_bool_t is_default;
2752
2753 /**
2754 * Account URI
2755 */
2756 pj_str_t acc_uri;
2757
2758 /**
2759 * Flag to tell whether this account has registration setting
2760 * (reg_uri is not empty).
2761 */
2762 pj_bool_t has_registration;
2763
2764 /**
2765 * An up to date expiration interval for account registration session.
2766 */
2767 int expires;
2768
2769 /**
2770 * Last registration status code. If status code is zero, the account
2771 * is currently not registered. Any other value indicates the SIP
2772 * status code of the registration.
2773 */
2774 pjsip_status_code status;
2775
2776 /**
Sauw Ming48f6dbf2010-09-07 05:10:25 +00002777 * Last registration error code. When the status field contains a SIP
2778 * status code that indicates a registration failure, last registration
2779 * error code contains the error code that causes the failure. In any
2780 * other case, its value is zero.
2781 */
2782 pj_status_t reg_last_err;
2783
2784 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002785 * String describing the registration status.
2786 */
2787 pj_str_t status_text;
2788
2789 /**
2790 * Presence online status for this account.
2791 */
2792 pj_bool_t online_status;
2793
2794 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00002795 * Presence online status text.
2796 */
2797 pj_str_t online_status_text;
2798
2799 /**
2800 * Extended RPID online status information.
2801 */
2802 pjrpid_element rpid;
2803
2804 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002805 * Buffer that is used internally to store the status text.
2806 */
2807 char buf_[PJ_ERR_MSG_SIZE];
2808
2809} pjsua_acc_info;
2810
2811
2812
2813/**
2814 * Get number of current accounts.
2815 *
2816 * @return Current number of accounts.
2817 */
2818PJ_DECL(unsigned) pjsua_acc_get_count(void);
2819
2820
2821/**
2822 * Check if the specified account ID is valid.
2823 *
2824 * @param acc_id Account ID to check.
2825 *
2826 * @return Non-zero if account ID is valid.
2827 */
2828PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
2829
2830
2831/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00002832 * Set default account to be used when incoming and outgoing
2833 * requests doesn't match any accounts.
2834 *
2835 * @param acc_id The account ID to be used as default.
2836 *
2837 * @return PJ_SUCCESS on success.
2838 */
2839PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2840
2841
2842/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002843 * Get default account to be used when receiving incoming requests (calls),
2844 * when the destination of the incoming call doesn't match any other
2845 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002846 *
2847 * @return The default account ID, or PJSUA_INVALID_ID if no
2848 * default account is configured.
2849 */
2850PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2851
2852
2853/**
Benny Prijono312aff92006-06-17 04:08:30 +00002854 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002855 * #pjsua_init()) before calling this function. If registration is configured
2856 * for this account, this function would also start the SIP registration
2857 * session with the SIP registrar server. This SIP registration session
2858 * will be maintained internally by the library, and application doesn't
2859 * need to do anything to maintain the registration session.
2860 *
Benny Prijono312aff92006-06-17 04:08:30 +00002861 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002862 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002863 * @param is_default If non-zero, this account will be set as the default
2864 * account. The default account will be used when sending
2865 * outgoing requests (e.g. making call) when no account is
2866 * specified, and when receiving incoming requests when the
2867 * request does not match any accounts. It is recommended
2868 * that default account is set to local/LAN account.
2869 * @param p_acc_id Pointer to receive account ID of the new account.
2870 *
2871 * @return PJ_SUCCESS on success, or the appropriate error code.
2872 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002873PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002874 pj_bool_t is_default,
2875 pjsua_acc_id *p_acc_id);
2876
2877
2878/**
2879 * Add a local account. A local account is used to identify local endpoint
2880 * instead of a specific user, and for this reason, a transport ID is needed
2881 * to obtain the local address information.
2882 *
2883 * @param tid Transport ID to generate account address.
2884 * @param is_default If non-zero, this account will be set as the default
2885 * account. The default account will be used when sending
2886 * outgoing requests (e.g. making call) when no account is
2887 * specified, and when receiving incoming requests when the
2888 * request does not match any accounts. It is recommended
2889 * that default account is set to local/LAN account.
2890 * @param p_acc_id Pointer to receive account ID of the new account.
2891 *
2892 * @return PJ_SUCCESS on success, or the appropriate error code.
2893 */
2894PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2895 pj_bool_t is_default,
2896 pjsua_acc_id *p_acc_id);
2897
2898/**
Benny Prijono705e7842008-07-21 18:12:51 +00002899 * Set arbitrary data to be associated with the account.
2900 *
2901 * @param acc_id The account ID.
2902 * @param user_data User/application data.
2903 *
2904 * @return PJ_SUCCESS on success, or the appropriate error code.
2905 */
2906PJ_DECL(pj_status_t) pjsua_acc_set_user_data(pjsua_acc_id acc_id,
2907 void *user_data);
2908
2909
2910/**
2911 * Retrieve arbitrary data associated with the account.
2912 *
2913 * @param acc_id The account ID.
2914 *
2915 * @return The user data. In the case where the account ID is
2916 * not valid, NULL is returned.
2917 */
2918PJ_DECL(void*) pjsua_acc_get_user_data(pjsua_acc_id acc_id);
2919
2920
2921/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002922 * Delete an account. This will unregister the account from the SIP server,
2923 * if necessary, and terminate server side presence subscriptions associated
2924 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002925 *
2926 * @param acc_id Id of the account to be deleted.
2927 *
2928 * @return PJ_SUCCESS on success, or the appropriate error code.
2929 */
2930PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2931
2932
2933/**
2934 * Modify account information.
2935 *
2936 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002937 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002938 *
2939 * @return PJ_SUCCESS on success, or the appropriate error code.
2940 */
2941PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002942 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002943
2944
2945/**
2946 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002947 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002948 * if there are server side presence subscription for this account, and/or
2949 * outgoing PUBLISH if presence publication is enabled for this account.
2950 *
2951 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002952 *
2953 * @param acc_id The account ID.
2954 * @param is_online True of false.
2955 *
2956 * @return PJ_SUCCESS on success, or the appropriate error code.
2957 */
2958PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2959 pj_bool_t is_online);
2960
Benny Prijono4461c7d2007-08-25 13:36:15 +00002961/**
2962 * Modify account's presence status to be advertised to remote/presence
2963 * subscribers. This would trigger the sending of outgoing NOTIFY request
2964 * if there are server side presence subscription for this account, and/or
2965 * outgoing PUBLISH if presence publication is enabled for this account.
2966 *
2967 * @see pjsua_acc_set_online_status()
2968 *
2969 * @param acc_id The account ID.
2970 * @param is_online True of false.
2971 * @param pr Extended information in subset of RPID format
2972 * which allows setting custom presence text.
2973 *
2974 * @return PJ_SUCCESS on success, or the appropriate error code.
2975 */
2976PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2977 pj_bool_t is_online,
2978 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002979
2980/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002981 * Update registration or perform unregistration. If registration is
2982 * configured for this account, then initial SIP REGISTER will be sent
2983 * when the account is added with #pjsua_acc_add(). Application normally
2984 * only need to call this function if it wants to manually update the
2985 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002986 *
2987 * @param acc_id The account ID.
2988 * @param renew If renew argument is zero, this will start
2989 * unregistration process.
2990 *
2991 * @return PJ_SUCCESS on success, or the appropriate error code.
2992 */
2993PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2994 pj_bool_t renew);
2995
Benny Prijono312aff92006-06-17 04:08:30 +00002996/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002997 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002998 *
2999 * @param acc_id Account identification.
3000 * @param info Pointer to receive account information.
3001 *
3002 * @return PJ_SUCCESS on success, or the appropriate error code.
3003 */
3004PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
3005 pjsua_acc_info *info);
3006
3007
3008/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003009 * Enumerate all account currently active in the library. This will fill
3010 * the array with the account Ids, and application can then query the
3011 * account information for each id with #pjsua_acc_get_info().
3012 *
3013 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00003014 *
3015 * @param ids Array of account IDs to be initialized.
3016 * @param count In input, specifies the maximum number of elements.
3017 * On return, it contains the actual number of elements.
3018 *
3019 * @return PJ_SUCCESS on success, or the appropriate error code.
3020 */
3021PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
3022 unsigned *count );
3023
3024
3025/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003026 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00003027 *
3028 * @param info Array of account infos to be initialized.
3029 * @param count In input, specifies the maximum number of elements.
3030 * On return, it contains the actual number of elements.
3031 *
3032 * @return PJ_SUCCESS on success, or the appropriate error code.
3033 */
3034PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
3035 unsigned *count );
3036
3037
3038/**
3039 * This is an internal function to find the most appropriate account to
3040 * used to reach to the specified URL.
3041 *
3042 * @param url The remote URL to reach.
3043 *
3044 * @return Account id.
3045 */
3046PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
3047
3048
3049/**
3050 * This is an internal function to find the most appropriate account to be
3051 * used to handle incoming calls.
3052 *
3053 * @param rdata The incoming request message.
3054 *
3055 * @return Account id.
3056 */
3057PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
3058
3059
Benny Prijonoc570f2d2006-07-18 00:33:02 +00003060/**
Benny Prijonofff245c2007-04-02 11:44:47 +00003061 * Create arbitrary requests using the account. Application should only use
3062 * this function to create auxiliary requests outside dialog, such as
3063 * OPTIONS, and use the call or presence API to create dialog related
3064 * requests.
3065 *
3066 * @param acc_id The account ID.
3067 * @param method The SIP method of the request.
3068 * @param target Target URI.
3069 * @param p_tdata Pointer to receive the request.
3070 *
3071 * @return PJ_SUCCESS or the error code.
3072 */
3073PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
3074 const pjsip_method *method,
3075 const pj_str_t *target,
3076 pjsip_tx_data **p_tdata);
3077
3078
3079/**
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00003080 * Create a suitable Contact header value, based on the specified target URI
3081 * for the specified account.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00003082 *
3083 * @param pool Pool to allocate memory for the string.
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00003084 * @param contact The string where the Contact will be stored.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00003085 * @param acc_id Account ID.
3086 * @param uri Destination URI of the request.
3087 *
3088 * @return PJ_SUCCESS on success, other on error.
3089 */
3090PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
3091 pj_str_t *contact,
3092 pjsua_acc_id acc_id,
3093 const pj_str_t *uri);
3094
3095
3096
3097/**
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00003098 * Create a suitable Contact header value, based on the information in the
3099 * incoming request.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00003100 *
3101 * @param pool Pool to allocate memory for the string.
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00003102 * @param contact The string where the Contact will be stored.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00003103 * @param acc_id Account ID.
3104 * @param rdata Incoming request.
3105 *
3106 * @return PJ_SUCCESS on success, other on error.
3107 */
3108PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
3109 pj_str_t *contact,
3110 pjsua_acc_id acc_id,
3111 pjsip_rx_data *rdata );
3112
3113
Benny Prijono62c5c5b2007-01-13 23:22:40 +00003114/**
3115 * Lock/bind this account to a specific transport/listener. Normally
3116 * application shouldn't need to do this, as transports will be selected
3117 * automatically by the stack according to the destination.
3118 *
3119 * When account is locked/bound to a specific transport, all outgoing
3120 * requests from this account will use the specified transport (this
3121 * includes SIP registration, dialog (call and event subscription), and
3122 * out-of-dialog requests such as MESSAGE).
3123 *
3124 * Note that transport_id may be specified in pjsua_acc_config too.
3125 *
3126 * @param acc_id The account ID.
3127 * @param tp_id The transport ID.
3128 *
3129 * @return PJ_SUCCESS on success.
3130 */
3131PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
3132 pjsua_transport_id tp_id);
3133
Benny Prijono312aff92006-06-17 04:08:30 +00003134
3135/**
3136 * @}
3137 */
3138
3139
3140/*****************************************************************************
3141 * CALLS API
3142 */
3143
3144
3145/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003146 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00003147 * @ingroup PJSUA_LIB
3148 * @brief Call manipulation.
3149 * @{
3150 */
3151
3152/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003153 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00003154 */
3155#ifndef PJSUA_MAX_CALLS
3156# define PJSUA_MAX_CALLS 32
3157#endif
3158
Benny Prijono9f468d12011-07-07 07:46:33 +00003159/**
3160 * Maximum active video windows
3161 */
3162#ifndef PJSUA_MAX_VID_WINS
3163# define PJSUA_MAX_VID_WINS 16
3164#endif
3165
3166/**
3167 * Video window ID.
3168 */
3169typedef int pjsua_vid_win_id;
Benny Prijono312aff92006-06-17 04:08:30 +00003170
3171
3172/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003173 * This enumeration specifies the media status of a call, and it's part
3174 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00003175 */
3176typedef enum pjsua_call_media_status
3177{
Benny Prijono0bc99a92011-03-17 04:34:43 +00003178 /**
3179 * Call currently has no media, or the media is not used.
3180 */
Benny Prijono312aff92006-06-17 04:08:30 +00003181 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00003182
Benny Prijono0bc99a92011-03-17 04:34:43 +00003183 /**
3184 * The media is active
3185 */
Benny Prijono312aff92006-06-17 04:08:30 +00003186 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00003187
Benny Prijono0bc99a92011-03-17 04:34:43 +00003188 /**
3189 * The media is currently put on hold by local endpoint
3190 */
Benny Prijono312aff92006-06-17 04:08:30 +00003191 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00003192
Benny Prijono0bc99a92011-03-17 04:34:43 +00003193 /**
3194 * The media is currently put on hold by remote endpoint
3195 */
Benny Prijono312aff92006-06-17 04:08:30 +00003196 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00003197
Benny Prijono0bc99a92011-03-17 04:34:43 +00003198 /**
3199 * The media has reported error (e.g. ICE negotiation)
3200 */
Benny Prijono096c56c2007-09-15 08:30:16 +00003201 PJSUA_CALL_MEDIA_ERROR
3202
Benny Prijono312aff92006-06-17 04:08:30 +00003203} pjsua_call_media_status;
3204
3205
3206/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003207 * This structure describes the information and current status of a call.
Benny Prijono312aff92006-06-17 04:08:30 +00003208 */
3209typedef struct pjsua_call_info
3210{
3211 /** Call identification. */
3212 pjsua_call_id id;
3213
3214 /** Initial call role (UAC == caller) */
3215 pjsip_role_e role;
3216
Benny Prijono90315512006-09-14 16:05:16 +00003217 /** The account ID where this call belongs. */
3218 pjsua_acc_id acc_id;
3219
Benny Prijono312aff92006-06-17 04:08:30 +00003220 /** Local URI */
3221 pj_str_t local_info;
3222
3223 /** Local Contact */
3224 pj_str_t local_contact;
3225
3226 /** Remote URI */
3227 pj_str_t remote_info;
3228
3229 /** Remote contact */
3230 pj_str_t remote_contact;
3231
3232 /** Dialog Call-ID string. */
3233 pj_str_t call_id;
3234
3235 /** Call state */
3236 pjsip_inv_state state;
3237
3238 /** Text describing the state */
3239 pj_str_t state_text;
3240
3241 /** Last status code heard, which can be used as cause code */
3242 pjsip_status_code last_status;
3243
3244 /** The reason phrase describing the status. */
3245 pj_str_t last_status_text;
3246
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003247 /** Media status of the first audio stream. */
Benny Prijono312aff92006-06-17 04:08:30 +00003248 pjsua_call_media_status media_status;
3249
Benny Prijono0bc99a92011-03-17 04:34:43 +00003250 /** Media direction of the first audio stream. */
Benny Prijono312aff92006-06-17 04:08:30 +00003251 pjmedia_dir media_dir;
3252
Benny Prijono0bc99a92011-03-17 04:34:43 +00003253 /** The conference port number for the first audio stream. */
Benny Prijono312aff92006-06-17 04:08:30 +00003254 pjsua_conf_port_id conf_slot;
3255
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003256 /** Number of media streams in this call */
3257 unsigned media_cnt;
3258
3259 /** Array of media stream information */
Benny Prijono0bc99a92011-03-17 04:34:43 +00003260 struct
3261 {
3262 /** Media index in SDP. */
3263 unsigned index;
3264
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003265 /** Media type. */
3266 pjmedia_type type;
Benny Prijono0bc99a92011-03-17 04:34:43 +00003267
3268 /** Media direction. */
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003269 pjmedia_dir dir;
Benny Prijono0bc99a92011-03-17 04:34:43 +00003270
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003271 /** Call media status. */
3272 pjsua_call_media_status status;
Benny Prijono0bc99a92011-03-17 04:34:43 +00003273
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003274 /** The specific media stream info. */
3275 union {
3276 /** Audio stream */
3277 struct {
Benny Prijono9f468d12011-07-07 07:46:33 +00003278 /** The conference port number for the call. */
3279 pjsua_conf_port_id conf_slot;
3280 } aud;
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003281
3282 /** Video stream */
3283 struct {
Benny Prijono9f468d12011-07-07 07:46:33 +00003284 /**
3285 * The window id for incoming video, if any, or
3286 * PJSUA_INVALID_ID.
3287 */
3288 pjsua_vid_win_id win_in;
3289
3290 /** The video capture device for outgoing transmission,
3291 * if any, or PJMEDIA_VID_INVALID_DEV
3292 */
3293 pjmedia_vid_dev_index cap_dev;
3294
3295 } vid;
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003296 } stream;
3297
3298 } media[PJMEDIA_MAX_SDP_MEDIA];
Benny Prijono0bc99a92011-03-17 04:34:43 +00003299
Benny Prijono312aff92006-06-17 04:08:30 +00003300 /** Up-to-date call connected duration (zero when call is not
3301 * established)
3302 */
3303 pj_time_val connect_duration;
3304
3305 /** Total call duration, including set-up time */
3306 pj_time_val total_duration;
3307
3308 /** Internal */
3309 struct {
3310 char local_info[128];
3311 char local_contact[128];
3312 char remote_info[128];
3313 char remote_contact[128];
3314 char call_id[128];
3315 char last_status_text[128];
3316 } buf_;
3317
3318} pjsua_call_info;
3319
Benny Prijonodec3a372011-03-16 03:52:20 +00003320/**
3321 * Flags to be given to various call APIs. More than one flags may be
3322 * specified by bitmasking them.
3323 */
3324typedef enum pjsua_call_flag
3325{
3326 /**
3327 * When the call is being put on hold, specify this flag to unhold it.
Benny Prijonocf51b612011-03-16 04:04:59 +00003328 * This flag is only valid for #pjsua_call_reinvite(). Note: for
3329 * compatibility reason, this flag must have value of 1 because
3330 * previously the unhold option is specified as boolean value.
Benny Prijonodec3a372011-03-16 03:52:20 +00003331 */
3332 PJSUA_CALL_UNHOLD = 1,
Benny Prijono312aff92006-06-17 04:08:30 +00003333
Benny Prijonodec3a372011-03-16 03:52:20 +00003334 /**
3335 * Update the local invite session's contact with the contact URI from
3336 * the account. This flag is only valid for #pjsua_call_reinvite() and
3337 * #pjsua_call_update(). This flag is useful in IP address change
3338 * situation, after the local account's Contact has been updated
3339 * (typically with re-registration) use this flag to update the invite
3340 * session with the new Contact and to inform this new Contact to the
3341 * remote peer with the outgoing re-INVITE or UPDATE
3342 */
3343 PJSUA_CALL_UPDATE_CONTACT = 2
3344
3345} pjsua_call_flag;
Benny Prijono312aff92006-06-17 04:08:30 +00003346
Benny Prijonoa91a0032006-02-26 21:23:45 +00003347
Benny Prijono9f468d12011-07-07 07:46:33 +00003348/**
3349 * Media stream info.
3350 */
3351typedef struct pjsua_stream_info
3352{
3353 /** Media type of this stream. */
3354 pjmedia_type type;
3355
3356 /** Stream info (union). */
3357 union {
3358 /** Audio stream info */
3359 pjmedia_stream_info aud;
3360
3361 /** Video stream info */
3362 pjmedia_vid_stream_info vid;
3363 } info;
3364
3365} pjsua_stream_info;
3366
3367
3368/**
3369 * Media stream statistic.
3370 */
3371typedef struct pjsua_stream_stat
3372{
3373 /** RTCP statistic. */
3374 pjmedia_rtcp_stat rtcp;
3375
3376 /** Jitter buffer statistic. */
3377 pjmedia_jb_state jbuf;
3378
3379} pjsua_stream_stat;
3380
Benny Prijonoa91a0032006-02-26 21:23:45 +00003381
3382/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00003383 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003384 *
3385 * @return Maximum number of calls configured.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003386 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003387PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003388
3389/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003390 * Get number of currently active calls.
3391 *
3392 * @return Number of currently active calls.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003393 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003394PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003395
3396/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003397 * Enumerate all active calls. Application may then query the information and
3398 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003399 *
3400 * @param ids Array of account IDs to be initialized.
3401 * @param count In input, specifies the maximum number of elements.
3402 * On return, it contains the actual number of elements.
3403 *
3404 * @return PJ_SUCCESS on success, or the appropriate error code.
3405 */
3406PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
3407 unsigned *count);
3408
3409
3410/**
3411 * Make outgoing call to the specified URI using the specified account.
3412 *
3413 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003414 * @param dst_uri URI to be put in the To header (normally is the same
3415 * as the target URI).
3416 * @param options Options (must be zero at the moment).
3417 * @param user_data Arbitrary user data to be attached to the call, and
3418 * can be retrieved later.
3419 * @param msg_data Optional headers etc to be added to outgoing INVITE
3420 * request, or NULL if no custom header is desired.
3421 * @param p_call_id Pointer to receive call identification.
3422 *
3423 * @return PJ_SUCCESS on success, or the appropriate error code.
3424 */
3425PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
3426 const pj_str_t *dst_uri,
3427 unsigned options,
3428 void *user_data,
3429 const pjsua_msg_data *msg_data,
3430 pjsua_call_id *p_call_id);
3431
3432
3433/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00003434 * Check if the specified call has active INVITE session and the INVITE
3435 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003436 *
3437 * @param call_id Call identification.
3438 *
3439 * @return Non-zero if call is active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003440 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003441PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003442
3443
3444/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003445 * Check if call has an active media session.
3446 *
3447 * @param call_id Call identification.
3448 *
3449 * @return Non-zero if yes.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003450 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003451PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003452
3453
3454/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003455 * Get the conference port identification associated with the call.
3456 *
3457 * @param call_id Call identification.
3458 *
Benny Prijono9f468d12011-07-07 07:46:33 +00003459 * @return Conference port ID, or PJSUA_INVALID_ID when the
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003460 * media has not been established or is not active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003461 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003462PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
3463
3464/**
3465 * Obtain detail information about the specified call.
3466 *
3467 * @param call_id Call identification.
3468 * @param info Call info to be initialized.
3469 *
3470 * @return PJ_SUCCESS on success, or the appropriate error code.
3471 */
3472PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003473 pjsua_call_info *info);
3474
Nanang Izzuddin2a1b9ee2010-06-03 10:41:32 +00003475/**
3476 * Check if remote peer support the specified capability.
3477 *
3478 * @param call_id Call identification.
3479 * @param htype The header type to be checked, which value may be:
3480 * - PJSIP_H_ACCEPT
3481 * - PJSIP_H_ALLOW
3482 * - PJSIP_H_SUPPORTED
3483 * @param hname If htype specifies PJSIP_H_OTHER, then the header
3484 * name must be supplied in this argument. Otherwise the
3485 * value must be set to NULL.
3486 * @param token The capability token to check. For example, if \a
3487 * htype is PJSIP_H_ALLOW, then \a token specifies the
3488 * method names; if \a htype is PJSIP_H_SUPPORTED, then
3489 * \a token specifies the extension names such as
3490 * "100rel".
3491 *
3492 * @return PJSIP_DIALOG_CAP_SUPPORTED if the specified capability
3493 * is explicitly supported, see @pjsip_dialog_cap_status
3494 * for more info.
3495 */
3496PJ_DECL(pjsip_dialog_cap_status) pjsua_call_remote_has_cap(
3497 pjsua_call_id call_id,
3498 int htype,
3499 const pj_str_t *hname,
3500 const pj_str_t *token);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003501
3502/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003503 * Attach application specific data to the call. Application can then
3504 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003505 *
3506 * @param call_id Call identification.
3507 * @param user_data Arbitrary data to be attached to the call.
3508 *
3509 * @return The user data.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003510 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003511PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
3512 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003513
3514
3515/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003516 * Get user data attached to the call, which has been previously set with
3517 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003518 *
3519 * @param call_id Call identification.
3520 *
3521 * @return The user data.
Benny Prijono268ca612006-02-07 12:34:11 +00003522 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003523PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00003524
3525
3526/**
Benny Prijono91a6a172007-10-31 08:59:29 +00003527 * Get the NAT type of remote's endpoint. This is a proprietary feature
3528 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
3529 * is set in #pjsua_config.
3530 *
3531 * This function can only be called after SDP has been received from remote,
3532 * which means for incoming call, this function can be called as soon as
3533 * call is received as long as incoming call contains SDP, and for outgoing
3534 * call, this function can be called only after SDP is received (normally in
3535 * 200/OK response to INVITE). As a general case, application should call
3536 * this function after or in \a on_call_media_state() callback.
3537 *
3538 * @param call_id Call identification.
3539 * @param p_type Pointer to store the NAT type. Application can then
3540 * retrieve the string description of the NAT type
3541 * by calling pj_stun_get_nat_name().
3542 *
3543 * @return PJ_SUCCESS on success.
3544 *
3545 * @see pjsua_get_nat_type(), nat_type_in_sdp
3546 */
3547PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
3548 pj_stun_nat_type *p_type);
3549
3550/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003551 * Send response to incoming INVITE request. Depending on the status
3552 * code specified as parameter, this function may send provisional
3553 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003554 *
3555 * @param call_id Incoming call identification.
3556 * @param code Status code, (100-699).
3557 * @param reason Optional reason phrase. If NULL, default text
3558 * will be used.
3559 * @param msg_data Optional list of headers etc to be added to outgoing
3560 * response message.
3561 *
3562 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoa91a0032006-02-26 21:23:45 +00003563 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003564PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
3565 unsigned code,
3566 const pj_str_t *reason,
3567 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00003568
3569/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003570 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00003571 * call state. This function is different than answering the call with
3572 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
3573 * will hangup the call regardless of the state and role of the call,
3574 * while #pjsua_call_answer() only works with incoming calls on EARLY
3575 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003576 *
3577 * @param call_id Call identification.
3578 * @param code Optional status code to be sent when we're rejecting
3579 * incoming call. If the value is zero, "603/Decline"
3580 * will be sent.
3581 * @param reason Optional reason phrase to be sent when we're rejecting
3582 * incoming call. If NULL, default text will be used.
3583 * @param msg_data Optional list of headers etc to be added to outgoing
3584 * request/response message.
3585 *
3586 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003587 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003588PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
3589 unsigned code,
3590 const pj_str_t *reason,
3591 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003592
Benny Prijono5e51a4e2008-11-27 00:06:46 +00003593/**
3594 * Accept or reject redirection response. Application MUST call this function
3595 * after it signaled PJSIP_REDIRECT_PENDING in the \a on_call_redirected()
3596 * callback, to notify the call whether to accept or reject the redirection
3597 * to the current target. Application can use the combination of
3598 * PJSIP_REDIRECT_PENDING command in \a on_call_redirected() callback and
3599 * this function to ask for user permission before redirecting the call.
3600 *
3601 * Note that if the application chooses to reject or stop redirection (by
3602 * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the
3603 * call disconnection callback will be called before this function returns.
3604 * And if the application rejects the target, the \a on_call_redirected()
3605 * callback may also be called before this function returns if there is
3606 * another target to try.
3607 *
3608 * @param call_id The call ID.
3609 * @param cmd Redirection operation to be applied to the current
3610 * target. The semantic of this argument is similar
3611 * to the description in the \a on_call_redirected()
3612 * callback, except that the PJSIP_REDIRECT_PENDING is
3613 * not accepted here.
3614 *
3615 * @return PJ_SUCCESS on successful operation.
3616 */
3617PJ_DECL(pj_status_t) pjsua_call_process_redirect(pjsua_call_id call_id,
3618 pjsip_redirect_op cmd);
Benny Prijono26ff9062006-02-21 23:47:00 +00003619
3620/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003621 * Put the specified call on hold. This will send re-INVITE with the
3622 * appropriate SDP to inform remote that the call is being put on hold.
3623 * The final status of the request itself will be reported on the
3624 * \a on_call_media_state() callback, which inform the application that
3625 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003626 *
3627 * @param call_id Call identification.
3628 * @param msg_data Optional message components to be sent with
3629 * the request.
3630 *
3631 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003632 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003633PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
3634 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003635
3636
3637/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003638 * Send re-INVITE to release hold.
3639 * The final status of the request itself will be reported on the
3640 * \a on_call_media_state() callback, which inform the application that
3641 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003642 *
3643 * @param call_id Call identification.
Benny Prijonodec3a372011-03-16 03:52:20 +00003644 * @param options Bitmask of pjsua_call_flag constants. Note that
3645 * for compatibility, specifying PJ_TRUE here is
3646 * equal to specifying PJSUA_CALL_UNHOLD flag.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003647 * @param msg_data Optional message components to be sent with
3648 * the request.
3649 *
3650 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003651 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003652PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
Benny Prijonodec3a372011-03-16 03:52:20 +00003653 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003654 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003655
Benny Prijonoc08682e2007-10-04 06:17:58 +00003656/**
3657 * Send UPDATE request.
3658 *
3659 * @param call_id Call identification.
Benny Prijonodec3a372011-03-16 03:52:20 +00003660 * @param options Bitmask of pjsua_call_flag constants.
Benny Prijonoc08682e2007-10-04 06:17:58 +00003661 * @param msg_data Optional message components to be sent with
3662 * the request.
3663 *
3664 * @return PJ_SUCCESS on success, or the appropriate error code.
3665 */
3666PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
3667 unsigned options,
3668 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003669
3670/**
Benny Prijono053f5222006-11-11 16:16:04 +00003671 * Initiate call transfer to the specified address. This function will send
3672 * REFER request to instruct remote call party to initiate a new INVITE
3673 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003674 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00003675 * If application is interested to monitor the successfulness and
3676 * the progress of the transfer request, it can implement
3677 * \a on_call_transfer_status() callback which will report the progress
3678 * of the call transfer request.
3679 *
Benny Prijono053f5222006-11-11 16:16:04 +00003680 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003681 * @param dest Address of new target to be contacted.
3682 * @param msg_data Optional message components to be sent with
3683 * the request.
3684 *
3685 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003686 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003687PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
3688 const pj_str_t *dest,
3689 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003690
3691/**
Benny Prijono053f5222006-11-11 16:16:04 +00003692 * Flag to indicate that "Require: replaces" should not be put in the
3693 * outgoing INVITE request caused by REFER request created by
3694 * #pjsua_call_xfer_replaces().
3695 */
3696#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
3697
3698/**
3699 * Initiate attended call transfer. This function will send REFER request
3700 * to instruct remote call party to initiate new INVITE session to the URL
3701 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
3702 * the call with us with the new call from the REFER recipient.
3703 *
3704 * @param call_id The call id to be transfered.
3705 * @param dest_call_id The call id to be replaced.
3706 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
3707 * to suppress the inclusion of "Require: replaces" in
3708 * the outgoing INVITE request created by the REFER
3709 * request.
3710 * @param msg_data Optional message components to be sent with
3711 * the request.
3712 *
3713 * @return PJ_SUCCESS on success, or the appropriate error code.
3714 */
3715PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
3716 pjsua_call_id dest_call_id,
3717 unsigned options,
3718 const pjsua_msg_data *msg_data);
3719
3720/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003721 * Send DTMF digits to remote using RFC 2833 payload formats.
3722 *
3723 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003724 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003725 *
3726 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003727 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003728PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003729 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00003730
Benny Prijono26ff9062006-02-21 23:47:00 +00003731/**
Benny Prijonob0808372006-03-02 21:18:58 +00003732 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003733 *
3734 * @param call_id Call identification.
3735 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3736 * assumed.
3737 * @param content The message content.
3738 * @param msg_data Optional list of headers etc to be included in outgoing
3739 * request. The body descriptor in the msg_data is
3740 * ignored.
3741 * @param user_data Optional user data, which will be given back when
3742 * the IM callback is called.
3743 *
3744 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003745 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003746PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
3747 const pj_str_t *mime_type,
3748 const pj_str_t *content,
3749 const pjsua_msg_data *msg_data,
3750 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003751
3752
3753/**
3754 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003755 *
3756 * @param call_id Call identification.
3757 * @param is_typing Non-zero to indicate to remote that local person is
3758 * currently typing an IM.
3759 * @param msg_data Optional list of headers etc to be included in outgoing
3760 * request.
3761 *
3762 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003763 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003764PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
3765 pj_bool_t is_typing,
3766 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003767
3768/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00003769 * Send arbitrary request with the call. This is useful for example to send
3770 * INFO request. Note that application should not use this function to send
3771 * requests which would change the invite session's state, such as re-INVITE,
3772 * UPDATE, PRACK, and BYE.
3773 *
3774 * @param call_id Call identification.
3775 * @param method SIP method of the request.
3776 * @param msg_data Optional message body and/or list of headers to be
3777 * included in outgoing request.
3778 *
3779 * @return PJ_SUCCESS on success, or the appropriate error code.
3780 */
3781PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
3782 const pj_str_t *method,
3783 const pjsua_msg_data *msg_data);
3784
3785
3786/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003787 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
3788 * currently active calls.
Benny Prijono834aee32006-02-19 01:38:06 +00003789 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00003790PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00003791
3792
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003793/**
3794 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003795 *
3796 * @param call_id Call identification.
3797 * @param with_media Non-zero to include media information too.
3798 * @param buffer Buffer where the statistics are to be written to.
3799 * @param maxlen Maximum length of buffer.
3800 * @param indent Spaces for left indentation.
3801 *
3802 * @return PJ_SUCCESS on success.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003803 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003804PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
3805 pj_bool_t with_media,
3806 char *buffer,
3807 unsigned maxlen,
3808 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003809
Benny Prijono9fc735d2006-05-28 14:58:12 +00003810/**
Benny Prijono9f468d12011-07-07 07:46:33 +00003811 * Get the media stream index of the default video stream in the call.
3812 * Typically this will just retrieve the stream index of the first
3813 * activated video stream in the call.
3814 *
3815 * @param call_id Call identification.
3816 *
3817 * @return The media stream index or -1 if no video stream
3818 * is present in the call.
3819 */
3820PJ_DECL(int) pjsua_call_get_vid_stream_idx(pjsua_call_id call_id);
3821
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +00003822
Benny Prijono9f468d12011-07-07 07:46:33 +00003823/**
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +00003824 * Add, remove, modify, and/or manipulate video media stream for the
3825 * specified call. This may trigger a re-INVITE or UPDATE to be sent
3826 * for the call.
Benny Prijono9f468d12011-07-07 07:46:33 +00003827 *
3828 * @param call_id Call identification.
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +00003829 * @param op The video stream operation to be performed,
3830 * possible values are #pjsua_call_vid_strm_op.
Nanang Izzuddin98085612011-07-15 07:41:02 +00003831 * @param param The parameters for the video stream operation,
3832 * or NULL for the default parameter values
3833 * (see #pjsua_call_vid_strm_op_param).
Benny Prijono9f468d12011-07-07 07:46:33 +00003834 *
3835 * @return PJ_SUCCESS on success or the appropriate error.
3836 */
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +00003837PJ_DECL(pj_status_t) pjsua_call_set_vid_strm (
3838 pjsua_call_id call_id,
3839 pjsua_call_vid_strm_op op,
3840 const pjsua_call_vid_strm_op_param *param);
3841
Benny Prijono9f468d12011-07-07 07:46:33 +00003842
3843/**
3844 * Get media stream info for the specified media index.
3845 *
3846 * @param call_id The call identification.
3847 * @param med_idx Media stream index.
3848 * @param psi To be filled with the stream info.
3849 *
3850 * @return PJ_SUCCESS on success or the appropriate error.
3851 */
3852PJ_DECL(pj_status_t) pjsua_call_get_stream_info(pjsua_call_id call_id,
3853 unsigned med_idx,
3854 pjsua_stream_info *psi);
3855
3856/**
3857 * Get media stream statistic for the specified media index.
3858 *
3859 * @param call_id The call identification.
3860 * @param med_idx Media stream index.
3861 * @param psi To be filled with the stream statistic.
3862 *
3863 * @return PJ_SUCCESS on success or the appropriate error.
3864 */
3865PJ_DECL(pj_status_t) pjsua_call_get_stream_stat(pjsua_call_id call_id,
3866 unsigned med_idx,
3867 pjsua_stream_stat *stat);
3868
3869/**
3870 * Get media transport info for the specified media index.
3871 *
3872 * @param call_id The call identification.
3873 * @param med_idx Media stream index.
3874 * @param t To be filled with the transport info.
3875 *
3876 * @return PJ_SUCCESS on success or the appropriate error.
3877 */
3878PJ_DECL(pj_status_t) pjsua_call_get_transport_info(pjsua_call_id call_id,
3879 unsigned med_idx,
3880 pjmedia_transport_info *t);
3881
3882
3883
3884/**
Benny Prijono312aff92006-06-17 04:08:30 +00003885 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003886 */
Benny Prijono834aee32006-02-19 01:38:06 +00003887
3888
3889/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00003890 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00003891 */
3892
Benny Prijono312aff92006-06-17 04:08:30 +00003893
3894/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003895 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00003896 * @ingroup PJSUA_LIB
3897 * @brief Buddy management, buddy's presence, and instant messaging.
3898 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00003899 *
3900 * This section describes PJSUA-APIs related to buddies management,
3901 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00003902 */
3903
3904/**
3905 * Max buddies in buddy list.
3906 */
3907#ifndef PJSUA_MAX_BUDDIES
3908# define PJSUA_MAX_BUDDIES 256
3909#endif
3910
3911
3912/**
Benny Prijono6ab05322009-10-21 03:03:06 +00003913 * This specifies how long the library should wait before retrying failed
3914 * SUBSCRIBE request, and there is no rule to automatically resubscribe
3915 * (for example, no "retry-after" parameter in Subscription-State header).
3916 *
3917 * This also controls the duration before failed PUBLISH request will be
3918 * retried.
Benny Prijonoa17496a2007-10-31 10:20:31 +00003919 *
3920 * Default: 300 seconds
3921 */
3922#ifndef PJSUA_PRES_TIMER
3923# define PJSUA_PRES_TIMER 300
3924#endif
3925
3926
3927/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003928 * This structure describes buddy configuration when adding a buddy to
3929 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
3930 * the structure with #pjsua_buddy_config_default() to initialize this
3931 * structure with default configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00003932 */
3933typedef struct pjsua_buddy_config
3934{
3935 /**
3936 * Buddy URL or name address.
3937 */
3938 pj_str_t uri;
3939
3940 /**
3941 * Specify whether presence subscription should start immediately.
3942 */
3943 pj_bool_t subscribe;
3944
Benny Prijono705e7842008-07-21 18:12:51 +00003945 /**
3946 * Specify arbitrary application data to be associated with with
3947 * the buddy object.
3948 */
3949 void *user_data;
3950
Benny Prijono312aff92006-06-17 04:08:30 +00003951} pjsua_buddy_config;
3952
3953
3954/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003955 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003956 */
3957typedef enum pjsua_buddy_status
3958{
3959 /**
3960 * Online status is unknown (possibly because no presence subscription
3961 * has been established).
3962 */
3963 PJSUA_BUDDY_STATUS_UNKNOWN,
3964
3965 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003966 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003967 */
3968 PJSUA_BUDDY_STATUS_ONLINE,
3969
3970 /**
3971 * Buddy is offline.
3972 */
3973 PJSUA_BUDDY_STATUS_OFFLINE,
3974
3975} pjsua_buddy_status;
3976
3977
3978
3979/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003980 * This structure describes buddy info, which can be retrieved by calling
3981 * #pjsua_buddy_get_info().
Benny Prijono312aff92006-06-17 04:08:30 +00003982 */
3983typedef struct pjsua_buddy_info
3984{
3985 /**
3986 * The buddy ID.
3987 */
3988 pjsua_buddy_id id;
3989
3990 /**
3991 * The full URI of the buddy, as specified in the configuration.
3992 */
3993 pj_str_t uri;
3994
3995 /**
3996 * Buddy's Contact, only available when presence subscription has
3997 * been established to the buddy.
3998 */
3999 pj_str_t contact;
4000
4001 /**
4002 * Buddy's online status.
4003 */
4004 pjsua_buddy_status status;
4005
4006 /**
4007 * Text to describe buddy's online status.
4008 */
4009 pj_str_t status_text;
4010
4011 /**
4012 * Flag to indicate that we should monitor the presence information for
4013 * this buddy (normally yes, unless explicitly disabled).
4014 */
4015 pj_bool_t monitor_pres;
4016
4017 /**
Benny Prijono63fba012008-07-17 14:19:10 +00004018 * If \a monitor_pres is enabled, this specifies the last state of the
4019 * presence subscription. If presence subscription session is currently
4020 * active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence
4021 * subscription request has been rejected, the value will be
4022 * PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be
4023 * specified in \a sub_term_reason.
4024 */
4025 pjsip_evsub_state sub_state;
4026
4027 /**
Benny Prijonod06d8c52009-06-30 13:53:47 +00004028 * String representation of subscription state.
4029 */
4030 const char *sub_state_name;
4031
4032 /**
Benny Prijono73bb7232009-10-20 13:56:26 +00004033 * Specifies the last presence subscription termination code. This would
4034 * return the last status of the SUBSCRIBE request. If the subscription
4035 * is terminated with NOTIFY by the server, this value will be set to
4036 * 200, and subscription termination reason will be given in the
4037 * \a sub_term_reason field.
4038 */
4039 unsigned sub_term_code;
4040
4041 /**
4042 * Specifies the last presence subscription termination reason. If
Benny Prijono63fba012008-07-17 14:19:10 +00004043 * presence subscription is currently active, the value will be empty.
4044 */
4045 pj_str_t sub_term_reason;
4046
4047 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00004048 * Extended RPID information about the person.
4049 */
4050 pjrpid_element rpid;
4051
4052 /**
Benny Prijono28add7e2009-06-15 16:03:40 +00004053 * Extended presence info.
4054 */
4055 pjsip_pres_status pres_status;
4056
4057 /**
Benny Prijono312aff92006-06-17 04:08:30 +00004058 * Internal buffer.
4059 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00004060 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00004061
4062} pjsua_buddy_info;
4063
4064
Benny Prijono834aee32006-02-19 01:38:06 +00004065/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004066 * Set default values to the buddy config.
4067 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00004068PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00004069
4070
4071/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004072 * Get total number of buddies.
4073 *
4074 * @return Number of buddies.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004075 */
4076PJ_DECL(unsigned) pjsua_get_buddy_count(void);
4077
4078
4079/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004080 * Check if buddy ID is valid.
4081 *
4082 * @param buddy_id Buddy ID to check.
4083 *
4084 * @return Non-zero if buddy ID is valid.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004085 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004086PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
4087
4088
4089/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004090 * Enumerate all buddy IDs in the buddy list. Application then can use
4091 * #pjsua_buddy_get_info() to get the detail information for each buddy
4092 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004093 *
4094 * @param ids Array of ids to be initialized.
4095 * @param count On input, specifies max elements in the array.
4096 * On return, it contains actual number of elements
4097 * that have been initialized.
4098 *
4099 * @return PJ_SUCCESS on success, or the appropriate error code.
4100 */
4101PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
4102 unsigned *count);
4103
4104/**
Benny Prijono705e7842008-07-21 18:12:51 +00004105 * Find the buddy ID with the specified URI.
4106 *
4107 * @param uri The buddy URI.
4108 *
4109 * @return The buddy ID, or PJSUA_INVALID_ID if not found.
4110 */
4111PJ_DECL(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri);
4112
4113
4114/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004115 * Get detailed buddy info.
4116 *
4117 * @param buddy_id The buddy identification.
4118 * @param info Pointer to receive information about buddy.
4119 *
4120 * @return PJ_SUCCESS on success, or the appropriate error code.
4121 */
4122PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00004123 pjsua_buddy_info *info);
4124
4125/**
Benny Prijono705e7842008-07-21 18:12:51 +00004126 * Set the user data associated with the buddy object.
4127 *
4128 * @param buddy_id The buddy identification.
4129 * @param user_data Arbitrary application data to be associated with
4130 * the buddy object.
4131 *
4132 * @return PJ_SUCCESS on success, or the appropriate error code.
4133 */
4134PJ_DECL(pj_status_t) pjsua_buddy_set_user_data(pjsua_buddy_id buddy_id,
4135 void *user_data);
4136
4137
4138/**
4139 * Get the user data associated with the budy object.
4140 *
4141 * @param buddy_id The buddy identification.
4142 *
4143 * @return The application data.
4144 */
4145PJ_DECL(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id);
4146
4147
4148/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004149 * Add new buddy to the buddy list. If presence subscription is enabled
4150 * for this buddy, this function will also start the presence subscription
4151 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004152 *
Benny Prijonoa7b376b2008-01-25 16:06:33 +00004153 * @param buddy_cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004154 * @param p_buddy_id Pointer to receive buddy ID.
4155 *
4156 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004157 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004158PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004159 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004160
4161
4162/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004163 * Delete the specified buddy from the buddy list. Any presence subscription
4164 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004165 *
4166 * @param buddy_id Buddy identification.
4167 *
4168 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004169 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004170PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004171
4172
4173/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004174 * Enable/disable buddy's presence monitoring. Once buddy's presence is
4175 * subscribed, application will be informed about buddy's presence status
4176 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004177 *
4178 * @param buddy_id Buddy identification.
4179 * @param subscribe Specify non-zero to activate presence subscription to
4180 * the specified buddy.
4181 *
4182 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004183 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004184PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
4185 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004186
4187
4188/**
Benny Prijono10861432007-10-31 10:54:53 +00004189 * Update the presence information for the buddy. Although the library
4190 * periodically refreshes the presence subscription for all buddies, some
4191 * application may want to refresh the buddy's presence subscription
4192 * immediately, and in this case it can use this function to accomplish
4193 * this.
4194 *
4195 * Note that the buddy's presence subscription will only be initiated
4196 * if presence monitoring is enabled for the buddy. See
4197 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
4198 * for the buddy is already active, this function will not do anything.
4199 *
4200 * Once the presence subscription is activated successfully for the buddy,
4201 * application will be notified about the buddy's presence status in the
4202 * on_buddy_state() callback.
4203 *
4204 * @param buddy_id Buddy identification.
4205 *
4206 * @return PJ_SUCCESS on success, or the appropriate error code.
4207 */
4208PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
4209
4210
4211/**
Benny Prijono63fba012008-07-17 14:19:10 +00004212 * Send NOTIFY to inform account presence status or to terminate server
4213 * side presence subscription. If application wants to reject the incoming
4214 * request, it should set the \a state to PJSIP_EVSUB_STATE_TERMINATED.
4215 *
4216 * @param acc_id Account ID.
4217 * @param srv_pres Server presence subscription instance.
4218 * @param state New state to set.
4219 * @param state_str Optionally specify the state string name, if state
4220 * is not "active", "pending", or "terminated".
4221 * @param reason If the new state is PJSIP_EVSUB_STATE_TERMINATED,
4222 * optionally specify the termination reason.
4223 * @param with_body If the new state is PJSIP_EVSUB_STATE_TERMINATED,
4224 * this specifies whether the NOTIFY request should
4225 * contain message body containing account's presence
4226 * information.
4227 * @param msg_data Optional list of headers to be sent with the NOTIFY
4228 * request.
4229 *
4230 * @return PJ_SUCCESS on success.
4231 */
4232PJ_DECL(pj_status_t) pjsua_pres_notify(pjsua_acc_id acc_id,
4233 pjsua_srv_pres *srv_pres,
4234 pjsip_evsub_state state,
4235 const pj_str_t *state_str,
4236 const pj_str_t *reason,
4237 pj_bool_t with_body,
4238 const pjsua_msg_data *msg_data);
4239
4240/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004241 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004242 *
4243 * @param verbose Yes or no.
Benny Prijono834aee32006-02-19 01:38:06 +00004244 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004245PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00004246
4247
Benny Prijonob0808372006-03-02 21:18:58 +00004248/**
4249 * The MESSAGE method (defined in pjsua_im.c)
4250 */
4251extern const pjsip_method pjsip_message_method;
4252
4253
Benny Prijonob0808372006-03-02 21:18:58 +00004254
4255/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004256 * Send instant messaging outside dialog, using the specified account for
4257 * route set and authentication.
4258 *
4259 * @param acc_id Account ID to be used to send the request.
4260 * @param to Remote URI.
4261 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
4262 * assumed.
4263 * @param content The message content.
4264 * @param msg_data Optional list of headers etc to be included in outgoing
4265 * request. The body descriptor in the msg_data is
4266 * ignored.
4267 * @param user_data Optional user data, which will be given back when
4268 * the IM callback is called.
4269 *
4270 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00004271 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004272PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
4273 const pj_str_t *to,
4274 const pj_str_t *mime_type,
4275 const pj_str_t *content,
4276 const pjsua_msg_data *msg_data,
4277 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00004278
4279
4280/**
4281 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004282 *
4283 * @param acc_id Account ID to be used to send the request.
4284 * @param to Remote URI.
4285 * @param is_typing If non-zero, it tells remote person that local person
4286 * is currently composing an IM.
4287 * @param msg_data Optional list of headers etc to be added to outgoing
4288 * request.
4289 *
4290 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00004291 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004292PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
4293 const pj_str_t *to,
4294 pj_bool_t is_typing,
4295 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00004296
4297
Benny Prijonof3195072006-02-14 21:15:30 +00004298
Benny Prijono312aff92006-06-17 04:08:30 +00004299/**
4300 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00004301 */
4302
Benny Prijono312aff92006-06-17 04:08:30 +00004303
4304/*****************************************************************************
4305 * MEDIA API
4306 */
4307
4308
4309/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00004310 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00004311 * @ingroup PJSUA_LIB
4312 * @brief Media manipulation.
4313 * @{
4314 *
4315 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00004316 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
4317 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00004318 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00004319 * the interconnection between these terminations freely.
4320 *
4321 * The conference bridge provides powerful switching and mixing functionality
4322 * for application. With the conference bridge, each conference slot (e.g.
4323 * a call) can transmit to multiple destinations, and one destination can
4324 * receive from multiple sources. If more than one media terminations are
4325 * terminated in the same slot, the conference bridge will mix the signal
4326 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00004327 *
4328 * Application connects one media termination/slot to another by calling
4329 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00004330 * media flow from the source termination to the sink termination. To
4331 * establish bidirectional media flow, application wound need to make another
4332 * call to #pjsua_conf_connect(), this time inverting the source and
4333 * destination slots in the parameter.
4334 *
4335 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00004336 * the following steps:
4337 *
4338 \code
4339
4340 pj_status_t stream_to_call( pjsua_call_id call_id )
4341 {
4342 pjsua_player_id player_id;
4343
4344 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
4345 if (status != PJ_SUCCESS)
4346 return status;
4347
4348 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
4349 pjsua_call_get_conf_port() );
4350 }
4351 \endcode
4352 *
4353 *
4354 * Other features of PJSUA media:
4355 * - efficient N to M interconnections between media terminations.
4356 * - media termination can be connected to itself to create loopback
4357 * media.
4358 * - the media termination may have different clock rates, and resampling
4359 * will be done automatically by conference bridge.
4360 * - media terminations may also have different frame time; the
4361 * conference bridge will perform the necessary bufferring to adjust
4362 * the difference between terminations.
4363 * - interconnections are removed automatically when media termination
4364 * is removed from the bridge.
4365 * - sound device may be changed even when there are active media
4366 * interconnections.
4367 * - correctly report call's media quality (in #pjsua_call_dump()) from
4368 * RTCP packet exchange.
4369 */
4370
4371/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004372 * Max ports in the conference bridge. This setting is the default value
4373 * for pjsua_media_config.max_media_ports.
Benny Prijono312aff92006-06-17 04:08:30 +00004374 */
4375#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00004376# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00004377#endif
4378
Benny Prijonob5388cf2007-01-04 22:45:08 +00004379/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004380 * The default clock rate to be used by the conference bridge. This setting
4381 * is the default value for pjsua_media_config.clock_rate.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004382 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004383#ifndef PJSUA_DEFAULT_CLOCK_RATE
4384# define PJSUA_DEFAULT_CLOCK_RATE 16000
4385#endif
4386
Benny Prijonob5388cf2007-01-04 22:45:08 +00004387/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004388 * Default frame length in the conference bridge. This setting
4389 * is the default value for pjsua_media_config.audio_frame_ptime.
4390 */
4391#ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Nanang Izzuddinaf974842008-05-08 09:51:16 +00004392# define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
Benny Prijono37c710b2008-01-10 12:09:26 +00004393#endif
4394
4395
4396/**
4397 * Default codec quality settings. This setting is the default value
4398 * for pjsua_media_config.quality.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004399 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004400#ifndef PJSUA_DEFAULT_CODEC_QUALITY
Nanang Izzuddin9dbad152008-06-10 18:56:10 +00004401# define PJSUA_DEFAULT_CODEC_QUALITY 8
Benny Prijono12a669c2006-11-23 07:32:13 +00004402#endif
4403
Benny Prijonob5388cf2007-01-04 22:45:08 +00004404/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004405 * Default iLBC mode. This setting is the default value for
4406 * pjsua_media_config.ilbc_mode.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004407 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004408#ifndef PJSUA_DEFAULT_ILBC_MODE
Benny Prijono37c710b2008-01-10 12:09:26 +00004409# define PJSUA_DEFAULT_ILBC_MODE 30
Benny Prijono12a669c2006-11-23 07:32:13 +00004410#endif
4411
Benny Prijonob5388cf2007-01-04 22:45:08 +00004412/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004413 * The default echo canceller tail length. This setting
4414 * is the default value for pjsua_media_config.ec_tail_len.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004415 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004416#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijono427439c2007-10-21 09:41:24 +00004417# define PJSUA_DEFAULT_EC_TAIL_LEN 200
Benny Prijono12a669c2006-11-23 07:32:13 +00004418#endif
Benny Prijono312aff92006-06-17 04:08:30 +00004419
4420
4421/**
Benny Prijonocba59d92007-02-16 09:22:56 +00004422 * The maximum file player.
4423 */
4424#ifndef PJSUA_MAX_PLAYERS
4425# define PJSUA_MAX_PLAYERS 32
4426#endif
4427
4428
4429/**
4430 * The maximum file player.
4431 */
4432#ifndef PJSUA_MAX_RECORDERS
4433# define PJSUA_MAX_RECORDERS 32
4434#endif
4435
4436
4437/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004438 * This structure describes media configuration, which will be specified
4439 * when calling #pjsua_init(). Application MUST initialize this structure
4440 * by calling #pjsua_media_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00004441 */
4442struct pjsua_media_config
4443{
4444 /**
4445 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004446 * If value is zero, default clock rate will be used
4447 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00004448 */
4449 unsigned clock_rate;
4450
4451 /**
Benny Prijonof3758ee2008-02-26 15:32:16 +00004452 * Clock rate to be applied when opening the sound device.
4453 * If value is zero, conference bridge clock rate will be used.
4454 */
4455 unsigned snd_clock_rate;
4456
4457 /**
Benny Prijono7d60d052008-03-29 12:24:20 +00004458 * Channel count be applied when opening the sound device and
4459 * conference bridge.
4460 */
4461 unsigned channel_count;
4462
4463 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004464 * Specify audio frame ptime. The value here will affect the
4465 * samples per frame of both the sound device and the conference
4466 * bridge. Specifying lower ptime will normally reduce the
4467 * latency.
4468 *
Benny Prijono37c710b2008-01-10 12:09:26 +00004469 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004470 */
4471 unsigned audio_frame_ptime;
4472
4473 /**
Benny Prijono312aff92006-06-17 04:08:30 +00004474 * Specify maximum number of media ports to be created in the
4475 * conference bridge. Since all media terminate in the bridge
4476 * (calls, file player, file recorder, etc), the value must be
4477 * large enough to support all of them. However, the larger
4478 * the value, the more computations are performed.
Benny Prijono37c710b2008-01-10 12:09:26 +00004479 *
4480 * Default value: PJSUA_MAX_CONF_PORTS
Benny Prijono312aff92006-06-17 04:08:30 +00004481 */
4482 unsigned max_media_ports;
4483
4484 /**
4485 * Specify whether the media manager should manage its own
4486 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
4487 * and at least one worker thread will be created too. If no,
4488 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
4489 * and no worker thread is needed.
4490 *
4491 * Normally application would say yes here, unless it wants to
4492 * run everything from a single thread.
4493 */
4494 pj_bool_t has_ioqueue;
4495
4496 /**
4497 * Specify the number of worker threads to handle incoming RTP
4498 * packets. A value of one is recommended for most applications.
4499 */
4500 unsigned thread_cnt;
4501
Benny Prijono0498d902006-06-19 14:49:14 +00004502 /**
4503 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00004504 * 5-10: resampling use large filter,
4505 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00004506 * 1-2: resampling use linear.
4507 * The media quality also sets speex codec quality/complexity to the
4508 * number.
4509 *
Benny Prijono70972992006-08-05 11:13:58 +00004510 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00004511 */
4512 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00004513
4514 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004515 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00004516 *
4517 * Default: 0 (codec specific)
4518 */
4519 unsigned ptime;
4520
4521 /**
4522 * Disable VAD?
4523 *
4524 * Default: 0 (no (meaning VAD is enabled))
4525 */
4526 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00004527
4528 /**
4529 * iLBC mode (20 or 30).
4530 *
Benny Prijono37c710b2008-01-10 12:09:26 +00004531 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00004532 */
4533 unsigned ilbc_mode;
4534
4535 /**
4536 * Percentage of RTP packet to drop in TX direction
4537 * (to simulate packet lost).
4538 *
4539 * Default: 0
4540 */
4541 unsigned tx_drop_pct;
4542
4543 /**
4544 * Percentage of RTP packet to drop in RX direction
4545 * (to simulate packet lost).
4546 *
4547 * Default: 0
4548 */
4549 unsigned rx_drop_pct;
4550
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004551 /**
Benny Prijono5da50432006-08-07 10:24:52 +00004552 * Echo canceller options (see #pjmedia_echo_create())
4553 *
4554 * Default: 0.
4555 */
4556 unsigned ec_options;
4557
4558 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004559 * Echo canceller tail length, in miliseconds.
4560 *
Benny Prijono669643c2006-09-20 20:02:18 +00004561 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004562 */
4563 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004564
Benny Prijono10454dc2009-02-21 14:21:59 +00004565 /**
4566 * Audio capture buffer length, in milliseconds.
4567 *
4568 * Default: PJMEDIA_SND_DEFAULT_REC_LATENCY
4569 */
4570 unsigned snd_rec_latency;
4571
4572 /**
4573 * Audio playback buffer length, in milliseconds.
4574 *
4575 * Default: PJMEDIA_SND_DEFAULT_PLAY_LATENCY
4576 */
4577 unsigned snd_play_latency;
4578
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004579 /**
4580 * Jitter buffer initial prefetch delay in msec. The value must be
4581 * between jb_min_pre and jb_max_pre below.
4582 *
4583 * Default: -1 (to use default stream settings, currently 150 msec)
4584 */
4585 int jb_init;
4586
4587 /**
4588 * Jitter buffer minimum prefetch delay in msec.
4589 *
4590 * Default: -1 (to use default stream settings, currently 60 msec)
4591 */
4592 int jb_min_pre;
4593
4594 /**
4595 * Jitter buffer maximum prefetch delay in msec.
4596 *
4597 * Default: -1 (to use default stream settings, currently 240 msec)
4598 */
4599 int jb_max_pre;
4600
4601 /**
4602 * Set maximum delay that can be accomodated by the jitter buffer msec.
4603 *
4604 * Default: -1 (to use default stream settings, currently 360 msec)
4605 */
4606 int jb_max;
4607
Benny Prijonoc97608e2007-03-23 16:34:20 +00004608 /**
4609 * Enable ICE
4610 */
4611 pj_bool_t enable_ice;
4612
4613 /**
Benny Prijono329d6382009-05-29 13:04:03 +00004614 * Set the maximum number of host candidates.
4615 *
4616 * Default: -1 (maximum not set)
Benny Prijonoc97608e2007-03-23 16:34:20 +00004617 */
Benny Prijono329d6382009-05-29 13:04:03 +00004618 int ice_max_host_cands;
4619
4620 /**
4621 * ICE session options.
4622 */
4623 pj_ice_sess_options ice_opt;
Benny Prijonof76e1392008-06-06 14:51:48 +00004624
4625 /**
Benny Prijono551af422008-08-07 09:55:52 +00004626 * Disable RTCP component.
4627 *
4628 * Default: no
4629 */
4630 pj_bool_t ice_no_rtcp;
4631
4632 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00004633 * Enable TURN relay candidate in ICE.
4634 */
4635 pj_bool_t enable_turn;
4636
4637 /**
4638 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
4639 * "HOST:PORT" format.
4640 */
4641 pj_str_t turn_server;
4642
4643 /**
4644 * Specify the connection type to be used to the TURN server. Valid
4645 * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP.
4646 *
4647 * Default: PJ_TURN_TP_UDP
4648 */
4649 pj_turn_tp_type turn_conn_type;
4650
4651 /**
4652 * Specify the credential to authenticate with the TURN server.
4653 */
4654 pj_stun_auth_cred turn_auth_cred;
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004655
4656 /**
4657 * Specify idle time of sound device before it is automatically closed,
Benny Prijonof798e502009-03-09 13:08:16 +00004658 * in seconds. Use value -1 to disable the auto-close feature of sound
4659 * device
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004660 *
Benny Prijonof798e502009-03-09 13:08:16 +00004661 * Default : 1
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004662 */
4663 int snd_auto_close_time;
Benny Prijono312aff92006-06-17 04:08:30 +00004664};
4665
4666
4667/**
4668 * Use this function to initialize media config.
4669 *
4670 * @param cfg The media config to be initialized.
4671 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00004672PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00004673
4674
4675/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004676 * This structure describes codec information, which can be retrieved by
4677 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00004678 */
4679typedef struct pjsua_codec_info
4680{
4681 /**
4682 * Codec unique identification.
4683 */
4684 pj_str_t codec_id;
4685
4686 /**
4687 * Codec priority (integer 0-255).
4688 */
4689 pj_uint8_t priority;
4690
4691 /**
Nanang Izzuddin56b2ce42011-04-06 13:55:01 +00004692 * Codec description.
4693 */
4694 pj_str_t desc;
4695
4696 /**
Benny Prijono312aff92006-06-17 04:08:30 +00004697 * Internal buffer.
4698 */
Nanang Izzuddin56b2ce42011-04-06 13:55:01 +00004699 char buf_[64];
Benny Prijono312aff92006-06-17 04:08:30 +00004700
4701} pjsua_codec_info;
4702
4703
4704/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004705 * This structure descibes information about a particular media port that
4706 * has been registered into the conference bridge. Application can query
4707 * this info by calling #pjsua_conf_get_port_info().
Benny Prijono312aff92006-06-17 04:08:30 +00004708 */
4709typedef struct pjsua_conf_port_info
4710{
4711 /** Conference port number. */
4712 pjsua_conf_port_id slot_id;
4713
4714 /** Port name. */
4715 pj_str_t name;
4716
4717 /** Clock rate. */
4718 unsigned clock_rate;
4719
4720 /** Number of channels. */
4721 unsigned channel_count;
4722
4723 /** Samples per frame */
4724 unsigned samples_per_frame;
4725
4726 /** Bits per sample */
4727 unsigned bits_per_sample;
4728
4729 /** Number of listeners in the array. */
4730 unsigned listener_cnt;
4731
4732 /** Array of listeners (in other words, ports where this port is
4733 * transmitting to.
4734 */
4735 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
4736
4737} pjsua_conf_port_info;
4738
4739
4740/**
4741 * This structure holds information about custom media transport to
4742 * be registered to pjsua.
4743 */
4744typedef struct pjsua_media_transport
4745{
4746 /**
4747 * Media socket information containing the address information
4748 * of the RTP and RTCP socket.
4749 */
4750 pjmedia_sock_info skinfo;
4751
4752 /**
4753 * The media transport instance.
4754 */
4755 pjmedia_transport *transport;
4756
4757} pjsua_media_transport;
4758
4759
Benny Prijono9fc735d2006-05-28 14:58:12 +00004760/**
4761 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004762 *
4763 * @return Maximum number of ports in the conference bridge.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004764 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004765PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004766
4767
4768/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004769 * Get current number of active ports in the bridge.
4770 *
4771 * @return The number.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004772 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004773PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
4774
4775
4776/**
4777 * Enumerate all conference ports.
4778 *
4779 * @param id Array of conference port ID to be initialized.
4780 * @param count On input, specifies max elements in the array.
4781 * On return, it contains actual number of elements
4782 * that have been initialized.
4783 *
4784 * @return PJ_SUCCESS on success, or the appropriate error code.
4785 */
4786PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
4787 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004788
4789
4790/**
4791 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004792 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004793 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004794 * @param info Pointer to store the port info.
4795 *
4796 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004797 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004798PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00004799 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004800
4801
4802/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00004803 * Add arbitrary media port to PJSUA's conference bridge. Application
4804 * can use this function to add the media port that it creates. For
4805 * media ports that are created by PJSUA-LIB (such as calls, file player,
4806 * or file recorder), PJSUA-LIB will automatically add the port to
4807 * the bridge.
4808 *
4809 * @param pool Pool to use.
4810 * @param port Media port to be added to the bridge.
4811 * @param p_id Optional pointer to receive the conference
4812 * slot id.
4813 *
4814 * @return PJ_SUCCESS on success, or the appropriate error code.
4815 */
4816PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
4817 pjmedia_port *port,
4818 pjsua_conf_port_id *p_id);
4819
4820
4821/**
4822 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00004823 * call this function if it registered the port manually with previous call
4824 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00004825 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004826 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00004827 *
4828 * @return PJ_SUCCESS on success, or the appropriate error code.
4829 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004830PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00004831
4832
4833/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004834 * Establish unidirectional media flow from souce to sink. One source
4835 * may transmit to multiple destinations/sink. And if multiple
4836 * sources are transmitting to the same sink, the media will be mixed
4837 * together. Source and sink may refer to the same ID, effectively
4838 * looping the media.
4839 *
4840 * If bidirectional media flow is desired, application needs to call
4841 * this function twice, with the second one having the arguments
4842 * reversed.
4843 *
4844 * @param source Port ID of the source media/transmitter.
4845 * @param sink Port ID of the destination media/received.
4846 *
4847 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004848 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004849PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
4850 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004851
4852
4853/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004854 * Disconnect media flow from the source to destination port.
4855 *
4856 * @param source Port ID of the source media/transmitter.
4857 * @param sink Port ID of the destination media/received.
4858 *
4859 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004860 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004861PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
4862 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004863
4864
Benny Prijono6dd967c2006-12-26 02:27:14 +00004865/**
4866 * Adjust the signal level to be transmitted from the bridge to the
4867 * specified port by making it louder or quieter.
4868 *
4869 * @param slot The conference bridge slot number.
4870 * @param level Signal level adjustment. Value 1.0 means no level
4871 * adjustment, while value 0 means to mute the port.
4872 *
4873 * @return PJ_SUCCESS on success, or the appropriate error code.
4874 */
4875PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
4876 float level);
4877
4878/**
4879 * Adjust the signal level to be received from the specified port (to
4880 * the bridge) by making it louder or quieter.
4881 *
4882 * @param slot The conference bridge slot number.
4883 * @param level Signal level adjustment. Value 1.0 means no level
4884 * adjustment, while value 0 means to mute the port.
4885 *
4886 * @return PJ_SUCCESS on success, or the appropriate error code.
4887 */
4888PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
4889 float level);
4890
4891/**
4892 * Get last signal level transmitted to or received from the specified port.
4893 * The signal level is an integer value in zero to 255, with zero indicates
4894 * no signal, and 255 indicates the loudest signal level.
4895 *
4896 * @param slot The conference bridge slot number.
4897 * @param tx_level Optional argument to receive the level of signal
4898 * transmitted to the specified port (i.e. the direction
4899 * is from the bridge to the port).
4900 * @param rx_level Optional argument to receive the level of signal
4901 * received from the port (i.e. the direction is from the
4902 * port to the bridge).
4903 *
4904 * @return PJ_SUCCESS on success.
4905 */
4906PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
4907 unsigned *tx_level,
4908 unsigned *rx_level);
4909
Benny Prijono6dd967c2006-12-26 02:27:14 +00004910
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004911/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00004912 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004913 */
4914
Benny Prijono9fc735d2006-05-28 14:58:12 +00004915/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004916 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004917 * the conference bridge.
4918 *
4919 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00004920 * WAV files are supported, and the WAV file MUST be
4921 * formatted as 16bit PCM mono/single channel (any
4922 * clock rate is supported).
Benny Prijono58add7c2008-01-18 13:24:07 +00004923 * @param options Optional option flag. Application may specify
4924 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004925 * @param p_id Pointer to receive player ID.
4926 *
4927 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004928 */
4929PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004930 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004931 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004932
4933
4934/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004935 * Create a file playlist media port, and automatically add the port
4936 * to the conference bridge.
4937 *
4938 * @param file_names Array of file names to be added to the play list.
4939 * Note that the files must have the same clock rate,
4940 * number of channels, and number of bits per sample.
4941 * @param file_count Number of files in the array.
4942 * @param label Optional label to be set for the media port.
4943 * @param options Optional option flag. Application may specify
4944 * PJMEDIA_FILE_NO_LOOP to prevent looping.
4945 * @param p_id Optional pointer to receive player ID.
4946 *
4947 * @return PJ_SUCCESS on success, or the appropriate error code.
4948 */
4949PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
4950 unsigned file_count,
4951 const pj_str_t *label,
4952 unsigned options,
4953 pjsua_player_id *p_id);
4954
4955/**
4956 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004957 *
4958 * @param id The file player ID.
4959 *
4960 * @return Conference port ID associated with this player.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004961 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004962PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004963
4964
4965/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004966 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00004967 *
4968 * @param id The player ID.
4969 * @param p_port The media port associated with the player.
4970 *
4971 * @return PJ_SUCCESS on success.
4972 */
Benny Prijono58add7c2008-01-18 13:24:07 +00004973PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
Benny Prijono469b1522006-12-26 03:05:17 +00004974 pjmedia_port **p_port);
4975
4976/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004977 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004978 *
4979 * @param id The file player ID.
4980 * @param samples The playback position, in samples. Application can
4981 * specify zero to re-start the playback.
4982 *
4983 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004984 */
4985PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
4986 pj_uint32_t samples);
4987
4988
4989/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004990 * Close the file of playlist, remove the player from the bridge, and free
4991 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004992 *
4993 * @param id The file player ID.
4994 *
4995 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004996 */
4997PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
4998
4999
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005000/*****************************************************************************
5001 * File recorder.
5002 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00005003
5004/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005005 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00005006 * the conference bridge. The recorder currently supports recording WAV file.
5007 * The type of the recorder to use is determined by the extension of the file
5008 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005009 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00005010 * @param filename Output file name. The function will determine the
5011 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00005012 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00005013 * @param enc_type Optionally specify the type of encoder to be used to
5014 * compress the media, if the file can support different
5015 * encodings. This value must be zero for now.
5016 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00005017 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00005018 * For .WAV recorder, this value must be NULL.
5019 * @param max_size Maximum file size. Specify zero or -1 to remove size
5020 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005021 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005022 * @param p_id Pointer to receive the recorder instance.
5023 *
5024 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00005025 */
5026PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00005027 unsigned enc_type,
5028 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005029 pj_ssize_t max_size,
5030 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005031 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00005032
5033
5034/**
5035 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005036 *
5037 * @param id The recorder ID.
5038 *
5039 * @return Conference port ID associated with this recorder.
Benny Prijono9fc735d2006-05-28 14:58:12 +00005040 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00005041PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00005042
5043
5044/**
Benny Prijono469b1522006-12-26 03:05:17 +00005045 * Get the media port for the recorder.
5046 *
5047 * @param id The recorder ID.
5048 * @param p_port The media port associated with the recorder.
5049 *
5050 * @return PJ_SUCCESS on success.
5051 */
5052PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
5053 pjmedia_port **p_port);
5054
5055
5056/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005057 * Destroy recorder (this will complete recording).
5058 *
5059 * @param id The recorder ID.
5060 *
5061 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00005062 */
5063PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
5064
5065
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005066/*****************************************************************************
5067 * Sound devices.
5068 */
5069
Benny Prijono9fc735d2006-05-28 14:58:12 +00005070/**
Benny Prijonof798e502009-03-09 13:08:16 +00005071 * Enum all audio devices installed in the system.
5072 *
5073 * @param info Array of info to be initialized.
5074 * @param count On input, specifies max elements in the array.
5075 * On return, it contains actual number of elements
5076 * that have been initialized.
5077 *
5078 * @return PJ_SUCCESS on success, or the appropriate error code.
5079 */
5080PJ_DECL(pj_status_t) pjsua_enum_aud_devs(pjmedia_aud_dev_info info[],
5081 unsigned *count);
5082
5083/**
5084 * Enum all sound devices installed in the system (old API).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005085 *
5086 * @param info Array of info to be initialized.
5087 * @param count On input, specifies max elements in the array.
5088 * On return, it contains actual number of elements
5089 * that have been initialized.
5090 *
5091 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00005092 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005093PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
5094 unsigned *count);
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00005095
5096/**
5097 * Get currently active sound devices. If sound devices has not been created
5098 * (for example when pjsua_start() is not called), it is possible that
5099 * the function returns PJ_SUCCESS with -1 as device IDs.
5100 *
5101 * @param capture_dev On return it will be filled with device ID of the
5102 * capture device.
5103 * @param playback_dev On return it will be filled with device ID of the
5104 * device ID of the playback device.
5105 *
5106 * @return PJ_SUCCESS on success, or the appropriate error code.
5107 */
5108PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
5109 int *playback_dev);
5110
5111
Benny Prijono9fc735d2006-05-28 14:58:12 +00005112/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005113 * Select or change sound device. Application may call this function at
5114 * any time to replace current sound device.
5115 *
5116 * @param capture_dev Device ID of the capture device.
5117 * @param playback_dev Device ID of the playback device.
5118 *
5119 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00005120 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005121PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
5122 int playback_dev);
5123
5124
5125/**
5126 * Set pjsua to use null sound device. The null sound device only provides
5127 * the timing needed by the conference bridge, and will not interract with
5128 * any hardware.
5129 *
5130 * @return PJ_SUCCESS on success, or the appropriate error code.
5131 */
5132PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
5133
5134
Benny Prijonoe909eac2006-07-27 22:04:56 +00005135/**
5136 * Disconnect the main conference bridge from any sound devices, and let
5137 * application connect the bridge to it's own sound device/master port.
5138 *
5139 * @return The port interface of the conference bridge,
5140 * so that application can connect this to it's own
5141 * sound device or master port.
5142 */
5143PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
5144
5145
Benny Prijonof20687a2006-08-04 18:27:19 +00005146/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00005147 * Change the echo cancellation settings.
Benny Prijonof798e502009-03-09 13:08:16 +00005148 *
5149 * The behavior of this function depends on whether the sound device is
5150 * currently active, and if it is, whether device or software AEC is
5151 * being used.
Benny Prijono10454dc2009-02-21 14:21:59 +00005152 *
5153 * If the sound device is currently active, and if the device supports AEC,
5154 * this function will forward the change request to the device and it will
5155 * be up to the device on whether support the request. If software AEC is
5156 * being used (the software EC will be used if the device does not support
5157 * AEC), this function will change the software EC settings. In all cases,
5158 * the setting will be saved for future opening of the sound device.
5159 *
5160 * If the sound device is not currently active, this will only change the
5161 * default AEC settings and the setting will be applied next time the
5162 * sound device is opened.
Benny Prijonof20687a2006-08-04 18:27:19 +00005163 *
5164 * @param tail_ms The tail length, in miliseconds. Set to zero to
5165 * disable AEC.
Benny Prijonoa7b376b2008-01-25 16:06:33 +00005166 * @param options Options to be passed to pjmedia_echo_create().
Benny Prijono5da50432006-08-07 10:24:52 +00005167 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00005168 *
5169 * @return PJ_SUCCESS on success.
5170 */
Benny Prijono5da50432006-08-07 10:24:52 +00005171PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00005172
5173
5174/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00005175 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00005176 *
5177 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
5178 * If AEC is disabled, the value will be zero.
5179 *
5180 * @return PJ_SUCCESS on success.
5181 */
Benny Prijono22dfe592006-08-06 12:07:13 +00005182PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00005183
5184
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00005185/**
Benny Prijonof798e502009-03-09 13:08:16 +00005186 * Check whether the sound device is currently active. The sound device
5187 * may be inactive if the application has set the auto close feature to
5188 * non-zero (the snd_auto_close_time setting in #pjsua_media_config), or
5189 * if null sound device or no sound device has been configured via the
5190 * #pjsua_set_no_snd_dev() function.
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00005191 */
Benny Prijonof798e502009-03-09 13:08:16 +00005192PJ_DECL(pj_bool_t) pjsua_snd_is_active(void);
5193
5194
5195/**
5196 * Configure sound device setting to the sound device being used. If sound
5197 * device is currently active, the function will forward the setting to the
5198 * sound device instance to be applied immediately, if it supports it.
5199 *
5200 * The setting will be saved for future opening of the sound device, if the
5201 * "keep" argument is set to non-zero. If the sound device is currently
5202 * inactive, and the "keep" argument is false, this function will return
5203 * error.
5204 *
5205 * Note that in case the setting is kept for future use, it will be applied
5206 * to any devices, even when application has changed the sound device to be
5207 * used.
5208 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00005209 * Note also that the echo cancellation setting should be set with
5210 * #pjsua_set_ec() API instead.
5211 *
Benny Prijonof798e502009-03-09 13:08:16 +00005212 * See also #pjmedia_aud_stream_set_cap() for more information about setting
5213 * an audio device capability.
5214 *
5215 * @param cap The sound device setting to change.
5216 * @param pval Pointer to value. Please see #pjmedia_aud_dev_cap
5217 * documentation about the type of value to be
5218 * supplied for each setting.
5219 * @param keep Specify whether the setting is to be kept for future
5220 * use.
5221 *
5222 * @return PJ_SUCCESS on success or the appropriate error code.
5223 */
5224PJ_DECL(pj_status_t) pjsua_snd_set_setting(pjmedia_aud_dev_cap cap,
5225 const void *pval,
5226 pj_bool_t keep);
5227
5228/**
5229 * Retrieve a sound device setting. If sound device is currently active,
5230 * the function will forward the request to the sound device. If sound device
5231 * is currently inactive, and if application had previously set the setting
5232 * and mark the setting as kept, then that setting will be returned.
5233 * Otherwise, this function will return error.
5234 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00005235 * Note that echo cancellation settings should be retrieved with
5236 * #pjsua_get_ec_tail() API instead.
5237 *
Benny Prijonof798e502009-03-09 13:08:16 +00005238 * @param cap The sound device setting to retrieve.
5239 * @param pval Pointer to receive the value.
5240 * Please see #pjmedia_aud_dev_cap documentation about
5241 * the type of value to be supplied for each setting.
5242 *
5243 * @return PJ_SUCCESS on success or the appropriate error code.
5244 */
5245PJ_DECL(pj_status_t) pjsua_snd_get_setting(pjmedia_aud_dev_cap cap,
5246 void *pval);
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00005247
5248
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005249/*****************************************************************************
5250 * Codecs.
5251 */
5252
5253/**
5254 * Enum all supported codecs in the system.
5255 *
5256 * @param id Array of ID to be initialized.
5257 * @param count On input, specifies max elements in the array.
5258 * On return, it contains actual number of elements
5259 * that have been initialized.
5260 *
5261 * @return PJ_SUCCESS on success, or the appropriate error code.
5262 */
5263PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
5264 unsigned *count );
5265
5266
5267/**
5268 * Change codec priority.
5269 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00005270 * @param codec_id Codec ID, which is a string that uniquely identify
5271 * the codec (such as "speex/8000"). Please see pjsua
5272 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005273 * @param priority Codec priority, 0-255, where zero means to disable
5274 * the codec.
5275 *
5276 * @return PJ_SUCCESS on success, or the appropriate error code.
5277 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00005278PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005279 pj_uint8_t priority );
5280
5281
5282/**
5283 * Get codec parameters.
5284 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00005285 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005286 * @param param Structure to receive codec parameters.
5287 *
5288 * @return PJ_SUCCESS on success, or the appropriate error code.
5289 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00005290PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005291 pjmedia_codec_param *param );
5292
5293
5294/**
5295 * Set codec parameters.
5296 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00005297 * @param codec_id Codec ID.
Nanang Izzuddin06839e72010-01-27 11:48:31 +00005298 * @param param Codec parameter to set. Set to NULL to reset
5299 * codec parameter to library default settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005300 *
5301 * @return PJ_SUCCESS on success, or the appropriate error code.
5302 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00005303PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005304 const pjmedia_codec_param *param);
5305
5306
Benny Prijono9f468d12011-07-07 07:46:33 +00005307#if DISABLED_FOR_TICKET_1185
Benny Prijono312aff92006-06-17 04:08:30 +00005308/**
5309 * Create UDP media transports for all the calls. This function creates
5310 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00005311 *
Benny Prijono312aff92006-06-17 04:08:30 +00005312 * @param cfg Media transport configuration. The "port" field in the
5313 * configuration is used as the start port to bind the
5314 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005315 *
5316 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonof3195072006-02-14 21:15:30 +00005317 */
Benny Prijono9f468d12011-07-07 07:46:33 +00005318PJ_DECL(pj_status_t)
Benny Prijono312aff92006-06-17 04:08:30 +00005319pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00005320
Benny Prijonodc39fe82006-05-26 12:17:46 +00005321
5322/**
Benny Prijono312aff92006-06-17 04:08:30 +00005323 * Register custom media transports to be used by calls. There must
5324 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005325 *
Benny Prijono312aff92006-06-17 04:08:30 +00005326 * @param tp The media transport array.
5327 * @param count Number of elements in the array. This number MUST
5328 * match the number of maximum calls configured when
5329 * pjsua is created.
5330 * @param auto_delete Flag to indicate whether the transports should be
5331 * destroyed when pjsua is shutdown.
5332 *
5333 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00005334 */
Benny Prijono9f468d12011-07-07 07:46:33 +00005335PJ_DECL(pj_status_t)
Benny Prijono312aff92006-06-17 04:08:30 +00005336pjsua_media_transports_attach( pjsua_media_transport tp[],
5337 unsigned count,
5338 pj_bool_t auto_delete);
Benny Prijono9f468d12011-07-07 07:46:33 +00005339#endif
Benny Prijonodc39fe82006-05-26 12:17:46 +00005340
5341
Benny Prijono9f468d12011-07-07 07:46:33 +00005342/* end of MEDIA API */
Benny Prijono312aff92006-06-17 04:08:30 +00005343/**
5344 * @}
5345 */
5346
Benny Prijonof3195072006-02-14 21:15:30 +00005347
Nanang Izzuddin50fae732011-03-22 09:49:23 +00005348/*****************************************************************************
Benny Prijono9f468d12011-07-07 07:46:33 +00005349 * VIDEO API
5350 */
5351
5352
5353/**
5354 * @defgroup PJSUA_LIB_VIDEO PJSUA-API Video
5355 * @ingroup PJSUA_LIB
5356 * @brief Video support
5357 * @{
5358 */
5359
5360/*
5361 * Video devices API
5362 */
5363
5364/**
5365 * Get the number of video devices installed in the system.
5366 *
5367 * @return The number of devices.
5368 */
5369PJ_DECL(unsigned) pjsua_vid_dev_count(void);
5370
5371/**
5372 * Retrieve the video device info for the specified device index.
5373 *
5374 * @param id The device index.
5375 * @param vdi Device info to be initialized.
5376 *
5377 * @return PJ_SUCCESS on success, or the appropriate error code.
5378 */
5379PJ_DECL(pj_status_t) pjsua_vid_dev_get_info(pjmedia_vid_dev_index id,
5380 pjmedia_vid_dev_info *vdi);
5381
5382/**
5383 * Enum all video devices installed in the system.
5384 *
5385 * @param info Array of info to be initialized.
5386 * @param count On input, specifies max elements in the array.
5387 * On return, it contains actual number of elements
5388 * that have been initialized.
5389 *
5390 * @return PJ_SUCCESS on success, or the appropriate error code.
5391 */
5392PJ_DECL(pj_status_t) pjsua_vid_enum_devs(pjmedia_vid_dev_info info[],
5393 unsigned *count);
5394
5395
5396/*
5397 * Video preview API
5398 */
5399
5400/**
5401 * Parameters for starting video preview with pjsua_vid_preview_start().
5402 * Application should initialize this structure with
5403 * pjsua_vid_preview_param_default().
5404 */
5405typedef struct pjsua_vid_preview_param
5406{
5407 /**
5408 * Device ID for the video renderer to be used for rendering the
5409 * capture stream for preview.
5410 */
5411 pjmedia_vid_dev_index rend_id;
5412} pjsua_vid_preview_param;
5413
5414
5415/**
5416 * Start video preview window for the specified capture device.
5417 *
5418 * @param id The capture device ID where its preview will be
5419 * started.
5420 * @param prm Optional video preview parameters. Specify NULL
5421 * to use default values.
5422 *
5423 * @return PJ_SUCCESS on success, or the appropriate error code.
5424 */
5425PJ_DECL(pj_status_t) pjsua_vid_preview_start(pjmedia_vid_dev_index id,
5426 pjsua_vid_preview_param *prm);
5427
5428/**
5429 * Get the preview window handle associated with the capture device, if any.
5430 *
5431 * @param id The capture device ID.
5432 *
5433 * @return The window ID of the preview window for the
5434 * specified capture device ID, or NULL if preview
5435 * does not exist.
5436 */
5437PJ_DECL(pjsua_vid_win_id) pjsua_vid_preview_get_win(pjmedia_vid_dev_index id);
5438
5439/**
5440 * Stop video preview.
5441 *
5442 * @param id The capture device ID.
5443 *
5444 * @return PJ_SUCCESS on success, or the appropriate error code.
5445 */
5446PJ_DECL(pj_status_t) pjsua_vid_preview_stop(pjmedia_vid_dev_index id);
5447
5448
5449/*
5450 * Video window manipulation API.
5451 */
5452
5453/**
5454 * This structure describes video window info.
5455 */
5456typedef struct pjsua_vid_win_info
5457{
5458 /**
Nanang Izzuddindb9b0022011-07-26 08:17:25 +00005459 * Renderer device ID.
5460 */
5461 pjmedia_vid_dev_index rdr_dev;
5462
5463 /**
Nanang Izzuddin6e2fcc32011-07-22 04:49:36 +00005464 * Native window handle.
5465 */
5466 pjmedia_vid_dev_hwnd hwnd;
5467
5468 /**
Benny Prijono9f468d12011-07-07 07:46:33 +00005469 * Window show status. The window is hidden if false.
5470 */
5471 pj_bool_t show;
5472
5473 /**
5474 * Window position.
5475 */
5476 pjmedia_coord pos;
5477
5478 /**
5479 * Window size.
5480 */
5481 pjmedia_rect_size size;
5482
5483} pjsua_vid_win_info;
5484
5485
5486/**
Nanang Izzuddinf3638022011-07-14 03:47:04 +00005487 * Enumerates all video windows.
5488 *
5489 * @param id Array of window ID to be initialized.
5490 * @param count On input, specifies max elements in the array.
5491 * On return, it contains actual number of elements
5492 * that have been initialized.
5493 *
5494 * @return PJ_SUCCESS on success, or the appropriate error code.
5495 */
5496PJ_DECL(pj_status_t) pjsua_vid_enum_wins(pjsua_vid_win_id wids[],
5497 unsigned *count);
5498
5499
5500/**
Benny Prijono9f468d12011-07-07 07:46:33 +00005501 * Get window info.
5502 *
5503 * @param wid The video window ID.
5504 * @param wi The video window info to be initialized.
5505 *
5506 * @return PJ_SUCCESS on success, or the appropriate error code.
5507 */
5508PJ_DECL(pj_status_t) pjsua_vid_win_get_info(pjsua_vid_win_id wid,
5509 pjsua_vid_win_info *wi);
5510
5511/**
5512 * Show or hide window.
5513 *
5514 * @param wid The video window ID.
5515 * @param show Set to PJ_TRUE to show the window, PJ_FALSE to
5516 * hide the window.
5517 *
5518 * @return PJ_SUCCESS on success, or the appropriate error code.
5519 */
5520PJ_DECL(pj_status_t) pjsua_vid_win_set_show(pjsua_vid_win_id wid,
5521 pj_bool_t show);
5522
5523/**
5524 * Set video window position.
5525 *
5526 * @param wid The video window ID.
5527 * @param pos The window position.
5528 *
5529 * @return PJ_SUCCESS on success, or the appropriate error code.
5530 */
5531PJ_DECL(pj_status_t) pjsua_vid_win_set_pos(pjsua_vid_win_id wid,
5532 const pjmedia_coord *pos);
5533
5534/**
5535 * Resize window.
5536 *
5537 * @param wid The video window ID.
5538 * @param size The new window size.
5539 *
5540 * @return PJ_SUCCESS on success, or the appropriate error code.
5541 */
5542PJ_DECL(pj_status_t) pjsua_vid_win_set_size(pjsua_vid_win_id wid,
5543 const pjmedia_rect_size *size);
5544
5545
5546
5547/*
5548 * Video codecs API
Nanang Izzuddin50fae732011-03-22 09:49:23 +00005549 */
5550
5551/**
5552 * Enum all supported video codecs in the system.
5553 *
5554 * @param id Array of ID to be initialized.
5555 * @param count On input, specifies max elements in the array.
5556 * On return, it contains actual number of elements
5557 * that have been initialized.
5558 *
5559 * @return PJ_SUCCESS on success, or the appropriate error code.
5560 */
5561PJ_DECL(pj_status_t) pjsua_vid_enum_codecs( pjsua_codec_info id[],
5562 unsigned *count );
5563
5564
5565/**
5566 * Change video codec priority.
5567 *
5568 * @param codec_id Codec ID, which is a string that uniquely identify
5569 * the codec (such as "H263/90000"). Please see pjsua
5570 * manual or pjmedia codec reference for details.
5571 * @param priority Codec priority, 0-255, where zero means to disable
5572 * the codec.
5573 *
5574 * @return PJ_SUCCESS on success, or the appropriate error code.
5575 */
5576PJ_DECL(pj_status_t) pjsua_vid_codec_set_priority( const pj_str_t *codec_id,
5577 pj_uint8_t priority );
5578
5579
5580/**
5581 * Get video codec parameters.
5582 *
5583 * @param codec_id Codec ID.
5584 * @param param Structure to receive video codec parameters.
5585 *
5586 * @return PJ_SUCCESS on success, or the appropriate error code.
5587 */
5588PJ_DECL(pj_status_t) pjsua_vid_codec_get_param(
5589 const pj_str_t *codec_id,
5590 pjmedia_vid_codec_param *param);
5591
5592
5593/**
5594 * Set video codec parameters.
5595 *
5596 * @param codec_id Codec ID.
5597 * @param param Codec parameter to set. Set to NULL to reset
5598 * codec parameter to library default settings.
5599 *
5600 * @return PJ_SUCCESS on success, or the appropriate error code.
5601 */
5602PJ_DECL(pj_status_t) pjsua_vid_codec_set_param(
5603 const pj_str_t *codec_id,
5604 const pjmedia_vid_codec_param *param);
5605
5606
Benny Prijono268ca612006-02-07 12:34:11 +00005607
Benny Prijono9f468d12011-07-07 07:46:33 +00005608/* end of VIDEO API */
Benny Prijono268ca612006-02-07 12:34:11 +00005609/**
5610 * @}
5611 */
5612
Benny Prijono268ca612006-02-07 12:34:11 +00005613
Benny Prijono312aff92006-06-17 04:08:30 +00005614/**
5615 * @}
5616 */
5617
Benny Prijonoe6ead542007-01-31 20:53:31 +00005618PJ_END_DECL
5619
Benny Prijono312aff92006-06-17 04:08:30 +00005620
Benny Prijono268ca612006-02-07 12:34:11 +00005621#endif /* __PJSUA_H__ */