blob: 44980caa14b916f694f57d8c661819f3054e9021 [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 Prijonoebbf6892007-03-24 17:37:25 +0000894 * Specify domain name to be resolved with DNS SRV resolution to get the
Benny Prijonof76e1392008-06-06 14:51:48 +0000895 * address of the STUN server. Alternatively application may specify
896 * \a stun_host instead.
Benny Prijonoebbf6892007-03-24 17:37:25 +0000897 *
898 * If DNS SRV resolution failed for this domain, then DNS A resolution
899 * will be performed only if \a stun_host is specified.
Benny Prijonoc97608e2007-03-23 16:34:20 +0000900 */
Benny Prijonoebbf6892007-03-24 17:37:25 +0000901 pj_str_t stun_domain;
902
903 /**
Benny Prijonoaf09dc32007-04-22 12:48:30 +0000904 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
905 * not specified, default port 3478 will be used.
Benny Prijonoebbf6892007-03-24 17:37:25 +0000906 */
907 pj_str_t stun_host;
908
909 /**
Benny Prijono91a6a172007-10-31 08:59:29 +0000910 * Support for adding and parsing NAT type in the SDP to assist
911 * troubleshooting. The valid values are:
912 * - 0: no information will be added in SDP, and parsing is disabled.
Benny Prijono6ba8c542007-10-16 01:34:14 +0000913 * - 1: only the NAT type number is added.
914 * - 2: add both NAT type number and name.
915 *
Benny Prijono91a6a172007-10-31 08:59:29 +0000916 * Default: 1
Benny Prijono6ba8c542007-10-16 01:34:14 +0000917 */
918 int nat_type_in_sdp;
919
920 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +0000921 * Specify whether support for reliable provisional response (100rel and
922 * PRACK) should be required by default. Note that this setting can be
923 * further customized in account configuration (#pjsua_acc_config).
924 *
925 * Default: PJ_FALSE
926 */
927 pj_bool_t require_100rel;
928
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000929 /**
930 * Number of credentials in the credential array.
931 */
932 unsigned cred_count;
933
934 /**
935 * Array of credentials. These credentials will be used by all accounts,
Benny Prijonob5388cf2007-01-04 22:45:08 +0000936 * and can be used to authenticate against outbound proxies. If the
937 * credential is specific to the account, then application should set
938 * the credential in the pjsua_acc_config rather than the credential
939 * here.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000940 */
941 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
942
943 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000944 * Application callback to receive various event notifications from
945 * the library.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000946 */
947 pjsua_callback cb;
948
Benny Prijono56315612006-07-18 14:39:40 +0000949 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +0000950 * Optional user agent string (default empty). If it's empty, no
951 * User-Agent header will be sent with outgoing requests.
Benny Prijono56315612006-07-18 14:39:40 +0000952 */
953 pj_str_t user_agent;
954
Benny Prijonod8179652008-01-23 20:39:07 +0000955#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
956 /**
957 * Specify default value of secure media transport usage.
958 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
959 * PJMEDIA_SRTP_MANDATORY.
960 *
961 * Note that this setting can be further customized in account
962 * configuration (#pjsua_acc_config).
963 *
964 * Default: #PJSUA_DEFAULT_USE_SRTP
965 */
966 pjmedia_srtp_use use_srtp;
967
968 /**
969 * Specify whether SRTP requires secure signaling to be used. This option
970 * is only used when \a use_srtp option above is non-zero.
971 *
972 * Valid values are:
973 * 0: SRTP does not require secure signaling
974 * 1: SRTP requires secure transport such as TLS
975 * 2: SRTP requires secure end-to-end transport (SIPS)
976 *
977 * Note that this setting can be further customized in account
978 * configuration (#pjsua_acc_config).
979 *
980 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
981 */
982 int srtp_secure_signaling;
983#endif
984
Benny Prijono3c5e28b2008-09-24 10:10:15 +0000985 /**
986 * Disconnect other call legs when more than one 2xx responses for
987 * outgoing INVITE are received due to forking. Currently the library
988 * is not able to handle simultaneous forked media, so disconnecting
989 * the other call legs is necessary.
990 *
991 * With this setting enabled, the library will handle only one of the
992 * connected call leg, and the other connected call legs will be
993 * disconnected.
994 *
995 * Default: PJ_TRUE (only disable this setting for testing purposes).
996 */
997 pj_bool_t hangup_forked_call;
998
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000999} pjsua_config;
1000
1001
1002/**
1003 * Use this function to initialize pjsua config.
1004 *
1005 * @param cfg pjsua config to be initialized.
1006 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001007PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001008
1009
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001010/** The implementation has been moved to sip_auth.h */
Benny Prijono7977f9f2007-10-10 11:37:56 +00001011#define pjsip_cred_dup pjsip_cred_info_dup
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001012
1013
1014/**
1015 * Duplicate pjsua_config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001016 *
1017 * @param pool The pool to get memory from.
1018 * @param dst Destination config.
1019 * @param src Source config.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001020 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001021PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1022 pjsua_config *dst,
1023 const pjsua_config *src);
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001024
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001025
1026/**
1027 * This structure describes additional information to be sent with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001028 * outgoing SIP message. It can (optionally) be specified for example
1029 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1030 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1031 *
1032 * Application MUST call #pjsua_msg_data_init() to initialize this
1033 * structure before setting its values.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001034 */
Benny Prijono63fba012008-07-17 14:19:10 +00001035struct pjsua_msg_data
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001036{
1037 /**
Benny Prijonoc92ca5c2007-06-11 17:03:41 +00001038 * Additional message headers as linked list. Application can add
1039 * headers to the list by creating the header, either from the heap/pool
1040 * or from temporary local variable, and add the header using
1041 * linked list operation. See pjsip_apps.c for some sample codes.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001042 */
1043 pjsip_hdr hdr_list;
1044
1045 /**
1046 * MIME type of optional message body.
1047 */
1048 pj_str_t content_type;
1049
1050 /**
1051 * Optional message body.
1052 */
1053 pj_str_t msg_body;
1054
Benny Prijono63fba012008-07-17 14:19:10 +00001055};
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001056
1057
1058/**
1059 * Initialize message data.
1060 *
1061 * @param msg_data Message data to be initialized.
1062 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001063PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
Benny Prijono268ca612006-02-07 12:34:11 +00001064
Benny Prijono268ca612006-02-07 12:34:11 +00001065
1066/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001067 * Instantiate pjsua application. Application must call this function before
1068 * calling any other functions, to make sure that the underlying libraries
1069 * are properly initialized. Once this function has returned success,
1070 * application must call pjsua_destroy() before quitting.
1071 *
1072 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00001073 */
1074PJ_DECL(pj_status_t) pjsua_create(void);
1075
1076
Benny Prijonoa7b376b2008-01-25 16:06:33 +00001077/** Forward declaration */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001078typedef struct pjsua_media_config pjsua_media_config;
1079
1080
Benny Prijonodc39fe82006-05-26 12:17:46 +00001081/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001082 * Initialize pjsua with the specified settings. All the settings are
1083 * optional, and the default values will be used when the config is not
1084 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001085 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001086 * Note that #pjsua_create() MUST be called before calling this function.
1087 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001088 * @param ua_cfg User agent configuration.
1089 * @param log_cfg Optional logging configuration.
1090 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001091 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001092 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001093 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001094PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1095 const pjsua_logging_config *log_cfg,
1096 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001097
1098
1099/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001100 * Application is recommended to call this function after all initialization
1101 * is done, so that the library can do additional checking set up
1102 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001103 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001104 * Application may call this function anytime after #pjsua_init().
1105 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001106 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoccf95622006-02-07 18:48:01 +00001107 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001108PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001109
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001110
Benny Prijonoccf95622006-02-07 18:48:01 +00001111/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001112 * Destroy pjsua. Application is recommended to perform graceful shutdown
1113 * before calling this function (such as unregister the account from the SIP
1114 * server, terminate presense subscription, and hangup active calls), however,
1115 * this function will do all of these if it finds there are active sessions
1116 * that need to be terminated. This function will approximately block for
1117 * one second to wait for replies from remote.
1118 *
1119 * Application.may safely call this function more than once if it doesn't
1120 * keep track of it's state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001121 *
1122 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001123 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001124PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001125
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001126
Benny Prijono9fc735d2006-05-28 14:58:12 +00001127/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001128 * Poll pjsua for events, and if necessary block the caller thread for
1129 * the specified maximum interval (in miliseconds).
1130 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00001131 * Application doesn't normally need to call this function if it has
1132 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1133 * because polling then will be done by these worker threads instead.
1134 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001135 * @param msec_timeout Maximum time to wait, in miliseconds.
1136 *
1137 * @return The number of events that have been handled during the
1138 * poll. Negative value indicates error, and application
Benny Prijonoe6ead542007-01-31 20:53:31 +00001139 * can retrieve the error as (status = -return_value).
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001140 */
1141PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1142
1143
1144/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001145 * Create memory pool to be used by the application. Once application
1146 * finished using the pool, it must be released with pj_pool_release().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001147 *
1148 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +00001149 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001150 * @param increment Increment size.
1151 *
1152 * @return The pool, or NULL when there's no memory.
1153 */
1154PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1155 pj_size_t increment);
1156
1157
1158/**
1159 * Application can call this function at any time (after pjsua_create(), of
1160 * course) to change logging settings.
1161 *
1162 * @param c Logging configuration.
1163 *
1164 * @return PJ_SUCCESS on success, or the appropriate error code.
1165 */
1166PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1167
1168
1169/**
1170 * Internal function to get SIP endpoint instance of pjsua, which is
1171 * needed for example to register module, create transports, etc.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001172 * Only valid after #pjsua_init() is called.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001173 *
1174 * @return SIP endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001175 */
1176PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1177
1178/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001179 * Internal function to get media endpoint instance.
1180 * Only valid after #pjsua_init() is called.
1181 *
1182 * @return Media endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001183 */
1184PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1185
Benny Prijono97b87172006-08-24 14:25:14 +00001186/**
1187 * Internal function to get PJSUA pool factory.
Benny Prijonob5388cf2007-01-04 22:45:08 +00001188 * Only valid after #pjsua_create() is called.
Benny Prijono97b87172006-08-24 14:25:14 +00001189 *
1190 * @return Pool factory currently used by PJSUA.
1191 */
1192PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1193
1194
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001195
1196/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001197 * Utilities.
1198 *
Benny Prijono9fc735d2006-05-28 14:58:12 +00001199 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001200
1201/**
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001202 * This is a utility function to detect NAT type in front of this
1203 * endpoint. Once invoked successfully, this function will complete
Benny Prijono6ba8c542007-10-16 01:34:14 +00001204 * asynchronously and report the result in \a on_nat_detect() callback
1205 * of pjsua_callback.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001206 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001207 * After NAT has been detected and the callback is called, application can
1208 * get the detected NAT type by calling #pjsua_get_nat_type(). Application
1209 * can also perform NAT detection by calling #pjsua_detect_nat_type()
1210 * again at later time.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001211 *
Benny Prijono6ba8c542007-10-16 01:34:14 +00001212 * Note that STUN must be enabled to run this function successfully.
1213 *
1214 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001215 */
Benny Prijono6ba8c542007-10-16 01:34:14 +00001216PJ_DECL(pj_status_t) pjsua_detect_nat_type(void);
1217
1218
1219/**
1220 * Get the NAT type as detected by #pjsua_detect_nat_type() function.
1221 * This function will only return useful NAT type after #pjsua_detect_nat_type()
1222 * has completed successfully and \a on_nat_detect() callback has been called.
1223 *
1224 * @param type NAT type.
1225 *
1226 * @return When detection is in progress, this function will
1227 * return PJ_EPENDING and \a type will be set to
1228 * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been
1229 * detected successfully, this function will return
1230 * PJ_SUCCESS and \a type will be set to the correct
1231 * value. Other return values indicate error and
1232 * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN.
Benny Prijono91a6a172007-10-31 08:59:29 +00001233 *
1234 * @see pjsua_call_get_rem_nat_type()
Benny Prijono6ba8c542007-10-16 01:34:14 +00001235 */
1236PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type);
Benny Prijono4ab9fbb2007-10-12 12:14:27 +00001237
1238
1239/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001240 * This is a utility function to verify that valid SIP url is given. If the
1241 * URL is valid, PJ_SUCCESS will be returned.
Benny Prijono312aff92006-06-17 04:08:30 +00001242 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001243 * @param url The URL, as NULL terminated string.
Benny Prijono312aff92006-06-17 04:08:30 +00001244 *
1245 * @return PJ_SUCCESS on success, or the appropriate error code.
1246 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001247PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
Benny Prijono312aff92006-06-17 04:08:30 +00001248
1249
1250/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001251 * This is a utility function to display error message for the specified
1252 * error code. The error message will be sent to the log.
Benny Prijono312aff92006-06-17 04:08:30 +00001253 *
1254 * @param sender The log sender field.
1255 * @param title Message title for the error.
1256 * @param status Status code.
1257 */
1258PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
1259 pj_status_t status);
1260
1261
Benny Prijonoda9785b2007-04-02 20:43:06 +00001262/**
1263 * This is a utility function to dump the stack states to log, using
1264 * verbosity level 3.
1265 *
1266 * @param detail Will print detailed output (such as list of
1267 * SIP transactions) when non-zero.
1268 */
1269PJ_DECL(void) pjsua_dump(pj_bool_t detail);
Benny Prijono312aff92006-06-17 04:08:30 +00001270
1271/**
1272 * @}
1273 */
1274
1275
1276
1277/*****************************************************************************
1278 * TRANSPORT API
1279 */
1280
1281/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001282 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
Benny Prijono312aff92006-06-17 04:08:30 +00001283 * @ingroup PJSUA_LIB
1284 * @brief API for managing SIP transports
1285 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001286 *
1287 * PJSUA-API supports creating multiple transport instances, for example UDP,
1288 * TCP, and TLS transport. SIP transport must be created before adding an
1289 * account.
Benny Prijono312aff92006-06-17 04:08:30 +00001290 */
1291
1292
Benny Prijonoe6ead542007-01-31 20:53:31 +00001293/** SIP transport identification.
1294 */
Benny Prijono312aff92006-06-17 04:08:30 +00001295typedef int pjsua_transport_id;
1296
1297
1298/**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001299 * Transport configuration for creating transports for both SIP
Benny Prijonob5388cf2007-01-04 22:45:08 +00001300 * and media. Before setting some values to this structure, application
1301 * MUST call #pjsua_transport_config_default() to initialize its
1302 * values with default settings.
Benny Prijono312aff92006-06-17 04:08:30 +00001303 */
1304typedef struct pjsua_transport_config
1305{
1306 /**
1307 * UDP port number to bind locally. This setting MUST be specified
1308 * even when default port is desired. If the value is zero, the
1309 * transport will be bound to any available port, and application
1310 * can query the port by querying the transport info.
1311 */
1312 unsigned port;
1313
1314 /**
Benny Prijono0a5cad82006-09-26 13:21:02 +00001315 * Optional address to advertise as the address of this transport.
1316 * Application can specify any address or hostname for this field,
1317 * for example it can point to one of the interface address in the
1318 * system, or it can point to the public address of a NAT router
1319 * where port mappings have been configured for the application.
1320 *
1321 * Note: this option can be used for both UDP and TCP as well!
Benny Prijono312aff92006-06-17 04:08:30 +00001322 */
Benny Prijono0a5cad82006-09-26 13:21:02 +00001323 pj_str_t public_addr;
1324
1325 /**
1326 * Optional address where the socket should be bound to. This option
1327 * SHOULD only be used to selectively bind the socket to particular
1328 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
1329 * published address of a transport (the public_addr field should be
1330 * used for that purpose).
1331 *
1332 * Note that unlike public_addr field, the address (or hostname) here
1333 * MUST correspond to the actual interface address in the host, since
1334 * this address will be specified as bind() argument.
1335 */
1336 pj_str_t bound_addr;
Benny Prijono312aff92006-06-17 04:08:30 +00001337
1338 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001339 * This specifies TLS settings for TLS transport. It is only be used
1340 * when this transport config is being used to create a SIP TLS
1341 * transport.
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001342 */
Benny Prijonof3bbc132006-12-25 06:43:59 +00001343 pjsip_tls_setting tls_setting;
Benny Prijono6e0e54b2006-12-08 21:58:31 +00001344
Benny Prijono312aff92006-06-17 04:08:30 +00001345} pjsua_transport_config;
1346
1347
1348/**
1349 * Call this function to initialize UDP config with default values.
1350 *
1351 * @param cfg The UDP config to be initialized.
1352 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001353PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001354
1355
1356/**
Benny Prijono312aff92006-06-17 04:08:30 +00001357 * Duplicate transport config.
Benny Prijonoe6ead542007-01-31 20:53:31 +00001358 *
1359 * @param pool The pool.
1360 * @param dst The destination config.
1361 * @param src The source config.
Benny Prijono312aff92006-06-17 04:08:30 +00001362 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001363PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
1364 pjsua_transport_config *dst,
1365 const pjsua_transport_config *src);
Benny Prijono312aff92006-06-17 04:08:30 +00001366
1367
1368/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001369 * This structure describes transport information returned by
1370 * #pjsua_transport_get_info() function.
Benny Prijono312aff92006-06-17 04:08:30 +00001371 */
1372typedef struct pjsua_transport_info
1373{
1374 /**
1375 * PJSUA transport identification.
1376 */
1377 pjsua_transport_id id;
1378
1379 /**
1380 * Transport type.
1381 */
1382 pjsip_transport_type_e type;
1383
1384 /**
1385 * Transport type name.
1386 */
1387 pj_str_t type_name;
1388
1389 /**
1390 * Transport string info/description.
1391 */
1392 pj_str_t info;
1393
1394 /**
1395 * Transport flag (see ##pjsip_transport_flags_e).
1396 */
1397 unsigned flag;
1398
1399 /**
1400 * Local address length.
1401 */
1402 unsigned addr_len;
1403
1404 /**
1405 * Local/bound address.
1406 */
1407 pj_sockaddr local_addr;
1408
1409 /**
1410 * Published address (or transport address name).
1411 */
1412 pjsip_host_port local_name;
1413
1414 /**
1415 * Current number of objects currently referencing this transport.
1416 */
1417 unsigned usage_count;
1418
1419
1420} pjsua_transport_info;
1421
1422
1423/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001424 * Create and start a new SIP transport according to the specified
1425 * settings.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001426 *
1427 * @param type Transport type.
1428 * @param cfg Transport configuration.
1429 * @param p_id Optional pointer to receive transport ID.
1430 *
1431 * @return PJ_SUCCESS on success, or the appropriate error code.
1432 */
1433PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1434 const pjsua_transport_config *cfg,
1435 pjsua_transport_id *p_id);
1436
1437/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001438 * Register transport that has been created by application. This function
1439 * is useful if application wants to implement custom SIP transport and use
1440 * it with pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001441 *
1442 * @param tp Transport instance.
1443 * @param p_id Optional pointer to receive transport ID.
1444 *
1445 * @return PJ_SUCCESS on success, or the appropriate error code.
1446 */
1447PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1448 pjsua_transport_id *p_id);
1449
1450
1451/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001452 * Enumerate all transports currently created in the system. This function
1453 * will return all transport IDs, and application may then call
1454 * #pjsua_transport_get_info() function to retrieve detailed information
1455 * about the transport.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001456 *
1457 * @param id Array to receive transport ids.
1458 * @param count In input, specifies the maximum number of elements.
1459 * On return, it contains the actual number of elements.
1460 *
1461 * @return PJ_SUCCESS on success, or the appropriate error code.
1462 */
1463PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1464 unsigned *count );
1465
1466
1467/**
1468 * Get information about transports.
1469 *
1470 * @param id Transport ID.
1471 * @param info Pointer to receive transport info.
1472 *
1473 * @return PJ_SUCCESS on success, or the appropriate error code.
1474 */
1475PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1476 pjsua_transport_info *info);
1477
1478
1479/**
1480 * Disable a transport or re-enable it. By default transport is always
1481 * enabled after it is created. Disabling a transport does not necessarily
1482 * close the socket, it will only discard incoming messages and prevent
1483 * the transport from being used to send outgoing messages.
1484 *
1485 * @param id Transport ID.
1486 * @param enabled Non-zero to enable, zero to disable.
1487 *
1488 * @return PJ_SUCCESS on success, or the appropriate error code.
1489 */
1490PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1491 pj_bool_t enabled);
1492
1493
1494/**
1495 * Close the transport. If transport is forcefully closed, it will be
1496 * immediately closed, and any pending transactions that are using the
Benny Prijonob5388cf2007-01-04 22:45:08 +00001497 * transport may not terminate properly (it may even crash). Otherwise,
1498 * the system will wait until all transactions are closed while preventing
1499 * new users from using the transport, and will close the transport when
1500 * it is safe to do so.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001501 *
1502 * @param id Transport ID.
1503 * @param force Non-zero to immediately close the transport. This
1504 * is not recommended!
1505 *
1506 * @return PJ_SUCCESS on success, or the appropriate error code.
1507 */
1508PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1509 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001510
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001511/**
Benny Prijono312aff92006-06-17 04:08:30 +00001512 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001513 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001514
1515
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001516
1517
1518/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001519 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +00001520 */
1521
Benny Prijono312aff92006-06-17 04:08:30 +00001522
1523/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00001524 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
Benny Prijono312aff92006-06-17 04:08:30 +00001525 * @ingroup PJSUA_LIB
Benny Prijonoe6ead542007-01-31 20:53:31 +00001526 * @brief PJSUA Accounts management
Benny Prijono312aff92006-06-17 04:08:30 +00001527 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00001528 *
Benny Prijono312aff92006-06-17 04:08:30 +00001529 * PJSUA accounts provide identity (or identities) of the user who is currently
Benny Prijonoe6ead542007-01-31 20:53:31 +00001530 * using the application. In SIP terms, the identity is used as the <b>From</b>
1531 * header in outgoing requests.
1532 *
1533 * PJSUA-API supports creating and managing multiple accounts. The maximum
1534 * number of accounts is limited by a compile time constant
1535 * <tt>PJSUA_MAX_ACC</tt>.
Benny Prijono312aff92006-06-17 04:08:30 +00001536 *
1537 * Account may or may not have client registration associated with it.
1538 * An account is also associated with <b>route set</b> and some <b>authentication
1539 * credentials</b>, which are used when sending SIP request messages using the
1540 * account. An account also has presence's <b>online status</b>, which
Benny Prijonoe6ead542007-01-31 20:53:31 +00001541 * will be reported to remote peer when they subscribe to the account's
1542 * presence, or which is published to a presence server if presence
1543 * publication is enabled for the account.
Benny Prijono312aff92006-06-17 04:08:30 +00001544 *
1545 * At least one account MUST be created in the application. If no user
1546 * association is required, application can create a userless account by
1547 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
Benny Prijonoe6ead542007-01-31 20:53:31 +00001548 * instead of a particular user, and it correspond with a particular
1549 * transport instance.
Benny Prijono312aff92006-06-17 04:08:30 +00001550 *
1551 * Also one account must be set as the <b>default account</b>, which is used as
1552 * the account to use when PJSUA fails to match a request with any other
1553 * accounts.
1554 *
1555 * When sending outgoing SIP requests (such as making calls or sending
1556 * instant messages), normally PJSUA requires the application to specify
1557 * which account to use for the request. If no account is specified,
1558 * PJSUA may be able to select the account by matching the destination
1559 * domain name, and fall back to default account when no match is found.
1560 */
1561
1562/**
1563 * Maximum accounts.
1564 */
1565#ifndef PJSUA_MAX_ACC
1566# define PJSUA_MAX_ACC 8
1567#endif
1568
1569
1570/**
1571 * Default registration interval.
1572 */
1573#ifndef PJSUA_REG_INTERVAL
Benny Prijonobddef2c2007-10-31 13:28:08 +00001574# define PJSUA_REG_INTERVAL 300
Benny Prijono312aff92006-06-17 04:08:30 +00001575#endif
1576
1577
1578/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001579 * Default PUBLISH expiration
1580 */
1581#ifndef PJSUA_PUBLISH_EXPIRATION
Benny Prijono53984d12009-04-28 22:19:49 +00001582# define PJSUA_PUBLISH_EXPIRATION PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001583#endif
1584
1585
1586/**
Benny Prijono093d3022006-09-24 00:07:11 +00001587 * Default account priority.
1588 */
1589#ifndef PJSUA_DEFAULT_ACC_PRIORITY
1590# define PJSUA_DEFAULT_ACC_PRIORITY 0
1591#endif
1592
1593
1594/**
Benny Prijono8058a622007-06-08 04:37:05 +00001595 * This macro specifies the URI scheme to use in Contact header
1596 * when secure transport such as TLS is used. Application can specify
1597 * either "sip" or "sips".
1598 */
1599#ifndef PJSUA_SECURE_SCHEME
Benny Prijono4c82c1e2008-10-16 08:14:51 +00001600# define PJSUA_SECURE_SCHEME "sip"
Benny Prijono8058a622007-06-08 04:37:05 +00001601#endif
1602
1603
1604/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001605 * This structure describes account configuration to be specified when
1606 * adding a new account with #pjsua_acc_add(). Application MUST initialize
1607 * this structure first by calling #pjsua_acc_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00001608 */
1609typedef struct pjsua_acc_config
1610{
Benny Prijono093d3022006-09-24 00:07:11 +00001611 /**
Benny Prijono705e7842008-07-21 18:12:51 +00001612 * Arbitrary user data to be associated with the newly created account.
1613 * Application may set this later with #pjsua_acc_set_user_data() and
1614 * retrieve it with #pjsua_acc_get_user_data().
1615 */
1616 void *user_data;
1617
1618 /**
Benny Prijono093d3022006-09-24 00:07:11 +00001619 * Account priority, which is used to control the order of matching
1620 * incoming/outgoing requests. The higher the number means the higher
1621 * the priority is, and the account will be matched first.
1622 */
1623 int priority;
1624
Benny Prijono312aff92006-06-17 04:08:30 +00001625 /**
1626 * The full SIP URL for the account. The value can take name address or
1627 * URL format, and will look something like "sip:account@serviceprovider".
1628 *
1629 * This field is mandatory.
1630 */
1631 pj_str_t id;
1632
1633 /**
1634 * This is the URL to be put in the request URI for the registration,
1635 * and will look something like "sip:serviceprovider".
1636 *
1637 * This field should be specified if registration is desired. If the
1638 * value is empty, no account registration will be performed.
1639 */
1640 pj_str_t reg_uri;
1641
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001642 /**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001643 * If this flag is set, the presence information of this account will
1644 * be PUBLISH-ed to the server where the account belongs.
Benny Prijono48ab2b72007-11-08 09:24:30 +00001645 *
1646 * Default: PJ_FALSE
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001647 */
1648 pj_bool_t publish_enabled;
1649
Benny Prijonofe04fb52007-08-24 08:28:52 +00001650 /**
Benny Prijono48ab2b72007-11-08 09:24:30 +00001651 * Authentication preference.
1652 */
1653 pjsip_auth_clt_pref auth_pref;
1654
1655 /**
Benny Prijonofe04fb52007-08-24 08:28:52 +00001656 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
1657 * is not specified, a random string will be used.
1658 */
1659 pj_str_t pidf_tuple_id;
1660
Benny Prijono312aff92006-06-17 04:08:30 +00001661 /**
1662 * Optional URI to be put as Contact for this account. It is recommended
1663 * that this field is left empty, so that the value will be calculated
1664 * automatically based on the transport address.
1665 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00001666 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00001667
1668 /**
Benny Prijono30fe4852008-12-10 16:54:16 +00001669 * Additional URI parameters that will be appended in the Contact header
1670 * for this account. This will affect the Contact header in all SIP
1671 * messages sent on behalf of this account, including but not limited to
1672 * REGISTER, INVITE, and SUBCRIBE requests or responses.
1673 *
1674 * The parameters should be preceeded by semicolon, and all strings must
1675 * be properly escaped. Example:
1676 * ";my-param=X;another-param=Hi%20there"
1677 */
1678 pj_str_t contact_params;
1679
1680 /**
Benny Prijonodcfc0ba2007-09-30 16:50:27 +00001681 * Specify whether support for reliable provisional response (100rel and
1682 * PRACK) should be required for all sessions of this account.
1683 *
1684 * Default: PJ_FALSE
1685 */
1686 pj_bool_t require_100rel;
1687
1688 /**
Benny Prijono312aff92006-06-17 04:08:30 +00001689 * Number of proxies in the proxy array below.
1690 */
1691 unsigned proxy_cnt;
1692
1693 /**
1694 * Optional URI of the proxies to be visited for all outgoing requests
1695 * that are using this account (REGISTER, INVITE, etc). Application need
1696 * to specify these proxies if the service provider requires that requests
1697 * destined towards its network should go through certain proxies first
1698 * (for example, border controllers).
1699 *
1700 * These proxies will be put in the route set for this account, with
1701 * maintaining the orders (the first proxy in the array will be visited
Benny Prijonob5388cf2007-01-04 22:45:08 +00001702 * first). If global outbound proxies are configured in pjsua_config,
1703 * then these account proxies will be placed after the global outbound
1704 * proxies in the routeset.
Benny Prijono312aff92006-06-17 04:08:30 +00001705 */
1706 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
1707
1708 /**
1709 * Optional interval for registration, in seconds. If the value is zero,
Benny Prijonobddef2c2007-10-31 13:28:08 +00001710 * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
Benny Prijono312aff92006-06-17 04:08:30 +00001711 */
1712 unsigned reg_timeout;
1713
1714 /**
1715 * Number of credentials in the credential array.
1716 */
1717 unsigned cred_count;
1718
1719 /**
1720 * Array of credentials. If registration is desired, normally there should
1721 * be at least one credential specified, to successfully authenticate
1722 * against the service provider. More credentials can be specified, for
1723 * example when the requests are expected to be challenged by the
1724 * proxies in the route set.
1725 */
1726 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1727
Benny Prijono62c5c5b2007-01-13 23:22:40 +00001728 /**
1729 * Optionally bind this account to specific transport. This normally is
1730 * not a good idea, as account should be able to send requests using
1731 * any available transports according to the destination. But some
1732 * application may want to have explicit control over the transport to
1733 * use, so in that case it can set this field.
1734 *
1735 * Default: -1 (PJSUA_INVALID_ID)
1736 *
1737 * @see pjsua_acc_set_transport()
1738 */
1739 pjsua_transport_id transport_id;
1740
Benny Prijono15b02302007-09-27 14:07:07 +00001741 /**
Benny Prijonoe8554ef2008-03-22 09:33:52 +00001742 * This option is used to update the UDP transport address and the Contact
1743 * header of REGISTER request. When this option is enabled, the library
1744 * will keep track of the public IP address from the response of REGISTER
1745 * request. Once it detects that the address has changed, it will
1746 * unregister current Contact, update the Contact with transport address
1747 * learned from Via header, and register a new Contact to the registrar.
1748 * This will also update the public name of UDP transport if STUN is
1749 * configured.
Benny Prijono15b02302007-09-27 14:07:07 +00001750 *
1751 * Default: 1 (yes)
1752 */
Benny Prijonoe8554ef2008-03-22 09:33:52 +00001753 pj_bool_t allow_contact_rewrite;
Benny Prijono15b02302007-09-27 14:07:07 +00001754
Benny Prijonobddef2c2007-10-31 13:28:08 +00001755 /**
1756 * Set the interval for periodic keep-alive transmission for this account.
1757 * If this value is zero, keep-alive will be disabled for this account.
1758 * The keep-alive transmission will be sent to the registrar's address,
1759 * after successful registration.
1760 *
Benny Prijonobddef2c2007-10-31 13:28:08 +00001761 * Default: 15 (seconds)
1762 */
1763 unsigned ka_interval;
1764
1765 /**
1766 * Specify the data to be transmitted as keep-alive packets.
1767 *
1768 * Default: CR-LF
1769 */
1770 pj_str_t ka_data;
1771
Benny Prijonod8179652008-01-23 20:39:07 +00001772#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)
1773 /**
1774 * Specify whether secure media transport should be used for this account.
1775 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
1776 * PJMEDIA_SRTP_MANDATORY.
1777 *
1778 * Default: #PJSUA_DEFAULT_USE_SRTP
1779 */
1780 pjmedia_srtp_use use_srtp;
1781
1782 /**
1783 * Specify whether SRTP requires secure signaling to be used. This option
1784 * is only used when \a use_srtp option above is non-zero.
1785 *
1786 * Valid values are:
1787 * 0: SRTP does not require secure signaling
1788 * 1: SRTP requires secure transport such as TLS
1789 * 2: SRTP requires secure end-to-end transport (SIPS)
1790 *
1791 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
1792 */
1793 int srtp_secure_signaling;
1794#endif
1795
Benny Prijono312aff92006-06-17 04:08:30 +00001796} pjsua_acc_config;
1797
1798
1799/**
1800 * Call this function to initialize account config with default values.
1801 *
1802 * @param cfg The account config to be initialized.
1803 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00001804PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00001805
1806
1807/**
Benny Prijonobddef2c2007-10-31 13:28:08 +00001808 * Duplicate account config.
1809 *
1810 * @param pool Pool to be used for duplicating the config.
1811 * @param dst Destination configuration.
1812 * @param src Source configuration.
1813 */
1814PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
1815 pjsua_acc_config *dst,
1816 const pjsua_acc_config *src);
1817
1818
1819/**
Benny Prijono312aff92006-06-17 04:08:30 +00001820 * Account info. Application can query account info by calling
1821 * #pjsua_acc_get_info().
1822 */
1823typedef struct pjsua_acc_info
1824{
1825 /**
1826 * The account ID.
1827 */
1828 pjsua_acc_id id;
1829
1830 /**
1831 * Flag to indicate whether this is the default account.
1832 */
1833 pj_bool_t is_default;
1834
1835 /**
1836 * Account URI
1837 */
1838 pj_str_t acc_uri;
1839
1840 /**
1841 * Flag to tell whether this account has registration setting
1842 * (reg_uri is not empty).
1843 */
1844 pj_bool_t has_registration;
1845
1846 /**
1847 * An up to date expiration interval for account registration session.
1848 */
1849 int expires;
1850
1851 /**
1852 * Last registration status code. If status code is zero, the account
1853 * is currently not registered. Any other value indicates the SIP
1854 * status code of the registration.
1855 */
1856 pjsip_status_code status;
1857
1858 /**
1859 * String describing the registration status.
1860 */
1861 pj_str_t status_text;
1862
1863 /**
1864 * Presence online status for this account.
1865 */
1866 pj_bool_t online_status;
1867
1868 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00001869 * Presence online status text.
1870 */
1871 pj_str_t online_status_text;
1872
1873 /**
1874 * Extended RPID online status information.
1875 */
1876 pjrpid_element rpid;
1877
1878 /**
Benny Prijono312aff92006-06-17 04:08:30 +00001879 * Buffer that is used internally to store the status text.
1880 */
1881 char buf_[PJ_ERR_MSG_SIZE];
1882
1883} pjsua_acc_info;
1884
1885
1886
1887/**
1888 * Get number of current accounts.
1889 *
1890 * @return Current number of accounts.
1891 */
1892PJ_DECL(unsigned) pjsua_acc_get_count(void);
1893
1894
1895/**
1896 * Check if the specified account ID is valid.
1897 *
1898 * @param acc_id Account ID to check.
1899 *
1900 * @return Non-zero if account ID is valid.
1901 */
1902PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
1903
1904
1905/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00001906 * Set default account to be used when incoming and outgoing
1907 * requests doesn't match any accounts.
1908 *
1909 * @param acc_id The account ID to be used as default.
1910 *
1911 * @return PJ_SUCCESS on success.
1912 */
1913PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
1914
1915
1916/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001917 * Get default account to be used when receiving incoming requests (calls),
1918 * when the destination of the incoming call doesn't match any other
1919 * accounts.
Benny Prijono21b9ad92006-08-15 13:11:22 +00001920 *
1921 * @return The default account ID, or PJSUA_INVALID_ID if no
1922 * default account is configured.
1923 */
1924PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
1925
1926
1927/**
Benny Prijono312aff92006-06-17 04:08:30 +00001928 * Add a new account to pjsua. PJSUA must have been initialized (with
Benny Prijonob5388cf2007-01-04 22:45:08 +00001929 * #pjsua_init()) before calling this function. If registration is configured
1930 * for this account, this function would also start the SIP registration
1931 * session with the SIP registrar server. This SIP registration session
1932 * will be maintained internally by the library, and application doesn't
1933 * need to do anything to maintain the registration session.
1934 *
Benny Prijono312aff92006-06-17 04:08:30 +00001935 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00001936 * @param acc_cfg Account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00001937 * @param is_default If non-zero, this account will be set as the default
1938 * account. The default account will be used when sending
1939 * outgoing requests (e.g. making call) when no account is
1940 * specified, and when receiving incoming requests when the
1941 * request does not match any accounts. It is recommended
1942 * that default account is set to local/LAN account.
1943 * @param p_acc_id Pointer to receive account ID of the new account.
1944 *
1945 * @return PJ_SUCCESS on success, or the appropriate error code.
1946 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00001947PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
Benny Prijono312aff92006-06-17 04:08:30 +00001948 pj_bool_t is_default,
1949 pjsua_acc_id *p_acc_id);
1950
1951
1952/**
1953 * Add a local account. A local account is used to identify local endpoint
1954 * instead of a specific user, and for this reason, a transport ID is needed
1955 * to obtain the local address information.
1956 *
1957 * @param tid Transport ID to generate account address.
1958 * @param is_default If non-zero, this account will be set as the default
1959 * account. The default account will be used when sending
1960 * outgoing requests (e.g. making call) when no account is
1961 * specified, and when receiving incoming requests when the
1962 * request does not match any accounts. It is recommended
1963 * that default account is set to local/LAN account.
1964 * @param p_acc_id Pointer to receive account ID of the new account.
1965 *
1966 * @return PJ_SUCCESS on success, or the appropriate error code.
1967 */
1968PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
1969 pj_bool_t is_default,
1970 pjsua_acc_id *p_acc_id);
1971
1972/**
Benny Prijono705e7842008-07-21 18:12:51 +00001973 * Set arbitrary data to be associated with the account.
1974 *
1975 * @param acc_id The account ID.
1976 * @param user_data User/application data.
1977 *
1978 * @return PJ_SUCCESS on success, or the appropriate error code.
1979 */
1980PJ_DECL(pj_status_t) pjsua_acc_set_user_data(pjsua_acc_id acc_id,
1981 void *user_data);
1982
1983
1984/**
1985 * Retrieve arbitrary data associated with the account.
1986 *
1987 * @param acc_id The account ID.
1988 *
1989 * @return The user data. In the case where the account ID is
1990 * not valid, NULL is returned.
1991 */
1992PJ_DECL(void*) pjsua_acc_get_user_data(pjsua_acc_id acc_id);
1993
1994
1995/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00001996 * Delete an account. This will unregister the account from the SIP server,
1997 * if necessary, and terminate server side presence subscriptions associated
1998 * with this account.
Benny Prijono312aff92006-06-17 04:08:30 +00001999 *
2000 * @param acc_id Id of the account to be deleted.
2001 *
2002 * @return PJ_SUCCESS on success, or the appropriate error code.
2003 */
2004PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
2005
2006
2007/**
2008 * Modify account information.
2009 *
2010 * @param acc_id Id of the account to be modified.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002011 * @param acc_cfg New account configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002012 *
2013 * @return PJ_SUCCESS on success, or the appropriate error code.
2014 */
2015PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
Benny Prijonoe6ead542007-01-31 20:53:31 +00002016 const pjsua_acc_config *acc_cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00002017
2018
2019/**
2020 * Modify account's presence status to be advertised to remote/presence
Benny Prijonob5388cf2007-01-04 22:45:08 +00002021 * subscribers. This would trigger the sending of outgoing NOTIFY request
Benny Prijono4461c7d2007-08-25 13:36:15 +00002022 * if there are server side presence subscription for this account, and/or
2023 * outgoing PUBLISH if presence publication is enabled for this account.
2024 *
2025 * @see pjsua_acc_set_online_status2()
Benny Prijono312aff92006-06-17 04:08:30 +00002026 *
2027 * @param acc_id The account ID.
2028 * @param is_online True of false.
2029 *
2030 * @return PJ_SUCCESS on success, or the appropriate error code.
2031 */
2032PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
2033 pj_bool_t is_online);
2034
Benny Prijono4461c7d2007-08-25 13:36:15 +00002035/**
2036 * Modify account's presence status to be advertised to remote/presence
2037 * subscribers. This would trigger the sending of outgoing NOTIFY request
2038 * if there are server side presence subscription for this account, and/or
2039 * outgoing PUBLISH if presence publication is enabled for this account.
2040 *
2041 * @see pjsua_acc_set_online_status()
2042 *
2043 * @param acc_id The account ID.
2044 * @param is_online True of false.
2045 * @param pr Extended information in subset of RPID format
2046 * which allows setting custom presence text.
2047 *
2048 * @return PJ_SUCCESS on success, or the appropriate error code.
2049 */
2050PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
2051 pj_bool_t is_online,
2052 const pjrpid_element *pr);
Benny Prijono312aff92006-06-17 04:08:30 +00002053
2054/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002055 * Update registration or perform unregistration. If registration is
2056 * configured for this account, then initial SIP REGISTER will be sent
2057 * when the account is added with #pjsua_acc_add(). Application normally
2058 * only need to call this function if it wants to manually update the
2059 * registration or to unregister from the server.
Benny Prijono312aff92006-06-17 04:08:30 +00002060 *
2061 * @param acc_id The account ID.
2062 * @param renew If renew argument is zero, this will start
2063 * unregistration process.
2064 *
2065 * @return PJ_SUCCESS on success, or the appropriate error code.
2066 */
2067PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
2068 pj_bool_t renew);
2069
Benny Prijono312aff92006-06-17 04:08:30 +00002070/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002071 * Get information about the specified account.
Benny Prijono312aff92006-06-17 04:08:30 +00002072 *
2073 * @param acc_id Account identification.
2074 * @param info Pointer to receive account information.
2075 *
2076 * @return PJ_SUCCESS on success, or the appropriate error code.
2077 */
2078PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
2079 pjsua_acc_info *info);
2080
2081
2082/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002083 * Enumerate all account currently active in the library. This will fill
2084 * the array with the account Ids, and application can then query the
2085 * account information for each id with #pjsua_acc_get_info().
2086 *
2087 * @see pjsua_acc_enum_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002088 *
2089 * @param ids Array of account IDs to be initialized.
2090 * @param count In input, specifies the maximum number of elements.
2091 * On return, it contains the actual number of elements.
2092 *
2093 * @return PJ_SUCCESS on success, or the appropriate error code.
2094 */
2095PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
2096 unsigned *count );
2097
2098
2099/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002100 * Enumerate account informations.
Benny Prijono312aff92006-06-17 04:08:30 +00002101 *
2102 * @param info Array of account infos to be initialized.
2103 * @param count In input, specifies the maximum number of elements.
2104 * On return, it contains the actual number of elements.
2105 *
2106 * @return PJ_SUCCESS on success, or the appropriate error code.
2107 */
2108PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
2109 unsigned *count );
2110
2111
2112/**
2113 * This is an internal function to find the most appropriate account to
2114 * used to reach to the specified URL.
2115 *
2116 * @param url The remote URL to reach.
2117 *
2118 * @return Account id.
2119 */
2120PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
2121
2122
2123/**
2124 * This is an internal function to find the most appropriate account to be
2125 * used to handle incoming calls.
2126 *
2127 * @param rdata The incoming request message.
2128 *
2129 * @return Account id.
2130 */
2131PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
2132
2133
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002134/**
Benny Prijonofff245c2007-04-02 11:44:47 +00002135 * Create arbitrary requests using the account. Application should only use
2136 * this function to create auxiliary requests outside dialog, such as
2137 * OPTIONS, and use the call or presence API to create dialog related
2138 * requests.
2139 *
2140 * @param acc_id The account ID.
2141 * @param method The SIP method of the request.
2142 * @param target Target URI.
2143 * @param p_tdata Pointer to receive the request.
2144 *
2145 * @return PJ_SUCCESS or the error code.
2146 */
2147PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
2148 const pjsip_method *method,
2149 const pj_str_t *target,
2150 pjsip_tx_data **p_tdata);
2151
2152
2153/**
Benny Prijonoc570f2d2006-07-18 00:33:02 +00002154 * Create a suitable URI to be put as Contact based on the specified
2155 * target URI for the specified account.
2156 *
2157 * @param pool Pool to allocate memory for the string.
2158 * @param contact The string where the Contact URI will be stored.
2159 * @param acc_id Account ID.
2160 * @param uri Destination URI of the request.
2161 *
2162 * @return PJ_SUCCESS on success, other on error.
2163 */
2164PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
2165 pj_str_t *contact,
2166 pjsua_acc_id acc_id,
2167 const pj_str_t *uri);
2168
2169
2170
2171/**
2172 * Create a suitable URI to be put as Contact based on the information
2173 * in the incoming request.
2174 *
2175 * @param pool Pool to allocate memory for the string.
2176 * @param contact The string where the Contact URI will be stored.
2177 * @param acc_id Account ID.
2178 * @param rdata Incoming request.
2179 *
2180 * @return PJ_SUCCESS on success, other on error.
2181 */
2182PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
2183 pj_str_t *contact,
2184 pjsua_acc_id acc_id,
2185 pjsip_rx_data *rdata );
2186
2187
Benny Prijono62c5c5b2007-01-13 23:22:40 +00002188/**
2189 * Lock/bind this account to a specific transport/listener. Normally
2190 * application shouldn't need to do this, as transports will be selected
2191 * automatically by the stack according to the destination.
2192 *
2193 * When account is locked/bound to a specific transport, all outgoing
2194 * requests from this account will use the specified transport (this
2195 * includes SIP registration, dialog (call and event subscription), and
2196 * out-of-dialog requests such as MESSAGE).
2197 *
2198 * Note that transport_id may be specified in pjsua_acc_config too.
2199 *
2200 * @param acc_id The account ID.
2201 * @param tp_id The transport ID.
2202 *
2203 * @return PJ_SUCCESS on success.
2204 */
2205PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
2206 pjsua_transport_id tp_id);
2207
Benny Prijono312aff92006-06-17 04:08:30 +00002208
2209/**
2210 * @}
2211 */
2212
2213
2214/*****************************************************************************
2215 * CALLS API
2216 */
2217
2218
2219/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002220 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
Benny Prijono312aff92006-06-17 04:08:30 +00002221 * @ingroup PJSUA_LIB
2222 * @brief Call manipulation.
2223 * @{
2224 */
2225
2226/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002227 * Maximum simultaneous calls.
Benny Prijono312aff92006-06-17 04:08:30 +00002228 */
2229#ifndef PJSUA_MAX_CALLS
2230# define PJSUA_MAX_CALLS 32
2231#endif
2232
2233
2234
2235/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002236 * This enumeration specifies the media status of a call, and it's part
2237 * of pjsua_call_info structure.
Benny Prijono312aff92006-06-17 04:08:30 +00002238 */
2239typedef enum pjsua_call_media_status
2240{
Benny Prijonob5388cf2007-01-04 22:45:08 +00002241 /** Call currently has no media */
Benny Prijono312aff92006-06-17 04:08:30 +00002242 PJSUA_CALL_MEDIA_NONE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002243
2244 /** The media is active */
Benny Prijono312aff92006-06-17 04:08:30 +00002245 PJSUA_CALL_MEDIA_ACTIVE,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002246
2247 /** The media is currently put on hold by local endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002248 PJSUA_CALL_MEDIA_LOCAL_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002249
2250 /** The media is currently put on hold by remote endpoint */
Benny Prijono312aff92006-06-17 04:08:30 +00002251 PJSUA_CALL_MEDIA_REMOTE_HOLD,
Benny Prijonob5388cf2007-01-04 22:45:08 +00002252
Benny Prijono096c56c2007-09-15 08:30:16 +00002253 /** The media has reported error (e.g. ICE negotiation) */
2254 PJSUA_CALL_MEDIA_ERROR
2255
Benny Prijono312aff92006-06-17 04:08:30 +00002256} pjsua_call_media_status;
2257
2258
2259/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002260 * This structure describes the information and current status of a call.
Benny Prijono312aff92006-06-17 04:08:30 +00002261 */
2262typedef struct pjsua_call_info
2263{
2264 /** Call identification. */
2265 pjsua_call_id id;
2266
2267 /** Initial call role (UAC == caller) */
2268 pjsip_role_e role;
2269
Benny Prijono90315512006-09-14 16:05:16 +00002270 /** The account ID where this call belongs. */
2271 pjsua_acc_id acc_id;
2272
Benny Prijono312aff92006-06-17 04:08:30 +00002273 /** Local URI */
2274 pj_str_t local_info;
2275
2276 /** Local Contact */
2277 pj_str_t local_contact;
2278
2279 /** Remote URI */
2280 pj_str_t remote_info;
2281
2282 /** Remote contact */
2283 pj_str_t remote_contact;
2284
2285 /** Dialog Call-ID string. */
2286 pj_str_t call_id;
2287
2288 /** Call state */
2289 pjsip_inv_state state;
2290
2291 /** Text describing the state */
2292 pj_str_t state_text;
2293
2294 /** Last status code heard, which can be used as cause code */
2295 pjsip_status_code last_status;
2296
2297 /** The reason phrase describing the status. */
2298 pj_str_t last_status_text;
2299
2300 /** Call media status. */
2301 pjsua_call_media_status media_status;
2302
2303 /** Media direction */
2304 pjmedia_dir media_dir;
2305
2306 /** The conference port number for the call */
2307 pjsua_conf_port_id conf_slot;
2308
2309 /** Up-to-date call connected duration (zero when call is not
2310 * established)
2311 */
2312 pj_time_val connect_duration;
2313
2314 /** Total call duration, including set-up time */
2315 pj_time_val total_duration;
2316
2317 /** Internal */
2318 struct {
2319 char local_info[128];
2320 char local_contact[128];
2321 char remote_info[128];
2322 char remote_contact[128];
2323 char call_id[128];
2324 char last_status_text[128];
2325 } buf_;
2326
2327} pjsua_call_info;
2328
2329
2330
Benny Prijonoa91a0032006-02-26 21:23:45 +00002331/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002332 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002333 *
2334 * @return Maximum number of calls configured.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002335 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002336PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002337
2338/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002339 * Get number of currently active calls.
2340 *
2341 * @return Number of currently active calls.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002342 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002343PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002344
2345/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002346 * Enumerate all active calls. Application may then query the information and
2347 * state of each call by calling #pjsua_call_get_info().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002348 *
2349 * @param ids Array of account IDs to be initialized.
2350 * @param count In input, specifies the maximum number of elements.
2351 * On return, it contains the actual number of elements.
2352 *
2353 * @return PJ_SUCCESS on success, or the appropriate error code.
2354 */
2355PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
2356 unsigned *count);
2357
2358
2359/**
2360 * Make outgoing call to the specified URI using the specified account.
2361 *
2362 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002363 * @param dst_uri URI to be put in the To header (normally is the same
2364 * as the target URI).
2365 * @param options Options (must be zero at the moment).
2366 * @param user_data Arbitrary user data to be attached to the call, and
2367 * can be retrieved later.
2368 * @param msg_data Optional headers etc to be added to outgoing INVITE
2369 * request, or NULL if no custom header is desired.
2370 * @param p_call_id Pointer to receive call identification.
2371 *
2372 * @return PJ_SUCCESS on success, or the appropriate error code.
2373 */
2374PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
2375 const pj_str_t *dst_uri,
2376 unsigned options,
2377 void *user_data,
2378 const pjsua_msg_data *msg_data,
2379 pjsua_call_id *p_call_id);
2380
2381
2382/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00002383 * Check if the specified call has active INVITE session and the INVITE
2384 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002385 *
2386 * @param call_id Call identification.
2387 *
2388 * @return Non-zero if call is active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002389 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002390PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002391
2392
2393/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002394 * Check if call has an active media session.
2395 *
2396 * @param call_id Call identification.
2397 *
2398 * @return Non-zero if yes.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002399 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002400PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002401
2402
2403/**
Benny Prijonocf986c42008-09-02 11:25:07 +00002404 * Retrieve the media session associated with this call. Note that the media
2405 * session may not be available depending on the current call's media status
2406 * (the pjsua_call_media_status information in pjsua_call_info). Application
2407 * may use the media session to retrieve more detailed information about the
2408 * call's media.
2409 *
2410 * @param call_id Call identification.
2411 *
2412 * @return Call media session.
2413 */
2414PJ_DECL(pjmedia_session*) pjsua_call_get_media_session(pjsua_call_id call_id);
2415
2416
2417/**
2418 * Retrieve the media transport instance that is used for this call.
2419 * Application may use the media transport to query more detailed information
2420 * about the media transport.
2421 *
2422 * @param cid Call identification (the call_id).
2423 *
2424 * @return Call media transport.
2425 */
2426PJ_DECL(pjmedia_transport*) pjsua_call_get_media_transport(pjsua_call_id cid);
2427
2428
2429/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002430 * Get the conference port identification associated with the call.
2431 *
2432 * @param call_id Call identification.
2433 *
2434 * @return Conference port ID, or PJSUA_INVALID_ID when the
2435 * media has not been established or is not active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002436 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002437PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
2438
2439/**
2440 * Obtain detail information about the specified call.
2441 *
2442 * @param call_id Call identification.
2443 * @param info Call info to be initialized.
2444 *
2445 * @return PJ_SUCCESS on success, or the appropriate error code.
2446 */
2447PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002448 pjsua_call_info *info);
2449
2450
2451/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002452 * Attach application specific data to the call. Application can then
2453 * inspect this data by calling #pjsua_call_get_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002454 *
2455 * @param call_id Call identification.
2456 * @param user_data Arbitrary data to be attached to the call.
2457 *
2458 * @return The user data.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002459 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002460PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
2461 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002462
2463
2464/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002465 * Get user data attached to the call, which has been previously set with
2466 * #pjsua_call_set_user_data().
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002467 *
2468 * @param call_id Call identification.
2469 *
2470 * @return The user data.
Benny Prijono268ca612006-02-07 12:34:11 +00002471 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002472PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00002473
2474
2475/**
Benny Prijono91a6a172007-10-31 08:59:29 +00002476 * Get the NAT type of remote's endpoint. This is a proprietary feature
2477 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
2478 * is set in #pjsua_config.
2479 *
2480 * This function can only be called after SDP has been received from remote,
2481 * which means for incoming call, this function can be called as soon as
2482 * call is received as long as incoming call contains SDP, and for outgoing
2483 * call, this function can be called only after SDP is received (normally in
2484 * 200/OK response to INVITE). As a general case, application should call
2485 * this function after or in \a on_call_media_state() callback.
2486 *
2487 * @param call_id Call identification.
2488 * @param p_type Pointer to store the NAT type. Application can then
2489 * retrieve the string description of the NAT type
2490 * by calling pj_stun_get_nat_name().
2491 *
2492 * @return PJ_SUCCESS on success.
2493 *
2494 * @see pjsua_get_nat_type(), nat_type_in_sdp
2495 */
2496PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
2497 pj_stun_nat_type *p_type);
2498
2499/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002500 * Send response to incoming INVITE request. Depending on the status
2501 * code specified as parameter, this function may send provisional
2502 * response, establish the call, or terminate the call.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002503 *
2504 * @param call_id Incoming call identification.
2505 * @param code Status code, (100-699).
2506 * @param reason Optional reason phrase. If NULL, default text
2507 * will be used.
2508 * @param msg_data Optional list of headers etc to be added to outgoing
2509 * response message.
2510 *
2511 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoa91a0032006-02-26 21:23:45 +00002512 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002513PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
2514 unsigned code,
2515 const pj_str_t *reason,
2516 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00002517
2518/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002519 * Hangup call by using method that is appropriate according to the
Benny Prijonob5388cf2007-01-04 22:45:08 +00002520 * call state. This function is different than answering the call with
2521 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
2522 * will hangup the call regardless of the state and role of the call,
2523 * while #pjsua_call_answer() only works with incoming calls on EARLY
2524 * state.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002525 *
2526 * @param call_id Call identification.
2527 * @param code Optional status code to be sent when we're rejecting
2528 * incoming call. If the value is zero, "603/Decline"
2529 * will be sent.
2530 * @param reason Optional reason phrase to be sent when we're rejecting
2531 * incoming call. If NULL, default text will be used.
2532 * @param msg_data Optional list of headers etc to be added to outgoing
2533 * request/response message.
2534 *
2535 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00002536 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002537PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
2538 unsigned code,
2539 const pj_str_t *reason,
2540 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002541
Benny Prijono5e51a4e2008-11-27 00:06:46 +00002542/**
2543 * Accept or reject redirection response. Application MUST call this function
2544 * after it signaled PJSIP_REDIRECT_PENDING in the \a on_call_redirected()
2545 * callback, to notify the call whether to accept or reject the redirection
2546 * to the current target. Application can use the combination of
2547 * PJSIP_REDIRECT_PENDING command in \a on_call_redirected() callback and
2548 * this function to ask for user permission before redirecting the call.
2549 *
2550 * Note that if the application chooses to reject or stop redirection (by
2551 * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the
2552 * call disconnection callback will be called before this function returns.
2553 * And if the application rejects the target, the \a on_call_redirected()
2554 * callback may also be called before this function returns if there is
2555 * another target to try.
2556 *
2557 * @param call_id The call ID.
2558 * @param cmd Redirection operation to be applied to the current
2559 * target. The semantic of this argument is similar
2560 * to the description in the \a on_call_redirected()
2561 * callback, except that the PJSIP_REDIRECT_PENDING is
2562 * not accepted here.
2563 *
2564 * @return PJ_SUCCESS on successful operation.
2565 */
2566PJ_DECL(pj_status_t) pjsua_call_process_redirect(pjsua_call_id call_id,
2567 pjsip_redirect_op cmd);
Benny Prijono26ff9062006-02-21 23:47:00 +00002568
2569/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002570 * Put the specified call on hold. This will send re-INVITE with the
2571 * appropriate SDP to inform remote that the call is being put on hold.
2572 * The final status of the request itself will be reported on the
2573 * \a on_call_media_state() callback, which inform the application that
2574 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002575 *
2576 * @param call_id Call identification.
2577 * @param msg_data Optional message components to be sent with
2578 * the request.
2579 *
2580 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00002581 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002582PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
2583 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002584
2585
2586/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002587 * Send re-INVITE to release hold.
2588 * The final status of the request itself will be reported on the
2589 * \a on_call_media_state() callback, which inform the application that
2590 * the media state of the call has changed.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002591 *
2592 * @param call_id Call identification.
2593 * @param unhold If this argument is non-zero and the call is locally
2594 * held, this will release the local hold.
2595 * @param msg_data Optional message components to be sent with
2596 * the request.
2597 *
2598 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00002599 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002600PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
2601 pj_bool_t unhold,
2602 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002603
Benny Prijonoc08682e2007-10-04 06:17:58 +00002604/**
2605 * Send UPDATE request.
2606 *
2607 * @param call_id Call identification.
2608 * @param options Must be zero for now.
2609 * @param msg_data Optional message components to be sent with
2610 * the request.
2611 *
2612 * @return PJ_SUCCESS on success, or the appropriate error code.
2613 */
2614PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
2615 unsigned options,
2616 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00002617
2618/**
Benny Prijono053f5222006-11-11 16:16:04 +00002619 * Initiate call transfer to the specified address. This function will send
2620 * REFER request to instruct remote call party to initiate a new INVITE
2621 * session to the specified destination/target.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002622 *
Benny Prijonob5388cf2007-01-04 22:45:08 +00002623 * If application is interested to monitor the successfulness and
2624 * the progress of the transfer request, it can implement
2625 * \a on_call_transfer_status() callback which will report the progress
2626 * of the call transfer request.
2627 *
Benny Prijono053f5222006-11-11 16:16:04 +00002628 * @param call_id The call id to be transfered.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002629 * @param dest Address of new target to be contacted.
2630 * @param msg_data Optional message components to be sent with
2631 * the request.
2632 *
2633 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00002634 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002635PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
2636 const pj_str_t *dest,
2637 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002638
2639/**
Benny Prijono053f5222006-11-11 16:16:04 +00002640 * Flag to indicate that "Require: replaces" should not be put in the
2641 * outgoing INVITE request caused by REFER request created by
2642 * #pjsua_call_xfer_replaces().
2643 */
2644#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
2645
2646/**
2647 * Initiate attended call transfer. This function will send REFER request
2648 * to instruct remote call party to initiate new INVITE session to the URL
2649 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
2650 * the call with us with the new call from the REFER recipient.
2651 *
2652 * @param call_id The call id to be transfered.
2653 * @param dest_call_id The call id to be replaced.
2654 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
2655 * to suppress the inclusion of "Require: replaces" in
2656 * the outgoing INVITE request created by the REFER
2657 * request.
2658 * @param msg_data Optional message components to be sent with
2659 * the request.
2660 *
2661 * @return PJ_SUCCESS on success, or the appropriate error code.
2662 */
2663PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
2664 pjsua_call_id dest_call_id,
2665 unsigned options,
2666 const pjsua_msg_data *msg_data);
2667
2668/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002669 * Send DTMF digits to remote using RFC 2833 payload formats.
2670 *
2671 * @param call_id Call identification.
Benny Prijonoe6ead542007-01-31 20:53:31 +00002672 * @param digits DTMF string digits to be sent.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002673 *
2674 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002675 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002676PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002677 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00002678
Benny Prijono26ff9062006-02-21 23:47:00 +00002679/**
Benny Prijonob0808372006-03-02 21:18:58 +00002680 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002681 *
2682 * @param call_id Call identification.
2683 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
2684 * assumed.
2685 * @param content The message content.
2686 * @param msg_data Optional list of headers etc to be included in outgoing
2687 * request. The body descriptor in the msg_data is
2688 * ignored.
2689 * @param user_data Optional user data, which will be given back when
2690 * the IM callback is called.
2691 *
2692 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00002693 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002694PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
2695 const pj_str_t *mime_type,
2696 const pj_str_t *content,
2697 const pjsua_msg_data *msg_data,
2698 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00002699
2700
2701/**
2702 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002703 *
2704 * @param call_id Call identification.
2705 * @param is_typing Non-zero to indicate to remote that local person is
2706 * currently typing an IM.
2707 * @param msg_data Optional list of headers etc to be included in outgoing
2708 * request.
2709 *
2710 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00002711 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002712PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
2713 pj_bool_t is_typing,
2714 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00002715
2716/**
Benny Prijonofeb69f42007-10-05 09:12:26 +00002717 * Send arbitrary request with the call. This is useful for example to send
2718 * INFO request. Note that application should not use this function to send
2719 * requests which would change the invite session's state, such as re-INVITE,
2720 * UPDATE, PRACK, and BYE.
2721 *
2722 * @param call_id Call identification.
2723 * @param method SIP method of the request.
2724 * @param msg_data Optional message body and/or list of headers to be
2725 * included in outgoing request.
2726 *
2727 * @return PJ_SUCCESS on success, or the appropriate error code.
2728 */
2729PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
2730 const pj_str_t *method,
2731 const pjsua_msg_data *msg_data);
2732
2733
2734/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002735 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
2736 * currently active calls.
Benny Prijono834aee32006-02-19 01:38:06 +00002737 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00002738PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00002739
2740
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002741/**
2742 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002743 *
2744 * @param call_id Call identification.
2745 * @param with_media Non-zero to include media information too.
2746 * @param buffer Buffer where the statistics are to be written to.
2747 * @param maxlen Maximum length of buffer.
2748 * @param indent Spaces for left indentation.
2749 *
2750 * @return PJ_SUCCESS on success.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002751 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002752PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
2753 pj_bool_t with_media,
2754 char *buffer,
2755 unsigned maxlen,
2756 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00002757
Benny Prijono9fc735d2006-05-28 14:58:12 +00002758/**
Benny Prijono312aff92006-06-17 04:08:30 +00002759 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00002760 */
Benny Prijono834aee32006-02-19 01:38:06 +00002761
2762
2763/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00002764 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00002765 */
2766
Benny Prijono312aff92006-06-17 04:08:30 +00002767
2768/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00002769 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
Benny Prijono312aff92006-06-17 04:08:30 +00002770 * @ingroup PJSUA_LIB
2771 * @brief Buddy management, buddy's presence, and instant messaging.
2772 * @{
Benny Prijonoe6ead542007-01-31 20:53:31 +00002773 *
2774 * This section describes PJSUA-APIs related to buddies management,
2775 * presence management, and instant messaging.
Benny Prijono312aff92006-06-17 04:08:30 +00002776 */
2777
2778/**
2779 * Max buddies in buddy list.
2780 */
2781#ifndef PJSUA_MAX_BUDDIES
2782# define PJSUA_MAX_BUDDIES 256
2783#endif
2784
2785
2786/**
Benny Prijonoa17496a2007-10-31 10:20:31 +00002787 * This specifies how long the library should retry resending SUBSCRIBE
Benny Prijono53984d12009-04-28 22:19:49 +00002788 * if the previous SUBSCRIBE failed. This also controls the duration
2789 * before failed PUBLISH request will be retried.
Benny Prijonoa17496a2007-10-31 10:20:31 +00002790 *
2791 * Default: 300 seconds
2792 */
2793#ifndef PJSUA_PRES_TIMER
2794# define PJSUA_PRES_TIMER 300
2795#endif
2796
2797
2798/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002799 * This structure describes buddy configuration when adding a buddy to
2800 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
2801 * the structure with #pjsua_buddy_config_default() to initialize this
2802 * structure with default configuration.
Benny Prijono312aff92006-06-17 04:08:30 +00002803 */
2804typedef struct pjsua_buddy_config
2805{
2806 /**
2807 * Buddy URL or name address.
2808 */
2809 pj_str_t uri;
2810
2811 /**
2812 * Specify whether presence subscription should start immediately.
2813 */
2814 pj_bool_t subscribe;
2815
Benny Prijono705e7842008-07-21 18:12:51 +00002816 /**
2817 * Specify arbitrary application data to be associated with with
2818 * the buddy object.
2819 */
2820 void *user_data;
2821
Benny Prijono312aff92006-06-17 04:08:30 +00002822} pjsua_buddy_config;
2823
2824
2825/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002826 * This enumeration describes basic buddy's online status.
Benny Prijono312aff92006-06-17 04:08:30 +00002827 */
2828typedef enum pjsua_buddy_status
2829{
2830 /**
2831 * Online status is unknown (possibly because no presence subscription
2832 * has been established).
2833 */
2834 PJSUA_BUDDY_STATUS_UNKNOWN,
2835
2836 /**
Benny Prijonofc24e692007-01-27 18:31:51 +00002837 * Buddy is known to be online.
Benny Prijono312aff92006-06-17 04:08:30 +00002838 */
2839 PJSUA_BUDDY_STATUS_ONLINE,
2840
2841 /**
2842 * Buddy is offline.
2843 */
2844 PJSUA_BUDDY_STATUS_OFFLINE,
2845
2846} pjsua_buddy_status;
2847
2848
2849
2850/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002851 * This structure describes buddy info, which can be retrieved by calling
2852 * #pjsua_buddy_get_info().
Benny Prijono312aff92006-06-17 04:08:30 +00002853 */
2854typedef struct pjsua_buddy_info
2855{
2856 /**
2857 * The buddy ID.
2858 */
2859 pjsua_buddy_id id;
2860
2861 /**
2862 * The full URI of the buddy, as specified in the configuration.
2863 */
2864 pj_str_t uri;
2865
2866 /**
2867 * Buddy's Contact, only available when presence subscription has
2868 * been established to the buddy.
2869 */
2870 pj_str_t contact;
2871
2872 /**
2873 * Buddy's online status.
2874 */
2875 pjsua_buddy_status status;
2876
2877 /**
2878 * Text to describe buddy's online status.
2879 */
2880 pj_str_t status_text;
2881
2882 /**
2883 * Flag to indicate that we should monitor the presence information for
2884 * this buddy (normally yes, unless explicitly disabled).
2885 */
2886 pj_bool_t monitor_pres;
2887
2888 /**
Benny Prijono63fba012008-07-17 14:19:10 +00002889 * If \a monitor_pres is enabled, this specifies the last state of the
2890 * presence subscription. If presence subscription session is currently
2891 * active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence
2892 * subscription request has been rejected, the value will be
2893 * PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be
2894 * specified in \a sub_term_reason.
2895 */
2896 pjsip_evsub_state sub_state;
2897
2898 /**
2899 * Specifies the last presence subscription terminatino reason. If
2900 * presence subscription is currently active, the value will be empty.
2901 */
2902 pj_str_t sub_term_reason;
2903
2904 /**
Benny Prijono4461c7d2007-08-25 13:36:15 +00002905 * Extended RPID information about the person.
2906 */
2907 pjrpid_element rpid;
2908
2909 /**
Benny Prijono312aff92006-06-17 04:08:30 +00002910 * Internal buffer.
2911 */
Benny Prijono4461c7d2007-08-25 13:36:15 +00002912 char buf_[512];
Benny Prijono312aff92006-06-17 04:08:30 +00002913
2914} pjsua_buddy_info;
2915
2916
Benny Prijono834aee32006-02-19 01:38:06 +00002917/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002918 * Set default values to the buddy config.
2919 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00002920PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
Benny Prijonob5388cf2007-01-04 22:45:08 +00002921
2922
2923/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002924 * Get total number of buddies.
2925 *
2926 * @return Number of buddies.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002927 */
2928PJ_DECL(unsigned) pjsua_get_buddy_count(void);
2929
2930
2931/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002932 * Check if buddy ID is valid.
2933 *
2934 * @param buddy_id Buddy ID to check.
2935 *
2936 * @return Non-zero if buddy ID is valid.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002937 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002938PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
2939
2940
2941/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00002942 * Enumerate all buddy IDs in the buddy list. Application then can use
2943 * #pjsua_buddy_get_info() to get the detail information for each buddy
2944 * id.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002945 *
2946 * @param ids Array of ids to be initialized.
2947 * @param count On input, specifies max elements in the array.
2948 * On return, it contains actual number of elements
2949 * that have been initialized.
2950 *
2951 * @return PJ_SUCCESS on success, or the appropriate error code.
2952 */
2953PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
2954 unsigned *count);
2955
2956/**
Benny Prijono705e7842008-07-21 18:12:51 +00002957 * Find the buddy ID with the specified URI.
2958 *
2959 * @param uri The buddy URI.
2960 *
2961 * @return The buddy ID, or PJSUA_INVALID_ID if not found.
2962 */
2963PJ_DECL(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri);
2964
2965
2966/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002967 * Get detailed buddy info.
2968 *
2969 * @param buddy_id The buddy identification.
2970 * @param info Pointer to receive information about buddy.
2971 *
2972 * @return PJ_SUCCESS on success, or the appropriate error code.
2973 */
2974PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00002975 pjsua_buddy_info *info);
2976
2977/**
Benny Prijono705e7842008-07-21 18:12:51 +00002978 * Set the user data associated with the buddy object.
2979 *
2980 * @param buddy_id The buddy identification.
2981 * @param user_data Arbitrary application data to be associated with
2982 * the buddy object.
2983 *
2984 * @return PJ_SUCCESS on success, or the appropriate error code.
2985 */
2986PJ_DECL(pj_status_t) pjsua_buddy_set_user_data(pjsua_buddy_id buddy_id,
2987 void *user_data);
2988
2989
2990/**
2991 * Get the user data associated with the budy object.
2992 *
2993 * @param buddy_id The buddy identification.
2994 *
2995 * @return The application data.
2996 */
2997PJ_DECL(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id);
2998
2999
3000/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003001 * Add new buddy to the buddy list. If presence subscription is enabled
3002 * for this buddy, this function will also start the presence subscription
3003 * session immediately.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003004 *
Benny Prijonoa7b376b2008-01-25 16:06:33 +00003005 * @param buddy_cfg Buddy configuration.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003006 * @param p_buddy_id Pointer to receive buddy ID.
3007 *
3008 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003009 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003010PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003011 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003012
3013
3014/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003015 * Delete the specified buddy from the buddy list. Any presence subscription
3016 * to this buddy will be terminated.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003017 *
3018 * @param buddy_id Buddy identification.
3019 *
3020 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00003021 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003022PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003023
3024
3025/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003026 * Enable/disable buddy's presence monitoring. Once buddy's presence is
3027 * subscribed, application will be informed about buddy's presence status
3028 * changed via \a on_buddy_state() callback.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003029 *
3030 * @param buddy_id Buddy identification.
3031 * @param subscribe Specify non-zero to activate presence subscription to
3032 * the specified buddy.
3033 *
3034 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003035 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003036PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
3037 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003038
3039
3040/**
Benny Prijono10861432007-10-31 10:54:53 +00003041 * Update the presence information for the buddy. Although the library
3042 * periodically refreshes the presence subscription for all buddies, some
3043 * application may want to refresh the buddy's presence subscription
3044 * immediately, and in this case it can use this function to accomplish
3045 * this.
3046 *
3047 * Note that the buddy's presence subscription will only be initiated
3048 * if presence monitoring is enabled for the buddy. See
3049 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
3050 * for the buddy is already active, this function will not do anything.
3051 *
3052 * Once the presence subscription is activated successfully for the buddy,
3053 * application will be notified about the buddy's presence status in the
3054 * on_buddy_state() callback.
3055 *
3056 * @param buddy_id Buddy identification.
3057 *
3058 * @return PJ_SUCCESS on success, or the appropriate error code.
3059 */
3060PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
3061
3062
3063/**
Benny Prijono63fba012008-07-17 14:19:10 +00003064 * Send NOTIFY to inform account presence status or to terminate server
3065 * side presence subscription. If application wants to reject the incoming
3066 * request, it should set the \a state to PJSIP_EVSUB_STATE_TERMINATED.
3067 *
3068 * @param acc_id Account ID.
3069 * @param srv_pres Server presence subscription instance.
3070 * @param state New state to set.
3071 * @param state_str Optionally specify the state string name, if state
3072 * is not "active", "pending", or "terminated".
3073 * @param reason If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3074 * optionally specify the termination reason.
3075 * @param with_body If the new state is PJSIP_EVSUB_STATE_TERMINATED,
3076 * this specifies whether the NOTIFY request should
3077 * contain message body containing account's presence
3078 * information.
3079 * @param msg_data Optional list of headers to be sent with the NOTIFY
3080 * request.
3081 *
3082 * @return PJ_SUCCESS on success.
3083 */
3084PJ_DECL(pj_status_t) pjsua_pres_notify(pjsua_acc_id acc_id,
3085 pjsua_srv_pres *srv_pres,
3086 pjsip_evsub_state state,
3087 const pj_str_t *state_str,
3088 const pj_str_t *reason,
3089 pj_bool_t with_body,
3090 const pjsua_msg_data *msg_data);
3091
3092/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003093 * Dump presence subscriptions to log.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003094 *
3095 * @param verbose Yes or no.
Benny Prijono834aee32006-02-19 01:38:06 +00003096 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003097PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00003098
3099
Benny Prijonob0808372006-03-02 21:18:58 +00003100/**
3101 * The MESSAGE method (defined in pjsua_im.c)
3102 */
3103extern const pjsip_method pjsip_message_method;
3104
3105
Benny Prijonob0808372006-03-02 21:18:58 +00003106
3107/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003108 * Send instant messaging outside dialog, using the specified account for
3109 * route set and authentication.
3110 *
3111 * @param acc_id Account ID to be used to send the request.
3112 * @param to Remote URI.
3113 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
3114 * assumed.
3115 * @param content The message content.
3116 * @param msg_data Optional list of headers etc to be included in outgoing
3117 * request. The body descriptor in the msg_data is
3118 * ignored.
3119 * @param user_data Optional user data, which will be given back when
3120 * the IM callback is called.
3121 *
3122 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003123 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003124PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
3125 const pj_str_t *to,
3126 const pj_str_t *mime_type,
3127 const pj_str_t *content,
3128 const pjsua_msg_data *msg_data,
3129 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003130
3131
3132/**
3133 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003134 *
3135 * @param acc_id Account ID to be used to send the request.
3136 * @param to Remote URI.
3137 * @param is_typing If non-zero, it tells remote person that local person
3138 * is currently composing an IM.
3139 * @param msg_data Optional list of headers etc to be added to outgoing
3140 * request.
3141 *
3142 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00003143 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003144PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
3145 const pj_str_t *to,
3146 pj_bool_t is_typing,
3147 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00003148
3149
Benny Prijonof3195072006-02-14 21:15:30 +00003150
Benny Prijono312aff92006-06-17 04:08:30 +00003151/**
3152 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00003153 */
3154
Benny Prijono312aff92006-06-17 04:08:30 +00003155
3156/*****************************************************************************
3157 * MEDIA API
3158 */
3159
3160
3161/**
Benny Prijonoe6ead542007-01-31 20:53:31 +00003162 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
Benny Prijono312aff92006-06-17 04:08:30 +00003163 * @ingroup PJSUA_LIB
3164 * @brief Media manipulation.
3165 * @{
3166 *
3167 * PJSUA has rather powerful media features, which are built around the
Benny Prijonoe6ead542007-01-31 20:53:31 +00003168 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
3169 * players, WAV playlist, file recorders, sound device, tone generators, etc)
Benny Prijono312aff92006-06-17 04:08:30 +00003170 * are terminated in the conference bridge, and application can manipulate
Benny Prijonoe6ead542007-01-31 20:53:31 +00003171 * the interconnection between these terminations freely.
3172 *
3173 * The conference bridge provides powerful switching and mixing functionality
3174 * for application. With the conference bridge, each conference slot (e.g.
3175 * a call) can transmit to multiple destinations, and one destination can
3176 * receive from multiple sources. If more than one media terminations are
3177 * terminated in the same slot, the conference bridge will mix the signal
3178 * automatically.
Benny Prijono312aff92006-06-17 04:08:30 +00003179 *
3180 * Application connects one media termination/slot to another by calling
3181 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
Benny Prijonoe6ead542007-01-31 20:53:31 +00003182 * media flow from the source termination to the sink termination. To
3183 * establish bidirectional media flow, application wound need to make another
3184 * call to #pjsua_conf_connect(), this time inverting the source and
3185 * destination slots in the parameter.
3186 *
3187 * For example, to stream a WAV file to remote call, application may use
Benny Prijono312aff92006-06-17 04:08:30 +00003188 * the following steps:
3189 *
3190 \code
3191
3192 pj_status_t stream_to_call( pjsua_call_id call_id )
3193 {
3194 pjsua_player_id player_id;
3195
3196 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
3197 if (status != PJ_SUCCESS)
3198 return status;
3199
3200 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
3201 pjsua_call_get_conf_port() );
3202 }
3203 \endcode
3204 *
3205 *
3206 * Other features of PJSUA media:
3207 * - efficient N to M interconnections between media terminations.
3208 * - media termination can be connected to itself to create loopback
3209 * media.
3210 * - the media termination may have different clock rates, and resampling
3211 * will be done automatically by conference bridge.
3212 * - media terminations may also have different frame time; the
3213 * conference bridge will perform the necessary bufferring to adjust
3214 * the difference between terminations.
3215 * - interconnections are removed automatically when media termination
3216 * is removed from the bridge.
3217 * - sound device may be changed even when there are active media
3218 * interconnections.
3219 * - correctly report call's media quality (in #pjsua_call_dump()) from
3220 * RTCP packet exchange.
3221 */
3222
3223/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003224 * Max ports in the conference bridge. This setting is the default value
3225 * for pjsua_media_config.max_media_ports.
Benny Prijono312aff92006-06-17 04:08:30 +00003226 */
3227#ifndef PJSUA_MAX_CONF_PORTS
Benny Prijono12a669c2006-11-23 07:32:13 +00003228# define PJSUA_MAX_CONF_PORTS 254
Benny Prijono312aff92006-06-17 04:08:30 +00003229#endif
3230
Benny Prijonob5388cf2007-01-04 22:45:08 +00003231/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003232 * The default clock rate to be used by the conference bridge. This setting
3233 * is the default value for pjsua_media_config.clock_rate.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003234 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003235#ifndef PJSUA_DEFAULT_CLOCK_RATE
3236# define PJSUA_DEFAULT_CLOCK_RATE 16000
3237#endif
3238
Benny Prijonob5388cf2007-01-04 22:45:08 +00003239/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003240 * Default frame length in the conference bridge. This setting
3241 * is the default value for pjsua_media_config.audio_frame_ptime.
3242 */
3243#ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Nanang Izzuddinaf974842008-05-08 09:51:16 +00003244# define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
Benny Prijono37c710b2008-01-10 12:09:26 +00003245#endif
3246
3247
3248/**
3249 * Default codec quality settings. This setting is the default value
3250 * for pjsua_media_config.quality.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003251 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003252#ifndef PJSUA_DEFAULT_CODEC_QUALITY
Nanang Izzuddin9dbad152008-06-10 18:56:10 +00003253# define PJSUA_DEFAULT_CODEC_QUALITY 8
Benny Prijono12a669c2006-11-23 07:32:13 +00003254#endif
3255
Benny Prijonob5388cf2007-01-04 22:45:08 +00003256/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003257 * Default iLBC mode. This setting is the default value for
3258 * pjsua_media_config.ilbc_mode.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003259 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003260#ifndef PJSUA_DEFAULT_ILBC_MODE
Benny Prijono37c710b2008-01-10 12:09:26 +00003261# define PJSUA_DEFAULT_ILBC_MODE 30
Benny Prijono12a669c2006-11-23 07:32:13 +00003262#endif
3263
Benny Prijonob5388cf2007-01-04 22:45:08 +00003264/**
Benny Prijono37c710b2008-01-10 12:09:26 +00003265 * The default echo canceller tail length. This setting
3266 * is the default value for pjsua_media_config.ec_tail_len.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003267 */
Benny Prijono12a669c2006-11-23 07:32:13 +00003268#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijono427439c2007-10-21 09:41:24 +00003269# define PJSUA_DEFAULT_EC_TAIL_LEN 200
Benny Prijono12a669c2006-11-23 07:32:13 +00003270#endif
Benny Prijono312aff92006-06-17 04:08:30 +00003271
3272
3273/**
Benny Prijonocba59d92007-02-16 09:22:56 +00003274 * The maximum file player.
3275 */
3276#ifndef PJSUA_MAX_PLAYERS
3277# define PJSUA_MAX_PLAYERS 32
3278#endif
3279
3280
3281/**
3282 * The maximum file player.
3283 */
3284#ifndef PJSUA_MAX_RECORDERS
3285# define PJSUA_MAX_RECORDERS 32
3286#endif
3287
3288
3289/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003290 * This structure describes media configuration, which will be specified
3291 * when calling #pjsua_init(). Application MUST initialize this structure
3292 * by calling #pjsua_media_config_default().
Benny Prijono312aff92006-06-17 04:08:30 +00003293 */
3294struct pjsua_media_config
3295{
3296 /**
3297 * Clock rate to be applied to the conference bridge.
Benny Prijonob5388cf2007-01-04 22:45:08 +00003298 * If value is zero, default clock rate will be used
3299 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
Benny Prijono312aff92006-06-17 04:08:30 +00003300 */
3301 unsigned clock_rate;
3302
3303 /**
Benny Prijonof3758ee2008-02-26 15:32:16 +00003304 * Clock rate to be applied when opening the sound device.
3305 * If value is zero, conference bridge clock rate will be used.
3306 */
3307 unsigned snd_clock_rate;
3308
3309 /**
Benny Prijono7d60d052008-03-29 12:24:20 +00003310 * Channel count be applied when opening the sound device and
3311 * conference bridge.
3312 */
3313 unsigned channel_count;
3314
3315 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003316 * Specify audio frame ptime. The value here will affect the
3317 * samples per frame of both the sound device and the conference
3318 * bridge. Specifying lower ptime will normally reduce the
3319 * latency.
3320 *
Benny Prijono37c710b2008-01-10 12:09:26 +00003321 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003322 */
3323 unsigned audio_frame_ptime;
3324
3325 /**
Benny Prijono312aff92006-06-17 04:08:30 +00003326 * Specify maximum number of media ports to be created in the
3327 * conference bridge. Since all media terminate in the bridge
3328 * (calls, file player, file recorder, etc), the value must be
3329 * large enough to support all of them. However, the larger
3330 * the value, the more computations are performed.
Benny Prijono37c710b2008-01-10 12:09:26 +00003331 *
3332 * Default value: PJSUA_MAX_CONF_PORTS
Benny Prijono312aff92006-06-17 04:08:30 +00003333 */
3334 unsigned max_media_ports;
3335
3336 /**
3337 * Specify whether the media manager should manage its own
3338 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
3339 * and at least one worker thread will be created too. If no,
3340 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
3341 * and no worker thread is needed.
3342 *
3343 * Normally application would say yes here, unless it wants to
3344 * run everything from a single thread.
3345 */
3346 pj_bool_t has_ioqueue;
3347
3348 /**
3349 * Specify the number of worker threads to handle incoming RTP
3350 * packets. A value of one is recommended for most applications.
3351 */
3352 unsigned thread_cnt;
3353
Benny Prijono0498d902006-06-19 14:49:14 +00003354 /**
3355 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00003356 * 5-10: resampling use large filter,
3357 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00003358 * 1-2: resampling use linear.
3359 * The media quality also sets speex codec quality/complexity to the
3360 * number.
3361 *
Benny Prijono70972992006-08-05 11:13:58 +00003362 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00003363 */
3364 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00003365
3366 /**
Benny Prijonocf0b4b22007-10-06 17:31:09 +00003367 * Specify default codec ptime.
Benny Prijono0a12f002006-07-26 17:05:39 +00003368 *
3369 * Default: 0 (codec specific)
3370 */
3371 unsigned ptime;
3372
3373 /**
3374 * Disable VAD?
3375 *
3376 * Default: 0 (no (meaning VAD is enabled))
3377 */
3378 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00003379
3380 /**
3381 * iLBC mode (20 or 30).
3382 *
Benny Prijono37c710b2008-01-10 12:09:26 +00003383 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00003384 */
3385 unsigned ilbc_mode;
3386
3387 /**
3388 * Percentage of RTP packet to drop in TX direction
3389 * (to simulate packet lost).
3390 *
3391 * Default: 0
3392 */
3393 unsigned tx_drop_pct;
3394
3395 /**
3396 * Percentage of RTP packet to drop in RX direction
3397 * (to simulate packet lost).
3398 *
3399 * Default: 0
3400 */
3401 unsigned rx_drop_pct;
3402
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003403 /**
Benny Prijono5da50432006-08-07 10:24:52 +00003404 * Echo canceller options (see #pjmedia_echo_create())
3405 *
3406 * Default: 0.
3407 */
3408 unsigned ec_options;
3409
3410 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003411 * Echo canceller tail length, in miliseconds.
3412 *
Benny Prijono669643c2006-09-20 20:02:18 +00003413 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
Benny Prijonoc8e24a12006-08-02 18:22:22 +00003414 */
3415 unsigned ec_tail_len;
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003416
Benny Prijono10454dc2009-02-21 14:21:59 +00003417 /**
3418 * Audio capture buffer length, in milliseconds.
3419 *
3420 * Default: PJMEDIA_SND_DEFAULT_REC_LATENCY
3421 */
3422 unsigned snd_rec_latency;
3423
3424 /**
3425 * Audio playback buffer length, in milliseconds.
3426 *
3427 * Default: PJMEDIA_SND_DEFAULT_PLAY_LATENCY
3428 */
3429 unsigned snd_play_latency;
3430
Benny Prijono1d0ca0c2006-11-21 09:06:47 +00003431 /**
3432 * Jitter buffer initial prefetch delay in msec. The value must be
3433 * between jb_min_pre and jb_max_pre below.
3434 *
3435 * Default: -1 (to use default stream settings, currently 150 msec)
3436 */
3437 int jb_init;
3438
3439 /**
3440 * Jitter buffer minimum prefetch delay in msec.
3441 *
3442 * Default: -1 (to use default stream settings, currently 60 msec)
3443 */
3444 int jb_min_pre;
3445
3446 /**
3447 * Jitter buffer maximum prefetch delay in msec.
3448 *
3449 * Default: -1 (to use default stream settings, currently 240 msec)
3450 */
3451 int jb_max_pre;
3452
3453 /**
3454 * Set maximum delay that can be accomodated by the jitter buffer msec.
3455 *
3456 * Default: -1 (to use default stream settings, currently 360 msec)
3457 */
3458 int jb_max;
3459
Benny Prijonoc97608e2007-03-23 16:34:20 +00003460 /**
3461 * Enable ICE
3462 */
3463 pj_bool_t enable_ice;
3464
3465 /**
Benny Prijono329d6382009-05-29 13:04:03 +00003466 * Set the maximum number of host candidates.
3467 *
3468 * Default: -1 (maximum not set)
Benny Prijonoc97608e2007-03-23 16:34:20 +00003469 */
Benny Prijono329d6382009-05-29 13:04:03 +00003470 int ice_max_host_cands;
3471
3472 /**
3473 * ICE session options.
3474 */
3475 pj_ice_sess_options ice_opt;
Benny Prijonof76e1392008-06-06 14:51:48 +00003476
3477 /**
Benny Prijono551af422008-08-07 09:55:52 +00003478 * Disable RTCP component.
3479 *
3480 * Default: no
3481 */
3482 pj_bool_t ice_no_rtcp;
3483
3484 /**
Benny Prijonof76e1392008-06-06 14:51:48 +00003485 * Enable TURN relay candidate in ICE.
3486 */
3487 pj_bool_t enable_turn;
3488
3489 /**
3490 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
3491 * "HOST:PORT" format.
3492 */
3493 pj_str_t turn_server;
3494
3495 /**
3496 * Specify the connection type to be used to the TURN server. Valid
3497 * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP.
3498 *
3499 * Default: PJ_TURN_TP_UDP
3500 */
3501 pj_turn_tp_type turn_conn_type;
3502
3503 /**
3504 * Specify the credential to authenticate with the TURN server.
3505 */
3506 pj_stun_auth_cred turn_auth_cred;
Nanang Izzuddin68559c32008-06-13 17:01:46 +00003507
3508 /**
3509 * Specify idle time of sound device before it is automatically closed,
Benny Prijonof798e502009-03-09 13:08:16 +00003510 * in seconds. Use value -1 to disable the auto-close feature of sound
3511 * device
Nanang Izzuddin68559c32008-06-13 17:01:46 +00003512 *
Benny Prijonof798e502009-03-09 13:08:16 +00003513 * Default : 1
Nanang Izzuddin68559c32008-06-13 17:01:46 +00003514 */
3515 int snd_auto_close_time;
Benny Prijono312aff92006-06-17 04:08:30 +00003516};
3517
3518
3519/**
3520 * Use this function to initialize media config.
3521 *
3522 * @param cfg The media config to be initialized.
3523 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +00003524PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
Benny Prijono312aff92006-06-17 04:08:30 +00003525
3526
3527/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003528 * This structure describes codec information, which can be retrieved by
3529 * calling #pjsua_enum_codecs().
Benny Prijono312aff92006-06-17 04:08:30 +00003530 */
3531typedef struct pjsua_codec_info
3532{
3533 /**
3534 * Codec unique identification.
3535 */
3536 pj_str_t codec_id;
3537
3538 /**
3539 * Codec priority (integer 0-255).
3540 */
3541 pj_uint8_t priority;
3542
3543 /**
3544 * Internal buffer.
3545 */
3546 char buf_[32];
3547
3548} pjsua_codec_info;
3549
3550
3551/**
Benny Prijonob5388cf2007-01-04 22:45:08 +00003552 * This structure descibes information about a particular media port that
3553 * has been registered into the conference bridge. Application can query
3554 * this info by calling #pjsua_conf_get_port_info().
Benny Prijono312aff92006-06-17 04:08:30 +00003555 */
3556typedef struct pjsua_conf_port_info
3557{
3558 /** Conference port number. */
3559 pjsua_conf_port_id slot_id;
3560
3561 /** Port name. */
3562 pj_str_t name;
3563
3564 /** Clock rate. */
3565 unsigned clock_rate;
3566
3567 /** Number of channels. */
3568 unsigned channel_count;
3569
3570 /** Samples per frame */
3571 unsigned samples_per_frame;
3572
3573 /** Bits per sample */
3574 unsigned bits_per_sample;
3575
3576 /** Number of listeners in the array. */
3577 unsigned listener_cnt;
3578
3579 /** Array of listeners (in other words, ports where this port is
3580 * transmitting to.
3581 */
3582 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
3583
3584} pjsua_conf_port_info;
3585
3586
3587/**
3588 * This structure holds information about custom media transport to
3589 * be registered to pjsua.
3590 */
3591typedef struct pjsua_media_transport
3592{
3593 /**
3594 * Media socket information containing the address information
3595 * of the RTP and RTCP socket.
3596 */
3597 pjmedia_sock_info skinfo;
3598
3599 /**
3600 * The media transport instance.
3601 */
3602 pjmedia_transport *transport;
3603
3604} pjsua_media_transport;
3605
3606
3607
3608
Benny Prijono9fc735d2006-05-28 14:58:12 +00003609/**
3610 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003611 *
3612 * @return Maximum number of ports in the conference bridge.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003613 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003614PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003615
3616
3617/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003618 * Get current number of active ports in the bridge.
3619 *
3620 * @return The number.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003621 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003622PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
3623
3624
3625/**
3626 * Enumerate all conference ports.
3627 *
3628 * @param id Array of conference port ID to be initialized.
3629 * @param count On input, specifies max elements in the array.
3630 * On return, it contains actual number of elements
3631 * that have been initialized.
3632 *
3633 * @return PJ_SUCCESS on success, or the appropriate error code.
3634 */
3635PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
3636 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00003637
3638
3639/**
3640 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003641 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003642 * @param port_id Port identification.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003643 * @param info Pointer to store the port info.
3644 *
3645 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00003646 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003647PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +00003648 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003649
3650
3651/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00003652 * Add arbitrary media port to PJSUA's conference bridge. Application
3653 * can use this function to add the media port that it creates. For
3654 * media ports that are created by PJSUA-LIB (such as calls, file player,
3655 * or file recorder), PJSUA-LIB will automatically add the port to
3656 * the bridge.
3657 *
3658 * @param pool Pool to use.
3659 * @param port Media port to be added to the bridge.
3660 * @param p_id Optional pointer to receive the conference
3661 * slot id.
3662 *
3663 * @return PJ_SUCCESS on success, or the appropriate error code.
3664 */
3665PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
3666 pjmedia_port *port,
3667 pjsua_conf_port_id *p_id);
3668
3669
3670/**
3671 * Remove arbitrary slot from the conference bridge. Application should only
Benny Prijonob5388cf2007-01-04 22:45:08 +00003672 * call this function if it registered the port manually with previous call
3673 * to #pjsua_conf_add_port().
Benny Prijonoe909eac2006-07-27 22:04:56 +00003674 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00003675 * @param port_id The slot id of the port to be removed.
Benny Prijonoe909eac2006-07-27 22:04:56 +00003676 *
3677 * @return PJ_SUCCESS on success, or the appropriate error code.
3678 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00003679PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
Benny Prijonoe909eac2006-07-27 22:04:56 +00003680
3681
3682/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003683 * Establish unidirectional media flow from souce to sink. One source
3684 * may transmit to multiple destinations/sink. And if multiple
3685 * sources are transmitting to the same sink, the media will be mixed
3686 * together. Source and sink may refer to the same ID, effectively
3687 * looping the media.
3688 *
3689 * If bidirectional media flow is desired, application needs to call
3690 * this function twice, with the second one having the arguments
3691 * reversed.
3692 *
3693 * @param source Port ID of the source media/transmitter.
3694 * @param sink Port ID of the destination media/received.
3695 *
3696 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003697 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003698PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
3699 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003700
3701
3702/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003703 * Disconnect media flow from the source to destination port.
3704 *
3705 * @param source Port ID of the source media/transmitter.
3706 * @param sink Port ID of the destination media/received.
3707 *
3708 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003709 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003710PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
3711 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003712
3713
Benny Prijono6dd967c2006-12-26 02:27:14 +00003714/**
3715 * Adjust the signal level to be transmitted from the bridge to the
3716 * specified port by making it louder or quieter.
3717 *
3718 * @param slot The conference bridge slot number.
3719 * @param level Signal level adjustment. Value 1.0 means no level
3720 * adjustment, while value 0 means to mute the port.
3721 *
3722 * @return PJ_SUCCESS on success, or the appropriate error code.
3723 */
3724PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
3725 float level);
3726
3727/**
3728 * Adjust the signal level to be received from the specified port (to
3729 * the bridge) by making it louder or quieter.
3730 *
3731 * @param slot The conference bridge slot number.
3732 * @param level Signal level adjustment. Value 1.0 means no level
3733 * adjustment, while value 0 means to mute the port.
3734 *
3735 * @return PJ_SUCCESS on success, or the appropriate error code.
3736 */
3737PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
3738 float level);
3739
3740/**
3741 * Get last signal level transmitted to or received from the specified port.
3742 * The signal level is an integer value in zero to 255, with zero indicates
3743 * no signal, and 255 indicates the loudest signal level.
3744 *
3745 * @param slot The conference bridge slot number.
3746 * @param tx_level Optional argument to receive the level of signal
3747 * transmitted to the specified port (i.e. the direction
3748 * is from the bridge to the port).
3749 * @param rx_level Optional argument to receive the level of signal
3750 * received from the port (i.e. the direction is from the
3751 * port to the bridge).
3752 *
3753 * @return PJ_SUCCESS on success.
3754 */
3755PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
3756 unsigned *tx_level,
3757 unsigned *rx_level);
3758
Benny Prijono6dd967c2006-12-26 02:27:14 +00003759
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003760/*****************************************************************************
Benny Prijonoa66c3312007-01-21 23:12:40 +00003761 * File player and playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003762 */
3763
Benny Prijono9fc735d2006-05-28 14:58:12 +00003764/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003765 * Create a file player, and automatically add this player to
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003766 * the conference bridge.
3767 *
3768 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00003769 * WAV files are supported, and the WAV file MUST be
3770 * formatted as 16bit PCM mono/single channel (any
3771 * clock rate is supported).
Benny Prijono58add7c2008-01-18 13:24:07 +00003772 * @param options Optional option flag. Application may specify
3773 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003774 * @param p_id Pointer to receive player ID.
3775 *
3776 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003777 */
3778PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003779 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003780 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003781
3782
3783/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003784 * Create a file playlist media port, and automatically add the port
3785 * to the conference bridge.
3786 *
3787 * @param file_names Array of file names to be added to the play list.
3788 * Note that the files must have the same clock rate,
3789 * number of channels, and number of bits per sample.
3790 * @param file_count Number of files in the array.
3791 * @param label Optional label to be set for the media port.
3792 * @param options Optional option flag. Application may specify
3793 * PJMEDIA_FILE_NO_LOOP to prevent looping.
3794 * @param p_id Optional pointer to receive player ID.
3795 *
3796 * @return PJ_SUCCESS on success, or the appropriate error code.
3797 */
3798PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
3799 unsigned file_count,
3800 const pj_str_t *label,
3801 unsigned options,
3802 pjsua_player_id *p_id);
3803
3804/**
3805 * Get conference port ID associated with player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003806 *
3807 * @param id The file player ID.
3808 *
3809 * @return Conference port ID associated with this player.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003810 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003811PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003812
3813
3814/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003815 * Get the media port for the player or playlist.
Benny Prijono469b1522006-12-26 03:05:17 +00003816 *
3817 * @param id The player ID.
3818 * @param p_port The media port associated with the player.
3819 *
3820 * @return PJ_SUCCESS on success.
3821 */
Benny Prijono58add7c2008-01-18 13:24:07 +00003822PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
Benny Prijono469b1522006-12-26 03:05:17 +00003823 pjmedia_port **p_port);
3824
3825/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003826 * Set playback position. This operation is not valid for playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003827 *
3828 * @param id The file player ID.
3829 * @param samples The playback position, in samples. Application can
3830 * specify zero to re-start the playback.
3831 *
3832 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003833 */
3834PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
3835 pj_uint32_t samples);
3836
3837
3838/**
Benny Prijonoa66c3312007-01-21 23:12:40 +00003839 * Close the file of playlist, remove the player from the bridge, and free
3840 * resources associated with the file player or playlist.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003841 *
3842 * @param id The file player ID.
3843 *
3844 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003845 */
3846PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
3847
3848
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003849/*****************************************************************************
3850 * File recorder.
3851 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00003852
3853/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003854 * Create a file recorder, and automatically connect this recorder to
Benny Prijonoc95a0f02007-04-09 07:06:08 +00003855 * the conference bridge. The recorder currently supports recording WAV file.
3856 * The type of the recorder to use is determined by the extension of the file
3857 * (e.g. ".wav").
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003858 *
Benny Prijonob3cdb2b2006-10-19 15:49:47 +00003859 * @param filename Output file name. The function will determine the
3860 * default format to be used based on the file extension.
Benny Prijonoc95a0f02007-04-09 07:06:08 +00003861 * Currently ".wav" is supported on all platforms.
Benny Prijono8f310522006-10-20 11:08:49 +00003862 * @param enc_type Optionally specify the type of encoder to be used to
3863 * compress the media, if the file can support different
3864 * encodings. This value must be zero for now.
3865 * @param enc_param Optionally specify codec specific parameter to be
Benny Prijonoc95a0f02007-04-09 07:06:08 +00003866 * passed to the file writer.
Benny Prijono8f310522006-10-20 11:08:49 +00003867 * For .WAV recorder, this value must be NULL.
3868 * @param max_size Maximum file size. Specify zero or -1 to remove size
3869 * limitation. This value must be zero or -1 for now.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003870 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003871 * @param p_id Pointer to receive the recorder instance.
3872 *
3873 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003874 */
3875PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijono8f310522006-10-20 11:08:49 +00003876 unsigned enc_type,
3877 void *enc_param,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003878 pj_ssize_t max_size,
3879 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003880 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003881
3882
3883/**
3884 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003885 *
3886 * @param id The recorder ID.
3887 *
3888 * @return Conference port ID associated with this recorder.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003889 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00003890PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00003891
3892
3893/**
Benny Prijono469b1522006-12-26 03:05:17 +00003894 * Get the media port for the recorder.
3895 *
3896 * @param id The recorder ID.
3897 * @param p_port The media port associated with the recorder.
3898 *
3899 * @return PJ_SUCCESS on success.
3900 */
3901PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
3902 pjmedia_port **p_port);
3903
3904
3905/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003906 * Destroy recorder (this will complete recording).
3907 *
3908 * @param id The recorder ID.
3909 *
3910 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003911 */
3912PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
3913
3914
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003915/*****************************************************************************
3916 * Sound devices.
3917 */
3918
Benny Prijono9fc735d2006-05-28 14:58:12 +00003919/**
Benny Prijonof798e502009-03-09 13:08:16 +00003920 * Enum all audio devices installed in the system.
3921 *
3922 * @param info Array of info to be initialized.
3923 * @param count On input, specifies max elements in the array.
3924 * On return, it contains actual number of elements
3925 * that have been initialized.
3926 *
3927 * @return PJ_SUCCESS on success, or the appropriate error code.
3928 */
3929PJ_DECL(pj_status_t) pjsua_enum_aud_devs(pjmedia_aud_dev_info info[],
3930 unsigned *count);
3931
3932/**
3933 * Enum all sound devices installed in the system (old API).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003934 *
3935 * @param info Array of info to be initialized.
3936 * @param count On input, specifies max elements in the array.
3937 * On return, it contains actual number of elements
3938 * that have been initialized.
3939 *
3940 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00003941 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003942PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
3943 unsigned *count);
Benny Prijonoa3cbb1c2006-08-25 12:41:05 +00003944
3945/**
3946 * Get currently active sound devices. If sound devices has not been created
3947 * (for example when pjsua_start() is not called), it is possible that
3948 * the function returns PJ_SUCCESS with -1 as device IDs.
3949 *
3950 * @param capture_dev On return it will be filled with device ID of the
3951 * capture device.
3952 * @param playback_dev On return it will be filled with device ID of the
3953 * device ID of the playback device.
3954 *
3955 * @return PJ_SUCCESS on success, or the appropriate error code.
3956 */
3957PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
3958 int *playback_dev);
3959
3960
Benny Prijono9fc735d2006-05-28 14:58:12 +00003961/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00003962 * Select or change sound device. Application may call this function at
3963 * any time to replace current sound device.
3964 *
3965 * @param capture_dev Device ID of the capture device.
3966 * @param playback_dev Device ID of the playback device.
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_set_snd_dev(int capture_dev,
3971 int playback_dev);
3972
3973
3974/**
3975 * Set pjsua to use null sound device. The null sound device only provides
3976 * the timing needed by the conference bridge, and will not interract with
3977 * any hardware.
3978 *
3979 * @return PJ_SUCCESS on success, or the appropriate error code.
3980 */
3981PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
3982
3983
Benny Prijonoe909eac2006-07-27 22:04:56 +00003984/**
3985 * Disconnect the main conference bridge from any sound devices, and let
3986 * application connect the bridge to it's own sound device/master port.
3987 *
3988 * @return The port interface of the conference bridge,
3989 * so that application can connect this to it's own
3990 * sound device or master port.
3991 */
3992PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
3993
3994
Benny Prijonof20687a2006-08-04 18:27:19 +00003995/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00003996 * Change the echo cancellation settings.
Benny Prijonof798e502009-03-09 13:08:16 +00003997 *
3998 * The behavior of this function depends on whether the sound device is
3999 * currently active, and if it is, whether device or software AEC is
4000 * being used.
Benny Prijono10454dc2009-02-21 14:21:59 +00004001 *
4002 * If the sound device is currently active, and if the device supports AEC,
4003 * this function will forward the change request to the device and it will
4004 * be up to the device on whether support the request. If software AEC is
4005 * being used (the software EC will be used if the device does not support
4006 * AEC), this function will change the software EC settings. In all cases,
4007 * the setting will be saved for future opening of the sound device.
4008 *
4009 * If the sound device is not currently active, this will only change the
4010 * default AEC settings and the setting will be applied next time the
4011 * sound device is opened.
Benny Prijonof20687a2006-08-04 18:27:19 +00004012 *
4013 * @param tail_ms The tail length, in miliseconds. Set to zero to
4014 * disable AEC.
Benny Prijonoa7b376b2008-01-25 16:06:33 +00004015 * @param options Options to be passed to pjmedia_echo_create().
Benny Prijono5da50432006-08-07 10:24:52 +00004016 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00004017 *
4018 * @return PJ_SUCCESS on success.
4019 */
Benny Prijono5da50432006-08-07 10:24:52 +00004020PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00004021
4022
4023/**
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004024 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00004025 *
4026 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
4027 * If AEC is disabled, the value will be zero.
4028 *
4029 * @return PJ_SUCCESS on success.
4030 */
Benny Prijono22dfe592006-08-06 12:07:13 +00004031PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00004032
4033
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004034/**
Benny Prijonof798e502009-03-09 13:08:16 +00004035 * Check whether the sound device is currently active. The sound device
4036 * may be inactive if the application has set the auto close feature to
4037 * non-zero (the snd_auto_close_time setting in #pjsua_media_config), or
4038 * if null sound device or no sound device has been configured via the
4039 * #pjsua_set_no_snd_dev() function.
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004040 */
Benny Prijonof798e502009-03-09 13:08:16 +00004041PJ_DECL(pj_bool_t) pjsua_snd_is_active(void);
4042
4043
4044/**
4045 * Configure sound device setting to the sound device being used. If sound
4046 * device is currently active, the function will forward the setting to the
4047 * sound device instance to be applied immediately, if it supports it.
4048 *
4049 * The setting will be saved for future opening of the sound device, if the
4050 * "keep" argument is set to non-zero. If the sound device is currently
4051 * inactive, and the "keep" argument is false, this function will return
4052 * error.
4053 *
4054 * Note that in case the setting is kept for future use, it will be applied
4055 * to any devices, even when application has changed the sound device to be
4056 * used.
4057 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004058 * Note also that the echo cancellation setting should be set with
4059 * #pjsua_set_ec() API instead.
4060 *
Benny Prijonof798e502009-03-09 13:08:16 +00004061 * See also #pjmedia_aud_stream_set_cap() for more information about setting
4062 * an audio device capability.
4063 *
4064 * @param cap The sound device setting to change.
4065 * @param pval Pointer to value. Please see #pjmedia_aud_dev_cap
4066 * documentation about the type of value to be
4067 * supplied for each setting.
4068 * @param keep Specify whether the setting is to be kept for future
4069 * use.
4070 *
4071 * @return PJ_SUCCESS on success or the appropriate error code.
4072 */
4073PJ_DECL(pj_status_t) pjsua_snd_set_setting(pjmedia_aud_dev_cap cap,
4074 const void *pval,
4075 pj_bool_t keep);
4076
4077/**
4078 * Retrieve a sound device setting. If sound device is currently active,
4079 * the function will forward the request to the sound device. If sound device
4080 * is currently inactive, and if application had previously set the setting
4081 * and mark the setting as kept, then that setting will be returned.
4082 * Otherwise, this function will return error.
4083 *
Benny Prijonoe506c8c2009-03-10 13:28:43 +00004084 * Note that echo cancellation settings should be retrieved with
4085 * #pjsua_get_ec_tail() API instead.
4086 *
Benny Prijonof798e502009-03-09 13:08:16 +00004087 * @param cap The sound device setting to retrieve.
4088 * @param pval Pointer to receive the value.
4089 * Please see #pjmedia_aud_dev_cap documentation about
4090 * the type of value to be supplied for each setting.
4091 *
4092 * @return PJ_SUCCESS on success or the appropriate error code.
4093 */
4094PJ_DECL(pj_status_t) pjsua_snd_get_setting(pjmedia_aud_dev_cap cap,
4095 void *pval);
Nanang Izzuddin0cb3b022009-02-27 17:37:35 +00004096
4097
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004098/*****************************************************************************
4099 * Codecs.
4100 */
4101
4102/**
4103 * Enum all supported codecs in the system.
4104 *
4105 * @param id Array of ID to be initialized.
4106 * @param count On input, specifies max elements in the array.
4107 * On return, it contains actual number of elements
4108 * that have been initialized.
4109 *
4110 * @return PJ_SUCCESS on success, or the appropriate error code.
4111 */
4112PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
4113 unsigned *count );
4114
4115
4116/**
4117 * Change codec priority.
4118 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004119 * @param codec_id Codec ID, which is a string that uniquely identify
4120 * the codec (such as "speex/8000"). Please see pjsua
4121 * manual or pjmedia codec reference for details.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004122 * @param priority Codec priority, 0-255, where zero means to disable
4123 * the codec.
4124 *
4125 * @return PJ_SUCCESS on success, or the appropriate error code.
4126 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004127PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004128 pj_uint8_t priority );
4129
4130
4131/**
4132 * Get codec parameters.
4133 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004134 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004135 * @param param Structure to receive codec parameters.
4136 *
4137 * @return PJ_SUCCESS on success, or the appropriate error code.
4138 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004139PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004140 pjmedia_codec_param *param );
4141
4142
4143/**
4144 * Set codec parameters.
4145 *
Benny Prijonoe6ead542007-01-31 20:53:31 +00004146 * @param codec_id Codec ID.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004147 * @param param Codec parameter to set.
4148 *
4149 * @return PJ_SUCCESS on success, or the appropriate error code.
4150 */
Benny Prijonoe6ead542007-01-31 20:53:31 +00004151PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004152 const pjmedia_codec_param *param);
4153
4154
4155
Benny Prijono9fc735d2006-05-28 14:58:12 +00004156
Benny Prijono312aff92006-06-17 04:08:30 +00004157/**
4158 * Create UDP media transports for all the calls. This function creates
4159 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00004160 *
Benny Prijono312aff92006-06-17 04:08:30 +00004161 * @param cfg Media transport configuration. The "port" field in the
4162 * configuration is used as the start port to bind the
4163 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004164 *
4165 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonof3195072006-02-14 21:15:30 +00004166 */
Benny Prijono312aff92006-06-17 04:08:30 +00004167PJ_DECL(pj_status_t)
4168pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00004169
Benny Prijonodc39fe82006-05-26 12:17:46 +00004170
4171/**
Benny Prijono312aff92006-06-17 04:08:30 +00004172 * Register custom media transports to be used by calls. There must
4173 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00004174 *
Benny Prijono312aff92006-06-17 04:08:30 +00004175 * @param tp The media transport array.
4176 * @param count Number of elements in the array. This number MUST
4177 * match the number of maximum calls configured when
4178 * pjsua is created.
4179 * @param auto_delete Flag to indicate whether the transports should be
4180 * destroyed when pjsua is shutdown.
4181 *
4182 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00004183 */
Benny Prijono312aff92006-06-17 04:08:30 +00004184PJ_DECL(pj_status_t)
4185pjsua_media_transports_attach( pjsua_media_transport tp[],
4186 unsigned count,
4187 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00004188
4189
Benny Prijono312aff92006-06-17 04:08:30 +00004190/**
4191 * @}
4192 */
4193
Benny Prijonof3195072006-02-14 21:15:30 +00004194
Benny Prijono268ca612006-02-07 12:34:11 +00004195
Benny Prijono312aff92006-06-17 04:08:30 +00004196/**
4197 * @}
4198 */
4199
Benny Prijonoe6ead542007-01-31 20:53:31 +00004200PJ_END_DECL
4201
Benny Prijono312aff92006-06-17 04:08:30 +00004202
Benny Prijono268ca612006-02-07 12:34:11 +00004203#endif /* __PJSUA_H__ */