blob: dff158a267f05e8fe1da42399c5dcfa2838432dc [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
1048
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001049} pjsua_callback;
1050
1051
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001052/**
1053 * This enumeration specifies the usage of SIP Session Timers extension.
1054 */
1055typedef enum pjsua_sip_timer_use
1056{
1057 /**
1058 * When this flag is specified, Session Timers will not be used in any
1059 * session, except it is explicitly required in the remote request.
1060 */
1061 PJSUA_SIP_TIMER_INACTIVE,
1062
1063 /**
1064 * When this flag is specified, Session Timers will be used in all
1065 * sessions whenever remote supports and uses it.
1066 */
1067 PJSUA_SIP_TIMER_OPTIONAL,
1068
1069 /**
1070 * When this flag is specified, Session Timers support will be
1071 * a requirement for the remote to be able to establish a session.
1072 */
1073 PJSUA_SIP_TIMER_REQUIRED,
1074
1075 /**
1076 * When this flag is specified, Session Timers will always be used
1077 * in all sessions, regardless whether remote supports/uses it or not.
1078 */
1079 PJSUA_SIP_TIMER_ALWAYS
1080
1081} pjsua_sip_timer_use;
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001082
Benny Prijonodc39fe82006-05-26 12:17:46 +00001083
1084/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001085 * This structure describes the settings to control the API and
1086 * user agent behavior, and can be specified when calling #pjsua_init().
1087 * Before setting the values, application must call #pjsua_config_default()
1088 * to initialize this structure with the default values.
Benny Prijonodc39fe82006-05-26 12:17:46 +00001089 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001090typedef struct pjsua_config
1091{
1092
1093 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001094 * Maximum calls to support (default: 4). The value specified here
1095 * must be smaller than the compile time maximum settings
1096 * PJSUA_MAX_CALLS, which by default is 32. To increase this
1097 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
1098 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001099 */
1100 unsigned max_calls;
1101
1102 /**
1103 * Number of worker threads. Normally application will want to have at
1104 * least one worker thread, unless when it wants to poll the library
1105 * periodically, which in this case the worker thread can be set to
1106 * zero.
1107 */
1108 unsigned thread_cnt;
1109
1110 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +00001111 * Number of nameservers. If no name server is configured, the SIP SRV
1112 * resolution would be disabled, and domain will be resolved with
1113 * standard pj_gethostbyname() function.
1114 */
1115 unsigned nameserver_count;
1116
1117 /**
1118 * Array of nameservers to be used by the SIP resolver subsystem.
1119 * The order of the name server specifies the priority (first name
1120 * server will be used first, unless it is not reachable).
1121 */
1122 pj_str_t nameserver[4];
1123
1124 /**
Benny Prijono91d06b62008-09-20 12:16:56 +00001125 * Force loose-route to be used in all route/proxy URIs (outbound_proxy
1126 * and account's proxy settings). When this setting is enabled, the
1127 * library will check all the route/proxy URIs specified in the settings
1128 * and append ";lr" parameter to the URI if the parameter is not present.
1129 *
1130 * Default: 1
1131 */
1132 pj_bool_t force_lr;
1133
1134 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001135 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001136 */
1137 unsigned outbound_proxy_cnt;
1138
1139 /**
1140 * Specify the URL of outbound proxies to visit for all outgoing requests.
1141 * The outbound proxies will be used for all accounts, and it will
1142 * be used to build the route set for outgoing requests. The final
1143 * route set for outgoing requests will consists of the outbound proxies
1144 * and the proxy configured in the account.
1145 */
1146 pj_str_t outbound_proxy[4];
1147
Benny Prijonoc97608e2007-03-23 16:34:20 +00001148 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001149 * Warning: deprecated, please use \a stun_srv field instead. To maintain
1150 * backward compatibility, if \a stun_srv_cnt is zero then the value of
1151 * this field will be copied to \a stun_srv field, if present.
1152 *
Benny Prijonoebbf6892007-03-24 17:37:25 +00001153 * Specify domain name to be resolved with DNS SRV resolution to get the
Benny Prijonof76e1392008-06-06 14:51:48 +00001154 * address of the STUN server. Alternatively application may specify
1155 * \a stun_host instead.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001156 *
1157 * If DNS SRV resolution failed for this domain, then DNS A resolution
1158 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +00001159 */
Benny Prijonoebbf6892007-03-24 17:37:25 +00001160 pj_str_t stun_domain;
1161
1162 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001163 * Warning: deprecated, please use \a stun_srv field instead. To maintain
1164 * backward compatibility, if \a stun_srv_cnt is zero then the value of
1165 * this field will be copied to \a stun_srv field, if present.
1166 *
Benny Prijonoaf09dc32007-04-22 12:48:30 +00001167 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
1168 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001169 */
1170 pj_str_t stun_host;
1171
1172 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001173 * Number of STUN server entries in \a stun_srv array.
1174 */
1175 unsigned stun_srv_cnt;
1176
1177 /**
1178 * Array of STUN servers to try. The library will try to resolve and
1179 * contact each of the STUN server entry until it finds one that is
1180 * usable. Each entry may be a domain name, host name, IP address, and
1181 * it may contain an optional port number. For example:
1182 * - "pjsip.org" (domain name)
1183 * - "sip.pjsip.org" (host name)
1184 * - "pjsip.org:33478" (domain name and a non-standard port number)
1185 * - "10.0.0.1:3478" (IP address and port number)
1186 *
1187 * When nameserver is configured in the \a pjsua_config.nameserver field,
1188 * if entry is not an IP address, it will be resolved with DNS SRV
1189 * resolution first, and it will fallback to use DNS A resolution if this
1190 * fails. Port number may be specified even if the entry is a domain name,
1191 * in case the DNS SRV resolution should fallback to a non-standard port.
1192 *
1193 * When nameserver is not configured, entries will be resolved with
1194 * #pj_gethostbyname() if it's not an IP address. Port number may be
1195 * specified if the server is not listening in standard STUN port.
1196 */
1197 pj_str_t stun_srv[8];
1198
1199 /**
1200 * This specifies if the library startup should ignore failure with the
1201 * STUN servers. If this is set to PJ_FALSE, the library will refuse to
1202 * start if it fails to resolve or contact any of the STUN servers.
1203 *
1204 * Default: PJ_TRUE
1205 */
1206 pj_bool_t stun_ignore_failure;
1207
1208 /**
Benny Prijono91a6a172007-10-31 08:59:29 +00001209 * Support for adding and parsing NAT type in the SDP to assist
1210 * troubleshooting. The valid values are:
1211 * - 0: no information will be added in SDP, and parsing is disabled.
Benny Prijono6ba8c542007-10-16 01:34:14 +00001212 * - 1: only the NAT type number is added.
1213 * - 2: add both NAT type number and name.
1214 *
Benny Prijono91a6a172007-10-31 08:59:29 +00001215 * Default: 1
Benny Prijono6ba8c542007-10-16 01:34:14 +00001216 */
1217 int nat_type_in_sdp;
1218
1219 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001220 * Specify whether support for reliable provisional response (100rel and
1221 * PRACK) should be required by default. Note that this setting can be
1222 * further customized in account configuration (#pjsua_acc_config).
1223 *
1224 * Default: PJ_FALSE
1225 */
1226 pj_bool_t require_100rel;
1227
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001228 /**
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001229 * Specify the usage of Session Timers for all sessions. See the
1230 * #pjsua_sip_timer_use for possible values. Note that this setting can be
1231 * further customized in account configuration (#pjsua_acc_config).
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001232 *
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001233 * Default: PJSUA_SIP_TIMER_OPTIONAL
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001234 */
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001235 pjsua_sip_timer_use use_timer;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001236
1237 /**
Benny Prijonofe1bd342009-11-20 23:33:07 +00001238 * Handle unsolicited NOTIFY requests containing message waiting
1239 * indication (MWI) info. Unsolicited MWI is incoming NOTIFY requests
1240 * which are not requested by client with SUBSCRIBE request.
1241 *
1242 * If this is enabled, the library will respond 200/OK to the NOTIFY
1243 * request and forward the request to \a on_mwi_info() callback.
1244 *
1245 * See also \a mwi_enabled field #on pjsua_acc_config.
1246 *
1247 * Default: PJ_TRUE
1248 *
1249 */
1250 pj_bool_t enable_unsolicited_mwi;
1251
1252 /**
Nanang Izzuddin65add622009-08-11 16:26:20 +00001253 * Specify Session Timer settings, see #pjsip_timer_setting.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001254 * Note that this setting can be further customized in account
1255 * configuration (#pjsua_acc_config).
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001256 */
Nanang Izzuddin65add622009-08-11 16:26:20 +00001257 pjsip_timer_setting timer_setting;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001258
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001259 /**
1260 * Number of credentials in the credential array.
1261 */
1262 unsigned cred_count;
1263
1264 /**
1265 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +00001266 * and can be used to authenticate against outbound proxies. If the
1267 * credential is specific to the account, then application should set
1268 * the credential in the pjsua_acc_config rather than the credential
1269 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001270 */
1271 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1272
1273 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001274 * Application callback to receive various event notifications from
1275 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001276 */
1277 pjsua_callback cb;
1278
Benny Prijono56315612006-07-18 14:39:40 +00001279 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001280 * Optional user agent string (default empty). If it's empty, no
1281 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +00001282 */
1283 pj_str_t user_agent;
1284
Benny Prijonod8179652008-01-23 20:39:07 +00001285 /**
1286 * Specify default value of secure media transport usage.
1287 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
1288 * PJMEDIA_SRTP_MANDATORY.
1289 *
1290 * Note that this setting can be further customized in account
1291 * configuration (#pjsua_acc_config).
1292 *
1293 * Default: #PJSUA_DEFAULT_USE_SRTP
1294 */
1295 pjmedia_srtp_use use_srtp;
1296
1297 /**
1298 * Specify whether SRTP requires secure signaling to be used. This option
1299 * is only used when \a use_srtp option above is non-zero.
1300 *
1301 * Valid values are:
1302 * 0: SRTP does not require secure signaling
1303 * 1: SRTP requires secure transport such as TLS
1304 * 2: SRTP requires secure end-to-end transport (SIPS)
1305 *
1306 * Note that this setting can be further customized in account
1307 * configuration (#pjsua_acc_config).
1308 *
1309 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
1310 */
1311 int srtp_secure_signaling;
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00001312
1313 /**
Benny Prijono0bc99a92011-03-17 04:34:43 +00001314 * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00001315 * duplicated media in SDP offer, i.e: unsecured and secured version.
Benny Prijono0bc99a92011-03-17 04:34:43 +00001316 * Otherwise, the SDP media will be composed as unsecured media but
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00001317 * with SDP "crypto" attribute.
1318 *
1319 * Default: PJ_FALSE
1320 */
1321 pj_bool_t srtp_optional_dup_offer;
Benny Prijonod8179652008-01-23 20:39:07 +00001322
Benny Prijono3c5e28b2008-09-24 10:10:15 +00001323 /**
1324 * Disconnect other call legs when more than one 2xx responses for
1325 * outgoing INVITE are received due to forking. Currently the library
1326 * is not able to handle simultaneous forked media, so disconnecting
1327 * the other call legs is necessary.
1328 *
1329 * With this setting enabled, the library will handle only one of the
1330 * connected call leg, and the other connected call legs will be
1331 * disconnected.
1332 *
1333 * Default: PJ_TRUE (only disable this setting for testing purposes).
1334 */
1335 pj_bool_t hangup_forked_call;
1336
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001337} pjsua_config;
1338
1339
1340/**
1341 * Use this function to initialize pjsua config.
1342 *
1343 * @param cfg pjsua config to be initialized.
1344 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001345PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001346
1347
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001348/** The implementation has been moved to sip_auth.h */
Benny Prijono7977f9f2007-10-10 11:37:56 +00001349#define pjsip_cred_dup pjsip_cred_info_dup
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001350
1351
1352/**
1353 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001354 *
1355 * @param pool The pool to get memory from.
1356 * @param dst Destination config.
1357 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001358 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001359PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1360 pjsua_config *dst,
1361 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001362
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001363
1364/**
1365 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001366 * outgoing SIP message. It can (optionally) be specified for example
1367 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1368 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1369 *
1370 * Application MUST call #pjsua_msg_data_init() to initialize this
1371 * structure before setting its values.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001372 */
Benny Prijono63fba012008-07-17 14:19:10 +00001373struct pjsua_msg_data
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001374{
1375 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001376 * Additional message headers as linked list. Application can add
1377 * headers to the list by creating the header, either from the heap/pool
1378 * or from temporary local variable, and add the header using
1379 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001380 */
1381 pjsip_hdr hdr_list;
1382
1383 /**
1384 * MIME type of optional message body.
1385 */
1386 pj_str_t content_type;
1387
1388 /**
Benny Prijono1c1d7342010-08-01 09:48:51 +00001389 * Optional message body to be added to the message, only when the
1390 * message doesn't have a body.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001391 */
1392 pj_str_t msg_body;
1393
Benny Prijono1c1d7342010-08-01 09:48:51 +00001394 /**
1395 * Content type of the multipart body. If application wants to send
1396 * multipart message bodies, it puts the parts in \a parts and set
1397 * the content type in \a multipart_ctype. If the message already
1398 * contains a body, the body will be added to the multipart bodies.
1399 */
1400 pjsip_media_type multipart_ctype;
1401
1402 /**
1403 * List of multipart parts. If application wants to send multipart
1404 * message bodies, it puts the parts in \a parts and set the content
1405 * type in \a multipart_ctype. If the message already contains a body,
1406 * the body will be added to the multipart bodies.
1407 */
1408 pjsip_multipart_part multipart_parts;
Benny Prijono63fba012008-07-17 14:19:10 +00001409};
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001410
1411
1412/**
1413 * Initialize message data.
1414 *
1415 * @param msg_data Message data to be initialized.
1416 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001417PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001418
Benny Prijono268ca612006-02-07 12:34:11 +00001419
1420/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001421 * Instantiate pjsua application. Application must call this function before
1422 * calling any other functions, to make sure that the underlying libraries
1423 * are properly initialized. Once this function has returned success,
1424 * application must call pjsua_destroy() before quitting.
1425 *
1426 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00001427 */
1428PJ_DECL(pj_status_t) pjsua_create(void);
1429
1430
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001431/** Forward declaration */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001432typedef struct pjsua_media_config pjsua_media_config;
1433
1434
Benny Prijonodc39fe82006-05-26 12:17:46 +00001435/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001436 * Initialize pjsua with the specified settings. All the settings are
1437 * optional, and the default values will be used when the config is not
1438 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001439 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001440 * Note that #pjsua_create() MUST be called before calling this function.
1441 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001442 * @param ua_cfg User agent configuration.
1443 * @param log_cfg Optional logging configuration.
1444 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001445 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001446 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001447 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001448PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1449 const pjsua_logging_config *log_cfg,
1450 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001451
1452
1453/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001454 * Application is recommended to call this function after all initialization
1455 * is done, so that the library can do additional checking set up
1456 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001457 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001458 * Application may call this function anytime after #pjsua_init().
1459 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001460 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoccf95622006-02-07 18:48:01 +00001461 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001462PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001463
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001464
Benny Prijonoccf95622006-02-07 18:48:01 +00001465/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001466 * Destroy pjsua. Application is recommended to perform graceful shutdown
1467 * before calling this function (such as unregister the account from the SIP
1468 * server, terminate presense subscription, and hangup active calls), however,
1469 * this function will do all of these if it finds there are active sessions
1470 * that need to be terminated. This function will approximately block for
1471 * one second to wait for replies from remote.
1472 *
1473 * Application.may safely call this function more than once if it doesn't
1474 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001475 *
1476 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001477 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001478PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001479
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001480
Benny Prijono9fc735d2006-05-28 14:58:12 +00001481/**
Benny Prijono0bc99a92011-03-17 04:34:43 +00001482 * Retrieve pjsua state.
1483 *
1484 * @return pjsua state.
1485 */
1486PJ_DECL(pjsua_state) pjsua_get_state(void);
1487
1488
1489/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001490 * Poll pjsua for events, and if necessary block the caller thread for
1491 * the specified maximum interval (in miliseconds).
1492 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001493 * Application doesn't normally need to call this function if it has
1494 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1495 * because polling then will be done by these worker threads instead.
1496 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001497 * @param msec_timeout Maximum time to wait, in miliseconds.
1498 *
1499 * @return The number of events that have been handled during the
1500 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001501 * can retrieve the error as (status = -return_value).
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001502 */
1503PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1504
1505
1506/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001507 * Create memory pool to be used by the application. Once application
1508 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001509 *
1510 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001511 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001512 * @param increment Increment size.
1513 *
1514 * @return The pool, or NULL when there's no memory.
1515 */
1516PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1517 pj_size_t increment);
1518
1519
1520/**
1521 * Application can call this function at any time (after pjsua_create(), of
1522 * course) to change logging settings.
1523 *
1524 * @param c Logging configuration.
1525 *
1526 * @return PJ_SUCCESS on success, or the appropriate error code.
1527 */
1528PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1529
1530
1531/**
1532 * Internal function to get SIP endpoint instance of pjsua, which is
1533 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001534 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001535 *
1536 * @return SIP endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001537 */
1538PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1539
1540/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001541 * Internal function to get media endpoint instance.
1542 * Only valid after #pjsua_init() is called.
1543 *
1544 * @return Media endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001545 */
1546PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1547
Benny Prijono97b87172006-08-24 14:25:14 +00001548/**
1549 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001550 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001551 *
1552 * @return Pool factory currently used by PJSUA.
1553 */
1554PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1555
1556
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001557
1558/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001559 * Utilities.
1560 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001561 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001562
1563/**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001564 * This structure is used to represent the result of the STUN server
1565 * resolution and testing, the #pjsua_resolve_stun_servers() function.
1566 * This structure will be passed in #pj_stun_resolve_cb callback.
1567 */
1568typedef struct pj_stun_resolve_result
1569{
1570 /**
1571 * Arbitrary data that was passed to #pjsua_resolve_stun_servers()
1572 * function.
1573 */
1574 void *token;
1575
1576 /**
1577 * This will contain PJ_SUCCESS if at least one usable STUN server
1578 * is found, otherwise it will contain the last error code during
1579 * the operation.
1580 */
1581 pj_status_t status;
1582
1583 /**
1584 * The server name that yields successful result. This will only
1585 * contain value if status is successful.
1586 */
1587 pj_str_t name;
1588
1589 /**
1590 * The server IP address. This will only contain value if status
1591 * is successful.
1592 */
1593 pj_sockaddr addr;
1594
1595} pj_stun_resolve_result;
1596
1597
1598/**
1599 * Typedef of callback to be registered to #pjsua_resolve_stun_servers().
1600 */
1601typedef void (*pj_stun_resolve_cb)(const pj_stun_resolve_result *result);
1602
1603/**
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001604 * This is a utility function to detect NAT type in front of this
1605 * endpoint. Once invoked successfully, this function will complete
Benny Prijono6ba8c542007-10-16 01:34:14 +00001606 * asynchronously and report the result in \a on_nat_detect() callback
1607 * of pjsua_callback.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001608 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001609 * After NAT has been detected and the callback is called, application can
1610 * get the detected NAT type by calling #pjsua_get_nat_type(). Application
1611 * can also perform NAT detection by calling #pjsua_detect_nat_type()
1612 * again at later time.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001613 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001614 * Note that STUN must be enabled to run this function successfully.
1615 *
1616 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001617 */
Benny Prijono6ba8c542007-10-16 01:34:14 +00001618PJ_DECL(pj_status_t) pjsua_detect_nat_type(void);
1619
1620
1621/**
1622 * Get the NAT type as detected by #pjsua_detect_nat_type() function.
1623 * This function will only return useful NAT type after #pjsua_detect_nat_type()
1624 * has completed successfully and \a on_nat_detect() callback has been called.
1625 *
1626 * @param type NAT type.
1627 *
1628 * @return When detection is in progress, this function will
1629 * return PJ_EPENDING and \a type will be set to
1630 * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been
1631 * detected successfully, this function will return
1632 * PJ_SUCCESS and \a type will be set to the correct
1633 * value. Other return values indicate error and
1634 * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN.
Benny Prijono91a6a172007-10-31 08:59:29 +00001635 *
1636 * @see pjsua_call_get_rem_nat_type()
Benny Prijono6ba8c542007-10-16 01:34:14 +00001637 */
1638PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type);
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001639
1640
1641/**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001642 * Auxiliary function to resolve and contact each of the STUN server
1643 * entries (sequentially) to find which is usable. The #pjsua_init() must
1644 * have been called before calling this function.
1645 *
1646 * @param count Number of STUN server entries to try.
1647 * @param srv Array of STUN server entries to try. Please see
1648 * the \a stun_srv field in the #pjsua_config
1649 * documentation about the format of this entry.
1650 * @param wait Specify non-zero to make the function block until
1651 * it gets the result. In this case, the function
1652 * will block while the resolution is being done,
1653 * and the callback will be called before this function
1654 * returns.
1655 * @param token Arbitrary token to be passed back to application
1656 * in the callback.
1657 * @param cb Callback to be called to notify the result of
1658 * the function.
1659 *
1660 * @return If \a wait parameter is non-zero, this will return
1661 * PJ_SUCCESS if one usable STUN server is found.
1662 * Otherwise it will always return PJ_SUCCESS, and
1663 * application will be notified about the result in
1664 * the callback.
1665 */
1666PJ_DECL(pj_status_t) pjsua_resolve_stun_servers(unsigned count,
1667 pj_str_t srv[],
1668 pj_bool_t wait,
1669 void *token,
1670 pj_stun_resolve_cb cb);
1671
1672/**
1673 * Cancel pending STUN resolution which match the specified token.
1674 *
1675 * @param token The token to match. This token was given to
1676 * #pjsua_resolve_stun_servers()
1677 * @param notify_cb Boolean to control whether the callback should
1678 * be called for cancelled resolutions. When the
1679 * callback is called, the status in the result
1680 * will be set as PJ_ECANCELLED.
1681 *
1682 * @return PJ_SUCCESS if there is at least one pending STUN
1683 * resolution cancelled, or PJ_ENOTFOUND if there is
1684 * no matching one, or other error.
1685 */
1686PJ_DECL(pj_status_t) pjsua_cancel_stun_resolution(void *token,
1687 pj_bool_t notify_cb);
1688
1689
1690/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001691 * This is a utility function to verify that valid SIP url is given. If the
Benny Prijonoc7545782010-09-28 07:43:18 +00001692 * URL is a valid SIP/SIPS scheme, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001693 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001694 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001695 *
1696 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoc7545782010-09-28 07:43:18 +00001697 *
1698 * @see pjsua_verify_url()
Benny Prijono312aff92006-06-17 04:08:30 +00001699 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001700PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001701
1702
1703/**
Benny Prijonoc7545782010-09-28 07:43:18 +00001704 * This is a utility function to verify that valid URI is given. Unlike
1705 * pjsua_verify_sip_url(), this function will return PJ_SUCCESS if tel: URI
1706 * is given.
1707 *
1708 * @param url The URL, as NULL terminated string.
1709 *
1710 * @return PJ_SUCCESS on success, or the appropriate error code.
1711 *
1712 * @see pjsua_verify_sip_url()
1713 */
1714PJ_DECL(pj_status_t) pjsua_verify_url(const char *url);
1715
1716
1717/**
Benny Prijono73bb7232009-10-20 13:56:26 +00001718 * Schedule a timer entry. Note that the timer callback may be executed
1719 * by different thread, depending on whether worker thread is enabled or
1720 * not.
1721 *
1722 * @param entry Timer heap entry.
1723 * @param delay The interval to expire.
1724 *
1725 * @return PJ_SUCCESS on success, or the appropriate error code.
1726 *
1727 * @see pjsip_endpt_schedule_timer()
1728 */
1729PJ_DECL(pj_status_t) pjsua_schedule_timer(pj_timer_entry *entry,
1730 const pj_time_val *delay);
1731
1732
1733/**
1734 * Cancel the previously scheduled timer.
1735 *
1736 * @param entry Timer heap entry.
1737 *
1738 * @see pjsip_endpt_cancel_timer()
1739 */
1740PJ_DECL(void) pjsua_cancel_timer(pj_timer_entry *entry);
1741
1742
1743/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001744 * This is a utility function to display error message for the specified
1745 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001746 *
1747 * @param sender The log sender field.
1748 * @param title Message title for the error.
1749 * @param status Status code.
1750 */
1751PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1752 pj_status_t status);
1753
1754
Benny Prijonoda9785b2007-04-02 20:43:06 +00001755/**
1756 * This is a utility function to dump the stack states to log, using
1757 * verbosity level 3.
1758 *
1759 * @param detail Will print detailed output (such as list of
1760 * SIP transactions) when non-zero.
1761 */
1762PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001763
1764/**
1765 * @}
1766 */
1767
1768
1769
1770/*****************************************************************************
1771 * TRANSPORT API
1772 */
1773
1774/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001775 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001776 * @ingroup PJSUA_LIB
1777 * @brief API for managing SIP transports
1778 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001779 *
1780 * PJSUA-API supports creating multiple transport instances, for example UDP,
1781 * TCP, and TLS transport. SIP transport must be created before adding an
1782 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001783 */
1784
1785
Benny Prijonoe6ead542007-01-31 20:53:31 +00001786/** SIP transport identification.
1787 */
Benny Prijono312aff92006-06-17 04:08:30 +00001788typedef int pjsua_transport_id;
1789
1790
1791/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001792 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001793 * and media. Before setting some values to this structure, application
1794 * MUST call #pjsua_transport_config_default() to initialize its
1795 * values with default settings.
Benny Prijono312aff92006-06-17 04:08:30 +00001796 */
1797typedef struct pjsua_transport_config
1798{
1799 /**
1800 * UDP port number to bind locally. This setting MUST be specified
1801 * even when default port is desired. If the value is zero, the
1802 * transport will be bound to any available port, and application
1803 * can query the port by querying the transport info.
1804 */
1805 unsigned port;
1806
1807 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001808 * Optional address to advertise as the address of this transport.
1809 * Application can specify any address or hostname for this field,
1810 * for example it can point to one of the interface address in the
1811 * system, or it can point to the public address of a NAT router
1812 * where port mappings have been configured for the application.
1813 *
1814 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001815 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001816 pj_str_t public_addr;
1817
1818 /**
1819 * Optional address where the socket should be bound to. This option
1820 * SHOULD only be used to selectively bind the socket to particular
1821 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1822 * published address of a transport (the public_addr field should be
1823 * used for that purpose).
1824 *
1825 * Note that unlike public_addr field, the address (or hostname) here
1826 * MUST correspond to the actual interface address in the host, since
1827 * this address will be specified as bind() argument.
1828 */
1829 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001830
1831 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001832 * This specifies TLS settings for TLS transport. It is only be used
1833 * when this transport config is being used to create a SIP TLS
1834 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001835 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001836 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001837
Benny Prijono4d79b0f2009-10-25 09:02:07 +00001838 /**
1839 * QoS traffic type to be set on this transport. When application wants
1840 * to apply QoS tagging to the transport, it's preferable to set this
1841 * field rather than \a qos_param fields since this is more portable.
1842 *
1843 * Default is QoS not set.
1844 */
1845 pj_qos_type qos_type;
1846
1847 /**
1848 * Set the low level QoS parameters to the transport. This is a lower
1849 * level operation than setting the \a qos_type field and may not be
1850 * supported on all platforms.
1851 *
1852 * Default is QoS not set.
1853 */
1854 pj_qos_params qos_params;
1855
Benny Prijono312aff92006-06-17 04:08:30 +00001856} pjsua_transport_config;
1857
1858
1859/**
1860 * Call this function to initialize UDP config with default values.
1861 *
1862 * @param cfg The UDP config to be initialized.
1863 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001864PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001865
1866
1867/**
Benny Prijono312aff92006-06-17 04:08:30 +00001868 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001869 *
1870 * @param pool The pool.
1871 * @param dst The destination config.
1872 * @param src The source config.
Benny Prijono312aff92006-06-17 04:08:30 +00001873 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001874PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1875 pjsua_transport_config *dst,
1876 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001877
1878
1879/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001880 * This structure describes transport information returned by
1881 * #pjsua_transport_get_info() function.
Benny Prijono312aff92006-06-17 04:08:30 +00001882 */
1883typedef struct pjsua_transport_info
1884{
1885 /**
1886 * PJSUA transport identification.
1887 */
1888 pjsua_transport_id id;
1889
1890 /**
1891 * Transport type.
1892 */
1893 pjsip_transport_type_e type;
1894
1895 /**
1896 * Transport type name.
1897 */
1898 pj_str_t type_name;
1899
1900 /**
1901 * Transport string info/description.
1902 */
1903 pj_str_t info;
1904
1905 /**
1906 * Transport flag (see ##pjsip_transport_flags_e).
1907 */
1908 unsigned flag;
1909
1910 /**
1911 * Local address length.
1912 */
1913 unsigned addr_len;
1914
1915 /**
1916 * Local/bound address.
1917 */
1918 pj_sockaddr local_addr;
1919
1920 /**
1921 * Published address (or transport address name).
1922 */
1923 pjsip_host_port local_name;
1924
1925 /**
1926 * Current number of objects currently referencing this transport.
1927 */
1928 unsigned usage_count;
1929
1930
1931} pjsua_transport_info;
1932
1933
1934/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001935 * Create and start a new SIP transport according to the specified
1936 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001937 *
1938 * @param type Transport type.
1939 * @param cfg Transport configuration.
1940 * @param p_id Optional pointer to receive transport ID.
1941 *
1942 * @return PJ_SUCCESS on success, or the appropriate error code.
1943 */
1944PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1945 const pjsua_transport_config *cfg,
1946 pjsua_transport_id *p_id);
1947
1948/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001949 * Register transport that has been created by application. This function
1950 * is useful if application wants to implement custom SIP transport and use
1951 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001952 *
1953 * @param tp Transport instance.
1954 * @param p_id Optional pointer to receive transport ID.
1955 *
1956 * @return PJ_SUCCESS on success, or the appropriate error code.
1957 */
1958PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1959 pjsua_transport_id *p_id);
1960
1961
1962/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001963 * Enumerate all transports currently created in the system. This function
1964 * will return all transport IDs, and application may then call
1965 * #pjsua_transport_get_info() function to retrieve detailed information
1966 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001967 *
1968 * @param id Array to receive transport ids.
1969 * @param count In input, specifies the maximum number of elements.
1970 * On return, it contains the actual number of elements.
1971 *
1972 * @return PJ_SUCCESS on success, or the appropriate error code.
1973 */
1974PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1975 unsigned *count );
1976
1977
1978/**
1979 * Get information about transports.
1980 *
1981 * @param id Transport ID.
1982 * @param info Pointer to receive transport info.
1983 *
1984 * @return PJ_SUCCESS on success, or the appropriate error code.
1985 */
1986PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1987 pjsua_transport_info *info);
1988
1989
1990/**
1991 * Disable a transport or re-enable it. By default transport is always
1992 * enabled after it is created. Disabling a transport does not necessarily
1993 * close the socket, it will only discard incoming messages and prevent
1994 * the transport from being used to send outgoing messages.
1995 *
1996 * @param id Transport ID.
1997 * @param enabled Non-zero to enable, zero to disable.
1998 *
1999 * @return PJ_SUCCESS on success, or the appropriate error code.
2000 */
2001PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
2002 pj_bool_t enabled);
2003
2004
2005/**
2006 * Close the transport. If transport is forcefully closed, it will be
2007 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00002008 * transport may not terminate properly (it may even crash). Otherwise,
2009 * the system will wait until all transactions are closed while preventing
2010 * new users from using the transport, and will close the transport when
2011 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002012 *
2013 * @param id Transport ID.
2014 * @param force Non-zero to immediately close the transport. This
2015 * is not recommended!
2016 *
2017 * @return PJ_SUCCESS on success, or the appropriate error code.
2018 */
2019PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
2020 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00002021
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002022/**
Benny Prijono312aff92006-06-17 04:08:30 +00002023 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002024 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002025
2026
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002027
2028
2029/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00002030 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00002031 */
2032
Benny Prijono312aff92006-06-17 04:08:30 +00002033
2034/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002035 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00002036 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00002037 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00002038 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00002039 *
Benny Prijono312aff92006-06-17 04:08:30 +00002040 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00002041 * using the application. In SIP terms, the identity is used as the <b>From</b>
2042 * header in outgoing requests.
2043 *
2044 * PJSUA-API supports creating and managing multiple accounts. The maximum
2045 * number of accounts is limited by a compile time constant
2046 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002047 *
2048 * Account may or may not have client registration associated with it.
2049 * An account is also associated with <b>route set</b> and some <b>authentication
2050 * credentials</b>, which are used when sending SIP request messages using the
2051 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00002052 * will be reported to remote peer when they subscribe to the account's
2053 * presence, or which is published to a presence server if presence
2054 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00002055 *
2056 * At least one account MUST be created in the application. If no user
2057 * association is required, application can create a userless account by
2058 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00002059 * instead of a particular user, and it correspond with a particular
2060 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00002061 *
2062 * Also one account must be set as the <b>default account</b>, which is used as
2063 * the account to use when PJSUA fails to match a request with any other
2064 * accounts.
2065 *
2066 * When sending outgoing SIP requests (such as making calls or sending
2067 * instant messages), normally PJSUA requires the application to specify
2068 * which account to use for the request. If no account is specified,
2069 * PJSUA may be able to select the account by matching the destination
2070 * domain name, and fall back to default account when no match is found.
2071 */
2072
2073/**
2074 * Maximum accounts.
2075 */
2076#ifndef PJSUA_MAX_ACC
2077# define PJSUA_MAX_ACC 8
2078#endif
2079
2080
2081/**
2082 * Default registration interval.
2083 */
2084#ifndef PJSUA_REG_INTERVAL
Benny Prijonobddef2c2007-10-31 13:28:08 +00002085# define PJSUA_REG_INTERVAL 300
Benny Prijono312aff92006-06-17 04:08:30 +00002086#endif
2087
2088
2089/**
Benny Prijono384dab42009-10-14 01:58:04 +00002090 * Default maximum time to wait for account unregistration transactions to
2091 * complete during library shutdown sequence.
2092 *
2093 * Default: 4000 (4 seconds)
2094 */
2095#ifndef PJSUA_UNREG_TIMEOUT
2096# define PJSUA_UNREG_TIMEOUT 4000
2097#endif
2098
2099
2100/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002101 * Default PUBLISH expiration
2102 */
2103#ifndef PJSUA_PUBLISH_EXPIRATION
Benny Prijono53984d12009-04-28 22:19:49 +00002104# define PJSUA_PUBLISH_EXPIRATION PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002105#endif
2106
2107
2108/**
Benny Prijono093d3022006-09-24 00:07:11 +00002109 * Default account priority.
2110 */
2111#ifndef PJSUA_DEFAULT_ACC_PRIORITY
2112# define PJSUA_DEFAULT_ACC_PRIORITY 0
2113#endif
2114
2115
2116/**
Benny Prijono8058a622007-06-08 04:37:05 +00002117 * This macro specifies the URI scheme to use in Contact header
2118 * when secure transport such as TLS is used. Application can specify
2119 * either "sip" or "sips".
2120 */
2121#ifndef PJSUA_SECURE_SCHEME
Benny Prijono4c82c1e2008-10-16 08:14:51 +00002122# define PJSUA_SECURE_SCHEME "sip"
Benny Prijono8058a622007-06-08 04:37:05 +00002123#endif
2124
2125
2126/**
Benny Prijono534a9ba2009-10-13 14:01:59 +00002127 * Maximum time to wait for unpublication transaction(s) to complete
2128 * during shutdown process, before sending unregistration. The library
2129 * tries to wait for the unpublication (un-PUBLISH) to complete before
2130 * sending REGISTER request to unregister the account, during library
2131 * shutdown process. If the value is set too short, it is possible that
2132 * the unregistration is sent before unpublication completes, causing
2133 * unpublication request to fail.
2134 *
2135 * Default: 2000 (2 seconds)
2136 */
2137#ifndef PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
2138# define PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC 2000
2139#endif
2140
2141
2142/**
Nanang Izzuddin36dd5b62010-03-30 11:13:59 +00002143 * Default auto retry re-registration interval, in seconds. Set to 0
2144 * to disable this. Application can set the timer on per account basis
2145 * by setting the pjsua_acc_config.reg_retry_interval field instead.
2146 *
2147 * Default: 300 (5 minutes)
2148 */
2149#ifndef PJSUA_REG_RETRY_INTERVAL
2150# define PJSUA_REG_RETRY_INTERVAL 300
2151#endif
2152
2153
2154/**
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00002155 * This macro specifies the default value for \a contact_rewrite_method
2156 * field in pjsua_acc_config. I specifies how Contact update will be
2157 * done with the registration, if \a allow_contact_rewrite is enabled in
2158 * the account config.
2159 *
2160 * If set to 1, the Contact update will be done by sending unregistration
2161 * to the currently registered Contact, while simultaneously sending new
2162 * registration (with different Call-ID) for the updated Contact.
2163 *
2164 * If set to 2, the Contact update will be done in a single, current
2165 * registration session, by removing the current binding (by setting its
2166 * Contact's expires parameter to zero) and adding a new Contact binding,
2167 * all done in a single request.
2168 *
2169 * Value 1 is the legacy behavior.
2170 *
2171 * Default value: 2
2172 */
2173#ifndef PJSUA_CONTACT_REWRITE_METHOD
2174# define PJSUA_CONTACT_REWRITE_METHOD 2
2175#endif
2176
2177
2178/**
Benny Prijono29c8ca32010-06-22 06:02:13 +00002179 * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that
2180 * the global outbound proxy list should be added to the REGISTER request.
2181 */
2182#define PJSUA_REG_USE_OUTBOUND_PROXY 1
2183
2184
2185/**
2186 * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that
2187 * the account proxy list should be added to the REGISTER request.
2188 */
2189#define PJSUA_REG_USE_ACC_PROXY 2
2190
2191
2192/**
Benny Prijonodd63b992010-10-01 02:03:42 +00002193 * This enumeration specifies how we should offer call hold request to
2194 * remote peer. The default value is set by compile time constant
2195 * PJSUA_CALL_HOLD_TYPE_DEFAULT, and application may control the setting
2196 * on per-account basis by manipulating \a call_hold_type field in
2197 * #pjsua_acc_config.
2198 */
2199typedef enum pjsua_call_hold_type
2200{
2201 /**
2202 * This will follow RFC 3264 recommendation to use a=sendonly,
2203 * a=recvonly, and a=inactive attribute as means to signal call
2204 * hold status. This is the correct value to use.
2205 */
2206 PJSUA_CALL_HOLD_TYPE_RFC3264,
2207
2208 /**
2209 * This will use the old and deprecated method as specified in RFC 2543,
2210 * and will offer c=0.0.0.0 in the SDP instead. Using this has many
2211 * drawbacks such as inability to keep the media transport alive while
2212 * the call is being put on hold, and should only be used if remote
2213 * does not understand RFC 3264 style call hold offer.
2214 */
2215 PJSUA_CALL_HOLD_TYPE_RFC2543
2216
2217} pjsua_call_hold_type;
2218
2219
2220/**
2221 * Specify the default call hold type to be used in #pjsua_acc_config.
2222 *
2223 * Default is PJSUA_CALL_HOLD_TYPE_RFC3264, and there's no reason to change
2224 * this except if you're communicating with an old/non-standard peer.
2225 */
2226#ifndef PJSUA_CALL_HOLD_TYPE_DEFAULT
2227# define PJSUA_CALL_HOLD_TYPE_DEFAULT PJSUA_CALL_HOLD_TYPE_RFC3264
2228#endif
2229
Benny Prijonodd63b992010-10-01 02:03:42 +00002230/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002231 * This structure describes account configuration to be specified when
2232 * adding a new account with #pjsua_acc_add(). Application MUST initialize
2233 * this structure first by calling #pjsua_acc_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00002234 */
2235typedef struct pjsua_acc_config
2236{
Benny Prijono093d3022006-09-24 00:07:11 +00002237 /**
Benny Prijono705e7842008-07-21 18:12:51 +00002238 * Arbitrary user data to be associated with the newly created account.
2239 * Application may set this later with #pjsua_acc_set_user_data() and
2240 * retrieve it with #pjsua_acc_get_user_data().
2241 */
2242 void *user_data;
2243
2244 /**
Benny Prijono093d3022006-09-24 00:07:11 +00002245 * Account priority, which is used to control the order of matching
2246 * incoming/outgoing requests. The higher the number means the higher
2247 * the priority is, and the account will be matched first.
2248 */
2249 int priority;
2250
Benny Prijono312aff92006-06-17 04:08:30 +00002251 /**
2252 * The full SIP URL for the account. The value can take name address or
2253 * URL format, and will look something like "sip:account@serviceprovider".
2254 *
2255 * This field is mandatory.
2256 */
2257 pj_str_t id;
2258
2259 /**
2260 * This is the URL to be put in the request URI for the registration,
2261 * and will look something like "sip:serviceprovider".
2262 *
2263 * This field should be specified if registration is desired. If the
2264 * value is empty, no account registration will be performed.
2265 */
2266 pj_str_t reg_uri;
2267
Nanang Izzuddin60e8aa92010-09-28 10:48:48 +00002268 /**
2269 * The optional custom SIP headers to be put in the registration
2270 * request.
2271 */
2272 pjsip_hdr reg_hdr_list;
2273
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002274 /**
Benny Prijonofe1bd342009-11-20 23:33:07 +00002275 * Subscribe to message waiting indication events (RFC 3842).
2276 *
2277 * See also \a enable_unsolicited_mwi field on #pjsua_config.
Benny Prijono4dd961b2009-10-26 11:21:37 +00002278 *
2279 * Default: no
2280 */
2281 pj_bool_t mwi_enabled;
2282
2283 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002284 * If this flag is set, the presence information of this account will
2285 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono48ab2b72007-11-08 09:24:30 +00002286 *
2287 * Default: PJ_FALSE
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002288 */
2289 pj_bool_t publish_enabled;
2290
Benny Prijonofe04fb52007-08-24 08:28:52 +00002291 /**
Benny Prijonofe50c9e2009-10-12 07:44:14 +00002292 * Event publication options.
2293 */
2294 pjsip_publishc_opt publish_opt;
2295
2296 /**
Benny Prijono534a9ba2009-10-13 14:01:59 +00002297 * Maximum time to wait for unpublication transaction(s) to complete
2298 * during shutdown process, before sending unregistration. The library
2299 * tries to wait for the unpublication (un-PUBLISH) to complete before
2300 * sending REGISTER request to unregister the account, during library
2301 * shutdown process. If the value is set too short, it is possible that
2302 * the unregistration is sent before unpublication completes, causing
2303 * unpublication request to fail.
2304 *
2305 * Default: PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
2306 */
2307 unsigned unpublish_max_wait_time_msec;
2308
2309 /**
Benny Prijono48ab2b72007-11-08 09:24:30 +00002310 * Authentication preference.
2311 */
2312 pjsip_auth_clt_pref auth_pref;
2313
2314 /**
Benny Prijonofe04fb52007-08-24 08:28:52 +00002315 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
2316 * is not specified, a random string will be used.
2317 */
2318 pj_str_t pidf_tuple_id;
2319
Benny Prijono312aff92006-06-17 04:08:30 +00002320 /**
2321 * Optional URI to be put as Contact for this account. It is recommended
2322 * that this field is left empty, so that the value will be calculated
2323 * automatically based on the transport address.
2324 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00002325 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00002326
2327 /**
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00002328 * Additional parameters that will be appended in the Contact header
Benny Prijono30fe4852008-12-10 16:54:16 +00002329 * for this account. This will affect the Contact header in all SIP
2330 * messages sent on behalf of this account, including but not limited to
2331 * REGISTER, INVITE, and SUBCRIBE requests or responses.
2332 *
2333 * The parameters should be preceeded by semicolon, and all strings must
2334 * be properly escaped. Example:
2335 * ";my-param=X;another-param=Hi%20there"
2336 */
2337 pj_str_t contact_params;
2338
2339 /**
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00002340 * Additional URI parameters that will be appended in the Contact URI
2341 * for this account. This will affect the Contact URI in all SIP
2342 * messages sent on behalf of this account, including but not limited to
2343 * REGISTER, INVITE, and SUBCRIBE requests or responses.
2344 *
2345 * The parameters should be preceeded by semicolon, and all strings must
2346 * be properly escaped. Example:
2347 * ";my-param=X;another-param=Hi%20there"
2348 */
2349 pj_str_t contact_uri_params;
2350
2351 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00002352 * Specify whether support for reliable provisional response (100rel and
2353 * PRACK) should be required for all sessions of this account.
2354 *
2355 * Default: PJ_FALSE
2356 */
2357 pj_bool_t require_100rel;
2358
2359 /**
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002360 * Specify the usage of Session Timers for all sessions. See the
2361 * #pjsua_sip_timer_use for possible values.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002362 *
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002363 * Default: PJSUA_SIP_TIMER_OPTIONAL
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002364 */
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002365 pjsua_sip_timer_use use_timer;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002366
2367 /**
Nanang Izzuddin65add622009-08-11 16:26:20 +00002368 * Specify Session Timer settings, see #pjsip_timer_setting.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002369 */
Nanang Izzuddin65add622009-08-11 16:26:20 +00002370 pjsip_timer_setting timer_setting;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002371
2372 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002373 * Number of proxies in the proxy array below.
2374 */
2375 unsigned proxy_cnt;
2376
2377 /**
2378 * Optional URI of the proxies to be visited for all outgoing requests
2379 * that are using this account (REGISTER, INVITE, etc). Application need
2380 * to specify these proxies if the service provider requires that requests
2381 * destined towards its network should go through certain proxies first
2382 * (for example, border controllers).
2383 *
2384 * These proxies will be put in the route set for this account, with
2385 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00002386 * first). If global outbound proxies are configured in pjsua_config,
2387 * then these account proxies will be placed after the global outbound
2388 * proxies in the routeset.
Benny Prijono312aff92006-06-17 04:08:30 +00002389 */
2390 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
2391
2392 /**
2393 * Optional interval for registration, in seconds. If the value is zero,
Benny Prijonobddef2c2007-10-31 13:28:08 +00002394 * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
Benny Prijono312aff92006-06-17 04:08:30 +00002395 */
2396 unsigned reg_timeout;
2397
Benny Prijono384dab42009-10-14 01:58:04 +00002398 /**
2399 * Specify the maximum time to wait for unregistration requests to
2400 * complete during library shutdown sequence.
2401 *
2402 * Default: PJSUA_UNREG_TIMEOUT
2403 */
2404 unsigned unreg_timeout;
2405
Benny Prijono312aff92006-06-17 04:08:30 +00002406 /**
2407 * Number of credentials in the credential array.
2408 */
2409 unsigned cred_count;
2410
2411 /**
2412 * Array of credentials. If registration is desired, normally there should
2413 * be at least one credential specified, to successfully authenticate
2414 * against the service provider. More credentials can be specified, for
2415 * example when the requests are expected to be challenged by the
2416 * proxies in the route set.
2417 */
2418 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
2419
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002420 /**
2421 * Optionally bind this account to specific transport. This normally is
2422 * not a good idea, as account should be able to send requests using
2423 * any available transports according to the destination. But some
2424 * application may want to have explicit control over the transport to
2425 * use, so in that case it can set this field.
2426 *
2427 * Default: -1 (PJSUA_INVALID_ID)
2428 *
2429 * @see pjsua_acc_set_transport()
2430 */
2431 pjsua_transport_id transport_id;
2432
Benny Prijono15b02302007-09-27 14:07:07 +00002433 /**
Benny Prijonocca2e432010-02-25 09:33:18 +00002434 * This option is used to update the transport address and the Contact
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002435 * header of REGISTER request. When this option is enabled, the library
2436 * will keep track of the public IP address from the response of REGISTER
2437 * request. Once it detects that the address has changed, it will
2438 * unregister current Contact, update the Contact with transport address
2439 * learned from Via header, and register a new Contact to the registrar.
2440 * This will also update the public name of UDP transport if STUN is
Benny Prijonocca2e432010-02-25 09:33:18 +00002441 * configured.
Benny Prijono15b02302007-09-27 14:07:07 +00002442 *
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00002443 * See also contact_rewrite_method field.
2444 *
Benny Prijono15b02302007-09-27 14:07:07 +00002445 * Default: 1 (yes)
2446 */
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002447 pj_bool_t allow_contact_rewrite;
Benny Prijono15b02302007-09-27 14:07:07 +00002448
Benny Prijonobddef2c2007-10-31 13:28:08 +00002449 /**
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00002450 * Specify how Contact update will be done with the registration, if
2451 * \a allow_contact_rewrite is enabled.
2452 *
2453 * If set to 1, the Contact update will be done by sending unregistration
2454 * to the currently registered Contact, while simultaneously sending new
2455 * registration (with different Call-ID) for the updated Contact.
2456 *
2457 * If set to 2, the Contact update will be done in a single, current
2458 * registration session, by removing the current binding (by setting its
2459 * Contact's expires parameter to zero) and adding a new Contact binding,
2460 * all done in a single request.
2461 *
2462 * Value 1 is the legacy behavior.
2463 *
2464 * Default value: PJSUA_CONTACT_REWRITE_METHOD (2)
2465 */
2466 int contact_rewrite_method;
2467
2468 /**
Benny Prijonob54719f2010-11-16 03:07:46 +00002469 * Control the use of SIP outbound feature. SIP outbound is described in
2470 * RFC 5626 to enable proxies or registrar to send inbound requests back
2471 * to UA using the same connection initiated by the UA for its
2472 * registration. This feature is highly useful in NAT-ed deployemtns,
2473 * hence it is enabled by default.
2474 *
2475 * Note: currently SIP outbound can only be used with TCP and TLS
2476 * transports. If UDP is used for the registration, the SIP outbound
2477 * feature will be silently ignored for the account.
2478 *
2479 * Default: PJ_TRUE
2480 */
2481 unsigned use_rfc5626;
2482
2483 /**
2484 * Specify SIP outbound (RFC 5626) instance ID to be used by this
2485 * application. If empty, an instance ID will be generated based on
2486 * the hostname of this agent. If application specifies this parameter, the
2487 * value will look like "<urn:uuid:00000000-0000-1000-8000-AABBCCDDEEFF>"
2488 * without the doublequote.
2489 *
2490 * Default: empty
2491 */
2492 pj_str_t rfc5626_instance_id;
2493
2494 /**
2495 * Specify SIP outbound (RFC 5626) registration ID. The default value
2496 * is empty, which would cause the library to automatically generate
2497 * a suitable value.
2498 *
2499 * Default: empty
2500 */
2501 pj_str_t rfc5626_reg_id;
2502
2503 /**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002504 * Set the interval for periodic keep-alive transmission for this account.
2505 * If this value is zero, keep-alive will be disabled for this account.
2506 * The keep-alive transmission will be sent to the registrar's address,
2507 * after successful registration.
2508 *
Benny Prijonobddef2c2007-10-31 13:28:08 +00002509 * Default: 15 (seconds)
2510 */
2511 unsigned ka_interval;
2512
2513 /**
2514 * Specify the data to be transmitted as keep-alive packets.
2515 *
2516 * Default: CR-LF
2517 */
2518 pj_str_t ka_data;
2519
Benny Prijono0bc99a92011-03-17 04:34:43 +00002520 /**
2521 * Maximum number of simultaneous active audio streams to be allowed
2522 * for calls on this account. Setting this to zero will disable audio
2523 * in calls on this account.
2524 *
2525 * Default: 1
2526 */
2527 unsigned max_audio_cnt;
2528
2529 /**
2530 * Maximum number of simultaneous active video streams to be allowed
2531 * for calls on this account. Setting this to zero will disable video
Benny Prijono9f468d12011-07-07 07:46:33 +00002532 * in calls on this account, regardless of other video settings.
Benny Prijono0bc99a92011-03-17 04:34:43 +00002533 *
Benny Prijono9f468d12011-07-07 07:46:33 +00002534 * Default: 1
Benny Prijono0bc99a92011-03-17 04:34:43 +00002535 */
2536 unsigned max_video_cnt;
2537
2538 /**
Benny Prijono9f468d12011-07-07 07:46:33 +00002539 * Specify whether incoming video should be shown to screen by default.
2540 * This applies to incoming call (INVITE), incoming re-INVITE, and
2541 * incoming UPDATE requests.
2542 *
2543 * Regardless of this setting, application can detect incoming video
2544 * by implementing \a on_call_media_state() callback and enumerating
2545 * the media stream(s) with #pjsua_call_get_info(). Once incoming
2546 * video is recognised, application may retrieve the window associated
2547 * with the incoming video and show or hide it with
2548 * #pjsua_vid_win_set_show().
2549 *
2550 * Default: PJ_FALSE
2551 */
2552 pj_bool_t vid_in_auto_show;
2553
2554 /**
2555 * Specify whether outgoing video should be activated by default when
2556 * making outgoing calls and/or when incoming video is detected. This
2557 * applies to incoming and outgoing calls, incoming re-INVITE, and
2558 * incoming UPDATE. If the setting is non-zero, outgoing video
2559 * transmission will be started as soon as response to these requests
2560 * is sent (or received).
2561 *
2562 * Regardless of the value of this setting, application can start and
2563 * stop outgoing video transmission with #pjsua_call_set_vid_out().
2564 *
2565 * Default: PJ_FALSE
2566 */
2567 pj_bool_t vid_out_auto_transmit;
2568
2569 /**
2570 * Specify the default capture device to be used by this account. If
2571 * \a vid_out_auto_transmit is enabled, this device will be used for
2572 * capturing video.
2573 *
2574 * Default: PJMEDIA_VID_DEFAULT_CAPTURE_DEV
2575 */
2576 pjmedia_vid_dev_index vid_cap_dev;
2577
2578 /**
2579 * Specify the default rendering device to be used by this account.
2580 *
2581 * Default: PJMEDIA_VID_DEFAULT_RENDER_DEV
2582 */
2583 pjmedia_vid_dev_index vid_rend_dev;
2584
2585 /**
Benny Prijono0bc99a92011-03-17 04:34:43 +00002586 * Media transport config.
2587 */
2588 pjsua_transport_config rtp_cfg;
2589
Benny Prijonod8179652008-01-23 20:39:07 +00002590 /**
2591 * Specify whether secure media transport should be used for this account.
2592 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
2593 * PJMEDIA_SRTP_MANDATORY.
2594 *
2595 * Default: #PJSUA_DEFAULT_USE_SRTP
2596 */
2597 pjmedia_srtp_use use_srtp;
2598
2599 /**
2600 * Specify whether SRTP requires secure signaling to be used. This option
2601 * is only used when \a use_srtp option above is non-zero.
2602 *
2603 * Valid values are:
2604 * 0: SRTP does not require secure signaling
2605 * 1: SRTP requires secure transport such as TLS
2606 * 2: SRTP requires secure end-to-end transport (SIPS)
2607 *
2608 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
2609 */
2610 int srtp_secure_signaling;
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00002611
2612 /**
Benny Prijono0bc99a92011-03-17 04:34:43 +00002613 * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00002614 * duplicated media in SDP offer, i.e: unsecured and secured version.
Benny Prijono0bc99a92011-03-17 04:34:43 +00002615 * Otherwise, the SDP media will be composed as unsecured media but
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00002616 * with SDP "crypto" attribute.
2617 *
2618 * Default: PJ_FALSE
2619 */
2620 pj_bool_t srtp_optional_dup_offer;
Benny Prijonod8179652008-01-23 20:39:07 +00002621
Nanang Izzuddin36dd5b62010-03-30 11:13:59 +00002622 /**
2623 * Specify interval of auto registration retry upon registration failure
2624 * (including caused by transport problem), in second. Set to 0 to
2625 * disable auto re-registration.
2626 *
2627 * Default: #PJSUA_REG_RETRY_INTERVAL
2628 */
2629 unsigned reg_retry_interval;
2630
2631 /**
2632 * Specify whether calls of the configured account should be dropped
2633 * after registration failure and an attempt of re-registration has
2634 * also failed.
2635 *
2636 * Default: PJ_FALSE (disabled)
2637 */
2638 pj_bool_t drop_calls_on_reg_fail;
2639
Benny Prijono29c8ca32010-06-22 06:02:13 +00002640 /**
2641 * Specify how the registration uses the outbound and account proxy
2642 * settings. This controls if and what Route headers will appear in
2643 * the REGISTER request of this account. The value is bitmask combination
2644 * of PJSUA_REG_USE_OUTBOUND_PROXY and PJSUA_REG_USE_ACC_PROXY bits.
2645 * If the value is set to 0, the REGISTER request will not use any proxy
2646 * (i.e. it will not have any Route headers).
2647 *
2648 * Default: 3 (PJSUA_REG_USE_OUTBOUND_PROXY | PJSUA_REG_USE_ACC_PROXY)
2649 */
2650 unsigned reg_use_proxy;
2651
Nanang Izzuddin5e39a2b2010-09-20 06:13:02 +00002652#if defined(PJMEDIA_STREAM_ENABLE_KA) && (PJMEDIA_STREAM_ENABLE_KA != 0)
2653 /**
2654 * Specify whether stream keep-alive and NAT hole punching with
2655 * non-codec-VAD mechanism (see @ref PJMEDIA_STREAM_ENABLE_KA) is enabled
2656 * for this account.
2657 *
2658 * Default: PJ_FALSE (disabled)
2659 */
2660 pj_bool_t use_stream_ka;
2661#endif
2662
Benny Prijonodd63b992010-10-01 02:03:42 +00002663 /**
2664 * Specify how to offer call hold to remote peer. Please see the
2665 * documentation on #pjsua_call_hold_type for more info.
2666 *
2667 * Default: PJSUA_CALL_HOLD_TYPE_DEFAULT
2668 */
2669 pjsua_call_hold_type call_hold_type;
2670
Benny Prijono312aff92006-06-17 04:08:30 +00002671} pjsua_acc_config;
2672
2673
2674/**
2675 * Call this function to initialize account config with default values.
2676 *
2677 * @param cfg The account config to be initialized.
2678 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00002679PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002680
2681
2682/**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002683 * Duplicate account config.
2684 *
2685 * @param pool Pool to be used for duplicating the config.
2686 * @param dst Destination configuration.
2687 * @param src Source configuration.
2688 */
2689PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
2690 pjsua_acc_config *dst,
2691 const pjsua_acc_config *src);
2692
2693
2694/**
Benny Prijono312aff92006-06-17 04:08:30 +00002695 * Account info. Application can query account info by calling
2696 * #pjsua_acc_get_info().
2697 */
2698typedef struct pjsua_acc_info
2699{
2700 /**
2701 * The account ID.
2702 */
2703 pjsua_acc_id id;
2704
2705 /**
2706 * Flag to indicate whether this is the default account.
2707 */
2708 pj_bool_t is_default;
2709
2710 /**
2711 * Account URI
2712 */
2713 pj_str_t acc_uri;
2714
2715 /**
2716 * Flag to tell whether this account has registration setting
2717 * (reg_uri is not empty).
2718 */
2719 pj_bool_t has_registration;
2720
2721 /**
2722 * An up to date expiration interval for account registration session.
2723 */
2724 int expires;
2725
2726 /**
2727 * Last registration status code. If status code is zero, the account
2728 * is currently not registered. Any other value indicates the SIP
2729 * status code of the registration.
2730 */
2731 pjsip_status_code status;
2732
2733 /**
Sauw Ming48f6dbf2010-09-07 05:10:25 +00002734 * Last registration error code. When the status field contains a SIP
2735 * status code that indicates a registration failure, last registration
2736 * error code contains the error code that causes the failure. In any
2737 * other case, its value is zero.
2738 */
2739 pj_status_t reg_last_err;
2740
2741 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002742 * String describing the registration status.
2743 */
2744 pj_str_t status_text;
2745
2746 /**
2747 * Presence online status for this account.
2748 */
2749 pj_bool_t online_status;
2750
2751 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00002752 * Presence online status text.
2753 */
2754 pj_str_t online_status_text;
2755
2756 /**
2757 * Extended RPID online status information.
2758 */
2759 pjrpid_element rpid;
2760
2761 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002762 * Buffer that is used internally to store the status text.
2763 */
2764 char buf_[PJ_ERR_MSG_SIZE];
2765
2766} pjsua_acc_info;
2767
2768
2769
2770/**
2771 * Get number of current accounts.
2772 *
2773 * @return Current number of accounts.
2774 */
2775PJ_DECL(unsigned) pjsua_acc_get_count(void);
2776
2777
2778/**
2779 * Check if the specified account ID is valid.
2780 *
2781 * @param acc_id Account ID to check.
2782 *
2783 * @return Non-zero if account ID is valid.
2784 */
2785PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
2786
2787
2788/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00002789 * Set default account to be used when incoming and outgoing
2790 * requests doesn't match any accounts.
2791 *
2792 * @param acc_id The account ID to be used as default.
2793 *
2794 * @return PJ_SUCCESS on success.
2795 */
2796PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2797
2798
2799/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002800 * Get default account to be used when receiving incoming requests (calls),
2801 * when the destination of the incoming call doesn't match any other
2802 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002803 *
2804 * @return The default account ID, or PJSUA_INVALID_ID if no
2805 * default account is configured.
2806 */
2807PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2808
2809
2810/**
Benny Prijono312aff92006-06-17 04:08:30 +00002811 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002812 * #pjsua_init()) before calling this function. If registration is configured
2813 * for this account, this function would also start the SIP registration
2814 * session with the SIP registrar server. This SIP registration session
2815 * will be maintained internally by the library, and application doesn't
2816 * need to do anything to maintain the registration session.
2817 *
Benny Prijono312aff92006-06-17 04:08:30 +00002818 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002819 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002820 * @param is_default If non-zero, this account will be set as the default
2821 * account. The default account will be used when sending
2822 * outgoing requests (e.g. making call) when no account is
2823 * specified, and when receiving incoming requests when the
2824 * request does not match any accounts. It is recommended
2825 * that default account is set to local/LAN account.
2826 * @param p_acc_id Pointer to receive account ID of the new account.
2827 *
2828 * @return PJ_SUCCESS on success, or the appropriate error code.
2829 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002830PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002831 pj_bool_t is_default,
2832 pjsua_acc_id *p_acc_id);
2833
2834
2835/**
2836 * Add a local account. A local account is used to identify local endpoint
2837 * instead of a specific user, and for this reason, a transport ID is needed
2838 * to obtain the local address information.
2839 *
2840 * @param tid Transport ID to generate account address.
2841 * @param is_default If non-zero, this account will be set as the default
2842 * account. The default account will be used when sending
2843 * outgoing requests (e.g. making call) when no account is
2844 * specified, and when receiving incoming requests when the
2845 * request does not match any accounts. It is recommended
2846 * that default account is set to local/LAN account.
2847 * @param p_acc_id Pointer to receive account ID of the new account.
2848 *
2849 * @return PJ_SUCCESS on success, or the appropriate error code.
2850 */
2851PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2852 pj_bool_t is_default,
2853 pjsua_acc_id *p_acc_id);
2854
2855/**
Benny Prijono705e7842008-07-21 18:12:51 +00002856 * Set arbitrary data to be associated with the account.
2857 *
2858 * @param acc_id The account ID.
2859 * @param user_data User/application data.
2860 *
2861 * @return PJ_SUCCESS on success, or the appropriate error code.
2862 */
2863PJ_DECL(pj_status_t) pjsua_acc_set_user_data(pjsua_acc_id acc_id,
2864 void *user_data);
2865
2866
2867/**
2868 * Retrieve arbitrary data associated with the account.
2869 *
2870 * @param acc_id The account ID.
2871 *
2872 * @return The user data. In the case where the account ID is
2873 * not valid, NULL is returned.
2874 */
2875PJ_DECL(void*) pjsua_acc_get_user_data(pjsua_acc_id acc_id);
2876
2877
2878/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002879 * Delete an account. This will unregister the account from the SIP server,
2880 * if necessary, and terminate server side presence subscriptions associated
2881 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002882 *
2883 * @param acc_id Id of the account to be deleted.
2884 *
2885 * @return PJ_SUCCESS on success, or the appropriate error code.
2886 */
2887PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2888
2889
2890/**
2891 * Modify account information.
2892 *
2893 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002894 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002895 *
2896 * @return PJ_SUCCESS on success, or the appropriate error code.
2897 */
2898PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002899 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002900
2901
2902/**
2903 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002904 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002905 * if there are server side presence subscription for this account, and/or
2906 * outgoing PUBLISH if presence publication is enabled for this account.
2907 *
2908 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002909 *
2910 * @param acc_id The account ID.
2911 * @param is_online True of false.
2912 *
2913 * @return PJ_SUCCESS on success, or the appropriate error code.
2914 */
2915PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2916 pj_bool_t is_online);
2917
Benny Prijono4461c7d2007-08-25 13:36:15 +00002918/**
2919 * Modify account's presence status to be advertised to remote/presence
2920 * subscribers. This would trigger the sending of outgoing NOTIFY request
2921 * if there are server side presence subscription for this account, and/or
2922 * outgoing PUBLISH if presence publication is enabled for this account.
2923 *
2924 * @see pjsua_acc_set_online_status()
2925 *
2926 * @param acc_id The account ID.
2927 * @param is_online True of false.
2928 * @param pr Extended information in subset of RPID format
2929 * which allows setting custom presence text.
2930 *
2931 * @return PJ_SUCCESS on success, or the appropriate error code.
2932 */
2933PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2934 pj_bool_t is_online,
2935 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002936
2937/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002938 * Update registration or perform unregistration. If registration is
2939 * configured for this account, then initial SIP REGISTER will be sent
2940 * when the account is added with #pjsua_acc_add(). Application normally
2941 * only need to call this function if it wants to manually update the
2942 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002943 *
2944 * @param acc_id The account ID.
2945 * @param renew If renew argument is zero, this will start
2946 * unregistration process.
2947 *
2948 * @return PJ_SUCCESS on success, or the appropriate error code.
2949 */
2950PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2951 pj_bool_t renew);
2952
Benny Prijono312aff92006-06-17 04:08:30 +00002953/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002954 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002955 *
2956 * @param acc_id Account identification.
2957 * @param info Pointer to receive account information.
2958 *
2959 * @return PJ_SUCCESS on success, or the appropriate error code.
2960 */
2961PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2962 pjsua_acc_info *info);
2963
2964
2965/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002966 * Enumerate all account currently active in the library. This will fill
2967 * the array with the account Ids, and application can then query the
2968 * account information for each id with #pjsua_acc_get_info().
2969 *
2970 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002971 *
2972 * @param ids Array of account IDs to be initialized.
2973 * @param count In input, specifies the maximum number of elements.
2974 * On return, it contains the actual number of elements.
2975 *
2976 * @return PJ_SUCCESS on success, or the appropriate error code.
2977 */
2978PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2979 unsigned *count );
2980
2981
2982/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002983 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002984 *
2985 * @param info Array of account infos to be initialized.
2986 * @param count In input, specifies the maximum number of elements.
2987 * On return, it contains the actual number of elements.
2988 *
2989 * @return PJ_SUCCESS on success, or the appropriate error code.
2990 */
2991PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2992 unsigned *count );
2993
2994
2995/**
2996 * This is an internal function to find the most appropriate account to
2997 * used to reach to the specified URL.
2998 *
2999 * @param url The remote URL to reach.
3000 *
3001 * @return Account id.
3002 */
3003PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
3004
3005
3006/**
3007 * This is an internal function to find the most appropriate account to be
3008 * used to handle incoming calls.
3009 *
3010 * @param rdata The incoming request message.
3011 *
3012 * @return Account id.
3013 */
3014PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
3015
3016
Benny Prijonoc570f2d2006-07-18 00:33:02 +00003017/**
Benny Prijonofff245c2007-04-02 11:44:47 +00003018 * Create arbitrary requests using the account. Application should only use
3019 * this function to create auxiliary requests outside dialog, such as
3020 * OPTIONS, and use the call or presence API to create dialog related
3021 * requests.
3022 *
3023 * @param acc_id The account ID.
3024 * @param method The SIP method of the request.
3025 * @param target Target URI.
3026 * @param p_tdata Pointer to receive the request.
3027 *
3028 * @return PJ_SUCCESS or the error code.
3029 */
3030PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
3031 const pjsip_method *method,
3032 const pj_str_t *target,
3033 pjsip_tx_data **p_tdata);
3034
3035
3036/**
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00003037 * Create a suitable Contact header value, based on the specified target URI
3038 * for the specified account.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00003039 *
3040 * @param pool Pool to allocate memory for the string.
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00003041 * @param contact The string where the Contact will be stored.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00003042 * @param acc_id Account ID.
3043 * @param uri Destination URI of the request.
3044 *
3045 * @return PJ_SUCCESS on success, other on error.
3046 */
3047PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
3048 pj_str_t *contact,
3049 pjsua_acc_id acc_id,
3050 const pj_str_t *uri);
3051
3052
3053
3054/**
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00003055 * Create a suitable Contact header value, based on the information in the
3056 * incoming request.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00003057 *
3058 * @param pool Pool to allocate memory for the string.
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00003059 * @param contact The string where the Contact will be stored.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00003060 * @param acc_id Account ID.
3061 * @param rdata Incoming request.
3062 *
3063 * @return PJ_SUCCESS on success, other on error.
3064 */
3065PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
3066 pj_str_t *contact,
3067 pjsua_acc_id acc_id,
3068 pjsip_rx_data *rdata );
3069
3070
Benny Prijono62c5c5b2007-01-13 23:22:40 +00003071/**
3072 * Lock/bind this account to a specific transport/listener. Normally
3073 * application shouldn't need to do this, as transports will be selected
3074 * automatically by the stack according to the destination.
3075 *
3076 * When account is locked/bound to a specific transport, all outgoing
3077 * requests from this account will use the specified transport (this
3078 * includes SIP registration, dialog (call and event subscription), and
3079 * out-of-dialog requests such as MESSAGE).
3080 *
3081 * Note that transport_id may be specified in pjsua_acc_config too.
3082 *
3083 * @param acc_id The account ID.
3084 * @param tp_id The transport ID.
3085 *
3086 * @return PJ_SUCCESS on success.
3087 */
3088PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
3089 pjsua_transport_id tp_id);
3090
Benny Prijono312aff92006-06-17 04:08:30 +00003091
3092/**
3093 * @}
3094 */
3095
3096
3097/*****************************************************************************
3098 * CALLS API
3099 */
3100
3101
3102/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003103 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00003104 * @ingroup PJSUA_LIB
3105 * @brief Call manipulation.
3106 * @{
3107 */
3108
3109/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003110 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00003111 */
3112#ifndef PJSUA_MAX_CALLS
3113# define PJSUA_MAX_CALLS 32
3114#endif
3115
Benny Prijono9f468d12011-07-07 07:46:33 +00003116/**
3117 * Maximum active video windows
3118 */
3119#ifndef PJSUA_MAX_VID_WINS
3120# define PJSUA_MAX_VID_WINS 16
3121#endif
3122
3123/**
3124 * Video window ID.
3125 */
3126typedef int pjsua_vid_win_id;
Benny Prijono312aff92006-06-17 04:08:30 +00003127
3128
3129/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003130 * This enumeration specifies the media status of a call, and it's part
3131 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00003132 */
3133typedef enum pjsua_call_media_status
3134{
Benny Prijono0bc99a92011-03-17 04:34:43 +00003135 /**
3136 * Call currently has no media, or the media is not used.
3137 */
Benny Prijono312aff92006-06-17 04:08:30 +00003138 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00003139
Benny Prijono0bc99a92011-03-17 04:34:43 +00003140 /**
3141 * The media is active
3142 */
Benny Prijono312aff92006-06-17 04:08:30 +00003143 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00003144
Benny Prijono0bc99a92011-03-17 04:34:43 +00003145 /**
3146 * The media is currently put on hold by local endpoint
3147 */
Benny Prijono312aff92006-06-17 04:08:30 +00003148 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00003149
Benny Prijono0bc99a92011-03-17 04:34:43 +00003150 /**
3151 * The media is currently put on hold by remote endpoint
3152 */
Benny Prijono312aff92006-06-17 04:08:30 +00003153 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00003154
Benny Prijono0bc99a92011-03-17 04:34:43 +00003155 /**
3156 * The media has reported error (e.g. ICE negotiation)
3157 */
Benny Prijono096c56c2007-09-15 08:30:16 +00003158 PJSUA_CALL_MEDIA_ERROR
3159
Benny Prijono312aff92006-06-17 04:08:30 +00003160} pjsua_call_media_status;
3161
3162
3163/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003164 * This structure describes the information and current status of a call.
Benny Prijono312aff92006-06-17 04:08:30 +00003165 */
3166typedef struct pjsua_call_info
3167{
3168 /** Call identification. */
3169 pjsua_call_id id;
3170
3171 /** Initial call role (UAC == caller) */
3172 pjsip_role_e role;
3173
Benny Prijono90315512006-09-14 16:05:16 +00003174 /** The account ID where this call belongs. */
3175 pjsua_acc_id acc_id;
3176
Benny Prijono312aff92006-06-17 04:08:30 +00003177 /** Local URI */
3178 pj_str_t local_info;
3179
3180 /** Local Contact */
3181 pj_str_t local_contact;
3182
3183 /** Remote URI */
3184 pj_str_t remote_info;
3185
3186 /** Remote contact */
3187 pj_str_t remote_contact;
3188
3189 /** Dialog Call-ID string. */
3190 pj_str_t call_id;
3191
3192 /** Call state */
3193 pjsip_inv_state state;
3194
3195 /** Text describing the state */
3196 pj_str_t state_text;
3197
3198 /** Last status code heard, which can be used as cause code */
3199 pjsip_status_code last_status;
3200
3201 /** The reason phrase describing the status. */
3202 pj_str_t last_status_text;
3203
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003204 /** Media status of the first audio stream. */
Benny Prijono312aff92006-06-17 04:08:30 +00003205 pjsua_call_media_status media_status;
3206
Benny Prijono0bc99a92011-03-17 04:34:43 +00003207 /** Media direction of the first audio stream. */
Benny Prijono312aff92006-06-17 04:08:30 +00003208 pjmedia_dir media_dir;
3209
Benny Prijono0bc99a92011-03-17 04:34:43 +00003210 /** The conference port number for the first audio stream. */
Benny Prijono312aff92006-06-17 04:08:30 +00003211 pjsua_conf_port_id conf_slot;
3212
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003213 /** Number of media streams in this call */
3214 unsigned media_cnt;
3215
3216 /** Array of media stream information */
Benny Prijono0bc99a92011-03-17 04:34:43 +00003217 struct
3218 {
3219 /** Media index in SDP. */
3220 unsigned index;
3221
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003222 /** Media type. */
3223 pjmedia_type type;
Benny Prijono0bc99a92011-03-17 04:34:43 +00003224
3225 /** Media direction. */
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003226 pjmedia_dir dir;
Benny Prijono0bc99a92011-03-17 04:34:43 +00003227
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003228 /** Call media status. */
3229 pjsua_call_media_status status;
Benny Prijono0bc99a92011-03-17 04:34:43 +00003230
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003231 /** The specific media stream info. */
3232 union {
3233 /** Audio stream */
3234 struct {
Benny Prijono9f468d12011-07-07 07:46:33 +00003235 /** The conference port number for the call. */
3236 pjsua_conf_port_id conf_slot;
3237 } aud;
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003238
3239 /** Video stream */
3240 struct {
Benny Prijono9f468d12011-07-07 07:46:33 +00003241 /**
3242 * The window id for incoming video, if any, or
3243 * PJSUA_INVALID_ID.
3244 */
3245 pjsua_vid_win_id win_in;
3246
3247 /** The video capture device for outgoing transmission,
3248 * if any, or PJMEDIA_VID_INVALID_DEV
3249 */
3250 pjmedia_vid_dev_index cap_dev;
3251
3252 } vid;
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003253 } stream;
3254
3255 } media[PJMEDIA_MAX_SDP_MEDIA];
Benny Prijono0bc99a92011-03-17 04:34:43 +00003256
Benny Prijono312aff92006-06-17 04:08:30 +00003257 /** Up-to-date call connected duration (zero when call is not
3258 * established)
3259 */
3260 pj_time_val connect_duration;
3261
3262 /** Total call duration, including set-up time */
3263 pj_time_val total_duration;
3264
3265 /** Internal */
3266 struct {
3267 char local_info[128];
3268 char local_contact[128];
3269 char remote_info[128];
3270 char remote_contact[128];
3271 char call_id[128];
3272 char last_status_text[128];
3273 } buf_;
3274
3275} pjsua_call_info;
3276
3277
Benny Prijono9f468d12011-07-07 07:46:33 +00003278/**
3279 * Media stream info.
3280 */
3281typedef struct pjsua_stream_info
3282{
3283 /** Media type of this stream. */
3284 pjmedia_type type;
3285
3286 /** Stream info (union). */
3287 union {
3288 /** Audio stream info */
3289 pjmedia_stream_info aud;
3290
3291 /** Video stream info */
3292 pjmedia_vid_stream_info vid;
3293 } info;
3294
3295} pjsua_stream_info;
3296
3297
3298/**
3299 * Media stream statistic.
3300 */
3301typedef struct pjsua_stream_stat
3302{
3303 /** RTCP statistic. */
3304 pjmedia_rtcp_stat rtcp;
3305
3306 /** Jitter buffer statistic. */
3307 pjmedia_jb_state jbuf;
3308
3309} pjsua_stream_stat;
3310
Benny Prijono312aff92006-06-17 04:08:30 +00003311
Benny Prijonoa91a0032006-02-26 21:23:45 +00003312/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00003313 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003314 *
3315 * @return Maximum number of calls configured.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003316 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003317PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003318
3319/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003320 * Get number of currently active calls.
3321 *
3322 * @return Number of currently active calls.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003323 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003324PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003325
3326/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003327 * Enumerate all active calls. Application may then query the information and
3328 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003329 *
3330 * @param ids Array of account IDs to be initialized.
3331 * @param count In input, specifies the maximum number of elements.
3332 * On return, it contains the actual number of elements.
3333 *
3334 * @return PJ_SUCCESS on success, or the appropriate error code.
3335 */
3336PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
3337 unsigned *count);
3338
3339
3340/**
3341 * Make outgoing call to the specified URI using the specified account.
3342 *
3343 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003344 * @param dst_uri URI to be put in the To header (normally is the same
3345 * as the target URI).
3346 * @param options Options (must be zero at the moment).
3347 * @param user_data Arbitrary user data to be attached to the call, and
3348 * can be retrieved later.
3349 * @param msg_data Optional headers etc to be added to outgoing INVITE
3350 * request, or NULL if no custom header is desired.
3351 * @param p_call_id Pointer to receive call identification.
3352 *
3353 * @return PJ_SUCCESS on success, or the appropriate error code.
3354 */
3355PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
3356 const pj_str_t *dst_uri,
3357 unsigned options,
3358 void *user_data,
3359 const pjsua_msg_data *msg_data,
3360 pjsua_call_id *p_call_id);
3361
3362
3363/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00003364 * Check if the specified call has active INVITE session and the INVITE
3365 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003366 *
3367 * @param call_id Call identification.
3368 *
3369 * @return Non-zero if call is active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003370 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003371PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003372
3373
3374/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003375 * Check if call has an active media session.
3376 *
3377 * @param call_id Call identification.
3378 *
3379 * @return Non-zero if yes.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003380 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003381PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003382
3383
Benny Prijonocf986c42008-09-02 11:25:07 +00003384/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003385 * Get the conference port identification associated with the call.
3386 *
3387 * @param call_id Call identification.
3388 *
Benny Prijono9f468d12011-07-07 07:46:33 +00003389 * @return Conference port ID, or PJSUA_INVALID_ID when the
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003390 * media has not been established or is not active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003391 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003392PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
3393
3394/**
3395 * Obtain detail information about the specified call.
3396 *
3397 * @param call_id Call identification.
3398 * @param info Call info to be initialized.
3399 *
3400 * @return PJ_SUCCESS on success, or the appropriate error code.
3401 */
3402PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003403 pjsua_call_info *info);
3404
Nanang Izzuddin2a1b9ee2010-06-03 10:41:32 +00003405/**
3406 * Check if remote peer support the specified capability.
3407 *
3408 * @param call_id Call identification.
3409 * @param htype The header type to be checked, which value may be:
3410 * - PJSIP_H_ACCEPT
3411 * - PJSIP_H_ALLOW
3412 * - PJSIP_H_SUPPORTED
3413 * @param hname If htype specifies PJSIP_H_OTHER, then the header
3414 * name must be supplied in this argument. Otherwise the
3415 * value must be set to NULL.
3416 * @param token The capability token to check. For example, if \a
3417 * htype is PJSIP_H_ALLOW, then \a token specifies the
3418 * method names; if \a htype is PJSIP_H_SUPPORTED, then
3419 * \a token specifies the extension names such as
3420 * "100rel".
3421 *
3422 * @return PJSIP_DIALOG_CAP_SUPPORTED if the specified capability
3423 * is explicitly supported, see @pjsip_dialog_cap_status
3424 * for more info.
3425 */
3426PJ_DECL(pjsip_dialog_cap_status) pjsua_call_remote_has_cap(
3427 pjsua_call_id call_id,
3428 int htype,
3429 const pj_str_t *hname,
3430 const pj_str_t *token);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003431
3432/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003433 * Attach application specific data to the call. Application can then
3434 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003435 *
3436 * @param call_id Call identification.
3437 * @param user_data Arbitrary data to be attached to the call.
3438 *
3439 * @return The user data.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003440 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003441PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
3442 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003443
3444
3445/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003446 * Get user data attached to the call, which has been previously set with
3447 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003448 *
3449 * @param call_id Call identification.
3450 *
3451 * @return The user data.
Benny Prijono268ca612006-02-07 12:34:11 +00003452 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003453PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00003454
3455
3456/**
Benny Prijono91a6a172007-10-31 08:59:29 +00003457 * Get the NAT type of remote's endpoint. This is a proprietary feature
3458 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
3459 * is set in #pjsua_config.
3460 *
3461 * This function can only be called after SDP has been received from remote,
3462 * which means for incoming call, this function can be called as soon as
3463 * call is received as long as incoming call contains SDP, and for outgoing
3464 * call, this function can be called only after SDP is received (normally in
3465 * 200/OK response to INVITE). As a general case, application should call
3466 * this function after or in \a on_call_media_state() callback.
3467 *
3468 * @param call_id Call identification.
3469 * @param p_type Pointer to store the NAT type. Application can then
3470 * retrieve the string description of the NAT type
3471 * by calling pj_stun_get_nat_name().
3472 *
3473 * @return PJ_SUCCESS on success.
3474 *
3475 * @see pjsua_get_nat_type(), nat_type_in_sdp
3476 */
3477PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
3478 pj_stun_nat_type *p_type);
3479
3480/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003481 * Send response to incoming INVITE request. Depending on the status
3482 * code specified as parameter, this function may send provisional
3483 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003484 *
3485 * @param call_id Incoming call identification.
3486 * @param code Status code, (100-699).
3487 * @param reason Optional reason phrase. If NULL, default text
3488 * will be used.
3489 * @param msg_data Optional list of headers etc to be added to outgoing
3490 * response message.
3491 *
3492 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoa91a0032006-02-26 21:23:45 +00003493 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003494PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
3495 unsigned code,
3496 const pj_str_t *reason,
3497 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00003498
3499/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003500 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00003501 * call state. This function is different than answering the call with
3502 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
3503 * will hangup the call regardless of the state and role of the call,
3504 * while #pjsua_call_answer() only works with incoming calls on EARLY
3505 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003506 *
3507 * @param call_id Call identification.
3508 * @param code Optional status code to be sent when we're rejecting
3509 * incoming call. If the value is zero, "603/Decline"
3510 * will be sent.
3511 * @param reason Optional reason phrase to be sent when we're rejecting
3512 * incoming call. If NULL, default text will be used.
3513 * @param msg_data Optional list of headers etc to be added to outgoing
3514 * request/response message.
3515 *
3516 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003517 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003518PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
3519 unsigned code,
3520 const pj_str_t *reason,
3521 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003522
Benny Prijono5e51a4e2008-11-27 00:06:46 +00003523/**
3524 * Accept or reject redirection response. Application MUST call this function
3525 * after it signaled PJSIP_REDIRECT_PENDING in the \a on_call_redirected()
3526 * callback, to notify the call whether to accept or reject the redirection
3527 * to the current target. Application can use the combination of
3528 * PJSIP_REDIRECT_PENDING command in \a on_call_redirected() callback and
3529 * this function to ask for user permission before redirecting the call.
3530 *
3531 * Note that if the application chooses to reject or stop redirection (by
3532 * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the
3533 * call disconnection callback will be called before this function returns.
3534 * And if the application rejects the target, the \a on_call_redirected()
3535 * callback may also be called before this function returns if there is
3536 * another target to try.
3537 *
3538 * @param call_id The call ID.
3539 * @param cmd Redirection operation to be applied to the current
3540 * target. The semantic of this argument is similar
3541 * to the description in the \a on_call_redirected()
3542 * callback, except that the PJSIP_REDIRECT_PENDING is
3543 * not accepted here.
3544 *
3545 * @return PJ_SUCCESS on successful operation.
3546 */
3547PJ_DECL(pj_status_t) pjsua_call_process_redirect(pjsua_call_id call_id,
3548 pjsip_redirect_op cmd);
Benny Prijono26ff9062006-02-21 23:47:00 +00003549
3550/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003551 * Put the specified call on hold. This will send re-INVITE with the
3552 * appropriate SDP to inform remote that the call is being put on hold.
3553 * The final status of the request itself will be reported on the
3554 * \a on_call_media_state() callback, which inform the application that
3555 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003556 *
3557 * @param call_id Call identification.
3558 * @param msg_data Optional message components to be sent with
3559 * the request.
3560 *
3561 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003562 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003563PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
3564 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003565
3566
3567/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003568 * Send re-INVITE to release hold.
3569 * The final status of the request itself will be reported on the
3570 * \a on_call_media_state() callback, which inform the application that
3571 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003572 *
3573 * @param call_id Call identification.
3574 * @param unhold If this argument is non-zero and the call is locally
3575 * held, this will release the local hold.
3576 * @param msg_data Optional message components to be sent with
3577 * the request.
3578 *
3579 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003580 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003581PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
3582 pj_bool_t unhold,
3583 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003584
Benny Prijonoc08682e2007-10-04 06:17:58 +00003585/**
3586 * Send UPDATE request.
3587 *
3588 * @param call_id Call identification.
3589 * @param options Must be zero for now.
3590 * @param msg_data Optional message components to be sent with
3591 * the request.
3592 *
3593 * @return PJ_SUCCESS on success, or the appropriate error code.
3594 */
3595PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
3596 unsigned options,
3597 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003598
3599/**
Benny Prijono053f5222006-11-11 16:16:04 +00003600 * Initiate call transfer to the specified address. This function will send
3601 * REFER request to instruct remote call party to initiate a new INVITE
3602 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003603 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00003604 * If application is interested to monitor the successfulness and
3605 * the progress of the transfer request, it can implement
3606 * \a on_call_transfer_status() callback which will report the progress
3607 * of the call transfer request.
3608 *
Benny Prijono053f5222006-11-11 16:16:04 +00003609 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003610 * @param dest Address of new target to be contacted.
3611 * @param msg_data Optional message components to be sent with
3612 * the request.
3613 *
3614 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003615 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003616PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
3617 const pj_str_t *dest,
3618 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003619
3620/**
Benny Prijono053f5222006-11-11 16:16:04 +00003621 * Flag to indicate that "Require: replaces" should not be put in the
3622 * outgoing INVITE request caused by REFER request created by
3623 * #pjsua_call_xfer_replaces().
3624 */
3625#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
3626
3627/**
3628 * Initiate attended call transfer. This function will send REFER request
3629 * to instruct remote call party to initiate new INVITE session to the URL
3630 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
3631 * the call with us with the new call from the REFER recipient.
3632 *
3633 * @param call_id The call id to be transfered.
3634 * @param dest_call_id The call id to be replaced.
3635 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
3636 * to suppress the inclusion of "Require: replaces" in
3637 * the outgoing INVITE request created by the REFER
3638 * request.
3639 * @param msg_data Optional message components to be sent with
3640 * the request.
3641 *
3642 * @return PJ_SUCCESS on success, or the appropriate error code.
3643 */
3644PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
3645 pjsua_call_id dest_call_id,
3646 unsigned options,
3647 const pjsua_msg_data *msg_data);
3648
3649/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003650 * Send DTMF digits to remote using RFC 2833 payload formats.
3651 *
3652 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003653 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003654 *
3655 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003656 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003657PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003658 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00003659
Benny Prijono26ff9062006-02-21 23:47:00 +00003660/**
Benny Prijonob0808372006-03-02 21:18:58 +00003661 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003662 *
3663 * @param call_id Call identification.
3664 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3665 * assumed.
3666 * @param content The message content.
3667 * @param msg_data Optional list of headers etc to be included in outgoing
3668 * request. The body descriptor in the msg_data is
3669 * ignored.
3670 * @param user_data Optional user data, which will be given back when
3671 * the IM callback is called.
3672 *
3673 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003674 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003675PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
3676 const pj_str_t *mime_type,
3677 const pj_str_t *content,
3678 const pjsua_msg_data *msg_data,
3679 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003680
3681
3682/**
3683 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003684 *
3685 * @param call_id Call identification.
3686 * @param is_typing Non-zero to indicate to remote that local person is
3687 * currently typing an IM.
3688 * @param msg_data Optional list of headers etc to be included in outgoing
3689 * request.
3690 *
3691 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003692 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003693PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
3694 pj_bool_t is_typing,
3695 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003696
3697/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00003698 * Send arbitrary request with the call. This is useful for example to send
3699 * INFO request. Note that application should not use this function to send
3700 * requests which would change the invite session's state, such as re-INVITE,
3701 * UPDATE, PRACK, and BYE.
3702 *
3703 * @param call_id Call identification.
3704 * @param method SIP method of the request.
3705 * @param msg_data Optional message body and/or list of headers to be
3706 * included in outgoing request.
3707 *
3708 * @return PJ_SUCCESS on success, or the appropriate error code.
3709 */
3710PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
3711 const pj_str_t *method,
3712 const pjsua_msg_data *msg_data);
3713
3714
3715/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003716 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
3717 * currently active calls.
Benny Prijono834aee32006-02-19 01:38:06 +00003718 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00003719PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00003720
3721
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003722/**
3723 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003724 *
3725 * @param call_id Call identification.
3726 * @param with_media Non-zero to include media information too.
3727 * @param buffer Buffer where the statistics are to be written to.
3728 * @param maxlen Maximum length of buffer.
3729 * @param indent Spaces for left indentation.
3730 *
3731 * @return PJ_SUCCESS on success.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003732 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003733PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
3734 pj_bool_t with_media,
3735 char *buffer,
3736 unsigned maxlen,
3737 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003738
Benny Prijono9fc735d2006-05-28 14:58:12 +00003739/**
Benny Prijono9f468d12011-07-07 07:46:33 +00003740 * Get the media stream index of the default video stream in the call.
3741 * Typically this will just retrieve the stream index of the first
3742 * activated video stream in the call.
3743 *
3744 * @param call_id Call identification.
3745 *
3746 * @return The media stream index or -1 if no video stream
3747 * is present in the call.
3748 */
3749PJ_DECL(int) pjsua_call_get_vid_stream_idx(pjsua_call_id call_id);
3750
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +00003751
Benny Prijono9f468d12011-07-07 07:46:33 +00003752/**
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +00003753 * Add, remove, modify, and/or manipulate video media stream for the
3754 * specified call. This may trigger a re-INVITE or UPDATE to be sent
3755 * for the call.
Benny Prijono9f468d12011-07-07 07:46:33 +00003756 *
3757 * @param call_id Call identification.
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +00003758 * @param op The video stream operation to be performed,
3759 * possible values are #pjsua_call_vid_strm_op.
3760 * @param param The parameters for the video stream operation.
Benny Prijono9f468d12011-07-07 07:46:33 +00003761 *
3762 * @return PJ_SUCCESS on success or the appropriate error.
3763 */
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +00003764PJ_DECL(pj_status_t) pjsua_call_set_vid_strm (
3765 pjsua_call_id call_id,
3766 pjsua_call_vid_strm_op op,
3767 const pjsua_call_vid_strm_op_param *param);
3768
Benny Prijono9f468d12011-07-07 07:46:33 +00003769
3770/**
3771 * Get media stream info for the specified media index.
3772 *
3773 * @param call_id The call identification.
3774 * @param med_idx Media stream index.
3775 * @param psi To be filled with the stream info.
3776 *
3777 * @return PJ_SUCCESS on success or the appropriate error.
3778 */
3779PJ_DECL(pj_status_t) pjsua_call_get_stream_info(pjsua_call_id call_id,
3780 unsigned med_idx,
3781 pjsua_stream_info *psi);
3782
3783/**
3784 * Get media stream statistic for the specified media index.
3785 *
3786 * @param call_id The call identification.
3787 * @param med_idx Media stream index.
3788 * @param psi To be filled with the stream statistic.
3789 *
3790 * @return PJ_SUCCESS on success or the appropriate error.
3791 */
3792PJ_DECL(pj_status_t) pjsua_call_get_stream_stat(pjsua_call_id call_id,
3793 unsigned med_idx,
3794 pjsua_stream_stat *stat);
3795
3796/**
3797 * Get media transport info for the specified media index.
3798 *
3799 * @param call_id The call identification.
3800 * @param med_idx Media stream index.
3801 * @param t To be filled with the transport info.
3802 *
3803 * @return PJ_SUCCESS on success or the appropriate error.
3804 */
3805PJ_DECL(pj_status_t) pjsua_call_get_transport_info(pjsua_call_id call_id,
3806 unsigned med_idx,
3807 pjmedia_transport_info *t);
3808
3809
3810
3811/**
Benny Prijono312aff92006-06-17 04:08:30 +00003812 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003813 */
Benny Prijono834aee32006-02-19 01:38:06 +00003814
3815
3816/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00003817 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00003818 */
3819
Benny Prijono312aff92006-06-17 04:08:30 +00003820
3821/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003822 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00003823 * @ingroup PJSUA_LIB
3824 * @brief Buddy management, buddy's presence, and instant messaging.
3825 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00003826 *
3827 * This section describes PJSUA-APIs related to buddies management,
3828 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00003829 */
3830
3831/**
3832 * Max buddies in buddy list.
3833 */
3834#ifndef PJSUA_MAX_BUDDIES
3835# define PJSUA_MAX_BUDDIES 256
3836#endif
3837
3838
3839/**
Benny Prijono6ab05322009-10-21 03:03:06 +00003840 * This specifies how long the library should wait before retrying failed
3841 * SUBSCRIBE request, and there is no rule to automatically resubscribe
3842 * (for example, no "retry-after" parameter in Subscription-State header).
3843 *
3844 * This also controls the duration before failed PUBLISH request will be
3845 * retried.
Benny Prijonoa17496a2007-10-31 10:20:31 +00003846 *
3847 * Default: 300 seconds
3848 */
3849#ifndef PJSUA_PRES_TIMER
3850# define PJSUA_PRES_TIMER 300
3851#endif
3852
3853
3854/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003855 * This structure describes buddy configuration when adding a buddy to
3856 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
3857 * the structure with #pjsua_buddy_config_default() to initialize this
3858 * structure with default configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00003859 */
3860typedef struct pjsua_buddy_config
3861{
3862 /**
3863 * Buddy URL or name address.
3864 */
3865 pj_str_t uri;
3866
3867 /**
3868 * Specify whether presence subscription should start immediately.
3869 */
3870 pj_bool_t subscribe;
3871
Benny Prijono705e7842008-07-21 18:12:51 +00003872 /**
3873 * Specify arbitrary application data to be associated with with
3874 * the buddy object.
3875 */
3876 void *user_data;
3877
Benny Prijono312aff92006-06-17 04:08:30 +00003878} pjsua_buddy_config;
3879
3880
3881/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003882 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003883 */
3884typedef enum pjsua_buddy_status
3885{
3886 /**
3887 * Online status is unknown (possibly because no presence subscription
3888 * has been established).
3889 */
3890 PJSUA_BUDDY_STATUS_UNKNOWN,
3891
3892 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003893 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003894 */
3895 PJSUA_BUDDY_STATUS_ONLINE,
3896
3897 /**
3898 * Buddy is offline.
3899 */
3900 PJSUA_BUDDY_STATUS_OFFLINE,
3901
3902} pjsua_buddy_status;
3903
3904
3905
3906/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003907 * This structure describes buddy info, which can be retrieved by calling
3908 * #pjsua_buddy_get_info().
Benny Prijono312aff92006-06-17 04:08:30 +00003909 */
3910typedef struct pjsua_buddy_info
3911{
3912 /**
3913 * The buddy ID.
3914 */
3915 pjsua_buddy_id id;
3916
3917 /**
3918 * The full URI of the buddy, as specified in the configuration.
3919 */
3920 pj_str_t uri;
3921
3922 /**
3923 * Buddy's Contact, only available when presence subscription has
3924 * been established to the buddy.
3925 */
3926 pj_str_t contact;
3927
3928 /**
3929 * Buddy's online status.
3930 */
3931 pjsua_buddy_status status;
3932
3933 /**
3934 * Text to describe buddy's online status.
3935 */
3936 pj_str_t status_text;
3937
3938 /**
3939 * Flag to indicate that we should monitor the presence information for
3940 * this buddy (normally yes, unless explicitly disabled).
3941 */
3942 pj_bool_t monitor_pres;
3943
3944 /**
Benny Prijono63fba012008-07-17 14:19:10 +00003945 * If \a monitor_pres is enabled, this specifies the last state of the
3946 * presence subscription. If presence subscription session is currently
3947 * active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence
3948 * subscription request has been rejected, the value will be
3949 * PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be
3950 * specified in \a sub_term_reason.
3951 */
3952 pjsip_evsub_state sub_state;
3953
3954 /**
Benny Prijonod06d8c52009-06-30 13:53:47 +00003955 * String representation of subscription state.
3956 */
3957 const char *sub_state_name;
3958
3959 /**
Benny Prijono73bb7232009-10-20 13:56:26 +00003960 * Specifies the last presence subscription termination code. This would
3961 * return the last status of the SUBSCRIBE request. If the subscription
3962 * is terminated with NOTIFY by the server, this value will be set to
3963 * 200, and subscription termination reason will be given in the
3964 * \a sub_term_reason field.
3965 */
3966 unsigned sub_term_code;
3967
3968 /**
3969 * Specifies the last presence subscription termination reason. If
Benny Prijono63fba012008-07-17 14:19:10 +00003970 * presence subscription is currently active, the value will be empty.
3971 */
3972 pj_str_t sub_term_reason;
3973
3974 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003975 * Extended RPID information about the person.
3976 */
3977 pjrpid_element rpid;
3978
3979 /**
Benny Prijono28add7e2009-06-15 16:03:40 +00003980 * Extended presence info.
3981 */
3982 pjsip_pres_status pres_status;
3983
3984 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003985 * Internal buffer.
3986 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003987 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003988
3989} pjsua_buddy_info;
3990
3991
Benny Prijono834aee32006-02-19 01:38:06 +00003992/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003993 * Set default values to the buddy config.
3994 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003995PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003996
3997
3998/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003999 * Get total number of buddies.
4000 *
4001 * @return Number of buddies.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004002 */
4003PJ_DECL(unsigned) pjsua_get_buddy_count(void);
4004
4005
4006/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004007 * Check if buddy ID is valid.
4008 *
4009 * @param buddy_id Buddy ID to check.
4010 *
4011 * @return Non-zero if buddy ID is valid.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004012 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004013PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
4014
4015
4016/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004017 * Enumerate all buddy IDs in the buddy list. Application then can use
4018 * #pjsua_buddy_get_info() to get the detail information for each buddy
4019 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004020 *
4021 * @param ids Array of ids to be initialized.
4022 * @param count On input, specifies max elements in the array.
4023 * On return, it contains actual number of elements
4024 * that have been initialized.
4025 *
4026 * @return PJ_SUCCESS on success, or the appropriate error code.
4027 */
4028PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
4029 unsigned *count);
4030
4031/**
Benny Prijono705e7842008-07-21 18:12:51 +00004032 * Find the buddy ID with the specified URI.
4033 *
4034 * @param uri The buddy URI.
4035 *
4036 * @return The buddy ID, or PJSUA_INVALID_ID if not found.
4037 */
4038PJ_DECL(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri);
4039
4040
4041/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004042 * Get detailed buddy info.
4043 *
4044 * @param buddy_id The buddy identification.
4045 * @param info Pointer to receive information about buddy.
4046 *
4047 * @return PJ_SUCCESS on success, or the appropriate error code.
4048 */
4049PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00004050 pjsua_buddy_info *info);
4051
4052/**
Benny Prijono705e7842008-07-21 18:12:51 +00004053 * Set the user data associated with the buddy object.
4054 *
4055 * @param buddy_id The buddy identification.
4056 * @param user_data Arbitrary application data to be associated with
4057 * the buddy object.
4058 *
4059 * @return PJ_SUCCESS on success, or the appropriate error code.
4060 */
4061PJ_DECL(pj_status_t) pjsua_buddy_set_user_data(pjsua_buddy_id buddy_id,
4062 void *user_data);
4063
4064
4065/**
4066 * Get the user data associated with the budy object.
4067 *
4068 * @param buddy_id The buddy identification.
4069 *
4070 * @return The application data.
4071 */
4072PJ_DECL(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id);
4073
4074
4075/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004076 * Add new buddy to the buddy list. If presence subscription is enabled
4077 * for this buddy, this function will also start the presence subscription
4078 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004079 *
Benny Prijonoa7b376b2008-01-25 16:06:33 +00004080 * @param buddy_cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004081 * @param p_buddy_id Pointer to receive buddy ID.
4082 *
4083 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004084 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004085PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004086 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004087
4088
4089/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004090 * Delete the specified buddy from the buddy list. Any presence subscription
4091 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004092 *
4093 * @param buddy_id Buddy identification.
4094 *
4095 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004096 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004097PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004098
4099
4100/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004101 * Enable/disable buddy's presence monitoring. Once buddy's presence is
4102 * subscribed, application will be informed about buddy's presence status
4103 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004104 *
4105 * @param buddy_id Buddy identification.
4106 * @param subscribe Specify non-zero to activate presence subscription to
4107 * the specified buddy.
4108 *
4109 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004110 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004111PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
4112 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004113
4114
4115/**
Benny Prijono10861432007-10-31 10:54:53 +00004116 * Update the presence information for the buddy. Although the library
4117 * periodically refreshes the presence subscription for all buddies, some
4118 * application may want to refresh the buddy's presence subscription
4119 * immediately, and in this case it can use this function to accomplish
4120 * this.
4121 *
4122 * Note that the buddy's presence subscription will only be initiated
4123 * if presence monitoring is enabled for the buddy. See
4124 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
4125 * for the buddy is already active, this function will not do anything.
4126 *
4127 * Once the presence subscription is activated successfully for the buddy,
4128 * application will be notified about the buddy's presence status in the
4129 * on_buddy_state() callback.
4130 *
4131 * @param buddy_id Buddy identification.
4132 *
4133 * @return PJ_SUCCESS on success, or the appropriate error code.
4134 */
4135PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
4136
4137
4138/**
Benny Prijono63fba012008-07-17 14:19:10 +00004139 * Send NOTIFY to inform account presence status or to terminate server
4140 * side presence subscription. If application wants to reject the incoming
4141 * request, it should set the \a state to PJSIP_EVSUB_STATE_TERMINATED.
4142 *
4143 * @param acc_id Account ID.
4144 * @param srv_pres Server presence subscription instance.
4145 * @param state New state to set.
4146 * @param state_str Optionally specify the state string name, if state
4147 * is not "active", "pending", or "terminated".
4148 * @param reason If the new state is PJSIP_EVSUB_STATE_TERMINATED,
4149 * optionally specify the termination reason.
4150 * @param with_body If the new state is PJSIP_EVSUB_STATE_TERMINATED,
4151 * this specifies whether the NOTIFY request should
4152 * contain message body containing account's presence
4153 * information.
4154 * @param msg_data Optional list of headers to be sent with the NOTIFY
4155 * request.
4156 *
4157 * @return PJ_SUCCESS on success.
4158 */
4159PJ_DECL(pj_status_t) pjsua_pres_notify(pjsua_acc_id acc_id,
4160 pjsua_srv_pres *srv_pres,
4161 pjsip_evsub_state state,
4162 const pj_str_t *state_str,
4163 const pj_str_t *reason,
4164 pj_bool_t with_body,
4165 const pjsua_msg_data *msg_data);
4166
4167/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004168 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004169 *
4170 * @param verbose Yes or no.
Benny Prijono834aee32006-02-19 01:38:06 +00004171 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004172PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00004173
4174
Benny Prijonob0808372006-03-02 21:18:58 +00004175/**
4176 * The MESSAGE method (defined in pjsua_im.c)
4177 */
4178extern const pjsip_method pjsip_message_method;
4179
4180
Benny Prijonob0808372006-03-02 21:18:58 +00004181
4182/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004183 * Send instant messaging outside dialog, using the specified account for
4184 * route set and authentication.
4185 *
4186 * @param acc_id Account ID to be used to send the request.
4187 * @param to Remote URI.
4188 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
4189 * assumed.
4190 * @param content The message content.
4191 * @param msg_data Optional list of headers etc to be included in outgoing
4192 * request. The body descriptor in the msg_data is
4193 * ignored.
4194 * @param user_data Optional user data, which will be given back when
4195 * the IM callback is called.
4196 *
4197 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00004198 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004199PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
4200 const pj_str_t *to,
4201 const pj_str_t *mime_type,
4202 const pj_str_t *content,
4203 const pjsua_msg_data *msg_data,
4204 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00004205
4206
4207/**
4208 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004209 *
4210 * @param acc_id Account ID to be used to send the request.
4211 * @param to Remote URI.
4212 * @param is_typing If non-zero, it tells remote person that local person
4213 * is currently composing an IM.
4214 * @param msg_data Optional list of headers etc to be added to outgoing
4215 * request.
4216 *
4217 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00004218 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004219PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
4220 const pj_str_t *to,
4221 pj_bool_t is_typing,
4222 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00004223
4224
Benny Prijonof3195072006-02-14 21:15:30 +00004225
Benny Prijono312aff92006-06-17 04:08:30 +00004226/**
4227 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00004228 */
4229
Benny Prijono312aff92006-06-17 04:08:30 +00004230
4231/*****************************************************************************
4232 * MEDIA API
4233 */
4234
4235
4236/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00004237 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00004238 * @ingroup PJSUA_LIB
4239 * @brief Media manipulation.
4240 * @{
4241 *
4242 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00004243 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
4244 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00004245 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00004246 * the interconnection between these terminations freely.
4247 *
4248 * The conference bridge provides powerful switching and mixing functionality
4249 * for application. With the conference bridge, each conference slot (e.g.
4250 * a call) can transmit to multiple destinations, and one destination can
4251 * receive from multiple sources. If more than one media terminations are
4252 * terminated in the same slot, the conference bridge will mix the signal
4253 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00004254 *
4255 * Application connects one media termination/slot to another by calling
4256 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00004257 * media flow from the source termination to the sink termination. To
4258 * establish bidirectional media flow, application wound need to make another
4259 * call to #pjsua_conf_connect(), this time inverting the source and
4260 * destination slots in the parameter.
4261 *
4262 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00004263 * the following steps:
4264 *
4265 \code
4266
4267 pj_status_t stream_to_call( pjsua_call_id call_id )
4268 {
4269 pjsua_player_id player_id;
4270
4271 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
4272 if (status != PJ_SUCCESS)
4273 return status;
4274
4275 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
4276 pjsua_call_get_conf_port() );
4277 }
4278 \endcode
4279 *
4280 *
4281 * Other features of PJSUA media:
4282 * - efficient N to M interconnections between media terminations.
4283 * - media termination can be connected to itself to create loopback
4284 * media.
4285 * - the media termination may have different clock rates, and resampling
4286 * will be done automatically by conference bridge.
4287 * - media terminations may also have different frame time; the
4288 * conference bridge will perform the necessary bufferring to adjust
4289 * the difference between terminations.
4290 * - interconnections are removed automatically when media termination
4291 * is removed from the bridge.
4292 * - sound device may be changed even when there are active media
4293 * interconnections.
4294 * - correctly report call's media quality (in #pjsua_call_dump()) from
4295 * RTCP packet exchange.
4296 */
4297
4298/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004299 * Max ports in the conference bridge. This setting is the default value
4300 * for pjsua_media_config.max_media_ports.
Benny Prijono312aff92006-06-17 04:08:30 +00004301 */
4302#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00004303# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00004304#endif
4305
Benny Prijonob5388cf2007-01-04 22:45:08 +00004306/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004307 * The default clock rate to be used by the conference bridge. This setting
4308 * is the default value for pjsua_media_config.clock_rate.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004309 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004310#ifndef PJSUA_DEFAULT_CLOCK_RATE
4311# define PJSUA_DEFAULT_CLOCK_RATE 16000
4312#endif
4313
Benny Prijonob5388cf2007-01-04 22:45:08 +00004314/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004315 * Default frame length in the conference bridge. This setting
4316 * is the default value for pjsua_media_config.audio_frame_ptime.
4317 */
4318#ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Nanang Izzuddinaf974842008-05-08 09:51:16 +00004319# define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
Benny Prijono37c710b2008-01-10 12:09:26 +00004320#endif
4321
4322
4323/**
4324 * Default codec quality settings. This setting is the default value
4325 * for pjsua_media_config.quality.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004326 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004327#ifndef PJSUA_DEFAULT_CODEC_QUALITY
Nanang Izzuddin9dbad152008-06-10 18:56:10 +00004328# define PJSUA_DEFAULT_CODEC_QUALITY 8
Benny Prijono12a669c2006-11-23 07:32:13 +00004329#endif
4330
Benny Prijonob5388cf2007-01-04 22:45:08 +00004331/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004332 * Default iLBC mode. This setting is the default value for
4333 * pjsua_media_config.ilbc_mode.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004334 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004335#ifndef PJSUA_DEFAULT_ILBC_MODE
Benny Prijono37c710b2008-01-10 12:09:26 +00004336# define PJSUA_DEFAULT_ILBC_MODE 30
Benny Prijono12a669c2006-11-23 07:32:13 +00004337#endif
4338
Benny Prijonob5388cf2007-01-04 22:45:08 +00004339/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004340 * The default echo canceller tail length. This setting
4341 * is the default value for pjsua_media_config.ec_tail_len.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004342 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004343#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijono427439c2007-10-21 09:41:24 +00004344# define PJSUA_DEFAULT_EC_TAIL_LEN 200
Benny Prijono12a669c2006-11-23 07:32:13 +00004345#endif
Benny Prijono312aff92006-06-17 04:08:30 +00004346
4347
4348/**
Benny Prijonocba59d92007-02-16 09:22:56 +00004349 * The maximum file player.
4350 */
4351#ifndef PJSUA_MAX_PLAYERS
4352# define PJSUA_MAX_PLAYERS 32
4353#endif
4354
4355
4356/**
4357 * The maximum file player.
4358 */
4359#ifndef PJSUA_MAX_RECORDERS
4360# define PJSUA_MAX_RECORDERS 32
4361#endif
4362
4363
4364/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004365 * This structure describes media configuration, which will be specified
4366 * when calling #pjsua_init(). Application MUST initialize this structure
4367 * by calling #pjsua_media_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00004368 */
4369struct pjsua_media_config
4370{
4371 /**
4372 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004373 * If value is zero, default clock rate will be used
4374 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00004375 */
4376 unsigned clock_rate;
4377
4378 /**
Benny Prijonof3758ee2008-02-26 15:32:16 +00004379 * Clock rate to be applied when opening the sound device.
4380 * If value is zero, conference bridge clock rate will be used.
4381 */
4382 unsigned snd_clock_rate;
4383
4384 /**
Benny Prijono7d60d052008-03-29 12:24:20 +00004385 * Channel count be applied when opening the sound device and
4386 * conference bridge.
4387 */
4388 unsigned channel_count;
4389
4390 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004391 * Specify audio frame ptime. The value here will affect the
4392 * samples per frame of both the sound device and the conference
4393 * bridge. Specifying lower ptime will normally reduce the
4394 * latency.
4395 *
Benny Prijono37c710b2008-01-10 12:09:26 +00004396 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004397 */
4398 unsigned audio_frame_ptime;
4399
4400 /**
Benny Prijono312aff92006-06-17 04:08:30 +00004401 * Specify maximum number of media ports to be created in the
4402 * conference bridge. Since all media terminate in the bridge
4403 * (calls, file player, file recorder, etc), the value must be
4404 * large enough to support all of them. However, the larger
4405 * the value, the more computations are performed.
Benny Prijono37c710b2008-01-10 12:09:26 +00004406 *
4407 * Default value: PJSUA_MAX_CONF_PORTS
Benny Prijono312aff92006-06-17 04:08:30 +00004408 */
4409 unsigned max_media_ports;
4410
4411 /**
4412 * Specify whether the media manager should manage its own
4413 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
4414 * and at least one worker thread will be created too. If no,
4415 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
4416 * and no worker thread is needed.
4417 *
4418 * Normally application would say yes here, unless it wants to
4419 * run everything from a single thread.
4420 */
4421 pj_bool_t has_ioqueue;
4422
4423 /**
4424 * Specify the number of worker threads to handle incoming RTP
4425 * packets. A value of one is recommended for most applications.
4426 */
4427 unsigned thread_cnt;
4428
Benny Prijono0498d902006-06-19 14:49:14 +00004429 /**
4430 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00004431 * 5-10: resampling use large filter,
4432 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00004433 * 1-2: resampling use linear.
4434 * The media quality also sets speex codec quality/complexity to the
4435 * number.
4436 *
Benny Prijono70972992006-08-05 11:13:58 +00004437 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00004438 */
4439 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00004440
4441 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004442 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00004443 *
4444 * Default: 0 (codec specific)
4445 */
4446 unsigned ptime;
4447
4448 /**
4449 * Disable VAD?
4450 *
4451 * Default: 0 (no (meaning VAD is enabled))
4452 */
4453 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00004454
4455 /**
4456 * iLBC mode (20 or 30).
4457 *
Benny Prijono37c710b2008-01-10 12:09:26 +00004458 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00004459 */
4460 unsigned ilbc_mode;
4461
4462 /**
4463 * Percentage of RTP packet to drop in TX direction
4464 * (to simulate packet lost).
4465 *
4466 * Default: 0
4467 */
4468 unsigned tx_drop_pct;
4469
4470 /**
4471 * Percentage of RTP packet to drop in RX direction
4472 * (to simulate packet lost).
4473 *
4474 * Default: 0
4475 */
4476 unsigned rx_drop_pct;
4477
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004478 /**
Benny Prijono5da50432006-08-07 10:24:52 +00004479 * Echo canceller options (see #pjmedia_echo_create())
4480 *
4481 * Default: 0.
4482 */
4483 unsigned ec_options;
4484
4485 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004486 * Echo canceller tail length, in miliseconds.
4487 *
Benny Prijono669643c2006-09-20 20:02:18 +00004488 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004489 */
4490 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004491
Benny Prijono10454dc2009-02-21 14:21:59 +00004492 /**
4493 * Audio capture buffer length, in milliseconds.
4494 *
4495 * Default: PJMEDIA_SND_DEFAULT_REC_LATENCY
4496 */
4497 unsigned snd_rec_latency;
4498
4499 /**
4500 * Audio playback buffer length, in milliseconds.
4501 *
4502 * Default: PJMEDIA_SND_DEFAULT_PLAY_LATENCY
4503 */
4504 unsigned snd_play_latency;
4505
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004506 /**
4507 * Jitter buffer initial prefetch delay in msec. The value must be
4508 * between jb_min_pre and jb_max_pre below.
4509 *
4510 * Default: -1 (to use default stream settings, currently 150 msec)
4511 */
4512 int jb_init;
4513
4514 /**
4515 * Jitter buffer minimum prefetch delay in msec.
4516 *
4517 * Default: -1 (to use default stream settings, currently 60 msec)
4518 */
4519 int jb_min_pre;
4520
4521 /**
4522 * Jitter buffer maximum prefetch delay in msec.
4523 *
4524 * Default: -1 (to use default stream settings, currently 240 msec)
4525 */
4526 int jb_max_pre;
4527
4528 /**
4529 * Set maximum delay that can be accomodated by the jitter buffer msec.
4530 *
4531 * Default: -1 (to use default stream settings, currently 360 msec)
4532 */
4533 int jb_max;
4534
Benny Prijonoc97608e2007-03-23 16:34:20 +00004535 /**
4536 * Enable ICE
4537 */
4538 pj_bool_t enable_ice;
4539
4540 /**
Benny Prijono329d6382009-05-29 13:04:03 +00004541 * Set the maximum number of host candidates.
4542 *
4543 * Default: -1 (maximum not set)
Benny Prijonoc97608e2007-03-23 16:34:20 +00004544 */
Benny Prijono329d6382009-05-29 13:04:03 +00004545 int ice_max_host_cands;
4546
4547 /**
4548 * ICE session options.
4549 */
4550 pj_ice_sess_options ice_opt;
Benny Prijonof76e1392008-06-06 14:51:48 +00004551
4552 /**
Benny Prijono551af422008-08-07 09:55:52 +00004553 * Disable RTCP component.
4554 *
4555 * Default: no
4556 */
4557 pj_bool_t ice_no_rtcp;
4558
4559 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00004560 * Enable TURN relay candidate in ICE.
4561 */
4562 pj_bool_t enable_turn;
4563
4564 /**
4565 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
4566 * "HOST:PORT" format.
4567 */
4568 pj_str_t turn_server;
4569
4570 /**
4571 * Specify the connection type to be used to the TURN server. Valid
4572 * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP.
4573 *
4574 * Default: PJ_TURN_TP_UDP
4575 */
4576 pj_turn_tp_type turn_conn_type;
4577
4578 /**
4579 * Specify the credential to authenticate with the TURN server.
4580 */
4581 pj_stun_auth_cred turn_auth_cred;
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004582
4583 /**
4584 * Specify idle time of sound device before it is automatically closed,
Benny Prijonof798e502009-03-09 13:08:16 +00004585 * in seconds. Use value -1 to disable the auto-close feature of sound
4586 * device
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004587 *
Benny Prijonof798e502009-03-09 13:08:16 +00004588 * Default : 1
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004589 */
4590 int snd_auto_close_time;
Benny Prijono312aff92006-06-17 04:08:30 +00004591};
4592
4593
4594/**
4595 * Use this function to initialize media config.
4596 *
4597 * @param cfg The media config to be initialized.
4598 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00004599PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00004600
4601
4602/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004603 * This structure describes codec information, which can be retrieved by
4604 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00004605 */
4606typedef struct pjsua_codec_info
4607{
4608 /**
4609 * Codec unique identification.
4610 */
4611 pj_str_t codec_id;
4612
4613 /**
4614 * Codec priority (integer 0-255).
4615 */
4616 pj_uint8_t priority;
4617
4618 /**
Nanang Izzuddin56b2ce42011-04-06 13:55:01 +00004619 * Codec description.
4620 */
4621 pj_str_t desc;
4622
4623 /**
Benny Prijono312aff92006-06-17 04:08:30 +00004624 * Internal buffer.
4625 */
Nanang Izzuddin56b2ce42011-04-06 13:55:01 +00004626 char buf_[64];
Benny Prijono312aff92006-06-17 04:08:30 +00004627
4628} pjsua_codec_info;
4629
4630
4631/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004632 * This structure descibes information about a particular media port that
4633 * has been registered into the conference bridge. Application can query
4634 * this info by calling #pjsua_conf_get_port_info().
Benny Prijono312aff92006-06-17 04:08:30 +00004635 */
4636typedef struct pjsua_conf_port_info
4637{
4638 /** Conference port number. */
4639 pjsua_conf_port_id slot_id;
4640
4641 /** Port name. */
4642 pj_str_t name;
4643
4644 /** Clock rate. */
4645 unsigned clock_rate;
4646
4647 /** Number of channels. */
4648 unsigned channel_count;
4649
4650 /** Samples per frame */
4651 unsigned samples_per_frame;
4652
4653 /** Bits per sample */
4654 unsigned bits_per_sample;
4655
4656 /** Number of listeners in the array. */
4657 unsigned listener_cnt;
4658
4659 /** Array of listeners (in other words, ports where this port is
4660 * transmitting to.
4661 */
4662 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
4663
4664} pjsua_conf_port_info;
4665
4666
4667/**
4668 * This structure holds information about custom media transport to
4669 * be registered to pjsua.
4670 */
4671typedef struct pjsua_media_transport
4672{
4673 /**
4674 * Media socket information containing the address information
4675 * of the RTP and RTCP socket.
4676 */
4677 pjmedia_sock_info skinfo;
4678
4679 /**
4680 * The media transport instance.
4681 */
4682 pjmedia_transport *transport;
4683
4684} pjsua_media_transport;
4685
4686
Benny Prijono9fc735d2006-05-28 14:58:12 +00004687/**
4688 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004689 *
4690 * @return Maximum number of ports in the conference bridge.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004691 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004692PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004693
4694
4695/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004696 * Get current number of active ports in the bridge.
4697 *
4698 * @return The number.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004699 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004700PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
4701
4702
4703/**
4704 * Enumerate all conference ports.
4705 *
4706 * @param id Array of conference port ID to be initialized.
4707 * @param count On input, specifies max elements in the array.
4708 * On return, it contains actual number of elements
4709 * that have been initialized.
4710 *
4711 * @return PJ_SUCCESS on success, or the appropriate error code.
4712 */
4713PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
4714 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004715
4716
4717/**
4718 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004719 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004720 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004721 * @param info Pointer to store the port info.
4722 *
4723 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004724 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004725PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00004726 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004727
4728
4729/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00004730 * Add arbitrary media port to PJSUA's conference bridge. Application
4731 * can use this function to add the media port that it creates. For
4732 * media ports that are created by PJSUA-LIB (such as calls, file player,
4733 * or file recorder), PJSUA-LIB will automatically add the port to
4734 * the bridge.
4735 *
4736 * @param pool Pool to use.
4737 * @param port Media port to be added to the bridge.
4738 * @param p_id Optional pointer to receive the conference
4739 * slot id.
4740 *
4741 * @return PJ_SUCCESS on success, or the appropriate error code.
4742 */
4743PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
4744 pjmedia_port *port,
4745 pjsua_conf_port_id *p_id);
4746
4747
4748/**
4749 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00004750 * call this function if it registered the port manually with previous call
4751 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00004752 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004753 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00004754 *
4755 * @return PJ_SUCCESS on success, or the appropriate error code.
4756 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004757PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00004758
4759
4760/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004761 * Establish unidirectional media flow from souce to sink. One source
4762 * may transmit to multiple destinations/sink. And if multiple
4763 * sources are transmitting to the same sink, the media will be mixed
4764 * together. Source and sink may refer to the same ID, effectively
4765 * looping the media.
4766 *
4767 * If bidirectional media flow is desired, application needs to call
4768 * this function twice, with the second one having the arguments
4769 * reversed.
4770 *
4771 * @param source Port ID of the source media/transmitter.
4772 * @param sink Port ID of the destination media/received.
4773 *
4774 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004775 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004776PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
4777 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004778
4779
4780/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004781 * Disconnect media flow from the source to destination port.
4782 *
4783 * @param source Port ID of the source media/transmitter.
4784 * @param sink Port ID of the destination media/received.
4785 *
4786 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004787 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004788PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
4789 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004790
4791
Benny Prijono6dd967c2006-12-26 02:27:14 +00004792/**
4793 * Adjust the signal level to be transmitted from the bridge to the
4794 * specified port by making it louder or quieter.
4795 *
4796 * @param slot The conference bridge slot number.
4797 * @param level Signal level adjustment. Value 1.0 means no level
4798 * adjustment, while value 0 means to mute the port.
4799 *
4800 * @return PJ_SUCCESS on success, or the appropriate error code.
4801 */
4802PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
4803 float level);
4804
4805/**
4806 * Adjust the signal level to be received from the specified port (to
4807 * the bridge) by making it louder or quieter.
4808 *
4809 * @param slot The conference bridge slot number.
4810 * @param level Signal level adjustment. Value 1.0 means no level
4811 * adjustment, while value 0 means to mute the port.
4812 *
4813 * @return PJ_SUCCESS on success, or the appropriate error code.
4814 */
4815PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
4816 float level);
4817
4818/**
4819 * Get last signal level transmitted to or received from the specified port.
4820 * The signal level is an integer value in zero to 255, with zero indicates
4821 * no signal, and 255 indicates the loudest signal level.
4822 *
4823 * @param slot The conference bridge slot number.
4824 * @param tx_level Optional argument to receive the level of signal
4825 * transmitted to the specified port (i.e. the direction
4826 * is from the bridge to the port).
4827 * @param rx_level Optional argument to receive the level of signal
4828 * received from the port (i.e. the direction is from the
4829 * port to the bridge).
4830 *
4831 * @return PJ_SUCCESS on success.
4832 */
4833PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
4834 unsigned *tx_level,
4835 unsigned *rx_level);
4836
Benny Prijono6dd967c2006-12-26 02:27:14 +00004837
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004838/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00004839 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004840 */
4841
Benny Prijono9fc735d2006-05-28 14:58:12 +00004842/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004843 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004844 * the conference bridge.
4845 *
4846 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00004847 * WAV files are supported, and the WAV file MUST be
4848 * formatted as 16bit PCM mono/single channel (any
4849 * clock rate is supported).
Benny Prijono58add7c2008-01-18 13:24:07 +00004850 * @param options Optional option flag. Application may specify
4851 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004852 * @param p_id Pointer to receive player ID.
4853 *
4854 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004855 */
4856PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004857 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004858 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004859
4860
4861/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004862 * Create a file playlist media port, and automatically add the port
4863 * to the conference bridge.
4864 *
4865 * @param file_names Array of file names to be added to the play list.
4866 * Note that the files must have the same clock rate,
4867 * number of channels, and number of bits per sample.
4868 * @param file_count Number of files in the array.
4869 * @param label Optional label to be set for the media port.
4870 * @param options Optional option flag. Application may specify
4871 * PJMEDIA_FILE_NO_LOOP to prevent looping.
4872 * @param p_id Optional pointer to receive player ID.
4873 *
4874 * @return PJ_SUCCESS on success, or the appropriate error code.
4875 */
4876PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
4877 unsigned file_count,
4878 const pj_str_t *label,
4879 unsigned options,
4880 pjsua_player_id *p_id);
4881
4882/**
4883 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004884 *
4885 * @param id The file player ID.
4886 *
4887 * @return Conference port ID associated with this player.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004888 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004889PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004890
4891
4892/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004893 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00004894 *
4895 * @param id The player ID.
4896 * @param p_port The media port associated with the player.
4897 *
4898 * @return PJ_SUCCESS on success.
4899 */
Benny Prijono58add7c2008-01-18 13:24:07 +00004900PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
Benny Prijono469b1522006-12-26 03:05:17 +00004901 pjmedia_port **p_port);
4902
4903/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004904 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004905 *
4906 * @param id The file player ID.
4907 * @param samples The playback position, in samples. Application can
4908 * specify zero to re-start the playback.
4909 *
4910 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004911 */
4912PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
4913 pj_uint32_t samples);
4914
4915
4916/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004917 * Close the file of playlist, remove the player from the bridge, and free
4918 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004919 *
4920 * @param id The file player ID.
4921 *
4922 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004923 */
4924PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
4925
4926
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004927/*****************************************************************************
4928 * File recorder.
4929 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00004930
4931/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004932 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004933 * the conference bridge. The recorder currently supports recording WAV file.
4934 * The type of the recorder to use is determined by the extension of the file
4935 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004936 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00004937 * @param filename Output file name. The function will determine the
4938 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004939 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00004940 * @param enc_type Optionally specify the type of encoder to be used to
4941 * compress the media, if the file can support different
4942 * encodings. This value must be zero for now.
4943 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004944 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00004945 * For .WAV recorder, this value must be NULL.
4946 * @param max_size Maximum file size. Specify zero or -1 to remove size
4947 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004948 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004949 * @param p_id Pointer to receive the recorder instance.
4950 *
4951 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004952 */
4953PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004954 unsigned enc_type,
4955 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004956 pj_ssize_t max_size,
4957 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004958 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004959
4960
4961/**
4962 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004963 *
4964 * @param id The recorder ID.
4965 *
4966 * @return Conference port ID associated with this recorder.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004967 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004968PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004969
4970
4971/**
Benny Prijono469b1522006-12-26 03:05:17 +00004972 * Get the media port for the recorder.
4973 *
4974 * @param id The recorder ID.
4975 * @param p_port The media port associated with the recorder.
4976 *
4977 * @return PJ_SUCCESS on success.
4978 */
4979PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4980 pjmedia_port **p_port);
4981
4982
4983/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004984 * Destroy recorder (this will complete recording).
4985 *
4986 * @param id The recorder ID.
4987 *
4988 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004989 */
4990PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4991
4992
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004993/*****************************************************************************
4994 * Sound devices.
4995 */
4996
Benny Prijono9fc735d2006-05-28 14:58:12 +00004997/**
Benny Prijonof798e502009-03-09 13:08:16 +00004998 * Enum all audio devices installed in the system.
4999 *
5000 * @param info Array of info to be initialized.
5001 * @param count On input, specifies max elements in the array.
5002 * On return, it contains actual number of elements
5003 * that have been initialized.
5004 *
5005 * @return PJ_SUCCESS on success, or the appropriate error code.
5006 */
5007PJ_DECL(pj_status_t) pjsua_enum_aud_devs(pjmedia_aud_dev_info info[],
5008 unsigned *count);
5009
5010/**
5011 * Enum all sound devices installed in the system (old API).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005012 *
5013 * @param info Array of info to be initialized.
5014 * @param count On input, specifies max elements in the array.
5015 * On return, it contains actual number of elements
5016 * that have been initialized.
5017 *
5018 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00005019 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005020PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
5021 unsigned *count);
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00005022
5023/**
5024 * Get currently active sound devices. If sound devices has not been created
5025 * (for example when pjsua_start() is not called), it is possible that
5026 * the function returns PJ_SUCCESS with -1 as device IDs.
5027 *
5028 * @param capture_dev On return it will be filled with device ID of the
5029 * capture device.
5030 * @param playback_dev On return it will be filled with device ID of the
5031 * device ID of the playback device.
5032 *
5033 * @return PJ_SUCCESS on success, or the appropriate error code.
5034 */
5035PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
5036 int *playback_dev);
5037
5038
Benny Prijono9fc735d2006-05-28 14:58:12 +00005039/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005040 * Select or change sound device. Application may call this function at
5041 * any time to replace current sound device.
5042 *
5043 * @param capture_dev Device ID of the capture device.
5044 * @param playback_dev Device ID of the playback device.
5045 *
5046 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00005047 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005048PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
5049 int playback_dev);
5050
5051
5052/**
5053 * Set pjsua to use null sound device. The null sound device only provides
5054 * the timing needed by the conference bridge, and will not interract with
5055 * any hardware.
5056 *
5057 * @return PJ_SUCCESS on success, or the appropriate error code.
5058 */
5059PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
5060
5061
Benny Prijonoe909eac2006-07-27 22:04:56 +00005062/**
5063 * Disconnect the main conference bridge from any sound devices, and let
5064 * application connect the bridge to it's own sound device/master port.
5065 *
5066 * @return The port interface of the conference bridge,
5067 * so that application can connect this to it's own
5068 * sound device or master port.
5069 */
5070PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
5071
5072
Benny Prijonof20687a2006-08-04 18:27:19 +00005073/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00005074 * Change the echo cancellation settings.
Benny Prijonof798e502009-03-09 13:08:16 +00005075 *
5076 * The behavior of this function depends on whether the sound device is
5077 * currently active, and if it is, whether device or software AEC is
5078 * being used.
Benny Prijono10454dc2009-02-21 14:21:59 +00005079 *
5080 * If the sound device is currently active, and if the device supports AEC,
5081 * this function will forward the change request to the device and it will
5082 * be up to the device on whether support the request. If software AEC is
5083 * being used (the software EC will be used if the device does not support
5084 * AEC), this function will change the software EC settings. In all cases,
5085 * the setting will be saved for future opening of the sound device.
5086 *
5087 * If the sound device is not currently active, this will only change the
5088 * default AEC settings and the setting will be applied next time the
5089 * sound device is opened.
Benny Prijonof20687a2006-08-04 18:27:19 +00005090 *
5091 * @param tail_ms The tail length, in miliseconds. Set to zero to
5092 * disable AEC.
Benny Prijonoa7b376b2008-01-25 16:06:33 +00005093 * @param options Options to be passed to pjmedia_echo_create().
Benny Prijono5da50432006-08-07 10:24:52 +00005094 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00005095 *
5096 * @return PJ_SUCCESS on success.
5097 */
Benny Prijono5da50432006-08-07 10:24:52 +00005098PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00005099
5100
5101/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00005102 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00005103 *
5104 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
5105 * If AEC is disabled, the value will be zero.
5106 *
5107 * @return PJ_SUCCESS on success.
5108 */
Benny Prijono22dfe592006-08-06 12:07:13 +00005109PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00005110
5111
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00005112/**
Benny Prijonof798e502009-03-09 13:08:16 +00005113 * Check whether the sound device is currently active. The sound device
5114 * may be inactive if the application has set the auto close feature to
5115 * non-zero (the snd_auto_close_time setting in #pjsua_media_config), or
5116 * if null sound device or no sound device has been configured via the
5117 * #pjsua_set_no_snd_dev() function.
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00005118 */
Benny Prijonof798e502009-03-09 13:08:16 +00005119PJ_DECL(pj_bool_t) pjsua_snd_is_active(void);
5120
5121
5122/**
5123 * Configure sound device setting to the sound device being used. If sound
5124 * device is currently active, the function will forward the setting to the
5125 * sound device instance to be applied immediately, if it supports it.
5126 *
5127 * The setting will be saved for future opening of the sound device, if the
5128 * "keep" argument is set to non-zero. If the sound device is currently
5129 * inactive, and the "keep" argument is false, this function will return
5130 * error.
5131 *
5132 * Note that in case the setting is kept for future use, it will be applied
5133 * to any devices, even when application has changed the sound device to be
5134 * used.
5135 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00005136 * Note also that the echo cancellation setting should be set with
5137 * #pjsua_set_ec() API instead.
5138 *
Benny Prijonof798e502009-03-09 13:08:16 +00005139 * See also #pjmedia_aud_stream_set_cap() for more information about setting
5140 * an audio device capability.
5141 *
5142 * @param cap The sound device setting to change.
5143 * @param pval Pointer to value. Please see #pjmedia_aud_dev_cap
5144 * documentation about the type of value to be
5145 * supplied for each setting.
5146 * @param keep Specify whether the setting is to be kept for future
5147 * use.
5148 *
5149 * @return PJ_SUCCESS on success or the appropriate error code.
5150 */
5151PJ_DECL(pj_status_t) pjsua_snd_set_setting(pjmedia_aud_dev_cap cap,
5152 const void *pval,
5153 pj_bool_t keep);
5154
5155/**
5156 * Retrieve a sound device setting. If sound device is currently active,
5157 * the function will forward the request to the sound device. If sound device
5158 * is currently inactive, and if application had previously set the setting
5159 * and mark the setting as kept, then that setting will be returned.
5160 * Otherwise, this function will return error.
5161 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00005162 * Note that echo cancellation settings should be retrieved with
5163 * #pjsua_get_ec_tail() API instead.
5164 *
Benny Prijonof798e502009-03-09 13:08:16 +00005165 * @param cap The sound device setting to retrieve.
5166 * @param pval Pointer to receive the value.
5167 * Please see #pjmedia_aud_dev_cap documentation about
5168 * the type of value to be supplied for each setting.
5169 *
5170 * @return PJ_SUCCESS on success or the appropriate error code.
5171 */
5172PJ_DECL(pj_status_t) pjsua_snd_get_setting(pjmedia_aud_dev_cap cap,
5173 void *pval);
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00005174
5175
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005176/*****************************************************************************
5177 * Codecs.
5178 */
5179
5180/**
5181 * Enum all supported codecs in the system.
5182 *
5183 * @param id Array of ID to be initialized.
5184 * @param count On input, specifies max elements in the array.
5185 * On return, it contains actual number of elements
5186 * that have been initialized.
5187 *
5188 * @return PJ_SUCCESS on success, or the appropriate error code.
5189 */
5190PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
5191 unsigned *count );
5192
5193
5194/**
5195 * Change codec priority.
5196 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00005197 * @param codec_id Codec ID, which is a string that uniquely identify
5198 * the codec (such as "speex/8000"). Please see pjsua
5199 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005200 * @param priority Codec priority, 0-255, where zero means to disable
5201 * the codec.
5202 *
5203 * @return PJ_SUCCESS on success, or the appropriate error code.
5204 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00005205PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005206 pj_uint8_t priority );
5207
5208
5209/**
5210 * Get codec parameters.
5211 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00005212 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005213 * @param param Structure to receive codec parameters.
5214 *
5215 * @return PJ_SUCCESS on success, or the appropriate error code.
5216 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00005217PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005218 pjmedia_codec_param *param );
5219
5220
5221/**
5222 * Set codec parameters.
5223 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00005224 * @param codec_id Codec ID.
Nanang Izzuddin06839e72010-01-27 11:48:31 +00005225 * @param param Codec parameter to set. Set to NULL to reset
5226 * codec parameter to library default settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005227 *
5228 * @return PJ_SUCCESS on success, or the appropriate error code.
5229 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00005230PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005231 const pjmedia_codec_param *param);
5232
Benny Prijono9f468d12011-07-07 07:46:33 +00005233
5234#if DISABLED_FOR_TICKET_1185
5235/**
5236 * Create UDP media transports for all the calls. This function creates
5237 * one UDP media transport for each call.
5238 *
5239 * @param cfg Media transport configuration. The "port" field in the
5240 * configuration is used as the start port to bind the
5241 * sockets.
5242 *
5243 * @return PJ_SUCCESS on success, or the appropriate error code.
5244 */
5245PJ_DECL(pj_status_t)
5246pjsua_media_transports_create(const pjsua_transport_config *cfg);
5247
5248
5249/**
5250 * Register custom media transports to be used by calls. There must
5251 * enough media transports for all calls.
5252 *
5253 * @param tp The media transport array.
5254 * @param count Number of elements in the array. This number MUST
5255 * match the number of maximum calls configured when
5256 * pjsua is created.
5257 * @param auto_delete Flag to indicate whether the transports should be
5258 * destroyed when pjsua is shutdown.
5259 *
5260 * @return PJ_SUCCESS on success, or the appropriate error code.
5261 */
5262PJ_DECL(pj_status_t)
5263pjsua_media_transports_attach( pjsua_media_transport tp[],
5264 unsigned count,
5265 pj_bool_t auto_delete);
5266#endif
5267
5268
5269/* end of MEDIA API */
5270/**
5271 * @}
5272 */
5273
5274
Nanang Izzuddin50fae732011-03-22 09:49:23 +00005275/*****************************************************************************
Benny Prijono9f468d12011-07-07 07:46:33 +00005276 * VIDEO API
5277 */
5278
5279
5280/**
5281 * @defgroup PJSUA_LIB_VIDEO PJSUA-API Video
5282 * @ingroup PJSUA_LIB
5283 * @brief Video support
5284 * @{
5285 */
5286
5287/*
5288 * Video devices API
5289 */
5290
5291/**
5292 * Get the number of video devices installed in the system.
5293 *
5294 * @return The number of devices.
5295 */
5296PJ_DECL(unsigned) pjsua_vid_dev_count(void);
5297
5298/**
5299 * Retrieve the video device info for the specified device index.
5300 *
5301 * @param id The device index.
5302 * @param vdi Device info to be initialized.
5303 *
5304 * @return PJ_SUCCESS on success, or the appropriate error code.
5305 */
5306PJ_DECL(pj_status_t) pjsua_vid_dev_get_info(pjmedia_vid_dev_index id,
5307 pjmedia_vid_dev_info *vdi);
5308
5309/**
5310 * Enum all video devices installed in the system.
5311 *
5312 * @param info Array of info to be initialized.
5313 * @param count On input, specifies max elements in the array.
5314 * On return, it contains actual number of elements
5315 * that have been initialized.
5316 *
5317 * @return PJ_SUCCESS on success, or the appropriate error code.
5318 */
5319PJ_DECL(pj_status_t) pjsua_vid_enum_devs(pjmedia_vid_dev_info info[],
5320 unsigned *count);
5321
5322
5323/*
5324 * Video preview API
5325 */
5326
5327/**
5328 * Parameters for starting video preview with pjsua_vid_preview_start().
5329 * Application should initialize this structure with
5330 * pjsua_vid_preview_param_default().
5331 */
5332typedef struct pjsua_vid_preview_param
5333{
5334 /**
5335 * Device ID for the video renderer to be used for rendering the
5336 * capture stream for preview.
5337 */
5338 pjmedia_vid_dev_index rend_id;
5339} pjsua_vid_preview_param;
5340
5341
5342/**
5343 * Start video preview window for the specified capture device.
5344 *
5345 * @param id The capture device ID where its preview will be
5346 * started.
5347 * @param prm Optional video preview parameters. Specify NULL
5348 * to use default values.
5349 *
5350 * @return PJ_SUCCESS on success, or the appropriate error code.
5351 */
5352PJ_DECL(pj_status_t) pjsua_vid_preview_start(pjmedia_vid_dev_index id,
5353 pjsua_vid_preview_param *prm);
5354
5355/**
5356 * Get the preview window handle associated with the capture device, if any.
5357 *
5358 * @param id The capture device ID.
5359 *
5360 * @return The window ID of the preview window for the
5361 * specified capture device ID, or NULL if preview
5362 * does not exist.
5363 */
5364PJ_DECL(pjsua_vid_win_id) pjsua_vid_preview_get_win(pjmedia_vid_dev_index id);
5365
5366/**
5367 * Stop video preview.
5368 *
5369 * @param id The capture device ID.
5370 *
5371 * @return PJ_SUCCESS on success, or the appropriate error code.
5372 */
5373PJ_DECL(pj_status_t) pjsua_vid_preview_stop(pjmedia_vid_dev_index id);
5374
5375
5376/*
5377 * Video window manipulation API.
5378 */
5379
5380/**
5381 * This structure describes video window info.
5382 */
5383typedef struct pjsua_vid_win_info
5384{
5385 /**
5386 * Window show status. The window is hidden if false.
5387 */
5388 pj_bool_t show;
5389
5390 /**
5391 * Window position.
5392 */
5393 pjmedia_coord pos;
5394
5395 /**
5396 * Window size.
5397 */
5398 pjmedia_rect_size size;
5399
5400} pjsua_vid_win_info;
5401
5402
5403/**
5404 * Get window info.
5405 *
5406 * @param wid The video window ID.
5407 * @param wi The video window info to be initialized.
5408 *
5409 * @return PJ_SUCCESS on success, or the appropriate error code.
5410 */
5411PJ_DECL(pj_status_t) pjsua_vid_win_get_info(pjsua_vid_win_id wid,
5412 pjsua_vid_win_info *wi);
5413
5414/**
5415 * Show or hide window.
5416 *
5417 * @param wid The video window ID.
5418 * @param show Set to PJ_TRUE to show the window, PJ_FALSE to
5419 * hide the window.
5420 *
5421 * @return PJ_SUCCESS on success, or the appropriate error code.
5422 */
5423PJ_DECL(pj_status_t) pjsua_vid_win_set_show(pjsua_vid_win_id wid,
5424 pj_bool_t show);
5425
5426/**
5427 * Set video window position.
5428 *
5429 * @param wid The video window ID.
5430 * @param pos The window position.
5431 *
5432 * @return PJ_SUCCESS on success, or the appropriate error code.
5433 */
5434PJ_DECL(pj_status_t) pjsua_vid_win_set_pos(pjsua_vid_win_id wid,
5435 const pjmedia_coord *pos);
5436
5437/**
5438 * Resize window.
5439 *
5440 * @param wid The video window ID.
5441 * @param size The new window size.
5442 *
5443 * @return PJ_SUCCESS on success, or the appropriate error code.
5444 */
5445PJ_DECL(pj_status_t) pjsua_vid_win_set_size(pjsua_vid_win_id wid,
5446 const pjmedia_rect_size *size);
5447
5448
5449
5450/*
5451 * Video codecs API
Nanang Izzuddin50fae732011-03-22 09:49:23 +00005452 */
5453
5454/**
5455 * Enum all supported video codecs in the system.
5456 *
5457 * @param id Array of ID to be initialized.
5458 * @param count On input, specifies max elements in the array.
5459 * On return, it contains actual number of elements
5460 * that have been initialized.
5461 *
5462 * @return PJ_SUCCESS on success, or the appropriate error code.
5463 */
5464PJ_DECL(pj_status_t) pjsua_vid_enum_codecs( pjsua_codec_info id[],
5465 unsigned *count );
5466
5467
5468/**
5469 * Change video codec priority.
5470 *
5471 * @param codec_id Codec ID, which is a string that uniquely identify
5472 * the codec (such as "H263/90000"). Please see pjsua
5473 * manual or pjmedia codec reference for details.
5474 * @param priority Codec priority, 0-255, where zero means to disable
5475 * the codec.
5476 *
5477 * @return PJ_SUCCESS on success, or the appropriate error code.
5478 */
5479PJ_DECL(pj_status_t) pjsua_vid_codec_set_priority( const pj_str_t *codec_id,
5480 pj_uint8_t priority );
5481
5482
5483/**
5484 * Get video codec parameters.
5485 *
5486 * @param codec_id Codec ID.
5487 * @param param Structure to receive video codec parameters.
5488 *
5489 * @return PJ_SUCCESS on success, or the appropriate error code.
5490 */
5491PJ_DECL(pj_status_t) pjsua_vid_codec_get_param(
5492 const pj_str_t *codec_id,
5493 pjmedia_vid_codec_param *param);
5494
5495
5496/**
5497 * Set video codec parameters.
5498 *
5499 * @param codec_id Codec ID.
5500 * @param param Codec parameter to set. Set to NULL to reset
5501 * codec parameter to library default settings.
5502 *
5503 * @return PJ_SUCCESS on success, or the appropriate error code.
5504 */
5505PJ_DECL(pj_status_t) pjsua_vid_codec_set_param(
5506 const pj_str_t *codec_id,
5507 const pjmedia_vid_codec_param *param);
5508
5509
Benny Prijonof3195072006-02-14 21:15:30 +00005510
Benny Prijono9f468d12011-07-07 07:46:33 +00005511/* end of VIDEO API */
Benny Prijono312aff92006-06-17 04:08:30 +00005512/**
5513 * @}
5514 */
5515
Benny Prijonof3195072006-02-14 21:15:30 +00005516
Benny Prijono312aff92006-06-17 04:08:30 +00005517/**
5518 * @}
5519 */
5520
Benny Prijonoe6ead542007-01-31 20:53:31 +00005521PJ_END_DECL
5522
Benny Prijono312aff92006-06-17 04:08:30 +00005523
Benny Prijono268ca612006-02-07 12:34:11 +00005524#endif /* __PJSUA_H__ */