Debian Codegraph @

Xpjproject/pjsip/include/pjsua-lib/pjsua.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <[email protected]>
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 /**
23 * @file pjsua.h
24 * @brief PJSUA API.
25 */
26
27
28 /* Include all PJSIP core headers. */
29 #include <pjsip.h>
30
31 /* Include all PJMEDIA headers. */
32 #include <pjmedia.h>
33
34 /* Include all PJMEDIA-CODEC headers. */
35 #include <pjmedia-codec.h>
36
37 /* Videodev too */
38 #include <pjmedia_videodev.h>
39
40 /* Include all PJSIP-UA headers */
41 #include <pjsip_ua.h>
42
43 /* Include all PJSIP-SIMPLE headers */
44 #include <pjsip_simple.h>
45
46 /* Include all PJNATH headers */
47 #include <pjnath.h>
48
49 /* Include all PJLIB-UTIL headers. */
50 #include <pjlib-util.h>
51
52 /* Include all PJLIB headers. */
53 #include <pjlib.h>
54
55
56 PJ_BEGIN_DECL
57
58
59 /**
60 * @defgroup PJSUA_LIB PJSUA API - High Level Softphone API
61 * @brief Very high level API for constructing SIP UA applications.
62 * @{
63 *
64 * @section pjsua_api_intro A SIP User Agent API for C/C++
65 *
66 * PJSUA API is very high level API for constructing SIP multimedia user agent
67 * applications. It wraps together the signaling and media functionalities
68 * into an easy to use call API, provides account management, buddy
69 * management, presence, instant messaging, along with multimedia
70 * features such as conferencing, file streaming, local playback,
71 * voice recording, and so on.
72 *
73 * @subsection pjsua_for_c_cpp C/C++ Binding
74 * Application must link with <b>pjsua-lib</b> to use this API. In addition,
75 * this library depends on the following libraries:
76 * - <b>pjsip-ua</b>,
77 * - <b>pjsip-simple</b>,
78 * - <b>pjsip-core</b>,
79 * - <b>pjmedia</b>,
80 * - <b>pjmedia-codec</b>,
81 * - <b>pjlib-util</b>, and
82 * - <b>pjlib</b>,
83 *
84 * so application must also link with these libraries as well. For more
85 * information, please refer to
86 * <A HREF="http://www.pjsip.org/using.htm">Getting Started with PJSIP</A>
87 * page.
88 *
89 * @section pjsua_samples
90 *
91 * Few samples are provided:
92 *
93 - Simple pjsua app: \src{pjsip-apps/src/samples/simple_pjsua.c} \n
94 Very simple SIP User Agent with registration, call, and media, using
95 PJSUA-API, all in under 200 lines of code.
96
97 - Pjsua app: \srcdir{pjsip-apps/src/pjsua/} \n
98 This is the reference implementation for PJSIP and PJMEDIA.
99 PJSUA is a console based application, designed to be simple enough
100 to be readble, but powerful enough to demonstrate all features
101 available in PJSIP and PJMEDIA.\n
102
103 * @section root_using_pjsua_lib Using PJSUA API
104 *
105 * Please refer to @ref PJSUA_LIB_BASE on how to create and initialize the API.
106 * And then see the Modules on the bottom of this page for more information
107 * about specific subject.
108 */
109
110
111
112 /*****************************************************************************
113 * BASE API
114 */
115
116 /**
117 * @defgroup PJSUA_LIB_BASE PJSUA-API Basic API
118 * @ingroup PJSUA_LIB
119 * @brief Basic application creation/initialization, logging configuration, etc.
120 * @{
121 *
122 * The base PJSUA API controls PJSUA creation, initialization, and startup, and
123 * also provides various auxiliary functions.
124 *
125 * @section using_pjsua_lib Using PJSUA Library
126 *
127 * @subsection creating_pjsua_lib Creating PJSUA
128 *
129 * Before anything else, application must create PJSUA by calling
130 * #pjsua_create().
131 * This, among other things, will initialize PJLIB, which is crucial before
132 * any PJLIB functions can be called, PJLIB-UTIL, and create a SIP endpoint.
133 *
134 * After this function is called, application can create a memory pool (with
135 * #pjsua_pool_create()) and read configurations from command line or file to
136 * build the settings to initialize PJSUA below.
137 *
138 * @subsection init_pjsua_lib Initializing PJSUA
139 *
140 * After PJSUA is created, application can initialize PJSUA by calling
141 * #pjsua_init(). This function takes several optional configuration settings
142 * in the argument, if application wants to set them.
143 *
144 * @subsubsection init_pjsua_lib_c_cpp PJSUA-LIB Initialization (in C)
145 * Sample code to initialize PJSUA in C code:
146 \code
147
148 #include <pjsua-lib/pjsua.h>
149
150 #define THIS_FILE __FILE__
151
152 static pj_status_t app_init(void)
153 {
154 pjsua_config ua_cfg;
155 pjsua_logging_config log_cfg;
156 pjsua_media_config media_cfg;
157 pj_status_t status;
158
159 // Must create pjsua before anything else!
160 status = pjsua_create();
161 if (status != PJ_SUCCESS) {
162 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
163 return status;
164 }
165
166 // Initialize configs with default settings.
167 pjsua_config_default(&ua_cfg);
168 pjsua_logging_config_default(&log_cfg);
169 pjsua_media_config_default(&media_cfg);
170
171 // At the very least, application would want to override
172 // the call callbacks in pjsua_config:
173 ua_cfg.cb.on_incoming_call = ...
174 ua_cfg.cb.on_call_state = ..
175 ...
176
177 // Customize other settings (or initialize them from application specific
178 // configuration file):
179 ...
180
181 // Initialize pjsua
182 status = pjsua_init(&ua_cfg, &log_cfg, &media_cfg);
183 if (status != PJ_SUCCESS) {
184 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
185 return status;
186 }
187 .
188 ...
189 }
190 \endcode
191 *
192 *
193
194
195 * @subsection other_init_pjsua_lib Other Initialization
196 *
197 * After PJSUA is initialized with #pjsua_init(), application will normally
198 * need/want to perform the following tasks:
199 *
200 * - create SIP transport with #pjsua_transport_create(). Application would
201 * to call #pjsua_transport_create() for each transport types that it
202 * wants to support (for example, UDP, TCP, and TLS). Please see
203 * @ref PJSUA_LIB_TRANSPORT section for more info.
204 * - create one or more SIP accounts with #pjsua_acc_add() or
205 * #pjsua_acc_add_local(). The SIP account is used for registering with
206 * the SIP server, if any. Please see @ref PJSUA_LIB_ACC for more info.
207 * - add one or more buddies with #pjsua_buddy_add(). Please see
208 * @ref PJSUA_LIB_BUDDY section for more info.
209 * - optionally configure the sound device, codec settings, and other
210 * media settings. Please see @ref PJSUA_LIB_MEDIA for more info.
211 *
212 *
213 * @subsection starting_pjsua_lib Starting PJSUA
214 *
215 * After all initializations have been done, application must call
216 * #pjsua_start() to start PJSUA. This function will check that all settings
217 * have been properly configured, and apply default settings when they haven't,
218 * or report error status when it is unable to recover from missing settings.
219 *
220 * Most settings can be changed during run-time. For example, application
221 * may add, modify, or delete accounts, buddies, or change media settings
222 * during run-time.
223 *
224 * @subsubsection starting_pjsua_lib_c C Example for Starting PJSUA
225 * Sample code:
226 \code
227 static pj_status_t app_run(void)
228 {
229 pj_status_t status;
230
231 // Start pjsua
232 status = pjsua_start();
233 if (status != PJ_SUCCESS) {
234 pjsua_destroy();
235 pjsua_perror(THIS_FILE, "Error starting pjsua", status);
236 return status;
237 }
238
239 // Run application loop
240 while (1) {
241 char choice[10];
242
243 printf("Select menu: ");
244 fgets(choice, sizeof(choice), stdin);
245 ...
246 }
247 }
248 \endcode
249
250 */
251
252 /** Constant to identify invalid ID for all sorts of IDs. */
253 enum pjsua_invalid_id_const_
254 {
255 PJSUA_INVALID_ID = -1
256 };
257
258 /** Disabled features temporarily for media reorganization */
259 #define DISABLED_FOR_TICKET_1185 0
260
261 /** Call identification */
262 typedef int pjsua_call_id;
263
264 /** Account identification */
265 typedef int pjsua_acc_id;
266
267 /** Buddy identification */
268 typedef int pjsua_buddy_id;
269
270 /** File player identification */
271 typedef int pjsua_player_id;
272
273 /** File recorder identification */
274 typedef int pjsua_recorder_id;
275
276 /** AVI player identification */
277 typedef int pjsua_avi_player_id;
278
279 /** AVI recorder identification */
280 typedef int pjsua_avi_rec_id;
281
282 /** Conference port identification */
283 typedef int pjsua_conf_port_id;
284
285 /** Opaque declaration for server side presence subscription */
286 typedef struct pjsua_srv_pres pjsua_srv_pres;
287
288 /** Forward declaration for pjsua_msg_data */
289 typedef struct pjsua_msg_data pjsua_msg_data;
290
291 /** Forward declaration for pj_stun_resolve_result */
292 typedef struct pj_stun_resolve_result pj_stun_resolve_result;
293
294 /**
295 * Initial memory block for PJSUA.
296 */
297 #ifndef PJSUA_POOL_LEN
298 # define PJSUA_POOL_LEN 1000
299 #endif
300
301 /**
302 * Memory increment for PJSUA.
303 */
304 #ifndef PJSUA_POOL_INC
305 # define PJSUA_POOL_INC 1000
306 #endif
307
308 /**
309 * Initial memory block for PJSUA account.
310 */
311 #ifndef PJSUA_POOL_LEN_ACC
312 # define PJSUA_POOL_LEN_ACC 512
313 #endif
314
315 /**
316 * Memory increment for PJSUA account.
317 */
318 #ifndef PJSUA_POOL_INC_ACC
319 # define PJSUA_POOL_INC_ACC 256
320 #endif
321
322 /**
323 * Maximum proxies in account.
324 */
325 #ifndef PJSUA_ACC_MAX_PROXIES
326 # define PJSUA_ACC_MAX_PROXIES 8
327 #endif
328
329 /**
330 * Default value of SRTP mode usage. Valid values are PJMEDIA_SRTP_DISABLED,
331 * PJMEDIA_SRTP_OPTIONAL, and PJMEDIA_SRTP_MANDATORY.
332 */
333 #ifndef PJSUA_DEFAULT_USE_SRTP
334 #define PJSUA_DEFAULT_USE_SRTP PJMEDIA_SRTP_DISABLED
335 #endif
336
337 /**
338 * Default value of secure signaling requirement for SRTP.
339 * Valid values are:
340 * 0: SRTP does not require secure signaling
341 * 1: SRTP requires secure transport such as TLS
342 * 2: SRTP requires secure end-to-end transport (SIPS)
343 */
344 #ifndef PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
345 #define PJSUA_DEFAULT_SRTP_SECURE_SIGNALING 1
346 #endif
347
348 /**
349 * Controls whether PJSUA-LIB should add ICE media feature tag
350 * parameter (the ";+sip.ice" parameter) to Contact header if ICE
351 * is enabled in the config.
352 *
353 * Default: 1
354 */
355 #ifndef PJSUA_ADD_ICE_TAGS
356 # define PJSUA_ADD_ICE_TAGS 1
357 #endif
358
359 /**
360 * Timeout value used to acquire mutex lock on a particular call.
361 *
362 * Default: 2000 ms
363 */
364 #ifndef PJSUA_ACQUIRE_CALL_TIMEOUT
365 # define PJSUA_ACQUIRE_CALL_TIMEOUT 2000
366 #endif
367
368 /**
369 * Is video enabled.
370 */
371 #ifndef PJSUA_HAS_VIDEO
372 # define PJSUA_HAS_VIDEO PJMEDIA_HAS_VIDEO
373 #endif
374
375
376 /**
377 * Interval between two keyframe requests, in milliseconds.
378 *
379 * Default: 3000 ms
380 */
381 #ifndef PJSUA_VID_REQ_KEYFRAME_INTERVAL
382 # define PJSUA_VID_REQ_KEYFRAME_INTERVAL 3000
383 #endif
384
385
386 /**
387 * Default redundancy level for text streams. If this macro is set to zero,
388 * it means that there will be no redundancy.
389 */
390 #ifndef PJSUA_TXT_DEFAULT_REDUNDANCY_LEVEL
391 # define PJSUA_TXT_DEFAULT_REDUNDANCY_LEVEL 2
392 #endif
393
394
395 /**
396 * Specify whether timer heap events will be polled by a separate worker
397 * thread. If this is set/enabled, a worker thread will be dedicated to
398 * poll timer heap events only, and the rest worker thread(s) will poll
399 * ioqueue/network events only.
400 *
401 * Note that if worker thread count setting (i.e: pjsua_config.thread_cnt)
402 * is set to zero, this setting will be ignored.
403 *
404 * Default: 0 (disabled)
405 */
406 #ifndef PJSUA_SEPARATE_WORKER_FOR_TIMER
407 # define PJSUA_SEPARATE_WORKER_FOR_TIMER 0
408 #endif
409
410
411 /**
412 * Specify whether pjsua should disable automatically sending initial
413 * answer 100/Trying for incoming calls. If disabled, application can
414 * later send 100/Trying if it wishes using pjsua_call_answer().
415 *
416 * Default: 0 (automatic sending enabled)
417 */
418 #ifndef PJSUA_DISABLE_AUTO_SEND_100
419 # define PJSUA_DISABLE_AUTO_SEND_100 0
420 #endif
421
422
423 /**
424 * Default options that will be passed when creating ice transport.
425 * See #pjmedia_transport_ice_options.
426 */
427 #ifndef PJSUA_ICE_TRANSPORT_OPTION
428 # define PJSUA_ICE_TRANSPORT_OPTION 0
429 #endif
430
431 /**
432 * Interval of checking for any new ICE candidate when trickle ICE is active.
433 * Trickle ICE gathers local ICE candidates, such as STUN and TURN candidates,
434 * in the background, while SDP offer/answer negotiation is being performed.
435 * Later, when any new ICE candidate is found, the endpoint will convey
436 * the candidate to the remote endpoint via SIP INFO.
437 *
438 * Default: 100 ms
439 */
440 #ifndef PJSUA_TRICKLE_ICE_NEW_CAND_CHECK_INTERVAL
441 # define PJSUA_TRICKLE_ICE_NEW_CAND_CHECK_INTERVAL 100
442 #endif
443
444 /**
445 * Specify if PJSUA should check for merged requests as per RFC 3261 section
446 * 8.2.2.2. If a merged request is detected, PJSUA will automatically reply
447 * with a 482 - Loop Detected.
448 *
449 * Default: 1 (enabled)
450 */
451 #ifndef PJSUA_DETECT_MERGED_REQUESTS
452 # define PJSUA_DETECT_MERGED_REQUESTS 1
453 #endif
454
455
456 /**
457 * Is session record (siprec) enabled.
458 *
459 * This feature is not fully implemented yet. Currently it only signals and
460 * verifies siprec capability in Supported & Required headers in INVITE.
461 *
462 * Default: 0 (disabled)
463 */
464 #ifndef PJSUA_HAS_SIPREC
465 # define PJSUA_HAS_SIPREC 0
466 #endif
467
468
469 /**
470 * Enable support for RFC 4235 dialog event package. This was introduced in
471 * PJSIP version 2.16 and provides client-side dialog event subscription
472 * support. Set this to 0 to disable the dialog event package, which can be
473 * useful if you have your own implementation of the dialog event server.
474 *
475 * Default: 1 (enabled)
476 */
477 #ifndef PJSUA_HAS_DLG_EVENT_PKG
478 # define PJSUA_HAS_DLG_EVENT_PKG 1
479 #endif
480
481
482 /**
483 * This enumeration represents pjsua state.
484 */
485 typedef enum pjsua_state
486 {
487 /**
488 * The library has not been initialized.
489 */
490 PJSUA_STATE_NULL,
491
492 /**
493 * After pjsua_create() is called but before pjsua_init() is called.
494 */
495 PJSUA_STATE_CREATED,
496
497 /**
498 * After pjsua_init() is called but before pjsua_start() is called.
499 */
500 PJSUA_STATE_INIT,
501
502 /**
503 * After pjsua_start() is called but before everything is running.
504 */
505 PJSUA_STATE_STARTING,
506
507 /**
508 * After pjsua_start() is called and before pjsua_destroy() is called.
509 */
510 PJSUA_STATE_RUNNING,
511
512 /**
513 * After pjsua_destroy() is called but before the function returns.
514 */
515 PJSUA_STATE_CLOSING
516
517 } pjsua_state;
518
519
520 /**
521 * Logging configuration, which can be (optionally) specified when calling
522 * #pjsua_init(). Application must call #pjsua_logging_config_default() to
523 * initialize this structure with the default values.
524 */
525 typedef struct pjsua_logging_config
526 {
527 /**
528 * Log incoming and outgoing SIP message? Yes!
529 */
530 pj_bool_t msg_logging;
531
532 /**
533 * Input verbosity level. Value 5 is reasonable.
534 */
535 unsigned level;
536
537 /**
538 * Verbosity level for console. Value 4 is reasonable.
539 */
540 unsigned console_level;
541
542 /**
543 * Log decoration.
544 */
545 unsigned decor;
546
547 /**
548 * Optional log filename.
549 */
550 pj_str_t log_filename;
551
552 /**
553 * Additional flags to be given to #pj_file_open() when opening
554 * the log file. By default, the flag is PJ_O_WRONLY. Application
555 * may set PJ_O_APPEND here so that logs are appended to existing
556 * file instead of overwriting it.
557 *
558 * Default is 0.
559 */
560 unsigned log_file_flags;
561
562 /**
563 * Optional callback function to be called to write log to
564 * application specific device. This function will be called for
565 * log messages on input verbosity level.
566 */
567 void (*cb)(int level, const char *data, int len);
568
569
570 } pjsua_logging_config;
571
572
573 /**
574 * Use this function to initialize logging config.
575 *
576 * @param cfg The logging config to be initialized.
577 */
578 PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg);
579
580
581 /**
582 * Use this function to duplicate logging config.
583 *
584 * @param pool Pool to use.
585 * @param dst Destination config.
586 * @param src Source config.
587 */
588 PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool,
589 pjsua_logging_config *dst,
590 const pjsua_logging_config *src);
591
592
593 /**
594 * Structure to be passed on MWI callback.
595 */
596 typedef struct pjsua_mwi_info
597 {
598 pjsip_evsub *evsub; /**< Event subscription session, for
599 reference. */
600 pjsip_rx_data *rdata; /**< The received NOTIFY request. */
601 } pjsua_mwi_info;
602
603
604 /**
605 * Structure to be passed on registration callback.
606 */
607 typedef struct pjsua_reg_info
608 {
609 struct pjsip_regc_cbparam *cbparam; /**< Parameters returned by
610 registration callback. */
611 pjsip_regc *regc; /**< Client registration
612 structure. */
613 pj_bool_t renew; /**< Non-zero for registration and
614 zero for unregistration. */
615 } pjsua_reg_info;
616
617
618 /**
619 * Media stream info.
620 */
621 typedef struct pjsua_stream_info
622 {
623 /** Media type of this stream. */
624 pjmedia_type type;
625
626 /** Stream info (union). */
627 union {
628 /** Audio stream info */
629 pjmedia_stream_info aud;
630
631 /** Video stream info */
632 pjmedia_vid_stream_info vid;
633
634 /** Text stream info */
635 pjmedia_txt_stream_info txt;
636 } info;
637
638 } pjsua_stream_info;
639
640
641 /**
642 * Media stream statistic.
643 */
644 typedef struct pjsua_stream_stat
645 {
646 /** RTCP statistic. */
647 pjmedia_rtcp_stat rtcp;
648
649 /** Jitter buffer statistic. */
650 pjmedia_jb_state jbuf;
651
652 } pjsua_stream_stat;
653
654
655 /**
656 * Structure to be passed to on stream precreate callback.
657 * See on_stream_precreate().
658 */
659 typedef struct pjsua_on_stream_precreate_param
660 {
661 /**
662 * Stream index in the media session, read-only.
663 */
664 unsigned stream_idx;
665
666 /**
667 * Parameters that the stream will be created from.
668 */
669 pjsua_stream_info stream_info;
670 } pjsua_on_stream_precreate_param;
671
672
673 /**
674 * Structure to be passed to on stream created callback.
675 * See on_stream_created2().
676 */
677 typedef struct pjsua_on_stream_created_param
678 {
679 /**
680 * The audio media stream, read-only.
681 */
682 pjmedia_stream *stream;
683
684 /**
685 * Stream index in the audio media session, read-only.
686 */
687 unsigned stream_idx;
688
689 /**
690 * Specify if PJSUA should take ownership of the port returned in
691 * the port parameter below. If set to PJ_TRUE,
692 * pjmedia_port_destroy() will be called on the port when it is
693 * no longer needed.
694 *
695 * Default: PJ_FALSE
696 */
697 pj_bool_t destroy_port;
698
699 /**
700 * On input, it specifies the audio media port of the stream. Application
701 * may modify this pointer to point to different media port to be
702 * registered to the conference bridge.
703 */
704 pjmedia_port *port;
705
706 } pjsua_on_stream_created_param;
707
708
709 /**
710 * Enumeration of media transport state types.
711 */
712 typedef enum pjsua_med_tp_st
713 {
714 /** Null, this is the state before media transport is created. */
715 PJSUA_MED_TP_NULL,
716
717 /**
718 * Just before media transport is created, which can finish
719 * asynchronously later.
720 */
721 PJSUA_MED_TP_CREATING,
722
723 /** Media transport creation is completed, but not initialized yet. */
724 PJSUA_MED_TP_IDLE,
725
726 /** Initialized (media_create() has been called). */
727 PJSUA_MED_TP_INIT,
728
729 /** Running (media_start() has been called). */
730 PJSUA_MED_TP_RUNNING,
731
732 /** Disabled (transport is initialized, but media is being disabled). */
733 PJSUA_MED_TP_DISABLED
734
735 } pjsua_med_tp_st;
736
737
738 /**
739 * Structure to be passed on media transport state callback.
740 */
741 typedef struct pjsua_med_tp_state_info
742 {
743 /**
744 * The media index.
745 */
746 unsigned med_idx;
747
748 /**
749 * The media transport state
750 */
751 pjsua_med_tp_st state;
752
753 /**
754 * The last error code related to the media transport state.
755 */
756 pj_status_t status;
757
758 /**
759 * Optional SIP error code.
760 */
761 int sip_err_code;
762
763 /**
764 * Optional extended info, the content is specific for each transport type.
765 */
766 void *ext_info;
767
768 } pjsua_med_tp_state_info;
769
770
771 /**
772 * Type of callback to be called when media transport state is changed.
773 *
774 * @param call_id The call ID.
775 * @param info The media transport state info.
776 *
777 * @return The callback must return PJ_SUCCESS at the moment.
778 */
779 typedef pj_status_t
780 (*pjsua_med_tp_state_cb)(pjsua_call_id call_id,
781 const pjsua_med_tp_state_info *info);
782
783
784 /**
785 * Typedef of callback to be registered to #pjsua_resolve_stun_servers()
786 * and to be called when STUN resolution completes.
787 */
788 typedef void (*pj_stun_resolve_cb)(const pj_stun_resolve_result *result);
789
790
791 /**
792 * This enumeration specifies the options for custom media transport creation.
793 */
794 typedef enum pjsua_create_media_transport_flag
795 {
796 /**
797 * This flag indicates that the media transport must also close its
798 * "member" or "child" transport when pjmedia_transport_close() is
799 * called. If this flag is not specified, then the media transport
800 * must not call pjmedia_transport_close() of its member transport.
801 */
802 PJSUA_MED_TP_CLOSE_MEMBER = 1
803
804 } pjsua_create_media_transport_flag;
805
806
807 /**
808 * Specify SRTP media transport settings.
809 */
810 typedef struct pjsua_srtp_opt
811 {
812 /**
813 * Specify the number of crypto suite settings. If set to zero, all
814 * available cryptos will be enabled. Note that available crypto names
815 * can be enumerated using pjmedia_srtp_enum_crypto().
816 *
817 * Default is zero.
818 */
819 unsigned crypto_count;
820
821 /**
822 * Specify individual crypto suite setting and its priority order.
823 *
824 * Notes for DTLS-SRTP keying:
825 * - Currently only supports these cryptos: AES_CM_128_HMAC_SHA1_80,
826 * AES_CM_128_HMAC_SHA1_32, AEAD_AES_256_GCM, and AEAD_AES_128_GCM.
827 * - SRTP key is not configurable.
828 */
829 pjmedia_srtp_crypto crypto[PJMEDIA_SRTP_MAX_CRYPTOS];
830
831 /**
832 * Specify the number of enabled keying methods. If set to zero, all
833 * keyings will be enabled. Maximum value is PJMEDIA_SRTP_MAX_KEYINGS.
834 * Note that available keying methods can be enumerated using
835 * pjmedia_srtp_enum_keying().
836 *
837 * Default is zero (all keyings are enabled with priority order:
838 * SDES, DTLS-SRTP).
839 */
840 unsigned keying_count;
841
842 /**
843 * Specify enabled keying methods and its priority order. Keying method
844 * with higher priority will be given earlier chance to process the SDP,
845 * for example as currently only one keying is supported in the SDP offer,
846 * keying with first priority will be likely used in the SDP offer.
847 */
848 pjmedia_srtp_keying_method keying[PJMEDIA_SRTP_KEYINGS_COUNT];
849
850 } pjsua_srtp_opt;
851
852
853 /**
854 * This enumeration specifies the contact rewrite method.
855 */
856 typedef enum pjsua_contact_rewrite_method
857 {
858 /**
859 * The Contact update will be done by sending unregistration
860 * to the currently registered Contact, while simultaneously sending new
861 * registration (with different Call-ID) for the updated Contact.
862 */
863 PJSUA_CONTACT_REWRITE_UNREGISTER = 1,
864
865 /**
866 * The Contact update will be done in a single, current
867 * registration session, by removing the current binding (by setting its
868 * Contact's expires parameter to zero) and adding a new Contact binding,
869 * all done in a single request.
870 */
871 PJSUA_CONTACT_REWRITE_NO_UNREG = 2,
872
873 /**
874 * The Contact update will be done when receiving any registration final
875 * response. If this flag is not specified, contact update will only be
876 * done upon receiving 2xx response. This flag MUST be used with
877 * PJSUA_CONTACT_REWRITE_UNREGISTER or PJSUA_CONTACT_REWRITE_NO_UNREG
878 * above to specify how the Contact update should be performed when
879 * receiving 2xx response.
880 */
881 PJSUA_CONTACT_REWRITE_ALWAYS_UPDATE = 4
882
883 } pjsua_contact_rewrite_method;
884
885
886 /**
887 * This enumeration specifies the operation when handling IP change.
888 */
889 typedef enum pjsua_ip_change_op {
890 /**
891 * Hasn't start ip change process.
892 */
893 PJSUA_IP_CHANGE_OP_NULL,
894
895 /**
896 * The restart listener process.
897 */
898 PJSUA_IP_CHANGE_OP_SHUTDOWN_TP,
899
900 /**
901 * The restart listener process.
902 */
903 PJSUA_IP_CHANGE_OP_RESTART_LIS,
904
905 /**
906 * The shutdown transport process.
907 */
908 PJSUA_IP_CHANGE_OP_ACC_SHUTDOWN_TP,
909
910 /**
911 * The update contact process.
912 */
913 PJSUA_IP_CHANGE_OP_ACC_UPDATE_CONTACT,
914
915 /**
916 * The hanging up call process.
917 */
918 PJSUA_IP_CHANGE_OP_ACC_HANGUP_CALLS,
919
920 /**
921 * The re-INVITE call process.
922 */
923 PJSUA_IP_CHANGE_OP_ACC_REINVITE_CALLS,
924
925 /**
926 * The ip change process has completed.
927 */
928 PJSUA_IP_CHANGE_OP_COMPLETED
929
930 } pjsua_ip_change_op;
931
932
933 /**
934 * This will contain the information of the callback \a on_ip_change_progress.
935 */
936 typedef union pjsua_ip_change_op_info {
937 /**
938 * The information from listener restart operation.
939 */
940 struct {
941 int transport_id;
942 } lis_restart;
943
944 /**
945 * The information from shutdown transport.
946 */
947 struct {
948 int acc_id;
949 } acc_shutdown_tp;
950
951 /**
952 * The information from updating contact.
953 */
954 struct {
955 pjsua_acc_id acc_id;
956 pj_bool_t is_register; /**< SIP Register if PJ_TRUE. */
957 int code; /**< SIP status code received. */
958 } acc_update_contact;
959
960 /**
961 * The information from hanging up call operation.
962 */
963 struct {
964 pjsua_acc_id acc_id;
965 pjsua_call_id call_id;
966 } acc_hangup_calls;
967
968 /**
969 * The information from re-Invite call operation.
970 */
971 struct {
972 pjsua_acc_id acc_id;
973 pjsua_call_id call_id;
974 } acc_reinvite_calls;
975
976 } pjsua_ip_change_op_info;
977
978
979 /**
980 * This enumeration specifies DTMF method.
981 */
982 typedef enum pjsua_dtmf_method {
983 /**
984 * Send DTMF using RFC2833.
985 */
986 PJSUA_DTMF_METHOD_RFC2833,
987
988 /**
989 * Send DTMF using SIP INFO.
990 * Notes:
991 * - This method is not finalized in any standard/rfc, however it is
992 * commonly used.
993 * - Warning: in case the remote doesn't support SIP INFO, response might
994 * not be sent and the sender will deal this as timeout and disconnect
995 * the call.
996 */
997 PJSUA_DTMF_METHOD_SIP_INFO
998
999 } pjsua_dtmf_method;
1000
1001
1002 /**
1003 * Constant to specify unknown duration in \a pjsua_dtmf_info and
1004 * \a pjsua_dtmf_event.
1005 */
1006 #define PJSUA_UNKNOWN_DTMF_DURATION ((unsigned)-1)
1007
1008
1009 /**
1010 * This will contain the information of the callback \a on_dtmf_digit2.
1011 */
1012 typedef struct pjsua_dtmf_info {
1013 /**
1014 * The method used to send DTMF.
1015 */
1016 pjsua_dtmf_method method;
1017
1018 /**
1019 * DTMF ASCII digit.
1020 */
1021 unsigned digit;
1022
1023 /**
1024 * DTMF signal duration. If the duration is unknown, this value is set to
1025 * PJSUA_UNKNOWN_DTMF_DURATION.
1026 */
1027 unsigned duration;
1028
1029 } pjsua_dtmf_info;
1030
1031
1032 /**
1033 * This will contain the information of the callback \a on_dtmf_event.
1034 */
1035 typedef struct pjsua_dtmf_event {
1036 /**
1037 * The method used to send DTMF.
1038 */
1039 pjsua_dtmf_method method;
1040
1041 /**
1042 * The timestamp identifying the begin of the event. Timestamp units are
1043 * expressed in milliseconds.
1044 * Note that this value should only be used to compare multiple events
1045 * received via the same method relatively to each other, as the time-base
1046 * is randomized.
1047 */
1048 unsigned timestamp;
1049
1050 /**
1051 * DTMF ASCII digit.
1052 */
1053 unsigned digit;
1054
1055 /**
1056 * DTMF signal duration in milliseconds. Interpretation of the duration
1057 * depends on the flag PJMEDIA_STREAM_DTMF_IS_END.
1058 * If PJMEDIA_STREAM_DTMF_IS_END is set, this contains the total duration
1059 * of the DTMF signal or PJSUA_UNKNOWN_DTMF_DURATION if the duration is
1060 * unknown.
1061 * If PJMEDIA_STREAM_DTMF_IS_END is not set, this contains the duration
1062 * of the DTMF signal received up to this point in time.
1063 * A duration of "0" indicates an infinitely long duration.
1064 */
1065 unsigned duration;
1066
1067 /**
1068 * Flags indicating additional information about the DTMF event.
1069 * If PJMEDIA_STREAM_DTMF_IS_UPDATE is set, the event was already
1070 * indicated earlier. The new indication contains an updated event
1071 * duration.
1072 * If PJMEDIA_STREAM_DTMF_IS_END is set, the event has ended and this
1073 * indication contains the final event duration. Note that end
1074 * indications might get lost. Hence it is not guaranteed to receive
1075 * an event with PJMEDIA_STREAM_DTMF_IS_END for every event.
1076 */
1077 unsigned flags;
1078 } pjsua_dtmf_event;
1079
1080
1081 /**
1082 * This will contain the information of the callback \a on_call_rx_text().
1083 */
1084 typedef struct pjsua_txt_stream_data {
1085 /**
1086 * The sequence of the incoming text block data.
1087 */
1088 int seq;
1089
1090 /**
1091 * The timestamp of the text block data.
1092 */
1093 unsigned ts;
1094
1095 /**
1096 * The content of the text block.
1097 * Note that the text can be empty.
1098 */
1099 pj_str_t text;
1100
1101 } pjsua_txt_stream_data;
1102
1103
1104 /**
1105 * Call settings.
1106 */
1107 typedef struct pjsua_call_setting
1108 {
1109 /**
1110 * Bitmask of #pjsua_call_flag constants.
1111 *
1112 * Default: 0
1113 * (PJSUA_CALL_INCLUDE_DISABLED_MEDIA is the legacy default value).
1114 */
1115 unsigned flag;
1116
1117 /**
1118 * This flag controls what methods to request keyframe are allowed on
1119 * the call. Value is bitmask of #pjsua_vid_req_keyframe_method.
1120 *
1121 * Default: (PJSUA_VID_REQ_KEYFRAME_SIP_INFO |
1122 * PJSUA_VID_REQ_KEYFRAME_RTCP_PLI)
1123 */
1124 unsigned req_keyframe_method;
1125
1126 /**
1127 * Number of simultaneous active audio streams for this call. Setting
1128 * this to zero will disable audio in this call.
1129 *
1130 * Default: 1
1131 */
1132 unsigned aud_cnt;
1133
1134 /**
1135 * Number of simultaneous active video streams for this call. Setting
1136 * this to zero will disable video in this call.
1137 *
1138 * Default: 1 (if video feature is enabled, otherwise it is zero)
1139 */
1140 unsigned vid_cnt;
1141
1142 /**
1143 * Number of simultaneous active text streams for this call. Setting
1144 * this to zero will disable text in this call.
1145 *
1146 * Default: 1
1147 */
1148 unsigned txt_cnt;
1149
1150 /**
1151 * Media direction. This setting will only be used if the flag
1152 * PJSUA_CALL_SET_MEDIA_DIR is set, and it will persist for subsequent
1153 * offers or answers.
1154 * For example, a media that is set as PJMEDIA_DIR_ENCODING can only
1155 * mark the stream in the SDP as sendonly or inactive, but will not
1156 * become sendrecv in subsequent offers and answers.
1157 * Application can update the media direction in any API or callback
1158 * that accepts pjsua_call_setting as a parameter, such as via
1159 * pjsua_call_reinvite/update() or in on_call_rx_offer/reinvite()
1160 * callback.
1161 *
1162 * The index of the media dir will correspond to the provisional media
1163 * in pjsua_call_info.prov_media.
1164 * For offers that involve adding new medias (such as initial offer),
1165 * the index will correspond to all new audio media first, then video.
1166 * For example, for a new call with 2 audios and 1 video, media_dir[0]
1167 * and media_dir[1] will be for the audios, and media_dir[2] video.
1168 *
1169 * Default: PJMEDIA_DIR_ENCODING_DECODING
1170 */
1171 pjmedia_dir media_dir[PJMEDIA_MAX_SDP_MEDIA];
1172
1173 /**
1174 * Custom Call-ID to be sent out with outgoing INVITE. Overrides
1175 * default Call-ID generated by dialog.
1176 *
1177 * Note: It is up to the developer to verify uniqueness of the
1178 * Call-ID as there will be no verification. The developer must
1179 * change the Call-ID between calls creating a unique id for each
1180 * outgoing call.
1181 *
1182 * This setting will only be used when creating a new outgoing call
1183 * via pjsua_call_make_call().
1184 */
1185
1186 pj_str_t custom_call_id;
1187
1188 } pjsua_call_setting;
1189
1190
1191 /**
1192 * This will contain the information passed from the callback
1193 * \a pjsua_on_rejected_incoming_call_cb.
1194 */
1195 typedef struct pjsua_on_rejected_incoming_call_param {
1196 /**
1197 * The incoming call id. This will be set to PJSUA_INVALID_ID when there is
1198 * no available call slot at the time.
1199 */
1200 pjsua_call_id call_id;
1201
1202 /**
1203 * Local URI.
1204 */
1205 pj_str_t local_info;
1206
1207 /**
1208 * Remote URI.
1209 */
1210 pj_str_t remote_info;
1211
1212 /**
1213 * Rejection code.
1214 */
1215 int st_code;
1216
1217 /**
1218 * Rejection text.
1219 */
1220 pj_str_t st_text;
1221
1222 /**
1223 * The original INVITE message, if it's not available this will be set
1224 * to NULL.
1225 */
1226 pjsip_rx_data *rdata;
1227
1228 /**
1229 * Internal.
1230 */
1231 struct {
1232 char local_info[PJSIP_MAX_URL_SIZE];
1233 char remote_info[PJSIP_MAX_URL_SIZE];
1234 } buf_;
1235
1236 } pjsua_on_rejected_incoming_call_param;
1237
1238 /**
1239 * Type of callback to be called when incoming call is rejected.
1240 *
1241 * @param param The rejected call information.
1242 *
1243 */
1244 typedef void (*pjsua_on_rejected_incoming_call_cb)(
1245 const pjsua_on_rejected_incoming_call_param *param);
1246
1247
1248 /**
1249 * This structure contains the parameters for \a on_auth_challenge callback.
1250 */
1251 typedef struct pjsua_on_auth_challenge_param
1252 {
1253 /**
1254 * The account ID associated with the challenged request.
1255 * May be PJSUA_INVALID_ID if the account cannot be determined.
1256 */
1257 pjsua_acc_id acc_id;
1258
1259 /**
1260 * The call ID associated with the challenged request.
1261 * Will be PJSUA_INVALID_ID for non-call requests (REGISTER, PUBLISH,
1262 * out-of-dialog MESSAGE, etc.).
1263 */
1264 pjsua_call_id call_id;
1265
1266 /**
1267 * The account-level shared authentication session.
1268 * Use this when calling pjsip_auth_clt_async_send_req() or
1269 * pjsip_auth_clt_async_abandon().
1270 */
1271 pjsip_auth_clt_sess *auth_sess;
1272
1273 /**
1274 * The authentication token to be passed to
1275 * pjsip_auth_clt_async_send_req() or pjsip_auth_clt_async_abandon().
1276 */
1277 void *token;
1278
1279 /**
1280 * The 401/407 response containing the challenge.
1281 * Only valid during the callback. Clone with pjsip_rx_data_clone()
1282 * if needed beyond the callback.
1283 */
1284 const pjsip_rx_data *rdata;
1285
1286 /**
1287 * The original request that was challenged. Needed to build the
1288 * authenticated retry. Only valid during the callback unless the
1289 * application extends its lifetime using pjsip_tx_data_add_ref().
1290 */
1291 pjsip_tx_data *tdata;
1292
1293 /**
1294 * Output: set to PJ_TRUE if the application handles the challenge.
1295 * The application MUST then eventually call
1296 * pjsip_auth_clt_async_send_req() or pjsip_auth_clt_async_abandon().
1297 * Default PJ_FALSE means the library handles authentication
1298 * via the synchronous path.
1299 */
1300 pj_bool_t handled;
1301
1302 } pjsua_on_auth_challenge_param;
1303
1304
1305 /**
1306 * This structure describes application callback to receive various event
1307 * notification from PJSUA-API. All of these callbacks are OPTIONAL,
1308 * although definitely application would want to implement some of
1309 * the important callbacks (such as \a on_incoming_call).
1310 */
1311 typedef struct pjsua_callback
1312 {
1313 /**
1314 * Notify application when call state has changed.
1315 * Application may then query the call info to get the
1316 * detail call states by calling pjsua_call_get_info() function.
1317 *
1318 * @param call_id The call index.
1319 * @param e Event which causes the call state to change.
1320 */
1321 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
1322
1323 /**
1324 * Notify application on incoming call.
1325 *
1326 * @param acc_id The account which match the incoming call.
1327 * @param call_id The call id that has just been created for
1328 * the call.
1329 * @param rdata The incoming INVITE request.
1330 */
1331 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
1332 pjsip_rx_data *rdata);
1333
1334 /**
1335 * This is a general notification callback which is called whenever
1336 * a transaction within the call has changed state. Application can
1337 * implement this callback for example to monitor the state of
1338 * outgoing requests, or to answer unhandled incoming requests
1339 * (such as INFO) with a final response.
1340 *
1341 * @param call_id Call identification.
1342 * @param tsx The transaction which has changed state.
1343 * @param e Transaction event that caused the state change.
1344 */
1345 void (*on_call_tsx_state)(pjsua_call_id call_id,
1346 pjsip_transaction *tsx,
1347 pjsip_event *e);
1348
1349 /**
1350 * Notify application when a transaction started by pjsua_acc_send_request()
1351 * has been completed,i.e. when a response has been received.
1352 *
1353 * @param acc_id Account identification.
1354 * @param token Arbitrary data owned by the application
1355 * that was specified when sending the request.
1356 * @param event Transaction event that caused the state change.
1357 */
1358 void (*on_acc_send_request)(pjsua_acc_id acc_id,
1359 void *token,
1360 pjsip_event *event);
1361
1362 /**
1363 * Notify application when media state in the call has changed.
1364 * Normal application would need to implement this callback, e.g.
1365 * to connect the call's media to sound device. When ICE is used,
1366 * this callback will also be called to report ICE negotiation
1367 * failure. When DTLS-SRTP is used, this callback will also be called
1368 * to report DTLS negotiation failure.
1369 *
1370 * @param call_id The call index.
1371 */
1372 void (*on_call_media_state)(pjsua_call_id call_id);
1373
1374
1375 /**
1376 * Notify application when a call has just created a local SDP (for
1377 * initial or subsequent SDP offer/answer). Application can implement
1378 * this callback to modify the SDP, before it is being sent and/or
1379 * negotiated with remote SDP, for example to apply per account/call
1380 * basis codecs priority or to add custom/proprietary SDP attributes.
1381 *
1382 * @param call_id The call index.
1383 * @param sdp The SDP has just been created.
1384 * @param pool The pool instance, application should use this pool
1385 * to modify the SDP.
1386 * @param rem_sdp The remote SDP, will be NULL if local is SDP offerer.
1387 */
1388 void (*on_call_sdp_created)(pjsua_call_id call_id,
1389 pjmedia_sdp_session *sdp,
1390 pj_pool_t *pool,
1391 const pjmedia_sdp_session *rem_sdp);
1392
1393 /**
1394 * Notify application when an audio media session is about to be created
1395 * (as opposed to on_stream_created() and on_stream_created2() which are
1396 * called *after* the session has been created). The application may change
1397 * some stream info parameter values, i.e: jb_init, jb_min_pre, jb_max_pre,
1398 * jb_max, use_ka, ka_cfg, rtcp_sdes_bye_disabled, jb_discard_algo (audio),
1399 * rx_event_pt (audio), codec_param->enc_fmt (video).
1400 *
1401 * @param call_id Call identification.
1402 * @param param The on stream precreate callback parameter.
1403 */
1404 void (*on_stream_precreate)(pjsua_call_id call_id,
1405 pjsua_on_stream_precreate_param *param);
1406
1407 /**
1408 * Notify application when audio media session is created and before it is
1409 * registered to the conference bridge. Application may return different
1410 * audio media port if it has added media processing port to the stream.
1411 * This media port then will be added to the conference bridge instead.
1412 *
1413 * Note: if implemented, on_stream_created2() callback will be called
1414 * instead of this one.
1415 *
1416 * @param call_id Call identification.
1417 * @param strm Audio media stream.
1418 * @param stream_idx Stream index in the audio media session.
1419 * @param p_port On input, it specifies the audio media port of the
1420 * stream. Application may modify this pointer to
1421 * point to different media port to be registered
1422 * to the conference bridge.
1423 */
1424 void (*on_stream_created)(pjsua_call_id call_id,
1425 pjmedia_stream *strm,
1426 unsigned stream_idx,
1427 pjmedia_port **p_port);
1428
1429 /**
1430 * Notify application when audio media session is created and before it is
1431 * registered to the conference bridge. Application may return different
1432 * audio media port if it has added media processing port to the stream.
1433 * This media port then will be added to the conference bridge instead.
1434 *
1435 * @param call_id Call identification.
1436 * @param param The on stream created callback parameter.
1437 */
1438 void (*on_stream_created2)(pjsua_call_id call_id,
1439 pjsua_on_stream_created_param *param);
1440
1441 /**
1442 * Notify application when audio media session has been unregistered from
1443 * the conference bridge and about to be destroyed.
1444 *
1445 * @param call_id Call identification.
1446 * @param strm Audio media stream.
1447 * @param stream_idx Stream index in the audio media session.
1448 */
1449 void (*on_stream_destroyed)(pjsua_call_id call_id,
1450 pjmedia_stream *strm,
1451 unsigned stream_idx);
1452
1453 /**
1454 * Notify application upon incoming DTMF digits using RFC 2833 payload
1455 * formats. This callback will not be called if app implements \a
1456 * on_dtmf_digit2() or \a on_dtmf_event().
1457 *
1458 * @param call_id The call index.
1459 * @param digit DTMF ASCII digit.
1460 */
1461 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
1462
1463 /**
1464 * Notify application upon incoming DTMF digits using the method specified
1465 * in \a pjsua_dtmf_method. This callback will not be called if app
1466 * implements \a on_dtmf_event().
1467 *
1468 * @param call_id The call index.
1469 * @param info The DTMF info.
1470 */
1471 void (*on_dtmf_digit2)(pjsua_call_id call_id, const pjsua_dtmf_info *info);
1472
1473 /**
1474 * Notify application upon incoming DTMF digits using the method specified
1475 * in \a pjsua_dtmf_method. Includes additional information about events
1476 * received via RTP.
1477 *
1478 * @param call_id The call index.
1479 * @param event The DTMF event.
1480 */
1481 void (*on_dtmf_event)(pjsua_call_id call_id,
1482 const pjsua_dtmf_event *event);
1483
1484 /**
1485 * Notify application upon incoming text data from the text stream.
1486 * Note that the received text can be empty.
1487 *
1488 * IMPORTANT: Application shall refrain from invoking call APIs from
1489 * within the callback, such as call re-invite or hangup.
1490 *
1491 * @param call_id The call index.
1492 * @param data The text data.
1493 */
1494 void (*on_call_rx_text)(pjsua_call_id call_id,
1495 const pjsua_txt_stream_data *data);
1496
1497 /**
1498 * Notify application on call being transferred (i.e. REFER is received).
1499 * Application can decide to accept/reject transfer request
1500 * by setting the code (default is 202). When this callback
1501 * is not defined, the default behavior is to accept the
1502 * transfer. See also on_call_transfer_request2() callback for
1503 * the version with \a pjsua_call_setting in the argument list.
1504 *
1505 * @param call_id The call index.
1506 * @param dst The destination where the call will be
1507 * transferred to.
1508 * @param code Status code to be returned for the call transfer
1509 * request. On input, it contains status code 202.
1510 */
1511 void (*on_call_transfer_request)(pjsua_call_id call_id,
1512 const pj_str_t *dst,
1513 pjsip_status_code *code);
1514
1515 /**
1516 * Notify application on call being transferred (i.e. REFER is received).
1517 * Application can decide to accept/reject transfer request
1518 * by setting the code (default is 202). When this callback
1519 * is not defined, the default behavior is to accept the
1520 * transfer.
1521 *
1522 * @param call_id The call index.
1523 * @param dst The destination where the call will be
1524 * transferred to.
1525 * @param code Status code to be returned for the call transfer
1526 * request. On input, it contains status code 202.
1527 * @param opt The current call setting, application can update
1528 * this setting for the call being transferred.
1529 */
1530 void (*on_call_transfer_request2)(pjsua_call_id call_id,
1531 const pj_str_t *dst,
1532 pjsip_status_code *code,
1533 pjsua_call_setting *opt);
1534
1535 /**
1536 * Notify application of the status of previously sent call
1537 * transfer request. Application can monitor the status of the
1538 * call transfer request, for example to decide whether to
1539 * terminate existing call.
1540 *
1541 * @param call_id Call ID.
1542 * @param st_code Status progress of the transfer request.
1543 * @param st_text Status progress text.
1544 * @param final If non-zero, no further notification will
1545 * be reported. The st_code specified in
1546 * this callback is the final status.
1547 * @param p_cont Initially will be set to non-zero, application
1548 * can set this to FALSE if it no longer wants
1549 * to receie further notification (for example,
1550 * after it hangs up the call).
1551 */
1552 void (*on_call_transfer_status)(pjsua_call_id call_id,
1553 int st_code,
1554 const pj_str_t *st_text,
1555 pj_bool_t final,
1556 pj_bool_t *p_cont);
1557
1558 /**
1559 * Notify application about incoming INVITE with Replaces header.
1560 * Application may reject the request by setting non-2xx code.
1561 * See also on_call_replace_request2() callback for the version
1562 * with \a pjsua_call_setting in the argument list.
1563 *
1564 * @param call_id The call ID to be replaced.
1565 * @param rdata The incoming INVITE request to replace the call.
1566 * @param st_code Status code to be set by application. Application
1567 * should only return a final status (200-699).
1568 * @param st_text Optional status text to be set by application.
1569 */
1570 void (*on_call_replace_request)(pjsua_call_id call_id,
1571 pjsip_rx_data *rdata,
1572 int *st_code,
1573 pj_str_t *st_text);
1574
1575 /**
1576 * Notify application about incoming INVITE with Replaces header.
1577 * Application may reject the request by setting non-2xx code.
1578 *
1579 * @param call_id The call ID to be replaced.
1580 * @param rdata The incoming INVITE request to replace the call.
1581 * @param st_code Status code to be set by application. Application
1582 * should only return a final status (200-699).
1583 * @param st_text Optional status text to be set by application.
1584 * @param opt The current call setting, application can update
1585 * this setting for the call being replaced.
1586 */
1587 void (*on_call_replace_request2)(pjsua_call_id call_id,
1588 pjsip_rx_data *rdata,
1589 int *st_code,
1590 pj_str_t *st_text,
1591 pjsua_call_setting *opt);
1592
1593 /**
1594 * Notify application that an existing call has been replaced with
1595 * a new call. This happens when PJSUA-API receives incoming INVITE
1596 * request with Replaces header.
1597 *
1598 * After this callback is called, normally PJSUA-API will disconnect
1599 * \a old_call_id and establish \a new_call_id.
1600 *
1601 * @param old_call_id Existing call which to be replaced with the
1602 * new call.
1603 * @param new_call_id The new call.
1604 * @param rdata The incoming INVITE with Replaces request.
1605 */
1606 void (*on_call_replaced)(pjsua_call_id old_call_id,
1607 pjsua_call_id new_call_id);
1608
1609
1610 /**
1611 * Notify application when call has received new offer from remote
1612 * (i.e. re-INVITE/UPDATE with SDP is received, or from the
1613 * INVITE response in the case that the initial outgoing INVITE
1614 * has no SDP). Application can
1615 * decide to accept/reject the offer by setting the code (default
1616 * is 200). If the offer is accepted, application can update the
1617 * call setting to be applied in the answer. When this callback is
1618 * not defined, the default behavior is to accept the offer using
1619 * current call setting.
1620 *
1621 * Note: this callback may not be called if \a on_call_rx_reinvite()
1622 * is implemented.
1623 *
1624 * @param call_id The call index.
1625 * @param offer The new offer received.
1626 * @param reserved Reserved param, currently not used.
1627 * @param code Status code to be returned for answering the
1628 * offer. On input, it contains status code 200.
1629 * Currently, valid values are only 200 and 488.
1630 * @param opt The current call setting, application can update
1631 * this setting for answering the offer.
1632 */
1633 void (*on_call_rx_offer)(pjsua_call_id call_id,
1634 const pjmedia_sdp_session *offer,
1635 void *reserved,
1636 pjsip_status_code *code,
1637 pjsua_call_setting *opt);
1638
1639
1640 /**
1641 * Notify application when call has received a re-INVITE with offer
1642 * from the peer. It allows more fine-grained control over the response
1643 * to a re-INVITE. If application sets async to PJ_TRUE, it can send
1644 * the reply manually using the function #pjsua_call_answer_with_sdp().
1645 * Otherwise, by default the re-INVITE will be answered automatically
1646 * after the callback returns.
1647 *
1648 * Currently, this callback is only called for re-INVITE with
1649 * SDP, but app should be prepared to handle the case of re-INVITE
1650 * without SDP.
1651 *
1652 * Remarks: If manually answering at a later timing, application may
1653 * need to monitor on_call_tsx_state() callback to check whether
1654 * the re-INVITE is already answered automatically with 487 due to
1655 * being cancelled.
1656 *
1657 * Note: on_call_rx_offer() will still be called after this callback,
1658 * but only if async is PJ_FALSE and code is 200.
1659 *
1660 * @param call_id The call index.
1661 * @param offer Remote offer.
1662 * @param rdata The received re-INVITE request.
1663 * @param reserved Reserved param, currently not used.
1664 * @param async On input, it is PJ_FALSE. Set to PJ_TRUE if
1665 * app wants to manually answer the re-INVITE.
1666 * @param code Status code to be returned for answering the
1667 * offer. On input, it contains status code 200.
1668 * Currently, valid values are only 200 and 488.
1669 * @param opt The current call setting, application can update
1670 * this setting for answering the offer.
1671 */
1672 void (*on_call_rx_reinvite)(pjsua_call_id call_id,
1673 const pjmedia_sdp_session *offer,
1674 pjsip_rx_data *rdata,
1675 void *reserved,
1676 pj_bool_t *async,
1677 pjsip_status_code *code,
1678 pjsua_call_setting *opt);
1679
1680
1681 /**
1682 * Notify application when call has received INVITE with no SDP offer.
1683 * Application can update the call setting (e.g: add audio/video), or
1684 * enable/disable codecs, or update other media session settings from
1685 * within the callback, however, as mandated by the standard (RFC3261
1686 * section 14.2), it must ensure that the update overlaps with the
1687 * existing media session (in codecs, transports, or other parameters)
1688 * that require support from the peer, this is to avoid the need for
1689 * the peer to reject the offer.
1690 *
1691 * When this callback is not defined, the default behavior is to send
1692 * SDP offer using current active media session (with all enabled codecs
1693 * on each media type).
1694 *
1695 * @param call_id The call index.
1696 * @param reserved Reserved param, currently not used.
1697 * @param opt The current call setting, application can update
1698 * this setting for generating the offer.
1699 */
1700 void (*on_call_tx_offer)(pjsua_call_id call_id,
1701 void *reserved,
1702 pjsua_call_setting *opt);
1703
1704
1705 /**
1706 * Notify application when registration or unregistration has been
1707 * initiated. Note that this only notifies the initial registration
1708 * and unregistration. Once registration session is active, subsequent
1709 * refresh will not cause this callback to be called.
1710 *
1711 * @param acc_id The account ID.
1712 * @param renew Non-zero for registration and zero for
1713 * unregistration.
1714 */
1715 void (*on_reg_started)(pjsua_acc_id acc_id, pj_bool_t renew);
1716
1717 /**
1718 * This is the alternative version of the \a on_reg_started() callback with
1719 * \a pjsua_reg_info argument.
1720 *
1721 * @param acc_id The account ID.
1722 * @param info The registration info.
1723 */
1724 void (*on_reg_started2)(pjsua_acc_id acc_id,
1725 pjsua_reg_info *info);
1726
1727 /**
1728 * Notify application when registration status has changed.
1729 * Application may then query the account info to get the
1730 * registration details.
1731 *
1732 * @param acc_id The account ID.
1733 */
1734 void (*on_reg_state)(pjsua_acc_id acc_id);
1735
1736 /**
1737 * Notify application when registration status has changed.
1738 * Application may inspect the registration info to get the
1739 * registration status details.
1740 *
1741 * @param acc_id The account ID.
1742 * @param info The registration info.
1743 */
1744 void (*on_reg_state2)(pjsua_acc_id acc_id, pjsua_reg_info *info);
1745
1746 /**
1747 * Notification when incoming SUBSCRIBE request is received. Application
1748 * may use this callback to authorize the incoming subscribe request
1749 * (e.g. ask user permission if the request should be granted).
1750 *
1751 * If this callback is not implemented, all incoming presence subscription
1752 * requests will be accepted.
1753 *
1754 * If this callback is implemented, application has several choices on
1755 * what to do with the incoming request:
1756 * - it may reject the request immediately by specifying non-200 class
1757 * final response in the \a code argument.
1758 * - it may immediately accept the request by specifying 200 as the
1759 * \a code argument. This is the default value if application doesn't
1760 * set any value to the \a code argument. In this case, the library
1761 * will automatically send NOTIFY request upon returning from this
1762 * callback.
1763 * - it may delay the processing of the request, for example to request
1764 * user permission whether to accept or reject the request. In this
1765 * case, the application MUST set the \a code argument to 202, then
1766 * IMMEDIATELY calls #pjsua_pres_notify() with state
1767 * PJSIP_EVSUB_STATE_PENDING and later calls #pjsua_pres_notify()
1768 * again to accept or reject the subscription request.
1769 *
1770 * Any \a code other than 200 and 202 will be treated as 200.
1771 *
1772 * Application MUST return from this callback immediately (e.g. it must
1773 * not block in this callback while waiting for user confirmation).
1774 *
1775 * @param srv_pres Server presence subscription instance. If
1776 * application delays the acceptance of the request,
1777 * it will need to specify this object when calling
1778 * #pjsua_pres_notify().
1779 * @param acc_id Account ID most appropriate for this request.
1780 * @param buddy_id ID of the buddy matching the sender of the
1781 * request, if any, or PJSUA_INVALID_ID if no
1782 * matching buddy is found.
1783 * @param from The From URI of the request.
1784 * @param rdata The incoming request.
1785 * @param code The status code to respond to the request. The
1786 * default value is 200. Application may set this
1787 * to other final status code to accept or reject
1788 * the request.
1789 * @param reason The reason phrase to respond to the request.
1790 * @param msg_data If the application wants to send additional
1791 * headers in the response, it can put it in this
1792 * parameter.
1793 */
1794 void (*on_incoming_subscribe)(pjsua_acc_id acc_id,
1795 pjsua_srv_pres *srv_pres,
1796 pjsua_buddy_id buddy_id,
1797 const pj_str_t *from,
1798 pjsip_rx_data *rdata,
1799 pjsip_status_code *code,
1800 pj_str_t *reason,
1801 pjsua_msg_data *msg_data);
1802
1803 /**
1804 * Notification when server side subscription state has changed.
1805 * This callback is optional as application normally does not need
1806 * to do anything to maintain server side presence subscription.
1807 *
1808 * @param acc_id The account ID.
1809 * @param srv_pres Server presence subscription object.
1810 * @param remote_uri Remote URI string.
1811 * @param state New subscription state.
1812 * @param event PJSIP event that triggers the state change.
1813 */
1814 void (*on_srv_subscribe_state)(pjsua_acc_id acc_id,
1815 pjsua_srv_pres *srv_pres,
1816 const pj_str_t *remote_uri,
1817 pjsip_evsub_state state,
1818 pjsip_event *event);
1819
1820 /**
1821 * Notify application when the buddy state has changed.
1822 * Application may then query the buddy into to get the details.
1823 *
1824 * @param buddy_id The buddy id.
1825 */
1826 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
1827
1828 /**
1829 * Notify application when the buddy dialog state has changed.
1830 * Application may then query the buddy into to get the details.
1831 *
1832 * @param buddy_id The buddy id.
1833 */
1834 void (*on_buddy_dlg_event_state)(pjsua_buddy_id buddy_id);
1835
1836 /**
1837 * Notify application when the state of client subscription session
1838 * associated with a buddy has changed. Application may use this
1839 * callback to retrieve more detailed information about the state
1840 * changed event.
1841 *
1842 * @param buddy_id The buddy id.
1843 * @param sub Event subscription session.
1844 * @param event The event which triggers state change event.
1845 */
1846 void (*on_buddy_evsub_state)(pjsua_buddy_id buddy_id,
1847 pjsip_evsub *sub,
1848 pjsip_event *event);
1849
1850 /**
1851 * Notify application when the state of client subscription session
1852 * associated with a buddy dialog state has changed. Application
1853 * may use this callback to retrieve more detailed information about the
1854 * state changed event.
1855 *
1856 * @param buddy_id The buddy id.
1857 * @param sub Event subscription session.
1858 * @param event The event which triggers state change event.
1859 */
1860 void (*on_buddy_evsub_dlg_event_state)(pjsua_buddy_id buddy_id,
1861 pjsip_evsub *sub,
1862 pjsip_event *event);
1863
1864 /**
1865 * Notify application on incoming pager (i.e. MESSAGE request).
1866 * Argument call_id will be -1 if MESSAGE request is not related to an
1867 * existing call.
1868 *
1869 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
1870 * passed as one of the argument.
1871 *
1872 * @param call_id Containts the ID of the call where the IM was
1873 * sent, or PJSUA_INVALID_ID if the IM was sent
1874 * outside call context.
1875 * @param from URI of the sender.
1876 * @param to URI of the destination message.
1877 * @param contact The Contact URI of the sender, if present.
1878 * @param mime_type MIME type of the message.
1879 * @param body The message content.
1880 */
1881 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
1882 const pj_str_t *to, const pj_str_t *contact,
1883 const pj_str_t *mime_type, const pj_str_t *body);
1884
1885 /**
1886 * This is the alternative version of the \a on_pager() callback with
1887 * \a pjsip_rx_data argument.
1888 *
1889 * @param call_id Containts the ID of the call where the IM was
1890 * sent, or PJSUA_INVALID_ID if the IM was sent
1891 * outside call context.
1892 * @param from URI of the sender.
1893 * @param to URI of the destination message.
1894 * @param contact The Contact URI of the sender, if present.
1895 * @param mime_type MIME type of the message.
1896 * @param body The message content.
1897 * @param rdata The incoming MESSAGE request.
1898 * @param acc_id Account ID most suitable for this message.
1899 */
1900 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
1901 const pj_str_t *to, const pj_str_t *contact,
1902 const pj_str_t *mime_type, const pj_str_t *body,
1903 pjsip_rx_data *rdata, pjsua_acc_id acc_id);
1904
1905 /**
1906 * Notify application about the delivery status of outgoing pager
1907 * request. See also on_pager_status2() callback for the version with
1908 * \a pjsip_rx_data in the argument list.
1909 *
1910 * @param call_id Containts the ID of the call where the IM was
1911 * sent, or PJSUA_INVALID_ID if the IM was sent
1912 * outside call context.
1913 * @param to Destination URI.
1914 * @param body Message body.
1915 * @param user_data Arbitrary data that was specified when sending
1916 * IM message.
1917 * @param status Delivery status.
1918 * @param reason Delivery status reason.
1919 */
1920 void (*on_pager_status)(pjsua_call_id call_id,
1921 const pj_str_t *to,
1922 const pj_str_t *body,
1923 void *user_data,
1924 pjsip_status_code status,
1925 const pj_str_t *reason);
1926
1927 /**
1928 * Notify application about the delivery status of outgoing pager
1929 * request.
1930 *
1931 * @param call_id Containts the ID of the call where the IM was
1932 * sent, or PJSUA_INVALID_ID if the IM was sent
1933 * outside call context.
1934 * @param to Destination URI.
1935 * @param body Message body.
1936 * @param user_data Arbitrary data that was specified when sending
1937 * IM message.
1938 * @param status Delivery status.
1939 * @param reason Delivery status reason.
1940 * @param tdata The original MESSAGE request.
1941 * @param rdata The incoming MESSAGE response, or NULL if the
1942 * message transaction fails because of time out
1943 * or transport error.
1944 * @param acc_id Account ID from this the instant message was
1945 * send.
1946 */
1947 void (*on_pager_status2)(pjsua_call_id call_id,
1948 const pj_str_t *to,
1949 const pj_str_t *body,
1950 void *user_data,
1951 pjsip_status_code status,
1952 const pj_str_t *reason,
1953 pjsip_tx_data *tdata,
1954 pjsip_rx_data *rdata,
1955 pjsua_acc_id acc_id);
1956
1957 /**
1958 * Notify application about typing indication.
1959 *
1960 * @param call_id Containts the ID of the call where the IM was
1961 * sent, or PJSUA_INVALID_ID if the IM was sent
1962 * outside call context.
1963 * @param from URI of the sender.
1964 * @param to URI of the destination message.
1965 * @param contact The Contact URI of the sender, if present.
1966 * @param is_typing Non-zero if peer is typing, or zero if peer
1967 * has stopped typing a message.
1968 */
1969 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
1970 const pj_str_t *to, const pj_str_t *contact,
1971 pj_bool_t is_typing);
1972
1973 /**
1974 * Notify application about typing indication.
1975 *
1976 * @param call_id Containts the ID of the call where the IM was
1977 * sent, or PJSUA_INVALID_ID if the IM was sent
1978 * outside call context.
1979 * @param from URI of the sender.
1980 * @param to URI of the destination message.
1981 * @param contact The Contact URI of the sender, if present.
1982 * @param is_typing Non-zero if peer is typing, or zero if peer
1983 * has stopped typing a message.
1984 * @param rdata The received request.
1985 * @param acc_id Account ID most suitable for this message.
1986 */
1987 void (*on_typing2)(pjsua_call_id call_id, const pj_str_t *from,
1988 const pj_str_t *to, const pj_str_t *contact,
1989 pj_bool_t is_typing, pjsip_rx_data *rdata,
1990 pjsua_acc_id acc_id);
1991
1992 /**
1993 * Callback when the library has finished performing NAT type
1994 * detection.
1995 *
1996 * @param res NAT detection result.
1997 */
1998 void (*on_nat_detect)(const pj_stun_nat_detect_result *res);
1999
2000 /**
2001 * This callback is called when the call is about to resend the
2002 * INVITE request to the specified target, following the previously
2003 * received redirection response.
2004 *
2005 * Application may accept the redirection to the specified target,
2006 * reject this target only and make the session continue to try the next
2007 * target in the list if such target exists, stop the whole
2008 * redirection process altogether and cause the session to be
2009 * disconnected, or defer the decision to ask for user confirmation.
2010 *
2011 * This callback is optional. If this callback is not implemented,
2012 * the default behavior is to NOT follow the redirection response.
2013 *
2014 * @param call_id The call ID.
2015 * @param target The current target to be tried.
2016 * @param e The event that caused this callback to be called.
2017 * This could be the receipt of 3xx response, or
2018 * 4xx/5xx response received for the INVITE sent to
2019 * subsequent targets, or NULL if this callback is
2020 * called from within #pjsua_call_process_redirect()
2021 * context.
2022 *
2023 * @return Action to be performed for the target. Set this
2024 * parameter to one of the value below:
2025 * - PJSIP_REDIRECT_ACCEPT: immediately accept the
2026 * redirection. When set, the call will immediately
2027 * resend INVITE request to the target.
2028 * - PJSIP_REDIRECT_ACCEPT_REPLACE: immediately accept
2029 * the redirection and replace the To header with the
2030 * current target. When set, the call will immediately
2031 * resend INVITE request to the target.
2032 * - PJSIP_REDIRECT_REJECT: immediately reject this
2033 * target. The call will continue retrying with
2034 * next target if present, or disconnect the call
2035 * if there is no more target to try.
2036 * - PJSIP_REDIRECT_STOP: stop the whole redirection
2037 * process and immediately disconnect the call. The
2038 * on_call_state() callback will be called with
2039 * PJSIP_INV_STATE_DISCONNECTED state immediately
2040 * after this callback returns.
2041 * - PJSIP_REDIRECT_PENDING: set to this value if
2042 * no decision can be made immediately (for example
2043 * to request confirmation from user). Application
2044 * then MUST call #pjsua_call_process_redirect()
2045 * to either accept or reject the redirection upon
2046 * getting user decision.
2047 */
2048 pjsip_redirect_op (*on_call_redirected)(pjsua_call_id call_id,
2049 const pjsip_uri *target,
2050 const pjsip_event *e);
2051
2052 /**
2053 * This callback is called when message waiting indication subscription
2054 * state has changed. Application can then query the subscription state
2055 * by calling #pjsip_evsub_get_state().
2056 *
2057 * @param acc_id The account ID.
2058 * @param evsub The subscription instance.
2059 */
2060 void (*on_mwi_state)(pjsua_acc_id acc_id, pjsip_evsub *evsub);
2061
2062 /**
2063 * This callback is called when a NOTIFY request for message summary /
2064 * message waiting indication is received.
2065 *
2066 * @param acc_id The account ID.
2067 * @param mwi_info Structure containing details of the event,
2068 * including the received NOTIFY request in the
2069 * \a rdata field.
2070 */
2071 void (*on_mwi_info)(pjsua_acc_id acc_id, pjsua_mwi_info *mwi_info);
2072
2073 /**
2074 * This callback is called when transport state is changed. See also
2075 * #pjsip_tp_state_callback.
2076 */
2077 pjsip_tp_state_callback on_transport_state;
2078
2079 /**
2080 * This callback is called when media transport state is changed. See
2081 * also #pjsua_med_tp_state_cb.
2082 */
2083 pjsua_med_tp_state_cb on_call_media_transport_state;
2084
2085 /**
2086 * This callback is called to report error in ICE media transport.
2087 * Currently it is used to report TURN Refresh error.
2088 *
2089 * @param index Transport index.
2090 * @param op Operation which trigger the failure.
2091 * @param status Error status.
2092 * @param param Additional info about the event. Currently this will
2093 * always be set to NULL.
2094 */
2095 void (*on_ice_transport_error)(int index, pj_ice_strans_op op,
2096 pj_status_t status, void *param);
2097
2098 /**
2099 * Callback when the sound device is about to be opened or closed.
2100 * This callback will be called even when null sound device or no
2101 * sound device is configured by the application (i.e. the
2102 * #pjsua_set_null_snd_dev() and #pjsua_set_no_snd_dev() APIs).
2103 * Application can use the API #pjsua_get_snd_dev() to get the info
2104 * about which sound device is going to be opened/closed.
2105 *
2106 * This callback is mostly useful when the application wants to manage
2107 * the sound device by itself (i.e. with #pjsua_set_no_snd_dev()),
2108 * to get notified when it should open or close the sound device.
2109 *
2110 * @param operation The value will be set to 0 to signal that sound
2111 * device is about to be closed, and 1 to be opened.
2112 *
2113 * @return The callback must return PJ_SUCCESS at the moment.
2114 */
2115 pj_status_t (*on_snd_dev_operation)(int operation);
2116
2117 /**
2118 * Notification about media events such as video notifications. This
2119 * callback will most likely be called from media threads, thus
2120 * application must not perform heavy processing in this callback.
2121 * Especially, application must not destroy the call or media in this
2122 * callback. If application needs to perform more complex tasks to
2123 * handle the event, it should post the task to another thread.
2124 *
2125 * @param call_id The call id.
2126 * @param med_idx The media stream index.
2127 * @param event The media event.
2128 */
2129 void (*on_call_media_event)(pjsua_call_id call_id,
2130 unsigned med_idx,
2131 pjmedia_event *event);
2132
2133 /**
2134 * This callback can be used by application to implement custom media
2135 * transport adapter for the call, or to replace the media transport
2136 * with something completely new altogether.
2137 *
2138 * This callback is called when a new call is created. The library has
2139 * created a media transport for the call, and it is provided as the
2140 * \a base_tp argument of this callback. Upon returning, the callback
2141 * must return an instance of media transport to be used by the call.
2142 *
2143 * @param call_id Call ID
2144 * @param media_idx The media index in the SDP for which this media
2145 * transport will be used.
2146 * @param base_tp The media transport which otherwise will be
2147 * used by the call has this callback not been
2148 * implemented.
2149 * @param flags Bitmask from pjsua_create_media_transport_flag.
2150 *
2151 * @return The callback must return an instance of media
2152 * transport to be used by the call.
2153 */
2154 pjmedia_transport* (*on_create_media_transport)(pjsua_call_id call_id,
2155 unsigned media_idx,
2156 pjmedia_transport *base_tp,
2157 unsigned flags);
2158
2159 /**
2160 * Warning: deprecated and may be removed in future release. Application
2161 * can set SRTP crypto settings (including keys) and keying methods
2162 * via pjsua_srtp_opt in pjsua_config and pjsua_acc_config.
2163 * See also ticket #2100.
2164 *
2165 * This callback is called before SRTP media transport is created.
2166 * Application can modify the SRTP setting \a srtp_opt to specify
2167 * the cryptos & keys and keying methods which are going to be used.
2168 * Note that only some fields of pjmedia_srtp_setting can be overriden
2169 * from this callback, i.e: "crypto_count", "crypto", "keying_count",
2170 * "keying", and "use" (only for initial INVITE), any modification in
2171 * other fields will be ignored.
2172 *
2173 * @param call_id Call ID
2174 * @param media_idx The media index in the SDP for which this SRTP
2175 * media transport will be used.
2176 * @param srtp_opt The SRTP setting. Application can modify this.
2177 */
2178 void (*on_create_media_transport_srtp)(pjsua_call_id call_id,
2179 unsigned media_idx,
2180 pjmedia_srtp_setting *srtp_opt);
2181
2182 /**
2183 * This callback can be used by application to override the account
2184 * to be used to handle an incoming message. Initially, the account to
2185 * be used will be calculated automatically by the library. This initial
2186 * account will be used if application does not implement this callback,
2187 * or application sets an invalid account upon returning from this
2188 * callback.
2189 *
2190 * Note that currently the incoming messages requiring account assignment
2191 * are INVITE, MESSAGE, SUBSCRIBE, and unsolicited NOTIFY. This callback
2192 * may be called before the callback of the SIP event itself, i.e:
2193 * incoming call, pager, subscription, or unsolicited-event.
2194 *
2195 * @param rdata The incoming message.
2196 * @param acc_id On input, initial account ID calculated automatically
2197 * by the library. On output, the account ID prefered
2198 * by application to handle the incoming message.
2199 */
2200 void (*on_acc_find_for_incoming)(const pjsip_rx_data *rdata,
2201 pjsua_acc_id* acc_id);
2202
2203 /**
2204 * Calling #pjsua_init() will initiate an async process to resolve and
2205 * contact each of the STUN server entries to find which is usable.
2206 * This callback is called when the process is complete, and can be
2207 * used by the application to start creating and registering accounts.
2208 * This way, the accounts can avoid call setup delay caused by pending
2209 * STUN resolution.
2210 *
2211 * See also #pj_stun_resolve_cb.
2212 */
2213 pj_stun_resolve_cb on_stun_resolution_complete;
2214
2215 /**
2216 * Calling #pjsua_handle_ip_change() may involve different operation. This
2217 * callback is called to report the progress of each enabled operation.
2218 *
2219 * @param op The operation.
2220 * @param status The status of operation.
2221 * @param info The info from the operation
2222 *
2223 */
2224 void (*on_ip_change_progress)(pjsua_ip_change_op op,
2225 pj_status_t status,
2226 const pjsua_ip_change_op_info *info);
2227
2228 /**
2229 * Notification about media events such as video notifications. This
2230 * callback will most likely be called from media threads, thus
2231 * application must not perform heavy processing in this callback.
2232 * If application needs to perform more complex tasks to handle
2233 * the event, it should post the task to another thread.
2234 *
2235 * @param event The media event.
2236 */
2237 void (*on_media_event)(pjmedia_event *event);
2238
2239 /**
2240 * This callback will be invoked when the library implicitly rejects
2241 * an incoming call.
2242 *
2243 * In addition to being declined explicitly using the
2244 * #pjsua_call_answer()/#pjsua_call_answer2() method,
2245 * the library may also automatically reject the incoming call due
2246 * to different scenarios, e.g:
2247 * - no available call slot.
2248 * - no available account to handle the call.
2249 * - when an incoming INVITE is received with, for instance, a message
2250 * containing invalid SDP.
2251 *
2252 * See also #pjsua_on_rejected_incoming_call_cb.
2253 */
2254 pjsua_on_rejected_incoming_call_cb on_rejected_incoming_call;
2255
2256 /**
2257 * This callback will be invoked when a port operation has been
2258 * completed. This callback will most likely be called from media threads,
2259 * thus application must not perform long/blocking processing in this
2260 * callback.
2261 */
2262 pjmedia_conf_op_cb on_conf_op_completed;
2263
2264 /**
2265 * This callback will be invoked when a video port operation has been
2266 * completed. This callback will most likely be called from media threads,
2267 * thus application must not perform long/blocking processing in this
2268 * callback.
2269 */
2270 pjmedia_vid_conf_op_cb on_vid_conf_op_completed;
2271
2272 /**
2273 * This callback is called when a 401/407 challenge is received.
2274 * It may be triggered by any outgoing SIP request that receives a
2275 * 401/407 response, including REGISTER, INVITE, PUBLISH, MESSAGE, etc.
2276 *
2277 * To handle the challenge, the application should set
2278 * \a param->handled to PJ_TRUE and later call
2279 * pjsip_auth_clt_async_send_req() to resend with authentication,
2280 * or pjsip_auth_clt_async_abandon() to give up. Both may be called
2281 * synchronously within this callback or deferred.
2282 *
2283 * If \a param->handled is left as PJ_FALSE (the default), the library
2284 * falls back to synchronous authentication using configured credentials.
2285 *
2286 * If this callback is not set, the library will handle authentication
2287 * automatically using the configured credentials (synchronous path).
2288 *
2289 * Note: this callback is invoked from the SIP worker thread.
2290 * PJSUA_LOCK is NOT held during the callback.
2291 *
2292 * @param param The callback parameters.
2293 */
2294 void (*on_auth_challenge)(pjsua_on_auth_challenge_param *param);
2295
2296 } pjsua_callback;
2297
2298
2299 /**
2300 * This enumeration specifies the usage of SIP Session Timers extension.
2301 */
2302 typedef enum pjsua_sip_timer_use
2303 {
2304 /**
2305 * When this flag is specified, Session Timers will not be used in any
2306 * session, except it is explicitly required in the remote request.
2307 */
2308 PJSUA_SIP_TIMER_INACTIVE,
2309
2310 /**
2311 * When this flag is specified, Session Timers will be used in all
2312 * sessions whenever remote supports and uses it.
2313 */
2314 PJSUA_SIP_TIMER_OPTIONAL,
2315
2316 /**
2317 * When this flag is specified, Session Timers support will be
2318 * a requirement for the remote to be able to establish a session.
2319 */
2320 PJSUA_SIP_TIMER_REQUIRED,
2321
2322 /**
2323 * When this flag is specified, Session Timers will always be used
2324 * in all sessions, regardless whether remote supports/uses it or not.
2325 */
2326 PJSUA_SIP_TIMER_ALWAYS
2327
2328 } pjsua_sip_timer_use;
2329
2330
2331 /**
2332 * This enumeration specifies the usage of SIPREC extension.
2333 */
2334 typedef enum pjsua_sip_siprec_use
2335 {
2336 /**
2337 * When this flag is specified, when a SIPREC request is received, it
2338 * returns bad extension error. and SIPREC calls will not be established.
2339 */
2340 PJSUA_SIP_SIPREC_INACTIVE,
2341
2342 /**
2343 * When this flag is specified, when you want both regular calls and
2344 * SIPREC calls to be established.
2345 */
2346 PJSUA_SIP_SIPREC_OPTIONAL,
2347
2348 /**
2349 * When this flag is specified, when you want only SIPREC calls to
2350 * be established, and regular calls are rejected.
2351 */
2352 PJSUA_SIP_SIPREC_MANDATORY,
2353
2354 } pjsua_sip_siprec_use;
2355
2356
2357 /**
2358 * This constants controls the use of 100rel extension.
2359 */
2360 typedef enum pjsua_100rel_use
2361 {
2362 /**
2363 * Not used. For UAC, support for 100rel will be indicated in Supported
2364 * header so that peer can opt to use it if it wants to. As UAS, this
2365 * option will NOT cause 100rel to be used even if UAC indicates that
2366 * it supports this feature.
2367 */
2368 PJSUA_100REL_NOT_USED,
2369
2370 /**
2371 * Mandatory. UAC will place 100rel in Require header, and UAS will
2372 * reject incoming calls unless it has 100rel in Supported header.
2373 */
2374 PJSUA_100REL_MANDATORY,
2375
2376 /**
2377 * Optional. Similar to PJSUA_100REL_NOT_USED, except that as UAS, this
2378 * option will cause 100rel to be used if UAC indicates that it supports it.
2379 */
2380 PJSUA_100REL_OPTIONAL
2381
2382 } pjsua_100rel_use;
2383
2384
2385 /**
2386 * This structure describes the settings to control the API and
2387 * user agent behavior, and can be specified when calling #pjsua_init().
2388 * Before setting the values, application must call #pjsua_config_default()
2389 * to initialize this structure with the default values.
2390 */
2391 typedef struct pjsua_config
2392 {
2393
2394 /**
2395 * Maximum calls to support (default: 4). The value specified here
2396 * must be smaller than or equal to the compile time maximum settings
2397 * PJSUA_MAX_CALLS. To increase this limit, the library must be
2398 * recompiled with new PJSUA_MAX_CALLS value.
2399 */
2400 unsigned max_calls;
2401
2402 /**
2403 * Number of worker threads. Normally application will want to have at
2404 * least one worker thread, unless when it wants to poll the library
2405 * periodically, which in this case the worker thread can be set to
2406 * zero.
2407 */
2408 unsigned thread_cnt;
2409
2410 /**
2411 * Number of nameservers. If no name server is configured, the SIP SRV
2412 * resolution would be disabled, and domain will be resolved with
2413 * standard pj_gethostbyname() function.
2414 */
2415 unsigned nameserver_count;
2416
2417 /**
2418 * Array of nameservers to be used by the SIP resolver subsystem.
2419 * The order of the name server specifies the priority (first name
2420 * server will be used first, unless it is not reachable).
2421 */
2422 pj_str_t nameserver[4];
2423
2424 /**
2425 * Force loose-route to be used in all route/proxy URIs (outbound_proxy
2426 * and account's proxy settings). When this setting is enabled, the
2427 * library will check all the route/proxy URIs specified in the settings
2428 * and append ";lr" parameter to the URI if the parameter is not present.
2429 *
2430 * Default: 1
2431 */
2432 pj_bool_t force_lr;
2433
2434 /**
2435 * Number of outbound proxies in the \a outbound_proxy array.
2436 */
2437 unsigned outbound_proxy_cnt;
2438
2439 /**
2440 * Specify the URL of outbound proxies to visit for all outgoing requests.
2441 * The outbound proxies will be used for all accounts, and it will
2442 * be used to build the route set for outgoing requests. The final
2443 * route set for outgoing requests will consists of the outbound proxies
2444 * and the proxy configured in the account.
2445 */
2446 pj_str_t outbound_proxy[4];
2447
2448 /**
2449 * Warning: deprecated, please use \a stun_srv field instead. To maintain
2450 * backward compatibility, if \a stun_srv_cnt is zero then the value of
2451 * this field will be copied to \a stun_srv field, if present.
2452 *
2453 * Specify domain name to be resolved with DNS SRV resolution to get the
2454 * address of the STUN server. Alternatively application may specify
2455 * \a stun_host instead.
2456 *
2457 * If DNS SRV resolution failed for this domain, then DNS A resolution
2458 * will be performed only if \a stun_host is specified.
2459 */
2460 pj_str_t stun_domain;
2461
2462 /**
2463 * Warning: deprecated, please use \a stun_srv field instead. To maintain
2464 * backward compatibility, if \a stun_srv_cnt is zero then the value of
2465 * this field will be copied to \a stun_srv field, if present.
2466 *
2467 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
2468 * not specified, default port 3478 will be used.
2469 */
2470 pj_str_t stun_host;
2471
2472 /**
2473 * Number of STUN server entries in \a stun_srv array.
2474 */
2475 unsigned stun_srv_cnt;
2476
2477 /**
2478 * Array of STUN servers to try. The library will try to resolve and
2479 * contact each of the STUN server entry until it finds one that is
2480 * usable. Each entry may be a domain name, host name, IP address, and
2481 * it may contain an optional port number. For example:
2482 * - "pjsip.org" (domain name)
2483 * - "sip.pjsip.org" (host name)
2484 * - "pjsip.org:33478" (domain name and a non-standard port number)
2485 * - "10.0.0.1:3478" (IP address and port number)
2486 *
2487 * When nameserver is configured in the \a pjsua_config.nameserver field,
2488 * if entry is not an IP address, it will be resolved with DNS SRV
2489 * resolution first, and it will fallback to use DNS A resolution if this
2490 * fails. Port number may be specified even if the entry is a domain name,
2491 * in case the DNS SRV resolution should fallback to a non-standard port.
2492 *
2493 * When nameserver is not configured, entries will be resolved with
2494 * #pj_gethostbyname() if it's not an IP address. Port number may be
2495 * specified if the server is not listening in standard STUN port.
2496 */
2497 pj_str_t stun_srv[8];
2498
2499 /**
2500 * This specifies if the library should try to do an IPv6 resolution of
2501 * the STUN servers if the IPv4 resolution fails. It can be useful
2502 * in an IPv6-only environment, including on NAT64.
2503 *
2504 * Default: PJ_FALSE
2505 */
2506 pj_bool_t stun_try_ipv6;
2507
2508 /**
2509 * This specifies if the library should ignore failure with the
2510 * STUN servers. If this is set to PJ_FALSE, the library will refuse to
2511 * start if it fails to resolve or contact any of the STUN servers.
2512 *
2513 * This setting will also determine what happens if STUN servers are
2514 * unavailable during runtime (if set to PJ_FALSE, calls will
2515 * directly fail, otherwise (if PJ_TRUE) call medias will
2516 * fallback to proceed as though not using STUN servers.
2517 *
2518 * Default: PJ_TRUE
2519 */
2520 pj_bool_t stun_ignore_failure;
2521
2522 /**
2523 * This specifies whether STUN requests for resolving socket mapped
2524 * address should use the new format, i.e: having STUN magic cookie
2525 * in its transaction ID.
2526 *
2527 * Default: PJ_FALSE
2528 */
2529 pj_bool_t stun_map_use_stun2;
2530
2531 /**
2532 * Support for adding and parsing NAT type in the SDP to assist
2533 * troubleshooting. The valid values are:
2534 * - 0: no information will be added in SDP, and parsing is disabled.
2535 * - 1: only the NAT type number is added.
2536 * - 2: add both NAT type number and name.
2537 *
2538 * Default: 1
2539 */
2540 int nat_type_in_sdp;
2541
2542 /**
2543 * Specify how the support for reliable provisional response (100rel/
2544 * PRACK) should be used by default. Note that this setting can be
2545 * further customized in account configuration (#pjsua_acc_config).
2546 *
2547 * Default: PJSUA_100REL_NOT_USED
2548 */
2549 pjsua_100rel_use require_100rel;
2550
2551 /**
2552 * Specify the usage of Session Timers for all sessions. See the
2553 * #pjsua_sip_timer_use for possible values. Note that this setting can be
2554 * further customized in account configuration (#pjsua_acc_config).
2555 *
2556 * Default: PJSUA_SIP_TIMER_OPTIONAL
2557 */
2558 pjsua_sip_timer_use use_timer;
2559
2560 /**
2561 * Specify the usage of SIPREC sessions. See the
2562 * #pjsua_sip_siprec_use for possible values. Note that this setting can be
2563 * further customized in account configuration (#pjsua_acc_config).
2564 *
2565 * Default: PJSUA_SIP_SIPREC_INACTIVE
2566 */
2567 pjsua_sip_siprec_use use_siprec;
2568
2569 /**
2570 * Handle unsolicited NOTIFY requests containing message waiting
2571 * indication (MWI) info. Unsolicited MWI is incoming NOTIFY requests
2572 * which are not requested by client with SUBSCRIBE request.
2573 *
2574 * If this is enabled, the library will respond 200/OK to the NOTIFY
2575 * request and forward the request to \a on_mwi_info() callback.
2576 *
2577 * Note: the callback will not be invoked and 481/"No account to handle" response
2578 * will be sent if this is enabled but no account is configured.
2579 *
2580 * See also \a mwi_enabled field #on pjsua_acc_config.
2581 *
2582 * Default: PJ_TRUE
2583 *
2584 */
2585 pj_bool_t enable_unsolicited_mwi;
2586
2587 /**
2588 * Specify Session Timer settings, see #pjsip_timer_setting.
2589 * Note that this setting can be further customized in account
2590 * configuration (#pjsua_acc_config).
2591 */
2592 pjsip_timer_setting timer_setting;
2593
2594 /**
2595 * Number of credentials in the credential array.
2596 */
2597 unsigned cred_count;
2598
2599 /**
2600 * Array of credentials. These credentials will be used by all accounts,
2601 * and can be used to authenticate against outbound proxies. If the
2602 * credential is specific to the account, then application should set
2603 * the credential in the pjsua_acc_config rather than the credential
2604 * here.
2605 */
2606 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
2607
2608 /**
2609 * Application callback to receive various event notifications from
2610 * the library.
2611 */
2612 pjsua_callback cb;
2613
2614 /**
2615 * Optional user agent string (default empty). If it's empty, no
2616 * User-Agent header will be sent with outgoing requests.
2617 */
2618 pj_str_t user_agent;
2619
2620 /**
2621 * Specify default value of secure media transport usage.
2622 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
2623 * PJMEDIA_SRTP_MANDATORY.
2624 *
2625 * Note that this setting can be further customized in account
2626 * configuration (#pjsua_acc_config).
2627 *
2628 * Default: #PJSUA_DEFAULT_USE_SRTP
2629 */
2630 pjmedia_srtp_use use_srtp;
2631
2632 /**
2633 * Specify whether SRTP requires secure signaling to be used. This option
2634 * is only used when \a use_srtp option above is non-zero.
2635 *
2636 * Valid values are:
2637 * 0: SRTP does not require secure signaling
2638 * 1: SRTP requires secure transport such as TLS
2639 * 2: SRTP requires secure end-to-end transport (SIPS)
2640 *
2641 * Note that this setting can be further customized in account
2642 * configuration (#pjsua_acc_config).
2643 *
2644 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
2645 */
2646 int srtp_secure_signaling;
2647
2648 /**
2649 * This setting has been deprecated and will be ignored.
2650 */
2651 pj_bool_t srtp_optional_dup_offer;
2652
2653 /**
2654 * Specify SRTP transport setting. Application can initialize it with
2655 * default values using pjsua_srtp_opt_default().
2656 */
2657 pjsua_srtp_opt srtp_opt;
2658
2659 /**
2660 * Disconnect other call legs when more than one 2xx responses for
2661 * outgoing INVITE are received due to forking. Currently the library
2662 * is not able to handle simultaneous forked media, so disconnecting
2663 * the other call legs is necessary.
2664 *
2665 * With this setting enabled, the library will handle only one of the
2666 * connected call leg, and the other connected call legs will be
2667 * disconnected.
2668 *
2669 * Default: PJ_TRUE (only disable this setting for testing purposes).
2670 */
2671 pj_bool_t hangup_forked_call;
2672
2673 /**
2674 * Specify whether to enable UPnP.
2675 *
2676 * Note that this setting can be further customized in account
2677 * configuration (#pjsua_acc_config).
2678 *
2679 * Default: PJ_FALSE
2680 */
2681 pj_bool_t enable_upnp;
2682
2683 /**
2684 * Specify which interface to use for UPnP. If empty, UPnP will use
2685 * the first suitable interface found.
2686 *
2687 * Note that this setting is only applicable if UPnP is enabled and
2688 * the string must be NULL terminated.
2689 *
2690 * Default: empty string
2691 */
2692 pj_str_t upnp_if_name;
2693
2694 /**
2695 * When non-zero, "norefersub" is advertised in the SIP Supported header
2696 * per RFC 4488, indicating that this endpoint is capable of suppressing
2697 * the implicit REFER event subscription. The actual suppression is
2698 * negotiated per-call via the Refer-Sub header; this flag only controls
2699 * whether the capability is announced.
2700 *
2701 * Default: PJ_TRUE
2702 */
2703 pj_bool_t no_refer_sub;
2704
2705 } pjsua_config;
2706
2707
2708 /**
2709 * Flags to be given to pjsua_destroy2()
2710 */
2711 typedef enum pjsua_destroy_flag
2712 {
2713 /**
2714 * Allow sending outgoing messages (such as unregistration, event
2715 * unpublication, BYEs, unsubscription, etc.), but do not wait for
2716 * responses. This is useful to perform "best effort" clean up
2717 * without delaying the shutdown process waiting for responses.
2718 */
2719 PJSUA_DESTROY_NO_RX_MSG = 1,
2720
2721 /**
2722 * If this flag is set, do not send any outgoing messages at all.
2723 * This flag is useful if application knows that the network which
2724 * the messages are to be sent on is currently down.
2725 */
2726 PJSUA_DESTROY_NO_TX_MSG = 2,
2727
2728 /**
2729 * Do not send or receive messages during destroy. This flag is
2730 * shorthand for PJSUA_DESTROY_NO_RX_MSG + PJSUA_DESTROY_NO_TX_MSG.
2731 */
2732 PJSUA_DESTROY_NO_NETWORK = PJSUA_DESTROY_NO_RX_MSG |
2733 PJSUA_DESTROY_NO_TX_MSG
2734
2735 } pjsua_destroy_flag;
2736
2737 /**
2738 * Use this function to initialize pjsua config.
2739 *
2740 * @param cfg pjsua config to be initialized.
2741 */
2742 PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
2743
2744
2745 /** The implementation has been moved to sip_auth.h */
2746 #define pjsip_cred_dup pjsip_cred_info_dup
2747
2748
2749 /**
2750 * Duplicate pjsua_config.
2751 *
2752 * @param pool The pool to get memory from.
2753 * @param dst Destination config.
2754 * @param src Source config.
2755 */
2756 PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
2757 pjsua_config *dst,
2758 const pjsua_config *src);
2759
2760
2761 /**
2762 * This structure describes additional information to be sent with
2763 * outgoing SIP message. It can (optionally) be specified for example
2764 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
2765 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
2766 *
2767 * Application MUST call #pjsua_msg_data_init() to initialize this
2768 * structure before setting its values.
2769 */
2770 struct pjsua_msg_data
2771 {
2772 /**
2773 * Optional remote target URI (i.e. Target header). If NULL, the target
2774 * will be set to the remote URI (To header). This field is used by
2775 * pjsua_call_make_call(), pjsua_im_send(), pjsua_call_reinvite(),
2776 * pjsua_call_set_hold(), and pjsua_call_update().
2777 */
2778 pj_str_t target_uri;
2779
2780 /**
2781 * Optional local URI (i.e. From header). If NULL, the account ID
2782 * \a pjsua_acc_config.id is used for the From header. This field is
2783 * currently used only by pjsua_call_make_call() and pjsua_im_send().
2784 */
2785 pj_str_t local_uri;
2786
2787 /**
2788 * Optional contact URI to be used for this call. If NULL, the contact
2789 * will be generated automatically based on the account configuration.
2790 * This field is currently used only by pjsua_call_make_call().
2791 */
2792 pj_str_t contact_uri;
2793
2794 /**
2795 * Additional message headers as linked list. Application can add
2796 * headers to the list by creating the header, either from the heap/pool
2797 * or from temporary local variable, and add the header using
2798 * linked list operation. See pjsua_app.c for some sample codes.
2799 *
2800 * Application may override Max-Forwards header value (the default is
2801 * #PJSIP_MAX_FORWARDS_VALUE) by adding a Max-Forwards header here.
2802 */
2803 pjsip_hdr hdr_list;
2804
2805 /**
2806 * MIME type of optional message body.
2807 */
2808 pj_str_t content_type;
2809
2810 /**
2811 * Optional message body to be added to the message, only when the
2812 * message doesn't have a body.
2813 */
2814 pj_str_t msg_body;
2815
2816 /**
2817 * Content type of the multipart body. If application wants to send
2818 * multipart message bodies, it puts the parts in \a parts and set
2819 * the content type in \a multipart_ctype. If the message already
2820 * contains a body, the body will be added to the multipart bodies.
2821 */
2822 pjsip_media_type multipart_ctype;
2823
2824 /**
2825 * List of multipart parts. If application wants to send multipart
2826 * message bodies, it puts the parts in \a parts and set the content
2827 * type in \a multipart_ctype. If the message already contains a body,
2828 * the body will be added to the multipart bodies.
2829 */
2830 pjsip_multipart_part multipart_parts;
2831 };
2832
2833
2834 /**
2835 * Initialize message data.
2836 *
2837 * @param msg_data Message data to be initialized.
2838 */
2839 PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
2840
2841
2842 /**
2843 * Clone message data.
2844 *
2845 * @param pool Pool to allocate memory for the new message data.
2846 * @param rhs Message data to be cloned.
2847 *
2848 * @return The new message data.
2849 */
2850 PJ_DECL(pjsua_msg_data*) pjsua_msg_data_clone(pj_pool_t *pool,
2851 const pjsua_msg_data *rhs);
2852
2853
2854 /**
2855 * Instantiate pjsua application. Application must call this function before
2856 * calling any other functions, to make sure that the underlying libraries
2857 * are properly initialized. Once this function has returned success,
2858 * application must call pjsua_destroy() before quitting.
2859 *
2860 * @return PJ_SUCCESS on success, or the appropriate error code.
2861 */
2862 PJ_DECL(pj_status_t) pjsua_create(void);
2863
2864
2865 /** Forward declaration */
2866 typedef struct pjsua_media_config pjsua_media_config;
2867
2868
2869 /**
2870 * Initialize pjsua with the specified settings. All the settings are
2871 * optional, and the default values will be used when the config is not
2872 * specified.
2873 *
2874 * Note that #pjsua_create() MUST be called before calling this function.
2875 *
2876 * @param ua_cfg User agent configuration.
2877 * @param log_cfg Optional logging configuration.
2878 * @param media_cfg Optional media configuration.
2879 *
2880 * @return PJ_SUCCESS on success, or the appropriate error code.
2881 */
2882 PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
2883 const pjsua_logging_config *log_cfg,
2884 const pjsua_media_config *media_cfg);
2885
2886
2887 /**
2888 * Application is recommended to call this function after all initialization
2889 * is done, so that the library can do additional checking set up
2890 * additional
2891 *
2892 * Application may call this function anytime after #pjsua_init().
2893 *
2894 * @return PJ_SUCCESS on success, or the appropriate error code.
2895 */
2896 PJ_DECL(pj_status_t) pjsua_start(void);
2897
2898
2899 /**
2900 * Destroy pjsua. Application is recommended to perform graceful shutdown
2901 * before calling this function (such as unregister the account from the SIP
2902 * server, terminate presense subscription, and hangup active calls), however,
2903 * this function will do all of these if it finds there are active sessions
2904 * that need to be terminated. This function will approximately block for
2905 * one second to wait for replies from remote.
2906 *
2907 * Application.may safely call this function more than once if it doesn't
2908 * keep track of it's state.
2909 *
2910 * @see pjsua_destroy2()
2911 *
2912 * @return PJ_SUCCESS on success, or the appropriate error code.
2913 */
2914 PJ_DECL(pj_status_t) pjsua_destroy(void);
2915
2916
2917 /**
2918 * Retrieve pjsua state.
2919 *
2920 * @return pjsua state.
2921 */
2922 PJ_DECL(pjsua_state) pjsua_get_state(void);
2923
2924
2925 /**
2926 * Variant of destroy with additional flags.
2927 *
2928 * @param flags Combination of pjsua_destroy_flag enumeration.
2929 *
2930 * @return PJ_SUCCESS on success, or the appropriate error code.
2931 */
2932 PJ_DECL(pj_status_t) pjsua_destroy2(unsigned flags);
2933
2934
2935 /**
2936 * Poll pjsua for events, and if necessary block the caller thread for
2937 * the specified maximum interval (in miliseconds).
2938 *
2939 * Application doesn't normally need to call this function if it has
2940 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
2941 * because polling then will be done by these worker threads instead.
2942 *
2943 * @param msec_timeout Maximum time to wait, in miliseconds.
2944 *
2945 * @return The number of events that have been handled during the
2946 * poll. Negative value indicates error, and application
2947 * can retrieve the error as (status = -return_value).
2948 */
2949 PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
2950
2951
2952 /**
2953 * Signal all worker threads to quit. This will only wait until internal
2954 * threads are done.
2955 */
2956 PJ_DECL(void) pjsua_stop_worker_threads(void);
2957
2958
2959 /**
2960 * Create memory pool to be used by the application. Once application
2961 * finished using the pool, it must be released with pj_pool_release().
2962 *
2963 * @param name Optional pool name.
2964 * @param init_size Initial size of the pool.
2965 * @param increment Increment size.
2966 *
2967 * @return The pool, or NULL when there's no memory.
2968 */
2969 PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
2970 pj_size_t increment);
2971
2972
2973 /**
2974 * Application can call this function at any time (after pjsua_create(), of
2975 * course) to change logging settings.
2976 *
2977 * @param c Logging configuration.
2978 *
2979 * @return PJ_SUCCESS on success, or the appropriate error code.
2980 */
2981 PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
2982
2983
2984 /**
2985 * Internal function to get SIP endpoint instance of pjsua, which is
2986 * needed for example to register module, create transports, etc.
2987 * Only valid after #pjsua_init() is called.
2988 *
2989 * @return SIP endpoint instance.
2990 */
2991 PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
2992
2993 /**
2994 * Internal function to get media endpoint instance.
2995 * Only valid after #pjsua_init() is called.
2996 *
2997 * @return Media endpoint instance.
2998 */
2999 PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
3000
3001 /**
3002 * Internal function to get PJSUA pool factory.
3003 * Only valid after #pjsua_create() is called.
3004 *
3005 * @return Pool factory currently used by PJSUA.
3006 */
3007 PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
3008
3009
3010
3011 /*****************************************************************************
3012 * Utilities.
3013 *
3014 */
3015
3016 /**
3017 * This structure is used to represent the result of the STUN server
3018 * resolution and testing, the #pjsua_resolve_stun_servers() function.
3019 * This structure will be passed in #pj_stun_resolve_cb callback.
3020 */
3021 struct pj_stun_resolve_result
3022 {
3023 /**
3024 * Arbitrary data that was passed to #pjsua_resolve_stun_servers()
3025 * function.
3026 */
3027 void *token;
3028
3029 /**
3030 * This will contain PJ_SUCCESS if at least one usable STUN server
3031 * is found, otherwise it will contain the last error code during
3032 * the operation.
3033 */
3034 pj_status_t status;
3035
3036 /**
3037 * The server name that yields successful result. This will only
3038 * contain value if status is successful.
3039 */
3040 pj_str_t name;
3041
3042 /**
3043 * The server IP address. This will only contain value if status
3044 * is successful.
3045 */
3046 pj_sockaddr addr;
3047
3048 /**
3049 * The index of the usable STUN server.
3050 */
3051 unsigned index;
3052 };
3053
3054
3055 /**
3056 * This structure describe the parameter passed to #pjsua_handle_ip_change().
3057 */
3058 typedef struct pjsua_ip_change_param
3059 {
3060 /**
3061 * If set to PJ_TRUE, this will restart the transport listener.
3062 * Note that if restarting listener is enabled and the listener is
3063 * configured with a bound address, the address will be reset
3064 * so it will bind to any address (e.g: IPv4 "0.0.0.0" or IPv6 "::").
3065 *
3066 * Default : PJ_TRUE
3067 */
3068 pj_bool_t restart_listener;
3069
3070 /**
3071 * If \a restart listener is set to PJ_TRUE, some delay might be needed
3072 * for the listener to be restarted. Use this to set the delay.
3073 *
3074 * Default : PJSUA_TRANSPORT_RESTART_DELAY_TIME
3075 */
3076 unsigned restart_lis_delay;
3077
3078 /**
3079 * If set to PJ_TRUE, this will forcefully shutdown all transports.
3080 * Note that this will shutdown TCP/TLS transports only, UDP transport
3081 * should be restarted via restart_listener.
3082 *
3083 * Default : PJ_TRUE
3084 */
3085 pj_bool_t shutdown_transport;
3086
3087 } pjsua_ip_change_param;
3088
3089
3090 /**
3091 * This structure describe the account config specific to IP address change.
3092 */
3093 typedef struct pjsua_ip_change_acc_cfg
3094 {
3095 /**
3096 * Shutdown the transport used for account registration. If this is set to
3097 * PJ_TRUE, the transport will be shutdown altough it's used by multiple
3098 * account. Shutdown transport will be followed by re-Registration if
3099 * pjsua_acc_config.allow_contact_rewrite is enabled.
3100 *
3101 * Default: PJ_TRUE
3102 */
3103 pj_bool_t shutdown_tp;
3104
3105 /**
3106 * Hangup active calls associated with the account. If this is set to
3107 * PJ_TRUE, then the calls will be hang up.
3108 *
3109 * Default: PJ_FALSE
3110 */
3111 pj_bool_t hangup_calls;
3112
3113 /**
3114 * Specify the call flags used in the re-INVITE when \a hangup_calls is set
3115 * to PJ_FALSE. If this is set to 0, no re-INVITE will be sent. The
3116 * re-INVITE will be sent after re-Registration is finished.
3117 *
3118 * Default: PJSUA_CALL_REINIT_MEDIA | PJSUA_CALL_UPDATE_CONTACT |
3119 * PJSUA_CALL_UPDATE_VIA
3120 */
3121 unsigned reinvite_flags;
3122
3123 /**
3124 * For refreshing the call, use SIP UPDATE, instead of re-INVITE, if
3125 * remote supports it (by publishing it in Allow header). If remote
3126 * does not support UPDATE method or somehow the UPDATE attempt fails,
3127 * it will fallback to using re-INVITE. The \a reinvite_flags will be
3128 * used regardless whether it is re-INVITE or UPDATE that is sent.
3129 *
3130 * Default: PJ_FALSE (using re-INVITE).
3131 */
3132 pj_bool_t reinv_use_update;
3133
3134 } pjsua_ip_change_acc_cfg;
3135
3136
3137 /**
3138 * Call this function to initialize \a pjsua_ip_change_param with default
3139 * values.
3140 *
3141 * @param param The IP change param to be initialized.
3142 */
3143 PJ_DECL(void) pjsua_ip_change_param_default(pjsua_ip_change_param *param);
3144
3145
3146 /**
3147 * This is a utility function to detect NAT type in front of this
3148 * endpoint. Once invoked successfully, this function will complete
3149 * asynchronously and report the result in \a on_nat_detect() callback
3150 * of pjsua_callback.
3151 *
3152 * After NAT has been detected and the callback is called, application can
3153 * get the detected NAT type by calling #pjsua_get_nat_type(). Application
3154 * can also perform NAT detection by calling #pjsua_detect_nat_type()
3155 * again at later time.
3156 *
3157 * Note that STUN must be enabled to run this function successfully.
3158 *
3159 * @return PJ_SUCCESS on success, or the appropriate error code.
3160 */
3161 PJ_DECL(pj_status_t) pjsua_detect_nat_type(void);
3162
3163
3164 /**
3165 * Get the NAT type as detected by #pjsua_detect_nat_type() function.
3166 * This function will only return useful NAT type after #pjsua_detect_nat_type()
3167 * has completed successfully and \a on_nat_detect() callback has been called.
3168 *
3169 * @param type NAT type.
3170 *
3171 * @return When detection is in progress, this function will
3172 * return PJ_EPENDING and \a type will be set to
3173 * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been
3174 * detected successfully, this function will return
3175 * PJ_SUCCESS and \a type will be set to the correct
3176 * value. Other return values indicate error and
3177 * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN.
3178 *
3179 * @see pjsua_call_get_rem_nat_type()
3180 */
3181 PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type);
3182
3183
3184 /**
3185 * Update the STUN servers list. The #pjsua_init() must have been called
3186 * before calling this function.
3187 *
3188 * @param count Number of STUN server entries.
3189 * @param srv Array of STUN server entries to try. Please see
3190 * the \a stun_srv field in the #pjsua_config
3191 * documentation about the format of this entry.
3192 * @param wait Specify non-zero to make the function block until
3193 * it gets the result. In this case, the function
3194 * will block while the resolution is being done,
3195 * and the callback will be called before this function
3196 * returns.
3197 *
3198 * @return If \a wait parameter is non-zero, this will return
3199 * PJ_SUCCESS if one usable STUN server is found.
3200 * Otherwise it will always return PJ_SUCCESS, and
3201 * application will be notified about the result in
3202 * the callback on_stun_resolution_complete().
3203 */
3204 PJ_DECL(pj_status_t) pjsua_update_stun_servers(unsigned count, pj_str_t srv[],
3205 pj_bool_t wait);
3206
3207
3208 /**
3209 * Auxiliary function to resolve and contact each of the STUN server
3210 * entries (sequentially) to find which is usable. The #pjsua_init() must
3211 * have been called before calling this function.
3212 *
3213 * @param count Number of STUN server entries to try.
3214 * @param srv Array of STUN server entries to try. Please see
3215 * the \a stun_srv field in the #pjsua_config
3216 * documentation about the format of this entry.
3217 * @param wait Specify non-zero to make the function block until
3218 * it gets the result. In this case, the function
3219 * will block while the resolution is being done,
3220 * and the callback will be called before this function
3221 * returns.
3222 * @param token Arbitrary token to be passed back to application
3223 * in the callback.
3224 * @param cb Callback to be called to notify the result of
3225 * the function.
3226 *
3227 * @return If \a wait parameter is non-zero, this will return
3228 * PJ_SUCCESS if one usable STUN server is found.
3229 * Otherwise it will always return PJ_SUCCESS, and
3230 * application will be notified about the result in
3231 * the callback.
3232 */
3233 PJ_DECL(pj_status_t) pjsua_resolve_stun_servers(unsigned count,
3234 pj_str_t srv[],
3235 pj_bool_t wait,
3236 void *token,
3237 pj_stun_resolve_cb cb);
3238
3239 /**
3240 * Cancel pending STUN resolution which match the specified token.
3241 *
3242 * @param token The token to match. This token was given to
3243 * #pjsua_resolve_stun_servers()
3244 * @param notify_cb Boolean to control whether the callback should
3245 * be called for cancelled resolutions. When the
3246 * callback is called, the status in the result
3247 * will be set as PJ_ECANCELLED.
3248 *
3249 * @return PJ_SUCCESS if there is at least one pending STUN
3250 * resolution cancelled, or PJ_ENOTFOUND if there is
3251 * no matching one, or other error.
3252 */
3253 PJ_DECL(pj_status_t) pjsua_cancel_stun_resolution(void *token,
3254 pj_bool_t notify_cb);
3255
3256
3257 /**
3258 * This is a utility function to verify that valid SIP url is given. If the
3259 * URL is a valid SIP/SIPS scheme, PJ_SUCCESS will be returned.
3260 *
3261 * @param url The URL, as NULL terminated string.
3262 *
3263 * @return PJ_SUCCESS on success, or the appropriate error code.
3264 *
3265 * @see pjsua_verify_url()
3266 */
3267 PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
3268
3269
3270 /**
3271 * This is a utility function to verify that valid URI is given. Unlike
3272 * pjsua_verify_sip_url(), this function will return PJ_SUCCESS if tel: URI
3273 * is given.
3274 *
3275 * @param url The URL, as NULL terminated string.
3276 *
3277 * @return PJ_SUCCESS on success, or the appropriate error code.
3278 *
3279 * @see pjsua_verify_sip_url()
3280 */
3281 PJ_DECL(pj_status_t) pjsua_verify_url(const char *url);
3282
3283
3284 /**
3285 * Schedule a timer entry. Note that the timer callback may be executed
3286 * by different thread, depending on whether worker thread is enabled or
3287 * not.
3288 *
3289 * @param entry Timer heap entry.
3290 * @param delay The interval to expire.
3291 *
3292 * @return PJ_SUCCESS on success, or the appropriate error code.
3293 *
3294 * @see pjsip_endpt_schedule_timer()
3295 */
3296 #if PJ_TIMER_DEBUG
3297 #define pjsua_schedule_timer(e,d) pjsua_schedule_timer_dbg(e,d,\
3298 __FILE__,__LINE__)
3299
3300 PJ_DECL(pj_status_t) pjsua_schedule_timer_dbg(pj_timer_entry *entry,
3301 const pj_time_val *delay,
3302 const char *src_file,
3303 int src_line);
3304 #else
3305 PJ_DECL(pj_status_t) pjsua_schedule_timer(pj_timer_entry *entry,
3306 const pj_time_val *delay);
3307 #endif
3308
3309 /**
3310 * Schedule a callback function to be called after a specified time interval.
3311 * Note that the callback may be executed by different thread, depending on
3312 * whether worker thread is enabled or not.
3313 *
3314 * @param cb The callback function.
3315 * @param user_data The user data.
3316 * @param msec_delay The time interval in msec.
3317 *
3318 * @return PJ_SUCCESS on success, or the appropriate error code.
3319 */
3320 #if PJ_TIMER_DEBUG
3321 #define pjsua_schedule_timer2(cb,u,d) \
3322 pjsua_schedule_timer2_dbg(cb,u,d,__FILE__,__LINE__)
3323
3324 PJ_DECL(pj_status_t) pjsua_schedule_timer2_dbg(void (*cb)(void *user_data),
3325 void *user_data,
3326 unsigned msec_delay,
3327 const char *src_file,
3328 int src_line);
3329 #else
3330 PJ_DECL(pj_status_t) pjsua_schedule_timer2(void (*cb)(void *user_data),
3331 void *user_data,
3332 unsigned msec_delay);
3333 #endif
3334
3335 /**
3336 * Cancel the previously scheduled timer.
3337 *
3338 * @param entry Timer heap entry.
3339 *
3340 * @see pjsip_endpt_cancel_timer()
3341 */
3342 PJ_DECL(void) pjsua_cancel_timer(pj_timer_entry *entry);
3343
3344
3345 /**
3346 * This is a utility function to display error message for the specified
3347 * error code. The error message will be sent to the log.
3348 *
3349 * @param sender The log sender field.
3350 * @param title Message title for the error.
3351 * @param status Status code.
3352 */
3353 PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
3354 pj_status_t status);
3355
3356
3357 /**
3358 * This is a utility function to dump the stack states to log, using
3359 * verbosity level 3.
3360 *
3361 * @param detail Will print detailed output (such as list of
3362 * SIP transactions) when non-zero.
3363 */
3364 PJ_DECL(void) pjsua_dump(pj_bool_t detail);
3365
3366
3367 /**
3368 * Inform the stack that IP address change event was detected.
3369 * The stack will:
3370 * 1. Restart the listener (this step is configurable via
3371 * \a pjsua_ip_change_param.restart_listener).
3372 * 2. Shutdown the transport used by account registration (this step is
3373 * configurable via \a pjsua_acc_config.ip_change_cfg.shutdown_tp).
3374 * 3. Update contact URI by sending re-Registration (this step is configurable
3375 * via a\ pjsua_acc_config.allow_contact_rewrite and
3376 * a\ pjsua_acc_config.contact_rewrite_method)
3377 * 4. Hangup active calls (this step is configurable via
3378 * a\ pjsua_acc_config.ip_change_cfg.hangup_calls) or
3379 * continue the call by sending re-INVITE
3380 * (configurable via \a pjsua_acc_config.ip_change_cfg.reinvite_flags).
3381 *
3382 * @param param The IP change parameter, have a look at
3383 * #pjsua_ip_change_param.
3384 *
3385 * @return PJ_SUCCESS on success, other on error.
3386 */
3387 PJ_DECL(pj_status_t) pjsua_handle_ip_change(
3388 const pjsua_ip_change_param *param);
3389
3390
3391 /**
3392 * @}
3393 */
3394
3395
3396
3397 /*****************************************************************************
3398 * TRANSPORT API
3399 */
3400
3401 /**
3402 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
3403 * @ingroup PJSUA_LIB
3404 * @brief API for managing SIP transports
3405 * @{
3406 *
3407 * PJSUA-API supports creating multiple transport instances, for example UDP,
3408 * TCP, and TLS transport. SIP transport must be created before adding an
3409 * account.
3410 */
3411
3412
3413 /** SIP transport identification.
3414 */
3415 typedef int pjsua_transport_id;
3416
3417
3418 /**
3419 * Transport configuration for creating transports for both SIP
3420 * and media. Before setting some values to this structure, application
3421 * MUST call #pjsua_transport_config_default() to initialize its
3422 * values with default settings.
3423 */
3424 typedef struct pjsua_transport_config
3425 {
3426 /**
3427 * UDP port number to bind locally. This setting MUST be specified
3428 * even when default port is desired. If the value is zero, the
3429 * transport will be bound to any available port, and application
3430 * can query the port by querying the transport info.
3431 */
3432 unsigned port;
3433
3434 /**
3435 * Specify the port range for socket binding, relative to the start
3436 * port number specified in \a port. Note that this setting is only
3437 * applicable to media transport when the start port number is non zero.
3438 * Media transport is configurable via account setting,
3439 * i.e: pjsua_acc_config.rtp_cfg, please check the media transport
3440 * config docs for more info.
3441 *
3442 * Available ports are in the range of [\a port, \a port + \a port_range].
3443 *
3444 * Default value is zero.
3445 */
3446 unsigned port_range;
3447
3448 /**
3449 * Specify whether to randomly pick the starting port number from
3450 * the range of [\a port, \a port + \a port_range]. This setting is
3451 * used only if both port and port_range are non-zero, and only
3452 * applicable for the port selection of UDP and loop media transport.
3453 *
3454 * Default is PJ_FALSE.
3455 */
3456 pj_bool_t randomize_port;
3457
3458 /**
3459 * Optional address to advertise as the address of this transport.
3460 * Application can specify any address or hostname for this field,
3461 * for example it can point to one of the interface address in the
3462 * system, or it can point to the public address of a NAT router
3463 * where port mappings have been configured for the application.
3464 *
3465 * Note: this option can be used for both UDP and TCP as well!
3466 */
3467 pj_str_t public_addr;
3468
3469 /**
3470 * Optional address where the socket should be bound to. This option
3471 * SHOULD only be used to selectively bind the socket to particular
3472 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
3473 * published address of a transport (the public_addr field should be
3474 * used for that purpose).
3475 *
3476 * Note that unlike public_addr field, the address (or hostname) here
3477 * MUST correspond to the actual interface address in the host, since
3478 * this address will be specified as bind() argument.
3479 */
3480 pj_str_t bound_addr;
3481
3482 /**
3483 * This specifies TLS settings for TLS transport.
3484 * It’s only used when creating a SIP TLS transport.
3485 */
3486 pjsip_tls_setting tls_setting;
3487
3488 /**
3489 * QoS traffic type to be set on this transport. When application wants
3490 * to apply QoS tagging to the transport, it's preferable to set this
3491 * field rather than \a qos_param fields since this is more portable.
3492 *
3493 * For TLS transport, this field will be ignored, the QoS traffic type
3494 * can be set via tls_setting.
3495 *
3496 * Default is QoS not set.
3497 */
3498 pj_qos_type qos_type;
3499
3500 /**
3501 * Set the low level QoS parameters to the transport. This is a lower
3502 * level operation than setting the \a qos_type field and may not be
3503 * supported on all platforms.
3504 *
3505 * For TLS transport, this field will be ignored, the low level QoS
3506 * parameters can be set via tls_setting.
3507 *
3508 * Default is QoS not set.
3509 */
3510 pj_qos_params qos_params;
3511
3512 /**
3513 * Specify options to be set on the transport.
3514 *
3515 * For TLS transport, this field will be ignored, the socket options
3516 * can be set via tls_setting.
3517 *
3518 * By default there is no options.
3519 *
3520 */
3521 pj_sockopt_params sockopt_params;
3522
3523 } pjsua_transport_config;
3524
3525
3526 /**
3527 * Call this function to initialize UDP config with default values.
3528 *
3529 * @param cfg The UDP config to be initialized.
3530 */
3531 PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
3532
3533
3534 /**
3535 * Duplicate transport config.
3536 *
3537 * @param pool The pool.
3538 * @param dst The destination config.
3539 * @param src The source config.
3540 */
3541 PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
3542 pjsua_transport_config *dst,
3543 const pjsua_transport_config *src);
3544
3545
3546 /**
3547 * This structure describes transport information returned by
3548 * #pjsua_transport_get_info() function.
3549 */
3550 typedef struct pjsua_transport_info
3551 {
3552 /**
3553 * PJSUA transport identification.
3554 */
3555 pjsua_transport_id id;
3556
3557 /**
3558 * Transport type.
3559 */
3560 pjsip_transport_type_e type;
3561
3562 /**
3563 * Transport type name.
3564 */
3565 pj_str_t type_name;
3566
3567 /**
3568 * Transport string info/description.
3569 */
3570 pj_str_t info;
3571
3572 /**
3573 * Transport flag (see ##pjsip_transport_flags_e).
3574 */
3575 unsigned flag;
3576
3577 /**
3578 * Local address length.
3579 */
3580 unsigned addr_len;
3581
3582 /**
3583 * Local/bound address.
3584 */
3585 pj_sockaddr local_addr;
3586
3587 /**
3588 * Published address (or transport address name).
3589 */
3590 pjsip_host_port local_name;
3591
3592 /**
3593 * Current number of objects currently referencing this transport.
3594 */
3595 unsigned usage_count;
3596
3597
3598 } pjsua_transport_info;
3599
3600
3601 /**
3602 * Create and start a new SIP transport according to the specified
3603 * settings.
3604 *
3605 * @param type Transport type.
3606 * @param cfg Transport configuration.
3607 * @param p_id Optional pointer to receive transport ID.
3608 *
3609 * @return PJ_SUCCESS on success, or the appropriate error code.
3610 */
3611 PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
3612 const pjsua_transport_config *cfg,
3613 pjsua_transport_id *p_id);
3614
3615 /**
3616 * Register transport that has been created by application. This function
3617 * is useful if application wants to implement custom SIP transport and use
3618 * it with pjsua.
3619 *
3620 * @param tp Transport instance.
3621 * @param p_id Optional pointer to receive transport ID.
3622 *
3623 * @return PJ_SUCCESS on success, or the appropriate error code.
3624 */
3625 PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
3626 pjsua_transport_id *p_id);
3627
3628
3629 /**
3630 * Register transport factory that has been created by application.
3631 * This function is useful if application wants to implement custom SIP
3632 * transport and use it with pjsua.
3633 *
3634 * @param tf Transport factory instance.
3635 * @param p_id Optional pointer to receive transport ID.
3636 *
3637 * @return PJ_SUCCESS on success, or the appropriate error code.
3638 */
3639 PJ_DECL(pj_status_t) pjsua_tpfactory_register( pjsip_tpfactory *tf,
3640 pjsua_transport_id *p_id);
3641
3642 /**
3643 * Enumerate all transports currently created in the system. This function
3644 * will return all transport IDs, and application may then call
3645 * #pjsua_transport_get_info() function to retrieve detailed information
3646 * about the transport.
3647 *
3648 * @param id Array to receive transport ids.
3649 * @param count In input, specifies the maximum number of elements.
3650 * On return, it contains the actual number of elements.
3651 *
3652 * @return PJ_SUCCESS on success, or the appropriate error code.
3653 */
3654 PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
3655 unsigned *count );
3656
3657
3658 /**
3659 * Get information about transports.
3660 *
3661 * @param id Transport ID.
3662 * @param info Pointer to receive transport info.
3663 *
3664 * @return PJ_SUCCESS on success, or the appropriate error code.
3665 */
3666 PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
3667 pjsua_transport_info *info);
3668
3669
3670 #if 0
3671 // Not implemented.
3672 /**
3673 * Disable a transport or re-enable it. By default transport is always
3674 * enabled after it is created. Disabling a transport does not necessarily
3675 * close the socket, it will only discard incoming messages and prevent
3676 * the transport from being used to send outgoing messages.
3677 *
3678 * @param id Transport ID.
3679 * @param enabled Non-zero to enable, zero to disable.
3680 *
3681 * @return PJ_SUCCESS on success, or the appropriate error code.
3682 */
3683 PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
3684 pj_bool_t enabled);
3685 #endif
3686
3687
3688 /**
3689 * Close the transport. The system will wait until all transactions are
3690 * closed while preventing new users from using the transport, and will
3691 * close the transport when it is safe to do so.
3692 *
3693 * NOTE: Forcefully closing transport (force = PJ_TRUE) is deprecated,
3694 * since any pending transactions that are using the transport may not
3695 * terminate properly and can even crash. Application wishing to immediately
3696 * close the transport for the purpose of restarting it should use
3697 * #pjsua_handle_ip_change() instead.
3698 *
3699 * @param id Transport ID.
3700 * @param force Must be PJ_FALSE. force = PJ_TRUE is deprecated.
3701 *
3702 * @return PJ_SUCCESS on success, or the appropriate error code.
3703 */
3704 PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
3705 pj_bool_t force );
3706
3707
3708 /**
3709 * Start the listener of the transport. This is useful when listener is not
3710 * automatically started when creating the transport.
3711 *
3712 * @param id Transport ID.
3713 * @param cfg The new transport config used by the listener.
3714 * Only port, public_addr and bound_addr are used at the
3715 * moment.
3716 *
3717 * @return PJ_SUCCESS on success, or the appropriate error code.
3718 */
3719 PJ_DECL(pj_status_t) pjsua_transport_lis_start( pjsua_transport_id id,
3720 const pjsua_transport_config *cfg);
3721
3722
3723 /**
3724 * Restart the listener of the transport. This will close the listener socket
3725 * and recreate it. For TLS transports, TLS settings can be specified in the
3726 * transport config to update certificates, keys, and other TLS parameters
3727 * during runtime. For UDP transports, this will restart the transport with
3728 * new settings.
3729 *
3730 * @param id Transport ID.
3731 * @param cfg The new transport config used by the listener.
3732 * For TCP/TLS: port, public_addr, bound_addr, and tls_setting
3733 * are used. For UDP: port, public_addr, and bound_addr are used.
3734 *
3735 * @return PJ_SUCCESS on success, or the appropriate error code.
3736 */
3737 PJ_DECL(pj_status_t) pjsua_transport_lis_restart( pjsua_transport_id id,
3738 const pjsua_transport_config *cfg);
3739
3740
3741 /**
3742 * @}
3743 */
3744
3745
3746
3747
3748 /*****************************************************************************
3749 * ACCOUNT API
3750 */
3751
3752
3753 /**
3754 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
3755 * @ingroup PJSUA_LIB
3756 * @brief PJSUA Accounts management
3757 * @{
3758 *
3759 * PJSUA accounts provide identity (or identities) of the user who is currently
3760 * using the application. In SIP terms, the identity is used as the <b>From</b>
3761 * header in outgoing requests.
3762 *
3763 * PJSUA-API supports creating and managing multiple accounts. The maximum
3764 * number of accounts is limited by a compile time constant
3765 * <tt>PJSUA_MAX_ACC</tt>.
3766 *
3767 * Account may or may not have client registration associated with it.
3768 * An account is also associated with <b>route set</b> and some <b>authentication
3769 * credentials</b>, which are used when sending SIP request messages using the
3770 * account. An account also has presence's <b>online status</b>, which
3771 * will be reported to remote peer when they subscribe to the account's
3772 * presence, or which is published to a presence server if presence
3773 * publication is enabled for the account.
3774 *
3775 * At least one account MUST be created in the application. If no user
3776 * association is required, application can create a userless account by
3777 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
3778 * instead of a particular user, and it correspond with a particular
3779 * transport instance.
3780 *
3781 * Also one account must be set as the <b>default account</b>, which is used as
3782 * the account to use when PJSUA fails to match a request with any other
3783 * accounts.
3784 *
3785 * When sending outgoing SIP requests (such as making calls or sending
3786 * instant messages), normally PJSUA requires the application to specify
3787 * which account to use for the request. If no account is specified,
3788 * PJSUA may be able to select the account by matching the destination
3789 * domain name, and fall back to default account when no match is found.
3790 */
3791
3792 /**
3793 * Maximum accounts.
3794 */
3795 #ifndef PJSUA_MAX_ACC
3796 # define PJSUA_MAX_ACC 8
3797 #endif
3798
3799
3800 /**
3801 * Default registration interval.
3802 */
3803 #ifndef PJSUA_REG_INTERVAL
3804 # define PJSUA_REG_INTERVAL 300
3805 #endif
3806
3807
3808 /**
3809 * Default maximum time to wait for account unregistration transactions to
3810 * complete during library shutdown sequence.
3811 *
3812 * Default: 4000 (4 seconds)
3813 */
3814 #ifndef PJSUA_UNREG_TIMEOUT
3815 # define PJSUA_UNREG_TIMEOUT 4000
3816 #endif
3817
3818
3819 /**
3820 * Default PUBLISH expiration
3821 */
3822 #ifndef PJSUA_PUBLISH_EXPIRATION
3823 # define PJSUA_PUBLISH_EXPIRATION PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED
3824 #endif
3825
3826
3827 /**
3828 * Default account priority.
3829 */
3830 #ifndef PJSUA_DEFAULT_ACC_PRIORITY
3831 # define PJSUA_DEFAULT_ACC_PRIORITY 0
3832 #endif
3833
3834
3835 /**
3836 * Maximum time to wait for unpublication transaction(s) to complete
3837 * during shutdown process, before sending unregistration. The library
3838 * tries to wait for the unpublication (un-PUBLISH) to complete before
3839 * sending REGISTER request to unregister the account, during library
3840 * shutdown process. If the value is set too short, it is possible that
3841 * the unregistration is sent before unpublication completes, causing
3842 * unpublication request to fail.
3843 *
3844 * Default: 2000 (2 seconds)
3845 */
3846 #ifndef PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
3847 # define PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC 2000
3848 #endif
3849
3850
3851 /**
3852 * Default auto retry re-registration interval, in seconds. Set to 0
3853 * to disable this. Application can set the timer on per account basis
3854 * by setting the pjsua_acc_config.reg_retry_interval field instead.
3855 *
3856 * Default: 300 (5 minutes)
3857 */
3858 #ifndef PJSUA_REG_RETRY_INTERVAL
3859 # define PJSUA_REG_RETRY_INTERVAL 300
3860 #endif
3861
3862 /**
3863 * When the registration is successful, the auto registration refresh will
3864 * be sent before it expires. Setting this to 0 will disable it.
3865 * This is useful for app that uses Push Notification and doesn't require auto
3866 * registration refresh. App can periodically send refresh registration or
3867 * send it before making a call.=
3868 * See https://github.com/pjsip/pjproject/pull/2652 for more info.
3869 *
3870 * Default: 1 (enabled)
3871 */
3872 #ifndef PJSUA_REG_AUTO_REG_REFRESH
3873 # define PJSUA_REG_AUTO_REG_REFRESH 1
3874 #endif
3875
3876 /**
3877 * This macro specifies the default value for \a contact_rewrite_method
3878 * field in pjsua_acc_config. It specifies how Contact update will be
3879 * done with the registration, if \a allow_contact_rewrite is enabled in
3880 * the account config. See \a pjsua_contact_rewrite_method for the options.
3881 *
3882 * Value PJSUA_CONTACT_REWRITE_UNREGISTER(1) is the legacy behavior.
3883 *
3884 * Default value: PJSUA_CONTACT_REWRITE_NO_UNREG(2) |
3885 * PJSUA_CONTACT_REWRITE_ALWAYS_UPDATE(4)
3886 */
3887 #ifndef PJSUA_CONTACT_REWRITE_METHOD
3888 # define PJSUA_CONTACT_REWRITE_METHOD (PJSUA_CONTACT_REWRITE_NO_UNREG | \
3889 PJSUA_CONTACT_REWRITE_ALWAYS_UPDATE)
3890 #endif
3891
3892
3893 /**
3894 * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that
3895 * the global outbound proxy list should be added to the REGISTER request.
3896 */
3897 #define PJSUA_REG_USE_OUTBOUND_PROXY 1
3898
3899
3900 /**
3901 * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that
3902 * the account proxy list should be added to the REGISTER request.
3903 */
3904 #define PJSUA_REG_USE_ACC_PROXY 2
3905
3906
3907 /**
3908 * This enumeration specifies how we should offer call hold request to
3909 * remote peer. The default value is set by compile time constant
3910 * PJSUA_CALL_HOLD_TYPE_DEFAULT, and application may control the setting
3911 * on per-account basis by manipulating \a call_hold_type field in
3912 * #pjsua_acc_config.
3913 */
3914 typedef enum pjsua_call_hold_type
3915 {
3916 /**
3917 * This will follow RFC 3264 recommendation to use a=sendonly,
3918 * a=recvonly, and a=inactive attribute as means to signal call
3919 * hold status. This is the correct value to use.
3920 */
3921 PJSUA_CALL_HOLD_TYPE_RFC3264,
3922
3923 /**
3924 * This will use the old and deprecated method as specified in RFC 2543,
3925 * and will offer c=0.0.0.0 in the SDP instead. Using this has many
3926 * drawbacks such as inability to keep the media transport alive while
3927 * the call is being put on hold, and should only be used if remote
3928 * does not understand RFC 3264 style call hold offer.
3929 */
3930 PJSUA_CALL_HOLD_TYPE_RFC2543
3931
3932 } pjsua_call_hold_type;
3933
3934
3935 /**
3936 * Specify the default call hold type to be used in #pjsua_acc_config.
3937 *
3938 * Default is PJSUA_CALL_HOLD_TYPE_RFC3264, and there's no reason to change
3939 * this except if you're communicating with an old/non-standard peer.
3940 */
3941 #ifndef PJSUA_CALL_HOLD_TYPE_DEFAULT
3942 # define PJSUA_CALL_HOLD_TYPE_DEFAULT PJSUA_CALL_HOLD_TYPE_RFC3264
3943 #endif
3944
3945 /**
3946 * This enumeration controls the use of STUN in the account.
3947 */
3948 typedef enum pjsua_stun_use
3949 {
3950 /**
3951 * Follow the default setting in the global \a pjsua_config.
3952 */
3953 PJSUA_STUN_USE_DEFAULT,
3954
3955 /**
3956 * Disable STUN. If STUN is not enabled in the global \a pjsua_config,
3957 * this setting has no effect.
3958 */
3959 PJSUA_STUN_USE_DISABLED,
3960
3961 /**
3962 * Retry other STUN servers if the STUN server selected during
3963 * startup (#pjsua_init()) or after calling #pjsua_update_stun_servers()
3964 * is unavailable during runtime. This setting is valid only for
3965 * account's media STUN setting and if the call is using UDP media
3966 * transport.
3967 */
3968 PJSUA_STUN_RETRY_ON_FAILURE
3969
3970 } pjsua_stun_use;
3971
3972 /**
3973 * This enumeration controls the use of UPnP in the account.
3974 */
3975 typedef enum pjsua_upnp_use
3976 {
3977 /**
3978 * Follow the default setting in the global \a pjsua_config.
3979 */
3980 PJSUA_UPNP_USE_DEFAULT,
3981
3982 /**
3983 * Disable UPnP.
3984 */
3985 PJSUA_UPNP_USE_DISABLED
3986
3987 } pjsua_upnp_use;
3988
3989 /**
3990 * This enumeration controls the use of ICE settings in the account.
3991 */
3992 typedef enum pjsua_ice_config_use
3993 {
3994 /**
3995 * Use the default settings in the global \a pjsua_media_config.
3996 */
3997 PJSUA_ICE_CONFIG_USE_DEFAULT,
3998
3999 /**
4000 * Use the custom \a pjsua_ice_config setting in the account.
4001 */
4002 PJSUA_ICE_CONFIG_USE_CUSTOM
4003
4004 } pjsua_ice_config_use;
4005
4006 /**
4007 * This enumeration controls the use of TURN settings in the account.
4008 */
4009 typedef enum pjsua_turn_config_use
4010 {
4011 /**
4012 * Use the default setting in the global \a pjsua_media_config.
4013 */
4014 PJSUA_TURN_CONFIG_USE_DEFAULT,
4015
4016 /**
4017 * Use the custom \a pjsua_turn_config setting in the account.
4018 */
4019 PJSUA_TURN_CONFIG_USE_CUSTOM
4020
4021 } pjsua_turn_config_use;
4022
4023 /**
4024 * ICE setting. This setting is used in the pjsua_acc_config.
4025 */
4026 typedef struct pjsua_ice_config
4027 {
4028 /**
4029 * Enable ICE.
4030 */
4031 pj_bool_t enable_ice;
4032
4033 /**
4034 * Set the maximum number of host candidates.
4035 *
4036 * Default: -1 (maximum not set)
4037 */
4038 int ice_max_host_cands;
4039
4040 /**
4041 * Number of manual host candidates. This must be equal or less than
4042 * \a ice_max_host_cands.
4043 */
4044 unsigned ice_manual_host_cnt;
4045
4046 /**
4047 * Optional configuration to manually specify host candidates.
4048 * Each candidate will use the same port as the automatic/base host
4049 * candidate.
4050 */
4051 pj_sockaddr ice_manual_host[PJ_ICE_ST_MAX_CAND];
4052
4053 /**
4054 * ICE session options.
4055 */
4056 pj_ice_sess_options ice_opt;
4057
4058 /**
4059 * Disable RTCP component.
4060 *
4061 * Default: no
4062 */
4063 pj_bool_t ice_no_rtcp;
4064
4065 /**
4066 * Send re-INVITE/UPDATE every after ICE connectivity check regardless
4067 * the default ICE transport address is changed or not. When this is set
4068 * to PJ_FALSE, re-INVITE/UPDATE will be sent only when the default ICE
4069 * transport address is changed.
4070 *
4071 * Default: yes
4072 */
4073 pj_bool_t ice_always_update;
4074
4075 } pjsua_ice_config;
4076
4077 /**
4078 * TURN setting. This setting is used in the pjsua_acc_config.
4079 */
4080 typedef struct pjsua_turn_config
4081 {
4082 /**
4083 * Enable TURN candidate in ICE.
4084 */
4085 pj_bool_t enable_turn;
4086
4087 /**
4088 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
4089 * "HOST:PORT" format.
4090 */
4091 pj_str_t turn_server;
4092
4093 /**
4094 * Specify the connection type to be used to the TURN server. Valid
4095 * values are PJ_TURN_TP_UDP, PJ_TURN_TP_TCP or PJ_TURN_TP_TLS.
4096 *
4097 * Default: PJ_TURN_TP_UDP
4098 */
4099 pj_turn_tp_type turn_conn_type;
4100
4101 /**
4102 * Specify the credential to authenticate with the TURN server.
4103 */
4104 pj_stun_auth_cred turn_auth_cred;
4105
4106 /**
4107 * This specifies TLS settings for TURN TLS. It’s only applicable when
4108 * TLS is used to connect to the TURN server.
4109 */
4110 pj_turn_sock_tls_cfg turn_tls_setting;
4111
4112 } pjsua_turn_config;
4113
4114 /**
4115 * Specify how IPv6 transport should be used in account config.
4116 * IP version preference only applies for outgoing direction, for incoming
4117 * direction, we will check the corresponding message/offer and match it.
4118 */
4119 typedef enum pjsua_ipv6_use
4120 {
4121 /**
4122 * IPv6 is not used.
4123 */
4124 PJSUA_IPV6_DISABLED,
4125
4126 /**
4127 * IPv6 is enabled.
4128 */
4129 PJSUA_IPV6_ENABLED = 1,
4130 PJSUA_IPV6_ENABLED_NO_PREFERENCE = 1,
4131
4132 /**
4133 * IPv6 is enabled, but IPv4 is preferable.
4134 */
4135 PJSUA_IPV6_ENABLED_PREFER_IPV4,
4136
4137 /**
4138 * IPv6 is enabled and preferable.
4139 */
4140 PJSUA_IPV6_ENABLED_PREFER_IPV6,
4141
4142 /**
4143 * Only IPv6 is enabled, IPv4 will not be used.
4144 */
4145 PJSUA_IPV6_ENABLED_USE_IPV6_ONLY
4146
4147 } pjsua_ipv6_use;
4148
4149 /**
4150 * Specify NAT64 options to be used in account config.
4151 */
4152 typedef enum pjsua_nat64_opt
4153 {
4154 /**
4155 * NAT64 is not used.
4156 */
4157 PJSUA_NAT64_DISABLED,
4158
4159 /**
4160 * NAT64 is enabled.
4161 */
4162 PJSUA_NAT64_ENABLED
4163
4164 } pjsua_nat64_opt;
4165
4166
4167 /**
4168 * This structure describes account configuration to be specified when
4169 * adding a new account with #pjsua_acc_add(). Application MUST initialize
4170 * this structure first by calling #pjsua_acc_config_default().
4171 */
4172 typedef struct pjsua_acc_config
4173 {
4174 /**
4175 * Arbitrary user data to be associated with the newly created account.
4176 * Application may set this later with #pjsua_acc_set_user_data() and
4177 * retrieve it with #pjsua_acc_get_user_data().
4178 */
4179 void *user_data;
4180
4181 /**
4182 * Account priority, which is used to control the order of matching
4183 * incoming/outgoing requests. The higher the number means the higher
4184 * the priority is, and the account will be matched first.
4185 */
4186 int priority;
4187
4188 /**
4189 * The full SIP URL for the account. The value can take name address or
4190 * URL format, and will look something like "sip:account@serviceprovider"
4191 * or "\"Display Name\" <sip:account@provider>".
4192 *
4193 * This field is mandatory.
4194 */
4195 pj_str_t id;
4196
4197 /**
4198 * This is the URL to be put in the request URI for the registration,
4199 * and will look something like "sip:serviceprovider".
4200 *
4201 * This field should be specified if registration is desired. If the
4202 * value is empty, no account registration will be performed.
4203 */
4204 pj_str_t reg_uri;
4205
4206 /**
4207 * The optional custom SIP headers to be put in the registration
4208 * request.
4209 */
4210 pjsip_hdr reg_hdr_list;
4211
4212 /**
4213 * Additional parameters that will be appended in the Contact header
4214 * for this account. This will only affect REGISTER requests and
4215 * will be appended after \a contact_params;
4216 *
4217 * The parameters should be preceeded by semicolon, and all strings must
4218 * be properly escaped. Example:
4219 * ";my-param=X;another-param=Hi%20there"
4220 */
4221 pj_str_t reg_contact_params;
4222
4223 /**
4224 * Additional URI parameters that will be appended in the Contact URI
4225 * for this account. This will only affect REGISTER requests and
4226 * will be appended after \a contact_uri_params;
4227 *
4228 * The parameters should be preceeded by semicolon, and all strings must
4229 * be properly escaped. Example:
4230 * ";my-param=X;another-param=Hi%20there"
4231 */
4232 pj_str_t reg_contact_uri_params;
4233
4234 /**
4235 * The optional custom SIP headers to be put in the presence
4236 * subscription request.
4237 */
4238 pjsip_hdr sub_hdr_list;
4239
4240 /**
4241 * Subscribe to message waiting indication events (RFC 3842).
4242 *
4243 * See also \a enable_unsolicited_mwi field on #pjsua_config.
4244 *
4245 * Default: no
4246 */
4247 pj_bool_t mwi_enabled;
4248
4249 /**
4250 * Specify the default expiration time for Message Waiting Indication
4251 * (RFC 3842) event subscription. This must not be zero.
4252 *
4253 * Default: PJSIP_MWI_DEFAULT_EXPIRES
4254 */
4255 unsigned mwi_expires;
4256
4257 /**
4258 * If this flag is set, the presence information of this account will
4259 * be PUBLISH-ed to the server where the account belongs.
4260 *
4261 * Default: PJ_FALSE
4262 */
4263 pj_bool_t publish_enabled;
4264
4265 /**
4266 * Event publication options.
4267 */
4268 pjsip_publishc_opt publish_opt;
4269
4270 /**
4271 * Maximum time to wait for unpublication transaction(s) to complete
4272 * during shutdown process, before sending unregistration. The library
4273 * tries to wait for the unpublication (un-PUBLISH) to complete before
4274 * sending REGISTER request to unregister the account, during library
4275 * shutdown process. If the value is set too short, it is possible that
4276 * the unregistration is sent before unpublication completes, causing
4277 * unpublication request to fail.
4278 *
4279 * Default: PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
4280 */
4281 unsigned unpublish_max_wait_time_msec;
4282
4283 /**
4284 * Authentication preference.
4285 */
4286 pjsip_auth_clt_pref auth_pref;
4287
4288 /**
4289 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
4290 * is not specified, a random string will be used.
4291 */
4292 pj_str_t pidf_tuple_id;
4293
4294 /**
4295 * Optional URI to be put as Contact for this account. It is recommended
4296 * that this field is left empty, so that the value will be calculated
4297 * automatically based on the transport address.
4298 */
4299 pj_str_t force_contact;
4300
4301 /**
4302 * Additional parameters that will be appended in the Contact header
4303 * for this account. This will affect the Contact header in all SIP
4304 * messages sent on behalf of this account, including but not limited to
4305 * REGISTER, INVITE, and SUBCRIBE requests or responses.
4306 *
4307 * The parameters should be preceeded by semicolon, and all strings must
4308 * be properly escaped. Example:
4309 * ";my-param=X;another-param=Hi%20there"
4310 */
4311 pj_str_t contact_params;
4312
4313 /**
4314 * Additional URI parameters that will be appended in the Contact URI
4315 * for this account. This will affect the Contact URI in all SIP
4316 * messages sent on behalf of this account, including but not limited to
4317 * REGISTER, INVITE, and SUBCRIBE requests or responses.
4318 *
4319 * The parameters should be preceeded by semicolon, and all strings must
4320 * be properly escaped. Example:
4321 * ";my-param=X;another-param=Hi%20there"
4322 */
4323 pj_str_t contact_uri_params;
4324
4325 /**
4326 * Specify how support for reliable provisional response (100rel/
4327 * PRACK) should be used for all sessions in this account. See the
4328 * documentation of pjsua_100rel_use enumeration for more info.
4329 *
4330 * Default: The default value is taken from the value of
4331 * require_100rel in pjsua_config.
4332 */
4333 pjsua_100rel_use require_100rel;
4334
4335 /**
4336 * Specify the usage of Session Timers for all sessions. See the
4337 * #pjsua_sip_timer_use for possible values.
4338 *
4339 * Default: PJSUA_SIP_TIMER_OPTIONAL
4340 */
4341 pjsua_sip_timer_use use_timer;
4342
4343 /**
4344 * Specify the usage of SIPREC sessions. See the
4345 * #pjsua_sip_siprec_use for possible values.
4346 *
4347 * Default: PJSUA_SIP_SIPREC_INACTIVE
4348 */
4349 pjsua_sip_siprec_use use_siprec;
4350
4351 /**
4352 * Specify Session Timer settings, see #pjsip_timer_setting.
4353 */
4354 pjsip_timer_setting timer_setting;
4355
4356 /**
4357 * Number of proxies in the proxy array below.
4358 */
4359 unsigned proxy_cnt;
4360
4361 /**
4362 * Optional URI of the proxies to be visited for all outgoing requests
4363 * that are using this account (REGISTER, INVITE, etc). Application need
4364 * to specify these proxies if the service provider requires that requests
4365 * destined towards its network should go through certain proxies first
4366 * (for example, border controllers).
4367 *
4368 * These proxies will be put in the route set for this account, with
4369 * maintaining the orders (the first proxy in the array will be visited
4370 * first). If global outbound proxies are configured in pjsua_config,
4371 * then these account proxies will be placed after the global outbound
4372 * proxies in the routeset.
4373 */
4374 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
4375
4376 /**
4377 * If remote sends SDP answer containing more than one format or codec in
4378 * the media line, send re-INVITE or UPDATE with just one codec to lock
4379 * which codec to use.
4380 *
4381 * Default: 1 (Yes). Set to zero to disable.
4382 */
4383 unsigned lock_codec;
4384
4385 /**
4386 * Optional interval for registration, in seconds. If the value is zero,
4387 * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
4388 */
4389 unsigned reg_timeout;
4390
4391 /**
4392 * Specify the number of seconds to refresh the client registration
4393 * before the registration expires.
4394 *
4395 * Default: PJSIP_REGISTER_CLIENT_DELAY_BEFORE_REFRESH, 5 seconds
4396 */
4397 unsigned reg_delay_before_refresh;
4398
4399 /**
4400 * Specify the maximum time to wait for unregistration requests to
4401 * complete during library shutdown sequence.
4402 *
4403 * Default: PJSUA_UNREG_TIMEOUT
4404 */
4405 unsigned unreg_timeout;
4406
4407 /**
4408 * Number of credentials in the credential array.
4409 */
4410 unsigned cred_count;
4411
4412 /**
4413 * Array of credentials. If registration is desired, normally there should
4414 * be at least one credential specified, to successfully authenticate
4415 * against the service provider. More credentials can be specified, for
4416 * example when the requests are expected to be challenged by the
4417 * proxies in the route set.
4418 */
4419 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
4420
4421 /**
4422 * Optionally bind this account to specific transport. This normally is
4423 * not a good idea, as account should be able to send requests using
4424 * any available transports according to the destination. But some
4425 * application may want to have explicit control over the transport to
4426 * use, so in that case it can set this field.
4427 *
4428 * Default: -1 (PJSUA_INVALID_ID)
4429 *
4430 * @see pjsua_acc_set_transport()
4431 */
4432 pjsua_transport_id transport_id;
4433
4434 /**
4435 * This option is used to update the transport address and the Contact
4436 * header of REGISTER request. When this option is enabled, the library
4437 * will keep track of the public IP address from the response of REGISTER
4438 * request. Once it detects that the address has changed, it will
4439 * unregister current Contact, update the Contact with transport address
4440 * learned from Via header, and register a new Contact to the registrar.
4441 * This will also update the public name of UDP transport if STUN is
4442 * configured.
4443 *
4444 * Possible values:
4445 * * 0 (disabled).
4446 * * 1 (enabled). Update except if both Contact and server's IP address
4447 * are public but response contains private IP.
4448 * * 2 (enabled). Update without exception.
4449 *
4450 * See also contact_rewrite_method field.
4451 *
4452 * Default: 1
4453 */
4454 pj_bool_t allow_contact_rewrite;
4455
4456 /**
4457 * Specify how Contact update will be done with the registration, if
4458 * \a allow_contact_rewrite is enabled. The value is bitmask combination of
4459 * \a pjsua_contact_rewrite_method. See also pjsua_contact_rewrite_method.
4460 *
4461 * Value PJSUA_CONTACT_REWRITE_UNREGISTER(1) is the legacy behavior.
4462 *
4463 * Default value: PJSUA_CONTACT_REWRITE_METHOD
4464 * (PJSUA_CONTACT_REWRITE_NO_UNREG | PJSUA_CONTACT_REWRITE_ALWAYS_UPDATE)
4465 */
4466 int contact_rewrite_method;
4467
4468 /**
4469 * Specify if source TCP port should be used as the initial Contact
4470 * address if TCP/TLS transport is used. Note that this feature will
4471 * be automatically turned off when nameserver is configured because
4472 * it may yield different destination address due to DNS SRV resolution.
4473 * Also some platforms are unable to report the local address of the
4474 * TCP socket when it is still connecting. In these cases, this
4475 * feature will also be turned off.
4476 *
4477 * Default: PJ_TRUE (yes).
4478 */
4479 pj_bool_t contact_use_src_port;
4480
4481 /**
4482 * This option is used to overwrite the "sent-by" field of the Via header
4483 * for outgoing messages with the same interface address as the one in
4484 * the REGISTER request, as long as the request uses the same transport
4485 * instance as the previous REGISTER request.
4486 *
4487 * Default: 1 (yes)
4488 */
4489 pj_bool_t allow_via_rewrite;
4490
4491 /**
4492 * This option controls whether the IP address in SDP should be replaced
4493 * with the IP address found in Via header of the REGISTER response, ONLY
4494 * when STUN and ICE are not used. If the value is FALSE (the original
4495 * behavior), then the local IP address will be used. If TRUE, and when
4496 * STUN and ICE are disabled, then the IP address found in registration
4497 * response will be used.
4498 *
4499 * Default: PJ_FALSE (no)
4500 */
4501 pj_bool_t allow_sdp_nat_rewrite;
4502
4503 /**
4504 * Control the use of SIP outbound feature. SIP outbound is described in
4505 * RFC 5626 to enable proxies or registrar to send inbound requests back
4506 * to UA using the same connection initiated by the UA for its
4507 * registration. This feature is highly useful in NAT-ed deployemtns,
4508 * hence it is enabled by default.
4509 *
4510 * Note: currently SIP outbound can only be used with TCP and TLS
4511 * transports. If UDP is used for the registration, the SIP outbound
4512 * feature will be silently ignored for the account.
4513 *
4514 * Default: PJ_TRUE
4515 */
4516 unsigned use_rfc5626;
4517
4518 /**
4519 * Specify SIP outbound (RFC 5626) instance ID to be used by this
4520 * application. If empty, an instance ID will be generated based on
4521 * the hostname of this agent. If application specifies this parameter, the
4522 * value will look like "<urn:uuid:00000000-0000-1000-8000-AABBCCDDEEFF>"
4523 * without the doublequote.
4524 *
4525 * Default: empty
4526 */
4527 pj_str_t rfc5626_instance_id;
4528
4529 /**
4530 * Specify SIP outbound (RFC 5626) registration ID. The default value
4531 * is empty, which would cause the library to automatically generate
4532 * a suitable value.
4533 *
4534 * Default: empty
4535 */
4536 pj_str_t rfc5626_reg_id;
4537
4538 /**
4539 * Set the interval for periodic keep-alive transmission for this account.
4540 * If this value is zero, keep-alive will be disabled for this account.
4541 * The keep-alive transmission will be sent to the registrar's address,
4542 * after successful registration.
4543 *
4544 * Default: 15 (seconds)
4545 */
4546 unsigned ka_interval;
4547
4548 /**
4549 * Specify the data to be transmitted as keep-alive packets.
4550 *
4551 * Default: CR-LF
4552 */
4553 pj_str_t ka_data;
4554
4555 /**
4556 * Specifies text stream redundancy level, as specified in RFC 4103
4557 * and 2198. When redundancy is enabled, each packet transmission
4558 * will contain the current text data as well as a number of the
4559 * previously transmitted text data to provide levels of redundancy.
4560 * This mechanism offers protection against loss of data at the cost
4561 * of additional bandwidth required.
4562 *
4563 * Value is integer indicating redundancy levels, i.e. the number
4564 * of previous text data to be included with the current packet.
4565 * (0 means disabled/no redundancy).
4566 * A value of 1 provides an adequate protection against an average
4567 * packet loss of up to 50%, while 2 can potentially protect
4568 * against 66.7%.
4569 * The maximum value is determined by PJMEDIA_TXT_STREAM_MAX_RED_LEVELS.
4570 *
4571 * Note that the redundancy level actually used is subject to remote
4572 * capability and we will opt to use the lower redundancy value based
4573 * on the result of SDP negotiation.
4574 *
4575 * Default: PJSUA_TXT_DEFAULT_REDUNDANCY_LEVEL (2), as per the
4576 * recommendation of RFC 4103.
4577 */
4578 int txt_red_level;
4579
4580 /**
4581 * Specify whether incoming video should be shown to screen by default.
4582 * This applies to incoming call (INVITE), incoming re-INVITE, and
4583 * incoming UPDATE requests.
4584 *
4585 * Regardless of this setting, application can detect incoming video
4586 * by implementing \a on_call_media_state() callback and enumerating
4587 * the media stream(s) with #pjsua_call_get_info(). Once incoming
4588 * video is recognised, application may retrieve the window associated
4589 * with the incoming video and show or hide it with
4590 * #pjsua_vid_win_set_show().
4591 *
4592 * Default: PJ_FALSE
4593 */
4594 pj_bool_t vid_in_auto_show;
4595
4596 /**
4597 * Specify whether outgoing video should be activated by default when
4598 * making outgoing calls and/or when incoming video is detected. This
4599 * applies to incoming and outgoing calls, incoming re-INVITE, and
4600 * incoming UPDATE. If the setting is non-zero, outgoing video
4601 * transmission will be started as soon as response to these requests
4602 * is sent (or received).
4603 *
4604 * Regardless of the value of this setting, application can start and
4605 * stop outgoing video transmission with #pjsua_call_set_vid_strm().
4606 *
4607 * Default: PJ_FALSE
4608 */
4609 pj_bool_t vid_out_auto_transmit;
4610
4611 /**
4612 * Specify video window's flags. The value is a bitmask combination of
4613 * #pjmedia_vid_dev_wnd_flag.
4614 *
4615 * Default: 0
4616 */
4617 unsigned vid_wnd_flags;
4618
4619 /**
4620 * Specify the default capture device to be used by this account. If
4621 * \a vid_out_auto_transmit is enabled, this device will be used for
4622 * capturing video.
4623 *
4624 * Default: PJMEDIA_VID_DEFAULT_CAPTURE_DEV
4625 */
4626 pjmedia_vid_dev_index vid_cap_dev;
4627
4628 /**
4629 * Specify the default rendering device to be used by this account.
4630 *
4631 * Default: PJMEDIA_VID_DEFAULT_RENDER_DEV
4632 */
4633 pjmedia_vid_dev_index vid_rend_dev;
4634
4635 /**
4636 * Specify the send rate control for video stream.
4637 *
4638 * Default: see #pjmedia_vid_stream_rc_config
4639 */
4640 pjmedia_vid_stream_rc_config vid_stream_rc_cfg;
4641
4642 /**
4643 * Specify the send keyframe config for video stream.
4644 *
4645 * Default: see #pjmedia_vid_stream_sk_config
4646 */
4647 pjmedia_vid_stream_sk_config vid_stream_sk_cfg;
4648
4649 /**
4650 * Media transport config.
4651 *
4652 * For \a port and \a port_range settings, RTCP port is selected as
4653 * RTP port+1.
4654 * Example: \a port=5000, \a port_range=4
4655 * - Available ports: 5000, 5002, 5004 (Media/RTP transport)
4656 * 5001, 5003, 5005 (Media/RTCP transport)
4657 */
4658 pjsua_transport_config rtp_cfg;
4659
4660 /**
4661 * Specify NAT64 options.
4662 *
4663 * Default: PJSUA_NAT64_DISABLED
4664 */
4665 pjsua_nat64_opt nat64_opt;
4666
4667 /**
4668 * Specify whether IPv6 should be used for SIP signalling.
4669 *
4670 * Default: PJSUA_IPV6_ENABLED_NO_PREFERENCE
4671 * (IP version used will be based on the address resolution
4672 * returned by OS/resolver)
4673 */
4674 pjsua_ipv6_use ipv6_sip_use;
4675
4676 /**
4677 * Specify whether IPv6 should be used on media.
4678 *
4679 * Default: PJSUA_IPV6_ENABLED_PREFER_IPV4
4680 * (Dual stack media, capable to use IPv4/IPv6.
4681 * Outgoing offer will prefer to use IPv4)
4682 */
4683 pjsua_ipv6_use ipv6_media_use;
4684
4685 /**
4686 * Control the use of STUN for the SIP signaling.
4687 *
4688 * Default: PJSUA_STUN_USE_DEFAULT
4689 */
4690 pjsua_stun_use sip_stun_use;
4691
4692 /**
4693 * Control the use of STUN for the media transports.
4694 *
4695 * Default: PJSUA_STUN_RETRY_ON_FAILURE
4696 */
4697 pjsua_stun_use media_stun_use;
4698
4699 /**
4700 * Control the use of UPnP for the SIP signaling.
4701 *
4702 * Default: PJSUA_UPNP_USE_DEFAULT
4703 */
4704 pjsua_upnp_use sip_upnp_use;
4705
4706 /**
4707 * Control the use of UPnP for the media transports.
4708 *
4709 * Default: PJSUA_UPNP_USE_DEFAULT
4710 */
4711 pjsua_upnp_use media_upnp_use;
4712
4713 /**
4714 * Use loopback media transport. This may be useful if application
4715 * doesn't want PJSIP to create real media transports/sockets, such as
4716 * when using third party media.
4717 *
4718 * Default: PJ_FALSE
4719 */
4720 pj_bool_t use_loop_med_tp;
4721
4722 /**
4723 * Enable local loopback when loop_med_tp_use is set to PJ_TRUE.
4724 * If enabled, packets sent to the transport will be sent back to
4725 * the streams attached to the transport.
4726 *
4727 * Default: PJ_FALSE
4728 */
4729 pj_bool_t enable_loopback;
4730
4731 /**
4732 * Control the use of ICE in the account. By default, the settings in the
4733 * \a pjsua_media_config will be used.
4734 *
4735 * Default: PJSUA_ICE_CONFIG_USE_DEFAULT
4736 */
4737 pjsua_ice_config_use ice_cfg_use;
4738
4739 /**
4740 * The custom ICE setting for this account. This setting will only be
4741 * used if \a ice_cfg_use is set to PJSUA_ICE_CONFIG_USE_CUSTOM
4742 */
4743 pjsua_ice_config ice_cfg;
4744
4745 /**
4746 * Control the use of TURN in the account. By default, the settings in the
4747 * \a pjsua_media_config will be used
4748 *
4749 * Default: PJSUA_TURN_CONFIG_USE_DEFAULT
4750 */
4751 pjsua_turn_config_use turn_cfg_use;
4752
4753 /**
4754 * The custom TURN setting for this account. This setting will only be
4755 * used if \a turn_cfg_use is set to PJSUA_TURN_CONFIG_USE_CUSTOM
4756 */
4757 pjsua_turn_config turn_cfg;
4758
4759 /**
4760 * Specify whether secure media transport should be used for this account.
4761 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
4762 * PJMEDIA_SRTP_MANDATORY.
4763 *
4764 * Default: #PJSUA_DEFAULT_USE_SRTP
4765 */
4766 pjmedia_srtp_use use_srtp;
4767
4768 /**
4769 * Specify whether SRTP requires secure signaling to be used. This option
4770 * is only used when \a use_srtp option above is non-zero.
4771 *
4772 * Valid values are:
4773 * 0: SRTP does not require secure signaling
4774 * 1: SRTP requires secure transport such as TLS
4775 * 2: SRTP requires secure end-to-end transport (SIPS)
4776 *
4777 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
4778 */
4779 int srtp_secure_signaling;
4780
4781 /**
4782 * This setting has been deprecated and will be ignored.
4783 */
4784 pj_bool_t srtp_optional_dup_offer;
4785
4786 /**
4787 * Specify SRTP transport setting. Application can initialize it with
4788 * default values using pjsua_srtp_opt_default().
4789 */
4790 pjsua_srtp_opt srtp_opt;
4791
4792 /**
4793 * Specify interval of auto registration retry upon registration failure,
4794 * in seconds. Set to 0 to disable auto re-registration. Note that
4795 * registration will only be automatically retried for temporal failures
4796 * considered to be recoverable in relatively short term, such as:
4797 * 408 (Request Timeout), 480 (Temporarily Unavailable),
4798 * 500 (Internal Server Error), 502 (Bad Gateway),
4799 * 503 (Service Unavailable), 504 (Server Timeout),
4800 * 6xx (global failure), and failure caused by transport problem.
4801 * For registration retry caused by transport failure, the first retry
4802 * will be done after \a reg_first_retry_interval seconds instead.
4803 * Note that the interval will be randomized slightly by some seconds
4804 * (specified in \a reg_retry_random_interval) to avoid all clients
4805 * re-registering at the same time.
4806 *
4807 * See also \a reg_first_retry_interval setting.
4808 *
4809 * Default: #PJSUA_REG_RETRY_INTERVAL
4810 */
4811 unsigned reg_retry_interval;
4812
4813 /**
4814 * This specifies the interval for the first registration retry. The
4815 * registration retry is explained in \a reg_retry_interval. Note that
4816 * the value here will also be randomized by some seconds (specified
4817 * in \a reg_retry_random_interval) to avoid all clients re-registering
4818 * at the same time.
4819 *
4820 * Default: 0
4821 */
4822 unsigned reg_first_retry_interval;
4823
4824 /**
4825 * This specifies maximum randomized value to be added/substracted
4826 * to/from the registration retry interval specified in \a
4827 * reg_retry_interval and \a reg_first_retry_interval, in second.
4828 * This is useful to avoid all clients re-registering at the same time.
4829 * For example, if the registration retry interval is set to 100 seconds
4830 * and this is set to 10 seconds, the actual registration retry interval
4831 * will be in the range of 90 to 110 seconds.
4832 *
4833 * Default: 10
4834 */
4835 unsigned reg_retry_random_interval;
4836
4837 /**
4838 * Specify whether calls of the configured account should be dropped
4839 * after registration failure and an attempt of re-registration has
4840 * also failed.
4841 *
4842 * Default: PJ_FALSE (disabled)
4843 */
4844 pj_bool_t drop_calls_on_reg_fail;
4845
4846 /**
4847 * Specify how the registration uses the outbound and account proxy
4848 * settings. This controls if and what Route headers will appear in
4849 * the REGISTER request of this account. The value is bitmask combination
4850 * of PJSUA_REG_USE_OUTBOUND_PROXY and PJSUA_REG_USE_ACC_PROXY bits.
4851 * If the value is set to 0, the REGISTER request will not use any proxy
4852 * (i.e. it will not have any Route headers).
4853 *
4854 * Default: 3 (PJSUA_REG_USE_OUTBOUND_PROXY | PJSUA_REG_USE_ACC_PROXY)
4855 */
4856 unsigned reg_use_proxy;
4857
4858 #if defined(PJMEDIA_STREAM_ENABLE_KA) && (PJMEDIA_STREAM_ENABLE_KA != 0)
4859 /**
4860 * Specify whether stream keep-alive and NAT hole punching with
4861 * non-codec-VAD mechanism (see @ref PJMEDIA_STREAM_ENABLE_KA) is enabled
4862 * for this account.
4863 *
4864 * Default: PJ_FALSE (disabled)
4865 */
4866 pj_bool_t use_stream_ka;
4867
4868 /**
4869 * Specify the keepalive configuration for stream.
4870 *
4871 * Default: see #pjmedia_stream_ka_config
4872 */
4873 pjmedia_stream_ka_config stream_ka_cfg;
4874 #endif
4875
4876 /**
4877 * Specify how to offer call hold to remote peer. Please see the
4878 * documentation on #pjsua_call_hold_type for more info.
4879 *
4880 * Default: PJSUA_CALL_HOLD_TYPE_DEFAULT
4881 */
4882 pjsua_call_hold_type call_hold_type;
4883
4884
4885 /**
4886 * Specify whether the account should register as soon as it is
4887 * added to the UA. Application can set this to PJ_FALSE and control
4888 * the registration manually with pjsua_acc_set_registration().
4889 *
4890 * Default: PJ_TRUE
4891 */
4892 pj_bool_t register_on_acc_add;
4893
4894 /**
4895 * Specify whether account modification with pjsua_acc_modify() should
4896 * automatically update registration if necessary, for example if
4897 * account credentials change.
4898 *
4899 * Disable this when immediate registration is not desirable, such as
4900 * during IP address change.
4901 *
4902 * Default: PJ_FALSE.
4903 */
4904 pj_bool_t disable_reg_on_modify;
4905
4906 /**
4907 * Specify account configuration specific to IP address change used when
4908 * calling #pjsua_handle_ip_change().
4909 */
4910 pjsua_ip_change_acc_cfg ip_change_cfg;
4911
4912 /**
4913 * Enable RTP and RTCP multiplexing.
4914 */
4915 pj_bool_t enable_rtcp_mux;
4916
4917 /**
4918 * RTCP Feedback configuration.
4919 */
4920 pjmedia_rtcp_fb_setting rtcp_fb_cfg;
4921
4922 /**
4923 * Enable RTCP Extended Report (RTCP XR).
4924 *
4925 * Default: PJMEDIA_STREAM_ENABLE_XR
4926 */
4927 pj_bool_t enable_rtcp_xr;
4928
4929 /**
4930 * Use a shared authorization session within this account.
4931 * This will use the account's credentials on outgoing requests,
4932 * so that fewer 401/407 responses will be returned.
4933 *
4934 * When the \a on_auth_challenge callback is set, the shared session
4935 * is also used as the auth session passed to the callback, regardless
4936 * of this setting.
4937 *
4938 * Needs PJSIP_AUTH_AUTO_SEND_NEXT and PJSIP_AUTH_HEADER_CACHING
4939 * enabled to work properly, and also will grow usage of the used pool for
4940 * the cached headers.
4941 *
4942 * Default: PJ_FALSE
4943 *
4944 * @see pjsua_callback::on_auth_challenge
4945 */
4946 pj_bool_t use_shared_auth;
4947
4948 /**
4949 * Specify whether incoming SIP MESSAGE requests are responded
4950 * automatically.
4951 *
4952 * If set to PJ_TRUE (automatic response), incoming MESSAGE requests
4953 * will be responded to immediately with SIP 200 OK (legacy behavior).
4954 *
4955 * If set to PJ_FALSE, incoming MESSAGE requests will create UAS
4956 * transactions supporting explicit responses and defering responses.
4957 *
4958 * The application may either respond immediately in the on_pager() or
4959 * on_pager2() callbacks by using pjsua_acc_send_response(), or defer the
4960 * response to later time. In the latter case, the application must clone the
4961 * rx_data by calling pjsip_rx_data_clone() within on_pager() or on_pager2()
4962 * callbacks. The cloned rx_data and the pointer to the transaction can then
4963 * be used later for pjsua_acc_send_response().
4964 *
4965 * Default: PJ_TRUE (automatic response for backward compatibility)
4966 */
4967 pj_bool_t auto_repond_sip_message;
4968
4969
4970 } pjsua_acc_config;
4971
4972
4973 /**
4974 * Initialize ICE config from a media config. If the \a pool argument
4975 * is NULL, a simple memcpy() will be used.
4976 *
4977 * @param pool Memory to duplicate strings.
4978 * @param dst Destination config.
4979 * @param src Source config.
4980 */
4981 PJ_DECL(void) pjsua_ice_config_from_media_config(pj_pool_t *pool,
4982 pjsua_ice_config *dst,
4983 const pjsua_media_config *src);
4984
4985 /**
4986 * Clone. If the \a pool argument is NULL, a simple memcpy() will be used.
4987 *
4988 * @param pool Memory to duplicate strings.
4989 * @param dst Destination config.
4990 * @param src Source config.
4991 */
4992 PJ_DECL(void) pjsua_ice_config_dup( pj_pool_t *pool,
4993 pjsua_ice_config *dst,
4994 const pjsua_ice_config *src);
4995
4996 /**
4997 * Initialize TURN config from a media config. If the \a pool argument
4998 * is NULL, a simple memcpy() will be used.
4999 *
5000 * @param pool Memory to duplicate strings.
5001 * @param dst Destination config.
5002 * @param src Source config.
5003 */
5004 PJ_DECL(void) pjsua_turn_config_from_media_config(pj_pool_t *pool,
5005 pjsua_turn_config *dst,
5006 const pjsua_media_config *src);
5007
5008 /**
5009 * Clone. If the \a pool argument is NULL, a simple memcpy() will be used.
5010 *
5011 * @param pool Memory to duplicate strings.
5012 * @param dst Destination config.
5013 * @param src Source config.
5014 */
5015 PJ_DECL(void) pjsua_turn_config_dup(pj_pool_t *pool,
5016 pjsua_turn_config *dst,
5017 const pjsua_turn_config *src);
5018
5019
5020 /**
5021 * Call this function to initialize SRTP config with default values.
5022 *
5023 * @param cfg The SRTP config to be initialized.
5024 */
5025 PJ_DECL(void) pjsua_srtp_opt_default(pjsua_srtp_opt *cfg);
5026
5027
5028 /**
5029 * Duplicate SRTP transport setting. If the \a pool argument is NULL,
5030 * a simple memcpy() will be used.
5031 *
5032 * @param pool Memory to duplicate strings.
5033 * @param dst Destination setting.
5034 * @param src Source setting.
5035 * @param check_str If set to TRUE, the function will check if strings
5036 * are identical before copying. Identical strings
5037 * will not be duplicated.
5038 * If set to FALSE, all strings will be duplicated.
5039 */
5040 PJ_DECL(void) pjsua_srtp_opt_dup(pj_pool_t *pool, pjsua_srtp_opt *dst,
5041 const pjsua_srtp_opt *src,
5042 pj_bool_t check_str);
5043
5044
5045 /**
5046 * Call this function to initialize account config with default values.
5047 *
5048 * @param cfg The account config to be initialized.
5049 */
5050 PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
5051
5052
5053 /**
5054 * Duplicate account config.
5055 *
5056 * @param pool Pool to be used for duplicating the config.
5057 * @param dst Destination configuration.
5058 * @param src Source configuration.
5059 */
5060 PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
5061 pjsua_acc_config *dst,
5062 const pjsua_acc_config *src);
5063
5064
5065 /**
5066 * Account info. Application can query account info by calling
5067 * #pjsua_acc_get_info().
5068 */
5069 typedef struct pjsua_acc_info
5070 {
5071 /**
5072 * The account ID.
5073 */
5074 pjsua_acc_id id;
5075
5076 /**
5077 * Flag to indicate whether this is the default account.
5078 */
5079 pj_bool_t is_default;
5080
5081 /**
5082 * Account URI
5083 */
5084 pj_str_t acc_uri;
5085
5086 /**
5087 * Flag to tell whether this account has registration setting
5088 * (reg_uri is not empty).
5089 */
5090 pj_bool_t has_registration;
5091
5092 /**
5093 * An up to date expiration interval for account registration session,
5094 * PJSIP_EXPIRES_NOT_SPECIFIED if the account doesn't have reg session.
5095 */
5096 unsigned expires;
5097
5098 /**
5099 * Last registration status code. If status code is zero, the account
5100 * is currently not registered. Any other value indicates the SIP
5101 * status code of the registration.
5102 */
5103 pjsip_status_code status;
5104
5105 /**
5106 * Last registration error code. When the status field contains a SIP
5107 * status code that indicates a registration failure, last registration
5108 * error code contains the error code that causes the failure. In any
5109 * other case, its value is zero.
5110 */
5111 pj_status_t reg_last_err;
5112
5113 /**
5114 * String describing the registration status.
5115 */
5116 pj_str_t status_text;
5117
5118 /**
5119 * Presence online status for this account.
5120 */
5121 pj_bool_t online_status;
5122
5123 /**
5124 * Presence online status text.
5125 */
5126 pj_str_t online_status_text;
5127
5128 /**
5129 * Extended RPID online status information.
5130 */
5131 pjrpid_element rpid;
5132
5133 /**
5134 * Buffer that is used internally to store the status text.
5135 */
5136 char buf_[PJ_ERR_MSG_SIZE];
5137
5138 } pjsua_acc_info;
5139
5140
5141
5142 /**
5143 * Get number of current accounts.
5144 *
5145 * @return Current number of accounts.
5146 */
5147 PJ_DECL(unsigned) pjsua_acc_get_count(void);
5148
5149
5150 /**
5151 * Check if the specified account ID is valid.
5152 *
5153 * @param acc_id Account ID to check.
5154 *
5155 * @return Non-zero if account ID is valid.
5156 */
5157 PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
5158
5159
5160 /**
5161 * Set default account to be used when incoming and outgoing
5162 * requests doesn't match any accounts.
5163 *
5164 * @param acc_id The account ID to be used as default.
5165 *
5166 * @return PJ_SUCCESS on success.
5167 */
5168 PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
5169
5170
5171 /**
5172 * Get default account to be used when receiving incoming requests (calls),
5173 * when the destination of the incoming call doesn't match any other
5174 * accounts.
5175 *
5176 * @return The default account ID, or PJSUA_INVALID_ID if no
5177 * default account is configured.
5178 */
5179 PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
5180
5181
5182 /**
5183 * Add a new account to pjsua. PJSUA must have been initialized (with
5184 * #pjsua_init()) before calling this function. If registration is configured
5185 * for this account, this function would also start the SIP registration
5186 * session with the SIP registrar server. This SIP registration session
5187 * will be maintained internally by the library, and application doesn't
5188 * need to do anything to maintain the registration session.
5189 *
5190 *
5191 * @param acc_cfg Account configuration.
5192 * @param is_default If non-zero, this account will be set as the default
5193 * account. The default account will be used when sending
5194 * outgoing requests (e.g. making call) when no account is
5195 * specified, and when receiving incoming requests when the
5196 * request does not match any accounts. It is recommended
5197 * that default account is set to local/LAN account.
5198 * @param p_acc_id Pointer to receive account ID of the new account.
5199 *
5200 * @return PJ_SUCCESS on success, or the appropriate error code.
5201 */
5202 PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
5203 pj_bool_t is_default,
5204 pjsua_acc_id *p_acc_id);
5205
5206
5207 /**
5208 * Add a local account. A local account is used to identify local endpoint
5209 * instead of a specific user, and for this reason, a transport ID is needed
5210 * to obtain the local address information.
5211 *
5212 * @param tid Transport ID to generate account address.
5213 * @param is_default If non-zero, this account will be set as the default
5214 * account. The default account will be used when sending
5215 * outgoing requests (e.g. making call) when no account is
5216 * specified, and when receiving incoming requests when the
5217 * request does not match any accounts. It is recommended
5218 * that default account is set to local/LAN account.
5219 * @param p_acc_id Pointer to receive account ID of the new account.
5220 *
5221 * @return PJ_SUCCESS on success, or the appropriate error code.
5222 */
5223 PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
5224 pj_bool_t is_default,
5225 pjsua_acc_id *p_acc_id);
5226
5227 /**
5228 * Set arbitrary data to be associated with the account.
5229 *
5230 * @param acc_id The account ID.
5231 * @param user_data User/application data.
5232 *
5233 * @return PJ_SUCCESS on success, or the appropriate error code.
5234 */
5235 PJ_DECL(pj_status_t) pjsua_acc_set_user_data(pjsua_acc_id acc_id,
5236 void *user_data);
5237
5238
5239 /**
5240 * Retrieve arbitrary data associated with the account.
5241 *
5242 * @param acc_id The account ID.
5243 *
5244 * @return The user data. In the case where the account ID is
5245 * not valid, NULL is returned.
5246 */
5247 PJ_DECL(void*) pjsua_acc_get_user_data(pjsua_acc_id acc_id);
5248
5249
5250 /**
5251 * Parameters for account deletion with pjsua_acc_del2(). Application should
5252 * use #pjsua_acc_del_param_default() to initialize this structure with its
5253 * default values.
5254 */
5255 typedef struct pjsua_acc_del_param
5256 {
5257 /**
5258 * If PJ_TRUE, the account will always be deleted even when there are
5259 * active calls using it (a warning will be logged). If PJ_FALSE, the
5260 * function will return PJ_EBUSY when active calls exist.
5261 *
5262 * Default: PJ_FALSE
5263 */
5264 pj_bool_t force;
5265
5266 } pjsua_acc_del_param;
5267
5268
5269 /**
5270 * Initialize account deletion parameters with default values.
5271 *
5272 * @param prm The parameter to be initialized.
5273 */
5274 PJ_DECL(void) pjsua_acc_del_param_default(pjsua_acc_del_param *prm);
5275
5276
5277 /**
5278 * Delete an account. This will unregister the account from the SIP server,
5279 * if necessary, and terminate server side presence subscriptions associated
5280 * with this account.
5281 *
5282 * This function always deletes the account regardless of active calls
5283 * (equivalent to calling pjsua_acc_del2() with force=PJ_TRUE). For safer
5284 * behavior that checks for active calls, use pjsua_acc_del2() instead.
5285 *
5286 * @param acc_id Id of the account to be deleted.
5287 *
5288 * @return PJ_SUCCESS on success, or the appropriate error code.
5289 */
5290 PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
5291
5292
5293 /**
5294 * Delete an account with additional options. This will unregister the account
5295 * from the SIP server, if necessary, and terminate server side presence
5296 * subscriptions associated with this account.
5297 *
5298 * By default (force=PJ_FALSE), if there are active calls using this account,
5299 * this function will return PJ_EBUSY. Application should hang up all calls
5300 * first using pjsua_call_hangup() and wait until the calls are fully
5301 * disconnected before deleting the account.
5302 *
5303 * When force=PJ_TRUE, the account will be deleted even if there are active
5304 * calls. A warning will be logged but deletion will proceed.
5305 *
5306 * @param acc_id Id of the account to be deleted.
5307 * @param prm Account deletion parameters.
5308 *
5309 * @return PJ_SUCCESS on success, PJ_EBUSY if force is PJ_FALSE
5310 * and there are active calls using this account, or the
5311 * appropriate error code.
5312 */
5313 PJ_DECL(pj_status_t) pjsua_acc_del2(pjsua_acc_id acc_id,
5314 const pjsua_acc_del_param *prm);
5315
5316
5317 /**
5318 * Get current config for the account. This will copy current account setting
5319 * to the specified parameter. Note that all pointers in the settings will
5320 * point to the original settings in the account and application must not
5321 * modify the values in any way. Application must also take care that these
5322 * data is only valid until the account is destroyed.
5323 *
5324 * @param acc_id The account ID.
5325 * @param pool Pool to duplicate the config.
5326 * @param acc_cfg Structure to receive the settings.
5327 *
5328 * @return PJ_SUCCESS on success, or the appropriate error code.
5329 */
5330 PJ_DECL(pj_status_t) pjsua_acc_get_config(pjsua_acc_id acc_id,
5331 pj_pool_t *pool,
5332 pjsua_acc_config *acc_cfg);
5333
5334
5335 /**
5336 * Modify account configuration setting. This function may trigger
5337 * unregistration (of old account setting) and re-registration (of the new
5338 * account setting), e.g: changing account ID, credential, registar, or
5339 * proxy setting.
5340 *
5341 * Note:
5342 * - when the new config triggers unregistration, the pjsua callback
5343 * on_reg_state()/on_reg_state2() for the unregistration will not be called
5344 * and any failure in the unregistration will be ignored, so if application
5345 * needs to be sure about the unregistration status, it should unregister
5346 * manually and wait for the callback before calling this function
5347 * - when the new config triggers re-registration and the re-registration
5348 * fails, the account setting will not be reverted back to the old setting
5349 * and the account will be in unregistered state.
5350 *
5351 * @param acc_id Id of the account to be modified.
5352 * @param acc_cfg New account configuration.
5353 *
5354 * @return PJ_SUCCESS on success, or the appropriate error code.
5355 */
5356 PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
5357 const pjsua_acc_config *acc_cfg);
5358
5359 /**
5360 * Send response to incoming request (e.g. SIP MESSAGE) that was
5361 * processed by a UAS transaction.
5362 *
5363 * This function can be used when the application wants to defer a
5364 * response to an incoming request that was processed by
5365 * a UAS transaction.
5366 *
5367 * @param acc_id The account that will send the response.
5368 * @param rdata The received request data.
5369 * @param tsx The UAS transaction that was created for the incoming
5370 * request.
5371 * @param st_code Status code to be sent (e.g., 200 for OK, 400 for
5372 * Bad Request, etc.).
5373 * @param st_text Optional status text. If NULL, default status text for
5374 * the status code will be used.
5375 * @param msg_data Optional headers etc. to be added to the outgoing
5376 * response, or NULL if no custom header is desired.
5377 *
5378 * @return PJ_SUCCESS on success, or the appropriate error code.
5379 */
5380 PJ_DECL(pj_status_t) pjsua_acc_send_response(pjsua_acc_id acc_id,
5381 pjsip_rx_data *rdata,
5382 pjsip_transaction *tsx,
5383 int st_code,
5384 const pj_str_t *st_text,
5385 const pjsua_msg_data *msg_data);
5386
5387 /**
5388 * Send arbitrary out-of-dialog requests from an account, e.g. OPTIONS.
5389 * The application should use the call or presence API to create
5390 * dialog-related requests.
5391 *
5392 * @param acc_id The account ID.
5393 * @param dest_uri URI to be put into the To header (normally is the same
5394 * as the target URI).
5395 * @param method The SIP method of the request.
5396 * @param options This is for future use (currently only NULL is
5397 * supported).
5398 * @param token Arbitrary token (user data owned by the application)
5399 * to be passed back to the application in callback
5400 * on_acc_send_request().
5401 * @param msg_data Optional headers etc. to be added to the outgoing
5402 * request, or NULL if no custom header is desired.
5403 *
5404 * @return PJ_SUCCESS or the error code.
5405 */
5406 PJ_DECL(pj_status_t) pjsua_acc_send_request(pjsua_acc_id acc_id,
5407 const pj_str_t *dest_uri,
5408 const pj_str_t *method,
5409 void *options,
5410 void *token,
5411 const pjsua_msg_data *msg_data);
5412
5413 /**
5414 * Modify account's presence status to be advertised to remote/presence
5415 * subscribers. This would trigger the sending of outgoing NOTIFY request
5416 * if there are server side presence subscription for this account, and/or
5417 * outgoing PUBLISH if presence publication is enabled for this account.
5418 *
5419 * @see pjsua_acc_set_online_status2()
5420 *
5421 * @param acc_id The account ID.
5422 * @param is_online True of false.
5423 *
5424 * @return PJ_SUCCESS on success, or the appropriate error code.
5425 */
5426 PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
5427 pj_bool_t is_online);
5428
5429 /**
5430 * Modify account's presence status to be advertised to remote/presence
5431 * subscribers. This would trigger the sending of outgoing NOTIFY request
5432 * if there are server side presence subscription for this account, and/or
5433 * outgoing PUBLISH if presence publication is enabled for this account.
5434 *
5435 * @see pjsua_acc_set_online_status()
5436 *
5437 * @param acc_id The account ID.
5438 * @param is_online True of false.
5439 * @param pr Extended information in subset of RPID format
5440 * which allows setting custom presence text.
5441 *
5442 * @return PJ_SUCCESS on success, or the appropriate error code.
5443 */
5444 PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
5445 pj_bool_t is_online,
5446 const pjrpid_element *pr);
5447
5448 /**
5449 * Update registration or perform unregistration. If registration is
5450 * configured for this account, then initial SIP REGISTER will be sent
5451 * when the account is added with #pjsua_acc_add(). Application normally
5452 * only need to call this function if it wants to manually update the
5453 * registration or to unregister from the server.
5454 *
5455 * @param acc_id The account ID.
5456 * @param renew If renew argument is zero, this will start
5457 * unregistration process.
5458 *
5459 * @return PJ_SUCCESS on success, or the appropriate error code.
5460 */
5461 PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
5462 pj_bool_t renew);
5463
5464 /**
5465 * Get information about the specified account.
5466 *
5467 * @param acc_id Account identification.
5468 * @param info Pointer to receive account information.
5469 *
5470 * @return PJ_SUCCESS on success, or the appropriate error code.
5471 */
5472 PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
5473 pjsua_acc_info *info);
5474
5475
5476 /**
5477 * Enumerate all account currently active in the library. This will fill
5478 * the array with the account Ids, and application can then query the
5479 * account information for each id with #pjsua_acc_get_info().
5480 *
5481 * @see pjsua_acc_enum_info().
5482 *
5483 * @param ids Array of account IDs to be initialized.
5484 * @param count In input, specifies the maximum number of elements.
5485 * On return, it contains the actual number of elements.
5486 *
5487 * @return PJ_SUCCESS on success, or the appropriate error code.
5488 */
5489 PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
5490 unsigned *count );
5491
5492
5493 /**
5494 * Enumerate account informations.
5495 *
5496 * @param info Array of account infos to be initialized.
5497 * @param count In input, specifies the maximum number of elements.
5498 * On return, it contains the actual number of elements.
5499 *
5500 * @return PJ_SUCCESS on success, or the appropriate error code.
5501 */
5502 PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
5503 unsigned *count );
5504
5505
5506 /**
5507 * This is an internal function to find the most appropriate account to
5508 * used to reach to the specified URL.
5509 *
5510 * @param url The remote URL to reach.
5511 *
5512 * @return Account id.
5513 */
5514 PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
5515
5516
5517 /**
5518 * This is an internal function to find the most appropriate account to be
5519 * used to handle incoming calls.
5520 *
5521 * @param rdata The incoming request message.
5522 *
5523 * @return Account id.
5524 */
5525 PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
5526
5527
5528 /**
5529 * Create arbitrary requests using the account. Application should only use
5530 * this function to create auxiliary requests outside dialog, such as
5531 * OPTIONS, and use the call or presence API to create dialog related
5532 * requests.
5533 *
5534 * @param acc_id The account ID.
5535 * @param method The SIP method of the request.
5536 * @param target Target URI.
5537 * @param p_tdata Pointer to receive the request.
5538 *
5539 * @return PJ_SUCCESS or the error code.
5540 */
5541 PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
5542 const pjsip_method *method,
5543 const pj_str_t *target,
5544 pjsip_tx_data **p_tdata);
5545
5546
5547 /**
5548 * Create a suitable Contact header value, based on the specified target URI
5549 * for the specified account.
5550 *
5551 * @param pool Pool to allocate memory for the string.
5552 * @param contact The string where the Contact will be stored.
5553 * @param acc_id Account ID.
5554 * @param uri Destination URI of the request.
5555 *
5556 * @return PJ_SUCCESS on success, other on error.
5557 */
5558 PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
5559 pj_str_t *contact,
5560 pjsua_acc_id acc_id,
5561 const pj_str_t *uri);
5562
5563
5564
5565 /**
5566 * Create a suitable Contact header value, based on the information in the
5567 * incoming request.
5568 *
5569 * @param pool Pool to allocate memory for the string.
5570 * @param contact The string where the Contact will be stored.
5571 * @param acc_id Account ID.
5572 * @param rdata Incoming request.
5573 *
5574 * @return PJ_SUCCESS on success, other on error.
5575 */
5576 PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
5577 pj_str_t *contact,
5578 pjsua_acc_id acc_id,
5579 pjsip_rx_data *rdata );
5580
5581
5582 /**
5583 * Lock/bind this account to a specific transport/listener. Normally
5584 * application shouldn't need to do this, as transports will be selected
5585 * automatically by the stack according to the destination.
5586 *
5587 * When account is locked/bound to a specific transport, all outgoing
5588 * requests from this account will use the specified transport (this
5589 * includes SIP registration, dialog (call and event subscription), and
5590 * out-of-dialog requests such as MESSAGE).
5591 *
5592 * Note that transport_id may be specified in pjsua_acc_config too.
5593 *
5594 * @param acc_id The account ID.
5595 * @param tp_id The transport ID.
5596 *
5597 * @return PJ_SUCCESS on success.
5598 */
5599 PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
5600 pjsua_transport_id tp_id);
5601
5602
5603 /**
5604 * @}
5605 */
5606
5607
5608 /*****************************************************************************
5609 * CALLS API
5610 */
5611
5612
5613 /**
5614 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
5615 * @ingroup PJSUA_LIB
5616 * @brief Call manipulation.
5617 * @{
5618 */
5619
5620 /**
5621 * Maximum simultaneous calls.
5622 */
5623 #ifndef PJSUA_MAX_CALLS
5624 # define PJSUA_MAX_CALLS 4
5625 #endif
5626
5627 /**
5628 * Maximum active video windows
5629 */
5630 #ifndef PJSUA_MAX_VID_WINS
5631 # define PJSUA_MAX_VID_WINS 16
5632 #endif
5633
5634
5635 /**
5636 * Specifies if lock codec feature should always use INVITE method.
5637 * This will also affect ICE completion update in updating default address
5638 * in SDP.
5639 *
5640 * This can be useful when communicating with endpoints that do not
5641 * respond to UPDATE properly while indicating UPDATE support (by
5642 * specifying UPDATE in its SIP Allow header).
5643 *
5644 * Note that UPDATE can be sent when dialog is still in early state,
5645 * while re-INVITE needs to wait until the dialog is confirmed.
5646 */
5647 #ifndef PJSUA_LOCK_CODEC_DONT_USE_UPDATE
5648 # define PJSUA_LOCK_CODEC_DONT_USE_UPDATE 0
5649 #endif
5650
5651
5652 /**
5653 * Video window ID.
5654 */
5655 typedef int pjsua_vid_win_id;
5656
5657
5658 /**
5659 * This enumeration specifies the media status of a call, and it's part
5660 * of pjsua_call_info structure.
5661 */
5662 typedef enum pjsua_call_media_status
5663 {
5664 /**
5665 * Call currently has no media, or the media is not used.
5666 */
5667 PJSUA_CALL_MEDIA_NONE,
5668
5669 /**
5670 * The media is active
5671 */
5672 PJSUA_CALL_MEDIA_ACTIVE,
5673
5674 /**
5675 * The media is currently put on hold by local endpoint
5676 */
5677 PJSUA_CALL_MEDIA_LOCAL_HOLD,
5678
5679 /**
5680 * The media is currently put on hold by remote endpoint
5681 */
5682 PJSUA_CALL_MEDIA_REMOTE_HOLD,
5683
5684 /**
5685 * The media has reported error (e.g. ICE negotiation)
5686 */
5687 PJSUA_CALL_MEDIA_ERROR
5688
5689 } pjsua_call_media_status;
5690
5691
5692 /**
5693 * Enumeration of video keyframe request methods. Keyframe request is
5694 * triggered by decoder, usually when the incoming video stream cannot
5695 * be decoded properly due to missing video keyframe.
5696 */
5697 typedef enum pjsua_vid_req_keyframe_method
5698 {
5699 /**
5700 * Requesting keyframe via SIP INFO message. Note that incoming keyframe
5701 * request via SIP INFO will always be handled even if this flag is unset.
5702 */
5703 PJSUA_VID_REQ_KEYFRAME_SIP_INFO = 1,
5704
5705 /**
5706 * Requesting keyframe via Picture Loss Indication of RTCP feedback.
5707 */
5708 PJSUA_VID_REQ_KEYFRAME_RTCP_PLI = 2
5709
5710 } pjsua_vid_req_keyframe_method;
5711
5712
5713 /**
5714 * Call media information.
5715 */
5716 typedef struct pjsua_call_media_info
5717 {
5718 /** Media index in SDP. */
5719 unsigned index;
5720
5721 /** Media type. */
5722 pjmedia_type type;
5723
5724 /** Media direction. */
5725 pjmedia_dir dir;
5726
5727 /** Call media status. */
5728 pjsua_call_media_status status;
5729
5730 /** The specific media stream info. */
5731 union {
5732 /** Audio stream */
5733 struct {
5734 /** The conference port number for the call. */
5735 pjsua_conf_port_id conf_slot;
5736 } aud;
5737
5738 /** Video stream */
5739 struct {
5740 /**
5741 * The window id for incoming video, if any, or
5742 * PJSUA_INVALID_ID.
5743 */
5744 pjsua_vid_win_id win_in;
5745
5746 /**
5747 * The video conference port number for the call in decoding
5748 * direction.
5749 */
5750 pjsua_conf_port_id dec_slot;
5751
5752 /**
5753 * The video conference port number for the call in encoding
5754 * direction.
5755 */
5756 pjsua_conf_port_id enc_slot;
5757
5758 /**
5759 * The video capture device for outgoing transmission,
5760 * if any, or PJMEDIA_VID_INVALID_DEV
5761 */
5762 pjmedia_vid_dev_index cap_dev;
5763
5764 } vid;
5765 } stream;
5766
5767 } pjsua_call_media_info;
5768
5769
5770 /**
5771 * This structure describes the information and current status of a call.
5772 */
5773 typedef struct pjsua_call_info
5774 {
5775 /** Call identification. */
5776 pjsua_call_id id;
5777
5778 /** Initial call role (UAC == caller) */
5779 pjsip_role_e role;
5780
5781 /** The account ID where this call belongs. */
5782 pjsua_acc_id acc_id;
5783
5784 /** Local URI */
5785 pj_str_t local_info;
5786
5787 /** Local Contact */
5788 pj_str_t local_contact;
5789
5790 /** Remote URI */
5791 pj_str_t remote_info;
5792
5793 /** Remote contact */
5794 pj_str_t remote_contact;
5795
5796 /** Dialog Call-ID string. */
5797 pj_str_t call_id;
5798
5799 /** Call setting */
5800 pjsua_call_setting setting;
5801
5802 /** Call state */
5803 pjsip_inv_state state;
5804
5805 /** Text describing the state */
5806 pj_str_t state_text;
5807
5808 /** Last status code heard, which can be used as cause code */
5809 pjsip_status_code last_status;
5810
5811 /** The reason phrase describing the status. */
5812 pj_str_t last_status_text;
5813
5814 /** Media status of the default audio stream. Default audio stream
5815 * is chosen according to this priority:
5816 * 1. enabled, i.e: SDP media port not zero
5817 * 2. transport protocol in the SDP matching account config's
5818 * secure media transport usage (\a use_srtp field).
5819 * 3. active, i.e: SDP media direction is not "inactive"
5820 * 4. media order (according to the SDP).
5821 */
5822 pjsua_call_media_status media_status;
5823
5824 /** Media direction of the default audio stream.
5825 * See \a media_status above on how the default is chosen.
5826 */
5827 pjmedia_dir media_dir;
5828
5829 /** The conference port number for the default audio stream.
5830 * See \a media_status above on how the default is chosen.
5831 */
5832 pjsua_conf_port_id conf_slot;
5833
5834 /** Number of active media info in this call. */
5835 unsigned media_cnt;
5836
5837 /** Array of active media information. */
5838 pjsua_call_media_info media[PJMEDIA_MAX_SDP_MEDIA];
5839
5840 /** Number of provisional media info in this call. */
5841 unsigned prov_media_cnt;
5842
5843 /** Array of provisional media information. This contains the media info
5844 * in the provisioning state, that is when the media session is being
5845 * created/updated (SDP offer/answer is on progress).
5846 */
5847 pjsua_call_media_info prov_media[PJMEDIA_MAX_SDP_MEDIA];
5848
5849 /** Up-to-date call connected duration (zero when call is not
5850 * established)
5851 */
5852 pj_time_val connect_duration;
5853
5854 /** Total call duration, including set-up time */
5855 pj_time_val total_duration;
5856
5857 /** Flag if remote was SDP offerer */
5858 pj_bool_t rem_offerer;
5859
5860 /** Number of audio streams offered by remote */
5861 unsigned rem_aud_cnt;
5862
5863 /** Number of video streams offered by remote */
5864 unsigned rem_vid_cnt;
5865
5866 /** Number of text streams offered by remote */
5867 unsigned rem_txt_cnt;
5868
5869 /** Internal */
5870 struct {
5871 char local_info[PJSIP_MAX_URL_SIZE];
5872 char local_contact[PJSIP_MAX_URL_SIZE];
5873 char remote_info[PJSIP_MAX_URL_SIZE];
5874 char remote_contact[PJSIP_MAX_URL_SIZE];
5875 char call_id[128];
5876 char last_status_text[128];
5877 } buf_;
5878
5879 } pjsua_call_info;
5880
5881 /**
5882 * Flags to be given to various call APIs. More than one flags may be
5883 * specified by bitmasking them.
5884 */
5885 typedef enum pjsua_call_flag
5886 {
5887 /**
5888 * When the call is being put on hold, specify this flag to unhold it.
5889 * This flag is only valid for #pjsua_call_reinvite() and
5890 * #pjsua_call_update(). Note: for compatibility reason, this flag must
5891 * have value of 1 because previously the unhold option is specified as
5892 * boolean value.
5893 */
5894 PJSUA_CALL_UNHOLD = 1,
5895
5896 /**
5897 * Update the local invite session's contact with the contact URI from
5898 * the account. This flag is only valid for #pjsua_call_set_hold2(),
5899 * #pjsua_call_reinvite() and #pjsua_call_update(). This flag is useful
5900 * in IP address change situation, after the local account's Contact has
5901 * been updated (typically with re-registration) use this flag to update
5902 * the invite session with the new Contact and to inform this new Contact
5903 * to the remote peer with the outgoing re-INVITE or UPDATE.
5904 */
5905 PJSUA_CALL_UPDATE_CONTACT = 2,
5906
5907 /**
5908 * Include SDP "m=" line with port set to zero for each disabled media
5909 * (i.e when aud_cnt or vid_cnt is set to zero). This flag is only valid
5910 * for #pjsua_call_make_call(), #pjsua_call_reinvite(), and
5911 * #pjsua_call_update(). Note that even this flag is applicable in
5912 * #pjsua_call_reinvite() and #pjsua_call_update(), it will only take
5913 * effect when the re-INVITE/UPDATE operation regenerates SDP offer,
5914 * such as changing audio or video count in the call setting.
5915 */
5916 PJSUA_CALL_INCLUDE_DISABLED_MEDIA = 4,
5917
5918 /**
5919 * Do not send SDP when sending INVITE or UPDATE. This flag is only valid
5920 * for #pjsua_call_make_call(), #pjsua_call_reinvite()/reinvite2(), or
5921 * #pjsua_call_update()/update2(). For re-invite/update, specifying
5922 * PJSUA_CALL_UNHOLD will take precedence over this flag.
5923 */
5924 PJSUA_CALL_NO_SDP_OFFER = 8,
5925
5926 /**
5927 * Deinitialize and recreate media, including media transport. This flag
5928 * is useful in IP address change situation, if the media transport
5929 * address (or address family) changes, for example during IPv4/IPv6
5930 * network handover.
5931 * This flag is only valid for #pjsua_call_reinvite()/reinvite2(), or
5932 * #pjsua_call_update()/update2().
5933 *
5934 * Warning: If the re-INVITE/UPDATE fails, the old media will not be
5935 * reverted.
5936 */
5937 PJSUA_CALL_REINIT_MEDIA = 16,
5938
5939 /**
5940 * Update the local invite session's Via with the via address from
5941 * the account. This flag is only valid for #pjsua_call_set_hold2(),
5942 * #pjsua_call_reinvite() and #pjsua_call_update(). Similar to
5943 * the flag PJSUA_CALL_UPDATE_CONTACT above, this flag is useful
5944 * in IP address change situation, after the local account's Via has
5945 * been updated (typically with re-registration).
5946 */
5947 PJSUA_CALL_UPDATE_VIA = 32,
5948
5949 /**
5950 * Update dialog target to URI specified in pjsua_msg_data.target_uri.
5951 * This flag is only valid for pjsua_call_set_hold(),
5952 * pjsua_call_reinvite(), and pjsua_call_update(). This flag can be
5953 * useful in IP address change scenario where IP version has been changed
5954 * and application needs to update target IP address.
5955 */
5956 PJSUA_CALL_UPDATE_TARGET = 64,
5957
5958 /**
5959 * Set media direction as specified in pjsua_call_setting.media_dir.
5960 */
5961 PJSUA_CALL_SET_MEDIA_DIR = 128,
5962
5963 /**
5964 * Disable inter-media synchronization.
5965 */
5966 PJSUA_CALL_NO_MEDIA_SYNC = 256
5967
5968 } pjsua_call_flag;
5969
5970 /**
5971 * This enumeration represents video stream operation on a call.
5972 * See also #pjsua_call_vid_strm_op_param for further info.
5973 */
5974 typedef enum pjsua_call_vid_strm_op
5975 {
5976 /**
5977 * No operation
5978 */
5979 PJSUA_CALL_VID_STRM_NO_OP,
5980
5981 /**
5982 * Add a new video stream. This will add a new m=video line to
5983 * the media, regardless of whether existing video is/are present
5984 * or not. This will cause re-INVITE or UPDATE to be sent to remote
5985 * party.
5986 */
5987 PJSUA_CALL_VID_STRM_ADD,
5988
5989 /**
5990 * Remove/disable an existing video stream. This will
5991 * cause re-INVITE or UPDATE to be sent to remote party.
5992 */
5993 PJSUA_CALL_VID_STRM_REMOVE,
5994
5995 /**
5996 * Change direction of a video stream. This operation can be used
5997 * to activate or deactivate an existing video media. This will
5998 * cause re-INVITE or UPDATE to be sent to remote party.
5999 */
6000 PJSUA_CALL_VID_STRM_CHANGE_DIR,
6001
6002 /**
6003 * Change capture device of a video stream. This will not send
6004 * re-INVITE or UPDATE to remote party.
6005 */
6006 PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV,
6007
6008 /**
6009 * Start transmitting video stream. This will cause previously
6010 * stopped stream to start transmitting again. Note that no
6011 * re-INVITE/UPDATE is to be transmitted to remote since this
6012 * operation only operates on local stream.
6013 */
6014 PJSUA_CALL_VID_STRM_START_TRANSMIT,
6015
6016 /**
6017 * Stop transmitting video stream. This will cause the stream to
6018 * be paused in TX direction, causing it to stop sending any video
6019 * packets. No re-INVITE/UPDATE is to be transmitted to remote
6020 * with this operation.
6021 */
6022 PJSUA_CALL_VID_STRM_STOP_TRANSMIT,
6023
6024 /**
6025 * Send keyframe in the video stream. This will force the stream to
6026 * generate and send video keyframe as soon as possible. No
6027 * re-INVITE/UPDATE is to be transmitted to remote with this operation.
6028 */
6029 PJSUA_CALL_VID_STRM_SEND_KEYFRAME
6030
6031 } pjsua_call_vid_strm_op;
6032
6033
6034 /**
6035 * Parameters for video stream operation on a call. Application should
6036 * use #pjsua_call_vid_strm_op_param_default() to initialize this structure
6037 * with its default values.
6038 */
6039 typedef struct pjsua_call_vid_strm_op_param
6040 {
6041 /**
6042 * Specify the media stream index. This can be set to -1 to denote
6043 * the default video stream in the call, which is the first active
6044 * video stream or any first video stream if none is active.
6045 *
6046 * This field is valid for all video stream operations, except
6047 * PJSUA_CALL_VID_STRM_ADD.
6048 *
6049 * Default: -1 (first active video stream, or any first video stream
6050 * if none is active)
6051 */
6052 int med_idx;
6053
6054 /**
6055 * Specify the media stream direction.
6056 *
6057 * This field is valid for the following video stream operations:
6058 * PJSUA_CALL_VID_STRM_ADD and PJSUA_CALL_VID_STRM_CHANGE_DIR.
6059 *
6060 * Default: PJMEDIA_DIR_ENCODING_DECODING
6061 */
6062 pjmedia_dir dir;
6063
6064 /**
6065 * Specify the video capture device ID. This can be set to
6066 * PJMEDIA_VID_DEFAULT_CAPTURE_DEV to specify the default capture
6067 * device as configured in the account.
6068 *
6069 * This field is valid for the following video stream operations:
6070 * PJSUA_CALL_VID_STRM_ADD and PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV.
6071 *
6072 * Default: PJMEDIA_VID_DEFAULT_CAPTURE_DEV.
6073 */
6074 pjmedia_vid_dev_index cap_dev;
6075
6076 } pjsua_call_vid_strm_op_param;
6077
6078
6079 /**
6080 * Specify the default signal duration when sending DTMF using SIP INFO.
6081 *
6082 * Default is 160
6083 */
6084 #ifndef PJSUA_CALL_SEND_DTMF_DURATION_DEFAULT
6085 # define PJSUA_CALL_SEND_DTMF_DURATION_DEFAULT 160
6086 #endif
6087
6088
6089 /**
6090 * Parameters for sending DTMF. Application should use
6091 * #pjsua_call_send_dtmf_param_default() to initialize this structure
6092 * with its default values.
6093 */
6094 typedef struct pjsua_call_send_dtmf_param
6095 {
6096 /**
6097 * The method used to send DTMF.
6098 *
6099 * Default: PJSUA_DTMF_METHOD_RFC2833
6100 */
6101 pjsua_dtmf_method method;
6102
6103 /**
6104 * The signal duration used for the DTMF.
6105 *
6106 * Default: PJSUA_CALL_SEND_DTMF_DURATION_DEFAULT
6107 */
6108 unsigned duration;
6109
6110 /**
6111 * The DTMF digits to be sent.
6112 */
6113 pj_str_t digits;
6114
6115 } pjsua_call_send_dtmf_param;
6116
6117
6118 /**
6119 * Parameters for sending text. Application should use
6120 * #pjsua_call_send_text_param_default() to initialize this structure
6121 * with its default values.
6122 */
6123 typedef struct pjsua_call_send_text_param
6124 {
6125 /**
6126 * Text media stream index.
6127 *
6128 * Default: -1 (use the first text media).
6129 */
6130 int med_idx;
6131
6132 /**
6133 * The text to be sent.
6134 */
6135 pj_str_t text;
6136
6137 } pjsua_call_send_text_param;
6138
6139
6140 /**
6141 * Initialize call settings.
6142 *
6143 * @param opt The call setting to be initialized.
6144 */
6145 PJ_DECL(void) pjsua_call_setting_default(pjsua_call_setting *opt);
6146
6147
6148 /**
6149 * Initialize video stream operation param with default values.
6150 *
6151 * @param param The video stream operation param to be initialized.
6152 */
6153 PJ_DECL(void)
6154 pjsua_call_vid_strm_op_param_default(pjsua_call_vid_strm_op_param *param);
6155
6156
6157 /**
6158 * Initialize send DTMF param with default values.
6159 *
6160 * @param param The send DTMF param to be initialized.
6161 */
6162 PJ_DECL(void)
6163 pjsua_call_send_dtmf_param_default(pjsua_call_send_dtmf_param *param);
6164
6165 /**
6166 * Initialize send DTMF param with default values.
6167 *
6168 * @param param The send DTMF param to be initialized.
6169 */
6170 PJ_DECL(void)
6171 pjsua_call_send_text_param_default(pjsua_call_send_text_param *param);
6172
6173 /**
6174 * Get maximum number of calls configured in pjsua.
6175 *
6176 * @return Maximum number of calls configured.
6177 */
6178 PJ_DECL(unsigned) pjsua_call_get_max_count(void);
6179
6180 /**
6181 * Get the number of current calls. The number includes active calls
6182 * (pjsua_call_is_active(call_id) == PJ_TRUE), as well as calls that
6183 * are no longer active but still in the process of hanging up.
6184 *
6185 * @return Number of current calls.
6186 */
6187 PJ_DECL(unsigned) pjsua_call_get_count(void);
6188
6189 /**
6190 * Enumerate all active calls. Application may then query the information and
6191 * state of each call by calling #pjsua_call_get_info().
6192 *
6193 * @param ids Array of account IDs to be initialized.
6194 * @param count In input, specifies the maximum number of elements.
6195 * On return, it contains the actual number of elements.
6196 *
6197 * @return PJ_SUCCESS on success, or the appropriate error code.
6198 */
6199 PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
6200 unsigned *count);
6201
6202
6203 /**
6204 * Make outgoing call to the specified URI using the specified account.
6205 *
6206 * @param acc_id The account to be used.
6207 * @param dst_uri URI to be put in the To header (normally is the same
6208 * as the target URI).
6209 * @param opt Optional call setting. This should be initialized
6210 * using #pjsua_call_setting_default().
6211 * @param user_data Arbitrary user data to be attached to the call, and
6212 * can be retrieved later.
6213 * @param msg_data Optional headers etc to be added to outgoing INVITE
6214 * request, or NULL if no custom header is desired.
6215 * @param p_call_id Pointer to receive call identification.
6216 *
6217 * @return PJ_SUCCESS on success, or the appropriate error code.
6218 */
6219 PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
6220 const pj_str_t *dst_uri,
6221 const pjsua_call_setting *opt,
6222 void *user_data,
6223 const pjsua_msg_data *msg_data,
6224 pjsua_call_id *p_call_id);
6225
6226
6227 /**
6228 * Check if the specified call has active INVITE session and the INVITE
6229 * session has not been disconnected.
6230 *
6231 * @param call_id Call identification.
6232 *
6233 * @return Non-zero if call is active.
6234 */
6235 PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
6236
6237
6238 /**
6239 * Check if call has an active media session.
6240 *
6241 * @param call_id Call identification.
6242 *
6243 * @return Non-zero if yes.
6244 */
6245 PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
6246
6247
6248 /**
6249 * Get the conference port identification associated with the call.
6250 *
6251 * @param call_id Call identification.
6252 *
6253 * @return Conference port ID, or PJSUA_INVALID_ID when the
6254 * media has not been established or is not active.
6255 */
6256 PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
6257
6258
6259 /**
6260 * Get the video window associated with the call. Note that this function
6261 * will only evaluate the first video stream in the call, to query any other
6262 * video stream, use pjsua_call_get_info().
6263 *
6264 * @param call_id Call identification.
6265 *
6266 * @return Video window, or PJSUA_INVALID_ID when the
6267 * media has not been established or is not active.
6268 */
6269 PJ_DECL(pjsua_vid_win_id) pjsua_call_get_vid_win(pjsua_call_id call_id);
6270
6271
6272 /**
6273 * Get the video conference port identification associated with the call.
6274 * Note that this function will only evaluate the first video stream in
6275 * the call, to query any other video stream, use pjsua_call_get_info().
6276 *
6277 * @param call_id Call identification.
6278 * @param dir Port direction to be queried. Valid values are
6279 * PJMEDIA_DIR_ENCODING and PJMEDIA_DIR_DECODING only.
6280 *
6281 * @return Conference port ID, or PJSUA_INVALID_ID when the
6282 * media has not been established or is not active.
6283 */
6284 PJ_DECL(pjsua_conf_port_id) pjsua_call_get_vid_conf_port(
6285 pjsua_call_id call_id,
6286 pjmedia_dir dir);
6287
6288 /**
6289 * Obtain detail information about the specified call.
6290 *
6291 * @param call_id Call identification.
6292 * @param info Call info to be initialized.
6293 *
6294 * @return PJ_SUCCESS on success, or the appropriate error code.
6295 */
6296 PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
6297 pjsua_call_info *info);
6298
6299 /**
6300 * Check if remote peer support the specified capability.
6301 *
6302 * @param call_id Call identification.
6303 * @param htype The header type to be checked, which value may be:
6304 * - PJSIP_H_ACCEPT
6305 * - PJSIP_H_ALLOW
6306 * - PJSIP_H_SUPPORTED
6307 * @param hname If htype specifies PJSIP_H_OTHER, then the header
6308 * name must be supplied in this argument. Otherwise the
6309 * value must be set to NULL.
6310 * @param token The capability token to check. For example, if \a
6311 * htype is PJSIP_H_ALLOW, then \a token specifies the
6312 * method names; if \a htype is PJSIP_H_SUPPORTED, then
6313 * \a token specifies the extension names such as
6314 * "100rel".
6315 *
6316 * @return PJSIP_DIALOG_CAP_SUPPORTED if the specified capability
6317 * is explicitly supported, see pjsip_dialog_cap_status
6318 * for more info.
6319 */
6320 PJ_DECL(pjsip_dialog_cap_status) pjsua_call_remote_has_cap(
6321 pjsua_call_id call_id,
6322 int htype,
6323 const pj_str_t *hname,
6324 const pj_str_t *token);
6325
6326 /**
6327 * Attach application specific data to the call. Application can then
6328 * inspect this data by calling #pjsua_call_get_user_data().
6329 *
6330 * @param call_id Call identification.
6331 * @param user_data Arbitrary data to be attached to the call.
6332 *
6333 * @return The user data.
6334 */
6335 PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
6336 void *user_data);
6337
6338
6339 /**
6340 * Get user data attached to the call, which has been previously set with
6341 * #pjsua_call_set_user_data().
6342 *
6343 * @param call_id Call identification.
6344 *
6345 * @return The user data.
6346 */
6347 PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
6348
6349
6350 /**
6351 * Get the NAT type of remote's endpoint. This is a proprietary feature
6352 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
6353 * is set in #pjsua_config.
6354 *
6355 * This function can only be called after SDP has been received from remote,
6356 * which means for incoming call, this function can be called as soon as
6357 * call is received as long as incoming call contains SDP, and for outgoing
6358 * call, this function can be called only after SDP is received (normally in
6359 * 200/OK response to INVITE). As a general case, application should call
6360 * this function after or in \a on_call_media_state() callback.
6361 *
6362 * @param call_id Call identification.
6363 * @param p_type Pointer to store the NAT type. Application can then
6364 * retrieve the string description of the NAT type
6365 * by calling pj_stun_get_nat_name().
6366 *
6367 * @return PJ_SUCCESS on success.
6368 *
6369 * @see pjsua_get_nat_type(), nat_type_in_sdp
6370 */
6371 PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
6372 pj_stun_nat_type *p_type);
6373
6374 /**
6375 * Send response to incoming INVITE request. Depending on the status
6376 * code specified as parameter, this function may send provisional
6377 * response, establish the call, or terminate the call. See also
6378 * #pjsua_call_answer2().
6379 *
6380 * @param call_id Incoming call identification.
6381 * @param code Status code, (100-699).
6382 * @param reason Optional reason phrase. If NULL, default text
6383 * will be used.
6384 * @param msg_data Optional list of headers etc to be added to outgoing
6385 * response message. Note that this message data will
6386 * be persistent in all next answers/responses for this
6387 * INVITE request.
6388 *
6389 * @return PJ_SUCCESS on success, or the appropriate error code.
6390 */
6391 PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
6392 unsigned code,
6393 const pj_str_t *reason,
6394 const pjsua_msg_data *msg_data);
6395
6396
6397 /**
6398 * Send response to incoming INVITE request with call setting param.
6399 * Depending on the status code specified as parameter, this function may
6400 * send provisional response, establish the call, or terminate the call.
6401 * Notes about call setting:
6402 * - if call setting is changed in the subsequent call to this function,
6403 * only the first call setting supplied will applied. So normally
6404 * application will not supply call setting before getting confirmation
6405 * from the user.
6406 * - if no call setting is supplied when SDP has to be sent, i.e: answer
6407 * with status code 183 or 2xx, the default call setting will be used,
6408 * check #pjsua_call_setting for its default values.
6409 *
6410 * @param call_id Incoming call identification.
6411 * @param opt Optional call setting.
6412 * @param code Status code, (100-699).
6413 * @param reason Optional reason phrase. If NULL, default text
6414 * will be used.
6415 * @param msg_data Optional list of headers etc to be added to outgoing
6416 * response message. Note that this message data will
6417 * be persistent in all next answers/responses for this
6418 * INVITE request.
6419 *
6420 * @return PJ_SUCCESS on success, or the appropriate error code.
6421 */
6422 PJ_DECL(pj_status_t) pjsua_call_answer2(pjsua_call_id call_id,
6423 const pjsua_call_setting *opt,
6424 unsigned code,
6425 const pj_str_t *reason,
6426 const pjsua_msg_data *msg_data);
6427
6428
6429 /**
6430 * Same as #pjsua_call_answer2() but this function will set the SDP
6431 * answer first before sending the response.
6432 *
6433 * @param call_id Incoming call identification.
6434 * @param sdp SDP answer.
6435 * @param opt Optional call setting.
6436 * @param code Status code, (100-699).
6437 * @param reason Optional reason phrase. If NULL, default text
6438 * will be used.
6439 * @param msg_data Optional list of headers etc to be added to outgoing
6440 * response message. Note that this message data will
6441 * be persistent in all next answers/responses for this
6442 * INVITE request.
6443 *
6444 * @return PJ_SUCCESS on success, or the appropriate error code.
6445 */
6446 PJ_DECL(pj_status_t)
6447 pjsua_call_answer_with_sdp(pjsua_call_id call_id,
6448 const pjmedia_sdp_session *sdp,
6449 const pjsua_call_setting *opt,
6450 unsigned code,
6451 const pj_str_t *reason,
6452 const pjsua_msg_data *msg_data);
6453
6454
6455 /**
6456 * Hangup call by using method that is appropriate according to the
6457 * call state. This function is different than answering the call with
6458 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
6459 * will hangup the call regardless of the state and role of the call,
6460 * while #pjsua_call_answer() only works with incoming calls on EARLY
6461 * state.
6462 *
6463 * After calling this function, media will be deinitialized (call media
6464 * callbacks, if any, will still be received) and then, on_call_state()
6465 * will be immediately called with state DISCONNECTED. No further
6466 * call callbacks will be received after this. The call hangup process
6467 * itself (sending BYE, waiting for the response, and resource cleanup)
6468 * will continue in the background and the call slot can be reused only
6469 * after this process is completed. If application has limited call slots
6470 * and would like to check if there are any free slots remaining, it can
6471 * query the number of free slots using the APIs:
6472 * pjsua_call_get_max_count()-pjsua_call_get_count()
6473 *
6474 * Note that on_call_tsx_state() will not be called when using this API.
6475 *
6476 * @param call_id Call identification.
6477 * @param code Optional status code to be sent when we're rejecting
6478 * incoming call. If the value is zero, "603/Decline"
6479 * will be sent.
6480 * @param reason Optional reason phrase to be sent when we're rejecting
6481 * incoming call. If NULL, default text will be used.
6482 * @param msg_data Optional list of headers etc to be added to outgoing
6483 * request/response message.
6484 *
6485 * @return PJ_SUCCESS on success, or the appropriate error code.
6486 */
6487 PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
6488 unsigned code,
6489 const pj_str_t *reason,
6490 const pjsua_msg_data *msg_data);
6491
6492 /**
6493 * Accept or reject redirection response. Application MUST call this function
6494 * after it signaled PJSIP_REDIRECT_PENDING in the \a on_call_redirected()
6495 * callback, to notify the call whether to accept or reject the redirection
6496 * to the current target. Application can use the combination of
6497 * PJSIP_REDIRECT_PENDING command in \a on_call_redirected() callback and
6498 * this function to ask for user permission before redirecting the call.
6499 *
6500 * Note that if the application chooses to reject or stop redirection (by
6501 * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the
6502 * call disconnection callback will be called before this function returns.
6503 * And if the application rejects the target, the \a on_call_redirected()
6504 * callback may also be called before this function returns if there is
6505 * another target to try.
6506 *
6507 * @param call_id The call ID.
6508 * @param cmd Redirection operation to be applied to the current
6509 * target. The semantic of this argument is similar
6510 * to the description in the \a on_call_redirected()
6511 * callback, except that the PJSIP_REDIRECT_PENDING is
6512 * not accepted here.
6513 *
6514 * @return PJ_SUCCESS on successful operation.
6515 */
6516 PJ_DECL(pj_status_t) pjsua_call_process_redirect(pjsua_call_id call_id,
6517 pjsip_redirect_op cmd);
6518
6519 /**
6520 * Put the specified call on hold. This will send re-INVITE with the
6521 * appropriate SDP to inform remote that the call is being put on hold.
6522 * The final status of the request itself will be reported on the
6523 * \a on_call_media_state() callback, which inform the application that
6524 * the media state of the call has changed.
6525 *
6526 * @param call_id Call identification.
6527 * @param msg_data Optional message components to be sent with
6528 * the request.
6529 *
6530 * @return PJ_SUCCESS on success, or the appropriate error code.
6531 */
6532 PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
6533 const pjsua_msg_data *msg_data);
6534
6535 /**
6536 * Put the specified call on hold. This will send re-INVITE with the
6537 * appropriate SDP to inform remote that the call is being put on hold.
6538 * The final status of the request itself will be reported on the
6539 * \a on_call_media_state() callback, which inform the application that
6540 * the media state of the call has changed.
6541 *
6542 * @param call_id Call identification.
6543 * @param options Bitmask of pjsua_call_flag constants. Currently, only
6544 * the flag PJSUA_CALL_UPDATE_CONTACT can be used.
6545 * @param msg_data Optional message components to be sent with
6546 * the request.
6547 *
6548 * @return PJ_SUCCESS on success, or the appropriate error code.
6549 */
6550 PJ_DECL(pj_status_t) pjsua_call_set_hold2(pjsua_call_id call_id,
6551 unsigned options,
6552 const pjsua_msg_data *msg_data);
6553
6554 /**
6555 * Send re-INVITE request or release hold.
6556 * The final status of the request itself will be reported on the
6557 * \a on_call_media_state() callback, which inform the application that
6558 * the media state of the call has changed.
6559 *
6560 * @param call_id Call identification.
6561 * @param options Bitmask of pjsua_call_flag constants. Note that
6562 * for compatibility, specifying PJ_TRUE here is
6563 * equal to specifying PJSUA_CALL_UNHOLD flag.
6564 * @param msg_data Optional message components to be sent with
6565 * the request.
6566 *
6567 * @return PJ_SUCCESS on success, or the appropriate error code.
6568 */
6569 PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
6570 unsigned options,
6571 const pjsua_msg_data *msg_data);
6572
6573
6574 /**
6575 * Send re-INVITE request or release hold.
6576 * The final status of the request itself will be reported on the
6577 * \a on_call_media_state() callback, which inform the application that
6578 * the media state of the call has changed.
6579 *
6580 * @param call_id Call identification.
6581 * @param opt Optional call setting, if NULL, the current call
6582 * setting will be used. Note that to release hold
6583 * or update contact or omit SDP offer, this parameter
6584 * cannot be NULL and it must specify appropriate flags,
6585 * e.g: PJSUA_CALL_UNHOLD, PJSUA_CALL_UPDATE_CONTACT,
6586 * PJSUA_CALL_NO_SDP_OFFER.
6587 * @param msg_data Optional message components to be sent with
6588 * the request.
6589 *
6590 * @return PJ_SUCCESS on success, or the appropriate error code.
6591 */
6592 PJ_DECL(pj_status_t) pjsua_call_reinvite2(pjsua_call_id call_id,
6593 const pjsua_call_setting *opt,
6594 const pjsua_msg_data *msg_data);
6595
6596
6597 /**
6598 * Send UPDATE request.
6599 *
6600 * @param call_id Call identification.
6601 * @param options Bitmask of pjsua_call_flag constants.
6602 * @param msg_data Optional message components to be sent with
6603 * the request.
6604 *
6605 * @return PJ_SUCCESS on success, or the appropriate error code.
6606 */
6607 PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
6608 unsigned options,
6609 const pjsua_msg_data *msg_data);
6610
6611
6612 /**
6613 * Send UPDATE request.
6614 *
6615 * @param call_id Call identification.
6616 * @param opt Optional call setting, if NULL, the current call
6617 * setting will be used. Note that to release hold
6618 * or update contact or omit SDP offer, this parameter
6619 * cannot be NULL and it must specify appropriate flags,
6620 * e.g: PJSUA_CALL_UNHOLD, PJSUA_CALL_UPDATE_CONTACT,
6621 * PJSUA_CALL_NO_SDP_OFFER.
6622 * @param msg_data Optional message components to be sent with
6623 * the request.
6624 *
6625 * @return PJ_SUCCESS on success, or the appropriate error code.
6626 */
6627 PJ_DECL(pj_status_t) pjsua_call_update2(pjsua_call_id call_id,
6628 const pjsua_call_setting *opt,
6629 const pjsua_msg_data *msg_data);
6630
6631
6632 /**
6633 * Initiate call transfer to the specified address. This function will send
6634 * REFER request to instruct remote call party to initiate a new INVITE
6635 * session to the specified destination/target.
6636 *
6637 * If application is interested to monitor the successfulness and
6638 * the progress of the transfer request, it can implement
6639 * \a on_call_transfer_status() callback which will report the progress
6640 * of the call transfer request.
6641 *
6642 * @param call_id The call id to be transferred.
6643 * @param dest URI of new target to be contacted. The URI may be
6644 * in name address or addr-spec format.
6645 * @param msg_data Optional message components to be sent with
6646 * the request.
6647 *
6648 * @return PJ_SUCCESS on success, or the appropriate error code.
6649 */
6650 PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
6651 const pj_str_t *dest,
6652 const pjsua_msg_data *msg_data);
6653
6654 /**
6655 * Flag to indicate that "Require: replaces" should not be put in the
6656 * outgoing INVITE request caused by REFER request created by
6657 * #pjsua_call_xfer_replaces().
6658 */
6659 #define PJSUA_XFER_NO_REQUIRE_REPLACES 1
6660
6661 /**
6662 * Initiate attended call transfer. This function will send REFER request
6663 * to instruct remote call party to initiate new INVITE session to the URL
6664 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
6665 * the call with us with the new call from the REFER recipient.
6666 *
6667 * @param call_id The call id to be transferred.
6668 * @param dest_call_id The call id to be replaced.
6669 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
6670 * to suppress the inclusion of "Require: replaces" in
6671 * the outgoing INVITE request created by the REFER
6672 * request.
6673 * @param msg_data Optional message components to be sent with
6674 * the request.
6675 *
6676 * @return PJ_SUCCESS on success, or the appropriate error code.
6677 */
6678 PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
6679 pjsua_call_id dest_call_id,
6680 unsigned options,
6681 const pjsua_msg_data *msg_data);
6682
6683 /**
6684 * Send DTMF digits to remote using RFC 2833 payload formats. Use
6685 * #pjsua_call_send_dtmf() to send DTMF using SIP INFO or other method in
6686 * \a pjsua_dtmf_method. App can use \a on_dtmf_digit() or \a on_dtmf_digit2()
6687 * callback to monitor incoming DTMF.
6688 *
6689 * @param call_id Call identification.
6690 * @param digits DTMF string digits to be sent as described on RFC 2833
6691 * section 3.10. If PJMEDIA_HAS_DTMF_FLASH is enabled,
6692 * character 'R' is used to represent the
6693 * event type 16 (flash) as stated in RFC 4730.
6694 *
6695 * @return PJ_SUCCESS on success, or the appropriate error code.
6696 */
6697 PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
6698 const pj_str_t *digits);
6699
6700 /**
6701 * Send DTMF digits to remote using RFC 2833 payload formats. Use
6702 * #pjsua_call_send_dtmf() to send DTMF using SIP INFO or other method in
6703 * \a pjsua_dtmf_method. App can use \a on_dtmf_digit() or \a on_dtmf_digit2()
6704 * callback to monitor incoming DTMF.
6705 *
6706 * @param call_id Call identification.
6707 * @param digits DTMF string digits to be sent as described on RFC 2833
6708 * section 3.10. If PJMEDIA_HAS_DTMF_FLASH is enabled,
6709 * character 'R' is used to represent the
6710 * event type 16 (flash) as stated in RFC 4730.
6711 * @param duration duration of event in ms or 0 to use default
6712 *
6713 * @return PJ_SUCCESS on success, or the appropriate error code.
6714 */
6715 PJ_DECL(pj_status_t) pjsua_call_dial_dtmf2(pjsua_call_id call_id,
6716 const pj_str_t *digits,
6717 unsigned duration);
6718
6719 /**
6720 * Send DTMF digits to remote. Use this method to send DTMF using the method in
6721 * \a pjsua_dtmf_method. This method will call #pjsua_call_dial_dtmf() when
6722 * sending DTMF using \a PJSUA_DTMF_METHOD_RFC2833. Note that
6723 * \a on_dtmf_digit() callback can only monitor incoming DTMF using RFC 2833.
6724 * App can use \a on_dtmf_digit2() to monitor incoming DTMF using the method in
6725 * \a pjsua_dtmf_method. Note that \a on_dtmf_digit() will not be called once
6726 * \a on_dtmf_digit2() is implemented.
6727 *
6728 * @param call_id Call identification.
6729 * @param param The send DTMF parameter.
6730 *
6731 * @return PJ_SUCCESS on success, or the appropriate error code.
6732 */
6733 PJ_DECL(pj_status_t) pjsua_call_send_dtmf(pjsua_call_id call_id,
6734 const pjsua_call_send_dtmf_param *param);
6735
6736 /**
6737 * Get the number of queued DTMF digits for transmission in the call.
6738 *
6739 * @param call_id Call identification.
6740 * @param digits On return, will contain the number of DTMF digits
6741 * queued for transmission.
6742 *
6743 * @return PJ_SUCCESS on success, or the appropriate error code.
6744 */
6745 PJ_DECL(pj_status_t) pjsua_call_get_queued_dtmf_digits(pjsua_call_id call_id,
6746 unsigned *digits);
6747
6748 /**
6749 * Send real-time text to remote via RTP stream. This only works if the call
6750 * has text media.
6751 *
6752 * @param call_id Call identification.
6753 * @param param The send text parameter.
6754 *
6755 * @return PJ_SUCCESS on success, or the appropriate error code.
6756 */
6757 PJ_DECL(pj_status_t) pjsua_call_send_text(pjsua_call_id call_id,
6758 const pjsua_call_send_text_param *param);
6759
6760 /**
6761 * Send instant messaging inside INVITE session.
6762 *
6763 * @param call_id Call identification.
6764 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
6765 * assumed.
6766 * @param content The message content. Can be NULL if msg_data specifies
6767 * body and/or multipart.
6768 * @param msg_data Optional list of headers etc to be included in outgoing
6769 * request. The body descriptor in the msg_data is
6770 * ignored if parameter 'content' is set.
6771 * @param user_data Optional user data, which will be given back when
6772 * the IM callback is called.
6773 *
6774 * @return PJ_SUCCESS on success, or the appropriate error code.
6775 */
6776 PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
6777 const pj_str_t *mime_type,
6778 const pj_str_t *content,
6779 const pjsua_msg_data *msg_data,
6780 void *user_data);
6781
6782
6783 /**
6784 * Send IM typing indication inside INVITE session.
6785 *
6786 * @param call_id Call identification.
6787 * @param is_typing Non-zero to indicate to remote that local person is
6788 * currently typing an IM.
6789 * @param msg_data Optional list of headers etc to be included in outgoing
6790 * request.
6791 *
6792 * @return PJ_SUCCESS on success, or the appropriate error code.
6793 */
6794 PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
6795 pj_bool_t is_typing,
6796 const pjsua_msg_data*msg_data);
6797
6798 /**
6799 * Send arbitrary request with the call. This is useful for example to send
6800 * INFO request. Note that application should not use this function to send
6801 * requests which would change the invite session's state, such as re-INVITE,
6802 * UPDATE, PRACK, and BYE.
6803 *
6804 * @param call_id Call identification.
6805 * @param method SIP method of the request.
6806 * @param msg_data Optional message body and/or list of headers to be
6807 * included in outgoing request.
6808 *
6809 * @return PJ_SUCCESS on success, or the appropriate error code.
6810 */
6811 PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
6812 const pj_str_t *method,
6813 const pjsua_msg_data *msg_data);
6814
6815
6816 /**
6817 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
6818 * currently active calls.
6819 */
6820 PJ_DECL(void) pjsua_call_hangup_all(void);
6821
6822
6823 /**
6824 * Dump call and media statistics to string.
6825 *
6826 * @param call_id Call identification.
6827 * @param with_media Non-zero to include media information too.
6828 * @param buffer Buffer where the statistics are to be written to.
6829 * @param maxlen Maximum length of buffer.
6830 * @param indent Spaces for left indentation.
6831 *
6832 * @return PJ_SUCCESS on success.
6833 */
6834 PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
6835 pj_bool_t with_media,
6836 char *buffer,
6837 unsigned maxlen,
6838 const char *indent);
6839
6840 /**
6841 * Get the media stream index of the default video stream in the call.
6842 * Typically this will just retrieve the stream index of the first
6843 * activated video stream in the call. If none is active, it will return
6844 * the first inactive video stream.
6845 *
6846 * @param call_id Call identification.
6847 *
6848 * @return The media stream index or -1 if no video stream
6849 * is present in the call.
6850 */
6851 PJ_DECL(int) pjsua_call_get_vid_stream_idx(pjsua_call_id call_id);
6852
6853
6854 /**
6855 * Determine if video stream for the specified call is currently running
6856 * (i.e. has been created, started, and not being paused) for the specified
6857 * direction.
6858 *
6859 * @param call_id Call identification.
6860 * @param med_idx Media stream index, or -1 to specify default video
6861 * media.
6862 * @param dir The direction to be checked.
6863 *
6864 * @return PJ_TRUE if stream is currently running for the
6865 * specified direction.
6866 */
6867 PJ_DECL(pj_bool_t) pjsua_call_vid_stream_is_running(pjsua_call_id call_id,
6868 int med_idx,
6869 pjmedia_dir dir);
6870
6871 /**
6872 * Add, remove, modify, and/or manipulate video media stream for the
6873 * specified call. This may trigger a re-INVITE or UPDATE to be sent
6874 * for the call.
6875 *
6876 * @param call_id Call identification.
6877 * @param op The video stream operation to be performed,
6878 * possible values are #pjsua_call_vid_strm_op.
6879 * @param param The parameters for the video stream operation,
6880 * or NULL for the default parameter values
6881 * (see #pjsua_call_vid_strm_op_param).
6882 *
6883 * @return PJ_SUCCESS on success or the appropriate error.
6884 */
6885 PJ_DECL(pj_status_t) pjsua_call_set_vid_strm (
6886 pjsua_call_id call_id,
6887 pjsua_call_vid_strm_op op,
6888 const pjsua_call_vid_strm_op_param *param);
6889
6890
6891 /**
6892 * Modify the video stream's codec parameter after the codec is opened.
6893 * Note that not all codec backends support modifying parameters during
6894 * runtime and only certain parameters can be changed.
6895 *
6896 * Currently, only Video Toolbox and OpenH264 backends support runtime
6897 * adjustment of encoding bitrate (avg_bps and max_bps).
6898 *
6899 * @param call_id Call identification.
6900 * @param med_idx Video stream index.
6901 * @param param The new codec parameter.
6902 *
6903 * @return PJ_SUCCESS on success.
6904 */
6905 PJ_DECL(pj_status_t)
6906 pjsua_call_vid_stream_modify_codec_param(pjsua_call_id call_id,
6907 int med_idx,
6908 const pjmedia_vid_codec_param *param);
6909
6910
6911 /**
6912 * Modify the audio stream's codec parameter after the codec is opened.
6913 * Note that not all codec parameters can be modified during run-time.
6914 * Currently, only Opus codec supports changing key codec parameters
6915 * such as bitrate and bandwidth, while other codecs may only be able to
6916 * modify minor settings such as VAD or PLC.
6917 *
6918 * @param call_id Call identification.
6919 * @param med_idx Media stream index, or -1 to specify default audio
6920 * media.
6921 * @param param The new codec parameter.
6922 *
6923 * @return PJ_SUCCESS on success.
6924 */
6925 PJ_DECL(pj_status_t)
6926 pjsua_call_aud_stream_modify_codec_param(pjsua_call_id call_id,
6927 int med_idx,
6928 const pjmedia_codec_param *param);
6929
6930 /**
6931 * Get media stream info for the specified media index.
6932 *
6933 * @param call_id The call identification.
6934 * @param med_idx Media stream index.
6935 * @param psi To be filled with the stream info.
6936 *
6937 * @return PJ_SUCCESS on success or the appropriate error.
6938 */
6939 PJ_DECL(pj_status_t) pjsua_call_get_stream_info(pjsua_call_id call_id,
6940 unsigned med_idx,
6941 pjsua_stream_info *psi);
6942
6943 /**
6944 * Get media stream statistic for the specified media index.
6945 *
6946 * @param call_id The call identification.
6947 * @param med_idx Media stream index.
6948 * @param stat To be filled with the stream statistic.
6949 *
6950 * @return PJ_SUCCESS on success or the appropriate error.
6951 */
6952 PJ_DECL(pj_status_t) pjsua_call_get_stream_stat(pjsua_call_id call_id,
6953 unsigned med_idx,
6954 pjsua_stream_stat *stat);
6955
6956 /**
6957 * Get media transport info for the specified media index.
6958 *
6959 * @param call_id The call identification.
6960 * @param med_idx Media stream index.
6961 * @param t To be filled with the transport info.
6962 *
6963 * @return PJ_SUCCESS on success or the appropriate error.
6964 */
6965 PJ_DECL(pj_status_t)
6966 pjsua_call_get_med_transport_info(pjsua_call_id call_id,
6967 unsigned med_idx,
6968 pjmedia_transport_info *t);
6969
6970
6971
6972 /**
6973 * @}
6974 */
6975
6976
6977 /*****************************************************************************
6978 * BUDDY API
6979 */
6980
6981
6982 /**
6983 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
6984 * @ingroup PJSUA_LIB
6985 * @brief Buddy management, buddy's presence, and instant messaging.
6986 * @{
6987 *
6988 * This section describes PJSUA-APIs related to buddies management,
6989 * presence management, and instant messaging.
6990 */
6991
6992 /**
6993 * Max buddies in buddy list.
6994 */
6995 #ifndef PJSUA_MAX_BUDDIES
6996 # define PJSUA_MAX_BUDDIES 256
6997 #endif
6998
6999
7000 /**
7001 * This specifies how long the library should wait before retrying failed
7002 * SUBSCRIBE request, and there is no rule to automatically resubscribe
7003 * (for example, no "retry-after" parameter in Subscription-State header).
7004 *
7005 * This also controls the duration before failed PUBLISH request will be
7006 * retried.
7007 *
7008 * Default: 300 seconds
7009 */
7010 #ifndef PJSUA_PRES_TIMER
7011 # define PJSUA_PRES_TIMER 300
7012 #endif
7013
7014 /**
7015 * This specifies the buffer size of pjsua_buddy_dlg_event_info.
7016 *
7017 * Default: 1024 bytes
7018 */
7019 #ifndef PJSUA_BUDDY_DLG_EVENT_INFO_BUF_SIZE
7020 # define PJSUA_BUDDY_DLG_EVENT_INFO_BUF_SIZE 1024
7021 #endif
7022 /**
7023 * This structure describes buddy configuration when adding a buddy to
7024 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
7025 * the structure with #pjsua_buddy_config_default() to initialize this
7026 * structure with default configuration.
7027 */
7028 typedef struct pjsua_buddy_config
7029 {
7030 /**
7031 * Buddy URL or name address.
7032 */
7033 pj_str_t uri;
7034
7035 /**
7036 * Specify whether presence subscription should start immediately.
7037 * Note that only one subscription (presence or dialog event)
7038 * can be active at any time.
7039 */
7040 pj_bool_t subscribe;
7041
7042 /**
7043 * Specify whether we should immediately subscribe to the buddy's
7044 * dialog event, such as for Busy Lamp Field (BLF) feature.
7045 * Note that only one subscription (presence or dialog event)
7046 * can be active at any time.
7047 */
7048 pj_bool_t subscribe_dlg_event;
7049
7050 /**
7051 * Specify arbitrary application data to be associated with
7052 * the buddy object.
7053 */
7054 void *user_data;
7055
7056 /**
7057 * Specify account to be associated with the buddy object. The account
7058 * will be used for creating the subscription.
7059 *
7060 * IMPORTANT: Account must remain valid throughout the entire lifetime
7061 * of the buddy object.
7062 *
7063 * Default: PJSUA_INVALID_ID (buddy is not associated to any account)
7064 */
7065 pjsua_acc_id acc_id;
7066
7067 } pjsua_buddy_config;
7068
7069
7070 /**
7071 * This enumeration describes basic buddy's online status.
7072 */
7073 typedef enum pjsua_buddy_status
7074 {
7075 /**
7076 * Online status is unknown (possibly because no presence subscription
7077 * has been established).
7078 */
7079 PJSUA_BUDDY_STATUS_UNKNOWN,
7080
7081 /**
7082 * Buddy is known to be online.
7083 */
7084 PJSUA_BUDDY_STATUS_ONLINE,
7085
7086 /**
7087 * Buddy is offline.
7088 */
7089 PJSUA_BUDDY_STATUS_OFFLINE,
7090
7091 } pjsua_buddy_status;
7092
7093
7094
7095 /**
7096 * This structure describes buddy info, which can be retrieved by calling
7097 * #pjsua_buddy_get_info().
7098 */
7099 typedef struct pjsua_buddy_info
7100 {
7101 /**
7102 * The buddy ID.
7103 */
7104 pjsua_buddy_id id;
7105
7106 /**
7107 * The full URI of the buddy, as specified in the configuration.
7108 */
7109 pj_str_t uri;
7110
7111 /**
7112 * The account ID associated with this buddy. If not associated
7113 * with any account, the value will be PJSUA_INVALID_ID.
7114 */
7115 pjsua_acc_id acc_id;
7116
7117 /**
7118 * Buddy's Contact, only available when presence subscription has
7119 * been established to the buddy.
7120 */
7121 pj_str_t contact;
7122
7123 /**
7124 * Buddy's online status.
7125 */
7126 pjsua_buddy_status status;
7127
7128 /**
7129 * Text to describe buddy's online status.
7130 */
7131 pj_str_t status_text;
7132
7133 /**
7134 * Flag to indicate that we should monitor the presence information for
7135 * this buddy (normally yes, unless explicitly disabled).
7136 */
7137 pj_bool_t monitor_pres;
7138
7139 /**
7140 * If \a monitor_pres is enabled, this specifies the last state of the
7141 * presence subscription. If presence subscription session is currently
7142 * active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence
7143 * subscription request has been rejected, the value will be
7144 * PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be
7145 * specified in \a sub_term_reason.
7146 */
7147 pjsip_evsub_state sub_state;
7148
7149 /**
7150 * String representation of subscription state.
7151 */
7152 const char *sub_state_name;
7153
7154 /**
7155 * Specifies the last presence subscription termination code. This would
7156 * return the last status of the SUBSCRIBE request. If the subscription
7157 * is terminated with NOTIFY by the server, this value will be set to
7158 * 200, and subscription termination reason will be given in the
7159 * \a sub_term_reason field.
7160 */
7161 unsigned sub_term_code;
7162
7163 /**
7164 * Specifies the last presence subscription termination reason. If
7165 * presence subscription is currently active, the value will be empty.
7166 */
7167 pj_str_t sub_term_reason;
7168
7169 /**
7170 * Extended RPID information about the person.
7171 */
7172 pjrpid_element rpid;
7173
7174 /**
7175 * Extended presence info.
7176 */
7177 pjsip_pres_status pres_status;
7178
7179 /**
7180 * Internal buffer.
7181 */
7182 char buf_[512];
7183
7184 } pjsua_buddy_info;
7185
7186
7187 typedef struct pjsua_buddy_dlg_event_info
7188 {
7189 /**
7190 * The buddy ID.
7191 */
7192 pjsua_buddy_id id;
7193
7194 /**
7195 * The full URI of the buddy, as specified in the configuration.
7196 */
7197 pj_str_t uri;
7198
7199 /* Dialog event Dialog-Info id */
7200 pj_str_t dialog_id;
7201
7202 /* Dialog event Dialog-Info state */
7203 pj_str_t dialog_info_state;
7204
7205 /* Dialog event Dialog-Info entity */
7206 pj_str_t dialog_info_entity;
7207
7208 /* Dialog event Dialog call_id */
7209 pj_str_t dialog_call_id;
7210
7211 /* Dialog event Dialog remote_tag */
7212 pj_str_t dialog_remote_tag;
7213
7214 /* Dialog event Dialog local_tag */
7215 pj_str_t dialog_local_tag;
7216
7217 /* Dialog event Dialog direction */
7218 pj_str_t dialog_direction;
7219
7220 /* Dialog event dialog state */
7221 pj_str_t dialog_state;
7222
7223 /* Dialog event dialog duration */
7224 pj_str_t dialog_duration;
7225
7226 /* Dialog event local identity */
7227 pj_str_t local_identity;
7228
7229 /* Dialog event local identity_display */
7230 pj_str_t local_identity_display;
7231
7232 /* Dialog event local target uri */
7233 pj_str_t local_target_uri;
7234
7235 /* Dialog event remote identity */
7236 pj_str_t remote_identity;
7237
7238 /* Dialog event remote identity_display */
7239 pj_str_t remote_identity_display;
7240
7241 /* Dialog event remote target uri */
7242 pj_str_t remote_target_uri;
7243
7244 /**
7245 * This specifies the last state of the dialog event subscription.
7246 */
7247 pjsip_evsub_state sub_state;
7248
7249 /**
7250 * String representation of subscription state.
7251 */
7252 const char *sub_state_name;
7253
7254 /**
7255 * Specifies the last dialog event subscription termination code.
7256 */
7257 unsigned sub_term_code;
7258
7259 /**
7260 * Specifies the last dialog event subscription termination reason. If
7261 * presence subscription is currently active, the value will be empty.
7262 */
7263 pj_str_t sub_term_reason;
7264
7265 /**
7266 * Internal buffer.
7267 */
7268 char buf_[PJSUA_BUDDY_DLG_EVENT_INFO_BUF_SIZE];
7269
7270 } pjsua_buddy_dlg_event_info;
7271
7272 /**
7273 * Set default values to the buddy config.
7274 */
7275 PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
7276
7277
7278 /**
7279 * Get total number of buddies.
7280 *
7281 * @return Number of buddies.
7282 */
7283 PJ_DECL(unsigned) pjsua_get_buddy_count(void);
7284
7285
7286 /**
7287 * Check if buddy ID is valid.
7288 *
7289 * @param buddy_id Buddy ID to check.
7290 *
7291 * @return Non-zero if buddy ID is valid.
7292 */
7293 PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
7294
7295
7296 /**
7297 * Enumerate all buddy IDs in the buddy list. Application then can use
7298 * #pjsua_buddy_get_info() to get the detail information for each buddy
7299 * id.
7300 *
7301 * @param ids Array of ids to be initialized.
7302 * @param count On input, specifies max elements in the array.
7303 * On return, it contains actual number of elements
7304 * that have been initialized.
7305 *
7306 * @return PJ_SUCCESS on success, or the appropriate error code.
7307 */
7308 PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
7309 unsigned *count);
7310
7311 /**
7312 * Find the buddy ID with the specified URI.
7313 *
7314 * @param uri The buddy URI.
7315 *
7316 * @return The buddy ID, or PJSUA_INVALID_ID if not found.
7317 */
7318 PJ_DECL(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri);
7319
7320
7321 /**
7322 * Get detailed buddy info.
7323 *
7324 * @param buddy_id The buddy identification.
7325 * @param info Pointer to receive information about buddy.
7326 *
7327 * @return PJ_SUCCESS on success, or the appropriate error code.
7328 */
7329 PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
7330 pjsua_buddy_info *info);
7331
7332 /**
7333 * Get detailed buddy dialog event info.
7334 *
7335 * @param buddy_id The buddy identification.
7336 * @param info Pointer to receive information about buddy.
7337 *
7338 * @return PJ_SUCCESS on success, or the appropriate error code.
7339 */
7340 PJ_DECL(pj_status_t)
7341 pjsua_buddy_get_dlg_event_info(pjsua_buddy_id buddy_id,
7342 pjsua_buddy_dlg_event_info *info);
7343
7344 /**
7345 * Set the user data associated with the buddy object.
7346 *
7347 * @param buddy_id The buddy identification.
7348 * @param user_data Arbitrary application data to be associated with
7349 * the buddy object.
7350 *
7351 * @return PJ_SUCCESS on success, or the appropriate error code.
7352 */
7353 PJ_DECL(pj_status_t) pjsua_buddy_set_user_data(pjsua_buddy_id buddy_id,
7354 void *user_data);
7355
7356
7357 /**
7358 * Get the user data associated with the budy object.
7359 *
7360 * @param buddy_id The buddy identification.
7361 *
7362 * @return The application data.
7363 */
7364 PJ_DECL(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id);
7365
7366
7367 /**
7368 * Add new buddy to the buddy list. If presence subscription is enabled
7369 * for this buddy, this function will also start the presence subscription
7370 * session immediately.
7371 *
7372 * @param buddy_cfg Buddy configuration.
7373 * @param p_buddy_id Pointer to receive buddy ID.
7374 *
7375 * @return PJ_SUCCESS on success, or the appropriate error code.
7376 */
7377 PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
7378 pjsua_buddy_id *p_buddy_id);
7379
7380
7381 /**
7382 * Delete the specified buddy from the buddy list. Any presence subscription
7383 * to this buddy will be terminated.
7384 *
7385 * @param buddy_id Buddy identification.
7386 *
7387 * @return PJ_SUCCESS on success, or the appropriate error code.
7388 */
7389 PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
7390
7391
7392 /**
7393 * Enable/disable buddy's presence monitoring. Once buddy's presence is
7394 * subscribed, application will be informed about buddy's presence status
7395 * changed via \a on_buddy_state() callback.
7396 *
7397 * Note that only one subscription (presence or dialog event) can be active
7398 * at any time.
7399 *
7400 * @param buddy_id Buddy identification.
7401 * @param subscribe Specify non-zero to activate presence subscription to
7402 * the specified buddy.
7403 *
7404 * @return PJ_SUCCESS on success, or the appropriate error code.
7405 */
7406 PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
7407 pj_bool_t subscribe);
7408
7409
7410 /**
7411 * Enable/disable buddy's dialog event monitoring. Once buddy's dialog event
7412 * is subscribed, application will be informed about buddy's dialog info
7413 * status change via \a on_buddy_dlg_event_state() callback.
7414 *
7415 * Note that only one subscription (presence or dialog event) can be active
7416 * at any time.
7417 *
7418 * @param buddy_id Buddy identification.
7419 * @param subscribe Specify non-zero to activate dialog event subscription
7420 * to the specified buddy.
7421 *
7422 * @return PJ_SUCCESS on success, or the appropriate error code.
7423 */
7424 PJ_DECL(pj_status_t) pjsua_buddy_subscribe_dlg_event(pjsua_buddy_id buddy_id,
7425 pj_bool_t subscribe);
7426
7427
7428 /**
7429 * Update the presence information for the buddy. Although the library
7430 * periodically refreshes the presence subscription for all buddies, some
7431 * application may want to refresh the buddy's presence subscription
7432 * immediately, and in this case it can use this function to accomplish
7433 * this.
7434 *
7435 * Note that the buddy's presence subscription will only be initiated
7436 * if presence monitoring is enabled for the buddy. See
7437 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
7438 * for the buddy is already active, this function will not do anything.
7439 *
7440 * Once the presence subscription is activated successfully for the buddy,
7441 * application will be notified about the buddy's presence status in the
7442 * on_buddy_state() callback.
7443 *
7444 * @param buddy_id Buddy identification.
7445 *
7446 * @return PJ_SUCCESS on success, or the appropriate error code.
7447 */
7448 PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
7449
7450
7451 /**
7452 * Update the dialog event information for the buddy. Although the library
7453 * periodically refreshes the dialog event subscription for all buddies, some
7454 * application may want to refresh the buddy's dialog event subscription
7455 * immediately, and in this case it can use this function to accomplish
7456 * this.
7457 *
7458 * Note that the buddy's dialog event subscription will only be initiated
7459 * if dialog event monitoring is enabled for the buddy. See
7460 * #pjsua_buddy_subscribe_dlg_event() for more info. Also if dialog event
7461 * subscription for the buddy is already active, this function will not do
7462 * anything.
7463 *
7464 * Once the dialog event subscription is activated successfully for the buddy,
7465 * application will be notified about the buddy's dialog info status in the
7466 * on_buddy_dlg_event_state() callback.
7467 *
7468 * @param buddy_id Buddy identification.
7469 *
7470 * @return PJ_SUCCESS on success, or the appropriate error code.
7471 */
7472 PJ_DECL(pj_status_t) pjsua_buddy_update_dlg_event(pjsua_buddy_id buddy_id);
7473
7474
7475 /**
7476 * Send NOTIFY to inform account presence status or to terminate server
7477 * side presence subscription. If application wants to reject the incoming
7478 * request, it should set the \a state to PJSIP_EVSUB_STATE_TERMINATED.
7479 *
7480 * @param acc_id Account ID.
7481 * @param srv_pres Server presence subscription instance.
7482 * @param state New state to set.
7483 * @param state_str Optionally specify the state string name, if state
7484 * is not "active", "pending", or "terminated".
7485 * @param reason If the new state is PJSIP_EVSUB_STATE_TERMINATED,
7486 * optionally specify the termination reason.
7487 * @param with_body If the new state is PJSIP_EVSUB_STATE_TERMINATED,
7488 * this specifies whether the NOTIFY request should
7489 * contain message body containing account's presence
7490 * information.
7491 * @param msg_data Optional list of headers to be sent with the NOTIFY
7492 * request.
7493 *
7494 * @return PJ_SUCCESS on success.
7495 */
7496 PJ_DECL(pj_status_t) pjsua_pres_notify(pjsua_acc_id acc_id,
7497 pjsua_srv_pres *srv_pres,
7498 pjsip_evsub_state state,
7499 const pj_str_t *state_str,
7500 const pj_str_t *reason,
7501 pj_bool_t with_body,
7502 const pjsua_msg_data *msg_data);
7503
7504 /**
7505 * Dump presence subscriptions to log.
7506 *
7507 * @param verbose Yes or no.
7508 */
7509 PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
7510
7511
7512 /**
7513 * The MESSAGE method (defined in pjsua_im.c)
7514 */
7515 extern const pjsip_method pjsip_message_method;
7516
7517
7518 /**
7519 * The INFO method (defined in pjsua_call.c)
7520 */
7521 extern const pjsip_method pjsip_info_method;
7522
7523
7524 /**
7525 * Send instant messaging outside dialog, using the specified account for
7526 * route set and authentication.
7527 *
7528 * @param acc_id Account ID to be used to send the request.
7529 * @param to Remote URI.
7530 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
7531 * assumed.
7532 * @param content The message content. Can be NULL if msg_data specifies
7533 * body and/or multipart.
7534 * @param msg_data Optional list of headers etc to be included in outgoing
7535 * request. The body descriptor in the msg_data is
7536 * ignored if parameter 'content' is set.
7537 * @param user_data Optional user data, which will be given back when
7538 * the IM callback is called.
7539 *
7540 * @return PJ_SUCCESS on success, or the appropriate error code.
7541 */
7542 PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
7543 const pj_str_t *to,
7544 const pj_str_t *mime_type,
7545 const pj_str_t *content,
7546 const pjsua_msg_data *msg_data,
7547 void *user_data);
7548
7549
7550 /**
7551 * Send typing indication outside dialog.
7552 *
7553 * @param acc_id Account ID to be used to send the request.
7554 * @param to Remote URI.
7555 * @param is_typing If non-zero, it tells remote person that local person
7556 * is currently composing an IM.
7557 * @param msg_data Optional list of headers etc to be added to outgoing
7558 * request.
7559 *
7560 * @return PJ_SUCCESS on success, or the appropriate error code.
7561 */
7562 PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
7563 const pj_str_t *to,
7564 pj_bool_t is_typing,
7565 const pjsua_msg_data *msg_data);
7566
7567
7568 /**
7569 * @}
7570 */
7571
7572
7573 /*****************************************************************************
7574 * MEDIA API
7575 */
7576
7577
7578 /**
7579 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
7580 * @ingroup PJSUA_LIB
7581 * @brief Media manipulation.
7582 * @{
7583 *
7584 * PJSUA has rather powerful media features, which are built around the
7585 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
7586 * players, WAV playlist, file recorders, sound device, tone generators, etc)
7587 * are terminated in the conference bridge, and application can manipulate
7588 * the interconnection between these terminations freely.
7589 *
7590 * The conference bridge provides powerful switching and mixing functionality
7591 * for application. With the conference bridge, each conference slot (e.g.
7592 * a call) can transmit to multiple destinations, and one destination can
7593 * receive from multiple sources. If more than one media terminations are
7594 * terminated in the same slot, the conference bridge will mix the signal
7595 * automatically.
7596 *
7597 * Application connects one media termination/slot to another by calling
7598 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
7599 * media flow from the source termination to the sink termination. To
7600 * establish bidirectional media flow, application would need to make another
7601 * call to #pjsua_conf_connect(), this time inverting the source and
7602 * destination slots in the parameter.
7603 *
7604 * For example, to stream a WAV file to remote call, application may use
7605 * the following steps:
7606 *
7607 \code
7608
7609 pj_status_t stream_to_call( pjsua_call_id call_id )
7610 {
7611 pjsua_player_id player_id;
7612
7613 status = pjsua_player_create("mysong.wav", 0, &player_id);
7614 if (status != PJ_SUCCESS)
7615 return status;
7616
7617 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
7618 pjsua_call_get_conf_port() );
7619 }
7620 \endcode
7621 *
7622 *
7623 * Other features of PJSUA media:
7624 * - efficient N to M interconnections between media terminations.
7625 * - media termination can be connected to itself to create loopback
7626 * media.
7627 * - the media termination may have different clock rates, and resampling
7628 * will be done automatically by conference bridge.
7629 * - media terminations may also have different frame time; the
7630 * conference bridge will perform the necessary bufferring to adjust
7631 * the difference between terminations.
7632 * - interconnections are removed automatically when media termination
7633 * is removed from the bridge.
7634 * - sound device may be changed even when there are active media
7635 * interconnections.
7636 * - correctly report call's media quality (in #pjsua_call_dump()) from
7637 * RTCP packet exchange.
7638 */
7639
7640 /**
7641 * Use PJMEDIA for media? Set this to zero when using third party media
7642 * stack.
7643 */
7644 #ifndef PJSUA_MEDIA_HAS_PJMEDIA
7645 # define PJSUA_MEDIA_HAS_PJMEDIA 1
7646 #endif /* PJSUA_MEDIA_HAS_PJMEDIA */
7647
7648
7649 /**
7650 * Specify whether the third party stream has the capability of retrieving
7651 * the stream info, i.e: pjmedia_stream_get_info() and
7652 * pjmedia_vid_stream_get_info(). Currently this capability is required
7653 * by smart media update and call dump.
7654 */
7655 #ifndef PJSUA_THIRD_PARTY_STREAM_HAS_GET_INFO
7656 # define PJSUA_THIRD_PARTY_STREAM_HAS_GET_INFO 0
7657 #endif
7658
7659
7660 /**
7661 * Specify whether the third party stream has the capability of retrieving
7662 * the stream statistics, i.e: pjmedia_stream_get_stat() and
7663 * pjmedia_vid_stream_get_stat(). Currently this capability is required
7664 * by call dump.
7665 */
7666 #ifndef PJSUA_THIRD_PARTY_STREAM_HAS_GET_STAT
7667 # define PJSUA_THIRD_PARTY_STREAM_HAS_GET_STAT 0
7668 #endif
7669
7670
7671 /**
7672 * Max ports in the conference bridge. This setting is the default value
7673 * for pjsua_media_config.max_media_ports.
7674 */
7675 #ifndef PJSUA_MAX_CONF_PORTS
7676 # define PJSUA_MAX_CONF_PORTS 254
7677 #endif
7678
7679 /**
7680 * The default clock rate to be used by the conference bridge. This setting
7681 * is the default value for pjsua_media_config.clock_rate.
7682 */
7683 #ifndef PJSUA_DEFAULT_CLOCK_RATE
7684 # define PJSUA_DEFAULT_CLOCK_RATE 16000
7685 #endif
7686
7687 /**
7688 * Sound device uses \ref PJMEDIA_CLOCK instead of native sound device
7689 * clock. This setting is the default value for
7690 * pjsua_media_config.snd_use_sw_clock.
7691 */
7692 #ifndef PJSUA_DEFAULT_SND_USE_SW_CLOCK
7693 # define PJSUA_DEFAULT_SND_USE_SW_CLOCK PJ_TRUE
7694 #endif
7695
7696 /**
7697 * Default frame length in the conference bridge. This setting
7698 * is the default value for pjsua_media_config.audio_frame_ptime.
7699 */
7700 #ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
7701 # define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
7702 #endif
7703
7704
7705 /**
7706 * Default codec quality settings. This setting is the default value
7707 * for pjsua_media_config.quality.
7708 */
7709 #ifndef PJSUA_DEFAULT_CODEC_QUALITY
7710 # define PJSUA_DEFAULT_CODEC_QUALITY 8
7711 #endif
7712
7713 /**
7714 * Default iLBC mode. This setting is the default value for
7715 * pjsua_media_config.ilbc_mode.
7716 */
7717 #ifndef PJSUA_DEFAULT_ILBC_MODE
7718 # define PJSUA_DEFAULT_ILBC_MODE 30
7719 #endif
7720
7721 /**
7722 * The default echo canceller tail length. This setting
7723 * is the default value for pjsua_media_config.ec_tail_len.
7724 */
7725 #ifndef PJSUA_DEFAULT_EC_TAIL_LEN
7726 # define PJSUA_DEFAULT_EC_TAIL_LEN 200
7727 #endif
7728
7729
7730 /**
7731 * The maximum file player.
7732 */
7733 #ifndef PJSUA_MAX_PLAYERS
7734 # define PJSUA_MAX_PLAYERS 32
7735 #endif
7736
7737
7738 /**
7739 * The maximum file recorder.
7740 */
7741 #ifndef PJSUA_MAX_RECORDERS
7742 # define PJSUA_MAX_RECORDERS 32
7743 #endif
7744
7745 /**
7746 * The maximum avi file player.
7747 */
7748 #ifndef PJSUA_MAX_AVI_PLAYERS
7749 # define PJSUA_MAX_AVI_PLAYERS 4
7750 #endif
7751
7752 /**
7753 * The maximum avi file recorder.
7754 */
7755 #ifndef PJSUA_MAX_AVI_RECORDERS
7756 # define PJSUA_MAX_AVI_RECORDERS 4
7757 #endif
7758
7759 /**
7760 * Enable/disable "c=" line in SDP session level. Set to zero to disable it.
7761 */
7762 #ifndef PJSUA_SDP_SESS_HAS_CONN
7763 # define PJSUA_SDP_SESS_HAS_CONN 0
7764 #endif
7765
7766
7767 /**
7768 * Specify the delay needed when restarting the transport/listener.
7769 * e.g: 10 msec on Linux or Android, and 0 on the other platforms.
7770 */
7771 #ifndef PJSUA_TRANSPORT_RESTART_DELAY_TIME
7772 # define PJSUA_TRANSPORT_RESTART_DELAY_TIME 10
7773 #endif
7774
7775
7776 /**
7777 * Specify the delay of video stream start in encoding direction, in
7778 * millisecond. Delayed encoding start generally smoothens video stream
7779 * initiation by reducing the risk of RTP packet loss in the receiver/decoder
7780 * (e.g.: due to the receiver's media transport or stream being unready).
7781 * Note that initial video RTP packets usually contain crucial information,
7782 * such as video codec parameters and keyframes.
7783 *
7784 * Default: 500ms
7785 */
7786 #ifndef PJSUA_VIDEO_STREAM_DELAY_START_ENCODE
7787 # define PJSUA_VIDEO_STREAM_DELAY_START_ENCODE 500
7788 #endif
7789
7790
7791 /**
7792 * This structure describes media configuration, which will be specified
7793 * when calling #pjsua_init(). Application MUST initialize this structure
7794 * by calling #pjsua_media_config_default().
7795 */
7796 struct pjsua_media_config
7797 {
7798 /**
7799 * Clock rate to be applied to the conference bridge.
7800 * If value is zero, default clock rate will be used
7801 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
7802 */
7803 unsigned clock_rate;
7804
7805 /**
7806 * Clock rate to be applied when opening the sound device.
7807 * If value is zero, conference bridge clock rate will be used.
7808 */
7809 unsigned snd_clock_rate;
7810
7811 /**
7812 * Sound device uses \ref PJMEDIA_CLOCK instead of native sound device
7813 * clock, generally this will be able to reduce jitter and clock drift.
7814 *
7815 * This option is not applicable for encoded/non-PCM format.
7816 *
7817 * Default value: PJSUA_DEFAULT_SND_USE_SW_CLOCK
7818 */
7819 pj_bool_t snd_use_sw_clock;
7820
7821 /**
7822 * Channel count be applied when opening the sound device and
7823 * conference bridge.
7824 */
7825 unsigned channel_count;
7826
7827 /**
7828 * Specify audio frame ptime. The value here will affect the
7829 * samples per frame of both the sound device and the conference
7830 * bridge. Specifying lower ptime will normally reduce the
7831 * latency.
7832 *
7833 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
7834 */
7835 unsigned audio_frame_ptime;
7836
7837 /**
7838 * Specify maximum number of media ports to be created in the
7839 * conference bridge. Since all media terminate in the bridge
7840 * (calls, file player, file recorder, etc), the value must be
7841 * large enough to support all of them. However, the larger
7842 * the value, the more computations are performed.
7843 *
7844 * Default value: PJSUA_MAX_CONF_PORTS
7845 */
7846 unsigned max_media_ports;
7847
7848 /**
7849 * Total number of threads that can be used by the conference bridge
7850 * including get_frame() thread.
7851 *
7852 * This value is used to determine if the conference bridge should be
7853 * implemented as a parallel bridge or not.
7854 * If the value is set to 0 or 1, the conference bridge will be implemented as a
7855 * serial bridge, otherwise it will be implemented as a parallel bridge.
7856 *
7857 * This value is ignored by all conference backends except for the
7858 * multithreaded conference bridge backend
7859 * (PJMEDIA_CONF_PARALLEL_BRIDGE_BACKEND).
7860 *
7861 * Default value: PJMEDIA_CONF_THREADS
7862 */
7863 unsigned conf_threads;
7864
7865 /**
7866 * Specify whether the media manager should manage its own
7867 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
7868 * and at least one worker thread will be created too. If no,
7869 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
7870 * and no worker thread is needed.
7871 *
7872 * Normally application would say yes here, unless it wants to
7873 * run everything from a single thread.
7874 */
7875 pj_bool_t has_ioqueue;
7876
7877 /**
7878 * Specify the number of worker threads to handle incoming RTP
7879 * packets. A value of one is recommended for most applications.
7880 */
7881 unsigned thread_cnt;
7882
7883 /**
7884 * Media quality, 0-10, according to this table:
7885 * 5-10: resampling use large filter,
7886 * 3-4: resampling use small filter,
7887 * 1-2: resampling use linear.
7888 * The media quality also sets speex codec quality/complexity to the
7889 * number.
7890 *
7891 * Default: PJSUA_DEFAULT_CODEC_QUALITY.
7892 */
7893 unsigned quality;
7894
7895 /**
7896 * Specify default codec ptime.
7897 *
7898 * Default: 0 (codec specific)
7899 */
7900 unsigned ptime;
7901
7902 /**
7903 * Disable VAD?
7904 *
7905 * Default: 0 (codec specific)
7906 */
7907 pj_bool_t no_vad;
7908
7909 /**
7910 * iLBC mode (20 or 30).
7911 *
7912 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
7913 */
7914 unsigned ilbc_mode;
7915
7916 /**
7917 * Percentage of RTP packet to drop in TX direction
7918 * (to simulate packet lost).
7919 *
7920 * Default: 0
7921 */
7922 unsigned tx_drop_pct;
7923
7924 /**
7925 * Percentage of RTP packet to drop in RX direction
7926 * (to simulate packet lost).
7927 *
7928 * Default: 0
7929 */
7930 unsigned rx_drop_pct;
7931
7932 /**
7933 * Echo canceller options (see #pjmedia_echo_create()).
7934 * Specify PJMEDIA_ECHO_USE_SW_ECHO here if application wishes
7935 * to use software echo canceller instead of device EC.
7936 *
7937 * Default: 0.
7938 */
7939 unsigned ec_options;
7940
7941 /**
7942 * Echo canceller tail length, in miliseconds.
7943 *
7944 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
7945 */
7946 unsigned ec_tail_len;
7947
7948 /**
7949 * Audio capture buffer length, in milliseconds.
7950 *
7951 * Default: PJMEDIA_SND_DEFAULT_REC_LATENCY
7952 */
7953 unsigned snd_rec_latency;
7954
7955 /**
7956 * Audio playback buffer length, in milliseconds.
7957 *
7958 * Default: PJMEDIA_SND_DEFAULT_PLAY_LATENCY
7959 */
7960 unsigned snd_play_latency;
7961
7962 /**
7963 * Jitter buffer initial prefetch delay in msec. The value must be
7964 * between jb_min_pre and jb_max_pre below. If the value is 0,
7965 * prefetching will be disabled.
7966 *
7967 * Default: -1 (to use default stream settings, currently 0)
7968 */
7969 int jb_init;
7970
7971 /**
7972 * Jitter buffer minimum prefetch delay in msec.
7973 *
7974 * Default: -1 (to use default stream settings, currently codec ptime)
7975 */
7976 int jb_min_pre;
7977
7978 /**
7979 * Jitter buffer maximum prefetch delay in msec.
7980 *
7981 * Default: -1 (to use default stream settings, currently 80% of jb_max)
7982 */
7983 int jb_max_pre;
7984
7985 /**
7986 * Set maximum delay that can be accomodated by the jitter buffer msec.
7987 *
7988 * Default: -1 (to use default stream settings, currently 500 msec)
7989 */
7990 int jb_max;
7991
7992 /**
7993 * Set the algorithm the jitter buffer uses to discard frames in order to
7994 * adjust the latency.
7995 *
7996 * Default: PJMEDIA_JB_DISCARD_PROGRESSIVE
7997 */
7998 pjmedia_jb_discard_algo jb_discard_algo;
7999
8000 /**
8001 * Enable ICE
8002 */
8003 pj_bool_t enable_ice;
8004
8005 /**
8006 * Set the maximum number of host candidates.
8007 *
8008 * Default: -1 (maximum not set)
8009 */
8010 int ice_max_host_cands;
8011
8012 /**
8013 * ICE session options.
8014 */
8015 pj_ice_sess_options ice_opt;
8016
8017 /**
8018 * Disable RTCP component.
8019 *
8020 * Default: no
8021 */
8022 pj_bool_t ice_no_rtcp;
8023
8024 /**
8025 * Send re-INVITE/UPDATE every after ICE connectivity check regardless
8026 * the default ICE transport address is changed or not. When this is set
8027 * to PJ_FALSE, re-INVITE/UPDATE will be sent only when the default ICE
8028 * transport address is changed.
8029 *
8030 * Default: yes
8031 */
8032 pj_bool_t ice_always_update;
8033
8034 /**
8035 * Enable TURN relay candidate in ICE.
8036 */
8037 pj_bool_t enable_turn;
8038
8039 /**
8040 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
8041 * "HOST:PORT" format.
8042 */
8043 pj_str_t turn_server;
8044
8045 /**
8046 * Specify the connection type to be used to the TURN server. Valid
8047 * values are PJ_TURN_TP_UDP, PJ_TURN_TP_TCP or PJ_TURN_TP_TLS.
8048 *
8049 * Default: PJ_TURN_TP_UDP
8050 */
8051 pj_turn_tp_type turn_conn_type;
8052
8053 /**
8054 * Specify the credential to authenticate with the TURN server.
8055 */
8056 pj_stun_auth_cred turn_auth_cred;
8057
8058 /**
8059 * This specifies TLS settings for TLS transport. It’s only applicable
8060 * when TLS is used to connect to the TURN server.
8061 */
8062 pj_turn_sock_tls_cfg turn_tls_setting;
8063
8064 /**
8065 * Specify idle time of sound device before it is automatically closed,
8066 * in seconds. Use value -1 to disable the auto-close feature of sound
8067 * device
8068 *
8069 * Default : 1
8070 */
8071 int snd_auto_close_time;
8072
8073 /**
8074 * Specify whether built-in/native preview should be used if available.
8075 * In some systems, video input devices have built-in capability to show
8076 * preview window of the device. Using this built-in preview is preferable
8077 * as it consumes less CPU power. If built-in preview is not available,
8078 * the library will perform software rendering of the input. If this
8079 * field is set to PJ_FALSE, software preview will always be used.
8080 *
8081 * Default: PJ_TRUE
8082 */
8083 pj_bool_t vid_preview_enable_native;
8084
8085 /**
8086 * Disable smart media update (ticket #1568). The smart media update
8087 * will check for any changes in the media properties after a successful
8088 * SDP negotiation and the media will only be reinitialized when any
8089 * change is found. When it is disabled, media streams will always be
8090 * reinitialized after a successful SDP negotiation.
8091 *
8092 * Note for third party media, the smart media update requires stream info
8093 * retrieval capability, see #PJSUA_THIRD_PARTY_STREAM_HAS_GET_INFO.
8094 *
8095 * Default: PJ_FALSE
8096 */
8097 pj_bool_t no_smart_media_update;
8098
8099 /**
8100 * Omit RTCP SDES and BYE in outgoing RTCP packet, this setting will be
8101 * applied for both audio and video streams. Note that, when RTCP SDES
8102 * and BYE are set to be omitted, RTCP SDES will still be sent once when
8103 * the stream starts/stops and RTCP BYE will be sent once when the stream
8104 * stops.
8105 *
8106 * Default: PJ_FALSE
8107 */
8108 pj_bool_t no_rtcp_sdes_bye;
8109
8110 /**
8111 * Optional callback for audio frame preview right before queued to
8112 * the speaker.
8113 * Notes:
8114 * - Application MUST NOT block or perform long operation in the callback
8115 * as the callback may be executed in sound device thread.
8116 * - When using software echo cancellation, application MUST NOT modify
8117 * the audio data from within the callback, otherwise the echo canceller
8118 * will not work properly.
8119 * - Application MUST NOT stop or switch the audio device, or modify
8120 * audio device settings (e.g: by calling #pjsua_set_ec()) from
8121 * within this callback.
8122 */
8123 void (*on_aud_prev_play_frame)(pjmedia_frame *frame);
8124
8125 /**
8126 * Optional callback for audio frame preview recorded from the microphone
8127 * before being processed by any media component such as software echo
8128 * canceller.
8129 * Notes:
8130 * - Application MUST NOT block or perform long operation in the callback
8131 * as the callback may be executed in sound device thread.
8132 * - When using software echo cancellation, application MUST NOT modify
8133 * the audio data from within the callback, otherwise the echo canceller
8134 * will not work properly.
8135 * - Application MUST NOT stop or switch the audio device, or modify
8136 * audio device settings (e.g: by calling #pjsua_set_ec()) from
8137 * within this callback.
8138 */
8139 void (*on_aud_prev_rec_frame)(pjmedia_frame *frame);
8140 };
8141
8142
8143 /**
8144 * Use this function to initialize media config.
8145 *
8146 * @param cfg The media config to be initialized.
8147 */
8148 PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
8149
8150
8151 /**
8152 * This structure describes codec information, which can be retrieved by
8153 * calling #pjsua_enum_codecs().
8154 */
8155 typedef struct pjsua_codec_info
8156 {
8157 /**
8158 * Codec unique identification.
8159 */
8160 pj_str_t codec_id;
8161
8162 /**
8163 * Codec priority (integer 0-255).
8164 */
8165 pj_uint8_t priority;
8166
8167 /**
8168 * Codec description.
8169 */
8170 pj_str_t desc;
8171
8172 /**
8173 * Internal buffer.
8174 */
8175 char buf_[64];
8176
8177 } pjsua_codec_info;
8178
8179
8180 /**
8181 * This structure describes information about a particular media port that
8182 * has been registered into the conference bridge. Application can query
8183 * this info by calling #pjsua_conf_get_port_info().
8184 */
8185 typedef struct pjsua_conf_port_info
8186 {
8187 /** Conference port number. */
8188 pjsua_conf_port_id slot_id;
8189
8190 /** Port name. */
8191 pj_str_t name;
8192
8193 /** Format. */
8194 pjmedia_format format;
8195
8196 /** Clock rate. */
8197 unsigned clock_rate;
8198
8199 /** Number of channels. */
8200 unsigned channel_count;
8201
8202 /** Samples per frame */
8203 unsigned samples_per_frame;
8204
8205 /** Bits per sample */
8206 unsigned bits_per_sample;
8207
8208 /** Tx level adjustment. */
8209 float tx_level_adj;
8210
8211 /** Rx level adjustment. */
8212 float rx_level_adj;
8213
8214 /** Number of listeners in the array. */
8215 unsigned listener_cnt;
8216
8217 /** Array of listeners (in other words, ports where this port is
8218 * transmitting to).
8219 */
8220 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
8221
8222 } pjsua_conf_port_info;
8223
8224
8225 /**
8226 * This structure holds information about custom media transport to
8227 * be registered to pjsua.
8228 */
8229 typedef struct pjsua_media_transport
8230 {
8231 /**
8232 * Media socket information containing the address information
8233 * of the RTP and RTCP socket.
8234 */
8235 pjmedia_sock_info skinfo;
8236
8237 /**
8238 * The media transport instance.
8239 */
8240 pjmedia_transport *transport;
8241
8242 } pjsua_media_transport;
8243
8244
8245 /**
8246 * Sound device index constants.
8247 */
8248 typedef enum pjsua_snd_dev_id
8249 {
8250 /**
8251 * Constant to denote default capture device.
8252 */
8253 PJSUA_SND_DEFAULT_CAPTURE_DEV = PJMEDIA_AUD_DEFAULT_CAPTURE_DEV,
8254
8255 /**
8256 * Constant to denote default playback device.
8257 */
8258 PJSUA_SND_DEFAULT_PLAYBACK_DEV = PJMEDIA_AUD_DEFAULT_PLAYBACK_DEV,
8259
8260 /**
8261 * Constant to denote that no sound device is being used.
8262 */
8263 PJSUA_SND_NO_DEV = PJMEDIA_AUD_INVALID_DEV,
8264
8265 /**
8266 * Constant to denote null sound device.
8267 */
8268 PJSUA_SND_NULL_DEV = -99
8269
8270 } pjsua_snd_dev_id;
8271
8272 /**
8273 * This enumeration specifies the sound device mode.
8274 */
8275 typedef enum pjsua_snd_dev_mode
8276 {
8277 /**
8278 * Open sound device without mic (speaker only).
8279 */
8280 PJSUA_SND_DEV_SPEAKER_ONLY = 1,
8281
8282 /**
8283 * Do not open sound device, after setting the sound device.
8284 */
8285 PJSUA_SND_DEV_NO_IMMEDIATE_OPEN = 2
8286
8287 } pjsua_snd_dev_mode;
8288
8289
8290 /**
8291 * This structure specifies the parameters to set the sound device.
8292 * Use pjsua_snd_dev_param_default() to initialize this structure with
8293 * default values.
8294 */
8295 typedef struct pjsua_snd_dev_param
8296 {
8297 /**
8298 * Capture dev id.
8299 *
8300 * Default: PJMEDIA_AUD_DEFAULT_CAPTURE_DEV
8301 */
8302 int capture_dev;
8303
8304 /**
8305 * Playback dev id.
8306 *
8307 * Default: PJMEDIA_AUD_DEFAULT_PLAYBACK_DEV
8308 */
8309 int playback_dev;
8310
8311 /**
8312 * Sound device mode, refer to #pjsua_snd_dev_mode.
8313 *
8314 * Default: 0
8315 */
8316 unsigned mode;
8317
8318 /**
8319 * The library will maintain the global sound device settings set when
8320 * opening the sound device for the first time and later can be modified
8321 * using #pjsua_snd_set_setting(). These setings are then applied to any
8322 * sound device when opening. This might be undesirable,
8323 * e.g: output volume changes when switching sound device due to the
8324 * use of previously set volume settings.
8325 *
8326 * To avoid such case, application can set this to PJ_TRUE and let the
8327 * sound device use default settings when opening. This will also reset
8328 * the global sound device settings.
8329 *
8330 * Default: PJ_FALSE
8331 */
8332 pj_bool_t use_default_settings;
8333
8334 } pjsua_snd_dev_param;
8335
8336
8337 /**
8338 * Initialize pjsua_snd_dev_param with default values.
8339 *
8340 * @param prm The parameter.
8341 */
8342 PJ_DECL(void) pjsua_snd_dev_param_default(pjsua_snd_dev_param *prm);
8343
8344
8345 /**
8346 * This structure specifies the parameters for conference ports connection.
8347 * Use pjsua_conf_connect_param_default() to initialize this structure with
8348 * default values.
8349 */
8350 typedef struct pjsua_conf_connect_param
8351 {
8352 /**
8353 * Signal level adjustment from the source to the sink to make it
8354 * louder or quieter. Value 1.0 means no level adjustment,
8355 * while value 0 means to mute the port.
8356 *
8357 * Default: 1.0
8358 */
8359 float level;
8360
8361 } pjsua_conf_connect_param;
8362
8363
8364 /**
8365 * Initialize pjsua_conf_connect_param with default values.
8366 *
8367 * @param prm The parameter.
8368 */
8369 PJ_DECL(void) pjsua_conf_connect_param_default(pjsua_conf_connect_param *prm);
8370
8371
8372 /**
8373 * Get maxinum number of conference ports.
8374 *
8375 * @return Maximum number of ports in the conference bridge.
8376 */
8377 PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
8378
8379
8380 /**
8381 * Get current number of active ports in the bridge.
8382 *
8383 * @return The number.
8384 */
8385 PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
8386
8387
8388 /**
8389 * Enumerate all conference ports.
8390 *
8391 * @param id Array of conference port ID to be initialized.
8392 * @param count On input, specifies max elements in the array.
8393 * On return, it contains actual number of elements
8394 * that have been initialized.
8395 *
8396 * @return PJ_SUCCESS on success, or the appropriate error code.
8397 */
8398 PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
8399 unsigned *count);
8400
8401
8402 /**
8403 * Get information about the specified conference port
8404 *
8405 * @param port_id Port identification.
8406 * @param info Pointer to store the port info.
8407 *
8408 * @return PJ_SUCCESS on success, or the appropriate error code.
8409 */
8410 PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
8411 pjsua_conf_port_info *info);
8412
8413
8414 /**
8415 * Add arbitrary media port to PJSUA's conference bridge. Application
8416 * can use this function to add the media port that it creates. For
8417 * media ports that are created by PJSUA-LIB (such as calls, file player,
8418 * or file recorder), PJSUA-LIB will automatically add the port to
8419 * the bridge.
8420 *
8421 * This operation executes asynchronously, use the callback set from
8422 * \a on_conf_op_completed to receive notification upon completion.
8423 *
8424 * @param pool Pool to use.
8425 * @param port Media port to be added to the bridge.
8426 * @param p_id Optional pointer to receive the conference
8427 * slot id.
8428 *
8429 * @return PJ_SUCCESS on success, or the appropriate error code.
8430 */
8431 PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
8432 pjmedia_port *port,
8433 pjsua_conf_port_id *p_id);
8434
8435
8436 /**
8437 * Remove arbitrary slot from the conference bridge. Application should only
8438 * call this function if it registered the port manually with previous call
8439 * to #pjsua_conf_add_port().
8440 *
8441 * This operation executes asynchronously, use the callback set from
8442 * \a on_conf_op_completed to receive notification upon completion.
8443 *
8444 * @param port_id The slot id of the port to be removed.
8445 *
8446 * @return PJ_SUCCESS on success, or the appropriate error code.
8447 */
8448 PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
8449
8450
8451 /**
8452 * Establish unidirectional media flow from souce to sink. One source
8453 * may transmit to multiple destinations/sink. And if multiple
8454 * sources are transmitting to the same sink, the media will be mixed
8455 * together. Source and sink may refer to the same ID, effectively
8456 * looping the media.
8457 *
8458 * If bidirectional media flow is desired, application needs to call
8459 * this function twice, with the second one having the arguments
8460 * reversed.
8461 *
8462 * This operation executes asynchronously, use the callback set from
8463 * \a on_conf_op_completed to receive notification upon completion.
8464 *
8465 * @param source Port ID of the source media/transmitter.
8466 * @param sink Port ID of the destination media/received.
8467 *
8468 * @return PJ_SUCCESS on success, or the appropriate error code.
8469 */
8470 PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
8471 pjsua_conf_port_id sink);
8472
8473 /**
8474 * Establish unidirectional media flow from source to sink. One source
8475 * may transmit to multiple destinations/sink. And if multiple
8476 * sources are transmitting to the same sink, the media will be mixed
8477 * together. Source and sink may refer to the same ID, effectively
8478 * looping the media.
8479 *
8480 * Signal level from the source to the sink can be adjusted by making
8481 * it louder or quieter via the parameter param. The level adjustment
8482 * will apply to a specific connection only (i.e. only for the signal
8483 * from the source to the sink), as compared to
8484 * pjsua_conf_adjust_tx_level()/pjsua_conf_adjust_rx_level() which
8485 * applies to all signals from/to that port. The signal adjustment
8486 * will be cumulative, in this following order:
8487 * signal from the source will be adjusted with the level specified
8488 * in pjsua_conf_adjust_rx_level(), then with the level specified
8489 * via this API, and finally with the level specified to the sink's
8490 * pjsua_conf_adjust_tx_level().
8491 *
8492 * If bidirectional media flow is desired, application needs to call
8493 * this function twice, with the second one having the arguments
8494 * reversed.
8495 *
8496 * This operation executes asynchronously, use the callback set from
8497 * \a on_conf_op_completed to receive notification upon completion.
8498 *
8499 * @param source Port ID of the source media/transmitter.
8500 * @param sink Port ID of the destination media/received.
8501 * @param prm Conference port connection param. If set to
8502 * NULL, default values will be used.
8503 *
8504 * @return PJ_SUCCESS on success, or the appropriate error code.
8505 */
8506 PJ_DECL(pj_status_t) pjsua_conf_connect2(pjsua_conf_port_id source,
8507 pjsua_conf_port_id sink,
8508 const pjsua_conf_connect_param *prm);
8509
8510
8511 /**
8512 * Disconnect media flow from the source to destination port.
8513 *
8514 * This operation executes asynchronously, use the callback set from
8515 * \a on_conf_op_completed to receive notification upon completion.
8516 *
8517 * @param source Port ID of the source media/transmitter.
8518 * @param sink Port ID of the destination media/received.
8519 *
8520 * @return PJ_SUCCESS on success, or the appropriate error code.
8521 */
8522 PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
8523 pjsua_conf_port_id sink);
8524
8525 /**
8526 * Change TX and RX settings for the port.
8527 *
8528 * @param slot Port number/slot in the conference bridge.
8529 * @param tx Settings for the transmission TO this port.
8530 * @param rx Settings for the receipt FROM this port.
8531 *
8532 * @return PJ_SUCCESS on success, or the appropriate error code.
8533 */
8534 PJ_DECL(pj_status_t) pjsua_conf_configure_port(pjsua_conf_port_id slot,
8535 pjmedia_port_op tx,
8536 pjmedia_port_op rx);
8537
8538 /**
8539 * Adjust the signal level to be transmitted from the bridge to the
8540 * specified port by making it louder or quieter.
8541 *
8542 * @param slot The conference bridge slot number.
8543 * @param level Signal level adjustment. Value 1.0 means no level
8544 * adjustment, while value 0 means to mute the port.
8545 *
8546 * @return PJ_SUCCESS on success, or the appropriate error code.
8547 */
8548 PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
8549 float level);
8550
8551 /**
8552 * Adjust the signal level to be received from the specified port (to
8553 * the bridge) by making it louder or quieter.
8554 *
8555 * @param slot The conference bridge slot number.
8556 * @param level Signal level adjustment. Value 1.0 means no level
8557 * adjustment, while value 0 means to mute the port.
8558 *
8559 * @return PJ_SUCCESS on success, or the appropriate error code.
8560 */
8561 PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
8562 float level);
8563
8564 /**
8565 * Get last signal level transmitted to or received from the specified port.
8566 * The signal level is an integer value in zero to 255, with zero indicates
8567 * no signal, and 255 indicates the loudest signal level.
8568 *
8569 * @param slot The conference bridge slot number.
8570 * @param tx_level Optional argument to receive the level of signal
8571 * transmitted to the specified port (i.e. the direction
8572 * is from the bridge to the port).
8573 * @param rx_level Optional argument to receive the level of signal
8574 * received from the port (i.e. the direction is from the
8575 * port to the bridge).
8576 *
8577 * @return PJ_SUCCESS on success.
8578 */
8579 PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
8580 unsigned *tx_level,
8581 unsigned *rx_level);
8582
8583
8584 /*****************************************************************************
8585 * File player and playlist.
8586 */
8587
8588 /**
8589 * Create a file player, and automatically add this player to
8590 * the conference bridge.
8591 *
8592 * @param filename The filename to be played. Currently only
8593 * WAV files are supported, and the WAV file MUST be
8594 * formatted as 16bit PCM mono/single channel (any
8595 * clock rate is supported).
8596 * Filename's length must be smaller than PJ_MAXPATH.
8597 * @param options Optional option flag. Application may specify
8598 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
8599 * @param p_id Pointer to receive player ID.
8600 *
8601 * @return PJ_SUCCESS on success, or the appropriate error code.
8602 */
8603 PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
8604 unsigned options,
8605 pjsua_player_id *p_id);
8606
8607
8608 /**
8609 * Create a file playlist media port, and automatically add the port
8610 * to the conference bridge.
8611 *
8612 * @param file_names Array of file names to be added to the play list.
8613 * Note that the files must have the same clock rate,
8614 * number of channels, and number of bits per sample.
8615 * Each filename's length must be smaller than
8616 * PJ_MAXPATH.
8617 * @param file_count Number of files in the array.
8618 * @param label Optional label to be set for the media port.
8619 * @param options Optional option flag. Application may specify
8620 * PJMEDIA_FILE_NO_LOOP to prevent looping.
8621 * @param p_id Optional pointer to receive player ID.
8622 *
8623 * @return PJ_SUCCESS on success, or the appropriate error code.
8624 */
8625 PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
8626 unsigned file_count,
8627 const pj_str_t *label,
8628 unsigned options,
8629 pjsua_player_id *p_id);
8630
8631 /**
8632 * Get conference port ID associated with player or playlist.
8633 *
8634 * @param id The file player ID.
8635 *
8636 * @return Conference port ID associated with this player.
8637 */
8638 PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
8639
8640
8641 /**
8642 * Get the media port for the player or playlist.
8643 *
8644 * @param id The player ID.
8645 * @param p_port The media port associated with the player.
8646 *
8647 * @return PJ_SUCCESS on success.
8648 */
8649 PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
8650 pjmedia_port **p_port);
8651
8652 /**
8653 * Get additional info about the file player. This operation is not valid
8654 * for playlist.
8655 *
8656 * @param id The file player ID.
8657 * @param info The info.
8658 *
8659 * @return PJ_SUCCESS on success or the appropriate error code.
8660 */
8661 PJ_DECL(pj_status_t) pjsua_player_get_info(pjsua_player_id id,
8662 pjmedia_wav_player_info *info);
8663
8664
8665 /**
8666 * Get playback position. This operation is not valid for playlist.
8667 *
8668 * @param id The file player ID.
8669 *
8670 * @return The current playback position, in samples. On error,
8671 * return the error code as negative value.
8672 */
8673 PJ_DECL(pj_ssize_t) pjsua_player_get_pos(pjsua_player_id id);
8674
8675 /**
8676 * Set playback position. This operation is not valid for playlist.
8677 *
8678 * @param id The file player ID.
8679 * @param samples The playback position, in samples. Application can
8680 * specify zero to re-start the playback.
8681 *
8682 * @return PJ_SUCCESS on success, or the appropriate error code.
8683 */
8684 PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
8685 pj_uint32_t samples);
8686
8687 /**
8688 * Close the file of playlist, remove the player from the bridge, and free
8689 * resources associated with the file player or playlist.
8690 *
8691 * @param id The file player ID.
8692 *
8693 * @return PJ_SUCCESS on success, or the appropriate error code.
8694 */
8695 PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
8696
8697
8698 /*****************************************************************************
8699 * File recorder.
8700 */
8701
8702 /**
8703 * Create a file recorder, and automatically connect this recorder to
8704 * the conference bridge. The recorder currently supports recording WAV file.
8705 * The type of the recorder to use is determined by the extension of the file
8706 * (e.g. ".wav").
8707 *
8708 * @param filename Output file name. The function will determine the
8709 * default format to be used based on the file extension.
8710 * Currently ".wav" is supported on all platforms.
8711 * Filename's length must be smaller than PJ_MAXPATH.
8712 * @param enc_type Optionally specify the type of encoder to be used to
8713 * compress the media, if the file can support different
8714 * encodings. This value must be zero for now.
8715 * @param enc_param Optionally specify codec specific parameter to be
8716 * passed to the file writer.
8717 * For .WAV recorder, this value must be NULL.
8718 * @param max_size Maximum file size. Specify zero or -1 to remove size
8719 * limitation. This value must be zero or -1 for now.
8720 * @param options Optional options.
8721 * @param p_id Pointer to receive the recorder instance.
8722 *
8723 * @return PJ_SUCCESS on success, or the appropriate error code.
8724 */
8725 PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
8726 unsigned enc_type,
8727 void *enc_param,
8728 pj_ssize_t max_size,
8729 unsigned options,
8730 pjsua_recorder_id *p_id);
8731
8732
8733 /**
8734 * Get conference port associated with recorder.
8735 *
8736 * @param id The recorder ID.
8737 *
8738 * @return Conference port ID associated with this recorder.
8739 */
8740 PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
8741
8742
8743 /**
8744 * Get the media port for the recorder.
8745 *
8746 * @param id The recorder ID.
8747 * @param p_port The media port associated with the recorder.
8748 *
8749 * @return PJ_SUCCESS on success.
8750 */
8751 PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
8752 pjmedia_port **p_port);
8753
8754
8755 /**
8756 * Destroy recorder (this will complete recording).
8757 *
8758 * @param id The recorder ID.
8759 *
8760 * @return PJ_SUCCESS on success, or the appropriate error code.
8761 */
8762 PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
8763
8764
8765 /*****************************************************************************
8766 * AVI player.
8767 */
8768
8769 /**
8770 * Create an avi file player, and automatically add this player to
8771 * the audio/video conference bridge. The player will create a virtual
8772 * video device and audio/video media port based on the streams contained
8773 * in the file.
8774 * The maximum number of stream is limited to PJSUA_MAX_AVI_NUM_STREAMS
8775 * and the video stream is limited to one stream.
8776 *
8777 * @param filename The filename to be played. Currently only
8778 * AVI files are supported. The video stream is using
8779 * YUY2/I420/RGB24 (uncompressed) format and the audio
8780 * stream is using 16 bit PCM format.
8781 * Filename's length must be smaller than PJ_MAXPATH.
8782 * @param p_id Pointer to receive player ID.
8783 *
8784 * @return PJ_SUCCESS on success, or the appropriate error code.
8785 */
8786 PJ_DECL(pj_status_t) pjsua_avi_player_create(const pj_str_t *filename,
8787 pjsua_avi_player_id *id);
8788
8789 /**
8790 * Get the video device index of the avi player. Application can use this index
8791 * as the video source/capture device.
8792 *
8793 * @param id The avi player id.
8794 *
8795 * @return The video device id or PJMEDIA_VID_INVALID_DEV if the
8796 * player doesn't have a video device.
8797 */
8798 PJ_DECL(pjmedia_vid_dev_index) pjsua_avi_player_get_vid_dev(
8799 pjsua_avi_player_id id);
8800
8801 /**
8802 * Get the number of streams created by the avi player.
8803 *
8804 * @param id The avi player id.
8805 * @param strm_type The stream type.
8806 *
8807 * @return The number of media stream of the avi player.
8808 */
8809 PJ_DECL(unsigned) pjsua_avi_player_get_num_stream(pjsua_avi_player_id id,
8810 pjmedia_type strm_type);
8811
8812 /**
8813 * Get conference port ID associated with avi player based on the media type.
8814 *
8815 * @param id The avi player id.
8816 *
8817 * @param strm_type The stream type.
8818 * @param strm_idx The stream index.
8819 *
8820 * @return The video/audio conference port id.
8821 */
8822 PJ_DECL(pjsua_conf_port_id) pjsua_avi_player_get_conf_port(
8823 pjsua_avi_player_id id,
8824 pjmedia_type strm_type,
8825 unsigned strm_idx);
8826
8827 /**
8828 * Get the media port for the avi player based on the media type.
8829 *
8830 * @param id The avi player id.
8831 *
8832 * @param strm_type The stream type.
8833 * @param strm_idx The stream index.
8834 * @param p_port The media port port associated with the avi player.
8835 *
8836 * @return The PJ_SUCCESS on success,or the appropriate error code.
8837 *
8838 */
8839 PJ_DECL(pj_status_t) pjsua_avi_player_get_port(pjsua_avi_player_id id,
8840 pjmedia_type strm_type,
8841 unsigned strm_idx,
8842 pjmedia_port **p_port);
8843
8844 /**
8845 * Close the avi file, remove the media streams from the bridge, and free
8846 * resources associated with the avi player. This API will try to remove the
8847 * ports before freeing the resources. However, since the operation is done
8848 * asynchronously, it might return PJ_EBUSY when the ports are still in use.
8849 * In this case, application can retry calling this API after the port removal
8850 * is done.
8851 *
8852 * @param id The avi player ID.
8853 *
8854 * @return PJ_SUCCESS on success, or the appropriate error code.
8855 */
8856 PJ_DECL(pj_status_t) pjsua_avi_player_destroy(pjsua_avi_player_id id);
8857
8858
8859 /*****************************************************************************
8860 * AVI writer.
8861 */
8862
8863 /**
8864 * Create an avi recorder and automatically add a audio/video port
8865 * the audio/video conference bridge. User can connect the audio/video port
8866 * from a source port to store the uncompressed video and 16 bit PCM audio.
8867 * The recorder currently supports YUY2/I420/RGB24 video format and
8868 * PCM audio format.
8869 *
8870 * Note: Uncompressed video can lead to significant file size growth.
8871 *
8872 * @param filename The filename to be played. Currently only
8873 * AVI files are supported. Filename's length must be
8874 * smaller than PJ_MAXPATH.
8875 * Filename's length must be smaller than PJ_MAXPATH.
8876 * @param max_size Maximum file size.
8877 * @param vid_fmt The video format. If this is not set (NULL), the
8878 format will be set to:
8879 - format:PJMEDIA_FORMAT_I420
8880 - size:320x240
8881 - fps:15
8882 * @param aud_fmt The audio format. If this is not set (NULL), the
8883 format will be set to:
8884 - format:PJMEDIA_FORMAT_PCM
8885 - bits_per_sample:16
8886 - clock rate/chan count/ptime:the conf bridge settings
8887 * @param options Optional options.
8888 * @param id Pointer to receive avi recorder instance.
8889 *
8890 * @return PJ_SUCCESS on success, or the appropriate error code.
8891 */
8892 PJ_DECL(pj_status_t) pjsua_avi_recorder_create(const pj_str_t *filename,
8893 pj_ssize_t max_size,
8894 const pjmedia_format *vid_fmt,
8895 const pjmedia_format *aud_fmt,
8896 unsigned options,
8897 pjsua_avi_rec_id *id);
8898
8899 /**
8900 * Get the conference port identification associated with the recorder.
8901 *
8902 * @param id The recorder id.
8903 * @param strm_type The stream type.
8904 *
8905 * @return The video/audio conference port ID.
8906 */
8907 PJ_DECL(pjsua_conf_port_id) pjsua_avi_recorder_get_conf_port(
8908 pjsua_avi_rec_id id,
8909 pjmedia_type strm_type);
8910
8911 /**
8912 * Get the media port for the avi recorder based on the media type.
8913 *
8914 * @param id The recorder ID.
8915 * @param strm_type The stream type.
8916 * @param p_port The media port associated with the avi recorder.
8917 *
8918 * @return PJ_SUCCESS on success.
8919 */
8920 PJ_DECL(pj_status_t) pjsua_avi_recorder_get_port(pjsua_avi_rec_id id,
8921 pjmedia_type strm_type,
8922 pjmedia_port **p_port);
8923
8924 /**
8925 * Register a callback to be called when the file size has reached the
8926 * max size.
8927 *
8928 * @param id The recorder ID.
8929 * @param user_data User data to be specified in the callback, and will be
8930 * given on the callback.
8931 * @param cb Callback to be called.
8932 */
8933 PJ_DECL(pj_status_t) pjsua_avi_recorder_set_cb(pjsua_avi_rec_id id,
8934 void *user_data,
8935 void(*cb)(pjsua_avi_rec_id rec_id,
8936 void *usr_data));
8937
8938 /**
8939 * Destroy the avi recorder, remove the media port from the bridge, and free
8940 * resources associated with the avi recorder.
8941 *
8942 * @param id The avi recorder ID.
8943 *
8944 * @return PJ_SUCCESS on success, or the appropriate error code.
8945 */
8946 PJ_DECL(pj_status_t) pjsua_avi_recorder_destroy(pjsua_avi_rec_id id);
8947
8948 /*****************************************************************************
8949 * Sound devices.
8950 */
8951
8952 /**
8953 * Enum all audio devices installed in the system.
8954 *
8955 * @param info Array of info to be initialized.
8956 * @param count On input, specifies max elements in the array.
8957 * On return, it contains actual number of elements
8958 * that have been initialized.
8959 *
8960 * @return PJ_SUCCESS on success, or the appropriate error code.
8961 */
8962 PJ_DECL(pj_status_t) pjsua_enum_aud_devs(pjmedia_aud_dev_info info[],
8963 unsigned *count);
8964
8965 /**
8966 * Enum all sound devices installed in the system (old API).
8967 *
8968 * @param info Array of info to be initialized.
8969 * @param count On input, specifies max elements in the array.
8970 * On return, it contains actual number of elements
8971 * that have been initialized.
8972 *
8973 * @return PJ_SUCCESS on success, or the appropriate error code.
8974 */
8975 PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
8976 unsigned *count);
8977
8978 /**
8979 * Get currently active sound devices. If sound devices has not been created
8980 * (for example when pjsua_start() is not called), it is possible that
8981 * the function returns PJ_SUCCESS with -1 as device IDs.
8982 * See also #pjsua_snd_dev_id constants.
8983 *
8984 * @param capture_dev On return it will be filled with device ID of the
8985 * capture device.
8986 * @param playback_dev On return it will be filled with device ID of the
8987 * device ID of the playback device.
8988 *
8989 * @return PJ_SUCCESS on success, or the appropriate error code.
8990 */
8991 PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
8992 int *playback_dev);
8993
8994
8995 /**
8996 * Select or change sound device. Application may call this function at
8997 * any time to replace current sound device.
8998 *
8999 * Note that this function will always try to open the sound device
9000 * immediately. If immediate open is not preferred, use pjsua_set_snd_dev2()
9001 * with PJSUA_SND_DEV_NO_IMMEDIATE_OPEN flag.
9002 *
9003 * @param capture_dev Device ID of the capture device.
9004 * @param playback_dev Device ID of the playback device.
9005 *
9006 * @return PJ_SUCCESS on success, or the appropriate error code.
9007 */
9008 PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
9009 int playback_dev);
9010
9011 /**
9012 * Get sound device parameters such as playback & capture device IDs and mode.
9013 *
9014 * @param snd_param On return, it is set with sound device param.
9015 *
9016 * @return PJ_SUCCESS on success, or the appropriate error code.
9017 */
9018 PJ_DECL(pj_status_t) pjsua_get_snd_dev2(pjsua_snd_dev_param *snd_param);
9019
9020
9021 /**
9022 * Select or change sound device according to the specified param.
9023 *
9024 * @param snd_param Sound device param.
9025 *
9026 * @return PJ_SUCCESS on success, or the appropriate error code.
9027 */
9028 PJ_DECL(pj_status_t) pjsua_set_snd_dev2(const pjsua_snd_dev_param *snd_param);
9029
9030
9031 /**
9032 * Set pjsua to use null sound device. The null sound device only provides
9033 * the timing needed by the conference bridge, and will not interract with
9034 * any hardware.
9035 *
9036 * @return PJ_SUCCESS on success, or the appropriate error code.
9037 */
9038 PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
9039
9040
9041 /**
9042 * Disconnect the main conference bridge from any sound devices, and let
9043 * application connect the bridge to it's own sound device/master port.
9044 *
9045 * @return The port interface of the conference bridge,
9046 * so that application can connect this to it's own
9047 * sound device or master port.
9048 */
9049 PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
9050
9051
9052 /**
9053 * Change the echo cancellation settings.
9054 *
9055 * The behavior of this function depends on whether the sound device is
9056 * currently active, and if it is, whether device or software AEC is
9057 * being used.
9058 *
9059 * If the sound device is currently active, and if the device supports AEC,
9060 * this function will forward the change request to the device and it will
9061 * be up to the device on whether support the request. If software AEC is
9062 * being used (the software EC will be used if the device does not support
9063 * AEC), this function will change the software EC settings. In all cases,
9064 * the setting will be saved for future opening of the sound device.
9065 *
9066 * If the sound device is not currently active, this will only change the
9067 * default AEC settings and the setting will be applied next time the
9068 * sound device is opened.
9069 *
9070 * @param tail_ms The tail length, in miliseconds. Set to zero to
9071 * disable AEC.
9072 * @param options Options to be passed to pjmedia_echo_create().
9073 * Normally the value should be zero.
9074 *
9075 * @return PJ_SUCCESS on success.
9076 */
9077 PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
9078
9079
9080 /**
9081 * Get current echo canceller tail length.
9082 *
9083 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
9084 * If AEC is disabled, the value will be zero.
9085 *
9086 * @return PJ_SUCCESS on success.
9087 */
9088 PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
9089
9090
9091 /**
9092 * Get echo canceller statistics.
9093 *
9094 * @param p_stat Pointer to receive the stat.
9095 *
9096 * @return PJ_SUCCESS on success, or the appropriate error
9097 * code.
9098 */
9099 PJ_DECL(pj_status_t) pjsua_get_ec_stat(pjmedia_echo_stat *p_stat);
9100
9101
9102 /**
9103 * Check whether the sound device is currently active. The sound device
9104 * may be inactive if the application has set the auto close feature to
9105 * non-zero (the snd_auto_close_time setting in #pjsua_media_config), or
9106 * if null sound device or no sound device has been configured via the
9107 * #pjsua_set_no_snd_dev() function.
9108 */
9109 PJ_DECL(pj_bool_t) pjsua_snd_is_active(void);
9110
9111
9112 /**
9113 * Configure sound device setting to the sound device being used. If sound
9114 * device is currently active, the function will forward the setting to the
9115 * sound device instance to be applied immediately, if it supports it.
9116 *
9117 * The setting will be saved for future opening of the sound device, if the
9118 * "keep" argument is set to non-zero. If the sound device is currently
9119 * inactive, and the "keep" argument is false, this function will return
9120 * error.
9121 *
9122 * Note that in case the setting is kept for future use, it will be applied
9123 * to any devices, even when application has changed the sound device to be
9124 * used. To reset the setting, application can call #pjsua_set_snd_dev2()
9125 * with \a use_default_settings set to PJ_TRUE.
9126 *
9127 * Note also that the echo cancellation setting should be set with
9128 * #pjsua_set_ec() API instead.
9129 *
9130 * See also #pjmedia_aud_stream_set_cap() for more information about setting
9131 * an audio device capability.
9132 *
9133 * @param cap The sound device setting to change.
9134 * @param pval Pointer to value. Please see #pjmedia_aud_dev_cap
9135 * documentation about the type of value to be
9136 * supplied for each setting.
9137 * @param keep Specify whether the setting is to be kept for future
9138 * use.
9139 *
9140 * @return PJ_SUCCESS on success or the appropriate error code.
9141 */
9142 PJ_DECL(pj_status_t) pjsua_snd_set_setting(pjmedia_aud_dev_cap cap,
9143 const void *pval,
9144 pj_bool_t keep);
9145
9146 /**
9147 * Retrieve a sound device setting. If sound device is currently active,
9148 * the function will forward the request to the sound device. If sound device
9149 * is currently inactive, and if application had previously set the setting
9150 * and mark the setting as kept, then that setting will be returned.
9151 * Otherwise, this function will return error.
9152 *
9153 * Note that echo cancellation settings should be retrieved with
9154 * #pjsua_get_ec_tail() API instead.
9155 *
9156 * @param cap The sound device setting to retrieve.
9157 * @param pval Pointer to receive the value.
9158 * Please see #pjmedia_aud_dev_cap documentation about
9159 * the type of value to be supplied for each setting.
9160 *
9161 * @return PJ_SUCCESS on success or the appropriate error code.
9162 */
9163 PJ_DECL(pj_status_t) pjsua_snd_get_setting(pjmedia_aud_dev_cap cap,
9164 void *pval);
9165
9166
9167 /**
9168 * Opaque type of extra sound device, an additional sound device
9169 * beside the primary sound device (the one instantiated via
9170 * pjsua_set_snd_dev() or pjsua_set_snd_dev2()). This sound device is
9171 * also registered to conference bridge so it can be used as a normal
9172 * conference bridge port, e.g: connect it to/from other ports,
9173 * adjust/check audio level, etc. The conference bridge port ID can be
9174 * queried using pjsua_ext_snd_dev_get_conf_port().
9175 *
9176 * Application may also use this API to improve media clock. Normally
9177 * media clock is driven by sound device in master port, but unfortunately
9178 * some sound devices may produce jittery clock. To improve media clock,
9179 * application can install Null Sound Device (i.e: using
9180 * pjsua_set_null_snd_dev()), which will act as a master port, and instantiate
9181 * the sound device as extra sound device.
9182 *
9183 * Note that extra sound device will not have auto-close upon idle feature.
9184 * Also note that currently extra sound device only supports mono channel.
9185 */
9186 typedef struct pjsua_ext_snd_dev pjsua_ext_snd_dev;
9187
9188
9189 /**
9190 * Create an extra sound device and register it to conference bridge.
9191 *
9192 * @param param Sound device port param. Currently this only supports
9193 * mono channel, so channel count must be set to 1.
9194 * @param p_snd The extra sound device instance.
9195 *
9196 * @return PJ_SUCCESS on success or the appropriate error code.
9197 */
9198 PJ_DECL(pj_status_t) pjsua_ext_snd_dev_create(pjmedia_snd_port_param *param,
9199 pjsua_ext_snd_dev **p_snd);
9200
9201
9202 /**
9203 * Destroy an extra sound device and unregister it from conference bridge.
9204 *
9205 * @param snd The extra sound device instance.
9206 *
9207 * @return PJ_SUCCESS on success or the appropriate error code.
9208 */
9209 PJ_DECL(pj_status_t) pjsua_ext_snd_dev_destroy(pjsua_ext_snd_dev *snd);
9210
9211
9212 /**
9213 * Get sound port instance of an extra sound device.
9214 *
9215 * @param snd The extra sound device instance.
9216 *
9217 * @return The sound port instance.
9218 */
9219 PJ_DECL(pjmedia_snd_port*) pjsua_ext_snd_dev_get_snd_port(
9220 pjsua_ext_snd_dev *snd);
9221
9222 /**
9223 * Get conference port ID of an extra sound device.
9224 *
9225 * @param snd The extra sound device instance.
9226 *
9227 * @return The conference port ID.
9228 */
9229 PJ_DECL(pjsua_conf_port_id) pjsua_ext_snd_dev_get_conf_port(
9230 pjsua_ext_snd_dev *snd);
9231
9232
9233 /*****************************************************************************
9234 * Codecs.
9235 */
9236
9237 /**
9238 * Enum all supported codecs in the system.
9239 *
9240 * @param id Array of ID to be initialized.
9241 * @param count On input, specifies max elements in the array.
9242 * On return, it contains actual number of elements
9243 * that have been initialized.
9244 *
9245 * @return PJ_SUCCESS on success, or the appropriate error code.
9246 */
9247 PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
9248 unsigned *count );
9249
9250
9251 /**
9252 * Change codec priority.
9253 *
9254 * @param codec_id Codec ID, which is a string that uniquely identify
9255 * the codec (such as "speex/8000"). Please see pjsua
9256 * manual or pjmedia codec reference for details.
9257 * @param priority Codec priority, 0-255, where zero means to disable
9258 * the codec.
9259 *
9260 * @return PJ_SUCCESS on success, or the appropriate error code.
9261 */
9262 PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
9263 pj_uint8_t priority );
9264
9265
9266 /**
9267 * Get codec parameters.
9268 *
9269 * @param codec_id Codec ID.
9270 * @param param Structure to receive codec parameters.
9271 *
9272 * @return PJ_SUCCESS on success, or the appropriate error code.
9273 */
9274 PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
9275 pjmedia_codec_param *param );
9276
9277
9278 /**
9279 * Set codec parameters.
9280 *
9281 * @param codec_id Codec ID.
9282 * @param param Codec parameter to set. Set to NULL to reset
9283 * codec parameter to library default settings.
9284 *
9285 * @return PJ_SUCCESS on success, or the appropriate error code.
9286 */
9287 PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
9288 const pjmedia_codec_param *param);
9289
9290
9291 #if DISABLED_FOR_TICKET_1185
9292 /**
9293 * Create UDP media transports for all the calls. This function creates
9294 * one UDP media transport for each call.
9295 *
9296 * @param cfg Media transport configuration. The "port" field in the
9297 * configuration is used as the start port to bind the
9298 * sockets.
9299 *
9300 * @return PJ_SUCCESS on success, or the appropriate error code.
9301 */
9302 PJ_DECL(pj_status_t)
9303 pjsua_media_transports_create(const pjsua_transport_config *cfg);
9304
9305
9306 /**
9307 * Register custom media transports to be used by calls. There must
9308 * enough media transports for all calls.
9309 *
9310 * @param tp The media transport array.
9311 * @param count Number of elements in the array. This number MUST
9312 * match the number of maximum calls configured when
9313 * pjsua is created.
9314 * @param auto_delete Flag to indicate whether the transports should be
9315 * destroyed when pjsua is shutdown.
9316 *
9317 * @return PJ_SUCCESS on success, or the appropriate error code.
9318 */
9319 PJ_DECL(pj_status_t)
9320 pjsua_media_transports_attach( pjsua_media_transport tp[],
9321 unsigned count,
9322 pj_bool_t auto_delete);
9323 #endif
9324
9325
9326 /* end of MEDIA API */
9327 /**
9328 * @}
9329 */
9330
9331
9332 /*****************************************************************************
9333 * VIDEO API
9334 */
9335
9336
9337 /**
9338 * @defgroup PJSUA_LIB_VIDEO PJSUA-API Video
9339 * @ingroup PJSUA_LIB
9340 * @brief Video support
9341 * @{
9342 */
9343
9344 /*
9345 * Video devices API
9346 */
9347
9348
9349 /**
9350 * Controls whether PJSUA-LIB should not initialize video device subsystem
9351 * in the PJSUA initialization. The video device subsystem initialization
9352 * may need to open cameras to enumerates available cameras and their
9353 * capabilities, which may not be preferable for some applications because
9354 * it may trigger privacy-alert/permission notification on application startup
9355 * (e.g: on Android app).
9356 *
9357 * If this is set, later application should manually initialize video device
9358 * subsystem when it needs to use any video devices (camera and renderer),
9359 * i.e: by invoking pjmedia_vid_dev_subsys_init() for PJSUA or
9360 * VidDevManager::initSubsys() for PJSUA2.
9361 *
9362 * Note that pjmedia_vid_dev_subsys_init() should not be called multiple
9363 * times (unless each has corresponding pjmedia_vid_dev_subsys_shutdown()),
9364 * while VidDevManager::initSubsys() is safe to be called multiple times.
9365 *
9366 * Default: 0 (no)
9367 */
9368 #ifndef PJSUA_DONT_INIT_VID_DEV_SUBSYS
9369 # define PJSUA_DONT_INIT_VID_DEV_SUBSYS 0
9370 #endif
9371
9372
9373 /**
9374 * Get the number of video devices installed in the system.
9375 *
9376 * @return The number of devices.
9377 */
9378 PJ_DECL(unsigned) pjsua_vid_dev_count(void);
9379
9380 /**
9381 * Retrieve the video device info for the specified device index.
9382 *
9383 * @param id The device index.
9384 * @param vdi Device info to be initialized.
9385 *
9386 * @return PJ_SUCCESS on success, or the appropriate error code.
9387 */
9388 PJ_DECL(pj_status_t) pjsua_vid_dev_get_info(pjmedia_vid_dev_index id,
9389 pjmedia_vid_dev_info *vdi);
9390
9391 /**
9392 * Check whether the video capture device is currently active, i.e. if
9393 * a video preview has been started or there is a video call using
9394 * the device. This function will return PJ_FALSE for video renderer device.
9395 *
9396 * @param id The video device index.
9397 *
9398 * @return PJ_TRUE if active, PJ_FALSE otherwise.
9399 */
9400 PJ_DECL(pj_bool_t) pjsua_vid_dev_is_active(pjmedia_vid_dev_index id);
9401
9402 /**
9403 * Configure the capability of a video capture device. If the device is
9404 * currently active (i.e. if there is a video call using the device or
9405 * a video preview has been started), the function will forward the setting
9406 * to the video device instance to be applied immediately, if it supports it.
9407 *
9408 * The setting will be saved for future opening of the video device, if the
9409 * "keep" argument is set to non-zero. If the video device is currently
9410 * inactive, and the "keep" argument is false, this function will return
9411 * error.
9412 *
9413 * Note: This function will only works for video capture devices. To
9414 * configure the setting of video renderer device instances, use
9415 * pjsua_vid_win API instead.
9416 *
9417 * Warning: If application refreshes the video device list, it needs to
9418 * manually update the settings to reflect the newly updated video device
9419 * indexes. See #pjmedia_vid_dev_refresh() for more information.
9420 *
9421 * See also pjmedia_vid_stream_set_cap() for more information about setting
9422 * a video device capability.
9423 *
9424 * @param id The video device index.
9425 * @param cap The video device capability to change.
9426 * @param pval Pointer to value. Please see #pjmedia_vid_dev_cap
9427 * documentation about the type of value to be
9428 * supplied for each setting.
9429 * @param keep (see description)
9430 *
9431 * @return PJ_SUCCESS on success or the appropriate error code.
9432 */
9433 PJ_DECL(pj_status_t) pjsua_vid_dev_set_setting(pjmedia_vid_dev_index id,
9434 pjmedia_vid_dev_cap cap,
9435 const void *pval,
9436 pj_bool_t keep);
9437
9438 /**
9439 * Retrieve the value of a video capture device setting. If the device is
9440 * currently active (i.e. if there is a video call using the device or
9441 * a video preview has been started), the function will forward the request
9442 * to the video device. If video device is currently inactive, and if
9443 * application had previously set the setting and mark the setting as kept,
9444 * then that setting will be returned. Otherwise, this function will return
9445 * error.
9446 * The function only works for video capture device.
9447 *
9448 * @param id The video device index.
9449 * @param cap The video device capability to retrieve.
9450 * @param pval Pointer to receive the value.
9451 * Please see #pjmedia_vid_dev_cap documentation about
9452 * the type of value to be supplied for each setting.
9453 *
9454 * @return PJ_SUCCESS on success or the appropriate error code.
9455 */
9456 PJ_DECL(pj_status_t) pjsua_vid_dev_get_setting(pjmedia_vid_dev_index id,
9457 pjmedia_vid_dev_cap cap,
9458 void *pval);
9459
9460 /**
9461 * Enum all video devices installed in the system.
9462 *
9463 * @param info Array of info to be initialized.
9464 * @param count On input, specifies max elements in the array.
9465 * On return, it contains actual number of elements
9466 * that have been initialized.
9467 *
9468 * @return PJ_SUCCESS on success, or the appropriate error code.
9469 */
9470 PJ_DECL(pj_status_t) pjsua_vid_enum_devs(pjmedia_vid_dev_info info[],
9471 unsigned *count);
9472
9473
9474 /*
9475 * Video preview API
9476 */
9477
9478 /**
9479 * Parameters for starting video preview with pjsua_vid_preview_start().
9480 * Application should initialize this structure with
9481 * pjsua_vid_preview_param_default().
9482 */
9483 typedef struct pjsua_vid_preview_param
9484 {
9485 /**
9486 * Device ID for the video renderer to be used for rendering the
9487 * capture stream for preview. This parameter is ignored if native
9488 * preview is being used.
9489 *
9490 * Default: PJMEDIA_VID_DEFAULT_RENDER_DEV
9491 */
9492 pjmedia_vid_dev_index rend_id;
9493
9494 /**
9495 * Show window initially.
9496 *
9497 * Default: PJ_TRUE.
9498 */
9499 pj_bool_t show;
9500
9501 /**
9502 * Window flags. The value is a bitmask combination of
9503 * #pjmedia_vid_dev_wnd_flag.
9504 *
9505 * Default: 0.
9506 */
9507 unsigned wnd_flags;
9508
9509 /**
9510 * Media format. Initialize this with #pjmedia_format_init_video().
9511 * If left unitialized, this parameter will not be used.
9512 */
9513 pjmedia_format format;
9514
9515 /**
9516 * Optional output window to be used to display the video preview.
9517 * This parameter will only be used if the video device supports
9518 * PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW capability and the capability
9519 * is not read-only.
9520 */
9521 pjmedia_vid_dev_hwnd wnd;
9522
9523 } pjsua_vid_preview_param;
9524
9525
9526 /**
9527 * Initialize pjsua_vid_preview_param
9528 *
9529 * @param p The parameter to be initialized.
9530 */
9531 PJ_DECL(void) pjsua_vid_preview_param_default(pjsua_vid_preview_param *p);
9532
9533 /**
9534 * Determine if the specified video input device has built-in native
9535 * preview capability. This is a convenience function that is equal to
9536 * querying device's capability for PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW
9537 * capability.
9538 *
9539 * @param id The capture device ID.
9540 *
9541 * @return PJ_TRUE if it has.
9542 */
9543 PJ_DECL(pj_bool_t) pjsua_vid_preview_has_native(pjmedia_vid_dev_index id);
9544
9545 /**
9546 * Start video preview window for the specified capture device.
9547 *
9548 * @param id The capture device ID where its preview will be
9549 * started.
9550 * @param p Optional video preview parameters. Specify NULL
9551 * to use default values.
9552 *
9553 * @return PJ_SUCCESS on success, or the appropriate error code.
9554 */
9555 PJ_DECL(pj_status_t) pjsua_vid_preview_start(pjmedia_vid_dev_index id,
9556 const pjsua_vid_preview_param *p);
9557
9558 /**
9559 * Get the preview window handle associated with the capture device, if any.
9560 *
9561 * @param id The capture device ID.
9562 *
9563 * @return The window ID of the preview window for the
9564 * specified capture device ID, or PJSUA_INVALID_ID if
9565 * preview has not been started for the device.
9566 */
9567 PJ_DECL(pjsua_vid_win_id) pjsua_vid_preview_get_win(pjmedia_vid_dev_index id);
9568
9569 /**
9570 * Get video conference slot ID of the specified capture device, if any.
9571 *
9572 * @param id The capture device ID.
9573 *
9574 * @return The video conference slot ID of the specified capture
9575 * device ID, or PJSUA_INVALID_ID if preview has not been
9576 * started for the device.
9577 */
9578 PJ_DECL(pjsua_conf_port_id) pjsua_vid_preview_get_vid_conf_port(
9579 pjmedia_vid_dev_index id);
9580
9581 /**
9582 * Stop video preview.
9583 *
9584 * @param id The capture device ID.
9585 *
9586 * @return PJ_SUCCESS on success, or the appropriate error code.
9587 */
9588 PJ_DECL(pj_status_t) pjsua_vid_preview_stop(pjmedia_vid_dev_index id);
9589
9590
9591 /*
9592 * Video window manipulation API.
9593 */
9594
9595 /**
9596 * This structure describes video window info.
9597 */
9598 typedef struct pjsua_vid_win_info
9599 {
9600 /**
9601 * Flag to indicate whether this window is a native window,
9602 * such as created by built-in preview device. If this field is
9603 * PJ_TRUE, only the native window handle field of this
9604 * structure is valid.
9605 */
9606 pj_bool_t is_native;
9607
9608 /**
9609 * Native window handle.
9610 */
9611 pjmedia_vid_dev_hwnd hwnd;
9612
9613 /**
9614 * Renderer device ID.
9615 */
9616 pjmedia_vid_dev_index rdr_dev;
9617
9618 /**
9619 * Renderer port ID in the video conference bridge.
9620 */
9621 pjsua_conf_port_id slot_id;
9622
9623 /**
9624 * Window show status. The window is hidden if false.
9625 */
9626 pj_bool_t show;
9627
9628 /**
9629 * Window position.
9630 */
9631 pjmedia_coord pos;
9632
9633 /**
9634 * Window size.
9635 */
9636 pjmedia_rect_size size;
9637
9638 } pjsua_vid_win_info;
9639
9640
9641 /**
9642 * Enumerates all video windows.
9643 *
9644 * @param wids Array of window ID to be initialized.
9645 * @param count On input, specifies max elements in the array.
9646 * On return, it contains actual number of elements
9647 * that have been initialized.
9648 *
9649 * @return PJ_SUCCESS on success, or the appropriate error code.
9650 */
9651 PJ_DECL(pj_status_t) pjsua_vid_enum_wins(pjsua_vid_win_id wids[],
9652 unsigned *count);
9653
9654
9655 /**
9656 * Get window info.
9657 *
9658 * @param wid The video window ID.
9659 * @param wi The video window info to be initialized.
9660 *
9661 * @return PJ_SUCCESS on success, or the appropriate error code.
9662 */
9663 PJ_DECL(pj_status_t) pjsua_vid_win_get_info(pjsua_vid_win_id wid,
9664 pjsua_vid_win_info *wi);
9665
9666 /**
9667 * Show or hide window. This operation is not valid for native windows
9668 * (pjsua_vid_win_info.is_native=PJ_TRUE), on which native windowing API
9669 * must be used instead.
9670 *
9671 * @param wid The video window ID.
9672 * @param show Set to PJ_TRUE to show the window, PJ_FALSE to
9673 * hide the window.
9674 *
9675 * @return PJ_SUCCESS on success, or the appropriate error code.
9676 */
9677 PJ_DECL(pj_status_t) pjsua_vid_win_set_show(pjsua_vid_win_id wid,
9678 pj_bool_t show);
9679
9680 /**
9681 * Set video window position. This operation is not valid for native windows
9682 * (pjsua_vid_win_info.is_native=PJ_TRUE), on which native windowing API
9683 * must be used instead.
9684 *
9685 * @param wid The video window ID.
9686 * @param pos The window position.
9687 *
9688 * @return PJ_SUCCESS on success, or the appropriate error code.
9689 */
9690 PJ_DECL(pj_status_t) pjsua_vid_win_set_pos(pjsua_vid_win_id wid,
9691 const pjmedia_coord *pos);
9692
9693 /**
9694 * Resize window. This operation is not valid for native windows
9695 * (pjsua_vid_win_info.is_native=PJ_TRUE), on which native windowing API
9696 * must be used instead.
9697 *
9698 * @param wid The video window ID.
9699 * @param size The new window size.
9700 *
9701 * @return PJ_SUCCESS on success, or the appropriate error code.
9702 */
9703 PJ_DECL(pj_status_t) pjsua_vid_win_set_size(pjsua_vid_win_id wid,
9704 const pjmedia_rect_size *size);
9705
9706 /**
9707 * Set output window. This operation is valid only when the underlying
9708 * video device supports PJMEDIA_VIDEO_DEV_CAP_OUTPUT_WINDOW capability AND
9709 * allows the output window to be changed on-the-fly. Currently it is only
9710 * supported on Android.
9711 *
9712 * @param wid The video window ID.
9713 * @param win The new output window.
9714 *
9715 * @return PJ_SUCCESS on success, or the appropriate error code.
9716 */
9717 PJ_DECL(pj_status_t) pjsua_vid_win_set_win(pjsua_vid_win_id wid,
9718 const pjmedia_vid_dev_hwnd *win);
9719
9720 /**
9721 * Rotate the video window. This function will change the video orientation
9722 * and also possibly the video window size (width and height get swapped).
9723 * This operation is not valid for native windows (pjsua_vid_win_info.is_native
9724 * =PJ_TRUE), on which native windowing API must be used instead.
9725 *
9726 * @param wid The video window ID.
9727 * @param angle The rotation angle in degrees, must be multiple of 90.
9728 * Specify positive value for clockwise rotation or
9729 * negative value for counter-clockwise rotation.
9730 *
9731 * @return PJ_SUCCESS on success, or the appropriate error code.
9732 */
9733 PJ_DECL(pj_status_t) pjsua_vid_win_rotate(pjsua_vid_win_id wid,
9734 int angle);
9735
9736
9737 /**
9738 * Set video window full-screen. This operation is valid only when the
9739 * underlying video device supports PJMEDIA_VID_DEV_CAP_OUTPUT_FULLSCREEN
9740 * capability. Currently it is only supported on SDL backend.
9741 *
9742 * @param wid The video window ID.
9743 * @param mode Fullscreen mode, see pjmedia_vid_dev_fullscreen_flag.
9744 *
9745 * @return PJ_SUCCESS on success, or the appropriate error code.
9746 */
9747 PJ_DECL(pj_status_t) pjsua_vid_win_set_fullscreen(
9748 pjsua_vid_win_id wid,
9749 pjmedia_vid_dev_fullscreen_flag mode);
9750
9751
9752 /*
9753 * Video codecs API
9754 */
9755
9756 /**
9757 * Enum all supported video codecs in the system.
9758 *
9759 * @param id Array of ID to be initialized.
9760 * @param count On input, specifies max elements in the array.
9761 * On return, it contains actual number of elements
9762 * that have been initialized.
9763 *
9764 * @return PJ_SUCCESS on success, or the appropriate error code.
9765 */
9766 PJ_DECL(pj_status_t) pjsua_vid_enum_codecs( pjsua_codec_info id[],
9767 unsigned *count );
9768
9769
9770 /**
9771 * Change video codec priority.
9772 *
9773 * @param codec_id Codec ID, which is a string that uniquely identify
9774 * the codec (such as "H263/90000"). Please see pjsua
9775 * manual or pjmedia codec reference for details.
9776 * @param priority Codec priority, 0-255, where zero means to disable
9777 * the codec.
9778 *
9779 * @return PJ_SUCCESS on success, or the appropriate error code.
9780 */
9781 PJ_DECL(pj_status_t) pjsua_vid_codec_set_priority( const pj_str_t *codec_id,
9782 pj_uint8_t priority );
9783
9784
9785 /**
9786 * Get video codec parameters.
9787 *
9788 * @param codec_id Codec ID.
9789 * @param param Structure to receive video codec parameters.
9790 *
9791 * @return PJ_SUCCESS on success, or the appropriate error code.
9792 */
9793 PJ_DECL(pj_status_t) pjsua_vid_codec_get_param(
9794 const pj_str_t *codec_id,
9795 pjmedia_vid_codec_param *param);
9796
9797
9798 /**
9799 * Set video codec parameters.
9800 *
9801 * @param codec_id Codec ID.
9802 * @param param Codec parameter to set. Set to NULL to reset
9803 * codec parameter to library default settings.
9804 *
9805 * @return PJ_SUCCESS on success, or the appropriate error code.
9806 */
9807 PJ_DECL(pj_status_t) pjsua_vid_codec_set_param(
9808 const pj_str_t *codec_id,
9809 const pjmedia_vid_codec_param *param);
9810
9811
9812 /*
9813 * Video conference API
9814 */
9815
9816 /**
9817 * This structure describes information about a particular video media port
9818 * that has been registered into the video conference bridge. Application
9819 * can query this info by calling #pjsua_vid_conf_get_port_info().
9820 */
9821 typedef struct pjsua_vid_conf_port_info
9822 {
9823 /** Conference port number. */
9824 pjsua_conf_port_id slot_id;
9825
9826 /** Port name. */
9827 pj_str_t name;
9828
9829 /** Format. */
9830 pjmedia_format format;
9831
9832 /** Number of listeners in the array. */
9833 unsigned listener_cnt;
9834
9835 /** Array of listeners (in other words, ports where this port is
9836 * transmitting to).
9837 */
9838 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
9839
9840 /** Number of transmitters in the array. */
9841 unsigned transmitter_cnt;
9842
9843 /** Array of transmitters (in other words, ports where this port is
9844 * receiving from).
9845 */
9846 pjsua_conf_port_id transmitters[PJSUA_MAX_CONF_PORTS];
9847
9848 } pjsua_vid_conf_port_info;
9849
9850
9851 /**
9852 * Get current number of active ports in the bridge.
9853 *
9854 * @return The number.
9855 */
9856 PJ_DECL(unsigned) pjsua_vid_conf_get_active_ports(void);
9857
9858
9859 /**
9860 * Enumerate all video conference ports.
9861 *
9862 * @param id Array of conference port ID to be initialized.
9863 * @param count On input, specifies max elements in the array.
9864 * On return, it contains actual number of elements
9865 * that have been initialized.
9866 *
9867 * @return PJ_SUCCESS on success, or the appropriate error code.
9868 */
9869 PJ_DECL(pj_status_t) pjsua_vid_conf_enum_ports(pjsua_conf_port_id id[],
9870 unsigned *count);
9871
9872
9873 /**
9874 * Get information about the specified video conference port
9875 *
9876 * @param port_id Port identification.
9877 * @param info Pointer to store the port info.
9878 *
9879 * @return PJ_SUCCESS on success, or the appropriate error code.
9880 */
9881 PJ_DECL(pj_status_t) pjsua_vid_conf_get_port_info(
9882 pjsua_conf_port_id port_id,
9883 pjsua_vid_conf_port_info *info);
9884
9885
9886 /**
9887 * Add arbitrary video media port to PJSUA's video conference bridge.
9888 * Application can use this function to add the media port that it creates.
9889 * For media ports that are created by PJSUA-LIB (such as calls, AVI player),
9890 * PJSUA-LIB will automatically add the port to the bridge.
9891 *
9892 * This operation executes asynchronously, use the callback set from
9893 * \a on_vid_conf_op_completed to receive notification upon completion.
9894 *
9895 * @param pool Pool to use.
9896 * @param port Media port to be added to the bridge.
9897 * @param param Currently this is not used and must be set to NULL.
9898 * @param p_id Optional pointer to receive the conference
9899 * slot id.
9900 *
9901 * @return PJ_SUCCESS on success, or the appropriate error code.
9902 */
9903 PJ_DECL(pj_status_t) pjsua_vid_conf_add_port(pj_pool_t *pool,
9904 pjmedia_port *port,
9905 const void *param,
9906 pjsua_conf_port_id *p_id);
9907
9908
9909 /**
9910 * Remove arbitrary slot from the video conference bridge. Application should
9911 * only call this function if it registered the port manually with previous
9912 * call to #pjsua_vid_conf_add_port().
9913 *
9914 * This operation executes asynchronously, use the callback set from
9915 * \a on_vid_conf_op_completed to receive notification upon completion.
9916 *
9917 * @param port_id The slot id of the port to be removed.
9918 *
9919 * @return PJ_SUCCESS on success, or the appropriate error code.
9920 */
9921 PJ_DECL(pj_status_t) pjsua_vid_conf_remove_port(pjsua_conf_port_id port_id);
9922
9923
9924 /**
9925 * Establish unidirectional video flow from souce to sink. One source
9926 * may transmit to multiple destinations/sink. And if multiple
9927 * sources are transmitting to the same sink, the video will be mixed
9928 * together (currently, each source will be resized down so all sources will
9929 * occupy the same portion in the sink video frame). Source and sink may
9930 * refer to the same ID, effectively looping the media.
9931 *
9932 * If bidirectional media flow is desired, application needs to call
9933 * this function twice, with the second one having the arguments
9934 * reversed.
9935 *
9936 * This operation executes asynchronously, use the callback set from
9937 * \a on_vid_conf_op_completed to receive notification upon completion.
9938 *
9939 * @param source Port ID of the source media/transmitter.
9940 * @param sink Port ID of the destination media/received.
9941 * @param param Currently this is not used and must be set to NULL.
9942 *
9943 * @return PJ_SUCCESS on success, or the appropriate error code.
9944 */
9945 PJ_DECL(pj_status_t) pjsua_vid_conf_connect(pjsua_conf_port_id source,
9946 pjsua_conf_port_id sink,
9947 const void *param);
9948
9949
9950 /**
9951 * Disconnect video flow from the source to destination port.
9952 *
9953 * This operation executes asynchronously, use the callback set from
9954 * \a on_vid_conf_op_completed to receive notification upon completion.
9955 *
9956 * @param source Port ID of the source media/transmitter.
9957 * @param sink Port ID of the destination media/received.
9958 *
9959 * @return PJ_SUCCESS on success, or the appropriate error code.
9960 */
9961 PJ_DECL(pj_status_t) pjsua_vid_conf_disconnect(pjsua_conf_port_id source,
9962 pjsua_conf_port_id sink);
9963
9964
9965 /**
9966 * Update or refresh port states from video port info. Some port may
9967 * change its port info in the middle of a session, for example when
9968 * a video stream decoder learns that incoming video size or frame rate
9969 * has changed, video conference needs to be informed to update its
9970 * internal states.
9971 *
9972 * This operation executes asynchronously, use the callback set from
9973 * \a on_vid_conf_op_completed to receive notification upon completion.
9974 *
9975 * @param port_id The slot id of the port to be updated.
9976 *
9977 * @return PJ_SUCCESS on success, or the appropriate error
9978 * code.
9979 */
9980 PJ_DECL(pj_status_t) pjsua_vid_conf_update_port(pjsua_conf_port_id port_id);
9981
9982
9983 /* end of VIDEO API */
9984 /**
9985 * @}
9986 */
9987
9988
9989 /**
9990 * @}
9991 */
9992
9993 PJ_END_DECL
9994
9995
9996 #endif /* __PJSUA_H__ */