blob: 0707493870c5edfa15fb55f3b040980e84be35eb [file] [log] [blame]
Tristan Matthews0a329cc2013-07-17 13:20:14 -04001/* $Id: pjsua.h 4555 2013-07-10 04:27:05Z ming $ */
2/*
3 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#ifndef __PJSUA_H__
21#define __PJSUA_H__
22
23/**
24 * @file pjsua.h
25 * @brief PJSUA API.
26 */
27
28
29/* Include all PJSIP core headers. */
30#include <pjsip.h>
31
32/* Include all PJMEDIA headers. */
33#include <pjmedia.h>
34
35/* Include all PJMEDIA-CODEC headers. */
36#include <pjmedia-codec.h>
37
38/* Videodev too */
39#include <pjmedia_videodev.h>
40
41/* Include all PJSIP-UA headers */
42#include <pjsip_ua.h>
43
44/* Include all PJSIP-SIMPLE headers */
45#include <pjsip_simple.h>
46
47/* Include all PJNATH headers */
48#include <pjnath.h>
49
50/* Include all PJLIB-UTIL headers. */
51#include <pjlib-util.h>
52
53/* Include all PJLIB headers. */
54#include <pjlib.h>
55
56
57PJ_BEGIN_DECL
58
59
60/**
61 * @defgroup PJSUA_LIB PJSUA API - High Level Softphone API
62 * @brief Very high level API for constructing SIP UA applications.
63 * @{
64 *
65 * @section pjsua_api_intro A SIP User Agent API for C/C++
66 *
67 * PJSUA API is very high level API for constructing SIP multimedia user agent
68 * applications. It wraps together the signaling and media functionalities
69 * into an easy to use call API, provides account management, buddy
70 * management, presence, instant messaging, along with multimedia
71 * features such as conferencing, file streaming, local playback,
72 * voice recording, and so on.
73 *
74 * @subsection pjsua_for_c_cpp C/C++ Binding
75 * Application must link with <b>pjsua-lib</b> to use this API. In addition,
76 * this library depends on the following libraries:
77 * - <b>pjsip-ua</b>,
78 * - <b>pjsip-simple</b>,
79 * - <b>pjsip-core</b>,
80 * - <b>pjmedia</b>,
81 * - <b>pjmedia-codec</b>,
82 * - <b>pjlib-util</b>, and
83 * - <b>pjlib</b>,
84 *
85 * so application must also link with these libraries as well. For more
86 * information, please refer to
87 * <A HREF="http://www.pjsip.org/using.htm">Getting Started with PJSIP</A>
88 * page.
89 *
90 * @section pjsua_samples
91 *
92 * Few samples are provided:
93 *
94 - @ref page_pjsip_sample_simple_pjsuaua_c\n
95 Very simple SIP User Agent with registration, call, and media, using
96 PJSUA-API, all in under 200 lines of code.
97
98 - @ref page_pjsip_samples_pjsua\n
99 This is the reference implementation for PJSIP and PJMEDIA.
100 PJSUA is a console based application, designed to be simple enough
101 to be readble, but powerful enough to demonstrate all features
102 available in PJSIP and PJMEDIA.\n
103
104 * @section root_using_pjsua_lib Using PJSUA API
105 *
106 * Please refer to @ref PJSUA_LIB_BASE on how to create and initialize the API.
107 * And then see the Modules on the bottom of this page for more information
108 * about specific subject.
109 */
110
111
112
113/*****************************************************************************
114 * BASE API
115 */
116
117/**
118 * @defgroup PJSUA_LIB_BASE PJSUA-API Basic API
119 * @ingroup PJSUA_LIB
120 * @brief Basic application creation/initialization, logging configuration, etc.
121 * @{
122 *
123 * The base PJSUA API controls PJSUA creation, initialization, and startup, and
124 * also provides various auxiliary functions.
125 *
126 * @section using_pjsua_lib Using PJSUA Library
127 *
128 * @subsection creating_pjsua_lib Creating PJSUA
129 *
130 * Before anything else, application must create PJSUA by calling
131 * #pjsua_create().
132 * This, among other things, will initialize PJLIB, which is crucial before
133 * any PJLIB functions can be called, PJLIB-UTIL, and create a SIP endpoint.
134 *
135 * After this function is called, application can create a memory pool (with
136 * #pjsua_pool_create()) and read configurations from command line or file to
137 * build the settings to initialize PJSUA below.
138 *
139 * @subsection init_pjsua_lib Initializing PJSUA
140 *
141 * After PJSUA is created, application can initialize PJSUA by calling
142 * #pjsua_init(). This function takes several optional configuration settings
143 * in the argument, if application wants to set them.
144 *
145 * @subsubsection init_pjsua_lib_c_cpp PJSUA-LIB Initialization (in C)
146 * Sample code to initialize PJSUA in C code:
147 \code
148
149 #include <pjsua-lib/pjsua.h>
150
151 #define THIS_FILE __FILE__
152
153 static pj_status_t app_init(void)
154 {
155 pjsua_config ua_cfg;
156 pjsua_logging_config log_cfg;
157 pjsua_media_config media_cfg;
158 pj_status_t status;
159
160 // Must create pjsua before anything else!
161 status = pjsua_create();
162 if (status != PJ_SUCCESS) {
163 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
164 return status;
165 }
166
167 // Initialize configs with default settings.
168 pjsua_config_default(&ua_cfg);
169 pjsua_logging_config_default(&log_cfg);
170 pjsua_media_config_default(&media_cfg);
171
172 // At the very least, application would want to override
173 // the call callbacks in pjsua_config:
174 ua_cfg.cb.on_incoming_call = ...
175 ua_cfg.cb.on_call_state = ..
176 ...
177
178 // Customize other settings (or initialize them from application specific
179 // configuration file):
180 ...
181
182 // Initialize pjsua
183 status = pjsua_init(&ua_cfg, &log_cfg, &media_cfg);
184 if (status != PJ_SUCCESS) {
185 pjsua_perror(THIS_FILE, "Error initializing pjsua", status);
186 return status;
187 }
188 .
189 ...
190 }
191 \endcode
192 *
193 *
194
195
196 * @subsection other_init_pjsua_lib Other Initialization
197 *
198 * After PJSUA is initialized with #pjsua_init(), application will normally
199 * need/want to perform the following tasks:
200 *
201 * - create SIP transport with #pjsua_transport_create(). Application would
202 * to call #pjsua_transport_create() for each transport types that it
203 * wants to support (for example, UDP, TCP, and TLS). Please see
204 * @ref PJSUA_LIB_TRANSPORT section for more info.
205 * - create one or more SIP accounts with #pjsua_acc_add() or
206 * #pjsua_acc_add_local(). The SIP account is used for registering with
207 * the SIP server, if any. Please see @ref PJSUA_LIB_ACC for more info.
208 * - add one or more buddies with #pjsua_buddy_add(). Please see
209 * @ref PJSUA_LIB_BUDDY section for more info.
210 * - optionally configure the sound device, codec settings, and other
211 * media settings. Please see @ref PJSUA_LIB_MEDIA for more info.
212 *
213 *
214 * @subsection starting_pjsua_lib Starting PJSUA
215 *
216 * After all initializations have been done, application must call
217 * #pjsua_start() to start PJSUA. This function will check that all settings
218 * have been properly configured, and apply default settings when they haven't,
219 * or report error status when it is unable to recover from missing settings.
220 *
221 * Most settings can be changed during run-time. For example, application
222 * may add, modify, or delete accounts, buddies, or change media settings
223 * during run-time.
224 *
225 * @subsubsection starting_pjsua_lib_c C Example for Starting PJSUA
226 * Sample code:
227 \code
228 static pj_status_t app_run(void)
229 {
230 pj_status_t status;
231
232 // Start pjsua
233 status = pjsua_start();
234 if (status != PJ_SUCCESS) {
235 pjsua_destroy();
236 pjsua_perror(THIS_FILE, "Error starting pjsua", status);
237 return status;
238 }
239
240 // Run application loop
241 while (1) {
242 char choice[10];
243
244 printf("Select menu: ");
245 fgets(choice, sizeof(choice), stdin);
246 ...
247 }
248 }
249 \endcode
250
251 */
252
253/** Constant to identify invalid ID for all sorts of IDs. */
254#define PJSUA_INVALID_ID (-1)
255
256/** Disabled features temporarily for media reorganization */
257#define DISABLED_FOR_TICKET_1185 0
258
259/** Call identification */
260typedef int pjsua_call_id;
261
262/** Account identification */
263typedef int pjsua_acc_id;
264
265/** Buddy identification */
266typedef int pjsua_buddy_id;
267
268/** File player identification */
269typedef int pjsua_player_id;
270
271/** File recorder identification */
272typedef int pjsua_recorder_id;
273
274/** Conference port identification */
275typedef int pjsua_conf_port_id;
276
277/** Opaque declaration for server side presence subscription */
278typedef struct pjsua_srv_pres pjsua_srv_pres;
279
280/** Forward declaration for pjsua_msg_data */
281typedef struct pjsua_msg_data pjsua_msg_data;
282
283
284/**
285 * Maximum proxies in account.
286 */
287#ifndef PJSUA_ACC_MAX_PROXIES
288# define PJSUA_ACC_MAX_PROXIES 8
289#endif
290
291/**
292 * Default value of SRTP mode usage. Valid values are PJMEDIA_SRTP_DISABLED,
293 * PJMEDIA_SRTP_OPTIONAL, and PJMEDIA_SRTP_MANDATORY.
294 */
295#ifndef PJSUA_DEFAULT_USE_SRTP
296 #define PJSUA_DEFAULT_USE_SRTP PJMEDIA_SRTP_DISABLED
297#endif
298
299/**
300 * Default value of secure signaling requirement for SRTP.
301 * Valid values are:
302 * 0: SRTP does not require secure signaling
303 * 1: SRTP requires secure transport such as TLS
304 * 2: SRTP requires secure end-to-end transport (SIPS)
305 */
306#ifndef PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
307 #define PJSUA_DEFAULT_SRTP_SECURE_SIGNALING 1
308#endif
309
310/**
311 * Controls whether PJSUA-LIB should add ICE media feature tag
312 * parameter (the ";+sip.ice" parameter) to Contact header if ICE
313 * is enabled in the config.
314 *
315 * Default: 1
316 */
317#ifndef PJSUA_ADD_ICE_TAGS
318# define PJSUA_ADD_ICE_TAGS 1
319#endif
320
321/**
322 * Timeout value used to acquire mutex lock on a particular call.
323 *
324 * Default: 2000 ms
325 */
326#ifndef PJSUA_ACQUIRE_CALL_TIMEOUT
327# define PJSUA_ACQUIRE_CALL_TIMEOUT 2000
328#endif
329
330/**
331 * Is video enabled.
332 */
333#ifndef PJSUA_HAS_VIDEO
334# define PJSUA_HAS_VIDEO PJMEDIA_HAS_VIDEO
335#endif
336
337
338/**
339 * Interval between two keyframe requests, in milliseconds.
340 *
341 * Default: 3000 ms
342 */
343#ifndef PJSUA_VID_REQ_KEYFRAME_INTERVAL
344# define PJSUA_VID_REQ_KEYFRAME_INTERVAL 3000
345#endif
346
347
348/**
349 * This enumeration represents pjsua state.
350 */
351typedef enum pjsua_state
352{
353 /**
354 * The library has not been initialized.
355 */
356 PJSUA_STATE_NULL,
357
358 /**
359 * After pjsua_create() is called but before pjsua_init() is called.
360 */
361 PJSUA_STATE_CREATED,
362
363 /**
364 * After pjsua_init() is called but before pjsua_start() is called.
365 */
366 PJSUA_STATE_INIT,
367
368 /**
369 * After pjsua_start() is called but before everything is running.
370 */
371 PJSUA_STATE_STARTING,
372
373 /**
374 * After pjsua_start() is called and before pjsua_destroy() is called.
375 */
376 PJSUA_STATE_RUNNING,
377
378 /**
379 * After pjsua_destroy() is called but before the function returns.
380 */
381 PJSUA_STATE_CLOSING
382
383} pjsua_state;
384
385
386/**
387 * Logging configuration, which can be (optionally) specified when calling
388 * #pjsua_init(). Application must call #pjsua_logging_config_default() to
389 * initialize this structure with the default values.
390 */
391typedef struct pjsua_logging_config
392{
393 /**
394 * Log incoming and outgoing SIP message? Yes!
395 */
396 pj_bool_t msg_logging;
397
398 /**
399 * Input verbosity level. Value 5 is reasonable.
400 */
401 unsigned level;
402
403 /**
404 * Verbosity level for console. Value 4 is reasonable.
405 */
406 unsigned console_level;
407
408 /**
409 * Log decoration.
410 */
411 unsigned decor;
412
413 /**
414 * Optional log filename.
415 */
416 pj_str_t log_filename;
417
418 /**
419 * Additional flags to be given to #pj_file_open() when opening
420 * the log file. By default, the flag is PJ_O_WRONLY. Application
421 * may set PJ_O_APPEND here so that logs are appended to existing
422 * file instead of overwriting it.
423 *
424 * Default is 0.
425 */
426 unsigned log_file_flags;
427
428 /**
429 * Optional callback function to be called to write log to
430 * application specific device. This function will be called for
431 * log messages on input verbosity level.
432 */
433 void (*cb)(int level, const char *data, int len);
434
435
436} pjsua_logging_config;
437
438
439/**
440 * Use this function to initialize logging config.
441 *
442 * @param cfg The logging config to be initialized.
443 */
444PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg);
445
446
447/**
448 * Use this function to duplicate logging config.
449 *
450 * @param pool Pool to use.
451 * @param dst Destination config.
452 * @param src Source config.
453 */
454PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool,
455 pjsua_logging_config *dst,
456 const pjsua_logging_config *src);
457
458
459/**
460 * Structure to be passed on MWI callback.
461 */
462typedef struct pjsua_mwi_info
463{
464 pjsip_evsub *evsub; /**< Event subscription session, for
465 reference. */
466 pjsip_rx_data *rdata; /**< The received NOTIFY request. */
467} pjsua_mwi_info;
468
469
470/**
471 * Structure to be passed on registration callback.
472 */
473typedef struct pjsua_reg_info
474{
475 struct pjsip_regc_cbparam *cbparam; /**< Parameters returned by
476 registration callback. */
477} pjsua_reg_info;
478
479
480/**
481 * Enumeration of media transport state types.
482 */
483typedef enum pjsua_med_tp_st
484{
485 /** Null, this is the state before media transport is created. */
486 PJSUA_MED_TP_NULL,
487
488 /**
489 * Just before media transport is created, which can finish
490 * asynchronously later.
491 */
492 PJSUA_MED_TP_CREATING,
493
494 /** Media transport creation is completed, but not initialized yet. */
495 PJSUA_MED_TP_IDLE,
496
497 /** Initialized (media_create() has been called). */
498 PJSUA_MED_TP_INIT,
499
500 /** Running (media_start() has been called). */
501 PJSUA_MED_TP_RUNNING,
502
503 /** Disabled (transport is initialized, but media is being disabled). */
504 PJSUA_MED_TP_DISABLED
505
506} pjsua_med_tp_st;
507
508
509/**
510 * Structure to be passed on media transport state callback.
511 */
512typedef struct pjsua_med_tp_state_info
513{
514 /**
515 * The media index.
516 */
517 unsigned med_idx;
518
519 /**
520 * The media transport state
521 */
522 pjsua_med_tp_st state;
523
524 /**
525 * The last error code related to the media transport state.
526 */
527 pj_status_t status;
528
529 /**
530 * Optional SIP error code.
531 */
532 int sip_err_code;
533
534 /**
535 * Optional extended info, the content is specific for each transport type.
536 */
537 void *ext_info;
538
539} pjsua_med_tp_state_info;
540
541
542/**
543 * Type of callback to be called when media transport state is changed.
544 *
545 * @param call_id The call ID.
546 * @param info The media transport state info.
547 *
548 * @return The callback must return PJ_SUCCESS at the moment.
549 */
550typedef pj_status_t
551(*pjsua_med_tp_state_cb)(pjsua_call_id call_id,
552 const pjsua_med_tp_state_info *info);
553
554
555/**
556 * This enumeration specifies the options for custom media transport creation.
557 */
558typedef enum pjsua_create_media_transport_flag
559{
560 /**
561 * This flag indicates that the media transport must also close its
562 * "member" or "child" transport when pjmedia_transport_close() is
563 * called. If this flag is not specified, then the media transport
564 * must not call pjmedia_transport_close() of its member transport.
565 */
566 PJSUA_MED_TP_CLOSE_MEMBER = 1
567
568} pjsua_create_media_transport_flag;
569
570
571/**
572 * Call settings.
573 */
574typedef struct pjsua_call_setting
575{
576 /**
577 * Bitmask of #pjsua_call_flag constants.
578 *
579 * Default: 0
580 */
581 unsigned flag;
582
583 /**
584 * This flag controls what methods to request keyframe are allowed on
585 * the call. Value is bitmask of #pjsua_vid_req_keyframe_method.
586 */
587 unsigned req_keyframe_method;
588
589 /**
590 * Number of simultaneous active audio streams for this call. Setting
591 * this to zero will disable audio in this call.
592 *
593 * Default: 1
594 */
595 unsigned aud_cnt;
596
597 /**
598 * Number of simultaneous active video streams for this call. Setting
599 * this to zero will disable video in this call.
600 *
601 * Default: 1 (if video feature is enabled, otherwise it is zero)
602 */
603 unsigned vid_cnt;
604
605} pjsua_call_setting;
606
607
608/**
609 * This structure describes application callback to receive various event
610 * notification from PJSUA-API. All of these callbacks are OPTIONAL,
611 * although definitely application would want to implement some of
612 * the important callbacks (such as \a on_incoming_call).
613 */
614typedef struct pjsua_callback
615{
616 /**
617 * Notify application when call state has changed.
618 * Application may then query the call info to get the
619 * detail call states by calling pjsua_call_get_info() function.
620 *
621 * @param call_id The call index.
622 * @param e Event which causes the call state to change.
623 */
624 void (*on_call_state)(pjsua_call_id call_id, pjsip_event *e);
625
626 /**
627 * Notify application on incoming call.
628 *
629 * @param acc_id The account which match the incoming call.
630 * @param call_id The call id that has just been created for
631 * the call.
632 * @param rdata The incoming INVITE request.
633 */
634 void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,
635 pjsip_rx_data *rdata);
636
637 /**
638 * This is a general notification callback which is called whenever
639 * a transaction within the call has changed state. Application can
640 * implement this callback for example to monitor the state of
641 * outgoing requests, or to answer unhandled incoming requests
642 * (such as INFO) with a final response.
643 *
644 * @param call_id Call identification.
645 * @param tsx The transaction which has changed state.
646 * @param e Transaction event that caused the state change.
647 */
648 void (*on_call_tsx_state)(pjsua_call_id call_id,
649 pjsip_transaction *tsx,
650 pjsip_event *e);
651
652 /**
653 * Notify application when media state in the call has changed.
654 * Normal application would need to implement this callback, e.g.
655 * to connect the call's media to sound device. When ICE is used,
656 * this callback will also be called to report ICE negotiation
657 * failure.
658 *
659 * @param call_id The call index.
660 */
661 void (*on_call_media_state)(pjsua_call_id call_id);
662
663
664 /**
665 * Notify application when a call has just created a local SDP (for
666 * initial or subsequent SDP offer/answer). Application can implement
667 * this callback to modify the SDP, before it is being sent and/or
668 * negotiated with remote SDP, for example to apply per account/call
669 * basis codecs priority or to add custom/proprietary SDP attributes.
670 *
671 * @param call_id The call index.
672 * @param sdp The SDP has just been created.
673 * @param pool The pool instance, application should use this pool
674 * to modify the SDP.
675 * @param rem_sdp The remote SDP, will be NULL if local is SDP offerer.
676 */
677 void (*on_call_sdp_created)(pjsua_call_id call_id,
678 pjmedia_sdp_session *sdp,
679 pj_pool_t *pool,
680 const pjmedia_sdp_session *rem_sdp);
681
682
683 /**
684 * Notify application when media session is created and before it is
685 * registered to the conference bridge. Application may return different
686 * media port if it has added media processing port to the stream. This
687 * media port then will be added to the conference bridge instead.
688 *
689 * @param call_id Call identification.
690 * @param strm Media stream.
691 * @param stream_idx Stream index in the media session.
692 * @param p_port On input, it specifies the media port of the
693 * stream. Application may modify this pointer to
694 * point to different media port to be registered
695 * to the conference bridge.
696 */
697 void (*on_stream_created)(pjsua_call_id call_id,
698 pjmedia_stream *strm,
699 unsigned stream_idx,
700 pjmedia_port **p_port);
701
702 /**
703 * Notify application when media session has been unregistered from the
704 * conference bridge and about to be destroyed.
705 *
706 * @param call_id Call identification.
707 * @param strm Media stream.
708 * @param stream_idx Stream index in the media session.
709 */
710 void (*on_stream_destroyed)(pjsua_call_id call_id,
711 pjmedia_stream *strm,
712 unsigned stream_idx);
713
714 /**
715 * Notify application upon incoming DTMF digits.
716 *
717 * @param call_id The call index.
718 * @param digit DTMF ASCII digit.
719 */
720 void (*on_dtmf_digit)(pjsua_call_id call_id, int digit);
721
722 /**
723 * Notify application on call being transfered (i.e. REFER is received).
724 * Application can decide to accept/reject transfer request
725 * by setting the code (default is 202). When this callback
726 * is not defined, the default behavior is to accept the
727 * transfer. See also on_call_transfer_request2() callback for
728 * the version with \a pjsua_call_setting in the argument list.
729 *
730 * @param call_id The call index.
731 * @param dst The destination where the call will be
732 * transfered to.
733 * @param code Status code to be returned for the call transfer
734 * request. On input, it contains status code 200.
735 */
736 void (*on_call_transfer_request)(pjsua_call_id call_id,
737 const pj_str_t *dst,
738 pjsip_status_code *code);
739
740 /**
741 * Notify application on call being transfered (i.e. REFER is received).
742 * Application can decide to accept/reject transfer request
743 * by setting the code (default is 202). When this callback
744 * is not defined, the default behavior is to accept the
745 * transfer.
746 *
747 * @param call_id The call index.
748 * @param dst The destination where the call will be
749 * transfered to.
750 * @param code Status code to be returned for the call transfer
751 * request. On input, it contains status code 200.
752 * @param opt The current call setting, application can update
753 * this setting for the call being transfered.
754 */
755 void (*on_call_transfer_request2)(pjsua_call_id call_id,
756 const pj_str_t *dst,
757 pjsip_status_code *code,
758 pjsua_call_setting *opt);
759
760 /**
761 * Notify application of the status of previously sent call
762 * transfer request. Application can monitor the status of the
763 * call transfer request, for example to decide whether to
764 * terminate existing call.
765 *
766 * @param call_id Call ID.
767 * @param st_code Status progress of the transfer request.
768 * @param st_text Status progress text.
769 * @param final If non-zero, no further notification will
770 * be reported. The st_code specified in
771 * this callback is the final status.
772 * @param p_cont Initially will be set to non-zero, application
773 * can set this to FALSE if it no longer wants
774 * to receie further notification (for example,
775 * after it hangs up the call).
776 */
777 void (*on_call_transfer_status)(pjsua_call_id call_id,
778 int st_code,
779 const pj_str_t *st_text,
780 pj_bool_t final,
781 pj_bool_t *p_cont);
782
783 /**
784 * Notify application about incoming INVITE with Replaces header.
785 * Application may reject the request by setting non-2xx code.
786 * See also on_call_replace_request2() callback for the version
787 * with \a pjsua_call_setting in the argument list.
788 *
789 * @param call_id The call ID to be replaced.
790 * @param rdata The incoming INVITE request to replace the call.
791 * @param st_code Status code to be set by application. Application
792 * should only return a final status (200-699).
793 * @param st_text Optional status text to be set by application.
794 */
795 void (*on_call_replace_request)(pjsua_call_id call_id,
796 pjsip_rx_data *rdata,
797 int *st_code,
798 pj_str_t *st_text);
799
800 /**
801 * Notify application about incoming INVITE with Replaces header.
802 * Application may reject the request by setting non-2xx code.
803 *
804 * @param call_id The call ID to be replaced.
805 * @param rdata The incoming INVITE request to replace the call.
806 * @param st_code Status code to be set by application. Application
807 * should only return a final status (200-699).
808 * @param st_text Optional status text to be set by application.
809 * @param opt The current call setting, application can update
810 * this setting for the call being replaced.
811 */
812 void (*on_call_replace_request2)(pjsua_call_id call_id,
813 pjsip_rx_data *rdata,
814 int *st_code,
815 pj_str_t *st_text,
816 pjsua_call_setting *opt);
817
818 /**
819 * Notify application that an existing call has been replaced with
820 * a new call. This happens when PJSUA-API receives incoming INVITE
821 * request with Replaces header.
822 *
823 * After this callback is called, normally PJSUA-API will disconnect
824 * \a old_call_id and establish \a new_call_id.
825 *
826 * @param old_call_id Existing call which to be replaced with the
827 * new call.
828 * @param new_call_id The new call.
829 * @param rdata The incoming INVITE with Replaces request.
830 */
831 void (*on_call_replaced)(pjsua_call_id old_call_id,
832 pjsua_call_id new_call_id);
833
834
835 /**
836 * Notify application when call has received new offer from remote
837 * (i.e. re-INVITE/UPDATE with SDP is received). Application can
838 * decide to accept/reject the offer by setting the code (default
839 * is 200). If the offer is accepted, application can update the
840 * call setting to be applied in the answer. When this callback is
841 * not defined, the default behavior is to accept the offer using
842 * current call setting.
843 *
844 * @param call_id The call index.
845 * @param offer The new offer received.
846 * @param reserved Reserved param, currently not used.
847 * @param code Status code to be returned for answering the
848 * offer. On input, it contains status code 200.
849 * Currently, valid values are only 200 and 488.
850 * @param opt The current call setting, application can update
851 * this setting for answering the offer.
852 */
853 void (*on_call_rx_offer)(pjsua_call_id call_id,
854 const pjmedia_sdp_session *offer,
855 void *reserved,
856 pjsip_status_code *code,
857 pjsua_call_setting *opt);
858
859 /**
860 * Notify application when registration or unregistration has been
861 * initiated. Note that this only notifies the initial registration
862 * and unregistration. Once registration session is active, subsequent
863 * refresh will not cause this callback to be called.
864 *
865 * @param acc_id The account ID.
866 * @param renew Non-zero for registration and zero for
867 * unregistration.
868 */
869 void (*on_reg_started)(pjsua_acc_id acc_id, pj_bool_t renew);
870
871 /**
872 * Notify application when registration status has changed.
873 * Application may then query the account info to get the
874 * registration details.
875 *
876 * @param acc_id The account ID.
877 */
878 void (*on_reg_state)(pjsua_acc_id acc_id);
879
880 /**
881 * Notify application when registration status has changed.
882 * Application may inspect the registration info to get the
883 * registration status details.
884 *
885 * @param acc_id The account ID.
886 * @param info The registration info.
887 */
888 void (*on_reg_state2)(pjsua_acc_id acc_id, pjsua_reg_info *info);
889
890 /**
891 * Notification when incoming SUBSCRIBE request is received. Application
892 * may use this callback to authorize the incoming subscribe request
893 * (e.g. ask user permission if the request should be granted).
894 *
895 * If this callback is not implemented, all incoming presence subscription
896 * requests will be accepted.
897 *
898 * If this callback is implemented, application has several choices on
899 * what to do with the incoming request:
900 * - it may reject the request immediately by specifying non-200 class
901 * final response in the \a code argument.
902 * - it may immediately accept the request by specifying 200 as the
903 * \a code argument. This is the default value if application doesn't
904 * set any value to the \a code argument. In this case, the library
905 * will automatically send NOTIFY request upon returning from this
906 * callback.
907 * - it may delay the processing of the request, for example to request
908 * user permission whether to accept or reject the request. In this
909 * case, the application MUST set the \a code argument to 202, then
910 * IMMEDIATELY calls #pjsua_pres_notify() with state
911 * PJSIP_EVSUB_STATE_PENDING and later calls #pjsua_pres_notify()
912 * again to accept or reject the subscription request.
913 *
914 * Any \a code other than 200 and 202 will be treated as 200.
915 *
916 * Application MUST return from this callback immediately (e.g. it must
917 * not block in this callback while waiting for user confirmation).
918 *
919 * @param srv_pres Server presence subscription instance. If
920 * application delays the acceptance of the request,
921 * it will need to specify this object when calling
922 * #pjsua_pres_notify().
923 * @param acc_id Account ID most appropriate for this request.
924 * @param buddy_id ID of the buddy matching the sender of the
925 * request, if any, or PJSUA_INVALID_ID if no
926 * matching buddy is found.
927 * @param from The From URI of the request.
928 * @param rdata The incoming request.
929 * @param code The status code to respond to the request. The
930 * default value is 200. Application may set this
931 * to other final status code to accept or reject
932 * the request.
933 * @param reason The reason phrase to respond to the request.
934 * @param msg_data If the application wants to send additional
935 * headers in the response, it can put it in this
936 * parameter.
937 */
938 void (*on_incoming_subscribe)(pjsua_acc_id acc_id,
939 pjsua_srv_pres *srv_pres,
940 pjsua_buddy_id buddy_id,
941 const pj_str_t *from,
942 pjsip_rx_data *rdata,
943 pjsip_status_code *code,
944 pj_str_t *reason,
945 pjsua_msg_data *msg_data);
946
947 /**
948 * Notification when server side subscription state has changed.
949 * This callback is optional as application normally does not need
950 * to do anything to maintain server side presence subscription.
951 *
952 * @param acc_id The account ID.
953 * @param srv_pres Server presence subscription object.
954 * @param remote_uri Remote URI string.
955 * @param state New subscription state.
956 * @param event PJSIP event that triggers the state change.
957 */
958 void (*on_srv_subscribe_state)(pjsua_acc_id acc_id,
959 pjsua_srv_pres *srv_pres,
960 const pj_str_t *remote_uri,
961 pjsip_evsub_state state,
962 pjsip_event *event);
963
964 /**
965 * Notify application when the buddy state has changed.
966 * Application may then query the buddy into to get the details.
967 *
968 * @param buddy_id The buddy id.
969 */
970 void (*on_buddy_state)(pjsua_buddy_id buddy_id);
971
972
973 /**
974 * Notify application when the state of client subscription session
975 * associated with a buddy has changed. Application may use this
976 * callback to retrieve more detailed information about the state
977 * changed event.
978 *
979 * @param buddy_id The buddy id.
980 * @param sub Event subscription session.
981 * @param event The event which triggers state change event.
982 */
983 void (*on_buddy_evsub_state)(pjsua_buddy_id buddy_id,
984 pjsip_evsub *sub,
985 pjsip_event *event);
986
987 /**
988 * Notify application on incoming pager (i.e. MESSAGE request).
989 * Argument call_id will be -1 if MESSAGE request is not related to an
990 * existing call.
991 *
992 * See also \a on_pager2() callback for the version with \a pjsip_rx_data
993 * passed as one of the argument.
994 *
995 * @param call_id Containts the ID of the call where the IM was
996 * sent, or PJSUA_INVALID_ID if the IM was sent
997 * outside call context.
998 * @param from URI of the sender.
999 * @param to URI of the destination message.
1000 * @param contact The Contact URI of the sender, if present.
1001 * @param mime_type MIME type of the message.
1002 * @param body The message content.
1003 */
1004 void (*on_pager)(pjsua_call_id call_id, const pj_str_t *from,
1005 const pj_str_t *to, const pj_str_t *contact,
1006 const pj_str_t *mime_type, const pj_str_t *body);
1007
1008 /**
1009 * This is the alternative version of the \a on_pager() callback with
1010 * \a pjsip_rx_data argument.
1011 *
1012 * @param call_id Containts the ID of the call where the IM was
1013 * sent, or PJSUA_INVALID_ID if the IM was sent
1014 * outside call context.
1015 * @param from URI of the sender.
1016 * @param to URI of the destination message.
1017 * @param contact The Contact URI of the sender, if present.
1018 * @param mime_type MIME type of the message.
1019 * @param body The message content.
1020 * @param rdata The incoming MESSAGE request.
1021 * @param acc_id Account ID most suitable for this message.
1022 */
1023 void (*on_pager2)(pjsua_call_id call_id, const pj_str_t *from,
1024 const pj_str_t *to, const pj_str_t *contact,
1025 const pj_str_t *mime_type, const pj_str_t *body,
1026 pjsip_rx_data *rdata, pjsua_acc_id acc_id);
1027
1028 /**
1029 * Notify application about the delivery status of outgoing pager
1030 * request. See also on_pager_status2() callback for the version with
1031 * \a pjsip_rx_data in the argument list.
1032 *
1033 * @param call_id Containts the ID of the call where the IM was
1034 * sent, or PJSUA_INVALID_ID if the IM was sent
1035 * outside call context.
1036 * @param to Destination URI.
1037 * @param body Message body.
1038 * @param user_data Arbitrary data that was specified when sending
1039 * IM message.
1040 * @param status Delivery status.
1041 * @param reason Delivery status reason.
1042 */
1043 void (*on_pager_status)(pjsua_call_id call_id,
1044 const pj_str_t *to,
1045 const pj_str_t *body,
1046 void *user_data,
1047 pjsip_status_code status,
1048 const pj_str_t *reason);
1049
1050 /**
1051 * Notify application about the delivery status of outgoing pager
1052 * request.
1053 *
1054 * @param call_id Containts the ID of the call where the IM was
1055 * sent, or PJSUA_INVALID_ID if the IM was sent
1056 * outside call context.
1057 * @param to Destination URI.
1058 * @param body Message body.
1059 * @param user_data Arbitrary data that was specified when sending
1060 * IM message.
1061 * @param status Delivery status.
1062 * @param reason Delivery status reason.
1063 * @param tdata The original MESSAGE request.
1064 * @param rdata The incoming MESSAGE response, or NULL if the
1065 * message transaction fails because of time out
1066 * or transport error.
1067 * @param acc_id Account ID from this the instant message was
1068 * send.
1069 */
1070 void (*on_pager_status2)(pjsua_call_id call_id,
1071 const pj_str_t *to,
1072 const pj_str_t *body,
1073 void *user_data,
1074 pjsip_status_code status,
1075 const pj_str_t *reason,
1076 pjsip_tx_data *tdata,
1077 pjsip_rx_data *rdata,
1078 pjsua_acc_id acc_id);
1079
1080 /**
1081 * Notify application about typing indication.
1082 *
1083 * @param call_id Containts the ID of the call where the IM was
1084 * sent, or PJSUA_INVALID_ID if the IM was sent
1085 * outside call context.
1086 * @param from URI of the sender.
1087 * @param to URI of the destination message.
1088 * @param contact The Contact URI of the sender, if present.
1089 * @param is_typing Non-zero if peer is typing, or zero if peer
1090 * has stopped typing a message.
1091 */
1092 void (*on_typing)(pjsua_call_id call_id, const pj_str_t *from,
1093 const pj_str_t *to, const pj_str_t *contact,
1094 pj_bool_t is_typing);
1095
1096 /**
1097 * Notify application about typing indication.
1098 *
1099 * @param call_id Containts the ID of the call where the IM was
1100 * sent, or PJSUA_INVALID_ID if the IM was sent
1101 * outside call context.
1102 * @param from URI of the sender.
1103 * @param to URI of the destination message.
1104 * @param contact The Contact URI of the sender, if present.
1105 * @param is_typing Non-zero if peer is typing, or zero if peer
1106 * has stopped typing a message.
1107 * @param rdata The received request.
1108 * @param acc_id Account ID most suitable for this message.
1109 */
1110 void (*on_typing2)(pjsua_call_id call_id, const pj_str_t *from,
1111 const pj_str_t *to, const pj_str_t *contact,
1112 pj_bool_t is_typing, pjsip_rx_data *rdata,
1113 pjsua_acc_id acc_id);
1114
1115 /**
1116 * Callback when the library has finished performing NAT type
1117 * detection.
1118 *
1119 * @param res NAT detection result.
1120 */
1121 void (*on_nat_detect)(const pj_stun_nat_detect_result *res);
1122
1123 /**
1124 * This callback is called when the call is about to resend the
1125 * INVITE request to the specified target, following the previously
1126 * received redirection response.
1127 *
1128 * Application may accept the redirection to the specified target,
1129 * reject this target only and make the session continue to try the next
1130 * target in the list if such target exists, stop the whole
1131 * redirection process altogether and cause the session to be
1132 * disconnected, or defer the decision to ask for user confirmation.
1133 *
1134 * This callback is optional. If this callback is not implemented,
1135 * the default behavior is to NOT follow the redirection response.
1136 *
1137 * @param call_id The call ID.
1138 * @param target The current target to be tried.
1139 * @param e The event that caused this callback to be called.
1140 * This could be the receipt of 3xx response, or
1141 * 4xx/5xx response received for the INVITE sent to
1142 * subsequent targets, or NULL if this callback is
1143 * called from within #pjsua_call_process_redirect()
1144 * context.
1145 *
1146 * @return Action to be performed for the target. Set this
1147 * parameter to one of the value below:
1148 * - PJSIP_REDIRECT_ACCEPT: immediately accept the
1149 * redirection. When set, the call will immediately
1150 * resend INVITE request to the target.
1151 * - PJSIP_REDIRECT_ACCEPT_REPLACE: immediately accept
1152 * the redirection and replace the To header with the
1153 * current target. When set, the call will immediately
1154 * resend INVITE request to the target.
1155 * - PJSIP_REDIRECT_REJECT: immediately reject this
1156 * target. The call will continue retrying with
1157 * next target if present, or disconnect the call
1158 * if there is no more target to try.
1159 * - PJSIP_REDIRECT_STOP: stop the whole redirection
1160 * process and immediately disconnect the call. The
1161 * on_call_state() callback will be called with
1162 * PJSIP_INV_STATE_DISCONNECTED state immediately
1163 * after this callback returns.
1164 * - PJSIP_REDIRECT_PENDING: set to this value if
1165 * no decision can be made immediately (for example
1166 * to request confirmation from user). Application
1167 * then MUST call #pjsua_call_process_redirect()
1168 * to either accept or reject the redirection upon
1169 * getting user decision.
1170 */
1171 pjsip_redirect_op (*on_call_redirected)(pjsua_call_id call_id,
1172 const pjsip_uri *target,
1173 const pjsip_event *e);
1174
1175 /**
1176 * This callback is called when message waiting indication subscription
1177 * state has changed. Application can then query the subscription state
1178 * by calling #pjsip_evsub_get_state().
1179 *
1180 * @param acc_id The account ID.
1181 * @param evsub The subscription instance.
1182 */
1183 void (*on_mwi_state)(pjsua_acc_id acc_id, pjsip_evsub *evsub);
1184
1185 /**
1186 * This callback is called when a NOTIFY request for message summary /
1187 * message waiting indication is received.
1188 *
1189 * @param acc_id The account ID.
1190 * @param mwi_info Structure containing details of the event,
1191 * including the received NOTIFY request in the
1192 * \a rdata field.
1193 */
1194 void (*on_mwi_info)(pjsua_acc_id acc_id, pjsua_mwi_info *mwi_info);
1195
1196 /**
1197 * This callback is called when transport state is changed. See also
1198 * #pjsip_tp_state_callback.
1199 */
1200 pjsip_tp_state_callback on_transport_state;
1201
1202 /**
1203 * This callback is called when media transport state is changed. See
1204 * also #pjsua_med_tp_state_cb.
1205 */
1206 pjsua_med_tp_state_cb on_call_media_transport_state;
1207
1208 /**
1209 * This callback is called to report error in ICE media transport.
1210 * Currently it is used to report TURN Refresh error.
1211 *
1212 * @param index Transport index.
1213 * @param op Operation which trigger the failure.
1214 * @param status Error status.
1215 * @param param Additional info about the event. Currently this will
1216 * always be set to NULL.
1217 */
1218 void (*on_ice_transport_error)(int index, pj_ice_strans_op op,
1219 pj_status_t status, void *param);
1220
1221 /**
1222 * Callback when the sound device is about to be opened or closed.
1223 * This callback will be called even when null sound device or no
1224 * sound device is configured by the application (i.e. the
1225 * #pjsua_set_null_snd_dev() and #pjsua_set_no_snd_dev() APIs).
1226 * This API is mostly useful when the application wants to manage
1227 * the sound device by itself (i.e. with #pjsua_set_no_snd_dev()),
1228 * to get notified when it should open or close the sound device.
1229 *
1230 * @param operation The value will be set to 0 to signal that sound
1231 * device is about to be closed, and 1 to be opened.
1232 *
1233 * @return The callback must return PJ_SUCCESS at the moment.
1234 */
1235 pj_status_t (*on_snd_dev_operation)(int operation);
1236
1237 /**
1238 * Notification about media events such as video notifications. This
1239 * callback will most likely be called from media threads, thus
1240 * application must not perform heavy processing in this callback.
1241 * Especially, application must not destroy the call or media in this
1242 * callback. If application needs to perform more complex tasks to
1243 * handle the event, it should post the task to another thread.
1244 *
1245 * @param call_id The call id.
1246 * @param med_idx The media stream index.
1247 * @param event The media event.
1248 */
1249 void (*on_call_media_event)(pjsua_call_id call_id,
1250 unsigned med_idx,
1251 pjmedia_event *event);
1252
1253 /**
1254 * This callback can be used by application to implement custom media
1255 * transport adapter for the call, or to replace the media transport
1256 * with something completely new altogether.
1257 *
1258 * This callback is called when a new call is created. The library has
1259 * created a media transport for the call, and it is provided as the
1260 * \a base_tp argument of this callback. Upon returning, the callback
1261 * must return an instance of media transport to be used by the call.
1262 *
1263 * @param call_id Call ID
1264 * @param media_idx The media index in the SDP for which this media
1265 * transport will be used.
1266 * @param base_tp The media transport which otherwise will be
1267 * used by the call has this callback not been
1268 * implemented.
1269 * @param flags Bitmask from pjsua_create_media_transport_flag.
1270 *
1271 * @return The callback must return an instance of media
1272 * transport to be used by the call.
1273 */
1274 pjmedia_transport* (*on_create_media_transport)(pjsua_call_id call_id,
1275 unsigned media_idx,
1276 pjmedia_transport *base_tp,
1277 unsigned flags);
1278
1279 /**
1280 * This callback can be used by application to override the account
1281 * to be used to handle an incoming message. Initially, the account to
1282 * be used will be calculated automatically by the library. This initial
1283 * account will be used if application does not implement this callback,
1284 * or application sets an invalid account upon returning from this
1285 * callback.
1286 *
1287 * Note that currently the incoming messages requiring account assignment
1288 * are INVITE, MESSAGE, SUBSCRIBE, and unsolicited NOTIFY. This callback
1289 * may be called before the callback of the SIP event itself, i.e:
1290 * incoming call, pager, subscription, or unsolicited-event.
1291 *
1292 * @param rdata The incoming message.
1293 * @param acc_id On input, initial account ID calculated automatically
1294 * by the library. On output, the account ID prefered
1295 * by application to handle the incoming message.
1296 */
1297 void (*on_acc_find_for_incoming)(const pjsip_rx_data *rdata,
1298 pjsua_acc_id* acc_id);
1299
1300} pjsua_callback;
1301
1302
1303/**
1304 * This enumeration specifies the usage of SIP Session Timers extension.
1305 */
1306typedef enum pjsua_sip_timer_use
1307{
1308 /**
1309 * When this flag is specified, Session Timers will not be used in any
1310 * session, except it is explicitly required in the remote request.
1311 */
1312 PJSUA_SIP_TIMER_INACTIVE,
1313
1314 /**
1315 * When this flag is specified, Session Timers will be used in all
1316 * sessions whenever remote supports and uses it.
1317 */
1318 PJSUA_SIP_TIMER_OPTIONAL,
1319
1320 /**
1321 * When this flag is specified, Session Timers support will be
1322 * a requirement for the remote to be able to establish a session.
1323 */
1324 PJSUA_SIP_TIMER_REQUIRED,
1325
1326 /**
1327 * When this flag is specified, Session Timers will always be used
1328 * in all sessions, regardless whether remote supports/uses it or not.
1329 */
1330 PJSUA_SIP_TIMER_ALWAYS
1331
1332} pjsua_sip_timer_use;
1333
1334
1335/**
1336 * This constants controls the use of 100rel extension.
1337 */
1338typedef enum pjsua_100rel_use
1339{
1340 /**
1341 * Not used. For UAC, support for 100rel will be indicated in Supported
1342 * header so that peer can opt to use it if it wants to. As UAS, this
1343 * option will NOT cause 100rel to be used even if UAC indicates that
1344 * it supports this feature.
1345 */
1346 PJSUA_100REL_NOT_USED,
1347
1348 /**
1349 * Mandatory. UAC will place 100rel in Require header, and UAS will
1350 * reject incoming calls unless it has 100rel in Supported header.
1351 */
1352 PJSUA_100REL_MANDATORY,
1353
1354 /**
1355 * Optional. Similar to PJSUA_100REL_NOT_USED, except that as UAS, this
1356 * option will cause 100rel to be used if UAC indicates that it supports it.
1357 */
1358 PJSUA_100REL_OPTIONAL
1359
1360} pjsua_100rel_use;
1361
1362
1363/**
1364 * This structure describes the settings to control the API and
1365 * user agent behavior, and can be specified when calling #pjsua_init().
1366 * Before setting the values, application must call #pjsua_config_default()
1367 * to initialize this structure with the default values.
1368 */
1369typedef struct pjsua_config
1370{
1371
1372 /**
1373 * Maximum calls to support (default: 4). The value specified here
1374 * must be smaller than the compile time maximum settings
1375 * PJSUA_MAX_CALLS, which by default is 32. To increase this
1376 * limit, the library must be recompiled with new PJSUA_MAX_CALLS
1377 * value.
1378 */
1379 unsigned max_calls;
1380
1381 /**
1382 * Number of worker threads. Normally application will want to have at
1383 * least one worker thread, unless when it wants to poll the library
1384 * periodically, which in this case the worker thread can be set to
1385 * zero.
1386 */
1387 unsigned thread_cnt;
1388
1389 /**
1390 * Number of nameservers. If no name server is configured, the SIP SRV
1391 * resolution would be disabled, and domain will be resolved with
1392 * standard pj_gethostbyname() function.
1393 */
1394 unsigned nameserver_count;
1395
1396 /**
1397 * Array of nameservers to be used by the SIP resolver subsystem.
1398 * The order of the name server specifies the priority (first name
1399 * server will be used first, unless it is not reachable).
1400 */
1401 pj_str_t nameserver[4];
1402
1403 /**
1404 * Force loose-route to be used in all route/proxy URIs (outbound_proxy
1405 * and account's proxy settings). When this setting is enabled, the
1406 * library will check all the route/proxy URIs specified in the settings
1407 * and append ";lr" parameter to the URI if the parameter is not present.
1408 *
1409 * Default: 1
1410 */
1411 pj_bool_t force_lr;
1412
1413 /**
1414 * Number of outbound proxies in the \a outbound_proxy array.
1415 */
1416 unsigned outbound_proxy_cnt;
1417
1418 /**
1419 * Specify the URL of outbound proxies to visit for all outgoing requests.
1420 * The outbound proxies will be used for all accounts, and it will
1421 * be used to build the route set for outgoing requests. The final
1422 * route set for outgoing requests will consists of the outbound proxies
1423 * and the proxy configured in the account.
1424 */
1425 pj_str_t outbound_proxy[4];
1426
1427 /**
1428 * Warning: deprecated, please use \a stun_srv field instead. To maintain
1429 * backward compatibility, if \a stun_srv_cnt is zero then the value of
1430 * this field will be copied to \a stun_srv field, if present.
1431 *
1432 * Specify domain name to be resolved with DNS SRV resolution to get the
1433 * address of the STUN server. Alternatively application may specify
1434 * \a stun_host instead.
1435 *
1436 * If DNS SRV resolution failed for this domain, then DNS A resolution
1437 * will be performed only if \a stun_host is specified.
1438 */
1439 pj_str_t stun_domain;
1440
1441 /**
1442 * Warning: deprecated, please use \a stun_srv field instead. To maintain
1443 * backward compatibility, if \a stun_srv_cnt is zero then the value of
1444 * this field will be copied to \a stun_srv field, if present.
1445 *
1446 * Specify STUN server to be used, in "HOST[:PORT]" format. If port is
1447 * not specified, default port 3478 will be used.
1448 */
1449 pj_str_t stun_host;
1450
1451 /**
1452 * Number of STUN server entries in \a stun_srv array.
1453 */
1454 unsigned stun_srv_cnt;
1455
1456 /**
1457 * Array of STUN servers to try. The library will try to resolve and
1458 * contact each of the STUN server entry until it finds one that is
1459 * usable. Each entry may be a domain name, host name, IP address, and
1460 * it may contain an optional port number. For example:
1461 * - "pjsip.org" (domain name)
1462 * - "sip.pjsip.org" (host name)
1463 * - "pjsip.org:33478" (domain name and a non-standard port number)
1464 * - "10.0.0.1:3478" (IP address and port number)
1465 *
1466 * When nameserver is configured in the \a pjsua_config.nameserver field,
1467 * if entry is not an IP address, it will be resolved with DNS SRV
1468 * resolution first, and it will fallback to use DNS A resolution if this
1469 * fails. Port number may be specified even if the entry is a domain name,
1470 * in case the DNS SRV resolution should fallback to a non-standard port.
1471 *
1472 * When nameserver is not configured, entries will be resolved with
1473 * #pj_gethostbyname() if it's not an IP address. Port number may be
1474 * specified if the server is not listening in standard STUN port.
1475 */
1476 pj_str_t stun_srv[8];
1477
1478 /**
1479 * This specifies if the library startup should ignore failure with the
1480 * STUN servers. If this is set to PJ_FALSE, the library will refuse to
1481 * start if it fails to resolve or contact any of the STUN servers.
1482 *
1483 * Default: PJ_TRUE
1484 */
1485 pj_bool_t stun_ignore_failure;
1486
1487 /**
1488 * This specifies whether STUN requests for resolving socket mapped
1489 * address should use the new format, i.e: having STUN magic cookie
1490 * in its transaction ID.
1491 *
1492 * Default: PJ_FALSE
1493 */
1494 pj_bool_t stun_map_use_stun2;
1495
1496 /**
1497 * Support for adding and parsing NAT type in the SDP to assist
1498 * troubleshooting. The valid values are:
1499 * - 0: no information will be added in SDP, and parsing is disabled.
1500 * - 1: only the NAT type number is added.
1501 * - 2: add both NAT type number and name.
1502 *
1503 * Default: 1
1504 */
1505 int nat_type_in_sdp;
1506
1507 /**
1508 * Specify how the support for reliable provisional response (100rel/
1509 * PRACK) should be used by default. Note that this setting can be
1510 * further customized in account configuration (#pjsua_acc_config).
1511 *
1512 * Default: PJSUA_100REL_NOT_USED
1513 */
1514 pjsua_100rel_use require_100rel;
1515
1516 /**
1517 * Specify the usage of Session Timers for all sessions. See the
1518 * #pjsua_sip_timer_use for possible values. Note that this setting can be
1519 * further customized in account configuration (#pjsua_acc_config).
1520 *
1521 * Default: PJSUA_SIP_TIMER_OPTIONAL
1522 */
1523 pjsua_sip_timer_use use_timer;
1524
1525 /**
1526 * Handle unsolicited NOTIFY requests containing message waiting
1527 * indication (MWI) info. Unsolicited MWI is incoming NOTIFY requests
1528 * which are not requested by client with SUBSCRIBE request.
1529 *
1530 * If this is enabled, the library will respond 200/OK to the NOTIFY
1531 * request and forward the request to \a on_mwi_info() callback.
1532 *
1533 * See also \a mwi_enabled field #on pjsua_acc_config.
1534 *
1535 * Default: PJ_TRUE
1536 *
1537 */
1538 pj_bool_t enable_unsolicited_mwi;
1539
1540 /**
1541 * Specify Session Timer settings, see #pjsip_timer_setting.
1542 * Note that this setting can be further customized in account
1543 * configuration (#pjsua_acc_config).
1544 */
1545 pjsip_timer_setting timer_setting;
1546
1547 /**
1548 * Number of credentials in the credential array.
1549 */
1550 unsigned cred_count;
1551
1552 /**
1553 * Array of credentials. These credentials will be used by all accounts,
1554 * and can be used to authenticate against outbound proxies. If the
1555 * credential is specific to the account, then application should set
1556 * the credential in the pjsua_acc_config rather than the credential
1557 * here.
1558 */
1559 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
1560
1561 /**
1562 * Application callback to receive various event notifications from
1563 * the library.
1564 */
1565 pjsua_callback cb;
1566
1567 /**
1568 * Optional user agent string (default empty). If it's empty, no
1569 * User-Agent header will be sent with outgoing requests.
1570 */
1571 pj_str_t user_agent;
1572
1573 /**
1574 * Specify default value of secure media transport usage.
1575 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
1576 * PJMEDIA_SRTP_MANDATORY.
1577 *
1578 * Note that this setting can be further customized in account
1579 * configuration (#pjsua_acc_config).
1580 *
1581 * Default: #PJSUA_DEFAULT_USE_SRTP
1582 */
1583 pjmedia_srtp_use use_srtp;
1584
1585 /**
1586 * Specify whether SRTP requires secure signaling to be used. This option
1587 * is only used when \a use_srtp option above is non-zero.
1588 *
1589 * Valid values are:
1590 * 0: SRTP does not require secure signaling
1591 * 1: SRTP requires secure transport such as TLS
1592 * 2: SRTP requires secure end-to-end transport (SIPS)
1593 *
1594 * Note that this setting can be further customized in account
1595 * configuration (#pjsua_acc_config).
1596 *
1597 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
1598 */
1599 int srtp_secure_signaling;
1600
1601 /**
1602 * This setting has been deprecated and will be ignored.
1603 */
1604 pj_bool_t srtp_optional_dup_offer;
1605
1606 /**
1607 * Disconnect other call legs when more than one 2xx responses for
1608 * outgoing INVITE are received due to forking. Currently the library
1609 * is not able to handle simultaneous forked media, so disconnecting
1610 * the other call legs is necessary.
1611 *
1612 * With this setting enabled, the library will handle only one of the
1613 * connected call leg, and the other connected call legs will be
1614 * disconnected.
1615 *
1616 * Default: PJ_TRUE (only disable this setting for testing purposes).
1617 */
1618 pj_bool_t hangup_forked_call;
1619
1620} pjsua_config;
1621
1622
1623/**
1624 * Flags to be given to pjsua_destroy2()
1625 */
1626typedef enum pjsua_destroy_flag
1627{
1628 /**
1629 * Allow sending outgoing messages (such as unregistration, event
1630 * unpublication, BYEs, unsubscription, etc.), but do not wait for
1631 * responses. This is useful to perform "best effort" clean up
1632 * without delaying the shutdown process waiting for responses.
1633 */
1634 PJSUA_DESTROY_NO_RX_MSG = 1,
1635
1636 /**
1637 * If this flag is set, do not send any outgoing messages at all.
1638 * This flag is useful if application knows that the network which
1639 * the messages are to be sent on is currently down.
1640 */
1641 PJSUA_DESTROY_NO_TX_MSG = 2,
1642
1643 /**
1644 * Do not send or receive messages during destroy. This flag is
1645 * shorthand for PJSUA_DESTROY_NO_RX_MSG + PJSUA_DESTROY_NO_TX_MSG.
1646 */
1647 PJSUA_DESTROY_NO_NETWORK = PJSUA_DESTROY_NO_RX_MSG |
1648 PJSUA_DESTROY_NO_TX_MSG
1649
1650} pjsua_destroy_flag;
1651
1652/**
1653 * Use this function to initialize pjsua config.
1654 *
1655 * @param cfg pjsua config to be initialized.
1656 */
1657PJ_DECL(void) pjsua_config_default(pjsua_config *cfg);
1658
1659
1660/** The implementation has been moved to sip_auth.h */
1661#define pjsip_cred_dup pjsip_cred_info_dup
1662
1663
1664/**
1665 * Duplicate pjsua_config.
1666 *
1667 * @param pool The pool to get memory from.
1668 * @param dst Destination config.
1669 * @param src Source config.
1670 */
1671PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool,
1672 pjsua_config *dst,
1673 const pjsua_config *src);
1674
1675
1676/**
1677 * This structure describes additional information to be sent with
1678 * outgoing SIP message. It can (optionally) be specified for example
1679 * with #pjsua_call_make_call(), #pjsua_call_answer(), #pjsua_call_hangup(),
1680 * #pjsua_call_set_hold(), #pjsua_call_send_im(), and many more.
1681 *
1682 * Application MUST call #pjsua_msg_data_init() to initialize this
1683 * structure before setting its values.
1684 */
1685struct pjsua_msg_data
1686{
1687 /**
1688 * Optional remote target URI (i.e. Target header). If NULL, the target
1689 * will be set to the remote URI (To header). At the moment this field
1690 * is only used by #pjsua_call_make_call() and #pjsua_im_send().
1691 */
1692 pj_str_t target_uri;
1693
1694 /**
1695 * Additional message headers as linked list. Application can add
1696 * headers to the list by creating the header, either from the heap/pool
1697 * or from temporary local variable, and add the header using
1698 * linked list operation. See pjsua_app.c for some sample codes.
1699 */
1700 pjsip_hdr hdr_list;
1701
1702 /**
1703 * MIME type of optional message body.
1704 */
1705 pj_str_t content_type;
1706
1707 /**
1708 * Optional message body to be added to the message, only when the
1709 * message doesn't have a body.
1710 */
1711 pj_str_t msg_body;
1712
1713 /**
1714 * Content type of the multipart body. If application wants to send
1715 * multipart message bodies, it puts the parts in \a parts and set
1716 * the content type in \a multipart_ctype. If the message already
1717 * contains a body, the body will be added to the multipart bodies.
1718 */
1719 pjsip_media_type multipart_ctype;
1720
1721 /**
1722 * List of multipart parts. If application wants to send multipart
1723 * message bodies, it puts the parts in \a parts and set the content
1724 * type in \a multipart_ctype. If the message already contains a body,
1725 * the body will be added to the multipart bodies.
1726 */
1727 pjsip_multipart_part multipart_parts;
1728};
1729
1730
1731/**
1732 * Initialize message data.
1733 *
1734 * @param msg_data Message data to be initialized.
1735 */
1736PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data);
1737
1738
1739/**
1740 * Clone message data.
1741 *
1742 * @param pool Pool to allocate memory for the new message data.
1743 * @param rhs Message data to be cloned.
1744 *
1745 * @return The new message data.
1746 */
1747PJ_DECL(pjsua_msg_data*) pjsua_msg_data_clone(pj_pool_t *pool,
1748 const pjsua_msg_data *rhs);
1749
1750
1751/**
1752 * Instantiate pjsua application. Application must call this function before
1753 * calling any other functions, to make sure that the underlying libraries
1754 * are properly initialized. Once this function has returned success,
1755 * application must call pjsua_destroy() before quitting.
1756 *
1757 * @return PJ_SUCCESS on success, or the appropriate error code.
1758 */
1759PJ_DECL(pj_status_t) pjsua_create(void);
1760
1761
1762/** Forward declaration */
1763typedef struct pjsua_media_config pjsua_media_config;
1764
1765
1766/**
1767 * Initialize pjsua with the specified settings. All the settings are
1768 * optional, and the default values will be used when the config is not
1769 * specified.
1770 *
1771 * Note that #pjsua_create() MUST be called before calling this function.
1772 *
1773 * @param ua_cfg User agent configuration.
1774 * @param log_cfg Optional logging configuration.
1775 * @param media_cfg Optional media configuration.
1776 *
1777 * @return PJ_SUCCESS on success, or the appropriate error code.
1778 */
1779PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *ua_cfg,
1780 const pjsua_logging_config *log_cfg,
1781 const pjsua_media_config *media_cfg);
1782
1783
1784/**
1785 * Application is recommended to call this function after all initialization
1786 * is done, so that the library can do additional checking set up
1787 * additional
1788 *
1789 * Application may call this function anytime after #pjsua_init().
1790 *
1791 * @return PJ_SUCCESS on success, or the appropriate error code.
1792 */
1793PJ_DECL(pj_status_t) pjsua_start(void);
1794
1795
1796/**
1797 * Destroy pjsua. Application is recommended to perform graceful shutdown
1798 * before calling this function (such as unregister the account from the SIP
1799 * server, terminate presense subscription, and hangup active calls), however,
1800 * this function will do all of these if it finds there are active sessions
1801 * that need to be terminated. This function will approximately block for
1802 * one second to wait for replies from remote.
1803 *
1804 * Application.may safely call this function more than once if it doesn't
1805 * keep track of it's state.
1806 *
1807 * @see pjsua_destroy2()
1808 *
1809 * @return PJ_SUCCESS on success, or the appropriate error code.
1810 */
1811PJ_DECL(pj_status_t) pjsua_destroy(void);
1812
1813
1814/**
1815 * Retrieve pjsua state.
1816 *
1817 * @return pjsua state.
1818 */
1819PJ_DECL(pjsua_state) pjsua_get_state(void);
1820
1821
1822/**
1823 * Variant of destroy with additional flags.
1824 *
1825 * @param flags Combination of pjsua_destroy_flag enumeration.
1826 *
1827 * @return PJ_SUCCESS on success, or the appropriate error code.
1828 */
1829PJ_DECL(pj_status_t) pjsua_destroy2(unsigned flags);
1830
1831
1832/**
1833 * Poll pjsua for events, and if necessary block the caller thread for
1834 * the specified maximum interval (in miliseconds).
1835 *
1836 * Application doesn't normally need to call this function if it has
1837 * configured worker thread (\a thread_cnt field) in pjsua_config structure,
1838 * because polling then will be done by these worker threads instead.
1839 *
1840 * @param msec_timeout Maximum time to wait, in miliseconds.
1841 *
1842 * @return The number of events that have been handled during the
1843 * poll. Negative value indicates error, and application
1844 * can retrieve the error as (status = -return_value).
1845 */
1846PJ_DECL(int) pjsua_handle_events(unsigned msec_timeout);
1847
1848
1849/**
1850 * Create memory pool to be used by the application. Once application
1851 * finished using the pool, it must be released with pj_pool_release().
1852 *
1853 * @param name Optional pool name.
1854 * @param init_size Initial size of the pool.
1855 * @param increment Increment size.
1856 *
1857 * @return The pool, or NULL when there's no memory.
1858 */
1859PJ_DECL(pj_pool_t*) pjsua_pool_create(const char *name, pj_size_t init_size,
1860 pj_size_t increment);
1861
1862
1863/**
1864 * Application can call this function at any time (after pjsua_create(), of
1865 * course) to change logging settings.
1866 *
1867 * @param c Logging configuration.
1868 *
1869 * @return PJ_SUCCESS on success, or the appropriate error code.
1870 */
1871PJ_DECL(pj_status_t) pjsua_reconfigure_logging(const pjsua_logging_config *c);
1872
1873
1874/**
1875 * Internal function to get SIP endpoint instance of pjsua, which is
1876 * needed for example to register module, create transports, etc.
1877 * Only valid after #pjsua_init() is called.
1878 *
1879 * @return SIP endpoint instance.
1880 */
1881PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void);
1882
1883/**
1884 * Internal function to get media endpoint instance.
1885 * Only valid after #pjsua_init() is called.
1886 *
1887 * @return Media endpoint instance.
1888 */
1889PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void);
1890
1891/**
1892 * Internal function to get PJSUA pool factory.
1893 * Only valid after #pjsua_create() is called.
1894 *
1895 * @return Pool factory currently used by PJSUA.
1896 */
1897PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
1898
1899
1900
1901/*****************************************************************************
1902 * Utilities.
1903 *
1904 */
1905
1906/**
1907 * This structure is used to represent the result of the STUN server
1908 * resolution and testing, the #pjsua_resolve_stun_servers() function.
1909 * This structure will be passed in #pj_stun_resolve_cb callback.
1910 */
1911typedef struct pj_stun_resolve_result
1912{
1913 /**
1914 * Arbitrary data that was passed to #pjsua_resolve_stun_servers()
1915 * function.
1916 */
1917 void *token;
1918
1919 /**
1920 * This will contain PJ_SUCCESS if at least one usable STUN server
1921 * is found, otherwise it will contain the last error code during
1922 * the operation.
1923 */
1924 pj_status_t status;
1925
1926 /**
1927 * The server name that yields successful result. This will only
1928 * contain value if status is successful.
1929 */
1930 pj_str_t name;
1931
1932 /**
1933 * The server IP address. This will only contain value if status
1934 * is successful.
1935 */
1936 pj_sockaddr addr;
1937
1938} pj_stun_resolve_result;
1939
1940
1941/**
1942 * Typedef of callback to be registered to #pjsua_resolve_stun_servers().
1943 */
1944typedef void (*pj_stun_resolve_cb)(const pj_stun_resolve_result *result);
1945
1946/**
1947 * This is a utility function to detect NAT type in front of this
1948 * endpoint. Once invoked successfully, this function will complete
1949 * asynchronously and report the result in \a on_nat_detect() callback
1950 * of pjsua_callback.
1951 *
1952 * After NAT has been detected and the callback is called, application can
1953 * get the detected NAT type by calling #pjsua_get_nat_type(). Application
1954 * can also perform NAT detection by calling #pjsua_detect_nat_type()
1955 * again at later time.
1956 *
1957 * Note that STUN must be enabled to run this function successfully.
1958 *
1959 * @return PJ_SUCCESS on success, or the appropriate error code.
1960 */
1961PJ_DECL(pj_status_t) pjsua_detect_nat_type(void);
1962
1963
1964/**
1965 * Get the NAT type as detected by #pjsua_detect_nat_type() function.
1966 * This function will only return useful NAT type after #pjsua_detect_nat_type()
1967 * has completed successfully and \a on_nat_detect() callback has been called.
1968 *
1969 * @param type NAT type.
1970 *
1971 * @return When detection is in progress, this function will
1972 * return PJ_EPENDING and \a type will be set to
1973 * PJ_STUN_NAT_TYPE_UNKNOWN. After NAT type has been
1974 * detected successfully, this function will return
1975 * PJ_SUCCESS and \a type will be set to the correct
1976 * value. Other return values indicate error and
1977 * \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN.
1978 *
1979 * @see pjsua_call_get_rem_nat_type()
1980 */
1981PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type);
1982
1983
1984/**
1985 * Auxiliary function to resolve and contact each of the STUN server
1986 * entries (sequentially) to find which is usable. The #pjsua_init() must
1987 * have been called before calling this function.
1988 *
1989 * @param count Number of STUN server entries to try.
1990 * @param srv Array of STUN server entries to try. Please see
1991 * the \a stun_srv field in the #pjsua_config
1992 * documentation about the format of this entry.
1993 * @param wait Specify non-zero to make the function block until
1994 * it gets the result. In this case, the function
1995 * will block while the resolution is being done,
1996 * and the callback will be called before this function
1997 * returns.
1998 * @param token Arbitrary token to be passed back to application
1999 * in the callback.
2000 * @param cb Callback to be called to notify the result of
2001 * the function.
2002 *
2003 * @return If \a wait parameter is non-zero, this will return
2004 * PJ_SUCCESS if one usable STUN server is found.
2005 * Otherwise it will always return PJ_SUCCESS, and
2006 * application will be notified about the result in
2007 * the callback.
2008 */
2009PJ_DECL(pj_status_t) pjsua_resolve_stun_servers(unsigned count,
2010 pj_str_t srv[],
2011 pj_bool_t wait,
2012 void *token,
2013 pj_stun_resolve_cb cb);
2014
2015/**
2016 * Cancel pending STUN resolution which match the specified token.
2017 *
2018 * @param token The token to match. This token was given to
2019 * #pjsua_resolve_stun_servers()
2020 * @param notify_cb Boolean to control whether the callback should
2021 * be called for cancelled resolutions. When the
2022 * callback is called, the status in the result
2023 * will be set as PJ_ECANCELLED.
2024 *
2025 * @return PJ_SUCCESS if there is at least one pending STUN
2026 * resolution cancelled, or PJ_ENOTFOUND if there is
2027 * no matching one, or other error.
2028 */
2029PJ_DECL(pj_status_t) pjsua_cancel_stun_resolution(void *token,
2030 pj_bool_t notify_cb);
2031
2032
2033/**
2034 * This is a utility function to verify that valid SIP url is given. If the
2035 * URL is a valid SIP/SIPS scheme, PJ_SUCCESS will be returned.
2036 *
2037 * @param url The URL, as NULL terminated string.
2038 *
2039 * @return PJ_SUCCESS on success, or the appropriate error code.
2040 *
2041 * @see pjsua_verify_url()
2042 */
2043PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *url);
2044
2045
2046/**
2047 * This is a utility function to verify that valid URI is given. Unlike
2048 * pjsua_verify_sip_url(), this function will return PJ_SUCCESS if tel: URI
2049 * is given.
2050 *
2051 * @param url The URL, as NULL terminated string.
2052 *
2053 * @return PJ_SUCCESS on success, or the appropriate error code.
2054 *
2055 * @see pjsua_verify_sip_url()
2056 */
2057PJ_DECL(pj_status_t) pjsua_verify_url(const char *url);
2058
2059
2060/**
2061 * Schedule a timer entry. Note that the timer callback may be executed
2062 * by different thread, depending on whether worker thread is enabled or
2063 * not.
2064 *
2065 * @param entry Timer heap entry.
2066 * @param delay The interval to expire.
2067 *
2068 * @return PJ_SUCCESS on success, or the appropriate error code.
2069 *
2070 * @see pjsip_endpt_schedule_timer()
2071 */
2072#if PJ_TIMER_DEBUG
2073#define pjsua_schedule_timer(e,d) pjsua_schedule_timer_dbg(e,d,\
2074 __FILE__,__LINE__)
2075
2076PJ_DECL(pj_status_t) pjsua_schedule_timer_dbg(pj_timer_entry *entry,
2077 const pj_time_val *delay,
2078 const char *src_file,
2079 int src_line);
2080#else
2081PJ_DECL(pj_status_t) pjsua_schedule_timer(pj_timer_entry *entry,
2082 const pj_time_val *delay);
2083#endif
2084
2085/**
2086 * Schedule a callback function to be called after a specified time interval.
2087 * Note that the callback may be executed by different thread, depending on
2088 * whether worker thread is enabled or not.
2089 *
2090 * @param cb The callback function.
2091 * @param user_data The user data.
2092 * @param msec_delay The time interval in msec.
2093 *
2094 * @return PJ_SUCCESS on success, or the appropriate error code.
2095 */
2096#if PJ_TIMER_DEBUG
2097#define pjsua_schedule_timer2(cb,u,d) \
2098 pjsua_schedule_timer2_dbg(cb,u,d,__FILE__,__LINE__)
2099
2100PJ_DECL(pj_status_t) pjsua_schedule_timer2_dbg(void (*cb)(void *user_data),
2101 void *user_data,
2102 unsigned msec_delay,
2103 const char *src_file,
2104 int src_line);
2105#else
2106PJ_DECL(pj_status_t) pjsua_schedule_timer2(void (*cb)(void *user_data),
2107 void *user_data,
2108 unsigned msec_delay);
2109#endif
2110
2111/**
2112 * Cancel the previously scheduled timer.
2113 *
2114 * @param entry Timer heap entry.
2115 *
2116 * @see pjsip_endpt_cancel_timer()
2117 */
2118PJ_DECL(void) pjsua_cancel_timer(pj_timer_entry *entry);
2119
2120
2121/**
2122 * This is a utility function to display error message for the specified
2123 * error code. The error message will be sent to the log.
2124 *
2125 * @param sender The log sender field.
2126 * @param title Message title for the error.
2127 * @param status Status code.
2128 */
2129PJ_DECL(void) pjsua_perror(const char *sender, const char *title,
2130 pj_status_t status);
2131
2132
2133/**
2134 * This is a utility function to dump the stack states to log, using
2135 * verbosity level 3.
2136 *
2137 * @param detail Will print detailed output (such as list of
2138 * SIP transactions) when non-zero.
2139 */
2140PJ_DECL(void) pjsua_dump(pj_bool_t detail);
2141
2142/**
2143 * @}
2144 */
2145
2146
2147
2148/*****************************************************************************
2149 * TRANSPORT API
2150 */
2151
2152/**
2153 * @defgroup PJSUA_LIB_TRANSPORT PJSUA-API Signaling Transport
2154 * @ingroup PJSUA_LIB
2155 * @brief API for managing SIP transports
2156 * @{
2157 *
2158 * PJSUA-API supports creating multiple transport instances, for example UDP,
2159 * TCP, and TLS transport. SIP transport must be created before adding an
2160 * account.
2161 */
2162
2163
2164/** SIP transport identification.
2165 */
2166typedef int pjsua_transport_id;
2167
2168
2169/**
2170 * Transport configuration for creating transports for both SIP
2171 * and media. Before setting some values to this structure, application
2172 * MUST call #pjsua_transport_config_default() to initialize its
2173 * values with default settings.
2174 */
2175typedef struct pjsua_transport_config
2176{
2177 /**
2178 * UDP port number to bind locally. This setting MUST be specified
2179 * even when default port is desired. If the value is zero, the
2180 * transport will be bound to any available port, and application
2181 * can query the port by querying the transport info.
2182 */
2183 unsigned port;
2184
2185 /**
2186 * Specify the port range for socket binding, relative to the start
2187 * port number specified in \a port. Note that this setting is only
2188 * applicable when the start port number is non zero.
2189 *
2190 * Default value is zero.
2191 */
2192 unsigned port_range;
2193
2194 /**
2195 * Optional address to advertise as the address of this transport.
2196 * Application can specify any address or hostname for this field,
2197 * for example it can point to one of the interface address in the
2198 * system, or it can point to the public address of a NAT router
2199 * where port mappings have been configured for the application.
2200 *
2201 * Note: this option can be used for both UDP and TCP as well!
2202 */
2203 pj_str_t public_addr;
2204
2205 /**
2206 * Optional address where the socket should be bound to. This option
2207 * SHOULD only be used to selectively bind the socket to particular
2208 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
2209 * published address of a transport (the public_addr field should be
2210 * used for that purpose).
2211 *
2212 * Note that unlike public_addr field, the address (or hostname) here
2213 * MUST correspond to the actual interface address in the host, since
2214 * this address will be specified as bind() argument.
2215 */
2216 pj_str_t bound_addr;
2217
2218 /**
2219 * This specifies TLS settings for TLS transport. It is only be used
2220 * when this transport config is being used to create a SIP TLS
2221 * transport.
2222 */
2223 pjsip_tls_setting tls_setting;
2224
2225 /**
2226 * QoS traffic type to be set on this transport. When application wants
2227 * to apply QoS tagging to the transport, it's preferable to set this
2228 * field rather than \a qos_param fields since this is more portable.
2229 *
2230 * Default is QoS not set.
2231 */
2232 pj_qos_type qos_type;
2233
2234 /**
2235 * Set the low level QoS parameters to the transport. This is a lower
2236 * level operation than setting the \a qos_type field and may not be
2237 * supported on all platforms.
2238 *
2239 * Default is QoS not set.
2240 */
2241 pj_qos_params qos_params;
2242
2243} pjsua_transport_config;
2244
2245
2246/**
2247 * Call this function to initialize UDP config with default values.
2248 *
2249 * @param cfg The UDP config to be initialized.
2250 */
2251PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg);
2252
2253
2254/**
2255 * Duplicate transport config.
2256 *
2257 * @param pool The pool.
2258 * @param dst The destination config.
2259 * @param src The source config.
2260 */
2261PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool,
2262 pjsua_transport_config *dst,
2263 const pjsua_transport_config *src);
2264
2265
2266/**
2267 * This structure describes transport information returned by
2268 * #pjsua_transport_get_info() function.
2269 */
2270typedef struct pjsua_transport_info
2271{
2272 /**
2273 * PJSUA transport identification.
2274 */
2275 pjsua_transport_id id;
2276
2277 /**
2278 * Transport type.
2279 */
2280 pjsip_transport_type_e type;
2281
2282 /**
2283 * Transport type name.
2284 */
2285 pj_str_t type_name;
2286
2287 /**
2288 * Transport string info/description.
2289 */
2290 pj_str_t info;
2291
2292 /**
2293 * Transport flag (see ##pjsip_transport_flags_e).
2294 */
2295 unsigned flag;
2296
2297 /**
2298 * Local address length.
2299 */
2300 unsigned addr_len;
2301
2302 /**
2303 * Local/bound address.
2304 */
2305 pj_sockaddr local_addr;
2306
2307 /**
2308 * Published address (or transport address name).
2309 */
2310 pjsip_host_port local_name;
2311
2312 /**
2313 * Current number of objects currently referencing this transport.
2314 */
2315 unsigned usage_count;
2316
2317
2318} pjsua_transport_info;
2319
2320
2321/**
2322 * Create and start a new SIP transport according to the specified
2323 * settings.
2324 *
2325 * @param type Transport type.
2326 * @param cfg Transport configuration.
2327 * @param p_id Optional pointer to receive transport ID.
2328 *
2329 * @return PJ_SUCCESS on success, or the appropriate error code.
2330 */
2331PJ_DECL(pj_status_t) pjsua_transport_create(pjsip_transport_type_e type,
2332 const pjsua_transport_config *cfg,
2333 pjsua_transport_id *p_id);
2334
2335/**
2336 * Register transport that has been created by application. This function
2337 * is useful if application wants to implement custom SIP transport and use
2338 * it with pjsua.
2339 *
2340 * @param tp Transport instance.
2341 * @param p_id Optional pointer to receive transport ID.
2342 *
2343 * @return PJ_SUCCESS on success, or the appropriate error code.
2344 */
2345PJ_DECL(pj_status_t) pjsua_transport_register(pjsip_transport *tp,
2346 pjsua_transport_id *p_id);
2347
2348
2349/**
2350 * Enumerate all transports currently created in the system. This function
2351 * will return all transport IDs, and application may then call
2352 * #pjsua_transport_get_info() function to retrieve detailed information
2353 * about the transport.
2354 *
2355 * @param id Array to receive transport ids.
2356 * @param count In input, specifies the maximum number of elements.
2357 * On return, it contains the actual number of elements.
2358 *
2359 * @return PJ_SUCCESS on success, or the appropriate error code.
2360 */
2361PJ_DECL(pj_status_t) pjsua_enum_transports( pjsua_transport_id id[],
2362 unsigned *count );
2363
2364
2365/**
2366 * Get information about transports.
2367 *
2368 * @param id Transport ID.
2369 * @param info Pointer to receive transport info.
2370 *
2371 * @return PJ_SUCCESS on success, or the appropriate error code.
2372 */
2373PJ_DECL(pj_status_t) pjsua_transport_get_info(pjsua_transport_id id,
2374 pjsua_transport_info *info);
2375
2376
2377/**
2378 * Disable a transport or re-enable it. By default transport is always
2379 * enabled after it is created. Disabling a transport does not necessarily
2380 * close the socket, it will only discard incoming messages and prevent
2381 * the transport from being used to send outgoing messages.
2382 *
2383 * @param id Transport ID.
2384 * @param enabled Non-zero to enable, zero to disable.
2385 *
2386 * @return PJ_SUCCESS on success, or the appropriate error code.
2387 */
2388PJ_DECL(pj_status_t) pjsua_transport_set_enable(pjsua_transport_id id,
2389 pj_bool_t enabled);
2390
2391
2392/**
2393 * Close the transport. If transport is forcefully closed, it will be
2394 * immediately closed, and any pending transactions that are using the
2395 * transport may not terminate properly (it may even crash). Otherwise,
2396 * the system will wait until all transactions are closed while preventing
2397 * new users from using the transport, and will close the transport when
2398 * it is safe to do so.
2399 *
2400 * @param id Transport ID.
2401 * @param force Non-zero to immediately close the transport. This
2402 * is not recommended!
2403 *
2404 * @return PJ_SUCCESS on success, or the appropriate error code.
2405 */
2406PJ_DECL(pj_status_t) pjsua_transport_close( pjsua_transport_id id,
2407 pj_bool_t force );
2408
2409/**
2410 * @}
2411 */
2412
2413
2414
2415
2416/*****************************************************************************
2417 * ACCOUNT API
2418 */
2419
2420
2421/**
2422 * @defgroup PJSUA_LIB_ACC PJSUA-API Accounts Management
2423 * @ingroup PJSUA_LIB
2424 * @brief PJSUA Accounts management
2425 * @{
2426 *
2427 * PJSUA accounts provide identity (or identities) of the user who is currently
2428 * using the application. In SIP terms, the identity is used as the <b>From</b>
2429 * header in outgoing requests.
2430 *
2431 * PJSUA-API supports creating and managing multiple accounts. The maximum
2432 * number of accounts is limited by a compile time constant
2433 * <tt>PJSUA_MAX_ACC</tt>.
2434 *
2435 * Account may or may not have client registration associated with it.
2436 * An account is also associated with <b>route set</b> and some <b>authentication
2437 * credentials</b>, which are used when sending SIP request messages using the
2438 * account. An account also has presence's <b>online status</b>, which
2439 * will be reported to remote peer when they subscribe to the account's
2440 * presence, or which is published to a presence server if presence
2441 * publication is enabled for the account.
2442 *
2443 * At least one account MUST be created in the application. If no user
2444 * association is required, application can create a userless account by
2445 * calling #pjsua_acc_add_local(). A userless account identifies local endpoint
2446 * instead of a particular user, and it correspond with a particular
2447 * transport instance.
2448 *
2449 * Also one account must be set as the <b>default account</b>, which is used as
2450 * the account to use when PJSUA fails to match a request with any other
2451 * accounts.
2452 *
2453 * When sending outgoing SIP requests (such as making calls or sending
2454 * instant messages), normally PJSUA requires the application to specify
2455 * which account to use for the request. If no account is specified,
2456 * PJSUA may be able to select the account by matching the destination
2457 * domain name, and fall back to default account when no match is found.
2458 */
2459
2460/**
2461 * Maximum accounts.
2462 */
2463#ifndef PJSUA_MAX_ACC
2464# define PJSUA_MAX_ACC 8
2465#endif
2466
2467
2468/**
2469 * Default registration interval.
2470 */
2471#ifndef PJSUA_REG_INTERVAL
2472# define PJSUA_REG_INTERVAL 300
2473#endif
2474
2475
2476/**
2477 * Default maximum time to wait for account unregistration transactions to
2478 * complete during library shutdown sequence.
2479 *
2480 * Default: 4000 (4 seconds)
2481 */
2482#ifndef PJSUA_UNREG_TIMEOUT
2483# define PJSUA_UNREG_TIMEOUT 4000
2484#endif
2485
2486
2487/**
2488 * Default PUBLISH expiration
2489 */
2490#ifndef PJSUA_PUBLISH_EXPIRATION
2491# define PJSUA_PUBLISH_EXPIRATION PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED
2492#endif
2493
2494
2495/**
2496 * Default account priority.
2497 */
2498#ifndef PJSUA_DEFAULT_ACC_PRIORITY
2499# define PJSUA_DEFAULT_ACC_PRIORITY 0
2500#endif
2501
2502
2503/**
2504 * This macro specifies the URI scheme to use in Contact header
2505 * when secure transport such as TLS is used. Application can specify
2506 * either "sip" or "sips".
2507 */
2508#ifndef PJSUA_SECURE_SCHEME
2509# define PJSUA_SECURE_SCHEME "sip"
2510#endif
2511
2512
2513/**
2514 * Maximum time to wait for unpublication transaction(s) to complete
2515 * during shutdown process, before sending unregistration. The library
2516 * tries to wait for the unpublication (un-PUBLISH) to complete before
2517 * sending REGISTER request to unregister the account, during library
2518 * shutdown process. If the value is set too short, it is possible that
2519 * the unregistration is sent before unpublication completes, causing
2520 * unpublication request to fail.
2521 *
2522 * Default: 2000 (2 seconds)
2523 */
2524#ifndef PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
2525# define PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC 2000
2526#endif
2527
2528
2529/**
2530 * Default auto retry re-registration interval, in seconds. Set to 0
2531 * to disable this. Application can set the timer on per account basis
2532 * by setting the pjsua_acc_config.reg_retry_interval field instead.
2533 *
2534 * Default: 300 (5 minutes)
2535 */
2536#ifndef PJSUA_REG_RETRY_INTERVAL
2537# define PJSUA_REG_RETRY_INTERVAL 300
2538#endif
2539
2540
2541/**
2542 * This macro specifies the default value for \a contact_rewrite_method
2543 * field in pjsua_acc_config. I specifies how Contact update will be
2544 * done with the registration, if \a allow_contact_rewrite is enabled in
2545 * the account config.
2546 *
2547 * If set to 1, the Contact update will be done by sending unregistration
2548 * to the currently registered Contact, while simultaneously sending new
2549 * registration (with different Call-ID) for the updated Contact.
2550 *
2551 * If set to 2, the Contact update will be done in a single, current
2552 * registration session, by removing the current binding (by setting its
2553 * Contact's expires parameter to zero) and adding a new Contact binding,
2554 * all done in a single request.
2555 *
2556 * Value 1 is the legacy behavior.
2557 *
2558 * Default value: 2
2559 */
2560#ifndef PJSUA_CONTACT_REWRITE_METHOD
2561# define PJSUA_CONTACT_REWRITE_METHOD 2
2562#endif
2563
2564
2565/**
2566 * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that
2567 * the global outbound proxy list should be added to the REGISTER request.
2568 */
2569#define PJSUA_REG_USE_OUTBOUND_PROXY 1
2570
2571
2572/**
2573 * Bit value used in pjsua_acc_config.reg_use_proxy field to indicate that
2574 * the account proxy list should be added to the REGISTER request.
2575 */
2576#define PJSUA_REG_USE_ACC_PROXY 2
2577
2578
2579/**
2580 * This enumeration specifies how we should offer call hold request to
2581 * remote peer. The default value is set by compile time constant
2582 * PJSUA_CALL_HOLD_TYPE_DEFAULT, and application may control the setting
2583 * on per-account basis by manipulating \a call_hold_type field in
2584 * #pjsua_acc_config.
2585 */
2586typedef enum pjsua_call_hold_type
2587{
2588 /**
2589 * This will follow RFC 3264 recommendation to use a=sendonly,
2590 * a=recvonly, and a=inactive attribute as means to signal call
2591 * hold status. This is the correct value to use.
2592 */
2593 PJSUA_CALL_HOLD_TYPE_RFC3264,
2594
2595 /**
2596 * This will use the old and deprecated method as specified in RFC 2543,
2597 * and will offer c=0.0.0.0 in the SDP instead. Using this has many
2598 * drawbacks such as inability to keep the media transport alive while
2599 * the call is being put on hold, and should only be used if remote
2600 * does not understand RFC 3264 style call hold offer.
2601 */
2602 PJSUA_CALL_HOLD_TYPE_RFC2543
2603
2604} pjsua_call_hold_type;
2605
2606
2607/**
2608 * Specify the default call hold type to be used in #pjsua_acc_config.
2609 *
2610 * Default is PJSUA_CALL_HOLD_TYPE_RFC3264, and there's no reason to change
2611 * this except if you're communicating with an old/non-standard peer.
2612 */
2613#ifndef PJSUA_CALL_HOLD_TYPE_DEFAULT
2614# define PJSUA_CALL_HOLD_TYPE_DEFAULT PJSUA_CALL_HOLD_TYPE_RFC3264
2615#endif
2616
2617/**
2618 * This enumeration controls the use of STUN in the account.
2619 */
2620typedef enum pjsua_stun_use
2621{
2622 /**
2623 * Follow the default setting in the global \a pjsua_config.
2624 */
2625 PJSUA_STUN_USE_DEFAULT,
2626
2627 /**
2628 * Disable STUN. If STUN is not enabled in the global \a pjsua_config,
2629 * this setting has no effect.
2630 */
2631 PJSUA_STUN_USE_DISABLED
2632
2633} pjsua_stun_use;
2634
2635/**
2636 * This enumeration controls the use of ICE settings in the account.
2637 */
2638typedef enum pjsua_ice_config_use
2639{
2640 /**
2641 * Use the default settings in the global \a pjsua_media_config.
2642 */
2643 PJSUA_ICE_CONFIG_USE_DEFAULT,
2644
2645 /**
2646 * Use the custom \a pjsua_ice_config setting in the account.
2647 */
2648 PJSUA_ICE_CONFIG_USE_CUSTOM
2649
2650} pjsua_ice_config_use;
2651
2652/**
2653 * This enumeration controls the use of TURN settings in the account.
2654 */
2655typedef enum pjsua_turn_config_use
2656{
2657 /**
2658 * Use the default setting in the global \a pjsua_media_config.
2659 */
2660 PJSUA_TURN_CONFIG_USE_DEFAULT,
2661
2662 /**
2663 * Use the custom \a pjsua_turn_config setting in the account.
2664 */
2665 PJSUA_TURN_CONFIG_USE_CUSTOM
2666
2667} pjsua_turn_config_use;
2668
2669/**
2670 * ICE setting. This setting is used in the pjsua_acc_config.
2671 */
2672typedef struct pjsua_ice_config
2673{
2674 /**
2675 * Enable ICE.
2676 */
2677 pj_bool_t enable_ice;
2678
2679 /**
2680 * Set the maximum number of host candidates.
2681 *
2682 * Default: -1 (maximum not set)
2683 */
2684 int ice_max_host_cands;
2685
2686 /**
2687 * ICE session options.
2688 */
2689 pj_ice_sess_options ice_opt;
2690
2691 /**
2692 * Disable RTCP component.
2693 *
2694 * Default: no
2695 */
2696 pj_bool_t ice_no_rtcp;
2697
2698 /**
2699 * Send re-INVITE/UPDATE every after ICE connectivity check regardless
2700 * the default ICE transport address is changed or not. When this is set
2701 * to PJ_FALSE, re-INVITE/UPDATE will be sent only when the default ICE
2702 * transport address is changed.
2703 *
2704 * Default: yes
2705 */
2706 pj_bool_t ice_always_update;
2707
2708} pjsua_ice_config;
2709
2710/**
2711 * TURN setting. This setting is used in the pjsua_acc_config.
2712 */
2713typedef struct pjsua_turn_config
2714{
2715 /**
2716 * Enable TURN candidate in ICE.
2717 */
2718 pj_bool_t enable_turn;
2719
2720 /**
2721 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
2722 * "HOST:PORT" format.
2723 */
2724 pj_str_t turn_server;
2725
2726 /**
2727 * Specify the connection type to be used to the TURN server. Valid
2728 * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP.
2729 *
2730 * Default: PJ_TURN_TP_UDP
2731 */
2732 pj_turn_tp_type turn_conn_type;
2733
2734 /**
2735 * Specify the credential to authenticate with the TURN server.
2736 */
2737 pj_stun_auth_cred turn_auth_cred;
2738
2739} pjsua_turn_config;
2740
2741/**
2742 * Specify how IPv6 transport should be used in account config.
2743 */
2744typedef enum pjsua_ipv6_use
2745{
2746 /**
2747 * IPv6 is not used.
2748 */
2749 PJSUA_IPV6_DISABLED,
2750
2751 /**
2752 * IPv6 is enabled.
2753 */
2754 PJSUA_IPV6_ENABLED
2755
2756} pjsua_ipv6_use;
2757
2758/**
2759 * This structure describes account configuration to be specified when
2760 * adding a new account with #pjsua_acc_add(). Application MUST initialize
2761 * this structure first by calling #pjsua_acc_config_default().
2762 */
2763typedef struct pjsua_acc_config
2764{
2765 /**
2766 * Arbitrary user data to be associated with the newly created account.
2767 * Application may set this later with #pjsua_acc_set_user_data() and
2768 * retrieve it with #pjsua_acc_get_user_data().
2769 */
2770 void *user_data;
2771
2772 /**
2773 * Account priority, which is used to control the order of matching
2774 * incoming/outgoing requests. The higher the number means the higher
2775 * the priority is, and the account will be matched first.
2776 */
2777 int priority;
2778
2779 /**
2780 * The full SIP URL for the account. The value can take name address or
2781 * URL format, and will look something like "sip:account@serviceprovider"
2782 * or "\"Display Name\" <sip:account@provider>".
2783 *
2784 * This field is mandatory.
2785 */
2786 pj_str_t id;
2787
2788 /**
2789 * This is the URL to be put in the request URI for the registration,
2790 * and will look something like "sip:serviceprovider".
2791 *
2792 * This field should be specified if registration is desired. If the
2793 * value is empty, no account registration will be performed.
2794 */
2795 pj_str_t reg_uri;
2796
2797 /**
2798 * The optional custom SIP headers to be put in the registration
2799 * request.
2800 */
2801 pjsip_hdr reg_hdr_list;
2802
2803 /**
2804 * The optional custom SIP headers to be put in the presence
2805 * subscription request.
2806 */
2807 pjsip_hdr sub_hdr_list;
2808
2809 /**
2810 * Subscribe to message waiting indication events (RFC 3842).
2811 *
2812 * See also \a enable_unsolicited_mwi field on #pjsua_config.
2813 *
2814 * Default: no
2815 */
2816 pj_bool_t mwi_enabled;
2817
2818 /**
2819 * Specify the default expiration time for Message Waiting Indication
2820 * (RFC 3842) event subscription. This must not be zero.
2821 *
2822 * Default: PJSIP_MWI_DEFAULT_EXPIRES
2823 */
2824 unsigned mwi_expires;
2825
2826 /**
2827 * If this flag is set, the presence information of this account will
2828 * be PUBLISH-ed to the server where the account belongs.
2829 *
2830 * Default: PJ_FALSE
2831 */
2832 pj_bool_t publish_enabled;
2833
2834 /**
2835 * Event publication options.
2836 */
2837 pjsip_publishc_opt publish_opt;
2838
2839 /**
2840 * Maximum time to wait for unpublication transaction(s) to complete
2841 * during shutdown process, before sending unregistration. The library
2842 * tries to wait for the unpublication (un-PUBLISH) to complete before
2843 * sending REGISTER request to unregister the account, during library
2844 * shutdown process. If the value is set too short, it is possible that
2845 * the unregistration is sent before unpublication completes, causing
2846 * unpublication request to fail.
2847 *
2848 * Default: PJSUA_UNPUBLISH_MAX_WAIT_TIME_MSEC
2849 */
2850 unsigned unpublish_max_wait_time_msec;
2851
2852 /**
2853 * Authentication preference.
2854 */
2855 pjsip_auth_clt_pref auth_pref;
2856
2857 /**
2858 * Optional PIDF tuple ID for outgoing PUBLISH and NOTIFY. If this value
2859 * is not specified, a random string will be used.
2860 */
2861 pj_str_t pidf_tuple_id;
2862
2863 /**
2864 * Optional URI to be put as Contact for this account. It is recommended
2865 * that this field is left empty, so that the value will be calculated
2866 * automatically based on the transport address.
2867 */
2868 pj_str_t force_contact;
2869
2870 /**
2871 * Additional parameters that will be appended in the Contact header
2872 * for this account. This will affect the Contact header in all SIP
2873 * messages sent on behalf of this account, including but not limited to
2874 * REGISTER, INVITE, and SUBCRIBE requests or responses.
2875 *
2876 * The parameters should be preceeded by semicolon, and all strings must
2877 * be properly escaped. Example:
2878 * ";my-param=X;another-param=Hi%20there"
2879 */
2880 pj_str_t contact_params;
2881
2882 /**
2883 * Additional URI parameters that will be appended in the Contact URI
2884 * for this account. This will affect the Contact URI in all SIP
2885 * messages sent on behalf of this account, including but not limited to
2886 * REGISTER, INVITE, and SUBCRIBE requests or responses.
2887 *
2888 * The parameters should be preceeded by semicolon, and all strings must
2889 * be properly escaped. Example:
2890 * ";my-param=X;another-param=Hi%20there"
2891 */
2892 pj_str_t contact_uri_params;
2893
2894 /**
2895 * Specify how support for reliable provisional response (100rel/
2896 * PRACK) should be used for all sessions in this account. See the
2897 * documentation of pjsua_100rel_use enumeration for more info.
2898 *
2899 * Default: The default value is taken from the value of
2900 * require_100rel in pjsua_config.
2901 */
2902 pjsua_100rel_use require_100rel;
2903
2904 /**
2905 * Specify the usage of Session Timers for all sessions. See the
2906 * #pjsua_sip_timer_use for possible values.
2907 *
2908 * Default: PJSUA_SIP_TIMER_OPTIONAL
2909 */
2910 pjsua_sip_timer_use use_timer;
2911
2912 /**
2913 * Specify Session Timer settings, see #pjsip_timer_setting.
2914 */
2915 pjsip_timer_setting timer_setting;
2916
2917 /**
2918 * Number of proxies in the proxy array below.
2919 */
2920 unsigned proxy_cnt;
2921
2922 /**
2923 * Optional URI of the proxies to be visited for all outgoing requests
2924 * that are using this account (REGISTER, INVITE, etc). Application need
2925 * to specify these proxies if the service provider requires that requests
2926 * destined towards its network should go through certain proxies first
2927 * (for example, border controllers).
2928 *
2929 * These proxies will be put in the route set for this account, with
2930 * maintaining the orders (the first proxy in the array will be visited
2931 * first). If global outbound proxies are configured in pjsua_config,
2932 * then these account proxies will be placed after the global outbound
2933 * proxies in the routeset.
2934 */
2935 pj_str_t proxy[PJSUA_ACC_MAX_PROXIES];
2936
2937 /**
2938 * If remote sends SDP answer containing more than one format or codec in
2939 * the media line, send re-INVITE or UPDATE with just one codec to lock
2940 * which codec to use.
2941 *
2942 * Default: 1 (Yes). Set to zero to disable.
2943 */
2944 unsigned lock_codec;
2945
2946 /**
2947 * Optional interval for registration, in seconds. If the value is zero,
2948 * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
2949 */
2950 unsigned reg_timeout;
2951
2952 /**
2953 * Specify the number of seconds to refresh the client registration
2954 * before the registration expires.
2955 *
2956 * Default: PJSIP_REGISTER_CLIENT_DELAY_BEFORE_REFRESH, 5 seconds
2957 */
2958 unsigned reg_delay_before_refresh;
2959
2960 /**
2961 * Specify the maximum time to wait for unregistration requests to
2962 * complete during library shutdown sequence.
2963 *
2964 * Default: PJSUA_UNREG_TIMEOUT
2965 */
2966 unsigned unreg_timeout;
2967
2968 /**
2969 * Number of credentials in the credential array.
2970 */
2971 unsigned cred_count;
2972
2973 /**
2974 * Array of credentials. If registration is desired, normally there should
2975 * be at least one credential specified, to successfully authenticate
2976 * against the service provider. More credentials can be specified, for
2977 * example when the requests are expected to be challenged by the
2978 * proxies in the route set.
2979 */
2980 pjsip_cred_info cred_info[PJSUA_ACC_MAX_PROXIES];
2981
2982 /**
2983 * Optionally bind this account to specific transport. This normally is
2984 * not a good idea, as account should be able to send requests using
2985 * any available transports according to the destination. But some
2986 * application may want to have explicit control over the transport to
2987 * use, so in that case it can set this field.
2988 *
2989 * Default: -1 (PJSUA_INVALID_ID)
2990 *
2991 * @see pjsua_acc_set_transport()
2992 */
2993 pjsua_transport_id transport_id;
2994
2995 /**
2996 * This option is used to update the transport address and the Contact
2997 * header of REGISTER request. When this option is enabled, the library
2998 * will keep track of the public IP address from the response of REGISTER
2999 * request. Once it detects that the address has changed, it will
3000 * unregister current Contact, update the Contact with transport address
3001 * learned from Via header, and register a new Contact to the registrar.
3002 * This will also update the public name of UDP transport if STUN is
3003 * configured.
3004 *
3005 * See also contact_rewrite_method field.
3006 *
3007 * Default: 1 (yes)
3008 */
3009 pj_bool_t allow_contact_rewrite;
3010
3011 /**
3012 * Specify how Contact update will be done with the registration, if
3013 * \a allow_contact_rewrite is enabled.
3014 *
3015 * If set to 1, the Contact update will be done by sending unregistration
3016 * to the currently registered Contact, while simultaneously sending new
3017 * registration (with different Call-ID) for the updated Contact.
3018 *
3019 * If set to 2, the Contact update will be done in a single, current
3020 * registration session, by removing the current binding (by setting its
3021 * Contact's expires parameter to zero) and adding a new Contact binding,
3022 * all done in a single request.
3023 *
3024 * Value 1 is the legacy behavior.
3025 *
3026 * Default value: PJSUA_CONTACT_REWRITE_METHOD (2)
3027 */
3028 int contact_rewrite_method;
3029
3030 /**
3031 * This option is used to overwrite the "sent-by" field of the Via header
3032 * for outgoing messages with the same interface address as the one in
3033 * the REGISTER request, as long as the request uses the same transport
3034 * instance as the previous REGISTER request.
3035 *
3036 * Default: 1 (yes)
3037 */
3038 pj_bool_t allow_via_rewrite;
3039
3040 /**
3041 * This option controls whether the IP address in SDP should be replaced
3042 * with the IP address found in Via header of the REGISTER response, ONLY
3043 * when STUN and ICE are not used. If the value is FALSE (the original
3044 * behavior), then the local IP address will be used. If TRUE, and when
3045 * STUN and ICE are disabled, then the IP address found in registration
3046 * response will be used.
3047 *
3048 * Default: PJ_FALSE (no)
3049 */
3050 pj_bool_t allow_sdp_nat_rewrite;
3051
3052 /**
3053 * Control the use of SIP outbound feature. SIP outbound is described in
3054 * RFC 5626 to enable proxies or registrar to send inbound requests back
3055 * to UA using the same connection initiated by the UA for its
3056 * registration. This feature is highly useful in NAT-ed deployemtns,
3057 * hence it is enabled by default.
3058 *
3059 * Note: currently SIP outbound can only be used with TCP and TLS
3060 * transports. If UDP is used for the registration, the SIP outbound
3061 * feature will be silently ignored for the account.
3062 *
3063 * Default: PJ_TRUE
3064 */
3065 unsigned use_rfc5626;
3066
3067 /**
3068 * Specify SIP outbound (RFC 5626) instance ID to be used by this
3069 * application. If empty, an instance ID will be generated based on
3070 * the hostname of this agent. If application specifies this parameter, the
3071 * value will look like "<urn:uuid:00000000-0000-1000-8000-AABBCCDDEEFF>"
3072 * without the doublequote.
3073 *
3074 * Default: empty
3075 */
3076 pj_str_t rfc5626_instance_id;
3077
3078 /**
3079 * Specify SIP outbound (RFC 5626) registration ID. The default value
3080 * is empty, which would cause the library to automatically generate
3081 * a suitable value.
3082 *
3083 * Default: empty
3084 */
3085 pj_str_t rfc5626_reg_id;
3086
3087 /**
3088 * Set the interval for periodic keep-alive transmission for this account.
3089 * If this value is zero, keep-alive will be disabled for this account.
3090 * The keep-alive transmission will be sent to the registrar's address,
3091 * after successful registration.
3092 *
3093 * Default: 15 (seconds)
3094 */
3095 unsigned ka_interval;
3096
3097 /**
3098 * Specify the data to be transmitted as keep-alive packets.
3099 *
3100 * Default: CR-LF
3101 */
3102 pj_str_t ka_data;
3103
3104 /**
3105 * Specify whether incoming video should be shown to screen by default.
3106 * This applies to incoming call (INVITE), incoming re-INVITE, and
3107 * incoming UPDATE requests.
3108 *
3109 * Regardless of this setting, application can detect incoming video
3110 * by implementing \a on_call_media_state() callback and enumerating
3111 * the media stream(s) with #pjsua_call_get_info(). Once incoming
3112 * video is recognised, application may retrieve the window associated
3113 * with the incoming video and show or hide it with
3114 * #pjsua_vid_win_set_show().
3115 *
3116 * Default: PJ_FALSE
3117 */
3118 pj_bool_t vid_in_auto_show;
3119
3120 /**
3121 * Specify whether outgoing video should be activated by default when
3122 * making outgoing calls and/or when incoming video is detected. This
3123 * applies to incoming and outgoing calls, incoming re-INVITE, and
3124 * incoming UPDATE. If the setting is non-zero, outgoing video
3125 * transmission will be started as soon as response to these requests
3126 * is sent (or received).
3127 *
3128 * Regardless of the value of this setting, application can start and
3129 * stop outgoing video transmission with #pjsua_call_set_vid_strm().
3130 *
3131 * Default: PJ_FALSE
3132 */
3133 pj_bool_t vid_out_auto_transmit;
3134
3135 /**
3136 * Specify video window's flags. The value is a bitmask combination of
3137 * #pjmedia_vid_dev_wnd_flag.
3138 *
3139 * Default: 0
3140 */
3141 unsigned vid_wnd_flags;
3142
3143 /**
3144 * Specify the default capture device to be used by this account. If
3145 * \a vid_out_auto_transmit is enabled, this device will be used for
3146 * capturing video.
3147 *
3148 * Default: PJMEDIA_VID_DEFAULT_CAPTURE_DEV
3149 */
3150 pjmedia_vid_dev_index vid_cap_dev;
3151
3152 /**
3153 * Specify the default rendering device to be used by this account.
3154 *
3155 * Default: PJMEDIA_VID_DEFAULT_RENDER_DEV
3156 */
3157 pjmedia_vid_dev_index vid_rend_dev;
3158
3159 /**
3160 * Specify the send rate control for video stream.
3161 *
3162 * Default: see #pjmedia_vid_stream_rc_config
3163 */
3164 pjmedia_vid_stream_rc_config vid_stream_rc_cfg;
3165
3166 /**
3167 * Media transport config.
3168 */
3169 pjsua_transport_config rtp_cfg;
3170
3171 /**
3172 * Specify whether IPv6 should be used on media.
3173 */
3174 pjsua_ipv6_use ipv6_media_use;
3175
3176 /**
3177 * Control the use of STUN for the SIP signaling.
3178 *
3179 * Default: PJSUA_STUN_USE_DEFAULT
3180 */
3181 pjsua_stun_use sip_stun_use;
3182
3183 /**
3184 * Control the use of STUN for the media transports.
3185 *
3186 * Default: PJSUA_STUN_USE_DEFAULT
3187 */
3188 pjsua_stun_use media_stun_use;
3189
3190 /**
3191 * Control the use of ICE in the account. By default, the settings in the
3192 * \a pjsua_media_config will be used.
3193 *
3194 * Default: PJSUA_ICE_CONFIG_USE_DEFAULT
3195 */
3196 pjsua_ice_config_use ice_cfg_use;
3197
3198 /**
3199 * The custom ICE setting for this account. This setting will only be
3200 * used if \a ice_cfg_use is set to PJSUA_ICE_CONFIG_USE_CUSTOM
3201 */
3202 pjsua_ice_config ice_cfg;
3203
3204 /**
3205 * Control the use of TURN in the account. By default, the settings in the
3206 * \a pjsua_media_config will be used
3207 *
3208 * Default: PJSUA_TURN_CONFIG_USE_DEFAULT
3209 */
3210 pjsua_turn_config_use turn_cfg_use;
3211
3212 /**
3213 * The custom TURN setting for this account. This setting will only be
3214 * used if \a turn_cfg_use is set to PJSUA_TURN_CONFIG_USE_CUSTOM
3215 */
3216 pjsua_turn_config turn_cfg;
3217
3218 /**
3219 * Specify whether secure media transport should be used for this account.
3220 * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
3221 * PJMEDIA_SRTP_MANDATORY.
3222 *
3223 * Default: #PJSUA_DEFAULT_USE_SRTP
3224 */
3225 pjmedia_srtp_use use_srtp;
3226
3227 /**
3228 * Specify whether SRTP requires secure signaling to be used. This option
3229 * is only used when \a use_srtp option above is non-zero.
3230 *
3231 * Valid values are:
3232 * 0: SRTP does not require secure signaling
3233 * 1: SRTP requires secure transport such as TLS
3234 * 2: SRTP requires secure end-to-end transport (SIPS)
3235 *
3236 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING
3237 */
3238 int srtp_secure_signaling;
3239
3240 /**
3241 * This setting has been deprecated and will be ignored.
3242 */
3243 pj_bool_t srtp_optional_dup_offer;
3244
3245 /**
3246 * Specify interval of auto registration retry upon registration failure
3247 * (including caused by transport problem), in second. Set to 0 to
3248 * disable auto re-registration. Note that if the registration retry
3249 * occurs because of transport failure, the first retry will be done
3250 * after \a reg_first_retry_interval seconds instead. Also note that
3251 * the interval will be randomized slightly by approximately +/- ten
3252 * seconds to avoid all clients re-registering at the same time.
3253 *
3254 * See also \a reg_first_retry_interval setting.
3255 *
3256 * Default: #PJSUA_REG_RETRY_INTERVAL
3257 */
3258 unsigned reg_retry_interval;
3259
3260 /**
3261 * This specifies the interval for the first registration retry. The
3262 * registration retry is explained in \a reg_retry_interval. Note that
3263 * the value here will also be randomized by +/- ten seconds.
3264 *
3265 * Default: 0
3266 */
3267 unsigned reg_first_retry_interval;
3268
3269 /**
3270 * Specify whether calls of the configured account should be dropped
3271 * after registration failure and an attempt of re-registration has
3272 * also failed.
3273 *
3274 * Default: PJ_FALSE (disabled)
3275 */
3276 pj_bool_t drop_calls_on_reg_fail;
3277
3278 /**
3279 * Specify how the registration uses the outbound and account proxy
3280 * settings. This controls if and what Route headers will appear in
3281 * the REGISTER request of this account. The value is bitmask combination
3282 * of PJSUA_REG_USE_OUTBOUND_PROXY and PJSUA_REG_USE_ACC_PROXY bits.
3283 * If the value is set to 0, the REGISTER request will not use any proxy
3284 * (i.e. it will not have any Route headers).
3285 *
3286 * Default: 3 (PJSUA_REG_USE_OUTBOUND_PROXY | PJSUA_REG_USE_ACC_PROXY)
3287 */
3288 unsigned reg_use_proxy;
3289
3290#if defined(PJMEDIA_STREAM_ENABLE_KA) && (PJMEDIA_STREAM_ENABLE_KA != 0)
3291 /**
3292 * Specify whether stream keep-alive and NAT hole punching with
3293 * non-codec-VAD mechanism (see @ref PJMEDIA_STREAM_ENABLE_KA) is enabled
3294 * for this account.
3295 *
3296 * Default: PJ_FALSE (disabled)
3297 */
3298 pj_bool_t use_stream_ka;
3299#endif
3300
3301 /**
3302 * Specify how to offer call hold to remote peer. Please see the
3303 * documentation on #pjsua_call_hold_type for more info.
3304 *
3305 * Default: PJSUA_CALL_HOLD_TYPE_DEFAULT
3306 */
3307 pjsua_call_hold_type call_hold_type;
3308
3309
3310 /**
3311 * Specify whether the account should register as soon as it is
3312 * added to the UA. Application can set this to PJ_FALSE and control
3313 * the registration manually with pjsua_acc_set_registration().
3314 *
3315 * Default: PJ_TRUE
3316 */
3317 pj_bool_t register_on_acc_add;
3318
3319} pjsua_acc_config;
3320
3321
3322/**
3323 * Initialize ICE config from a media config. If the \a pool argument
3324 * is NULL, a simple memcpy() will be used.
3325 *
3326 * @param pool Memory to duplicate strings.
3327 * @param dst Destination config.
3328 * @param src Source config.
3329 */
3330PJ_DECL(void) pjsua_ice_config_from_media_config(pj_pool_t *pool,
3331 pjsua_ice_config *dst,
3332 const pjsua_media_config *src);
3333
3334/**
3335 * Clone. If the \a pool argument is NULL, a simple memcpy() will be used.
3336 *
3337 * @param pool Memory to duplicate strings.
3338 * @param dst Destination config.
3339 * @param src Source config.
3340 */
3341PJ_DECL(void) pjsua_ice_config_dup( pj_pool_t *pool,
3342 pjsua_ice_config *dst,
3343 const pjsua_ice_config *src);
3344
3345/**
3346 * Initialize TURN config from a media config. If the \a pool argument
3347 * is NULL, a simple memcpy() will be used.
3348 *
3349 * @param pool Memory to duplicate strings.
3350 * @param dst Destination config.
3351 * @param src Source config.
3352 */
3353PJ_DECL(void) pjsua_turn_config_from_media_config(pj_pool_t *pool,
3354 pjsua_turn_config *dst,
3355 const pjsua_media_config *src);
3356
3357/**
3358 * Clone. If the \a pool argument is NULL, a simple memcpy() will be used.
3359 *
3360 * @param pool Memory to duplicate strings.
3361 * @param dst Destination config.
3362 * @param src Source config.
3363 */
3364PJ_DECL(void) pjsua_turn_config_dup(pj_pool_t *pool,
3365 pjsua_turn_config *dst,
3366 const pjsua_turn_config *src);
3367
3368/**
3369 * Call this function to initialize account config with default values.
3370 *
3371 * @param cfg The account config to be initialized.
3372 */
3373PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg);
3374
3375
3376/**
3377 * Duplicate account config.
3378 *
3379 * @param pool Pool to be used for duplicating the config.
3380 * @param dst Destination configuration.
3381 * @param src Source configuration.
3382 */
3383PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
3384 pjsua_acc_config *dst,
3385 const pjsua_acc_config *src);
3386
3387
3388/**
3389 * Account info. Application can query account info by calling
3390 * #pjsua_acc_get_info().
3391 */
3392typedef struct pjsua_acc_info
3393{
3394 /**
3395 * The account ID.
3396 */
3397 pjsua_acc_id id;
3398
3399 /**
3400 * Flag to indicate whether this is the default account.
3401 */
3402 pj_bool_t is_default;
3403
3404 /**
3405 * Account URI
3406 */
3407 pj_str_t acc_uri;
3408
3409 /**
3410 * Flag to tell whether this account has registration setting
3411 * (reg_uri is not empty).
3412 */
3413 pj_bool_t has_registration;
3414
3415 /**
3416 * An up to date expiration interval for account registration session.
3417 */
3418 int expires;
3419
3420 /**
3421 * Last registration status code. If status code is zero, the account
3422 * is currently not registered. Any other value indicates the SIP
3423 * status code of the registration.
3424 */
3425 pjsip_status_code status;
3426
3427 /**
3428 * Last registration error code. When the status field contains a SIP
3429 * status code that indicates a registration failure, last registration
3430 * error code contains the error code that causes the failure. In any
3431 * other case, its value is zero.
3432 */
3433 pj_status_t reg_last_err;
3434
3435 /**
3436 * String describing the registration status.
3437 */
3438 pj_str_t status_text;
3439
3440 /**
3441 * Presence online status for this account.
3442 */
3443 pj_bool_t online_status;
3444
3445 /**
3446 * Presence online status text.
3447 */
3448 pj_str_t online_status_text;
3449
3450 /**
3451 * Extended RPID online status information.
3452 */
3453 pjrpid_element rpid;
3454
3455 /**
3456 * Buffer that is used internally to store the status text.
3457 */
3458 char buf_[PJ_ERR_MSG_SIZE];
3459
3460} pjsua_acc_info;
3461
3462
3463
3464/**
3465 * Get number of current accounts.
3466 *
3467 * @return Current number of accounts.
3468 */
3469PJ_DECL(unsigned) pjsua_acc_get_count(void);
3470
3471
3472/**
3473 * Check if the specified account ID is valid.
3474 *
3475 * @param acc_id Account ID to check.
3476 *
3477 * @return Non-zero if account ID is valid.
3478 */
3479PJ_DECL(pj_bool_t) pjsua_acc_is_valid(pjsua_acc_id acc_id);
3480
3481
3482/**
3483 * Set default account to be used when incoming and outgoing
3484 * requests doesn't match any accounts.
3485 *
3486 * @param acc_id The account ID to be used as default.
3487 *
3488 * @return PJ_SUCCESS on success.
3489 */
3490PJ_DECL(pj_status_t) pjsua_acc_set_default(pjsua_acc_id acc_id);
3491
3492
3493/**
3494 * Get default account to be used when receiving incoming requests (calls),
3495 * when the destination of the incoming call doesn't match any other
3496 * accounts.
3497 *
3498 * @return The default account ID, or PJSUA_INVALID_ID if no
3499 * default account is configured.
3500 */
3501PJ_DECL(pjsua_acc_id) pjsua_acc_get_default(void);
3502
3503
3504/**
3505 * Add a new account to pjsua. PJSUA must have been initialized (with
3506 * #pjsua_init()) before calling this function. If registration is configured
3507 * for this account, this function would also start the SIP registration
3508 * session with the SIP registrar server. This SIP registration session
3509 * will be maintained internally by the library, and application doesn't
3510 * need to do anything to maintain the registration session.
3511 *
3512 *
3513 * @param acc_cfg Account configuration.
3514 * @param is_default If non-zero, this account will be set as the default
3515 * account. The default account will be used when sending
3516 * outgoing requests (e.g. making call) when no account is
3517 * specified, and when receiving incoming requests when the
3518 * request does not match any accounts. It is recommended
3519 * that default account is set to local/LAN account.
3520 * @param p_acc_id Pointer to receive account ID of the new account.
3521 *
3522 * @return PJ_SUCCESS on success, or the appropriate error code.
3523 */
3524PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *acc_cfg,
3525 pj_bool_t is_default,
3526 pjsua_acc_id *p_acc_id);
3527
3528
3529/**
3530 * Add a local account. A local account is used to identify local endpoint
3531 * instead of a specific user, and for this reason, a transport ID is needed
3532 * to obtain the local address information.
3533 *
3534 * @param tid Transport ID to generate account address.
3535 * @param is_default If non-zero, this account will be set as the default
3536 * account. The default account will be used when sending
3537 * outgoing requests (e.g. making call) when no account is
3538 * specified, and when receiving incoming requests when the
3539 * request does not match any accounts. It is recommended
3540 * that default account is set to local/LAN account.
3541 * @param p_acc_id Pointer to receive account ID of the new account.
3542 *
3543 * @return PJ_SUCCESS on success, or the appropriate error code.
3544 */
3545PJ_DECL(pj_status_t) pjsua_acc_add_local(pjsua_transport_id tid,
3546 pj_bool_t is_default,
3547 pjsua_acc_id *p_acc_id);
3548
3549/**
3550 * Set arbitrary data to be associated with the account.
3551 *
3552 * @param acc_id The account ID.
3553 * @param user_data User/application data.
3554 *
3555 * @return PJ_SUCCESS on success, or the appropriate error code.
3556 */
3557PJ_DECL(pj_status_t) pjsua_acc_set_user_data(pjsua_acc_id acc_id,
3558 void *user_data);
3559
3560
3561/**
3562 * Retrieve arbitrary data associated with the account.
3563 *
3564 * @param acc_id The account ID.
3565 *
3566 * @return The user data. In the case where the account ID is
3567 * not valid, NULL is returned.
3568 */
3569PJ_DECL(void*) pjsua_acc_get_user_data(pjsua_acc_id acc_id);
3570
3571
3572/**
3573 * Delete an account. This will unregister the account from the SIP server,
3574 * if necessary, and terminate server side presence subscriptions associated
3575 * with this account.
3576 *
3577 * @param acc_id Id of the account to be deleted.
3578 *
3579 * @return PJ_SUCCESS on success, or the appropriate error code.
3580 */
3581PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
3582
3583
3584/**
3585 * Get current config for the account. This will copy current account setting
3586 * to the specified parameter. Note that all pointers in the settings will
3587 * point to the original settings in the account and application must not
3588 * modify the values in any way. Application must also take care that these
3589 * data is only valid until the account is destroyed.
3590 *
3591 * @param acc_id The account ID.
3592 * @param acc_cfg Structure to receive the settings.
3593 *
3594 * @return PJ_SUCCESS on success, or the appropriate error code.
3595 */
3596PJ_DECL(pj_status_t) pjsua_acc_get_config(pjsua_acc_id acc_id,
3597 pjsua_acc_config *acc_cfg);
3598
3599
3600/**
3601 * Modify account information.
3602 *
3603 * @param acc_id Id of the account to be modified.
3604 * @param acc_cfg New account configuration.
3605 *
3606 * @return PJ_SUCCESS on success, or the appropriate error code.
3607 */
3608PJ_DECL(pj_status_t) pjsua_acc_modify(pjsua_acc_id acc_id,
3609 const pjsua_acc_config *acc_cfg);
3610
3611
3612/**
3613 * Modify account's presence status to be advertised to remote/presence
3614 * subscribers. This would trigger the sending of outgoing NOTIFY request
3615 * if there are server side presence subscription for this account, and/or
3616 * outgoing PUBLISH if presence publication is enabled for this account.
3617 *
3618 * @see pjsua_acc_set_online_status2()
3619 *
3620 * @param acc_id The account ID.
3621 * @param is_online True of false.
3622 *
3623 * @return PJ_SUCCESS on success, or the appropriate error code.
3624 */
3625PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
3626 pj_bool_t is_online);
3627
3628/**
3629 * Modify account's presence status to be advertised to remote/presence
3630 * subscribers. This would trigger the sending of outgoing NOTIFY request
3631 * if there are server side presence subscription for this account, and/or
3632 * outgoing PUBLISH if presence publication is enabled for this account.
3633 *
3634 * @see pjsua_acc_set_online_status()
3635 *
3636 * @param acc_id The account ID.
3637 * @param is_online True of false.
3638 * @param pr Extended information in subset of RPID format
3639 * which allows setting custom presence text.
3640 *
3641 * @return PJ_SUCCESS on success, or the appropriate error code.
3642 */
3643PJ_DECL(pj_status_t) pjsua_acc_set_online_status2(pjsua_acc_id acc_id,
3644 pj_bool_t is_online,
3645 const pjrpid_element *pr);
3646
3647/**
3648 * Update registration or perform unregistration. If registration is
3649 * configured for this account, then initial SIP REGISTER will be sent
3650 * when the account is added with #pjsua_acc_add(). Application normally
3651 * only need to call this function if it wants to manually update the
3652 * registration or to unregister from the server.
3653 *
3654 * @param acc_id The account ID.
3655 * @param renew If renew argument is zero, this will start
3656 * unregistration process.
3657 *
3658 * @return PJ_SUCCESS on success, or the appropriate error code.
3659 */
3660PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id,
3661 pj_bool_t renew);
3662
3663/**
3664 * Get information about the specified account.
3665 *
3666 * @param acc_id Account identification.
3667 * @param info Pointer to receive account information.
3668 *
3669 * @return PJ_SUCCESS on success, or the appropriate error code.
3670 */
3671PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
3672 pjsua_acc_info *info);
3673
3674
3675/**
3676 * Enumerate all account currently active in the library. This will fill
3677 * the array with the account Ids, and application can then query the
3678 * account information for each id with #pjsua_acc_get_info().
3679 *
3680 * @see pjsua_acc_enum_info().
3681 *
3682 * @param ids Array of account IDs to be initialized.
3683 * @param count In input, specifies the maximum number of elements.
3684 * On return, it contains the actual number of elements.
3685 *
3686 * @return PJ_SUCCESS on success, or the appropriate error code.
3687 */
3688PJ_DECL(pj_status_t) pjsua_enum_accs(pjsua_acc_id ids[],
3689 unsigned *count );
3690
3691
3692/**
3693 * Enumerate account informations.
3694 *
3695 * @param info Array of account infos to be initialized.
3696 * @param count In input, specifies the maximum number of elements.
3697 * On return, it contains the actual number of elements.
3698 *
3699 * @return PJ_SUCCESS on success, or the appropriate error code.
3700 */
3701PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
3702 unsigned *count );
3703
3704
3705/**
3706 * This is an internal function to find the most appropriate account to
3707 * used to reach to the specified URL.
3708 *
3709 * @param url The remote URL to reach.
3710 *
3711 * @return Account id.
3712 */
3713PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
3714
3715
3716/**
3717 * This is an internal function to find the most appropriate account to be
3718 * used to handle incoming calls.
3719 *
3720 * @param rdata The incoming request message.
3721 *
3722 * @return Account id.
3723 */
3724PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
3725
3726
3727/**
3728 * Create arbitrary requests using the account. Application should only use
3729 * this function to create auxiliary requests outside dialog, such as
3730 * OPTIONS, and use the call or presence API to create dialog related
3731 * requests.
3732 *
3733 * @param acc_id The account ID.
3734 * @param method The SIP method of the request.
3735 * @param target Target URI.
3736 * @param p_tdata Pointer to receive the request.
3737 *
3738 * @return PJ_SUCCESS or the error code.
3739 */
3740PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id,
3741 const pjsip_method *method,
3742 const pj_str_t *target,
3743 pjsip_tx_data **p_tdata);
3744
3745
3746/**
3747 * Create a suitable Contact header value, based on the specified target URI
3748 * for the specified account.
3749 *
3750 * @param pool Pool to allocate memory for the string.
3751 * @param contact The string where the Contact will be stored.
3752 * @param acc_id Account ID.
3753 * @param uri Destination URI of the request.
3754 *
3755 * @return PJ_SUCCESS on success, other on error.
3756 */
3757PJ_DECL(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool,
3758 pj_str_t *contact,
3759 pjsua_acc_id acc_id,
3760 const pj_str_t *uri);
3761
3762
3763
3764/**
3765 * Create a suitable Contact header value, based on the information in the
3766 * incoming request.
3767 *
3768 * @param pool Pool to allocate memory for the string.
3769 * @param contact The string where the Contact will be stored.
3770 * @param acc_id Account ID.
3771 * @param rdata Incoming request.
3772 *
3773 * @return PJ_SUCCESS on success, other on error.
3774 */
3775PJ_DECL(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool,
3776 pj_str_t *contact,
3777 pjsua_acc_id acc_id,
3778 pjsip_rx_data *rdata );
3779
3780
3781/**
3782 * Lock/bind this account to a specific transport/listener. Normally
3783 * application shouldn't need to do this, as transports will be selected
3784 * automatically by the stack according to the destination.
3785 *
3786 * When account is locked/bound to a specific transport, all outgoing
3787 * requests from this account will use the specified transport (this
3788 * includes SIP registration, dialog (call and event subscription), and
3789 * out-of-dialog requests such as MESSAGE).
3790 *
3791 * Note that transport_id may be specified in pjsua_acc_config too.
3792 *
3793 * @param acc_id The account ID.
3794 * @param tp_id The transport ID.
3795 *
3796 * @return PJ_SUCCESS on success.
3797 */
3798PJ_DECL(pj_status_t) pjsua_acc_set_transport(pjsua_acc_id acc_id,
3799 pjsua_transport_id tp_id);
3800
3801
3802/**
3803 * @}
3804 */
3805
3806
3807/*****************************************************************************
3808 * CALLS API
3809 */
3810
3811
3812/**
3813 * @defgroup PJSUA_LIB_CALL PJSUA-API Calls Management
3814 * @ingroup PJSUA_LIB
3815 * @brief Call manipulation.
3816 * @{
3817 */
3818
3819/**
3820 * Maximum simultaneous calls.
3821 */
3822#ifndef PJSUA_MAX_CALLS
3823# define PJSUA_MAX_CALLS 32
3824#endif
3825
3826/**
3827 * Maximum active video windows
3828 */
3829#ifndef PJSUA_MAX_VID_WINS
3830# define PJSUA_MAX_VID_WINS 16
3831#endif
3832
3833/**
3834 * Video window ID.
3835 */
3836typedef int pjsua_vid_win_id;
3837
3838
3839/**
3840 * This enumeration specifies the media status of a call, and it's part
3841 * of pjsua_call_info structure.
3842 */
3843typedef enum pjsua_call_media_status
3844{
3845 /**
3846 * Call currently has no media, or the media is not used.
3847 */
3848 PJSUA_CALL_MEDIA_NONE,
3849
3850 /**
3851 * The media is active
3852 */
3853 PJSUA_CALL_MEDIA_ACTIVE,
3854
3855 /**
3856 * The media is currently put on hold by local endpoint
3857 */
3858 PJSUA_CALL_MEDIA_LOCAL_HOLD,
3859
3860 /**
3861 * The media is currently put on hold by remote endpoint
3862 */
3863 PJSUA_CALL_MEDIA_REMOTE_HOLD,
3864
3865 /**
3866 * The media has reported error (e.g. ICE negotiation)
3867 */
3868 PJSUA_CALL_MEDIA_ERROR
3869
3870} pjsua_call_media_status;
3871
3872
3873/**
3874 * Enumeration of video keyframe request methods. Keyframe request is
3875 * triggered by decoder, usually when the incoming video stream cannot
3876 * be decoded properly due to missing video keyframe.
3877 */
3878typedef enum pjsua_vid_req_keyframe_method
3879{
3880 /**
3881 * Requesting keyframe via SIP INFO message. Note that incoming keyframe
3882 * request via SIP INFO will always be handled even if this flag is unset.
3883 */
3884 PJSUA_VID_REQ_KEYFRAME_SIP_INFO = 1,
3885
3886 /**
3887 * Requesting keyframe via Picture Loss Indication of RTCP feedback.
3888 * This is currently not supported.
3889 */
3890 PJSUA_VID_REQ_KEYFRAME_RTCP_PLI = 2
3891
3892} pjsua_vid_req_keyframe_method;
3893
3894
3895/**
3896 * Call media information.
3897 */
3898typedef struct pjsua_call_media_info
3899{
3900 /** Media index in SDP. */
3901 unsigned index;
3902
3903 /** Media type. */
3904 pjmedia_type type;
3905
3906 /** Media direction. */
3907 pjmedia_dir dir;
3908
3909 /** Call media status. */
3910 pjsua_call_media_status status;
3911
3912 /** The specific media stream info. */
3913 union {
3914 /** Audio stream */
3915 struct {
3916 /** The conference port number for the call. */
3917 pjsua_conf_port_id conf_slot;
3918 } aud;
3919
3920 /** Video stream */
3921 struct {
3922 /**
3923 * The window id for incoming video, if any, or
3924 * PJSUA_INVALID_ID.
3925 */
3926 pjsua_vid_win_id win_in;
3927
3928 /** The video capture device for outgoing transmission,
3929 * if any, or PJMEDIA_VID_INVALID_DEV
3930 */
3931 pjmedia_vid_dev_index cap_dev;
3932
3933 } vid;
3934 } stream;
3935
3936} pjsua_call_media_info;
3937
3938
3939/**
3940 * This structure describes the information and current status of a call.
3941 */
3942typedef struct pjsua_call_info
3943{
3944 /** Call identification. */
3945 pjsua_call_id id;
3946
3947 /** Initial call role (UAC == caller) */
3948 pjsip_role_e role;
3949
3950 /** The account ID where this call belongs. */
3951 pjsua_acc_id acc_id;
3952
3953 /** Local URI */
3954 pj_str_t local_info;
3955
3956 /** Local Contact */
3957 pj_str_t local_contact;
3958
3959 /** Remote URI */
3960 pj_str_t remote_info;
3961
3962 /** Remote contact */
3963 pj_str_t remote_contact;
3964
3965 /** Dialog Call-ID string. */
3966 pj_str_t call_id;
3967
3968 /** Call setting */
3969 pjsua_call_setting setting;
3970
3971 /** Call state */
3972 pjsip_inv_state state;
3973
3974 /** Text describing the state */
3975 pj_str_t state_text;
3976
3977 /** Last status code heard, which can be used as cause code */
3978 pjsip_status_code last_status;
3979
3980 /** The reason phrase describing the status. */
3981 pj_str_t last_status_text;
3982
3983 /** Media status of the first audio stream. */
3984 pjsua_call_media_status media_status;
3985
3986 /** Media direction of the first audio stream. */
3987 pjmedia_dir media_dir;
3988
3989 /** The conference port number for the first audio stream. */
3990 pjsua_conf_port_id conf_slot;
3991
3992 /** Number of active media info in this call. */
3993 unsigned media_cnt;
3994
3995 /** Array of active media information. */
3996 pjsua_call_media_info media[PJMEDIA_MAX_SDP_MEDIA];
3997
3998 /** Number of provisional media info in this call. */
3999 unsigned prov_media_cnt;
4000
4001 /** Array of provisional media information. This contains the media info
4002 * in the provisioning state, that is when the media session is being
4003 * created/updated (SDP offer/answer is on progress).
4004 */
4005 pjsua_call_media_info prov_media[PJMEDIA_MAX_SDP_MEDIA];
4006
4007 /** Up-to-date call connected duration (zero when call is not
4008 * established)
4009 */
4010 pj_time_val connect_duration;
4011
4012 /** Total call duration, including set-up time */
4013 pj_time_val total_duration;
4014
4015 /** Flag if remote was SDP offerer */
4016 pj_bool_t rem_offerer;
4017
4018 /** Number of audio streams offered by remote */
4019 unsigned rem_aud_cnt;
4020
4021 /** Number of video streams offered by remote */
4022 unsigned rem_vid_cnt;
4023
4024 /** Internal */
4025 struct {
4026 char local_info[128];
4027 char local_contact[128];
4028 char remote_info[128];
4029 char remote_contact[128];
4030 char call_id[128];
4031 char last_status_text[128];
4032 } buf_;
4033
4034} pjsua_call_info;
4035
4036/**
4037 * Flags to be given to various call APIs. More than one flags may be
4038 * specified by bitmasking them.
4039 */
4040typedef enum pjsua_call_flag
4041{
4042 /**
4043 * When the call is being put on hold, specify this flag to unhold it.
4044 * This flag is only valid for #pjsua_call_reinvite(). Note: for
4045 * compatibility reason, this flag must have value of 1 because
4046 * previously the unhold option is specified as boolean value.
4047 */
4048 PJSUA_CALL_UNHOLD = 1,
4049
4050 /**
4051 * Update the local invite session's contact with the contact URI from
4052 * the account. This flag is only valid for #pjsua_call_set_hold2(),
4053 * #pjsua_call_reinvite() and #pjsua_call_update(). This flag is useful
4054 * in IP address change situation, after the local account's Contact has
4055 * been updated (typically with re-registration) use this flag to update
4056 * the invite session with the new Contact and to inform this new Contact
4057 * to the remote peer with the outgoing re-INVITE or UPDATE.
4058 */
4059 PJSUA_CALL_UPDATE_CONTACT = 2,
4060
4061 /**
4062 * Include SDP "m=" line with port set to zero for each disabled media
4063 * (i.e when aud_cnt or vid_cnt is set to zero). This flag is only valid
4064 * for #pjsua_call_make_call().
4065 */
4066 PJSUA_CALL_INCLUDE_DISABLED_MEDIA = 4
4067
4068} pjsua_call_flag;
4069
4070
4071/**
4072 * Media stream info.
4073 */
4074typedef struct pjsua_stream_info
4075{
4076 /** Media type of this stream. */
4077 pjmedia_type type;
4078
4079 /** Stream info (union). */
4080 union {
4081 /** Audio stream info */
4082 pjmedia_stream_info aud;
4083
4084 /** Video stream info */
4085 pjmedia_vid_stream_info vid;
4086 } info;
4087
4088} pjsua_stream_info;
4089
4090
4091/**
4092 * Media stream statistic.
4093 */
4094typedef struct pjsua_stream_stat
4095{
4096 /** RTCP statistic. */
4097 pjmedia_rtcp_stat rtcp;
4098
4099 /** Jitter buffer statistic. */
4100 pjmedia_jb_state jbuf;
4101
4102} pjsua_stream_stat;
4103
4104/**
4105 * This enumeration represents video stream operation on a call.
4106 * See also #pjsua_call_vid_strm_op_param for further info.
4107 */
4108typedef enum pjsua_call_vid_strm_op
4109{
4110 /**
4111 * No operation
4112 */
4113 PJSUA_CALL_VID_STRM_NO_OP,
4114
4115 /**
4116 * Add a new video stream. This will add a new m=video line to
4117 * the media, regardless of whether existing video is/are present
4118 * or not. This will cause re-INVITE or UPDATE to be sent to remote
4119 * party.
4120 */
4121 PJSUA_CALL_VID_STRM_ADD,
4122
4123 /**
4124 * Remove/disable an existing video stream. This will
4125 * cause re-INVITE or UPDATE to be sent to remote party.
4126 */
4127 PJSUA_CALL_VID_STRM_REMOVE,
4128
4129 /**
4130 * Change direction of a video stream. This operation can be used
4131 * to activate or deactivate an existing video media. This will
4132 * cause re-INVITE or UPDATE to be sent to remote party.
4133 */
4134 PJSUA_CALL_VID_STRM_CHANGE_DIR,
4135
4136 /**
4137 * Change capture device of a video stream. This will not send
4138 * re-INVITE or UPDATE to remote party.
4139 */
4140 PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV,
4141
4142 /**
4143 * Start transmitting video stream. This will cause previously
4144 * stopped stream to start transmitting again. Note that no
4145 * re-INVITE/UPDATE is to be transmitted to remote since this
4146 * operation only operates on local stream.
4147 */
4148 PJSUA_CALL_VID_STRM_START_TRANSMIT,
4149
4150 /**
4151 * Stop transmitting video stream. This will cause the stream to
4152 * be paused in TX direction, causing it to stop sending any video
4153 * packets. No re-INVITE/UPDATE is to be transmitted to remote
4154 * with this operation.
4155 */
4156 PJSUA_CALL_VID_STRM_STOP_TRANSMIT,
4157
4158 /**
4159 * Send keyframe in the video stream. This will force the stream to
4160 * generate and send video keyframe as soon as possible. No
4161 * re-INVITE/UPDATE is to be transmitted to remote with this operation.
4162 */
4163 PJSUA_CALL_VID_STRM_SEND_KEYFRAME
4164
4165} pjsua_call_vid_strm_op;
4166
4167
4168/**
4169 * Parameters for video stream operation on a call. Application should
4170 * use #pjsua_call_vid_strm_op_param_default() to initialize this structure
4171 * with its default values.
4172 */
4173typedef struct pjsua_call_vid_strm_op_param
4174{
4175 /**
4176 * Specify the media stream index. This can be set to -1 to denote
4177 * the default video stream in the call, which is the first active
4178 * video stream or any first video stream if none is active.
4179 *
4180 * This field is valid for all video stream operations, except
4181 * PJSUA_CALL_VID_STRM_ADD.
4182 *
4183 * Default: -1 (first active video stream, or any first video stream
4184 * if none is active)
4185 */
4186 int med_idx;
4187
4188 /**
4189 * Specify the media stream direction.
4190 *
4191 * This field is valid for the following video stream operations:
4192 * PJSUA_CALL_VID_STRM_ADD and PJSUA_CALL_VID_STRM_CHANGE_DIR.
4193 *
4194 * Default: PJMEDIA_DIR_ENCODING_DECODING
4195 */
4196 pjmedia_dir dir;
4197
4198 /**
4199 * Specify the video capture device ID. This can be set to
4200 * PJMEDIA_VID_DEFAULT_CAPTURE_DEV to specify the default capture
4201 * device as configured in the account.
4202 *
4203 * This field is valid for the following video stream operations:
4204 * PJSUA_CALL_VID_STRM_ADD and PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV.
4205 *
4206 * Default: PJMEDIA_VID_DEFAULT_CAPTURE_DEV.
4207 */
4208 pjmedia_vid_dev_index cap_dev;
4209
4210} pjsua_call_vid_strm_op_param;
4211
4212
4213/**
4214 * Initialize call settings.
4215 *
4216 * @param opt The call setting to be initialized.
4217 */
4218PJ_DECL(void) pjsua_call_setting_default(pjsua_call_setting *opt);
4219
4220
4221/**
4222 * Initialize video stream operation param with default values.
4223 *
4224 * @param param The video stream operation param to be initialized.
4225 */
4226PJ_DECL(void)
4227pjsua_call_vid_strm_op_param_default(pjsua_call_vid_strm_op_param *param);
4228
4229
4230/**
4231 * Get maximum number of calls configured in pjsua.
4232 *
4233 * @return Maximum number of calls configured.
4234 */
4235PJ_DECL(unsigned) pjsua_call_get_max_count(void);
4236
4237/**
4238 * Get number of currently active calls.
4239 *
4240 * @return Number of currently active calls.
4241 */
4242PJ_DECL(unsigned) pjsua_call_get_count(void);
4243
4244/**
4245 * Enumerate all active calls. Application may then query the information and
4246 * state of each call by calling #pjsua_call_get_info().
4247 *
4248 * @param ids Array of account IDs to be initialized.
4249 * @param count In input, specifies the maximum number of elements.
4250 * On return, it contains the actual number of elements.
4251 *
4252 * @return PJ_SUCCESS on success, or the appropriate error code.
4253 */
4254PJ_DECL(pj_status_t) pjsua_enum_calls(pjsua_call_id ids[],
4255 unsigned *count);
4256
4257
4258/**
4259 * Make outgoing call to the specified URI using the specified account.
4260 *
4261 * @param acc_id The account to be used.
4262 * @param dst_uri URI to be put in the To header (normally is the same
4263 * as the target URI).
4264 * @param opt Optional call setting. This should be initialized
4265 * using #pjsua_call_setting_default().
4266 * @param user_data Arbitrary user data to be attached to the call, and
4267 * can be retrieved later.
4268 * @param msg_data Optional headers etc to be added to outgoing INVITE
4269 * request, or NULL if no custom header is desired.
4270 * @param p_call_id Pointer to receive call identification.
4271 *
4272 * @return PJ_SUCCESS on success, or the appropriate error code.
4273 */
4274PJ_DECL(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
4275 const pj_str_t *dst_uri,
4276 const pjsua_call_setting *opt,
4277 void *user_data,
4278 const pjsua_msg_data *msg_data,
4279 pjsua_call_id *p_call_id);
4280
4281
4282/**
4283 * Check if the specified call has active INVITE session and the INVITE
4284 * session has not been disconnected.
4285 *
4286 * @param call_id Call identification.
4287 *
4288 * @return Non-zero if call is active.
4289 */
4290PJ_DECL(pj_bool_t) pjsua_call_is_active(pjsua_call_id call_id);
4291
4292
4293/**
4294 * Check if call has an active media session.
4295 *
4296 * @param call_id Call identification.
4297 *
4298 * @return Non-zero if yes.
4299 */
4300PJ_DECL(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id);
4301
4302
4303/**
4304 * Get the conference port identification associated with the call.
4305 *
4306 * @param call_id Call identification.
4307 *
4308 * @return Conference port ID, or PJSUA_INVALID_ID when the
4309 * media has not been established or is not active.
4310 */
4311PJ_DECL(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id);
4312
4313/**
4314 * Obtain detail information about the specified call.
4315 *
4316 * @param call_id Call identification.
4317 * @param info Call info to be initialized.
4318 *
4319 * @return PJ_SUCCESS on success, or the appropriate error code.
4320 */
4321PJ_DECL(pj_status_t) pjsua_call_get_info(pjsua_call_id call_id,
4322 pjsua_call_info *info);
4323
4324/**
4325 * Check if remote peer support the specified capability.
4326 *
4327 * @param call_id Call identification.
4328 * @param htype The header type to be checked, which value may be:
4329 * - PJSIP_H_ACCEPT
4330 * - PJSIP_H_ALLOW
4331 * - PJSIP_H_SUPPORTED
4332 * @param hname If htype specifies PJSIP_H_OTHER, then the header
4333 * name must be supplied in this argument. Otherwise the
4334 * value must be set to NULL.
4335 * @param token The capability token to check. For example, if \a
4336 * htype is PJSIP_H_ALLOW, then \a token specifies the
4337 * method names; if \a htype is PJSIP_H_SUPPORTED, then
4338 * \a token specifies the extension names such as
4339 * "100rel".
4340 *
4341 * @return PJSIP_DIALOG_CAP_SUPPORTED if the specified capability
4342 * is explicitly supported, see @pjsip_dialog_cap_status
4343 * for more info.
4344 */
4345PJ_DECL(pjsip_dialog_cap_status) pjsua_call_remote_has_cap(
4346 pjsua_call_id call_id,
4347 int htype,
4348 const pj_str_t *hname,
4349 const pj_str_t *token);
4350
4351/**
4352 * Attach application specific data to the call. Application can then
4353 * inspect this data by calling #pjsua_call_get_user_data().
4354 *
4355 * @param call_id Call identification.
4356 * @param user_data Arbitrary data to be attached to the call.
4357 *
4358 * @return The user data.
4359 */
4360PJ_DECL(pj_status_t) pjsua_call_set_user_data(pjsua_call_id call_id,
4361 void *user_data);
4362
4363
4364/**
4365 * Get user data attached to the call, which has been previously set with
4366 * #pjsua_call_set_user_data().
4367 *
4368 * @param call_id Call identification.
4369 *
4370 * @return The user data.
4371 */
4372PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id);
4373
4374
4375/**
4376 * Get the NAT type of remote's endpoint. This is a proprietary feature
4377 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp
4378 * is set in #pjsua_config.
4379 *
4380 * This function can only be called after SDP has been received from remote,
4381 * which means for incoming call, this function can be called as soon as
4382 * call is received as long as incoming call contains SDP, and for outgoing
4383 * call, this function can be called only after SDP is received (normally in
4384 * 200/OK response to INVITE). As a general case, application should call
4385 * this function after or in \a on_call_media_state() callback.
4386 *
4387 * @param call_id Call identification.
4388 * @param p_type Pointer to store the NAT type. Application can then
4389 * retrieve the string description of the NAT type
4390 * by calling pj_stun_get_nat_name().
4391 *
4392 * @return PJ_SUCCESS on success.
4393 *
4394 * @see pjsua_get_nat_type(), nat_type_in_sdp
4395 */
4396PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id,
4397 pj_stun_nat_type *p_type);
4398
4399/**
4400 * Send response to incoming INVITE request. Depending on the status
4401 * code specified as parameter, this function may send provisional
4402 * response, establish the call, or terminate the call. See also
4403 * #pjsua_call_answer2().
4404 *
4405 * @param call_id Incoming call identification.
4406 * @param code Status code, (100-699).
4407 * @param reason Optional reason phrase. If NULL, default text
4408 * will be used.
4409 * @param msg_data Optional list of headers etc to be added to outgoing
4410 * response message. Note that this message data will
4411 * be persistent in all next answers/responses for this
4412 * INVITE request.
4413 *
4414 * @return PJ_SUCCESS on success, or the appropriate error code.
4415 */
4416PJ_DECL(pj_status_t) pjsua_call_answer(pjsua_call_id call_id,
4417 unsigned code,
4418 const pj_str_t *reason,
4419 const pjsua_msg_data *msg_data);
4420
4421
4422/**
4423 * Send response to incoming INVITE request with call setting param.
4424 * Depending on the status code specified as parameter, this function may
4425 * send provisional response, establish the call, or terminate the call.
4426 * Notes about call setting:
4427 * - if call setting is changed in the subsequent call to this function,
4428 * only the first call setting supplied will applied. So normally
4429 * application will not supply call setting before getting confirmation
4430 * from the user.
4431 * - if no call setting is supplied when SDP has to be sent, i.e: answer
4432 * with status code 183 or 2xx, the default call setting will be used,
4433 * check #pjsua_call_setting for its default values.
4434 *
4435 * @param call_id Incoming call identification.
4436 * @param opt Optional call setting.
4437 * @param code Status code, (100-699).
4438 * @param reason Optional reason phrase. If NULL, default text
4439 * will be used.
4440 * @param msg_data Optional list of headers etc to be added to outgoing
4441 * response message. Note that this message data will
4442 * be persistent in all next answers/responses for this
4443 * INVITE request.
4444 *
4445 * @return PJ_SUCCESS on success, or the appropriate error code.
4446 */
4447PJ_DECL(pj_status_t) pjsua_call_answer2(pjsua_call_id call_id,
4448 const pjsua_call_setting *opt,
4449 unsigned code,
4450 const pj_str_t *reason,
4451 const pjsua_msg_data *msg_data);
4452
4453
4454/**
4455 * Hangup call by using method that is appropriate according to the
4456 * call state. This function is different than answering the call with
4457 * 3xx-6xx response (with #pjsua_call_answer()), in that this function
4458 * will hangup the call regardless of the state and role of the call,
4459 * while #pjsua_call_answer() only works with incoming calls on EARLY
4460 * state.
4461 *
4462 * @param call_id Call identification.
4463 * @param code Optional status code to be sent when we're rejecting
4464 * incoming call. If the value is zero, "603/Decline"
4465 * will be sent.
4466 * @param reason Optional reason phrase to be sent when we're rejecting
4467 * incoming call. If NULL, default text will be used.
4468 * @param msg_data Optional list of headers etc to be added to outgoing
4469 * request/response message.
4470 *
4471 * @return PJ_SUCCESS on success, or the appropriate error code.
4472 */
4473PJ_DECL(pj_status_t) pjsua_call_hangup(pjsua_call_id call_id,
4474 unsigned code,
4475 const pj_str_t *reason,
4476 const pjsua_msg_data *msg_data);
4477
4478/**
4479 * Accept or reject redirection response. Application MUST call this function
4480 * after it signaled PJSIP_REDIRECT_PENDING in the \a on_call_redirected()
4481 * callback, to notify the call whether to accept or reject the redirection
4482 * to the current target. Application can use the combination of
4483 * PJSIP_REDIRECT_PENDING command in \a on_call_redirected() callback and
4484 * this function to ask for user permission before redirecting the call.
4485 *
4486 * Note that if the application chooses to reject or stop redirection (by
4487 * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the
4488 * call disconnection callback will be called before this function returns.
4489 * And if the application rejects the target, the \a on_call_redirected()
4490 * callback may also be called before this function returns if there is
4491 * another target to try.
4492 *
4493 * @param call_id The call ID.
4494 * @param cmd Redirection operation to be applied to the current
4495 * target. The semantic of this argument is similar
4496 * to the description in the \a on_call_redirected()
4497 * callback, except that the PJSIP_REDIRECT_PENDING is
4498 * not accepted here.
4499 *
4500 * @return PJ_SUCCESS on successful operation.
4501 */
4502PJ_DECL(pj_status_t) pjsua_call_process_redirect(pjsua_call_id call_id,
4503 pjsip_redirect_op cmd);
4504
4505/**
4506 * Put the specified call on hold. This will send re-INVITE with the
4507 * appropriate SDP to inform remote that the call is being put on hold.
4508 * The final status of the request itself will be reported on the
4509 * \a on_call_media_state() callback, which inform the application that
4510 * the media state of the call has changed.
4511 *
4512 * @param call_id Call identification.
4513 * @param msg_data Optional message components to be sent with
4514 * the request.
4515 *
4516 * @return PJ_SUCCESS on success, or the appropriate error code.
4517 */
4518PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id,
4519 const pjsua_msg_data *msg_data);
4520
4521/**
4522 * Put the specified call on hold. This will send re-INVITE with the
4523 * appropriate SDP to inform remote that the call is being put on hold.
4524 * The final status of the request itself will be reported on the
4525 * \a on_call_media_state() callback, which inform the application that
4526 * the media state of the call has changed.
4527 *
4528 * @param call_id Call identification.
4529 * @param options Bitmask of pjsua_call_flag constants. Currently, only
4530 * the flag PJSUA_CALL_UPDATE_CONTACT can be used.
4531 * @param msg_data Optional message components to be sent with
4532 * the request.
4533 *
4534 * @return PJ_SUCCESS on success, or the appropriate error code.
4535 */
4536PJ_DECL(pj_status_t) pjsua_call_set_hold2(pjsua_call_id call_id,
4537 unsigned options,
4538 const pjsua_msg_data *msg_data);
4539
4540/**
4541 * Send re-INVITE to release hold.
4542 * The final status of the request itself will be reported on the
4543 * \a on_call_media_state() callback, which inform the application that
4544 * the media state of the call has changed.
4545 *
4546 * @param call_id Call identification.
4547 * @param options Bitmask of pjsua_call_flag constants. Note that
4548 * for compatibility, specifying PJ_TRUE here is
4549 * equal to specifying PJSUA_CALL_UNHOLD flag.
4550 * @param msg_data Optional message components to be sent with
4551 * the request.
4552 *
4553 * @return PJ_SUCCESS on success, or the appropriate error code.
4554 */
4555PJ_DECL(pj_status_t) pjsua_call_reinvite(pjsua_call_id call_id,
4556 unsigned options,
4557 const pjsua_msg_data *msg_data);
4558
4559
4560/**
4561 * Send re-INVITE to release hold.
4562 * The final status of the request itself will be reported on the
4563 * \a on_call_media_state() callback, which inform the application that
4564 * the media state of the call has changed.
4565 *
4566 * @param call_id Call identification.
4567 * @param opt Optional call setting, if NULL, the current call
4568 * setting will remain unchanged.
4569 * @param msg_data Optional message components to be sent with
4570 * the request.
4571 *
4572 * @return PJ_SUCCESS on success, or the appropriate error code.
4573 */
4574PJ_DECL(pj_status_t) pjsua_call_reinvite2(pjsua_call_id call_id,
4575 const pjsua_call_setting *opt,
4576 const pjsua_msg_data *msg_data);
4577
4578
4579/**
4580 * Send UPDATE request.
4581 *
4582 * @param call_id Call identification.
4583 * @param options Bitmask of pjsua_call_flag constants.
4584 * @param msg_data Optional message components to be sent with
4585 * the request.
4586 *
4587 * @return PJ_SUCCESS on success, or the appropriate error code.
4588 */
4589PJ_DECL(pj_status_t) pjsua_call_update(pjsua_call_id call_id,
4590 unsigned options,
4591 const pjsua_msg_data *msg_data);
4592
4593
4594/**
4595 * Send UPDATE request.
4596 *
4597 * @param call_id Call identification.
4598 * @param opt Optional call setting, if NULL, the current call
4599 * setting will remain unchanged.
4600 * @param msg_data Optional message components to be sent with
4601 * the request.
4602 *
4603 * @return PJ_SUCCESS on success, or the appropriate error code.
4604 */
4605PJ_DECL(pj_status_t) pjsua_call_update2(pjsua_call_id call_id,
4606 const pjsua_call_setting *opt,
4607 const pjsua_msg_data *msg_data);
4608
4609
4610/**
4611 * Initiate call transfer to the specified address. This function will send
4612 * REFER request to instruct remote call party to initiate a new INVITE
4613 * session to the specified destination/target.
4614 *
4615 * If application is interested to monitor the successfulness and
4616 * the progress of the transfer request, it can implement
4617 * \a on_call_transfer_status() callback which will report the progress
4618 * of the call transfer request.
4619 *
4620 * @param call_id The call id to be transfered.
4621 * @param dest URI of new target to be contacted. The URI may be
4622 * in name address or addr-spec format.
4623 * @param msg_data Optional message components to be sent with
4624 * the request.
4625 *
4626 * @return PJ_SUCCESS on success, or the appropriate error code.
4627 */
4628PJ_DECL(pj_status_t) pjsua_call_xfer(pjsua_call_id call_id,
4629 const pj_str_t *dest,
4630 const pjsua_msg_data *msg_data);
4631
4632/**
4633 * Flag to indicate that "Require: replaces" should not be put in the
4634 * outgoing INVITE request caused by REFER request created by
4635 * #pjsua_call_xfer_replaces().
4636 */
4637#define PJSUA_XFER_NO_REQUIRE_REPLACES 1
4638
4639/**
4640 * Initiate attended call transfer. This function will send REFER request
4641 * to instruct remote call party to initiate new INVITE session to the URL
4642 * of \a dest_call_id. The party at \a dest_call_id then should "replace"
4643 * the call with us with the new call from the REFER recipient.
4644 *
4645 * @param call_id The call id to be transfered.
4646 * @param dest_call_id The call id to be replaced.
4647 * @param options Application may specify PJSUA_XFER_NO_REQUIRE_REPLACES
4648 * to suppress the inclusion of "Require: replaces" in
4649 * the outgoing INVITE request created by the REFER
4650 * request.
4651 * @param msg_data Optional message components to be sent with
4652 * the request.
4653 *
4654 * @return PJ_SUCCESS on success, or the appropriate error code.
4655 */
4656PJ_DECL(pj_status_t) pjsua_call_xfer_replaces(pjsua_call_id call_id,
4657 pjsua_call_id dest_call_id,
4658 unsigned options,
4659 const pjsua_msg_data *msg_data);
4660
4661/**
4662 * Send DTMF digits to remote using RFC 2833 payload formats.
4663 *
4664 * @param call_id Call identification.
4665 * @param digits DTMF string digits to be sent.
4666 *
4667 * @return PJ_SUCCESS on success, or the appropriate error code.
4668 */
4669PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(pjsua_call_id call_id,
4670 const pj_str_t *digits);
4671
4672/**
4673 * Send instant messaging inside INVITE session.
4674 *
4675 * @param call_id Call identification.
4676 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
4677 * assumed.
4678 * @param content The message content.
4679 * @param msg_data Optional list of headers etc to be included in outgoing
4680 * request. The body descriptor in the msg_data is
4681 * ignored.
4682 * @param user_data Optional user data, which will be given back when
4683 * the IM callback is called.
4684 *
4685 * @return PJ_SUCCESS on success, or the appropriate error code.
4686 */
4687PJ_DECL(pj_status_t) pjsua_call_send_im( pjsua_call_id call_id,
4688 const pj_str_t *mime_type,
4689 const pj_str_t *content,
4690 const pjsua_msg_data *msg_data,
4691 void *user_data);
4692
4693
4694/**
4695 * Send IM typing indication inside INVITE session.
4696 *
4697 * @param call_id Call identification.
4698 * @param is_typing Non-zero to indicate to remote that local person is
4699 * currently typing an IM.
4700 * @param msg_data Optional list of headers etc to be included in outgoing
4701 * request.
4702 *
4703 * @return PJ_SUCCESS on success, or the appropriate error code.
4704 */
4705PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(pjsua_call_id call_id,
4706 pj_bool_t is_typing,
4707 const pjsua_msg_data*msg_data);
4708
4709/**
4710 * Send arbitrary request with the call. This is useful for example to send
4711 * INFO request. Note that application should not use this function to send
4712 * requests which would change the invite session's state, such as re-INVITE,
4713 * UPDATE, PRACK, and BYE.
4714 *
4715 * @param call_id Call identification.
4716 * @param method SIP method of the request.
4717 * @param msg_data Optional message body and/or list of headers to be
4718 * included in outgoing request.
4719 *
4720 * @return PJ_SUCCESS on success, or the appropriate error code.
4721 */
4722PJ_DECL(pj_status_t) pjsua_call_send_request(pjsua_call_id call_id,
4723 const pj_str_t *method,
4724 const pjsua_msg_data *msg_data);
4725
4726
4727/**
4728 * Terminate all calls. This will initiate #pjsua_call_hangup() for all
4729 * currently active calls.
4730 */
4731PJ_DECL(void) pjsua_call_hangup_all(void);
4732
4733
4734/**
4735 * Dump call and media statistics to string.
4736 *
4737 * @param call_id Call identification.
4738 * @param with_media Non-zero to include media information too.
4739 * @param buffer Buffer where the statistics are to be written to.
4740 * @param maxlen Maximum length of buffer.
4741 * @param indent Spaces for left indentation.
4742 *
4743 * @return PJ_SUCCESS on success.
4744 */
4745PJ_DECL(pj_status_t) pjsua_call_dump(pjsua_call_id call_id,
4746 pj_bool_t with_media,
4747 char *buffer,
4748 unsigned maxlen,
4749 const char *indent);
4750
4751/**
4752 * Get the media stream index of the default video stream in the call.
4753 * Typically this will just retrieve the stream index of the first
4754 * activated video stream in the call. If none is active, it will return
4755 * the first inactive video stream.
4756 *
4757 * @param call_id Call identification.
4758 *
4759 * @return The media stream index or -1 if no video stream
4760 * is present in the call.
4761 */
4762PJ_DECL(int) pjsua_call_get_vid_stream_idx(pjsua_call_id call_id);
4763
4764
4765/**
4766 * Determine if video stream for the specified call is currently running
4767 * (i.e. has been created, started, and not being paused) for the specified
4768 * direction.
4769 *
4770 * @param call_id Call identification.
4771 * @param med_idx Media stream index, or -1 to specify default video
4772 * media.
4773 * @param dir The direction to be checked.
4774 *
4775 * @return PJ_TRUE if stream is currently running for the
4776 * specified direction.
4777 */
4778PJ_DECL(pj_bool_t) pjsua_call_vid_stream_is_running(pjsua_call_id call_id,
4779 int med_idx,
4780 pjmedia_dir dir);
4781
4782/**
4783 * Add, remove, modify, and/or manipulate video media stream for the
4784 * specified call. This may trigger a re-INVITE or UPDATE to be sent
4785 * for the call.
4786 *
4787 * @param call_id Call identification.
4788 * @param op The video stream operation to be performed,
4789 * possible values are #pjsua_call_vid_strm_op.
4790 * @param param The parameters for the video stream operation,
4791 * or NULL for the default parameter values
4792 * (see #pjsua_call_vid_strm_op_param).
4793 *
4794 * @return PJ_SUCCESS on success or the appropriate error.
4795 */
4796PJ_DECL(pj_status_t) pjsua_call_set_vid_strm (
4797 pjsua_call_id call_id,
4798 pjsua_call_vid_strm_op op,
4799 const pjsua_call_vid_strm_op_param *param);
4800
4801
4802/**
4803 * Get media stream info for the specified media index.
4804 *
4805 * @param call_id The call identification.
4806 * @param med_idx Media stream index.
4807 * @param psi To be filled with the stream info.
4808 *
4809 * @return PJ_SUCCESS on success or the appropriate error.
4810 */
4811PJ_DECL(pj_status_t) pjsua_call_get_stream_info(pjsua_call_id call_id,
4812 unsigned med_idx,
4813 pjsua_stream_info *psi);
4814
4815/**
4816 * Get media stream statistic for the specified media index.
4817 *
4818 * @param call_id The call identification.
4819 * @param med_idx Media stream index.
4820 * @param psi To be filled with the stream statistic.
4821 *
4822 * @return PJ_SUCCESS on success or the appropriate error.
4823 */
4824PJ_DECL(pj_status_t) pjsua_call_get_stream_stat(pjsua_call_id call_id,
4825 unsigned med_idx,
4826 pjsua_stream_stat *stat);
4827
4828/**
4829 * Get media transport info for the specified media index.
4830 *
4831 * @param call_id The call identification.
4832 * @param med_idx Media stream index.
4833 * @param t To be filled with the transport info.
4834 *
4835 * @return PJ_SUCCESS on success or the appropriate error.
4836 */
4837PJ_DECL(pj_status_t)
4838pjsua_call_get_med_transport_info(pjsua_call_id call_id,
4839 unsigned med_idx,
4840 pjmedia_transport_info *t);
4841
4842
4843
4844/**
4845 * @}
4846 */
4847
4848
4849/*****************************************************************************
4850 * BUDDY API
4851 */
4852
4853
4854/**
4855 * @defgroup PJSUA_LIB_BUDDY PJSUA-API Buddy, Presence, and Instant Messaging
4856 * @ingroup PJSUA_LIB
4857 * @brief Buddy management, buddy's presence, and instant messaging.
4858 * @{
4859 *
4860 * This section describes PJSUA-APIs related to buddies management,
4861 * presence management, and instant messaging.
4862 */
4863
4864/**
4865 * Max buddies in buddy list.
4866 */
4867#ifndef PJSUA_MAX_BUDDIES
4868# define PJSUA_MAX_BUDDIES 256
4869#endif
4870
4871
4872/**
4873 * This specifies how long the library should wait before retrying failed
4874 * SUBSCRIBE request, and there is no rule to automatically resubscribe
4875 * (for example, no "retry-after" parameter in Subscription-State header).
4876 *
4877 * This also controls the duration before failed PUBLISH request will be
4878 * retried.
4879 *
4880 * Default: 300 seconds
4881 */
4882#ifndef PJSUA_PRES_TIMER
4883# define PJSUA_PRES_TIMER 300
4884#endif
4885
4886
4887/**
4888 * This structure describes buddy configuration when adding a buddy to
4889 * the buddy list with #pjsua_buddy_add(). Application MUST initialize
4890 * the structure with #pjsua_buddy_config_default() to initialize this
4891 * structure with default configuration.
4892 */
4893typedef struct pjsua_buddy_config
4894{
4895 /**
4896 * Buddy URL or name address.
4897 */
4898 pj_str_t uri;
4899
4900 /**
4901 * Specify whether presence subscription should start immediately.
4902 */
4903 pj_bool_t subscribe;
4904
4905 /**
4906 * Specify arbitrary application data to be associated with with
4907 * the buddy object.
4908 */
4909 void *user_data;
4910
4911} pjsua_buddy_config;
4912
4913
4914/**
4915 * This enumeration describes basic buddy's online status.
4916 */
4917typedef enum pjsua_buddy_status
4918{
4919 /**
4920 * Online status is unknown (possibly because no presence subscription
4921 * has been established).
4922 */
4923 PJSUA_BUDDY_STATUS_UNKNOWN,
4924
4925 /**
4926 * Buddy is known to be online.
4927 */
4928 PJSUA_BUDDY_STATUS_ONLINE,
4929
4930 /**
4931 * Buddy is offline.
4932 */
4933 PJSUA_BUDDY_STATUS_OFFLINE,
4934
4935} pjsua_buddy_status;
4936
4937
4938
4939/**
4940 * This structure describes buddy info, which can be retrieved by calling
4941 * #pjsua_buddy_get_info().
4942 */
4943typedef struct pjsua_buddy_info
4944{
4945 /**
4946 * The buddy ID.
4947 */
4948 pjsua_buddy_id id;
4949
4950 /**
4951 * The full URI of the buddy, as specified in the configuration.
4952 */
4953 pj_str_t uri;
4954
4955 /**
4956 * Buddy's Contact, only available when presence subscription has
4957 * been established to the buddy.
4958 */
4959 pj_str_t contact;
4960
4961 /**
4962 * Buddy's online status.
4963 */
4964 pjsua_buddy_status status;
4965
4966 /**
4967 * Text to describe buddy's online status.
4968 */
4969 pj_str_t status_text;
4970
4971 /**
4972 * Flag to indicate that we should monitor the presence information for
4973 * this buddy (normally yes, unless explicitly disabled).
4974 */
4975 pj_bool_t monitor_pres;
4976
4977 /**
4978 * If \a monitor_pres is enabled, this specifies the last state of the
4979 * presence subscription. If presence subscription session is currently
4980 * active, the value will be PJSIP_EVSUB_STATE_ACTIVE. If presence
4981 * subscription request has been rejected, the value will be
4982 * PJSIP_EVSUB_STATE_TERMINATED, and the termination reason will be
4983 * specified in \a sub_term_reason.
4984 */
4985 pjsip_evsub_state sub_state;
4986
4987 /**
4988 * String representation of subscription state.
4989 */
4990 const char *sub_state_name;
4991
4992 /**
4993 * Specifies the last presence subscription termination code. This would
4994 * return the last status of the SUBSCRIBE request. If the subscription
4995 * is terminated with NOTIFY by the server, this value will be set to
4996 * 200, and subscription termination reason will be given in the
4997 * \a sub_term_reason field.
4998 */
4999 unsigned sub_term_code;
5000
5001 /**
5002 * Specifies the last presence subscription termination reason. If
5003 * presence subscription is currently active, the value will be empty.
5004 */
5005 pj_str_t sub_term_reason;
5006
5007 /**
5008 * Extended RPID information about the person.
5009 */
5010 pjrpid_element rpid;
5011
5012 /**
5013 * Extended presence info.
5014 */
5015 pjsip_pres_status pres_status;
5016
5017 /**
5018 * Internal buffer.
5019 */
5020 char buf_[512];
5021
5022} pjsua_buddy_info;
5023
5024
5025/**
5026 * Set default values to the buddy config.
5027 */
5028PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg);
5029
5030
5031/**
5032 * Get total number of buddies.
5033 *
5034 * @return Number of buddies.
5035 */
5036PJ_DECL(unsigned) pjsua_get_buddy_count(void);
5037
5038
5039/**
5040 * Check if buddy ID is valid.
5041 *
5042 * @param buddy_id Buddy ID to check.
5043 *
5044 * @return Non-zero if buddy ID is valid.
5045 */
5046PJ_DECL(pj_bool_t) pjsua_buddy_is_valid(pjsua_buddy_id buddy_id);
5047
5048
5049/**
5050 * Enumerate all buddy IDs in the buddy list. Application then can use
5051 * #pjsua_buddy_get_info() to get the detail information for each buddy
5052 * id.
5053 *
5054 * @param ids Array of ids to be initialized.
5055 * @param count On input, specifies max elements in the array.
5056 * On return, it contains actual number of elements
5057 * that have been initialized.
5058 *
5059 * @return PJ_SUCCESS on success, or the appropriate error code.
5060 */
5061PJ_DECL(pj_status_t) pjsua_enum_buddies(pjsua_buddy_id ids[],
5062 unsigned *count);
5063
5064/**
5065 * Find the buddy ID with the specified URI.
5066 *
5067 * @param uri The buddy URI.
5068 *
5069 * @return The buddy ID, or PJSUA_INVALID_ID if not found.
5070 */
5071PJ_DECL(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri);
5072
5073
5074/**
5075 * Get detailed buddy info.
5076 *
5077 * @param buddy_id The buddy identification.
5078 * @param info Pointer to receive information about buddy.
5079 *
5080 * @return PJ_SUCCESS on success, or the appropriate error code.
5081 */
5082PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
5083 pjsua_buddy_info *info);
5084
5085/**
5086 * Set the user data associated with the buddy object.
5087 *
5088 * @param buddy_id The buddy identification.
5089 * @param user_data Arbitrary application data to be associated with
5090 * the buddy object.
5091 *
5092 * @return PJ_SUCCESS on success, or the appropriate error code.
5093 */
5094PJ_DECL(pj_status_t) pjsua_buddy_set_user_data(pjsua_buddy_id buddy_id,
5095 void *user_data);
5096
5097
5098/**
5099 * Get the user data associated with the budy object.
5100 *
5101 * @param buddy_id The buddy identification.
5102 *
5103 * @return The application data.
5104 */
5105PJ_DECL(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id);
5106
5107
5108/**
5109 * Add new buddy to the buddy list. If presence subscription is enabled
5110 * for this buddy, this function will also start the presence subscription
5111 * session immediately.
5112 *
5113 * @param buddy_cfg Buddy configuration.
5114 * @param p_buddy_id Pointer to receive buddy ID.
5115 *
5116 * @return PJ_SUCCESS on success, or the appropriate error code.
5117 */
5118PJ_DECL(pj_status_t) pjsua_buddy_add(const pjsua_buddy_config *buddy_cfg,
5119 pjsua_buddy_id *p_buddy_id);
5120
5121
5122/**
5123 * Delete the specified buddy from the buddy list. Any presence subscription
5124 * to this buddy will be terminated.
5125 *
5126 * @param buddy_id Buddy identification.
5127 *
5128 * @return PJ_SUCCESS on success, or the appropriate error code.
5129 */
5130PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_id);
5131
5132
5133/**
5134 * Enable/disable buddy's presence monitoring. Once buddy's presence is
5135 * subscribed, application will be informed about buddy's presence status
5136 * changed via \a on_buddy_state() callback.
5137 *
5138 * @param buddy_id Buddy identification.
5139 * @param subscribe Specify non-zero to activate presence subscription to
5140 * the specified buddy.
5141 *
5142 * @return PJ_SUCCESS on success, or the appropriate error code.
5143 */
5144PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_id,
5145 pj_bool_t subscribe);
5146
5147
5148/**
5149 * Update the presence information for the buddy. Although the library
5150 * periodically refreshes the presence subscription for all buddies, some
5151 * application may want to refresh the buddy's presence subscription
5152 * immediately, and in this case it can use this function to accomplish
5153 * this.
5154 *
5155 * Note that the buddy's presence subscription will only be initiated
5156 * if presence monitoring is enabled for the buddy. See
5157 * #pjsua_buddy_subscribe_pres() for more info. Also if presence subscription
5158 * for the buddy is already active, this function will not do anything.
5159 *
5160 * Once the presence subscription is activated successfully for the buddy,
5161 * application will be notified about the buddy's presence status in the
5162 * on_buddy_state() callback.
5163 *
5164 * @param buddy_id Buddy identification.
5165 *
5166 * @return PJ_SUCCESS on success, or the appropriate error code.
5167 */
5168PJ_DECL(pj_status_t) pjsua_buddy_update_pres(pjsua_buddy_id buddy_id);
5169
5170
5171/**
5172 * Send NOTIFY to inform account presence status or to terminate server
5173 * side presence subscription. If application wants to reject the incoming
5174 * request, it should set the \a state to PJSIP_EVSUB_STATE_TERMINATED.
5175 *
5176 * @param acc_id Account ID.
5177 * @param srv_pres Server presence subscription instance.
5178 * @param state New state to set.
5179 * @param state_str Optionally specify the state string name, if state
5180 * is not "active", "pending", or "terminated".
5181 * @param reason If the new state is PJSIP_EVSUB_STATE_TERMINATED,
5182 * optionally specify the termination reason.
5183 * @param with_body If the new state is PJSIP_EVSUB_STATE_TERMINATED,
5184 * this specifies whether the NOTIFY request should
5185 * contain message body containing account's presence
5186 * information.
5187 * @param msg_data Optional list of headers to be sent with the NOTIFY
5188 * request.
5189 *
5190 * @return PJ_SUCCESS on success.
5191 */
5192PJ_DECL(pj_status_t) pjsua_pres_notify(pjsua_acc_id acc_id,
5193 pjsua_srv_pres *srv_pres,
5194 pjsip_evsub_state state,
5195 const pj_str_t *state_str,
5196 const pj_str_t *reason,
5197 pj_bool_t with_body,
5198 const pjsua_msg_data *msg_data);
5199
5200/**
5201 * Dump presence subscriptions to log.
5202 *
5203 * @param verbose Yes or no.
5204 */
5205PJ_DECL(void) pjsua_pres_dump(pj_bool_t verbose);
5206
5207
5208/**
5209 * The MESSAGE method (defined in pjsua_im.c)
5210 */
5211extern const pjsip_method pjsip_message_method;
5212
5213
5214/**
5215 * The INFO method (defined in pjsua_call.c)
5216 */
5217extern const pjsip_method pjsip_info_method;
5218
5219
5220/**
5221 * Send instant messaging outside dialog, using the specified account for
5222 * route set and authentication.
5223 *
5224 * @param acc_id Account ID to be used to send the request.
5225 * @param to Remote URI.
5226 * @param mime_type Optional MIME type. If NULL, then "text/plain" is
5227 * assumed.
5228 * @param content The message content.
5229 * @param msg_data Optional list of headers etc to be included in outgoing
5230 * request. The body descriptor in the msg_data is
5231 * ignored.
5232 * @param user_data Optional user data, which will be given back when
5233 * the IM callback is called.
5234 *
5235 * @return PJ_SUCCESS on success, or the appropriate error code.
5236 */
5237PJ_DECL(pj_status_t) pjsua_im_send(pjsua_acc_id acc_id,
5238 const pj_str_t *to,
5239 const pj_str_t *mime_type,
5240 const pj_str_t *content,
5241 const pjsua_msg_data *msg_data,
5242 void *user_data);
5243
5244
5245/**
5246 * Send typing indication outside dialog.
5247 *
5248 * @param acc_id Account ID to be used to send the request.
5249 * @param to Remote URI.
5250 * @param is_typing If non-zero, it tells remote person that local person
5251 * is currently composing an IM.
5252 * @param msg_data Optional list of headers etc to be added to outgoing
5253 * request.
5254 *
5255 * @return PJ_SUCCESS on success, or the appropriate error code.
5256 */
5257PJ_DECL(pj_status_t) pjsua_im_typing(pjsua_acc_id acc_id,
5258 const pj_str_t *to,
5259 pj_bool_t is_typing,
5260 const pjsua_msg_data *msg_data);
5261
5262
5263
5264/**
5265 * @}
5266 */
5267
5268
5269/*****************************************************************************
5270 * MEDIA API
5271 */
5272
5273
5274/**
5275 * @defgroup PJSUA_LIB_MEDIA PJSUA-API Media Manipulation
5276 * @ingroup PJSUA_LIB
5277 * @brief Media manipulation.
5278 * @{
5279 *
5280 * PJSUA has rather powerful media features, which are built around the
5281 * PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV
5282 * players, WAV playlist, file recorders, sound device, tone generators, etc)
5283 * are terminated in the conference bridge, and application can manipulate
5284 * the interconnection between these terminations freely.
5285 *
5286 * The conference bridge provides powerful switching and mixing functionality
5287 * for application. With the conference bridge, each conference slot (e.g.
5288 * a call) can transmit to multiple destinations, and one destination can
5289 * receive from multiple sources. If more than one media terminations are
5290 * terminated in the same slot, the conference bridge will mix the signal
5291 * automatically.
5292 *
5293 * Application connects one media termination/slot to another by calling
5294 * #pjsua_conf_connect() function. This will establish <b>unidirectional</b>
5295 * media flow from the source termination to the sink termination. To
5296 * establish bidirectional media flow, application wound need to make another
5297 * call to #pjsua_conf_connect(), this time inverting the source and
5298 * destination slots in the parameter.
5299 *
5300 * For example, to stream a WAV file to remote call, application may use
5301 * the following steps:
5302 *
5303 \code
5304
5305 pj_status_t stream_to_call( pjsua_call_id call_id )
5306 {
5307 pjsua_player_id player_id;
5308
5309 status = pjsua_player_create("mysong.wav", 0, &player_id);
5310 if (status != PJ_SUCCESS)
5311 return status;
5312
5313 status = pjsua_conf_connect( pjsua_player_get_conf_port(),
5314 pjsua_call_get_conf_port() );
5315 }
5316 \endcode
5317 *
5318 *
5319 * Other features of PJSUA media:
5320 * - efficient N to M interconnections between media terminations.
5321 * - media termination can be connected to itself to create loopback
5322 * media.
5323 * - the media termination may have different clock rates, and resampling
5324 * will be done automatically by conference bridge.
5325 * - media terminations may also have different frame time; the
5326 * conference bridge will perform the necessary bufferring to adjust
5327 * the difference between terminations.
5328 * - interconnections are removed automatically when media termination
5329 * is removed from the bridge.
5330 * - sound device may be changed even when there are active media
5331 * interconnections.
5332 * - correctly report call's media quality (in #pjsua_call_dump()) from
5333 * RTCP packet exchange.
5334 */
5335
5336/**
5337 * Use PJMEDIA for media? Set this to zero when using third party media
5338 * stack.
5339 */
5340#ifndef PJSUA_MEDIA_HAS_PJMEDIA
5341# define PJSUA_MEDIA_HAS_PJMEDIA 1
5342#endif /* PJSUA_MEDIA_HAS_PJMEDIA */
5343
5344
5345/**
5346 * Specify whether the third party stream has the capability of retrieving
5347 * the stream info, i.e: pjmedia_stream_get_info() and
5348 * pjmedia_vid_stream_get_info(). Currently this capability is required
5349 * by smart media update and call dump.
5350 */
5351#ifndef PJSUA_THIRD_PARTY_STREAM_HAS_GET_INFO
5352# define PJSUA_THIRD_PARTY_STREAM_HAS_GET_INFO 0
5353#endif
5354
5355
5356/**
5357 * Specify whether the third party stream has the capability of retrieving
5358 * the stream statistics, i.e: pjmedia_stream_get_stat() and
5359 * pjmedia_vid_stream_get_stat(). Currently this capability is required
5360 * by call dump.
5361 */
5362#ifndef PJSUA_THIRD_PARTY_STREAM_HAS_GET_STAT
5363# define PJSUA_THIRD_PARTY_STREAM_HAS_GET_STAT 0
5364#endif
5365
5366
5367/**
5368 * Max ports in the conference bridge. This setting is the default value
5369 * for pjsua_media_config.max_media_ports.
5370 */
5371#ifndef PJSUA_MAX_CONF_PORTS
5372# define PJSUA_MAX_CONF_PORTS 254
5373#endif
5374
5375/**
5376 * The default clock rate to be used by the conference bridge. This setting
5377 * is the default value for pjsua_media_config.clock_rate.
5378 */
5379#ifndef PJSUA_DEFAULT_CLOCK_RATE
5380# define PJSUA_DEFAULT_CLOCK_RATE 16000
5381#endif
5382
5383/**
5384 * Default frame length in the conference bridge. This setting
5385 * is the default value for pjsua_media_config.audio_frame_ptime.
5386 */
5387#ifndef PJSUA_DEFAULT_AUDIO_FRAME_PTIME
5388# define PJSUA_DEFAULT_AUDIO_FRAME_PTIME 20
5389#endif
5390
5391
5392/**
5393 * Default codec quality settings. This setting is the default value
5394 * for pjsua_media_config.quality.
5395 */
5396#ifndef PJSUA_DEFAULT_CODEC_QUALITY
5397# define PJSUA_DEFAULT_CODEC_QUALITY 8
5398#endif
5399
5400/**
5401 * Default iLBC mode. This setting is the default value for
5402 * pjsua_media_config.ilbc_mode.
5403 */
5404#ifndef PJSUA_DEFAULT_ILBC_MODE
5405# define PJSUA_DEFAULT_ILBC_MODE 30
5406#endif
5407
5408/**
5409 * The default echo canceller tail length. This setting
5410 * is the default value for pjsua_media_config.ec_tail_len.
5411 */
5412#ifndef PJSUA_DEFAULT_EC_TAIL_LEN
5413# define PJSUA_DEFAULT_EC_TAIL_LEN 200
5414#endif
5415
5416
5417/**
5418 * The maximum file player.
5419 */
5420#ifndef PJSUA_MAX_PLAYERS
5421# define PJSUA_MAX_PLAYERS 32
5422#endif
5423
5424
5425/**
5426 * The maximum file player.
5427 */
5428#ifndef PJSUA_MAX_RECORDERS
5429# define PJSUA_MAX_RECORDERS 32
5430#endif
5431
5432
5433/**
5434 * Enable/disable "c=" line in SDP session level. Set to zero to disable it.
5435 */
5436#ifndef PJSUA_SDP_SESS_HAS_CONN
5437# define PJSUA_SDP_SESS_HAS_CONN 0
5438#endif
5439
5440
5441/**
5442 * This structure describes media configuration, which will be specified
5443 * when calling #pjsua_init(). Application MUST initialize this structure
5444 * by calling #pjsua_media_config_default().
5445 */
5446struct pjsua_media_config
5447{
5448 /**
5449 * Clock rate to be applied to the conference bridge.
5450 * If value is zero, default clock rate will be used
5451 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
5452 */
5453 unsigned clock_rate;
5454
5455 /**
5456 * Clock rate to be applied when opening the sound device.
5457 * If value is zero, conference bridge clock rate will be used.
5458 */
5459 unsigned snd_clock_rate;
5460
5461 /**
5462 * Channel count be applied when opening the sound device and
5463 * conference bridge.
5464 */
5465 unsigned channel_count;
5466
5467 /**
5468 * Specify audio frame ptime. The value here will affect the
5469 * samples per frame of both the sound device and the conference
5470 * bridge. Specifying lower ptime will normally reduce the
5471 * latency.
5472 *
5473 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
5474 */
5475 unsigned audio_frame_ptime;
5476
5477 /**
5478 * Specify maximum number of media ports to be created in the
5479 * conference bridge. Since all media terminate in the bridge
5480 * (calls, file player, file recorder, etc), the value must be
5481 * large enough to support all of them. However, the larger
5482 * the value, the more computations are performed.
5483 *
5484 * Default value: PJSUA_MAX_CONF_PORTS
5485 */
5486 unsigned max_media_ports;
5487
5488 /**
5489 * Specify whether the media manager should manage its own
5490 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
5491 * and at least one worker thread will be created too. If no,
5492 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
5493 * and no worker thread is needed.
5494 *
5495 * Normally application would say yes here, unless it wants to
5496 * run everything from a single thread.
5497 */
5498 pj_bool_t has_ioqueue;
5499
5500 /**
5501 * Specify the number of worker threads to handle incoming RTP
5502 * packets. A value of one is recommended for most applications.
5503 */
5504 unsigned thread_cnt;
5505
5506 /**
5507 * Media quality, 0-10, according to this table:
5508 * 5-10: resampling use large filter,
5509 * 3-4: resampling use small filter,
5510 * 1-2: resampling use linear.
5511 * The media quality also sets speex codec quality/complexity to the
5512 * number.
5513 *
5514 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).
5515 */
5516 unsigned quality;
5517
5518 /**
5519 * Specify default codec ptime.
5520 *
5521 * Default: 0 (codec specific)
5522 */
5523 unsigned ptime;
5524
5525 /**
5526 * Disable VAD?
5527 *
5528 * Default: 0 (no (meaning VAD is enabled))
5529 */
5530 pj_bool_t no_vad;
5531
5532 /**
5533 * iLBC mode (20 or 30).
5534 *
5535 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
5536 */
5537 unsigned ilbc_mode;
5538
5539 /**
5540 * Percentage of RTP packet to drop in TX direction
5541 * (to simulate packet lost).
5542 *
5543 * Default: 0
5544 */
5545 unsigned tx_drop_pct;
5546
5547 /**
5548 * Percentage of RTP packet to drop in RX direction
5549 * (to simulate packet lost).
5550 *
5551 * Default: 0
5552 */
5553 unsigned rx_drop_pct;
5554
5555 /**
5556 * Echo canceller options (see #pjmedia_echo_create())
5557 *
5558 * Default: 0.
5559 */
5560 unsigned ec_options;
5561
5562 /**
5563 * Echo canceller tail length, in miliseconds.
5564 *
5565 * Default: PJSUA_DEFAULT_EC_TAIL_LEN
5566 */
5567 unsigned ec_tail_len;
5568
5569 /**
5570 * Audio capture buffer length, in milliseconds.
5571 *
5572 * Default: PJMEDIA_SND_DEFAULT_REC_LATENCY
5573 */
5574 unsigned snd_rec_latency;
5575
5576 /**
5577 * Audio playback buffer length, in milliseconds.
5578 *
5579 * Default: PJMEDIA_SND_DEFAULT_PLAY_LATENCY
5580 */
5581 unsigned snd_play_latency;
5582
5583 /**
5584 * Jitter buffer initial prefetch delay in msec. The value must be
5585 * between jb_min_pre and jb_max_pre below.
5586 *
5587 * Default: -1 (to use default stream settings, currently 150 msec)
5588 */
5589 int jb_init;
5590
5591 /**
5592 * Jitter buffer minimum prefetch delay in msec.
5593 *
5594 * Default: -1 (to use default stream settings, currently 60 msec)
5595 */
5596 int jb_min_pre;
5597
5598 /**
5599 * Jitter buffer maximum prefetch delay in msec.
5600 *
5601 * Default: -1 (to use default stream settings, currently 240 msec)
5602 */
5603 int jb_max_pre;
5604
5605 /**
5606 * Set maximum delay that can be accomodated by the jitter buffer msec.
5607 *
5608 * Default: -1 (to use default stream settings, currently 360 msec)
5609 */
5610 int jb_max;
5611
5612 /**
5613 * Enable ICE
5614 */
5615 pj_bool_t enable_ice;
5616
5617 /**
5618 * Set the maximum number of host candidates.
5619 *
5620 * Default: -1 (maximum not set)
5621 */
5622 int ice_max_host_cands;
5623
5624 /**
5625 * ICE session options.
5626 */
5627 pj_ice_sess_options ice_opt;
5628
5629 /**
5630 * Disable RTCP component.
5631 *
5632 * Default: no
5633 */
5634 pj_bool_t ice_no_rtcp;
5635
5636 /**
5637 * Send re-INVITE/UPDATE every after ICE connectivity check regardless
5638 * the default ICE transport address is changed or not. When this is set
5639 * to PJ_FALSE, re-INVITE/UPDATE will be sent only when the default ICE
5640 * transport address is changed.
5641 *
5642 * Default: yes
5643 */
5644 pj_bool_t ice_always_update;
5645
5646 /**
5647 * Enable TURN relay candidate in ICE.
5648 */
5649 pj_bool_t enable_turn;
5650
5651 /**
5652 * Specify TURN domain name or host name, in in "DOMAIN:PORT" or
5653 * "HOST:PORT" format.
5654 */
5655 pj_str_t turn_server;
5656
5657 /**
5658 * Specify the connection type to be used to the TURN server. Valid
5659 * values are PJ_TURN_TP_UDP or PJ_TURN_TP_TCP.
5660 *
5661 * Default: PJ_TURN_TP_UDP
5662 */
5663 pj_turn_tp_type turn_conn_type;
5664
5665 /**
5666 * Specify the credential to authenticate with the TURN server.
5667 */
5668 pj_stun_auth_cred turn_auth_cred;
5669
5670 /**
5671 * Specify idle time of sound device before it is automatically closed,
5672 * in seconds. Use value -1 to disable the auto-close feature of sound
5673 * device
5674 *
5675 * Default : 1
5676 */
5677 int snd_auto_close_time;
5678
5679 /**
5680 * Specify whether built-in/native preview should be used if available.
5681 * In some systems, video input devices have built-in capability to show
5682 * preview window of the device. Using this built-in preview is preferable
5683 * as it consumes less CPU power. If built-in preview is not available,
5684 * the library will perform software rendering of the input. If this
5685 * field is set to PJ_FALSE, software preview will always be used.
5686 *
5687 * Default: PJ_TRUE
5688 */
5689 pj_bool_t vid_preview_enable_native;
5690
5691 /**
5692 * Disable smart media update (ticket #1568). The smart media update
5693 * will check for any changes in the media properties after a successful
5694 * SDP negotiation and the media will only be reinitialized when any
5695 * change is found. When it is disabled, media streams will always be
5696 * reinitialized after a successful SDP negotiation.
5697 *
5698 * Note for third party media, the smart media update requires stream info
5699 * retrieval capability, see #PJSUA_THIRD_PARTY_STREAM_HAS_GET_INFO.
5700 *
5701 * Default: PJ_FALSE
5702 */
5703 pj_bool_t no_smart_media_update;
5704
5705 /**
5706 * Omit RTCP SDES and BYE in outgoing RTCP packet, this setting will be
5707 * applied for both audio and video streams. Note that, when RTCP SDES
5708 * and BYE are set to be omitted, RTCP SDES will still be sent once when
5709 * the stream starts/stops and RTCP BYE will be sent once when the stream
5710 * stops.
5711 *
5712 * Default: PJ_FALSE
5713 */
5714 pj_bool_t no_rtcp_sdes_bye;
5715};
5716
5717
5718/**
5719 * Use this function to initialize media config.
5720 *
5721 * @param cfg The media config to be initialized.
5722 */
5723PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg);
5724
5725
5726/**
5727 * This structure describes codec information, which can be retrieved by
5728 * calling #pjsua_enum_codecs().
5729 */
5730typedef struct pjsua_codec_info
5731{
5732 /**
5733 * Codec unique identification.
5734 */
5735 pj_str_t codec_id;
5736
5737 /**
5738 * Codec priority (integer 0-255).
5739 */
5740 pj_uint8_t priority;
5741
5742 /**
5743 * Codec description.
5744 */
5745 pj_str_t desc;
5746
5747 /**
5748 * Internal buffer.
5749 */
5750 char buf_[64];
5751
5752} pjsua_codec_info;
5753
5754
5755/**
5756 * This structure descibes information about a particular media port that
5757 * has been registered into the conference bridge. Application can query
5758 * this info by calling #pjsua_conf_get_port_info().
5759 */
5760typedef struct pjsua_conf_port_info
5761{
5762 /** Conference port number. */
5763 pjsua_conf_port_id slot_id;
5764
5765 /** Port name. */
5766 pj_str_t name;
5767
5768 /** Clock rate. */
5769 unsigned clock_rate;
5770
5771 /** Number of channels. */
5772 unsigned channel_count;
5773
5774 /** Samples per frame */
5775 unsigned samples_per_frame;
5776
5777 /** Bits per sample */
5778 unsigned bits_per_sample;
5779
5780 /** Number of listeners in the array. */
5781 unsigned listener_cnt;
5782
5783 /** Array of listeners (in other words, ports where this port is
5784 * transmitting to.
5785 */
5786 pjsua_conf_port_id listeners[PJSUA_MAX_CONF_PORTS];
5787
5788} pjsua_conf_port_info;
5789
5790
5791/**
5792 * This structure holds information about custom media transport to
5793 * be registered to pjsua.
5794 */
5795typedef struct pjsua_media_transport
5796{
5797 /**
5798 * Media socket information containing the address information
5799 * of the RTP and RTCP socket.
5800 */
5801 pjmedia_sock_info skinfo;
5802
5803 /**
5804 * The media transport instance.
5805 */
5806 pjmedia_transport *transport;
5807
5808} pjsua_media_transport;
5809
5810
5811/**
5812 * Get maxinum number of conference ports.
5813 *
5814 * @return Maximum number of ports in the conference bridge.
5815 */
5816PJ_DECL(unsigned) pjsua_conf_get_max_ports(void);
5817
5818
5819/**
5820 * Get current number of active ports in the bridge.
5821 *
5822 * @return The number.
5823 */
5824PJ_DECL(unsigned) pjsua_conf_get_active_ports(void);
5825
5826
5827/**
5828 * Enumerate all conference ports.
5829 *
5830 * @param id Array of conference port ID to be initialized.
5831 * @param count On input, specifies max elements in the array.
5832 * On return, it contains actual number of elements
5833 * that have been initialized.
5834 *
5835 * @return PJ_SUCCESS on success, or the appropriate error code.
5836 */
5837PJ_DECL(pj_status_t) pjsua_enum_conf_ports(pjsua_conf_port_id id[],
5838 unsigned *count);
5839
5840
5841/**
5842 * Get information about the specified conference port
5843 *
5844 * @param port_id Port identification.
5845 * @param info Pointer to store the port info.
5846 *
5847 * @return PJ_SUCCESS on success, or the appropriate error code.
5848 */
5849PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id port_id,
5850 pjsua_conf_port_info *info);
5851
5852
5853/**
5854 * Add arbitrary media port to PJSUA's conference bridge. Application
5855 * can use this function to add the media port that it creates. For
5856 * media ports that are created by PJSUA-LIB (such as calls, file player,
5857 * or file recorder), PJSUA-LIB will automatically add the port to
5858 * the bridge.
5859 *
5860 * @param pool Pool to use.
5861 * @param port Media port to be added to the bridge.
5862 * @param p_id Optional pointer to receive the conference
5863 * slot id.
5864 *
5865 * @return PJ_SUCCESS on success, or the appropriate error code.
5866 */
5867PJ_DECL(pj_status_t) pjsua_conf_add_port(pj_pool_t *pool,
5868 pjmedia_port *port,
5869 pjsua_conf_port_id *p_id);
5870
5871
5872/**
5873 * Remove arbitrary slot from the conference bridge. Application should only
5874 * call this function if it registered the port manually with previous call
5875 * to #pjsua_conf_add_port().
5876 *
5877 * @param port_id The slot id of the port to be removed.
5878 *
5879 * @return PJ_SUCCESS on success, or the appropriate error code.
5880 */
5881PJ_DECL(pj_status_t) pjsua_conf_remove_port(pjsua_conf_port_id port_id);
5882
5883
5884/**
5885 * Establish unidirectional media flow from souce to sink. One source
5886 * may transmit to multiple destinations/sink. And if multiple
5887 * sources are transmitting to the same sink, the media will be mixed
5888 * together. Source and sink may refer to the same ID, effectively
5889 * looping the media.
5890 *
5891 * If bidirectional media flow is desired, application needs to call
5892 * this function twice, with the second one having the arguments
5893 * reversed.
5894 *
5895 * @param source Port ID of the source media/transmitter.
5896 * @param sink Port ID of the destination media/received.
5897 *
5898 * @return PJ_SUCCESS on success, or the appropriate error code.
5899 */
5900PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id source,
5901 pjsua_conf_port_id sink);
5902
5903
5904/**
5905 * Disconnect media flow from the source to destination port.
5906 *
5907 * @param source Port ID of the source media/transmitter.
5908 * @param sink Port ID of the destination media/received.
5909 *
5910 * @return PJ_SUCCESS on success, or the appropriate error code.
5911 */
5912PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id source,
5913 pjsua_conf_port_id sink);
5914
5915
5916/**
5917 * Adjust the signal level to be transmitted from the bridge to the
5918 * specified port by making it louder or quieter.
5919 *
5920 * @param slot The conference bridge slot number.
5921 * @param level Signal level adjustment. Value 1.0 means no level
5922 * adjustment, while value 0 means to mute the port.
5923 *
5924 * @return PJ_SUCCESS on success, or the appropriate error code.
5925 */
5926PJ_DECL(pj_status_t) pjsua_conf_adjust_tx_level(pjsua_conf_port_id slot,
5927 float level);
5928
5929/**
5930 * Adjust the signal level to be received from the specified port (to
5931 * the bridge) by making it louder or quieter.
5932 *
5933 * @param slot The conference bridge slot number.
5934 * @param level Signal level adjustment. Value 1.0 means no level
5935 * adjustment, while value 0 means to mute the port.
5936 *
5937 * @return PJ_SUCCESS on success, or the appropriate error code.
5938 */
5939PJ_DECL(pj_status_t) pjsua_conf_adjust_rx_level(pjsua_conf_port_id slot,
5940 float level);
5941
5942/**
5943 * Get last signal level transmitted to or received from the specified port.
5944 * The signal level is an integer value in zero to 255, with zero indicates
5945 * no signal, and 255 indicates the loudest signal level.
5946 *
5947 * @param slot The conference bridge slot number.
5948 * @param tx_level Optional argument to receive the level of signal
5949 * transmitted to the specified port (i.e. the direction
5950 * is from the bridge to the port).
5951 * @param rx_level Optional argument to receive the level of signal
5952 * received from the port (i.e. the direction is from the
5953 * port to the bridge).
5954 *
5955 * @return PJ_SUCCESS on success.
5956 */
5957PJ_DECL(pj_status_t) pjsua_conf_get_signal_level(pjsua_conf_port_id slot,
5958 unsigned *tx_level,
5959 unsigned *rx_level);
5960
5961
5962/*****************************************************************************
5963 * File player and playlist.
5964 */
5965
5966/**
5967 * Create a file player, and automatically add this player to
5968 * the conference bridge.
5969 *
5970 * @param filename The filename to be played. Currently only
5971 * WAV files are supported, and the WAV file MUST be
5972 * formatted as 16bit PCM mono/single channel (any
5973 * clock rate is supported).
5974 * @param options Optional option flag. Application may specify
5975 * PJMEDIA_FILE_NO_LOOP to prevent playback loop.
5976 * @param p_id Pointer to receive player ID.
5977 *
5978 * @return PJ_SUCCESS on success, or the appropriate error code.
5979 */
5980PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename,
5981 unsigned options,
5982 pjsua_player_id *p_id);
5983
5984
5985/**
5986 * Create a file playlist media port, and automatically add the port
5987 * to the conference bridge.
5988 *
5989 * @param file_names Array of file names to be added to the play list.
5990 * Note that the files must have the same clock rate,
5991 * number of channels, and number of bits per sample.
5992 * @param file_count Number of files in the array.
5993 * @param label Optional label to be set for the media port.
5994 * @param options Optional option flag. Application may specify
5995 * PJMEDIA_FILE_NO_LOOP to prevent looping.
5996 * @param p_id Optional pointer to receive player ID.
5997 *
5998 * @return PJ_SUCCESS on success, or the appropriate error code.
5999 */
6000PJ_DECL(pj_status_t) pjsua_playlist_create(const pj_str_t file_names[],
6001 unsigned file_count,
6002 const pj_str_t *label,
6003 unsigned options,
6004 pjsua_player_id *p_id);
6005
6006/**
6007 * Get conference port ID associated with player or playlist.
6008 *
6009 * @param id The file player ID.
6010 *
6011 * @return Conference port ID associated with this player.
6012 */
6013PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
6014
6015
6016/**
6017 * Get the media port for the player or playlist.
6018 *
6019 * @param id The player ID.
6020 * @param p_port The media port associated with the player.
6021 *
6022 * @return PJ_SUCCESS on success.
6023 */
6024PJ_DECL(pj_status_t) pjsua_player_get_port(pjsua_player_id id,
6025 pjmedia_port **p_port);
6026
6027/**
6028 * Set playback position. This operation is not valid for playlist.
6029 *
6030 * @param id The file player ID.
6031 * @param samples The playback position, in samples. Application can
6032 * specify zero to re-start the playback.
6033 *
6034 * @return PJ_SUCCESS on success, or the appropriate error code.
6035 */
6036PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id,
6037 pj_uint32_t samples);
6038
6039
6040/**
6041 * Close the file of playlist, remove the player from the bridge, and free
6042 * resources associated with the file player or playlist.
6043 *
6044 * @param id The file player ID.
6045 *
6046 * @return PJ_SUCCESS on success, or the appropriate error code.
6047 */
6048PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id);
6049
6050
6051/*****************************************************************************
6052 * File recorder.
6053 */
6054
6055/**
6056 * Create a file recorder, and automatically connect this recorder to
6057 * the conference bridge. The recorder currently supports recording WAV file.
6058 * The type of the recorder to use is determined by the extension of the file
6059 * (e.g. ".wav").
6060 *
6061 * @param filename Output file name. The function will determine the
6062 * default format to be used based on the file extension.
6063 * Currently ".wav" is supported on all platforms.
6064 * @param enc_type Optionally specify the type of encoder to be used to
6065 * compress the media, if the file can support different
6066 * encodings. This value must be zero for now.
6067 * @param enc_param Optionally specify codec specific parameter to be
6068 * passed to the file writer.
6069 * For .WAV recorder, this value must be NULL.
6070 * @param max_size Maximum file size. Specify zero or -1 to remove size
6071 * limitation. This value must be zero or -1 for now.
6072 * @param options Optional options.
6073 * @param p_id Pointer to receive the recorder instance.
6074 *
6075 * @return PJ_SUCCESS on success, or the appropriate error code.
6076 */
6077PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename,
6078 unsigned enc_type,
6079 void *enc_param,
6080 pj_ssize_t max_size,
6081 unsigned options,
6082 pjsua_recorder_id *p_id);
6083
6084
6085/**
6086 * Get conference port associated with recorder.
6087 *
6088 * @param id The recorder ID.
6089 *
6090 * @return Conference port ID associated with this recorder.
6091 */
6092PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
6093
6094
6095/**
6096 * Get the media port for the recorder.
6097 *
6098 * @param id The recorder ID.
6099 * @param p_port The media port associated with the recorder.
6100 *
6101 * @return PJ_SUCCESS on success.
6102 */
6103PJ_DECL(pj_status_t) pjsua_recorder_get_port(pjsua_recorder_id id,
6104 pjmedia_port **p_port);
6105
6106
6107/**
6108 * Destroy recorder (this will complete recording).
6109 *
6110 * @param id The recorder ID.
6111 *
6112 * @return PJ_SUCCESS on success, or the appropriate error code.
6113 */
6114PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id);
6115
6116
6117/*****************************************************************************
6118 * Sound devices.
6119 */
6120
6121/**
6122 * Enum all audio devices installed in the system.
6123 *
6124 * @param info Array of info to be initialized.
6125 * @param count On input, specifies max elements in the array.
6126 * On return, it contains actual number of elements
6127 * that have been initialized.
6128 *
6129 * @return PJ_SUCCESS on success, or the appropriate error code.
6130 */
6131PJ_DECL(pj_status_t) pjsua_enum_aud_devs(pjmedia_aud_dev_info info[],
6132 unsigned *count);
6133
6134/**
6135 * Enum all sound devices installed in the system (old API).
6136 *
6137 * @param info Array of info to be initialized.
6138 * @param count On input, specifies max elements in the array.
6139 * On return, it contains actual number of elements
6140 * that have been initialized.
6141 *
6142 * @return PJ_SUCCESS on success, or the appropriate error code.
6143 */
6144PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[],
6145 unsigned *count);
6146
6147/**
6148 * Get currently active sound devices. If sound devices has not been created
6149 * (for example when pjsua_start() is not called), it is possible that
6150 * the function returns PJ_SUCCESS with -1 as device IDs.
6151 *
6152 * @param capture_dev On return it will be filled with device ID of the
6153 * capture device.
6154 * @param playback_dev On return it will be filled with device ID of the
6155 * device ID of the playback device.
6156 *
6157 * @return PJ_SUCCESS on success, or the appropriate error code.
6158 */
6159PJ_DECL(pj_status_t) pjsua_get_snd_dev(int *capture_dev,
6160 int *playback_dev);
6161
6162
6163/**
6164 * Select or change sound device. Application may call this function at
6165 * any time to replace current sound device.
6166 *
6167 * @param capture_dev Device ID of the capture device.
6168 * @param playback_dev Device ID of the playback device.
6169 *
6170 * @return PJ_SUCCESS on success, or the appropriate error code.
6171 */
6172PJ_DECL(pj_status_t) pjsua_set_snd_dev(int capture_dev,
6173 int playback_dev);
6174
6175
6176/**
6177 * Set pjsua to use null sound device. The null sound device only provides
6178 * the timing needed by the conference bridge, and will not interract with
6179 * any hardware.
6180 *
6181 * @return PJ_SUCCESS on success, or the appropriate error code.
6182 */
6183PJ_DECL(pj_status_t) pjsua_set_null_snd_dev(void);
6184
6185
6186/**
6187 * Disconnect the main conference bridge from any sound devices, and let
6188 * application connect the bridge to it's own sound device/master port.
6189 *
6190 * @return The port interface of the conference bridge,
6191 * so that application can connect this to it's own
6192 * sound device or master port.
6193 */
6194PJ_DECL(pjmedia_port*) pjsua_set_no_snd_dev(void);
6195
6196
6197/**
6198 * Change the echo cancellation settings.
6199 *
6200 * The behavior of this function depends on whether the sound device is
6201 * currently active, and if it is, whether device or software AEC is
6202 * being used.
6203 *
6204 * If the sound device is currently active, and if the device supports AEC,
6205 * this function will forward the change request to the device and it will
6206 * be up to the device on whether support the request. If software AEC is
6207 * being used (the software EC will be used if the device does not support
6208 * AEC), this function will change the software EC settings. In all cases,
6209 * the setting will be saved for future opening of the sound device.
6210 *
6211 * If the sound device is not currently active, this will only change the
6212 * default AEC settings and the setting will be applied next time the
6213 * sound device is opened.
6214 *
6215 * @param tail_ms The tail length, in miliseconds. Set to zero to
6216 * disable AEC.
6217 * @param options Options to be passed to pjmedia_echo_create().
6218 * Normally the value should be zero.
6219 *
6220 * @return PJ_SUCCESS on success.
6221 */
6222PJ_DECL(pj_status_t) pjsua_set_ec(unsigned tail_ms, unsigned options);
6223
6224
6225/**
6226 * Get current echo canceller tail length.
6227 *
6228 * @param p_tail_ms Pointer to receive the tail length, in miliseconds.
6229 * If AEC is disabled, the value will be zero.
6230 *
6231 * @return PJ_SUCCESS on success.
6232 */
6233PJ_DECL(pj_status_t) pjsua_get_ec_tail(unsigned *p_tail_ms);
6234
6235
6236/**
6237 * Check whether the sound device is currently active. The sound device
6238 * may be inactive if the application has set the auto close feature to
6239 * non-zero (the snd_auto_close_time setting in #pjsua_media_config), or
6240 * if null sound device or no sound device has been configured via the
6241 * #pjsua_set_no_snd_dev() function.
6242 */
6243PJ_DECL(pj_bool_t) pjsua_snd_is_active(void);
6244
6245
6246/**
6247 * Configure sound device setting to the sound device being used. If sound
6248 * device is currently active, the function will forward the setting to the
6249 * sound device instance to be applied immediately, if it supports it.
6250 *
6251 * The setting will be saved for future opening of the sound device, if the
6252 * "keep" argument is set to non-zero. If the sound device is currently
6253 * inactive, and the "keep" argument is false, this function will return
6254 * error.
6255 *
6256 * Note that in case the setting is kept for future use, it will be applied
6257 * to any devices, even when application has changed the sound device to be
6258 * used.
6259 *
6260 * Note also that the echo cancellation setting should be set with
6261 * #pjsua_set_ec() API instead.
6262 *
6263 * See also #pjmedia_aud_stream_set_cap() for more information about setting
6264 * an audio device capability.
6265 *
6266 * @param cap The sound device setting to change.
6267 * @param pval Pointer to value. Please see #pjmedia_aud_dev_cap
6268 * documentation about the type of value to be
6269 * supplied for each setting.
6270 * @param keep Specify whether the setting is to be kept for future
6271 * use.
6272 *
6273 * @return PJ_SUCCESS on success or the appropriate error code.
6274 */
6275PJ_DECL(pj_status_t) pjsua_snd_set_setting(pjmedia_aud_dev_cap cap,
6276 const void *pval,
6277 pj_bool_t keep);
6278
6279/**
6280 * Retrieve a sound device setting. If sound device is currently active,
6281 * the function will forward the request to the sound device. If sound device
6282 * is currently inactive, and if application had previously set the setting
6283 * and mark the setting as kept, then that setting will be returned.
6284 * Otherwise, this function will return error.
6285 *
6286 * Note that echo cancellation settings should be retrieved with
6287 * #pjsua_get_ec_tail() API instead.
6288 *
6289 * @param cap The sound device setting to retrieve.
6290 * @param pval Pointer to receive the value.
6291 * Please see #pjmedia_aud_dev_cap documentation about
6292 * the type of value to be supplied for each setting.
6293 *
6294 * @return PJ_SUCCESS on success or the appropriate error code.
6295 */
6296PJ_DECL(pj_status_t) pjsua_snd_get_setting(pjmedia_aud_dev_cap cap,
6297 void *pval);
6298
6299
6300/*****************************************************************************
6301 * Codecs.
6302 */
6303
6304/**
6305 * Enum all supported codecs in the system.
6306 *
6307 * @param id Array of ID to be initialized.
6308 * @param count On input, specifies max elements in the array.
6309 * On return, it contains actual number of elements
6310 * that have been initialized.
6311 *
6312 * @return PJ_SUCCESS on success, or the appropriate error code.
6313 */
6314PJ_DECL(pj_status_t) pjsua_enum_codecs( pjsua_codec_info id[],
6315 unsigned *count );
6316
6317
6318/**
6319 * Change codec priority.
6320 *
6321 * @param codec_id Codec ID, which is a string that uniquely identify
6322 * the codec (such as "speex/8000"). Please see pjsua
6323 * manual or pjmedia codec reference for details.
6324 * @param priority Codec priority, 0-255, where zero means to disable
6325 * the codec.
6326 *
6327 * @return PJ_SUCCESS on success, or the appropriate error code.
6328 */
6329PJ_DECL(pj_status_t) pjsua_codec_set_priority( const pj_str_t *codec_id,
6330 pj_uint8_t priority );
6331
6332
6333/**
6334 * Get codec parameters.
6335 *
6336 * @param codec_id Codec ID.
6337 * @param param Structure to receive codec parameters.
6338 *
6339 * @return PJ_SUCCESS on success, or the appropriate error code.
6340 */
6341PJ_DECL(pj_status_t) pjsua_codec_get_param( const pj_str_t *codec_id,
6342 pjmedia_codec_param *param );
6343
6344
6345/**
6346 * Set codec parameters.
6347 *
6348 * @param codec_id Codec ID.
6349 * @param param Codec parameter to set. Set to NULL to reset
6350 * codec parameter to library default settings.
6351 *
6352 * @return PJ_SUCCESS on success, or the appropriate error code.
6353 */
6354PJ_DECL(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id,
6355 const pjmedia_codec_param *param);
6356
6357
6358#if DISABLED_FOR_TICKET_1185
6359/**
6360 * Create UDP media transports for all the calls. This function creates
6361 * one UDP media transport for each call.
6362 *
6363 * @param cfg Media transport configuration. The "port" field in the
6364 * configuration is used as the start port to bind the
6365 * sockets.
6366 *
6367 * @return PJ_SUCCESS on success, or the appropriate error code.
6368 */
6369PJ_DECL(pj_status_t)
6370pjsua_media_transports_create(const pjsua_transport_config *cfg);
6371
6372
6373/**
6374 * Register custom media transports to be used by calls. There must
6375 * enough media transports for all calls.
6376 *
6377 * @param tp The media transport array.
6378 * @param count Number of elements in the array. This number MUST
6379 * match the number of maximum calls configured when
6380 * pjsua is created.
6381 * @param auto_delete Flag to indicate whether the transports should be
6382 * destroyed when pjsua is shutdown.
6383 *
6384 * @return PJ_SUCCESS on success, or the appropriate error code.
6385 */
6386PJ_DECL(pj_status_t)
6387pjsua_media_transports_attach( pjsua_media_transport tp[],
6388 unsigned count,
6389 pj_bool_t auto_delete);
6390#endif
6391
6392
6393/* end of MEDIA API */
6394/**
6395 * @}
6396 */
6397
6398
6399/*****************************************************************************
6400 * VIDEO API
6401 */
6402
6403
6404/**
6405 * @defgroup PJSUA_LIB_VIDEO PJSUA-API Video
6406 * @ingroup PJSUA_LIB
6407 * @brief Video support
6408 * @{
6409 */
6410
6411/*
6412 * Video devices API
6413 */
6414
6415/**
6416 * Get the number of video devices installed in the system.
6417 *
6418 * @return The number of devices.
6419 */
6420PJ_DECL(unsigned) pjsua_vid_dev_count(void);
6421
6422/**
6423 * Retrieve the video device info for the specified device index.
6424 *
6425 * @param id The device index.
6426 * @param vdi Device info to be initialized.
6427 *
6428 * @return PJ_SUCCESS on success, or the appropriate error code.
6429 */
6430PJ_DECL(pj_status_t) pjsua_vid_dev_get_info(pjmedia_vid_dev_index id,
6431 pjmedia_vid_dev_info *vdi);
6432
6433/**
6434 * Enum all video devices installed in the system.
6435 *
6436 * @param info Array of info to be initialized.
6437 * @param count On input, specifies max elements in the array.
6438 * On return, it contains actual number of elements
6439 * that have been initialized.
6440 *
6441 * @return PJ_SUCCESS on success, or the appropriate error code.
6442 */
6443PJ_DECL(pj_status_t) pjsua_vid_enum_devs(pjmedia_vid_dev_info info[],
6444 unsigned *count);
6445
6446
6447/*
6448 * Video preview API
6449 */
6450
6451/**
6452 * Parameters for starting video preview with pjsua_vid_preview_start().
6453 * Application should initialize this structure with
6454 * pjsua_vid_preview_param_default().
6455 */
6456typedef struct pjsua_vid_preview_param
6457{
6458 /**
6459 * Device ID for the video renderer to be used for rendering the
6460 * capture stream for preview. This parameter is ignored if native
6461 * preview is being used.
6462 *
6463 * Default: PJMEDIA_VID_DEFAULT_RENDER_DEV
6464 */
6465 pjmedia_vid_dev_index rend_id;
6466
6467 /**
6468 * Show window initially.
6469 *
6470 * Default: PJ_TRUE.
6471 */
6472 pj_bool_t show;
6473
6474 /**
6475 * Window flags. The value is a bitmask combination of
6476 * #pjmedia_vid_dev_wnd_flag.
6477 *
6478 * Default: 0.
6479 */
6480 unsigned wnd_flags;
6481
6482} pjsua_vid_preview_param;
6483
6484
6485/**
6486 * Initialize pjsua_vid_preview_param
6487 *
6488 * @param p The parameter to be initialized.
6489 */
6490PJ_DECL(void) pjsua_vid_preview_param_default(pjsua_vid_preview_param *p);
6491
6492/**
6493 * Determine if the specified video input device has built-in native
6494 * preview capability. This is a convenience function that is equal to
6495 * querying device's capability for PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW
6496 * capability.
6497 *
6498 * @param id The capture device ID.
6499 *
6500 * @return PJ_TRUE if it has.
6501 */
6502PJ_DECL(pj_bool_t) pjsua_vid_preview_has_native(pjmedia_vid_dev_index id);
6503
6504/**
6505 * Start video preview window for the specified capture device.
6506 *
6507 * @param id The capture device ID where its preview will be
6508 * started.
6509 * @param p Optional video preview parameters. Specify NULL
6510 * to use default values.
6511 *
6512 * @return PJ_SUCCESS on success, or the appropriate error code.
6513 */
6514PJ_DECL(pj_status_t) pjsua_vid_preview_start(pjmedia_vid_dev_index id,
6515 const pjsua_vid_preview_param *p);
6516
6517/**
6518 * Get the preview window handle associated with the capture device, if any.
6519 *
6520 * @param id The capture device ID.
6521 *
6522 * @return The window ID of the preview window for the
6523 * specified capture device ID, or PJSUA_INVALID_ID if
6524 * preview has not been started for the device.
6525 */
6526PJ_DECL(pjsua_vid_win_id) pjsua_vid_preview_get_win(pjmedia_vid_dev_index id);
6527
6528/**
6529 * Stop video preview.
6530 *
6531 * @param id The capture device ID.
6532 *
6533 * @return PJ_SUCCESS on success, or the appropriate error code.
6534 */
6535PJ_DECL(pj_status_t) pjsua_vid_preview_stop(pjmedia_vid_dev_index id);
6536
6537
6538/*
6539 * Video window manipulation API.
6540 */
6541
6542/**
6543 * This structure describes video window info.
6544 */
6545typedef struct pjsua_vid_win_info
6546{
6547 /**
6548 * Flag to indicate whether this window is a native window,
6549 * such as created by built-in preview device. If this field is
6550 * PJ_TRUE, only the native window handle field of this
6551 * structure is valid.
6552 */
6553 pj_bool_t is_native;
6554
6555 /**
6556 * Native window handle.
6557 */
6558 pjmedia_vid_dev_hwnd hwnd;
6559
6560 /**
6561 * Renderer device ID.
6562 */
6563 pjmedia_vid_dev_index rdr_dev;
6564
6565 /**
6566 * Window show status. The window is hidden if false.
6567 */
6568 pj_bool_t show;
6569
6570 /**
6571 * Window position.
6572 */
6573 pjmedia_coord pos;
6574
6575 /**
6576 * Window size.
6577 */
6578 pjmedia_rect_size size;
6579
6580} pjsua_vid_win_info;
6581
6582
6583/**
6584 * Enumerates all video windows.
6585 *
6586 * @param id Array of window ID to be initialized.
6587 * @param count On input, specifies max elements in the array.
6588 * On return, it contains actual number of elements
6589 * that have been initialized.
6590 *
6591 * @return PJ_SUCCESS on success, or the appropriate error code.
6592 */
6593PJ_DECL(pj_status_t) pjsua_vid_enum_wins(pjsua_vid_win_id wids[],
6594 unsigned *count);
6595
6596
6597/**
6598 * Get window info.
6599 *
6600 * @param wid The video window ID.
6601 * @param wi The video window info to be initialized.
6602 *
6603 * @return PJ_SUCCESS on success, or the appropriate error code.
6604 */
6605PJ_DECL(pj_status_t) pjsua_vid_win_get_info(pjsua_vid_win_id wid,
6606 pjsua_vid_win_info *wi);
6607
6608/**
6609 * Show or hide window. This operation is not valid for native windows
6610 * (pjsua_vid_win_info.is_native=PJ_TRUE), on which native windowing API
6611 * must be used instead.
6612 *
6613 * @param wid The video window ID.
6614 * @param show Set to PJ_TRUE to show the window, PJ_FALSE to
6615 * hide the window.
6616 *
6617 * @return PJ_SUCCESS on success, or the appropriate error code.
6618 */
6619PJ_DECL(pj_status_t) pjsua_vid_win_set_show(pjsua_vid_win_id wid,
6620 pj_bool_t show);
6621
6622/**
6623 * Set video window position. This operation is not valid for native windows
6624 * (pjsua_vid_win_info.is_native=PJ_TRUE), on which native windowing API
6625 * must be used instead.
6626 *
6627 * @param wid The video window ID.
6628 * @param pos The window position.
6629 *
6630 * @return PJ_SUCCESS on success, or the appropriate error code.
6631 */
6632PJ_DECL(pj_status_t) pjsua_vid_win_set_pos(pjsua_vid_win_id wid,
6633 const pjmedia_coord *pos);
6634
6635/**
6636 * Resize window. This operation is not valid for native windows
6637 * (pjsua_vid_win_info.is_native=PJ_TRUE), on which native windowing API
6638 * must be used instead.
6639 *
6640 * @param wid The video window ID.
6641 * @param size The new window size.
6642 *
6643 * @return PJ_SUCCESS on success, or the appropriate error code.
6644 */
6645PJ_DECL(pj_status_t) pjsua_vid_win_set_size(pjsua_vid_win_id wid,
6646 const pjmedia_rect_size *size);
6647
6648/**
6649 * Rotate the video window. This function will change the video orientation
6650 * and also possibly the video window size (width and height get swapped).
6651 * This operation is not valid for native windows (pjsua_vid_win_info.is_native
6652 * =PJ_TRUE), on which native windowing API must be used instead.
6653 *
6654 * @param wid The video window ID.
6655 * @param angle The rotation angle in degrees, must be multiple of 90.
6656 * Specify positive value for clockwise rotation or
6657 * negative value for counter-clockwise rotation.
6658 *
6659 * @return PJ_SUCCESS on success, or the appropriate error code.
6660 */
6661PJ_DECL(pj_status_t) pjsua_vid_win_rotate(pjsua_vid_win_id wid,
6662 int angle);
6663
6664
6665/*
6666 * Video codecs API
6667 */
6668
6669/**
6670 * Enum all supported video codecs in the system.
6671 *
6672 * @param id Array of ID to be initialized.
6673 * @param count On input, specifies max elements in the array.
6674 * On return, it contains actual number of elements
6675 * that have been initialized.
6676 *
6677 * @return PJ_SUCCESS on success, or the appropriate error code.
6678 */
6679PJ_DECL(pj_status_t) pjsua_vid_enum_codecs( pjsua_codec_info id[],
6680 unsigned *count );
6681
6682
6683/**
6684 * Change video codec priority.
6685 *
6686 * @param codec_id Codec ID, which is a string that uniquely identify
6687 * the codec (such as "H263/90000"). Please see pjsua
6688 * manual or pjmedia codec reference for details.
6689 * @param priority Codec priority, 0-255, where zero means to disable
6690 * the codec.
6691 *
6692 * @return PJ_SUCCESS on success, or the appropriate error code.
6693 */
6694PJ_DECL(pj_status_t) pjsua_vid_codec_set_priority( const pj_str_t *codec_id,
6695 pj_uint8_t priority );
6696
6697
6698/**
6699 * Get video codec parameters.
6700 *
6701 * @param codec_id Codec ID.
6702 * @param param Structure to receive video codec parameters.
6703 *
6704 * @return PJ_SUCCESS on success, or the appropriate error code.
6705 */
6706PJ_DECL(pj_status_t) pjsua_vid_codec_get_param(
6707 const pj_str_t *codec_id,
6708 pjmedia_vid_codec_param *param);
6709
6710
6711/**
6712 * Set video codec parameters.
6713 *
6714 * @param codec_id Codec ID.
6715 * @param param Codec parameter to set. Set to NULL to reset
6716 * codec parameter to library default settings.
6717 *
6718 * @return PJ_SUCCESS on success, or the appropriate error code.
6719 */
6720PJ_DECL(pj_status_t) pjsua_vid_codec_set_param(
6721 const pj_str_t *codec_id,
6722 const pjmedia_vid_codec_param *param);
6723
6724
6725
6726/* end of VIDEO API */
6727/**
6728 * @}
6729 */
6730
6731
6732/**
6733 * @}
6734 */
6735
6736PJ_END_DECL
6737
6738
6739#endif /* __PJSUA_H__ */