blob: 65e0cc727115f172436848bbe43c51acc5902934 [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
22/* Include all PJSIP core headers. */
23#include <pjsip.h>
24
25/* Include all PJMEDIA headers. */
26#include <pjmedia.h>
27
Benny Prijono1f9afba2006-02-10 15:57:32 +000028/* Include all PJMEDIA-CODEC headers. */
29#include <pjmedia-codec.h>
30
Benny Prijono268ca612006-02-07 12:34:11 +000031/* Include all PJSIP-UA headers */
32#include <pjsip_ua.h>
33
Benny Prijono834aee32006-02-19 01:38:06 +000034/* Include all PJSIP-SIMPLE headers */
35#include <pjsip_simple.h>
36
Benny Prijono268ca612006-02-07 12:34:11 +000037/* Include all PJLIB-UTIL headers. */
38#include <pjlib-util.h>
39
40/* Include all PJLIB headers. */
41#include <pjlib.h>
42
43
Benny Prijono1a01ad32006-02-07 21:13:28 +000044PJ_BEGIN_DECL
45
Benny Prijono632ce712006-02-09 14:01:40 +000046
Benny Prijonof3195072006-02-14 21:15:30 +000047/**
48 * Max buddies in buddy list.
49 */
Benny Prijonoa91a0032006-02-26 21:23:45 +000050#ifndef PJSUA_MAX_BUDDIES
Benny Prijonodc39fe82006-05-26 12:17:46 +000051# define PJSUA_MAX_BUDDIES 256
Benny Prijonoa91a0032006-02-26 21:23:45 +000052#endif
53
Benny Prijonof3195072006-02-14 21:15:30 +000054
Benny Prijonof04ffdd2006-02-21 00:11:18 +000055/**
56 * Max simultaneous calls.
57 */
Benny Prijonoa91a0032006-02-26 21:23:45 +000058#ifndef PJSUA_MAX_CALLS
Benny Prijonoeebe9af2006-06-13 22:57:13 +000059# define PJSUA_MAX_CALLS 32
60#endif
61
62
63/**
64 * Max ports in the conference bridge.
65 */
66#ifndef PJSUA_MAX_CONF_PORTS
67# define PJSUA_MAX_CONF_PORTS 254
Benny Prijonoa91a0032006-02-26 21:23:45 +000068#endif
69
70
71/**
Benny Prijonoa91a0032006-02-26 21:23:45 +000072 * Maximum accounts.
73 */
74#ifndef PJSUA_MAX_ACC
Benny Prijonoeebe9af2006-06-13 22:57:13 +000075# define PJSUA_MAX_ACC 8
Benny Prijonoa91a0032006-02-26 21:23:45 +000076#endif
77
78
Benny Prijonoeebe9af2006-06-13 22:57:13 +000079/**
80 * Maximum proxies in account.
81 */
82#ifndef PJSUA_ACC_MAX_PROXIES
83# define PJSUA_ACC_MAX_PROXIES 8
84#endif
85
86/**
87 * Default registration interval.
88 */
89#ifndef PJSUA_REG_INTERVAL
90# define PJSUA_REG_INTERVAL 55
91#endif
92
93
94/** Account identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +000095typedef int pjsua_acc_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +000096
97/** Call identification */
98typedef int pjsua_call_id;
99
100/** SIP transport identification */
101typedef int pjsua_transport_id;
102
103/** Buddy identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000104typedef int pjsua_buddy_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000105
106/** File player identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000107typedef int pjsua_player_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000108
109/** File recorder identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000110typedef int pjsua_recorder_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000111
112/** Conference port identification */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000113typedef int pjsua_conf_port_id;
114
115
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000116/** Constant to identify invalid ID for all sorts of IDs. */
117#define PJSUA_INVALID_ID (-1)
118
119
120
Benny Prijonoa91a0032006-02-26 21:23:45 +0000121/**
Benny Prijonodc39fe82006-05-26 12:17:46 +0000122 * Account configuration.
123 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000124typedef struct pjsua_acc_config
Benny Prijonodc39fe82006-05-26 12:17:46 +0000125{
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000126 /**
127 * The full SIP URL for the account. The value can take name address or
128 * URL format, and will look something like "sip:account@serviceprovider".
129 *
130 * This field is mandatory.
131 */
Benny Prijonodc39fe82006-05-26 12:17:46 +0000132 pj_str_t id;
133
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000134 /**
135 * This is the URL to be put in the request URI for the registration,
136 * and will look something like "sip:serviceprovider".
137 *
138 * This field should be specified if registration is desired. If the
139 * value is empty, no account registration will be performed.
140 */
Benny Prijonodc39fe82006-05-26 12:17:46 +0000141 pj_str_t reg_uri;
142
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000143 /**
144 * Optional URI to be put as Contact for this account. It is recommended
145 * that this field is left empty, so that the value will be calculated
146 * automatically based on the transport address.
147 */
Benny Prijonodc39fe82006-05-26 12:17:46 +0000148 pj_str_t contact;
149
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000150 /**
151 * Number of proxies in the proxy array below.
152 */
153 unsigned proxy_cnt;
Benny Prijonodc39fe82006-05-26 12:17:46 +0000154
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000155 /**
156 * Optional URI of the proxies to be visited for all outgoing requests
157 * that are using this account (REGISTER, INVITE, etc). Application need
158 * to specify these proxies if the service provider requires that requests
159 * destined towards its network should go through certain proxies first
160 * (for example, border controllers).
161 *
162 * These proxies will be put in the route set for this account, with
163 * maintaining the orders (the first proxy in the array will be visited
164 * first).
165 */
166 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
Benny Prijonodc39fe82006-05-26 12:17:46 +0000167
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000168 /**
169 * Optional interval for registration, in seconds. If the value is zero,
170 * default interval will be used (PJSUA_REG_INTERVAL, 55 seconds).
171 */
172 unsigned reg_timeout;
173
174 /**
175 * Number of credentials in the credential array.
176 */
Benny Prijonodc39fe82006-05-26 12:17:46 +0000177 unsigned cred_count;
178
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000179 /**
180 * Array of credentials. If registration is desired, normally there should
181 * be at least one credential specified, to successfully authenticate
182 * against the service provider. More credentials can be specified, for
183 * example when the requests are expected to be challenged by the
184 * proxies in the route set.
185 */
186 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
Benny Prijonodc39fe82006-05-26 12:17:46 +0000187
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000188} pjsua_acc_config;
Benny Prijonodc39fe82006-05-26 12:17:46 +0000189
190
191/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000192 * Call this function to initialize account config with default values.
193 *
194 * @param cfg The account config to be initialized.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000195 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000196PJ_INLINE(void) pjsua_acc_config_default(pjsua_acc_config *cfg)
Benny Prijonodc39fe82006-05-26 12:17:46 +0000197{
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000198 pj_memset(cfg, 0, sizeof(*cfg));
Benny Prijonodc39fe82006-05-26 12:17:46 +0000199
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000200 cfg->reg_timeout = PJSUA_REG_INTERVAL;
201}
Benny Prijonodc39fe82006-05-26 12:17:46 +0000202
Benny Prijonodc39fe82006-05-26 12:17:46 +0000203
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000204
205/**
206 * Account info. Application can query account info by calling
207 * #pjsua_acc_get_info().
208 */
209typedef struct pjsua_acc_info
210{
211 /**
212 * The account ID.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000213 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000214 pjsua_acc_id id;
Benny Prijonodc39fe82006-05-26 12:17:46 +0000215
Benny Prijono8b1889b2006-06-06 18:40:40 +0000216 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000217 * Flag to indicate whether this is the default account.
Benny Prijono8b1889b2006-06-06 18:40:40 +0000218 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000219 pj_bool_t is_default;
Benny Prijono8b1889b2006-06-06 18:40:40 +0000220
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000221 /**
222 * Account URI
Benny Prijonodc39fe82006-05-26 12:17:46 +0000223 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000224 pj_str_t acc_uri;
Benny Prijonodc39fe82006-05-26 12:17:46 +0000225
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000226 /**
227 * Flag to tell whether this account has registration setting
228 * (reg_uri is not empty).
229 */
230 pj_bool_t has_registration;
Benny Prijonodc39fe82006-05-26 12:17:46 +0000231
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000232 /**
233 * An up to date expiration interval for account registration session.
234 */
235 int expires;
Benny Prijonob9b32ab2006-06-01 12:28:44 +0000236
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000237 /**
238 * Last registration status code. If status code is zero, the account
239 * is currently not registered. Any other value indicates the SIP
240 * status code of the registration.
241 */
242 pjsip_status_code status;
Benny Prijonob9b32ab2006-06-01 12:28:44 +0000243
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000244 /**
245 * String describing the registration status.
246 */
247 pj_str_t status_text;
248
249 /**
250 * Presence online status for this account.
251 */
252 pj_bool_t online_status;
253
254 /**
255 * Buffer that is used internally to store the status text.
256 */
257 char buf_[PJ_ERR_MSG_SIZE];
258
259} pjsua_acc_info;
260
261
262
263/**
264 * STUN configuration.
265 */
266typedef struct pjsua_stun_config
267{
268 /**
269 * The first STUN server IP address or hostname.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000270 */
271 pj_str_t stun_srv1;
272
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000273 /**
274 * Port number of the first STUN server.
275 * If zero, default STUN port will be used.
276 */
Benny Prijonodc39fe82006-05-26 12:17:46 +0000277 unsigned stun_port1;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000278
279 /**
280 * Optional second STUN server IP address or hostname, for which the
281 * result of the mapping request will be compared to. If the value
282 * is empty, only one STUN server will be used.
283 */
Benny Prijonodc39fe82006-05-26 12:17:46 +0000284 pj_str_t stun_srv2;
285
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000286 /**
287 * Port number of the second STUN server.
288 * If zero, default STUN port will be used.
289 */
Benny Prijonodc39fe82006-05-26 12:17:46 +0000290 unsigned stun_port2;
291
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000292} pjsua_stun_config;
Benny Prijono9fc735d2006-05-28 14:58:12 +0000293
Benny Prijonodc39fe82006-05-26 12:17:46 +0000294
295
296/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000297 * Call this function to initialize STUN config with default values.
298 *
299 * @param cfg The STUN config to be initialized.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000300 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000301PJ_INLINE(void) pjsua_stun_config_default(pjsua_stun_config *cfg)
302{
303 pj_memset(cfg, 0, sizeof(*cfg));
304}
Benny Prijonodc39fe82006-05-26 12:17:46 +0000305
306
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000307/**
308 * Transport configuration for creating UDP transports for both SIP
309 * and media.
310 */
311typedef struct pjsua_transport_config
312{
313 /**
314 * UDP port number to bind locally. This setting MUST be specified
315 * even when default port is desired. If the value is zero, the
316 * transport will be bound to any available port, and application
317 * can query the port by querying the transport info.
318 */
319 unsigned port;
320
321 /**
322 * Optional address where the socket should be bound.
323 */
324 pj_in_addr ip_addr;
325
326 /**
327 * Flag to indicate whether STUN should be used.
328 */
329 pj_bool_t use_stun;
330
331 /**
332 * STUN configuration, must be specified when STUN is used.
333 */
334 pjsua_stun_config stun_config;
335
336} pjsua_transport_config;
337
338
339/**
340 * Call this function to initialize UDP config with default values.
341 *
342 * @param cfg The UDP config to be initialized.
343 */
344PJ_INLINE(void) pjsua_transport_config_default(pjsua_transport_config *cfg)
345{
346 pj_memset(cfg, 0, sizeof(*cfg));
347}
348
349
350/**
351 * Normalize STUN config.
352 */
353PJ_INLINE(void) pjsua_normalize_stun_config( pjsua_stun_config *cfg )
354{
355 if (cfg->stun_srv1.slen) {
356
357 if (cfg->stun_port1 == 0)
358 cfg->stun_port1 = 3478;
359
360 if (cfg->stun_srv2.slen == 0) {
361 cfg->stun_srv2 = cfg->stun_srv1;
362 cfg->stun_port2 = cfg->stun_port1;
363 } else {
364 if (cfg->stun_port2 == 0)
365 cfg->stun_port2 = 3478;
366 }
367
368 } else {
369 cfg->stun_port1 = 0;
370 cfg->stun_srv2.slen = 0;
371 cfg->stun_port2 = 0;
372 }
373}
374
375
376/**
377 * Duplicate transport config.
378 */
379PJ_INLINE(void) pjsua_transport_config_dup(pj_pool_t *pool,
380 pjsua_transport_config *dst,
381 const pjsua_transport_config *src)
382{
383 pj_memcpy(dst, src, sizeof(*src));
384
385 if (src->stun_config.stun_srv1.slen) {
386 pj_strdup_with_null(pool, &dst->stun_config.stun_srv1,
387 &src->stun_config.stun_srv1);
388 }
389
390 if (src->stun_config.stun_srv2.slen) {
391 pj_strdup_with_null(pool, &dst->stun_config.stun_srv2,
392 &src->stun_config.stun_srv2);
393 }
394
395 pjsua_normalize_stun_config(&dst->stun_config);
396}
397
398
399
400/**
401 * Transport info.
402 */
403typedef struct pjsua_transport_info
404{
405 /**
406 * PJSUA transport identification.
407 */
408 pjsua_transport_id id;
409
410 /**
411 * Transport type.
412 */
413 pjsip_transport_type_e type;
414
415 /**
416 * Transport type name.
417 */
418 pj_str_t type_name;
419
420 /**
421 * Transport string info/description.
422 */
423 pj_str_t info;
424
425 /**
426 * Transport flag (see ##pjsip_transport_flags_e).
427 */
428 unsigned flag;
429
430 /**
431 * Local address length.
432 */
433 unsigned addr_len;
434
435 /**
436 * Local/bound address.
437 */
438 pj_sockaddr local_addr;
439
440 /**
441 * Published address (or transport address name).
442 */
443 pjsip_host_port local_name;
444
445 /**
446 * Current number of objects currently referencing this transport.
447 */
448 unsigned usage_count;
449
450
451} pjsua_transport_info;
452
453
454/**
455 * Media configuration.
456 */
457typedef struct pjsua_media_config
458{
459 /**
460 * Clock rate to be applied to the conference bridge.
461 * If value is zero, default clock rate will be used (16KHz).
462 */
463 unsigned clock_rate;
464
465 /**
466 * Specify maximum number of media ports to be created in the
467 * conference bridge. Since all media terminate in the bridge
468 * (calls, file player, file recorder, etc), the value must be
469 * large enough to support all of them. However, the larger
470 * the value, the more computations are performed.
471 */
472 unsigned max_media_ports;
473
474 /**
475 * Specify whether the media manager should manage its own
476 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
477 * and at least one worker thread will be created too. If no,
478 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
479 * and no worker thread is needed.
480 *
481 * Normally application would say yes here, unless it wants to
482 * run everything from a single thread.
483 */
484 pj_bool_t has_ioqueue;
485
486 /**
487 * Specify the number of worker threads to handle incoming RTP
488 * packets. A value of one is recommended for most applications.
489 */
490 unsigned thread_cnt;
491
492
493} pjsua_media_config;
494
495
496/**
497 * Use this function to initialize media config.
498 *
499 * @param cfg The media config to be initialized.
500 */
501PJ_INLINE(void) pjsua_media_config_default(pjsua_media_config *cfg)
502{
503 pj_memset(cfg, 0, sizeof(*cfg));
504
505 cfg->clock_rate = 16000;
506 cfg->max_media_ports = 32;
507 cfg->has_ioqueue = PJ_TRUE;
508 cfg->thread_cnt = 1;
509}
510
511
512
513/**
514 * Logging configuration.
515 */
516typedef struct pjsua_logging_config
517{
518 /**
519 * Log incoming and outgoing SIP message? Yes!
520 */
521 pj_bool_t msg_logging;
522
523 /**
524 * Input verbosity level. Value 5 is reasonable.
525 */
526 unsigned level;
527
528 /**
529 * Verbosity level for console. Value 4 is reasonable.
530 */
531 unsigned console_level;
532
533 /**
534 * Log decoration.
535 */
536 unsigned decor;
537
538 /**
539 * Optional log filename.
540 */
541 pj_str_t log_filename;
542
543 /**
544 * Optional callback function to be called to write log to
545 * application specific device. This function will be called for
546 * log messages on input verbosity level.
547 */
548 void (*cb)(int level, const char *data, pj_size_t len);
549
550
551} pjsua_logging_config;
552
553
554/**
555 * Use this function to initialize logging config.
556 *
557 * @param cfg The logging config to be initialized.
558 */
559PJ_INLINE(void) pjsua_logging_config_default(pjsua_logging_config *cfg)
560{
561 pj_memset(cfg, 0, sizeof(*cfg));
562
563 cfg->msg_logging = PJ_TRUE;
564 cfg->level = 5;
565 cfg->console_level = 4;
566 cfg->decor = PJ_LOG_HAS_SENDER | PJ_LOG_HAS_TIME |
567 PJ_LOG_HAS_MICRO_SEC | PJ_LOG_HAS_NEWLINE;
568}
569
570/**
571 * Use this function to duplicate logging config.
572 *
573 * @param pool Pool to use.
574 * @param dst Destination config.
575 * @param src Source config.
576 */
577PJ_INLINE(void) pjsua_logging_config_dup(pj_pool_t *pool,
578 pjsua_logging_config *dst,
579 const pjsua_logging_config *src)
580{
581 pj_memcpy(dst, src, sizeof(*src));
582 pj_strdup_with_null(pool, &dst->log_filename, &src->log_filename);
583}
584
585
586/**
587 * Buddy configuration.
588 */
589typedef struct pjsua_buddy_config
590{
591 /**
592 * Buddy URL or name address.
593 */
594 pj_str_t uri;
595
596 /**
597 * Specify whether presence subscription should start immediately.
598 */
599 pj_bool_t subscribe;
600
601} pjsua_buddy_config;
602
603
604/**
605 * Buddy's online status.
606 */
607typedef enum pjsua_buddy_status
608{
609 /**
610 * Online status is unknown (possibly because no presence subscription
611 * has been established).
612 */
613 PJSUA_BUDDY_STATUS_UNKNOWN,
614
615 /**
616 * Buddy is known to be offline.
617 */
618 PJSUA_BUDDY_STATUS_ONLINE,
619
620 /**
621 * Buddy is offline.
622 */
623 PJSUA_BUDDY_STATUS_OFFLINE,
624
625} pjsua_buddy_status;
626
627
628
629/**
630 * Buddy info.
631 */
632typedef struct pjsua_buddy_info
633{
634 /**
635 * The buddy ID.
636 */
637 pjsua_buddy_id id;
638
639 /**
640 * The full URI of the buddy, as specified in the configuration.
641 */
642 pj_str_t uri;
643
644 /**
645 * Buddy's Contact, only available when presence subscription has
646 * been established to the buddy.
647 */
648 pj_str_t contact;
649
650 /**
651 * Buddy's online status.
652 */
653 pjsua_buddy_status status;
654
655 /**
656 * Text to describe buddy's online status.
657 */
658 pj_str_t status_text;
659
660 /**
661 * Flag to indicate that we should monitor the presence information for
662 * this buddy (normally yes, unless explicitly disabled).
663 */
664 pj_bool_t monitor_pres;
665
666 /**
667 * Internal buffer.
668 */
669 char buf_[256];
670
671} pjsua_buddy_info;
672
673
674/**
675 * Codec config.
676 */
677typedef struct pjsua_codec_info
678{
679 /**
680 * Codec unique identification.
681 */
682 pj_str_t codec_id;
683
684 /**
685 * Codec priority (integer 0-255).
686 */
687 pj_uint8_t priority;
688
689 /**
690 * Internal buffer.
691 */
692 char buf_[32];
693
694} pjsua_codec_info;
695
Benny Prijonodc39fe82006-05-26 12:17:46 +0000696
697/**
698 * Application callbacks.
699 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000700typedef struct pjsua_callback
Benny Prijonodc39fe82006-05-26 12:17:46 +0000701{
702 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000703 * Notify application when invite state has changed.
704 * Application may then query the call info to get the
705 * detail call states.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000706 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000707 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000708
709 /**
Benny Prijono8b1889b2006-06-06 18:40:40 +0000710 * Notify application on incoming call.
711 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000712 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
Benny Prijono8b1889b2006-06-06 18:40:40 +0000713 pjsip_rx_data *rdata);
714
715 /**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000716 * Notify application when media state in the call has changed.
717 * Normal application would need to implement this callback, e.g.
718 * to connect the call's media to sound device.
719 */
720 void (*on_call_media_state)(pjsua_call_id call_id);
721
722 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000723 * Notify application on call being transfered.
724 * Application can decide to accept/reject transfer request
725 * by setting the code (default is 200). When this callback
726 * is not defined, the default behavior is to accept the
727 * transfer.
728 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000729 void (*on_call_transfered)(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +0000730 const pj_str_t *dst,
731 pjsip_status_code *code);
732
733 /**
734 * Notify application when registration status has changed.
735 * Application may then query the account info to get the
736 * registration details.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000737 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000738 void (*on_reg_state)(pjsua_acc_id acc_id);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000739
740 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000741 * Notify application when the buddy state has changed.
742 * Application may then query the buddy into to get the details.
743 */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000744 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +0000745
746 /**
747 * Notify application on incoming pager (i.e. MESSAGE request).
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000748 * Argument call_id will be -1 if MESSAGE request is not related to an
Benny Prijonodc39fe82006-05-26 12:17:46 +0000749 * existing call.
750 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000751 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
752 const pj_str_t *to, const pj_str_t *contact,
753 const pj_str_t *mime_type, const pj_str_t *body);
754
755 /**
756 * Notify application about the delivery status of outgoing pager
757 * request.
758 *
759 * @param call_id Containts the ID of the call where the IM was
760 * sent, or PJSUA_INVALID_ID if the IM was sent
761 * outside call context.
762 * @param to Destination URI.
763 * @param body Message body.
764 * @param user_data Arbitrary data that was specified when sending
765 * IM message.
766 * @param status Delivery status.
767 * @param reason Delivery status reason.
768 */
769 void (*on_pager_status)(pjsua_call_id call_id,
770 const pj_str_t *to,
771 const pj_str_t *body,
772 void *user_data,
773 pjsip_status_code status,
774 const pj_str_t *reason);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000775
776 /**
Benny Prijono9fc735d2006-05-28 14:58:12 +0000777 * Notify application about typing indication.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000778 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000779 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
780 const pj_str_t *to, const pj_str_t *contact,
781 pj_bool_t is_typing);
Benny Prijonodc39fe82006-05-26 12:17:46 +0000782
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000783} pjsua_callback;
784
785
786
Benny Prijonodc39fe82006-05-26 12:17:46 +0000787
788/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000789 * PJSUA settings.
Benny Prijonodc39fe82006-05-26 12:17:46 +0000790 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000791typedef struct pjsua_config
792{
793
794 /**
795 * Maximum calls to support (default: 4)
796 */
797 unsigned max_calls;
798
799 /**
800 * Number of worker threads. Normally application will want to have at
801 * least one worker thread, unless when it wants to poll the library
802 * periodically, which in this case the worker thread can be set to
803 * zero.
804 */
805 unsigned thread_cnt;
806
807 /**
808 * Number of outbound proxies in the array.
809 */
810 unsigned outbound_proxy_cnt;
811
812 /**
813 * Specify the URL of outbound proxies to visit for all outgoing requests.
814 * The outbound proxies will be used for all accounts, and it will
815 * be used to build the route set for outgoing requests. The final
816 * route set for outgoing requests will consists of the outbound proxies
817 * and the proxy configured in the account.
818 */
819 pj_str_t outbound_proxy[4];
820
821 /**
822 * Number of credentials in the credential array.
823 */
824 unsigned cred_count;
825
826 /**
827 * Array of credentials. These credentials will be used by all accounts,
828 * and can be used to authenticate against outbound proxies.
829 */
830 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
831
832 /**
833 * Application callback.
834 */
835 pjsua_callback cb;
836
837} pjsua_config;
838
839
840/**
841 * Use this function to initialize pjsua config.
842 *
843 * @param cfg pjsua config to be initialized.
844 */
845PJ_INLINE(void) pjsua_config_default(pjsua_config *cfg)
846{
847 pj_memset(cfg, 0, sizeof(*cfg));
848
849 cfg->max_calls = 4;
850 cfg->thread_cnt = 1;
851}
852
853
854/**
855 * Duplicate credential.
856 */
857PJ_INLINE(void) pjsip_cred_dup( pj_pool_t *pool,
858 pjsip_cred_info *dst,
859 const pjsip_cred_info *src)
860{
861 pj_strdup_with_null(pool, &dst->realm, &src->realm);
862 pj_strdup_with_null(pool, &dst->scheme, &src->scheme);
863 pj_strdup_with_null(pool, &dst->username, &src->username);
864 pj_strdup_with_null(pool, &dst->data, &src->data);
865
866}
867
868
869/**
870 * Duplicate pjsua_config.
871 */
872PJ_INLINE(void) pjsua_config_dup(pj_pool_t *pool,
873 pjsua_config *dst,
874 const pjsua_config *src)
875{
876 unsigned i;
877
878 pj_memcpy(dst, src, sizeof(*src));
879
880 for (i=0; i<src->outbound_proxy_cnt; ++i) {
881 pj_strdup_with_null(pool, &dst->outbound_proxy[i],
882 &src->outbound_proxy[i]);
883 }
884
885 for (i=0; i<src->cred_count; ++i) {
886 pjsip_cred_dup(pool, &dst->cred_info[i], &src->cred_info[i]);
887 }
888}
889
890
891/**
892 * Call media status.
893 */
894typedef enum pjsua_call_media_status
895{
896 PJSUA_CALL_MEDIA_NONE,
897 PJSUA_CALL_MEDIA_ACTIVE,
898 PJSUA_CALL_MEDIA_LOCAL_HOLD,
899 PJSUA_CALL_MEDIA_REMOTE_HOLD,
900} pjsua_call_media_status;
Benny Prijonodc39fe82006-05-26 12:17:46 +0000901
902
Benny Prijono9fc735d2006-05-28 14:58:12 +0000903/**
904 * Call info.
905 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000906typedef struct pjsua_call_info
Benny Prijono268ca612006-02-07 12:34:11 +0000907{
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000908 /** Call identification. */
909 pjsua_call_id id;
910
911 /** Initial call role (UAC == caller) */
Benny Prijono9fc735d2006-05-28 14:58:12 +0000912 pjsip_role_e role;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000913
914 /** Local URI */
Benny Prijono9fc735d2006-05-28 14:58:12 +0000915 pj_str_t local_info;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000916
917 /** Local Contact */
918 pj_str_t local_contact;
919
920 /** Remote URI */
Benny Prijono9fc735d2006-05-28 14:58:12 +0000921 pj_str_t remote_info;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000922
923 /** Remote contact */
924 pj_str_t remote_contact;
925
926 /** Dialog Call-ID string. */
927 pj_str_t call_id;
928
929 /** Call state */
Benny Prijono9fc735d2006-05-28 14:58:12 +0000930 pjsip_inv_state state;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000931
932 /** Text describing the state */
Benny Prijono9fc735d2006-05-28 14:58:12 +0000933 pj_str_t state_text;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000934
935 /** Last status code heard, which can be used as cause code */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000936 pjsip_status_code last_status;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000937
938 /** The reason phrase describing the status. */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000939 pj_str_t last_status_text;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000940
941 /** Call media status. */
942 pjsua_call_media_status media_status;
943
944 /** Media direction */
945 pjmedia_dir media_dir;
946
947 /** The conference port number for the call */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000948 pjsua_conf_port_id conf_slot;
Benny Prijono268ca612006-02-07 12:34:11 +0000949
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000950 /** Up-to-date call connected duration (zero when call is not
951 * established)
952 */
953 pj_time_val connect_duration;
954
955 /** Total call duration, including set-up time */
956 pj_time_val total_duration;
957
958 /** Internal */
959 struct {
960 char local_info[128];
961 char local_contact[128];
962 char remote_info[128];
963 char remote_contact[128];
964 char call_id[128];
965 char last_status_text[128];
966 } buf_;
967
968} pjsua_call_info;
Benny Prijono95196582006-02-09 00:13:40 +0000969
Benny Prijono9fc735d2006-05-28 14:58:12 +0000970
Benny Prijono9fc735d2006-05-28 14:58:12 +0000971
972
Benny Prijono8b1889b2006-06-06 18:40:40 +0000973/**
974 * Conference port info.
975 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000976typedef struct pjsua_conf_port_info
Benny Prijono8b1889b2006-06-06 18:40:40 +0000977{
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000978 /** Conference port number. */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000979 pjsua_conf_port_id slot_id;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000980
981 /** Port name. */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000982 pj_str_t name;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000983
984 /** Clock rate. */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000985 unsigned clock_rate;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000986
987 /** Number of channels. */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000988 unsigned channel_count;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000989
990 /** Samples per frame */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000991 unsigned samples_per_frame;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000992
993 /** Bits per sample */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000994 unsigned bits_per_sample;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000995
996 /** Number of listeners in the array. */
Benny Prijono8b1889b2006-06-06 18:40:40 +0000997 unsigned listener_cnt;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000998
999 /** Array of listeners (in other words, ports where this port is
1000 * transmitting to.
1001 */
1002 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
1003
1004} pjsua_conf_port_info;
Benny Prijono95196582006-02-09 00:13:40 +00001005
1006
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001007/**
1008 * This structure holds information about custom media transport to
1009 * be registered to pjsua.
1010 */
1011typedef struct pjsua_media_transport
1012{
1013 /**
1014 * Media socket information containing the address information
1015 * of the RTP and RTCP socket.
1016 */
1017 pjmedia_sock_info skinfo;
1018
1019 /**
1020 * The media transport instance.
1021 */
1022 pjmedia_transport *transport;
1023
1024} pjsua_media_transport;
1025
1026
1027/**
1028 * This structure describes additional information to be sent with
1029 * outgoing SIP message.
1030 */
1031typedef struct pjsua_msg_data
1032{
1033 /**
1034 * Additional message headers as linked list.
1035 */
1036 pjsip_hdr hdr_list;
1037
1038 /**
1039 * MIME type of optional message body.
1040 */
1041 pj_str_t content_type;
1042
1043 /**
1044 * Optional message body.
1045 */
1046 pj_str_t msg_body;
1047
1048} pjsua_msg_data;
1049
1050
1051/**
1052 * Initialize message data.
1053 *
1054 * @param msg_data Message data to be initialized.
1055 */
1056PJ_INLINE(void) pjsua_msg_data_init(pjsua_msg_data *msg_data)
1057{
1058 pj_memset(msg_data, 0, sizeof(*msg_data));
1059 pj_list_init(&msg_data->hdr_list);
1060}
Benny Prijono8b1889b2006-06-06 18:40:40 +00001061
Benny Prijono268ca612006-02-07 12:34:11 +00001062
1063/*****************************************************************************
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001064 * PJSUA Core API
Benny Prijono268ca612006-02-07 12:34:11 +00001065 */
1066
Benny Prijono268ca612006-02-07 12:34:11 +00001067
1068/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001069 * Instantiate pjsua application. Application must call this function before
1070 * calling any other functions, to make sure that the underlying libraries
1071 * are properly initialized. Once this function has returned success,
1072 * application must call pjsua_destroy() before quitting.
1073 *
1074 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00001075 */
1076PJ_DECL(pj_status_t) pjsua_create(void);
1077
1078
1079/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001080 * Initialize pjsua with the specified settings. All the settings are
1081 * optional, and the default values will be used when the config is not
1082 * specified.
Benny Prijonoccf95622006-02-07 18:48:01 +00001083 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001084 * @param ua_cfg User agent configuration.
1085 * @param log_cfg Optional logging configuration.
1086 * @param media_cfg Optional media configuration.
Benny Prijonoccf95622006-02-07 18:48:01 +00001087 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001088 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001089 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001090PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1091 const pjsua_logging_config *log_cfg,
1092 const pjsua_media_config *media_cfg);
Benny Prijono268ca612006-02-07 12:34:11 +00001093
1094
1095/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001096 * Application is recommended to call this function after all initialization
1097 * is done, so that the library can do additional checking set up
1098 * additional
Benny Prijonoccf95622006-02-07 18:48:01 +00001099 *
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001100 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoccf95622006-02-07 18:48:01 +00001101 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001102PJ_DECL(pj_status_t) pjsua_start(void);
Benny Prijonoccf95622006-02-07 18:48:01 +00001103
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001104
Benny Prijonoccf95622006-02-07 18:48:01 +00001105/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001106 * Destroy pjsua. This function must be called once PJSUA is created. To
1107 * make it easier for application, application may call this function
1108 * several times with no danger.
1109 *
1110 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono268ca612006-02-07 12:34:11 +00001111 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001112PJ_DECL(pj_status_t) pjsua_destroy(void);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001113
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001114
Benny Prijono9fc735d2006-05-28 14:58:12 +00001115/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001116 * Poll pjsua for events, and if necessary block the caller thread for
1117 * the specified maximum interval (in miliseconds).
1118 *
1119 * @param msec_timeout Maximum time to wait, in miliseconds.
1120 *
1121 * @return The number of events that have been handled during the
1122 * poll. Negative value indicates error, and application
1123 * can retrieve the error as (err = -return_value).
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001124 */
1125PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1126
1127
1128/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001129 * Create memory pool.
1130 *
1131 * @param name Optional pool name.
1132 * @param size Initial size of the pool.
1133 * @param increment Increment size.
1134 *
1135 * @return The pool, or NULL when there's no memory.
1136 */
1137PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1138 pj_size_t increment);
1139
1140
1141/**
1142 * Application can call this function at any time (after pjsua_create(), of
1143 * course) to change logging settings.
1144 *
1145 * @param c Logging configuration.
1146 *
1147 * @return PJ_SUCCESS on success, or the appropriate error code.
1148 */
1149PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1150
1151
1152/**
1153 * Internal function to get SIP endpoint instance of pjsua, which is
1154 * needed for example to register module, create transports, etc.
1155 * Probably is only valid after #pjsua_init() is called.
1156 *
1157 * @return SIP endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001158 */
1159PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1160
1161/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001162 * Internal function to get media endpoint instance.
1163 * Only valid after #pjsua_init() is called.
1164 *
1165 * @return Media endpoint instance.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001166 */
1167PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1168
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001169
1170/*****************************************************************************
1171 * PJSUA SIP Transport API.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001172 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001173
1174/**
1175 * Create SIP transport.
1176 *
1177 * @param type Transport type.
1178 * @param cfg Transport configuration.
1179 * @param p_id Optional pointer to receive transport ID.
1180 *
1181 * @return PJ_SUCCESS on success, or the appropriate error code.
1182 */
1183PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
1184 const pjsua_transport_config *cfg,
1185 pjsua_transport_id *p_id);
1186
1187/**
1188 * Register transport that has been created by application.
1189 *
1190 * @param tp Transport instance.
1191 * @param p_id Optional pointer to receive transport ID.
1192 *
1193 * @return PJ_SUCCESS on success, or the appropriate error code.
1194 */
1195PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
1196 pjsua_transport_id *p_id);
1197
1198
1199/**
1200 * Enumerate all transports currently created in the system.
1201 *
1202 * @param id Array to receive transport ids.
1203 * @param count In input, specifies the maximum number of elements.
1204 * On return, it contains the actual number of elements.
1205 *
1206 * @return PJ_SUCCESS on success, or the appropriate error code.
1207 */
1208PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
1209 unsigned *count );
1210
1211
1212/**
1213 * Get information about transports.
1214 *
1215 * @param id Transport ID.
1216 * @param info Pointer to receive transport info.
1217 *
1218 * @return PJ_SUCCESS on success, or the appropriate error code.
1219 */
1220PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
1221 pjsua_transport_info *info);
1222
1223
1224/**
1225 * Disable a transport or re-enable it. By default transport is always
1226 * enabled after it is created. Disabling a transport does not necessarily
1227 * close the socket, it will only discard incoming messages and prevent
1228 * the transport from being used to send outgoing messages.
1229 *
1230 * @param id Transport ID.
1231 * @param enabled Non-zero to enable, zero to disable.
1232 *
1233 * @return PJ_SUCCESS on success, or the appropriate error code.
1234 */
1235PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
1236 pj_bool_t enabled);
1237
1238
1239/**
1240 * Close the transport. If transport is forcefully closed, it will be
1241 * immediately closed, and any pending transactions that are using the
1242 * transport may not terminate properly. Otherwise, the system will wait
1243 * until all transactions are closed while preventing new users from
1244 * using the transport, and will close the transport when it is safe to
1245 * do so.
1246 *
1247 * @param id Transport ID.
1248 * @param force Non-zero to immediately close the transport. This
1249 * is not recommended!
1250 *
1251 * @return PJ_SUCCESS on success, or the appropriate error code.
1252 */
1253PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
1254 pj_bool_t force );
Benny Prijono9fc735d2006-05-28 14:58:12 +00001255
Benny Prijonoa91a0032006-02-26 21:23:45 +00001256
1257/*****************************************************************************
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001258 * PJSUA Media Transport.
1259 */
1260
1261/**
1262 * Create UDP media transports for all the calls. This function creates
1263 * one UDP media transport for each call.
1264 *
1265 * @param cfg Media transport configuration. The "port" field in the
1266 * configuration is used as the start port to bind the
1267 * sockets.
1268 *
1269 * @return PJ_SUCCESS on success, or the appropriate error code.
1270 */
1271PJ_DECL(pj_status_t)
1272pjsua_media_transports_create(const pjsua_transport_config *cfg);
1273
1274
1275/**
1276 * Register custom media transports to be used by calls. There must
1277 * enough media transports for all calls.
1278 *
1279 * @param tp The media transport array.
1280 * @param count Number of elements in the array. This number MUST
1281 * match the number of maximum calls configured when
1282 * pjsua is created.
1283 * @param auto_delete Flag to indicate whether the transports should be
1284 * destroyed when pjsua is shutdown.
1285 *
1286 * @return PJ_SUCCESS on success, or the appropriate error code.
1287 */
1288PJ_DECL(pj_status_t)
1289pjsua_media_transports_attach( pjsua_media_transport tp[],
1290 unsigned count,
1291 pj_bool_t auto_delete);
1292
1293
1294
1295/*****************************************************************************
1296 * PJSUA Call API.
Benny Prijonoa91a0032006-02-26 21:23:45 +00001297 */
1298
1299/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00001300 * Get maximum number of calls configured in pjsua.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001301 *
1302 * @return Maximum number of calls configured.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001303 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00001304PJ_DECL(unsigned) pjsua_call_get_max_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001305
1306/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001307 * Get number of currently active calls.
1308 *
1309 * @return Number of currently active calls.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001310 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00001311PJ_DECL(unsigned) pjsua_call_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001312
1313/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001314 * Enumerate all active calls.
1315 *
1316 * @param ids Array of account IDs to be initialized.
1317 * @param count In input, specifies the maximum number of elements.
1318 * On return, it contains the actual number of elements.
1319 *
1320 * @return PJ_SUCCESS on success, or the appropriate error code.
1321 */
1322PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
1323 unsigned *count);
1324
1325
1326/**
1327 * Make outgoing call to the specified URI using the specified account.
1328 *
1329 * @param acc_id The account to be used.
1330 * @param target URI to be put in the request URI.
1331 * @param dst_uri URI to be put in the To header (normally is the same
1332 * as the target URI).
1333 * @param options Options (must be zero at the moment).
1334 * @param user_data Arbitrary user data to be attached to the call, and
1335 * can be retrieved later.
1336 * @param msg_data Optional headers etc to be added to outgoing INVITE
1337 * request, or NULL if no custom header is desired.
1338 * @param p_call_id Pointer to receive call identification.
1339 *
1340 * @return PJ_SUCCESS on success, or the appropriate error code.
1341 */
1342PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
1343 const pj_str_t *dst_uri,
1344 unsigned options,
1345 void *user_data,
1346 const pjsua_msg_data *msg_data,
1347 pjsua_call_id *p_call_id);
1348
1349
1350/**
Benny Prijono9fc735d2006-05-28 14:58:12 +00001351 * Check if the specified call has active INVITE session and the INVITE
1352 * session has not been disconnected.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001353 *
1354 * @param call_id Call identification.
1355 *
1356 * @return Non-zero if call is active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001357 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001358PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001359
1360
1361/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001362 * Check if call has an active media session.
1363 *
1364 * @param call_id Call identification.
1365 *
1366 * @return Non-zero if yes.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001367 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001368PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001369
1370
1371/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001372 * Get the conference port identification associated with the call.
1373 *
1374 * @param call_id Call identification.
1375 *
1376 * @return Conference port ID, or PJSUA_INVALID_ID when the
1377 * media has not been established or is not active.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001378 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001379PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
1380
1381/**
1382 * Obtain detail information about the specified call.
1383 *
1384 * @param call_id Call identification.
1385 * @param info Call info to be initialized.
1386 *
1387 * @return PJ_SUCCESS on success, or the appropriate error code.
1388 */
1389PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00001390 pjsua_call_info *info);
1391
1392
1393/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001394 * Attach application specific data to the call.
1395 *
1396 * @param call_id Call identification.
1397 * @param user_data Arbitrary data to be attached to the call.
1398 *
1399 * @return The user data.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001400 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001401PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
1402 void *user_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001403
1404
1405/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001406 * Get user data attached to the call.
1407 *
1408 * @param call_id Call identification.
1409 *
1410 * @return The user data.
Benny Prijono268ca612006-02-07 12:34:11 +00001411 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001412PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
Benny Prijono84126ab2006-02-09 09:30:09 +00001413
1414
1415/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001416 * Send response to incoming INVITE request.
1417 *
1418 * @param call_id Incoming call identification.
1419 * @param code Status code, (100-699).
1420 * @param reason Optional reason phrase. If NULL, default text
1421 * will be used.
1422 * @param msg_data Optional list of headers etc to be added to outgoing
1423 * response message.
1424 *
1425 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoa91a0032006-02-26 21:23:45 +00001426 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001427PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
1428 unsigned code,
1429 const pj_str_t *reason,
1430 const pjsua_msg_data *msg_data);
Benny Prijonoa91a0032006-02-26 21:23:45 +00001431
1432/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001433 * Hangup call by using method that is appropriate according to the
1434 * call state.
1435 *
1436 * @param call_id Call identification.
1437 * @param code Optional status code to be sent when we're rejecting
1438 * incoming call. If the value is zero, "603/Decline"
1439 * will be sent.
1440 * @param reason Optional reason phrase to be sent when we're rejecting
1441 * incoming call. If NULL, default text will be used.
1442 * @param msg_data Optional list of headers etc to be added to outgoing
1443 * request/response message.
1444 *
1445 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00001446 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001447PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
1448 unsigned code,
1449 const pj_str_t *reason,
1450 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00001451
1452
1453/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001454 * Put the specified call on hold.
1455 *
1456 * @param call_id Call identification.
1457 * @param msg_data Optional message components to be sent with
1458 * the request.
1459 *
1460 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00001461 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001462PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
1463 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00001464
1465
1466/**
1467 * Send re-INVITE (to release hold).
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001468 *
1469 * @param call_id Call identification.
1470 * @param unhold If this argument is non-zero and the call is locally
1471 * held, this will release the local hold.
1472 * @param msg_data Optional message components to be sent with
1473 * the request.
1474 *
1475 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00001476 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001477PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
1478 pj_bool_t unhold,
1479 const pjsua_msg_data *msg_data);
Benny Prijono26ff9062006-02-21 23:47:00 +00001480
1481
1482/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001483 * Initiate call transfer to the specified address.
1484 *
1485 * @param call_id Call identification.
1486 * @param dest Address of new target to be contacted.
1487 * @param msg_data Optional message components to be sent with
1488 * the request.
1489 *
1490 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono26ff9062006-02-21 23:47:00 +00001491 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001492PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
1493 const pj_str_t *dest,
1494 const pjsua_msg_data *msg_data);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001495
1496/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001497 * Send DTMF digits to remote using RFC 2833 payload formats.
1498 *
1499 * @param call_id Call identification.
1500 * @param digits DTMF digits to be sent.
1501 *
1502 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001503 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001504PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00001505 const pj_str_t *digits);
Benny Prijono26ff9062006-02-21 23:47:00 +00001506
Benny Prijono26ff9062006-02-21 23:47:00 +00001507/**
Benny Prijonob0808372006-03-02 21:18:58 +00001508 * Send instant messaging inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001509 *
1510 * @param call_id Call identification.
1511 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
1512 * assumed.
1513 * @param content The message content.
1514 * @param msg_data Optional list of headers etc to be included in outgoing
1515 * request. The body descriptor in the msg_data is
1516 * ignored.
1517 * @param user_data Optional user data, which will be given back when
1518 * the IM callback is called.
1519 *
1520 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00001521 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001522PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
1523 const pj_str_t *mime_type,
1524 const pj_str_t *content,
1525 const pjsua_msg_data *msg_data,
1526 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00001527
1528
1529/**
1530 * Send IM typing indication inside INVITE session.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001531 *
1532 * @param call_id Call identification.
1533 * @param is_typing Non-zero to indicate to remote that local person is
1534 * currently typing an IM.
1535 * @param msg_data Optional list of headers etc to be included in outgoing
1536 * request.
1537 *
1538 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00001539 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001540PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
1541 pj_bool_t is_typing,
1542 const pjsua_msg_data*msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00001543
1544/**
Benny Prijono834aee32006-02-19 01:38:06 +00001545 * Terminate all calls.
1546 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00001547PJ_DECL(void) pjsua_call_hangup_all(void);
Benny Prijono834aee32006-02-19 01:38:06 +00001548
1549
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001550/**
1551 * Dump call and media statistics to string.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001552 *
1553 * @param call_id Call identification.
1554 * @param with_media Non-zero to include media information too.
1555 * @param buffer Buffer where the statistics are to be written to.
1556 * @param maxlen Maximum length of buffer.
1557 * @param indent Spaces for left indentation.
1558 *
1559 * @return PJ_SUCCESS on success.
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001560 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001561PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
1562 pj_bool_t with_media,
1563 char *buffer,
1564 unsigned maxlen,
1565 const char *indent);
Benny Prijonob9b32ab2006-06-01 12:28:44 +00001566
1567
Benny Prijono268ca612006-02-07 12:34:11 +00001568/*****************************************************************************
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001569 * PJSUA Account and Client Registration API.
Benny Prijonoccf95622006-02-07 18:48:01 +00001570 */
1571
Benny Prijono9fc735d2006-05-28 14:58:12 +00001572
1573/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001574 * Get number of current accounts.
1575 *
1576 * @return Current number of accounts.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001577 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001578PJ_DECL(unsigned) pjsua_acc_get_count(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001579
Benny Prijono8b1889b2006-06-06 18:40:40 +00001580
1581/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001582 * Check if the specified account ID is valid.
1583 *
1584 * @param acc_id Account ID to check.
1585 *
1586 * @return Non-zero if account ID is valid.
Benny Prijono8b1889b2006-06-06 18:40:40 +00001587 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001588PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00001589
1590
1591/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001592 * Add a new account to pjsua. PJSUA must have been initialized (with
1593 * #pjsua_init()) before calling this function.
1594 *
1595 * @param cfg Account configuration.
1596 * @param is_default If non-zero, this account will be set as the default
1597 * account. The default account will be used when sending
1598 * outgoing requests (e.g. making call) when no account is
1599 * specified, and when receiving incoming requests when the
1600 * request does not match any accounts. It is recommended
1601 * that default account is set to local/LAN account.
1602 * @param p_acc_id Pointer to receive account ID of the new account.
1603 *
1604 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001605 */
1606PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *cfg,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001607 pj_bool_t is_default,
1608 pjsua_acc_id *p_acc_id);
1609
1610
1611/**
1612 * Add a local account. A local account is used to identify local endpoint
1613 * instead of a specific user, and for this reason, a transport ID is needed
1614 * to obtain the local address information.
1615 *
1616 * @param tid Transport ID to generate account address.
1617 * @param is_default If non-zero, this account will be set as the default
1618 * account. The default account will be used when sending
1619 * outgoing requests (e.g. making call) when no account is
1620 * specified, and when receiving incoming requests when the
1621 * request does not match any accounts. It is recommended
1622 * that default account is set to local/LAN account.
1623 * @param p_acc_id Pointer to receive account ID of the new account.
1624 *
1625 * @return PJ_SUCCESS on success, or the appropriate error code.
1626 */
1627PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
1628 pj_bool_t is_default,
1629 pjsua_acc_id *p_acc_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00001630
1631/**
1632 * Delete account.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001633 *
1634 * @param acc_id Id of the account to be deleted.
1635 *
1636 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00001637 */
1638PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001639
1640
1641/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001642 * Modify account information.
1643 *
1644 * @param acc_id Id of the account to be modified.
1645 * @param cfg New account configuration.
1646 *
1647 * @return PJ_SUCCESS on success, or the appropriate error code.
1648 */
1649PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
1650 const pjsua_acc_config *cfg);
1651
1652
1653/**
1654 * Modify account's presence status to be advertised to remote/presence
1655 * subscribers.
1656 *
1657 * @param acc_id The account ID.
1658 * @param is_online True of false.
1659 *
1660 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001661 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00001662PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00001663 pj_bool_t is_online);
1664
1665
Benny Prijonoccf95622006-02-07 18:48:01 +00001666/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001667 * Update registration or perform unregistration.
1668 *
1669 * @param acc_id The account ID.
1670 * @param renew If renew argument is zero, this will start
1671 * unregistration process.
1672 *
1673 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonoccf95622006-02-07 18:48:01 +00001674 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00001675PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
1676 pj_bool_t renew);
Benny Prijonoccf95622006-02-07 18:48:01 +00001677
1678
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001679/**
1680 * Get account information.
1681 *
1682 * @param acc_id Account identification.
1683 * @param info Pointer to receive account information.
1684 *
1685 * @return PJ_SUCCESS on success, or the appropriate error code.
1686 */
1687PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
1688 pjsua_acc_info *info);
1689
1690
1691/**
1692 * Enum accounts all account ids.
1693 *
1694 * @param ids Array of account IDs to be initialized.
1695 * @param count In input, specifies the maximum number of elements.
1696 * On return, it contains the actual number of elements.
1697 *
1698 * @return PJ_SUCCESS on success, or the appropriate error code.
1699 */
1700PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
1701 unsigned *count );
1702
1703
1704/**
1705 * Enum accounts info.
1706 *
1707 * @param info Array of account infos to be initialized.
1708 * @param count In input, specifies the maximum number of elements.
1709 * On return, it contains the actual number of elements.
1710 *
1711 * @return PJ_SUCCESS on success, or the appropriate error code.
1712 */
1713PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
1714 unsigned *count );
1715
1716
1717/**
1718 * This is an internal function to find the most appropriate account to
1719 * used to reach to the specified URL.
1720 *
1721 * @param url The remote URL to reach.
1722 *
1723 * @return Account id.
1724 */
1725PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
1726
1727
1728/**
1729 * This is an internal function to find the most appropriate account to be
1730 * used to handle incoming calls.
1731 *
1732 * @param rdata The incoming request message.
1733 *
1734 * @return Account id.
1735 */
1736PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
1737
Benny Prijono834aee32006-02-19 01:38:06 +00001738
1739
1740/*****************************************************************************
1741 * PJSUA Presence (pjsua_pres.c)
1742 */
1743
1744/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001745 * Get total number of buddies.
1746 *
1747 * @return Number of buddies.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001748 */
1749PJ_DECL(unsigned) pjsua_get_buddy_count(void);
1750
1751
1752/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001753 * Check if buddy ID is valid.
1754 *
1755 * @param buddy_id Buddy ID to check.
1756 *
1757 * @return Non-zero if buddy ID is valid.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001758 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001759PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
1760
1761
1762/**
1763 * Enum buddy IDs.
1764 *
1765 * @param ids Array of ids to be initialized.
1766 * @param count On input, specifies max elements in the array.
1767 * On return, it contains actual number of elements
1768 * that have been initialized.
1769 *
1770 * @return PJ_SUCCESS on success, or the appropriate error code.
1771 */
1772PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
1773 unsigned *count);
1774
1775/**
1776 * Get detailed buddy info.
1777 *
1778 * @param buddy_id The buddy identification.
1779 * @param info Pointer to receive information about buddy.
1780 *
1781 * @return PJ_SUCCESS on success, or the appropriate error code.
1782 */
1783PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
Benny Prijono9fc735d2006-05-28 14:58:12 +00001784 pjsua_buddy_info *info);
1785
1786/**
1787 * Add new buddy.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001788 *
1789 * @param cfg Buddy configuration.
1790 * @param p_buddy_id Pointer to receive buddy ID.
1791 *
1792 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001793 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001794PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *cfg,
1795 pjsua_buddy_id *p_buddy_id);
Benny Prijono8b1889b2006-06-06 18:40:40 +00001796
1797
1798/**
1799 * Delete buddy.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001800 *
1801 * @param buddy_id Buddy identification.
1802 *
1803 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00001804 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001805PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001806
1807
1808/**
1809 * Enable/disable buddy's presence monitoring.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001810 *
1811 * @param buddy_id Buddy identification.
1812 * @param subscribe Specify non-zero to activate presence subscription to
1813 * the specified buddy.
1814 *
1815 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001816 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001817PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
1818 pj_bool_t subscribe);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001819
1820
1821/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001822 * Dump presence subscriptions to log file.
1823 *
1824 * @param verbose Yes or no.
Benny Prijono834aee32006-02-19 01:38:06 +00001825 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001826PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
Benny Prijono834aee32006-02-19 01:38:06 +00001827
1828
Benny Prijonoccf95622006-02-07 18:48:01 +00001829/*****************************************************************************
Benny Prijonob0808372006-03-02 21:18:58 +00001830 * PJSUA Instant Messaging (pjsua_im.c)
1831 */
1832
1833/**
1834 * The MESSAGE method (defined in pjsua_im.c)
1835 */
1836extern const pjsip_method pjsip_message_method;
1837
1838
Benny Prijonob0808372006-03-02 21:18:58 +00001839
1840/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001841 * Send instant messaging outside dialog, using the specified account for
1842 * route set and authentication.
1843 *
1844 * @param acc_id Account ID to be used to send the request.
1845 * @param to Remote URI.
1846 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
1847 * assumed.
1848 * @param content The message content.
1849 * @param msg_data Optional list of headers etc to be included in outgoing
1850 * request. The body descriptor in the msg_data is
1851 * ignored.
1852 * @param user_data Optional user data, which will be given back when
1853 * the IM callback is called.
1854 *
1855 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00001856 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001857PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
1858 const pj_str_t *to,
1859 const pj_str_t *mime_type,
1860 const pj_str_t *content,
1861 const pjsua_msg_data *msg_data,
1862 void *user_data);
Benny Prijonob0808372006-03-02 21:18:58 +00001863
1864
1865/**
1866 * Send typing indication outside dialog.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001867 *
1868 * @param acc_id Account ID to be used to send the request.
1869 * @param to Remote URI.
1870 * @param is_typing If non-zero, it tells remote person that local person
1871 * is currently composing an IM.
1872 * @param msg_data Optional list of headers etc to be added to outgoing
1873 * request.
1874 *
1875 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonob0808372006-03-02 21:18:58 +00001876 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001877PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
1878 const pj_str_t *to,
1879 pj_bool_t is_typing,
1880 const pjsua_msg_data *msg_data);
Benny Prijonob0808372006-03-02 21:18:58 +00001881
1882
Benny Prijonof3195072006-02-14 21:15:30 +00001883
1884/*****************************************************************************
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001885 * Conference bridge manipulation.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001886 */
1887
1888/**
1889 * Get maxinum number of conference ports.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001890 *
1891 * @return Maximum number of ports in the conference bridge.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001892 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001893PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001894
1895
1896/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001897 * Get current number of active ports in the bridge.
1898 *
1899 * @return The number.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001900 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001901PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
1902
1903
1904/**
1905 * Enumerate all conference ports.
1906 *
1907 * @param id Array of conference port ID to be initialized.
1908 * @param count On input, specifies max elements in the array.
1909 * On return, it contains actual number of elements
1910 * that have been initialized.
1911 *
1912 * @return PJ_SUCCESS on success, or the appropriate error code.
1913 */
1914PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
1915 unsigned *count);
Benny Prijono8b1889b2006-06-06 18:40:40 +00001916
1917
1918/**
1919 * Get information about the specified conference port
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001920 *
1921 * @param id Port identification.
1922 * @param info Pointer to store the port info.
1923 *
1924 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono8b1889b2006-06-06 18:40:40 +00001925 */
1926PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id id,
1927 pjsua_conf_port_info *info);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001928
1929
1930/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001931 * Establish unidirectional media flow from souce to sink. One source
1932 * may transmit to multiple destinations/sink. And if multiple
1933 * sources are transmitting to the same sink, the media will be mixed
1934 * together. Source and sink may refer to the same ID, effectively
1935 * looping the media.
1936 *
1937 * If bidirectional media flow is desired, application needs to call
1938 * this function twice, with the second one having the arguments
1939 * reversed.
1940 *
1941 * @param source Port ID of the source media/transmitter.
1942 * @param sink Port ID of the destination media/received.
1943 *
1944 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001945 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001946PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
1947 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001948
1949
1950/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001951 * Disconnect media flow from the source to destination port.
1952 *
1953 * @param source Port ID of the source media/transmitter.
1954 * @param sink Port ID of the destination media/received.
1955 *
1956 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001957 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001958PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
1959 pjsua_conf_port_id sink);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001960
1961
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001962/*****************************************************************************
1963 * File player.
1964 */
1965
Benny Prijono9fc735d2006-05-28 14:58:12 +00001966/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001967 * Create a file player, and automatically connect this player to
1968 * the conference bridge.
1969 *
1970 * @param filename The filename to be played. Currently only
1971 * WAV files are supported.
1972 * @param options Options (currently zero).
1973 * @param user_data Arbitrary user data to be associated with the player.
1974 * @param p_id Pointer to receive player ID.
1975 *
1976 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001977 */
1978PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001979 unsigned options,
1980 void *user_data,
1981 pjsua_player_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001982
1983
1984/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001985 * Get conference port ID associated with player.
1986 *
1987 * @param id The file player ID.
1988 *
1989 * @return Conference port ID associated with this player.
Benny Prijono9fc735d2006-05-28 14:58:12 +00001990 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00001991PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00001992
1993
1994/**
1995 * Set playback position.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001996 *
1997 * @param id The file player ID.
1998 * @param samples The playback position, in samples. Application can
1999 * specify zero to re-start the playback.
2000 *
2001 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002002 */
2003PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
2004 pj_uint32_t samples);
2005
2006
2007/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002008 * Close the file, remove the player from the bridge, and free
2009 * resources associated with the file player.
2010 *
2011 * @param id The file player ID.
2012 *
2013 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002014 */
2015PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
2016
2017
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002018/*****************************************************************************
2019 * File recorder.
2020 */
Benny Prijono9fc735d2006-05-28 14:58:12 +00002021
2022/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002023 * Create a file recorder, and automatically connect this recorder to
2024 * the conference bridge.
2025 *
2026 * @param filename Output file name.
2027 * @param file_format Specify the file format (currently only WAV is
2028 * supported, so the value MUST be zero).
2029 * @param encoding Specify the encoding to be applied to the file.
2030 * Currently only 16bit raw PCM is supported, so
2031 * the value must be NULL.
2032 * @param max_size Maximum file size. Specify -1 to remove size
2033 * limitation.
2034 * @param options Optional options.
2035 * @param user_data Arbitrary user data which will be given in the
2036 * callback once the recording complete.
2037 * @param p_id Pointer to receive the recorder instance.
2038 *
2039 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002040 */
2041PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002042 unsigned file_format,
2043 const pj_str_t *encoding,
2044 pj_ssize_t max_size,
2045 unsigned options,
2046 void *user_data,
2047 pjsua_recorder_id *p_id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002048
2049
2050/**
2051 * Get conference port associated with recorder.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002052 *
2053 * @param id The recorder ID.
2054 *
2055 * @return Conference port ID associated with this recorder.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002056 */
Benny Prijono8b1889b2006-06-06 18:40:40 +00002057PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002058
2059
2060/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002061 * Destroy recorder (this will complete recording).
2062 *
2063 * @param id The recorder ID.
2064 *
2065 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002066 */
2067PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
2068
2069
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002070/*****************************************************************************
2071 * Sound devices.
2072 */
2073
Benny Prijono9fc735d2006-05-28 14:58:12 +00002074/**
2075 * Enum sound devices.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002076 *
2077 * @param info Array of info to be initialized.
2078 * @param count On input, specifies max elements in the array.
2079 * On return, it contains actual number of elements
2080 * that have been initialized.
2081 *
2082 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002083 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002084PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
2085 unsigned *count);
Benny Prijono9fc735d2006-05-28 14:58:12 +00002086
2087
2088/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002089 * Select or change sound device. Application may call this function at
2090 * any time to replace current sound device.
2091 *
2092 * @param capture_dev Device ID of the capture device.
2093 * @param playback_dev Device ID of the playback device.
2094 *
2095 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijono9fc735d2006-05-28 14:58:12 +00002096 */
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002097PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
2098 int playback_dev);
2099
2100
2101/**
2102 * Set pjsua to use null sound device. The null sound device only provides
2103 * the timing needed by the conference bridge, and will not interract with
2104 * any hardware.
2105 *
2106 * @return PJ_SUCCESS on success, or the appropriate error code.
2107 */
2108PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
2109
2110
2111/*****************************************************************************
2112 * Codecs.
2113 */
2114
2115/**
2116 * Enum all supported codecs in the system.
2117 *
2118 * @param id Array of ID to be initialized.
2119 * @param count On input, specifies max elements in the array.
2120 * On return, it contains actual number of elements
2121 * that have been initialized.
2122 *
2123 * @return PJ_SUCCESS on success, or the appropriate error code.
2124 */
2125PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
2126 unsigned *count );
2127
2128
2129/**
2130 * Change codec priority.
2131 *
2132 * @param id Codec ID.
2133 * @param priority Codec priority, 0-255, where zero means to disable
2134 * the codec.
2135 *
2136 * @return PJ_SUCCESS on success, or the appropriate error code.
2137 */
2138PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *id,
2139 pj_uint8_t priority );
2140
2141
2142/**
2143 * Get codec parameters.
2144 *
2145 * @param id Codec ID.
2146 * @param param Structure to receive codec parameters.
2147 *
2148 * @return PJ_SUCCESS on success, or the appropriate error code.
2149 */
2150PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *id,
2151 pjmedia_codec_param *param );
2152
2153
2154/**
2155 * Set codec parameters.
2156 *
2157 * @param id Codec ID.
2158 * @param param Codec parameter to set.
2159 *
2160 * @return PJ_SUCCESS on success, or the appropriate error code.
2161 */
2162PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *id,
2163 const pjmedia_codec_param *param);
2164
2165
2166
Benny Prijono9fc735d2006-05-28 14:58:12 +00002167
2168
2169/*****************************************************************************
Benny Prijonof3195072006-02-14 21:15:30 +00002170 * Utilities.
2171 *
2172 */
2173
Benny Prijonof3195072006-02-14 21:15:30 +00002174/*
2175 * Verify that valid SIP url is given.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002176 *
2177 * @param c_url The URL, as NULL terminated string.
2178 *
2179 * @return PJ_SUCCESS on success, or the appropriate error code.
Benny Prijonof3195072006-02-14 21:15:30 +00002180 */
Benny Prijonodc39fe82006-05-26 12:17:46 +00002181PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *c_url);
Benny Prijonof3195072006-02-14 21:15:30 +00002182
Benny Prijonodc39fe82006-05-26 12:17:46 +00002183
2184/**
2185 * Display error message for the specified error code.
Benny Prijonoeebe9af2006-06-13 22:57:13 +00002186 *
2187 * @param sender The log sender field.
2188 * @param title Message title for the error.
2189 * @param status Status code.
Benny Prijonodc39fe82006-05-26 12:17:46 +00002190 */
2191PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
2192 pj_status_t status);
2193
2194
Benny Prijonof3195072006-02-14 21:15:30 +00002195
Benny Prijono268ca612006-02-07 12:34:11 +00002196
Benny Prijono1a01ad32006-02-07 21:13:28 +00002197PJ_END_DECL
2198
Benny Prijonof3195072006-02-14 21:15:30 +00002199
Benny Prijono268ca612006-02-07 12:34:11 +00002200#endif /* __PJSUA_H__ */