blob: 6958bc4ffcc0a5124fecd1a6663c99ac54721feb [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 Prijonoeebe9af2006-06-13 22:57:13 +0000620
621/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +0000622 * Utilities.
623 *
Benny Prijono9fc735d2006-05-28 14:58:12 +0000624 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000625
626/**
Benny Prijono312aff92006-06-17 04:08:30 +0000627 * Verify that valid SIP url is given.
628 *
629 * @param c_url The URL, as NULL terminated string.
630 *
631 * @return PJ_SUCCESS on success, or the appropriate error code.
632 */
633PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *c_url);
634
635
636/**
637 * Display error message for the specified error code.
638 *
639 * @param sender The log sender field.
640 * @param title Message title for the error.
641 * @param status Status code.
642 */
643PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
644 pj_status_t status);
645
646
647
648
649/**
650 * @}
651 */
652
653
654
655/*****************************************************************************
656 * TRANSPORT API
657 */
658
659/**
660 * @defgroup PJSUA_LIB_TRANSPORT Signaling Transport
661 * @ingroup PJSUA_LIB
662 * @brief API for managing SIP transports
663 * @{
664 * SIP transport must be created before adding an account. SIP transport is
665 * created by calling #pjsua_transport_create() function.
666 */
667
668
669/** SIP transport identification */
670typedef int pjsua_transport_id;
671
672
673/**
674 * STUN configuration.
675 */
676typedef struct pjsua_stun_config
677{
678 /**
679 * The first STUN server IP address or hostname.
680 */
681 pj_str_t stun_srv1;
682
683 /**
684 * Port number of the first STUN server.
685 * If zero, default STUN port will be used.
686 */
687 unsigned stun_port1;
688
689 /**
690 * Optional second STUN server IP address or hostname, for which the
691 * result of the mapping request will be compared to. If the value
692 * is empty, only one STUN server will be used.
693 */
694 pj_str_t stun_srv2;
695
696 /**
697 * Port number of the second STUN server.
698 * If zero, default STUN port will be used.
699 */
700 unsigned stun_port2;
701
702} pjsua_stun_config;
703
704
705
706/**
707 * Call this function to initialize STUN config with default values.
708 *
709 * @param cfg The STUN config to be initialized.
710 */
711PJ_INLINE(void) pjsua_stun_config_default(pjsua_stun_config *cfg)
712{
Benny Prijonoac623b32006-07-03 15:19:31 +0000713 pj_bzero(cfg, sizeof(*cfg));
Benny Prijono312aff92006-06-17 04:08:30 +0000714}
715
716
717/**
718 * Transport configuration for creating UDP transports for both SIP
719 * and media.
720 */
721typedef struct pjsua_transport_config
722{
723 /**
724 * UDP port number to bind locally. This setting MUST be specified
725 * even when default port is desired. If the value is zero, the
726 * transport will be bound to any available port, and application
727 * can query the port by querying the transport info.
728 */
729 unsigned port;
730
731 /**
732 * Optional address where the socket should be bound.
733 */
734 pj_in_addr ip_addr;
735
736 /**
737 * Flag to indicate whether STUN should be used.
738 */
739 pj_bool_t use_stun;
740
741 /**
742 * STUN configuration, must be specified when STUN is used.
743 */
744 pjsua_stun_config stun_config;
745
746} pjsua_transport_config;
747
748
749/**
750 * Call this function to initialize UDP config with default values.
751 *
752 * @param cfg The UDP config to be initialized.
753 */
754PJ_INLINE(void) pjsua_transport_config_default(pjsua_transport_config *cfg)
755{
Benny Prijonoac623b32006-07-03 15:19:31 +0000756 pj_bzero(cfg, sizeof(*cfg));
Benny Prijono312aff92006-06-17 04:08:30 +0000757}
758
759
760/**
761 * Normalize STUN config.
762 */
763PJ_INLINE(void) pjsua_normalize_stun_config( pjsua_stun_config *cfg )
764{
765 if (cfg->stun_srv1.slen) {
766
767 if (cfg->stun_port1 == 0)
768 cfg->stun_port1 = 3478;
769
770 if (cfg->stun_srv2.slen == 0) {
771 cfg->stun_srv2 = cfg->stun_srv1;
772 cfg->stun_port2 = cfg->stun_port1;
773 } else {
774 if (cfg->stun_port2 == 0)
775 cfg->stun_port2 = 3478;
776 }
777
778 } else {
779 cfg->stun_port1 = 0;
780 cfg->stun_srv2.slen = 0;
781 cfg->stun_port2 = 0;
782 }
783}
784
785
786/**
787 * Duplicate transport config.
788 */
789PJ_INLINE(void) pjsua_transport_config_dup(pj_pool_t *pool,
790 pjsua_transport_config *dst,
791 const pjsua_transport_config *src)
792{
793 pj_memcpy(dst, src, sizeof(*src));
794
795 if (src->stun_config.stun_srv1.slen) {
796 pj_strdup_with_null(pool, &dst->stun_config.stun_srv1,
797 &src->stun_config.stun_srv1);
798 }
799
800 if (src->stun_config.stun_srv2.slen) {
801 pj_strdup_with_null(pool, &dst->stun_config.stun_srv2,
802 &src->stun_config.stun_srv2);
803 }
804
805 pjsua_normalize_stun_config(&dst->stun_config);
806}
807
808
809
810/**
811 * Transport info.
812 */
813typedef struct pjsua_transport_info
814{
815 /**
816 * PJSUA transport identification.
817 */
818 pjsua_transport_id id;
819
820 /**
821 * Transport type.
822 */
823 pjsip_transport_type_e type;
824
825 /**
826 * Transport type name.
827 */
828 pj_str_t type_name;
829
830 /**
831 * Transport string info/description.
832 */
833 pj_str_t info;
834
835 /**
836 * Transport flag (see ##pjsip_transport_flags_e).
837 */
838 unsigned flag;
839
840 /**
841 * Local address length.
842 */
843 unsigned addr_len;
844
845 /**
846 * Local/bound address.
847 */
848 pj_sockaddr local_addr;
849
850 /**
851 * Published address (or transport address name).
852 */
853 pjsip_host_port local_name;
854
855 /**
856 * Current number of objects currently referencing this transport.
857 */
858 unsigned usage_count;
859
860
861} pjsua_transport_info;
862
863
864/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000865 * Create SIP transport.
866 *
867 * @param type Transport type.
868 * @param cfg Transport configuration.
869 * @param p_id Optional pointer to receive transport ID.
870 *
871 * @return PJ_SUCCESS on success, or the appropriate error code.
872 */
873PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
874 const pjsua_transport_config *cfg,
875 pjsua_transport_id *p_id);
876
877/**
878 * Register transport that has been created by application.
879 *
880 * @param tp Transport instance.
881 * @param p_id Optional pointer to receive transport ID.
882 *
883 * @return PJ_SUCCESS on success, or the appropriate error code.
884 */
885PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
886 pjsua_transport_id *p_id);
887
888
889/**
890 * Enumerate all transports currently created in the system.
891 *
892 * @param id Array to receive transport ids.
893 * @param count In input, specifies the maximum number of elements.
894 * On return, it contains the actual number of elements.
895 *
896 * @return PJ_SUCCESS on success, or the appropriate error code.
897 */
898PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
899 unsigned *count );
900
901
902/**
903 * Get information about transports.
904 *
905 * @param id Transport ID.
906 * @param info Pointer to receive transport info.
907 *
908 * @return PJ_SUCCESS on success, or the appropriate error code.
909 */
910PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
911 pjsua_transport_info *info);
912
913
914/**
915 * Disable a transport or re-enable it. By default transport is always
916 * enabled after it is created. Disabling a transport does not necessarily
917 * close the socket, it will only discard incoming messages and prevent
918 * the transport from being used to send outgoing messages.
919 *
920 * @param id Transport ID.
921 * @param enabled Non-zero to enable, zero to disable.
922 *
923 * @return PJ_SUCCESS on success, or the appropriate error code.
924 */
925PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
926 pj_bool_t enabled);
927
928
929/**
930 * Close the transport. If transport is forcefully closed, it will be
931 * immediately closed, and any pending transactions that are using the
932 * transport may not terminate properly. Otherwise, the system will wait
933 * until all transactions are closed while preventing new users from
934 * using the transport, and will close the transport when it is safe to
935 * do so.
936 *
937 * @param id Transport ID.
938 * @param force Non-zero to immediately close the transport. This
939 * is not recommended!
940 *
941 * @return PJ_SUCCESS on success, or the appropriate error code.
942 */
943PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
944 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +0000945
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000946/**
Benny Prijono312aff92006-06-17 04:08:30 +0000947 * @}
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000948 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000949
950
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000951
952
953/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +0000954 * ACCOUNT API
Benny Prijonoa91a0032006-02-26 21:23:45 +0000955 */
956
Benny Prijono312aff92006-06-17 04:08:30 +0000957
958/**
959 * @defgroup PJSUA_LIB_ACC Account Management
960 * @ingroup PJSUA_LIB
961 * @brief PJSUA supports multiple accounts..
962 * @{
963 * PJSUA accounts provide identity (or identities) of the user who is currently
964 * using the application. More than one account maybe created with PJSUA.
965 *
966 * Account may or may not have client registration associated with it.
967 * An account is also associated with <b>route set</b> and some <b>authentication
968 * credentials</b>, which are used when sending SIP request messages using the
969 * account. An account also has presence's <b>online status</b>, which
970 * will be reported to remote peer when the subscribe to the account's
971 * presence.
972 *
973 * At least one account MUST be created in the application. If no user
974 * association is required, application can create a userless account by
975 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
976 * instead of a particular user.
977 *
978 * Also one account must be set as the <b>default account</b>, which is used as
979 * the account to use when PJSUA fails to match a request with any other
980 * accounts.
981 *
982 * When sending outgoing SIP requests (such as making calls or sending
983 * instant messages), normally PJSUA requires the application to specify
984 * which account to use for the request. If no account is specified,
985 * PJSUA may be able to select the account by matching the destination
986 * domain name, and fall back to default account when no match is found.
987 */
988
989/**
990 * Maximum accounts.
991 */
992#ifndef PJSUA_MAX_ACC
993# define PJSUA_MAX_ACC 8
994#endif
995
996
997/**
998 * Default registration interval.
999 */
1000#ifndef PJSUA_REG_INTERVAL
1001# define PJSUA_REG_INTERVAL 55
1002#endif
1003
1004
1005/**
1006 * Account configuration.
1007 */
1008typedef struct pjsua_acc_config
1009{
1010 /**
1011 * The full SIP URL for the account. The value can take name address or
1012 * URL format, and will look something like "sip:account@serviceprovider".
1013 *
1014 * This field is mandatory.
1015 */
1016 pj_str_t id;
1017
1018 /**
1019 * This is the URL to be put in the request URI for the registration,
1020 * and will look something like "sip:serviceprovider".
1021 *
1022 * This field should be specified if registration is desired. If the
1023 * value is empty, no account registration will be performed.
1024 */
1025 pj_str_t reg_uri;
1026
1027 /**
1028 * Optional URI to be put as Contact for this account. It is recommended
1029 * that this field is left empty, so that the value will be calculated
1030 * automatically based on the transport address.
1031 */
Benny Prijonob4a17c92006-07-10 14:40:21 +00001032 pj_str_t force_contact;
Benny Prijono312aff92006-06-17 04:08:30 +00001033
1034 /**
1035 * Number of proxies in the proxy array below.
1036 */
1037 unsigned proxy_cnt;
1038
1039 /**
1040 * Optional URI of the proxies to be visited for all outgoing requests
1041 * that are using this account (REGISTER, INVITE, etc). Application need
1042 * to specify these proxies if the service provider requires that requests
1043 * destined towards its network should go through certain proxies first
1044 * (for example, border controllers).
1045 *
1046 * These proxies will be put in the route set for this account, with
1047 * maintaining the orders (the first proxy in the array will be visited
1048 * first).
1049 */
1050 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
1051
1052 /**
1053 * Optional interval for registration, in seconds. If the value is zero,
1054 * default interval will be used (PJSUA_REG_INTERVAL, 55 seconds).
1055 */
1056 unsigned reg_timeout;
1057
1058 /**
1059 * Number of credentials in the credential array.
1060 */
1061 unsigned cred_count;
1062
1063 /**
1064 * Array of credentials. If registration is desired, normally there should
1065 * be at least one credential specified, to successfully authenticate
1066 * against the service provider. More credentials can be specified, for
1067 * example when the requests are expected to be challenged by the
1068 * proxies in the route set.
1069 */
1070 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1071
1072} pjsua_acc_config;
1073
1074
1075/**
1076 * Call this function to initialize account config with default values.
1077 *
1078 * @param cfg The account config to be initialized.
1079 */
1080PJ_INLINE(void) pjsua_acc_config_default(pjsua_acc_config *cfg)
1081{
Benny Prijonoac623b32006-07-03 15:19:31 +00001082 pj_bzero(cfg, sizeof(*cfg));
Benny Prijono312aff92006-06-17 04:08:30 +00001083
1084 cfg->reg_timeout = PJSUA_REG_INTERVAL;
1085}
1086
1087
1088
1089/**
1090 * Account info. Application can query account info by calling
1091 * #pjsua_acc_get_info().
1092 */
1093typedef struct pjsua_acc_info
1094{
1095 /**
1096 * The account ID.
1097 */
1098 pjsua_acc_id id;
1099
1100 /**
1101 * Flag to indicate whether this is the default account.
1102 */
1103 pj_bool_t is_default;
1104
1105 /**
1106 * Account URI
1107 */
1108 pj_str_t acc_uri;
1109
1110 /**
1111 * Flag to tell whether this account has registration setting
1112 * (reg_uri is not empty).
1113 */
1114 pj_bool_t has_registration;
1115
1116 /**
1117 * An up to date expiration interval for account registration session.
1118 */
1119 int expires;
1120
1121 /**
1122 * Last registration status code. If status code is zero, the account
1123 * is currently not registered. Any other value indicates the SIP
1124 * status code of the registration.
1125 */
1126 pjsip_status_code status;
1127
1128 /**
1129 * String describing the registration status.
1130 */
1131 pj_str_t status_text;
1132
1133 /**
1134 * Presence online status for this account.
1135 */
1136 pj_bool_t online_status;
1137
1138 /**
1139 * Buffer that is used internally to store the status text.
1140 */
1141 char buf_[PJ_ERR_MSG_SIZE];
1142
1143} pjsua_acc_info;
1144
1145
1146
1147/**
1148 * Get number of current accounts.
1149 *
1150 * @return Current number of accounts.
1151 */
1152PJ_DECL(unsigned) pjsua_acc_get_count(void);
1153
1154
1155/**
1156 * Check if the specified account ID is valid.
1157 *
1158 * @param acc_id Account ID to check.
1159 *
1160 * @return Non-zero if account ID is valid.
1161 */
1162PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
1163
1164
1165/**
1166 * Add a new account to pjsua. PJSUA must have been initialized (with
1167 * #pjsua_init()) before calling this function.
1168 *
1169 * @param cfg Account configuration.
1170 * @param is_default If non-zero, this account will be set as the default
1171 * account. The default account will be used when sending
1172 * outgoing requests (e.g. making call) when no account is
1173 * specified, and when receiving incoming requests when the
1174 * request does not match any accounts. It is recommended
1175 * that default account is set to local/LAN account.
1176 * @param p_acc_id Pointer to receive account ID of the new account.
1177 *
1178 * @return PJ_SUCCESS on success, or the appropriate error code.
1179 */
1180PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *cfg,
1181 pj_bool_t is_default,
1182 pjsua_acc_id *p_acc_id);
1183
1184
1185/**
1186 * Add a local account. A local account is used to identify local endpoint
1187 * instead of a specific user, and for this reason, a transport ID is needed
1188 * to obtain the local address information.
1189 *
1190 * @param tid Transport ID to generate account address.
1191 * @param is_default If non-zero, this account will be set as the default
1192 * account. The default account will be used when sending
1193 * outgoing requests (e.g. making call) when no account is
1194 * specified, and when receiving incoming requests when the
1195 * request does not match any accounts. It is recommended
1196 * that default account is set to local/LAN account.
1197 * @param p_acc_id Pointer to receive account ID of the new account.
1198 *
1199 * @return PJ_SUCCESS on success, or the appropriate error code.
1200 */
1201PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
1202 pj_bool_t is_default,
1203 pjsua_acc_id *p_acc_id);
1204
1205/**
1206 * Delete account.
1207 *
1208 * @param acc_id Id of the account to be deleted.
1209 *
1210 * @return PJ_SUCCESS on success, or the appropriate error code.
1211 */
1212PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
1213
1214
1215/**
1216 * Modify account information.
1217 *
1218 * @param acc_id Id of the account to be modified.
1219 * @param cfg New account configuration.
1220 *
1221 * @return PJ_SUCCESS on success, or the appropriate error code.
1222 */
1223PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
1224 const pjsua_acc_config *cfg);
1225
1226
1227/**
1228 * Modify account's presence status to be advertised to remote/presence
1229 * subscribers.
1230 *
1231 * @param acc_id The account ID.
1232 * @param is_online True of false.
1233 *
1234 * @return PJ_SUCCESS on success, or the appropriate error code.
1235 */
1236PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
1237 pj_bool_t is_online);
1238
1239
1240/**
1241 * Update registration or perform unregistration.
1242 *
1243 * @param acc_id The account ID.
1244 * @param renew If renew argument is zero, this will start
1245 * unregistration process.
1246 *
1247 * @return PJ_SUCCESS on success, or the appropriate error code.
1248 */
1249PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
1250 pj_bool_t renew);
1251
1252
1253/**
1254 * Get account information.
1255 *
1256 * @param acc_id Account identification.
1257 * @param info Pointer to receive account information.
1258 *
1259 * @return PJ_SUCCESS on success, or the appropriate error code.
1260 */
1261PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
1262 pjsua_acc_info *info);
1263
1264
1265/**
1266 * Enum accounts all account ids.
1267 *
1268 * @param ids Array of account IDs to be initialized.
1269 * @param count In input, specifies the maximum number of elements.
1270 * On return, it contains the actual number of elements.
1271 *
1272 * @return PJ_SUCCESS on success, or the appropriate error code.
1273 */
1274PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
1275 unsigned *count );
1276
1277
1278/**
1279 * Enum accounts info.
1280 *
1281 * @param info Array of account infos to be initialized.
1282 * @param count In input, specifies the maximum number of elements.
1283 * On return, it contains the actual number of elements.
1284 *
1285 * @return PJ_SUCCESS on success, or the appropriate error code.
1286 */
1287PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
1288 unsigned *count );
1289
1290
1291/**
1292 * This is an internal function to find the most appropriate account to
1293 * used to reach to the specified URL.
1294 *
1295 * @param url The remote URL to reach.
1296 *
1297 * @return Account id.
1298 */
1299PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
1300
1301
1302/**
1303 * This is an internal function to find the most appropriate account to be
1304 * used to handle incoming calls.
1305 *
1306 * @param rdata The incoming request message.
1307 *
1308 * @return Account id.
1309 */
1310PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
1311
1312
Benny Prijonoc570f2d2006-07-18 00:33:02 +00001313/**
1314 * Create a suitable URI to be put as Contact based on the specified
1315 * target URI for the specified account.
1316 *
1317 * @param pool Pool to allocate memory for the string.
1318 * @param contact The string where the Contact URI will be stored.
1319 * @param acc_id Account ID.
1320 * @param uri Destination URI of the request.
1321 *
1322 * @return PJ_SUCCESS on success, other on error.
1323 */
1324PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
1325 pj_str_t *contact,
1326 pjsua_acc_id acc_id,
1327 const pj_str_t *uri);
1328
1329
1330
1331/**
1332 * Create a suitable URI to be put as Contact based on the information
1333 * in the incoming request.
1334 *
1335 * @param pool Pool to allocate memory for the string.
1336 * @param contact The string where the Contact URI will be stored.
1337 * @param acc_id Account ID.
1338 * @param rdata Incoming request.
1339 *
1340 * @return PJ_SUCCESS on success, other on error.
1341 */
1342PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
1343 pj_str_t *contact,
1344 pjsua_acc_id acc_id,
1345 pjsip_rx_data *rdata );
1346
1347
Benny Prijono312aff92006-06-17 04:08:30 +00001348
1349/**
1350 * @}
1351 */
1352
1353
1354/*****************************************************************************
1355 * CALLS API
1356 */
1357
1358
1359/**
1360 * @defgroup PJSUA_LIB_CALL Calls
1361 * @ingroup PJSUA_LIB
1362 * @brief Call manipulation.
1363 * @{
1364 */
1365
1366/**
1367 * Max simultaneous calls.
1368 */
1369#ifndef PJSUA_MAX_CALLS
1370# define PJSUA_MAX_CALLS 32
1371#endif
1372
1373
1374
1375/**
1376 * Call media status.
1377 */
1378typedef enum pjsua_call_media_status
1379{
1380 PJSUA_CALL_MEDIA_NONE,
1381 PJSUA_CALL_MEDIA_ACTIVE,
1382 PJSUA_CALL_MEDIA_LOCAL_HOLD,
1383 PJSUA_CALL_MEDIA_REMOTE_HOLD,
1384} pjsua_call_media_status;
1385
1386
1387/**
1388 * Call info.
1389 */
1390typedef struct pjsua_call_info
1391{
1392 /** Call identification. */
1393 pjsua_call_id id;
1394
1395 /** Initial call role (UAC == caller) */
1396 pjsip_role_e role;
1397
1398 /** Local URI */
1399 pj_str_t local_info;
1400
1401 /** Local Contact */
1402 pj_str_t local_contact;
1403
1404 /** Remote URI */
1405 pj_str_t remote_info;
1406
1407 /** Remote contact */
1408 pj_str_t remote_contact;
1409
1410 /** Dialog Call-ID string. */
1411 pj_str_t call_id;
1412
1413 /** Call state */
1414 pjsip_inv_state state;
1415
1416 /** Text describing the state */
1417 pj_str_t state_text;
1418
1419 /** Last status code heard, which can be used as cause code */
1420 pjsip_status_code last_status;
1421
1422 /** The reason phrase describing the status. */
1423 pj_str_t last_status_text;
1424
1425 /** Call media status. */
1426 pjsua_call_media_status media_status;
1427
1428 /** Media direction */
1429 pjmedia_dir media_dir;
1430
1431 /** The conference port number for the call */
1432 pjsua_conf_port_id conf_slot;
1433
1434 /** Up-to-date call connected duration (zero when call is not
1435 * established)
1436 */
1437 pj_time_val connect_duration;
1438
1439 /** Total call duration, including set-up time */
1440 pj_time_val total_duration;
1441
1442 /** Internal */
1443 struct {
1444 char local_info[128];
1445 char local_contact[128];
1446 char remote_info[128];
1447 char remote_contact[128];
1448 char call_id[128];
1449 char last_status_text[128];
1450 } buf_;
1451
1452} pjsua_call_info;
1453
1454
1455
Benny Prijonoa91a0032006-02-26 21:23:45 +00001456/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00001457 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001458 *
1459 * @return Maximum number of calls configured.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001460 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00001461PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001462
1463/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001464 * Get number of currently active calls.
1465 *
1466 * @return Number of currently active calls.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001467 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00001468PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001469
1470/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001471 * Enumerate all active calls.
1472 *
1473 * @param ids Array of account IDs to be initialized.
1474 * @param count In input, specifies the maximum number of elements.
1475 * On return, it contains the actual number of elements.
1476 *
1477 * @return PJ_SUCCESS on success, or the appropriate error code.
1478 */
1479PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
1480 unsigned *count);
1481
1482
1483/**
1484 * Make outgoing call to the specified URI using the specified account.
1485 *
1486 * @param acc_id The account to be used.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001487 * @param dst_uri URI to be put in the To header (normally is the same
1488 * as the target URI).
1489 * @param options Options (must be zero at the moment).
1490 * @param user_data Arbitrary user data to be attached to the call, and
1491 * can be retrieved later.
1492 * @param msg_data Optional headers etc to be added to outgoing INVITE
1493 * request, or NULL if no custom header is desired.
1494 * @param p_call_id Pointer to receive call identification.
1495 *
1496 * @return PJ_SUCCESS on success, or the appropriate error code.
1497 */
1498PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
1499 const pj_str_t *dst_uri,
1500 unsigned options,
1501 void *user_data,
1502 const pjsua_msg_data *msg_data,
1503 pjsua_call_id *p_call_id);
1504
1505
1506/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00001507 * Check if the specified call has active INVITE session and the INVITE
1508 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001509 *
1510 * @param call_id Call identification.
1511 *
1512 * @return Non-zero if call is active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001513 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001514PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001515
1516
1517/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001518 * Check if call has an active media session.
1519 *
1520 * @param call_id Call identification.
1521 *
1522 * @return Non-zero if yes.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001523 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001524PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001525
1526
1527/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001528 * Get the conference port identification associated with the call.
1529 *
1530 * @param call_id Call identification.
1531 *
1532 * @return Conference port ID, or PJSUA_INVALID_ID when the
1533 * media has not been established or is not active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001534 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001535PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
1536
1537/**
1538 * Obtain detail information about the specified call.
1539 *
1540 * @param call_id Call identification.
1541 * @param info Call info to be initialized.
1542 *
1543 * @return PJ_SUCCESS on success, or the appropriate error code.
1544 */
1545PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00001546 pjsua_call_info *info);
1547
1548
1549/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001550 * Attach application specific data to the call.
1551 *
1552 * @param call_id Call identification.
1553 * @param user_data Arbitrary data to be attached to the call.
1554 *
1555 * @return The user data.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001556 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001557PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
1558 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001559
1560
1561/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001562 * Get user data attached to the call.
1563 *
1564 * @param call_id Call identification.
1565 *
1566 * @return The user data.
Benny Prijono268ca612006-02-07 12:34:11 +00001567 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001568PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00001569
1570
1571/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001572 * Send response to incoming INVITE request.
1573 *
1574 * @param call_id Incoming call identification.
1575 * @param code Status code, (100-699).
1576 * @param reason Optional reason phrase. If NULL, default text
1577 * will be used.
1578 * @param msg_data Optional list of headers etc to be added to outgoing
1579 * response message.
1580 *
1581 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoa91a0032006-02-26 21:23:45 +00001582 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001583PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
1584 unsigned code,
1585 const pj_str_t *reason,
1586 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001587
1588/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001589 * Hangup call by using method that is appropriate according to the
1590 * call state.
1591 *
1592 * @param call_id Call identification.
1593 * @param code Optional status code to be sent when we're rejecting
1594 * incoming call. If the value is zero, "603/Decline"
1595 * will be sent.
1596 * @param reason Optional reason phrase to be sent when we're rejecting
1597 * incoming call. If NULL, default text will be used.
1598 * @param msg_data Optional list of headers etc to be added to outgoing
1599 * request/response message.
1600 *
1601 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00001602 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001603PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
1604 unsigned code,
1605 const pj_str_t *reason,
1606 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00001607
1608
1609/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001610 * Put the specified call on hold.
1611 *
1612 * @param call_id Call identification.
1613 * @param msg_data Optional message components to be sent with
1614 * the request.
1615 *
1616 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00001617 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001618PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
1619 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00001620
1621
1622/**
1623 * Send re-INVITE (to release hold).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001624 *
1625 * @param call_id Call identification.
1626 * @param unhold If this argument is non-zero and the call is locally
1627 * held, this will release the local hold.
1628 * @param msg_data Optional message components to be sent with
1629 * the request.
1630 *
1631 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00001632 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001633PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
1634 pj_bool_t unhold,
1635 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00001636
1637
1638/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001639 * Initiate call transfer to the specified address.
1640 *
1641 * @param call_id Call identification.
1642 * @param dest Address of new target to be contacted.
1643 * @param msg_data Optional message components to be sent with
1644 * the request.
1645 *
1646 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00001647 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001648PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
1649 const pj_str_t *dest,
1650 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001651
1652/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001653 * Send DTMF digits to remote using RFC 2833 payload formats.
1654 *
1655 * @param call_id Call identification.
1656 * @param digits DTMF digits to be sent.
1657 *
1658 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001659 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001660PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00001661 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00001662
Benny Prijono26ff9062006-02-21 23:47:00 +00001663/**
Benny Prijonob0808372006-03-02 21:18:58 +00001664 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001665 *
1666 * @param call_id Call identification.
1667 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
1668 * assumed.
1669 * @param content The message content.
1670 * @param msg_data Optional list of headers etc to be included in outgoing
1671 * request. The body descriptor in the msg_data is
1672 * ignored.
1673 * @param user_data Optional user data, which will be given back when
1674 * the IM callback is called.
1675 *
1676 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00001677 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001678PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
1679 const pj_str_t *mime_type,
1680 const pj_str_t *content,
1681 const pjsua_msg_data *msg_data,
1682 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00001683
1684
1685/**
1686 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001687 *
1688 * @param call_id Call identification.
1689 * @param is_typing Non-zero to indicate to remote that local person is
1690 * currently typing an IM.
1691 * @param msg_data Optional list of headers etc to be included in outgoing
1692 * request.
1693 *
1694 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00001695 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001696PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
1697 pj_bool_t is_typing,
1698 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00001699
1700/**
Benny Prijono834aee32006-02-19 01:38:06 +00001701 * Terminate all calls.
1702 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001703PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00001704
1705
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001706/**
1707 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001708 *
1709 * @param call_id Call identification.
1710 * @param with_media Non-zero to include media information too.
1711 * @param buffer Buffer where the statistics are to be written to.
1712 * @param maxlen Maximum length of buffer.
1713 * @param indent Spaces for left indentation.
1714 *
1715 * @return PJ_SUCCESS on success.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001716 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001717PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
1718 pj_bool_t with_media,
1719 char *buffer,
1720 unsigned maxlen,
1721 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001722
Benny Prijono9fc735d2006-05-28 14:58:12 +00001723/**
Benny Prijono312aff92006-06-17 04:08:30 +00001724 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00001725 */
Benny Prijono834aee32006-02-19 01:38:06 +00001726
1727
1728/*****************************************************************************
Benny Prijono312aff92006-06-17 04:08:30 +00001729 * BUDDY API
Benny Prijono834aee32006-02-19 01:38:06 +00001730 */
1731
Benny Prijono312aff92006-06-17 04:08:30 +00001732
1733/**
1734 * @defgroup PJSUA_LIB_BUDDY Buddy, Presence, and Instant Messaging
1735 * @ingroup PJSUA_LIB
1736 * @brief Buddy management, buddy's presence, and instant messaging.
1737 * @{
1738 */
1739
1740/**
1741 * Max buddies in buddy list.
1742 */
1743#ifndef PJSUA_MAX_BUDDIES
1744# define PJSUA_MAX_BUDDIES 256
1745#endif
1746
1747
1748/**
1749 * Buddy configuration.
1750 */
1751typedef struct pjsua_buddy_config
1752{
1753 /**
1754 * Buddy URL or name address.
1755 */
1756 pj_str_t uri;
1757
1758 /**
1759 * Specify whether presence subscription should start immediately.
1760 */
1761 pj_bool_t subscribe;
1762
1763} pjsua_buddy_config;
1764
1765
1766/**
1767 * Buddy's online status.
1768 */
1769typedef enum pjsua_buddy_status
1770{
1771 /**
1772 * Online status is unknown (possibly because no presence subscription
1773 * has been established).
1774 */
1775 PJSUA_BUDDY_STATUS_UNKNOWN,
1776
1777 /**
1778 * Buddy is known to be offline.
1779 */
1780 PJSUA_BUDDY_STATUS_ONLINE,
1781
1782 /**
1783 * Buddy is offline.
1784 */
1785 PJSUA_BUDDY_STATUS_OFFLINE,
1786
1787} pjsua_buddy_status;
1788
1789
1790
1791/**
1792 * Buddy info.
1793 */
1794typedef struct pjsua_buddy_info
1795{
1796 /**
1797 * The buddy ID.
1798 */
1799 pjsua_buddy_id id;
1800
1801 /**
1802 * The full URI of the buddy, as specified in the configuration.
1803 */
1804 pj_str_t uri;
1805
1806 /**
1807 * Buddy's Contact, only available when presence subscription has
1808 * been established to the buddy.
1809 */
1810 pj_str_t contact;
1811
1812 /**
1813 * Buddy's online status.
1814 */
1815 pjsua_buddy_status status;
1816
1817 /**
1818 * Text to describe buddy's online status.
1819 */
1820 pj_str_t status_text;
1821
1822 /**
1823 * Flag to indicate that we should monitor the presence information for
1824 * this buddy (normally yes, unless explicitly disabled).
1825 */
1826 pj_bool_t monitor_pres;
1827
1828 /**
1829 * Internal buffer.
1830 */
1831 char buf_[256];
1832
1833} pjsua_buddy_info;
1834
1835
Benny Prijono834aee32006-02-19 01:38:06 +00001836/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001837 * Get total number of buddies.
1838 *
1839 * @return Number of buddies.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001840 */
1841PJ_DECL(unsigned) pjsua_get_buddy_count(void);
1842
1843
1844/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001845 * Check if buddy ID is valid.
1846 *
1847 * @param buddy_id Buddy ID to check.
1848 *
1849 * @return Non-zero if buddy ID is valid.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001850 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001851PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
1852
1853
1854/**
1855 * Enum buddy IDs.
1856 *
1857 * @param ids Array of ids to be initialized.
1858 * @param count On input, specifies max elements in the array.
1859 * On return, it contains actual number of elements
1860 * that have been initialized.
1861 *
1862 * @return PJ_SUCCESS on success, or the appropriate error code.
1863 */
1864PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
1865 unsigned *count);
1866
1867/**
1868 * Get detailed buddy info.
1869 *
1870 * @param buddy_id The buddy identification.
1871 * @param info Pointer to receive information about buddy.
1872 *
1873 * @return PJ_SUCCESS on success, or the appropriate error code.
1874 */
1875PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00001876 pjsua_buddy_info *info);
1877
1878/**
1879 * Add new buddy.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001880 *
1881 * @param cfg Buddy configuration.
1882 * @param p_buddy_id Pointer to receive buddy ID.
1883 *
1884 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001885 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001886PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *cfg,
1887 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00001888
1889
1890/**
1891 * Delete buddy.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001892 *
1893 * @param buddy_id Buddy identification.
1894 *
1895 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00001896 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001897PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001898
1899
1900/**
1901 * Enable/disable buddy's presence monitoring.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001902 *
1903 * @param buddy_id Buddy identification.
1904 * @param subscribe Specify non-zero to activate presence subscription to
1905 * the specified buddy.
1906 *
1907 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001908 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001909PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
1910 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001911
1912
1913/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001914 * Dump presence subscriptions to log file.
1915 *
1916 * @param verbose Yes or no.
Benny Prijono834aee32006-02-19 01:38:06 +00001917 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001918PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00001919
1920
Benny Prijonob0808372006-03-02 21:18:58 +00001921/**
1922 * The MESSAGE method (defined in pjsua_im.c)
1923 */
1924extern const pjsip_method pjsip_message_method;
1925
1926
Benny Prijonob0808372006-03-02 21:18:58 +00001927
1928/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001929 * Send instant messaging outside dialog, using the specified account for
1930 * route set and authentication.
1931 *
1932 * @param acc_id Account ID to be used to send the request.
1933 * @param to Remote URI.
1934 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
1935 * assumed.
1936 * @param content The message content.
1937 * @param msg_data Optional list of headers etc to be included in outgoing
1938 * request. The body descriptor in the msg_data is
1939 * ignored.
1940 * @param user_data Optional user data, which will be given back when
1941 * the IM callback is called.
1942 *
1943 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00001944 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001945PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
1946 const pj_str_t *to,
1947 const pj_str_t *mime_type,
1948 const pj_str_t *content,
1949 const pjsua_msg_data *msg_data,
1950 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00001951
1952
1953/**
1954 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001955 *
1956 * @param acc_id Account ID to be used to send the request.
1957 * @param to Remote URI.
1958 * @param is_typing If non-zero, it tells remote person that local person
1959 * is currently composing an IM.
1960 * @param msg_data Optional list of headers etc to be added to outgoing
1961 * request.
1962 *
1963 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00001964 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001965PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
1966 const pj_str_t *to,
1967 pj_bool_t is_typing,
1968 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00001969
1970
Benny Prijonof3195072006-02-14 21:15:30 +00001971
Benny Prijono312aff92006-06-17 04:08:30 +00001972/**
1973 * @}
Benny Prijono9fc735d2006-05-28 14:58:12 +00001974 */
1975
Benny Prijono312aff92006-06-17 04:08:30 +00001976
1977/*****************************************************************************
1978 * MEDIA API
1979 */
1980
1981
1982/**
1983 * @defgroup PJSUA_LIB_MEDIA Media
1984 * @ingroup PJSUA_LIB
1985 * @brief Media manipulation.
1986 * @{
1987 *
1988 * PJSUA has rather powerful media features, which are built around the
1989 * PJMEDIA conference bridge. Basically, all media termination (such as
1990 * calls, file players, file recorders, sound device, tone generators, etc)
1991 * are terminated in the conference bridge, and application can manipulate
1992 * the interconnection between these terminations freely. If more than
1993 * one media terminations are terminated in the same slot, the conference
1994 * bridge will mix the signal automatically.
1995 *
1996 * Application connects one media termination/slot to another by calling
1997 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
1998 * media flow from the source termination to the sink termination. For
1999 * example, to stream a WAV file to remote call, application may use
2000 * the following steps:
2001 *
2002 \code
2003
2004 pj_status_t stream_to_call( pjsua_call_id call_id )
2005 {
2006 pjsua_player_id player_id;
2007
2008 status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
2009 if (status != PJ_SUCCESS)
2010 return status;
2011
2012 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
2013 pjsua_call_get_conf_port() );
2014 }
2015 \endcode
2016 *
2017 *
2018 * Other features of PJSUA media:
2019 * - efficient N to M interconnections between media terminations.
2020 * - media termination can be connected to itself to create loopback
2021 * media.
2022 * - the media termination may have different clock rates, and resampling
2023 * will be done automatically by conference bridge.
2024 * - media terminations may also have different frame time; the
2025 * conference bridge will perform the necessary bufferring to adjust
2026 * the difference between terminations.
2027 * - interconnections are removed automatically when media termination
2028 * is removed from the bridge.
2029 * - sound device may be changed even when there are active media
2030 * interconnections.
2031 * - correctly report call's media quality (in #pjsua_call_dump()) from
2032 * RTCP packet exchange.
2033 */
2034
2035/**
2036 * Max ports in the conference bridge.
2037 */
2038#ifndef PJSUA_MAX_CONF_PORTS
2039# define PJSUA_MAX_CONF_PORTS 254
2040#endif
2041
2042
2043
2044/**
2045 * Media configuration.
2046 */
2047struct pjsua_media_config
2048{
2049 /**
2050 * Clock rate to be applied to the conference bridge.
2051 * If value is zero, default clock rate will be used (16KHz).
2052 */
2053 unsigned clock_rate;
2054
2055 /**
2056 * Specify maximum number of media ports to be created in the
2057 * conference bridge. Since all media terminate in the bridge
2058 * (calls, file player, file recorder, etc), the value must be
2059 * large enough to support all of them. However, the larger
2060 * the value, the more computations are performed.
2061 */
2062 unsigned max_media_ports;
2063
2064 /**
2065 * Specify whether the media manager should manage its own
2066 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
2067 * and at least one worker thread will be created too. If no,
2068 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
2069 * and no worker thread is needed.
2070 *
2071 * Normally application would say yes here, unless it wants to
2072 * run everything from a single thread.
2073 */
2074 pj_bool_t has_ioqueue;
2075
2076 /**
2077 * Specify the number of worker threads to handle incoming RTP
2078 * packets. A value of one is recommended for most applications.
2079 */
2080 unsigned thread_cnt;
2081
Benny Prijono0498d902006-06-19 14:49:14 +00002082 /**
2083 * Media quality, 0-10, according to this table:
2084 * 8-10: resampling use large filter,
2085 * 3-7: resampling use small filter,
2086 * 1-2: resampling use linear.
2087 * The media quality also sets speex codec quality/complexity to the
2088 * number.
2089 *
Benny Prijono56315612006-07-18 14:39:40 +00002090 * Default: 5.
Benny Prijono0498d902006-06-19 14:49:14 +00002091 */
2092 unsigned quality;
Benny Prijono0a12f002006-07-26 17:05:39 +00002093
2094 /**
2095 * Specify default ptime.
2096 *
2097 * Default: 0 (codec specific)
2098 */
2099 unsigned ptime;
2100
2101 /**
2102 * Disable VAD?
2103 *
2104 * Default: 0 (no (meaning VAD is enabled))
2105 */
2106 pj_bool_t no_vad;
Benny Prijono312aff92006-06-17 04:08:30 +00002107};
2108
2109
2110/**
2111 * Use this function to initialize media config.
2112 *
2113 * @param cfg The media config to be initialized.
2114 */
2115PJ_INLINE(void) pjsua_media_config_default(pjsua_media_config *cfg)
2116{
Benny Prijonoac623b32006-07-03 15:19:31 +00002117 pj_bzero(cfg, sizeof(*cfg));
Benny Prijono312aff92006-06-17 04:08:30 +00002118
2119 cfg->clock_rate = 16000;
2120 cfg->max_media_ports = 32;
2121 cfg->has_ioqueue = PJ_TRUE;
2122 cfg->thread_cnt = 1;
Benny Prijono56315612006-07-18 14:39:40 +00002123 cfg->quality = 5;
Benny Prijono312aff92006-06-17 04:08:30 +00002124}
2125
2126
2127
2128/**
2129 * Codec config.
2130 */
2131typedef struct pjsua_codec_info
2132{
2133 /**
2134 * Codec unique identification.
2135 */
2136 pj_str_t codec_id;
2137
2138 /**
2139 * Codec priority (integer 0-255).
2140 */
2141 pj_uint8_t priority;
2142
2143 /**
2144 * Internal buffer.
2145 */
2146 char buf_[32];
2147
2148} pjsua_codec_info;
2149
2150
2151/**
2152 * Conference port info.
2153 */
2154typedef struct pjsua_conf_port_info
2155{
2156 /** Conference port number. */
2157 pjsua_conf_port_id slot_id;
2158
2159 /** Port name. */
2160 pj_str_t name;
2161
2162 /** Clock rate. */
2163 unsigned clock_rate;
2164
2165 /** Number of channels. */
2166 unsigned channel_count;
2167
2168 /** Samples per frame */
2169 unsigned samples_per_frame;
2170
2171 /** Bits per sample */
2172 unsigned bits_per_sample;
2173
2174 /** Number of listeners in the array. */
2175 unsigned listener_cnt;
2176
2177 /** Array of listeners (in other words, ports where this port is
2178 * transmitting to.
2179 */
2180 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
2181
2182} pjsua_conf_port_info;
2183
2184
2185/**
2186 * This structure holds information about custom media transport to
2187 * be registered to pjsua.
2188 */
2189typedef struct pjsua_media_transport
2190{
2191 /**
2192 * Media socket information containing the address information
2193 * of the RTP and RTCP socket.
2194 */
2195 pjmedia_sock_info skinfo;
2196
2197 /**
2198 * The media transport instance.
2199 */
2200 pjmedia_transport *transport;
2201
2202} pjsua_media_transport;
2203
2204
2205
2206
Benny Prijono9fc735d2006-05-28 14:58:12 +00002207/**
2208 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002209 *
2210 * @return Maximum number of ports in the conference bridge.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002211 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002212PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002213
2214
2215/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002216 * Get current number of active ports in the bridge.
2217 *
2218 * @return The number.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002219 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002220PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
2221
2222
2223/**
2224 * Enumerate all conference ports.
2225 *
2226 * @param id Array of conference port ID to be initialized.
2227 * @param count On input, specifies max elements in the array.
2228 * On return, it contains actual number of elements
2229 * that have been initialized.
2230 *
2231 * @return PJ_SUCCESS on success, or the appropriate error code.
2232 */
2233PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
2234 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00002235
2236
2237/**
2238 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002239 *
2240 * @param id Port identification.
2241 * @param info Pointer to store the port info.
2242 *
2243 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00002244 */
2245PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id id,
2246 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002247
2248
2249/**
Benny Prijonoe909eac2006-07-27 22:04:56 +00002250 * Add arbitrary media port to PJSUA's conference bridge. Application
2251 * can use this function to add the media port that it creates. For
2252 * media ports that are created by PJSUA-LIB (such as calls, file player,
2253 * or file recorder), PJSUA-LIB will automatically add the port to
2254 * the bridge.
2255 *
2256 * @param pool Pool to use.
2257 * @param port Media port to be added to the bridge.
2258 * @param p_id Optional pointer to receive the conference
2259 * slot id.
2260 *
2261 * @return PJ_SUCCESS on success, or the appropriate error code.
2262 */
2263PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
2264 pjmedia_port *port,
2265 pjsua_conf_port_id *p_id);
2266
2267
2268/**
2269 * Remove arbitrary slot from the conference bridge. Application should only
2270 * call this function if it registered the port manually.
2271 *
2272 * @param id The slot id of the port to be removed.
2273 *
2274 * @return PJ_SUCCESS on success, or the appropriate error code.
2275 */
2276PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id id);
2277
2278
2279/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002280 * Establish unidirectional media flow from souce to sink. One source
2281 * may transmit to multiple destinations/sink. And if multiple
2282 * sources are transmitting to the same sink, the media will be mixed
2283 * together. Source and sink may refer to the same ID, effectively
2284 * looping the media.
2285 *
2286 * If bidirectional media flow is desired, application needs to call
2287 * this function twice, with the second one having the arguments
2288 * reversed.
2289 *
2290 * @param source Port ID of the source media/transmitter.
2291 * @param sink Port ID of the destination media/received.
2292 *
2293 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002294 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002295PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
2296 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002297
2298
2299/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002300 * Disconnect media flow from the source to destination port.
2301 *
2302 * @param source Port ID of the source media/transmitter.
2303 * @param sink Port ID of the destination media/received.
2304 *
2305 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002306 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002307PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
2308 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002309
2310
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002311/*****************************************************************************
2312 * File player.
2313 */
2314
Benny Prijono9fc735d2006-05-28 14:58:12 +00002315/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002316 * Create a file player, and automatically connect this player to
2317 * the conference bridge.
2318 *
2319 * @param filename The filename to be played. Currently only
Benny Prijono312aff92006-06-17 04:08:30 +00002320 * WAV files are supported, and the WAV file MUST be
2321 * formatted as 16bit PCM mono/single channel (any
2322 * clock rate is supported).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002323 * @param options Options (currently zero).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002324 * @param p_id Pointer to receive player ID.
2325 *
2326 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002327 */
2328PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002329 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002330 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002331
2332
2333/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002334 * Get conference port ID associated with player.
2335 *
2336 * @param id The file player ID.
2337 *
2338 * @return Conference port ID associated with this player.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002339 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002340PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002341
2342
2343/**
2344 * Set playback position.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002345 *
2346 * @param id The file player ID.
2347 * @param samples The playback position, in samples. Application can
2348 * specify zero to re-start the playback.
2349 *
2350 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002351 */
2352PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
2353 pj_uint32_t samples);
2354
2355
2356/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002357 * Close the file, remove the player from the bridge, and free
2358 * resources associated with the file player.
2359 *
2360 * @param id The file player ID.
2361 *
2362 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002363 */
2364PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
2365
2366
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002367/*****************************************************************************
2368 * File recorder.
2369 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00002370
2371/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002372 * Create a file recorder, and automatically connect this recorder to
2373 * the conference bridge.
2374 *
2375 * @param filename Output file name.
2376 * @param file_format Specify the file format (currently only WAV is
2377 * supported, so the value MUST be zero).
2378 * @param encoding Specify the encoding to be applied to the file.
2379 * Currently only 16bit raw PCM is supported, so
2380 * the value must be NULL.
2381 * @param max_size Maximum file size. Specify -1 to remove size
2382 * limitation.
2383 * @param options Optional options.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002384 * @param p_id Pointer to receive the recorder instance.
2385 *
2386 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002387 */
2388PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002389 unsigned file_format,
2390 const pj_str_t *encoding,
2391 pj_ssize_t max_size,
2392 unsigned options,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002393 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002394
2395
2396/**
2397 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002398 *
2399 * @param id The recorder ID.
2400 *
2401 * @return Conference port ID associated with this recorder.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002402 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002403PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002404
2405
2406/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002407 * Destroy recorder (this will complete recording).
2408 *
2409 * @param id The recorder 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_recorder_destroy(pjsua_recorder_id id);
2414
2415
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002416/*****************************************************************************
2417 * Sound devices.
2418 */
2419
Benny Prijono9fc735d2006-05-28 14:58:12 +00002420/**
2421 * Enum sound devices.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002422 *
2423 * @param info Array of info to be initialized.
2424 * @param count On input, specifies max elements in the array.
2425 * On return, it contains actual number of elements
2426 * that have been initialized.
2427 *
2428 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002429 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002430PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
2431 unsigned *count);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002432
2433
2434/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002435 * Select or change sound device. Application may call this function at
2436 * any time to replace current sound device.
2437 *
2438 * @param capture_dev Device ID of the capture device.
2439 * @param playback_dev Device ID of the playback device.
2440 *
2441 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002442 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002443PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
2444 int playback_dev);
2445
2446
2447/**
2448 * Set pjsua to use null sound device. The null sound device only provides
2449 * the timing needed by the conference bridge, and will not interract with
2450 * any hardware.
2451 *
2452 * @return PJ_SUCCESS on success, or the appropriate error code.
2453 */
2454PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
2455
2456
Benny Prijonoe909eac2006-07-27 22:04:56 +00002457/**
2458 * Disconnect the main conference bridge from any sound devices, and let
2459 * application connect the bridge to it's own sound device/master port.
2460 *
2461 * @return The port interface of the conference bridge,
2462 * so that application can connect this to it's own
2463 * sound device or master port.
2464 */
2465PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
2466
2467
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002468/*****************************************************************************
2469 * Codecs.
2470 */
2471
2472/**
2473 * Enum all supported codecs in the system.
2474 *
2475 * @param id Array of ID to be initialized.
2476 * @param count On input, specifies max elements in the array.
2477 * On return, it contains actual number of elements
2478 * that have been initialized.
2479 *
2480 * @return PJ_SUCCESS on success, or the appropriate error code.
2481 */
2482PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
2483 unsigned *count );
2484
2485
2486/**
2487 * Change codec priority.
2488 *
2489 * @param id Codec ID.
2490 * @param priority Codec priority, 0-255, where zero means to disable
2491 * the codec.
2492 *
2493 * @return PJ_SUCCESS on success, or the appropriate error code.
2494 */
2495PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *id,
2496 pj_uint8_t priority );
2497
2498
2499/**
2500 * Get codec parameters.
2501 *
2502 * @param id Codec ID.
2503 * @param param Structure to receive codec parameters.
2504 *
2505 * @return PJ_SUCCESS on success, or the appropriate error code.
2506 */
2507PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *id,
2508 pjmedia_codec_param *param );
2509
2510
2511/**
2512 * Set codec parameters.
2513 *
2514 * @param id Codec ID.
2515 * @param param Codec parameter to set.
2516 *
2517 * @return PJ_SUCCESS on success, or the appropriate error code.
2518 */
2519PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *id,
2520 const pjmedia_codec_param *param);
2521
2522
2523
Benny Prijono9fc735d2006-05-28 14:58:12 +00002524
Benny Prijono312aff92006-06-17 04:08:30 +00002525/**
2526 * Create UDP media transports for all the calls. This function creates
2527 * one UDP media transport for each call.
Benny Prijonof3195072006-02-14 21:15:30 +00002528 *
Benny Prijono312aff92006-06-17 04:08:30 +00002529 * @param cfg Media transport configuration. The "port" field in the
2530 * configuration is used as the start port to bind the
2531 * sockets.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002532 *
2533 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonof3195072006-02-14 21:15:30 +00002534 */
Benny Prijono312aff92006-06-17 04:08:30 +00002535PJ_DECL(pj_status_t)
2536pjsua_media_transports_create(const pjsua_transport_config *cfg);
Benny Prijonof3195072006-02-14 21:15:30 +00002537
Benny Prijonodc39fe82006-05-26 12:17:46 +00002538
2539/**
Benny Prijono312aff92006-06-17 04:08:30 +00002540 * Register custom media transports to be used by calls. There must
2541 * enough media transports for all calls.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002542 *
Benny Prijono312aff92006-06-17 04:08:30 +00002543 * @param tp The media transport array.
2544 * @param count Number of elements in the array. This number MUST
2545 * match the number of maximum calls configured when
2546 * pjsua is created.
2547 * @param auto_delete Flag to indicate whether the transports should be
2548 * destroyed when pjsua is shutdown.
2549 *
2550 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00002551 */
Benny Prijono312aff92006-06-17 04:08:30 +00002552PJ_DECL(pj_status_t)
2553pjsua_media_transports_attach( pjsua_media_transport tp[],
2554 unsigned count,
2555 pj_bool_t auto_delete);
Benny Prijonodc39fe82006-05-26 12:17:46 +00002556
2557
Benny Prijono312aff92006-06-17 04:08:30 +00002558/**
2559 * @}
2560 */
2561
Benny Prijonof3195072006-02-14 21:15:30 +00002562
Benny Prijono268ca612006-02-07 12:34:11 +00002563
Benny Prijono1a01ad32006-02-07 21:13:28 +00002564PJ_END_DECL
2565
Benny Prijonof3195072006-02-14 21:15:30 +00002566
Benny Prijono312aff92006-06-17 04:08:30 +00002567/**
2568 * @}
2569 */
2570
2571
Benny Prijono268ca612006-02-07 12:34:11 +00002572#endif /* __PJSUA_H__ */