blob: bab8a0f6c59da9238cff67b43dcfac46795d8e0f [file] [log] [blame]
Benny Prijono268ca612006-02-07 12:34:11 +00001/* $Id$ */
2/*
Benny Prijono844653c2008-12-23 17:27:53 +00003 * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
Benny Prijono32177c02008-06-20 22:44:47 +00004 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
Benny Prijono268ca612006-02-07 12:34:11 +00005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#ifndef __PJSUA_H__
21#define __PJSUA_H__
22
Benny Prijono312aff92006-06-17 04:08:30 +000023/**
24 * @file pjsua.h
25 * @brief PJSUA API.
26 */
27
28
Benny Prijono268ca612006-02-07 12:34:11 +000029/* Include all PJSIP core headers. */
30#include <pjsip.h>
31
32/* Include all PJMEDIA headers. */
33#include <pjmedia.h>
34
Benny Prijono1f9afba2006-02-10 15:57:32 +000035/* Include all PJMEDIA-CODEC headers. */
36#include <pjmedia-codec.h>
37
Benny Prijono268ca612006-02-07 12:34:11 +000038/* Include all PJSIP-UA headers */
39#include <pjsip_ua.h>
40
Benny Prijono834aee32006-02-19 01:38:06 +000041/* Include all PJSIP-SIMPLE headers */
42#include <pjsip_simple.h>
43
Benny Prijono4ab9fbb2007-10-12 12:14:27 +000044/* Include all PJNATH headers */
45#include <pjnath.h>
46
Benny Prijono268ca612006-02-07 12:34:11 +000047/* Include all PJLIB-UTIL headers. */
48#include <pjlib-util.h>
49
50/* Include all PJLIB headers. */
51#include <pjlib.h>
52
53
Benny Prijonoe6ead542007-01-31 20:53:31 +000054PJ_BEGIN_DECL
55
56
Benny Prijono312aff92006-06-17 04:08:30 +000057/**
Benny Prijono58163a22009-06-03 08:40:24 +000058 * @defgroup PJSUA_LIB PJSUA API - High Level Softphone API
Benny Prijono312aff92006-06-17 04:08:30 +000059 * @brief Very high level API for constructing SIP UA applications.
60 * @{
61 *
Benny Prijono58163a22009-06-03 08:40:24 +000062 * @section pjsua_api_intro A SIP User Agent API for C/C++
Benny Prijonoe6ead542007-01-31 20:53:31 +000063 *
Benny Prijono58163a22009-06-03 08:40:24 +000064 * PJSUA API is very high level API for constructing SIP multimedia user agent
Benny Prijono312aff92006-06-17 04:08:30 +000065 * applications. It wraps together the signaling and media functionalities
66 * into an easy to use call API, provides account management, buddy
67 * management, presence, instant messaging, along with multimedia
68 * features such as conferencing, file streaming, local playback,
69 * voice recording, and so on.
70 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000071 * @subsection pjsua_for_c_cpp C/C++ Binding
Benny Prijono312aff92006-06-17 04:08:30 +000072 * Application must link with <b>pjsua-lib</b> to use this API. In addition,
73 * this library depends on the following libraries:
74 * - <b>pjsip-ua</b>,
75 * - <b>pjsip-simple</b>,
76 * - <b>pjsip-core</b>,
77 * - <b>pjmedia</b>,
78 * - <b>pjmedia-codec</b>,
79 * - <b>pjlib-util</b>, and
80 * - <b>pjlib</b>,
81 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000082 * so application must also link with these libraries as well. For more
83 * information, please refer to
84 * <A HREF="http://www.pjsip.org/using.htm">Getting Started with PJSIP</A>
85 * page.
Benny Prijono312aff92006-06-17 04:08:30 +000086 *
Benny Prijonoe6ead542007-01-31 20:53:31 +000087 * @section pjsua_samples
88 *
Benny Prijono58163a22009-06-03 08:40:24 +000089 * Few samples are provided:
Benny Prijonoe6ead542007-01-31 20:53:31 +000090 *
91 - @ref page_pjsip_sample_simple_pjsuaua_c\n
92 Very simple SIP User Agent with registration, call, and media, using
93 PJSUA-API, all in under 200 lines of code.
94
95 - @ref page_pjsip_samples_pjsua\n
96 This is the reference implementation for PJSIP and PJMEDIA.
97 PJSUA is a console based application, designed to be simple enough
98 to be readble, but powerful enough to demonstrate all features
99 available in PJSIP and PJMEDIA.\n
100
Benny Prijono312aff92006-06-17 04:08:30 +0000101 * @section root_using_pjsua_lib Using PJSUA API
102 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000103 * Please refer to @ref PJSUA_LIB_BASE on how to create and initialize the API.
104 * And then see the Modules on the bottom of this page for more information
105 * about specific subject.
Benny Prijono312aff92006-06-17 04:08:30 +0000106 */
107
Benny Prijonoa91a0032006-02-26 21:23:45 +0000108
Benny Prijonof3195072006-02-14 21:15:30 +0000109
Benny Prijono312aff92006-06-17 04:08:30 +0000110/*****************************************************************************
111 * BASE API
112 */
113
Benny Prijonof04ffdd2006-02-21 00:11:18 +0000114/**
Benny Prijonoe6ead542007-01-31 20:53:31 +0000115 * @defgroup PJSUA_LIB_BASE PJSUA-API Basic API
Benny Prijono312aff92006-06-17 04:08:30 +0000116 * @ingroup PJSUA_LIB
117 * @brief Basic application creation/initialization, logging configuration, etc.
118 * @{
119 *
120 * The base PJSUA API controls PJSUA creation, initialization, and startup, and
121 * also provides various auxiliary functions.
122 *
123 * @section using_pjsua_lib Using PJSUA Library
124 *
125 * @subsection creating_pjsua_lib Creating PJSUA
126 *
Benny Prijono58163a22009-06-03 08:40:24 +0000127 * Before anything else, application must create PJSUA by calling
128 * #pjsua_create().
Benny Prijono312aff92006-06-17 04:08:30 +0000129 * This, among other things, will initialize PJLIB, which is crucial before
Benny Prijonoe6ead542007-01-31 20:53:31 +0000130 * any PJLIB functions can be called, PJLIB-UTIL, and create a SIP endpoint.
131 *
132 * After this function is called, application can create a memory pool (with
133 * #pjsua_pool_create()) and read configurations from command line or file to
134 * build the settings to initialize PJSUA below.
Benny Prijono312aff92006-06-17 04:08:30 +0000135 *
136 * @subsection init_pjsua_lib Initializing PJSUA
137 *
138 * After PJSUA is created, application can initialize PJSUA by calling
Benny Prijonoe6ead542007-01-31 20:53:31 +0000139 * #pjsua_init(). This function takes several optional configuration settings
140 * in the argument, if application wants to set them.
Benny Prijono312aff92006-06-17 04:08:30 +0000141 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000142 * @subsubsection init_pjsua_lib_c_cpp PJSUA-LIB Initialization (in C)
143 * Sample code to initialize PJSUA in C code:
Benny Prijono312aff92006-06-17 04:08:30 +0000144 \code
145
Benny Prijonob5388cf2007-01-04 22:45:08 +0000146 #include <pjsua-lib/pjsua.h>
147
148 #define THIS_FILE __FILE__
149
150 static pj_status_t app_init(void)
151 {
Benny Prijono312aff92006-06-17 04:08:30 +0000152 pjsua_config ua_cfg;
153 pjsua_logging_config log_cfg;
154 pjsua_media_config media_cfg;
Benny Prijonob5388cf2007-01-04 22:45:08 +0000155 pj_status_t status;
156
157 // Must create pjsua before anything else!
158 status = pjsua_create();
159 if (status != PJ_SUCCESS) {
160 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
161 return status;
162 }
Benny Prijono312aff92006-06-17 04:08:30 +0000163
164 // Initialize configs with default settings.
165 pjsua_config_default(&ua_cfg);
166 pjsua_logging_config_default(&log_cfg);
167 pjsua_media_config_default(&media_cfg);
168
169 // At the very least, application would want to override
170 // the call callbacks in pjsua_config:
171 ua_cfg.cb.on_incoming_call = ...
172 ua_cfg.cb.on_call_state = ..
173 ...
174
175 // Customize other settings (or initialize them from application specific
176 // configuration file):
177 ...
178
179 // Initialize pjsua
180 status = pjsua_init(&ua_cfg, &log_cfg, &media_cfg);
181 if (status != PJ_SUCCESS) {
182 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
183 return status;
184 }
Benny Prijonob5388cf2007-01-04 22:45:08 +0000185 .
186 ...
187 }
Benny Prijono312aff92006-06-17 04:08:30 +0000188 \endcode
189 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000190 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000191
192
Benny Prijono312aff92006-06-17 04:08:30 +0000193 * @subsection other_init_pjsua_lib Other Initialization
194 *
195 * After PJSUA is initialized with #pjsua_init(), application will normally
196 * need/want to perform the following tasks:
197 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000198 * - create SIP transport with #pjsua_transport_create(). Application would
199 * to call #pjsua_transport_create() for each transport types that it
200 * wants to support (for example, UDP, TCP, and TLS). Please see
Benny Prijono312aff92006-06-17 04:08:30 +0000201 * @ref PJSUA_LIB_TRANSPORT section for more info.
202 * - create one or more SIP accounts with #pjsua_acc_add() or
Benny Prijonoe6ead542007-01-31 20:53:31 +0000203 * #pjsua_acc_add_local(). The SIP account is used for registering with
204 * the SIP server, if any. Please see @ref PJSUA_LIB_ACC for more info.
Benny Prijono312aff92006-06-17 04:08:30 +0000205 * - add one or more buddies with #pjsua_buddy_add(). Please see
206 * @ref PJSUA_LIB_BUDDY section for more info.
207 * - optionally configure the sound device, codec settings, and other
208 * media settings. Please see @ref PJSUA_LIB_MEDIA for more info.
209 *
210 *
211 * @subsection starting_pjsua_lib Starting PJSUA
212 *
213 * After all initializations have been done, application must call
214 * #pjsua_start() to start PJSUA. This function will check that all settings
Benny Prijonoe6ead542007-01-31 20:53:31 +0000215 * have been properly configured, and apply default settings when they haven't,
216 * or report error status when it is unable to recover from missing settings.
Benny Prijono312aff92006-06-17 04:08:30 +0000217 *
218 * Most settings can be changed during run-time. For example, application
219 * may add, modify, or delete accounts, buddies, or change media settings
220 * during run-time.
Benny Prijonob5388cf2007-01-04 22:45:08 +0000221 *
Benny Prijonoe6ead542007-01-31 20:53:31 +0000222 * @subsubsection starting_pjsua_lib_c C Example for Starting PJSUA
Benny Prijonob5388cf2007-01-04 22:45:08 +0000223 * Sample code:
224 \code
225 static pj_status_t app_run(void)
226 {
227 pj_status_t status;
228
229 // Start pjsua
230 status = pjsua_start();
231 if (status != PJ_SUCCESS) {
232 pjsua_destroy();
233 pjsua_perror(THIS_FILE, "Error starting pjsua", status);
234 return status;
235 }
236
237 // Run application loop
238 while (1) {
239 char choice[10];
240
241 printf("Select menu: ");
242 fgets(choice, sizeof(choice), stdin);
243 ...
244 }
245 }
246 \endcode
Benny Prijonoe6ead542007-01-31 20:53:31 +0000247
Benny Prijonof04ffdd2006-02-21 00:11:18 +0000248 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000249
Benny Prijono312aff92006-06-17 04:08:30 +0000250/** Constant to identify invalid ID for all sorts of IDs. */
251#define PJSUA_INVALID_ID (-1)
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000252
Benny Prijono0bc99a92011-03-17 04:34:43 +0000253/** Disabled features temporarily for media reorganization */
254#define DISABLED_FOR_TICKET_1185 0
255
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000256/** Call identification */
257typedef int pjsua_call_id;
258
Benny Prijono312aff92006-06-17 04:08:30 +0000259/** Account identification */
260typedef int pjsua_acc_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000261
262/** Buddy identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000263typedef int pjsua_buddy_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000264
265/** File player identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000266typedef int pjsua_player_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000267
268/** File recorder identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000269typedef int pjsua_recorder_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000270
271/** Conference port identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000272typedef int pjsua_conf_port_id;
273
Benny Prijono63fba012008-07-17 14:19:10 +0000274/** Opaque declaration for server side presence subscription */
275typedef struct pjsua_srv_pres pjsua_srv_pres;
276
277/** Forward declaration for pjsua_msg_data */
278typedef struct pjsua_msg_data pjsua_msg_data;
Benny Prijono8b1889b2006-06-06 18:40:40 +0000279
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000280
Benny Prijonoa91a0032006-02-26 21:23:45 +0000281/**
Benny Prijono312aff92006-06-17 04:08:30 +0000282 * Maximum proxies in account.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000283 */
Benny Prijono312aff92006-06-17 04:08:30 +0000284#ifndef PJSUA_ACC_MAX_PROXIES
285# define PJSUA_ACC_MAX_PROXIES 8
286#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000287
Benny Prijonod8179652008-01-23 20:39:07 +0000288/**
289 * Default value of SRTP mode usage. Valid values are PJMEDIA_SRTP_DISABLED,
290 * PJMEDIA_SRTP_OPTIONAL, and PJMEDIA_SRTP_MANDATORY.
291 */
292#ifndef PJSUA_DEFAULT_USE_SRTP
293 #define PJSUA_DEFAULT_USE_SRTP PJMEDIA_SRTP_DISABLED
294#endif
295
296/**
297 * Default value of secure signaling requirement for SRTP.
298 * Valid values are:
299 * 0: SRTP does not require secure signaling
300 * 1: SRTP requires secure transport such as TLS
301 * 2: SRTP requires secure end-to-end transport (SIPS)
302 */
303#ifndef PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
304 #define PJSUA_DEFAULT_SRTP_SECURE_SIGNALING 1
305#endif
306
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000307/**
Benny Prijono07fe2302010-06-24 12:33:18 +0000308 * Controls whether PJSUA-LIB should add ICE media feature tag
309 * parameter (the ";+sip.ice" parameter) to Contact header if ICE
310 * is enabled in the config.
311 *
312 * Default: 1
313 */
314#ifndef PJSUA_ADD_ICE_TAGS
315# define PJSUA_ADD_ICE_TAGS 1
316#endif
317
Sauw Ming844c1c92010-09-07 05:12:02 +0000318/**
319 * Timeout value used to acquire mutex lock on a particular call.
320 *
321 * Default: 2000 ms
322 */
323#ifndef PJSUA_ACQUIRE_CALL_TIMEOUT
324# define PJSUA_ACQUIRE_CALL_TIMEOUT 2000
325#endif
326
Benny Prijono9f468d12011-07-07 07:46:33 +0000327/**
328 * Is video enabled.
329 */
330#ifndef PJSUA_HAS_VIDEO
331# define PJSUA_HAS_VIDEO PJMEDIA_HAS_VIDEO
332#endif
Benny Prijono07fe2302010-06-24 12:33:18 +0000333
334/**
Benny Prijono0bc99a92011-03-17 04:34:43 +0000335 * This enumeration represents pjsua state.
336 */
337typedef enum pjsua_state
338{
339 /**
340 * The library has not been initialized.
341 */
342 PJSUA_STATE_NULL,
343
344 /**
345 * After pjsua_create() is called but before pjsua_init() is called.
346 */
347 PJSUA_STATE_CREATED,
348
349 /**
350 * After pjsua_init() is called but before pjsua_start() is called.
351 */
352 PJSUA_STATE_INIT,
353
354 /**
355 * After pjsua_start() is called but before everything is running.
356 */
357 PJSUA_STATE_STARTING,
358
359 /**
360 * After pjsua_start() is called and before pjsua_destroy() is called.
361 */
362 PJSUA_STATE_RUNNING,
363
364 /**
365 * After pjsua_destroy() is called but before the function returns.
366 */
367 PJSUA_STATE_CLOSING
368
369} pjsua_state;
370
371
372/**
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 Izzuddin7ad53c32011-07-13 13:31:08 +0000384 * Disable/remove an existing video stream.
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +0000385 */
Nanang Izzuddin7ad53c32011-07-13 13:31:08 +0000386 PJSUA_CALL_VID_STRM_DISABLE,
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +0000387
388 /**
Nanang Izzuddin7ad53c32011-07-13 13:31:08 +0000389 * Enable video stream.
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +0000390 */
Nanang Izzuddin7ad53c32011-07-13 13:31:08 +0000391 PJSUA_CALL_VID_STRM_ENABLE,
392
393 /**
394 * Changing capture device of a video stream.
395 */
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.
423 */
424 int med_idx;
425
426 /**
427 * Specify the video capture device ID. This can be set to
428 * PJMEDIA_VID_DEFAULT_CAPTURE_DEV to specify the default capture
429 * device as configured in the account.
430 *
431 * This field is valid for the following video stream operations:
Nanang Izzuddin7ad53c32011-07-13 13:31:08 +0000432 * PJSUA_CALL_VID_STRM_ADD, PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV, and
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +0000433 * PJSUA_CALL_VID_STRM_START_TRANSMIT.
434 */
435 pjmedia_vid_dev_index cap_dev;
436
437} pjsua_call_vid_strm_op_param;
438
439
440/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000441 * Logging configuration, which can be (optionally) specified when calling
442 * #pjsua_init(). Application must call #pjsua_logging_config_default() to
443 * initialize this structure with the default values.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000444 */
445typedef struct pjsua_logging_config
446{
447 /**
448 * Log incoming and outgoing SIP message? Yes!
449 */
450 pj_bool_t msg_logging;
451
452 /**
453 * Input verbosity level. Value 5 is reasonable.
454 */
455 unsigned level;
456
457 /**
458 * Verbosity level for console. Value 4 is reasonable.
459 */
460 unsigned console_level;
461
462 /**
463 * Log decoration.
464 */
465 unsigned decor;
466
467 /**
468 * Optional log filename.
469 */
470 pj_str_t log_filename;
471
472 /**
Benny Prijonodbe3f4b2009-05-07 16:56:04 +0000473 * Additional flags to be given to #pj_file_open() when opening
474 * the log file. By default, the flag is PJ_O_WRONLY. Application
475 * may set PJ_O_APPEND here so that logs are appended to existing
476 * file instead of overwriting it.
477 *
478 * Default is 0.
479 */
480 unsigned log_file_flags;
481
482 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000483 * Optional callback function to be called to write log to
484 * application specific device. This function will be called for
485 * log messages on input verbosity level.
486 */
Benny Prijonofe7d87b2007-11-29 11:35:44 +0000487 void (*cb)(int level, const char *data, int len);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000488
489
490} pjsua_logging_config;
491
492
493/**
494 * Use this function to initialize logging config.
495 *
496 * @param cfg The logging config to be initialized.
497 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000498PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000499
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000500
501/**
502 * Use this function to duplicate logging config.
503 *
504 * @param pool Pool to use.
505 * @param dst Destination config.
506 * @param src Source config.
507 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000508PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool,
509 pjsua_logging_config *dst,
510 const pjsua_logging_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000511
Benny Prijonodc39fe82006-05-26 12:17:46 +0000512
513/**
Benny Prijono4dd961b2009-10-26 11:21:37 +0000514 * Structure to be passed on MWI callback.
515 */
516typedef struct pjsua_mwi_info
517{
518 pjsip_evsub *evsub; /**< Event subscription session, for
519 reference. */
520 pjsip_rx_data *rdata; /**< The received NOTIFY request. */
521} pjsua_mwi_info;
522
523
524/**
Nanang Izzuddin4ea1bcc2010-09-28 04:57:01 +0000525 * Structure to be passed on registration callback.
526 */
527typedef struct pjsua_reg_info
528{
529 struct pjsip_regc_cbparam *cbparam; /**< Parameters returned by
530 registration callback. */
531} pjsua_reg_info;
532
533
534/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000535 * This structure describes application callback to receive various event
536 * notification from PJSUA-API. All of these callbacks are OPTIONAL,
537 * although definitely application would want to implement some of
538 * the important callbacks (such as \a on_incoming_call).
Benny Prijonodc39fe82006-05-26 12:17:46 +0000539 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000540typedef struct pjsua_callback
Benny Prijonodc39fe82006-05-26 12:17:46 +0000541{
542 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000543 * Notify application when invite state has changed.
544 * Application may then query the call info to get the
Benny Prijonoe6ead542007-01-31 20:53:31 +0000545 * detail call states by calling pjsua_call_get_info() function.
Benny Prijono0875ae82006-12-26 00:11:48 +0000546 *
547 * @param call_id The call index.
548 * @param e Event which causes the call state to change.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000549 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000550 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000551
552 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000553 * Notify application on incoming call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000554 *
555 * @param acc_id The account which match the incoming call.
556 * @param call_id The call id that has just been created for
557 * the call.
558 * @param rdata The incoming INVITE request.
Benny Prijono8b1889b2006-06-06 18:40:40 +0000559 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000560 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000561 pjsip_rx_data *rdata);
562
563 /**
Benny Prijonofeb69f42007-10-05 09:12:26 +0000564 * This is a general notification callback which is called whenever
565 * a transaction within the call has changed state. Application can
566 * implement this callback for example to monitor the state of
567 * outgoing requests, or to answer unhandled incoming requests
568 * (such as INFO) with a final response.
569 *
570 * @param call_id Call identification.
571 * @param tsx The transaction which has changed state.
572 * @param e Transaction event that caused the state change.
573 */
574 void (*on_call_tsx_state)(pjsua_call_id call_id,
575 pjsip_transaction *tsx,
576 pjsip_event *e);
577
578 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000579 * Notify application when media state in the call has changed.
580 * Normal application would need to implement this callback, e.g.
Benny Prijono6ba8c542007-10-16 01:34:14 +0000581 * to connect the call's media to sound device. When ICE is used,
582 * this callback will also be called to report ICE negotiation
583 * failure.
Benny Prijono0875ae82006-12-26 00:11:48 +0000584 *
585 * @param call_id The call index.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000586 */
587 void (*on_call_media_state)(pjsua_call_id call_id);
588
Benny Prijonofc13bf62008-02-20 08:56:15 +0000589
590 /**
591 * Notify application when media session is created and before it is
592 * registered to the conference bridge. Application may return different
593 * media port if it has added media processing port to the stream. This
594 * media port then will be added to the conference bridge instead.
595 *
596 * @param call_id Call identification.
Benny Prijono0bc99a92011-03-17 04:34:43 +0000597 * @param strm Media stream.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000598 * @param stream_idx Stream index in the media session.
599 * @param p_port On input, it specifies the media port of the
600 * stream. Application may modify this pointer to
601 * point to different media port to be registered
602 * to the conference bridge.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000603 */
604 void (*on_stream_created)(pjsua_call_id call_id,
Benny Prijono0bc99a92011-03-17 04:34:43 +0000605 pjmedia_stream *strm,
Benny Prijonofc13bf62008-02-20 08:56:15 +0000606 unsigned stream_idx,
607 pjmedia_port **p_port);
608
609 /**
610 * Notify application when media session has been unregistered from the
611 * conference bridge and about to be destroyed.
612 *
613 * @param call_id Call identification.
Benny Prijono0bc99a92011-03-17 04:34:43 +0000614 * @param strm Media stream.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000615 * @param stream_idx Stream index in the media session.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000616 */
617 void (*on_stream_destroyed)(pjsua_call_id call_id,
Benny Prijono0bc99a92011-03-17 04:34:43 +0000618 pjmedia_stream *strm,
Benny Prijonofc13bf62008-02-20 08:56:15 +0000619 unsigned stream_idx);
620
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000621 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000622 * Notify application upon incoming DTMF digits.
623 *
624 * @param call_id The call index.
625 * @param digit DTMF ASCII digit.
626 */
627 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
628
629 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000630 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000631 * Application can decide to accept/reject transfer request
Benny Prijonoc54dcb32008-04-08 23:33:15 +0000632 * by setting the code (default is 202). When this callback
Benny Prijono9fc735d2006-05-28 14:58:12 +0000633 * is not defined, the default behavior is to accept the
634 * transfer.
Benny Prijono0875ae82006-12-26 00:11:48 +0000635 *
636 * @param call_id The call index.
637 * @param dst The destination where the call will be
638 * transfered to.
639 * @param code Status code to be returned for the call transfer
640 * request. On input, it contains status code 200.
Benny Prijono9fc735d2006-05-28 14:58:12 +0000641 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000642 void (*on_call_transfer_request)(pjsua_call_id call_id,
643 const pj_str_t *dst,
644 pjsip_status_code *code);
645
646 /**
647 * Notify application of the status of previously sent call
648 * transfer request. Application can monitor the status of the
649 * call transfer request, for example to decide whether to
650 * terminate existing call.
651 *
652 * @param call_id Call ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000653 * @param st_code Status progress of the transfer request.
654 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000655 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000656 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000657 * this callback is the final status.
658 * @param p_cont Initially will be set to non-zero, application
659 * can set this to FALSE if it no longer wants
660 * to receie further notification (for example,
661 * after it hangs up the call).
662 */
663 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000664 int st_code,
665 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000666 pj_bool_t final,
667 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000668
669 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000670 * Notify application about incoming INVITE with Replaces header.
671 * Application may reject the request by setting non-2xx code.
672 *
673 * @param call_id The call ID to be replaced.
674 * @param rdata The incoming INVITE request to replace the call.
675 * @param st_code Status code to be set by application. Application
676 * should only return a final status (200-699).
677 * @param st_text Optional status text to be set by application.
678 */
679 void (*on_call_replace_request)(pjsua_call_id call_id,
680 pjsip_rx_data *rdata,
681 int *st_code,
682 pj_str_t *st_text);
683
684 /**
685 * Notify application that an existing call has been replaced with
686 * a new call. This happens when PJSUA-API receives incoming INVITE
687 * request with Replaces header.
688 *
689 * After this callback is called, normally PJSUA-API will disconnect
690 * \a old_call_id and establish \a new_call_id.
691 *
692 * @param old_call_id Existing call which to be replaced with the
693 * new call.
694 * @param new_call_id The new call.
695 * @param rdata The incoming INVITE with Replaces request.
696 */
697 void (*on_call_replaced)(pjsua_call_id old_call_id,
698 pjsua_call_id new_call_id);
699
700
701 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000702 * Notify application when registration status has changed.
703 * Application may then query the account info to get the
704 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000705 *
Nanang Izzuddin4ea1bcc2010-09-28 04:57:01 +0000706 * @param acc_id The account ID.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000707 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000708 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000709
710 /**
Nanang Izzuddin4ea1bcc2010-09-28 04:57:01 +0000711 * Notify application when registration status has changed.
712 * Application may inspect the registration info to get the
713 * registration status details.
714 *
715 * @param acc_id The account ID.
716 * @param info The registration info.
717 */
718 void (*on_reg_state2)(pjsua_acc_id acc_id, pjsua_reg_info *info);
719
720 /**
Benny Prijono63fba012008-07-17 14:19:10 +0000721 * Notification when incoming SUBSCRIBE request is received. Application
722 * may use this callback to authorize the incoming subscribe request
723 * (e.g. ask user permission if the request should be granted).
724 *
725 * If this callback is not implemented, all incoming presence subscription
726 * requests will be accepted.
727 *
728 * If this callback is implemented, application has several choices on
729 * what to do with the incoming request:
730 * - it may reject the request immediately by specifying non-200 class
731 * final response in the \a code argument.
732 * - it may immediately accept the request by specifying 200 as the
733 * \a code argument. This is the default value if application doesn't
734 * set any value to the \a code argument. In this case, the library
735 * will automatically send NOTIFY request upon returning from this
736 * callback.
737 * - it may delay the processing of the request, for example to request
738 * user permission whether to accept or reject the request. In this
739 * case, the application MUST set the \a code argument to 202, and
740 * later calls #pjsua_pres_notify() to accept or reject the
741 * subscription request.
742 *
743 * Any \a code other than 200 and 202 will be treated as 200.
744 *
745 * Application MUST return from this callback immediately (e.g. it must
746 * not block in this callback while waiting for user confirmation).
747 *
748 * @param srv_pres Server presence subscription instance. If
749 * application delays the acceptance of the request,
750 * it will need to specify this object when calling
751 * #pjsua_pres_notify().
752 * @param acc_id Account ID most appropriate for this request.
753 * @param buddy_id ID of the buddy matching the sender of the
754 * request, if any, or PJSUA_INVALID_ID if no
755 * matching buddy is found.
756 * @param from The From URI of the request.
757 * @param rdata The incoming request.
758 * @param code The status code to respond to the request. The
759 * default value is 200. Application may set this
760 * to other final status code to accept or reject
761 * the request.
762 * @param reason The reason phrase to respond to the request.
763 * @param msg_data If the application wants to send additional
764 * headers in the response, it can put it in this
765 * parameter.
766 */
767 void (*on_incoming_subscribe)(pjsua_acc_id acc_id,
768 pjsua_srv_pres *srv_pres,
769 pjsua_buddy_id buddy_id,
770 const pj_str_t *from,
771 pjsip_rx_data *rdata,
772 pjsip_status_code *code,
773 pj_str_t *reason,
774 pjsua_msg_data *msg_data);
775
776 /**
777 * Notification when server side subscription state has changed.
778 * This callback is optional as application normally does not need
779 * to do anything to maintain server side presence subscription.
780 *
781 * @param acc_id The account ID.
782 * @param srv_pres Server presence subscription object.
783 * @param remote_uri Remote URI string.
784 * @param state New subscription state.
785 * @param event PJSIP event that triggers the state change.
786 */
787 void (*on_srv_subscribe_state)(pjsua_acc_id acc_id,
788 pjsua_srv_pres *srv_pres,
789 const pj_str_t *remote_uri,
790 pjsip_evsub_state state,
791 pjsip_event *event);
792
793 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000794 * Notify application when the buddy state has changed.
795 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000796 *
797 * @param buddy_id The buddy id.
Benny Prijono9fc735d2006-05-28 14:58:12 +0000798 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000799 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000800
Benny Prijono63499892010-10-12 12:45:15 +0000801
802 /**
803 * Notify application when the state of client subscription session
804 * associated with a buddy has changed. Application may use this
805 * callback to retrieve more detailed information about the state
806 * changed event.
807 *
808 * @param buddy_id The buddy id.
809 * @param sub Event subscription session.
810 * @param event The event which triggers state change event.
811 */
812 void (*on_buddy_evsub_state)(pjsua_buddy_id buddy_id,
813 pjsip_evsub *sub,
814 pjsip_event *event);
815
Benny Prijono9fc735d2006-05-28 14:58:12 +0000816 /**
817 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000818 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000819 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000820 *
Benny Prijonobbeb3992007-05-21 13:48:35 +0000821 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
822 * passed as one of the argument.
823 *
Benny Prijono0875ae82006-12-26 00:11:48 +0000824 * @param call_id Containts the ID of the call where the IM was
825 * sent, or PJSUA_INVALID_ID if the IM was sent
826 * outside call context.
827 * @param from URI of the sender.
828 * @param to URI of the destination message.
829 * @param contact The Contact URI of the sender, if present.
830 * @param mime_type MIME type of the message.
831 * @param body The message content.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000832 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000833 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
834 const pj_str_t *to, const pj_str_t *contact,
835 const pj_str_t *mime_type, const pj_str_t *body);
836
837 /**
Benny Prijonobbeb3992007-05-21 13:48:35 +0000838 * This is the alternative version of the \a on_pager() callback with
839 * \a pjsip_rx_data argument.
840 *
841 * @param call_id Containts the ID of the call where the IM was
842 * sent, or PJSUA_INVALID_ID if the IM was sent
843 * outside call context.
844 * @param from URI of the sender.
845 * @param to URI of the destination message.
846 * @param contact The Contact URI of the sender, if present.
847 * @param mime_type MIME type of the message.
848 * @param body The message content.
849 * @param rdata The incoming MESSAGE request.
Benny Prijonoba736c42008-07-10 20:45:03 +0000850 * @param acc_id Account ID most suitable for this message.
Benny Prijonobbeb3992007-05-21 13:48:35 +0000851 */
852 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
853 const pj_str_t *to, const pj_str_t *contact,
854 const pj_str_t *mime_type, const pj_str_t *body,
Benny Prijonoba736c42008-07-10 20:45:03 +0000855 pjsip_rx_data *rdata, pjsua_acc_id acc_id);
Benny Prijonobbeb3992007-05-21 13:48:35 +0000856
857 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000858 * Notify application about the delivery status of outgoing pager
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000859 * request. See also on_pager_status2() callback for the version with
860 * \a pjsip_rx_data in the argument list.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000861 *
862 * @param call_id Containts the ID of the call where the IM was
863 * sent, or PJSUA_INVALID_ID if the IM was sent
864 * outside call context.
865 * @param to Destination URI.
866 * @param body Message body.
867 * @param user_data Arbitrary data that was specified when sending
868 * IM message.
869 * @param status Delivery status.
870 * @param reason Delivery status reason.
871 */
872 void (*on_pager_status)(pjsua_call_id call_id,
873 const pj_str_t *to,
874 const pj_str_t *body,
875 void *user_data,
876 pjsip_status_code status,
877 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000878
879 /**
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000880 * Notify application about the delivery status of outgoing pager
881 * request.
882 *
883 * @param call_id Containts the ID of the call where the IM was
884 * sent, or PJSUA_INVALID_ID if the IM was sent
885 * outside call context.
886 * @param to Destination URI.
887 * @param body Message body.
888 * @param user_data Arbitrary data that was specified when sending
889 * IM message.
890 * @param status Delivery status.
891 * @param reason Delivery status reason.
Benny Prijono0a982002007-06-12 16:22:09 +0000892 * @param tdata The original MESSAGE request.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000893 * @param rdata The incoming MESSAGE response, or NULL if the
894 * message transaction fails because of time out
895 * or transport error.
Benny Prijonoba736c42008-07-10 20:45:03 +0000896 * @param acc_id Account ID from this the instant message was
897 * send.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000898 */
899 void (*on_pager_status2)(pjsua_call_id call_id,
900 const pj_str_t *to,
901 const pj_str_t *body,
902 void *user_data,
903 pjsip_status_code status,
904 const pj_str_t *reason,
Benny Prijono0a982002007-06-12 16:22:09 +0000905 pjsip_tx_data *tdata,
Benny Prijonoba736c42008-07-10 20:45:03 +0000906 pjsip_rx_data *rdata,
907 pjsua_acc_id acc_id);
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000908
909 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000910 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +0000911 *
912 * @param call_id Containts the ID of the call where the IM was
913 * sent, or PJSUA_INVALID_ID if the IM was sent
914 * outside call context.
915 * @param from URI of the sender.
916 * @param to URI of the destination message.
917 * @param contact The Contact URI of the sender, if present.
918 * @param is_typing Non-zero if peer is typing, or zero if peer
919 * has stopped typing a message.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000920 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000921 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
922 const pj_str_t *to, const pj_str_t *contact,
923 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000924
Benny Prijono6ba8c542007-10-16 01:34:14 +0000925 /**
Benny Prijonoba736c42008-07-10 20:45:03 +0000926 * Notify application about typing indication.
927 *
928 * @param call_id Containts the ID of the call where the IM was
929 * sent, or PJSUA_INVALID_ID if the IM was sent
930 * outside call context.
931 * @param from URI of the sender.
932 * @param to URI of the destination message.
933 * @param contact The Contact URI of the sender, if present.
934 * @param is_typing Non-zero if peer is typing, or zero if peer
935 * has stopped typing a message.
936 * @param rdata The received request.
937 * @param acc_id Account ID most suitable for this message.
938 */
939 void (*on_typing2)(pjsua_call_id call_id, const pj_str_t *from,
940 const pj_str_t *to, const pj_str_t *contact,
941 pj_bool_t is_typing, pjsip_rx_data *rdata,
942 pjsua_acc_id acc_id);
943
944 /**
Benny Prijono6ba8c542007-10-16 01:34:14 +0000945 * Callback when the library has finished performing NAT type
946 * detection.
947 *
948 * @param res NAT detection result.
949 */
950 void (*on_nat_detect)(const pj_stun_nat_detect_result *res);
951
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000952 /**
953 * This callback is called when the call is about to resend the
954 * INVITE request to the specified target, following the previously
955 * received redirection response.
956 *
957 * Application may accept the redirection to the specified target
958 * (the default behavior if this callback is implemented), reject
959 * this target only and make the session continue to try the next
960 * target in the list if such target exists, stop the whole
961 * redirection process altogether and cause the session to be
962 * disconnected, or defer the decision to ask for user confirmation.
963 *
964 * This callback is optional. If this callback is not implemented,
965 * the default behavior is to NOT follow the redirection response.
966 *
967 * @param call_id The call ID.
968 * @param target The current target to be tried.
Benny Prijono08a48b82008-11-27 12:42:07 +0000969 * @param e The event that caused this callback to be called.
970 * This could be the receipt of 3xx response, or
971 * 4xx/5xx response received for the INVITE sent to
972 * subsequent targets, or NULL if this callback is
973 * called from within #pjsua_call_process_redirect()
974 * context.
975 *
976 * @return Action to be performed for the target. Set this
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000977 * parameter to one of the value below:
978 * - PJSIP_REDIRECT_ACCEPT: immediately accept the
979 * redirection (default value). When set, the
980 * call will immediately resend INVITE request
981 * to the target.
982 * - PJSIP_REDIRECT_REJECT: immediately reject this
983 * target. The call will continue retrying with
984 * next target if present, or disconnect the call
985 * if there is no more target to try.
986 * - PJSIP_REDIRECT_STOP: stop the whole redirection
987 * process and immediately disconnect the call. The
988 * on_call_state() callback will be called with
989 * PJSIP_INV_STATE_DISCONNECTED state immediately
990 * after this callback returns.
991 * - PJSIP_REDIRECT_PENDING: set to this value if
992 * no decision can be made immediately (for example
993 * to request confirmation from user). Application
994 * then MUST call #pjsua_call_process_redirect()
995 * to either accept or reject the redirection upon
996 * getting user decision.
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000997 */
Benny Prijono08a48b82008-11-27 12:42:07 +0000998 pjsip_redirect_op (*on_call_redirected)(pjsua_call_id call_id,
999 const pjsip_uri *target,
1000 const pjsip_event *e);
Benny Prijono5e51a4e2008-11-27 00:06:46 +00001001
Benny Prijono4dd961b2009-10-26 11:21:37 +00001002 /**
1003 * This callback is called when a NOTIFY request for message summary /
1004 * message waiting indication is received.
1005 *
1006 * @param acc_id The account ID.
1007 * @param mwi_info Structure containing details of the event,
1008 * including the received NOTIFY request in the
1009 * \a rdata field.
1010 */
1011 void (*on_mwi_info)(pjsua_acc_id acc_id, pjsua_mwi_info *mwi_info);
1012
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +00001013 /**
1014 * This callback is called when transport state is changed. See also
1015 * #pjsip_tp_state_callback.
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +00001016 */
Nanang Izzuddin5e69da52010-02-25 11:58:19 +00001017 pjsip_tp_state_callback on_transport_state;
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +00001018
Benny Prijono4d6ff4d2010-06-19 12:35:33 +00001019 /**
1020 * This callback is called to report error in ICE media transport.
1021 * Currently it is used to report TURN Refresh error.
1022 *
1023 * @param index Transport index.
1024 * @param op Operation which trigger the failure.
1025 * @param status Error status.
1026 * @param param Additional info about the event. Currently this will
1027 * always be set to NULL.
1028 */
1029 void (*on_ice_transport_error)(int index, pj_ice_strans_op op,
1030 pj_status_t status, void *param);
1031
Benny Prijono2d647722011-07-13 03:05:22 +00001032 /**
1033 * Callback when the sound device is about to be opened or closed.
1034 * This callback will be called even when null sound device or no
1035 * sound device is configured by the application (i.e. the
1036 * #pjsua_set_null_snd_dev() and #pjsua_set_no_snd_dev() APIs).
1037 * This API is mostly useful when the application wants to manage
1038 * the sound device by itself (i.e. with #pjsua_set_no_snd_dev()),
1039 * to get notified when it should open or close the sound device.
1040 *
1041 * @param operation The value will be set to 0 to signal that sound
1042 * device is about to be closed, and 1 to be opened.
1043 *
1044 * @return The callback must return PJ_SUCCESS at the moment.
1045 */
1046 pj_status_t (*on_snd_dev_operation)(int operation);
1047
Benny Prijonoee0ba182011-07-15 06:18:29 +00001048 /**
1049 * Notification about media events such as video notifications. This
1050 * callback will most likely be called from media threads, thus
1051 * application must not perform heavy processing in this callback.
1052 * Especially, application must not destroy the call or media in this
1053 * callback. If application needs to perform more complex tasks to
1054 * handle the event, it should post the task to another thread.
1055 *
1056 * @param call_id The call id.
1057 * @param med_idx The media stream index.
1058 * @param event The media event.
1059 */
1060 void (*on_call_media_event)(pjsua_call_id call_id,
1061 unsigned med_idx,
1062 pjmedia_event *event);
Benny Prijono2d647722011-07-13 03:05:22 +00001063
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001064} pjsua_callback;
1065
1066
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001067/**
1068 * This enumeration specifies the usage of SIP Session Timers extension.
1069 */
1070typedef enum pjsua_sip_timer_use
1071{
1072 /**
1073 * When this flag is specified, Session Timers will not be used in any
1074 * session, except it is explicitly required in the remote request.
1075 */
1076 PJSUA_SIP_TIMER_INACTIVE,
1077
1078 /**
1079 * When this flag is specified, Session Timers will be used in all
1080 * sessions whenever remote supports and uses it.
1081 */
1082 PJSUA_SIP_TIMER_OPTIONAL,
1083
1084 /**
1085 * When this flag is specified, Session Timers support will be
1086 * a requirement for the remote to be able to establish a session.
1087 */
1088 PJSUA_SIP_TIMER_REQUIRED,
1089
1090 /**
1091 * When this flag is specified, Session Timers will always be used
1092 * in all sessions, regardless whether remote supports/uses it or not.
1093 */
1094 PJSUA_SIP_TIMER_ALWAYS
1095
1096} pjsua_sip_timer_use;
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001097
Benny Prijonodc39fe82006-05-26 12:17:46 +00001098
1099/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001100 * This structure describes the settings to control the API and
1101 * user agent behavior, and can be specified when calling #pjsua_init().
1102 * Before setting the values, application must call #pjsua_config_default()
1103 * to initialize this structure with the default values.
Benny Prijonodc39fe82006-05-26 12:17:46 +00001104 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001105typedef struct pjsua_config
1106{
1107
1108 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001109 * Maximum calls to support (default: 4). The value specified here
1110 * must be smaller than the compile time maximum settings
1111 * PJSUA_MAX_CALLS, which by default is 32. To increase this
1112 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
1113 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001114 */
1115 unsigned max_calls;
1116
1117 /**
1118 * Number of worker threads. Normally application will want to have at
1119 * least one worker thread, unless when it wants to poll the library
1120 * periodically, which in this case the worker thread can be set to
1121 * zero.
1122 */
1123 unsigned thread_cnt;
1124
1125 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +00001126 * Number of nameservers. If no name server is configured, the SIP SRV
1127 * resolution would be disabled, and domain will be resolved with
1128 * standard pj_gethostbyname() function.
1129 */
1130 unsigned nameserver_count;
1131
1132 /**
1133 * Array of nameservers to be used by the SIP resolver subsystem.
1134 * The order of the name server specifies the priority (first name
1135 * server will be used first, unless it is not reachable).
1136 */
1137 pj_str_t nameserver[4];
1138
1139 /**
Benny Prijono91d06b62008-09-20 12:16:56 +00001140 * Force loose-route to be used in all route/proxy URIs (outbound_proxy
1141 * and account's proxy settings). When this setting is enabled, the
1142 * library will check all the route/proxy URIs specified in the settings
1143 * and append ";lr" parameter to the URI if the parameter is not present.
1144 *
1145 * Default: 1
1146 */
1147 pj_bool_t force_lr;
1148
1149 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001150 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001151 */
1152 unsigned outbound_proxy_cnt;
1153
1154 /**
1155 * Specify the URL of outbound proxies to visit for all outgoing requests.
1156 * The outbound proxies will be used for all accounts, and it will
1157 * be used to build the route set for outgoing requests. The final
1158 * route set for outgoing requests will consists of the outbound proxies
1159 * and the proxy configured in the account.
1160 */
1161 pj_str_t outbound_proxy[4];
1162
Benny Prijonoc97608e2007-03-23 16:34:20 +00001163 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001164 * Warning: deprecated, please use \a stun_srv field instead. To maintain
1165 * backward compatibility, if \a stun_srv_cnt is zero then the value of
1166 * this field will be copied to \a stun_srv field, if present.
1167 *
Benny Prijonoebbf6892007-03-24 17:37:25 +00001168 * Specify domain name to be resolved with DNS SRV resolution to get the
Benny Prijonof76e1392008-06-06 14:51:48 +00001169 * address of the STUN server. Alternatively application may specify
1170 * \a stun_host instead.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001171 *
1172 * If DNS SRV resolution failed for this domain, then DNS A resolution
1173 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +00001174 */
Benny Prijonoebbf6892007-03-24 17:37:25 +00001175 pj_str_t stun_domain;
1176
1177 /**
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 Prijonoaf09dc32007-04-22 12:48:30 +00001182 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
1183 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001184 */
1185 pj_str_t stun_host;
1186
1187 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001188 * Number of STUN server entries in \a stun_srv array.
1189 */
1190 unsigned stun_srv_cnt;
1191
1192 /**
1193 * Array of STUN servers to try. The library will try to resolve and
1194 * contact each of the STUN server entry until it finds one that is
1195 * usable. Each entry may be a domain name, host name, IP address, and
1196 * it may contain an optional port number. For example:
1197 * - "pjsip.org" (domain name)
1198 * - "sip.pjsip.org" (host name)
1199 * - "pjsip.org:33478" (domain name and a non-standard port number)
1200 * - "10.0.0.1:3478" (IP address and port number)
1201 *
1202 * When nameserver is configured in the \a pjsua_config.nameserver field,
1203 * if entry is not an IP address, it will be resolved with DNS SRV
1204 * resolution first, and it will fallback to use DNS A resolution if this
1205 * fails. Port number may be specified even if the entry is a domain name,
1206 * in case the DNS SRV resolution should fallback to a non-standard port.
1207 *
1208 * When nameserver is not configured, entries will be resolved with
1209 * #pj_gethostbyname() if it's not an IP address. Port number may be
1210 * specified if the server is not listening in standard STUN port.
1211 */
1212 pj_str_t stun_srv[8];
1213
1214 /**
1215 * This specifies if the library startup should ignore failure with the
1216 * STUN servers. If this is set to PJ_FALSE, the library will refuse to
1217 * start if it fails to resolve or contact any of the STUN servers.
1218 *
1219 * Default: PJ_TRUE
1220 */
1221 pj_bool_t stun_ignore_failure;
1222
1223 /**
Benny Prijono91a6a172007-10-31 08:59:29 +00001224 * Support for adding and parsing NAT type in the SDP to assist
1225 * troubleshooting. The valid values are:
1226 * - 0: no information will be added in SDP, and parsing is disabled.
Benny Prijono6ba8c542007-10-16 01:34:14 +00001227 * - 1: only the NAT type number is added.
1228 * - 2: add both NAT type number and name.
1229 *
Benny Prijono91a6a172007-10-31 08:59:29 +00001230 * Default: 1
Benny Prijono6ba8c542007-10-16 01:34:14 +00001231 */
1232 int nat_type_in_sdp;
1233
1234 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001235 * Specify whether support for reliable provisional response (100rel and
1236 * PRACK) should be required by default. Note that this setting can be
1237 * further customized in account configuration (#pjsua_acc_config).
1238 *
1239 * Default: PJ_FALSE
1240 */
1241 pj_bool_t require_100rel;
1242
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001243 /**
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001244 * Specify the usage of Session Timers for all sessions. See the
1245 * #pjsua_sip_timer_use for possible values. Note that this setting can be
1246 * further customized in account configuration (#pjsua_acc_config).
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001247 *
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001248 * Default: PJSUA_SIP_TIMER_OPTIONAL
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001249 */
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001250 pjsua_sip_timer_use use_timer;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001251
1252 /**
Benny Prijonofe1bd342009-11-20 23:33:07 +00001253 * Handle unsolicited NOTIFY requests containing message waiting
1254 * indication (MWI) info. Unsolicited MWI is incoming NOTIFY requests
1255 * which are not requested by client with SUBSCRIBE request.
1256 *
1257 * If this is enabled, the library will respond 200/OK to the NOTIFY
1258 * request and forward the request to \a on_mwi_info() callback.
1259 *
1260 * See also \a mwi_enabled field #on pjsua_acc_config.
1261 *
1262 * Default: PJ_TRUE
1263 *
1264 */
1265 pj_bool_t enable_unsolicited_mwi;
1266
1267 /**
Nanang Izzuddin65add622009-08-11 16:26:20 +00001268 * Specify Session Timer settings, see #pjsip_timer_setting.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001269 * Note that this setting can be further customized in account
1270 * configuration (#pjsua_acc_config).
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001271 */
Nanang Izzuddin65add622009-08-11 16:26:20 +00001272 pjsip_timer_setting timer_setting;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001273
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001274 /**
1275 * Number of credentials in the credential array.
1276 */
1277 unsigned cred_count;
1278
1279 /**
1280 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +00001281 * and can be used to authenticate against outbound proxies. If the
1282 * credential is specific to the account, then application should set
1283 * the credential in the pjsua_acc_config rather than the credential
1284 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001285 */
1286 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1287
1288 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001289 * Application callback to receive various event notifications from
1290 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001291 */
1292 pjsua_callback cb;
1293
Benny Prijono56315612006-07-18 14:39:40 +00001294 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001295 * Optional user agent string (default empty). If it's empty, no
1296 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +00001297 */
1298 pj_str_t user_agent;
1299
Benny Prijonod8179652008-01-23 20:39:07 +00001300 /**
1301 * Specify default value of secure media transport usage.
1302 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
1303 * PJMEDIA_SRTP_MANDATORY.
1304 *
1305 * Note that this setting can be further customized in account
1306 * configuration (#pjsua_acc_config).
1307 *
1308 * Default: #PJSUA_DEFAULT_USE_SRTP
1309 */
1310 pjmedia_srtp_use use_srtp;
1311
1312 /**
1313 * Specify whether SRTP requires secure signaling to be used. This option
1314 * is only used when \a use_srtp option above is non-zero.
1315 *
1316 * Valid values are:
1317 * 0: SRTP does not require secure signaling
1318 * 1: SRTP requires secure transport such as TLS
1319 * 2: SRTP requires secure end-to-end transport (SIPS)
1320 *
1321 * Note that this setting can be further customized in account
1322 * configuration (#pjsua_acc_config).
1323 *
1324 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
1325 */
1326 int srtp_secure_signaling;
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00001327
1328 /**
Benny Prijono0bc99a92011-03-17 04:34:43 +00001329 * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00001330 * duplicated media in SDP offer, i.e: unsecured and secured version.
Benny Prijono0bc99a92011-03-17 04:34:43 +00001331 * Otherwise, the SDP media will be composed as unsecured media but
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00001332 * with SDP "crypto" attribute.
1333 *
1334 * Default: PJ_FALSE
1335 */
1336 pj_bool_t srtp_optional_dup_offer;
Benny Prijonod8179652008-01-23 20:39:07 +00001337
Benny Prijono3c5e28b2008-09-24 10:10:15 +00001338 /**
1339 * Disconnect other call legs when more than one 2xx responses for
1340 * outgoing INVITE are received due to forking. Currently the library
1341 * is not able to handle simultaneous forked media, so disconnecting
1342 * the other call legs is necessary.
1343 *
1344 * With this setting enabled, the library will handle only one of the
1345 * connected call leg, and the other connected call legs will be
1346 * disconnected.
1347 *
1348 * Default: PJ_TRUE (only disable this setting for testing purposes).
1349 */
1350 pj_bool_t hangup_forked_call;
1351
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001352} pjsua_config;
1353
1354
1355/**
1356 * Use this function to initialize pjsua config.
1357 *
1358 * @param cfg pjsua config to be initialized.
1359 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001360PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001361
1362
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001363/** The implementation has been moved to sip_auth.h */
Benny Prijono7977f9f2007-10-10 11:37:56 +00001364#define pjsip_cred_dup pjsip_cred_info_dup
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001365
1366
1367/**
1368 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001369 *
1370 * @param pool The pool to get memory from.
1371 * @param dst Destination config.
1372 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001373 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001374PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1375 pjsua_config *dst,
1376 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001377
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001378
1379/**
1380 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001381 * outgoing SIP message. It can (optionally) be specified for example
1382 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1383 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1384 *
1385 * Application MUST call #pjsua_msg_data_init() to initialize this
1386 * structure before setting its values.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001387 */
Benny Prijono63fba012008-07-17 14:19:10 +00001388struct pjsua_msg_data
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001389{
1390 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001391 * Additional message headers as linked list. Application can add
1392 * headers to the list by creating the header, either from the heap/pool
1393 * or from temporary local variable, and add the header using
1394 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001395 */
1396 pjsip_hdr hdr_list;
1397
1398 /**
1399 * MIME type of optional message body.
1400 */
1401 pj_str_t content_type;
1402
1403 /**
Benny Prijono1c1d7342010-08-01 09:48:51 +00001404 * Optional message body to be added to the message, only when the
1405 * message doesn't have a body.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001406 */
1407 pj_str_t msg_body;
1408
Benny Prijono1c1d7342010-08-01 09:48:51 +00001409 /**
1410 * Content type of the multipart body. If application wants to send
1411 * multipart message bodies, it puts the parts in \a parts and set
1412 * the content type in \a multipart_ctype. If the message already
1413 * contains a body, the body will be added to the multipart bodies.
1414 */
1415 pjsip_media_type multipart_ctype;
1416
1417 /**
1418 * List of multipart parts. If application wants to send multipart
1419 * message bodies, it puts the parts in \a parts and set the content
1420 * type in \a multipart_ctype. If the message already contains a body,
1421 * the body will be added to the multipart bodies.
1422 */
1423 pjsip_multipart_part multipart_parts;
Benny Prijono63fba012008-07-17 14:19:10 +00001424};
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001425
1426
1427/**
1428 * Initialize message data.
1429 *
1430 * @param msg_data Message data to be initialized.
1431 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001432PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001433
Benny Prijono268ca612006-02-07 12:34:11 +00001434
1435/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001436 * Instantiate pjsua application. Application must call this function before
1437 * calling any other functions, to make sure that the underlying libraries
1438 * are properly initialized. Once this function has returned success,
1439 * application must call pjsua_destroy() before quitting.
1440 *
1441 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00001442 */
1443PJ_DECL(pj_status_t) pjsua_create(void);
1444
1445
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001446/** Forward declaration */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001447typedef struct pjsua_media_config pjsua_media_config;
1448
1449
Benny Prijonodc39fe82006-05-26 12:17:46 +00001450/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001451 * Initialize pjsua with the specified settings. All the settings are
1452 * optional, and the default values will be used when the config is not
1453 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001454 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001455 * Note that #pjsua_create() MUST be called before calling this function.
1456 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001457 * @param ua_cfg User agent configuration.
1458 * @param log_cfg Optional logging configuration.
1459 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001460 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001461 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001462 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001463PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1464 const pjsua_logging_config *log_cfg,
1465 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001466
1467
1468/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001469 * Application is recommended to call this function after all initialization
1470 * is done, so that the library can do additional checking set up
1471 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001472 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001473 * Application may call this function anytime after #pjsua_init().
1474 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001475 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoccf95622006-02-07 18:48:01 +00001476 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001477PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001478
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001479
Benny Prijonoccf95622006-02-07 18:48:01 +00001480/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001481 * Destroy pjsua. Application is recommended to perform graceful shutdown
1482 * before calling this function (such as unregister the account from the SIP
1483 * server, terminate presense subscription, and hangup active calls), however,
1484 * this function will do all of these if it finds there are active sessions
1485 * that need to be terminated. This function will approximately block for
1486 * one second to wait for replies from remote.
1487 *
1488 * Application.may safely call this function more than once if it doesn't
1489 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001490 *
1491 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001492 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001493PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001494
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001495
Benny Prijono9fc735d2006-05-28 14:58:12 +00001496/**
Benny Prijono0bc99a92011-03-17 04:34:43 +00001497 * Retrieve pjsua state.
1498 *
1499 * @return pjsua state.
1500 */
1501PJ_DECL(pjsua_state) pjsua_get_state(void);
1502
1503
1504/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001505 * Poll pjsua for events, and if necessary block the caller thread for
1506 * the specified maximum interval (in miliseconds).
1507 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001508 * Application doesn't normally need to call this function if it has
1509 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1510 * because polling then will be done by these worker threads instead.
1511 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001512 * @param msec_timeout Maximum time to wait, in miliseconds.
1513 *
1514 * @return The number of events that have been handled during the
1515 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001516 * can retrieve the error as (status = -return_value).
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001517 */
1518PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1519
1520
1521/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001522 * Create memory pool to be used by the application. Once application
1523 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001524 *
1525 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001526 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001527 * @param increment Increment size.
1528 *
1529 * @return The pool, or NULL when there's no memory.
1530 */
1531PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1532 pj_size_t increment);
1533
1534
1535/**
1536 * Application can call this function at any time (after pjsua_create(), of
1537 * course) to change logging settings.
1538 *
1539 * @param c Logging configuration.
1540 *
1541 * @return PJ_SUCCESS on success, or the appropriate error code.
1542 */
1543PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1544
1545
1546/**
1547 * Internal function to get SIP endpoint instance of pjsua, which is
1548 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001549 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001550 *
1551 * @return SIP endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001552 */
1553PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1554
1555/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001556 * Internal function to get media endpoint instance.
1557 * Only valid after #pjsua_init() is called.
1558 *
1559 * @return Media endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001560 */
1561PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1562
Benny Prijono97b87172006-08-24 14:25:14 +00001563/**
1564 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001565 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001566 *
1567 * @return Pool factory currently used by PJSUA.
1568 */
1569PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1570
1571
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001572
1573/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001574 * Utilities.
1575 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001576 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001577
1578/**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001579 * This structure is used to represent the result of the STUN server
1580 * resolution and testing, the #pjsua_resolve_stun_servers() function.
1581 * This structure will be passed in #pj_stun_resolve_cb callback.
1582 */
1583typedef struct pj_stun_resolve_result
1584{
1585 /**
1586 * Arbitrary data that was passed to #pjsua_resolve_stun_servers()
1587 * function.
1588 */
1589 void *token;
1590
1591 /**
1592 * This will contain PJ_SUCCESS if at least one usable STUN server
1593 * is found, otherwise it will contain the last error code during
1594 * the operation.
1595 */
1596 pj_status_t status;
1597
1598 /**
1599 * The server name that yields successful result. This will only
1600 * contain value if status is successful.
1601 */
1602 pj_str_t name;
1603
1604 /**
1605 * The server IP address. This will only contain value if status
1606 * is successful.
1607 */
1608 pj_sockaddr addr;
1609
1610} pj_stun_resolve_result;
1611
1612
1613/**
1614 * Typedef of callback to be registered to #pjsua_resolve_stun_servers().
1615 */
1616typedef void (*pj_stun_resolve_cb)(const pj_stun_resolve_result *result);
1617
1618/**
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001619 * This is a utility function to detect NAT type in front of this
1620 * endpoint. Once invoked successfully, this function will complete
Benny Prijono6ba8c542007-10-16 01:34:14 +00001621 * asynchronously and report the result in \a on_nat_detect() callback
1622 * of pjsua_callback.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001623 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001624 * After NAT has been detected and the callback is called, application can
1625 * get the detected NAT type by calling #pjsua_get_nat_type(). Application
1626 * can also perform NAT detection by calling #pjsua_detect_nat_type()
1627 * again at later time.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001628 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001629 * Note that STUN must be enabled to run this function successfully.
1630 *
1631 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001632 */
Benny Prijono6ba8c542007-10-16 01:34:14 +00001633PJ_DECL(pj_status_t) pjsua_detect_nat_type(void);
1634
1635
1636/**
1637 * Get the NAT type as detected by #pjsua_detect_nat_type() function.
1638 * This function will only return useful NAT type after #pjsua_detect_nat_type()
1639 * has completed successfully and \a on_nat_detect() callback has been called.
1640 *
1641 * @param type NAT type.
1642 *
1643 * @return When detection is in progress, this function will
1644 * return PJ_EPENDING and \a type will be set to
1645 * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been
1646 * detected successfully, this function will return
1647 * PJ_SUCCESS and \a type will be set to the correct
1648 * value. Other return values indicate error and
1649 * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN.
Benny Prijono91a6a172007-10-31 08:59:29 +00001650 *
1651 * @see pjsua_call_get_rem_nat_type()
Benny Prijono6ba8c542007-10-16 01:34:14 +00001652 */
1653PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type);
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001654
1655
1656/**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001657 * Auxiliary function to resolve and contact each of the STUN server
1658 * entries (sequentially) to find which is usable. The #pjsua_init() must
1659 * have been called before calling this function.
1660 *
1661 * @param count Number of STUN server entries to try.
1662 * @param srv Array of STUN server entries to try. Please see
1663 * the \a stun_srv field in the #pjsua_config
1664 * documentation about the format of this entry.
1665 * @param wait Specify non-zero to make the function block until
1666 * it gets the result. In this case, the function
1667 * will block while the resolution is being done,
1668 * and the callback will be called before this function
1669 * returns.
1670 * @param token Arbitrary token to be passed back to application
1671 * in the callback.
1672 * @param cb Callback to be called to notify the result of
1673 * the function.
1674 *
1675 * @return If \a wait parameter is non-zero, this will return
1676 * PJ_SUCCESS if one usable STUN server is found.
1677 * Otherwise it will always return PJ_SUCCESS, and
1678 * application will be notified about the result in
1679 * the callback.
1680 */
1681PJ_DECL(pj_status_t) pjsua_resolve_stun_servers(unsigned count,
1682 pj_str_t srv[],
1683 pj_bool_t wait,
1684 void *token,
1685 pj_stun_resolve_cb cb);
1686
1687/**
1688 * Cancel pending STUN resolution which match the specified token.
1689 *
1690 * @param token The token to match. This token was given to
1691 * #pjsua_resolve_stun_servers()
1692 * @param notify_cb Boolean to control whether the callback should
1693 * be called for cancelled resolutions. When the
1694 * callback is called, the status in the result
1695 * will be set as PJ_ECANCELLED.
1696 *
1697 * @return PJ_SUCCESS if there is at least one pending STUN
1698 * resolution cancelled, or PJ_ENOTFOUND if there is
1699 * no matching one, or other error.
1700 */
1701PJ_DECL(pj_status_t) pjsua_cancel_stun_resolution(void *token,
1702 pj_bool_t notify_cb);
1703
1704
1705/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001706 * This is a utility function to verify that valid SIP url is given. If the
Benny Prijonoc7545782010-09-28 07:43:18 +00001707 * URL is a valid SIP/SIPS scheme, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001708 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001709 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001710 *
1711 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoc7545782010-09-28 07:43:18 +00001712 *
1713 * @see pjsua_verify_url()
Benny Prijono312aff92006-06-17 04:08:30 +00001714 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001715PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001716
1717
1718/**
Benny Prijonoc7545782010-09-28 07:43:18 +00001719 * This is a utility function to verify that valid URI is given. Unlike
1720 * pjsua_verify_sip_url(), this function will return PJ_SUCCESS if tel: URI
1721 * is given.
1722 *
1723 * @param url The URL, as NULL terminated string.
1724 *
1725 * @return PJ_SUCCESS on success, or the appropriate error code.
1726 *
1727 * @see pjsua_verify_sip_url()
1728 */
1729PJ_DECL(pj_status_t) pjsua_verify_url(const char *url);
1730
1731
1732/**
Benny Prijono73bb7232009-10-20 13:56:26 +00001733 * Schedule a timer entry. Note that the timer callback may be executed
1734 * by different thread, depending on whether worker thread is enabled or
1735 * not.
1736 *
1737 * @param entry Timer heap entry.
1738 * @param delay The interval to expire.
1739 *
1740 * @return PJ_SUCCESS on success, or the appropriate error code.
1741 *
1742 * @see pjsip_endpt_schedule_timer()
1743 */
1744PJ_DECL(pj_status_t) pjsua_schedule_timer(pj_timer_entry *entry,
1745 const pj_time_val *delay);
1746
1747
1748/**
1749 * Cancel the previously scheduled timer.
1750 *
1751 * @param entry Timer heap entry.
1752 *
1753 * @see pjsip_endpt_cancel_timer()
1754 */
1755PJ_DECL(void) pjsua_cancel_timer(pj_timer_entry *entry);
1756
1757
1758/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001759 * This is a utility function to display error message for the specified
1760 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001761 *
1762 * @param sender The log sender field.
1763 * @param title Message title for the error.
1764 * @param status Status code.
1765 */
1766PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1767 pj_status_t status);
1768
1769
Benny Prijonoda9785b2007-04-02 20:43:06 +00001770/**
1771 * This is a utility function to dump the stack states to log, using
1772 * verbosity level 3.
1773 *
1774 * @param detail Will print detailed output (such as list of
1775 * SIP transactions) when non-zero.
1776 */
1777PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001778
1779/**
1780 * @}
1781 */
1782
1783
1784
1785/*****************************************************************************
1786 * TRANSPORT API
1787 */
1788
1789/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001790 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001791 * @ingroup PJSUA_LIB
1792 * @brief API for managing SIP transports
1793 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001794 *
1795 * PJSUA-API supports creating multiple transport instances, for example UDP,
1796 * TCP, and TLS transport. SIP transport must be created before adding an
1797 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001798 */
1799
1800
Benny Prijonoe6ead542007-01-31 20:53:31 +00001801/** SIP transport identification.
1802 */
Benny Prijono312aff92006-06-17 04:08:30 +00001803typedef int pjsua_transport_id;
1804
1805
1806/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001807 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001808 * and media. Before setting some values to this structure, application
1809 * MUST call #pjsua_transport_config_default() to initialize its
1810 * values with default settings.
Benny Prijono312aff92006-06-17 04:08:30 +00001811 */
1812typedef struct pjsua_transport_config
1813{
1814 /**
1815 * UDP port number to bind locally. This setting MUST be specified
1816 * even when default port is desired. If the value is zero, the
1817 * transport will be bound to any available port, and application
1818 * can query the port by querying the transport info.
1819 */
1820 unsigned port;
1821
1822 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001823 * Optional address to advertise as the address of this transport.
1824 * Application can specify any address or hostname for this field,
1825 * for example it can point to one of the interface address in the
1826 * system, or it can point to the public address of a NAT router
1827 * where port mappings have been configured for the application.
1828 *
1829 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001830 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001831 pj_str_t public_addr;
1832
1833 /**
1834 * Optional address where the socket should be bound to. This option
1835 * SHOULD only be used to selectively bind the socket to particular
1836 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1837 * published address of a transport (the public_addr field should be
1838 * used for that purpose).
1839 *
1840 * Note that unlike public_addr field, the address (or hostname) here
1841 * MUST correspond to the actual interface address in the host, since
1842 * this address will be specified as bind() argument.
1843 */
1844 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001845
1846 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001847 * This specifies TLS settings for TLS transport. It is only be used
1848 * when this transport config is being used to create a SIP TLS
1849 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001850 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001851 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001852
Benny Prijono4d79b0f2009-10-25 09:02:07 +00001853 /**
1854 * QoS traffic type to be set on this transport. When application wants
1855 * to apply QoS tagging to the transport, it's preferable to set this
1856 * field rather than \a qos_param fields since this is more portable.
1857 *
1858 * Default is QoS not set.
1859 */
1860 pj_qos_type qos_type;
1861
1862 /**
1863 * Set the low level QoS parameters to the transport. This is a lower
1864 * level operation than setting the \a qos_type field and may not be
1865 * supported on all platforms.
1866 *
1867 * Default is QoS not set.
1868 */
1869 pj_qos_params qos_params;
1870
Benny Prijono312aff92006-06-17 04:08:30 +00001871} pjsua_transport_config;
1872
1873
1874/**
1875 * Call this function to initialize UDP config with default values.
1876 *
1877 * @param cfg The UDP config to be initialized.
1878 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001879PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001880
1881
1882/**
Benny Prijono312aff92006-06-17 04:08:30 +00001883 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001884 *
1885 * @param pool The pool.
1886 * @param dst The destination config.
1887 * @param src The source config.
Benny Prijono312aff92006-06-17 04:08:30 +00001888 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001889PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1890 pjsua_transport_config *dst,
1891 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001892
1893
1894/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001895 * This structure describes transport information returned by
1896 * #pjsua_transport_get_info() function.
Benny Prijono312aff92006-06-17 04:08:30 +00001897 */
1898typedef struct pjsua_transport_info
1899{
1900 /**
1901 * PJSUA transport identification.
1902 */
1903 pjsua_transport_id id;
1904
1905 /**
1906 * Transport type.
1907 */
1908 pjsip_transport_type_e type;
1909
1910 /**
1911 * Transport type name.
1912 */
1913 pj_str_t type_name;
1914
1915 /**
1916 * Transport string info/description.
1917 */
1918 pj_str_t info;
1919
1920 /**
1921 * Transport flag (see ##pjsip_transport_flags_e).
1922 */
1923 unsigned flag;
1924
1925 /**
1926 * Local address length.
1927 */
1928 unsigned addr_len;
1929
1930 /**
1931 * Local/bound address.
1932 */
1933 pj_sockaddr local_addr;
1934
1935 /**
1936 * Published address (or transport address name).
1937 */
1938 pjsip_host_port local_name;
1939
1940 /**
1941 * Current number of objects currently referencing this transport.
1942 */
1943 unsigned usage_count;
1944
1945
1946} pjsua_transport_info;
1947
1948
1949/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001950 * Create and start a new SIP transport according to the specified
1951 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001952 *
1953 * @param type Transport type.
1954 * @param cfg Transport configuration.
1955 * @param p_id Optional pointer to receive transport ID.
1956 *
1957 * @return PJ_SUCCESS on success, or the appropriate error code.
1958 */
1959PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1960 const pjsua_transport_config *cfg,
1961 pjsua_transport_id *p_id);
1962
1963/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001964 * Register transport that has been created by application. This function
1965 * is useful if application wants to implement custom SIP transport and use
1966 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001967 *
1968 * @param tp Transport instance.
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_register(pjsip_transport *tp,
1974 pjsua_transport_id *p_id);
1975
1976
1977/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001978 * Enumerate all transports currently created in the system. This function
1979 * will return all transport IDs, and application may then call
1980 * #pjsua_transport_get_info() function to retrieve detailed information
1981 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001982 *
1983 * @param id Array to receive transport ids.
1984 * @param count In input, specifies the maximum number of elements.
1985 * On return, it contains the actual number of elements.
1986 *
1987 * @return PJ_SUCCESS on success, or the appropriate error code.
1988 */
1989PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1990 unsigned *count );
1991
1992
1993/**
1994 * Get information about transports.
1995 *
1996 * @param id Transport ID.
1997 * @param info Pointer to receive transport info.
1998 *
1999 * @return PJ_SUCCESS on success, or the appropriate error code.
2000 */
2001PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
2002 pjsua_transport_info *info);
2003
2004
2005/**
2006 * Disable a transport or re-enable it. By default transport is always
2007 * enabled after it is created. Disabling a transport does not necessarily
2008 * close the socket, it will only discard incoming messages and prevent
2009 * the transport from being used to send outgoing messages.
2010 *
2011 * @param id Transport ID.
2012 * @param enabled Non-zero to enable, zero to disable.
2013 *
2014 * @return PJ_SUCCESS on success, or the appropriate error code.
2015 */
2016PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
2017 pj_bool_t enabled);
2018
2019
2020/**
2021 * Close the transport. If transport is forcefully closed, it will be
2022 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00002023 * transport may not terminate properly (it may even crash). Otherwise,
2024 * the system will wait until all transactions are closed while preventing
2025 * new users from using the transport, and will close the transport when
2026 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002027 *
2028 * @param id Transport ID.
2029 * @param force Non-zero to immediately close the transport. This
2030 * is not recommended!
2031 *
2032 * @return PJ_SUCCESS on success, or the appropriate error code.
2033 */
2034PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
2035 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00002036
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002037/**
Benny Prijono312aff92006-06-17 04:08:30 +00002038 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002039 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002040
2041
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002042
2043
2044/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00002045 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00002046 */
2047
Benny Prijono312aff92006-06-17 04:08:30 +00002048
2049/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002050 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00002051 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00002052 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00002053 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00002054 *
Benny Prijono312aff92006-06-17 04:08:30 +00002055 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00002056 * using the application. In SIP terms, the identity is used as the <b>From</b>
2057 * header in outgoing requests.
2058 *
2059 * PJSUA-API supports creating and managing multiple accounts. The maximum
2060 * number of accounts is limited by a compile time constant
2061 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002062 *
2063 * Account may or may not have client registration associated with it.
2064 * An account is also associated with <b>route set</b> and some <b>authentication
2065 * credentials</b>, which are used when sending SIP request messages using the
2066 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00002067 * will be reported to remote peer when they subscribe to the account's
2068 * presence, or which is published to a presence server if presence
2069 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00002070 *
2071 * At least one account MUST be created in the application. If no user
2072 * association is required, application can create a userless account by
2073 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00002074 * instead of a particular user, and it correspond with a particular
2075 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00002076 *
2077 * Also one account must be set as the <b>default account</b>, which is used as
2078 * the account to use when PJSUA fails to match a request with any other
2079 * accounts.
2080 *
2081 * When sending outgoing SIP requests (such as making calls or sending
2082 * instant messages), normally PJSUA requires the application to specify
2083 * which account to use for the request. If no account is specified,
2084 * PJSUA may be able to select the account by matching the destination
2085 * domain name, and fall back to default account when no match is found.
2086 */
2087
2088/**
2089 * Maximum accounts.
2090 */
2091#ifndef PJSUA_MAX_ACC
2092# define PJSUA_MAX_ACC 8
2093#endif
2094
2095
2096/**
2097 * Default registration interval.
2098 */
2099#ifndef PJSUA_REG_INTERVAL
Benny Prijonobddef2c2007-10-31 13:28:08 +00002100# define PJSUA_REG_INTERVAL 300
Benny Prijono312aff92006-06-17 04:08:30 +00002101#endif
2102
2103
2104/**
Benny Prijono384dab42009-10-14 01:58:04 +00002105 * Default maximum time to wait for account unregistration transactions to
2106 * complete during library shutdown sequence.
2107 *
2108 * Default: 4000 (4 seconds)
2109 */
2110#ifndef PJSUA_UNREG_TIMEOUT
2111# define PJSUA_UNREG_TIMEOUT 4000
2112#endif
2113
2114
2115/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002116 * Default PUBLISH expiration
2117 */
2118#ifndef PJSUA_PUBLISH_EXPIRATION
Benny Prijono53984d12009-04-28 22:19:49 +00002119# define PJSUA_PUBLISH_EXPIRATION PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002120#endif
2121
2122
2123/**
Benny Prijono093d3022006-09-24 00:07:11 +00002124 * Default account priority.
2125 */
2126#ifndef PJSUA_DEFAULT_ACC_PRIORITY
2127# define PJSUA_DEFAULT_ACC_PRIORITY 0
2128#endif
2129
2130
2131/**
Benny Prijono8058a622007-06-08 04:37:05 +00002132 * This macro specifies the URI scheme to use in Contact header
2133 * when secure transport such as TLS is used. Application can specify
2134 * either "sip" or "sips".
2135 */
2136#ifndef PJSUA_SECURE_SCHEME
Benny Prijono4c82c1e2008-10-16 08:14:51 +00002137# define PJSUA_SECURE_SCHEME "sip"
Benny Prijono8058a622007-06-08 04:37:05 +00002138#endif
2139
2140
2141/**
Benny Prijono534a9ba2009-10-13 14:01:59 +00002142 * Maximum time to wait for unpublication transaction(s) to complete
2143 * during shutdown process, before sending unregistration. The library
2144 * tries to wait for the unpublication (un-PUBLISH) to complete before
2145 * sending REGISTER request to unregister the account, during library
2146 * shutdown process. If the value is set too short, it is possible that
2147 * the unregistration is sent before unpublication completes, causing
2148 * unpublication request to fail.
2149 *
2150 * Default: 2000 (2 seconds)
2151 */
2152#ifndef PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
2153# define PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC 2000
2154#endif
2155
2156
2157/**
Nanang Izzuddin36dd5b62010-03-30 11:13:59 +00002158 * Default auto retry re-registration interval, in seconds. Set to 0
2159 * to disable this. Application can set the timer on per account basis
2160 * by setting the pjsua_acc_config.reg_retry_interval field instead.
2161 *
2162 * Default: 300 (5 minutes)
2163 */
2164#ifndef PJSUA_REG_RETRY_INTERVAL
2165# define PJSUA_REG_RETRY_INTERVAL 300
2166#endif
2167
2168
2169/**
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00002170 * This macro specifies the default value for \a contact_rewrite_method
2171 * field in pjsua_acc_config. I specifies how Contact update will be
2172 * done with the registration, if \a allow_contact_rewrite is enabled in
2173 * the account config.
2174 *
2175 * If set to 1, the Contact update will be done by sending unregistration
2176 * to the currently registered Contact, while simultaneously sending new
2177 * registration (with different Call-ID) for the updated Contact.
2178 *
2179 * If set to 2, the Contact update will be done in a single, current
2180 * registration session, by removing the current binding (by setting its
2181 * Contact's expires parameter to zero) and adding a new Contact binding,
2182 * all done in a single request.
2183 *
2184 * Value 1 is the legacy behavior.
2185 *
2186 * Default value: 2
2187 */
2188#ifndef PJSUA_CONTACT_REWRITE_METHOD
2189# define PJSUA_CONTACT_REWRITE_METHOD 2
2190#endif
2191
2192
2193/**
Benny Prijono29c8ca32010-06-22 06:02:13 +00002194 * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that
2195 * the global outbound proxy list should be added to the REGISTER request.
2196 */
2197#define PJSUA_REG_USE_OUTBOUND_PROXY 1
2198
2199
2200/**
2201 * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that
2202 * the account proxy list should be added to the REGISTER request.
2203 */
2204#define PJSUA_REG_USE_ACC_PROXY 2
2205
2206
2207/**
Benny Prijonodd63b992010-10-01 02:03:42 +00002208 * This enumeration specifies how we should offer call hold request to
2209 * remote peer. The default value is set by compile time constant
2210 * PJSUA_CALL_HOLD_TYPE_DEFAULT, and application may control the setting
2211 * on per-account basis by manipulating \a call_hold_type field in
2212 * #pjsua_acc_config.
2213 */
2214typedef enum pjsua_call_hold_type
2215{
2216 /**
2217 * This will follow RFC 3264 recommendation to use a=sendonly,
2218 * a=recvonly, and a=inactive attribute as means to signal call
2219 * hold status. This is the correct value to use.
2220 */
2221 PJSUA_CALL_HOLD_TYPE_RFC3264,
2222
2223 /**
2224 * This will use the old and deprecated method as specified in RFC 2543,
2225 * and will offer c=0.0.0.0 in the SDP instead. Using this has many
2226 * drawbacks such as inability to keep the media transport alive while
2227 * the call is being put on hold, and should only be used if remote
2228 * does not understand RFC 3264 style call hold offer.
2229 */
2230 PJSUA_CALL_HOLD_TYPE_RFC2543
2231
2232} pjsua_call_hold_type;
2233
2234
2235/**
2236 * Specify the default call hold type to be used in #pjsua_acc_config.
2237 *
2238 * Default is PJSUA_CALL_HOLD_TYPE_RFC3264, and there's no reason to change
2239 * this except if you're communicating with an old/non-standard peer.
2240 */
2241#ifndef PJSUA_CALL_HOLD_TYPE_DEFAULT
2242# define PJSUA_CALL_HOLD_TYPE_DEFAULT PJSUA_CALL_HOLD_TYPE_RFC3264
2243#endif
2244
Benny Prijonodd63b992010-10-01 02:03:42 +00002245/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002246 * This structure describes account configuration to be specified when
2247 * adding a new account with #pjsua_acc_add(). Application MUST initialize
2248 * this structure first by calling #pjsua_acc_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00002249 */
2250typedef struct pjsua_acc_config
2251{
Benny Prijono093d3022006-09-24 00:07:11 +00002252 /**
Benny Prijono705e7842008-07-21 18:12:51 +00002253 * Arbitrary user data to be associated with the newly created account.
2254 * Application may set this later with #pjsua_acc_set_user_data() and
2255 * retrieve it with #pjsua_acc_get_user_data().
2256 */
2257 void *user_data;
2258
2259 /**
Benny Prijono093d3022006-09-24 00:07:11 +00002260 * Account priority, which is used to control the order of matching
2261 * incoming/outgoing requests. The higher the number means the higher
2262 * the priority is, and the account will be matched first.
2263 */
2264 int priority;
2265
Benny Prijono312aff92006-06-17 04:08:30 +00002266 /**
2267 * The full SIP URL for the account. The value can take name address or
2268 * URL format, and will look something like "sip:account@serviceprovider".
2269 *
2270 * This field is mandatory.
2271 */
2272 pj_str_t id;
2273
2274 /**
2275 * This is the URL to be put in the request URI for the registration,
2276 * and will look something like "sip:serviceprovider".
2277 *
2278 * This field should be specified if registration is desired. If the
2279 * value is empty, no account registration will be performed.
2280 */
2281 pj_str_t reg_uri;
2282
Nanang Izzuddin60e8aa92010-09-28 10:48:48 +00002283 /**
2284 * The optional custom SIP headers to be put in the registration
2285 * request.
2286 */
2287 pjsip_hdr reg_hdr_list;
2288
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002289 /**
Benny Prijonofe1bd342009-11-20 23:33:07 +00002290 * Subscribe to message waiting indication events (RFC 3842).
2291 *
2292 * See also \a enable_unsolicited_mwi field on #pjsua_config.
Benny Prijono4dd961b2009-10-26 11:21:37 +00002293 *
2294 * Default: no
2295 */
2296 pj_bool_t mwi_enabled;
2297
2298 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002299 * If this flag is set, the presence information of this account will
2300 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono48ab2b72007-11-08 09:24:30 +00002301 *
2302 * Default: PJ_FALSE
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002303 */
2304 pj_bool_t publish_enabled;
2305
Benny Prijonofe04fb52007-08-24 08:28:52 +00002306 /**
Benny Prijonofe50c9e2009-10-12 07:44:14 +00002307 * Event publication options.
2308 */
2309 pjsip_publishc_opt publish_opt;
2310
2311 /**
Benny Prijono534a9ba2009-10-13 14:01:59 +00002312 * Maximum time to wait for unpublication transaction(s) to complete
2313 * during shutdown process, before sending unregistration. The library
2314 * tries to wait for the unpublication (un-PUBLISH) to complete before
2315 * sending REGISTER request to unregister the account, during library
2316 * shutdown process. If the value is set too short, it is possible that
2317 * the unregistration is sent before unpublication completes, causing
2318 * unpublication request to fail.
2319 *
2320 * Default: PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
2321 */
2322 unsigned unpublish_max_wait_time_msec;
2323
2324 /**
Benny Prijono48ab2b72007-11-08 09:24:30 +00002325 * Authentication preference.
2326 */
2327 pjsip_auth_clt_pref auth_pref;
2328
2329 /**
Benny Prijonofe04fb52007-08-24 08:28:52 +00002330 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
2331 * is not specified, a random string will be used.
2332 */
2333 pj_str_t pidf_tuple_id;
2334
Benny Prijono312aff92006-06-17 04:08:30 +00002335 /**
2336 * Optional URI to be put as Contact for this account. It is recommended
2337 * that this field is left empty, so that the value will be calculated
2338 * automatically based on the transport address.
2339 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00002340 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00002341
2342 /**
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00002343 * Additional parameters that will be appended in the Contact header
Benny Prijono30fe4852008-12-10 16:54:16 +00002344 * for this account. This will affect the Contact header in all SIP
2345 * messages sent on behalf of this account, including but not limited to
2346 * REGISTER, INVITE, and SUBCRIBE requests or responses.
2347 *
2348 * The parameters should be preceeded by semicolon, and all strings must
2349 * be properly escaped. Example:
2350 * ";my-param=X;another-param=Hi%20there"
2351 */
2352 pj_str_t contact_params;
2353
2354 /**
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00002355 * Additional URI parameters that will be appended in the Contact URI
2356 * for this account. This will affect the Contact URI in all SIP
2357 * messages sent on behalf of this account, including but not limited to
2358 * REGISTER, INVITE, and SUBCRIBE requests or responses.
2359 *
2360 * The parameters should be preceeded by semicolon, and all strings must
2361 * be properly escaped. Example:
2362 * ";my-param=X;another-param=Hi%20there"
2363 */
2364 pj_str_t contact_uri_params;
2365
2366 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00002367 * Specify whether support for reliable provisional response (100rel and
2368 * PRACK) should be required for all sessions of this account.
2369 *
2370 * Default: PJ_FALSE
2371 */
2372 pj_bool_t require_100rel;
2373
2374 /**
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002375 * Specify the usage of Session Timers for all sessions. See the
2376 * #pjsua_sip_timer_use for possible values.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002377 *
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002378 * Default: PJSUA_SIP_TIMER_OPTIONAL
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002379 */
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002380 pjsua_sip_timer_use use_timer;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002381
2382 /**
Nanang Izzuddin65add622009-08-11 16:26:20 +00002383 * Specify Session Timer settings, see #pjsip_timer_setting.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002384 */
Nanang Izzuddin65add622009-08-11 16:26:20 +00002385 pjsip_timer_setting timer_setting;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002386
2387 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002388 * Number of proxies in the proxy array below.
2389 */
2390 unsigned proxy_cnt;
2391
2392 /**
2393 * Optional URI of the proxies to be visited for all outgoing requests
2394 * that are using this account (REGISTER, INVITE, etc). Application need
2395 * to specify these proxies if the service provider requires that requests
2396 * destined towards its network should go through certain proxies first
2397 * (for example, border controllers).
2398 *
2399 * These proxies will be put in the route set for this account, with
2400 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00002401 * first). If global outbound proxies are configured in pjsua_config,
2402 * then these account proxies will be placed after the global outbound
2403 * proxies in the routeset.
Benny Prijono312aff92006-06-17 04:08:30 +00002404 */
2405 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
2406
2407 /**
2408 * Optional interval for registration, in seconds. If the value is zero,
Benny Prijonobddef2c2007-10-31 13:28:08 +00002409 * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
Benny Prijono312aff92006-06-17 04:08:30 +00002410 */
2411 unsigned reg_timeout;
2412
Benny Prijono384dab42009-10-14 01:58:04 +00002413 /**
2414 * Specify the maximum time to wait for unregistration requests to
2415 * complete during library shutdown sequence.
2416 *
2417 * Default: PJSUA_UNREG_TIMEOUT
2418 */
2419 unsigned unreg_timeout;
2420
Benny Prijono312aff92006-06-17 04:08:30 +00002421 /**
2422 * Number of credentials in the credential array.
2423 */
2424 unsigned cred_count;
2425
2426 /**
2427 * Array of credentials. If registration is desired, normally there should
2428 * be at least one credential specified, to successfully authenticate
2429 * against the service provider. More credentials can be specified, for
2430 * example when the requests are expected to be challenged by the
2431 * proxies in the route set.
2432 */
2433 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
2434
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002435 /**
2436 * Optionally bind this account to specific transport. This normally is
2437 * not a good idea, as account should be able to send requests using
2438 * any available transports according to the destination. But some
2439 * application may want to have explicit control over the transport to
2440 * use, so in that case it can set this field.
2441 *
2442 * Default: -1 (PJSUA_INVALID_ID)
2443 *
2444 * @see pjsua_acc_set_transport()
2445 */
2446 pjsua_transport_id transport_id;
2447
Benny Prijono15b02302007-09-27 14:07:07 +00002448 /**
Benny Prijonocca2e432010-02-25 09:33:18 +00002449 * This option is used to update the transport address and the Contact
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002450 * header of REGISTER request. When this option is enabled, the library
2451 * will keep track of the public IP address from the response of REGISTER
2452 * request. Once it detects that the address has changed, it will
2453 * unregister current Contact, update the Contact with transport address
2454 * learned from Via header, and register a new Contact to the registrar.
2455 * This will also update the public name of UDP transport if STUN is
Benny Prijonocca2e432010-02-25 09:33:18 +00002456 * configured.
Benny Prijono15b02302007-09-27 14:07:07 +00002457 *
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00002458 * See also contact_rewrite_method field.
2459 *
Benny Prijono15b02302007-09-27 14:07:07 +00002460 * Default: 1 (yes)
2461 */
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002462 pj_bool_t allow_contact_rewrite;
Benny Prijono15b02302007-09-27 14:07:07 +00002463
Benny Prijonobddef2c2007-10-31 13:28:08 +00002464 /**
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00002465 * Specify how Contact update will be done with the registration, if
2466 * \a allow_contact_rewrite is enabled.
2467 *
2468 * If set to 1, the Contact update will be done by sending unregistration
2469 * to the currently registered Contact, while simultaneously sending new
2470 * registration (with different Call-ID) for the updated Contact.
2471 *
2472 * If set to 2, the Contact update will be done in a single, current
2473 * registration session, by removing the current binding (by setting its
2474 * Contact's expires parameter to zero) and adding a new Contact binding,
2475 * all done in a single request.
2476 *
2477 * Value 1 is the legacy behavior.
2478 *
2479 * Default value: PJSUA_CONTACT_REWRITE_METHOD (2)
2480 */
2481 int contact_rewrite_method;
2482
2483 /**
Benny Prijonob54719f2010-11-16 03:07:46 +00002484 * Control the use of SIP outbound feature. SIP outbound is described in
2485 * RFC 5626 to enable proxies or registrar to send inbound requests back
2486 * to UA using the same connection initiated by the UA for its
2487 * registration. This feature is highly useful in NAT-ed deployemtns,
2488 * hence it is enabled by default.
2489 *
2490 * Note: currently SIP outbound can only be used with TCP and TLS
2491 * transports. If UDP is used for the registration, the SIP outbound
2492 * feature will be silently ignored for the account.
2493 *
2494 * Default: PJ_TRUE
2495 */
2496 unsigned use_rfc5626;
2497
2498 /**
2499 * Specify SIP outbound (RFC 5626) instance ID to be used by this
2500 * application. If empty, an instance ID will be generated based on
2501 * the hostname of this agent. If application specifies this parameter, the
2502 * value will look like "<urn:uuid:00000000-0000-1000-8000-AABBCCDDEEFF>"
2503 * without the doublequote.
2504 *
2505 * Default: empty
2506 */
2507 pj_str_t rfc5626_instance_id;
2508
2509 /**
2510 * Specify SIP outbound (RFC 5626) registration ID. The default value
2511 * is empty, which would cause the library to automatically generate
2512 * a suitable value.
2513 *
2514 * Default: empty
2515 */
2516 pj_str_t rfc5626_reg_id;
2517
2518 /**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002519 * Set the interval for periodic keep-alive transmission for this account.
2520 * If this value is zero, keep-alive will be disabled for this account.
2521 * The keep-alive transmission will be sent to the registrar's address,
2522 * after successful registration.
2523 *
Benny Prijonobddef2c2007-10-31 13:28:08 +00002524 * Default: 15 (seconds)
2525 */
2526 unsigned ka_interval;
2527
2528 /**
2529 * Specify the data to be transmitted as keep-alive packets.
2530 *
2531 * Default: CR-LF
2532 */
2533 pj_str_t ka_data;
2534
Benny Prijono0bc99a92011-03-17 04:34:43 +00002535 /**
2536 * Maximum number of simultaneous active audio streams to be allowed
2537 * for calls on this account. Setting this to zero will disable audio
2538 * in calls on this account.
2539 *
2540 * Default: 1
2541 */
2542 unsigned max_audio_cnt;
2543
2544 /**
2545 * Maximum number of simultaneous active video streams to be allowed
2546 * for calls on this account. Setting this to zero will disable video
Benny Prijono9f468d12011-07-07 07:46:33 +00002547 * in calls on this account, regardless of other video settings.
Benny Prijono0bc99a92011-03-17 04:34:43 +00002548 *
Benny Prijono9f468d12011-07-07 07:46:33 +00002549 * Default: 1
Benny Prijono0bc99a92011-03-17 04:34:43 +00002550 */
2551 unsigned max_video_cnt;
2552
2553 /**
Benny Prijono9f468d12011-07-07 07:46:33 +00002554 * Specify whether incoming video should be shown to screen by default.
2555 * This applies to incoming call (INVITE), incoming re-INVITE, and
2556 * incoming UPDATE requests.
2557 *
2558 * Regardless of this setting, application can detect incoming video
2559 * by implementing \a on_call_media_state() callback and enumerating
2560 * the media stream(s) with #pjsua_call_get_info(). Once incoming
2561 * video is recognised, application may retrieve the window associated
2562 * with the incoming video and show or hide it with
2563 * #pjsua_vid_win_set_show().
2564 *
2565 * Default: PJ_FALSE
2566 */
2567 pj_bool_t vid_in_auto_show;
2568
2569 /**
2570 * Specify whether outgoing video should be activated by default when
2571 * making outgoing calls and/or when incoming video is detected. This
2572 * applies to incoming and outgoing calls, incoming re-INVITE, and
2573 * incoming UPDATE. If the setting is non-zero, outgoing video
2574 * transmission will be started as soon as response to these requests
2575 * is sent (or received).
2576 *
2577 * Regardless of the value of this setting, application can start and
2578 * stop outgoing video transmission with #pjsua_call_set_vid_out().
2579 *
2580 * Default: PJ_FALSE
2581 */
2582 pj_bool_t vid_out_auto_transmit;
2583
2584 /**
2585 * Specify the default capture device to be used by this account. If
2586 * \a vid_out_auto_transmit is enabled, this device will be used for
2587 * capturing video.
2588 *
2589 * Default: PJMEDIA_VID_DEFAULT_CAPTURE_DEV
2590 */
2591 pjmedia_vid_dev_index vid_cap_dev;
2592
2593 /**
2594 * Specify the default rendering device to be used by this account.
2595 *
2596 * Default: PJMEDIA_VID_DEFAULT_RENDER_DEV
2597 */
2598 pjmedia_vid_dev_index vid_rend_dev;
2599
2600 /**
Benny Prijono0bc99a92011-03-17 04:34:43 +00002601 * Media transport config.
2602 */
2603 pjsua_transport_config rtp_cfg;
2604
Benny Prijonod8179652008-01-23 20:39:07 +00002605 /**
2606 * Specify whether secure media transport should be used for this account.
2607 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
2608 * PJMEDIA_SRTP_MANDATORY.
2609 *
2610 * Default: #PJSUA_DEFAULT_USE_SRTP
2611 */
2612 pjmedia_srtp_use use_srtp;
2613
2614 /**
2615 * Specify whether SRTP requires secure signaling to be used. This option
2616 * is only used when \a use_srtp option above is non-zero.
2617 *
2618 * Valid values are:
2619 * 0: SRTP does not require secure signaling
2620 * 1: SRTP requires secure transport such as TLS
2621 * 2: SRTP requires secure end-to-end transport (SIPS)
2622 *
2623 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
2624 */
2625 int srtp_secure_signaling;
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00002626
2627 /**
Benny Prijono0bc99a92011-03-17 04:34:43 +00002628 * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00002629 * duplicated media in SDP offer, i.e: unsecured and secured version.
Benny Prijono0bc99a92011-03-17 04:34:43 +00002630 * Otherwise, the SDP media will be composed as unsecured media but
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00002631 * with SDP "crypto" attribute.
2632 *
2633 * Default: PJ_FALSE
2634 */
2635 pj_bool_t srtp_optional_dup_offer;
Benny Prijonod8179652008-01-23 20:39:07 +00002636
Nanang Izzuddin36dd5b62010-03-30 11:13:59 +00002637 /**
2638 * Specify interval of auto registration retry upon registration failure
2639 * (including caused by transport problem), in second. Set to 0 to
2640 * disable auto re-registration.
2641 *
2642 * Default: #PJSUA_REG_RETRY_INTERVAL
2643 */
2644 unsigned reg_retry_interval;
2645
2646 /**
2647 * Specify whether calls of the configured account should be dropped
2648 * after registration failure and an attempt of re-registration has
2649 * also failed.
2650 *
2651 * Default: PJ_FALSE (disabled)
2652 */
2653 pj_bool_t drop_calls_on_reg_fail;
2654
Benny Prijono29c8ca32010-06-22 06:02:13 +00002655 /**
2656 * Specify how the registration uses the outbound and account proxy
2657 * settings. This controls if and what Route headers will appear in
2658 * the REGISTER request of this account. The value is bitmask combination
2659 * of PJSUA_REG_USE_OUTBOUND_PROXY and PJSUA_REG_USE_ACC_PROXY bits.
2660 * If the value is set to 0, the REGISTER request will not use any proxy
2661 * (i.e. it will not have any Route headers).
2662 *
2663 * Default: 3 (PJSUA_REG_USE_OUTBOUND_PROXY | PJSUA_REG_USE_ACC_PROXY)
2664 */
2665 unsigned reg_use_proxy;
2666
Nanang Izzuddin5e39a2b2010-09-20 06:13:02 +00002667#if defined(PJMEDIA_STREAM_ENABLE_KA) && (PJMEDIA_STREAM_ENABLE_KA != 0)
2668 /**
2669 * Specify whether stream keep-alive and NAT hole punching with
2670 * non-codec-VAD mechanism (see @ref PJMEDIA_STREAM_ENABLE_KA) is enabled
2671 * for this account.
2672 *
2673 * Default: PJ_FALSE (disabled)
2674 */
2675 pj_bool_t use_stream_ka;
2676#endif
2677
Benny Prijonodd63b992010-10-01 02:03:42 +00002678 /**
2679 * Specify how to offer call hold to remote peer. Please see the
2680 * documentation on #pjsua_call_hold_type for more info.
2681 *
2682 * Default: PJSUA_CALL_HOLD_TYPE_DEFAULT
2683 */
2684 pjsua_call_hold_type call_hold_type;
2685
Benny Prijono312aff92006-06-17 04:08:30 +00002686} pjsua_acc_config;
2687
2688
2689/**
2690 * Call this function to initialize account config with default values.
2691 *
2692 * @param cfg The account config to be initialized.
2693 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00002694PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002695
2696
2697/**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002698 * Duplicate account config.
2699 *
2700 * @param pool Pool to be used for duplicating the config.
2701 * @param dst Destination configuration.
2702 * @param src Source configuration.
2703 */
2704PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
2705 pjsua_acc_config *dst,
2706 const pjsua_acc_config *src);
2707
2708
2709/**
Benny Prijono312aff92006-06-17 04:08:30 +00002710 * Account info. Application can query account info by calling
2711 * #pjsua_acc_get_info().
2712 */
2713typedef struct pjsua_acc_info
2714{
2715 /**
2716 * The account ID.
2717 */
2718 pjsua_acc_id id;
2719
2720 /**
2721 * Flag to indicate whether this is the default account.
2722 */
2723 pj_bool_t is_default;
2724
2725 /**
2726 * Account URI
2727 */
2728 pj_str_t acc_uri;
2729
2730 /**
2731 * Flag to tell whether this account has registration setting
2732 * (reg_uri is not empty).
2733 */
2734 pj_bool_t has_registration;
2735
2736 /**
2737 * An up to date expiration interval for account registration session.
2738 */
2739 int expires;
2740
2741 /**
2742 * Last registration status code. If status code is zero, the account
2743 * is currently not registered. Any other value indicates the SIP
2744 * status code of the registration.
2745 */
2746 pjsip_status_code status;
2747
2748 /**
Sauw Ming48f6dbf2010-09-07 05:10:25 +00002749 * Last registration error code. When the status field contains a SIP
2750 * status code that indicates a registration failure, last registration
2751 * error code contains the error code that causes the failure. In any
2752 * other case, its value is zero.
2753 */
2754 pj_status_t reg_last_err;
2755
2756 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002757 * String describing the registration status.
2758 */
2759 pj_str_t status_text;
2760
2761 /**
2762 * Presence online status for this account.
2763 */
2764 pj_bool_t online_status;
2765
2766 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00002767 * Presence online status text.
2768 */
2769 pj_str_t online_status_text;
2770
2771 /**
2772 * Extended RPID online status information.
2773 */
2774 pjrpid_element rpid;
2775
2776 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002777 * Buffer that is used internally to store the status text.
2778 */
2779 char buf_[PJ_ERR_MSG_SIZE];
2780
2781} pjsua_acc_info;
2782
2783
2784
2785/**
2786 * Get number of current accounts.
2787 *
2788 * @return Current number of accounts.
2789 */
2790PJ_DECL(unsigned) pjsua_acc_get_count(void);
2791
2792
2793/**
2794 * Check if the specified account ID is valid.
2795 *
2796 * @param acc_id Account ID to check.
2797 *
2798 * @return Non-zero if account ID is valid.
2799 */
2800PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
2801
2802
2803/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00002804 * Set default account to be used when incoming and outgoing
2805 * requests doesn't match any accounts.
2806 *
2807 * @param acc_id The account ID to be used as default.
2808 *
2809 * @return PJ_SUCCESS on success.
2810 */
2811PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2812
2813
2814/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002815 * Get default account to be used when receiving incoming requests (calls),
2816 * when the destination of the incoming call doesn't match any other
2817 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002818 *
2819 * @return The default account ID, or PJSUA_INVALID_ID if no
2820 * default account is configured.
2821 */
2822PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2823
2824
2825/**
Benny Prijono312aff92006-06-17 04:08:30 +00002826 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002827 * #pjsua_init()) before calling this function. If registration is configured
2828 * for this account, this function would also start the SIP registration
2829 * session with the SIP registrar server. This SIP registration session
2830 * will be maintained internally by the library, and application doesn't
2831 * need to do anything to maintain the registration session.
2832 *
Benny Prijono312aff92006-06-17 04:08:30 +00002833 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002834 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002835 * @param is_default If non-zero, this account will be set as the default
2836 * account. The default account will be used when sending
2837 * outgoing requests (e.g. making call) when no account is
2838 * specified, and when receiving incoming requests when the
2839 * request does not match any accounts. It is recommended
2840 * that default account is set to local/LAN account.
2841 * @param p_acc_id Pointer to receive account ID of the new account.
2842 *
2843 * @return PJ_SUCCESS on success, or the appropriate error code.
2844 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002845PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002846 pj_bool_t is_default,
2847 pjsua_acc_id *p_acc_id);
2848
2849
2850/**
2851 * Add a local account. A local account is used to identify local endpoint
2852 * instead of a specific user, and for this reason, a transport ID is needed
2853 * to obtain the local address information.
2854 *
2855 * @param tid Transport ID to generate account address.
2856 * @param is_default If non-zero, this account will be set as the default
2857 * account. The default account will be used when sending
2858 * outgoing requests (e.g. making call) when no account is
2859 * specified, and when receiving incoming requests when the
2860 * request does not match any accounts. It is recommended
2861 * that default account is set to local/LAN account.
2862 * @param p_acc_id Pointer to receive account ID of the new account.
2863 *
2864 * @return PJ_SUCCESS on success, or the appropriate error code.
2865 */
2866PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2867 pj_bool_t is_default,
2868 pjsua_acc_id *p_acc_id);
2869
2870/**
Benny Prijono705e7842008-07-21 18:12:51 +00002871 * Set arbitrary data to be associated with the account.
2872 *
2873 * @param acc_id The account ID.
2874 * @param user_data User/application data.
2875 *
2876 * @return PJ_SUCCESS on success, or the appropriate error code.
2877 */
2878PJ_DECL(pj_status_t) pjsua_acc_set_user_data(pjsua_acc_id acc_id,
2879 void *user_data);
2880
2881
2882/**
2883 * Retrieve arbitrary data associated with the account.
2884 *
2885 * @param acc_id The account ID.
2886 *
2887 * @return The user data. In the case where the account ID is
2888 * not valid, NULL is returned.
2889 */
2890PJ_DECL(void*) pjsua_acc_get_user_data(pjsua_acc_id acc_id);
2891
2892
2893/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002894 * Delete an account. This will unregister the account from the SIP server,
2895 * if necessary, and terminate server side presence subscriptions associated
2896 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002897 *
2898 * @param acc_id Id of the account to be deleted.
2899 *
2900 * @return PJ_SUCCESS on success, or the appropriate error code.
2901 */
2902PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2903
2904
2905/**
2906 * Modify account information.
2907 *
2908 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002909 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002910 *
2911 * @return PJ_SUCCESS on success, or the appropriate error code.
2912 */
2913PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002914 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002915
2916
2917/**
2918 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002919 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002920 * if there are server side presence subscription for this account, and/or
2921 * outgoing PUBLISH if presence publication is enabled for this account.
2922 *
2923 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002924 *
2925 * @param acc_id The account ID.
2926 * @param is_online True of false.
2927 *
2928 * @return PJ_SUCCESS on success, or the appropriate error code.
2929 */
2930PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2931 pj_bool_t is_online);
2932
Benny Prijono4461c7d2007-08-25 13:36:15 +00002933/**
2934 * Modify account's presence status to be advertised to remote/presence
2935 * subscribers. This would trigger the sending of outgoing NOTIFY request
2936 * if there are server side presence subscription for this account, and/or
2937 * outgoing PUBLISH if presence publication is enabled for this account.
2938 *
2939 * @see pjsua_acc_set_online_status()
2940 *
2941 * @param acc_id The account ID.
2942 * @param is_online True of false.
2943 * @param pr Extended information in subset of RPID format
2944 * which allows setting custom presence text.
2945 *
2946 * @return PJ_SUCCESS on success, or the appropriate error code.
2947 */
2948PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2949 pj_bool_t is_online,
2950 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002951
2952/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002953 * Update registration or perform unregistration. If registration is
2954 * configured for this account, then initial SIP REGISTER will be sent
2955 * when the account is added with #pjsua_acc_add(). Application normally
2956 * only need to call this function if it wants to manually update the
2957 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002958 *
2959 * @param acc_id The account ID.
2960 * @param renew If renew argument is zero, this will start
2961 * unregistration process.
2962 *
2963 * @return PJ_SUCCESS on success, or the appropriate error code.
2964 */
2965PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2966 pj_bool_t renew);
2967
Benny Prijono312aff92006-06-17 04:08:30 +00002968/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002969 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002970 *
2971 * @param acc_id Account identification.
2972 * @param info Pointer to receive account information.
2973 *
2974 * @return PJ_SUCCESS on success, or the appropriate error code.
2975 */
2976PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2977 pjsua_acc_info *info);
2978
2979
2980/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002981 * Enumerate all account currently active in the library. This will fill
2982 * the array with the account Ids, and application can then query the
2983 * account information for each id with #pjsua_acc_get_info().
2984 *
2985 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002986 *
2987 * @param ids Array of account IDs to be initialized.
2988 * @param count In input, specifies the maximum number of elements.
2989 * On return, it contains the actual number of elements.
2990 *
2991 * @return PJ_SUCCESS on success, or the appropriate error code.
2992 */
2993PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2994 unsigned *count );
2995
2996
2997/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002998 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002999 *
3000 * @param info Array of account infos to be initialized.
3001 * @param count In input, specifies the maximum number of elements.
3002 * On return, it contains the actual number of elements.
3003 *
3004 * @return PJ_SUCCESS on success, or the appropriate error code.
3005 */
3006PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
3007 unsigned *count );
3008
3009
3010/**
3011 * This is an internal function to find the most appropriate account to
3012 * used to reach to the specified URL.
3013 *
3014 * @param url The remote URL to reach.
3015 *
3016 * @return Account id.
3017 */
3018PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
3019
3020
3021/**
3022 * This is an internal function to find the most appropriate account to be
3023 * used to handle incoming calls.
3024 *
3025 * @param rdata The incoming request message.
3026 *
3027 * @return Account id.
3028 */
3029PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
3030
3031
Benny Prijonoc570f2d2006-07-18 00:33:02 +00003032/**
Benny Prijonofff245c2007-04-02 11:44:47 +00003033 * Create arbitrary requests using the account. Application should only use
3034 * this function to create auxiliary requests outside dialog, such as
3035 * OPTIONS, and use the call or presence API to create dialog related
3036 * requests.
3037 *
3038 * @param acc_id The account ID.
3039 * @param method The SIP method of the request.
3040 * @param target Target URI.
3041 * @param p_tdata Pointer to receive the request.
3042 *
3043 * @return PJ_SUCCESS or the error code.
3044 */
3045PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
3046 const pjsip_method *method,
3047 const pj_str_t *target,
3048 pjsip_tx_data **p_tdata);
3049
3050
3051/**
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00003052 * Create a suitable Contact header value, based on the specified target URI
3053 * for the specified account.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00003054 *
3055 * @param pool Pool to allocate memory for the string.
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00003056 * @param contact The string where the Contact will be stored.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00003057 * @param acc_id Account ID.
3058 * @param uri Destination URI of the request.
3059 *
3060 * @return PJ_SUCCESS on success, other on error.
3061 */
3062PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
3063 pj_str_t *contact,
3064 pjsua_acc_id acc_id,
3065 const pj_str_t *uri);
3066
3067
3068
3069/**
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00003070 * Create a suitable Contact header value, based on the information in the
3071 * incoming request.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00003072 *
3073 * @param pool Pool to allocate memory for the string.
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00003074 * @param contact The string where the Contact will be stored.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00003075 * @param acc_id Account ID.
3076 * @param rdata Incoming request.
3077 *
3078 * @return PJ_SUCCESS on success, other on error.
3079 */
3080PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
3081 pj_str_t *contact,
3082 pjsua_acc_id acc_id,
3083 pjsip_rx_data *rdata );
3084
3085
Benny Prijono62c5c5b2007-01-13 23:22:40 +00003086/**
3087 * Lock/bind this account to a specific transport/listener. Normally
3088 * application shouldn't need to do this, as transports will be selected
3089 * automatically by the stack according to the destination.
3090 *
3091 * When account is locked/bound to a specific transport, all outgoing
3092 * requests from this account will use the specified transport (this
3093 * includes SIP registration, dialog (call and event subscription), and
3094 * out-of-dialog requests such as MESSAGE).
3095 *
3096 * Note that transport_id may be specified in pjsua_acc_config too.
3097 *
3098 * @param acc_id The account ID.
3099 * @param tp_id The transport ID.
3100 *
3101 * @return PJ_SUCCESS on success.
3102 */
3103PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
3104 pjsua_transport_id tp_id);
3105
Benny Prijono312aff92006-06-17 04:08:30 +00003106
3107/**
3108 * @}
3109 */
3110
3111
3112/*****************************************************************************
3113 * CALLS API
3114 */
3115
3116
3117/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003118 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00003119 * @ingroup PJSUA_LIB
3120 * @brief Call manipulation.
3121 * @{
3122 */
3123
3124/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003125 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00003126 */
3127#ifndef PJSUA_MAX_CALLS
3128# define PJSUA_MAX_CALLS 32
3129#endif
3130
Benny Prijono9f468d12011-07-07 07:46:33 +00003131/**
3132 * Maximum active video windows
3133 */
3134#ifndef PJSUA_MAX_VID_WINS
3135# define PJSUA_MAX_VID_WINS 16
3136#endif
3137
3138/**
3139 * Video window ID.
3140 */
3141typedef int pjsua_vid_win_id;
Benny Prijono312aff92006-06-17 04:08:30 +00003142
3143
3144/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003145 * This enumeration specifies the media status of a call, and it's part
3146 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00003147 */
3148typedef enum pjsua_call_media_status
3149{
Benny Prijono0bc99a92011-03-17 04:34:43 +00003150 /**
3151 * Call currently has no media, or the media is not used.
3152 */
Benny Prijono312aff92006-06-17 04:08:30 +00003153 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00003154
Benny Prijono0bc99a92011-03-17 04:34:43 +00003155 /**
3156 * The media is active
3157 */
Benny Prijono312aff92006-06-17 04:08:30 +00003158 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00003159
Benny Prijono0bc99a92011-03-17 04:34:43 +00003160 /**
3161 * The media is currently put on hold by local endpoint
3162 */
Benny Prijono312aff92006-06-17 04:08:30 +00003163 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00003164
Benny Prijono0bc99a92011-03-17 04:34:43 +00003165 /**
3166 * The media is currently put on hold by remote endpoint
3167 */
Benny Prijono312aff92006-06-17 04:08:30 +00003168 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00003169
Benny Prijono0bc99a92011-03-17 04:34:43 +00003170 /**
3171 * The media has reported error (e.g. ICE negotiation)
3172 */
Benny Prijono096c56c2007-09-15 08:30:16 +00003173 PJSUA_CALL_MEDIA_ERROR
3174
Benny Prijono312aff92006-06-17 04:08:30 +00003175} pjsua_call_media_status;
3176
3177
3178/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003179 * This structure describes the information and current status of a call.
Benny Prijono312aff92006-06-17 04:08:30 +00003180 */
3181typedef struct pjsua_call_info
3182{
3183 /** Call identification. */
3184 pjsua_call_id id;
3185
3186 /** Initial call role (UAC == caller) */
3187 pjsip_role_e role;
3188
Benny Prijono90315512006-09-14 16:05:16 +00003189 /** The account ID where this call belongs. */
3190 pjsua_acc_id acc_id;
3191
Benny Prijono312aff92006-06-17 04:08:30 +00003192 /** Local URI */
3193 pj_str_t local_info;
3194
3195 /** Local Contact */
3196 pj_str_t local_contact;
3197
3198 /** Remote URI */
3199 pj_str_t remote_info;
3200
3201 /** Remote contact */
3202 pj_str_t remote_contact;
3203
3204 /** Dialog Call-ID string. */
3205 pj_str_t call_id;
3206
3207 /** Call state */
3208 pjsip_inv_state state;
3209
3210 /** Text describing the state */
3211 pj_str_t state_text;
3212
3213 /** Last status code heard, which can be used as cause code */
3214 pjsip_status_code last_status;
3215
3216 /** The reason phrase describing the status. */
3217 pj_str_t last_status_text;
3218
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003219 /** Media status of the first audio stream. */
Benny Prijono312aff92006-06-17 04:08:30 +00003220 pjsua_call_media_status media_status;
3221
Benny Prijono0bc99a92011-03-17 04:34:43 +00003222 /** Media direction of the first audio stream. */
Benny Prijono312aff92006-06-17 04:08:30 +00003223 pjmedia_dir media_dir;
3224
Benny Prijono0bc99a92011-03-17 04:34:43 +00003225 /** The conference port number for the first audio stream. */
Benny Prijono312aff92006-06-17 04:08:30 +00003226 pjsua_conf_port_id conf_slot;
3227
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003228 /** Number of media streams in this call */
3229 unsigned media_cnt;
3230
3231 /** Array of media stream information */
Benny Prijono0bc99a92011-03-17 04:34:43 +00003232 struct
3233 {
3234 /** Media index in SDP. */
3235 unsigned index;
3236
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003237 /** Media type. */
3238 pjmedia_type type;
Benny Prijono0bc99a92011-03-17 04:34:43 +00003239
3240 /** Media direction. */
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003241 pjmedia_dir dir;
Benny Prijono0bc99a92011-03-17 04:34:43 +00003242
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003243 /** Call media status. */
3244 pjsua_call_media_status status;
Benny Prijono0bc99a92011-03-17 04:34:43 +00003245
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003246 /** The specific media stream info. */
3247 union {
3248 /** Audio stream */
3249 struct {
Benny Prijono9f468d12011-07-07 07:46:33 +00003250 /** The conference port number for the call. */
3251 pjsua_conf_port_id conf_slot;
3252 } aud;
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003253
3254 /** Video stream */
3255 struct {
Benny Prijono9f468d12011-07-07 07:46:33 +00003256 /**
3257 * The window id for incoming video, if any, or
3258 * PJSUA_INVALID_ID.
3259 */
3260 pjsua_vid_win_id win_in;
3261
3262 /** The video capture device for outgoing transmission,
3263 * if any, or PJMEDIA_VID_INVALID_DEV
3264 */
3265 pjmedia_vid_dev_index cap_dev;
3266
3267 } vid;
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003268 } stream;
3269
3270 } media[PJMEDIA_MAX_SDP_MEDIA];
Benny Prijono0bc99a92011-03-17 04:34:43 +00003271
Benny Prijono312aff92006-06-17 04:08:30 +00003272 /** Up-to-date call connected duration (zero when call is not
3273 * established)
3274 */
3275 pj_time_val connect_duration;
3276
3277 /** Total call duration, including set-up time */
3278 pj_time_val total_duration;
3279
3280 /** Internal */
3281 struct {
3282 char local_info[128];
3283 char local_contact[128];
3284 char remote_info[128];
3285 char remote_contact[128];
3286 char call_id[128];
3287 char last_status_text[128];
3288 } buf_;
3289
3290} pjsua_call_info;
3291
3292
Benny Prijono9f468d12011-07-07 07:46:33 +00003293/**
3294 * Media stream info.
3295 */
3296typedef struct pjsua_stream_info
3297{
3298 /** Media type of this stream. */
3299 pjmedia_type type;
3300
3301 /** Stream info (union). */
3302 union {
3303 /** Audio stream info */
3304 pjmedia_stream_info aud;
3305
3306 /** Video stream info */
3307 pjmedia_vid_stream_info vid;
3308 } info;
3309
3310} pjsua_stream_info;
3311
3312
3313/**
3314 * Media stream statistic.
3315 */
3316typedef struct pjsua_stream_stat
3317{
3318 /** RTCP statistic. */
3319 pjmedia_rtcp_stat rtcp;
3320
3321 /** Jitter buffer statistic. */
3322 pjmedia_jb_state jbuf;
3323
3324} pjsua_stream_stat;
3325
Benny Prijono312aff92006-06-17 04:08:30 +00003326
Benny Prijonoa91a0032006-02-26 21:23:45 +00003327/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00003328 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003329 *
3330 * @return Maximum number of calls configured.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003331 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003332PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003333
3334/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003335 * Get number of currently active calls.
3336 *
3337 * @return Number of currently active calls.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003338 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003339PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003340
3341/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003342 * Enumerate all active calls. Application may then query the information and
3343 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003344 *
3345 * @param ids Array of account IDs to be initialized.
3346 * @param count In input, specifies the maximum number of elements.
3347 * On return, it contains the actual number of elements.
3348 *
3349 * @return PJ_SUCCESS on success, or the appropriate error code.
3350 */
3351PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
3352 unsigned *count);
3353
3354
3355/**
3356 * Make outgoing call to the specified URI using the specified account.
3357 *
3358 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003359 * @param dst_uri URI to be put in the To header (normally is the same
3360 * as the target URI).
3361 * @param options Options (must be zero at the moment).
3362 * @param user_data Arbitrary user data to be attached to the call, and
3363 * can be retrieved later.
3364 * @param msg_data Optional headers etc to be added to outgoing INVITE
3365 * request, or NULL if no custom header is desired.
3366 * @param p_call_id Pointer to receive call identification.
3367 *
3368 * @return PJ_SUCCESS on success, or the appropriate error code.
3369 */
3370PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
3371 const pj_str_t *dst_uri,
3372 unsigned options,
3373 void *user_data,
3374 const pjsua_msg_data *msg_data,
3375 pjsua_call_id *p_call_id);
3376
3377
3378/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00003379 * Check if the specified call has active INVITE session and the INVITE
3380 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003381 *
3382 * @param call_id Call identification.
3383 *
3384 * @return Non-zero if call is active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003385 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003386PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003387
3388
3389/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003390 * Check if call has an active media session.
3391 *
3392 * @param call_id Call identification.
3393 *
3394 * @return Non-zero if yes.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003395 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003396PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003397
3398
Benny Prijonocf986c42008-09-02 11:25:07 +00003399/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003400 * Get the conference port identification associated with the call.
3401 *
3402 * @param call_id Call identification.
3403 *
Benny Prijono9f468d12011-07-07 07:46:33 +00003404 * @return Conference port ID, or PJSUA_INVALID_ID when the
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003405 * media has not been established or is not active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003406 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003407PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
3408
3409/**
3410 * Obtain detail information about the specified call.
3411 *
3412 * @param call_id Call identification.
3413 * @param info Call info to be initialized.
3414 *
3415 * @return PJ_SUCCESS on success, or the appropriate error code.
3416 */
3417PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003418 pjsua_call_info *info);
3419
Nanang Izzuddin2a1b9ee2010-06-03 10:41:32 +00003420/**
3421 * Check if remote peer support the specified capability.
3422 *
3423 * @param call_id Call identification.
3424 * @param htype The header type to be checked, which value may be:
3425 * - PJSIP_H_ACCEPT
3426 * - PJSIP_H_ALLOW
3427 * - PJSIP_H_SUPPORTED
3428 * @param hname If htype specifies PJSIP_H_OTHER, then the header
3429 * name must be supplied in this argument. Otherwise the
3430 * value must be set to NULL.
3431 * @param token The capability token to check. For example, if \a
3432 * htype is PJSIP_H_ALLOW, then \a token specifies the
3433 * method names; if \a htype is PJSIP_H_SUPPORTED, then
3434 * \a token specifies the extension names such as
3435 * "100rel".
3436 *
3437 * @return PJSIP_DIALOG_CAP_SUPPORTED if the specified capability
3438 * is explicitly supported, see @pjsip_dialog_cap_status
3439 * for more info.
3440 */
3441PJ_DECL(pjsip_dialog_cap_status) pjsua_call_remote_has_cap(
3442 pjsua_call_id call_id,
3443 int htype,
3444 const pj_str_t *hname,
3445 const pj_str_t *token);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003446
3447/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003448 * Attach application specific data to the call. Application can then
3449 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003450 *
3451 * @param call_id Call identification.
3452 * @param user_data Arbitrary data to be attached to the call.
3453 *
3454 * @return The user data.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003455 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003456PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
3457 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003458
3459
3460/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003461 * Get user data attached to the call, which has been previously set with
3462 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003463 *
3464 * @param call_id Call identification.
3465 *
3466 * @return The user data.
Benny Prijono268ca612006-02-07 12:34:11 +00003467 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003468PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00003469
3470
3471/**
Benny Prijono91a6a172007-10-31 08:59:29 +00003472 * Get the NAT type of remote's endpoint. This is a proprietary feature
3473 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
3474 * is set in #pjsua_config.
3475 *
3476 * This function can only be called after SDP has been received from remote,
3477 * which means for incoming call, this function can be called as soon as
3478 * call is received as long as incoming call contains SDP, and for outgoing
3479 * call, this function can be called only after SDP is received (normally in
3480 * 200/OK response to INVITE). As a general case, application should call
3481 * this function after or in \a on_call_media_state() callback.
3482 *
3483 * @param call_id Call identification.
3484 * @param p_type Pointer to store the NAT type. Application can then
3485 * retrieve the string description of the NAT type
3486 * by calling pj_stun_get_nat_name().
3487 *
3488 * @return PJ_SUCCESS on success.
3489 *
3490 * @see pjsua_get_nat_type(), nat_type_in_sdp
3491 */
3492PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
3493 pj_stun_nat_type *p_type);
3494
3495/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003496 * Send response to incoming INVITE request. Depending on the status
3497 * code specified as parameter, this function may send provisional
3498 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003499 *
3500 * @param call_id Incoming call identification.
3501 * @param code Status code, (100-699).
3502 * @param reason Optional reason phrase. If NULL, default text
3503 * will be used.
3504 * @param msg_data Optional list of headers etc to be added to outgoing
3505 * response message.
3506 *
3507 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoa91a0032006-02-26 21:23:45 +00003508 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003509PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
3510 unsigned code,
3511 const pj_str_t *reason,
3512 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00003513
3514/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003515 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00003516 * call state. This function is different than answering the call with
3517 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
3518 * will hangup the call regardless of the state and role of the call,
3519 * while #pjsua_call_answer() only works with incoming calls on EARLY
3520 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003521 *
3522 * @param call_id Call identification.
3523 * @param code Optional status code to be sent when we're rejecting
3524 * incoming call. If the value is zero, "603/Decline"
3525 * will be sent.
3526 * @param reason Optional reason phrase to be sent when we're rejecting
3527 * incoming call. If NULL, default text will be used.
3528 * @param msg_data Optional list of headers etc to be added to outgoing
3529 * request/response message.
3530 *
3531 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003532 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003533PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
3534 unsigned code,
3535 const pj_str_t *reason,
3536 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003537
Benny Prijono5e51a4e2008-11-27 00:06:46 +00003538/**
3539 * Accept or reject redirection response. Application MUST call this function
3540 * after it signaled PJSIP_REDIRECT_PENDING in the \a on_call_redirected()
3541 * callback, to notify the call whether to accept or reject the redirection
3542 * to the current target. Application can use the combination of
3543 * PJSIP_REDIRECT_PENDING command in \a on_call_redirected() callback and
3544 * this function to ask for user permission before redirecting the call.
3545 *
3546 * Note that if the application chooses to reject or stop redirection (by
3547 * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the
3548 * call disconnection callback will be called before this function returns.
3549 * And if the application rejects the target, the \a on_call_redirected()
3550 * callback may also be called before this function returns if there is
3551 * another target to try.
3552 *
3553 * @param call_id The call ID.
3554 * @param cmd Redirection operation to be applied to the current
3555 * target. The semantic of this argument is similar
3556 * to the description in the \a on_call_redirected()
3557 * callback, except that the PJSIP_REDIRECT_PENDING is
3558 * not accepted here.
3559 *
3560 * @return PJ_SUCCESS on successful operation.
3561 */
3562PJ_DECL(pj_status_t) pjsua_call_process_redirect(pjsua_call_id call_id,
3563 pjsip_redirect_op cmd);
Benny Prijono26ff9062006-02-21 23:47:00 +00003564
3565/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003566 * Put the specified call on hold. This will send re-INVITE with the
3567 * appropriate SDP to inform remote that the call is being put on hold.
3568 * The final status of the request itself will be reported on the
3569 * \a on_call_media_state() callback, which inform the application that
3570 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003571 *
3572 * @param call_id Call identification.
3573 * @param msg_data Optional message components to be sent with
3574 * the request.
3575 *
3576 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003577 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003578PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
3579 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003580
3581
3582/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003583 * Send re-INVITE to release hold.
3584 * The final status of the request itself will be reported on the
3585 * \a on_call_media_state() callback, which inform the application that
3586 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003587 *
3588 * @param call_id Call identification.
3589 * @param unhold If this argument is non-zero and the call is locally
3590 * held, this will release the local hold.
3591 * @param msg_data Optional message components to be sent with
3592 * the request.
3593 *
3594 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003595 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003596PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
3597 pj_bool_t unhold,
3598 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003599
Benny Prijonoc08682e2007-10-04 06:17:58 +00003600/**
3601 * Send UPDATE request.
3602 *
3603 * @param call_id Call identification.
3604 * @param options Must be zero for now.
3605 * @param msg_data Optional message components to be sent with
3606 * the request.
3607 *
3608 * @return PJ_SUCCESS on success, or the appropriate error code.
3609 */
3610PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
3611 unsigned options,
3612 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003613
3614/**
Benny Prijono053f5222006-11-11 16:16:04 +00003615 * Initiate call transfer to the specified address. This function will send
3616 * REFER request to instruct remote call party to initiate a new INVITE
3617 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003618 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00003619 * If application is interested to monitor the successfulness and
3620 * the progress of the transfer request, it can implement
3621 * \a on_call_transfer_status() callback which will report the progress
3622 * of the call transfer request.
3623 *
Benny Prijono053f5222006-11-11 16:16:04 +00003624 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003625 * @param dest Address of new target to be contacted.
3626 * @param msg_data Optional message components to be sent with
3627 * the request.
3628 *
3629 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003630 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003631PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
3632 const pj_str_t *dest,
3633 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003634
3635/**
Benny Prijono053f5222006-11-11 16:16:04 +00003636 * Flag to indicate that "Require: replaces" should not be put in the
3637 * outgoing INVITE request caused by REFER request created by
3638 * #pjsua_call_xfer_replaces().
3639 */
3640#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
3641
3642/**
3643 * Initiate attended call transfer. This function will send REFER request
3644 * to instruct remote call party to initiate new INVITE session to the URL
3645 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
3646 * the call with us with the new call from the REFER recipient.
3647 *
3648 * @param call_id The call id to be transfered.
3649 * @param dest_call_id The call id to be replaced.
3650 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
3651 * to suppress the inclusion of "Require: replaces" in
3652 * the outgoing INVITE request created by the REFER
3653 * request.
3654 * @param msg_data Optional message components to be sent with
3655 * the request.
3656 *
3657 * @return PJ_SUCCESS on success, or the appropriate error code.
3658 */
3659PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
3660 pjsua_call_id dest_call_id,
3661 unsigned options,
3662 const pjsua_msg_data *msg_data);
3663
3664/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003665 * Send DTMF digits to remote using RFC 2833 payload formats.
3666 *
3667 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003668 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003669 *
3670 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003671 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003672PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003673 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00003674
Benny Prijono26ff9062006-02-21 23:47:00 +00003675/**
Benny Prijonob0808372006-03-02 21:18:58 +00003676 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003677 *
3678 * @param call_id Call identification.
3679 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3680 * assumed.
3681 * @param content The message content.
3682 * @param msg_data Optional list of headers etc to be included in outgoing
3683 * request. The body descriptor in the msg_data is
3684 * ignored.
3685 * @param user_data Optional user data, which will be given back when
3686 * the IM callback is called.
3687 *
3688 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003689 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003690PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
3691 const pj_str_t *mime_type,
3692 const pj_str_t *content,
3693 const pjsua_msg_data *msg_data,
3694 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003695
3696
3697/**
3698 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003699 *
3700 * @param call_id Call identification.
3701 * @param is_typing Non-zero to indicate to remote that local person is
3702 * currently typing an IM.
3703 * @param msg_data Optional list of headers etc to be included in outgoing
3704 * request.
3705 *
3706 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003707 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003708PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
3709 pj_bool_t is_typing,
3710 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003711
3712/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00003713 * Send arbitrary request with the call. This is useful for example to send
3714 * INFO request. Note that application should not use this function to send
3715 * requests which would change the invite session's state, such as re-INVITE,
3716 * UPDATE, PRACK, and BYE.
3717 *
3718 * @param call_id Call identification.
3719 * @param method SIP method of the request.
3720 * @param msg_data Optional message body and/or list of headers to be
3721 * included in outgoing request.
3722 *
3723 * @return PJ_SUCCESS on success, or the appropriate error code.
3724 */
3725PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
3726 const pj_str_t *method,
3727 const pjsua_msg_data *msg_data);
3728
3729
3730/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003731 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
3732 * currently active calls.
Benny Prijono834aee32006-02-19 01:38:06 +00003733 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00003734PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00003735
3736
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003737/**
3738 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003739 *
3740 * @param call_id Call identification.
3741 * @param with_media Non-zero to include media information too.
3742 * @param buffer Buffer where the statistics are to be written to.
3743 * @param maxlen Maximum length of buffer.
3744 * @param indent Spaces for left indentation.
3745 *
3746 * @return PJ_SUCCESS on success.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003747 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003748PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
3749 pj_bool_t with_media,
3750 char *buffer,
3751 unsigned maxlen,
3752 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003753
Benny Prijono9fc735d2006-05-28 14:58:12 +00003754/**
Benny Prijono9f468d12011-07-07 07:46:33 +00003755 * Get the media stream index of the default video stream in the call.
3756 * Typically this will just retrieve the stream index of the first
3757 * activated video stream in the call.
3758 *
3759 * @param call_id Call identification.
3760 *
3761 * @return The media stream index or -1 if no video stream
3762 * is present in the call.
3763 */
3764PJ_DECL(int) pjsua_call_get_vid_stream_idx(pjsua_call_id call_id);
3765
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +00003766
Benny Prijono9f468d12011-07-07 07:46:33 +00003767/**
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +00003768 * Add, remove, modify, and/or manipulate video media stream for the
3769 * specified call. This may trigger a re-INVITE or UPDATE to be sent
3770 * for the call.
Benny Prijono9f468d12011-07-07 07:46:33 +00003771 *
3772 * @param call_id Call identification.
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +00003773 * @param op The video stream operation to be performed,
3774 * possible values are #pjsua_call_vid_strm_op.
3775 * @param param The parameters for the video stream operation.
Benny Prijono9f468d12011-07-07 07:46:33 +00003776 *
3777 * @return PJ_SUCCESS on success or the appropriate error.
3778 */
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +00003779PJ_DECL(pj_status_t) pjsua_call_set_vid_strm (
3780 pjsua_call_id call_id,
3781 pjsua_call_vid_strm_op op,
3782 const pjsua_call_vid_strm_op_param *param);
3783
Benny Prijono9f468d12011-07-07 07:46:33 +00003784
3785/**
3786 * Get media stream info for the specified media index.
3787 *
3788 * @param call_id The call identification.
3789 * @param med_idx Media stream index.
3790 * @param psi To be filled with the stream info.
3791 *
3792 * @return PJ_SUCCESS on success or the appropriate error.
3793 */
3794PJ_DECL(pj_status_t) pjsua_call_get_stream_info(pjsua_call_id call_id,
3795 unsigned med_idx,
3796 pjsua_stream_info *psi);
3797
3798/**
3799 * Get media stream statistic for the specified media index.
3800 *
3801 * @param call_id The call identification.
3802 * @param med_idx Media stream index.
3803 * @param psi To be filled with the stream statistic.
3804 *
3805 * @return PJ_SUCCESS on success or the appropriate error.
3806 */
3807PJ_DECL(pj_status_t) pjsua_call_get_stream_stat(pjsua_call_id call_id,
3808 unsigned med_idx,
3809 pjsua_stream_stat *stat);
3810
3811/**
3812 * Get media transport info for the specified media index.
3813 *
3814 * @param call_id The call identification.
3815 * @param med_idx Media stream index.
3816 * @param t To be filled with the transport info.
3817 *
3818 * @return PJ_SUCCESS on success or the appropriate error.
3819 */
3820PJ_DECL(pj_status_t) pjsua_call_get_transport_info(pjsua_call_id call_id,
3821 unsigned med_idx,
3822 pjmedia_transport_info *t);
3823
3824
3825
3826/**
Benny Prijono312aff92006-06-17 04:08:30 +00003827 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003828 */
Benny Prijono834aee32006-02-19 01:38:06 +00003829
3830
3831/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00003832 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00003833 */
3834
Benny Prijono312aff92006-06-17 04:08:30 +00003835
3836/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003837 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00003838 * @ingroup PJSUA_LIB
3839 * @brief Buddy management, buddy's presence, and instant messaging.
3840 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00003841 *
3842 * This section describes PJSUA-APIs related to buddies management,
3843 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00003844 */
3845
3846/**
3847 * Max buddies in buddy list.
3848 */
3849#ifndef PJSUA_MAX_BUDDIES
3850# define PJSUA_MAX_BUDDIES 256
3851#endif
3852
3853
3854/**
Benny Prijono6ab05322009-10-21 03:03:06 +00003855 * This specifies how long the library should wait before retrying failed
3856 * SUBSCRIBE request, and there is no rule to automatically resubscribe
3857 * (for example, no "retry-after" parameter in Subscription-State header).
3858 *
3859 * This also controls the duration before failed PUBLISH request will be
3860 * retried.
Benny Prijonoa17496a2007-10-31 10:20:31 +00003861 *
3862 * Default: 300 seconds
3863 */
3864#ifndef PJSUA_PRES_TIMER
3865# define PJSUA_PRES_TIMER 300
3866#endif
3867
3868
3869/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003870 * This structure describes buddy configuration when adding a buddy to
3871 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
3872 * the structure with #pjsua_buddy_config_default() to initialize this
3873 * structure with default configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00003874 */
3875typedef struct pjsua_buddy_config
3876{
3877 /**
3878 * Buddy URL or name address.
3879 */
3880 pj_str_t uri;
3881
3882 /**
3883 * Specify whether presence subscription should start immediately.
3884 */
3885 pj_bool_t subscribe;
3886
Benny Prijono705e7842008-07-21 18:12:51 +00003887 /**
3888 * Specify arbitrary application data to be associated with with
3889 * the buddy object.
3890 */
3891 void *user_data;
3892
Benny Prijono312aff92006-06-17 04:08:30 +00003893} pjsua_buddy_config;
3894
3895
3896/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003897 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003898 */
3899typedef enum pjsua_buddy_status
3900{
3901 /**
3902 * Online status is unknown (possibly because no presence subscription
3903 * has been established).
3904 */
3905 PJSUA_BUDDY_STATUS_UNKNOWN,
3906
3907 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003908 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003909 */
3910 PJSUA_BUDDY_STATUS_ONLINE,
3911
3912 /**
3913 * Buddy is offline.
3914 */
3915 PJSUA_BUDDY_STATUS_OFFLINE,
3916
3917} pjsua_buddy_status;
3918
3919
3920
3921/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003922 * This structure describes buddy info, which can be retrieved by calling
3923 * #pjsua_buddy_get_info().
Benny Prijono312aff92006-06-17 04:08:30 +00003924 */
3925typedef struct pjsua_buddy_info
3926{
3927 /**
3928 * The buddy ID.
3929 */
3930 pjsua_buddy_id id;
3931
3932 /**
3933 * The full URI of the buddy, as specified in the configuration.
3934 */
3935 pj_str_t uri;
3936
3937 /**
3938 * Buddy's Contact, only available when presence subscription has
3939 * been established to the buddy.
3940 */
3941 pj_str_t contact;
3942
3943 /**
3944 * Buddy's online status.
3945 */
3946 pjsua_buddy_status status;
3947
3948 /**
3949 * Text to describe buddy's online status.
3950 */
3951 pj_str_t status_text;
3952
3953 /**
3954 * Flag to indicate that we should monitor the presence information for
3955 * this buddy (normally yes, unless explicitly disabled).
3956 */
3957 pj_bool_t monitor_pres;
3958
3959 /**
Benny Prijono63fba012008-07-17 14:19:10 +00003960 * If \a monitor_pres is enabled, this specifies the last state of the
3961 * presence subscription. If presence subscription session is currently
3962 * active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence
3963 * subscription request has been rejected, the value will be
3964 * PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be
3965 * specified in \a sub_term_reason.
3966 */
3967 pjsip_evsub_state sub_state;
3968
3969 /**
Benny Prijonod06d8c52009-06-30 13:53:47 +00003970 * String representation of subscription state.
3971 */
3972 const char *sub_state_name;
3973
3974 /**
Benny Prijono73bb7232009-10-20 13:56:26 +00003975 * Specifies the last presence subscription termination code. This would
3976 * return the last status of the SUBSCRIBE request. If the subscription
3977 * is terminated with NOTIFY by the server, this value will be set to
3978 * 200, and subscription termination reason will be given in the
3979 * \a sub_term_reason field.
3980 */
3981 unsigned sub_term_code;
3982
3983 /**
3984 * Specifies the last presence subscription termination reason. If
Benny Prijono63fba012008-07-17 14:19:10 +00003985 * presence subscription is currently active, the value will be empty.
3986 */
3987 pj_str_t sub_term_reason;
3988
3989 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003990 * Extended RPID information about the person.
3991 */
3992 pjrpid_element rpid;
3993
3994 /**
Benny Prijono28add7e2009-06-15 16:03:40 +00003995 * Extended presence info.
3996 */
3997 pjsip_pres_status pres_status;
3998
3999 /**
Benny Prijono312aff92006-06-17 04:08:30 +00004000 * Internal buffer.
4001 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00004002 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00004003
4004} pjsua_buddy_info;
4005
4006
Benny Prijono834aee32006-02-19 01:38:06 +00004007/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004008 * Set default values to the buddy config.
4009 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00004010PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00004011
4012
4013/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004014 * Get total number of buddies.
4015 *
4016 * @return Number of buddies.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004017 */
4018PJ_DECL(unsigned) pjsua_get_buddy_count(void);
4019
4020
4021/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004022 * Check if buddy ID is valid.
4023 *
4024 * @param buddy_id Buddy ID to check.
4025 *
4026 * @return Non-zero if buddy ID is valid.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004027 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004028PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
4029
4030
4031/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004032 * Enumerate all buddy IDs in the buddy list. Application then can use
4033 * #pjsua_buddy_get_info() to get the detail information for each buddy
4034 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004035 *
4036 * @param ids Array of ids to be initialized.
4037 * @param count On input, specifies max elements in the array.
4038 * On return, it contains actual number of elements
4039 * that have been initialized.
4040 *
4041 * @return PJ_SUCCESS on success, or the appropriate error code.
4042 */
4043PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
4044 unsigned *count);
4045
4046/**
Benny Prijono705e7842008-07-21 18:12:51 +00004047 * Find the buddy ID with the specified URI.
4048 *
4049 * @param uri The buddy URI.
4050 *
4051 * @return The buddy ID, or PJSUA_INVALID_ID if not found.
4052 */
4053PJ_DECL(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri);
4054
4055
4056/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004057 * Get detailed buddy info.
4058 *
4059 * @param buddy_id The buddy identification.
4060 * @param info Pointer to receive information about buddy.
4061 *
4062 * @return PJ_SUCCESS on success, or the appropriate error code.
4063 */
4064PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00004065 pjsua_buddy_info *info);
4066
4067/**
Benny Prijono705e7842008-07-21 18:12:51 +00004068 * Set the user data associated with the buddy object.
4069 *
4070 * @param buddy_id The buddy identification.
4071 * @param user_data Arbitrary application data to be associated with
4072 * the buddy object.
4073 *
4074 * @return PJ_SUCCESS on success, or the appropriate error code.
4075 */
4076PJ_DECL(pj_status_t) pjsua_buddy_set_user_data(pjsua_buddy_id buddy_id,
4077 void *user_data);
4078
4079
4080/**
4081 * Get the user data associated with the budy object.
4082 *
4083 * @param buddy_id The buddy identification.
4084 *
4085 * @return The application data.
4086 */
4087PJ_DECL(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id);
4088
4089
4090/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004091 * Add new buddy to the buddy list. If presence subscription is enabled
4092 * for this buddy, this function will also start the presence subscription
4093 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004094 *
Benny Prijonoa7b376b2008-01-25 16:06:33 +00004095 * @param buddy_cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004096 * @param p_buddy_id Pointer to receive buddy ID.
4097 *
4098 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004099 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004100PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004101 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004102
4103
4104/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004105 * Delete the specified buddy from the buddy list. Any presence subscription
4106 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004107 *
4108 * @param buddy_id Buddy identification.
4109 *
4110 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004111 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004112PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004113
4114
4115/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004116 * Enable/disable buddy's presence monitoring. Once buddy's presence is
4117 * subscribed, application will be informed about buddy's presence status
4118 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004119 *
4120 * @param buddy_id Buddy identification.
4121 * @param subscribe Specify non-zero to activate presence subscription to
4122 * the specified buddy.
4123 *
4124 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004125 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004126PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
4127 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004128
4129
4130/**
Benny Prijono10861432007-10-31 10:54:53 +00004131 * Update the presence information for the buddy. Although the library
4132 * periodically refreshes the presence subscription for all buddies, some
4133 * application may want to refresh the buddy's presence subscription
4134 * immediately, and in this case it can use this function to accomplish
4135 * this.
4136 *
4137 * Note that the buddy's presence subscription will only be initiated
4138 * if presence monitoring is enabled for the buddy. See
4139 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
4140 * for the buddy is already active, this function will not do anything.
4141 *
4142 * Once the presence subscription is activated successfully for the buddy,
4143 * application will be notified about the buddy's presence status in the
4144 * on_buddy_state() callback.
4145 *
4146 * @param buddy_id Buddy identification.
4147 *
4148 * @return PJ_SUCCESS on success, or the appropriate error code.
4149 */
4150PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
4151
4152
4153/**
Benny Prijono63fba012008-07-17 14:19:10 +00004154 * Send NOTIFY to inform account presence status or to terminate server
4155 * side presence subscription. If application wants to reject the incoming
4156 * request, it should set the \a state to PJSIP_EVSUB_STATE_TERMINATED.
4157 *
4158 * @param acc_id Account ID.
4159 * @param srv_pres Server presence subscription instance.
4160 * @param state New state to set.
4161 * @param state_str Optionally specify the state string name, if state
4162 * is not "active", "pending", or "terminated".
4163 * @param reason If the new state is PJSIP_EVSUB_STATE_TERMINATED,
4164 * optionally specify the termination reason.
4165 * @param with_body If the new state is PJSIP_EVSUB_STATE_TERMINATED,
4166 * this specifies whether the NOTIFY request should
4167 * contain message body containing account's presence
4168 * information.
4169 * @param msg_data Optional list of headers to be sent with the NOTIFY
4170 * request.
4171 *
4172 * @return PJ_SUCCESS on success.
4173 */
4174PJ_DECL(pj_status_t) pjsua_pres_notify(pjsua_acc_id acc_id,
4175 pjsua_srv_pres *srv_pres,
4176 pjsip_evsub_state state,
4177 const pj_str_t *state_str,
4178 const pj_str_t *reason,
4179 pj_bool_t with_body,
4180 const pjsua_msg_data *msg_data);
4181
4182/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004183 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004184 *
4185 * @param verbose Yes or no.
Benny Prijono834aee32006-02-19 01:38:06 +00004186 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004187PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00004188
4189
Benny Prijonob0808372006-03-02 21:18:58 +00004190/**
4191 * The MESSAGE method (defined in pjsua_im.c)
4192 */
4193extern const pjsip_method pjsip_message_method;
4194
4195
Benny Prijonob0808372006-03-02 21:18:58 +00004196
4197/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004198 * Send instant messaging outside dialog, using the specified account for
4199 * route set and authentication.
4200 *
4201 * @param acc_id Account ID to be used to send the request.
4202 * @param to Remote URI.
4203 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
4204 * assumed.
4205 * @param content The message content.
4206 * @param msg_data Optional list of headers etc to be included in outgoing
4207 * request. The body descriptor in the msg_data is
4208 * ignored.
4209 * @param user_data Optional user data, which will be given back when
4210 * the IM callback is called.
4211 *
4212 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00004213 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004214PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
4215 const pj_str_t *to,
4216 const pj_str_t *mime_type,
4217 const pj_str_t *content,
4218 const pjsua_msg_data *msg_data,
4219 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00004220
4221
4222/**
4223 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004224 *
4225 * @param acc_id Account ID to be used to send the request.
4226 * @param to Remote URI.
4227 * @param is_typing If non-zero, it tells remote person that local person
4228 * is currently composing an IM.
4229 * @param msg_data Optional list of headers etc to be added to outgoing
4230 * request.
4231 *
4232 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00004233 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004234PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
4235 const pj_str_t *to,
4236 pj_bool_t is_typing,
4237 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00004238
4239
Benny Prijonof3195072006-02-14 21:15:30 +00004240
Benny Prijono312aff92006-06-17 04:08:30 +00004241/**
4242 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00004243 */
4244
Benny Prijono312aff92006-06-17 04:08:30 +00004245
4246/*****************************************************************************
4247 * MEDIA API
4248 */
4249
4250
4251/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00004252 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00004253 * @ingroup PJSUA_LIB
4254 * @brief Media manipulation.
4255 * @{
4256 *
4257 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00004258 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
4259 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00004260 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00004261 * the interconnection between these terminations freely.
4262 *
4263 * The conference bridge provides powerful switching and mixing functionality
4264 * for application. With the conference bridge, each conference slot (e.g.
4265 * a call) can transmit to multiple destinations, and one destination can
4266 * receive from multiple sources. If more than one media terminations are
4267 * terminated in the same slot, the conference bridge will mix the signal
4268 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00004269 *
4270 * Application connects one media termination/slot to another by calling
4271 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00004272 * media flow from the source termination to the sink termination. To
4273 * establish bidirectional media flow, application wound need to make another
4274 * call to #pjsua_conf_connect(), this time inverting the source and
4275 * destination slots in the parameter.
4276 *
4277 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00004278 * the following steps:
4279 *
4280 \code
4281
4282 pj_status_t stream_to_call( pjsua_call_id call_id )
4283 {
4284 pjsua_player_id player_id;
4285
4286 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
4287 if (status != PJ_SUCCESS)
4288 return status;
4289
4290 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
4291 pjsua_call_get_conf_port() );
4292 }
4293 \endcode
4294 *
4295 *
4296 * Other features of PJSUA media:
4297 * - efficient N to M interconnections between media terminations.
4298 * - media termination can be connected to itself to create loopback
4299 * media.
4300 * - the media termination may have different clock rates, and resampling
4301 * will be done automatically by conference bridge.
4302 * - media terminations may also have different frame time; the
4303 * conference bridge will perform the necessary bufferring to adjust
4304 * the difference between terminations.
4305 * - interconnections are removed automatically when media termination
4306 * is removed from the bridge.
4307 * - sound device may be changed even when there are active media
4308 * interconnections.
4309 * - correctly report call's media quality (in #pjsua_call_dump()) from
4310 * RTCP packet exchange.
4311 */
4312
4313/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004314 * Max ports in the conference bridge. This setting is the default value
4315 * for pjsua_media_config.max_media_ports.
Benny Prijono312aff92006-06-17 04:08:30 +00004316 */
4317#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00004318# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00004319#endif
4320
Benny Prijonob5388cf2007-01-04 22:45:08 +00004321/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004322 * The default clock rate to be used by the conference bridge. This setting
4323 * is the default value for pjsua_media_config.clock_rate.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004324 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004325#ifndef PJSUA_DEFAULT_CLOCK_RATE
4326# define PJSUA_DEFAULT_CLOCK_RATE 16000
4327#endif
4328
Benny Prijonob5388cf2007-01-04 22:45:08 +00004329/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004330 * Default frame length in the conference bridge. This setting
4331 * is the default value for pjsua_media_config.audio_frame_ptime.
4332 */
4333#ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Nanang Izzuddinaf974842008-05-08 09:51:16 +00004334# define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
Benny Prijono37c710b2008-01-10 12:09:26 +00004335#endif
4336
4337
4338/**
4339 * Default codec quality settings. This setting is the default value
4340 * for pjsua_media_config.quality.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004341 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004342#ifndef PJSUA_DEFAULT_CODEC_QUALITY
Nanang Izzuddin9dbad152008-06-10 18:56:10 +00004343# define PJSUA_DEFAULT_CODEC_QUALITY 8
Benny Prijono12a669c2006-11-23 07:32:13 +00004344#endif
4345
Benny Prijonob5388cf2007-01-04 22:45:08 +00004346/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004347 * Default iLBC mode. This setting is the default value for
4348 * pjsua_media_config.ilbc_mode.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004349 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004350#ifndef PJSUA_DEFAULT_ILBC_MODE
Benny Prijono37c710b2008-01-10 12:09:26 +00004351# define PJSUA_DEFAULT_ILBC_MODE 30
Benny Prijono12a669c2006-11-23 07:32:13 +00004352#endif
4353
Benny Prijonob5388cf2007-01-04 22:45:08 +00004354/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004355 * The default echo canceller tail length. This setting
4356 * is the default value for pjsua_media_config.ec_tail_len.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004357 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004358#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijono427439c2007-10-21 09:41:24 +00004359# define PJSUA_DEFAULT_EC_TAIL_LEN 200
Benny Prijono12a669c2006-11-23 07:32:13 +00004360#endif
Benny Prijono312aff92006-06-17 04:08:30 +00004361
4362
4363/**
Benny Prijonocba59d92007-02-16 09:22:56 +00004364 * The maximum file player.
4365 */
4366#ifndef PJSUA_MAX_PLAYERS
4367# define PJSUA_MAX_PLAYERS 32
4368#endif
4369
4370
4371/**
4372 * The maximum file player.
4373 */
4374#ifndef PJSUA_MAX_RECORDERS
4375# define PJSUA_MAX_RECORDERS 32
4376#endif
4377
4378
4379/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004380 * This structure describes media configuration, which will be specified
4381 * when calling #pjsua_init(). Application MUST initialize this structure
4382 * by calling #pjsua_media_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00004383 */
4384struct pjsua_media_config
4385{
4386 /**
4387 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004388 * If value is zero, default clock rate will be used
4389 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00004390 */
4391 unsigned clock_rate;
4392
4393 /**
Benny Prijonof3758ee2008-02-26 15:32:16 +00004394 * Clock rate to be applied when opening the sound device.
4395 * If value is zero, conference bridge clock rate will be used.
4396 */
4397 unsigned snd_clock_rate;
4398
4399 /**
Benny Prijono7d60d052008-03-29 12:24:20 +00004400 * Channel count be applied when opening the sound device and
4401 * conference bridge.
4402 */
4403 unsigned channel_count;
4404
4405 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004406 * Specify audio frame ptime. The value here will affect the
4407 * samples per frame of both the sound device and the conference
4408 * bridge. Specifying lower ptime will normally reduce the
4409 * latency.
4410 *
Benny Prijono37c710b2008-01-10 12:09:26 +00004411 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004412 */
4413 unsigned audio_frame_ptime;
4414
4415 /**
Benny Prijono312aff92006-06-17 04:08:30 +00004416 * Specify maximum number of media ports to be created in the
4417 * conference bridge. Since all media terminate in the bridge
4418 * (calls, file player, file recorder, etc), the value must be
4419 * large enough to support all of them. However, the larger
4420 * the value, the more computations are performed.
Benny Prijono37c710b2008-01-10 12:09:26 +00004421 *
4422 * Default value: PJSUA_MAX_CONF_PORTS
Benny Prijono312aff92006-06-17 04:08:30 +00004423 */
4424 unsigned max_media_ports;
4425
4426 /**
4427 * Specify whether the media manager should manage its own
4428 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
4429 * and at least one worker thread will be created too. If no,
4430 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
4431 * and no worker thread is needed.
4432 *
4433 * Normally application would say yes here, unless it wants to
4434 * run everything from a single thread.
4435 */
4436 pj_bool_t has_ioqueue;
4437
4438 /**
4439 * Specify the number of worker threads to handle incoming RTP
4440 * packets. A value of one is recommended for most applications.
4441 */
4442 unsigned thread_cnt;
4443
Benny Prijono0498d902006-06-19 14:49:14 +00004444 /**
4445 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00004446 * 5-10: resampling use large filter,
4447 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00004448 * 1-2: resampling use linear.
4449 * The media quality also sets speex codec quality/complexity to the
4450 * number.
4451 *
Benny Prijono70972992006-08-05 11:13:58 +00004452 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00004453 */
4454 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00004455
4456 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004457 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00004458 *
4459 * Default: 0 (codec specific)
4460 */
4461 unsigned ptime;
4462
4463 /**
4464 * Disable VAD?
4465 *
4466 * Default: 0 (no (meaning VAD is enabled))
4467 */
4468 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00004469
4470 /**
4471 * iLBC mode (20 or 30).
4472 *
Benny Prijono37c710b2008-01-10 12:09:26 +00004473 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00004474 */
4475 unsigned ilbc_mode;
4476
4477 /**
4478 * Percentage of RTP packet to drop in TX direction
4479 * (to simulate packet lost).
4480 *
4481 * Default: 0
4482 */
4483 unsigned tx_drop_pct;
4484
4485 /**
4486 * Percentage of RTP packet to drop in RX direction
4487 * (to simulate packet lost).
4488 *
4489 * Default: 0
4490 */
4491 unsigned rx_drop_pct;
4492
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004493 /**
Benny Prijono5da50432006-08-07 10:24:52 +00004494 * Echo canceller options (see #pjmedia_echo_create())
4495 *
4496 * Default: 0.
4497 */
4498 unsigned ec_options;
4499
4500 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004501 * Echo canceller tail length, in miliseconds.
4502 *
Benny Prijono669643c2006-09-20 20:02:18 +00004503 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004504 */
4505 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004506
Benny Prijono10454dc2009-02-21 14:21:59 +00004507 /**
4508 * Audio capture buffer length, in milliseconds.
4509 *
4510 * Default: PJMEDIA_SND_DEFAULT_REC_LATENCY
4511 */
4512 unsigned snd_rec_latency;
4513
4514 /**
4515 * Audio playback buffer length, in milliseconds.
4516 *
4517 * Default: PJMEDIA_SND_DEFAULT_PLAY_LATENCY
4518 */
4519 unsigned snd_play_latency;
4520
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004521 /**
4522 * Jitter buffer initial prefetch delay in msec. The value must be
4523 * between jb_min_pre and jb_max_pre below.
4524 *
4525 * Default: -1 (to use default stream settings, currently 150 msec)
4526 */
4527 int jb_init;
4528
4529 /**
4530 * Jitter buffer minimum prefetch delay in msec.
4531 *
4532 * Default: -1 (to use default stream settings, currently 60 msec)
4533 */
4534 int jb_min_pre;
4535
4536 /**
4537 * Jitter buffer maximum prefetch delay in msec.
4538 *
4539 * Default: -1 (to use default stream settings, currently 240 msec)
4540 */
4541 int jb_max_pre;
4542
4543 /**
4544 * Set maximum delay that can be accomodated by the jitter buffer msec.
4545 *
4546 * Default: -1 (to use default stream settings, currently 360 msec)
4547 */
4548 int jb_max;
4549
Benny Prijonoc97608e2007-03-23 16:34:20 +00004550 /**
4551 * Enable ICE
4552 */
4553 pj_bool_t enable_ice;
4554
4555 /**
Benny Prijono329d6382009-05-29 13:04:03 +00004556 * Set the maximum number of host candidates.
4557 *
4558 * Default: -1 (maximum not set)
Benny Prijonoc97608e2007-03-23 16:34:20 +00004559 */
Benny Prijono329d6382009-05-29 13:04:03 +00004560 int ice_max_host_cands;
4561
4562 /**
4563 * ICE session options.
4564 */
4565 pj_ice_sess_options ice_opt;
Benny Prijonof76e1392008-06-06 14:51:48 +00004566
4567 /**
Benny Prijono551af422008-08-07 09:55:52 +00004568 * Disable RTCP component.
4569 *
4570 * Default: no
4571 */
4572 pj_bool_t ice_no_rtcp;
4573
4574 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00004575 * Enable TURN relay candidate in ICE.
4576 */
4577 pj_bool_t enable_turn;
4578
4579 /**
4580 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
4581 * "HOST:PORT" format.
4582 */
4583 pj_str_t turn_server;
4584
4585 /**
4586 * Specify the connection type to be used to the TURN server. Valid
4587 * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP.
4588 *
4589 * Default: PJ_TURN_TP_UDP
4590 */
4591 pj_turn_tp_type turn_conn_type;
4592
4593 /**
4594 * Specify the credential to authenticate with the TURN server.
4595 */
4596 pj_stun_auth_cred turn_auth_cred;
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004597
4598 /**
4599 * Specify idle time of sound device before it is automatically closed,
Benny Prijonof798e502009-03-09 13:08:16 +00004600 * in seconds. Use value -1 to disable the auto-close feature of sound
4601 * device
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004602 *
Benny Prijonof798e502009-03-09 13:08:16 +00004603 * Default : 1
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004604 */
4605 int snd_auto_close_time;
Benny Prijono312aff92006-06-17 04:08:30 +00004606};
4607
4608
4609/**
4610 * Use this function to initialize media config.
4611 *
4612 * @param cfg The media config to be initialized.
4613 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00004614PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00004615
4616
4617/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004618 * This structure describes codec information, which can be retrieved by
4619 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00004620 */
4621typedef struct pjsua_codec_info
4622{
4623 /**
4624 * Codec unique identification.
4625 */
4626 pj_str_t codec_id;
4627
4628 /**
4629 * Codec priority (integer 0-255).
4630 */
4631 pj_uint8_t priority;
4632
4633 /**
Nanang Izzuddin56b2ce42011-04-06 13:55:01 +00004634 * Codec description.
4635 */
4636 pj_str_t desc;
4637
4638 /**
Benny Prijono312aff92006-06-17 04:08:30 +00004639 * Internal buffer.
4640 */
Nanang Izzuddin56b2ce42011-04-06 13:55:01 +00004641 char buf_[64];
Benny Prijono312aff92006-06-17 04:08:30 +00004642
4643} pjsua_codec_info;
4644
4645
4646/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004647 * This structure descibes information about a particular media port that
4648 * has been registered into the conference bridge. Application can query
4649 * this info by calling #pjsua_conf_get_port_info().
Benny Prijono312aff92006-06-17 04:08:30 +00004650 */
4651typedef struct pjsua_conf_port_info
4652{
4653 /** Conference port number. */
4654 pjsua_conf_port_id slot_id;
4655
4656 /** Port name. */
4657 pj_str_t name;
4658
4659 /** Clock rate. */
4660 unsigned clock_rate;
4661
4662 /** Number of channels. */
4663 unsigned channel_count;
4664
4665 /** Samples per frame */
4666 unsigned samples_per_frame;
4667
4668 /** Bits per sample */
4669 unsigned bits_per_sample;
4670
4671 /** Number of listeners in the array. */
4672 unsigned listener_cnt;
4673
4674 /** Array of listeners (in other words, ports where this port is
4675 * transmitting to.
4676 */
4677 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
4678
4679} pjsua_conf_port_info;
4680
4681
4682/**
4683 * This structure holds information about custom media transport to
4684 * be registered to pjsua.
4685 */
4686typedef struct pjsua_media_transport
4687{
4688 /**
4689 * Media socket information containing the address information
4690 * of the RTP and RTCP socket.
4691 */
4692 pjmedia_sock_info skinfo;
4693
4694 /**
4695 * The media transport instance.
4696 */
4697 pjmedia_transport *transport;
4698
4699} pjsua_media_transport;
4700
4701
Benny Prijono9fc735d2006-05-28 14:58:12 +00004702/**
4703 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004704 *
4705 * @return Maximum number of ports in the conference bridge.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004706 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004707PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004708
4709
4710/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004711 * Get current number of active ports in the bridge.
4712 *
4713 * @return The number.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004714 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004715PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
4716
4717
4718/**
4719 * Enumerate all conference ports.
4720 *
4721 * @param id Array of conference port ID to be initialized.
4722 * @param count On input, specifies max elements in the array.
4723 * On return, it contains actual number of elements
4724 * that have been initialized.
4725 *
4726 * @return PJ_SUCCESS on success, or the appropriate error code.
4727 */
4728PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
4729 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004730
4731
4732/**
4733 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004734 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004735 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004736 * @param info Pointer to store the port info.
4737 *
4738 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004739 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004740PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00004741 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004742
4743
4744/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00004745 * Add arbitrary media port to PJSUA's conference bridge. Application
4746 * can use this function to add the media port that it creates. For
4747 * media ports that are created by PJSUA-LIB (such as calls, file player,
4748 * or file recorder), PJSUA-LIB will automatically add the port to
4749 * the bridge.
4750 *
4751 * @param pool Pool to use.
4752 * @param port Media port to be added to the bridge.
4753 * @param p_id Optional pointer to receive the conference
4754 * slot id.
4755 *
4756 * @return PJ_SUCCESS on success, or the appropriate error code.
4757 */
4758PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
4759 pjmedia_port *port,
4760 pjsua_conf_port_id *p_id);
4761
4762
4763/**
4764 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00004765 * call this function if it registered the port manually with previous call
4766 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00004767 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004768 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00004769 *
4770 * @return PJ_SUCCESS on success, or the appropriate error code.
4771 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004772PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00004773
4774
4775/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004776 * Establish unidirectional media flow from souce to sink. One source
4777 * may transmit to multiple destinations/sink. And if multiple
4778 * sources are transmitting to the same sink, the media will be mixed
4779 * together. Source and sink may refer to the same ID, effectively
4780 * looping the media.
4781 *
4782 * If bidirectional media flow is desired, application needs to call
4783 * this function twice, with the second one having the arguments
4784 * reversed.
4785 *
4786 * @param source Port ID of the source media/transmitter.
4787 * @param sink Port ID of the destination media/received.
4788 *
4789 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004790 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004791PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
4792 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004793
4794
4795/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004796 * Disconnect media flow from the source to destination port.
4797 *
4798 * @param source Port ID of the source media/transmitter.
4799 * @param sink Port ID of the destination media/received.
4800 *
4801 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004802 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004803PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
4804 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004805
4806
Benny Prijono6dd967c2006-12-26 02:27:14 +00004807/**
4808 * Adjust the signal level to be transmitted from the bridge to the
4809 * specified port by making it louder or quieter.
4810 *
4811 * @param slot The conference bridge slot number.
4812 * @param level Signal level adjustment. Value 1.0 means no level
4813 * adjustment, while value 0 means to mute the port.
4814 *
4815 * @return PJ_SUCCESS on success, or the appropriate error code.
4816 */
4817PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
4818 float level);
4819
4820/**
4821 * Adjust the signal level to be received from the specified port (to
4822 * the bridge) by making it louder or quieter.
4823 *
4824 * @param slot The conference bridge slot number.
4825 * @param level Signal level adjustment. Value 1.0 means no level
4826 * adjustment, while value 0 means to mute the port.
4827 *
4828 * @return PJ_SUCCESS on success, or the appropriate error code.
4829 */
4830PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
4831 float level);
4832
4833/**
4834 * Get last signal level transmitted to or received from the specified port.
4835 * The signal level is an integer value in zero to 255, with zero indicates
4836 * no signal, and 255 indicates the loudest signal level.
4837 *
4838 * @param slot The conference bridge slot number.
4839 * @param tx_level Optional argument to receive the level of signal
4840 * transmitted to the specified port (i.e. the direction
4841 * is from the bridge to the port).
4842 * @param rx_level Optional argument to receive the level of signal
4843 * received from the port (i.e. the direction is from the
4844 * port to the bridge).
4845 *
4846 * @return PJ_SUCCESS on success.
4847 */
4848PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
4849 unsigned *tx_level,
4850 unsigned *rx_level);
4851
Benny Prijono6dd967c2006-12-26 02:27:14 +00004852
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004853/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00004854 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004855 */
4856
Benny Prijono9fc735d2006-05-28 14:58:12 +00004857/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004858 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004859 * the conference bridge.
4860 *
4861 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00004862 * WAV files are supported, and the WAV file MUST be
4863 * formatted as 16bit PCM mono/single channel (any
4864 * clock rate is supported).
Benny Prijono58add7c2008-01-18 13:24:07 +00004865 * @param options Optional option flag. Application may specify
4866 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004867 * @param p_id Pointer to receive player ID.
4868 *
4869 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004870 */
4871PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004872 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004873 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004874
4875
4876/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004877 * Create a file playlist media port, and automatically add the port
4878 * to the conference bridge.
4879 *
4880 * @param file_names Array of file names to be added to the play list.
4881 * Note that the files must have the same clock rate,
4882 * number of channels, and number of bits per sample.
4883 * @param file_count Number of files in the array.
4884 * @param label Optional label to be set for the media port.
4885 * @param options Optional option flag. Application may specify
4886 * PJMEDIA_FILE_NO_LOOP to prevent looping.
4887 * @param p_id Optional pointer to receive player ID.
4888 *
4889 * @return PJ_SUCCESS on success, or the appropriate error code.
4890 */
4891PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
4892 unsigned file_count,
4893 const pj_str_t *label,
4894 unsigned options,
4895 pjsua_player_id *p_id);
4896
4897/**
4898 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004899 *
4900 * @param id The file player ID.
4901 *
4902 * @return Conference port ID associated with this player.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004903 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004904PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004905
4906
4907/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004908 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00004909 *
4910 * @param id The player ID.
4911 * @param p_port The media port associated with the player.
4912 *
4913 * @return PJ_SUCCESS on success.
4914 */
Benny Prijono58add7c2008-01-18 13:24:07 +00004915PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
Benny Prijono469b1522006-12-26 03:05:17 +00004916 pjmedia_port **p_port);
4917
4918/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004919 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004920 *
4921 * @param id The file player ID.
4922 * @param samples The playback position, in samples. Application can
4923 * specify zero to re-start the playback.
4924 *
4925 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004926 */
4927PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
4928 pj_uint32_t samples);
4929
4930
4931/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004932 * Close the file of playlist, remove the player from the bridge, and free
4933 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004934 *
4935 * @param id The file player ID.
4936 *
4937 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004938 */
4939PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
4940
4941
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004942/*****************************************************************************
4943 * File recorder.
4944 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00004945
4946/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004947 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004948 * the conference bridge. The recorder currently supports recording WAV file.
4949 * The type of the recorder to use is determined by the extension of the file
4950 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004951 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00004952 * @param filename Output file name. The function will determine the
4953 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004954 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00004955 * @param enc_type Optionally specify the type of encoder to be used to
4956 * compress the media, if the file can support different
4957 * encodings. This value must be zero for now.
4958 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004959 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00004960 * For .WAV recorder, this value must be NULL.
4961 * @param max_size Maximum file size. Specify zero or -1 to remove size
4962 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004963 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004964 * @param p_id Pointer to receive the recorder instance.
4965 *
4966 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004967 */
4968PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004969 unsigned enc_type,
4970 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004971 pj_ssize_t max_size,
4972 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004973 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004974
4975
4976/**
4977 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004978 *
4979 * @param id The recorder ID.
4980 *
4981 * @return Conference port ID associated with this recorder.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004982 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004983PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004984
4985
4986/**
Benny Prijono469b1522006-12-26 03:05:17 +00004987 * Get the media port for the recorder.
4988 *
4989 * @param id The recorder ID.
4990 * @param p_port The media port associated with the recorder.
4991 *
4992 * @return PJ_SUCCESS on success.
4993 */
4994PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4995 pjmedia_port **p_port);
4996
4997
4998/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004999 * Destroy recorder (this will complete recording).
5000 *
5001 * @param id The recorder ID.
5002 *
5003 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00005004 */
5005PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
5006
5007
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005008/*****************************************************************************
5009 * Sound devices.
5010 */
5011
Benny Prijono9fc735d2006-05-28 14:58:12 +00005012/**
Benny Prijonof798e502009-03-09 13:08:16 +00005013 * Enum all audio devices installed in the system.
5014 *
5015 * @param info Array of info to be initialized.
5016 * @param count On input, specifies max elements in the array.
5017 * On return, it contains actual number of elements
5018 * that have been initialized.
5019 *
5020 * @return PJ_SUCCESS on success, or the appropriate error code.
5021 */
5022PJ_DECL(pj_status_t) pjsua_enum_aud_devs(pjmedia_aud_dev_info info[],
5023 unsigned *count);
5024
5025/**
5026 * Enum all sound devices installed in the system (old API).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005027 *
5028 * @param info Array of info to be initialized.
5029 * @param count On input, specifies max elements in the array.
5030 * On return, it contains actual number of elements
5031 * that have been initialized.
5032 *
5033 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00005034 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005035PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
5036 unsigned *count);
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00005037
5038/**
5039 * Get currently active sound devices. If sound devices has not been created
5040 * (for example when pjsua_start() is not called), it is possible that
5041 * the function returns PJ_SUCCESS with -1 as device IDs.
5042 *
5043 * @param capture_dev On return it will be filled with device ID of the
5044 * capture device.
5045 * @param playback_dev On return it will be filled with device ID of the
5046 * device ID of the playback device.
5047 *
5048 * @return PJ_SUCCESS on success, or the appropriate error code.
5049 */
5050PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
5051 int *playback_dev);
5052
5053
Benny Prijono9fc735d2006-05-28 14:58:12 +00005054/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005055 * Select or change sound device. Application may call this function at
5056 * any time to replace current sound device.
5057 *
5058 * @param capture_dev Device ID of the capture device.
5059 * @param playback_dev Device ID of the playback device.
5060 *
5061 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00005062 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005063PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
5064 int playback_dev);
5065
5066
5067/**
5068 * Set pjsua to use null sound device. The null sound device only provides
5069 * the timing needed by the conference bridge, and will not interract with
5070 * any hardware.
5071 *
5072 * @return PJ_SUCCESS on success, or the appropriate error code.
5073 */
5074PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
5075
5076
Benny Prijonoe909eac2006-07-27 22:04:56 +00005077/**
5078 * Disconnect the main conference bridge from any sound devices, and let
5079 * application connect the bridge to it's own sound device/master port.
5080 *
5081 * @return The port interface of the conference bridge,
5082 * so that application can connect this to it's own
5083 * sound device or master port.
5084 */
5085PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
5086
5087
Benny Prijonof20687a2006-08-04 18:27:19 +00005088/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00005089 * Change the echo cancellation settings.
Benny Prijonof798e502009-03-09 13:08:16 +00005090 *
5091 * The behavior of this function depends on whether the sound device is
5092 * currently active, and if it is, whether device or software AEC is
5093 * being used.
Benny Prijono10454dc2009-02-21 14:21:59 +00005094 *
5095 * If the sound device is currently active, and if the device supports AEC,
5096 * this function will forward the change request to the device and it will
5097 * be up to the device on whether support the request. If software AEC is
5098 * being used (the software EC will be used if the device does not support
5099 * AEC), this function will change the software EC settings. In all cases,
5100 * the setting will be saved for future opening of the sound device.
5101 *
5102 * If the sound device is not currently active, this will only change the
5103 * default AEC settings and the setting will be applied next time the
5104 * sound device is opened.
Benny Prijonof20687a2006-08-04 18:27:19 +00005105 *
5106 * @param tail_ms The tail length, in miliseconds. Set to zero to
5107 * disable AEC.
Benny Prijonoa7b376b2008-01-25 16:06:33 +00005108 * @param options Options to be passed to pjmedia_echo_create().
Benny Prijono5da50432006-08-07 10:24:52 +00005109 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00005110 *
5111 * @return PJ_SUCCESS on success.
5112 */
Benny Prijono5da50432006-08-07 10:24:52 +00005113PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00005114
5115
5116/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00005117 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00005118 *
5119 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
5120 * If AEC is disabled, the value will be zero.
5121 *
5122 * @return PJ_SUCCESS on success.
5123 */
Benny Prijono22dfe592006-08-06 12:07:13 +00005124PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00005125
5126
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00005127/**
Benny Prijonof798e502009-03-09 13:08:16 +00005128 * Check whether the sound device is currently active. The sound device
5129 * may be inactive if the application has set the auto close feature to
5130 * non-zero (the snd_auto_close_time setting in #pjsua_media_config), or
5131 * if null sound device or no sound device has been configured via the
5132 * #pjsua_set_no_snd_dev() function.
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00005133 */
Benny Prijonof798e502009-03-09 13:08:16 +00005134PJ_DECL(pj_bool_t) pjsua_snd_is_active(void);
5135
5136
5137/**
5138 * Configure sound device setting to the sound device being used. If sound
5139 * device is currently active, the function will forward the setting to the
5140 * sound device instance to be applied immediately, if it supports it.
5141 *
5142 * The setting will be saved for future opening of the sound device, if the
5143 * "keep" argument is set to non-zero. If the sound device is currently
5144 * inactive, and the "keep" argument is false, this function will return
5145 * error.
5146 *
5147 * Note that in case the setting is kept for future use, it will be applied
5148 * to any devices, even when application has changed the sound device to be
5149 * used.
5150 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00005151 * Note also that the echo cancellation setting should be set with
5152 * #pjsua_set_ec() API instead.
5153 *
Benny Prijonof798e502009-03-09 13:08:16 +00005154 * See also #pjmedia_aud_stream_set_cap() for more information about setting
5155 * an audio device capability.
5156 *
5157 * @param cap The sound device setting to change.
5158 * @param pval Pointer to value. Please see #pjmedia_aud_dev_cap
5159 * documentation about the type of value to be
5160 * supplied for each setting.
5161 * @param keep Specify whether the setting is to be kept for future
5162 * use.
5163 *
5164 * @return PJ_SUCCESS on success or the appropriate error code.
5165 */
5166PJ_DECL(pj_status_t) pjsua_snd_set_setting(pjmedia_aud_dev_cap cap,
5167 const void *pval,
5168 pj_bool_t keep);
5169
5170/**
5171 * Retrieve a sound device setting. If sound device is currently active,
5172 * the function will forward the request to the sound device. If sound device
5173 * is currently inactive, and if application had previously set the setting
5174 * and mark the setting as kept, then that setting will be returned.
5175 * Otherwise, this function will return error.
5176 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00005177 * Note that echo cancellation settings should be retrieved with
5178 * #pjsua_get_ec_tail() API instead.
5179 *
Benny Prijonof798e502009-03-09 13:08:16 +00005180 * @param cap The sound device setting to retrieve.
5181 * @param pval Pointer to receive the value.
5182 * Please see #pjmedia_aud_dev_cap documentation about
5183 * the type of value to be supplied for each setting.
5184 *
5185 * @return PJ_SUCCESS on success or the appropriate error code.
5186 */
5187PJ_DECL(pj_status_t) pjsua_snd_get_setting(pjmedia_aud_dev_cap cap,
5188 void *pval);
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00005189
5190
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005191/*****************************************************************************
5192 * Codecs.
5193 */
5194
5195/**
5196 * Enum all supported codecs in the system.
5197 *
5198 * @param id Array of ID to be initialized.
5199 * @param count On input, specifies max elements in the array.
5200 * On return, it contains actual number of elements
5201 * that have been initialized.
5202 *
5203 * @return PJ_SUCCESS on success, or the appropriate error code.
5204 */
5205PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
5206 unsigned *count );
5207
5208
5209/**
5210 * Change codec priority.
5211 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00005212 * @param codec_id Codec ID, which is a string that uniquely identify
5213 * the codec (such as "speex/8000"). Please see pjsua
5214 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005215 * @param priority Codec priority, 0-255, where zero means to disable
5216 * the codec.
5217 *
5218 * @return PJ_SUCCESS on success, or the appropriate error code.
5219 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00005220PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005221 pj_uint8_t priority );
5222
5223
5224/**
5225 * Get codec parameters.
5226 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00005227 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005228 * @param param Structure to receive codec parameters.
5229 *
5230 * @return PJ_SUCCESS on success, or the appropriate error code.
5231 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00005232PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005233 pjmedia_codec_param *param );
5234
5235
5236/**
5237 * Set codec parameters.
5238 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00005239 * @param codec_id Codec ID.
Nanang Izzuddin06839e72010-01-27 11:48:31 +00005240 * @param param Codec parameter to set. Set to NULL to reset
5241 * codec parameter to library default settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005242 *
5243 * @return PJ_SUCCESS on success, or the appropriate error code.
5244 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00005245PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005246 const pjmedia_codec_param *param);
5247
Benny Prijono9f468d12011-07-07 07:46:33 +00005248
5249#if DISABLED_FOR_TICKET_1185
5250/**
5251 * Create UDP media transports for all the calls. This function creates
5252 * one UDP media transport for each call.
5253 *
5254 * @param cfg Media transport configuration. The "port" field in the
5255 * configuration is used as the start port to bind the
5256 * sockets.
5257 *
5258 * @return PJ_SUCCESS on success, or the appropriate error code.
5259 */
5260PJ_DECL(pj_status_t)
5261pjsua_media_transports_create(const pjsua_transport_config *cfg);
5262
5263
5264/**
5265 * Register custom media transports to be used by calls. There must
5266 * enough media transports for all calls.
5267 *
5268 * @param tp The media transport array.
5269 * @param count Number of elements in the array. This number MUST
5270 * match the number of maximum calls configured when
5271 * pjsua is created.
5272 * @param auto_delete Flag to indicate whether the transports should be
5273 * destroyed when pjsua is shutdown.
5274 *
5275 * @return PJ_SUCCESS on success, or the appropriate error code.
5276 */
5277PJ_DECL(pj_status_t)
5278pjsua_media_transports_attach( pjsua_media_transport tp[],
5279 unsigned count,
5280 pj_bool_t auto_delete);
5281#endif
5282
5283
5284/* end of MEDIA API */
5285/**
5286 * @}
5287 */
5288
5289
Nanang Izzuddin50fae732011-03-22 09:49:23 +00005290/*****************************************************************************
Benny Prijono9f468d12011-07-07 07:46:33 +00005291 * VIDEO API
5292 */
5293
5294
5295/**
5296 * @defgroup PJSUA_LIB_VIDEO PJSUA-API Video
5297 * @ingroup PJSUA_LIB
5298 * @brief Video support
5299 * @{
5300 */
5301
5302/*
5303 * Video devices API
5304 */
5305
5306/**
5307 * Get the number of video devices installed in the system.
5308 *
5309 * @return The number of devices.
5310 */
5311PJ_DECL(unsigned) pjsua_vid_dev_count(void);
5312
5313/**
5314 * Retrieve the video device info for the specified device index.
5315 *
5316 * @param id The device index.
5317 * @param vdi Device info to be initialized.
5318 *
5319 * @return PJ_SUCCESS on success, or the appropriate error code.
5320 */
5321PJ_DECL(pj_status_t) pjsua_vid_dev_get_info(pjmedia_vid_dev_index id,
5322 pjmedia_vid_dev_info *vdi);
5323
5324/**
5325 * Enum all video devices installed in the system.
5326 *
5327 * @param info Array of info to be initialized.
5328 * @param count On input, specifies max elements in the array.
5329 * On return, it contains actual number of elements
5330 * that have been initialized.
5331 *
5332 * @return PJ_SUCCESS on success, or the appropriate error code.
5333 */
5334PJ_DECL(pj_status_t) pjsua_vid_enum_devs(pjmedia_vid_dev_info info[],
5335 unsigned *count);
5336
5337
5338/*
5339 * Video preview API
5340 */
5341
5342/**
5343 * Parameters for starting video preview with pjsua_vid_preview_start().
5344 * Application should initialize this structure with
5345 * pjsua_vid_preview_param_default().
5346 */
5347typedef struct pjsua_vid_preview_param
5348{
5349 /**
5350 * Device ID for the video renderer to be used for rendering the
5351 * capture stream for preview.
5352 */
5353 pjmedia_vid_dev_index rend_id;
5354} pjsua_vid_preview_param;
5355
5356
5357/**
5358 * Start video preview window for the specified capture device.
5359 *
5360 * @param id The capture device ID where its preview will be
5361 * started.
5362 * @param prm Optional video preview parameters. Specify NULL
5363 * to use default values.
5364 *
5365 * @return PJ_SUCCESS on success, or the appropriate error code.
5366 */
5367PJ_DECL(pj_status_t) pjsua_vid_preview_start(pjmedia_vid_dev_index id,
5368 pjsua_vid_preview_param *prm);
5369
5370/**
5371 * Get the preview window handle associated with the capture device, if any.
5372 *
5373 * @param id The capture device ID.
5374 *
5375 * @return The window ID of the preview window for the
5376 * specified capture device ID, or NULL if preview
5377 * does not exist.
5378 */
5379PJ_DECL(pjsua_vid_win_id) pjsua_vid_preview_get_win(pjmedia_vid_dev_index id);
5380
5381/**
5382 * Stop video preview.
5383 *
5384 * @param id The capture device ID.
5385 *
5386 * @return PJ_SUCCESS on success, or the appropriate error code.
5387 */
5388PJ_DECL(pj_status_t) pjsua_vid_preview_stop(pjmedia_vid_dev_index id);
5389
5390
5391/*
5392 * Video window manipulation API.
5393 */
5394
5395/**
5396 * This structure describes video window info.
5397 */
5398typedef struct pjsua_vid_win_info
5399{
5400 /**
5401 * Window show status. The window is hidden if false.
5402 */
5403 pj_bool_t show;
5404
5405 /**
5406 * Window position.
5407 */
5408 pjmedia_coord pos;
5409
5410 /**
5411 * Window size.
5412 */
5413 pjmedia_rect_size size;
5414
5415} pjsua_vid_win_info;
5416
5417
5418/**
Nanang Izzuddinf3638022011-07-14 03:47:04 +00005419 * Enumerates all video windows.
5420 *
5421 * @param id Array of window ID to be initialized.
5422 * @param count On input, specifies max elements in the array.
5423 * On return, it contains actual number of elements
5424 * that have been initialized.
5425 *
5426 * @return PJ_SUCCESS on success, or the appropriate error code.
5427 */
5428PJ_DECL(pj_status_t) pjsua_vid_enum_wins(pjsua_vid_win_id wids[],
5429 unsigned *count);
5430
5431
5432/**
Benny Prijono9f468d12011-07-07 07:46:33 +00005433 * Get window info.
5434 *
5435 * @param wid The video window ID.
5436 * @param wi The video window info to be initialized.
5437 *
5438 * @return PJ_SUCCESS on success, or the appropriate error code.
5439 */
5440PJ_DECL(pj_status_t) pjsua_vid_win_get_info(pjsua_vid_win_id wid,
5441 pjsua_vid_win_info *wi);
5442
5443/**
5444 * Show or hide window.
5445 *
5446 * @param wid The video window ID.
5447 * @param show Set to PJ_TRUE to show the window, PJ_FALSE to
5448 * hide the window.
5449 *
5450 * @return PJ_SUCCESS on success, or the appropriate error code.
5451 */
5452PJ_DECL(pj_status_t) pjsua_vid_win_set_show(pjsua_vid_win_id wid,
5453 pj_bool_t show);
5454
5455/**
5456 * Set video window position.
5457 *
5458 * @param wid The video window ID.
5459 * @param pos The window position.
5460 *
5461 * @return PJ_SUCCESS on success, or the appropriate error code.
5462 */
5463PJ_DECL(pj_status_t) pjsua_vid_win_set_pos(pjsua_vid_win_id wid,
5464 const pjmedia_coord *pos);
5465
5466/**
5467 * Resize window.
5468 *
5469 * @param wid The video window ID.
5470 * @param size The new window size.
5471 *
5472 * @return PJ_SUCCESS on success, or the appropriate error code.
5473 */
5474PJ_DECL(pj_status_t) pjsua_vid_win_set_size(pjsua_vid_win_id wid,
5475 const pjmedia_rect_size *size);
5476
5477
5478
5479/*
5480 * Video codecs API
Nanang Izzuddin50fae732011-03-22 09:49:23 +00005481 */
5482
5483/**
5484 * Enum all supported video codecs in the system.
5485 *
5486 * @param id Array of ID to be initialized.
5487 * @param count On input, specifies max elements in the array.
5488 * On return, it contains actual number of elements
5489 * that have been initialized.
5490 *
5491 * @return PJ_SUCCESS on success, or the appropriate error code.
5492 */
5493PJ_DECL(pj_status_t) pjsua_vid_enum_codecs( pjsua_codec_info id[],
5494 unsigned *count );
5495
5496
5497/**
5498 * Change video codec priority.
5499 *
5500 * @param codec_id Codec ID, which is a string that uniquely identify
5501 * the codec (such as "H263/90000"). Please see pjsua
5502 * manual or pjmedia codec reference for details.
5503 * @param priority Codec priority, 0-255, where zero means to disable
5504 * the codec.
5505 *
5506 * @return PJ_SUCCESS on success, or the appropriate error code.
5507 */
5508PJ_DECL(pj_status_t) pjsua_vid_codec_set_priority( const pj_str_t *codec_id,
5509 pj_uint8_t priority );
5510
5511
5512/**
5513 * Get video codec parameters.
5514 *
5515 * @param codec_id Codec ID.
5516 * @param param Structure to receive video codec parameters.
5517 *
5518 * @return PJ_SUCCESS on success, or the appropriate error code.
5519 */
5520PJ_DECL(pj_status_t) pjsua_vid_codec_get_param(
5521 const pj_str_t *codec_id,
5522 pjmedia_vid_codec_param *param);
5523
5524
5525/**
5526 * Set video codec parameters.
5527 *
5528 * @param codec_id Codec ID.
5529 * @param param Codec parameter to set. Set to NULL to reset
5530 * codec parameter to library default settings.
5531 *
5532 * @return PJ_SUCCESS on success, or the appropriate error code.
5533 */
5534PJ_DECL(pj_status_t) pjsua_vid_codec_set_param(
5535 const pj_str_t *codec_id,
5536 const pjmedia_vid_codec_param *param);
5537
5538
Benny Prijonof3195072006-02-14 21:15:30 +00005539
Benny Prijono9f468d12011-07-07 07:46:33 +00005540/* end of VIDEO API */
Benny Prijono312aff92006-06-17 04:08:30 +00005541/**
5542 * @}
5543 */
5544
Benny Prijonof3195072006-02-14 21:15:30 +00005545
Benny Prijono312aff92006-06-17 04:08:30 +00005546/**
5547 * @}
5548 */
5549
Benny Prijonoe6ead542007-01-31 20:53:31 +00005550PJ_END_DECL
5551
Benny Prijono312aff92006-06-17 04:08:30 +00005552
Benny Prijono268ca612006-02-07 12:34:11 +00005553#endif /* __PJSUA_H__ */