blob: d2ca7a34e93022566a8cd0ef16071d74e0036579 [file] [log] [blame]
Benny Prijono268ca612006-02-07 12:34:11 +00001/* $Id$ */
2/*
3 * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJSUA_H__
20#define __PJSUA_H__
21
Benny Prijono312aff92006-06-17 04:08:30 +000022/**
23 * @file pjsua.h
24 * @brief PJSUA API.
25 */
26
27
Benny Prijono268ca612006-02-07 12:34:11 +000028/* Include all PJSIP core headers. */
29#include <pjsip.h>
30
31/* Include all PJMEDIA headers. */
32#include <pjmedia.h>
33
Benny Prijono1f9afba2006-02-10 15:57:32 +000034/* Include all PJMEDIA-CODEC headers. */
35#include <pjmedia-codec.h>
36
Benny Prijono268ca612006-02-07 12:34:11 +000037/* Include all PJSIP-UA headers */
38#include <pjsip_ua.h>
39
Benny Prijono834aee32006-02-19 01:38:06 +000040/* Include all PJSIP-SIMPLE headers */
41#include <pjsip_simple.h>
42
Benny Prijono268ca612006-02-07 12:34:11 +000043/* Include all PJLIB-UTIL headers. */
44#include <pjlib-util.h>
45
46/* Include all PJLIB headers. */
47#include <pjlib.h>
48
49
Benny Prijono312aff92006-06-17 04:08:30 +000050/**
51 * @defgroup PJSUA_LIB PJSUA API
52 * @ingroup PJSIP
53 * @brief Very high level API for constructing SIP UA applications.
54 * @{
55 *
56 * PJSUA API is very high level API for constructing SIP user agent
57 * applications. It wraps together the signaling and media functionalities
58 * into an easy to use call API, provides account management, buddy
59 * management, presence, instant messaging, along with multimedia
60 * features such as conferencing, file streaming, local playback,
61 * voice recording, and so on.
62 *
63 * Application must link with <b>pjsua-lib</b> to use this API. In addition,
64 * this library depends on the following libraries:
65 * - <b>pjsip-ua</b>,
66 * - <b>pjsip-simple</b>,
67 * - <b>pjsip-core</b>,
68 * - <b>pjmedia</b>,
69 * - <b>pjmedia-codec</b>,
70 * - <b>pjlib-util</b>, and
71 * - <b>pjlib</b>,
72 *
73 * so application must also link with these libraries as well.
74 *
75 * @section root_using_pjsua_lib Using PJSUA API
76 *
77 * Please refer to @ref using_pjsua_lib on how to use PJSUA API.
78 */
79
Benny Prijono1a01ad32006-02-07 21:13:28 +000080PJ_BEGIN_DECL
81
Benny Prijono632ce712006-02-09 14:01:40 +000082
Benny Prijono312aff92006-06-17 04:08:30 +000083/** Forward declaration */
84typedef struct pjsua_media_config pjsua_media_config;
Benny Prijonoa91a0032006-02-26 21:23:45 +000085
Benny Prijonof3195072006-02-14 21:15:30 +000086
Benny Prijono312aff92006-06-17 04:08:30 +000087/*****************************************************************************
88 * BASE API
89 */
90
Benny Prijonof04ffdd2006-02-21 00:11:18 +000091/**
Benny Prijono312aff92006-06-17 04:08:30 +000092 * @defgroup PJSUA_LIB_BASE Base API
93 * @ingroup PJSUA_LIB
94 * @brief Basic application creation/initialization, logging configuration, etc.
95 * @{
96 *
97 * The base PJSUA API controls PJSUA creation, initialization, and startup, and
98 * also provides various auxiliary functions.
99 *
100 * @section using_pjsua_lib Using PJSUA Library
101 *
102 * @subsection creating_pjsua_lib Creating PJSUA
103 *
104 * Before anything else, application must create PJSUA by calling #pjsua_create().
105 * This, among other things, will initialize PJLIB, which is crucial before
106 * any PJLIB functions can be called.
107 *
108 * @subsection init_pjsua_lib Initializing PJSUA
109 *
110 * After PJSUA is created, application can initialize PJSUA by calling
111 * #pjsua_init(). This function takes several configuration settings in the
112 * argument, so application normally would want to set these configuration
113 * before passing them to #pjsua_init().
114 *
115 * Sample code to initialize PJSUA:
116 \code
117
118 pjsua_config ua_cfg;
119 pjsua_logging_config log_cfg;
120 pjsua_media_config media_cfg;
121
122 // Initialize configs with default settings.
123 pjsua_config_default(&ua_cfg);
124 pjsua_logging_config_default(&log_cfg);
125 pjsua_media_config_default(&media_cfg);
126
127 // At the very least, application would want to override
128 // the call callbacks in pjsua_config:
129 ua_cfg.cb.on_incoming_call = ...
130 ua_cfg.cb.on_call_state = ..
131 ...
132
133 // Customize other settings (or initialize them from application specific
134 // configuration file):
135 ...
136
137 // Initialize pjsua
138 status = pjsua_init(&ua_cfg, &log_cfg, &media_cfg);
139 if (status != PJ_SUCCESS) {
140 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
141 return status;
142 }
143 ..
144
145 \endcode
146 *
147 * @subsection other_init_pjsua_lib Other Initialization
148 *
149 * After PJSUA is initialized with #pjsua_init(), application will normally
150 * need/want to perform the following tasks:
151 *
152 * - create SIP transport with #pjsua_transport_create(). Please see
153 * @ref PJSUA_LIB_TRANSPORT section for more info.
154 * - create one or more SIP accounts with #pjsua_acc_add() or
155 * #pjsua_acc_add_local(). Please see @ref PJSUA_LIB_ACC for more info.
156 * - add one or more buddies with #pjsua_buddy_add(). Please see
157 * @ref PJSUA_LIB_BUDDY section for more info.
158 * - optionally configure the sound device, codec settings, and other
159 * media settings. Please see @ref PJSUA_LIB_MEDIA for more info.
160 *
161 *
162 * @subsection starting_pjsua_lib Starting PJSUA
163 *
164 * After all initializations have been done, application must call
165 * #pjsua_start() to start PJSUA. This function will check that all settings
166 * are properly configured, and apply default settings when it's not, or
167 * report error status when it is unable to recover from missing setting.
168 *
169 * Most settings can be changed during run-time. For example, application
170 * may add, modify, or delete accounts, buddies, or change media settings
171 * during run-time.
Benny Prijonof04ffdd2006-02-21 00:11:18 +0000172 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000173
Benny Prijono312aff92006-06-17 04:08:30 +0000174/** Constant to identify invalid ID for all sorts of IDs. */
175#define PJSUA_INVALID_ID (-1)
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000176
177/** Call identification */
178typedef int pjsua_call_id;
179
Benny Prijono312aff92006-06-17 04:08:30 +0000180/** Account identification */
181typedef int pjsua_acc_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000182
183/** Buddy identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000184typedef int pjsua_buddy_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000185
186/** File player identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000187typedef int pjsua_player_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000188
189/** File recorder identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000190typedef int pjsua_recorder_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000191
192/** Conference port identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000193typedef int pjsua_conf_port_id;
194
195
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000196
Benny Prijonoa91a0032006-02-26 21:23:45 +0000197/**
Benny Prijono312aff92006-06-17 04:08:30 +0000198 * Maximum proxies in account.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000199 */
Benny Prijono312aff92006-06-17 04:08:30 +0000200#ifndef PJSUA_ACC_MAX_PROXIES
201# define PJSUA_ACC_MAX_PROXIES 8
202#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000203
204
205
206/**
207 * Logging configuration.
208 */
209typedef struct pjsua_logging_config
210{
211 /**
212 * Log incoming and outgoing SIP message? Yes!
213 */
214 pj_bool_t msg_logging;
215
216 /**
217 * Input verbosity level. Value 5 is reasonable.
218 */
219 unsigned level;
220
221 /**
222 * Verbosity level for console. Value 4 is reasonable.
223 */
224 unsigned console_level;
225
226 /**
227 * Log decoration.
228 */
229 unsigned decor;
230
231 /**
232 * Optional log filename.
233 */
234 pj_str_t log_filename;
235
236 /**
237 * Optional callback function to be called to write log to
238 * application specific device. This function will be called for
239 * log messages on input verbosity level.
240 */
241 void (*cb)(int level, const char *data, pj_size_t len);
242
243
244} pjsua_logging_config;
245
246
247/**
248 * Use this function to initialize logging config.
249 *
250 * @param cfg The logging config to be initialized.
251 */
252PJ_INLINE(void) pjsua_logging_config_default(pjsua_logging_config *cfg)
253{
Benny Prijonoac623b32006-07-03 15:19:31 +0000254 pj_bzero(cfg, sizeof(*cfg));
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000255
256 cfg->msg_logging = PJ_TRUE;
257 cfg->level = 5;
258 cfg->console_level = 4;
259 cfg->decor = PJ_LOG_HAS_SENDER | PJ_LOG_HAS_TIME |
260 PJ_LOG_HAS_MICRO_SEC | PJ_LOG_HAS_NEWLINE;
261}
262
263/**
264 * Use this function to duplicate logging config.
265 *
266 * @param pool Pool to use.
267 * @param dst Destination config.
268 * @param src Source config.
269 */
270PJ_INLINE(void) pjsua_logging_config_dup(pj_pool_t *pool,
271 pjsua_logging_config *dst,
272 const pjsua_logging_config *src)
273{
274 pj_memcpy(dst, src, sizeof(*src));
275 pj_strdup_with_null(pool, &dst->log_filename, &src->log_filename);
276}
277
278
Benny Prijonodc39fe82006-05-26 12:17:46 +0000279
280/**
281 * Application callbacks.
282 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000283typedef struct pjsua_callback
Benny Prijonodc39fe82006-05-26 12:17:46 +0000284{
285 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000286 * Notify application when invite state has changed.
287 * Application may then query the call info to get the
288 * detail call states.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000289 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000290 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000291
292 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000293 * Notify application on incoming call.
294 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000295 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000296 pjsip_rx_data *rdata);
297
298 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000299 * Notify application when media state in the call has changed.
300 * Normal application would need to implement this callback, e.g.
301 * to connect the call's media to sound device.
302 */
303 void (*on_call_media_state)(pjsua_call_id call_id);
304
305 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000306 * Notify application on call being transfered.
307 * Application can decide to accept/reject transfer request
308 * by setting the code (default is 200). When this callback
309 * is not defined, the default behavior is to accept the
310 * transfer.
311 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000312 void (*on_call_transfered)(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +0000313 const pj_str_t *dst,
314 pjsip_status_code *code);
315
316 /**
317 * Notify application when registration status has changed.
318 * Application may then query the account info to get the
319 * registration details.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000320 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000321 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000322
323 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000324 * Notify application when the buddy state has changed.
325 * Application may then query the buddy into to get the details.
326 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000327 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000328
329 /**
330 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000331 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000332 * existing call.
333 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000334 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
335 const pj_str_t *to, const pj_str_t *contact,
336 const pj_str_t *mime_type, const pj_str_t *body);
337
338 /**
339 * Notify application about the delivery status of outgoing pager
340 * request.
341 *
342 * @param call_id Containts the ID of the call where the IM was
343 * sent, or PJSUA_INVALID_ID if the IM was sent
344 * outside call context.
345 * @param to Destination URI.
346 * @param body Message body.
347 * @param user_data Arbitrary data that was specified when sending
348 * IM message.
349 * @param status Delivery status.
350 * @param reason Delivery status reason.
351 */
352 void (*on_pager_status)(pjsua_call_id call_id,
353 const pj_str_t *to,
354 const pj_str_t *body,
355 void *user_data,
356 pjsip_status_code status,
357 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000358
359 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000360 * Notify application about typing indication.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000361 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000362 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
363 const pj_str_t *to, const pj_str_t *contact,
364 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000365
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000366} pjsua_callback;
367
368
369
Benny Prijonodc39fe82006-05-26 12:17:46 +0000370
371/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000372 * PJSUA settings.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000373 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000374typedef struct pjsua_config
375{
376
377 /**
378 * Maximum calls to support (default: 4)
379 */
380 unsigned max_calls;
381
382 /**
383 * Number of worker threads. Normally application will want to have at
384 * least one worker thread, unless when it wants to poll the library
385 * periodically, which in this case the worker thread can be set to
386 * zero.
387 */
388 unsigned thread_cnt;
389
390 /**
391 * Number of outbound proxies in the array.
392 */
393 unsigned outbound_proxy_cnt;
394
395 /**
396 * Specify the URL of outbound proxies to visit for all outgoing requests.
397 * The outbound proxies will be used for all accounts, and it will
398 * be used to build the route set for outgoing requests. The final
399 * route set for outgoing requests will consists of the outbound proxies
400 * and the proxy configured in the account.
401 */
402 pj_str_t outbound_proxy[4];
403
404 /**
405 * Number of credentials in the credential array.
406 */
407 unsigned cred_count;
408
409 /**
410 * Array of credentials. These credentials will be used by all accounts,
411 * and can be used to authenticate against outbound proxies.
412 */
413 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
414
415 /**
416 * Application callback.
417 */
418 pjsua_callback cb;
419
Benny Prijono56315612006-07-18 14:39:40 +0000420 /**
421 * User agent string (default empty)
422 */
423 pj_str_t user_agent;
424
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000425} pjsua_config;
426
427
428/**
429 * Use this function to initialize pjsua config.
430 *
431 * @param cfg pjsua config to be initialized.
432 */
433PJ_INLINE(void) pjsua_config_default(pjsua_config *cfg)
434{
Benny Prijonoac623b32006-07-03 15:19:31 +0000435 pj_bzero(cfg, sizeof(*cfg));
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000436
437 cfg->max_calls = 4;
438 cfg->thread_cnt = 1;
439}
440
441
442/**
443 * Duplicate credential.
444 */
445PJ_INLINE(void) pjsip_cred_dup( pj_pool_t *pool,
446 pjsip_cred_info *dst,
447 const pjsip_cred_info *src)
448{
449 pj_strdup_with_null(pool, &dst->realm, &src->realm);
450 pj_strdup_with_null(pool, &dst->scheme, &src->scheme);
451 pj_strdup_with_null(pool, &dst->username, &src->username);
452 pj_strdup_with_null(pool, &dst->data, &src->data);
453
454}
455
456
457/**
458 * Duplicate pjsua_config.
459 */
460PJ_INLINE(void) pjsua_config_dup(pj_pool_t *pool,
461 pjsua_config *dst,
462 const pjsua_config *src)
463{
464 unsigned i;
465
466 pj_memcpy(dst, src, sizeof(*src));
467
468 for (i=0; i<src->outbound_proxy_cnt; ++i) {
469 pj_strdup_with_null(pool, &dst->outbound_proxy[i],
470 &src->outbound_proxy[i]);
471 }
472
473 for (i=0; i<src->cred_count; ++i) {
474 pjsip_cred_dup(pool, &dst->cred_info[i], &src->cred_info[i]);
475 }
Benny Prijono56315612006-07-18 14:39:40 +0000476
477 pj_strdup_with_null(pool, &dst->user_agent, &src->user_agent);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000478}
479
480
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000481
482/**
483 * This structure describes additional information to be sent with
484 * outgoing SIP message.
485 */
486typedef struct pjsua_msg_data
487{
488 /**
489 * Additional message headers as linked list.
490 */
491 pjsip_hdr hdr_list;
492
493 /**
494 * MIME type of optional message body.
495 */
496 pj_str_t content_type;
497
498 /**
499 * Optional message body.
500 */
501 pj_str_t msg_body;
502
503} pjsua_msg_data;
504
505
506/**
507 * Initialize message data.
508 *
509 * @param msg_data Message data to be initialized.
510 */
511PJ_INLINE(void) pjsua_msg_data_init(pjsua_msg_data *msg_data)
512{
Benny Prijonoac623b32006-07-03 15:19:31 +0000513 pj_bzero(msg_data, sizeof(*msg_data));
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000514 pj_list_init(&msg_data->hdr_list);
515}
Benny Prijono8b1889b2006-06-06 18:40:40 +0000516
Benny Prijono268ca612006-02-07 12:34:11 +0000517
Benny Prijono268ca612006-02-07 12:34:11 +0000518
519/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000520 * Instantiate pjsua application. Application must call this function before
521 * calling any other functions, to make sure that the underlying libraries
522 * are properly initialized. Once this function has returned success,
523 * application must call pjsua_destroy() before quitting.
524 *
525 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000526 */
527PJ_DECL(pj_status_t) pjsua_create(void);
528
529
530/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000531 * Initialize pjsua with the specified settings. All the settings are
532 * optional, and the default values will be used when the config is not
533 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +0000534 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000535 * @param ua_cfg User agent configuration.
536 * @param log_cfg Optional logging configuration.
537 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +0000538 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000539 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +0000540 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000541PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
542 const pjsua_logging_config *log_cfg,
543 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +0000544
545
546/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000547 * Application is recommended to call this function after all initialization
548 * is done, so that the library can do additional checking set up
549 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +0000550 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000551 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoccf95622006-02-07 18:48:01 +0000552 */
Benny Prijonodc39fe82006-05-26 12:17:46 +0000553PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +0000554
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000555
Benny Prijonoccf95622006-02-07 18:48:01 +0000556/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000557 * Destroy pjsua. This function must be called once PJSUA is created. To
558 * make it easier for application, application may call this function
559 * several times with no danger.
560 *
561 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +0000562 */
Benny Prijonodc39fe82006-05-26 12:17:46 +0000563PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +0000564
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000565
Benny Prijono9fc735d2006-05-28 14:58:12 +0000566/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000567 * Poll pjsua for events, and if necessary block the caller thread for
568 * the specified maximum interval (in miliseconds).
569 *
570 * @param msec_timeout Maximum time to wait, in miliseconds.
571 *
572 * @return The number of events that have been handled during the
573 * poll. Negative value indicates error, and application
574 * can retrieve the error as (err = -return_value).
Benny Prijonob9b32ab2006-06-01 12:28:44 +0000575 */
576PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
577
578
579/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000580 * Create memory pool.
581 *
582 * @param name Optional pool name.
Benny Prijono312aff92006-06-17 04:08:30 +0000583 * @param init_size Initial size of the pool.
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000584 * @param increment Increment size.
585 *
586 * @return The pool, or NULL when there's no memory.
587 */
588PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
589 pj_size_t increment);
590
591
592/**
593 * Application can call this function at any time (after pjsua_create(), of
594 * course) to change logging settings.
595 *
596 * @param c Logging configuration.
597 *
598 * @return PJ_SUCCESS on success, or the appropriate error code.
599 */
600PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
601
602
603/**
604 * Internal function to get SIP endpoint instance of pjsua, which is
605 * needed for example to register module, create transports, etc.
606 * Probably is only valid after #pjsua_init() is called.
607 *
608 * @return SIP endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +0000609 */
610PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
611
612/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000613 * Internal function to get media endpoint instance.
614 * Only valid after #pjsua_init() is called.
615 *
616 * @return Media endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +0000617 */
618PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
619
Benny Prijono97b87172006-08-24 14:25:14 +0000620/**
621 * Internal function to get PJSUA pool factory.
622 * Only valid after #pjsua_init() is called.
623 *
624 * @return Pool factory currently used by PJSUA.
625 */
626PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
627
628
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000629
630/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +0000631 * Utilities.
632 *
Benny Prijono9fc735d2006-05-28 14:58:12 +0000633 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000634
635/**
Benny Prijono312aff92006-06-17 04:08:30 +0000636 * Verify that valid SIP url is given.
637 *
638 * @param c_url The URL, as NULL terminated string.
639 *
640 * @return PJ_SUCCESS on success, or the appropriate error code.
641 */
642PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *c_url);
643
644
645/**
646 * Display error message for the specified error code.
647 *
648 * @param sender The log sender field.
649 * @param title Message title for the error.
650 * @param status Status code.
651 */
652PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
653 pj_status_t status);
654
655
656
657
658/**
659 * @}
660 */
661
662
663
664/*****************************************************************************
665 * TRANSPORT API
666 */
667
668/**
669 * @defgroup PJSUA_LIB_TRANSPORT Signaling Transport
670 * @ingroup PJSUA_LIB
671 * @brief API for managing SIP transports
672 * @{
673 * SIP transport must be created before adding an account. SIP transport is
674 * created by calling #pjsua_transport_create() function.
675 */
676
677
678/** SIP transport identification */
679typedef int pjsua_transport_id;
680
681
682/**
683 * STUN configuration.
684 */
685typedef struct pjsua_stun_config
686{
687 /**
688 * The first STUN server IP address or hostname.
689 */
690 pj_str_t stun_srv1;
691
692 /**
693 * Port number of the first STUN server.
694 * If zero, default STUN port will be used.
695 */
696 unsigned stun_port1;
697
698 /**
699 * Optional second STUN server IP address or hostname, for which the
700 * result of the mapping request will be compared to. If the value
701 * is empty, only one STUN server will be used.
702 */
703 pj_str_t stun_srv2;
704
705 /**
706 * Port number of the second STUN server.
707 * If zero, default STUN port will be used.
708 */
709 unsigned stun_port2;
710
711} pjsua_stun_config;
712
713
714
715/**
716 * Call this function to initialize STUN config with default values.
717 *
718 * @param cfg The STUN config to be initialized.
719 */
720PJ_INLINE(void) pjsua_stun_config_default(pjsua_stun_config *cfg)
721{
Benny Prijonoac623b32006-07-03 15:19:31 +0000722 pj_bzero(cfg, sizeof(*cfg));
Benny Prijono312aff92006-06-17 04:08:30 +0000723}
724
725
726/**
727 * Transport configuration for creating UDP transports for both SIP
728 * and media.
729 */
730typedef struct pjsua_transport_config
731{
732 /**
733 * UDP port number to bind locally. This setting MUST be specified
734 * even when default port is desired. If the value is zero, the
735 * transport will be bound to any available port, and application
736 * can query the port by querying the transport info.
737 */
738 unsigned port;
739
740 /**
741 * Optional address where the socket should be bound.
742 */
743 pj_in_addr ip_addr;
744
745 /**
746 * Flag to indicate whether STUN should be used.
747 */
748 pj_bool_t use_stun;
749
750 /**
751 * STUN configuration, must be specified when STUN is used.
752 */
753 pjsua_stun_config stun_config;
754
755} pjsua_transport_config;
756
757
758/**
759 * Call this function to initialize UDP config with default values.
760 *
761 * @param cfg The UDP config to be initialized.
762 */
763PJ_INLINE(void) pjsua_transport_config_default(pjsua_transport_config *cfg)
764{
Benny Prijonoac623b32006-07-03 15:19:31 +0000765 pj_bzero(cfg, sizeof(*cfg));
Benny Prijono312aff92006-06-17 04:08:30 +0000766}
767
768
769/**
770 * Normalize STUN config.
771 */
772PJ_INLINE(void) pjsua_normalize_stun_config( pjsua_stun_config *cfg )
773{
774 if (cfg->stun_srv1.slen) {
775
776 if (cfg->stun_port1 == 0)
777 cfg->stun_port1 = 3478;
778
779 if (cfg->stun_srv2.slen == 0) {
780 cfg->stun_srv2 = cfg->stun_srv1;
781 cfg->stun_port2 = cfg->stun_port1;
782 } else {
783 if (cfg->stun_port2 == 0)
784 cfg->stun_port2 = 3478;
785 }
786
787 } else {
788 cfg->stun_port1 = 0;
789 cfg->stun_srv2.slen = 0;
790 cfg->stun_port2 = 0;
791 }
792}
793
794
795/**
796 * Duplicate transport config.
797 */
798PJ_INLINE(void) pjsua_transport_config_dup(pj_pool_t *pool,
799 pjsua_transport_config *dst,
800 const pjsua_transport_config *src)
801{
802 pj_memcpy(dst, src, sizeof(*src));
803
804 if (src->stun_config.stun_srv1.slen) {
805 pj_strdup_with_null(pool, &dst->stun_config.stun_srv1,
806 &src->stun_config.stun_srv1);
807 }
808
809 if (src->stun_config.stun_srv2.slen) {
810 pj_strdup_with_null(pool, &dst->stun_config.stun_srv2,
811 &src->stun_config.stun_srv2);
812 }
813
814 pjsua_normalize_stun_config(&dst->stun_config);
815}
816
817
818
819/**
820 * Transport info.
821 */
822typedef struct pjsua_transport_info
823{
824 /**
825 * PJSUA transport identification.
826 */
827 pjsua_transport_id id;
828
829 /**
830 * Transport type.
831 */
832 pjsip_transport_type_e type;
833
834 /**
835 * Transport type name.
836 */
837 pj_str_t type_name;
838
839 /**
840 * Transport string info/description.
841 */
842 pj_str_t info;
843
844 /**
845 * Transport flag (see ##pjsip_transport_flags_e).
846 */
847 unsigned flag;
848
849 /**
850 * Local address length.
851 */
852 unsigned addr_len;
853
854 /**
855 * Local/bound address.
856 */
857 pj_sockaddr local_addr;
858
859 /**
860 * Published address (or transport address name).
861 */
862 pjsip_host_port local_name;
863
864 /**
865 * Current number of objects currently referencing this transport.
866 */
867 unsigned usage_count;
868
869
870} pjsua_transport_info;
871
872
873/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000874 * Create SIP transport.
875 *
876 * @param type Transport type.
877 * @param cfg Transport configuration.
878 * @param p_id Optional pointer to receive transport ID.
879 *
880 * @return PJ_SUCCESS on success, or the appropriate error code.
881 */
882PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
883 const pjsua_transport_config *cfg,
884 pjsua_transport_id *p_id);
885
886/**
887 * Register transport that has been created by application.
888 *
889 * @param tp Transport instance.
890 * @param p_id Optional pointer to receive transport ID.
891 *
892 * @return PJ_SUCCESS on success, or the appropriate error code.
893 */
894PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
895 pjsua_transport_id *p_id);
896
897
898/**
899 * Enumerate all transports currently created in the system.
900 *
901 * @param id Array to receive transport ids.
902 * @param count In input, specifies the maximum number of elements.
903 * On return, it contains the actual number of elements.
904 *
905 * @return PJ_SUCCESS on success, or the appropriate error code.
906 */
907PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
908 unsigned *count );
909
910
911/**
912 * Get information about transports.
913 *
914 * @param id Transport ID.
915 * @param info Pointer to receive transport info.
916 *
917 * @return PJ_SUCCESS on success, or the appropriate error code.
918 */
919PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
920 pjsua_transport_info *info);
921
922
923/**
924 * Disable a transport or re-enable it. By default transport is always
925 * enabled after it is created. Disabling a transport does not necessarily
926 * close the socket, it will only discard incoming messages and prevent
927 * the transport from being used to send outgoing messages.
928 *
929 * @param id Transport ID.
930 * @param enabled Non-zero to enable, zero to disable.
931 *
932 * @return PJ_SUCCESS on success, or the appropriate error code.
933 */
934PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
935 pj_bool_t enabled);
936
937
938/**
939 * Close the transport. If transport is forcefully closed, it will be
940 * immediately closed, and any pending transactions that are using the
941 * transport may not terminate properly. Otherwise, the system will wait
942 * until all transactions are closed while preventing new users from
943 * using the transport, and will close the transport when it is safe to
944 * do so.
945 *
946 * @param id Transport ID.
947 * @param force Non-zero to immediately close the transport. This
948 * is not recommended!
949 *
950 * @return PJ_SUCCESS on success, or the appropriate error code.
951 */
952PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
953 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +0000954
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000955/**
Benny Prijono312aff92006-06-17 04:08:30 +0000956 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000957 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000958
959
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000960
961
962/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +0000963 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +0000964 */
965
Benny Prijono312aff92006-06-17 04:08:30 +0000966
967/**
968 * @defgroup PJSUA_LIB_ACC Account Management
969 * @ingroup PJSUA_LIB
970 * @brief PJSUA supports multiple accounts..
971 * @{
972 * PJSUA accounts provide identity (or identities) of the user who is currently
973 * using the application. More than one account maybe created with PJSUA.
974 *
975 * Account may or may not have client registration associated with it.
976 * An account is also associated with <b>route set</b> and some <b>authentication
977 * credentials</b>, which are used when sending SIP request messages using the
978 * account. An account also has presence's <b>online status</b>, which
979 * will be reported to remote peer when the subscribe to the account's
980 * presence.
981 *
982 * At least one account MUST be created in the application. If no user
983 * association is required, application can create a userless account by
984 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
985 * instead of a particular user.
986 *
987 * Also one account must be set as the <b>default account</b>, which is used as
988 * the account to use when PJSUA fails to match a request with any other
989 * accounts.
990 *
991 * When sending outgoing SIP requests (such as making calls or sending
992 * instant messages), normally PJSUA requires the application to specify
993 * which account to use for the request. If no account is specified,
994 * PJSUA may be able to select the account by matching the destination
995 * domain name, and fall back to default account when no match is found.
996 */
997
998/**
999 * Maximum accounts.
1000 */
1001#ifndef PJSUA_MAX_ACC
1002# define PJSUA_MAX_ACC 8
1003#endif
1004
1005
1006/**
1007 * Default registration interval.
1008 */
1009#ifndef PJSUA_REG_INTERVAL
1010# define PJSUA_REG_INTERVAL 55
1011#endif
1012
1013
1014/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001015 * Default PUBLISH expiration
1016 */
1017#ifndef PJSUA_PUBLISH_EXPIRATION
1018# define PJSUA_PUBLISH_EXPIRATION 600
1019#endif
1020
1021
1022/**
Benny Prijono312aff92006-06-17 04:08:30 +00001023 * Account configuration.
1024 */
1025typedef struct pjsua_acc_config
1026{
1027 /**
1028 * The full SIP URL for the account. The value can take name address or
1029 * URL format, and will look something like "sip:account@serviceprovider".
1030 *
1031 * This field is mandatory.
1032 */
1033 pj_str_t id;
1034
1035 /**
1036 * This is the URL to be put in the request URI for the registration,
1037 * and will look something like "sip:serviceprovider".
1038 *
1039 * This field should be specified if registration is desired. If the
1040 * value is empty, no account registration will be performed.
1041 */
1042 pj_str_t reg_uri;
1043
Benny Prijono3a5e1ab2006-08-15 20:26:34 +00001044 /**
1045 * Publish presence?
1046 */
1047 pj_bool_t publish_enabled;
1048
Benny Prijono312aff92006-06-17 04:08:30 +00001049 /**
1050 * Optional URI to be put as Contact for this account. It is recommended
1051 * that this field is left empty, so that the value will be calculated
1052 * automatically based on the transport address.
1053 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00001054 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00001055
1056 /**
1057 * Number of proxies in the proxy array below.
1058 */
1059 unsigned proxy_cnt;
1060
1061 /**
1062 * Optional URI of the proxies to be visited for all outgoing requests
1063 * that are using this account (REGISTER, INVITE, etc). Application need
1064 * to specify these proxies if the service provider requires that requests
1065 * destined towards its network should go through certain proxies first
1066 * (for example, border controllers).
1067 *
1068 * These proxies will be put in the route set for this account, with
1069 * maintaining the orders (the first proxy in the array will be visited
1070 * first).
1071 */
1072 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
1073
1074 /**
1075 * Optional interval for registration, in seconds. If the value is zero,
1076 * default interval will be used (PJSUA_REG_INTERVAL, 55 seconds).
1077 */
1078 unsigned reg_timeout;
1079
1080 /**
1081 * Number of credentials in the credential array.
1082 */
1083 unsigned cred_count;
1084
1085 /**
1086 * Array of credentials. If registration is desired, normally there should
1087 * be at least one credential specified, to successfully authenticate
1088 * against the service provider. More credentials can be specified, for
1089 * example when the requests are expected to be challenged by the
1090 * proxies in the route set.
1091 */
1092 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1093
1094} pjsua_acc_config;
1095
1096
1097/**
1098 * Call this function to initialize account config with default values.
1099 *
1100 * @param cfg The account config to be initialized.
1101 */
1102PJ_INLINE(void) pjsua_acc_config_default(pjsua_acc_config *cfg)
1103{
Benny Prijonoac623b32006-07-03 15:19:31 +00001104 pj_bzero(cfg, sizeof(*cfg));
Benny Prijono312aff92006-06-17 04:08:30 +00001105
1106 cfg->reg_timeout = PJSUA_REG_INTERVAL;
1107}
1108
1109
1110
1111/**
1112 * Account info. Application can query account info by calling
1113 * #pjsua_acc_get_info().
1114 */
1115typedef struct pjsua_acc_info
1116{
1117 /**
1118 * The account ID.
1119 */
1120 pjsua_acc_id id;
1121
1122 /**
1123 * Flag to indicate whether this is the default account.
1124 */
1125 pj_bool_t is_default;
1126
1127 /**
1128 * Account URI
1129 */
1130 pj_str_t acc_uri;
1131
1132 /**
1133 * Flag to tell whether this account has registration setting
1134 * (reg_uri is not empty).
1135 */
1136 pj_bool_t has_registration;
1137
1138 /**
1139 * An up to date expiration interval for account registration session.
1140 */
1141 int expires;
1142
1143 /**
1144 * Last registration status code. If status code is zero, the account
1145 * is currently not registered. Any other value indicates the SIP
1146 * status code of the registration.
1147 */
1148 pjsip_status_code status;
1149
1150 /**
1151 * String describing the registration status.
1152 */
1153 pj_str_t status_text;
1154
1155 /**
1156 * Presence online status for this account.
1157 */
1158 pj_bool_t online_status;
1159
1160 /**
1161 * Buffer that is used internally to store the status text.
1162 */
1163 char buf_[PJ_ERR_MSG_SIZE];
1164
1165} pjsua_acc_info;
1166
1167
1168
1169/**
1170 * Get number of current accounts.
1171 *
1172 * @return Current number of accounts.
1173 */
1174PJ_DECL(unsigned) pjsua_acc_get_count(void);
1175
1176
1177/**
1178 * Check if the specified account ID is valid.
1179 *
1180 * @param acc_id Account ID to check.
1181 *
1182 * @return Non-zero if account ID is valid.
1183 */
1184PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
1185
1186
1187/**
Benny Prijono21b9ad92006-08-15 13:11:22 +00001188 * Set default account to be used when incoming and outgoing
1189 * requests doesn't match any accounts.
1190 *
1191 * @param acc_id The account ID to be used as default.
1192 *
1193 * @return PJ_SUCCESS on success.
1194 */
1195PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
1196
1197
1198/**
1199 * Get default account.
1200 *
1201 * @return The default account ID, or PJSUA_INVALID_ID if no
1202 * default account is configured.
1203 */
1204PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
1205
1206
1207/**
Benny Prijono312aff92006-06-17 04:08:30 +00001208 * Add a new account to pjsua. PJSUA must have been initialized (with
1209 * #pjsua_init()) before calling this function.
1210 *
1211 * @param cfg Account configuration.
1212 * @param is_default If non-zero, this account will be set as the default
1213 * account. The default account will be used when sending
1214 * outgoing requests (e.g. making call) when no account is
1215 * specified, and when receiving incoming requests when the
1216 * request does not match any accounts. It is recommended
1217 * that default account is set to local/LAN account.
1218 * @param p_acc_id Pointer to receive account ID of the new account.
1219 *
1220 * @return PJ_SUCCESS on success, or the appropriate error code.
1221 */
1222PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *cfg,
1223 pj_bool_t is_default,
1224 pjsua_acc_id *p_acc_id);
1225
1226
1227/**
1228 * Add a local account. A local account is used to identify local endpoint
1229 * instead of a specific user, and for this reason, a transport ID is needed
1230 * to obtain the local address information.
1231 *
1232 * @param tid Transport ID to generate account address.
1233 * @param is_default If non-zero, this account will be set as the default
1234 * account. The default account will be used when sending
1235 * outgoing requests (e.g. making call) when no account is
1236 * specified, and when receiving incoming requests when the
1237 * request does not match any accounts. It is recommended
1238 * that default account is set to local/LAN account.
1239 * @param p_acc_id Pointer to receive account ID of the new account.
1240 *
1241 * @return PJ_SUCCESS on success, or the appropriate error code.
1242 */
1243PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
1244 pj_bool_t is_default,
1245 pjsua_acc_id *p_acc_id);
1246
1247/**
1248 * Delete account.
1249 *
1250 * @param acc_id Id of the account to be deleted.
1251 *
1252 * @return PJ_SUCCESS on success, or the appropriate error code.
1253 */
1254PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
1255
1256
1257/**
1258 * Modify account information.
1259 *
1260 * @param acc_id Id of the account to be modified.
1261 * @param cfg New account configuration.
1262 *
1263 * @return PJ_SUCCESS on success, or the appropriate error code.
1264 */
1265PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
1266 const pjsua_acc_config *cfg);
1267
1268
1269/**
1270 * Modify account's presence status to be advertised to remote/presence
1271 * subscribers.
1272 *
1273 * @param acc_id The account ID.
1274 * @param is_online True of false.
1275 *
1276 * @return PJ_SUCCESS on success, or the appropriate error code.
1277 */
1278PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
1279 pj_bool_t is_online);
1280
1281
1282/**
1283 * Update registration or perform unregistration.
1284 *
1285 * @param acc_id The account ID.
1286 * @param renew If renew argument is zero, this will start
1287 * unregistration process.
1288 *
1289 * @return PJ_SUCCESS on success, or the appropriate error code.
1290 */
1291PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
1292 pj_bool_t renew);
1293
1294
1295/**
1296 * Get account information.
1297 *
1298 * @param acc_id Account identification.
1299 * @param info Pointer to receive account information.
1300 *
1301 * @return PJ_SUCCESS on success, or the appropriate error code.
1302 */
1303PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
1304 pjsua_acc_info *info);
1305
1306
1307/**
1308 * Enum accounts all account ids.
1309 *
1310 * @param ids Array of account IDs to be initialized.
1311 * @param count In input, specifies the maximum number of elements.
1312 * On return, it contains the actual number of elements.
1313 *
1314 * @return PJ_SUCCESS on success, or the appropriate error code.
1315 */
1316PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
1317 unsigned *count );
1318
1319
1320/**
1321 * Enum accounts info.
1322 *
1323 * @param info Array of account infos to be initialized.
1324 * @param count In input, specifies the maximum number of elements.
1325 * On return, it contains the actual number of elements.
1326 *
1327 * @return PJ_SUCCESS on success, or the appropriate error code.
1328 */
1329PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
1330 unsigned *count );
1331
1332
1333/**
1334 * This is an internal function to find the most appropriate account to
1335 * used to reach to the specified URL.
1336 *
1337 * @param url The remote URL to reach.
1338 *
1339 * @return Account id.
1340 */
1341PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
1342
1343
1344/**
1345 * This is an internal function to find the most appropriate account to be
1346 * used to handle incoming calls.
1347 *
1348 * @param rdata The incoming request message.
1349 *
1350 * @return Account id.
1351 */
1352PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
1353
1354
Benny Prijonoc570f2d2006-07-18 00:33:02 +00001355/**
1356 * Create a suitable URI to be put as Contact based on the specified
1357 * target URI for the specified account.
1358 *
1359 * @param pool Pool to allocate memory for the string.
1360 * @param contact The string where the Contact URI will be stored.
1361 * @param acc_id Account ID.
1362 * @param uri Destination URI of the request.
1363 *
1364 * @return PJ_SUCCESS on success, other on error.
1365 */
1366PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
1367 pj_str_t *contact,
1368 pjsua_acc_id acc_id,
1369 const pj_str_t *uri);
1370
1371
1372
1373/**
1374 * Create a suitable URI to be put as Contact based on the information
1375 * in the incoming request.
1376 *
1377 * @param pool Pool to allocate memory for the string.
1378 * @param contact The string where the Contact URI will be stored.
1379 * @param acc_id Account ID.
1380 * @param rdata Incoming request.
1381 *
1382 * @return PJ_SUCCESS on success, other on error.
1383 */
1384PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
1385 pj_str_t *contact,
1386 pjsua_acc_id acc_id,
1387 pjsip_rx_data *rdata );
1388
1389
Benny Prijono312aff92006-06-17 04:08:30 +00001390
1391/**
1392 * @}
1393 */
1394
1395
1396/*****************************************************************************
1397 * CALLS API
1398 */
1399
1400
1401/**
1402 * @defgroup PJSUA_LIB_CALL Calls
1403 * @ingroup PJSUA_LIB
1404 * @brief Call manipulation.
1405 * @{
1406 */
1407
1408/**
1409 * Max simultaneous calls.
1410 */
1411#ifndef PJSUA_MAX_CALLS
1412# define PJSUA_MAX_CALLS 32
1413#endif
1414
1415
1416
1417/**
1418 * Call media status.
1419 */
1420typedef enum pjsua_call_media_status
1421{
1422 PJSUA_CALL_MEDIA_NONE,
1423 PJSUA_CALL_MEDIA_ACTIVE,
1424 PJSUA_CALL_MEDIA_LOCAL_HOLD,
1425 PJSUA_CALL_MEDIA_REMOTE_HOLD,
1426} pjsua_call_media_status;
1427
1428
1429/**
1430 * Call info.
1431 */
1432typedef struct pjsua_call_info
1433{
1434 /** Call identification. */
1435 pjsua_call_id id;
1436
1437 /** Initial call role (UAC == caller) */
1438 pjsip_role_e role;
1439
1440 /** Local URI */
1441 pj_str_t local_info;
1442
1443 /** Local Contact */
1444 pj_str_t local_contact;
1445
1446 /** Remote URI */
1447 pj_str_t remote_info;
1448
1449 /** Remote contact */
1450 pj_str_t remote_contact;
1451
1452 /** Dialog Call-ID string. */
1453 pj_str_t call_id;
1454
1455 /** Call state */
1456 pjsip_inv_state state;
1457
1458 /** Text describing the state */
1459 pj_str_t state_text;
1460
1461 /** Last status code heard, which can be used as cause code */
1462 pjsip_status_code last_status;
1463
1464 /** The reason phrase describing the status. */
1465 pj_str_t last_status_text;
1466
1467 /** Call media status. */
1468 pjsua_call_media_status media_status;
1469
1470 /** Media direction */
1471 pjmedia_dir media_dir;
1472
1473 /** The conference port number for the call */
1474 pjsua_conf_port_id conf_slot;
1475
1476 /** Up-to-date call connected duration (zero when call is not
1477 * established)
1478 */
1479 pj_time_val connect_duration;
1480
1481 /** Total call duration, including set-up time */
1482 pj_time_val total_duration;
1483
1484 /** Internal */
1485 struct {
1486 char local_info[128];
1487 char local_contact[128];
1488 char remote_info[128];
1489 char remote_contact[128];
1490 char call_id[128];
1491 char last_status_text[128];
1492 } buf_;
1493
1494} pjsua_call_info;
1495
1496
1497
Benny Prijonoa91a0032006-02-26 21:23:45 +00001498/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00001499 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001500 *
1501 * @return Maximum number of calls configured.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001502 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00001503PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001504
1505/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001506 * Get number of currently active calls.
1507 *
1508 * @return Number of currently active calls.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001509 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00001510PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001511
1512/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001513 * Enumerate all active calls.
1514 *
1515 * @param ids Array of account IDs to be initialized.
1516 * @param count In input, specifies the maximum number of elements.
1517 * On return, it contains the actual number of elements.
1518 *
1519 * @return PJ_SUCCESS on success, or the appropriate error code.
1520 */
1521PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
1522 unsigned *count);
1523
1524
1525/**
1526 * Make outgoing call to the specified URI using the specified account.
1527 *
1528 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001529 * @param dst_uri URI to be put in the To header (normally is the same
1530 * as the target URI).
1531 * @param options Options (must be zero at the moment).
1532 * @param user_data Arbitrary user data to be attached to the call, and
1533 * can be retrieved later.
1534 * @param msg_data Optional headers etc to be added to outgoing INVITE
1535 * request, or NULL if no custom header is desired.
1536 * @param p_call_id Pointer to receive call identification.
1537 *
1538 * @return PJ_SUCCESS on success, or the appropriate error code.
1539 */
1540PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
1541 const pj_str_t *dst_uri,
1542 unsigned options,
1543 void *user_data,
1544 const pjsua_msg_data *msg_data,
1545 pjsua_call_id *p_call_id);
1546
1547
1548/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00001549 * Check if the specified call has active INVITE session and the INVITE
1550 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001551 *
1552 * @param call_id Call identification.
1553 *
1554 * @return Non-zero if call is active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001555 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001556PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001557
1558
1559/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001560 * Check if call has an active media session.
1561 *
1562 * @param call_id Call identification.
1563 *
1564 * @return Non-zero if yes.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001565 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001566PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001567
1568
1569/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001570 * Get the conference port identification associated with the call.
1571 *
1572 * @param call_id Call identification.
1573 *
1574 * @return Conference port ID, or PJSUA_INVALID_ID when the
1575 * media has not been established or is not active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001576 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001577PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
1578
1579/**
1580 * Obtain detail information about the specified call.
1581 *
1582 * @param call_id Call identification.
1583 * @param info Call info to be initialized.
1584 *
1585 * @return PJ_SUCCESS on success, or the appropriate error code.
1586 */
1587PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00001588 pjsua_call_info *info);
1589
1590
1591/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001592 * Attach application specific data to the call.
1593 *
1594 * @param call_id Call identification.
1595 * @param user_data Arbitrary data to be attached to the call.
1596 *
1597 * @return The user data.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001598 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001599PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
1600 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001601
1602
1603/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001604 * Get user data attached to the call.
1605 *
1606 * @param call_id Call identification.
1607 *
1608 * @return The user data.
Benny Prijono268ca612006-02-07 12:34:11 +00001609 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001610PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00001611
1612
1613/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001614 * Send response to incoming INVITE request.
1615 *
1616 * @param call_id Incoming call identification.
1617 * @param code Status code, (100-699).
1618 * @param reason Optional reason phrase. If NULL, default text
1619 * will be used.
1620 * @param msg_data Optional list of headers etc to be added to outgoing
1621 * response message.
1622 *
1623 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoa91a0032006-02-26 21:23:45 +00001624 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001625PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
1626 unsigned code,
1627 const pj_str_t *reason,
1628 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001629
1630/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001631 * Hangup call by using method that is appropriate according to the
1632 * call state.
1633 *
1634 * @param call_id Call identification.
1635 * @param code Optional status code to be sent when we're rejecting
1636 * incoming call. If the value is zero, "603/Decline"
1637 * will be sent.
1638 * @param reason Optional reason phrase to be sent when we're rejecting
1639 * incoming call. If NULL, default text will be used.
1640 * @param msg_data Optional list of headers etc to be added to outgoing
1641 * request/response message.
1642 *
1643 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00001644 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001645PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
1646 unsigned code,
1647 const pj_str_t *reason,
1648 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00001649
1650
1651/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001652 * Put the specified call on hold.
1653 *
1654 * @param call_id Call identification.
1655 * @param msg_data Optional message components to be sent with
1656 * the request.
1657 *
1658 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00001659 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001660PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
1661 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00001662
1663
1664/**
1665 * Send re-INVITE (to release hold).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001666 *
1667 * @param call_id Call identification.
1668 * @param unhold If this argument is non-zero and the call is locally
1669 * held, this will release the local hold.
1670 * @param msg_data Optional message components to be sent with
1671 * the request.
1672 *
1673 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00001674 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001675PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
1676 pj_bool_t unhold,
1677 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00001678
1679
1680/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001681 * Initiate call transfer to the specified address.
1682 *
1683 * @param call_id Call identification.
1684 * @param dest Address of new target to be contacted.
1685 * @param msg_data Optional message components to be sent with
1686 * the request.
1687 *
1688 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00001689 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001690PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
1691 const pj_str_t *dest,
1692 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001693
1694/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001695 * Send DTMF digits to remote using RFC 2833 payload formats.
1696 *
1697 * @param call_id Call identification.
1698 * @param digits DTMF digits to be sent.
1699 *
1700 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001701 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001702PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00001703 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00001704
Benny Prijono26ff9062006-02-21 23:47:00 +00001705/**
Benny Prijonob0808372006-03-02 21:18:58 +00001706 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001707 *
1708 * @param call_id Call identification.
1709 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
1710 * assumed.
1711 * @param content The message content.
1712 * @param msg_data Optional list of headers etc to be included in outgoing
1713 * request. The body descriptor in the msg_data is
1714 * ignored.
1715 * @param user_data Optional user data, which will be given back when
1716 * the IM callback is called.
1717 *
1718 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00001719 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001720PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
1721 const pj_str_t *mime_type,
1722 const pj_str_t *content,
1723 const pjsua_msg_data *msg_data,
1724 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00001725
1726
1727/**
1728 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001729 *
1730 * @param call_id Call identification.
1731 * @param is_typing Non-zero to indicate to remote that local person is
1732 * currently typing an IM.
1733 * @param msg_data Optional list of headers etc to be included in outgoing
1734 * request.
1735 *
1736 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00001737 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001738PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
1739 pj_bool_t is_typing,
1740 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00001741
1742/**
Benny Prijono834aee32006-02-19 01:38:06 +00001743 * Terminate all calls.
1744 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001745PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00001746
1747
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001748/**
1749 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001750 *
1751 * @param call_id Call identification.
1752 * @param with_media Non-zero to include media information too.
1753 * @param buffer Buffer where the statistics are to be written to.
1754 * @param maxlen Maximum length of buffer.
1755 * @param indent Spaces for left indentation.
1756 *
1757 * @return PJ_SUCCESS on success.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001758 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001759PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
1760 pj_bool_t with_media,
1761 char *buffer,
1762 unsigned maxlen,
1763 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001764
Benny Prijono9fc735d2006-05-28 14:58:12 +00001765/**
Benny Prijono312aff92006-06-17 04:08:30 +00001766 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00001767 */
Benny Prijono834aee32006-02-19 01:38:06 +00001768
1769
1770/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001771 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00001772 */
1773
Benny Prijono312aff92006-06-17 04:08:30 +00001774
1775/**
1776 * @defgroup PJSUA_LIB_BUDDY Buddy, Presence, and Instant Messaging
1777 * @ingroup PJSUA_LIB
1778 * @brief Buddy management, buddy's presence, and instant messaging.
1779 * @{
1780 */
1781
1782/**
1783 * Max buddies in buddy list.
1784 */
1785#ifndef PJSUA_MAX_BUDDIES
1786# define PJSUA_MAX_BUDDIES 256
1787#endif
1788
1789
1790/**
1791 * Buddy configuration.
1792 */
1793typedef struct pjsua_buddy_config
1794{
1795 /**
1796 * Buddy URL or name address.
1797 */
1798 pj_str_t uri;
1799
1800 /**
1801 * Specify whether presence subscription should start immediately.
1802 */
1803 pj_bool_t subscribe;
1804
1805} pjsua_buddy_config;
1806
1807
1808/**
1809 * Buddy's online status.
1810 */
1811typedef enum pjsua_buddy_status
1812{
1813 /**
1814 * Online status is unknown (possibly because no presence subscription
1815 * has been established).
1816 */
1817 PJSUA_BUDDY_STATUS_UNKNOWN,
1818
1819 /**
1820 * Buddy is known to be offline.
1821 */
1822 PJSUA_BUDDY_STATUS_ONLINE,
1823
1824 /**
1825 * Buddy is offline.
1826 */
1827 PJSUA_BUDDY_STATUS_OFFLINE,
1828
1829} pjsua_buddy_status;
1830
1831
1832
1833/**
1834 * Buddy info.
1835 */
1836typedef struct pjsua_buddy_info
1837{
1838 /**
1839 * The buddy ID.
1840 */
1841 pjsua_buddy_id id;
1842
1843 /**
1844 * The full URI of the buddy, as specified in the configuration.
1845 */
1846 pj_str_t uri;
1847
1848 /**
1849 * Buddy's Contact, only available when presence subscription has
1850 * been established to the buddy.
1851 */
1852 pj_str_t contact;
1853
1854 /**
1855 * Buddy's online status.
1856 */
1857 pjsua_buddy_status status;
1858
1859 /**
1860 * Text to describe buddy's online status.
1861 */
1862 pj_str_t status_text;
1863
1864 /**
1865 * Flag to indicate that we should monitor the presence information for
1866 * this buddy (normally yes, unless explicitly disabled).
1867 */
1868 pj_bool_t monitor_pres;
1869
1870 /**
1871 * Internal buffer.
1872 */
1873 char buf_[256];
1874
1875} pjsua_buddy_info;
1876
1877
Benny Prijono834aee32006-02-19 01:38:06 +00001878/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001879 * Get total number of buddies.
1880 *
1881 * @return Number of buddies.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001882 */
1883PJ_DECL(unsigned) pjsua_get_buddy_count(void);
1884
1885
1886/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001887 * Check if buddy ID is valid.
1888 *
1889 * @param buddy_id Buddy ID to check.
1890 *
1891 * @return Non-zero if buddy ID is valid.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001892 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001893PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
1894
1895
1896/**
1897 * Enum buddy IDs.
1898 *
1899 * @param ids Array of ids to be initialized.
1900 * @param count On input, specifies max elements in the array.
1901 * On return, it contains actual number of elements
1902 * that have been initialized.
1903 *
1904 * @return PJ_SUCCESS on success, or the appropriate error code.
1905 */
1906PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
1907 unsigned *count);
1908
1909/**
1910 * Get detailed buddy info.
1911 *
1912 * @param buddy_id The buddy identification.
1913 * @param info Pointer to receive information about buddy.
1914 *
1915 * @return PJ_SUCCESS on success, or the appropriate error code.
1916 */
1917PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00001918 pjsua_buddy_info *info);
1919
1920/**
1921 * Add new buddy.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001922 *
1923 * @param cfg Buddy configuration.
1924 * @param p_buddy_id Pointer to receive buddy ID.
1925 *
1926 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001927 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001928PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *cfg,
1929 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00001930
1931
1932/**
1933 * Delete buddy.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001934 *
1935 * @param buddy_id Buddy identification.
1936 *
1937 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00001938 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001939PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001940
1941
1942/**
1943 * Enable/disable buddy's presence monitoring.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001944 *
1945 * @param buddy_id Buddy identification.
1946 * @param subscribe Specify non-zero to activate presence subscription to
1947 * the specified buddy.
1948 *
1949 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001950 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001951PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
1952 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001953
1954
1955/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001956 * Dump presence subscriptions to log file.
1957 *
1958 * @param verbose Yes or no.
Benny Prijono834aee32006-02-19 01:38:06 +00001959 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001960PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00001961
1962
Benny Prijonob0808372006-03-02 21:18:58 +00001963/**
1964 * The MESSAGE method (defined in pjsua_im.c)
1965 */
1966extern const pjsip_method pjsip_message_method;
1967
1968
Benny Prijonob0808372006-03-02 21:18:58 +00001969
1970/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001971 * Send instant messaging outside dialog, using the specified account for
1972 * route set and authentication.
1973 *
1974 * @param acc_id Account ID to be used to send the request.
1975 * @param to Remote URI.
1976 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
1977 * assumed.
1978 * @param content The message content.
1979 * @param msg_data Optional list of headers etc to be included in outgoing
1980 * request. The body descriptor in the msg_data is
1981 * ignored.
1982 * @param user_data Optional user data, which will be given back when
1983 * the IM callback is called.
1984 *
1985 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00001986 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001987PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
1988 const pj_str_t *to,
1989 const pj_str_t *mime_type,
1990 const pj_str_t *content,
1991 const pjsua_msg_data *msg_data,
1992 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00001993
1994
1995/**
1996 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001997 *
1998 * @param acc_id Account ID to be used to send the request.
1999 * @param to Remote URI.
2000 * @param is_typing If non-zero, it tells remote person that local person
2001 * is currently composing an IM.
2002 * @param msg_data Optional list of headers etc to be added to outgoing
2003 * request.
2004 *
2005 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00002006 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002007PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
2008 const pj_str_t *to,
2009 pj_bool_t is_typing,
2010 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00002011
2012
Benny Prijonof3195072006-02-14 21:15:30 +00002013
Benny Prijono312aff92006-06-17 04:08:30 +00002014/**
2015 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00002016 */
2017
Benny Prijono312aff92006-06-17 04:08:30 +00002018
2019/*****************************************************************************
2020 * MEDIA API
2021 */
2022
2023
2024/**
2025 * @defgroup PJSUA_LIB_MEDIA Media
2026 * @ingroup PJSUA_LIB
2027 * @brief Media manipulation.
2028 * @{
2029 *
2030 * PJSUA has rather powerful media features, which are built around the
2031 * PJMEDIA conference bridge. Basically, all media termination (such as
2032 * calls, file players, file recorders, sound device, tone generators, etc)
2033 * are terminated in the conference bridge, and application can manipulate
2034 * the interconnection between these terminations freely. If more than
2035 * one media terminations are terminated in the same slot, the conference
2036 * bridge will mix the signal automatically.
2037 *
2038 * Application connects one media termination/slot to another by calling
2039 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
2040 * media flow from the source termination to the sink termination. For
2041 * example, to stream a WAV file to remote call, application may use
2042 * the following steps:
2043 *
2044 \code
2045
2046 pj_status_t stream_to_call( pjsua_call_id call_id )
2047 {
2048 pjsua_player_id player_id;
2049
2050 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
2051 if (status != PJ_SUCCESS)
2052 return status;
2053
2054 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
2055 pjsua_call_get_conf_port() );
2056 }
2057 \endcode
2058 *
2059 *
2060 * Other features of PJSUA media:
2061 * - efficient N to M interconnections between media terminations.
2062 * - media termination can be connected to itself to create loopback
2063 * media.
2064 * - the media termination may have different clock rates, and resampling
2065 * will be done automatically by conference bridge.
2066 * - media terminations may also have different frame time; the
2067 * conference bridge will perform the necessary bufferring to adjust
2068 * the difference between terminations.
2069 * - interconnections are removed automatically when media termination
2070 * is removed from the bridge.
2071 * - sound device may be changed even when there are active media
2072 * interconnections.
2073 * - correctly report call's media quality (in #pjsua_call_dump()) from
2074 * RTCP packet exchange.
2075 */
2076
2077/**
2078 * Max ports in the conference bridge.
2079 */
2080#ifndef PJSUA_MAX_CONF_PORTS
2081# define PJSUA_MAX_CONF_PORTS 254
2082#endif
2083
Benny Prijono70972992006-08-05 11:13:58 +00002084#define PJSUA_DEFAULT_CLOCK_RATE 16000
2085#define PJSUA_DEFAULT_CODEC_QUALITY 5
2086#define PJSUA_DEFAULT_ILBC_MODE 20
2087#define PJSUA_DEFAULT_EC_TAIL_LEN 256
Benny Prijono312aff92006-06-17 04:08:30 +00002088
2089
2090/**
2091 * Media configuration.
2092 */
2093struct pjsua_media_config
2094{
2095 /**
2096 * Clock rate to be applied to the conference bridge.
2097 * If value is zero, default clock rate will be used (16KHz).
2098 */
2099 unsigned clock_rate;
2100
2101 /**
2102 * Specify maximum number of media ports to be created in the
2103 * conference bridge. Since all media terminate in the bridge
2104 * (calls, file player, file recorder, etc), the value must be
2105 * large enough to support all of them. However, the larger
2106 * the value, the more computations are performed.
2107 */
2108 unsigned max_media_ports;
2109
2110 /**
2111 * Specify whether the media manager should manage its own
2112 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
2113 * and at least one worker thread will be created too. If no,
2114 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
2115 * and no worker thread is needed.
2116 *
2117 * Normally application would say yes here, unless it wants to
2118 * run everything from a single thread.
2119 */
2120 pj_bool_t has_ioqueue;
2121
2122 /**
2123 * Specify the number of worker threads to handle incoming RTP
2124 * packets. A value of one is recommended for most applications.
2125 */
2126 unsigned thread_cnt;
2127
Benny Prijono0498d902006-06-19 14:49:14 +00002128 /**
2129 * Media quality, 0-10, according to this table:
Benny Prijono7ca96da2006-08-07 12:11:40 +00002130 * 5-10: resampling use large filter,
2131 * 3-4: resampling use small filter,
Benny Prijono0498d902006-06-19 14:49:14 +00002132 * 1-2: resampling use linear.
2133 * The media quality also sets speex codec quality/complexity to the
2134 * number.
2135 *
Benny Prijono70972992006-08-05 11:13:58 +00002136 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
Benny Prijono0498d902006-06-19 14:49:14 +00002137 */
2138 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00002139
2140 /**
2141 * Specify default ptime.
2142 *
2143 * Default: 0 (codec specific)
2144 */
2145 unsigned ptime;
2146
2147 /**
2148 * Disable VAD?
2149 *
2150 * Default: 0 (no (meaning VAD is enabled))
2151 */
2152 pj_bool_t no_vad;
Benny Prijono00cae612006-07-31 15:19:36 +00002153
2154 /**
2155 * iLBC mode (20 or 30).
2156 *
Benny Prijono70972992006-08-05 11:13:58 +00002157 * Default: 20 (PJSUA_DEFAULT_ILBC_MODE)
Benny Prijono00cae612006-07-31 15:19:36 +00002158 */
2159 unsigned ilbc_mode;
2160
2161 /**
2162 * Percentage of RTP packet to drop in TX direction
2163 * (to simulate packet lost).
2164 *
2165 * Default: 0
2166 */
2167 unsigned tx_drop_pct;
2168
2169 /**
2170 * Percentage of RTP packet to drop in RX direction
2171 * (to simulate packet lost).
2172 *
2173 * Default: 0
2174 */
2175 unsigned rx_drop_pct;
2176
Benny Prijonoc8e24a12006-08-02 18:22:22 +00002177 /**
Benny Prijono5da50432006-08-07 10:24:52 +00002178 * Echo canceller options (see #pjmedia_echo_create())
2179 *
2180 * Default: 0.
2181 */
2182 unsigned ec_options;
2183
2184 /**
Benny Prijonoc8e24a12006-08-02 18:22:22 +00002185 * Echo canceller tail length, in miliseconds.
2186 *
Benny Prijono70972992006-08-05 11:13:58 +00002187 * Default: 128 (PJSUA_DEFAULT_EC_TAIL_LEN)
Benny Prijonoc8e24a12006-08-02 18:22:22 +00002188 */
2189 unsigned ec_tail_len;
Benny Prijono312aff92006-06-17 04:08:30 +00002190};
2191
2192
2193/**
2194 * Use this function to initialize media config.
2195 *
2196 * @param cfg The media config to be initialized.
2197 */
2198PJ_INLINE(void) pjsua_media_config_default(pjsua_media_config *cfg)
2199{
Benny Prijonoac623b32006-07-03 15:19:31 +00002200 pj_bzero(cfg, sizeof(*cfg));
Benny Prijono312aff92006-06-17 04:08:30 +00002201
Benny Prijono70972992006-08-05 11:13:58 +00002202 cfg->clock_rate = PJSUA_DEFAULT_CLOCK_RATE;
Benny Prijono312aff92006-06-17 04:08:30 +00002203 cfg->max_media_ports = 32;
2204 cfg->has_ioqueue = PJ_TRUE;
2205 cfg->thread_cnt = 1;
Benny Prijono70972992006-08-05 11:13:58 +00002206 cfg->quality = PJSUA_DEFAULT_CODEC_QUALITY;
2207 cfg->ilbc_mode = PJSUA_DEFAULT_ILBC_MODE;
2208 cfg->ec_tail_len = PJSUA_DEFAULT_EC_TAIL_LEN;
Benny Prijono312aff92006-06-17 04:08:30 +00002209}
2210
2211
2212
2213/**
2214 * Codec config.
2215 */
2216typedef struct pjsua_codec_info
2217{
2218 /**
2219 * Codec unique identification.
2220 */
2221 pj_str_t codec_id;
2222
2223 /**
2224 * Codec priority (integer 0-255).
2225 */
2226 pj_uint8_t priority;
2227
2228 /**
2229 * Internal buffer.
2230 */
2231 char buf_[32];
2232
2233} pjsua_codec_info;
2234
2235
2236/**
2237 * Conference port info.
2238 */
2239typedef struct pjsua_conf_port_info
2240{
2241 /** Conference port number. */
2242 pjsua_conf_port_id slot_id;
2243
2244 /** Port name. */
2245 pj_str_t name;
2246
2247 /** Clock rate. */
2248 unsigned clock_rate;
2249
2250 /** Number of channels. */
2251 unsigned channel_count;
2252
2253 /** Samples per frame */
2254 unsigned samples_per_frame;
2255
2256 /** Bits per sample */
2257 unsigned bits_per_sample;
2258
2259 /** Number of listeners in the array. */
2260 unsigned listener_cnt;
2261
2262 /** Array of listeners (in other words, ports where this port is
2263 * transmitting to.
2264 */
2265 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
2266
2267} pjsua_conf_port_info;
2268
2269
2270/**
2271 * This structure holds information about custom media transport to
2272 * be registered to pjsua.
2273 */
2274typedef struct pjsua_media_transport
2275{
2276 /**
2277 * Media socket information containing the address information
2278 * of the RTP and RTCP socket.
2279 */
2280 pjmedia_sock_info skinfo;
2281
2282 /**
2283 * The media transport instance.
2284 */
2285 pjmedia_transport *transport;
2286
2287} pjsua_media_transport;
2288
2289
2290
2291
Benny Prijono9fc735d2006-05-28 14:58:12 +00002292/**
2293 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002294 *
2295 * @return Maximum number of ports in the conference bridge.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002296 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002297PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002298
2299
2300/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002301 * Get current number of active ports in the bridge.
2302 *
2303 * @return The number.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002304 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002305PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
2306
2307
2308/**
2309 * Enumerate all conference ports.
2310 *
2311 * @param id Array of conference port ID to be initialized.
2312 * @param count On input, specifies max elements in the array.
2313 * On return, it contains actual number of elements
2314 * that have been initialized.
2315 *
2316 * @return PJ_SUCCESS on success, or the appropriate error code.
2317 */
2318PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
2319 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00002320
2321
2322/**
2323 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002324 *
2325 * @param id Port identification.
2326 * @param info Pointer to store the port info.
2327 *
2328 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00002329 */
2330PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id id,
2331 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002332
2333
2334/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00002335 * Add arbitrary media port to PJSUA's conference bridge. Application
2336 * can use this function to add the media port that it creates. For
2337 * media ports that are created by PJSUA-LIB (such as calls, file player,
2338 * or file recorder), PJSUA-LIB will automatically add the port to
2339 * the bridge.
2340 *
2341 * @param pool Pool to use.
2342 * @param port Media port to be added to the bridge.
2343 * @param p_id Optional pointer to receive the conference
2344 * slot id.
2345 *
2346 * @return PJ_SUCCESS on success, or the appropriate error code.
2347 */
2348PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
2349 pjmedia_port *port,
2350 pjsua_conf_port_id *p_id);
2351
2352
2353/**
2354 * Remove arbitrary slot from the conference bridge. Application should only
2355 * call this function if it registered the port manually.
2356 *
2357 * @param id The slot id of the port to be removed.
2358 *
2359 * @return PJ_SUCCESS on success, or the appropriate error code.
2360 */
2361PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id id);
2362
2363
2364/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002365 * Establish unidirectional media flow from souce to sink. One source
2366 * may transmit to multiple destinations/sink. And if multiple
2367 * sources are transmitting to the same sink, the media will be mixed
2368 * together. Source and sink may refer to the same ID, effectively
2369 * looping the media.
2370 *
2371 * If bidirectional media flow is desired, application needs to call
2372 * this function twice, with the second one having the arguments
2373 * reversed.
2374 *
2375 * @param source Port ID of the source media/transmitter.
2376 * @param sink Port ID of the destination media/received.
2377 *
2378 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002379 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002380PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
2381 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002382
2383
2384/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002385 * Disconnect media flow from the source to destination port.
2386 *
2387 * @param source Port ID of the source media/transmitter.
2388 * @param sink Port ID of the destination media/received.
2389 *
2390 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002391 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002392PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
2393 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002394
2395
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002396/*****************************************************************************
2397 * File player.
2398 */
2399
Benny Prijono9fc735d2006-05-28 14:58:12 +00002400/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002401 * Create a file player, and automatically connect this player to
2402 * the conference bridge.
2403 *
2404 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00002405 * WAV files are supported, and the WAV file MUST be
2406 * formatted as 16bit PCM mono/single channel (any
2407 * clock rate is supported).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002408 * @param options Options (currently zero).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002409 * @param p_id Pointer to receive player ID.
2410 *
2411 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002412 */
2413PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002414 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002415 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002416
2417
2418/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002419 * Get conference port ID associated with player.
2420 *
2421 * @param id The file player ID.
2422 *
2423 * @return Conference port ID associated with this player.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002424 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002425PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002426
2427
2428/**
2429 * Set playback position.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002430 *
2431 * @param id The file player ID.
2432 * @param samples The playback position, in samples. Application can
2433 * specify zero to re-start the playback.
2434 *
2435 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002436 */
2437PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
2438 pj_uint32_t samples);
2439
2440
2441/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002442 * Close the file, remove the player from the bridge, and free
2443 * resources associated with the file player.
2444 *
2445 * @param id The file player ID.
2446 *
2447 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002448 */
2449PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
2450
2451
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002452/*****************************************************************************
2453 * File recorder.
2454 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00002455
2456/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002457 * Create a file recorder, and automatically connect this recorder to
2458 * the conference bridge.
2459 *
2460 * @param filename Output file name.
2461 * @param file_format Specify the file format (currently only WAV is
2462 * supported, so the value MUST be zero).
2463 * @param encoding Specify the encoding to be applied to the file.
2464 * Currently only 16bit raw PCM is supported, so
2465 * the value must be NULL.
2466 * @param max_size Maximum file size. Specify -1 to remove size
2467 * limitation.
2468 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002469 * @param p_id Pointer to receive the recorder instance.
2470 *
2471 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002472 */
2473PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002474 unsigned file_format,
2475 const pj_str_t *encoding,
2476 pj_ssize_t max_size,
2477 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002478 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002479
2480
2481/**
2482 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002483 *
2484 * @param id The recorder ID.
2485 *
2486 * @return Conference port ID associated with this recorder.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002487 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002488PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002489
2490
2491/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002492 * Destroy recorder (this will complete recording).
2493 *
2494 * @param id The recorder ID.
2495 *
2496 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002497 */
2498PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
2499
2500
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002501/*****************************************************************************
2502 * Sound devices.
2503 */
2504
Benny Prijono9fc735d2006-05-28 14:58:12 +00002505/**
2506 * Enum sound devices.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002507 *
2508 * @param info Array of info to be initialized.
2509 * @param count On input, specifies max elements in the array.
2510 * On return, it contains actual number of elements
2511 * that have been initialized.
2512 *
2513 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002514 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002515PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
2516 unsigned *count);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002517
2518
2519/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002520 * Select or change sound device. Application may call this function at
2521 * any time to replace current sound device.
2522 *
2523 * @param capture_dev Device ID of the capture device.
2524 * @param playback_dev Device ID of the playback device.
2525 *
2526 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002527 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002528PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
2529 int playback_dev);
2530
2531
2532/**
2533 * Set pjsua to use null sound device. The null sound device only provides
2534 * the timing needed by the conference bridge, and will not interract with
2535 * any hardware.
2536 *
2537 * @return PJ_SUCCESS on success, or the appropriate error code.
2538 */
2539PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
2540
2541
Benny Prijonoe909eac2006-07-27 22:04:56 +00002542/**
2543 * Disconnect the main conference bridge from any sound devices, and let
2544 * application connect the bridge to it's own sound device/master port.
2545 *
2546 * @return The port interface of the conference bridge,
2547 * so that application can connect this to it's own
2548 * sound device or master port.
2549 */
2550PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
2551
2552
Benny Prijonof20687a2006-08-04 18:27:19 +00002553/**
Benny Prijono22dfe592006-08-06 12:07:13 +00002554 * Configure the echo canceller tail length of the sound port.
Benny Prijonof20687a2006-08-04 18:27:19 +00002555 *
2556 * @param tail_ms The tail length, in miliseconds. Set to zero to
2557 * disable AEC.
Benny Prijono5da50432006-08-07 10:24:52 +00002558 * @param options Options to be passed to #pjmedia_echo_create().
2559 * Normally the value should be zero.
Benny Prijonof20687a2006-08-04 18:27:19 +00002560 *
2561 * @return PJ_SUCCESS on success.
2562 */
Benny Prijono5da50432006-08-07 10:24:52 +00002563PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
Benny Prijonof20687a2006-08-04 18:27:19 +00002564
2565
2566/**
Benny Prijono22dfe592006-08-06 12:07:13 +00002567 * Get current echo canceller tail length.
Benny Prijonof20687a2006-08-04 18:27:19 +00002568 *
2569 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
2570 * If AEC is disabled, the value will be zero.
2571 *
2572 * @return PJ_SUCCESS on success.
2573 */
Benny Prijono22dfe592006-08-06 12:07:13 +00002574PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
Benny Prijonof20687a2006-08-04 18:27:19 +00002575
2576
2577
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002578/*****************************************************************************
2579 * Codecs.
2580 */
2581
2582/**
2583 * Enum all supported codecs in the system.
2584 *
2585 * @param id Array of ID to be initialized.
2586 * @param count On input, specifies max elements in the array.
2587 * On return, it contains actual number of elements
2588 * that have been initialized.
2589 *
2590 * @return PJ_SUCCESS on success, or the appropriate error code.
2591 */
2592PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
2593 unsigned *count );
2594
2595
2596/**
2597 * Change codec priority.
2598 *
2599 * @param id Codec ID.
2600 * @param priority Codec priority, 0-255, where zero means to disable
2601 * the codec.
2602 *
2603 * @return PJ_SUCCESS on success, or the appropriate error code.
2604 */
2605PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *id,
2606 pj_uint8_t priority );
2607
2608
2609/**
2610 * Get codec parameters.
2611 *
2612 * @param id Codec ID.
2613 * @param param Structure to receive codec parameters.
2614 *
2615 * @return PJ_SUCCESS on success, or the appropriate error code.
2616 */
2617PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *id,
2618 pjmedia_codec_param *param );
2619
2620
2621/**
2622 * Set codec parameters.
2623 *
2624 * @param id Codec ID.
2625 * @param param Codec parameter to set.
2626 *
2627 * @return PJ_SUCCESS on success, or the appropriate error code.
2628 */
2629PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *id,
2630 const pjmedia_codec_param *param);
2631
2632
2633
Benny Prijono9fc735d2006-05-28 14:58:12 +00002634
Benny Prijono312aff92006-06-17 04:08:30 +00002635/**
2636 * Create UDP media transports for all the calls. This function creates
2637 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00002638 *
Benny Prijono312aff92006-06-17 04:08:30 +00002639 * @param cfg Media transport configuration. The "port" field in the
2640 * configuration is used as the start port to bind the
2641 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002642 *
2643 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonof3195072006-02-14 21:15:30 +00002644 */
Benny Prijono312aff92006-06-17 04:08:30 +00002645PJ_DECL(pj_status_t)
2646pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00002647
Benny Prijonodc39fe82006-05-26 12:17:46 +00002648
2649/**
Benny Prijono312aff92006-06-17 04:08:30 +00002650 * Register custom media transports to be used by calls. There must
2651 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002652 *
Benny Prijono312aff92006-06-17 04:08:30 +00002653 * @param tp The media transport array.
2654 * @param count Number of elements in the array. This number MUST
2655 * match the number of maximum calls configured when
2656 * pjsua is created.
2657 * @param auto_delete Flag to indicate whether the transports should be
2658 * destroyed when pjsua is shutdown.
2659 *
2660 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00002661 */
Benny Prijono312aff92006-06-17 04:08:30 +00002662PJ_DECL(pj_status_t)
2663pjsua_media_transports_attach( pjsua_media_transport tp[],
2664 unsigned count,
2665 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00002666
2667
Benny Prijono312aff92006-06-17 04:08:30 +00002668/**
2669 * @}
2670 */
2671
Benny Prijonof3195072006-02-14 21:15:30 +00002672
Benny Prijono268ca612006-02-07 12:34:11 +00002673
Benny Prijono1a01ad32006-02-07 21:13:28 +00002674PJ_END_DECL
2675
Benny Prijonof3195072006-02-14 21:15:30 +00002676
Benny Prijono312aff92006-06-17 04:08:30 +00002677/**
2678 * @}
2679 */
2680
2681
Benny Prijono268ca612006-02-07 12:34:11 +00002682#endif /* __PJSUA_H__ */