blob: 06e5430a8b42570ec562fec7b751402565b3e9e1 [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 /**
384 * Remove an existing video stream.
385 */
386 PJSUA_CALL_VID_STRM_REMOVE,
387
388 /**
389 * Modify an existing video stream, such as changing the capture device.
390 */
391 PJSUA_CALL_VID_STRM_MODIFY,
392
393 /**
394 * Start transmitting video stream.
395 */
396 PJSUA_CALL_VID_STRM_START_TRANSMIT,
397
398 /**
399 * Stop transmitting video stream.
400 */
401 PJSUA_CALL_VID_STRM_STOP_TRANSMIT,
402
403} pjsua_call_vid_strm_op;
404
405
406/**
407 * Parameters for video stream operation on a call.
408 */
409typedef struct pjsua_call_vid_strm_op_param
410{
411 /**
412 * Specify the media stream index. This can be set to -1 to denote
413 * the default video stream in the call, which is the first active
414 * video stream or any first video stream if none is active.
415 *
416 * This field is valid for all video stream operations, except
417 * PJSUA_CALL_VID_STRM_ADD.
418 */
419 int med_idx;
420
421 /**
422 * Specify the video capture device ID. This can be set to
423 * PJMEDIA_VID_DEFAULT_CAPTURE_DEV to specify the default capture
424 * device as configured in the account.
425 *
426 * This field is valid for the following video stream operations:
427 * PJSUA_CALL_VID_STRM_ADD, PJSUA_CALL_VID_STRM_MODIFY, and
428 * PJSUA_CALL_VID_STRM_START_TRANSMIT.
429 */
430 pjmedia_vid_dev_index cap_dev;
431
432} pjsua_call_vid_strm_op_param;
433
434
435/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000436 * Logging configuration, which can be (optionally) specified when calling
437 * #pjsua_init(). Application must call #pjsua_logging_config_default() to
438 * initialize this structure with the default values.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000439 */
440typedef struct pjsua_logging_config
441{
442 /**
443 * Log incoming and outgoing SIP message? Yes!
444 */
445 pj_bool_t msg_logging;
446
447 /**
448 * Input verbosity level. Value 5 is reasonable.
449 */
450 unsigned level;
451
452 /**
453 * Verbosity level for console. Value 4 is reasonable.
454 */
455 unsigned console_level;
456
457 /**
458 * Log decoration.
459 */
460 unsigned decor;
461
462 /**
463 * Optional log filename.
464 */
465 pj_str_t log_filename;
466
467 /**
Benny Prijonodbe3f4b2009-05-07 16:56:04 +0000468 * Additional flags to be given to #pj_file_open() when opening
469 * the log file. By default, the flag is PJ_O_WRONLY. Application
470 * may set PJ_O_APPEND here so that logs are appended to existing
471 * file instead of overwriting it.
472 *
473 * Default is 0.
474 */
475 unsigned log_file_flags;
476
477 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000478 * Optional callback function to be called to write log to
479 * application specific device. This function will be called for
480 * log messages on input verbosity level.
481 */
Benny Prijonofe7d87b2007-11-29 11:35:44 +0000482 void (*cb)(int level, const char *data, int len);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000483
484
485} pjsua_logging_config;
486
487
488/**
489 * Use this function to initialize logging config.
490 *
491 * @param cfg The logging config to be initialized.
492 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000493PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000494
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000495
496/**
497 * Use this function to duplicate logging config.
498 *
499 * @param pool Pool to use.
500 * @param dst Destination config.
501 * @param src Source config.
502 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000503PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool,
504 pjsua_logging_config *dst,
505 const pjsua_logging_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000506
Benny Prijonodc39fe82006-05-26 12:17:46 +0000507
508/**
Benny Prijono4dd961b2009-10-26 11:21:37 +0000509 * Structure to be passed on MWI callback.
510 */
511typedef struct pjsua_mwi_info
512{
513 pjsip_evsub *evsub; /**< Event subscription session, for
514 reference. */
515 pjsip_rx_data *rdata; /**< The received NOTIFY request. */
516} pjsua_mwi_info;
517
518
519/**
Nanang Izzuddin4ea1bcc2010-09-28 04:57:01 +0000520 * Structure to be passed on registration callback.
521 */
522typedef struct pjsua_reg_info
523{
524 struct pjsip_regc_cbparam *cbparam; /**< Parameters returned by
525 registration callback. */
526} pjsua_reg_info;
527
528
529/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000530 * This structure describes application callback to receive various event
531 * notification from PJSUA-API. All of these callbacks are OPTIONAL,
532 * although definitely application would want to implement some of
533 * the important callbacks (such as \a on_incoming_call).
Benny Prijonodc39fe82006-05-26 12:17:46 +0000534 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000535typedef struct pjsua_callback
Benny Prijonodc39fe82006-05-26 12:17:46 +0000536{
537 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000538 * Notify application when invite state has changed.
539 * Application may then query the call info to get the
Benny Prijonoe6ead542007-01-31 20:53:31 +0000540 * detail call states by calling pjsua_call_get_info() function.
Benny Prijono0875ae82006-12-26 00:11:48 +0000541 *
542 * @param call_id The call index.
543 * @param e Event which causes the call state to change.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000544 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000545 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000546
547 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000548 * Notify application on incoming call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000549 *
550 * @param acc_id The account which match the incoming call.
551 * @param call_id The call id that has just been created for
552 * the call.
553 * @param rdata The incoming INVITE request.
Benny Prijono8b1889b2006-06-06 18:40:40 +0000554 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000555 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000556 pjsip_rx_data *rdata);
557
558 /**
Benny Prijonofeb69f42007-10-05 09:12:26 +0000559 * This is a general notification callback which is called whenever
560 * a transaction within the call has changed state. Application can
561 * implement this callback for example to monitor the state of
562 * outgoing requests, or to answer unhandled incoming requests
563 * (such as INFO) with a final response.
564 *
565 * @param call_id Call identification.
566 * @param tsx The transaction which has changed state.
567 * @param e Transaction event that caused the state change.
568 */
569 void (*on_call_tsx_state)(pjsua_call_id call_id,
570 pjsip_transaction *tsx,
571 pjsip_event *e);
572
573 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000574 * Notify application when media state in the call has changed.
575 * Normal application would need to implement this callback, e.g.
Benny Prijono6ba8c542007-10-16 01:34:14 +0000576 * to connect the call's media to sound device. When ICE is used,
577 * this callback will also be called to report ICE negotiation
578 * failure.
Benny Prijono0875ae82006-12-26 00:11:48 +0000579 *
580 * @param call_id The call index.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000581 */
582 void (*on_call_media_state)(pjsua_call_id call_id);
583
Benny Prijonofc13bf62008-02-20 08:56:15 +0000584
585 /**
586 * Notify application when media session is created and before it is
587 * registered to the conference bridge. Application may return different
588 * media port if it has added media processing port to the stream. This
589 * media port then will be added to the conference bridge instead.
590 *
591 * @param call_id Call identification.
Benny Prijono0bc99a92011-03-17 04:34:43 +0000592 * @param strm Media stream.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000593 * @param stream_idx Stream index in the media session.
594 * @param p_port On input, it specifies the media port of the
595 * stream. Application may modify this pointer to
596 * point to different media port to be registered
597 * to the conference bridge.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000598 */
599 void (*on_stream_created)(pjsua_call_id call_id,
Benny Prijono0bc99a92011-03-17 04:34:43 +0000600 pjmedia_stream *strm,
Benny Prijonofc13bf62008-02-20 08:56:15 +0000601 unsigned stream_idx,
602 pjmedia_port **p_port);
603
604 /**
605 * Notify application when media session has been unregistered from the
606 * conference bridge and about to be destroyed.
607 *
608 * @param call_id Call identification.
Benny Prijono0bc99a92011-03-17 04:34:43 +0000609 * @param strm Media stream.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000610 * @param stream_idx Stream index in the media session.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000611 */
612 void (*on_stream_destroyed)(pjsua_call_id call_id,
Benny Prijono0bc99a92011-03-17 04:34:43 +0000613 pjmedia_stream *strm,
Benny Prijonofc13bf62008-02-20 08:56:15 +0000614 unsigned stream_idx);
615
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000616 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000617 * Notify application upon incoming DTMF digits.
618 *
619 * @param call_id The call index.
620 * @param digit DTMF ASCII digit.
621 */
622 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
623
624 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000625 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000626 * Application can decide to accept/reject transfer request
Benny Prijonoc54dcb32008-04-08 23:33:15 +0000627 * by setting the code (default is 202). When this callback
Benny Prijono9fc735d2006-05-28 14:58:12 +0000628 * is not defined, the default behavior is to accept the
629 * transfer.
Benny Prijono0875ae82006-12-26 00:11:48 +0000630 *
631 * @param call_id The call index.
632 * @param dst The destination where the call will be
633 * transfered to.
634 * @param code Status code to be returned for the call transfer
635 * request. On input, it contains status code 200.
Benny Prijono9fc735d2006-05-28 14:58:12 +0000636 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000637 void (*on_call_transfer_request)(pjsua_call_id call_id,
638 const pj_str_t *dst,
639 pjsip_status_code *code);
640
641 /**
642 * Notify application of the status of previously sent call
643 * transfer request. Application can monitor the status of the
644 * call transfer request, for example to decide whether to
645 * terminate existing call.
646 *
647 * @param call_id Call ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000648 * @param st_code Status progress of the transfer request.
649 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000650 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000651 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000652 * this callback is the final status.
653 * @param p_cont Initially will be set to non-zero, application
654 * can set this to FALSE if it no longer wants
655 * to receie further notification (for example,
656 * after it hangs up the call).
657 */
658 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000659 int st_code,
660 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000661 pj_bool_t final,
662 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000663
664 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000665 * Notify application about incoming INVITE with Replaces header.
666 * Application may reject the request by setting non-2xx code.
667 *
668 * @param call_id The call ID to be replaced.
669 * @param rdata The incoming INVITE request to replace the call.
670 * @param st_code Status code to be set by application. Application
671 * should only return a final status (200-699).
672 * @param st_text Optional status text to be set by application.
673 */
674 void (*on_call_replace_request)(pjsua_call_id call_id,
675 pjsip_rx_data *rdata,
676 int *st_code,
677 pj_str_t *st_text);
678
679 /**
680 * Notify application that an existing call has been replaced with
681 * a new call. This happens when PJSUA-API receives incoming INVITE
682 * request with Replaces header.
683 *
684 * After this callback is called, normally PJSUA-API will disconnect
685 * \a old_call_id and establish \a new_call_id.
686 *
687 * @param old_call_id Existing call which to be replaced with the
688 * new call.
689 * @param new_call_id The new call.
690 * @param rdata The incoming INVITE with Replaces request.
691 */
692 void (*on_call_replaced)(pjsua_call_id old_call_id,
693 pjsua_call_id new_call_id);
694
695
696 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000697 * Notify application when registration status has changed.
698 * Application may then query the account info to get the
699 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000700 *
Nanang Izzuddin4ea1bcc2010-09-28 04:57:01 +0000701 * @param acc_id The account ID.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000702 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000703 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000704
705 /**
Nanang Izzuddin4ea1bcc2010-09-28 04:57:01 +0000706 * Notify application when registration status has changed.
707 * Application may inspect the registration info to get the
708 * registration status details.
709 *
710 * @param acc_id The account ID.
711 * @param info The registration info.
712 */
713 void (*on_reg_state2)(pjsua_acc_id acc_id, pjsua_reg_info *info);
714
715 /**
Benny Prijono63fba012008-07-17 14:19:10 +0000716 * Notification when incoming SUBSCRIBE request is received. Application
717 * may use this callback to authorize the incoming subscribe request
718 * (e.g. ask user permission if the request should be granted).
719 *
720 * If this callback is not implemented, all incoming presence subscription
721 * requests will be accepted.
722 *
723 * If this callback is implemented, application has several choices on
724 * what to do with the incoming request:
725 * - it may reject the request immediately by specifying non-200 class
726 * final response in the \a code argument.
727 * - it may immediately accept the request by specifying 200 as the
728 * \a code argument. This is the default value if application doesn't
729 * set any value to the \a code argument. In this case, the library
730 * will automatically send NOTIFY request upon returning from this
731 * callback.
732 * - it may delay the processing of the request, for example to request
733 * user permission whether to accept or reject the request. In this
734 * case, the application MUST set the \a code argument to 202, and
735 * later calls #pjsua_pres_notify() to accept or reject the
736 * subscription request.
737 *
738 * Any \a code other than 200 and 202 will be treated as 200.
739 *
740 * Application MUST return from this callback immediately (e.g. it must
741 * not block in this callback while waiting for user confirmation).
742 *
743 * @param srv_pres Server presence subscription instance. If
744 * application delays the acceptance of the request,
745 * it will need to specify this object when calling
746 * #pjsua_pres_notify().
747 * @param acc_id Account ID most appropriate for this request.
748 * @param buddy_id ID of the buddy matching the sender of the
749 * request, if any, or PJSUA_INVALID_ID if no
750 * matching buddy is found.
751 * @param from The From URI of the request.
752 * @param rdata The incoming request.
753 * @param code The status code to respond to the request. The
754 * default value is 200. Application may set this
755 * to other final status code to accept or reject
756 * the request.
757 * @param reason The reason phrase to respond to the request.
758 * @param msg_data If the application wants to send additional
759 * headers in the response, it can put it in this
760 * parameter.
761 */
762 void (*on_incoming_subscribe)(pjsua_acc_id acc_id,
763 pjsua_srv_pres *srv_pres,
764 pjsua_buddy_id buddy_id,
765 const pj_str_t *from,
766 pjsip_rx_data *rdata,
767 pjsip_status_code *code,
768 pj_str_t *reason,
769 pjsua_msg_data *msg_data);
770
771 /**
772 * Notification when server side subscription state has changed.
773 * This callback is optional as application normally does not need
774 * to do anything to maintain server side presence subscription.
775 *
776 * @param acc_id The account ID.
777 * @param srv_pres Server presence subscription object.
778 * @param remote_uri Remote URI string.
779 * @param state New subscription state.
780 * @param event PJSIP event that triggers the state change.
781 */
782 void (*on_srv_subscribe_state)(pjsua_acc_id acc_id,
783 pjsua_srv_pres *srv_pres,
784 const pj_str_t *remote_uri,
785 pjsip_evsub_state state,
786 pjsip_event *event);
787
788 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000789 * Notify application when the buddy state has changed.
790 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000791 *
792 * @param buddy_id The buddy id.
Benny Prijono9fc735d2006-05-28 14:58:12 +0000793 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000794 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000795
Benny Prijono63499892010-10-12 12:45:15 +0000796
797 /**
798 * Notify application when the state of client subscription session
799 * associated with a buddy has changed. Application may use this
800 * callback to retrieve more detailed information about the state
801 * changed event.
802 *
803 * @param buddy_id The buddy id.
804 * @param sub Event subscription session.
805 * @param event The event which triggers state change event.
806 */
807 void (*on_buddy_evsub_state)(pjsua_buddy_id buddy_id,
808 pjsip_evsub *sub,
809 pjsip_event *event);
810
Benny Prijono9fc735d2006-05-28 14:58:12 +0000811 /**
812 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000813 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000814 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000815 *
Benny Prijonobbeb3992007-05-21 13:48:35 +0000816 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
817 * passed as one of the argument.
818 *
Benny Prijono0875ae82006-12-26 00:11:48 +0000819 * @param call_id Containts the ID of the call where the IM was
820 * sent, or PJSUA_INVALID_ID if the IM was sent
821 * outside call context.
822 * @param from URI of the sender.
823 * @param to URI of the destination message.
824 * @param contact The Contact URI of the sender, if present.
825 * @param mime_type MIME type of the message.
826 * @param body The message content.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000827 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000828 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
829 const pj_str_t *to, const pj_str_t *contact,
830 const pj_str_t *mime_type, const pj_str_t *body);
831
832 /**
Benny Prijonobbeb3992007-05-21 13:48:35 +0000833 * This is the alternative version of the \a on_pager() callback with
834 * \a pjsip_rx_data argument.
835 *
836 * @param call_id Containts the ID of the call where the IM was
837 * sent, or PJSUA_INVALID_ID if the IM was sent
838 * outside call context.
839 * @param from URI of the sender.
840 * @param to URI of the destination message.
841 * @param contact The Contact URI of the sender, if present.
842 * @param mime_type MIME type of the message.
843 * @param body The message content.
844 * @param rdata The incoming MESSAGE request.
Benny Prijonoba736c42008-07-10 20:45:03 +0000845 * @param acc_id Account ID most suitable for this message.
Benny Prijonobbeb3992007-05-21 13:48:35 +0000846 */
847 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
848 const pj_str_t *to, const pj_str_t *contact,
849 const pj_str_t *mime_type, const pj_str_t *body,
Benny Prijonoba736c42008-07-10 20:45:03 +0000850 pjsip_rx_data *rdata, pjsua_acc_id acc_id);
Benny Prijonobbeb3992007-05-21 13:48:35 +0000851
852 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000853 * Notify application about the delivery status of outgoing pager
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000854 * request. See also on_pager_status2() callback for the version with
855 * \a pjsip_rx_data in the argument list.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000856 *
857 * @param call_id Containts the ID of the call where the IM was
858 * sent, or PJSUA_INVALID_ID if the IM was sent
859 * outside call context.
860 * @param to Destination URI.
861 * @param body Message body.
862 * @param user_data Arbitrary data that was specified when sending
863 * IM message.
864 * @param status Delivery status.
865 * @param reason Delivery status reason.
866 */
867 void (*on_pager_status)(pjsua_call_id call_id,
868 const pj_str_t *to,
869 const pj_str_t *body,
870 void *user_data,
871 pjsip_status_code status,
872 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000873
874 /**
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000875 * Notify application about the delivery status of outgoing pager
876 * request.
877 *
878 * @param call_id Containts the ID of the call where the IM was
879 * sent, or PJSUA_INVALID_ID if the IM was sent
880 * outside call context.
881 * @param to Destination URI.
882 * @param body Message body.
883 * @param user_data Arbitrary data that was specified when sending
884 * IM message.
885 * @param status Delivery status.
886 * @param reason Delivery status reason.
Benny Prijono0a982002007-06-12 16:22:09 +0000887 * @param tdata The original MESSAGE request.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000888 * @param rdata The incoming MESSAGE response, or NULL if the
889 * message transaction fails because of time out
890 * or transport error.
Benny Prijonoba736c42008-07-10 20:45:03 +0000891 * @param acc_id Account ID from this the instant message was
892 * send.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000893 */
894 void (*on_pager_status2)(pjsua_call_id call_id,
895 const pj_str_t *to,
896 const pj_str_t *body,
897 void *user_data,
898 pjsip_status_code status,
899 const pj_str_t *reason,
Benny Prijono0a982002007-06-12 16:22:09 +0000900 pjsip_tx_data *tdata,
Benny Prijonoba736c42008-07-10 20:45:03 +0000901 pjsip_rx_data *rdata,
902 pjsua_acc_id acc_id);
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000903
904 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000905 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +0000906 *
907 * @param call_id Containts the ID of the call where the IM was
908 * sent, or PJSUA_INVALID_ID if the IM was sent
909 * outside call context.
910 * @param from URI of the sender.
911 * @param to URI of the destination message.
912 * @param contact The Contact URI of the sender, if present.
913 * @param is_typing Non-zero if peer is typing, or zero if peer
914 * has stopped typing a message.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000915 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000916 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
917 const pj_str_t *to, const pj_str_t *contact,
918 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000919
Benny Prijono6ba8c542007-10-16 01:34:14 +0000920 /**
Benny Prijonoba736c42008-07-10 20:45:03 +0000921 * Notify application about typing indication.
922 *
923 * @param call_id Containts the ID of the call where the IM was
924 * sent, or PJSUA_INVALID_ID if the IM was sent
925 * outside call context.
926 * @param from URI of the sender.
927 * @param to URI of the destination message.
928 * @param contact The Contact URI of the sender, if present.
929 * @param is_typing Non-zero if peer is typing, or zero if peer
930 * has stopped typing a message.
931 * @param rdata The received request.
932 * @param acc_id Account ID most suitable for this message.
933 */
934 void (*on_typing2)(pjsua_call_id call_id, const pj_str_t *from,
935 const pj_str_t *to, const pj_str_t *contact,
936 pj_bool_t is_typing, pjsip_rx_data *rdata,
937 pjsua_acc_id acc_id);
938
939 /**
Benny Prijono6ba8c542007-10-16 01:34:14 +0000940 * Callback when the library has finished performing NAT type
941 * detection.
942 *
943 * @param res NAT detection result.
944 */
945 void (*on_nat_detect)(const pj_stun_nat_detect_result *res);
946
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000947 /**
948 * This callback is called when the call is about to resend the
949 * INVITE request to the specified target, following the previously
950 * received redirection response.
951 *
952 * Application may accept the redirection to the specified target
953 * (the default behavior if this callback is implemented), reject
954 * this target only and make the session continue to try the next
955 * target in the list if such target exists, stop the whole
956 * redirection process altogether and cause the session to be
957 * disconnected, or defer the decision to ask for user confirmation.
958 *
959 * This callback is optional. If this callback is not implemented,
960 * the default behavior is to NOT follow the redirection response.
961 *
962 * @param call_id The call ID.
963 * @param target The current target to be tried.
Benny Prijono08a48b82008-11-27 12:42:07 +0000964 * @param e The event that caused this callback to be called.
965 * This could be the receipt of 3xx response, or
966 * 4xx/5xx response received for the INVITE sent to
967 * subsequent targets, or NULL if this callback is
968 * called from within #pjsua_call_process_redirect()
969 * context.
970 *
971 * @return Action to be performed for the target. Set this
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000972 * parameter to one of the value below:
973 * - PJSIP_REDIRECT_ACCEPT: immediately accept the
974 * redirection (default value). When set, the
975 * call will immediately resend INVITE request
976 * to the target.
977 * - PJSIP_REDIRECT_REJECT: immediately reject this
978 * target. The call will continue retrying with
979 * next target if present, or disconnect the call
980 * if there is no more target to try.
981 * - PJSIP_REDIRECT_STOP: stop the whole redirection
982 * process and immediately disconnect the call. The
983 * on_call_state() callback will be called with
984 * PJSIP_INV_STATE_DISCONNECTED state immediately
985 * after this callback returns.
986 * - PJSIP_REDIRECT_PENDING: set to this value if
987 * no decision can be made immediately (for example
988 * to request confirmation from user). Application
989 * then MUST call #pjsua_call_process_redirect()
990 * to either accept or reject the redirection upon
991 * getting user decision.
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000992 */
Benny Prijono08a48b82008-11-27 12:42:07 +0000993 pjsip_redirect_op (*on_call_redirected)(pjsua_call_id call_id,
994 const pjsip_uri *target,
995 const pjsip_event *e);
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000996
Benny Prijono4dd961b2009-10-26 11:21:37 +0000997 /**
998 * This callback is called when a NOTIFY request for message summary /
999 * message waiting indication is received.
1000 *
1001 * @param acc_id The account ID.
1002 * @param mwi_info Structure containing details of the event,
1003 * including the received NOTIFY request in the
1004 * \a rdata field.
1005 */
1006 void (*on_mwi_info)(pjsua_acc_id acc_id, pjsua_mwi_info *mwi_info);
1007
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +00001008 /**
1009 * This callback is called when transport state is changed. See also
1010 * #pjsip_tp_state_callback.
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +00001011 */
Nanang Izzuddin5e69da52010-02-25 11:58:19 +00001012 pjsip_tp_state_callback on_transport_state;
Nanang Izzuddin2fb937e2010-02-24 05:43:34 +00001013
Benny Prijono4d6ff4d2010-06-19 12:35:33 +00001014 /**
1015 * This callback is called to report error in ICE media transport.
1016 * Currently it is used to report TURN Refresh error.
1017 *
1018 * @param index Transport index.
1019 * @param op Operation which trigger the failure.
1020 * @param status Error status.
1021 * @param param Additional info about the event. Currently this will
1022 * always be set to NULL.
1023 */
1024 void (*on_ice_transport_error)(int index, pj_ice_strans_op op,
1025 pj_status_t status, void *param);
1026
Benny Prijono2d647722011-07-13 03:05:22 +00001027 /**
1028 * Callback when the sound device is about to be opened or closed.
1029 * This callback will be called even when null sound device or no
1030 * sound device is configured by the application (i.e. the
1031 * #pjsua_set_null_snd_dev() and #pjsua_set_no_snd_dev() APIs).
1032 * This API is mostly useful when the application wants to manage
1033 * the sound device by itself (i.e. with #pjsua_set_no_snd_dev()),
1034 * to get notified when it should open or close the sound device.
1035 *
1036 * @param operation The value will be set to 0 to signal that sound
1037 * device is about to be closed, and 1 to be opened.
1038 *
1039 * @return The callback must return PJ_SUCCESS at the moment.
1040 */
1041 pj_status_t (*on_snd_dev_operation)(int operation);
1042
1043
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001044} pjsua_callback;
1045
1046
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001047/**
1048 * This enumeration specifies the usage of SIP Session Timers extension.
1049 */
1050typedef enum pjsua_sip_timer_use
1051{
1052 /**
1053 * When this flag is specified, Session Timers will not be used in any
1054 * session, except it is explicitly required in the remote request.
1055 */
1056 PJSUA_SIP_TIMER_INACTIVE,
1057
1058 /**
1059 * When this flag is specified, Session Timers will be used in all
1060 * sessions whenever remote supports and uses it.
1061 */
1062 PJSUA_SIP_TIMER_OPTIONAL,
1063
1064 /**
1065 * When this flag is specified, Session Timers support will be
1066 * a requirement for the remote to be able to establish a session.
1067 */
1068 PJSUA_SIP_TIMER_REQUIRED,
1069
1070 /**
1071 * When this flag is specified, Session Timers will always be used
1072 * in all sessions, regardless whether remote supports/uses it or not.
1073 */
1074 PJSUA_SIP_TIMER_ALWAYS
1075
1076} pjsua_sip_timer_use;
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001077
Benny Prijonodc39fe82006-05-26 12:17:46 +00001078
1079/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001080 * This structure describes the settings to control the API and
1081 * user agent behavior, and can be specified when calling #pjsua_init().
1082 * Before setting the values, application must call #pjsua_config_default()
1083 * to initialize this structure with the default values.
Benny Prijonodc39fe82006-05-26 12:17:46 +00001084 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001085typedef struct pjsua_config
1086{
1087
1088 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001089 * Maximum calls to support (default: 4). The value specified here
1090 * must be smaller than the compile time maximum settings
1091 * PJSUA_MAX_CALLS, which by default is 32. To increase this
1092 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
1093 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001094 */
1095 unsigned max_calls;
1096
1097 /**
1098 * Number of worker threads. Normally application will want to have at
1099 * least one worker thread, unless when it wants to poll the library
1100 * periodically, which in this case the worker thread can be set to
1101 * zero.
1102 */
1103 unsigned thread_cnt;
1104
1105 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +00001106 * Number of nameservers. If no name server is configured, the SIP SRV
1107 * resolution would be disabled, and domain will be resolved with
1108 * standard pj_gethostbyname() function.
1109 */
1110 unsigned nameserver_count;
1111
1112 /**
1113 * Array of nameservers to be used by the SIP resolver subsystem.
1114 * The order of the name server specifies the priority (first name
1115 * server will be used first, unless it is not reachable).
1116 */
1117 pj_str_t nameserver[4];
1118
1119 /**
Benny Prijono91d06b62008-09-20 12:16:56 +00001120 * Force loose-route to be used in all route/proxy URIs (outbound_proxy
1121 * and account's proxy settings). When this setting is enabled, the
1122 * library will check all the route/proxy URIs specified in the settings
1123 * and append ";lr" parameter to the URI if the parameter is not present.
1124 *
1125 * Default: 1
1126 */
1127 pj_bool_t force_lr;
1128
1129 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001130 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001131 */
1132 unsigned outbound_proxy_cnt;
1133
1134 /**
1135 * Specify the URL of outbound proxies to visit for all outgoing requests.
1136 * The outbound proxies will be used for all accounts, and it will
1137 * be used to build the route set for outgoing requests. The final
1138 * route set for outgoing requests will consists of the outbound proxies
1139 * and the proxy configured in the account.
1140 */
1141 pj_str_t outbound_proxy[4];
1142
Benny Prijonoc97608e2007-03-23 16:34:20 +00001143 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001144 * Warning: deprecated, please use \a stun_srv field instead. To maintain
1145 * backward compatibility, if \a stun_srv_cnt is zero then the value of
1146 * this field will be copied to \a stun_srv field, if present.
1147 *
Benny Prijonoebbf6892007-03-24 17:37:25 +00001148 * Specify domain name to be resolved with DNS SRV resolution to get the
Benny Prijonof76e1392008-06-06 14:51:48 +00001149 * address of the STUN server. Alternatively application may specify
1150 * \a stun_host instead.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001151 *
1152 * If DNS SRV resolution failed for this domain, then DNS A resolution
1153 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +00001154 */
Benny Prijonoebbf6892007-03-24 17:37:25 +00001155 pj_str_t stun_domain;
1156
1157 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001158 * Warning: deprecated, please use \a stun_srv field instead. To maintain
1159 * backward compatibility, if \a stun_srv_cnt is zero then the value of
1160 * this field will be copied to \a stun_srv field, if present.
1161 *
Benny Prijonoaf09dc32007-04-22 12:48:30 +00001162 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
1163 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +00001164 */
1165 pj_str_t stun_host;
1166
1167 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001168 * Number of STUN server entries in \a stun_srv array.
1169 */
1170 unsigned stun_srv_cnt;
1171
1172 /**
1173 * Array of STUN servers to try. The library will try to resolve and
1174 * contact each of the STUN server entry until it finds one that is
1175 * usable. Each entry may be a domain name, host name, IP address, and
1176 * it may contain an optional port number. For example:
1177 * - "pjsip.org" (domain name)
1178 * - "sip.pjsip.org" (host name)
1179 * - "pjsip.org:33478" (domain name and a non-standard port number)
1180 * - "10.0.0.1:3478" (IP address and port number)
1181 *
1182 * When nameserver is configured in the \a pjsua_config.nameserver field,
1183 * if entry is not an IP address, it will be resolved with DNS SRV
1184 * resolution first, and it will fallback to use DNS A resolution if this
1185 * fails. Port number may be specified even if the entry is a domain name,
1186 * in case the DNS SRV resolution should fallback to a non-standard port.
1187 *
1188 * When nameserver is not configured, entries will be resolved with
1189 * #pj_gethostbyname() if it's not an IP address. Port number may be
1190 * specified if the server is not listening in standard STUN port.
1191 */
1192 pj_str_t stun_srv[8];
1193
1194 /**
1195 * This specifies if the library startup should ignore failure with the
1196 * STUN servers. If this is set to PJ_FALSE, the library will refuse to
1197 * start if it fails to resolve or contact any of the STUN servers.
1198 *
1199 * Default: PJ_TRUE
1200 */
1201 pj_bool_t stun_ignore_failure;
1202
1203 /**
Benny Prijono91a6a172007-10-31 08:59:29 +00001204 * Support for adding and parsing NAT type in the SDP to assist
1205 * troubleshooting. The valid values are:
1206 * - 0: no information will be added in SDP, and parsing is disabled.
Benny Prijono6ba8c542007-10-16 01:34:14 +00001207 * - 1: only the NAT type number is added.
1208 * - 2: add both NAT type number and name.
1209 *
Benny Prijono91a6a172007-10-31 08:59:29 +00001210 * Default: 1
Benny Prijono6ba8c542007-10-16 01:34:14 +00001211 */
1212 int nat_type_in_sdp;
1213
1214 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001215 * Specify whether support for reliable provisional response (100rel and
1216 * PRACK) should be required by default. Note that this setting can be
1217 * further customized in account configuration (#pjsua_acc_config).
1218 *
1219 * Default: PJ_FALSE
1220 */
1221 pj_bool_t require_100rel;
1222
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001223 /**
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001224 * Specify the usage of Session Timers for all sessions. See the
1225 * #pjsua_sip_timer_use for possible values. Note that this setting can be
1226 * further customized in account configuration (#pjsua_acc_config).
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001227 *
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001228 * Default: PJSUA_SIP_TIMER_OPTIONAL
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001229 */
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00001230 pjsua_sip_timer_use use_timer;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001231
1232 /**
Benny Prijonofe1bd342009-11-20 23:33:07 +00001233 * Handle unsolicited NOTIFY requests containing message waiting
1234 * indication (MWI) info. Unsolicited MWI is incoming NOTIFY requests
1235 * which are not requested by client with SUBSCRIBE request.
1236 *
1237 * If this is enabled, the library will respond 200/OK to the NOTIFY
1238 * request and forward the request to \a on_mwi_info() callback.
1239 *
1240 * See also \a mwi_enabled field #on pjsua_acc_config.
1241 *
1242 * Default: PJ_TRUE
1243 *
1244 */
1245 pj_bool_t enable_unsolicited_mwi;
1246
1247 /**
Nanang Izzuddin65add622009-08-11 16:26:20 +00001248 * Specify Session Timer settings, see #pjsip_timer_setting.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001249 * Note that this setting can be further customized in account
1250 * configuration (#pjsua_acc_config).
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001251 */
Nanang Izzuddin65add622009-08-11 16:26:20 +00001252 pjsip_timer_setting timer_setting;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001253
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001254 /**
1255 * Number of credentials in the credential array.
1256 */
1257 unsigned cred_count;
1258
1259 /**
1260 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +00001261 * and can be used to authenticate against outbound proxies. If the
1262 * credential is specific to the account, then application should set
1263 * the credential in the pjsua_acc_config rather than the credential
1264 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001265 */
1266 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1267
1268 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001269 * Application callback to receive various event notifications from
1270 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001271 */
1272 pjsua_callback cb;
1273
Benny Prijono56315612006-07-18 14:39:40 +00001274 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001275 * Optional user agent string (default empty). If it's empty, no
1276 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +00001277 */
1278 pj_str_t user_agent;
1279
Benny Prijonod8179652008-01-23 20:39:07 +00001280 /**
1281 * Specify default value of secure media transport usage.
1282 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
1283 * PJMEDIA_SRTP_MANDATORY.
1284 *
1285 * Note that this setting can be further customized in account
1286 * configuration (#pjsua_acc_config).
1287 *
1288 * Default: #PJSUA_DEFAULT_USE_SRTP
1289 */
1290 pjmedia_srtp_use use_srtp;
1291
1292 /**
1293 * Specify whether SRTP requires secure signaling to be used. This option
1294 * is only used when \a use_srtp option above is non-zero.
1295 *
1296 * Valid values are:
1297 * 0: SRTP does not require secure signaling
1298 * 1: SRTP requires secure transport such as TLS
1299 * 2: SRTP requires secure end-to-end transport (SIPS)
1300 *
1301 * Note that this setting can be further customized in account
1302 * configuration (#pjsua_acc_config).
1303 *
1304 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
1305 */
1306 int srtp_secure_signaling;
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00001307
1308 /**
Benny Prijono0bc99a92011-03-17 04:34:43 +00001309 * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00001310 * duplicated media in SDP offer, i.e: unsecured and secured version.
Benny Prijono0bc99a92011-03-17 04:34:43 +00001311 * Otherwise, the SDP media will be composed as unsecured media but
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00001312 * with SDP "crypto" attribute.
1313 *
1314 * Default: PJ_FALSE
1315 */
1316 pj_bool_t srtp_optional_dup_offer;
Benny Prijonod8179652008-01-23 20:39:07 +00001317
Benny Prijono3c5e28b2008-09-24 10:10:15 +00001318 /**
1319 * Disconnect other call legs when more than one 2xx responses for
1320 * outgoing INVITE are received due to forking. Currently the library
1321 * is not able to handle simultaneous forked media, so disconnecting
1322 * the other call legs is necessary.
1323 *
1324 * With this setting enabled, the library will handle only one of the
1325 * connected call leg, and the other connected call legs will be
1326 * disconnected.
1327 *
1328 * Default: PJ_TRUE (only disable this setting for testing purposes).
1329 */
1330 pj_bool_t hangup_forked_call;
1331
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001332} pjsua_config;
1333
1334
1335/**
1336 * Use this function to initialize pjsua config.
1337 *
1338 * @param cfg pjsua config to be initialized.
1339 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001340PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001341
1342
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001343/** The implementation has been moved to sip_auth.h */
Benny Prijono7977f9f2007-10-10 11:37:56 +00001344#define pjsip_cred_dup pjsip_cred_info_dup
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001345
1346
1347/**
1348 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001349 *
1350 * @param pool The pool to get memory from.
1351 * @param dst Destination config.
1352 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001353 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001354PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1355 pjsua_config *dst,
1356 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001357
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001358
1359/**
1360 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001361 * outgoing SIP message. It can (optionally) be specified for example
1362 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1363 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1364 *
1365 * Application MUST call #pjsua_msg_data_init() to initialize this
1366 * structure before setting its values.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001367 */
Benny Prijono63fba012008-07-17 14:19:10 +00001368struct pjsua_msg_data
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001369{
1370 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001371 * Additional message headers as linked list. Application can add
1372 * headers to the list by creating the header, either from the heap/pool
1373 * or from temporary local variable, and add the header using
1374 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001375 */
1376 pjsip_hdr hdr_list;
1377
1378 /**
1379 * MIME type of optional message body.
1380 */
1381 pj_str_t content_type;
1382
1383 /**
Benny Prijono1c1d7342010-08-01 09:48:51 +00001384 * Optional message body to be added to the message, only when the
1385 * message doesn't have a body.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001386 */
1387 pj_str_t msg_body;
1388
Benny Prijono1c1d7342010-08-01 09:48:51 +00001389 /**
1390 * Content type of the multipart body. If application wants to send
1391 * multipart message bodies, it puts the parts in \a parts and set
1392 * the content type in \a multipart_ctype. If the message already
1393 * contains a body, the body will be added to the multipart bodies.
1394 */
1395 pjsip_media_type multipart_ctype;
1396
1397 /**
1398 * List of multipart parts. If application wants to send multipart
1399 * message bodies, it puts the parts in \a parts and set the content
1400 * type in \a multipart_ctype. If the message already contains a body,
1401 * the body will be added to the multipart bodies.
1402 */
1403 pjsip_multipart_part multipart_parts;
Benny Prijono63fba012008-07-17 14:19:10 +00001404};
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001405
1406
1407/**
1408 * Initialize message data.
1409 *
1410 * @param msg_data Message data to be initialized.
1411 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001412PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001413
Benny Prijono268ca612006-02-07 12:34:11 +00001414
1415/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001416 * Instantiate pjsua application. Application must call this function before
1417 * calling any other functions, to make sure that the underlying libraries
1418 * are properly initialized. Once this function has returned success,
1419 * application must call pjsua_destroy() before quitting.
1420 *
1421 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00001422 */
1423PJ_DECL(pj_status_t) pjsua_create(void);
1424
1425
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001426/** Forward declaration */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001427typedef struct pjsua_media_config pjsua_media_config;
1428
1429
Benny Prijonodc39fe82006-05-26 12:17:46 +00001430/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001431 * Initialize pjsua with the specified settings. All the settings are
1432 * optional, and the default values will be used when the config is not
1433 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001434 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001435 * Note that #pjsua_create() MUST be called before calling this function.
1436 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001437 * @param ua_cfg User agent configuration.
1438 * @param log_cfg Optional logging configuration.
1439 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001440 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001441 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001442 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001443PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1444 const pjsua_logging_config *log_cfg,
1445 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001446
1447
1448/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001449 * Application is recommended to call this function after all initialization
1450 * is done, so that the library can do additional checking set up
1451 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001452 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001453 * Application may call this function anytime after #pjsua_init().
1454 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001455 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoccf95622006-02-07 18:48:01 +00001456 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001457PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001458
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001459
Benny Prijonoccf95622006-02-07 18:48:01 +00001460/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001461 * Destroy pjsua. Application is recommended to perform graceful shutdown
1462 * before calling this function (such as unregister the account from the SIP
1463 * server, terminate presense subscription, and hangup active calls), however,
1464 * this function will do all of these if it finds there are active sessions
1465 * that need to be terminated. This function will approximately block for
1466 * one second to wait for replies from remote.
1467 *
1468 * Application.may safely call this function more than once if it doesn't
1469 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001470 *
1471 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001472 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001473PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001474
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001475
Benny Prijono9fc735d2006-05-28 14:58:12 +00001476/**
Benny Prijono0bc99a92011-03-17 04:34:43 +00001477 * Retrieve pjsua state.
1478 *
1479 * @return pjsua state.
1480 */
1481PJ_DECL(pjsua_state) pjsua_get_state(void);
1482
1483
1484/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001485 * Poll pjsua for events, and if necessary block the caller thread for
1486 * the specified maximum interval (in miliseconds).
1487 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001488 * Application doesn't normally need to call this function if it has
1489 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1490 * because polling then will be done by these worker threads instead.
1491 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001492 * @param msec_timeout Maximum time to wait, in miliseconds.
1493 *
1494 * @return The number of events that have been handled during the
1495 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001496 * can retrieve the error as (status = -return_value).
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001497 */
1498PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1499
1500
1501/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001502 * Create memory pool to be used by the application. Once application
1503 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001504 *
1505 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001506 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001507 * @param increment Increment size.
1508 *
1509 * @return The pool, or NULL when there's no memory.
1510 */
1511PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1512 pj_size_t increment);
1513
1514
1515/**
1516 * Application can call this function at any time (after pjsua_create(), of
1517 * course) to change logging settings.
1518 *
1519 * @param c Logging configuration.
1520 *
1521 * @return PJ_SUCCESS on success, or the appropriate error code.
1522 */
1523PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1524
1525
1526/**
1527 * Internal function to get SIP endpoint instance of pjsua, which is
1528 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001529 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001530 *
1531 * @return SIP endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001532 */
1533PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1534
1535/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001536 * Internal function to get media endpoint instance.
1537 * Only valid after #pjsua_init() is called.
1538 *
1539 * @return Media endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001540 */
1541PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1542
Benny Prijono97b87172006-08-24 14:25:14 +00001543/**
1544 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001545 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001546 *
1547 * @return Pool factory currently used by PJSUA.
1548 */
1549PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1550
1551
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001552
1553/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001554 * Utilities.
1555 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001556 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001557
1558/**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001559 * This structure is used to represent the result of the STUN server
1560 * resolution and testing, the #pjsua_resolve_stun_servers() function.
1561 * This structure will be passed in #pj_stun_resolve_cb callback.
1562 */
1563typedef struct pj_stun_resolve_result
1564{
1565 /**
1566 * Arbitrary data that was passed to #pjsua_resolve_stun_servers()
1567 * function.
1568 */
1569 void *token;
1570
1571 /**
1572 * This will contain PJ_SUCCESS if at least one usable STUN server
1573 * is found, otherwise it will contain the last error code during
1574 * the operation.
1575 */
1576 pj_status_t status;
1577
1578 /**
1579 * The server name that yields successful result. This will only
1580 * contain value if status is successful.
1581 */
1582 pj_str_t name;
1583
1584 /**
1585 * The server IP address. This will only contain value if status
1586 * is successful.
1587 */
1588 pj_sockaddr addr;
1589
1590} pj_stun_resolve_result;
1591
1592
1593/**
1594 * Typedef of callback to be registered to #pjsua_resolve_stun_servers().
1595 */
1596typedef void (*pj_stun_resolve_cb)(const pj_stun_resolve_result *result);
1597
1598/**
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001599 * This is a utility function to detect NAT type in front of this
1600 * endpoint. Once invoked successfully, this function will complete
Benny Prijono6ba8c542007-10-16 01:34:14 +00001601 * asynchronously and report the result in \a on_nat_detect() callback
1602 * of pjsua_callback.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001603 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001604 * After NAT has been detected and the callback is called, application can
1605 * get the detected NAT type by calling #pjsua_get_nat_type(). Application
1606 * can also perform NAT detection by calling #pjsua_detect_nat_type()
1607 * again at later time.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001608 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001609 * Note that STUN must be enabled to run this function successfully.
1610 *
1611 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001612 */
Benny Prijono6ba8c542007-10-16 01:34:14 +00001613PJ_DECL(pj_status_t) pjsua_detect_nat_type(void);
1614
1615
1616/**
1617 * Get the NAT type as detected by #pjsua_detect_nat_type() function.
1618 * This function will only return useful NAT type after #pjsua_detect_nat_type()
1619 * has completed successfully and \a on_nat_detect() callback has been called.
1620 *
1621 * @param type NAT type.
1622 *
1623 * @return When detection is in progress, this function will
1624 * return PJ_EPENDING and \a type will be set to
1625 * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been
1626 * detected successfully, this function will return
1627 * PJ_SUCCESS and \a type will be set to the correct
1628 * value. Other return values indicate error and
1629 * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN.
Benny Prijono91a6a172007-10-31 08:59:29 +00001630 *
1631 * @see pjsua_call_get_rem_nat_type()
Benny Prijono6ba8c542007-10-16 01:34:14 +00001632 */
1633PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type);
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001634
1635
1636/**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001637 * Auxiliary function to resolve and contact each of the STUN server
1638 * entries (sequentially) to find which is usable. The #pjsua_init() must
1639 * have been called before calling this function.
1640 *
1641 * @param count Number of STUN server entries to try.
1642 * @param srv Array of STUN server entries to try. Please see
1643 * the \a stun_srv field in the #pjsua_config
1644 * documentation about the format of this entry.
1645 * @param wait Specify non-zero to make the function block until
1646 * it gets the result. In this case, the function
1647 * will block while the resolution is being done,
1648 * and the callback will be called before this function
1649 * returns.
1650 * @param token Arbitrary token to be passed back to application
1651 * in the callback.
1652 * @param cb Callback to be called to notify the result of
1653 * the function.
1654 *
1655 * @return If \a wait parameter is non-zero, this will return
1656 * PJ_SUCCESS if one usable STUN server is found.
1657 * Otherwise it will always return PJ_SUCCESS, and
1658 * application will be notified about the result in
1659 * the callback.
1660 */
1661PJ_DECL(pj_status_t) pjsua_resolve_stun_servers(unsigned count,
1662 pj_str_t srv[],
1663 pj_bool_t wait,
1664 void *token,
1665 pj_stun_resolve_cb cb);
1666
1667/**
1668 * Cancel pending STUN resolution which match the specified token.
1669 *
1670 * @param token The token to match. This token was given to
1671 * #pjsua_resolve_stun_servers()
1672 * @param notify_cb Boolean to control whether the callback should
1673 * be called for cancelled resolutions. When the
1674 * callback is called, the status in the result
1675 * will be set as PJ_ECANCELLED.
1676 *
1677 * @return PJ_SUCCESS if there is at least one pending STUN
1678 * resolution cancelled, or PJ_ENOTFOUND if there is
1679 * no matching one, or other error.
1680 */
1681PJ_DECL(pj_status_t) pjsua_cancel_stun_resolution(void *token,
1682 pj_bool_t notify_cb);
1683
1684
1685/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001686 * This is a utility function to verify that valid SIP url is given. If the
Benny Prijonoc7545782010-09-28 07:43:18 +00001687 * URL is a valid SIP/SIPS scheme, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001688 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001689 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001690 *
1691 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoc7545782010-09-28 07:43:18 +00001692 *
1693 * @see pjsua_verify_url()
Benny Prijono312aff92006-06-17 04:08:30 +00001694 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001695PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001696
1697
1698/**
Benny Prijonoc7545782010-09-28 07:43:18 +00001699 * This is a utility function to verify that valid URI is given. Unlike
1700 * pjsua_verify_sip_url(), this function will return PJ_SUCCESS if tel: URI
1701 * is given.
1702 *
1703 * @param url The URL, as NULL terminated string.
1704 *
1705 * @return PJ_SUCCESS on success, or the appropriate error code.
1706 *
1707 * @see pjsua_verify_sip_url()
1708 */
1709PJ_DECL(pj_status_t) pjsua_verify_url(const char *url);
1710
1711
1712/**
Benny Prijono73bb7232009-10-20 13:56:26 +00001713 * Schedule a timer entry. Note that the timer callback may be executed
1714 * by different thread, depending on whether worker thread is enabled or
1715 * not.
1716 *
1717 * @param entry Timer heap entry.
1718 * @param delay The interval to expire.
1719 *
1720 * @return PJ_SUCCESS on success, or the appropriate error code.
1721 *
1722 * @see pjsip_endpt_schedule_timer()
1723 */
1724PJ_DECL(pj_status_t) pjsua_schedule_timer(pj_timer_entry *entry,
1725 const pj_time_val *delay);
1726
1727
1728/**
1729 * Cancel the previously scheduled timer.
1730 *
1731 * @param entry Timer heap entry.
1732 *
1733 * @see pjsip_endpt_cancel_timer()
1734 */
1735PJ_DECL(void) pjsua_cancel_timer(pj_timer_entry *entry);
1736
1737
1738/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001739 * This is a utility function to display error message for the specified
1740 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001741 *
1742 * @param sender The log sender field.
1743 * @param title Message title for the error.
1744 * @param status Status code.
1745 */
1746PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1747 pj_status_t status);
1748
1749
Benny Prijonoda9785b2007-04-02 20:43:06 +00001750/**
1751 * This is a utility function to dump the stack states to log, using
1752 * verbosity level 3.
1753 *
1754 * @param detail Will print detailed output (such as list of
1755 * SIP transactions) when non-zero.
1756 */
1757PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001758
1759/**
1760 * @}
1761 */
1762
1763
1764
1765/*****************************************************************************
1766 * TRANSPORT API
1767 */
1768
1769/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001770 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001771 * @ingroup PJSUA_LIB
1772 * @brief API for managing SIP transports
1773 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001774 *
1775 * PJSUA-API supports creating multiple transport instances, for example UDP,
1776 * TCP, and TLS transport. SIP transport must be created before adding an
1777 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001778 */
1779
1780
Benny Prijonoe6ead542007-01-31 20:53:31 +00001781/** SIP transport identification.
1782 */
Benny Prijono312aff92006-06-17 04:08:30 +00001783typedef int pjsua_transport_id;
1784
1785
1786/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001787 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001788 * and media. Before setting some values to this structure, application
1789 * MUST call #pjsua_transport_config_default() to initialize its
1790 * values with default settings.
Benny Prijono312aff92006-06-17 04:08:30 +00001791 */
1792typedef struct pjsua_transport_config
1793{
1794 /**
1795 * UDP port number to bind locally. This setting MUST be specified
1796 * even when default port is desired. If the value is zero, the
1797 * transport will be bound to any available port, and application
1798 * can query the port by querying the transport info.
1799 */
1800 unsigned port;
1801
1802 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001803 * Optional address to advertise as the address of this transport.
1804 * Application can specify any address or hostname for this field,
1805 * for example it can point to one of the interface address in the
1806 * system, or it can point to the public address of a NAT router
1807 * where port mappings have been configured for the application.
1808 *
1809 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001810 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001811 pj_str_t public_addr;
1812
1813 /**
1814 * Optional address where the socket should be bound to. This option
1815 * SHOULD only be used to selectively bind the socket to particular
1816 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1817 * published address of a transport (the public_addr field should be
1818 * used for that purpose).
1819 *
1820 * Note that unlike public_addr field, the address (or hostname) here
1821 * MUST correspond to the actual interface address in the host, since
1822 * this address will be specified as bind() argument.
1823 */
1824 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001825
1826 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001827 * This specifies TLS settings for TLS transport. It is only be used
1828 * when this transport config is being used to create a SIP TLS
1829 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001830 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001831 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001832
Benny Prijono4d79b0f2009-10-25 09:02:07 +00001833 /**
1834 * QoS traffic type to be set on this transport. When application wants
1835 * to apply QoS tagging to the transport, it's preferable to set this
1836 * field rather than \a qos_param fields since this is more portable.
1837 *
1838 * Default is QoS not set.
1839 */
1840 pj_qos_type qos_type;
1841
1842 /**
1843 * Set the low level QoS parameters to the transport. This is a lower
1844 * level operation than setting the \a qos_type field and may not be
1845 * supported on all platforms.
1846 *
1847 * Default is QoS not set.
1848 */
1849 pj_qos_params qos_params;
1850
Benny Prijono312aff92006-06-17 04:08:30 +00001851} pjsua_transport_config;
1852
1853
1854/**
1855 * Call this function to initialize UDP config with default values.
1856 *
1857 * @param cfg The UDP config to be initialized.
1858 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001859PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001860
1861
1862/**
Benny Prijono312aff92006-06-17 04:08:30 +00001863 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001864 *
1865 * @param pool The pool.
1866 * @param dst The destination config.
1867 * @param src The source config.
Benny Prijono312aff92006-06-17 04:08:30 +00001868 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001869PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1870 pjsua_transport_config *dst,
1871 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001872
1873
1874/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001875 * This structure describes transport information returned by
1876 * #pjsua_transport_get_info() function.
Benny Prijono312aff92006-06-17 04:08:30 +00001877 */
1878typedef struct pjsua_transport_info
1879{
1880 /**
1881 * PJSUA transport identification.
1882 */
1883 pjsua_transport_id id;
1884
1885 /**
1886 * Transport type.
1887 */
1888 pjsip_transport_type_e type;
1889
1890 /**
1891 * Transport type name.
1892 */
1893 pj_str_t type_name;
1894
1895 /**
1896 * Transport string info/description.
1897 */
1898 pj_str_t info;
1899
1900 /**
1901 * Transport flag (see ##pjsip_transport_flags_e).
1902 */
1903 unsigned flag;
1904
1905 /**
1906 * Local address length.
1907 */
1908 unsigned addr_len;
1909
1910 /**
1911 * Local/bound address.
1912 */
1913 pj_sockaddr local_addr;
1914
1915 /**
1916 * Published address (or transport address name).
1917 */
1918 pjsip_host_port local_name;
1919
1920 /**
1921 * Current number of objects currently referencing this transport.
1922 */
1923 unsigned usage_count;
1924
1925
1926} pjsua_transport_info;
1927
1928
1929/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001930 * Create and start a new SIP transport according to the specified
1931 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001932 *
1933 * @param type Transport type.
1934 * @param cfg Transport configuration.
1935 * @param p_id Optional pointer to receive transport ID.
1936 *
1937 * @return PJ_SUCCESS on success, or the appropriate error code.
1938 */
1939PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1940 const pjsua_transport_config *cfg,
1941 pjsua_transport_id *p_id);
1942
1943/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001944 * Register transport that has been created by application. This function
1945 * is useful if application wants to implement custom SIP transport and use
1946 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001947 *
1948 * @param tp Transport instance.
1949 * @param p_id Optional pointer to receive transport ID.
1950 *
1951 * @return PJ_SUCCESS on success, or the appropriate error code.
1952 */
1953PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1954 pjsua_transport_id *p_id);
1955
1956
1957/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001958 * Enumerate all transports currently created in the system. This function
1959 * will return all transport IDs, and application may then call
1960 * #pjsua_transport_get_info() function to retrieve detailed information
1961 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001962 *
1963 * @param id Array to receive transport ids.
1964 * @param count In input, specifies the maximum number of elements.
1965 * On return, it contains the actual number of elements.
1966 *
1967 * @return PJ_SUCCESS on success, or the appropriate error code.
1968 */
1969PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1970 unsigned *count );
1971
1972
1973/**
1974 * Get information about transports.
1975 *
1976 * @param id Transport ID.
1977 * @param info Pointer to receive transport info.
1978 *
1979 * @return PJ_SUCCESS on success, or the appropriate error code.
1980 */
1981PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1982 pjsua_transport_info *info);
1983
1984
1985/**
1986 * Disable a transport or re-enable it. By default transport is always
1987 * enabled after it is created. Disabling a transport does not necessarily
1988 * close the socket, it will only discard incoming messages and prevent
1989 * the transport from being used to send outgoing messages.
1990 *
1991 * @param id Transport ID.
1992 * @param enabled Non-zero to enable, zero to disable.
1993 *
1994 * @return PJ_SUCCESS on success, or the appropriate error code.
1995 */
1996PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1997 pj_bool_t enabled);
1998
1999
2000/**
2001 * Close the transport. If transport is forcefully closed, it will be
2002 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00002003 * transport may not terminate properly (it may even crash). Otherwise,
2004 * the system will wait until all transactions are closed while preventing
2005 * new users from using the transport, and will close the transport when
2006 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002007 *
2008 * @param id Transport ID.
2009 * @param force Non-zero to immediately close the transport. This
2010 * is not recommended!
2011 *
2012 * @return PJ_SUCCESS on success, or the appropriate error code.
2013 */
2014PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
2015 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00002016
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002017/**
Benny Prijono312aff92006-06-17 04:08:30 +00002018 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002019 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002020
2021
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002022
2023
2024/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00002025 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00002026 */
2027
Benny Prijono312aff92006-06-17 04:08:30 +00002028
2029/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002030 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00002031 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00002032 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00002033 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00002034 *
Benny Prijono312aff92006-06-17 04:08:30 +00002035 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00002036 * using the application. In SIP terms, the identity is used as the <b>From</b>
2037 * header in outgoing requests.
2038 *
2039 * PJSUA-API supports creating and managing multiple accounts. The maximum
2040 * number of accounts is limited by a compile time constant
2041 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00002042 *
2043 * Account may or may not have client registration associated with it.
2044 * An account is also associated with <b>route set</b> and some <b>authentication
2045 * credentials</b>, which are used when sending SIP request messages using the
2046 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00002047 * will be reported to remote peer when they subscribe to the account's
2048 * presence, or which is published to a presence server if presence
2049 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00002050 *
2051 * At least one account MUST be created in the application. If no user
2052 * association is required, application can create a userless account by
2053 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00002054 * instead of a particular user, and it correspond with a particular
2055 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00002056 *
2057 * Also one account must be set as the <b>default account</b>, which is used as
2058 * the account to use when PJSUA fails to match a request with any other
2059 * accounts.
2060 *
2061 * When sending outgoing SIP requests (such as making calls or sending
2062 * instant messages), normally PJSUA requires the application to specify
2063 * which account to use for the request. If no account is specified,
2064 * PJSUA may be able to select the account by matching the destination
2065 * domain name, and fall back to default account when no match is found.
2066 */
2067
2068/**
2069 * Maximum accounts.
2070 */
2071#ifndef PJSUA_MAX_ACC
2072# define PJSUA_MAX_ACC 8
2073#endif
2074
2075
2076/**
2077 * Default registration interval.
2078 */
2079#ifndef PJSUA_REG_INTERVAL
Benny Prijonobddef2c2007-10-31 13:28:08 +00002080# define PJSUA_REG_INTERVAL 300
Benny Prijono312aff92006-06-17 04:08:30 +00002081#endif
2082
2083
2084/**
Benny Prijono384dab42009-10-14 01:58:04 +00002085 * Default maximum time to wait for account unregistration transactions to
2086 * complete during library shutdown sequence.
2087 *
2088 * Default: 4000 (4 seconds)
2089 */
2090#ifndef PJSUA_UNREG_TIMEOUT
2091# define PJSUA_UNREG_TIMEOUT 4000
2092#endif
2093
2094
2095/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002096 * Default PUBLISH expiration
2097 */
2098#ifndef PJSUA_PUBLISH_EXPIRATION
Benny Prijono53984d12009-04-28 22:19:49 +00002099# define PJSUA_PUBLISH_EXPIRATION PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002100#endif
2101
2102
2103/**
Benny Prijono093d3022006-09-24 00:07:11 +00002104 * Default account priority.
2105 */
2106#ifndef PJSUA_DEFAULT_ACC_PRIORITY
2107# define PJSUA_DEFAULT_ACC_PRIORITY 0
2108#endif
2109
2110
2111/**
Benny Prijono8058a622007-06-08 04:37:05 +00002112 * This macro specifies the URI scheme to use in Contact header
2113 * when secure transport such as TLS is used. Application can specify
2114 * either "sip" or "sips".
2115 */
2116#ifndef PJSUA_SECURE_SCHEME
Benny Prijono4c82c1e2008-10-16 08:14:51 +00002117# define PJSUA_SECURE_SCHEME "sip"
Benny Prijono8058a622007-06-08 04:37:05 +00002118#endif
2119
2120
2121/**
Benny Prijono534a9ba2009-10-13 14:01:59 +00002122 * Maximum time to wait for unpublication transaction(s) to complete
2123 * during shutdown process, before sending unregistration. The library
2124 * tries to wait for the unpublication (un-PUBLISH) to complete before
2125 * sending REGISTER request to unregister the account, during library
2126 * shutdown process. If the value is set too short, it is possible that
2127 * the unregistration is sent before unpublication completes, causing
2128 * unpublication request to fail.
2129 *
2130 * Default: 2000 (2 seconds)
2131 */
2132#ifndef PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
2133# define PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC 2000
2134#endif
2135
2136
2137/**
Nanang Izzuddin36dd5b62010-03-30 11:13:59 +00002138 * Default auto retry re-registration interval, in seconds. Set to 0
2139 * to disable this. Application can set the timer on per account basis
2140 * by setting the pjsua_acc_config.reg_retry_interval field instead.
2141 *
2142 * Default: 300 (5 minutes)
2143 */
2144#ifndef PJSUA_REG_RETRY_INTERVAL
2145# define PJSUA_REG_RETRY_INTERVAL 300
2146#endif
2147
2148
2149/**
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00002150 * This macro specifies the default value for \a contact_rewrite_method
2151 * field in pjsua_acc_config. I specifies how Contact update will be
2152 * done with the registration, if \a allow_contact_rewrite is enabled in
2153 * the account config.
2154 *
2155 * If set to 1, the Contact update will be done by sending unregistration
2156 * to the currently registered Contact, while simultaneously sending new
2157 * registration (with different Call-ID) for the updated Contact.
2158 *
2159 * If set to 2, the Contact update will be done in a single, current
2160 * registration session, by removing the current binding (by setting its
2161 * Contact's expires parameter to zero) and adding a new Contact binding,
2162 * all done in a single request.
2163 *
2164 * Value 1 is the legacy behavior.
2165 *
2166 * Default value: 2
2167 */
2168#ifndef PJSUA_CONTACT_REWRITE_METHOD
2169# define PJSUA_CONTACT_REWRITE_METHOD 2
2170#endif
2171
2172
2173/**
Benny Prijono29c8ca32010-06-22 06:02:13 +00002174 * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that
2175 * the global outbound proxy list should be added to the REGISTER request.
2176 */
2177#define PJSUA_REG_USE_OUTBOUND_PROXY 1
2178
2179
2180/**
2181 * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that
2182 * the account proxy list should be added to the REGISTER request.
2183 */
2184#define PJSUA_REG_USE_ACC_PROXY 2
2185
2186
2187/**
Benny Prijonodd63b992010-10-01 02:03:42 +00002188 * This enumeration specifies how we should offer call hold request to
2189 * remote peer. The default value is set by compile time constant
2190 * PJSUA_CALL_HOLD_TYPE_DEFAULT, and application may control the setting
2191 * on per-account basis by manipulating \a call_hold_type field in
2192 * #pjsua_acc_config.
2193 */
2194typedef enum pjsua_call_hold_type
2195{
2196 /**
2197 * This will follow RFC 3264 recommendation to use a=sendonly,
2198 * a=recvonly, and a=inactive attribute as means to signal call
2199 * hold status. This is the correct value to use.
2200 */
2201 PJSUA_CALL_HOLD_TYPE_RFC3264,
2202
2203 /**
2204 * This will use the old and deprecated method as specified in RFC 2543,
2205 * and will offer c=0.0.0.0 in the SDP instead. Using this has many
2206 * drawbacks such as inability to keep the media transport alive while
2207 * the call is being put on hold, and should only be used if remote
2208 * does not understand RFC 3264 style call hold offer.
2209 */
2210 PJSUA_CALL_HOLD_TYPE_RFC2543
2211
2212} pjsua_call_hold_type;
2213
2214
2215/**
2216 * Specify the default call hold type to be used in #pjsua_acc_config.
2217 *
2218 * Default is PJSUA_CALL_HOLD_TYPE_RFC3264, and there's no reason to change
2219 * this except if you're communicating with an old/non-standard peer.
2220 */
2221#ifndef PJSUA_CALL_HOLD_TYPE_DEFAULT
2222# define PJSUA_CALL_HOLD_TYPE_DEFAULT PJSUA_CALL_HOLD_TYPE_RFC3264
2223#endif
2224
Benny Prijonodd63b992010-10-01 02:03:42 +00002225/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002226 * This structure describes account configuration to be specified when
2227 * adding a new account with #pjsua_acc_add(). Application MUST initialize
2228 * this structure first by calling #pjsua_acc_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00002229 */
2230typedef struct pjsua_acc_config
2231{
Benny Prijono093d3022006-09-24 00:07:11 +00002232 /**
Benny Prijono705e7842008-07-21 18:12:51 +00002233 * Arbitrary user data to be associated with the newly created account.
2234 * Application may set this later with #pjsua_acc_set_user_data() and
2235 * retrieve it with #pjsua_acc_get_user_data().
2236 */
2237 void *user_data;
2238
2239 /**
Benny Prijono093d3022006-09-24 00:07:11 +00002240 * Account priority, which is used to control the order of matching
2241 * incoming/outgoing requests. The higher the number means the higher
2242 * the priority is, and the account will be matched first.
2243 */
2244 int priority;
2245
Benny Prijono312aff92006-06-17 04:08:30 +00002246 /**
2247 * The full SIP URL for the account. The value can take name address or
2248 * URL format, and will look something like "sip:account@serviceprovider".
2249 *
2250 * This field is mandatory.
2251 */
2252 pj_str_t id;
2253
2254 /**
2255 * This is the URL to be put in the request URI for the registration,
2256 * and will look something like "sip:serviceprovider".
2257 *
2258 * This field should be specified if registration is desired. If the
2259 * value is empty, no account registration will be performed.
2260 */
2261 pj_str_t reg_uri;
2262
Nanang Izzuddin60e8aa92010-09-28 10:48:48 +00002263 /**
2264 * The optional custom SIP headers to be put in the registration
2265 * request.
2266 */
2267 pjsip_hdr reg_hdr_list;
2268
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002269 /**
Benny Prijonofe1bd342009-11-20 23:33:07 +00002270 * Subscribe to message waiting indication events (RFC 3842).
2271 *
2272 * See also \a enable_unsolicited_mwi field on #pjsua_config.
Benny Prijono4dd961b2009-10-26 11:21:37 +00002273 *
2274 * Default: no
2275 */
2276 pj_bool_t mwi_enabled;
2277
2278 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002279 * If this flag is set, the presence information of this account will
2280 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono48ab2b72007-11-08 09:24:30 +00002281 *
2282 * Default: PJ_FALSE
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00002283 */
2284 pj_bool_t publish_enabled;
2285
Benny Prijonofe04fb52007-08-24 08:28:52 +00002286 /**
Benny Prijonofe50c9e2009-10-12 07:44:14 +00002287 * Event publication options.
2288 */
2289 pjsip_publishc_opt publish_opt;
2290
2291 /**
Benny Prijono534a9ba2009-10-13 14:01:59 +00002292 * Maximum time to wait for unpublication transaction(s) to complete
2293 * during shutdown process, before sending unregistration. The library
2294 * tries to wait for the unpublication (un-PUBLISH) to complete before
2295 * sending REGISTER request to unregister the account, during library
2296 * shutdown process. If the value is set too short, it is possible that
2297 * the unregistration is sent before unpublication completes, causing
2298 * unpublication request to fail.
2299 *
2300 * Default: PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
2301 */
2302 unsigned unpublish_max_wait_time_msec;
2303
2304 /**
Benny Prijono48ab2b72007-11-08 09:24:30 +00002305 * Authentication preference.
2306 */
2307 pjsip_auth_clt_pref auth_pref;
2308
2309 /**
Benny Prijonofe04fb52007-08-24 08:28:52 +00002310 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
2311 * is not specified, a random string will be used.
2312 */
2313 pj_str_t pidf_tuple_id;
2314
Benny Prijono312aff92006-06-17 04:08:30 +00002315 /**
2316 * Optional URI to be put as Contact for this account. It is recommended
2317 * that this field is left empty, so that the value will be calculated
2318 * automatically based on the transport address.
2319 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00002320 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00002321
2322 /**
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00002323 * Additional parameters that will be appended in the Contact header
Benny Prijono30fe4852008-12-10 16:54:16 +00002324 * for this account. This will affect the Contact header in all SIP
2325 * messages sent on behalf of this account, including but not limited to
2326 * REGISTER, INVITE, and SUBCRIBE requests or responses.
2327 *
2328 * The parameters should be preceeded by semicolon, and all strings must
2329 * be properly escaped. Example:
2330 * ";my-param=X;another-param=Hi%20there"
2331 */
2332 pj_str_t contact_params;
2333
2334 /**
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00002335 * Additional URI parameters that will be appended in the Contact URI
2336 * for this account. This will affect the Contact URI in all SIP
2337 * messages sent on behalf of this account, including but not limited to
2338 * REGISTER, INVITE, and SUBCRIBE requests or responses.
2339 *
2340 * The parameters should be preceeded by semicolon, and all strings must
2341 * be properly escaped. Example:
2342 * ";my-param=X;another-param=Hi%20there"
2343 */
2344 pj_str_t contact_uri_params;
2345
2346 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00002347 * Specify whether support for reliable provisional response (100rel and
2348 * PRACK) should be required for all sessions of this account.
2349 *
2350 * Default: PJ_FALSE
2351 */
2352 pj_bool_t require_100rel;
2353
2354 /**
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002355 * Specify the usage of Session Timers for all sessions. See the
2356 * #pjsua_sip_timer_use for possible values.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002357 *
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002358 * Default: PJSUA_SIP_TIMER_OPTIONAL
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002359 */
Nanang Izzuddin742ef4b2010-09-07 09:36:15 +00002360 pjsua_sip_timer_use use_timer;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002361
2362 /**
Nanang Izzuddin65add622009-08-11 16:26:20 +00002363 * Specify Session Timer settings, see #pjsip_timer_setting.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002364 */
Nanang Izzuddin65add622009-08-11 16:26:20 +00002365 pjsip_timer_setting timer_setting;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00002366
2367 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002368 * Number of proxies in the proxy array below.
2369 */
2370 unsigned proxy_cnt;
2371
2372 /**
2373 * Optional URI of the proxies to be visited for all outgoing requests
2374 * that are using this account (REGISTER, INVITE, etc). Application need
2375 * to specify these proxies if the service provider requires that requests
2376 * destined towards its network should go through certain proxies first
2377 * (for example, border controllers).
2378 *
2379 * These proxies will be put in the route set for this account, with
2380 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00002381 * first). If global outbound proxies are configured in pjsua_config,
2382 * then these account proxies will be placed after the global outbound
2383 * proxies in the routeset.
Benny Prijono312aff92006-06-17 04:08:30 +00002384 */
2385 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
2386
2387 /**
2388 * Optional interval for registration, in seconds. If the value is zero,
Benny Prijonobddef2c2007-10-31 13:28:08 +00002389 * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
Benny Prijono312aff92006-06-17 04:08:30 +00002390 */
2391 unsigned reg_timeout;
2392
Benny Prijono384dab42009-10-14 01:58:04 +00002393 /**
2394 * Specify the maximum time to wait for unregistration requests to
2395 * complete during library shutdown sequence.
2396 *
2397 * Default: PJSUA_UNREG_TIMEOUT
2398 */
2399 unsigned unreg_timeout;
2400
Benny Prijono312aff92006-06-17 04:08:30 +00002401 /**
2402 * Number of credentials in the credential array.
2403 */
2404 unsigned cred_count;
2405
2406 /**
2407 * Array of credentials. If registration is desired, normally there should
2408 * be at least one credential specified, to successfully authenticate
2409 * against the service provider. More credentials can be specified, for
2410 * example when the requests are expected to be challenged by the
2411 * proxies in the route set.
2412 */
2413 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
2414
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002415 /**
2416 * Optionally bind this account to specific transport. This normally is
2417 * not a good idea, as account should be able to send requests using
2418 * any available transports according to the destination. But some
2419 * application may want to have explicit control over the transport to
2420 * use, so in that case it can set this field.
2421 *
2422 * Default: -1 (PJSUA_INVALID_ID)
2423 *
2424 * @see pjsua_acc_set_transport()
2425 */
2426 pjsua_transport_id transport_id;
2427
Benny Prijono15b02302007-09-27 14:07:07 +00002428 /**
Benny Prijonocca2e432010-02-25 09:33:18 +00002429 * This option is used to update the transport address and the Contact
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002430 * header of REGISTER request. When this option is enabled, the library
2431 * will keep track of the public IP address from the response of REGISTER
2432 * request. Once it detects that the address has changed, it will
2433 * unregister current Contact, update the Contact with transport address
2434 * learned from Via header, and register a new Contact to the registrar.
2435 * This will also update the public name of UDP transport if STUN is
Benny Prijonocca2e432010-02-25 09:33:18 +00002436 * configured.
Benny Prijono15b02302007-09-27 14:07:07 +00002437 *
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00002438 * See also contact_rewrite_method field.
2439 *
Benny Prijono15b02302007-09-27 14:07:07 +00002440 * Default: 1 (yes)
2441 */
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002442 pj_bool_t allow_contact_rewrite;
Benny Prijono15b02302007-09-27 14:07:07 +00002443
Benny Prijonobddef2c2007-10-31 13:28:08 +00002444 /**
Benny Prijonoc6d5fdc2010-06-20 08:58:26 +00002445 * Specify how Contact update will be done with the registration, if
2446 * \a allow_contact_rewrite is enabled.
2447 *
2448 * If set to 1, the Contact update will be done by sending unregistration
2449 * to the currently registered Contact, while simultaneously sending new
2450 * registration (with different Call-ID) for the updated Contact.
2451 *
2452 * If set to 2, the Contact update will be done in a single, current
2453 * registration session, by removing the current binding (by setting its
2454 * Contact's expires parameter to zero) and adding a new Contact binding,
2455 * all done in a single request.
2456 *
2457 * Value 1 is the legacy behavior.
2458 *
2459 * Default value: PJSUA_CONTACT_REWRITE_METHOD (2)
2460 */
2461 int contact_rewrite_method;
2462
2463 /**
Benny Prijonob54719f2010-11-16 03:07:46 +00002464 * Control the use of SIP outbound feature. SIP outbound is described in
2465 * RFC 5626 to enable proxies or registrar to send inbound requests back
2466 * to UA using the same connection initiated by the UA for its
2467 * registration. This feature is highly useful in NAT-ed deployemtns,
2468 * hence it is enabled by default.
2469 *
2470 * Note: currently SIP outbound can only be used with TCP and TLS
2471 * transports. If UDP is used for the registration, the SIP outbound
2472 * feature will be silently ignored for the account.
2473 *
2474 * Default: PJ_TRUE
2475 */
2476 unsigned use_rfc5626;
2477
2478 /**
2479 * Specify SIP outbound (RFC 5626) instance ID to be used by this
2480 * application. If empty, an instance ID will be generated based on
2481 * the hostname of this agent. If application specifies this parameter, the
2482 * value will look like "<urn:uuid:00000000-0000-1000-8000-AABBCCDDEEFF>"
2483 * without the doublequote.
2484 *
2485 * Default: empty
2486 */
2487 pj_str_t rfc5626_instance_id;
2488
2489 /**
2490 * Specify SIP outbound (RFC 5626) registration ID. The default value
2491 * is empty, which would cause the library to automatically generate
2492 * a suitable value.
2493 *
2494 * Default: empty
2495 */
2496 pj_str_t rfc5626_reg_id;
2497
2498 /**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002499 * Set the interval for periodic keep-alive transmission for this account.
2500 * If this value is zero, keep-alive will be disabled for this account.
2501 * The keep-alive transmission will be sent to the registrar's address,
2502 * after successful registration.
2503 *
Benny Prijonobddef2c2007-10-31 13:28:08 +00002504 * Default: 15 (seconds)
2505 */
2506 unsigned ka_interval;
2507
2508 /**
2509 * Specify the data to be transmitted as keep-alive packets.
2510 *
2511 * Default: CR-LF
2512 */
2513 pj_str_t ka_data;
2514
Benny Prijono0bc99a92011-03-17 04:34:43 +00002515 /**
2516 * Maximum number of simultaneous active audio streams to be allowed
2517 * for calls on this account. Setting this to zero will disable audio
2518 * in calls on this account.
2519 *
2520 * Default: 1
2521 */
2522 unsigned max_audio_cnt;
2523
2524 /**
2525 * Maximum number of simultaneous active video streams to be allowed
2526 * for calls on this account. Setting this to zero will disable video
Benny Prijono9f468d12011-07-07 07:46:33 +00002527 * in calls on this account, regardless of other video settings.
Benny Prijono0bc99a92011-03-17 04:34:43 +00002528 *
Benny Prijono9f468d12011-07-07 07:46:33 +00002529 * Default: 1
Benny Prijono0bc99a92011-03-17 04:34:43 +00002530 */
2531 unsigned max_video_cnt;
2532
2533 /**
Benny Prijono9f468d12011-07-07 07:46:33 +00002534 * Specify whether incoming video should be shown to screen by default.
2535 * This applies to incoming call (INVITE), incoming re-INVITE, and
2536 * incoming UPDATE requests.
2537 *
2538 * Regardless of this setting, application can detect incoming video
2539 * by implementing \a on_call_media_state() callback and enumerating
2540 * the media stream(s) with #pjsua_call_get_info(). Once incoming
2541 * video is recognised, application may retrieve the window associated
2542 * with the incoming video and show or hide it with
2543 * #pjsua_vid_win_set_show().
2544 *
2545 * Default: PJ_FALSE
2546 */
2547 pj_bool_t vid_in_auto_show;
2548
2549 /**
2550 * Specify whether outgoing video should be activated by default when
2551 * making outgoing calls and/or when incoming video is detected. This
2552 * applies to incoming and outgoing calls, incoming re-INVITE, and
2553 * incoming UPDATE. If the setting is non-zero, outgoing video
2554 * transmission will be started as soon as response to these requests
2555 * is sent (or received).
2556 *
2557 * Regardless of the value of this setting, application can start and
2558 * stop outgoing video transmission with #pjsua_call_set_vid_out().
2559 *
2560 * Default: PJ_FALSE
2561 */
2562 pj_bool_t vid_out_auto_transmit;
2563
2564 /**
2565 * Specify the default capture device to be used by this account. If
2566 * \a vid_out_auto_transmit is enabled, this device will be used for
2567 * capturing video.
2568 *
2569 * Default: PJMEDIA_VID_DEFAULT_CAPTURE_DEV
2570 */
2571 pjmedia_vid_dev_index vid_cap_dev;
2572
2573 /**
2574 * Specify the default rendering device to be used by this account.
2575 *
2576 * Default: PJMEDIA_VID_DEFAULT_RENDER_DEV
2577 */
2578 pjmedia_vid_dev_index vid_rend_dev;
2579
2580 /**
Benny Prijono0bc99a92011-03-17 04:34:43 +00002581 * Media transport config.
2582 */
2583 pjsua_transport_config rtp_cfg;
2584
Benny Prijonod8179652008-01-23 20:39:07 +00002585 /**
2586 * Specify whether secure media transport should be used for this account.
2587 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
2588 * PJMEDIA_SRTP_MANDATORY.
2589 *
2590 * Default: #PJSUA_DEFAULT_USE_SRTP
2591 */
2592 pjmedia_srtp_use use_srtp;
2593
2594 /**
2595 * Specify whether SRTP requires secure signaling to be used. This option
2596 * is only used when \a use_srtp option above is non-zero.
2597 *
2598 * Valid values are:
2599 * 0: SRTP does not require secure signaling
2600 * 1: SRTP requires secure transport such as TLS
2601 * 2: SRTP requires secure end-to-end transport (SIPS)
2602 *
2603 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
2604 */
2605 int srtp_secure_signaling;
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00002606
2607 /**
Benny Prijono0bc99a92011-03-17 04:34:43 +00002608 * Specify whether SRTP in PJMEDIA_SRTP_OPTIONAL mode should compose
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00002609 * duplicated media in SDP offer, i.e: unsecured and secured version.
Benny Prijono0bc99a92011-03-17 04:34:43 +00002610 * Otherwise, the SDP media will be composed as unsecured media but
Nanang Izzuddind89cc3a2010-05-13 05:22:51 +00002611 * with SDP "crypto" attribute.
2612 *
2613 * Default: PJ_FALSE
2614 */
2615 pj_bool_t srtp_optional_dup_offer;
Benny Prijonod8179652008-01-23 20:39:07 +00002616
Nanang Izzuddin36dd5b62010-03-30 11:13:59 +00002617 /**
2618 * Specify interval of auto registration retry upon registration failure
2619 * (including caused by transport problem), in second. Set to 0 to
2620 * disable auto re-registration.
2621 *
2622 * Default: #PJSUA_REG_RETRY_INTERVAL
2623 */
2624 unsigned reg_retry_interval;
2625
2626 /**
2627 * Specify whether calls of the configured account should be dropped
2628 * after registration failure and an attempt of re-registration has
2629 * also failed.
2630 *
2631 * Default: PJ_FALSE (disabled)
2632 */
2633 pj_bool_t drop_calls_on_reg_fail;
2634
Benny Prijono29c8ca32010-06-22 06:02:13 +00002635 /**
2636 * Specify how the registration uses the outbound and account proxy
2637 * settings. This controls if and what Route headers will appear in
2638 * the REGISTER request of this account. The value is bitmask combination
2639 * of PJSUA_REG_USE_OUTBOUND_PROXY and PJSUA_REG_USE_ACC_PROXY bits.
2640 * If the value is set to 0, the REGISTER request will not use any proxy
2641 * (i.e. it will not have any Route headers).
2642 *
2643 * Default: 3 (PJSUA_REG_USE_OUTBOUND_PROXY | PJSUA_REG_USE_ACC_PROXY)
2644 */
2645 unsigned reg_use_proxy;
2646
Nanang Izzuddin5e39a2b2010-09-20 06:13:02 +00002647#if defined(PJMEDIA_STREAM_ENABLE_KA) && (PJMEDIA_STREAM_ENABLE_KA != 0)
2648 /**
2649 * Specify whether stream keep-alive and NAT hole punching with
2650 * non-codec-VAD mechanism (see @ref PJMEDIA_STREAM_ENABLE_KA) is enabled
2651 * for this account.
2652 *
2653 * Default: PJ_FALSE (disabled)
2654 */
2655 pj_bool_t use_stream_ka;
2656#endif
2657
Benny Prijonodd63b992010-10-01 02:03:42 +00002658 /**
2659 * Specify how to offer call hold to remote peer. Please see the
2660 * documentation on #pjsua_call_hold_type for more info.
2661 *
2662 * Default: PJSUA_CALL_HOLD_TYPE_DEFAULT
2663 */
2664 pjsua_call_hold_type call_hold_type;
2665
Benny Prijono312aff92006-06-17 04:08:30 +00002666} pjsua_acc_config;
2667
2668
2669/**
2670 * Call this function to initialize account config with default values.
2671 *
2672 * @param cfg The account config to be initialized.
2673 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00002674PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002675
2676
2677/**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002678 * Duplicate account config.
2679 *
2680 * @param pool Pool to be used for duplicating the config.
2681 * @param dst Destination configuration.
2682 * @param src Source configuration.
2683 */
2684PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
2685 pjsua_acc_config *dst,
2686 const pjsua_acc_config *src);
2687
2688
2689/**
Benny Prijono312aff92006-06-17 04:08:30 +00002690 * Account info. Application can query account info by calling
2691 * #pjsua_acc_get_info().
2692 */
2693typedef struct pjsua_acc_info
2694{
2695 /**
2696 * The account ID.
2697 */
2698 pjsua_acc_id id;
2699
2700 /**
2701 * Flag to indicate whether this is the default account.
2702 */
2703 pj_bool_t is_default;
2704
2705 /**
2706 * Account URI
2707 */
2708 pj_str_t acc_uri;
2709
2710 /**
2711 * Flag to tell whether this account has registration setting
2712 * (reg_uri is not empty).
2713 */
2714 pj_bool_t has_registration;
2715
2716 /**
2717 * An up to date expiration interval for account registration session.
2718 */
2719 int expires;
2720
2721 /**
2722 * Last registration status code. If status code is zero, the account
2723 * is currently not registered. Any other value indicates the SIP
2724 * status code of the registration.
2725 */
2726 pjsip_status_code status;
2727
2728 /**
Sauw Ming48f6dbf2010-09-07 05:10:25 +00002729 * Last registration error code. When the status field contains a SIP
2730 * status code that indicates a registration failure, last registration
2731 * error code contains the error code that causes the failure. In any
2732 * other case, its value is zero.
2733 */
2734 pj_status_t reg_last_err;
2735
2736 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002737 * String describing the registration status.
2738 */
2739 pj_str_t status_text;
2740
2741 /**
2742 * Presence online status for this account.
2743 */
2744 pj_bool_t online_status;
2745
2746 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00002747 * Presence online status text.
2748 */
2749 pj_str_t online_status_text;
2750
2751 /**
2752 * Extended RPID online status information.
2753 */
2754 pjrpid_element rpid;
2755
2756 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002757 * Buffer that is used internally to store the status text.
2758 */
2759 char buf_[PJ_ERR_MSG_SIZE];
2760
2761} pjsua_acc_info;
2762
2763
2764
2765/**
2766 * Get number of current accounts.
2767 *
2768 * @return Current number of accounts.
2769 */
2770PJ_DECL(unsigned) pjsua_acc_get_count(void);
2771
2772
2773/**
2774 * Check if the specified account ID is valid.
2775 *
2776 * @param acc_id Account ID to check.
2777 *
2778 * @return Non-zero if account ID is valid.
2779 */
2780PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
2781
2782
2783/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00002784 * Set default account to be used when incoming and outgoing
2785 * requests doesn't match any accounts.
2786 *
2787 * @param acc_id The account ID to be used as default.
2788 *
2789 * @return PJ_SUCCESS on success.
2790 */
2791PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2792
2793
2794/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002795 * Get default account to be used when receiving incoming requests (calls),
2796 * when the destination of the incoming call doesn't match any other
2797 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002798 *
2799 * @return The default account ID, or PJSUA_INVALID_ID if no
2800 * default account is configured.
2801 */
2802PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2803
2804
2805/**
Benny Prijono312aff92006-06-17 04:08:30 +00002806 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002807 * #pjsua_init()) before calling this function. If registration is configured
2808 * for this account, this function would also start the SIP registration
2809 * session with the SIP registrar server. This SIP registration session
2810 * will be maintained internally by the library, and application doesn't
2811 * need to do anything to maintain the registration session.
2812 *
Benny Prijono312aff92006-06-17 04:08:30 +00002813 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002814 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002815 * @param is_default If non-zero, this account will be set as the default
2816 * account. The default account will be used when sending
2817 * outgoing requests (e.g. making call) when no account is
2818 * specified, and when receiving incoming requests when the
2819 * request does not match any accounts. It is recommended
2820 * that default account is set to local/LAN account.
2821 * @param p_acc_id Pointer to receive account ID of the new account.
2822 *
2823 * @return PJ_SUCCESS on success, or the appropriate error code.
2824 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002825PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002826 pj_bool_t is_default,
2827 pjsua_acc_id *p_acc_id);
2828
2829
2830/**
2831 * Add a local account. A local account is used to identify local endpoint
2832 * instead of a specific user, and for this reason, a transport ID is needed
2833 * to obtain the local address information.
2834 *
2835 * @param tid Transport ID to generate account address.
2836 * @param is_default If non-zero, this account will be set as the default
2837 * account. The default account will be used when sending
2838 * outgoing requests (e.g. making call) when no account is
2839 * specified, and when receiving incoming requests when the
2840 * request does not match any accounts. It is recommended
2841 * that default account is set to local/LAN account.
2842 * @param p_acc_id Pointer to receive account ID of the new account.
2843 *
2844 * @return PJ_SUCCESS on success, or the appropriate error code.
2845 */
2846PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2847 pj_bool_t is_default,
2848 pjsua_acc_id *p_acc_id);
2849
2850/**
Benny Prijono705e7842008-07-21 18:12:51 +00002851 * Set arbitrary data to be associated with the account.
2852 *
2853 * @param acc_id The account ID.
2854 * @param user_data User/application data.
2855 *
2856 * @return PJ_SUCCESS on success, or the appropriate error code.
2857 */
2858PJ_DECL(pj_status_t) pjsua_acc_set_user_data(pjsua_acc_id acc_id,
2859 void *user_data);
2860
2861
2862/**
2863 * Retrieve arbitrary data associated with the account.
2864 *
2865 * @param acc_id The account ID.
2866 *
2867 * @return The user data. In the case where the account ID is
2868 * not valid, NULL is returned.
2869 */
2870PJ_DECL(void*) pjsua_acc_get_user_data(pjsua_acc_id acc_id);
2871
2872
2873/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002874 * Delete an account. This will unregister the account from the SIP server,
2875 * if necessary, and terminate server side presence subscriptions associated
2876 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002877 *
2878 * @param acc_id Id of the account to be deleted.
2879 *
2880 * @return PJ_SUCCESS on success, or the appropriate error code.
2881 */
2882PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2883
2884
2885/**
2886 * Modify account information.
2887 *
2888 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002889 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002890 *
2891 * @return PJ_SUCCESS on success, or the appropriate error code.
2892 */
2893PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002894 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002895
2896
2897/**
2898 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002899 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002900 * if there are server side presence subscription for this account, and/or
2901 * outgoing PUBLISH if presence publication is enabled for this account.
2902 *
2903 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002904 *
2905 * @param acc_id The account ID.
2906 * @param is_online True of false.
2907 *
2908 * @return PJ_SUCCESS on success, or the appropriate error code.
2909 */
2910PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2911 pj_bool_t is_online);
2912
Benny Prijono4461c7d2007-08-25 13:36:15 +00002913/**
2914 * Modify account's presence status to be advertised to remote/presence
2915 * subscribers. This would trigger the sending of outgoing NOTIFY request
2916 * if there are server side presence subscription for this account, and/or
2917 * outgoing PUBLISH if presence publication is enabled for this account.
2918 *
2919 * @see pjsua_acc_set_online_status()
2920 *
2921 * @param acc_id The account ID.
2922 * @param is_online True of false.
2923 * @param pr Extended information in subset of RPID format
2924 * which allows setting custom presence text.
2925 *
2926 * @return PJ_SUCCESS on success, or the appropriate error code.
2927 */
2928PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2929 pj_bool_t is_online,
2930 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002931
2932/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002933 * Update registration or perform unregistration. If registration is
2934 * configured for this account, then initial SIP REGISTER will be sent
2935 * when the account is added with #pjsua_acc_add(). Application normally
2936 * only need to call this function if it wants to manually update the
2937 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002938 *
2939 * @param acc_id The account ID.
2940 * @param renew If renew argument is zero, this will start
2941 * unregistration process.
2942 *
2943 * @return PJ_SUCCESS on success, or the appropriate error code.
2944 */
2945PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2946 pj_bool_t renew);
2947
Benny Prijono312aff92006-06-17 04:08:30 +00002948/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002949 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002950 *
2951 * @param acc_id Account identification.
2952 * @param info Pointer to receive account information.
2953 *
2954 * @return PJ_SUCCESS on success, or the appropriate error code.
2955 */
2956PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2957 pjsua_acc_info *info);
2958
2959
2960/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002961 * Enumerate all account currently active in the library. This will fill
2962 * the array with the account Ids, and application can then query the
2963 * account information for each id with #pjsua_acc_get_info().
2964 *
2965 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002966 *
2967 * @param ids Array of account IDs to be initialized.
2968 * @param count In input, specifies the maximum number of elements.
2969 * On return, it contains the actual number of elements.
2970 *
2971 * @return PJ_SUCCESS on success, or the appropriate error code.
2972 */
2973PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2974 unsigned *count );
2975
2976
2977/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002978 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002979 *
2980 * @param info Array of account infos to be initialized.
2981 * @param count In input, specifies the maximum number of elements.
2982 * On return, it contains the actual number of elements.
2983 *
2984 * @return PJ_SUCCESS on success, or the appropriate error code.
2985 */
2986PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2987 unsigned *count );
2988
2989
2990/**
2991 * This is an internal function to find the most appropriate account to
2992 * used to reach to the specified URL.
2993 *
2994 * @param url The remote URL to reach.
2995 *
2996 * @return Account id.
2997 */
2998PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2999
3000
3001/**
3002 * This is an internal function to find the most appropriate account to be
3003 * used to handle incoming calls.
3004 *
3005 * @param rdata The incoming request message.
3006 *
3007 * @return Account id.
3008 */
3009PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
3010
3011
Benny Prijonoc570f2d2006-07-18 00:33:02 +00003012/**
Benny Prijonofff245c2007-04-02 11:44:47 +00003013 * Create arbitrary requests using the account. Application should only use
3014 * this function to create auxiliary requests outside dialog, such as
3015 * OPTIONS, and use the call or presence API to create dialog related
3016 * requests.
3017 *
3018 * @param acc_id The account ID.
3019 * @param method The SIP method of the request.
3020 * @param target Target URI.
3021 * @param p_tdata Pointer to receive the request.
3022 *
3023 * @return PJ_SUCCESS or the error code.
3024 */
3025PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
3026 const pjsip_method *method,
3027 const pj_str_t *target,
3028 pjsip_tx_data **p_tdata);
3029
3030
3031/**
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00003032 * Create a suitable Contact header value, based on the specified target URI
3033 * for the specified account.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00003034 *
3035 * @param pool Pool to allocate memory for the string.
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00003036 * @param contact The string where the Contact will be stored.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00003037 * @param acc_id Account ID.
3038 * @param uri Destination URI of the request.
3039 *
3040 * @return PJ_SUCCESS on success, other on error.
3041 */
3042PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
3043 pj_str_t *contact,
3044 pjsua_acc_id acc_id,
3045 const pj_str_t *uri);
3046
3047
3048
3049/**
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00003050 * Create a suitable Contact header value, based on the information in the
3051 * incoming request.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00003052 *
3053 * @param pool Pool to allocate memory for the string.
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00003054 * @param contact The string where the Contact will be stored.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00003055 * @param acc_id Account ID.
3056 * @param rdata Incoming request.
3057 *
3058 * @return PJ_SUCCESS on success, other on error.
3059 */
3060PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
3061 pj_str_t *contact,
3062 pjsua_acc_id acc_id,
3063 pjsip_rx_data *rdata );
3064
3065
Benny Prijono62c5c5b2007-01-13 23:22:40 +00003066/**
3067 * Lock/bind this account to a specific transport/listener. Normally
3068 * application shouldn't need to do this, as transports will be selected
3069 * automatically by the stack according to the destination.
3070 *
3071 * When account is locked/bound to a specific transport, all outgoing
3072 * requests from this account will use the specified transport (this
3073 * includes SIP registration, dialog (call and event subscription), and
3074 * out-of-dialog requests such as MESSAGE).
3075 *
3076 * Note that transport_id may be specified in pjsua_acc_config too.
3077 *
3078 * @param acc_id The account ID.
3079 * @param tp_id The transport ID.
3080 *
3081 * @return PJ_SUCCESS on success.
3082 */
3083PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
3084 pjsua_transport_id tp_id);
3085
Benny Prijono312aff92006-06-17 04:08:30 +00003086
3087/**
3088 * @}
3089 */
3090
3091
3092/*****************************************************************************
3093 * CALLS API
3094 */
3095
3096
3097/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003098 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00003099 * @ingroup PJSUA_LIB
3100 * @brief Call manipulation.
3101 * @{
3102 */
3103
3104/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003105 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00003106 */
3107#ifndef PJSUA_MAX_CALLS
3108# define PJSUA_MAX_CALLS 32
3109#endif
3110
Benny Prijono9f468d12011-07-07 07:46:33 +00003111/**
3112 * Maximum active video windows
3113 */
3114#ifndef PJSUA_MAX_VID_WINS
3115# define PJSUA_MAX_VID_WINS 16
3116#endif
3117
3118/**
3119 * Video window ID.
3120 */
3121typedef int pjsua_vid_win_id;
Benny Prijono312aff92006-06-17 04:08:30 +00003122
3123
3124/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003125 * This enumeration specifies the media status of a call, and it's part
3126 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00003127 */
3128typedef enum pjsua_call_media_status
3129{
Benny Prijono0bc99a92011-03-17 04:34:43 +00003130 /**
3131 * Call currently has no media, or the media is not used.
3132 */
Benny Prijono312aff92006-06-17 04:08:30 +00003133 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00003134
Benny Prijono0bc99a92011-03-17 04:34:43 +00003135 /**
3136 * The media is active
3137 */
Benny Prijono312aff92006-06-17 04:08:30 +00003138 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00003139
Benny Prijono0bc99a92011-03-17 04:34:43 +00003140 /**
3141 * The media is currently put on hold by local endpoint
3142 */
Benny Prijono312aff92006-06-17 04:08:30 +00003143 PJSUA_CALL_MEDIA_LOCAL_HOLD,
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 remote endpoint
3147 */
Benny Prijono312aff92006-06-17 04:08:30 +00003148 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00003149
Benny Prijono0bc99a92011-03-17 04:34:43 +00003150 /**
3151 * The media has reported error (e.g. ICE negotiation)
3152 */
Benny Prijono096c56c2007-09-15 08:30:16 +00003153 PJSUA_CALL_MEDIA_ERROR
3154
Benny Prijono312aff92006-06-17 04:08:30 +00003155} pjsua_call_media_status;
3156
3157
3158/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003159 * This structure describes the information and current status of a call.
Benny Prijono312aff92006-06-17 04:08:30 +00003160 */
3161typedef struct pjsua_call_info
3162{
3163 /** Call identification. */
3164 pjsua_call_id id;
3165
3166 /** Initial call role (UAC == caller) */
3167 pjsip_role_e role;
3168
Benny Prijono90315512006-09-14 16:05:16 +00003169 /** The account ID where this call belongs. */
3170 pjsua_acc_id acc_id;
3171
Benny Prijono312aff92006-06-17 04:08:30 +00003172 /** Local URI */
3173 pj_str_t local_info;
3174
3175 /** Local Contact */
3176 pj_str_t local_contact;
3177
3178 /** Remote URI */
3179 pj_str_t remote_info;
3180
3181 /** Remote contact */
3182 pj_str_t remote_contact;
3183
3184 /** Dialog Call-ID string. */
3185 pj_str_t call_id;
3186
3187 /** Call state */
3188 pjsip_inv_state state;
3189
3190 /** Text describing the state */
3191 pj_str_t state_text;
3192
3193 /** Last status code heard, which can be used as cause code */
3194 pjsip_status_code last_status;
3195
3196 /** The reason phrase describing the status. */
3197 pj_str_t last_status_text;
3198
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003199 /** Media status of the first audio stream. */
Benny Prijono312aff92006-06-17 04:08:30 +00003200 pjsua_call_media_status media_status;
3201
Benny Prijono0bc99a92011-03-17 04:34:43 +00003202 /** Media direction of the first audio stream. */
Benny Prijono312aff92006-06-17 04:08:30 +00003203 pjmedia_dir media_dir;
3204
Benny Prijono0bc99a92011-03-17 04:34:43 +00003205 /** The conference port number for the first audio stream. */
Benny Prijono312aff92006-06-17 04:08:30 +00003206 pjsua_conf_port_id conf_slot;
3207
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003208 /** Number of media streams in this call */
3209 unsigned media_cnt;
3210
3211 /** Array of media stream information */
Benny Prijono0bc99a92011-03-17 04:34:43 +00003212 struct
3213 {
3214 /** Media index in SDP. */
3215 unsigned index;
3216
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003217 /** Media type. */
3218 pjmedia_type type;
Benny Prijono0bc99a92011-03-17 04:34:43 +00003219
3220 /** Media direction. */
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003221 pjmedia_dir dir;
Benny Prijono0bc99a92011-03-17 04:34:43 +00003222
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003223 /** Call media status. */
3224 pjsua_call_media_status status;
Benny Prijono0bc99a92011-03-17 04:34:43 +00003225
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003226 /** The specific media stream info. */
3227 union {
3228 /** Audio stream */
3229 struct {
Benny Prijono9f468d12011-07-07 07:46:33 +00003230 /** The conference port number for the call. */
3231 pjsua_conf_port_id conf_slot;
3232 } aud;
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003233
3234 /** Video stream */
3235 struct {
Benny Prijono9f468d12011-07-07 07:46:33 +00003236 /**
3237 * The window id for incoming video, if any, or
3238 * PJSUA_INVALID_ID.
3239 */
3240 pjsua_vid_win_id win_in;
3241
3242 /** The video capture device for outgoing transmission,
3243 * if any, or PJMEDIA_VID_INVALID_DEV
3244 */
3245 pjmedia_vid_dev_index cap_dev;
3246
3247 } vid;
Nanang Izzuddinbf26db12011-03-18 07:54:50 +00003248 } stream;
3249
3250 } media[PJMEDIA_MAX_SDP_MEDIA];
Benny Prijono0bc99a92011-03-17 04:34:43 +00003251
Benny Prijono312aff92006-06-17 04:08:30 +00003252 /** Up-to-date call connected duration (zero when call is not
3253 * established)
3254 */
3255 pj_time_val connect_duration;
3256
3257 /** Total call duration, including set-up time */
3258 pj_time_val total_duration;
3259
3260 /** Internal */
3261 struct {
3262 char local_info[128];
3263 char local_contact[128];
3264 char remote_info[128];
3265 char remote_contact[128];
3266 char call_id[128];
3267 char last_status_text[128];
3268 } buf_;
3269
3270} pjsua_call_info;
3271
3272
Benny Prijono9f468d12011-07-07 07:46:33 +00003273/**
3274 * Media stream info.
3275 */
3276typedef struct pjsua_stream_info
3277{
3278 /** Media type of this stream. */
3279 pjmedia_type type;
3280
3281 /** Stream info (union). */
3282 union {
3283 /** Audio stream info */
3284 pjmedia_stream_info aud;
3285
3286 /** Video stream info */
3287 pjmedia_vid_stream_info vid;
3288 } info;
3289
3290} pjsua_stream_info;
3291
3292
3293/**
3294 * Media stream statistic.
3295 */
3296typedef struct pjsua_stream_stat
3297{
3298 /** RTCP statistic. */
3299 pjmedia_rtcp_stat rtcp;
3300
3301 /** Jitter buffer statistic. */
3302 pjmedia_jb_state jbuf;
3303
3304} pjsua_stream_stat;
3305
Benny Prijono312aff92006-06-17 04:08:30 +00003306
Benny Prijonoa91a0032006-02-26 21:23:45 +00003307/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00003308 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003309 *
3310 * @return Maximum number of calls configured.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003311 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003312PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003313
3314/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003315 * Get number of currently active calls.
3316 *
3317 * @return Number of currently active calls.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003318 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003319PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003320
3321/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003322 * Enumerate all active calls. Application may then query the information and
3323 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003324 *
3325 * @param ids Array of account IDs to be initialized.
3326 * @param count In input, specifies the maximum number of elements.
3327 * On return, it contains the actual number of elements.
3328 *
3329 * @return PJ_SUCCESS on success, or the appropriate error code.
3330 */
3331PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
3332 unsigned *count);
3333
3334
3335/**
3336 * Make outgoing call to the specified URI using the specified account.
3337 *
3338 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003339 * @param dst_uri URI to be put in the To header (normally is the same
3340 * as the target URI).
3341 * @param options Options (must be zero at the moment).
3342 * @param user_data Arbitrary user data to be attached to the call, and
3343 * can be retrieved later.
3344 * @param msg_data Optional headers etc to be added to outgoing INVITE
3345 * request, or NULL if no custom header is desired.
3346 * @param p_call_id Pointer to receive call identification.
3347 *
3348 * @return PJ_SUCCESS on success, or the appropriate error code.
3349 */
3350PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
3351 const pj_str_t *dst_uri,
3352 unsigned options,
3353 void *user_data,
3354 const pjsua_msg_data *msg_data,
3355 pjsua_call_id *p_call_id);
3356
3357
3358/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00003359 * Check if the specified call has active INVITE session and the INVITE
3360 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003361 *
3362 * @param call_id Call identification.
3363 *
3364 * @return Non-zero if call is active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003365 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003366PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003367
3368
3369/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003370 * Check if call has an active media session.
3371 *
3372 * @param call_id Call identification.
3373 *
3374 * @return Non-zero if yes.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003375 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003376PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003377
3378
Benny Prijonocf986c42008-09-02 11:25:07 +00003379/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003380 * Get the conference port identification associated with the call.
3381 *
3382 * @param call_id Call identification.
3383 *
Benny Prijono9f468d12011-07-07 07:46:33 +00003384 * @return Conference port ID, or PJSUA_INVALID_ID when the
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003385 * media has not been established or is not active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003386 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003387PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
3388
3389/**
3390 * Obtain detail information about the specified call.
3391 *
3392 * @param call_id Call identification.
3393 * @param info Call info to be initialized.
3394 *
3395 * @return PJ_SUCCESS on success, or the appropriate error code.
3396 */
3397PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003398 pjsua_call_info *info);
3399
Nanang Izzuddin2a1b9ee2010-06-03 10:41:32 +00003400/**
3401 * Check if remote peer support the specified capability.
3402 *
3403 * @param call_id Call identification.
3404 * @param htype The header type to be checked, which value may be:
3405 * - PJSIP_H_ACCEPT
3406 * - PJSIP_H_ALLOW
3407 * - PJSIP_H_SUPPORTED
3408 * @param hname If htype specifies PJSIP_H_OTHER, then the header
3409 * name must be supplied in this argument. Otherwise the
3410 * value must be set to NULL.
3411 * @param token The capability token to check. For example, if \a
3412 * htype is PJSIP_H_ALLOW, then \a token specifies the
3413 * method names; if \a htype is PJSIP_H_SUPPORTED, then
3414 * \a token specifies the extension names such as
3415 * "100rel".
3416 *
3417 * @return PJSIP_DIALOG_CAP_SUPPORTED if the specified capability
3418 * is explicitly supported, see @pjsip_dialog_cap_status
3419 * for more info.
3420 */
3421PJ_DECL(pjsip_dialog_cap_status) pjsua_call_remote_has_cap(
3422 pjsua_call_id call_id,
3423 int htype,
3424 const pj_str_t *hname,
3425 const pj_str_t *token);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003426
3427/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003428 * Attach application specific data to the call. Application can then
3429 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003430 *
3431 * @param call_id Call identification.
3432 * @param user_data Arbitrary data to be attached to the call.
3433 *
3434 * @return The user data.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003435 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003436PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
3437 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003438
3439
3440/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003441 * Get user data attached to the call, which has been previously set with
3442 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003443 *
3444 * @param call_id Call identification.
3445 *
3446 * @return The user data.
Benny Prijono268ca612006-02-07 12:34:11 +00003447 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003448PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00003449
3450
3451/**
Benny Prijono91a6a172007-10-31 08:59:29 +00003452 * Get the NAT type of remote's endpoint. This is a proprietary feature
3453 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
3454 * is set in #pjsua_config.
3455 *
3456 * This function can only be called after SDP has been received from remote,
3457 * which means for incoming call, this function can be called as soon as
3458 * call is received as long as incoming call contains SDP, and for outgoing
3459 * call, this function can be called only after SDP is received (normally in
3460 * 200/OK response to INVITE). As a general case, application should call
3461 * this function after or in \a on_call_media_state() callback.
3462 *
3463 * @param call_id Call identification.
3464 * @param p_type Pointer to store the NAT type. Application can then
3465 * retrieve the string description of the NAT type
3466 * by calling pj_stun_get_nat_name().
3467 *
3468 * @return PJ_SUCCESS on success.
3469 *
3470 * @see pjsua_get_nat_type(), nat_type_in_sdp
3471 */
3472PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
3473 pj_stun_nat_type *p_type);
3474
3475/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003476 * Send response to incoming INVITE request. Depending on the status
3477 * code specified as parameter, this function may send provisional
3478 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003479 *
3480 * @param call_id Incoming call identification.
3481 * @param code Status code, (100-699).
3482 * @param reason Optional reason phrase. If NULL, default text
3483 * will be used.
3484 * @param msg_data Optional list of headers etc to be added to outgoing
3485 * response message.
3486 *
3487 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoa91a0032006-02-26 21:23:45 +00003488 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003489PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
3490 unsigned code,
3491 const pj_str_t *reason,
3492 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00003493
3494/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003495 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00003496 * call state. This function is different than answering the call with
3497 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
3498 * will hangup the call regardless of the state and role of the call,
3499 * while #pjsua_call_answer() only works with incoming calls on EARLY
3500 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003501 *
3502 * @param call_id Call identification.
3503 * @param code Optional status code to be sent when we're rejecting
3504 * incoming call. If the value is zero, "603/Decline"
3505 * will be sent.
3506 * @param reason Optional reason phrase to be sent when we're rejecting
3507 * incoming call. If NULL, default text will be used.
3508 * @param msg_data Optional list of headers etc to be added to outgoing
3509 * request/response message.
3510 *
3511 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003512 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003513PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
3514 unsigned code,
3515 const pj_str_t *reason,
3516 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003517
Benny Prijono5e51a4e2008-11-27 00:06:46 +00003518/**
3519 * Accept or reject redirection response. Application MUST call this function
3520 * after it signaled PJSIP_REDIRECT_PENDING in the \a on_call_redirected()
3521 * callback, to notify the call whether to accept or reject the redirection
3522 * to the current target. Application can use the combination of
3523 * PJSIP_REDIRECT_PENDING command in \a on_call_redirected() callback and
3524 * this function to ask for user permission before redirecting the call.
3525 *
3526 * Note that if the application chooses to reject or stop redirection (by
3527 * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the
3528 * call disconnection callback will be called before this function returns.
3529 * And if the application rejects the target, the \a on_call_redirected()
3530 * callback may also be called before this function returns if there is
3531 * another target to try.
3532 *
3533 * @param call_id The call ID.
3534 * @param cmd Redirection operation to be applied to the current
3535 * target. The semantic of this argument is similar
3536 * to the description in the \a on_call_redirected()
3537 * callback, except that the PJSIP_REDIRECT_PENDING is
3538 * not accepted here.
3539 *
3540 * @return PJ_SUCCESS on successful operation.
3541 */
3542PJ_DECL(pj_status_t) pjsua_call_process_redirect(pjsua_call_id call_id,
3543 pjsip_redirect_op cmd);
Benny Prijono26ff9062006-02-21 23:47:00 +00003544
3545/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003546 * Put the specified call on hold. This will send re-INVITE with the
3547 * appropriate SDP to inform remote that the call is being put on hold.
3548 * The final status of the request itself will be reported on the
3549 * \a on_call_media_state() callback, which inform the application that
3550 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003551 *
3552 * @param call_id Call identification.
3553 * @param msg_data Optional message components to be sent with
3554 * the request.
3555 *
3556 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003557 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003558PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
3559 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003560
3561
3562/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003563 * Send re-INVITE to release hold.
3564 * The final status of the request itself will be reported on the
3565 * \a on_call_media_state() callback, which inform the application that
3566 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003567 *
3568 * @param call_id Call identification.
3569 * @param unhold If this argument is non-zero and the call is locally
3570 * held, this will release the local hold.
3571 * @param msg_data Optional message components to be sent with
3572 * the request.
3573 *
3574 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003575 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003576PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
3577 pj_bool_t unhold,
3578 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003579
Benny Prijonoc08682e2007-10-04 06:17:58 +00003580/**
3581 * Send UPDATE request.
3582 *
3583 * @param call_id Call identification.
3584 * @param options Must be zero for now.
3585 * @param msg_data Optional message components to be sent with
3586 * the request.
3587 *
3588 * @return PJ_SUCCESS on success, or the appropriate error code.
3589 */
3590PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
3591 unsigned options,
3592 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00003593
3594/**
Benny Prijono053f5222006-11-11 16:16:04 +00003595 * Initiate call transfer to the specified address. This function will send
3596 * REFER request to instruct remote call party to initiate a new INVITE
3597 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003598 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00003599 * If application is interested to monitor the successfulness and
3600 * the progress of the transfer request, it can implement
3601 * \a on_call_transfer_status() callback which will report the progress
3602 * of the call transfer request.
3603 *
Benny Prijono053f5222006-11-11 16:16:04 +00003604 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003605 * @param dest Address of new target to be contacted.
3606 * @param msg_data Optional message components to be sent with
3607 * the request.
3608 *
3609 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00003610 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003611PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
3612 const pj_str_t *dest,
3613 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003614
3615/**
Benny Prijono053f5222006-11-11 16:16:04 +00003616 * Flag to indicate that "Require: replaces" should not be put in the
3617 * outgoing INVITE request caused by REFER request created by
3618 * #pjsua_call_xfer_replaces().
3619 */
3620#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
3621
3622/**
3623 * Initiate attended call transfer. This function will send REFER request
3624 * to instruct remote call party to initiate new INVITE session to the URL
3625 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
3626 * the call with us with the new call from the REFER recipient.
3627 *
3628 * @param call_id The call id to be transfered.
3629 * @param dest_call_id The call id to be replaced.
3630 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
3631 * to suppress the inclusion of "Require: replaces" in
3632 * the outgoing INVITE request created by the REFER
3633 * request.
3634 * @param msg_data Optional message components to be sent with
3635 * the request.
3636 *
3637 * @return PJ_SUCCESS on success, or the appropriate error code.
3638 */
3639PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
3640 pjsua_call_id dest_call_id,
3641 unsigned options,
3642 const pjsua_msg_data *msg_data);
3643
3644/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003645 * Send DTMF digits to remote using RFC 2833 payload formats.
3646 *
3647 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00003648 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003649 *
3650 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003651 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003652PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003653 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00003654
Benny Prijono26ff9062006-02-21 23:47:00 +00003655/**
Benny Prijonob0808372006-03-02 21:18:58 +00003656 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003657 *
3658 * @param call_id Call identification.
3659 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3660 * assumed.
3661 * @param content The message content.
3662 * @param msg_data Optional list of headers etc to be included in outgoing
3663 * request. The body descriptor in the msg_data is
3664 * ignored.
3665 * @param user_data Optional user data, which will be given back when
3666 * the IM callback is called.
3667 *
3668 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003669 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003670PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
3671 const pj_str_t *mime_type,
3672 const pj_str_t *content,
3673 const pjsua_msg_data *msg_data,
3674 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003675
3676
3677/**
3678 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003679 *
3680 * @param call_id Call identification.
3681 * @param is_typing Non-zero to indicate to remote that local person is
3682 * currently typing an IM.
3683 * @param msg_data Optional list of headers etc to be included in outgoing
3684 * request.
3685 *
3686 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003687 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003688PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
3689 pj_bool_t is_typing,
3690 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003691
3692/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00003693 * Send arbitrary request with the call. This is useful for example to send
3694 * INFO request. Note that application should not use this function to send
3695 * requests which would change the invite session's state, such as re-INVITE,
3696 * UPDATE, PRACK, and BYE.
3697 *
3698 * @param call_id Call identification.
3699 * @param method SIP method of the request.
3700 * @param msg_data Optional message body and/or list of headers to be
3701 * included in outgoing request.
3702 *
3703 * @return PJ_SUCCESS on success, or the appropriate error code.
3704 */
3705PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
3706 const pj_str_t *method,
3707 const pjsua_msg_data *msg_data);
3708
3709
3710/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003711 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
3712 * currently active calls.
Benny Prijono834aee32006-02-19 01:38:06 +00003713 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00003714PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00003715
3716
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003717/**
3718 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003719 *
3720 * @param call_id Call identification.
3721 * @param with_media Non-zero to include media information too.
3722 * @param buffer Buffer where the statistics are to be written to.
3723 * @param maxlen Maximum length of buffer.
3724 * @param indent Spaces for left indentation.
3725 *
3726 * @return PJ_SUCCESS on success.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003727 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003728PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
3729 pj_bool_t with_media,
3730 char *buffer,
3731 unsigned maxlen,
3732 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003733
Benny Prijono9fc735d2006-05-28 14:58:12 +00003734/**
Benny Prijono9f468d12011-07-07 07:46:33 +00003735 * Get the media stream index of the default video stream in the call.
3736 * Typically this will just retrieve the stream index of the first
3737 * activated video stream in the call.
3738 *
3739 * @param call_id Call identification.
3740 *
3741 * @return The media stream index or -1 if no video stream
3742 * is present in the call.
3743 */
3744PJ_DECL(int) pjsua_call_get_vid_stream_idx(pjsua_call_id call_id);
3745
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +00003746
Benny Prijono9f468d12011-07-07 07:46:33 +00003747/**
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +00003748 * Add, remove, modify, and/or manipulate video media stream for the
3749 * specified call. This may trigger a re-INVITE or UPDATE to be sent
3750 * for the call.
Benny Prijono9f468d12011-07-07 07:46:33 +00003751 *
3752 * @param call_id Call identification.
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +00003753 * @param op The video stream operation to be performed,
3754 * possible values are #pjsua_call_vid_strm_op.
3755 * @param param The parameters for the video stream operation.
Benny Prijono9f468d12011-07-07 07:46:33 +00003756 *
3757 * @return PJ_SUCCESS on success or the appropriate error.
3758 */
Nanang Izzuddinb4d4dad2011-07-13 08:51:10 +00003759PJ_DECL(pj_status_t) pjsua_call_set_vid_strm (
3760 pjsua_call_id call_id,
3761 pjsua_call_vid_strm_op op,
3762 const pjsua_call_vid_strm_op_param *param);
3763
Benny Prijono9f468d12011-07-07 07:46:33 +00003764
3765/**
3766 * Get media stream info for the specified media index.
3767 *
3768 * @param call_id The call identification.
3769 * @param med_idx Media stream index.
3770 * @param psi To be filled with the stream info.
3771 *
3772 * @return PJ_SUCCESS on success or the appropriate error.
3773 */
3774PJ_DECL(pj_status_t) pjsua_call_get_stream_info(pjsua_call_id call_id,
3775 unsigned med_idx,
3776 pjsua_stream_info *psi);
3777
3778/**
3779 * Get media stream statistic for the specified media index.
3780 *
3781 * @param call_id The call identification.
3782 * @param med_idx Media stream index.
3783 * @param psi To be filled with the stream statistic.
3784 *
3785 * @return PJ_SUCCESS on success or the appropriate error.
3786 */
3787PJ_DECL(pj_status_t) pjsua_call_get_stream_stat(pjsua_call_id call_id,
3788 unsigned med_idx,
3789 pjsua_stream_stat *stat);
3790
3791/**
3792 * Get media transport info for the specified media index.
3793 *
3794 * @param call_id The call identification.
3795 * @param med_idx Media stream index.
3796 * @param t To be filled with the transport info.
3797 *
3798 * @return PJ_SUCCESS on success or the appropriate error.
3799 */
3800PJ_DECL(pj_status_t) pjsua_call_get_transport_info(pjsua_call_id call_id,
3801 unsigned med_idx,
3802 pjmedia_transport_info *t);
3803
3804
3805
3806/**
Benny Prijono312aff92006-06-17 04:08:30 +00003807 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003808 */
Benny Prijono834aee32006-02-19 01:38:06 +00003809
3810
3811/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00003812 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00003813 */
3814
Benny Prijono312aff92006-06-17 04:08:30 +00003815
3816/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003817 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00003818 * @ingroup PJSUA_LIB
3819 * @brief Buddy management, buddy's presence, and instant messaging.
3820 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00003821 *
3822 * This section describes PJSUA-APIs related to buddies management,
3823 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00003824 */
3825
3826/**
3827 * Max buddies in buddy list.
3828 */
3829#ifndef PJSUA_MAX_BUDDIES
3830# define PJSUA_MAX_BUDDIES 256
3831#endif
3832
3833
3834/**
Benny Prijono6ab05322009-10-21 03:03:06 +00003835 * This specifies how long the library should wait before retrying failed
3836 * SUBSCRIBE request, and there is no rule to automatically resubscribe
3837 * (for example, no "retry-after" parameter in Subscription-State header).
3838 *
3839 * This also controls the duration before failed PUBLISH request will be
3840 * retried.
Benny Prijonoa17496a2007-10-31 10:20:31 +00003841 *
3842 * Default: 300 seconds
3843 */
3844#ifndef PJSUA_PRES_TIMER
3845# define PJSUA_PRES_TIMER 300
3846#endif
3847
3848
3849/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003850 * This structure describes buddy configuration when adding a buddy to
3851 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
3852 * the structure with #pjsua_buddy_config_default() to initialize this
3853 * structure with default configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00003854 */
3855typedef struct pjsua_buddy_config
3856{
3857 /**
3858 * Buddy URL or name address.
3859 */
3860 pj_str_t uri;
3861
3862 /**
3863 * Specify whether presence subscription should start immediately.
3864 */
3865 pj_bool_t subscribe;
3866
Benny Prijono705e7842008-07-21 18:12:51 +00003867 /**
3868 * Specify arbitrary application data to be associated with with
3869 * the buddy object.
3870 */
3871 void *user_data;
3872
Benny Prijono312aff92006-06-17 04:08:30 +00003873} pjsua_buddy_config;
3874
3875
3876/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003877 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003878 */
3879typedef enum pjsua_buddy_status
3880{
3881 /**
3882 * Online status is unknown (possibly because no presence subscription
3883 * has been established).
3884 */
3885 PJSUA_BUDDY_STATUS_UNKNOWN,
3886
3887 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003888 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003889 */
3890 PJSUA_BUDDY_STATUS_ONLINE,
3891
3892 /**
3893 * Buddy is offline.
3894 */
3895 PJSUA_BUDDY_STATUS_OFFLINE,
3896
3897} pjsua_buddy_status;
3898
3899
3900
3901/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003902 * This structure describes buddy info, which can be retrieved by calling
3903 * #pjsua_buddy_get_info().
Benny Prijono312aff92006-06-17 04:08:30 +00003904 */
3905typedef struct pjsua_buddy_info
3906{
3907 /**
3908 * The buddy ID.
3909 */
3910 pjsua_buddy_id id;
3911
3912 /**
3913 * The full URI of the buddy, as specified in the configuration.
3914 */
3915 pj_str_t uri;
3916
3917 /**
3918 * Buddy's Contact, only available when presence subscription has
3919 * been established to the buddy.
3920 */
3921 pj_str_t contact;
3922
3923 /**
3924 * Buddy's online status.
3925 */
3926 pjsua_buddy_status status;
3927
3928 /**
3929 * Text to describe buddy's online status.
3930 */
3931 pj_str_t status_text;
3932
3933 /**
3934 * Flag to indicate that we should monitor the presence information for
3935 * this buddy (normally yes, unless explicitly disabled).
3936 */
3937 pj_bool_t monitor_pres;
3938
3939 /**
Benny Prijono63fba012008-07-17 14:19:10 +00003940 * If \a monitor_pres is enabled, this specifies the last state of the
3941 * presence subscription. If presence subscription session is currently
3942 * active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence
3943 * subscription request has been rejected, the value will be
3944 * PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be
3945 * specified in \a sub_term_reason.
3946 */
3947 pjsip_evsub_state sub_state;
3948
3949 /**
Benny Prijonod06d8c52009-06-30 13:53:47 +00003950 * String representation of subscription state.
3951 */
3952 const char *sub_state_name;
3953
3954 /**
Benny Prijono73bb7232009-10-20 13:56:26 +00003955 * Specifies the last presence subscription termination code. This would
3956 * return the last status of the SUBSCRIBE request. If the subscription
3957 * is terminated with NOTIFY by the server, this value will be set to
3958 * 200, and subscription termination reason will be given in the
3959 * \a sub_term_reason field.
3960 */
3961 unsigned sub_term_code;
3962
3963 /**
3964 * Specifies the last presence subscription termination reason. If
Benny Prijono63fba012008-07-17 14:19:10 +00003965 * presence subscription is currently active, the value will be empty.
3966 */
3967 pj_str_t sub_term_reason;
3968
3969 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003970 * Extended RPID information about the person.
3971 */
3972 pjrpid_element rpid;
3973
3974 /**
Benny Prijono28add7e2009-06-15 16:03:40 +00003975 * Extended presence info.
3976 */
3977 pjsip_pres_status pres_status;
3978
3979 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003980 * Internal buffer.
3981 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003982 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003983
3984} pjsua_buddy_info;
3985
3986
Benny Prijono834aee32006-02-19 01:38:06 +00003987/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003988 * Set default values to the buddy config.
3989 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003990PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003991
3992
3993/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003994 * Get total number of buddies.
3995 *
3996 * @return Number of buddies.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003997 */
3998PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3999
4000
4001/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004002 * Check if buddy ID is valid.
4003 *
4004 * @param buddy_id Buddy ID to check.
4005 *
4006 * @return Non-zero if buddy ID is valid.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004007 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004008PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
4009
4010
4011/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004012 * Enumerate all buddy IDs in the buddy list. Application then can use
4013 * #pjsua_buddy_get_info() to get the detail information for each buddy
4014 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004015 *
4016 * @param ids Array of ids to be initialized.
4017 * @param count On input, specifies max elements in the array.
4018 * On return, it contains actual number of elements
4019 * that have been initialized.
4020 *
4021 * @return PJ_SUCCESS on success, or the appropriate error code.
4022 */
4023PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
4024 unsigned *count);
4025
4026/**
Benny Prijono705e7842008-07-21 18:12:51 +00004027 * Find the buddy ID with the specified URI.
4028 *
4029 * @param uri The buddy URI.
4030 *
4031 * @return The buddy ID, or PJSUA_INVALID_ID if not found.
4032 */
4033PJ_DECL(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri);
4034
4035
4036/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004037 * Get detailed buddy info.
4038 *
4039 * @param buddy_id The buddy identification.
4040 * @param info Pointer to receive information about buddy.
4041 *
4042 * @return PJ_SUCCESS on success, or the appropriate error code.
4043 */
4044PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00004045 pjsua_buddy_info *info);
4046
4047/**
Benny Prijono705e7842008-07-21 18:12:51 +00004048 * Set the user data associated with the buddy object.
4049 *
4050 * @param buddy_id The buddy identification.
4051 * @param user_data Arbitrary application data to be associated with
4052 * the buddy object.
4053 *
4054 * @return PJ_SUCCESS on success, or the appropriate error code.
4055 */
4056PJ_DECL(pj_status_t) pjsua_buddy_set_user_data(pjsua_buddy_id buddy_id,
4057 void *user_data);
4058
4059
4060/**
4061 * Get the user data associated with the budy object.
4062 *
4063 * @param buddy_id The buddy identification.
4064 *
4065 * @return The application data.
4066 */
4067PJ_DECL(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id);
4068
4069
4070/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004071 * Add new buddy to the buddy list. If presence subscription is enabled
4072 * for this buddy, this function will also start the presence subscription
4073 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004074 *
Benny Prijonoa7b376b2008-01-25 16:06:33 +00004075 * @param buddy_cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004076 * @param p_buddy_id Pointer to receive buddy ID.
4077 *
4078 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004079 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004080PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004081 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004082
4083
4084/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004085 * Delete the specified buddy from the buddy list. Any presence subscription
4086 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004087 *
4088 * @param buddy_id Buddy identification.
4089 *
4090 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004091 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004092PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004093
4094
4095/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004096 * Enable/disable buddy's presence monitoring. Once buddy's presence is
4097 * subscribed, application will be informed about buddy's presence status
4098 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004099 *
4100 * @param buddy_id Buddy identification.
4101 * @param subscribe Specify non-zero to activate presence subscription to
4102 * the specified buddy.
4103 *
4104 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004105 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004106PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
4107 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004108
4109
4110/**
Benny Prijono10861432007-10-31 10:54:53 +00004111 * Update the presence information for the buddy. Although the library
4112 * periodically refreshes the presence subscription for all buddies, some
4113 * application may want to refresh the buddy's presence subscription
4114 * immediately, and in this case it can use this function to accomplish
4115 * this.
4116 *
4117 * Note that the buddy's presence subscription will only be initiated
4118 * if presence monitoring is enabled for the buddy. See
4119 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
4120 * for the buddy is already active, this function will not do anything.
4121 *
4122 * Once the presence subscription is activated successfully for the buddy,
4123 * application will be notified about the buddy's presence status in the
4124 * on_buddy_state() callback.
4125 *
4126 * @param buddy_id Buddy identification.
4127 *
4128 * @return PJ_SUCCESS on success, or the appropriate error code.
4129 */
4130PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
4131
4132
4133/**
Benny Prijono63fba012008-07-17 14:19:10 +00004134 * Send NOTIFY to inform account presence status or to terminate server
4135 * side presence subscription. If application wants to reject the incoming
4136 * request, it should set the \a state to PJSIP_EVSUB_STATE_TERMINATED.
4137 *
4138 * @param acc_id Account ID.
4139 * @param srv_pres Server presence subscription instance.
4140 * @param state New state to set.
4141 * @param state_str Optionally specify the state string name, if state
4142 * is not "active", "pending", or "terminated".
4143 * @param reason If the new state is PJSIP_EVSUB_STATE_TERMINATED,
4144 * optionally specify the termination reason.
4145 * @param with_body If the new state is PJSIP_EVSUB_STATE_TERMINATED,
4146 * this specifies whether the NOTIFY request should
4147 * contain message body containing account's presence
4148 * information.
4149 * @param msg_data Optional list of headers to be sent with the NOTIFY
4150 * request.
4151 *
4152 * @return PJ_SUCCESS on success.
4153 */
4154PJ_DECL(pj_status_t) pjsua_pres_notify(pjsua_acc_id acc_id,
4155 pjsua_srv_pres *srv_pres,
4156 pjsip_evsub_state state,
4157 const pj_str_t *state_str,
4158 const pj_str_t *reason,
4159 pj_bool_t with_body,
4160 const pjsua_msg_data *msg_data);
4161
4162/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004163 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004164 *
4165 * @param verbose Yes or no.
Benny Prijono834aee32006-02-19 01:38:06 +00004166 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004167PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00004168
4169
Benny Prijonob0808372006-03-02 21:18:58 +00004170/**
4171 * The MESSAGE method (defined in pjsua_im.c)
4172 */
4173extern const pjsip_method pjsip_message_method;
4174
4175
Benny Prijonob0808372006-03-02 21:18:58 +00004176
4177/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004178 * Send instant messaging outside dialog, using the specified account for
4179 * route set and authentication.
4180 *
4181 * @param acc_id Account ID to be used to send the request.
4182 * @param to Remote URI.
4183 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
4184 * assumed.
4185 * @param content The message content.
4186 * @param msg_data Optional list of headers etc to be included in outgoing
4187 * request. The body descriptor in the msg_data is
4188 * ignored.
4189 * @param user_data Optional user data, which will be given back when
4190 * the IM callback is called.
4191 *
4192 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00004193 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004194PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
4195 const pj_str_t *to,
4196 const pj_str_t *mime_type,
4197 const pj_str_t *content,
4198 const pjsua_msg_data *msg_data,
4199 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00004200
4201
4202/**
4203 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004204 *
4205 * @param acc_id Account ID to be used to send the request.
4206 * @param to Remote URI.
4207 * @param is_typing If non-zero, it tells remote person that local person
4208 * is currently composing an IM.
4209 * @param msg_data Optional list of headers etc to be added to outgoing
4210 * request.
4211 *
4212 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00004213 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004214PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
4215 const pj_str_t *to,
4216 pj_bool_t is_typing,
4217 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00004218
4219
Benny Prijonof3195072006-02-14 21:15:30 +00004220
Benny Prijono312aff92006-06-17 04:08:30 +00004221/**
4222 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00004223 */
4224
Benny Prijono312aff92006-06-17 04:08:30 +00004225
4226/*****************************************************************************
4227 * MEDIA API
4228 */
4229
4230
4231/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00004232 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00004233 * @ingroup PJSUA_LIB
4234 * @brief Media manipulation.
4235 * @{
4236 *
4237 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00004238 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
4239 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00004240 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00004241 * the interconnection between these terminations freely.
4242 *
4243 * The conference bridge provides powerful switching and mixing functionality
4244 * for application. With the conference bridge, each conference slot (e.g.
4245 * a call) can transmit to multiple destinations, and one destination can
4246 * receive from multiple sources. If more than one media terminations are
4247 * terminated in the same slot, the conference bridge will mix the signal
4248 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00004249 *
4250 * Application connects one media termination/slot to another by calling
4251 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00004252 * media flow from the source termination to the sink termination. To
4253 * establish bidirectional media flow, application wound need to make another
4254 * call to #pjsua_conf_connect(), this time inverting the source and
4255 * destination slots in the parameter.
4256 *
4257 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00004258 * the following steps:
4259 *
4260 \code
4261
4262 pj_status_t stream_to_call( pjsua_call_id call_id )
4263 {
4264 pjsua_player_id player_id;
4265
4266 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
4267 if (status != PJ_SUCCESS)
4268 return status;
4269
4270 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
4271 pjsua_call_get_conf_port() );
4272 }
4273 \endcode
4274 *
4275 *
4276 * Other features of PJSUA media:
4277 * - efficient N to M interconnections between media terminations.
4278 * - media termination can be connected to itself to create loopback
4279 * media.
4280 * - the media termination may have different clock rates, and resampling
4281 * will be done automatically by conference bridge.
4282 * - media terminations may also have different frame time; the
4283 * conference bridge will perform the necessary bufferring to adjust
4284 * the difference between terminations.
4285 * - interconnections are removed automatically when media termination
4286 * is removed from the bridge.
4287 * - sound device may be changed even when there are active media
4288 * interconnections.
4289 * - correctly report call's media quality (in #pjsua_call_dump()) from
4290 * RTCP packet exchange.
4291 */
4292
4293/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004294 * Max ports in the conference bridge. This setting is the default value
4295 * for pjsua_media_config.max_media_ports.
Benny Prijono312aff92006-06-17 04:08:30 +00004296 */
4297#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00004298# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00004299#endif
4300
Benny Prijonob5388cf2007-01-04 22:45:08 +00004301/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004302 * The default clock rate to be used by the conference bridge. This setting
4303 * is the default value for pjsua_media_config.clock_rate.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004304 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004305#ifndef PJSUA_DEFAULT_CLOCK_RATE
4306# define PJSUA_DEFAULT_CLOCK_RATE 16000
4307#endif
4308
Benny Prijonob5388cf2007-01-04 22:45:08 +00004309/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004310 * Default frame length in the conference bridge. This setting
4311 * is the default value for pjsua_media_config.audio_frame_ptime.
4312 */
4313#ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Nanang Izzuddinaf974842008-05-08 09:51:16 +00004314# define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
Benny Prijono37c710b2008-01-10 12:09:26 +00004315#endif
4316
4317
4318/**
4319 * Default codec quality settings. This setting is the default value
4320 * for pjsua_media_config.quality.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004321 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004322#ifndef PJSUA_DEFAULT_CODEC_QUALITY
Nanang Izzuddin9dbad152008-06-10 18:56:10 +00004323# define PJSUA_DEFAULT_CODEC_QUALITY 8
Benny Prijono12a669c2006-11-23 07:32:13 +00004324#endif
4325
Benny Prijonob5388cf2007-01-04 22:45:08 +00004326/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004327 * Default iLBC mode. This setting is the default value for
4328 * pjsua_media_config.ilbc_mode.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004329 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004330#ifndef PJSUA_DEFAULT_ILBC_MODE
Benny Prijono37c710b2008-01-10 12:09:26 +00004331# define PJSUA_DEFAULT_ILBC_MODE 30
Benny Prijono12a669c2006-11-23 07:32:13 +00004332#endif
4333
Benny Prijonob5388cf2007-01-04 22:45:08 +00004334/**
Benny Prijono37c710b2008-01-10 12:09:26 +00004335 * The default echo canceller tail length. This setting
4336 * is the default value for pjsua_media_config.ec_tail_len.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004337 */
Benny Prijono12a669c2006-11-23 07:32:13 +00004338#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijono427439c2007-10-21 09:41:24 +00004339# define PJSUA_DEFAULT_EC_TAIL_LEN 200
Benny Prijono12a669c2006-11-23 07:32:13 +00004340#endif
Benny Prijono312aff92006-06-17 04:08:30 +00004341
4342
4343/**
Benny Prijonocba59d92007-02-16 09:22:56 +00004344 * The maximum file player.
4345 */
4346#ifndef PJSUA_MAX_PLAYERS
4347# define PJSUA_MAX_PLAYERS 32
4348#endif
4349
4350
4351/**
4352 * The maximum file player.
4353 */
4354#ifndef PJSUA_MAX_RECORDERS
4355# define PJSUA_MAX_RECORDERS 32
4356#endif
4357
4358
4359/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004360 * This structure describes media configuration, which will be specified
4361 * when calling #pjsua_init(). Application MUST initialize this structure
4362 * by calling #pjsua_media_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00004363 */
4364struct pjsua_media_config
4365{
4366 /**
4367 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00004368 * If value is zero, default clock rate will be used
4369 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00004370 */
4371 unsigned clock_rate;
4372
4373 /**
Benny Prijonof3758ee2008-02-26 15:32:16 +00004374 * Clock rate to be applied when opening the sound device.
4375 * If value is zero, conference bridge clock rate will be used.
4376 */
4377 unsigned snd_clock_rate;
4378
4379 /**
Benny Prijono7d60d052008-03-29 12:24:20 +00004380 * Channel count be applied when opening the sound device and
4381 * conference bridge.
4382 */
4383 unsigned channel_count;
4384
4385 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004386 * Specify audio frame ptime. The value here will affect the
4387 * samples per frame of both the sound device and the conference
4388 * bridge. Specifying lower ptime will normally reduce the
4389 * latency.
4390 *
Benny Prijono37c710b2008-01-10 12:09:26 +00004391 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004392 */
4393 unsigned audio_frame_ptime;
4394
4395 /**
Benny Prijono312aff92006-06-17 04:08:30 +00004396 * Specify maximum number of media ports to be created in the
4397 * conference bridge. Since all media terminate in the bridge
4398 * (calls, file player, file recorder, etc), the value must be
4399 * large enough to support all of them. However, the larger
4400 * the value, the more computations are performed.
Benny Prijono37c710b2008-01-10 12:09:26 +00004401 *
4402 * Default value: PJSUA_MAX_CONF_PORTS
Benny Prijono312aff92006-06-17 04:08:30 +00004403 */
4404 unsigned max_media_ports;
4405
4406 /**
4407 * Specify whether the media manager should manage its own
4408 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
4409 * and at least one worker thread will be created too. If no,
4410 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
4411 * and no worker thread is needed.
4412 *
4413 * Normally application would say yes here, unless it wants to
4414 * run everything from a single thread.
4415 */
4416 pj_bool_t has_ioqueue;
4417
4418 /**
4419 * Specify the number of worker threads to handle incoming RTP
4420 * packets. A value of one is recommended for most applications.
4421 */
4422 unsigned thread_cnt;
4423
Benny Prijono0498d902006-06-19 14:49:14 +00004424 /**
4425 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00004426 * 5-10: resampling use large filter,
4427 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00004428 * 1-2: resampling use linear.
4429 * The media quality also sets speex codec quality/complexity to the
4430 * number.
4431 *
Benny Prijono70972992006-08-05 11:13:58 +00004432 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00004433 */
4434 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00004435
4436 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00004437 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00004438 *
4439 * Default: 0 (codec specific)
4440 */
4441 unsigned ptime;
4442
4443 /**
4444 * Disable VAD?
4445 *
4446 * Default: 0 (no (meaning VAD is enabled))
4447 */
4448 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00004449
4450 /**
4451 * iLBC mode (20 or 30).
4452 *
Benny Prijono37c710b2008-01-10 12:09:26 +00004453 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00004454 */
4455 unsigned ilbc_mode;
4456
4457 /**
4458 * Percentage of RTP packet to drop in TX direction
4459 * (to simulate packet lost).
4460 *
4461 * Default: 0
4462 */
4463 unsigned tx_drop_pct;
4464
4465 /**
4466 * Percentage of RTP packet to drop in RX direction
4467 * (to simulate packet lost).
4468 *
4469 * Default: 0
4470 */
4471 unsigned rx_drop_pct;
4472
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004473 /**
Benny Prijono5da50432006-08-07 10:24:52 +00004474 * Echo canceller options (see #pjmedia_echo_create())
4475 *
4476 * Default: 0.
4477 */
4478 unsigned ec_options;
4479
4480 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004481 * Echo canceller tail length, in miliseconds.
4482 *
Benny Prijono669643c2006-09-20 20:02:18 +00004483 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00004484 */
4485 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004486
Benny Prijono10454dc2009-02-21 14:21:59 +00004487 /**
4488 * Audio capture buffer length, in milliseconds.
4489 *
4490 * Default: PJMEDIA_SND_DEFAULT_REC_LATENCY
4491 */
4492 unsigned snd_rec_latency;
4493
4494 /**
4495 * Audio playback buffer length, in milliseconds.
4496 *
4497 * Default: PJMEDIA_SND_DEFAULT_PLAY_LATENCY
4498 */
4499 unsigned snd_play_latency;
4500
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00004501 /**
4502 * Jitter buffer initial prefetch delay in msec. The value must be
4503 * between jb_min_pre and jb_max_pre below.
4504 *
4505 * Default: -1 (to use default stream settings, currently 150 msec)
4506 */
4507 int jb_init;
4508
4509 /**
4510 * Jitter buffer minimum prefetch delay in msec.
4511 *
4512 * Default: -1 (to use default stream settings, currently 60 msec)
4513 */
4514 int jb_min_pre;
4515
4516 /**
4517 * Jitter buffer maximum prefetch delay in msec.
4518 *
4519 * Default: -1 (to use default stream settings, currently 240 msec)
4520 */
4521 int jb_max_pre;
4522
4523 /**
4524 * Set maximum delay that can be accomodated by the jitter buffer msec.
4525 *
4526 * Default: -1 (to use default stream settings, currently 360 msec)
4527 */
4528 int jb_max;
4529
Benny Prijonoc97608e2007-03-23 16:34:20 +00004530 /**
4531 * Enable ICE
4532 */
4533 pj_bool_t enable_ice;
4534
4535 /**
Benny Prijono329d6382009-05-29 13:04:03 +00004536 * Set the maximum number of host candidates.
4537 *
4538 * Default: -1 (maximum not set)
Benny Prijonoc97608e2007-03-23 16:34:20 +00004539 */
Benny Prijono329d6382009-05-29 13:04:03 +00004540 int ice_max_host_cands;
4541
4542 /**
4543 * ICE session options.
4544 */
4545 pj_ice_sess_options ice_opt;
Benny Prijonof76e1392008-06-06 14:51:48 +00004546
4547 /**
Benny Prijono551af422008-08-07 09:55:52 +00004548 * Disable RTCP component.
4549 *
4550 * Default: no
4551 */
4552 pj_bool_t ice_no_rtcp;
4553
4554 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00004555 * Enable TURN relay candidate in ICE.
4556 */
4557 pj_bool_t enable_turn;
4558
4559 /**
4560 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
4561 * "HOST:PORT" format.
4562 */
4563 pj_str_t turn_server;
4564
4565 /**
4566 * Specify the connection type to be used to the TURN server. Valid
4567 * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP.
4568 *
4569 * Default: PJ_TURN_TP_UDP
4570 */
4571 pj_turn_tp_type turn_conn_type;
4572
4573 /**
4574 * Specify the credential to authenticate with the TURN server.
4575 */
4576 pj_stun_auth_cred turn_auth_cred;
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004577
4578 /**
4579 * Specify idle time of sound device before it is automatically closed,
Benny Prijonof798e502009-03-09 13:08:16 +00004580 * in seconds. Use value -1 to disable the auto-close feature of sound
4581 * device
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004582 *
Benny Prijonof798e502009-03-09 13:08:16 +00004583 * Default : 1
Nanang Izzuddin68559c32008-06-13 17:01:46 +00004584 */
4585 int snd_auto_close_time;
Benny Prijono312aff92006-06-17 04:08:30 +00004586};
4587
4588
4589/**
4590 * Use this function to initialize media config.
4591 *
4592 * @param cfg The media config to be initialized.
4593 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00004594PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00004595
4596
4597/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004598 * This structure describes codec information, which can be retrieved by
4599 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00004600 */
4601typedef struct pjsua_codec_info
4602{
4603 /**
4604 * Codec unique identification.
4605 */
4606 pj_str_t codec_id;
4607
4608 /**
4609 * Codec priority (integer 0-255).
4610 */
4611 pj_uint8_t priority;
4612
4613 /**
Nanang Izzuddin56b2ce42011-04-06 13:55:01 +00004614 * Codec description.
4615 */
4616 pj_str_t desc;
4617
4618 /**
Benny Prijono312aff92006-06-17 04:08:30 +00004619 * Internal buffer.
4620 */
Nanang Izzuddin56b2ce42011-04-06 13:55:01 +00004621 char buf_[64];
Benny Prijono312aff92006-06-17 04:08:30 +00004622
4623} pjsua_codec_info;
4624
4625
4626/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00004627 * This structure descibes information about a particular media port that
4628 * has been registered into the conference bridge. Application can query
4629 * this info by calling #pjsua_conf_get_port_info().
Benny Prijono312aff92006-06-17 04:08:30 +00004630 */
4631typedef struct pjsua_conf_port_info
4632{
4633 /** Conference port number. */
4634 pjsua_conf_port_id slot_id;
4635
4636 /** Port name. */
4637 pj_str_t name;
4638
4639 /** Clock rate. */
4640 unsigned clock_rate;
4641
4642 /** Number of channels. */
4643 unsigned channel_count;
4644
4645 /** Samples per frame */
4646 unsigned samples_per_frame;
4647
4648 /** Bits per sample */
4649 unsigned bits_per_sample;
4650
4651 /** Number of listeners in the array. */
4652 unsigned listener_cnt;
4653
4654 /** Array of listeners (in other words, ports where this port is
4655 * transmitting to.
4656 */
4657 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
4658
4659} pjsua_conf_port_info;
4660
4661
4662/**
4663 * This structure holds information about custom media transport to
4664 * be registered to pjsua.
4665 */
4666typedef struct pjsua_media_transport
4667{
4668 /**
4669 * Media socket information containing the address information
4670 * of the RTP and RTCP socket.
4671 */
4672 pjmedia_sock_info skinfo;
4673
4674 /**
4675 * The media transport instance.
4676 */
4677 pjmedia_transport *transport;
4678
4679} pjsua_media_transport;
4680
4681
Benny Prijono9fc735d2006-05-28 14:58:12 +00004682/**
4683 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004684 *
4685 * @return Maximum number of ports in the conference bridge.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004686 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004687PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004688
4689
4690/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004691 * Get current number of active ports in the bridge.
4692 *
4693 * @return The number.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004694 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004695PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
4696
4697
4698/**
4699 * Enumerate all conference ports.
4700 *
4701 * @param id Array of conference port ID to be initialized.
4702 * @param count On input, specifies max elements in the array.
4703 * On return, it contains actual number of elements
4704 * that have been initialized.
4705 *
4706 * @return PJ_SUCCESS on success, or the appropriate error code.
4707 */
4708PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
4709 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00004710
4711
4712/**
4713 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004714 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004715 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004716 * @param info Pointer to store the port info.
4717 *
4718 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00004719 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004720PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00004721 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004722
4723
4724/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00004725 * Add arbitrary media port to PJSUA's conference bridge. Application
4726 * can use this function to add the media port that it creates. For
4727 * media ports that are created by PJSUA-LIB (such as calls, file player,
4728 * or file recorder), PJSUA-LIB will automatically add the port to
4729 * the bridge.
4730 *
4731 * @param pool Pool to use.
4732 * @param port Media port to be added to the bridge.
4733 * @param p_id Optional pointer to receive the conference
4734 * slot id.
4735 *
4736 * @return PJ_SUCCESS on success, or the appropriate error code.
4737 */
4738PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
4739 pjmedia_port *port,
4740 pjsua_conf_port_id *p_id);
4741
4742
4743/**
4744 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00004745 * call this function if it registered the port manually with previous call
4746 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00004747 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004748 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00004749 *
4750 * @return PJ_SUCCESS on success, or the appropriate error code.
4751 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004752PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00004753
4754
4755/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004756 * Establish unidirectional media flow from souce to sink. One source
4757 * may transmit to multiple destinations/sink. And if multiple
4758 * sources are transmitting to the same sink, the media will be mixed
4759 * together. Source and sink may refer to the same ID, effectively
4760 * looping the media.
4761 *
4762 * If bidirectional media flow is desired, application needs to call
4763 * this function twice, with the second one having the arguments
4764 * reversed.
4765 *
4766 * @param source Port ID of the source media/transmitter.
4767 * @param sink Port ID of the destination media/received.
4768 *
4769 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004770 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004771PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
4772 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004773
4774
4775/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004776 * Disconnect media flow from the source to destination port.
4777 *
4778 * @param source Port ID of the source media/transmitter.
4779 * @param sink Port ID of the destination media/received.
4780 *
4781 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004782 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004783PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
4784 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004785
4786
Benny Prijono6dd967c2006-12-26 02:27:14 +00004787/**
4788 * Adjust the signal level to be transmitted from the bridge to the
4789 * specified port by making it louder or quieter.
4790 *
4791 * @param slot The conference bridge slot number.
4792 * @param level Signal level adjustment. Value 1.0 means no level
4793 * adjustment, while value 0 means to mute the port.
4794 *
4795 * @return PJ_SUCCESS on success, or the appropriate error code.
4796 */
4797PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
4798 float level);
4799
4800/**
4801 * Adjust the signal level to be received from the specified port (to
4802 * the bridge) by making it louder or quieter.
4803 *
4804 * @param slot The conference bridge slot number.
4805 * @param level Signal level adjustment. Value 1.0 means no level
4806 * adjustment, while value 0 means to mute the port.
4807 *
4808 * @return PJ_SUCCESS on success, or the appropriate error code.
4809 */
4810PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
4811 float level);
4812
4813/**
4814 * Get last signal level transmitted to or received from the specified port.
4815 * The signal level is an integer value in zero to 255, with zero indicates
4816 * no signal, and 255 indicates the loudest signal level.
4817 *
4818 * @param slot The conference bridge slot number.
4819 * @param tx_level Optional argument to receive the level of signal
4820 * transmitted to the specified port (i.e. the direction
4821 * is from the bridge to the port).
4822 * @param rx_level Optional argument to receive the level of signal
4823 * received from the port (i.e. the direction is from the
4824 * port to the bridge).
4825 *
4826 * @return PJ_SUCCESS on success.
4827 */
4828PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
4829 unsigned *tx_level,
4830 unsigned *rx_level);
4831
Benny Prijono6dd967c2006-12-26 02:27:14 +00004832
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004833/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00004834 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004835 */
4836
Benny Prijono9fc735d2006-05-28 14:58:12 +00004837/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004838 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004839 * the conference bridge.
4840 *
4841 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00004842 * WAV files are supported, and the WAV file MUST be
4843 * formatted as 16bit PCM mono/single channel (any
4844 * clock rate is supported).
Benny Prijono58add7c2008-01-18 13:24:07 +00004845 * @param options Optional option flag. Application may specify
4846 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004847 * @param p_id Pointer to receive player ID.
4848 *
4849 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004850 */
4851PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004852 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004853 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004854
4855
4856/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004857 * Create a file playlist media port, and automatically add the port
4858 * to the conference bridge.
4859 *
4860 * @param file_names Array of file names to be added to the play list.
4861 * Note that the files must have the same clock rate,
4862 * number of channels, and number of bits per sample.
4863 * @param file_count Number of files in the array.
4864 * @param label Optional label to be set for the media port.
4865 * @param options Optional option flag. Application may specify
4866 * PJMEDIA_FILE_NO_LOOP to prevent looping.
4867 * @param p_id Optional pointer to receive player ID.
4868 *
4869 * @return PJ_SUCCESS on success, or the appropriate error code.
4870 */
4871PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
4872 unsigned file_count,
4873 const pj_str_t *label,
4874 unsigned options,
4875 pjsua_player_id *p_id);
4876
4877/**
4878 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004879 *
4880 * @param id The file player ID.
4881 *
4882 * @return Conference port ID associated with this player.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004883 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004884PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004885
4886
4887/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004888 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00004889 *
4890 * @param id The player ID.
4891 * @param p_port The media port associated with the player.
4892 *
4893 * @return PJ_SUCCESS on success.
4894 */
Benny Prijono58add7c2008-01-18 13:24:07 +00004895PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
Benny Prijono469b1522006-12-26 03:05:17 +00004896 pjmedia_port **p_port);
4897
4898/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004899 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004900 *
4901 * @param id The file player ID.
4902 * @param samples The playback position, in samples. Application can
4903 * specify zero to re-start the playback.
4904 *
4905 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004906 */
4907PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
4908 pj_uint32_t samples);
4909
4910
4911/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004912 * Close the file of playlist, remove the player from the bridge, and free
4913 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004914 *
4915 * @param id The file player ID.
4916 *
4917 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004918 */
4919PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
4920
4921
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004922/*****************************************************************************
4923 * File recorder.
4924 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00004925
4926/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004927 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004928 * the conference bridge. The recorder currently supports recording WAV file.
4929 * The type of the recorder to use is determined by the extension of the file
4930 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004931 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00004932 * @param filename Output file name. The function will determine the
4933 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004934 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00004935 * @param enc_type Optionally specify the type of encoder to be used to
4936 * compress the media, if the file can support different
4937 * encodings. This value must be zero for now.
4938 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004939 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00004940 * For .WAV recorder, this value must be NULL.
4941 * @param max_size Maximum file size. Specify zero or -1 to remove size
4942 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004943 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004944 * @param p_id Pointer to receive the recorder instance.
4945 *
4946 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004947 */
4948PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004949 unsigned enc_type,
4950 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004951 pj_ssize_t max_size,
4952 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004953 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004954
4955
4956/**
4957 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004958 *
4959 * @param id The recorder ID.
4960 *
4961 * @return Conference port ID associated with this recorder.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004962 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004963PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004964
4965
4966/**
Benny Prijono469b1522006-12-26 03:05:17 +00004967 * Get the media port for the recorder.
4968 *
4969 * @param id The recorder ID.
4970 * @param p_port The media port associated with the recorder.
4971 *
4972 * @return PJ_SUCCESS on success.
4973 */
4974PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4975 pjmedia_port **p_port);
4976
4977
4978/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004979 * Destroy recorder (this will complete recording).
4980 *
4981 * @param id The recorder ID.
4982 *
4983 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004984 */
4985PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4986
4987
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004988/*****************************************************************************
4989 * Sound devices.
4990 */
4991
Benny Prijono9fc735d2006-05-28 14:58:12 +00004992/**
Benny Prijonof798e502009-03-09 13:08:16 +00004993 * Enum all audio devices installed in the system.
4994 *
4995 * @param info Array of info to be initialized.
4996 * @param count On input, specifies max elements in the array.
4997 * On return, it contains actual number of elements
4998 * that have been initialized.
4999 *
5000 * @return PJ_SUCCESS on success, or the appropriate error code.
5001 */
5002PJ_DECL(pj_status_t) pjsua_enum_aud_devs(pjmedia_aud_dev_info info[],
5003 unsigned *count);
5004
5005/**
5006 * Enum all sound devices installed in the system (old API).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005007 *
5008 * @param info Array of info to be initialized.
5009 * @param count On input, specifies max elements in the array.
5010 * On return, it contains actual number of elements
5011 * that have been initialized.
5012 *
5013 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00005014 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005015PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
5016 unsigned *count);
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00005017
5018/**
5019 * Get currently active sound devices. If sound devices has not been created
5020 * (for example when pjsua_start() is not called), it is possible that
5021 * the function returns PJ_SUCCESS with -1 as device IDs.
5022 *
5023 * @param capture_dev On return it will be filled with device ID of the
5024 * capture device.
5025 * @param playback_dev On return it will be filled with device ID of the
5026 * device ID of the playback device.
5027 *
5028 * @return PJ_SUCCESS on success, or the appropriate error code.
5029 */
5030PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
5031 int *playback_dev);
5032
5033
Benny Prijono9fc735d2006-05-28 14:58:12 +00005034/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005035 * Select or change sound device. Application may call this function at
5036 * any time to replace current sound device.
5037 *
5038 * @param capture_dev Device ID of the capture device.
5039 * @param playback_dev Device ID of the playback device.
5040 *
5041 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00005042 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005043PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
5044 int playback_dev);
5045
5046
5047/**
5048 * Set pjsua to use null sound device. The null sound device only provides
5049 * the timing needed by the conference bridge, and will not interract with
5050 * any hardware.
5051 *
5052 * @return PJ_SUCCESS on success, or the appropriate error code.
5053 */
5054PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
5055
5056
Benny Prijonoe909eac2006-07-27 22:04:56 +00005057/**
5058 * Disconnect the main conference bridge from any sound devices, and let
5059 * application connect the bridge to it's own sound device/master port.
5060 *
5061 * @return The port interface of the conference bridge,
5062 * so that application can connect this to it's own
5063 * sound device or master port.
5064 */
5065PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
5066
5067
Benny Prijonof20687a2006-08-04 18:27:19 +00005068/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00005069 * Change the echo cancellation settings.
Benny Prijonof798e502009-03-09 13:08:16 +00005070 *
5071 * The behavior of this function depends on whether the sound device is
5072 * currently active, and if it is, whether device or software AEC is
5073 * being used.
Benny Prijono10454dc2009-02-21 14:21:59 +00005074 *
5075 * If the sound device is currently active, and if the device supports AEC,
5076 * this function will forward the change request to the device and it will
5077 * be up to the device on whether support the request. If software AEC is
5078 * being used (the software EC will be used if the device does not support
5079 * AEC), this function will change the software EC settings. In all cases,
5080 * the setting will be saved for future opening of the sound device.
5081 *
5082 * If the sound device is not currently active, this will only change the
5083 * default AEC settings and the setting will be applied next time the
5084 * sound device is opened.
Benny Prijonof20687a2006-08-04 18:27:19 +00005085 *
5086 * @param tail_ms The tail length, in miliseconds. Set to zero to
5087 * disable AEC.
Benny Prijonoa7b376b2008-01-25 16:06:33 +00005088 * @param options Options to be passed to pjmedia_echo_create().
Benny Prijono5da50432006-08-07 10:24:52 +00005089 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00005090 *
5091 * @return PJ_SUCCESS on success.
5092 */
Benny Prijono5da50432006-08-07 10:24:52 +00005093PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00005094
5095
5096/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00005097 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00005098 *
5099 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
5100 * If AEC is disabled, the value will be zero.
5101 *
5102 * @return PJ_SUCCESS on success.
5103 */
Benny Prijono22dfe592006-08-06 12:07:13 +00005104PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00005105
5106
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00005107/**
Benny Prijonof798e502009-03-09 13:08:16 +00005108 * Check whether the sound device is currently active. The sound device
5109 * may be inactive if the application has set the auto close feature to
5110 * non-zero (the snd_auto_close_time setting in #pjsua_media_config), or
5111 * if null sound device or no sound device has been configured via the
5112 * #pjsua_set_no_snd_dev() function.
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00005113 */
Benny Prijonof798e502009-03-09 13:08:16 +00005114PJ_DECL(pj_bool_t) pjsua_snd_is_active(void);
5115
5116
5117/**
5118 * Configure sound device setting to the sound device being used. If sound
5119 * device is currently active, the function will forward the setting to the
5120 * sound device instance to be applied immediately, if it supports it.
5121 *
5122 * The setting will be saved for future opening of the sound device, if the
5123 * "keep" argument is set to non-zero. If the sound device is currently
5124 * inactive, and the "keep" argument is false, this function will return
5125 * error.
5126 *
5127 * Note that in case the setting is kept for future use, it will be applied
5128 * to any devices, even when application has changed the sound device to be
5129 * used.
5130 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00005131 * Note also that the echo cancellation setting should be set with
5132 * #pjsua_set_ec() API instead.
5133 *
Benny Prijonof798e502009-03-09 13:08:16 +00005134 * See also #pjmedia_aud_stream_set_cap() for more information about setting
5135 * an audio device capability.
5136 *
5137 * @param cap The sound device setting to change.
5138 * @param pval Pointer to value. Please see #pjmedia_aud_dev_cap
5139 * documentation about the type of value to be
5140 * supplied for each setting.
5141 * @param keep Specify whether the setting is to be kept for future
5142 * use.
5143 *
5144 * @return PJ_SUCCESS on success or the appropriate error code.
5145 */
5146PJ_DECL(pj_status_t) pjsua_snd_set_setting(pjmedia_aud_dev_cap cap,
5147 const void *pval,
5148 pj_bool_t keep);
5149
5150/**
5151 * Retrieve a sound device setting. If sound device is currently active,
5152 * the function will forward the request to the sound device. If sound device
5153 * is currently inactive, and if application had previously set the setting
5154 * and mark the setting as kept, then that setting will be returned.
5155 * Otherwise, this function will return error.
5156 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00005157 * Note that echo cancellation settings should be retrieved with
5158 * #pjsua_get_ec_tail() API instead.
5159 *
Benny Prijonof798e502009-03-09 13:08:16 +00005160 * @param cap The sound device setting to retrieve.
5161 * @param pval Pointer to receive the value.
5162 * Please see #pjmedia_aud_dev_cap documentation about
5163 * the type of value to be supplied for each setting.
5164 *
5165 * @return PJ_SUCCESS on success or the appropriate error code.
5166 */
5167PJ_DECL(pj_status_t) pjsua_snd_get_setting(pjmedia_aud_dev_cap cap,
5168 void *pval);
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00005169
5170
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005171/*****************************************************************************
5172 * Codecs.
5173 */
5174
5175/**
5176 * Enum all supported codecs in the system.
5177 *
5178 * @param id Array of ID to be initialized.
5179 * @param count On input, specifies max elements in the array.
5180 * On return, it contains actual number of elements
5181 * that have been initialized.
5182 *
5183 * @return PJ_SUCCESS on success, or the appropriate error code.
5184 */
5185PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
5186 unsigned *count );
5187
5188
5189/**
5190 * Change codec priority.
5191 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00005192 * @param codec_id Codec ID, which is a string that uniquely identify
5193 * the codec (such as "speex/8000"). Please see pjsua
5194 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005195 * @param priority Codec priority, 0-255, where zero means to disable
5196 * the codec.
5197 *
5198 * @return PJ_SUCCESS on success, or the appropriate error code.
5199 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00005200PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005201 pj_uint8_t priority );
5202
5203
5204/**
5205 * Get codec parameters.
5206 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00005207 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005208 * @param param Structure to receive codec parameters.
5209 *
5210 * @return PJ_SUCCESS on success, or the appropriate error code.
5211 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00005212PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005213 pjmedia_codec_param *param );
5214
5215
5216/**
5217 * Set codec parameters.
5218 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00005219 * @param codec_id Codec ID.
Nanang Izzuddin06839e72010-01-27 11:48:31 +00005220 * @param param Codec parameter to set. Set to NULL to reset
5221 * codec parameter to library default settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005222 *
5223 * @return PJ_SUCCESS on success, or the appropriate error code.
5224 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00005225PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005226 const pjmedia_codec_param *param);
5227
Benny Prijono9f468d12011-07-07 07:46:33 +00005228
5229#if DISABLED_FOR_TICKET_1185
5230/**
5231 * Create UDP media transports for all the calls. This function creates
5232 * one UDP media transport for each call.
5233 *
5234 * @param cfg Media transport configuration. The "port" field in the
5235 * configuration is used as the start port to bind the
5236 * sockets.
5237 *
5238 * @return PJ_SUCCESS on success, or the appropriate error code.
5239 */
5240PJ_DECL(pj_status_t)
5241pjsua_media_transports_create(const pjsua_transport_config *cfg);
5242
5243
5244/**
5245 * Register custom media transports to be used by calls. There must
5246 * enough media transports for all calls.
5247 *
5248 * @param tp The media transport array.
5249 * @param count Number of elements in the array. This number MUST
5250 * match the number of maximum calls configured when
5251 * pjsua is created.
5252 * @param auto_delete Flag to indicate whether the transports should be
5253 * destroyed when pjsua is shutdown.
5254 *
5255 * @return PJ_SUCCESS on success, or the appropriate error code.
5256 */
5257PJ_DECL(pj_status_t)
5258pjsua_media_transports_attach( pjsua_media_transport tp[],
5259 unsigned count,
5260 pj_bool_t auto_delete);
5261#endif
5262
5263
5264/* end of MEDIA API */
5265/**
5266 * @}
5267 */
5268
5269
Nanang Izzuddin50fae732011-03-22 09:49:23 +00005270/*****************************************************************************
Benny Prijono9f468d12011-07-07 07:46:33 +00005271 * VIDEO API
5272 */
5273
5274
5275/**
5276 * @defgroup PJSUA_LIB_VIDEO PJSUA-API Video
5277 * @ingroup PJSUA_LIB
5278 * @brief Video support
5279 * @{
5280 */
5281
5282/*
5283 * Video devices API
5284 */
5285
5286/**
5287 * Get the number of video devices installed in the system.
5288 *
5289 * @return The number of devices.
5290 */
5291PJ_DECL(unsigned) pjsua_vid_dev_count(void);
5292
5293/**
5294 * Retrieve the video device info for the specified device index.
5295 *
5296 * @param id The device index.
5297 * @param vdi Device info to be initialized.
5298 *
5299 * @return PJ_SUCCESS on success, or the appropriate error code.
5300 */
5301PJ_DECL(pj_status_t) pjsua_vid_dev_get_info(pjmedia_vid_dev_index id,
5302 pjmedia_vid_dev_info *vdi);
5303
5304/**
5305 * Enum all video devices installed in the system.
5306 *
5307 * @param info Array of info to be initialized.
5308 * @param count On input, specifies max elements in the array.
5309 * On return, it contains actual number of elements
5310 * that have been initialized.
5311 *
5312 * @return PJ_SUCCESS on success, or the appropriate error code.
5313 */
5314PJ_DECL(pj_status_t) pjsua_vid_enum_devs(pjmedia_vid_dev_info info[],
5315 unsigned *count);
5316
5317
5318/*
5319 * Video preview API
5320 */
5321
5322/**
5323 * Parameters for starting video preview with pjsua_vid_preview_start().
5324 * Application should initialize this structure with
5325 * pjsua_vid_preview_param_default().
5326 */
5327typedef struct pjsua_vid_preview_param
5328{
5329 /**
5330 * Device ID for the video renderer to be used for rendering the
5331 * capture stream for preview.
5332 */
5333 pjmedia_vid_dev_index rend_id;
5334} pjsua_vid_preview_param;
5335
5336
5337/**
5338 * Start video preview window for the specified capture device.
5339 *
5340 * @param id The capture device ID where its preview will be
5341 * started.
5342 * @param prm Optional video preview parameters. Specify NULL
5343 * to use default values.
5344 *
5345 * @return PJ_SUCCESS on success, or the appropriate error code.
5346 */
5347PJ_DECL(pj_status_t) pjsua_vid_preview_start(pjmedia_vid_dev_index id,
5348 pjsua_vid_preview_param *prm);
5349
5350/**
5351 * Get the preview window handle associated with the capture device, if any.
5352 *
5353 * @param id The capture device ID.
5354 *
5355 * @return The window ID of the preview window for the
5356 * specified capture device ID, or NULL if preview
5357 * does not exist.
5358 */
5359PJ_DECL(pjsua_vid_win_id) pjsua_vid_preview_get_win(pjmedia_vid_dev_index id);
5360
5361/**
5362 * Stop video preview.
5363 *
5364 * @param id The capture device ID.
5365 *
5366 * @return PJ_SUCCESS on success, or the appropriate error code.
5367 */
5368PJ_DECL(pj_status_t) pjsua_vid_preview_stop(pjmedia_vid_dev_index id);
5369
5370
5371/*
5372 * Video window manipulation API.
5373 */
5374
5375/**
5376 * This structure describes video window info.
5377 */
5378typedef struct pjsua_vid_win_info
5379{
5380 /**
5381 * Window show status. The window is hidden if false.
5382 */
5383 pj_bool_t show;
5384
5385 /**
5386 * Window position.
5387 */
5388 pjmedia_coord pos;
5389
5390 /**
5391 * Window size.
5392 */
5393 pjmedia_rect_size size;
5394
5395} pjsua_vid_win_info;
5396
5397
5398/**
5399 * Get window info.
5400 *
5401 * @param wid The video window ID.
5402 * @param wi The video window info to be initialized.
5403 *
5404 * @return PJ_SUCCESS on success, or the appropriate error code.
5405 */
5406PJ_DECL(pj_status_t) pjsua_vid_win_get_info(pjsua_vid_win_id wid,
5407 pjsua_vid_win_info *wi);
5408
5409/**
5410 * Show or hide window.
5411 *
5412 * @param wid The video window ID.
5413 * @param show Set to PJ_TRUE to show the window, PJ_FALSE to
5414 * hide the window.
5415 *
5416 * @return PJ_SUCCESS on success, or the appropriate error code.
5417 */
5418PJ_DECL(pj_status_t) pjsua_vid_win_set_show(pjsua_vid_win_id wid,
5419 pj_bool_t show);
5420
5421/**
5422 * Set video window position.
5423 *
5424 * @param wid The video window ID.
5425 * @param pos The window position.
5426 *
5427 * @return PJ_SUCCESS on success, or the appropriate error code.
5428 */
5429PJ_DECL(pj_status_t) pjsua_vid_win_set_pos(pjsua_vid_win_id wid,
5430 const pjmedia_coord *pos);
5431
5432/**
5433 * Resize window.
5434 *
5435 * @param wid The video window ID.
5436 * @param size The new window size.
5437 *
5438 * @return PJ_SUCCESS on success, or the appropriate error code.
5439 */
5440PJ_DECL(pj_status_t) pjsua_vid_win_set_size(pjsua_vid_win_id wid,
5441 const pjmedia_rect_size *size);
5442
5443
5444
5445/*
5446 * Video codecs API
Nanang Izzuddin50fae732011-03-22 09:49:23 +00005447 */
5448
5449/**
5450 * Enum all supported video codecs in the system.
5451 *
5452 * @param id Array of ID to be initialized.
5453 * @param count On input, specifies max elements in the array.
5454 * On return, it contains actual number of elements
5455 * that have been initialized.
5456 *
5457 * @return PJ_SUCCESS on success, or the appropriate error code.
5458 */
5459PJ_DECL(pj_status_t) pjsua_vid_enum_codecs( pjsua_codec_info id[],
5460 unsigned *count );
5461
5462
5463/**
5464 * Change video codec priority.
5465 *
5466 * @param codec_id Codec ID, which is a string that uniquely identify
5467 * the codec (such as "H263/90000"). Please see pjsua
5468 * manual or pjmedia codec reference for details.
5469 * @param priority Codec priority, 0-255, where zero means to disable
5470 * the codec.
5471 *
5472 * @return PJ_SUCCESS on success, or the appropriate error code.
5473 */
5474PJ_DECL(pj_status_t) pjsua_vid_codec_set_priority( const pj_str_t *codec_id,
5475 pj_uint8_t priority );
5476
5477
5478/**
5479 * Get video codec parameters.
5480 *
5481 * @param codec_id Codec ID.
5482 * @param param Structure to receive video codec parameters.
5483 *
5484 * @return PJ_SUCCESS on success, or the appropriate error code.
5485 */
5486PJ_DECL(pj_status_t) pjsua_vid_codec_get_param(
5487 const pj_str_t *codec_id,
5488 pjmedia_vid_codec_param *param);
5489
5490
5491/**
5492 * Set video codec parameters.
5493 *
5494 * @param codec_id Codec ID.
5495 * @param param Codec parameter to set. Set to NULL to reset
5496 * codec parameter to library default settings.
5497 *
5498 * @return PJ_SUCCESS on success, or the appropriate error code.
5499 */
5500PJ_DECL(pj_status_t) pjsua_vid_codec_set_param(
5501 const pj_str_t *codec_id,
5502 const pjmedia_vid_codec_param *param);
5503
5504
Benny Prijonof3195072006-02-14 21:15:30 +00005505
Benny Prijono9f468d12011-07-07 07:46:33 +00005506/* end of VIDEO API */
Benny Prijono312aff92006-06-17 04:08:30 +00005507/**
5508 * @}
5509 */
5510
Benny Prijonof3195072006-02-14 21:15:30 +00005511
Benny Prijono312aff92006-06-17 04:08:30 +00005512/**
5513 * @}
5514 */
5515
Benny Prijonoe6ead542007-01-31 20:53:31 +00005516PJ_END_DECL
5517
Benny Prijono312aff92006-06-17 04:08:30 +00005518
Benny Prijono268ca612006-02-07 12:34:11 +00005519#endif /* __PJSUA_H__ */