blob: 93167785dcc9ec4bfe4174dd20eb3e3f033b0070 [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
253/** Call identification */
254typedef int pjsua_call_id;
255
Benny Prijono312aff92006-06-17 04:08:30 +0000256/** Account identification */
257typedef int pjsua_acc_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000258
259/** Buddy identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000260typedef int pjsua_buddy_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000261
262/** File player identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000263typedef int pjsua_player_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000264
265/** File recorder identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000266typedef int pjsua_recorder_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000267
268/** Conference port identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000269typedef int pjsua_conf_port_id;
270
Benny Prijono63fba012008-07-17 14:19:10 +0000271/** Opaque declaration for server side presence subscription */
272typedef struct pjsua_srv_pres pjsua_srv_pres;
273
274/** Forward declaration for pjsua_msg_data */
275typedef struct pjsua_msg_data pjsua_msg_data;
Benny Prijono8b1889b2006-06-06 18:40:40 +0000276
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000277
Benny Prijonoa91a0032006-02-26 21:23:45 +0000278/**
Benny Prijono312aff92006-06-17 04:08:30 +0000279 * Maximum proxies in account.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000280 */
Benny Prijono312aff92006-06-17 04:08:30 +0000281#ifndef PJSUA_ACC_MAX_PROXIES
282# define PJSUA_ACC_MAX_PROXIES 8
283#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000284
Benny Prijonod8179652008-01-23 20:39:07 +0000285#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000286
Benny Prijonod8179652008-01-23 20:39:07 +0000287/**
288 * Default value of SRTP mode usage. Valid values are PJMEDIA_SRTP_DISABLED,
289 * PJMEDIA_SRTP_OPTIONAL, and PJMEDIA_SRTP_MANDATORY.
290 */
291#ifndef PJSUA_DEFAULT_USE_SRTP
292 #define PJSUA_DEFAULT_USE_SRTP PJMEDIA_SRTP_DISABLED
293#endif
294
295/**
296 * Default value of secure signaling requirement for SRTP.
297 * Valid values are:
298 * 0: SRTP does not require secure signaling
299 * 1: SRTP requires secure transport such as TLS
300 * 2: SRTP requires secure end-to-end transport (SIPS)
301 */
302#ifndef PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
303 #define PJSUA_DEFAULT_SRTP_SECURE_SIGNALING 1
304#endif
305
306#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000307
308/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000309 * Logging configuration, which can be (optionally) specified when calling
310 * #pjsua_init(). Application must call #pjsua_logging_config_default() to
311 * initialize this structure with the default values.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000312 */
313typedef struct pjsua_logging_config
314{
315 /**
316 * Log incoming and outgoing SIP message? Yes!
317 */
318 pj_bool_t msg_logging;
319
320 /**
321 * Input verbosity level. Value 5 is reasonable.
322 */
323 unsigned level;
324
325 /**
326 * Verbosity level for console. Value 4 is reasonable.
327 */
328 unsigned console_level;
329
330 /**
331 * Log decoration.
332 */
333 unsigned decor;
334
335 /**
336 * Optional log filename.
337 */
338 pj_str_t log_filename;
339
340 /**
Benny Prijonodbe3f4b2009-05-07 16:56:04 +0000341 * Additional flags to be given to #pj_file_open() when opening
342 * the log file. By default, the flag is PJ_O_WRONLY. Application
343 * may set PJ_O_APPEND here so that logs are appended to existing
344 * file instead of overwriting it.
345 *
346 * Default is 0.
347 */
348 unsigned log_file_flags;
349
350 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000351 * Optional callback function to be called to write log to
352 * application specific device. This function will be called for
353 * log messages on input verbosity level.
354 */
Benny Prijonofe7d87b2007-11-29 11:35:44 +0000355 void (*cb)(int level, const char *data, int len);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000356
357
358} pjsua_logging_config;
359
360
361/**
362 * Use this function to initialize logging config.
363 *
364 * @param cfg The logging config to be initialized.
365 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000366PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000367
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000368
369/**
370 * Use this function to duplicate logging config.
371 *
372 * @param pool Pool to use.
373 * @param dst Destination config.
374 * @param src Source config.
375 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +0000376PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool,
377 pjsua_logging_config *dst,
378 const pjsua_logging_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000379
Benny Prijonodc39fe82006-05-26 12:17:46 +0000380
381/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000382 * This structure describes application callback to receive various event
383 * notification from PJSUA-API. All of these callbacks are OPTIONAL,
384 * although definitely application would want to implement some of
385 * the important callbacks (such as \a on_incoming_call).
Benny Prijonodc39fe82006-05-26 12:17:46 +0000386 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000387typedef struct pjsua_callback
Benny Prijonodc39fe82006-05-26 12:17:46 +0000388{
389 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000390 * Notify application when invite state has changed.
391 * Application may then query the call info to get the
Benny Prijonoe6ead542007-01-31 20:53:31 +0000392 * detail call states by calling pjsua_call_get_info() function.
Benny Prijono0875ae82006-12-26 00:11:48 +0000393 *
394 * @param call_id The call index.
395 * @param e Event which causes the call state to change.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000396 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000397 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000398
399 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000400 * Notify application on incoming call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000401 *
402 * @param acc_id The account which match the incoming call.
403 * @param call_id The call id that has just been created for
404 * the call.
405 * @param rdata The incoming INVITE request.
Benny Prijono8b1889b2006-06-06 18:40:40 +0000406 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000407 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000408 pjsip_rx_data *rdata);
409
410 /**
Benny Prijonofeb69f42007-10-05 09:12:26 +0000411 * This is a general notification callback which is called whenever
412 * a transaction within the call has changed state. Application can
413 * implement this callback for example to monitor the state of
414 * outgoing requests, or to answer unhandled incoming requests
415 * (such as INFO) with a final response.
416 *
417 * @param call_id Call identification.
418 * @param tsx The transaction which has changed state.
419 * @param e Transaction event that caused the state change.
420 */
421 void (*on_call_tsx_state)(pjsua_call_id call_id,
422 pjsip_transaction *tsx,
423 pjsip_event *e);
424
425 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000426 * Notify application when media state in the call has changed.
427 * Normal application would need to implement this callback, e.g.
Benny Prijono6ba8c542007-10-16 01:34:14 +0000428 * to connect the call's media to sound device. When ICE is used,
429 * this callback will also be called to report ICE negotiation
430 * failure.
Benny Prijono0875ae82006-12-26 00:11:48 +0000431 *
432 * @param call_id The call index.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000433 */
434 void (*on_call_media_state)(pjsua_call_id call_id);
435
Benny Prijonofc13bf62008-02-20 08:56:15 +0000436
437 /**
438 * Notify application when media session is created and before it is
439 * registered to the conference bridge. Application may return different
440 * media port if it has added media processing port to the stream. This
441 * media port then will be added to the conference bridge instead.
442 *
443 * @param call_id Call identification.
444 * @param sess Media session for the call.
445 * @param stream_idx Stream index in the media session.
446 * @param p_port On input, it specifies the media port of the
447 * stream. Application may modify this pointer to
448 * point to different media port to be registered
449 * to the conference bridge.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000450 */
451 void (*on_stream_created)(pjsua_call_id call_id,
452 pjmedia_session *sess,
453 unsigned stream_idx,
454 pjmedia_port **p_port);
455
456 /**
457 * Notify application when media session has been unregistered from the
458 * conference bridge and about to be destroyed.
459 *
460 * @param call_id Call identification.
461 * @param sess Media session for the call.
462 * @param stream_idx Stream index in the media session.
Benny Prijonofc13bf62008-02-20 08:56:15 +0000463 */
464 void (*on_stream_destroyed)(pjsua_call_id call_id,
465 pjmedia_session *sess,
466 unsigned stream_idx);
467
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000468 /**
Benny Prijono0875ae82006-12-26 00:11:48 +0000469 * Notify application upon incoming DTMF digits.
470 *
471 * @param call_id The call index.
472 * @param digit DTMF ASCII digit.
473 */
474 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
475
476 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000477 * Notify application on call being transfered (i.e. REFER is received).
Benny Prijono9fc735d2006-05-28 14:58:12 +0000478 * Application can decide to accept/reject transfer request
Benny Prijonoc54dcb32008-04-08 23:33:15 +0000479 * by setting the code (default is 202). When this callback
Benny Prijono9fc735d2006-05-28 14:58:12 +0000480 * is not defined, the default behavior is to accept the
481 * transfer.
Benny Prijono0875ae82006-12-26 00:11:48 +0000482 *
483 * @param call_id The call index.
484 * @param dst The destination where the call will be
485 * transfered to.
486 * @param code Status code to be returned for the call transfer
487 * request. On input, it contains status code 200.
Benny Prijono9fc735d2006-05-28 14:58:12 +0000488 */
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000489 void (*on_call_transfer_request)(pjsua_call_id call_id,
490 const pj_str_t *dst,
491 pjsip_status_code *code);
492
493 /**
494 * Notify application of the status of previously sent call
495 * transfer request. Application can monitor the status of the
496 * call transfer request, for example to decide whether to
497 * terminate existing call.
498 *
499 * @param call_id Call ID.
Benny Prijonoe6ead542007-01-31 20:53:31 +0000500 * @param st_code Status progress of the transfer request.
501 * @param st_text Status progress text.
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000502 * @param final If non-zero, no further notification will
Benny Prijonoe6ead542007-01-31 20:53:31 +0000503 * be reported. The st_code specified in
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000504 * this callback is the final status.
505 * @param p_cont Initially will be set to non-zero, application
506 * can set this to FALSE if it no longer wants
507 * to receie further notification (for example,
508 * after it hangs up the call).
509 */
510 void (*on_call_transfer_status)(pjsua_call_id call_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +0000511 int st_code,
512 const pj_str_t *st_text,
Benny Prijono4ddad2c2006-10-18 17:16:34 +0000513 pj_bool_t final,
514 pj_bool_t *p_cont);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000515
516 /**
Benny Prijono053f5222006-11-11 16:16:04 +0000517 * Notify application about incoming INVITE with Replaces header.
518 * Application may reject the request by setting non-2xx code.
519 *
520 * @param call_id The call ID to be replaced.
521 * @param rdata The incoming INVITE request to replace the call.
522 * @param st_code Status code to be set by application. Application
523 * should only return a final status (200-699).
524 * @param st_text Optional status text to be set by application.
525 */
526 void (*on_call_replace_request)(pjsua_call_id call_id,
527 pjsip_rx_data *rdata,
528 int *st_code,
529 pj_str_t *st_text);
530
531 /**
532 * Notify application that an existing call has been replaced with
533 * a new call. This happens when PJSUA-API receives incoming INVITE
534 * request with Replaces header.
535 *
536 * After this callback is called, normally PJSUA-API will disconnect
537 * \a old_call_id and establish \a new_call_id.
538 *
539 * @param old_call_id Existing call which to be replaced with the
540 * new call.
541 * @param new_call_id The new call.
542 * @param rdata The incoming INVITE with Replaces request.
543 */
544 void (*on_call_replaced)(pjsua_call_id old_call_id,
545 pjsua_call_id new_call_id);
546
547
548 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000549 * Notify application when registration status has changed.
550 * Application may then query the account info to get the
551 * registration details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000552 *
553 * @param acc_id Account ID.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000554 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000555 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000556
557 /**
Benny Prijono63fba012008-07-17 14:19:10 +0000558 * Notification when incoming SUBSCRIBE request is received. Application
559 * may use this callback to authorize the incoming subscribe request
560 * (e.g. ask user permission if the request should be granted).
561 *
562 * If this callback is not implemented, all incoming presence subscription
563 * requests will be accepted.
564 *
565 * If this callback is implemented, application has several choices on
566 * what to do with the incoming request:
567 * - it may reject the request immediately by specifying non-200 class
568 * final response in the \a code argument.
569 * - it may immediately accept the request by specifying 200 as the
570 * \a code argument. This is the default value if application doesn't
571 * set any value to the \a code argument. In this case, the library
572 * will automatically send NOTIFY request upon returning from this
573 * callback.
574 * - it may delay the processing of the request, for example to request
575 * user permission whether to accept or reject the request. In this
576 * case, the application MUST set the \a code argument to 202, and
577 * later calls #pjsua_pres_notify() to accept or reject the
578 * subscription request.
579 *
580 * Any \a code other than 200 and 202 will be treated as 200.
581 *
582 * Application MUST return from this callback immediately (e.g. it must
583 * not block in this callback while waiting for user confirmation).
584 *
585 * @param srv_pres Server presence subscription instance. If
586 * application delays the acceptance of the request,
587 * it will need to specify this object when calling
588 * #pjsua_pres_notify().
589 * @param acc_id Account ID most appropriate for this request.
590 * @param buddy_id ID of the buddy matching the sender of the
591 * request, if any, or PJSUA_INVALID_ID if no
592 * matching buddy is found.
593 * @param from The From URI of the request.
594 * @param rdata The incoming request.
595 * @param code The status code to respond to the request. The
596 * default value is 200. Application may set this
597 * to other final status code to accept or reject
598 * the request.
599 * @param reason The reason phrase to respond to the request.
600 * @param msg_data If the application wants to send additional
601 * headers in the response, it can put it in this
602 * parameter.
603 */
604 void (*on_incoming_subscribe)(pjsua_acc_id acc_id,
605 pjsua_srv_pres *srv_pres,
606 pjsua_buddy_id buddy_id,
607 const pj_str_t *from,
608 pjsip_rx_data *rdata,
609 pjsip_status_code *code,
610 pj_str_t *reason,
611 pjsua_msg_data *msg_data);
612
613 /**
614 * Notification when server side subscription state has changed.
615 * This callback is optional as application normally does not need
616 * to do anything to maintain server side presence subscription.
617 *
618 * @param acc_id The account ID.
619 * @param srv_pres Server presence subscription object.
620 * @param remote_uri Remote URI string.
621 * @param state New subscription state.
622 * @param event PJSIP event that triggers the state change.
623 */
624 void (*on_srv_subscribe_state)(pjsua_acc_id acc_id,
625 pjsua_srv_pres *srv_pres,
626 const pj_str_t *remote_uri,
627 pjsip_evsub_state state,
628 pjsip_event *event);
629
630 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000631 * Notify application when the buddy state has changed.
632 * Application may then query the buddy into to get the details.
Benny Prijono0875ae82006-12-26 00:11:48 +0000633 *
634 * @param buddy_id The buddy id.
Benny Prijono9fc735d2006-05-28 14:58:12 +0000635 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000636 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000637
638 /**
639 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000640 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000641 * existing call.
Benny Prijono0875ae82006-12-26 00:11:48 +0000642 *
Benny Prijonobbeb3992007-05-21 13:48:35 +0000643 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
644 * passed as one of the argument.
645 *
Benny Prijono0875ae82006-12-26 00:11:48 +0000646 * @param call_id Containts the ID of the call where the IM was
647 * sent, or PJSUA_INVALID_ID if the IM was sent
648 * outside call context.
649 * @param from URI of the sender.
650 * @param to URI of the destination message.
651 * @param contact The Contact URI of the sender, if present.
652 * @param mime_type MIME type of the message.
653 * @param body The message content.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000654 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000655 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
656 const pj_str_t *to, const pj_str_t *contact,
657 const pj_str_t *mime_type, const pj_str_t *body);
658
659 /**
Benny Prijonobbeb3992007-05-21 13:48:35 +0000660 * This is the alternative version of the \a on_pager() callback with
661 * \a pjsip_rx_data argument.
662 *
663 * @param call_id Containts the ID of the call where the IM was
664 * sent, or PJSUA_INVALID_ID if the IM was sent
665 * outside call context.
666 * @param from URI of the sender.
667 * @param to URI of the destination message.
668 * @param contact The Contact URI of the sender, if present.
669 * @param mime_type MIME type of the message.
670 * @param body The message content.
671 * @param rdata The incoming MESSAGE request.
Benny Prijonoba736c42008-07-10 20:45:03 +0000672 * @param acc_id Account ID most suitable for this message.
Benny Prijonobbeb3992007-05-21 13:48:35 +0000673 */
674 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
675 const pj_str_t *to, const pj_str_t *contact,
676 const pj_str_t *mime_type, const pj_str_t *body,
Benny Prijonoba736c42008-07-10 20:45:03 +0000677 pjsip_rx_data *rdata, pjsua_acc_id acc_id);
Benny Prijonobbeb3992007-05-21 13:48:35 +0000678
679 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000680 * Notify application about the delivery status of outgoing pager
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000681 * request. See also on_pager_status2() callback for the version with
682 * \a pjsip_rx_data in the argument list.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000683 *
684 * @param call_id Containts the ID of the call where the IM was
685 * sent, or PJSUA_INVALID_ID if the IM was sent
686 * outside call context.
687 * @param to Destination URI.
688 * @param body Message body.
689 * @param user_data Arbitrary data that was specified when sending
690 * IM message.
691 * @param status Delivery status.
692 * @param reason Delivery status reason.
693 */
694 void (*on_pager_status)(pjsua_call_id call_id,
695 const pj_str_t *to,
696 const pj_str_t *body,
697 void *user_data,
698 pjsip_status_code status,
699 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000700
701 /**
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000702 * Notify application about the delivery status of outgoing pager
703 * request.
704 *
705 * @param call_id Containts the ID of the call where the IM was
706 * sent, or PJSUA_INVALID_ID if the IM was sent
707 * outside call context.
708 * @param to Destination URI.
709 * @param body Message body.
710 * @param user_data Arbitrary data that was specified when sending
711 * IM message.
712 * @param status Delivery status.
713 * @param reason Delivery status reason.
Benny Prijono0a982002007-06-12 16:22:09 +0000714 * @param tdata The original MESSAGE request.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000715 * @param rdata The incoming MESSAGE response, or NULL if the
716 * message transaction fails because of time out
717 * or transport error.
Benny Prijonoba736c42008-07-10 20:45:03 +0000718 * @param acc_id Account ID from this the instant message was
719 * send.
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000720 */
721 void (*on_pager_status2)(pjsua_call_id call_id,
722 const pj_str_t *to,
723 const pj_str_t *body,
724 void *user_data,
725 pjsip_status_code status,
726 const pj_str_t *reason,
Benny Prijono0a982002007-06-12 16:22:09 +0000727 pjsip_tx_data *tdata,
Benny Prijonoba736c42008-07-10 20:45:03 +0000728 pjsip_rx_data *rdata,
729 pjsua_acc_id acc_id);
Benny Prijono4da0b1d2007-06-11 18:22:54 +0000730
731 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000732 * Notify application about typing indication.
Benny Prijono0875ae82006-12-26 00:11:48 +0000733 *
734 * @param call_id Containts the ID of the call where the IM was
735 * sent, or PJSUA_INVALID_ID if the IM was sent
736 * outside call context.
737 * @param from URI of the sender.
738 * @param to URI of the destination message.
739 * @param contact The Contact URI of the sender, if present.
740 * @param is_typing Non-zero if peer is typing, or zero if peer
741 * has stopped typing a message.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000742 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000743 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
744 const pj_str_t *to, const pj_str_t *contact,
745 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000746
Benny Prijono6ba8c542007-10-16 01:34:14 +0000747 /**
Benny Prijonoba736c42008-07-10 20:45:03 +0000748 * Notify application about typing indication.
749 *
750 * @param call_id Containts the ID of the call where the IM was
751 * sent, or PJSUA_INVALID_ID if the IM was sent
752 * outside call context.
753 * @param from URI of the sender.
754 * @param to URI of the destination message.
755 * @param contact The Contact URI of the sender, if present.
756 * @param is_typing Non-zero if peer is typing, or zero if peer
757 * has stopped typing a message.
758 * @param rdata The received request.
759 * @param acc_id Account ID most suitable for this message.
760 */
761 void (*on_typing2)(pjsua_call_id call_id, const pj_str_t *from,
762 const pj_str_t *to, const pj_str_t *contact,
763 pj_bool_t is_typing, pjsip_rx_data *rdata,
764 pjsua_acc_id acc_id);
765
766 /**
Benny Prijono6ba8c542007-10-16 01:34:14 +0000767 * Callback when the library has finished performing NAT type
768 * detection.
769 *
770 * @param res NAT detection result.
771 */
772 void (*on_nat_detect)(const pj_stun_nat_detect_result *res);
773
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000774 /**
775 * This callback is called when the call is about to resend the
776 * INVITE request to the specified target, following the previously
777 * received redirection response.
778 *
779 * Application may accept the redirection to the specified target
780 * (the default behavior if this callback is implemented), reject
781 * this target only and make the session continue to try the next
782 * target in the list if such target exists, stop the whole
783 * redirection process altogether and cause the session to be
784 * disconnected, or defer the decision to ask for user confirmation.
785 *
786 * This callback is optional. If this callback is not implemented,
787 * the default behavior is to NOT follow the redirection response.
788 *
789 * @param call_id The call ID.
790 * @param target The current target to be tried.
Benny Prijono08a48b82008-11-27 12:42:07 +0000791 * @param e The event that caused this callback to be called.
792 * This could be the receipt of 3xx response, or
793 * 4xx/5xx response received for the INVITE sent to
794 * subsequent targets, or NULL if this callback is
795 * called from within #pjsua_call_process_redirect()
796 * context.
797 *
798 * @return Action to be performed for the target. Set this
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000799 * parameter to one of the value below:
800 * - PJSIP_REDIRECT_ACCEPT: immediately accept the
801 * redirection (default value). When set, the
802 * call will immediately resend INVITE request
803 * to the target.
804 * - PJSIP_REDIRECT_REJECT: immediately reject this
805 * target. The call will continue retrying with
806 * next target if present, or disconnect the call
807 * if there is no more target to try.
808 * - PJSIP_REDIRECT_STOP: stop the whole redirection
809 * process and immediately disconnect the call. The
810 * on_call_state() callback will be called with
811 * PJSIP_INV_STATE_DISCONNECTED state immediately
812 * after this callback returns.
813 * - PJSIP_REDIRECT_PENDING: set to this value if
814 * no decision can be made immediately (for example
815 * to request confirmation from user). Application
816 * then MUST call #pjsua_call_process_redirect()
817 * to either accept or reject the redirection upon
818 * getting user decision.
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000819 */
Benny Prijono08a48b82008-11-27 12:42:07 +0000820 pjsip_redirect_op (*on_call_redirected)(pjsua_call_id call_id,
821 const pjsip_uri *target,
822 const pjsip_event *e);
Benny Prijono5e51a4e2008-11-27 00:06:46 +0000823
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000824} pjsua_callback;
825
826
827
Benny Prijonodc39fe82006-05-26 12:17:46 +0000828
829/**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000830 * This structure describes the settings to control the API and
831 * user agent behavior, and can be specified when calling #pjsua_init().
832 * Before setting the values, application must call #pjsua_config_default()
833 * to initialize this structure with the default values.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000834 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000835typedef struct pjsua_config
836{
837
838 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000839 * Maximum calls to support (default: 4). The value specified here
840 * must be smaller than the compile time maximum settings
841 * PJSUA_MAX_CALLS, which by default is 32. To increase this
842 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
843 * value.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000844 */
845 unsigned max_calls;
846
847 /**
848 * Number of worker threads. Normally application will want to have at
849 * least one worker thread, unless when it wants to poll the library
850 * periodically, which in this case the worker thread can be set to
851 * zero.
852 */
853 unsigned thread_cnt;
854
855 /**
Benny Prijonofa9e5b12006-10-08 12:39:34 +0000856 * Number of nameservers. If no name server is configured, the SIP SRV
857 * resolution would be disabled, and domain will be resolved with
858 * standard pj_gethostbyname() function.
859 */
860 unsigned nameserver_count;
861
862 /**
863 * Array of nameservers to be used by the SIP resolver subsystem.
864 * The order of the name server specifies the priority (first name
865 * server will be used first, unless it is not reachable).
866 */
867 pj_str_t nameserver[4];
868
869 /**
Benny Prijono91d06b62008-09-20 12:16:56 +0000870 * Force loose-route to be used in all route/proxy URIs (outbound_proxy
871 * and account's proxy settings). When this setting is enabled, the
872 * library will check all the route/proxy URIs specified in the settings
873 * and append ";lr" parameter to the URI if the parameter is not present.
874 *
875 * Default: 1
876 */
877 pj_bool_t force_lr;
878
879 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000880 * Number of outbound proxies in the \a outbound_proxy array.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000881 */
882 unsigned outbound_proxy_cnt;
883
884 /**
885 * Specify the URL of outbound proxies to visit for all outgoing requests.
886 * The outbound proxies will be used for all accounts, and it will
887 * be used to build the route set for outgoing requests. The final
888 * route set for outgoing requests will consists of the outbound proxies
889 * and the proxy configured in the account.
890 */
891 pj_str_t outbound_proxy[4];
892
Benny Prijonoc97608e2007-03-23 16:34:20 +0000893 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +0000894 * Warning: deprecated, please use \a stun_srv field instead. To maintain
895 * backward compatibility, if \a stun_srv_cnt is zero then the value of
896 * this field will be copied to \a stun_srv field, if present.
897 *
Benny Prijonoebbf6892007-03-24 17:37:25 +0000898 * Specify domain name to be resolved with DNS SRV resolution to get the
Benny Prijonof76e1392008-06-06 14:51:48 +0000899 * address of the STUN server. Alternatively application may specify
900 * \a stun_host instead.
Benny Prijonoebbf6892007-03-24 17:37:25 +0000901 *
902 * If DNS SRV resolution failed for this domain, then DNS A resolution
903 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +0000904 */
Benny Prijonoebbf6892007-03-24 17:37:25 +0000905 pj_str_t stun_domain;
906
907 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +0000908 * Warning: deprecated, please use \a stun_srv field instead. To maintain
909 * backward compatibility, if \a stun_srv_cnt is zero then the value of
910 * this field will be copied to \a stun_srv field, if present.
911 *
Benny Prijonoaf09dc32007-04-22 12:48:30 +0000912 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
913 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +0000914 */
915 pj_str_t stun_host;
916
917 /**
Benny Prijonobb995fd2009-08-12 11:03:23 +0000918 * Number of STUN server entries in \a stun_srv array.
919 */
920 unsigned stun_srv_cnt;
921
922 /**
923 * Array of STUN servers to try. The library will try to resolve and
924 * contact each of the STUN server entry until it finds one that is
925 * usable. Each entry may be a domain name, host name, IP address, and
926 * it may contain an optional port number. For example:
927 * - "pjsip.org" (domain name)
928 * - "sip.pjsip.org" (host name)
929 * - "pjsip.org:33478" (domain name and a non-standard port number)
930 * - "10.0.0.1:3478" (IP address and port number)
931 *
932 * When nameserver is configured in the \a pjsua_config.nameserver field,
933 * if entry is not an IP address, it will be resolved with DNS SRV
934 * resolution first, and it will fallback to use DNS A resolution if this
935 * fails. Port number may be specified even if the entry is a domain name,
936 * in case the DNS SRV resolution should fallback to a non-standard port.
937 *
938 * When nameserver is not configured, entries will be resolved with
939 * #pj_gethostbyname() if it's not an IP address. Port number may be
940 * specified if the server is not listening in standard STUN port.
941 */
942 pj_str_t stun_srv[8];
943
944 /**
945 * This specifies if the library startup should ignore failure with the
946 * STUN servers. If this is set to PJ_FALSE, the library will refuse to
947 * start if it fails to resolve or contact any of the STUN servers.
948 *
949 * Default: PJ_TRUE
950 */
951 pj_bool_t stun_ignore_failure;
952
953 /**
Benny Prijono91a6a172007-10-31 08:59:29 +0000954 * Support for adding and parsing NAT type in the SDP to assist
955 * troubleshooting. The valid values are:
956 * - 0: no information will be added in SDP, and parsing is disabled.
Benny Prijono6ba8c542007-10-16 01:34:14 +0000957 * - 1: only the NAT type number is added.
958 * - 2: add both NAT type number and name.
959 *
Benny Prijono91a6a172007-10-31 08:59:29 +0000960 * Default: 1
Benny Prijono6ba8c542007-10-16 01:34:14 +0000961 */
962 int nat_type_in_sdp;
963
964 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +0000965 * Specify whether support for reliable provisional response (100rel and
966 * PRACK) should be required by default. Note that this setting can be
967 * further customized in account configuration (#pjsua_acc_config).
968 *
969 * Default: PJ_FALSE
970 */
971 pj_bool_t require_100rel;
972
Nanang Izzuddin59dffb12009-08-11 12:42:38 +0000973 /**
974 * Specify whether support for Session Timers should be required by
975 * default. Note that this setting can be further customized in account
976 * configuration (#pjsua_acc_config).
977 *
978 * Default: PJ_FALSE
979 */
980 pj_bool_t require_timer;
981
982 /**
Nanang Izzuddin65add622009-08-11 16:26:20 +0000983 * Specify Session Timer settings, see #pjsip_timer_setting.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +0000984 * Note that this setting can be further customized in account
985 * configuration (#pjsua_acc_config).
Nanang Izzuddin59dffb12009-08-11 12:42:38 +0000986 */
Nanang Izzuddin65add622009-08-11 16:26:20 +0000987 pjsip_timer_setting timer_setting;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +0000988
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000989 /**
990 * Number of credentials in the credential array.
991 */
992 unsigned cred_count;
993
994 /**
995 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +0000996 * and can be used to authenticate against outbound proxies. If the
997 * credential is specific to the account, then application should set
998 * the credential in the pjsua_acc_config rather than the credential
999 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001000 */
1001 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1002
1003 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001004 * Application callback to receive various event notifications from
1005 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001006 */
1007 pjsua_callback cb;
1008
Benny Prijono56315612006-07-18 14:39:40 +00001009 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001010 * Optional user agent string (default empty). If it's empty, no
1011 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +00001012 */
1013 pj_str_t user_agent;
1014
Benny Prijonod8179652008-01-23 20:39:07 +00001015#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
1016 /**
1017 * Specify default value of secure media transport usage.
1018 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
1019 * PJMEDIA_SRTP_MANDATORY.
1020 *
1021 * Note that this setting can be further customized in account
1022 * configuration (#pjsua_acc_config).
1023 *
1024 * Default: #PJSUA_DEFAULT_USE_SRTP
1025 */
1026 pjmedia_srtp_use use_srtp;
1027
1028 /**
1029 * Specify whether SRTP requires secure signaling to be used. This option
1030 * is only used when \a use_srtp option above is non-zero.
1031 *
1032 * Valid values are:
1033 * 0: SRTP does not require secure signaling
1034 * 1: SRTP requires secure transport such as TLS
1035 * 2: SRTP requires secure end-to-end transport (SIPS)
1036 *
1037 * Note that this setting can be further customized in account
1038 * configuration (#pjsua_acc_config).
1039 *
1040 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
1041 */
1042 int srtp_secure_signaling;
1043#endif
1044
Benny Prijono3c5e28b2008-09-24 10:10:15 +00001045 /**
1046 * Disconnect other call legs when more than one 2xx responses for
1047 * outgoing INVITE are received due to forking. Currently the library
1048 * is not able to handle simultaneous forked media, so disconnecting
1049 * the other call legs is necessary.
1050 *
1051 * With this setting enabled, the library will handle only one of the
1052 * connected call leg, and the other connected call legs will be
1053 * disconnected.
1054 *
1055 * Default: PJ_TRUE (only disable this setting for testing purposes).
1056 */
1057 pj_bool_t hangup_forked_call;
1058
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001059} pjsua_config;
1060
1061
1062/**
1063 * Use this function to initialize pjsua config.
1064 *
1065 * @param cfg pjsua config to be initialized.
1066 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001067PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001068
1069
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001070/** The implementation has been moved to sip_auth.h */
Benny Prijono7977f9f2007-10-10 11:37:56 +00001071#define pjsip_cred_dup pjsip_cred_info_dup
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001072
1073
1074/**
1075 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001076 *
1077 * @param pool The pool to get memory from.
1078 * @param dst Destination config.
1079 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001080 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001081PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1082 pjsua_config *dst,
1083 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001084
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001085
1086/**
1087 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001088 * outgoing SIP message. It can (optionally) be specified for example
1089 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1090 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1091 *
1092 * Application MUST call #pjsua_msg_data_init() to initialize this
1093 * structure before setting its values.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001094 */
Benny Prijono63fba012008-07-17 14:19:10 +00001095struct pjsua_msg_data
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001096{
1097 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001098 * Additional message headers as linked list. Application can add
1099 * headers to the list by creating the header, either from the heap/pool
1100 * or from temporary local variable, and add the header using
1101 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001102 */
1103 pjsip_hdr hdr_list;
1104
1105 /**
1106 * MIME type of optional message body.
1107 */
1108 pj_str_t content_type;
1109
1110 /**
1111 * Optional message body.
1112 */
1113 pj_str_t msg_body;
1114
Benny Prijono63fba012008-07-17 14:19:10 +00001115};
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001116
1117
1118/**
1119 * Initialize message data.
1120 *
1121 * @param msg_data Message data to be initialized.
1122 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001123PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001124
Benny Prijono268ca612006-02-07 12:34:11 +00001125
1126/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001127 * Instantiate pjsua application. Application must call this function before
1128 * calling any other functions, to make sure that the underlying libraries
1129 * are properly initialized. Once this function has returned success,
1130 * application must call pjsua_destroy() before quitting.
1131 *
1132 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00001133 */
1134PJ_DECL(pj_status_t) pjsua_create(void);
1135
1136
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001137/** Forward declaration */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001138typedef struct pjsua_media_config pjsua_media_config;
1139
1140
Benny Prijonodc39fe82006-05-26 12:17:46 +00001141/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001142 * Initialize pjsua with the specified settings. All the settings are
1143 * optional, and the default values will be used when the config is not
1144 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001145 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001146 * Note that #pjsua_create() MUST be called before calling this function.
1147 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001148 * @param ua_cfg User agent configuration.
1149 * @param log_cfg Optional logging configuration.
1150 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001151 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001152 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001153 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001154PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1155 const pjsua_logging_config *log_cfg,
1156 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001157
1158
1159/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001160 * Application is recommended to call this function after all initialization
1161 * is done, so that the library can do additional checking set up
1162 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001163 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001164 * Application may call this function anytime after #pjsua_init().
1165 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001166 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoccf95622006-02-07 18:48:01 +00001167 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001168PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001169
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001170
Benny Prijonoccf95622006-02-07 18:48:01 +00001171/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001172 * Destroy pjsua. Application is recommended to perform graceful shutdown
1173 * before calling this function (such as unregister the account from the SIP
1174 * server, terminate presense subscription, and hangup active calls), however,
1175 * this function will do all of these if it finds there are active sessions
1176 * that need to be terminated. This function will approximately block for
1177 * one second to wait for replies from remote.
1178 *
1179 * Application.may safely call this function more than once if it doesn't
1180 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001181 *
1182 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001183 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001184PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001185
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001186
Benny Prijono9fc735d2006-05-28 14:58:12 +00001187/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001188 * Poll pjsua for events, and if necessary block the caller thread for
1189 * the specified maximum interval (in miliseconds).
1190 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001191 * Application doesn't normally need to call this function if it has
1192 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1193 * because polling then will be done by these worker threads instead.
1194 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001195 * @param msec_timeout Maximum time to wait, in miliseconds.
1196 *
1197 * @return The number of events that have been handled during the
1198 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001199 * can retrieve the error as (status = -return_value).
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001200 */
1201PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1202
1203
1204/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001205 * Create memory pool to be used by the application. Once application
1206 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001207 *
1208 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001209 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001210 * @param increment Increment size.
1211 *
1212 * @return The pool, or NULL when there's no memory.
1213 */
1214PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1215 pj_size_t increment);
1216
1217
1218/**
1219 * Application can call this function at any time (after pjsua_create(), of
1220 * course) to change logging settings.
1221 *
1222 * @param c Logging configuration.
1223 *
1224 * @return PJ_SUCCESS on success, or the appropriate error code.
1225 */
1226PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1227
1228
1229/**
1230 * Internal function to get SIP endpoint instance of pjsua, which is
1231 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001232 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001233 *
1234 * @return SIP endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001235 */
1236PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1237
1238/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001239 * Internal function to get media endpoint instance.
1240 * Only valid after #pjsua_init() is called.
1241 *
1242 * @return Media endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001243 */
1244PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1245
Benny Prijono97b87172006-08-24 14:25:14 +00001246/**
1247 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001248 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001249 *
1250 * @return Pool factory currently used by PJSUA.
1251 */
1252PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1253
1254
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001255
1256/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001257 * Utilities.
1258 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001259 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001260
1261/**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001262 * This structure is used to represent the result of the STUN server
1263 * resolution and testing, the #pjsua_resolve_stun_servers() function.
1264 * This structure will be passed in #pj_stun_resolve_cb callback.
1265 */
1266typedef struct pj_stun_resolve_result
1267{
1268 /**
1269 * Arbitrary data that was passed to #pjsua_resolve_stun_servers()
1270 * function.
1271 */
1272 void *token;
1273
1274 /**
1275 * This will contain PJ_SUCCESS if at least one usable STUN server
1276 * is found, otherwise it will contain the last error code during
1277 * the operation.
1278 */
1279 pj_status_t status;
1280
1281 /**
1282 * The server name that yields successful result. This will only
1283 * contain value if status is successful.
1284 */
1285 pj_str_t name;
1286
1287 /**
1288 * The server IP address. This will only contain value if status
1289 * is successful.
1290 */
1291 pj_sockaddr addr;
1292
1293} pj_stun_resolve_result;
1294
1295
1296/**
1297 * Typedef of callback to be registered to #pjsua_resolve_stun_servers().
1298 */
1299typedef void (*pj_stun_resolve_cb)(const pj_stun_resolve_result *result);
1300
1301/**
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001302 * This is a utility function to detect NAT type in front of this
1303 * endpoint. Once invoked successfully, this function will complete
Benny Prijono6ba8c542007-10-16 01:34:14 +00001304 * asynchronously and report the result in \a on_nat_detect() callback
1305 * of pjsua_callback.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001306 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001307 * After NAT has been detected and the callback is called, application can
1308 * get the detected NAT type by calling #pjsua_get_nat_type(). Application
1309 * can also perform NAT detection by calling #pjsua_detect_nat_type()
1310 * again at later time.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001311 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001312 * Note that STUN must be enabled to run this function successfully.
1313 *
1314 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001315 */
Benny Prijono6ba8c542007-10-16 01:34:14 +00001316PJ_DECL(pj_status_t) pjsua_detect_nat_type(void);
1317
1318
1319/**
1320 * Get the NAT type as detected by #pjsua_detect_nat_type() function.
1321 * This function will only return useful NAT type after #pjsua_detect_nat_type()
1322 * has completed successfully and \a on_nat_detect() callback has been called.
1323 *
1324 * @param type NAT type.
1325 *
1326 * @return When detection is in progress, this function will
1327 * return PJ_EPENDING and \a type will be set to
1328 * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been
1329 * detected successfully, this function will return
1330 * PJ_SUCCESS and \a type will be set to the correct
1331 * value. Other return values indicate error and
1332 * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN.
Benny Prijono91a6a172007-10-31 08:59:29 +00001333 *
1334 * @see pjsua_call_get_rem_nat_type()
Benny Prijono6ba8c542007-10-16 01:34:14 +00001335 */
1336PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type);
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001337
1338
1339/**
Benny Prijonobb995fd2009-08-12 11:03:23 +00001340 * Auxiliary function to resolve and contact each of the STUN server
1341 * entries (sequentially) to find which is usable. The #pjsua_init() must
1342 * have been called before calling this function.
1343 *
1344 * @param count Number of STUN server entries to try.
1345 * @param srv Array of STUN server entries to try. Please see
1346 * the \a stun_srv field in the #pjsua_config
1347 * documentation about the format of this entry.
1348 * @param wait Specify non-zero to make the function block until
1349 * it gets the result. In this case, the function
1350 * will block while the resolution is being done,
1351 * and the callback will be called before this function
1352 * returns.
1353 * @param token Arbitrary token to be passed back to application
1354 * in the callback.
1355 * @param cb Callback to be called to notify the result of
1356 * the function.
1357 *
1358 * @return If \a wait parameter is non-zero, this will return
1359 * PJ_SUCCESS if one usable STUN server is found.
1360 * Otherwise it will always return PJ_SUCCESS, and
1361 * application will be notified about the result in
1362 * the callback.
1363 */
1364PJ_DECL(pj_status_t) pjsua_resolve_stun_servers(unsigned count,
1365 pj_str_t srv[],
1366 pj_bool_t wait,
1367 void *token,
1368 pj_stun_resolve_cb cb);
1369
1370/**
1371 * Cancel pending STUN resolution which match the specified token.
1372 *
1373 * @param token The token to match. This token was given to
1374 * #pjsua_resolve_stun_servers()
1375 * @param notify_cb Boolean to control whether the callback should
1376 * be called for cancelled resolutions. When the
1377 * callback is called, the status in the result
1378 * will be set as PJ_ECANCELLED.
1379 *
1380 * @return PJ_SUCCESS if there is at least one pending STUN
1381 * resolution cancelled, or PJ_ENOTFOUND if there is
1382 * no matching one, or other error.
1383 */
1384PJ_DECL(pj_status_t) pjsua_cancel_stun_resolution(void *token,
1385 pj_bool_t notify_cb);
1386
1387
1388/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001389 * This is a utility function to verify that valid SIP url is given. If the
1390 * URL is valid, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001391 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001392 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001393 *
1394 * @return PJ_SUCCESS on success, or the appropriate error code.
1395 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001396PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001397
1398
1399/**
Benny Prijono73bb7232009-10-20 13:56:26 +00001400 * Schedule a timer entry. Note that the timer callback may be executed
1401 * by different thread, depending on whether worker thread is enabled or
1402 * not.
1403 *
1404 * @param entry Timer heap entry.
1405 * @param delay The interval to expire.
1406 *
1407 * @return PJ_SUCCESS on success, or the appropriate error code.
1408 *
1409 * @see pjsip_endpt_schedule_timer()
1410 */
1411PJ_DECL(pj_status_t) pjsua_schedule_timer(pj_timer_entry *entry,
1412 const pj_time_val *delay);
1413
1414
1415/**
1416 * Cancel the previously scheduled timer.
1417 *
1418 * @param entry Timer heap entry.
1419 *
1420 * @see pjsip_endpt_cancel_timer()
1421 */
1422PJ_DECL(void) pjsua_cancel_timer(pj_timer_entry *entry);
1423
1424
1425/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001426 * This is a utility function to display error message for the specified
1427 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001428 *
1429 * @param sender The log sender field.
1430 * @param title Message title for the error.
1431 * @param status Status code.
1432 */
1433PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1434 pj_status_t status);
1435
1436
Benny Prijonoda9785b2007-04-02 20:43:06 +00001437/**
1438 * This is a utility function to dump the stack states to log, using
1439 * verbosity level 3.
1440 *
1441 * @param detail Will print detailed output (such as list of
1442 * SIP transactions) when non-zero.
1443 */
1444PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001445
1446/**
1447 * @}
1448 */
1449
1450
1451
1452/*****************************************************************************
1453 * TRANSPORT API
1454 */
1455
1456/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001457 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001458 * @ingroup PJSUA_LIB
1459 * @brief API for managing SIP transports
1460 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001461 *
1462 * PJSUA-API supports creating multiple transport instances, for example UDP,
1463 * TCP, and TLS transport. SIP transport must be created before adding an
1464 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001465 */
1466
1467
Benny Prijonoe6ead542007-01-31 20:53:31 +00001468/** SIP transport identification.
1469 */
Benny Prijono312aff92006-06-17 04:08:30 +00001470typedef int pjsua_transport_id;
1471
1472
1473/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001474 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001475 * and media. Before setting some values to this structure, application
1476 * MUST call #pjsua_transport_config_default() to initialize its
1477 * values with default settings.
Benny Prijono312aff92006-06-17 04:08:30 +00001478 */
1479typedef struct pjsua_transport_config
1480{
1481 /**
1482 * UDP port number to bind locally. This setting MUST be specified
1483 * even when default port is desired. If the value is zero, the
1484 * transport will be bound to any available port, and application
1485 * can query the port by querying the transport info.
1486 */
1487 unsigned port;
1488
1489 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001490 * Optional address to advertise as the address of this transport.
1491 * Application can specify any address or hostname for this field,
1492 * for example it can point to one of the interface address in the
1493 * system, or it can point to the public address of a NAT router
1494 * where port mappings have been configured for the application.
1495 *
1496 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001497 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001498 pj_str_t public_addr;
1499
1500 /**
1501 * Optional address where the socket should be bound to. This option
1502 * SHOULD only be used to selectively bind the socket to particular
1503 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1504 * published address of a transport (the public_addr field should be
1505 * used for that purpose).
1506 *
1507 * Note that unlike public_addr field, the address (or hostname) here
1508 * MUST correspond to the actual interface address in the host, since
1509 * this address will be specified as bind() argument.
1510 */
1511 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001512
1513 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001514 * This specifies TLS settings for TLS transport. It is only be used
1515 * when this transport config is being used to create a SIP TLS
1516 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001517 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001518 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001519
Benny Prijono312aff92006-06-17 04:08:30 +00001520} pjsua_transport_config;
1521
1522
1523/**
1524 * Call this function to initialize UDP config with default values.
1525 *
1526 * @param cfg The UDP config to be initialized.
1527 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001528PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001529
1530
1531/**
Benny Prijono312aff92006-06-17 04:08:30 +00001532 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001533 *
1534 * @param pool The pool.
1535 * @param dst The destination config.
1536 * @param src The source config.
Benny Prijono312aff92006-06-17 04:08:30 +00001537 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001538PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1539 pjsua_transport_config *dst,
1540 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001541
1542
1543/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001544 * This structure describes transport information returned by
1545 * #pjsua_transport_get_info() function.
Benny Prijono312aff92006-06-17 04:08:30 +00001546 */
1547typedef struct pjsua_transport_info
1548{
1549 /**
1550 * PJSUA transport identification.
1551 */
1552 pjsua_transport_id id;
1553
1554 /**
1555 * Transport type.
1556 */
1557 pjsip_transport_type_e type;
1558
1559 /**
1560 * Transport type name.
1561 */
1562 pj_str_t type_name;
1563
1564 /**
1565 * Transport string info/description.
1566 */
1567 pj_str_t info;
1568
1569 /**
1570 * Transport flag (see ##pjsip_transport_flags_e).
1571 */
1572 unsigned flag;
1573
1574 /**
1575 * Local address length.
1576 */
1577 unsigned addr_len;
1578
1579 /**
1580 * Local/bound address.
1581 */
1582 pj_sockaddr local_addr;
1583
1584 /**
1585 * Published address (or transport address name).
1586 */
1587 pjsip_host_port local_name;
1588
1589 /**
1590 * Current number of objects currently referencing this transport.
1591 */
1592 unsigned usage_count;
1593
1594
1595} pjsua_transport_info;
1596
1597
1598/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001599 * Create and start a new SIP transport according to the specified
1600 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001601 *
1602 * @param type Transport type.
1603 * @param cfg Transport configuration.
1604 * @param p_id Optional pointer to receive transport ID.
1605 *
1606 * @return PJ_SUCCESS on success, or the appropriate error code.
1607 */
1608PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1609 const pjsua_transport_config *cfg,
1610 pjsua_transport_id *p_id);
1611
1612/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001613 * Register transport that has been created by application. This function
1614 * is useful if application wants to implement custom SIP transport and use
1615 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001616 *
1617 * @param tp Transport instance.
1618 * @param p_id Optional pointer to receive transport ID.
1619 *
1620 * @return PJ_SUCCESS on success, or the appropriate error code.
1621 */
1622PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1623 pjsua_transport_id *p_id);
1624
1625
1626/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001627 * Enumerate all transports currently created in the system. This function
1628 * will return all transport IDs, and application may then call
1629 * #pjsua_transport_get_info() function to retrieve detailed information
1630 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001631 *
1632 * @param id Array to receive transport ids.
1633 * @param count In input, specifies the maximum number of elements.
1634 * On return, it contains the actual number of elements.
1635 *
1636 * @return PJ_SUCCESS on success, or the appropriate error code.
1637 */
1638PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1639 unsigned *count );
1640
1641
1642/**
1643 * Get information about transports.
1644 *
1645 * @param id Transport ID.
1646 * @param info Pointer to receive transport info.
1647 *
1648 * @return PJ_SUCCESS on success, or the appropriate error code.
1649 */
1650PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1651 pjsua_transport_info *info);
1652
1653
1654/**
1655 * Disable a transport or re-enable it. By default transport is always
1656 * enabled after it is created. Disabling a transport does not necessarily
1657 * close the socket, it will only discard incoming messages and prevent
1658 * the transport from being used to send outgoing messages.
1659 *
1660 * @param id Transport ID.
1661 * @param enabled Non-zero to enable, zero to disable.
1662 *
1663 * @return PJ_SUCCESS on success, or the appropriate error code.
1664 */
1665PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1666 pj_bool_t enabled);
1667
1668
1669/**
1670 * Close the transport. If transport is forcefully closed, it will be
1671 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00001672 * transport may not terminate properly (it may even crash). Otherwise,
1673 * the system will wait until all transactions are closed while preventing
1674 * new users from using the transport, and will close the transport when
1675 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001676 *
1677 * @param id Transport ID.
1678 * @param force Non-zero to immediately close the transport. This
1679 * is not recommended!
1680 *
1681 * @return PJ_SUCCESS on success, or the appropriate error code.
1682 */
1683PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1684 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001685
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001686/**
Benny Prijono312aff92006-06-17 04:08:30 +00001687 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001688 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001689
1690
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001691
1692
1693/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001694 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001695 */
1696
Benny Prijono312aff92006-06-17 04:08:30 +00001697
1698/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001699 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001700 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001701 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001702 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001703 *
Benny Prijono312aff92006-06-17 04:08:30 +00001704 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001705 * using the application. In SIP terms, the identity is used as the <b>From</b>
1706 * header in outgoing requests.
1707 *
1708 * PJSUA-API supports creating and managing multiple accounts. The maximum
1709 * number of accounts is limited by a compile time constant
1710 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001711 *
1712 * Account may or may not have client registration associated with it.
1713 * An account is also associated with <b>route set</b> and some <b>authentication
1714 * credentials</b>, which are used when sending SIP request messages using the
1715 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00001716 * will be reported to remote peer when they subscribe to the account's
1717 * presence, or which is published to a presence server if presence
1718 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00001719 *
1720 * At least one account MUST be created in the application. If no user
1721 * association is required, application can create a userless account by
1722 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00001723 * instead of a particular user, and it correspond with a particular
1724 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00001725 *
1726 * Also one account must be set as the <b>default account</b>, which is used as
1727 * the account to use when PJSUA fails to match a request with any other
1728 * accounts.
1729 *
1730 * When sending outgoing SIP requests (such as making calls or sending
1731 * instant messages), normally PJSUA requires the application to specify
1732 * which account to use for the request. If no account is specified,
1733 * PJSUA may be able to select the account by matching the destination
1734 * domain name, and fall back to default account when no match is found.
1735 */
1736
1737/**
1738 * Maximum accounts.
1739 */
1740#ifndef PJSUA_MAX_ACC
1741# define PJSUA_MAX_ACC 8
1742#endif
1743
1744
1745/**
1746 * Default registration interval.
1747 */
1748#ifndef PJSUA_REG_INTERVAL
Benny Prijonobddef2c2007-10-31 13:28:08 +00001749# define PJSUA_REG_INTERVAL 300
Benny Prijono312aff92006-06-17 04:08:30 +00001750#endif
1751
1752
1753/**
Benny Prijono384dab42009-10-14 01:58:04 +00001754 * Default maximum time to wait for account unregistration transactions to
1755 * complete during library shutdown sequence.
1756 *
1757 * Default: 4000 (4 seconds)
1758 */
1759#ifndef PJSUA_UNREG_TIMEOUT
1760# define PJSUA_UNREG_TIMEOUT 4000
1761#endif
1762
1763
1764/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001765 * Default PUBLISH expiration
1766 */
1767#ifndef PJSUA_PUBLISH_EXPIRATION
Benny Prijono53984d12009-04-28 22:19:49 +00001768# define PJSUA_PUBLISH_EXPIRATION PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001769#endif
1770
1771
1772/**
Benny Prijono093d3022006-09-24 00:07:11 +00001773 * Default account priority.
1774 */
1775#ifndef PJSUA_DEFAULT_ACC_PRIORITY
1776# define PJSUA_DEFAULT_ACC_PRIORITY 0
1777#endif
1778
1779
1780/**
Benny Prijono8058a622007-06-08 04:37:05 +00001781 * This macro specifies the URI scheme to use in Contact header
1782 * when secure transport such as TLS is used. Application can specify
1783 * either "sip" or "sips".
1784 */
1785#ifndef PJSUA_SECURE_SCHEME
Benny Prijono4c82c1e2008-10-16 08:14:51 +00001786# define PJSUA_SECURE_SCHEME "sip"
Benny Prijono8058a622007-06-08 04:37:05 +00001787#endif
1788
1789
1790/**
Benny Prijono534a9ba2009-10-13 14:01:59 +00001791 * Maximum time to wait for unpublication transaction(s) to complete
1792 * during shutdown process, before sending unregistration. The library
1793 * tries to wait for the unpublication (un-PUBLISH) to complete before
1794 * sending REGISTER request to unregister the account, during library
1795 * shutdown process. If the value is set too short, it is possible that
1796 * the unregistration is sent before unpublication completes, causing
1797 * unpublication request to fail.
1798 *
1799 * Default: 2000 (2 seconds)
1800 */
1801#ifndef PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
1802# define PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC 2000
1803#endif
1804
1805
1806/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001807 * This structure describes account configuration to be specified when
1808 * adding a new account with #pjsua_acc_add(). Application MUST initialize
1809 * this structure first by calling #pjsua_acc_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00001810 */
1811typedef struct pjsua_acc_config
1812{
Benny Prijono093d3022006-09-24 00:07:11 +00001813 /**
Benny Prijono705e7842008-07-21 18:12:51 +00001814 * Arbitrary user data to be associated with the newly created account.
1815 * Application may set this later with #pjsua_acc_set_user_data() and
1816 * retrieve it with #pjsua_acc_get_user_data().
1817 */
1818 void *user_data;
1819
1820 /**
Benny Prijono093d3022006-09-24 00:07:11 +00001821 * Account priority, which is used to control the order of matching
1822 * incoming/outgoing requests. The higher the number means the higher
1823 * the priority is, and the account will be matched first.
1824 */
1825 int priority;
1826
Benny Prijono312aff92006-06-17 04:08:30 +00001827 /**
1828 * The full SIP URL for the account. The value can take name address or
1829 * URL format, and will look something like "sip:account@serviceprovider".
1830 *
1831 * This field is mandatory.
1832 */
1833 pj_str_t id;
1834
1835 /**
1836 * This is the URL to be put in the request URI for the registration,
1837 * and will look something like "sip:serviceprovider".
1838 *
1839 * This field should be specified if registration is desired. If the
1840 * value is empty, no account registration will be performed.
1841 */
1842 pj_str_t reg_uri;
1843
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001844 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001845 * If this flag is set, the presence information of this account will
1846 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono48ab2b72007-11-08 09:24:30 +00001847 *
1848 * Default: PJ_FALSE
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001849 */
1850 pj_bool_t publish_enabled;
1851
Benny Prijonofe04fb52007-08-24 08:28:52 +00001852 /**
Benny Prijonofe50c9e2009-10-12 07:44:14 +00001853 * Event publication options.
1854 */
1855 pjsip_publishc_opt publish_opt;
1856
1857 /**
Benny Prijono534a9ba2009-10-13 14:01:59 +00001858 * Maximum time to wait for unpublication transaction(s) to complete
1859 * during shutdown process, before sending unregistration. The library
1860 * tries to wait for the unpublication (un-PUBLISH) to complete before
1861 * sending REGISTER request to unregister the account, during library
1862 * shutdown process. If the value is set too short, it is possible that
1863 * the unregistration is sent before unpublication completes, causing
1864 * unpublication request to fail.
1865 *
1866 * Default: PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
1867 */
1868 unsigned unpublish_max_wait_time_msec;
1869
1870 /**
Benny Prijono48ab2b72007-11-08 09:24:30 +00001871 * Authentication preference.
1872 */
1873 pjsip_auth_clt_pref auth_pref;
1874
1875 /**
Benny Prijonofe04fb52007-08-24 08:28:52 +00001876 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
1877 * is not specified, a random string will be used.
1878 */
1879 pj_str_t pidf_tuple_id;
1880
Benny Prijono312aff92006-06-17 04:08:30 +00001881 /**
1882 * Optional URI to be put as Contact for this account. It is recommended
1883 * that this field is left empty, so that the value will be calculated
1884 * automatically based on the transport address.
1885 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00001886 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00001887
1888 /**
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00001889 * Additional parameters that will be appended in the Contact header
Benny Prijono30fe4852008-12-10 16:54:16 +00001890 * for this account. This will affect the Contact header in all SIP
1891 * messages sent on behalf of this account, including but not limited to
1892 * REGISTER, INVITE, and SUBCRIBE requests or responses.
1893 *
1894 * The parameters should be preceeded by semicolon, and all strings must
1895 * be properly escaped. Example:
1896 * ";my-param=X;another-param=Hi%20there"
1897 */
1898 pj_str_t contact_params;
1899
1900 /**
Nanang Izzuddine2c7e852009-08-04 14:36:17 +00001901 * Additional URI parameters that will be appended in the Contact URI
1902 * for this account. This will affect the Contact URI in all SIP
1903 * messages sent on behalf of this account, including but not limited to
1904 * REGISTER, INVITE, and SUBCRIBE requests or responses.
1905 *
1906 * The parameters should be preceeded by semicolon, and all strings must
1907 * be properly escaped. Example:
1908 * ";my-param=X;another-param=Hi%20there"
1909 */
1910 pj_str_t contact_uri_params;
1911
1912 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001913 * Specify whether support for reliable provisional response (100rel and
1914 * PRACK) should be required for all sessions of this account.
1915 *
1916 * Default: PJ_FALSE
1917 */
1918 pj_bool_t require_100rel;
1919
1920 /**
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001921 * Specify whether support for Session Timers should be required for all
1922 * sessions of this account.
1923 *
1924 * Default: PJ_FALSE
1925 */
1926 pj_bool_t require_timer;
1927
1928 /**
Nanang Izzuddin65add622009-08-11 16:26:20 +00001929 * Specify Session Timer settings, see #pjsip_timer_setting.
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001930 */
Nanang Izzuddin65add622009-08-11 16:26:20 +00001931 pjsip_timer_setting timer_setting;
Nanang Izzuddin59dffb12009-08-11 12:42:38 +00001932
1933 /**
Benny Prijono312aff92006-06-17 04:08:30 +00001934 * Number of proxies in the proxy array below.
1935 */
1936 unsigned proxy_cnt;
1937
1938 /**
1939 * Optional URI of the proxies to be visited for all outgoing requests
1940 * that are using this account (REGISTER, INVITE, etc). Application need
1941 * to specify these proxies if the service provider requires that requests
1942 * destined towards its network should go through certain proxies first
1943 * (for example, border controllers).
1944 *
1945 * These proxies will be put in the route set for this account, with
1946 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00001947 * first). If global outbound proxies are configured in pjsua_config,
1948 * then these account proxies will be placed after the global outbound
1949 * proxies in the routeset.
Benny Prijono312aff92006-06-17 04:08:30 +00001950 */
1951 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
1952
1953 /**
1954 * Optional interval for registration, in seconds. If the value is zero,
Benny Prijonobddef2c2007-10-31 13:28:08 +00001955 * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
Benny Prijono312aff92006-06-17 04:08:30 +00001956 */
1957 unsigned reg_timeout;
1958
Benny Prijono384dab42009-10-14 01:58:04 +00001959 /**
1960 * Specify the maximum time to wait for unregistration requests to
1961 * complete during library shutdown sequence.
1962 *
1963 * Default: PJSUA_UNREG_TIMEOUT
1964 */
1965 unsigned unreg_timeout;
1966
Benny Prijono312aff92006-06-17 04:08:30 +00001967 /**
1968 * Number of credentials in the credential array.
1969 */
1970 unsigned cred_count;
1971
1972 /**
1973 * Array of credentials. If registration is desired, normally there should
1974 * be at least one credential specified, to successfully authenticate
1975 * against the service provider. More credentials can be specified, for
1976 * example when the requests are expected to be challenged by the
1977 * proxies in the route set.
1978 */
1979 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1980
Benny Prijono62c5c5b2007-01-13 23:22:40 +00001981 /**
1982 * Optionally bind this account to specific transport. This normally is
1983 * not a good idea, as account should be able to send requests using
1984 * any available transports according to the destination. But some
1985 * application may want to have explicit control over the transport to
1986 * use, so in that case it can set this field.
1987 *
1988 * Default: -1 (PJSUA_INVALID_ID)
1989 *
1990 * @see pjsua_acc_set_transport()
1991 */
1992 pjsua_transport_id transport_id;
1993
Benny Prijono15b02302007-09-27 14:07:07 +00001994 /**
Benny Prijonoe8554ef2008-03-22 09:33:52 +00001995 * This option is used to update the UDP transport address and the Contact
1996 * header of REGISTER request. When this option is enabled, the library
1997 * will keep track of the public IP address from the response of REGISTER
1998 * request. Once it detects that the address has changed, it will
1999 * unregister current Contact, update the Contact with transport address
2000 * learned from Via header, and register a new Contact to the registrar.
2001 * This will also update the public name of UDP transport if STUN is
2002 * configured.
Benny Prijono15b02302007-09-27 14:07:07 +00002003 *
2004 * Default: 1 (yes)
2005 */
Benny Prijonoe8554ef2008-03-22 09:33:52 +00002006 pj_bool_t allow_contact_rewrite;
Benny Prijono15b02302007-09-27 14:07:07 +00002007
Benny Prijonobddef2c2007-10-31 13:28:08 +00002008 /**
2009 * Set the interval for periodic keep-alive transmission for this account.
2010 * If this value is zero, keep-alive will be disabled for this account.
2011 * The keep-alive transmission will be sent to the registrar's address,
2012 * after successful registration.
2013 *
Benny Prijonobddef2c2007-10-31 13:28:08 +00002014 * Default: 15 (seconds)
2015 */
2016 unsigned ka_interval;
2017
2018 /**
2019 * Specify the data to be transmitted as keep-alive packets.
2020 *
2021 * Default: CR-LF
2022 */
2023 pj_str_t ka_data;
2024
Benny Prijonod8179652008-01-23 20:39:07 +00002025#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
2026 /**
2027 * Specify whether secure media transport should be used for this account.
2028 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
2029 * PJMEDIA_SRTP_MANDATORY.
2030 *
2031 * Default: #PJSUA_DEFAULT_USE_SRTP
2032 */
2033 pjmedia_srtp_use use_srtp;
2034
2035 /**
2036 * Specify whether SRTP requires secure signaling to be used. This option
2037 * is only used when \a use_srtp option above is non-zero.
2038 *
2039 * Valid values are:
2040 * 0: SRTP does not require secure signaling
2041 * 1: SRTP requires secure transport such as TLS
2042 * 2: SRTP requires secure end-to-end transport (SIPS)
2043 *
2044 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
2045 */
2046 int srtp_secure_signaling;
2047#endif
2048
Benny Prijono312aff92006-06-17 04:08:30 +00002049} pjsua_acc_config;
2050
2051
2052/**
2053 * Call this function to initialize account config with default values.
2054 *
2055 * @param cfg The account config to be initialized.
2056 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00002057PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002058
2059
2060/**
Benny Prijonobddef2c2007-10-31 13:28:08 +00002061 * Duplicate account config.
2062 *
2063 * @param pool Pool to be used for duplicating the config.
2064 * @param dst Destination configuration.
2065 * @param src Source configuration.
2066 */
2067PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
2068 pjsua_acc_config *dst,
2069 const pjsua_acc_config *src);
2070
2071
2072/**
Benny Prijono312aff92006-06-17 04:08:30 +00002073 * Account info. Application can query account info by calling
2074 * #pjsua_acc_get_info().
2075 */
2076typedef struct pjsua_acc_info
2077{
2078 /**
2079 * The account ID.
2080 */
2081 pjsua_acc_id id;
2082
2083 /**
2084 * Flag to indicate whether this is the default account.
2085 */
2086 pj_bool_t is_default;
2087
2088 /**
2089 * Account URI
2090 */
2091 pj_str_t acc_uri;
2092
2093 /**
2094 * Flag to tell whether this account has registration setting
2095 * (reg_uri is not empty).
2096 */
2097 pj_bool_t has_registration;
2098
2099 /**
2100 * An up to date expiration interval for account registration session.
2101 */
2102 int expires;
2103
2104 /**
2105 * Last registration status code. If status code is zero, the account
2106 * is currently not registered. Any other value indicates the SIP
2107 * status code of the registration.
2108 */
2109 pjsip_status_code status;
2110
2111 /**
2112 * String describing the registration status.
2113 */
2114 pj_str_t status_text;
2115
2116 /**
2117 * Presence online status for this account.
2118 */
2119 pj_bool_t online_status;
2120
2121 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00002122 * Presence online status text.
2123 */
2124 pj_str_t online_status_text;
2125
2126 /**
2127 * Extended RPID online status information.
2128 */
2129 pjrpid_element rpid;
2130
2131 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002132 * Buffer that is used internally to store the status text.
2133 */
2134 char buf_[PJ_ERR_MSG_SIZE];
2135
2136} pjsua_acc_info;
2137
2138
2139
2140/**
2141 * Get number of current accounts.
2142 *
2143 * @return Current number of accounts.
2144 */
2145PJ_DECL(unsigned) pjsua_acc_get_count(void);
2146
2147
2148/**
2149 * Check if the specified account ID is valid.
2150 *
2151 * @param acc_id Account ID to check.
2152 *
2153 * @return Non-zero if account ID is valid.
2154 */
2155PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
2156
2157
2158/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00002159 * Set default account to be used when incoming and outgoing
2160 * requests doesn't match any accounts.
2161 *
2162 * @param acc_id The account ID to be used as default.
2163 *
2164 * @return PJ_SUCCESS on success.
2165 */
2166PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
2167
2168
2169/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002170 * Get default account to be used when receiving incoming requests (calls),
2171 * when the destination of the incoming call doesn't match any other
2172 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00002173 *
2174 * @return The default account ID, or PJSUA_INVALID_ID if no
2175 * default account is configured.
2176 */
2177PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
2178
2179
2180/**
Benny Prijono312aff92006-06-17 04:08:30 +00002181 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00002182 * #pjsua_init()) before calling this function. If registration is configured
2183 * for this account, this function would also start the SIP registration
2184 * session with the SIP registrar server. This SIP registration session
2185 * will be maintained internally by the library, and application doesn't
2186 * need to do anything to maintain the registration session.
2187 *
Benny Prijono312aff92006-06-17 04:08:30 +00002188 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00002189 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002190 * @param is_default If non-zero, this account will be set as the default
2191 * account. The default account will be used when sending
2192 * outgoing requests (e.g. making call) when no account is
2193 * specified, and when receiving incoming requests when the
2194 * request does not match any accounts. It is recommended
2195 * that default account is set to local/LAN account.
2196 * @param p_acc_id Pointer to receive account ID of the new account.
2197 *
2198 * @return PJ_SUCCESS on success, or the appropriate error code.
2199 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00002200PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00002201 pj_bool_t is_default,
2202 pjsua_acc_id *p_acc_id);
2203
2204
2205/**
2206 * Add a local account. A local account is used to identify local endpoint
2207 * instead of a specific user, and for this reason, a transport ID is needed
2208 * to obtain the local address information.
2209 *
2210 * @param tid Transport ID to generate account address.
2211 * @param is_default If non-zero, this account will be set as the default
2212 * account. The default account will be used when sending
2213 * outgoing requests (e.g. making call) when no account is
2214 * specified, and when receiving incoming requests when the
2215 * request does not match any accounts. It is recommended
2216 * that default account is set to local/LAN account.
2217 * @param p_acc_id Pointer to receive account ID of the new account.
2218 *
2219 * @return PJ_SUCCESS on success, or the appropriate error code.
2220 */
2221PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
2222 pj_bool_t is_default,
2223 pjsua_acc_id *p_acc_id);
2224
2225/**
Benny Prijono705e7842008-07-21 18:12:51 +00002226 * Set arbitrary data to be associated with the account.
2227 *
2228 * @param acc_id The account ID.
2229 * @param user_data User/application data.
2230 *
2231 * @return PJ_SUCCESS on success, or the appropriate error code.
2232 */
2233PJ_DECL(pj_status_t) pjsua_acc_set_user_data(pjsua_acc_id acc_id,
2234 void *user_data);
2235
2236
2237/**
2238 * Retrieve arbitrary data associated with the account.
2239 *
2240 * @param acc_id The account ID.
2241 *
2242 * @return The user data. In the case where the account ID is
2243 * not valid, NULL is returned.
2244 */
2245PJ_DECL(void*) pjsua_acc_get_user_data(pjsua_acc_id acc_id);
2246
2247
2248/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002249 * Delete an account. This will unregister the account from the SIP server,
2250 * if necessary, and terminate server side presence subscriptions associated
2251 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00002252 *
2253 * @param acc_id Id of the account to be deleted.
2254 *
2255 * @return PJ_SUCCESS on success, or the appropriate error code.
2256 */
2257PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2258
2259
2260/**
2261 * Modify account information.
2262 *
2263 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002264 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002265 *
2266 * @return PJ_SUCCESS on success, or the appropriate error code.
2267 */
2268PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002269 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002270
2271
2272/**
2273 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002274 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002275 * if there are server side presence subscription for this account, and/or
2276 * outgoing PUBLISH if presence publication is enabled for this account.
2277 *
2278 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002279 *
2280 * @param acc_id The account ID.
2281 * @param is_online True of false.
2282 *
2283 * @return PJ_SUCCESS on success, or the appropriate error code.
2284 */
2285PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2286 pj_bool_t is_online);
2287
Benny Prijono4461c7d2007-08-25 13:36:15 +00002288/**
2289 * Modify account's presence status to be advertised to remote/presence
2290 * subscribers. This would trigger the sending of outgoing NOTIFY request
2291 * if there are server side presence subscription for this account, and/or
2292 * outgoing PUBLISH if presence publication is enabled for this account.
2293 *
2294 * @see pjsua_acc_set_online_status()
2295 *
2296 * @param acc_id The account ID.
2297 * @param is_online True of false.
2298 * @param pr Extended information in subset of RPID format
2299 * which allows setting custom presence text.
2300 *
2301 * @return PJ_SUCCESS on success, or the appropriate error code.
2302 */
2303PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2304 pj_bool_t is_online,
2305 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002306
2307/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002308 * Update registration or perform unregistration. If registration is
2309 * configured for this account, then initial SIP REGISTER will be sent
2310 * when the account is added with #pjsua_acc_add(). Application normally
2311 * only need to call this function if it wants to manually update the
2312 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002313 *
2314 * @param acc_id The account ID.
2315 * @param renew If renew argument is zero, this will start
2316 * unregistration process.
2317 *
2318 * @return PJ_SUCCESS on success, or the appropriate error code.
2319 */
2320PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2321 pj_bool_t renew);
2322
Benny Prijono312aff92006-06-17 04:08:30 +00002323/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002324 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002325 *
2326 * @param acc_id Account identification.
2327 * @param info Pointer to receive account information.
2328 *
2329 * @return PJ_SUCCESS on success, or the appropriate error code.
2330 */
2331PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2332 pjsua_acc_info *info);
2333
2334
2335/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002336 * Enumerate all account currently active in the library. This will fill
2337 * the array with the account Ids, and application can then query the
2338 * account information for each id with #pjsua_acc_get_info().
2339 *
2340 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002341 *
2342 * @param ids Array of account IDs to be initialized.
2343 * @param count In input, specifies the maximum number of elements.
2344 * On return, it contains the actual number of elements.
2345 *
2346 * @return PJ_SUCCESS on success, or the appropriate error code.
2347 */
2348PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2349 unsigned *count );
2350
2351
2352/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002353 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002354 *
2355 * @param info Array of account infos to be initialized.
2356 * @param count In input, specifies the maximum number of elements.
2357 * On return, it contains the actual number of elements.
2358 *
2359 * @return PJ_SUCCESS on success, or the appropriate error code.
2360 */
2361PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2362 unsigned *count );
2363
2364
2365/**
2366 * This is an internal function to find the most appropriate account to
2367 * used to reach to the specified URL.
2368 *
2369 * @param url The remote URL to reach.
2370 *
2371 * @return Account id.
2372 */
2373PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2374
2375
2376/**
2377 * This is an internal function to find the most appropriate account to be
2378 * used to handle incoming calls.
2379 *
2380 * @param rdata The incoming request message.
2381 *
2382 * @return Account id.
2383 */
2384PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2385
2386
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002387/**
Benny Prijonofff245c2007-04-02 11:44:47 +00002388 * Create arbitrary requests using the account. Application should only use
2389 * this function to create auxiliary requests outside dialog, such as
2390 * OPTIONS, and use the call or presence API to create dialog related
2391 * requests.
2392 *
2393 * @param acc_id The account ID.
2394 * @param method The SIP method of the request.
2395 * @param target Target URI.
2396 * @param p_tdata Pointer to receive the request.
2397 *
2398 * @return PJ_SUCCESS or the error code.
2399 */
2400PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
2401 const pjsip_method *method,
2402 const pj_str_t *target,
2403 pjsip_tx_data **p_tdata);
2404
2405
2406/**
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002407 * Create a suitable Contact header value, based on the specified target URI
2408 * for the specified account.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002409 *
2410 * @param pool Pool to allocate memory for the string.
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002411 * @param contact The string where the Contact will be stored.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002412 * @param acc_id Account ID.
2413 * @param uri Destination URI of the request.
2414 *
2415 * @return PJ_SUCCESS on success, other on error.
2416 */
2417PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
2418 pj_str_t *contact,
2419 pjsua_acc_id acc_id,
2420 const pj_str_t *uri);
2421
2422
2423
2424/**
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002425 * Create a suitable Contact header value, based on the information in the
2426 * incoming request.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002427 *
2428 * @param pool Pool to allocate memory for the string.
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +00002429 * @param contact The string where the Contact will be stored.
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002430 * @param acc_id Account ID.
2431 * @param rdata Incoming request.
2432 *
2433 * @return PJ_SUCCESS on success, other on error.
2434 */
2435PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
2436 pj_str_t *contact,
2437 pjsua_acc_id acc_id,
2438 pjsip_rx_data *rdata );
2439
2440
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002441/**
2442 * Lock/bind this account to a specific transport/listener. Normally
2443 * application shouldn't need to do this, as transports will be selected
2444 * automatically by the stack according to the destination.
2445 *
2446 * When account is locked/bound to a specific transport, all outgoing
2447 * requests from this account will use the specified transport (this
2448 * includes SIP registration, dialog (call and event subscription), and
2449 * out-of-dialog requests such as MESSAGE).
2450 *
2451 * Note that transport_id may be specified in pjsua_acc_config too.
2452 *
2453 * @param acc_id The account ID.
2454 * @param tp_id The transport ID.
2455 *
2456 * @return PJ_SUCCESS on success.
2457 */
2458PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
2459 pjsua_transport_id tp_id);
2460
Benny Prijono312aff92006-06-17 04:08:30 +00002461
2462/**
2463 * @}
2464 */
2465
2466
2467/*****************************************************************************
2468 * CALLS API
2469 */
2470
2471
2472/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002473 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00002474 * @ingroup PJSUA_LIB
2475 * @brief Call manipulation.
2476 * @{
2477 */
2478
2479/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002480 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00002481 */
2482#ifndef PJSUA_MAX_CALLS
2483# define PJSUA_MAX_CALLS 32
2484#endif
2485
2486
2487
2488/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002489 * This enumeration specifies the media status of a call, and it's part
2490 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00002491 */
2492typedef enum pjsua_call_media_status
2493{
Benny Prijonob5388cf2007-01-04 22:45:08 +00002494 /** Call currently has no media */
Benny Prijono312aff92006-06-17 04:08:30 +00002495 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002496
2497 /** The media is active */
Benny Prijono312aff92006-06-17 04:08:30 +00002498 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002499
2500 /** The media is currently put on hold by local endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002501 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002502
2503 /** The media is currently put on hold by remote endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002504 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002505
Benny Prijono096c56c2007-09-15 08:30:16 +00002506 /** The media has reported error (e.g. ICE negotiation) */
2507 PJSUA_CALL_MEDIA_ERROR
2508
Benny Prijono312aff92006-06-17 04:08:30 +00002509} pjsua_call_media_status;
2510
2511
2512/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002513 * This structure describes the information and current status of a call.
Benny Prijono312aff92006-06-17 04:08:30 +00002514 */
2515typedef struct pjsua_call_info
2516{
2517 /** Call identification. */
2518 pjsua_call_id id;
2519
2520 /** Initial call role (UAC == caller) */
2521 pjsip_role_e role;
2522
Benny Prijono90315512006-09-14 16:05:16 +00002523 /** The account ID where this call belongs. */
2524 pjsua_acc_id acc_id;
2525
Benny Prijono312aff92006-06-17 04:08:30 +00002526 /** Local URI */
2527 pj_str_t local_info;
2528
2529 /** Local Contact */
2530 pj_str_t local_contact;
2531
2532 /** Remote URI */
2533 pj_str_t remote_info;
2534
2535 /** Remote contact */
2536 pj_str_t remote_contact;
2537
2538 /** Dialog Call-ID string. */
2539 pj_str_t call_id;
2540
2541 /** Call state */
2542 pjsip_inv_state state;
2543
2544 /** Text describing the state */
2545 pj_str_t state_text;
2546
2547 /** Last status code heard, which can be used as cause code */
2548 pjsip_status_code last_status;
2549
2550 /** The reason phrase describing the status. */
2551 pj_str_t last_status_text;
2552
2553 /** Call media status. */
2554 pjsua_call_media_status media_status;
2555
2556 /** Media direction */
2557 pjmedia_dir media_dir;
2558
2559 /** The conference port number for the call */
2560 pjsua_conf_port_id conf_slot;
2561
2562 /** Up-to-date call connected duration (zero when call is not
2563 * established)
2564 */
2565 pj_time_val connect_duration;
2566
2567 /** Total call duration, including set-up time */
2568 pj_time_val total_duration;
2569
2570 /** Internal */
2571 struct {
2572 char local_info[128];
2573 char local_contact[128];
2574 char remote_info[128];
2575 char remote_contact[128];
2576 char call_id[128];
2577 char last_status_text[128];
2578 } buf_;
2579
2580} pjsua_call_info;
2581
2582
2583
Benny Prijonoa91a0032006-02-26 21:23:45 +00002584/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002585 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002586 *
2587 * @return Maximum number of calls configured.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002588 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002589PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002590
2591/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002592 * Get number of currently active calls.
2593 *
2594 * @return Number of currently active calls.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002595 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002596PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002597
2598/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002599 * Enumerate all active calls. Application may then query the information and
2600 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002601 *
2602 * @param ids Array of account IDs to be initialized.
2603 * @param count In input, specifies the maximum number of elements.
2604 * On return, it contains the actual number of elements.
2605 *
2606 * @return PJ_SUCCESS on success, or the appropriate error code.
2607 */
2608PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
2609 unsigned *count);
2610
2611
2612/**
2613 * Make outgoing call to the specified URI using the specified account.
2614 *
2615 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002616 * @param dst_uri URI to be put in the To header (normally is the same
2617 * as the target URI).
2618 * @param options Options (must be zero at the moment).
2619 * @param user_data Arbitrary user data to be attached to the call, and
2620 * can be retrieved later.
2621 * @param msg_data Optional headers etc to be added to outgoing INVITE
2622 * request, or NULL if no custom header is desired.
2623 * @param p_call_id Pointer to receive call identification.
2624 *
2625 * @return PJ_SUCCESS on success, or the appropriate error code.
2626 */
2627PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
2628 const pj_str_t *dst_uri,
2629 unsigned options,
2630 void *user_data,
2631 const pjsua_msg_data *msg_data,
2632 pjsua_call_id *p_call_id);
2633
2634
2635/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002636 * Check if the specified call has active INVITE session and the INVITE
2637 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002638 *
2639 * @param call_id Call identification.
2640 *
2641 * @return Non-zero if call is active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002642 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002643PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002644
2645
2646/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002647 * Check if call has an active media session.
2648 *
2649 * @param call_id Call identification.
2650 *
2651 * @return Non-zero if yes.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002652 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002653PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002654
2655
2656/**
Benny Prijonocf986c42008-09-02 11:25:07 +00002657 * Retrieve the media session associated with this call. Note that the media
2658 * session may not be available depending on the current call's media status
2659 * (the pjsua_call_media_status information in pjsua_call_info). Application
2660 * may use the media session to retrieve more detailed information about the
2661 * call's media.
2662 *
2663 * @param call_id Call identification.
2664 *
2665 * @return Call media session.
2666 */
2667PJ_DECL(pjmedia_session*) pjsua_call_get_media_session(pjsua_call_id call_id);
2668
2669
2670/**
2671 * Retrieve the media transport instance that is used for this call.
2672 * Application may use the media transport to query more detailed information
2673 * about the media transport.
2674 *
2675 * @param cid Call identification (the call_id).
2676 *
2677 * @return Call media transport.
2678 */
2679PJ_DECL(pjmedia_transport*) pjsua_call_get_media_transport(pjsua_call_id cid);
2680
2681
2682/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002683 * Get the conference port identification associated with the call.
2684 *
2685 * @param call_id Call identification.
2686 *
2687 * @return Conference port ID, or PJSUA_INVALID_ID when the
2688 * media has not been established or is not active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002689 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002690PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
2691
2692/**
2693 * Obtain detail information about the specified call.
2694 *
2695 * @param call_id Call identification.
2696 * @param info Call info to be initialized.
2697 *
2698 * @return PJ_SUCCESS on success, or the appropriate error code.
2699 */
2700PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002701 pjsua_call_info *info);
2702
2703
2704/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002705 * Attach application specific data to the call. Application can then
2706 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002707 *
2708 * @param call_id Call identification.
2709 * @param user_data Arbitrary data to be attached to the call.
2710 *
2711 * @return The user data.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002712 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002713PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
2714 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002715
2716
2717/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002718 * Get user data attached to the call, which has been previously set with
2719 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002720 *
2721 * @param call_id Call identification.
2722 *
2723 * @return The user data.
Benny Prijono268ca612006-02-07 12:34:11 +00002724 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002725PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00002726
2727
2728/**
Benny Prijono91a6a172007-10-31 08:59:29 +00002729 * Get the NAT type of remote's endpoint. This is a proprietary feature
2730 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
2731 * is set in #pjsua_config.
2732 *
2733 * This function can only be called after SDP has been received from remote,
2734 * which means for incoming call, this function can be called as soon as
2735 * call is received as long as incoming call contains SDP, and for outgoing
2736 * call, this function can be called only after SDP is received (normally in
2737 * 200/OK response to INVITE). As a general case, application should call
2738 * this function after or in \a on_call_media_state() callback.
2739 *
2740 * @param call_id Call identification.
2741 * @param p_type Pointer to store the NAT type. Application can then
2742 * retrieve the string description of the NAT type
2743 * by calling pj_stun_get_nat_name().
2744 *
2745 * @return PJ_SUCCESS on success.
2746 *
2747 * @see pjsua_get_nat_type(), nat_type_in_sdp
2748 */
2749PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
2750 pj_stun_nat_type *p_type);
2751
2752/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002753 * Send response to incoming INVITE request. Depending on the status
2754 * code specified as parameter, this function may send provisional
2755 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002756 *
2757 * @param call_id Incoming call identification.
2758 * @param code Status code, (100-699).
2759 * @param reason Optional reason phrase. If NULL, default text
2760 * will be used.
2761 * @param msg_data Optional list of headers etc to be added to outgoing
2762 * response message.
2763 *
2764 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoa91a0032006-02-26 21:23:45 +00002765 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002766PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
2767 unsigned code,
2768 const pj_str_t *reason,
2769 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00002770
2771/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002772 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00002773 * call state. This function is different than answering the call with
2774 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
2775 * will hangup the call regardless of the state and role of the call,
2776 * while #pjsua_call_answer() only works with incoming calls on EARLY
2777 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002778 *
2779 * @param call_id Call identification.
2780 * @param code Optional status code to be sent when we're rejecting
2781 * incoming call. If the value is zero, "603/Decline"
2782 * will be sent.
2783 * @param reason Optional reason phrase to be sent when we're rejecting
2784 * incoming call. If NULL, default text will be used.
2785 * @param msg_data Optional list of headers etc to be added to outgoing
2786 * request/response message.
2787 *
2788 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00002789 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002790PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
2791 unsigned code,
2792 const pj_str_t *reason,
2793 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002794
Benny Prijono5e51a4e2008-11-27 00:06:46 +00002795/**
2796 * Accept or reject redirection response. Application MUST call this function
2797 * after it signaled PJSIP_REDIRECT_PENDING in the \a on_call_redirected()
2798 * callback, to notify the call whether to accept or reject the redirection
2799 * to the current target. Application can use the combination of
2800 * PJSIP_REDIRECT_PENDING command in \a on_call_redirected() callback and
2801 * this function to ask for user permission before redirecting the call.
2802 *
2803 * Note that if the application chooses to reject or stop redirection (by
2804 * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the
2805 * call disconnection callback will be called before this function returns.
2806 * And if the application rejects the target, the \a on_call_redirected()
2807 * callback may also be called before this function returns if there is
2808 * another target to try.
2809 *
2810 * @param call_id The call ID.
2811 * @param cmd Redirection operation to be applied to the current
2812 * target. The semantic of this argument is similar
2813 * to the description in the \a on_call_redirected()
2814 * callback, except that the PJSIP_REDIRECT_PENDING is
2815 * not accepted here.
2816 *
2817 * @return PJ_SUCCESS on successful operation.
2818 */
2819PJ_DECL(pj_status_t) pjsua_call_process_redirect(pjsua_call_id call_id,
2820 pjsip_redirect_op cmd);
Benny Prijono26ff9062006-02-21 23:47:00 +00002821
2822/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002823 * Put the specified call on hold. This will send re-INVITE with the
2824 * appropriate SDP to inform remote that the call is being put on hold.
2825 * The final status of the request itself will be reported on the
2826 * \a on_call_media_state() callback, which inform the application that
2827 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002828 *
2829 * @param call_id Call identification.
2830 * @param msg_data Optional message components to be sent with
2831 * the request.
2832 *
2833 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00002834 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002835PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
2836 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002837
2838
2839/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002840 * Send re-INVITE to release hold.
2841 * The final status of the request itself will be reported on the
2842 * \a on_call_media_state() callback, which inform the application that
2843 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002844 *
2845 * @param call_id Call identification.
2846 * @param unhold If this argument is non-zero and the call is locally
2847 * held, this will release the local hold.
2848 * @param msg_data Optional message components to be sent with
2849 * the request.
2850 *
2851 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00002852 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002853PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
2854 pj_bool_t unhold,
2855 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002856
Benny Prijonoc08682e2007-10-04 06:17:58 +00002857/**
2858 * Send UPDATE request.
2859 *
2860 * @param call_id Call identification.
2861 * @param options Must be zero for now.
2862 * @param msg_data Optional message components to be sent with
2863 * the request.
2864 *
2865 * @return PJ_SUCCESS on success, or the appropriate error code.
2866 */
2867PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
2868 unsigned options,
2869 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002870
2871/**
Benny Prijono053f5222006-11-11 16:16:04 +00002872 * Initiate call transfer to the specified address. This function will send
2873 * REFER request to instruct remote call party to initiate a new INVITE
2874 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002875 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00002876 * If application is interested to monitor the successfulness and
2877 * the progress of the transfer request, it can implement
2878 * \a on_call_transfer_status() callback which will report the progress
2879 * of the call transfer request.
2880 *
Benny Prijono053f5222006-11-11 16:16:04 +00002881 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002882 * @param dest Address of new target to be contacted.
2883 * @param msg_data Optional message components to be sent with
2884 * the request.
2885 *
2886 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00002887 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002888PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
2889 const pj_str_t *dest,
2890 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002891
2892/**
Benny Prijono053f5222006-11-11 16:16:04 +00002893 * Flag to indicate that "Require: replaces" should not be put in the
2894 * outgoing INVITE request caused by REFER request created by
2895 * #pjsua_call_xfer_replaces().
2896 */
2897#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
2898
2899/**
2900 * Initiate attended call transfer. This function will send REFER request
2901 * to instruct remote call party to initiate new INVITE session to the URL
2902 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
2903 * the call with us with the new call from the REFER recipient.
2904 *
2905 * @param call_id The call id to be transfered.
2906 * @param dest_call_id The call id to be replaced.
2907 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
2908 * to suppress the inclusion of "Require: replaces" in
2909 * the outgoing INVITE request created by the REFER
2910 * request.
2911 * @param msg_data Optional message components to be sent with
2912 * the request.
2913 *
2914 * @return PJ_SUCCESS on success, or the appropriate error code.
2915 */
2916PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
2917 pjsua_call_id dest_call_id,
2918 unsigned options,
2919 const pjsua_msg_data *msg_data);
2920
2921/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002922 * Send DTMF digits to remote using RFC 2833 payload formats.
2923 *
2924 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002925 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002926 *
2927 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002928 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002929PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002930 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00002931
Benny Prijono26ff9062006-02-21 23:47:00 +00002932/**
Benny Prijonob0808372006-03-02 21:18:58 +00002933 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002934 *
2935 * @param call_id Call identification.
2936 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
2937 * assumed.
2938 * @param content The message content.
2939 * @param msg_data Optional list of headers etc to be included in outgoing
2940 * request. The body descriptor in the msg_data is
2941 * ignored.
2942 * @param user_data Optional user data, which will be given back when
2943 * the IM callback is called.
2944 *
2945 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00002946 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002947PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
2948 const pj_str_t *mime_type,
2949 const pj_str_t *content,
2950 const pjsua_msg_data *msg_data,
2951 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00002952
2953
2954/**
2955 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002956 *
2957 * @param call_id Call identification.
2958 * @param is_typing Non-zero to indicate to remote that local person is
2959 * currently typing an IM.
2960 * @param msg_data Optional list of headers etc to be included in outgoing
2961 * request.
2962 *
2963 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00002964 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002965PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
2966 pj_bool_t is_typing,
2967 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00002968
2969/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00002970 * Send arbitrary request with the call. This is useful for example to send
2971 * INFO request. Note that application should not use this function to send
2972 * requests which would change the invite session's state, such as re-INVITE,
2973 * UPDATE, PRACK, and BYE.
2974 *
2975 * @param call_id Call identification.
2976 * @param method SIP method of the request.
2977 * @param msg_data Optional message body and/or list of headers to be
2978 * included in outgoing request.
2979 *
2980 * @return PJ_SUCCESS on success, or the appropriate error code.
2981 */
2982PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
2983 const pj_str_t *method,
2984 const pjsua_msg_data *msg_data);
2985
2986
2987/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002988 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
2989 * currently active calls.
Benny Prijono834aee32006-02-19 01:38:06 +00002990 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00002991PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00002992
2993
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002994/**
2995 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002996 *
2997 * @param call_id Call identification.
2998 * @param with_media Non-zero to include media information too.
2999 * @param buffer Buffer where the statistics are to be written to.
3000 * @param maxlen Maximum length of buffer.
3001 * @param indent Spaces for left indentation.
3002 *
3003 * @return PJ_SUCCESS on success.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003004 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003005PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
3006 pj_bool_t with_media,
3007 char *buffer,
3008 unsigned maxlen,
3009 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00003010
Benny Prijono9fc735d2006-05-28 14:58:12 +00003011/**
Benny Prijono312aff92006-06-17 04:08:30 +00003012 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003013 */
Benny Prijono834aee32006-02-19 01:38:06 +00003014
3015
3016/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00003017 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00003018 */
3019
Benny Prijono312aff92006-06-17 04:08:30 +00003020
3021/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003022 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00003023 * @ingroup PJSUA_LIB
3024 * @brief Buddy management, buddy's presence, and instant messaging.
3025 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00003026 *
3027 * This section describes PJSUA-APIs related to buddies management,
3028 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00003029 */
3030
3031/**
3032 * Max buddies in buddy list.
3033 */
3034#ifndef PJSUA_MAX_BUDDIES
3035# define PJSUA_MAX_BUDDIES 256
3036#endif
3037
3038
3039/**
Benny Prijonoa17496a2007-10-31 10:20:31 +00003040 * This specifies how long the library should retry resending SUBSCRIBE
Benny Prijono53984d12009-04-28 22:19:49 +00003041 * if the previous SUBSCRIBE failed. This also controls the duration
3042 * before failed PUBLISH request will be retried.
Benny Prijonoa17496a2007-10-31 10:20:31 +00003043 *
3044 * Default: 300 seconds
3045 */
3046#ifndef PJSUA_PRES_TIMER
3047# define PJSUA_PRES_TIMER 300
3048#endif
3049
3050
3051/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003052 * This structure describes buddy configuration when adding a buddy to
3053 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
3054 * the structure with #pjsua_buddy_config_default() to initialize this
3055 * structure with default configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00003056 */
3057typedef struct pjsua_buddy_config
3058{
3059 /**
3060 * Buddy URL or name address.
3061 */
3062 pj_str_t uri;
3063
3064 /**
3065 * Specify whether presence subscription should start immediately.
3066 */
3067 pj_bool_t subscribe;
3068
Benny Prijono705e7842008-07-21 18:12:51 +00003069 /**
3070 * Specify arbitrary application data to be associated with with
3071 * the buddy object.
3072 */
3073 void *user_data;
3074
Benny Prijono312aff92006-06-17 04:08:30 +00003075} pjsua_buddy_config;
3076
3077
3078/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003079 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00003080 */
3081typedef enum pjsua_buddy_status
3082{
3083 /**
3084 * Online status is unknown (possibly because no presence subscription
3085 * has been established).
3086 */
3087 PJSUA_BUDDY_STATUS_UNKNOWN,
3088
3089 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00003090 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00003091 */
3092 PJSUA_BUDDY_STATUS_ONLINE,
3093
3094 /**
3095 * Buddy is offline.
3096 */
3097 PJSUA_BUDDY_STATUS_OFFLINE,
3098
3099} pjsua_buddy_status;
3100
3101
3102
3103/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003104 * This structure describes buddy info, which can be retrieved by calling
3105 * #pjsua_buddy_get_info().
Benny Prijono312aff92006-06-17 04:08:30 +00003106 */
3107typedef struct pjsua_buddy_info
3108{
3109 /**
3110 * The buddy ID.
3111 */
3112 pjsua_buddy_id id;
3113
3114 /**
3115 * The full URI of the buddy, as specified in the configuration.
3116 */
3117 pj_str_t uri;
3118
3119 /**
3120 * Buddy's Contact, only available when presence subscription has
3121 * been established to the buddy.
3122 */
3123 pj_str_t contact;
3124
3125 /**
3126 * Buddy's online status.
3127 */
3128 pjsua_buddy_status status;
3129
3130 /**
3131 * Text to describe buddy's online status.
3132 */
3133 pj_str_t status_text;
3134
3135 /**
3136 * Flag to indicate that we should monitor the presence information for
3137 * this buddy (normally yes, unless explicitly disabled).
3138 */
3139 pj_bool_t monitor_pres;
3140
3141 /**
Benny Prijono63fba012008-07-17 14:19:10 +00003142 * If \a monitor_pres is enabled, this specifies the last state of the
3143 * presence subscription. If presence subscription session is currently
3144 * active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence
3145 * subscription request has been rejected, the value will be
3146 * PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be
3147 * specified in \a sub_term_reason.
3148 */
3149 pjsip_evsub_state sub_state;
3150
3151 /**
Benny Prijonod06d8c52009-06-30 13:53:47 +00003152 * String representation of subscription state.
3153 */
3154 const char *sub_state_name;
3155
3156 /**
Benny Prijono73bb7232009-10-20 13:56:26 +00003157 * Specifies the last presence subscription termination code. This would
3158 * return the last status of the SUBSCRIBE request. If the subscription
3159 * is terminated with NOTIFY by the server, this value will be set to
3160 * 200, and subscription termination reason will be given in the
3161 * \a sub_term_reason field.
3162 */
3163 unsigned sub_term_code;
3164
3165 /**
3166 * Specifies the last presence subscription termination reason. If
Benny Prijono63fba012008-07-17 14:19:10 +00003167 * presence subscription is currently active, the value will be empty.
3168 */
3169 pj_str_t sub_term_reason;
3170
3171 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00003172 * Extended RPID information about the person.
3173 */
3174 pjrpid_element rpid;
3175
3176 /**
Benny Prijono28add7e2009-06-15 16:03:40 +00003177 * Extended presence info.
3178 */
3179 pjsip_pres_status pres_status;
3180
3181 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003182 * Internal buffer.
3183 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00003184 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00003185
3186} pjsua_buddy_info;
3187
3188
Benny Prijono834aee32006-02-19 01:38:06 +00003189/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003190 * Set default values to the buddy config.
3191 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003192PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00003193
3194
3195/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003196 * Get total number of buddies.
3197 *
3198 * @return Number of buddies.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003199 */
3200PJ_DECL(unsigned) pjsua_get_buddy_count(void);
3201
3202
3203/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003204 * Check if buddy ID is valid.
3205 *
3206 * @param buddy_id Buddy ID to check.
3207 *
3208 * @return Non-zero if buddy ID is valid.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003209 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003210PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
3211
3212
3213/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003214 * Enumerate all buddy IDs in the buddy list. Application then can use
3215 * #pjsua_buddy_get_info() to get the detail information for each buddy
3216 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003217 *
3218 * @param ids Array of ids to be initialized.
3219 * @param count On input, specifies max elements in the array.
3220 * On return, it contains actual number of elements
3221 * that have been initialized.
3222 *
3223 * @return PJ_SUCCESS on success, or the appropriate error code.
3224 */
3225PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
3226 unsigned *count);
3227
3228/**
Benny Prijono705e7842008-07-21 18:12:51 +00003229 * Find the buddy ID with the specified URI.
3230 *
3231 * @param uri The buddy URI.
3232 *
3233 * @return The buddy ID, or PJSUA_INVALID_ID if not found.
3234 */
3235PJ_DECL(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri);
3236
3237
3238/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003239 * Get detailed buddy info.
3240 *
3241 * @param buddy_id The buddy identification.
3242 * @param info Pointer to receive information about buddy.
3243 *
3244 * @return PJ_SUCCESS on success, or the appropriate error code.
3245 */
3246PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00003247 pjsua_buddy_info *info);
3248
3249/**
Benny Prijono705e7842008-07-21 18:12:51 +00003250 * Set the user data associated with the buddy object.
3251 *
3252 * @param buddy_id The buddy identification.
3253 * @param user_data Arbitrary application data to be associated with
3254 * the buddy object.
3255 *
3256 * @return PJ_SUCCESS on success, or the appropriate error code.
3257 */
3258PJ_DECL(pj_status_t) pjsua_buddy_set_user_data(pjsua_buddy_id buddy_id,
3259 void *user_data);
3260
3261
3262/**
3263 * Get the user data associated with the budy object.
3264 *
3265 * @param buddy_id The buddy identification.
3266 *
3267 * @return The application data.
3268 */
3269PJ_DECL(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id);
3270
3271
3272/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003273 * Add new buddy to the buddy list. If presence subscription is enabled
3274 * for this buddy, this function will also start the presence subscription
3275 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003276 *
Benny Prijonoa7b376b2008-01-25 16:06:33 +00003277 * @param buddy_cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003278 * @param p_buddy_id Pointer to receive buddy ID.
3279 *
3280 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003281 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003282PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003283 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003284
3285
3286/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003287 * Delete the specified buddy from the buddy list. Any presence subscription
3288 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003289 *
3290 * @param buddy_id Buddy identification.
3291 *
3292 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00003293 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003294PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003295
3296
3297/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003298 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3299 * subscribed, application will be informed about buddy's presence status
3300 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003301 *
3302 * @param buddy_id Buddy identification.
3303 * @param subscribe Specify non-zero to activate presence subscription to
3304 * the specified buddy.
3305 *
3306 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003307 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003308PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3309 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003310
3311
3312/**
Benny Prijono10861432007-10-31 10:54:53 +00003313 * Update the presence information for the buddy. Although the library
3314 * periodically refreshes the presence subscription for all buddies, some
3315 * application may want to refresh the buddy's presence subscription
3316 * immediately, and in this case it can use this function to accomplish
3317 * this.
3318 *
3319 * Note that the buddy's presence subscription will only be initiated
3320 * if presence monitoring is enabled for the buddy. See
3321 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
3322 * for the buddy is already active, this function will not do anything.
3323 *
3324 * Once the presence subscription is activated successfully for the buddy,
3325 * application will be notified about the buddy's presence status in the
3326 * on_buddy_state() callback.
3327 *
3328 * @param buddy_id Buddy identification.
3329 *
3330 * @return PJ_SUCCESS on success, or the appropriate error code.
3331 */
3332PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
3333
3334
3335/**
Benny Prijono63fba012008-07-17 14:19:10 +00003336 * Send NOTIFY to inform account presence status or to terminate server
3337 * side presence subscription. If application wants to reject the incoming
3338 * request, it should set the \a state to PJSIP_EVSUB_STATE_TERMINATED.
3339 *
3340 * @param acc_id Account ID.
3341 * @param srv_pres Server presence subscription instance.
3342 * @param state New state to set.
3343 * @param state_str Optionally specify the state string name, if state
3344 * is not "active", "pending", or "terminated".
3345 * @param reason If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3346 * optionally specify the termination reason.
3347 * @param with_body If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3348 * this specifies whether the NOTIFY request should
3349 * contain message body containing account's presence
3350 * information.
3351 * @param msg_data Optional list of headers to be sent with the NOTIFY
3352 * request.
3353 *
3354 * @return PJ_SUCCESS on success.
3355 */
3356PJ_DECL(pj_status_t) pjsua_pres_notify(pjsua_acc_id acc_id,
3357 pjsua_srv_pres *srv_pres,
3358 pjsip_evsub_state state,
3359 const pj_str_t *state_str,
3360 const pj_str_t *reason,
3361 pj_bool_t with_body,
3362 const pjsua_msg_data *msg_data);
3363
3364/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003365 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003366 *
3367 * @param verbose Yes or no.
Benny Prijono834aee32006-02-19 01:38:06 +00003368 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003369PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003370
3371
Benny Prijonob0808372006-03-02 21:18:58 +00003372/**
3373 * The MESSAGE method (defined in pjsua_im.c)
3374 */
3375extern const pjsip_method pjsip_message_method;
3376
3377
Benny Prijonob0808372006-03-02 21:18:58 +00003378
3379/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003380 * Send instant messaging outside dialog, using the specified account for
3381 * route set and authentication.
3382 *
3383 * @param acc_id Account ID to be used to send the request.
3384 * @param to Remote URI.
3385 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3386 * assumed.
3387 * @param content The message content.
3388 * @param msg_data Optional list of headers etc to be included in outgoing
3389 * request. The body descriptor in the msg_data is
3390 * ignored.
3391 * @param user_data Optional user data, which will be given back when
3392 * the IM callback is called.
3393 *
3394 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003395 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003396PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3397 const pj_str_t *to,
3398 const pj_str_t *mime_type,
3399 const pj_str_t *content,
3400 const pjsua_msg_data *msg_data,
3401 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003402
3403
3404/**
3405 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003406 *
3407 * @param acc_id Account ID to be used to send the request.
3408 * @param to Remote URI.
3409 * @param is_typing If non-zero, it tells remote person that local person
3410 * is currently composing an IM.
3411 * @param msg_data Optional list of headers etc to be added to outgoing
3412 * request.
3413 *
3414 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003415 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003416PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3417 const pj_str_t *to,
3418 pj_bool_t is_typing,
3419 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003420
3421
Benny Prijonof3195072006-02-14 21:15:30 +00003422
Benny Prijono312aff92006-06-17 04:08:30 +00003423/**
3424 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003425 */
3426
Benny Prijono312aff92006-06-17 04:08:30 +00003427
3428/*****************************************************************************
3429 * MEDIA API
3430 */
3431
3432
3433/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003434 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003435 * @ingroup PJSUA_LIB
3436 * @brief Media manipulation.
3437 * @{
3438 *
3439 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003440 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3441 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003442 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003443 * the interconnection between these terminations freely.
3444 *
3445 * The conference bridge provides powerful switching and mixing functionality
3446 * for application. With the conference bridge, each conference slot (e.g.
3447 * a call) can transmit to multiple destinations, and one destination can
3448 * receive from multiple sources. If more than one media terminations are
3449 * terminated in the same slot, the conference bridge will mix the signal
3450 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00003451 *
3452 * Application connects one media termination/slot to another by calling
3453 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003454 * media flow from the source termination to the sink termination. To
3455 * establish bidirectional media flow, application wound need to make another
3456 * call to #pjsua_conf_connect(), this time inverting the source and
3457 * destination slots in the parameter.
3458 *
3459 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00003460 * the following steps:
3461 *
3462 \code
3463
3464 pj_status_t stream_to_call( pjsua_call_id call_id )
3465 {
3466 pjsua_player_id player_id;
3467
3468 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
3469 if (status != PJ_SUCCESS)
3470 return status;
3471
3472 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
3473 pjsua_call_get_conf_port() );
3474 }
3475 \endcode
3476 *
3477 *
3478 * Other features of PJSUA media:
3479 * - efficient N to M interconnections between media terminations.
3480 * - media termination can be connected to itself to create loopback
3481 * media.
3482 * - the media termination may have different clock rates, and resampling
3483 * will be done automatically by conference bridge.
3484 * - media terminations may also have different frame time; the
3485 * conference bridge will perform the necessary bufferring to adjust
3486 * the difference between terminations.
3487 * - interconnections are removed automatically when media termination
3488 * is removed from the bridge.
3489 * - sound device may be changed even when there are active media
3490 * interconnections.
3491 * - correctly report call's media quality (in #pjsua_call_dump()) from
3492 * RTCP packet exchange.
3493 */
3494
3495/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003496 * Max ports in the conference bridge. This setting is the default value
3497 * for pjsua_media_config.max_media_ports.
Benny Prijono312aff92006-06-17 04:08:30 +00003498 */
3499#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00003500# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00003501#endif
3502
Benny Prijonob5388cf2007-01-04 22:45:08 +00003503/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003504 * The default clock rate to be used by the conference bridge. This setting
3505 * is the default value for pjsua_media_config.clock_rate.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003506 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003507#ifndef PJSUA_DEFAULT_CLOCK_RATE
3508# define PJSUA_DEFAULT_CLOCK_RATE 16000
3509#endif
3510
Benny Prijonob5388cf2007-01-04 22:45:08 +00003511/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003512 * Default frame length in the conference bridge. This setting
3513 * is the default value for pjsua_media_config.audio_frame_ptime.
3514 */
3515#ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Nanang Izzuddinaf974842008-05-08 09:51:16 +00003516# define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
Benny Prijono37c710b2008-01-10 12:09:26 +00003517#endif
3518
3519
3520/**
3521 * Default codec quality settings. This setting is the default value
3522 * for pjsua_media_config.quality.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003523 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003524#ifndef PJSUA_DEFAULT_CODEC_QUALITY
Nanang Izzuddin9dbad152008-06-10 18:56:10 +00003525# define PJSUA_DEFAULT_CODEC_QUALITY 8
Benny Prijono12a669c2006-11-23 07:32:13 +00003526#endif
3527
Benny Prijonob5388cf2007-01-04 22:45:08 +00003528/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003529 * Default iLBC mode. This setting is the default value for
3530 * pjsua_media_config.ilbc_mode.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003531 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003532#ifndef PJSUA_DEFAULT_ILBC_MODE
Benny Prijono37c710b2008-01-10 12:09:26 +00003533# define PJSUA_DEFAULT_ILBC_MODE 30
Benny Prijono12a669c2006-11-23 07:32:13 +00003534#endif
3535
Benny Prijonob5388cf2007-01-04 22:45:08 +00003536/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003537 * The default echo canceller tail length. This setting
3538 * is the default value for pjsua_media_config.ec_tail_len.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003539 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003540#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijono427439c2007-10-21 09:41:24 +00003541# define PJSUA_DEFAULT_EC_TAIL_LEN 200
Benny Prijono12a669c2006-11-23 07:32:13 +00003542#endif
Benny Prijono312aff92006-06-17 04:08:30 +00003543
3544
3545/**
Benny Prijonocba59d92007-02-16 09:22:56 +00003546 * The maximum file player.
3547 */
3548#ifndef PJSUA_MAX_PLAYERS
3549# define PJSUA_MAX_PLAYERS 32
3550#endif
3551
3552
3553/**
3554 * The maximum file player.
3555 */
3556#ifndef PJSUA_MAX_RECORDERS
3557# define PJSUA_MAX_RECORDERS 32
3558#endif
3559
3560
3561/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003562 * This structure describes media configuration, which will be specified
3563 * when calling #pjsua_init(). Application MUST initialize this structure
3564 * by calling #pjsua_media_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00003565 */
3566struct pjsua_media_config
3567{
3568 /**
3569 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003570 * If value is zero, default clock rate will be used
3571 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00003572 */
3573 unsigned clock_rate;
3574
3575 /**
Benny Prijonof3758ee2008-02-26 15:32:16 +00003576 * Clock rate to be applied when opening the sound device.
3577 * If value is zero, conference bridge clock rate will be used.
3578 */
3579 unsigned snd_clock_rate;
3580
3581 /**
Benny Prijono7d60d052008-03-29 12:24:20 +00003582 * Channel count be applied when opening the sound device and
3583 * conference bridge.
3584 */
3585 unsigned channel_count;
3586
3587 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003588 * Specify audio frame ptime. The value here will affect the
3589 * samples per frame of both the sound device and the conference
3590 * bridge. Specifying lower ptime will normally reduce the
3591 * latency.
3592 *
Benny Prijono37c710b2008-01-10 12:09:26 +00003593 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003594 */
3595 unsigned audio_frame_ptime;
3596
3597 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003598 * Specify maximum number of media ports to be created in the
3599 * conference bridge. Since all media terminate in the bridge
3600 * (calls, file player, file recorder, etc), the value must be
3601 * large enough to support all of them. However, the larger
3602 * the value, the more computations are performed.
Benny Prijono37c710b2008-01-10 12:09:26 +00003603 *
3604 * Default value: PJSUA_MAX_CONF_PORTS
Benny Prijono312aff92006-06-17 04:08:30 +00003605 */
3606 unsigned max_media_ports;
3607
3608 /**
3609 * Specify whether the media manager should manage its own
3610 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
3611 * and at least one worker thread will be created too. If no,
3612 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
3613 * and no worker thread is needed.
3614 *
3615 * Normally application would say yes here, unless it wants to
3616 * run everything from a single thread.
3617 */
3618 pj_bool_t has_ioqueue;
3619
3620 /**
3621 * Specify the number of worker threads to handle incoming RTP
3622 * packets. A value of one is recommended for most applications.
3623 */
3624 unsigned thread_cnt;
3625
Benny Prijono0498d902006-06-19 14:49:14 +00003626 /**
3627 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00003628 * 5-10: resampling use large filter,
3629 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00003630 * 1-2: resampling use linear.
3631 * The media quality also sets speex codec quality/complexity to the
3632 * number.
3633 *
Benny Prijono70972992006-08-05 11:13:58 +00003634 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00003635 */
3636 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00003637
3638 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003639 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00003640 *
3641 * Default: 0 (codec specific)
3642 */
3643 unsigned ptime;
3644
3645 /**
3646 * Disable VAD?
3647 *
3648 * Default: 0 (no (meaning VAD is enabled))
3649 */
3650 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00003651
3652 /**
3653 * iLBC mode (20 or 30).
3654 *
Benny Prijono37c710b2008-01-10 12:09:26 +00003655 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00003656 */
3657 unsigned ilbc_mode;
3658
3659 /**
3660 * Percentage of RTP packet to drop in TX direction
3661 * (to simulate packet lost).
3662 *
3663 * Default: 0
3664 */
3665 unsigned tx_drop_pct;
3666
3667 /**
3668 * Percentage of RTP packet to drop in RX direction
3669 * (to simulate packet lost).
3670 *
3671 * Default: 0
3672 */
3673 unsigned rx_drop_pct;
3674
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003675 /**
Benny Prijono5da50432006-08-07 10:24:52 +00003676 * Echo canceller options (see #pjmedia_echo_create())
3677 *
3678 * Default: 0.
3679 */
3680 unsigned ec_options;
3681
3682 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003683 * Echo canceller tail length, in miliseconds.
3684 *
Benny Prijono669643c2006-09-20 20:02:18 +00003685 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003686 */
3687 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003688
Benny Prijono10454dc2009-02-21 14:21:59 +00003689 /**
3690 * Audio capture buffer length, in milliseconds.
3691 *
3692 * Default: PJMEDIA_SND_DEFAULT_REC_LATENCY
3693 */
3694 unsigned snd_rec_latency;
3695
3696 /**
3697 * Audio playback buffer length, in milliseconds.
3698 *
3699 * Default: PJMEDIA_SND_DEFAULT_PLAY_LATENCY
3700 */
3701 unsigned snd_play_latency;
3702
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003703 /**
3704 * Jitter buffer initial prefetch delay in msec. The value must be
3705 * between jb_min_pre and jb_max_pre below.
3706 *
3707 * Default: -1 (to use default stream settings, currently 150 msec)
3708 */
3709 int jb_init;
3710
3711 /**
3712 * Jitter buffer minimum prefetch delay in msec.
3713 *
3714 * Default: -1 (to use default stream settings, currently 60 msec)
3715 */
3716 int jb_min_pre;
3717
3718 /**
3719 * Jitter buffer maximum prefetch delay in msec.
3720 *
3721 * Default: -1 (to use default stream settings, currently 240 msec)
3722 */
3723 int jb_max_pre;
3724
3725 /**
3726 * Set maximum delay that can be accomodated by the jitter buffer msec.
3727 *
3728 * Default: -1 (to use default stream settings, currently 360 msec)
3729 */
3730 int jb_max;
3731
Benny Prijonoc97608e2007-03-23 16:34:20 +00003732 /**
3733 * Enable ICE
3734 */
3735 pj_bool_t enable_ice;
3736
3737 /**
Benny Prijono329d6382009-05-29 13:04:03 +00003738 * Set the maximum number of host candidates.
3739 *
3740 * Default: -1 (maximum not set)
Benny Prijonoc97608e2007-03-23 16:34:20 +00003741 */
Benny Prijono329d6382009-05-29 13:04:03 +00003742 int ice_max_host_cands;
3743
3744 /**
3745 * ICE session options.
3746 */
3747 pj_ice_sess_options ice_opt;
Benny Prijonof76e1392008-06-06 14:51:48 +00003748
3749 /**
Benny Prijono551af422008-08-07 09:55:52 +00003750 * Disable RTCP component.
3751 *
3752 * Default: no
3753 */
3754 pj_bool_t ice_no_rtcp;
3755
3756 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00003757 * Enable TURN relay candidate in ICE.
3758 */
3759 pj_bool_t enable_turn;
3760
3761 /**
3762 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
3763 * "HOST:PORT" format.
3764 */
3765 pj_str_t turn_server;
3766
3767 /**
3768 * Specify the connection type to be used to the TURN server. Valid
3769 * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP.
3770 *
3771 * Default: PJ_TURN_TP_UDP
3772 */
3773 pj_turn_tp_type turn_conn_type;
3774
3775 /**
3776 * Specify the credential to authenticate with the TURN server.
3777 */
3778 pj_stun_auth_cred turn_auth_cred;
Nanang Izzuddin68559c32008-06-13 17:01:46 +00003779
3780 /**
3781 * Specify idle time of sound device before it is automatically closed,
Benny Prijonof798e502009-03-09 13:08:16 +00003782 * in seconds. Use value -1 to disable the auto-close feature of sound
3783 * device
Nanang Izzuddin68559c32008-06-13 17:01:46 +00003784 *
Benny Prijonof798e502009-03-09 13:08:16 +00003785 * Default : 1
Nanang Izzuddin68559c32008-06-13 17:01:46 +00003786 */
3787 int snd_auto_close_time;
Benny Prijono312aff92006-06-17 04:08:30 +00003788};
3789
3790
3791/**
3792 * Use this function to initialize media config.
3793 *
3794 * @param cfg The media config to be initialized.
3795 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003796PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00003797
3798
3799/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003800 * This structure describes codec information, which can be retrieved by
3801 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00003802 */
3803typedef struct pjsua_codec_info
3804{
3805 /**
3806 * Codec unique identification.
3807 */
3808 pj_str_t codec_id;
3809
3810 /**
3811 * Codec priority (integer 0-255).
3812 */
3813 pj_uint8_t priority;
3814
3815 /**
3816 * Internal buffer.
3817 */
3818 char buf_[32];
3819
3820} pjsua_codec_info;
3821
3822
3823/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003824 * This structure descibes information about a particular media port that
3825 * has been registered into the conference bridge. Application can query
3826 * this info by calling #pjsua_conf_get_port_info().
Benny Prijono312aff92006-06-17 04:08:30 +00003827 */
3828typedef struct pjsua_conf_port_info
3829{
3830 /** Conference port number. */
3831 pjsua_conf_port_id slot_id;
3832
3833 /** Port name. */
3834 pj_str_t name;
3835
3836 /** Clock rate. */
3837 unsigned clock_rate;
3838
3839 /** Number of channels. */
3840 unsigned channel_count;
3841
3842 /** Samples per frame */
3843 unsigned samples_per_frame;
3844
3845 /** Bits per sample */
3846 unsigned bits_per_sample;
3847
3848 /** Number of listeners in the array. */
3849 unsigned listener_cnt;
3850
3851 /** Array of listeners (in other words, ports where this port is
3852 * transmitting to.
3853 */
3854 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
3855
3856} pjsua_conf_port_info;
3857
3858
3859/**
3860 * This structure holds information about custom media transport to
3861 * be registered to pjsua.
3862 */
3863typedef struct pjsua_media_transport
3864{
3865 /**
3866 * Media socket information containing the address information
3867 * of the RTP and RTCP socket.
3868 */
3869 pjmedia_sock_info skinfo;
3870
3871 /**
3872 * The media transport instance.
3873 */
3874 pjmedia_transport *transport;
3875
3876} pjsua_media_transport;
3877
3878
3879
3880
Benny Prijono9fc735d2006-05-28 14:58:12 +00003881/**
3882 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003883 *
3884 * @return Maximum number of ports in the conference bridge.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003885 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003886PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003887
3888
3889/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003890 * Get current number of active ports in the bridge.
3891 *
3892 * @return The number.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003893 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003894PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
3895
3896
3897/**
3898 * Enumerate all conference ports.
3899 *
3900 * @param id Array of conference port ID to be initialized.
3901 * @param count On input, specifies max elements in the array.
3902 * On return, it contains actual number of elements
3903 * that have been initialized.
3904 *
3905 * @return PJ_SUCCESS on success, or the appropriate error code.
3906 */
3907PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
3908 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003909
3910
3911/**
3912 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003913 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003914 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003915 * @param info Pointer to store the port info.
3916 *
3917 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00003918 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003919PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00003920 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003921
3922
3923/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00003924 * Add arbitrary media port to PJSUA's conference bridge. Application
3925 * can use this function to add the media port that it creates. For
3926 * media ports that are created by PJSUA-LIB (such as calls, file player,
3927 * or file recorder), PJSUA-LIB will automatically add the port to
3928 * the bridge.
3929 *
3930 * @param pool Pool to use.
3931 * @param port Media port to be added to the bridge.
3932 * @param p_id Optional pointer to receive the conference
3933 * slot id.
3934 *
3935 * @return PJ_SUCCESS on success, or the appropriate error code.
3936 */
3937PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
3938 pjmedia_port *port,
3939 pjsua_conf_port_id *p_id);
3940
3941
3942/**
3943 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00003944 * call this function if it registered the port manually with previous call
3945 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00003946 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003947 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00003948 *
3949 * @return PJ_SUCCESS on success, or the appropriate error code.
3950 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003951PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00003952
3953
3954/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003955 * Establish unidirectional media flow from souce to sink. One source
3956 * may transmit to multiple destinations/sink. And if multiple
3957 * sources are transmitting to the same sink, the media will be mixed
3958 * together. Source and sink may refer to the same ID, effectively
3959 * looping the media.
3960 *
3961 * If bidirectional media flow is desired, application needs to call
3962 * this function twice, with the second one having the arguments
3963 * reversed.
3964 *
3965 * @param source Port ID of the source media/transmitter.
3966 * @param sink Port ID of the destination media/received.
3967 *
3968 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003969 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003970PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
3971 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003972
3973
3974/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003975 * Disconnect media flow from the source to destination port.
3976 *
3977 * @param source Port ID of the source media/transmitter.
3978 * @param sink Port ID of the destination media/received.
3979 *
3980 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003981 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003982PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
3983 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003984
3985
Benny Prijono6dd967c2006-12-26 02:27:14 +00003986/**
3987 * Adjust the signal level to be transmitted from the bridge to the
3988 * specified port by making it louder or quieter.
3989 *
3990 * @param slot The conference bridge slot number.
3991 * @param level Signal level adjustment. Value 1.0 means no level
3992 * adjustment, while value 0 means to mute the port.
3993 *
3994 * @return PJ_SUCCESS on success, or the appropriate error code.
3995 */
3996PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
3997 float level);
3998
3999/**
4000 * Adjust the signal level to be received from the specified port (to
4001 * the bridge) by making it louder or quieter.
4002 *
4003 * @param slot The conference bridge slot number.
4004 * @param level Signal level adjustment. Value 1.0 means no level
4005 * adjustment, while value 0 means to mute the port.
4006 *
4007 * @return PJ_SUCCESS on success, or the appropriate error code.
4008 */
4009PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
4010 float level);
4011
4012/**
4013 * Get last signal level transmitted to or received from the specified port.
4014 * The signal level is an integer value in zero to 255, with zero indicates
4015 * no signal, and 255 indicates the loudest signal level.
4016 *
4017 * @param slot The conference bridge slot number.
4018 * @param tx_level Optional argument to receive the level of signal
4019 * transmitted to the specified port (i.e. the direction
4020 * is from the bridge to the port).
4021 * @param rx_level Optional argument to receive the level of signal
4022 * received from the port (i.e. the direction is from the
4023 * port to the bridge).
4024 *
4025 * @return PJ_SUCCESS on success.
4026 */
4027PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
4028 unsigned *tx_level,
4029 unsigned *rx_level);
4030
Benny Prijono6dd967c2006-12-26 02:27:14 +00004031
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004032/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00004033 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004034 */
4035
Benny Prijono9fc735d2006-05-28 14:58:12 +00004036/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004037 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004038 * the conference bridge.
4039 *
4040 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00004041 * WAV files are supported, and the WAV file MUST be
4042 * formatted as 16bit PCM mono/single channel (any
4043 * clock rate is supported).
Benny Prijono58add7c2008-01-18 13:24:07 +00004044 * @param options Optional option flag. Application may specify
4045 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004046 * @param p_id Pointer to receive player ID.
4047 *
4048 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004049 */
4050PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004051 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004052 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004053
4054
4055/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004056 * Create a file playlist media port, and automatically add the port
4057 * to the conference bridge.
4058 *
4059 * @param file_names Array of file names to be added to the play list.
4060 * Note that the files must have the same clock rate,
4061 * number of channels, and number of bits per sample.
4062 * @param file_count Number of files in the array.
4063 * @param label Optional label to be set for the media port.
4064 * @param options Optional option flag. Application may specify
4065 * PJMEDIA_FILE_NO_LOOP to prevent looping.
4066 * @param p_id Optional pointer to receive player ID.
4067 *
4068 * @return PJ_SUCCESS on success, or the appropriate error code.
4069 */
4070PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
4071 unsigned file_count,
4072 const pj_str_t *label,
4073 unsigned options,
4074 pjsua_player_id *p_id);
4075
4076/**
4077 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004078 *
4079 * @param id The file player ID.
4080 *
4081 * @return Conference port ID associated with this player.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004082 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004083PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004084
4085
4086/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004087 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00004088 *
4089 * @param id The player ID.
4090 * @param p_port The media port associated with the player.
4091 *
4092 * @return PJ_SUCCESS on success.
4093 */
Benny Prijono58add7c2008-01-18 13:24:07 +00004094PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
Benny Prijono469b1522006-12-26 03:05:17 +00004095 pjmedia_port **p_port);
4096
4097/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004098 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004099 *
4100 * @param id The file player ID.
4101 * @param samples The playback position, in samples. Application can
4102 * specify zero to re-start the playback.
4103 *
4104 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004105 */
4106PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
4107 pj_uint32_t samples);
4108
4109
4110/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00004111 * Close the file of playlist, remove the player from the bridge, and free
4112 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004113 *
4114 * @param id The file player ID.
4115 *
4116 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004117 */
4118PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
4119
4120
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004121/*****************************************************************************
4122 * File recorder.
4123 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00004124
4125/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004126 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004127 * the conference bridge. The recorder currently supports recording WAV file.
4128 * The type of the recorder to use is determined by the extension of the file
4129 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004130 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00004131 * @param filename Output file name. The function will determine the
4132 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004133 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00004134 * @param enc_type Optionally specify the type of encoder to be used to
4135 * compress the media, if the file can support different
4136 * encodings. This value must be zero for now.
4137 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00004138 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00004139 * For .WAV recorder, this value must be NULL.
4140 * @param max_size Maximum file size. Specify zero or -1 to remove size
4141 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004142 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004143 * @param p_id Pointer to receive the recorder instance.
4144 *
4145 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004146 */
4147PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00004148 unsigned enc_type,
4149 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004150 pj_ssize_t max_size,
4151 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004152 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004153
4154
4155/**
4156 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004157 *
4158 * @param id The recorder ID.
4159 *
4160 * @return Conference port ID associated with this recorder.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004161 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00004162PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00004163
4164
4165/**
Benny Prijono469b1522006-12-26 03:05:17 +00004166 * Get the media port for the recorder.
4167 *
4168 * @param id The recorder ID.
4169 * @param p_port The media port associated with the recorder.
4170 *
4171 * @return PJ_SUCCESS on success.
4172 */
4173PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
4174 pjmedia_port **p_port);
4175
4176
4177/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004178 * Destroy recorder (this will complete recording).
4179 *
4180 * @param id The recorder ID.
4181 *
4182 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004183 */
4184PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
4185
4186
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004187/*****************************************************************************
4188 * Sound devices.
4189 */
4190
Benny Prijono9fc735d2006-05-28 14:58:12 +00004191/**
Benny Prijonof798e502009-03-09 13:08:16 +00004192 * Enum all audio devices installed in the system.
4193 *
4194 * @param info Array of info to be initialized.
4195 * @param count On input, specifies max elements in the array.
4196 * On return, it contains actual number of elements
4197 * that have been initialized.
4198 *
4199 * @return PJ_SUCCESS on success, or the appropriate error code.
4200 */
4201PJ_DECL(pj_status_t) pjsua_enum_aud_devs(pjmedia_aud_dev_info info[],
4202 unsigned *count);
4203
4204/**
4205 * Enum all sound devices installed in the system (old API).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004206 *
4207 * @param info Array of info to be initialized.
4208 * @param count On input, specifies max elements in the array.
4209 * On return, it contains actual number of elements
4210 * that have been initialized.
4211 *
4212 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004213 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004214PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
4215 unsigned *count);
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00004216
4217/**
4218 * Get currently active sound devices. If sound devices has not been created
4219 * (for example when pjsua_start() is not called), it is possible that
4220 * the function returns PJ_SUCCESS with -1 as device IDs.
4221 *
4222 * @param capture_dev On return it will be filled with device ID of the
4223 * capture device.
4224 * @param playback_dev On return it will be filled with device ID of the
4225 * device ID of the playback device.
4226 *
4227 * @return PJ_SUCCESS on success, or the appropriate error code.
4228 */
4229PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
4230 int *playback_dev);
4231
4232
Benny Prijono9fc735d2006-05-28 14:58:12 +00004233/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004234 * Select or change sound device. Application may call this function at
4235 * any time to replace current sound device.
4236 *
4237 * @param capture_dev Device ID of the capture device.
4238 * @param playback_dev Device ID of the playback device.
4239 *
4240 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00004241 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004242PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
4243 int playback_dev);
4244
4245
4246/**
4247 * Set pjsua to use null sound device. The null sound device only provides
4248 * the timing needed by the conference bridge, and will not interract with
4249 * any hardware.
4250 *
4251 * @return PJ_SUCCESS on success, or the appropriate error code.
4252 */
4253PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
4254
4255
Benny Prijonoe909eac2006-07-27 22:04:56 +00004256/**
4257 * Disconnect the main conference bridge from any sound devices, and let
4258 * application connect the bridge to it's own sound device/master port.
4259 *
4260 * @return The port interface of the conference bridge,
4261 * so that application can connect this to it's own
4262 * sound device or master port.
4263 */
4264PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
4265
4266
Benny Prijonof20687a2006-08-04 18:27:19 +00004267/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004268 * Change the echo cancellation settings.
Benny Prijonof798e502009-03-09 13:08:16 +00004269 *
4270 * The behavior of this function depends on whether the sound device is
4271 * currently active, and if it is, whether device or software AEC is
4272 * being used.
Benny Prijono10454dc2009-02-21 14:21:59 +00004273 *
4274 * If the sound device is currently active, and if the device supports AEC,
4275 * this function will forward the change request to the device and it will
4276 * be up to the device on whether support the request. If software AEC is
4277 * being used (the software EC will be used if the device does not support
4278 * AEC), this function will change the software EC settings. In all cases,
4279 * the setting will be saved for future opening of the sound device.
4280 *
4281 * If the sound device is not currently active, this will only change the
4282 * default AEC settings and the setting will be applied next time the
4283 * sound device is opened.
Benny Prijonof20687a2006-08-04 18:27:19 +00004284 *
4285 * @param tail_ms The tail length, in miliseconds. Set to zero to
4286 * disable AEC.
Benny Prijonoa7b376b2008-01-25 16:06:33 +00004287 * @param options Options to be passed to pjmedia_echo_create().
Benny Prijono5da50432006-08-07 10:24:52 +00004288 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004289 *
4290 * @return PJ_SUCCESS on success.
4291 */
Benny Prijono5da50432006-08-07 10:24:52 +00004292PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004293
4294
4295/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004296 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004297 *
4298 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4299 * If AEC is disabled, the value will be zero.
4300 *
4301 * @return PJ_SUCCESS on success.
4302 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004303PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004304
4305
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004306/**
Benny Prijonof798e502009-03-09 13:08:16 +00004307 * Check whether the sound device is currently active. The sound device
4308 * may be inactive if the application has set the auto close feature to
4309 * non-zero (the snd_auto_close_time setting in #pjsua_media_config), or
4310 * if null sound device or no sound device has been configured via the
4311 * #pjsua_set_no_snd_dev() function.
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004312 */
Benny Prijonof798e502009-03-09 13:08:16 +00004313PJ_DECL(pj_bool_t) pjsua_snd_is_active(void);
4314
4315
4316/**
4317 * Configure sound device setting to the sound device being used. If sound
4318 * device is currently active, the function will forward the setting to the
4319 * sound device instance to be applied immediately, if it supports it.
4320 *
4321 * The setting will be saved for future opening of the sound device, if the
4322 * "keep" argument is set to non-zero. If the sound device is currently
4323 * inactive, and the "keep" argument is false, this function will return
4324 * error.
4325 *
4326 * Note that in case the setting is kept for future use, it will be applied
4327 * to any devices, even when application has changed the sound device to be
4328 * used.
4329 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004330 * Note also that the echo cancellation setting should be set with
4331 * #pjsua_set_ec() API instead.
4332 *
Benny Prijonof798e502009-03-09 13:08:16 +00004333 * See also #pjmedia_aud_stream_set_cap() for more information about setting
4334 * an audio device capability.
4335 *
4336 * @param cap The sound device setting to change.
4337 * @param pval Pointer to value. Please see #pjmedia_aud_dev_cap
4338 * documentation about the type of value to be
4339 * supplied for each setting.
4340 * @param keep Specify whether the setting is to be kept for future
4341 * use.
4342 *
4343 * @return PJ_SUCCESS on success or the appropriate error code.
4344 */
4345PJ_DECL(pj_status_t) pjsua_snd_set_setting(pjmedia_aud_dev_cap cap,
4346 const void *pval,
4347 pj_bool_t keep);
4348
4349/**
4350 * Retrieve a sound device setting. If sound device is currently active,
4351 * the function will forward the request to the sound device. If sound device
4352 * is currently inactive, and if application had previously set the setting
4353 * and mark the setting as kept, then that setting will be returned.
4354 * Otherwise, this function will return error.
4355 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004356 * Note that echo cancellation settings should be retrieved with
4357 * #pjsua_get_ec_tail() API instead.
4358 *
Benny Prijonof798e502009-03-09 13:08:16 +00004359 * @param cap The sound device setting to retrieve.
4360 * @param pval Pointer to receive the value.
4361 * Please see #pjmedia_aud_dev_cap documentation about
4362 * the type of value to be supplied for each setting.
4363 *
4364 * @return PJ_SUCCESS on success or the appropriate error code.
4365 */
4366PJ_DECL(pj_status_t) pjsua_snd_get_setting(pjmedia_aud_dev_cap cap,
4367 void *pval);
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004368
4369
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004370/*****************************************************************************
4371 * Codecs.
4372 */
4373
4374/**
4375 * Enum all supported codecs in the system.
4376 *
4377 * @param id Array of ID to be initialized.
4378 * @param count On input, specifies max elements in the array.
4379 * On return, it contains actual number of elements
4380 * that have been initialized.
4381 *
4382 * @return PJ_SUCCESS on success, or the appropriate error code.
4383 */
4384PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4385 unsigned *count );
4386
4387
4388/**
4389 * Change codec priority.
4390 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004391 * @param codec_id Codec ID, which is a string that uniquely identify
4392 * the codec (such as "speex/8000"). Please see pjsua
4393 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004394 * @param priority Codec priority, 0-255, where zero means to disable
4395 * the codec.
4396 *
4397 * @return PJ_SUCCESS on success, or the appropriate error code.
4398 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004399PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004400 pj_uint8_t priority );
4401
4402
4403/**
4404 * Get codec parameters.
4405 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004406 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004407 * @param param Structure to receive codec parameters.
4408 *
4409 * @return PJ_SUCCESS on success, or the appropriate error code.
4410 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004411PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004412 pjmedia_codec_param *param );
4413
4414
4415/**
4416 * Set codec parameters.
4417 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004418 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004419 * @param param Codec parameter to set.
4420 *
4421 * @return PJ_SUCCESS on success, or the appropriate error code.
4422 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004423PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004424 const pjmedia_codec_param *param);
4425
4426
4427
Benny Prijono9fc735d2006-05-28 14:58:12 +00004428
Benny Prijono312aff92006-06-17 04:08:30 +00004429/**
4430 * Create UDP media transports for all the calls. This function creates
4431 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00004432 *
Benny Prijono312aff92006-06-17 04:08:30 +00004433 * @param cfg Media transport configuration. The "port" field in the
4434 * configuration is used as the start port to bind the
4435 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004436 *
4437 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonof3195072006-02-14 21:15:30 +00004438 */
Benny Prijono312aff92006-06-17 04:08:30 +00004439PJ_DECL(pj_status_t)
4440pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00004441
Benny Prijonodc39fe82006-05-26 12:17:46 +00004442
4443/**
Benny Prijono312aff92006-06-17 04:08:30 +00004444 * Register custom media transports to be used by calls. There must
4445 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004446 *
Benny Prijono312aff92006-06-17 04:08:30 +00004447 * @param tp The media transport array.
4448 * @param count Number of elements in the array. This number MUST
4449 * match the number of maximum calls configured when
4450 * pjsua is created.
4451 * @param auto_delete Flag to indicate whether the transports should be
4452 * destroyed when pjsua is shutdown.
4453 *
4454 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00004455 */
Benny Prijono312aff92006-06-17 04:08:30 +00004456PJ_DECL(pj_status_t)
4457pjsua_media_transports_attach( pjsua_media_transport tp[],
4458 unsigned count,
4459 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00004460
4461
Benny Prijono312aff92006-06-17 04:08:30 +00004462/**
4463 * @}
4464 */
4465
Benny Prijonof3195072006-02-14 21:15:30 +00004466
Benny Prijono268ca612006-02-07 12:34:11 +00004467
Benny Prijono312aff92006-06-17 04:08:30 +00004468/**
4469 * @}
4470 */
4471
Benny Prijonoe6ead542007-01-31 20:53:31 +00004472PJ_END_DECL
4473
Benny Prijono312aff92006-06-17 04:08:30 +00004474
Benny Prijono268ca612006-02-07 12:34:11 +00004475#endif /* __PJSUA_H__ */